Rustup to rustc 1.19.0-nightly (2d4ed8e0c 2017-05-03)
This commit is contained in:
@@ -4,7 +4,7 @@ extern crate rustc;
|
||||
extern crate rustc_driver;
|
||||
extern crate test;
|
||||
|
||||
use self::miri::{eval_main, run_mir_passes};
|
||||
use self::miri::eval_main;
|
||||
use self::rustc::session::Session;
|
||||
use self::rustc_driver::{driver, CompilerCalls, Compilation};
|
||||
use std::cell::RefCell;
|
||||
@@ -55,7 +55,6 @@ impl<'a> CompilerCalls<'a> for MiriCompilerCalls<'a> {
|
||||
.expect("no main or start function found");
|
||||
let entry_def_id = tcx.map.local_def_id(entry_node_id);
|
||||
|
||||
run_mir_passes(tcx);
|
||||
let memory_size = 100*1024*1024; // 100MB
|
||||
let step_limit = 1000_000;
|
||||
let stack_limit = 100;
|
||||
|
||||
@@ -74,7 +74,6 @@ fn after_analysis<'a, 'tcx>(state: &mut CompileState<'a, 'tcx>) {
|
||||
state.session.abort_if_errors();
|
||||
|
||||
let tcx = state.tcx.unwrap();
|
||||
miri::run_mir_passes(tcx);
|
||||
let limits = resource_limits_from_attributes(state);
|
||||
|
||||
if std::env::args().any(|arg| arg == "--test") {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use std::cell::Ref;
|
||||
use std::collections::HashMap;
|
||||
use std::fmt::Write;
|
||||
|
||||
@@ -24,8 +23,6 @@ use memory::{Memory, Pointer};
|
||||
use operator;
|
||||
use value::{PrimVal, PrimValKind, Value};
|
||||
|
||||
pub type MirRef<'tcx> = Ref<'tcx, mir::Mir<'tcx>>;
|
||||
|
||||
pub struct EvalContext<'a, 'tcx: 'a> {
|
||||
/// The results of the type checker, from rustc.
|
||||
pub(crate) tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
@@ -48,7 +45,7 @@ pub struct EvalContext<'a, 'tcx: 'a> {
|
||||
pub(crate) steps_remaining: u64,
|
||||
|
||||
/// Drop glue for arrays and slices
|
||||
pub(crate) seq_drop_glue: MirRef<'tcx>,
|
||||
pub(crate) seq_drop_glue: &'tcx mir::Mir<'tcx>,
|
||||
}
|
||||
|
||||
/// A stack frame.
|
||||
@@ -58,7 +55,7 @@ pub struct Frame<'tcx> {
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/// The MIR for the function called on this frame.
|
||||
pub mir: MirRef<'tcx>,
|
||||
pub mir: &'tcx mir::Mir<'tcx>,
|
||||
|
||||
/// The def_id and substs of the current function
|
||||
pub instance: ty::Instance<'tcx>,
|
||||
@@ -302,8 +299,6 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
|
||||
DUMMY_SP,
|
||||
);
|
||||
let seq_drop_glue = tcx.alloc_mir(seq_drop_glue);
|
||||
// Perma-borrow MIR from shims to prevent mutation.
|
||||
::std::mem::forget(seq_drop_glue.borrow());
|
||||
EvalContext {
|
||||
tcx,
|
||||
memory: Memory::new(&tcx.data_layout, limits.memory_size),
|
||||
@@ -311,7 +306,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
|
||||
stack: Vec::new(),
|
||||
stack_limit: limits.stack_limit,
|
||||
steps_remaining: limits.step_limit,
|
||||
seq_drop_glue: seq_drop_glue.borrow(),
|
||||
seq_drop_glue: seq_drop_glue,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -385,10 +380,10 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
|
||||
ty.is_sized(self.tcx, &self.tcx.empty_parameter_environment(), DUMMY_SP)
|
||||
}
|
||||
|
||||
pub fn load_mir(&self, instance: ty::InstanceDef<'tcx>) -> EvalResult<'tcx, MirRef<'tcx>> {
|
||||
pub fn load_mir(&self, instance: ty::InstanceDef<'tcx>) -> EvalResult<'tcx, &'tcx mir::Mir<'tcx>> {
|
||||
trace!("load mir {:?}", instance);
|
||||
match instance {
|
||||
ty::InstanceDef::Item(def_id) => self.tcx.maybe_item_mir(def_id).ok_or_else(|| EvalError::NoMirFor(self.tcx.item_path_str(def_id))),
|
||||
ty::InstanceDef::Item(def_id) => self.tcx.maybe_optimized_mir(def_id).ok_or_else(|| EvalError::NoMirFor(self.tcx.item_path_str(def_id))),
|
||||
_ => Ok(self.tcx.instance_mir(instance)),
|
||||
}
|
||||
}
|
||||
@@ -450,7 +445,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
|
||||
&mut self,
|
||||
instance: ty::Instance<'tcx>,
|
||||
span: codemap::Span,
|
||||
mir: MirRef<'tcx>,
|
||||
mir: &'tcx mir::Mir<'tcx>,
|
||||
return_lvalue: Lvalue<'tcx>,
|
||||
return_to_block: StackPopCleanup,
|
||||
) -> EvalResult<'tcx> {
|
||||
@@ -1445,8 +1440,8 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
|
||||
self.stack.last_mut().expect("no call frames exist")
|
||||
}
|
||||
|
||||
pub(super) fn mir(&self) -> MirRef<'tcx> {
|
||||
Ref::clone(&self.frame().mir)
|
||||
pub(super) fn mir(&self) -> &'tcx mir::Mir<'tcx> {
|
||||
self.frame().mir
|
||||
}
|
||||
|
||||
pub(super) fn substs(&self) -> &'tcx Substs<'tcx> {
|
||||
@@ -1734,32 +1729,6 @@ fn report(tcx: TyCtxt, ecx: &EvalContext, e: EvalError) {
|
||||
err.emit();
|
||||
}
|
||||
|
||||
pub fn run_mir_passes<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
|
||||
let mut passes = ::rustc::mir::transform::Passes::new();
|
||||
passes.push_hook(Box::new(::rustc_mir::transform::dump_mir::DumpMir));
|
||||
passes.push_pass(Box::new(::rustc_mir::transform::no_landing_pads::NoLandingPads));
|
||||
passes.push_pass(Box::new(::rustc_mir::transform::simplify::SimplifyCfg::new("no-landing-pads")));
|
||||
|
||||
// From here on out, regions are gone.
|
||||
passes.push_pass(Box::new(::rustc_mir::transform::erase_regions::EraseRegions));
|
||||
|
||||
passes.push_pass(Box::new(::rustc_mir::transform::add_call_guards::AddCallGuards));
|
||||
passes.push_pass(Box::new(::rustc_borrowck::ElaborateDrops));
|
||||
passes.push_pass(Box::new(::rustc_mir::transform::no_landing_pads::NoLandingPads));
|
||||
passes.push_pass(Box::new(::rustc_mir::transform::simplify::SimplifyCfg::new("elaborate-drops")));
|
||||
|
||||
// No lifetime analysis based on borrowing can be done from here on out.
|
||||
passes.push_pass(Box::new(::rustc_mir::transform::instcombine::InstCombine::new()));
|
||||
passes.push_pass(Box::new(::rustc_mir::transform::deaggregator::Deaggregator));
|
||||
passes.push_pass(Box::new(::rustc_mir::transform::copy_prop::CopyPropagation));
|
||||
|
||||
passes.push_pass(Box::new(::rustc_mir::transform::simplify::SimplifyLocals));
|
||||
passes.push_pass(Box::new(::rustc_mir::transform::add_call_guards::AddCallGuards));
|
||||
passes.push_pass(Box::new(::rustc_mir::transform::dump_mir::Marker("PreMiri")));
|
||||
|
||||
passes.run_passes(tcx);
|
||||
}
|
||||
|
||||
// TODO(solson): Upstream these methods into rustc::ty::layout.
|
||||
|
||||
pub(super) trait IntegerExt {
|
||||
|
||||
@@ -40,7 +40,6 @@ pub use eval_context::{
|
||||
ResourceLimits,
|
||||
StackPopCleanup,
|
||||
eval_main,
|
||||
run_mir_passes,
|
||||
};
|
||||
|
||||
pub use lvalue::{
|
||||
|
||||
13
src/step.rs
13
src/step.rs
@@ -2,8 +2,6 @@
|
||||
//!
|
||||
//! The main entry point is the `step` method.
|
||||
|
||||
use std::cell::Ref;
|
||||
|
||||
use rustc::hir::def_id::DefId;
|
||||
use rustc::hir;
|
||||
use rustc::mir::visit::{Visitor, LvalueContext};
|
||||
@@ -12,7 +10,7 @@ use rustc::ty::layout::Layout;
|
||||
use rustc::ty::{subst, self};
|
||||
|
||||
use error::{EvalResult, EvalError};
|
||||
use eval_context::{EvalContext, StackPopCleanup, MirRef};
|
||||
use eval_context::{EvalContext, StackPopCleanup};
|
||||
use lvalue::{Global, GlobalId, Lvalue};
|
||||
use value::{Value, PrimVal};
|
||||
use syntax::codemap::Span;
|
||||
@@ -47,7 +45,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
|
||||
span: stmt.source_info.span,
|
||||
instance: self.frame().instance,
|
||||
ecx: self,
|
||||
mir: Ref::clone(&mir),
|
||||
mir,
|
||||
new_constants: &mut new,
|
||||
}.visit_statement(block, stmt, mir::Location { block, statement_index: stmt_id });
|
||||
if new? == 0 {
|
||||
@@ -64,7 +62,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
|
||||
span: terminator.source_info.span,
|
||||
instance: self.frame().instance,
|
||||
ecx: self,
|
||||
mir: Ref::clone(&mir),
|
||||
mir,
|
||||
new_constants: &mut new,
|
||||
}.visit_terminator(block, terminator, mir::Location { block, statement_index: stmt_id });
|
||||
if new? == 0 {
|
||||
@@ -142,7 +140,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
|
||||
struct ConstantExtractor<'a, 'b: 'a, 'tcx: 'b> {
|
||||
span: Span,
|
||||
ecx: &'a mut EvalContext<'b, 'tcx>,
|
||||
mir: MirRef<'tcx>,
|
||||
mir: &'tcx mir::Mir<'tcx>,
|
||||
instance: ty::Instance<'tcx>,
|
||||
new_constants: &'a mut EvalResult<'tcx, u64>,
|
||||
}
|
||||
@@ -209,8 +207,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for ConstantExtractor<'a, 'b, 'tcx> {
|
||||
if self.ecx.globals.contains_key(&cid) {
|
||||
return;
|
||||
}
|
||||
let mir = Ref::clone(&self.mir);
|
||||
let mir = Ref::map(mir, |mir| &mir.promoted[index]);
|
||||
let mir = &self.mir.promoted[index];
|
||||
self.try(|this| {
|
||||
let ty = this.ecx.monomorphize(mir.return_ty, this.instance.substs);
|
||||
this.ecx.globals.insert(cid, Global::uninitialized(ty));
|
||||
|
||||
@@ -53,13 +53,13 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
|
||||
_ => bug!("expected thin ptr, got {:?}", arg),
|
||||
};
|
||||
arg = Value::ByValPair(PrimVal::Ptr(ptr), PrimVal::Bytes(n as u128));
|
||||
::eval_context::MirRef::clone(&self.seq_drop_glue)
|
||||
&self.seq_drop_glue
|
||||
},
|
||||
ty::TySlice(elem) => {
|
||||
instance.substs = self.tcx.mk_substs([
|
||||
Kind::from(elem),
|
||||
].iter().cloned());
|
||||
::eval_context::MirRef::clone(&self.seq_drop_glue)
|
||||
&self.seq_drop_glue
|
||||
},
|
||||
_ => self.load_mir(instance.def)?,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user