Skip to content

Fix the miri submodule #51225

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/librustc_mir/interpret/eval_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M
let ty = self.place_ty(place);
let place = self.eval_place(place)?;
let discr_val = self.read_discriminant_value(place, ty)?;
let defined = self.layout_of(ty).unwrap().size.bits() as u8;
let defined = self.layout_of(dest_ty).unwrap().size.bits() as u8;
self.write_scalar(dest, Scalar::Bits {
bits: discr_val,
defined,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/interpret/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
}

// Forget all the relocations.
alloc.relocations.remove_range(first ..= last);
alloc.relocations.remove_range(first..last);

Ok(())
}
Expand Down
41 changes: 28 additions & 13 deletions src/librustc_mir/interpret/terminator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,15 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
} => {
let discr_val = self.eval_operand(discr)?;
let discr_prim = self.value_to_scalar(discr_val)?;
let discr_layout = self.layout_of(discr_val.ty).unwrap();
trace!("SwitchInt({:?}, {:#?})", discr_prim, discr_layout);
let discr_prim = discr_prim.to_bits(discr_layout.size)?;

// Branch to the `otherwise` case by default, if no match is found.
let mut target_block = targets[targets.len() - 1];

for (index, &const_int) in values.iter().enumerate() {
if discr_prim.to_bits(self.layout_of(discr_val.ty).unwrap().size)? == const_int {
if discr_prim == const_int {
target_block = targets[index];
break;
}
Expand Down Expand Up @@ -288,10 +291,10 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
// and need to pack arguments
Abi::Rust => {
trace!(
"arg_locals: {:?}",
"arg_locals: {:#?}",
self.frame().mir.args_iter().collect::<Vec<_>>()
);
trace!("args: {:?}", args);
trace!("args: {:#?}", args);
let local = arg_locals.nth(1).unwrap();
for (i, &valty) in args.into_iter().enumerate() {
let dest = self.eval_place(&mir::Place::Local(local).field(
Expand All @@ -318,10 +321,10 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
let mut arg_locals = self.frame().mir.args_iter();
trace!("ABI: {:?}", sig.abi);
trace!(
"arg_locals: {:?}",
"arg_locals: {:#?}",
self.frame().mir.args_iter().collect::<Vec<_>>()
);
trace!("args: {:?}", args);
trace!("args: {:#?}", args);
match sig.abi {
Abi::RustCall => {
assert_eq!(args.len(), 2);
Expand Down Expand Up @@ -373,14 +376,26 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
}
break;
}
let dest = self.eval_place(&mir::Place::Local(
arg_locals.next().unwrap(),
))?;
let valty = ValTy {
value: other,
ty: layout.ty,
};
self.write_value(valty, dest)?;
{
let mut write_next = |value| {
let dest = self.eval_place(&mir::Place::Local(
arg_locals.next().unwrap(),
))?;
let valty = ValTy {
value: Value::Scalar(value),
ty: layout.ty,
};
self.write_value(valty, dest)
};
match other {
Value::Scalar(value) | Value::ScalarPair(value, _) => write_next(value)?,
_ => unreachable!(),
}
if let Value::ScalarPair(_, value) = other {
write_next(value)?;
}
}
assert!(arg_locals.next().is_none());
}
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/tools/miri
Submodule miri updated from 6a4c62 to 066a28