Skip to content

Commit d24a563

Browse files
Remove compLvFrameListRoot special-casing from liveness
This is referenced explicitly from IR generated by lowering.
1 parent 5ed2d9b commit d24a563

File tree

5 files changed

+0
-150
lines changed

5 files changed

+0
-150
lines changed

src/coreclr/jit/compiler.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9925,10 +9925,6 @@ JITDBGAPI void __cdecl cTreeFlags(Compiler* comp, GenTree* tree)
99259925
}
99269926
}
99279927

9928-
if (call->gtCallMoreFlags & GTF_CALL_M_FRAME_VAR_DEATH)
9929-
{
9930-
chars += printf("[CALL_M_FRAME_VAR_DEATH]");
9931-
}
99329928
if (call->gtCallMoreFlags & GTF_CALL_M_TAILCALL_VIA_JIT_HELPER)
99339929
{
99349930
chars += printf("[CALL_M_TAILCALL_VIA_JIT_HELPER]");

src/coreclr/jit/gentree.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13145,11 +13145,6 @@ void Compiler::gtDispTree(GenTree* tree,
1314513145
printf(" (async)");
1314613146
}
1314713147

13148-
if ((call->gtFlags & GTF_CALL_UNMANAGED) && (call->gtCallMoreFlags & GTF_CALL_M_FRAME_VAR_DEATH))
13149-
{
13150-
printf(" (FramesRoot last use)");
13151-
}
13152-
1315313148
if ((call->gtFlags & GTF_CALL_INLINE_CANDIDATE) != 0)
1315413149
{
1315513150
InlineCandidateInfo* inlineInfo;

src/coreclr/jit/gentree.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4356,7 +4356,6 @@ enum GenTreeCallFlags : unsigned int
43564356
// in special cases. Used to optimize fast way out in morphing
43574357
GTF_CALL_M_VIRTSTUB_REL_INDIRECT = 0x00000020, // the virtstub is indirected through a relative address (only for GTF_CALL_VIRT_STUB)
43584358
GTF_CALL_M_NONVIRT_SAME_THIS = 0x00000020, // callee "this" pointer is equal to caller this pointer (only for GTF_CALL_NONVIRT)
4359-
GTF_CALL_M_FRAME_VAR_DEATH = 0x00000040, // the compLvFrameListRoot variable dies here (last use)
43604359

43614360
GTF_CALL_M_TAILCALL = 0x00000080, // the call is a tailcall
43624361
GTF_CALL_M_EXPLICIT_TAILCALL = 0x00000100, // the call is "tail" prefixed and importer has performed tail call checks

src/coreclr/jit/lclvars.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3162,22 +3162,6 @@ bool LclVarDsc::CanBeReplacedWithItsField(Compiler* comp) const
31623162
void Compiler::lvaMarkLclRefs(GenTree* tree, BasicBlock* block, Statement* stmt)
31633163
{
31643164
const weight_t weight = block->getBBWeight(this);
3165-
3166-
/* Is this a call to unmanaged code ? */
3167-
if (tree->IsCall() && compMethodRequiresPInvokeFrame())
3168-
{
3169-
assert(!opts.ShouldUsePInvokeHelpers() || (info.compLvFrameListRoot == BAD_VAR_NUM));
3170-
if (!opts.ShouldUsePInvokeHelpers())
3171-
{
3172-
/* Get the special variable descriptor */
3173-
LclVarDsc* varDsc = lvaGetDesc(info.compLvFrameListRoot);
3174-
3175-
/* Increment the ref counts twice */
3176-
varDsc->incRefCnts(weight, this);
3177-
varDsc->incRefCnts(weight, this);
3178-
}
3179-
}
3180-
31813165
if (tree->OperIs(GT_LCL_ADDR))
31823166
{
31833167
LclVarDsc* varDsc = lvaGetDesc(tree->AsLclVarCommon());

src/coreclr/jit/liveness.cpp

Lines changed: 0 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)