align_offset intrinsic is now a lang item

This commit is contained in:
Oliver Schneider 2018-05-30 17:43:27 +02:00
parent e4f075459c
commit ea2c8bfb04
2 changed files with 12 additions and 8 deletions

View file

@ -135,6 +135,18 @@ impl<'a, 'mir, 'tcx: 'mir + 'a> EvalContextExt<'tcx> for EvalContext<'a, 'mir, '
_ => {}
}
if self.tcx.lang_items().align_offset_fn() == Some(instance.def.def_id()) {
// FIXME: return a real value in case the target allocation has an
// alignment bigger than the one requested
let n = u128::max_value();
let amt = 128 - self.memory.pointer_size().bytes() * 8;
let (dest, return_to_block) = destination.unwrap();
let ty = self.tcx.types.usize;
self.write_scalar(dest, Scalar::from_u128((n << amt) >> amt), ty)?;
self.goto_block(return_to_block);
return Ok(true);
}
let mir = match self.load_mir(instance.def) {
Ok(mir) => mir,
Err(EvalError { kind: EvalErrorKind::NoMirFor(path), .. }) => {

View file

@ -33,14 +33,6 @@ impl<'a, 'mir, 'tcx> EvalContextExt<'tcx> for EvalContext<'a, 'mir, 'tcx, super:
let intrinsic_name = &self.tcx.item_name(instance.def_id()).as_str()[..];
match intrinsic_name {
"align_offset" => {
// FIXME: return a real value in case the target allocation has an
// alignment bigger than the one requested
let n = u128::max_value();
let amt = 128 - self.memory.pointer_size().bytes() * 8;
self.write_scalar(dest, Scalar::from_u128((n << amt) >> amt), dest_layout.ty)?;
},
"add_with_overflow" => {
self.intrinsic_with_overflow(
mir::BinOp::Add,