Skip to content

Rustup to rustc 1.28.0-nightly (952f344cd 2018-05-18) #378

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

Closed
wants to merge 7 commits into from
Closed
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 .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ script:
- |
# Test plain miri
cargo build --release --all-features &&
cargo test --release --all-features --all &&
RUST_BACKTRACE=1 cargo test --release --all-features --all &&
cargo install --all-features --force
- |
# Test cargo miri
Expand Down
9 changes: 3 additions & 6 deletions benches/helpers/miri_helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,13 @@ impl<'a> CompilerCalls<'a> for MiriCompilerCalls<'a> {
state.session.abort_if_errors();

let tcx = state.tcx.unwrap();
let (entry_node_id, _) = state.session.entry_fn.borrow().expect(
let (entry_node_id, _, _) = state.session.entry_fn.borrow().expect(
"no main or start function found",
);
let entry_def_id = tcx.map.local_def_id(entry_node_id);
let entry_def_id = tcx.hir.local_def_id(entry_node_id);

let memory_size = 100 * 1024 * 1024; // 100MB
let step_limit = 1000_000;
let stack_limit = 100;
bencher.borrow_mut().iter(|| {
eval_main(tcx, entry_def_id, memory_size, step_limit, stack_limit);
eval_main(tcx, entry_def_id, None);
});

state.session.abort_if_errors();
Expand Down
8 changes: 4 additions & 4 deletions src/bin/miri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ extern crate miri;
extern crate rustc;
extern crate rustc_driver;
extern crate rustc_errors;
extern crate rustc_trans_utils;
extern crate rustc_codegen_utils;
extern crate env_logger;
extern crate log_settings;
extern crate syntax;
Expand All @@ -18,7 +18,7 @@ use rustc_driver::driver::{CompileState, CompileController};
use rustc::session::config::{self, Input, ErrorOutputType};
use rustc::hir::{self, itemlikevisit};
use rustc::ty::TyCtxt;
use rustc_trans_utils::trans_crate::TransCrate;
use rustc_codegen_utils::codegen_backend::CodegenBackend;
use syntax::ast;
use std::path::PathBuf;

Expand Down Expand Up @@ -67,15 +67,15 @@ impl<'a> CompilerCalls<'a> for MiriCompilerCalls {
}
fn late_callback(
&mut self,
trans: &TransCrate,
codegen_backend: &CodegenBackend,
matches: &getopts::Matches,
sess: &Session,
cstore: &CrateStore,
input: &Input,
odir: &Option<PathBuf>,
ofile: &Option<PathBuf>,
) -> Compilation {
self.default.late_callback(trans, matches, sess, cstore, input, odir, ofile)
self.default.late_callback(codegen_backend, matches, sess, cstore, input, odir, ofile)
}
fn build_controller(
&mut self,
Expand Down
144 changes: 73 additions & 71 deletions src/fn_call.rs

Large diffs are not rendered by default.

34 changes: 17 additions & 17 deletions src/helpers.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
use mir;
use rustc::ty::Ty;
use rustc::ty::layout::LayoutOf;
use rustc::ty::layout::{LayoutOf, Size};

use super::{Pointer, EvalResult, PrimVal, EvalContext, ValTy};
use super::{Scalar, ScalarExt, EvalResult, EvalContext, ValTy};
use rustc_mir::interpret::sign_extend;

pub trait EvalContextExt<'tcx> {
fn wrapping_pointer_offset(
&self,
ptr: Pointer,
ptr: Scalar,
pointee_ty: Ty<'tcx>,
offset: i64,
) -> EvalResult<'tcx, Pointer>;
) -> EvalResult<'tcx, Scalar>;

fn pointer_offset(
&self,
ptr: Pointer,
ptr: Scalar,
pointee_ty: Ty<'tcx>,
offset: i64,
) -> EvalResult<'tcx, Pointer>;
) -> EvalResult<'tcx, Scalar>;

