@@ -718,34 +718,6 @@ void Liveness<TLiveness>::PerBlockLocalVarLiveness()
718718 }
719719 }
720720
721- // Mark the FrameListRoot as used, if applicable.
722-
723- if (block->KindIs (BBJ_RETURN) && m_compiler->compMethodRequiresPInvokeFrame ())
724- {
725- assert (!m_compiler->opts .ShouldUsePInvokeHelpers () ||
726- (m_compiler->info .compLvFrameListRoot == BAD_VAR_NUM));
727- if (!m_compiler->opts .ShouldUsePInvokeHelpers ())
728- {
729- // 32-bit targets always pop the frame in the epilog.
730- // For 64-bit targets, we only do this in the epilog for IL stubs;
731- // for non-IL stubs the frame is popped after every PInvoke call.
732- #ifdef TARGET_64BIT
733- if (m_compiler->opts .jitFlags ->IsSet (JitFlags::JIT_FLAG_IL_STUB))
734- #endif
735- {
736- LclVarDsc* varDsc = m_compiler->lvaGetDesc (m_compiler->info .compLvFrameListRoot );
737-
738- if (varDsc->lvTracked )
739- {
740- if (!VarSetOps::IsMember (m_compiler, m_curDefSet, varDsc->lvVarIndex ))
741- {
742- VarSetOps::AddElemD (m_compiler, m_curUseSet, varDsc->lvVarIndex );
743- }
744- }
745- }
746- }
747- }
748-
749721 VarSetOps::Assign (m_compiler, block->bbVarUse , m_curUseSet);
750722 VarSetOps::Assign (m_compiler, block->bbVarDef , m_curDefSet);
751723
@@ -933,33 +905,6 @@ void Liveness<TLiveness>::PerNodeLocalVarLiveness(GenTree* tree)
933905 }
934906 }
935907
936- // If this is a p/invoke unmanaged call or if this is a tail-call via helper,
937- // and we have an unmanaged p/invoke call in the method,
938- // then we're going to run the p/invoke epilog.
939- // So we mark the FrameRoot as used by this instruction.
940- // This ensures that the block->bbVarUse will contain
941- // the FrameRoot local var if is it a tracked variable.
942-
943- if ((call->IsUnmanaged () || call->IsTailCallViaJitHelper ()) && m_compiler->compMethodRequiresPInvokeFrame ())
944- {
945- assert (!m_compiler->opts .ShouldUsePInvokeHelpers () ||
946- (m_compiler->info .compLvFrameListRoot == BAD_VAR_NUM));
947- if (!m_compiler->opts .ShouldUsePInvokeHelpers () && !call->IsSuppressGCTransition ())
948- {
949- // Get the FrameRoot local and mark it as used.
950-
951- LclVarDsc* varDsc = m_compiler->lvaGetDesc (m_compiler->info .compLvFrameListRoot );
952-
953- if (varDsc->lvTracked )
954- {
955- if (!VarSetOps::IsMember (m_compiler, m_curDefSet, varDsc->lvVarIndex ))
956- {
957- VarSetOps::AddElemD (m_compiler, m_curUseSet, varDsc->lvVarIndex );
958- }
959- }
960- }
961- }
962-
963908 auto visitDef = [=](GenTreeLclVarCommon* lcl) {
964909 MarkUseDef (lcl);
965910 return GenTree::VisitResult::Continue;
@@ -1767,66 +1712,7 @@ GenTreeLclVarCommon* Liveness<TLiveness>::ComputeLifeCall(VARSET_TP& life,
17671712 GenTreeCall* call)
17681713{
17691714 assert (call != nullptr );
1770- // If this is a tail-call via helper, and we have any unmanaged p/invoke calls in
1771- // the method, then we're going to run the p/invoke epilog
1772- // So we mark the FrameRoot as used by this instruction.
1773- // This ensure that this variable is kept alive at the tail-call
1774- if (call->IsTailCallViaJitHelper () && m_compiler->compMethodRequiresPInvokeFrame ())
1775- {
1776- assert (!m_compiler->opts .ShouldUsePInvokeHelpers () || (m_compiler->info .compLvFrameListRoot == BAD_VAR_NUM));
1777- if (!m_compiler->opts .ShouldUsePInvokeHelpers ())
1778- {
1779- // Get the FrameListRoot local and make it live.
1780-
1781- LclVarDsc* frameVarDsc = m_compiler->lvaGetDesc (m_compiler->info .compLvFrameListRoot );
1782-
1783- if (frameVarDsc->lvTracked )
1784- {
1785- VarSetOps::AddElemD (m_compiler, life, frameVarDsc->lvVarIndex );
1786- }
1787- }
1788- }
1789-
1790- // TODO: we should generate the code for saving to/restoring
1791- // from the inlined PInvoke frame instead.
1792-
1793- /* Is this call to unmanaged code? */
1794- if (call->IsUnmanaged () && m_compiler->compMethodRequiresPInvokeFrame ())
1795- {
1796- // Get the FrameListRoot local and make it live.
1797- assert (!m_compiler->opts .ShouldUsePInvokeHelpers () || (m_compiler->info .compLvFrameListRoot == BAD_VAR_NUM));
1798- if (!m_compiler->opts .ShouldUsePInvokeHelpers () && !call->IsSuppressGCTransition ())
1799- {
1800- LclVarDsc* frameVarDsc = m_compiler->lvaGetDesc (m_compiler->info .compLvFrameListRoot );
1801-
1802- if (frameVarDsc->lvTracked )
1803- {
1804- unsigned varIndex = frameVarDsc->lvVarIndex ;
1805- noway_assert (varIndex < m_compiler->lvaTrackedCount );
1806-
1807- // Is the variable already known to be alive?
1808- //
1809- if (VarSetOps::IsMember (m_compiler, life, varIndex))
1810- {
1811- // Since we may call this multiple times, clear the GTF_CALL_M_FRAME_VAR_DEATH if set.
1812- //
1813- call->gtCallMoreFlags &= ~GTF_CALL_M_FRAME_VAR_DEATH;
1814- }
1815- else
1816- {
1817- // The variable is just coming to life
1818- // Since this is a backwards walk of the trees
1819- // that makes this change in liveness a 'last-use'
1820- //
1821- VarSetOps::AddElemD (m_compiler, life, varIndex);
1822- call->gtCallMoreFlags |= GTF_CALL_M_FRAME_VAR_DEATH;
1823- }
1824- }
1825- }
1826- }
1827-
18281715 GenTreeLclVarCommon* partialDef = nullptr ;
1829-
18301716 auto visitDef = [&](const LocalDef& def) {
18311717 if (!def.IsEntire )
18321718 {
@@ -2371,16 +2257,6 @@ void Liveness<TLiveness>::ComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VAR
23712257 });
23722258
23732259 blockRange.Remove (node);
2374-
2375- // Removing a call does not affect liveness unless it is a tail call in a method with P/Invokes or
2376- // is itself a P/Invoke, in which case it may affect the liveness of the frame root variable.
2377- if (!m_compiler->opts .ShouldUsePInvokeHelpers () &&
2378- ((call->IsTailCall () && m_compiler->compMethodRequiresPInvokeFrame ()) ||
2379- (call->IsUnmanaged () && !call->IsSuppressGCTransition ())) &&
2380- m_compiler->lvaTable [m_compiler->info .compLvFrameListRoot ].lvTracked )
2381- {
2382- m_compiler->fgStmtRemoved = true ;
2383- }
23842260 }
23852261 else
23862262 {
0 commit comments