From dd18258ad690da4e6b10c347ad309c69c7fe4c35 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Thu, 2 Nov 2017 14:08:40 +0800 Subject: MIR Optimise - Slight optimisation --- src/mir/helpers.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'src/mir/helpers.cpp') diff --git a/src/mir/helpers.cpp b/src/mir/helpers.cpp index 1e43e361..2cb55e4a 100644 --- a/src/mir/helpers.cpp +++ b/src/mir/helpers.cpp @@ -557,7 +557,7 @@ namespace #if 1 void MIR_Helper_GetLifetimes_DetermineValueLifetime(::MIR::TypeResolve& state, const ::MIR::Function& fcn, size_t bb_idx, size_t stmt_idx, const ::MIR::LValue& lv, const ::std::vector& block_offsets, ValueLifetime& vl); -::MIR::ValueLifetimes MIR_Helper_GetLifetimes(::MIR::TypeResolve& state, const ::MIR::Function& fcn, bool dump_debug) +::MIR::ValueLifetimes MIR_Helper_GetLifetimes(::MIR::TypeResolve& state, const ::MIR::Function& fcn, bool dump_debug, const ::std::vector* mask/*=nullptr*/) { TRACE_FUNCTION_F(state); @@ -580,8 +580,11 @@ void MIR_Helper_GetLifetimes_DetermineValueLifetime(::MIR::TypeResolve& state, c // NOTE: Fills the first statement after running, just to ensure that any assigned value has _a_ lifetime if( const auto* de = lv.opt_Local() ) { - MIR_Helper_GetLifetimes_DetermineValueLifetime(state, fcn, bb_idx, stmt_idx, lv, block_offsets, slot_lifetimes[*de]); - slot_lifetimes[*de].fill(block_offsets, bb_idx, stmt_idx, stmt_idx); + if( !mask || mask->at(*de) ) + { + MIR_Helper_GetLifetimes_DetermineValueLifetime(state, fcn, bb_idx, stmt_idx, lv, block_offsets, slot_lifetimes[*de]); + slot_lifetimes[*de].fill(block_offsets, bb_idx, stmt_idx, stmt_idx); + } } else { @@ -591,8 +594,11 @@ void MIR_Helper_GetLifetimes_DetermineValueLifetime(::MIR::TypeResolve& state, c { if( vu == ValUsage::Write ) { - MIR_Helper_GetLifetimes_DetermineValueLifetime(state, fcn, bb_idx, stmt_idx, lv, block_offsets, slot_lifetimes[*de]); - slot_lifetimes[*de].fill(block_offsets, bb_idx, stmt_idx, stmt_idx); + if( !mask || mask->at(*de) ) + { + MIR_Helper_GetLifetimes_DetermineValueLifetime(state, fcn, bb_idx, stmt_idx, lv, block_offsets, slot_lifetimes[*de]); + slot_lifetimes[*de].fill(block_offsets, bb_idx, stmt_idx, stmt_idx); + } } } return false; @@ -622,7 +628,10 @@ void MIR_Helper_GetLifetimes_DetermineValueLifetime(::MIR::TypeResolve& state, c // HACK: Mark values as valid wherever there's a drop (prevents confusion by simple validator) if( const auto* de = se->slot.opt_Local() ) { - slot_lifetimes[*de].fill(block_offsets, bb_idx, stmt_idx,stmt_idx); + if( !mask || mask->at(*de) ) + { + slot_lifetimes[*de].fill(block_offsets, bb_idx, stmt_idx,stmt_idx); + } } } } -- cgit v1.2.3