From e9315a60e42d355a36c778f43d92b5ffc8b54252 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Tue, 5 Sep 2017 17:18:48 +0200 Subject: [PATCH 1/4] Rustup --- src/librustc_mir/interpret/eval_context.rs | 4 +-- src/librustc_mir/interpret/lvalue.rs | 11 ++++---- src/librustc_mir/interpret/step.rs | 25 +++++++------------ tests/run-pass-fullmir/unsized-tuple-impls.rs | 2 ++ 4 files changed, 19 insertions(+), 23 deletions(-) diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs index 44777caa4f5d..bc227fcc3985 100644 --- a/src/librustc_mir/interpret/eval_context.rs +++ b/src/librustc_mir/interpret/eval_context.rs @@ -467,8 +467,8 @@ fn collect_storage_annotations<'tcx>(mir: &'tcx mir::Mir<'tcx>) -> HashSet { + StorageLive(local) | + StorageDead(local) => { set.insert(local); } _ => {} diff --git a/src/librustc_mir/interpret/lvalue.rs b/src/librustc_mir/interpret/lvalue.rs index f26f5adfff96..3342be7300e7 100644 --- a/src/librustc_mir/interpret/lvalue.rs +++ b/src/librustc_mir/interpret/lvalue.rs @@ -3,7 +3,7 @@ use rustc::ty::{self, Ty}; use rustc_data_structures::indexed_vec::Idx; -use super::{EvalResult, EvalContext, MemoryPointer, PrimVal, Value, Pointer, Machine, PtrAndAlign}; +use super::{EvalResult, EvalContext, MemoryPointer, PrimVal, Value, Pointer, Machine, PtrAndAlign, ValTy}; #[derive(Copy, Clone, Debug)] pub enum Lvalue { @@ -400,7 +400,7 @@ pub(super) fn eval_lvalue_projection( &mut self, base: Lvalue, base_ty: Ty<'tcx>, - proj_elem: &mir::ProjectionElem<'tcx, mir::Operand<'tcx>, Ty<'tcx>>, + proj_elem: &mir::ProjectionElem<'tcx, mir::Local, Ty<'tcx>>, ) -> EvalResult<'tcx, Lvalue> { use rustc::mir::ProjectionElem::*; let (ptr, extra) = match *proj_elem { @@ -439,9 +439,10 @@ pub(super) fn eval_lvalue_projection( return self.val_to_lvalue(val, pointee_type); } - Index(ref operand) => { - let n_ptr = self.eval_operand(operand)?; - let n = self.value_to_primval(n_ptr)?.to_u64()?; + Index(local) => { + let value = self.frame().get_local(local)?; + let ty = self.tcx.types.usize; + let n = self.value_to_primval(ValTy { value, ty })?.to_u64()?; return self.lvalue_index(base, base_ty, n); } diff --git a/src/librustc_mir/interpret/step.rs b/src/librustc_mir/interpret/step.rs index ea90e39489d5..e7d5a83532b3 100644 --- a/src/librustc_mir/interpret/step.rs +++ b/src/librustc_mir/interpret/step.rs @@ -145,22 +145,15 @@ fn statement(&mut self, stmt: &mir::Statement<'tcx>) -> EvalResult<'tcx> { } } - // Mark locals as dead or alive. - StorageLive(ref lvalue) | - StorageDead(ref lvalue) => { - let (frame, local) = - match self.eval_lvalue(lvalue)? { - Lvalue::Local { frame, local } if self.cur_frame() == frame => ( - frame, - local, - ), - _ => return err!(Unimplemented("Storage annotations must refer to locals of the topmost stack frame.".to_owned())), // FIXME maybe this should get its own error type - }; - let old_val = match stmt.kind { - StorageLive(_) => self.stack[frame].storage_live(local)?, - StorageDead(_) => self.stack[frame].storage_dead(local)?, - _ => bug!("We already checked that we are a storage stmt"), - }; + // Mark locals as alive + StorageLive(local) => { + let old_val = self.frame_mut().storage_live(local)?; + self.deallocate_local(old_val)?; + } + + // Mark locals as dead + StorageDead(local) => { + let old_val = self.frame_mut().storage_dead(local)?; self.deallocate_local(old_val)?; } diff --git a/tests/run-pass-fullmir/unsized-tuple-impls.rs b/tests/run-pass-fullmir/unsized-tuple-impls.rs index ccb6883e8733..acaedebbf9b8 100644 --- a/tests/run-pass-fullmir/unsized-tuple-impls.rs +++ b/tests/run-pass-fullmir/unsized-tuple-impls.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// compile-flags: -Zmir-emit-validate=0 + #![feature(unsized_tuple_coercion)] use std::mem; From 59cbfdbf0852c394a1a1cac9eece8db65a39e446 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 6 Sep 2017 10:10:43 +0200 Subject: [PATCH 2/4] enable a test that works just fine --- tests/run-pass-fullmir/unsized-tuple-impls.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/run-pass-fullmir/unsized-tuple-impls.rs b/tests/run-pass-fullmir/unsized-tuple-impls.rs index acaedebbf9b8..ccb6883e8733 100644 --- a/tests/run-pass-fullmir/unsized-tuple-impls.rs +++ b/tests/run-pass-fullmir/unsized-tuple-impls.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// compile-flags: -Zmir-emit-validate=0 - #![feature(unsized_tuple_coercion)] use std::mem; From 2ee999b2cacf0ec9f7abf5615c4a7acd7938d7dd Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 6 Sep 2017 10:15:28 +0200 Subject: [PATCH 3/4] use latest xargo; this fixes the libstd build problem --- .travis.yml | 2 +- xargo/build.sh | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 43858eec5719..5f4724a89e72 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ before_script: - rustup target add i686-pc-windows-gnu - rustup target add i686-pc-windows-msvc - rustup component add rust-src -- cargo install xargo +- cargo install --git https://github.com/japaric/xargo.git - export RUST_SYSROOT=$HOME/rust script: - set -e diff --git a/xargo/build.sh b/xargo/build.sh index b842c04ae09e..15a7c770910d 100755 --- a/xargo/build.sh +++ b/xargo/build.sh @@ -1,4 +1,3 @@ #!/bin/sh cd "$(dirname "$0")" -sed 's/gcc = "0\.3\.50"/gcc = "=0\.3\.50"/' -i ~/.rustup/toolchains/*/lib/rustlib/src/rust/src/libstd/Cargo.toml RUSTFLAGS='-Zalways-encode-mir -Zmir-emit-validate=1' xargo build From 9fe0d60da621c982fbc9add5198e8c4f7bc961c4 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 6 Sep 2017 10:30:00 +0200 Subject: [PATCH 4/4] disable optimized tests until rustc is fixed --- tests/compiletest.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/compiletest.rs b/tests/compiletest.rs index f9d99206e278..aa27386ca7e1 100644 --- a/tests/compiletest.rs +++ b/tests/compiletest.rs @@ -190,7 +190,8 @@ fn run_pass_miri_noopt() { #[test] fn run_pass_miri_opt() { - run_pass_miri(true); + // FIXME: Disabled for now, as the optimizer is pretty broken and crashes... + //run_pass_miri(true); } #[test]