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 rustc_driver;
|
||||||
extern crate test;
|
extern crate test;
|
||||||
|
|
||||||
use self::miri::{eval_main, run_mir_passes};
|
use self::miri::eval_main;
|
||||||
use self::rustc::session::Session;
|
use self::rustc::session::Session;
|
||||||
use self::rustc_driver::{driver, CompilerCalls, Compilation};
|
use self::rustc_driver::{driver, CompilerCalls, Compilation};
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
@@ -55,7 +55,6 @@ impl<'a> CompilerCalls<'a> for MiriCompilerCalls<'a> {
|
|||||||
.expect("no main or start function found");
|
.expect("no main or start function found");
|
||||||
let entry_def_id = tcx.map.local_def_id(entry_node_id);
|
let entry_def_id = tcx.map.local_def_id(entry_node_id);
|
||||||
|
|
||||||
run_mir_passes(tcx);
|
|
||||||
let memory_size = 100*1024*1024; // 100MB
|
let memory_size = 100*1024*1024; // 100MB
|
||||||
let step_limit = 1000_000;
|
let step_limit = 1000_000;
|
||||||
let stack_limit = 100;
|
let stack_limit = 100;
|
||||||
|
|||||||
@@ -74,7 +74,6 @@ fn after_analysis<'a, 'tcx>(state: &mut CompileState<'a, 'tcx>) {
|
|||||||
state.session.abort_if_errors();
|
state.session.abort_if_errors();
|
||||||
|
|
||||||
let tcx = state.tcx.unwrap();
|
let tcx = state.tcx.unwrap();
|
||||||
miri::run_mir_passes(tcx);
|
|
||||||
let limits = resource_limits_from_attributes(state);
|
let limits = resource_limits_from_attributes(state);
|
||||||
|
|
||||||
if std::env::args().any(|arg| arg == "--test") {
|
if std::env::args().any(|arg| arg == "--test") {
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
use std::cell::Ref;
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::fmt::Write;
|
use std::fmt::Write;
|
||||||
|
|
||||||
@@ -24,8 +23,6 @@ use memory::{Memory, Pointer};
|
|||||||
use operator;
|
use operator;
|
||||||
use value::{PrimVal, PrimValKind, Value};
|
use value::{PrimVal, PrimValKind, Value};
|
||||||
|
|
||||||
pub type MirRef<'tcx> = Ref<'tcx, mir::Mir<'tcx>>;
|
|
||||||
|
|
||||||
pub struct EvalContext<'a, 'tcx: 'a> {
|
pub struct EvalContext<'a, 'tcx: 'a> {
|
||||||
/// The results of the type checker, from rustc.
|
/// The results of the type checker, from rustc.
|
||||||
pub(crate) tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
pub(crate) tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
@@ -48,7 +45,7 @@ pub struct EvalContext<'a, 'tcx: 'a> {
|
|||||||
pub(crate) steps_remaining: u64,
|
pub(crate) steps_remaining: u64,
|
||||||
|
|
||||||
/// Drop glue for arrays and slices
|
/// 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.
|
/// A stack frame.
|
||||||
@@ -58,7 +55,7 @@ pub struct Frame<'tcx> {
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/// The MIR for the function called on this frame.
|
/// 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
|
/// The def_id and substs of the current function
|
||||||
pub instance: ty::Instance<'tcx>,
|
pub instance: ty::Instance<'tcx>,
|
||||||
@@ -302,8 +299,6 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
|
|||||||
DUMMY_SP,
|
DUMMY_SP,
|
||||||
);
|
);
|
||||||
let seq_drop_glue = tcx.alloc_mir(seq_drop_glue);
|
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 {
|
EvalContext {
|
||||||
tcx,
|
tcx,
|
||||||
memory: Memory::new(&tcx.data_layout, limits.memory_size),
|
memory: Memory::new(&tcx.data_layout, limits.memory_size),
|
||||||
@@ -311,7 +306,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
|
|||||||
stack: Vec::new(),
|
stack: Vec::new(),
|
||||||
stack_limit: limits.stack_limit,
|
stack_limit: limits.stack_limit,
|
||||||
steps_remaining: limits.step_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)
|
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);
|
trace!("load mir {:?}", instance);
|
||||||
match 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)),
|
_ => Ok(self.tcx.instance_mir(instance)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -450,7 +445,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
|
|||||||
&mut self,
|
&mut self,
|
||||||
instance: ty::Instance<'tcx>,
|
instance: ty::Instance<'tcx>,
|
||||||
span: codemap::Span,
|
span: codemap::Span,
|
||||||
mir: MirRef<'tcx>,
|
mir: &'tcx mir::Mir<'tcx>,
|
||||||
return_lvalue: Lvalue<'tcx>,
|
return_lvalue: Lvalue<'tcx>,
|
||||||
return_to_block: StackPopCleanup,
|
return_to_block: StackPopCleanup,
|
||||||
) -> EvalResult<'tcx> {
|
) -> EvalResult<'tcx> {
|
||||||
@@ -1445,8 +1440,8 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
|
|||||||
self.stack.last_mut().expect("no call frames exist")
|
self.stack.last_mut().expect("no call frames exist")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn mir(&self) -> MirRef<'tcx> {
|
pub(super) fn mir(&self) -> &'tcx mir::Mir<'tcx> {
|
||||||
Ref::clone(&self.frame().mir)
|
self.frame().mir
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn substs(&self) -> &'tcx Substs<'tcx> {
|
pub(super) fn substs(&self) -> &'tcx Substs<'tcx> {
|
||||||
@@ -1734,32 +1729,6 @@ fn report(tcx: TyCtxt, ecx: &EvalContext, e: EvalError) {
|
|||||||
err.emit();
|
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.
|
// TODO(solson): Upstream these methods into rustc::ty::layout.
|
||||||
|
|
||||||
pub(super) trait IntegerExt {
|
pub(super) trait IntegerExt {
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ pub use eval_context::{
|
|||||||
ResourceLimits,
|
ResourceLimits,
|
||||||
StackPopCleanup,
|
StackPopCleanup,
|
||||||
eval_main,
|
eval_main,
|
||||||
run_mir_passes,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub use lvalue::{
|
pub use lvalue::{
|
||||||
|
|||||||
13
src/step.rs
13
src/step.rs
@@ -2,8 +2,6 @@
|
|||||||
//!
|
//!
|
||||||
//! The main entry point is the `step` method.
|
//! The main entry point is the `step` method.
|
||||||
|
|
||||||
use std::cell::Ref;
|
|
||||||
|
|
||||||
use rustc::hir::def_id::DefId;
|
use rustc::hir::def_id::DefId;
|
||||||
use rustc::hir;
|
use rustc::hir;
|
||||||
use rustc::mir::visit::{Visitor, LvalueContext};
|
use rustc::mir::visit::{Visitor, LvalueContext};
|
||||||
@@ -12,7 +10,7 @@ use rustc::ty::layout::Layout;
|
|||||||
use rustc::ty::{subst, self};
|
use rustc::ty::{subst, self};
|
||||||
|
|
||||||
use error::{EvalResult, EvalError};
|
use error::{EvalResult, EvalError};
|
||||||
use eval_context::{EvalContext, StackPopCleanup, MirRef};
|
use eval_context::{EvalContext, StackPopCleanup};
|
||||||
use lvalue::{Global, GlobalId, Lvalue};
|
use lvalue::{Global, GlobalId, Lvalue};
|
||||||
use value::{Value, PrimVal};
|
use value::{Value, PrimVal};
|
||||||
use syntax::codemap::Span;
|
use syntax::codemap::Span;
|
||||||
@@ -47,7 +45,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
|
|||||||
span: stmt.source_info.span,
|
span: stmt.source_info.span,
|
||||||
instance: self.frame().instance,
|
instance: self.frame().instance,
|
||||||
ecx: self,
|
ecx: self,
|
||||||
mir: Ref::clone(&mir),
|
mir,
|
||||||
new_constants: &mut new,
|
new_constants: &mut new,
|
||||||
}.visit_statement(block, stmt, mir::Location { block, statement_index: stmt_id });
|
}.visit_statement(block, stmt, mir::Location { block, statement_index: stmt_id });
|
||||||
if new? == 0 {
|
if new? == 0 {
|
||||||
@@ -64,7 +62,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
|
|||||||
span: terminator.source_info.span,
|
span: terminator.source_info.span,
|
||||||
instance: self.frame().instance,
|
instance: self.frame().instance,
|
||||||
ecx: self,
|
ecx: self,
|
||||||
mir: Ref::clone(&mir),
|
mir,
|
||||||
new_constants: &mut new,
|
new_constants: &mut new,
|
||||||
}.visit_terminator(block, terminator, mir::Location { block, statement_index: stmt_id });
|
}.visit_terminator(block, terminator, mir::Location { block, statement_index: stmt_id });
|
||||||
if new? == 0 {
|
if new? == 0 {
|
||||||
@@ -142,7 +140,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
|
|||||||
struct ConstantExtractor<'a, 'b: 'a, 'tcx: 'b> {
|
struct ConstantExtractor<'a, 'b: 'a, 'tcx: 'b> {
|
||||||
span: Span,
|
span: Span,
|
||||||
ecx: &'a mut EvalContext<'b, 'tcx>,
|
ecx: &'a mut EvalContext<'b, 'tcx>,
|
||||||
mir: MirRef<'tcx>,
|
mir: &'tcx mir::Mir<'tcx>,
|
||||||
instance: ty::Instance<'tcx>,
|
instance: ty::Instance<'tcx>,
|
||||||
new_constants: &'a mut EvalResult<'tcx, u64>,
|
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) {
|
if self.ecx.globals.contains_key(&cid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let mir = Ref::clone(&self.mir);
|
let mir = &self.mir.promoted[index];
|
||||||
let mir = Ref::map(mir, |mir| &mir.promoted[index]);
|
|
||||||
self.try(|this| {
|
self.try(|this| {
|
||||||
let ty = this.ecx.monomorphize(mir.return_ty, this.instance.substs);
|
let ty = this.ecx.monomorphize(mir.return_ty, this.instance.substs);
|
||||||
this.ecx.globals.insert(cid, Global::uninitialized(ty));
|
this.ecx.globals.insert(cid, Global::uninitialized(ty));
|
||||||
|
|||||||
@@ -53,13 +53,13 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
|
|||||||
_ => bug!("expected thin ptr, got {:?}", arg),
|
_ => bug!("expected thin ptr, got {:?}", arg),
|
||||||
};
|
};
|
||||||
arg = Value::ByValPair(PrimVal::Ptr(ptr), PrimVal::Bytes(n as u128));
|
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) => {
|
ty::TySlice(elem) => {
|
||||||
instance.substs = self.tcx.mk_substs([
|
instance.substs = self.tcx.mk_substs([
|
||||||
Kind::from(elem),
|
Kind::from(elem),
|
||||||
].iter().cloned());
|
].iter().cloned());
|
||||||
::eval_context::MirRef::clone(&self.seq_drop_glue)
|
&self.seq_drop_glue
|
||||||
},
|
},
|
||||||
_ => self.load_mir(instance.def)?,
|
_ => self.load_mir(instance.def)?,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user