diff options
author | John Hodge <tpg@ucc.asn.au> | 2019-07-07 13:30:29 +0800 |
---|---|---|
committer | John Hodge <tpg@ucc.asn.au> | 2019-07-07 13:30:29 +0800 |
commit | a94abe48f395b161ade776c019da12ba99eb5e88 (patch) | |
tree | 6639ab378f60929c65ff6945435da13b44039862 /src/mir/check.cpp | |
parent | cb11800ea4a8a542c2a0667870ab3730e2b8b9df (diff) | |
download | mrust-a94abe48f395b161ade776c019da12ba99eb5e88.tar.gz |
MIR Optimise - Fix (and detect) mis-optimisation with indexing, more const propagation
Diffstat (limited to 'src/mir/check.cpp')
-rw-r--r-- | src/mir/check.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/mir/check.cpp b/src/mir/check.cpp index 6ed34563..d159c85f 100644 --- a/src/mir/check.cpp +++ b/src/mir/check.cpp @@ -357,6 +357,18 @@ void MIR_Validate_ValState(::MIR::TypeResolve& state, const ::MIR::Function& fcn val_state.mark_validity( state, v.second, true ); break; case ::MIR::Statement::TAG_Assign: + // Destination must be valid + for(const auto& w : stmt.as_Assign().dst.m_wrappers) + { + if( w.is_Deref() ) { + // TODO: Check validity of the rest of the wrappers. + } + if( w.is_Index() ) + { + if( val_state.locals[w.as_Index()] != ValStates::State::Valid ) + MIR_BUG(state, "Use of non-valid lvalue - " << ::MIR::LValue::new_Local(w.as_Index())); + } + } // Check source (and invalidate sources) TU_MATCH( ::MIR::RValue, (stmt.as_Assign().src), (se), (Use, |