Rustup to rustc 1.40.0-nightly (9e346646e 2019-11-08)

This commit is contained in:
bjorn3 2019-11-09 11:14:18 +01:00
parent 74ea53f1fb
commit 5407b51aa7
6 changed files with 43 additions and 9 deletions

View File

@ -71,6 +71,8 @@ fn main() {
let _a = 1u32 << 2u8;
println!("{:?}", unsafe { std::intrinsics::caller_location() });
unsafe {
test_simd();
}

View File

@ -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) => {

View File

@ -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.");

View File

@ -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)
}
}

View File

@ -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<impl Backend>, 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)
}

View File

@ -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, <T> (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) {