fn value_to_isize(
&self,
Expand All @@ -44,22 +44,22 @@ pub trait EvalContextExt<'tcx> {
impl<'a, 'mir, 'tcx> EvalContextExt<'tcx> for EvalContext<'a, 'mir, 'tcx, super::Evaluator<'tcx>> {
fn wrapping_pointer_offset(
&self,
ptr: Pointer,
ptr: Scalar,
pointee_ty: Ty<'tcx>,
offset: i64,
) -> EvalResult<'tcx, Pointer> {
) -> EvalResult<'tcx, Scalar> {
// FIXME: assuming here that type size is < i64::max_value()
let pointee_size = self.layout_of(pointee_ty)?.size.bytes() as i64;
let offset = offset.overflowing_mul(pointee_size).0;
ptr.wrapping_signed_offset(offset, self)
ptr.ptr_wrapping_signed_offset(offset, self)
}

fn pointer_offset(
&self,
ptr: Pointer,
ptr: Scalar,
pointee_ty: Ty<'tcx>,
offset: i64,
) -> EvalResult<'tcx, Pointer> {
) -> EvalResult<'tcx, Scalar> {
// This function raises an error if the offset moves the pointer outside of its allocation. We consider
// ZSTs their own huge allocation that doesn't overlap with anything (and nothing moves in there because the size is 0).
// We also consider the NULL pointer its own separate allocation, and all the remaining integers pointers their own
Expand All @@ -76,9 +76,9 @@ impl<'a, 'mir, 'tcx> EvalContextExt<'tcx> for EvalContext<'a, 'mir, 'tcx, super:
// FIXME: assuming here that type size is < i64::max_value()
let pointee_size = self.layout_of(pointee_ty)?.size.bytes() as i64;
return if let Some(offset) = offset.checked_mul(pointee_size) {
let ptr = ptr.signed_offset(offset, self)?;
let ptr = ptr.ptr_signed_offset(offset, self)?;
// Do not do bounds-checking for integers; they can never alias a normal pointer anyway.
if let PrimVal::Ptr(ptr) = ptr.into_inner_primval() {
if let Scalar::Ptr(ptr) = ptr {
self.memory.check_bounds(ptr, false)?;
} else if ptr.is_null()? {
// We moved *to* a NULL pointer. That seems wrong, LLVM considers the NULL pointer its own small allocation. Reject this, for now.
Expand All @@ -95,7 +95,7 @@ impl<'a, 'mir, 'tcx> EvalContextExt<'tcx> for EvalContext<'a, 'mir, 'tcx, super:
value: ValTy<'tcx>,
) -> EvalResult<'tcx, i64> {
assert_eq!(value.ty, self.tcx.types.isize);
let raw = self.value_to_primval(value)?.to_bytes()?;
let raw = self.value_to_scalar(value)?.to_bits(self.memory.pointer_size())?;
let raw = sign_extend(self.tcx.tcx, raw, self.tcx.types.isize)?;
Ok(raw as i64)
}
Expand All @@ -105,15 +105,15 @@ impl<'a, 'mir, 'tcx> EvalContextExt<'tcx> for EvalContext<'a, 'mir, 'tcx, super:
value: ValTy<'tcx>,
) -> EvalResult<'tcx, u64> {
assert_eq!(value.ty, self.tcx.types.usize);
self.value_to_primval(value)?.to_bytes().map(|v| v as u64)
self.value_to_scalar(value)?.to_bits(self.memory.pointer_size()).map(|v| v as u64)
}

fn value_to_i32(
&self,
value: ValTy<'tcx>,
) -> EvalResult<'tcx, i32> {
assert_eq!(value.ty, self.tcx.types.i32);
let raw = self.value_to_primval(value)?.to_bytes()?;
let raw = self.value_to_scalar(value)?.to_bits(Size::from_bits(32))?;
let raw = sign_extend(self.tcx.tcx, raw, self.tcx.types.i32)?;
Ok(raw as i32)
}
Expand All @@ -123,6 +123,6 @@ impl<'a, 'mir, 'tcx> EvalContextExt<'tcx> for EvalContext<'a, 'mir, 'tcx, super:
value: ValTy<'tcx>,
) -> EvalResult<'tcx, u8> {
assert_eq!(value.ty, self.tcx.types.u8);
self.value_to_primval(value)?.to_bytes().map(|v| v as u8)
self.value_to_scalar(value)?.to_bits(Size::from_bits(8)).map(|v| v as u8)
}
}
Loading