Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 34 additions & 22 deletions src/coreclr/jit/async.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -397,14 +397,12 @@ BasicBlock* Compiler::CreateReturnBB(unsigned* mergedReturnLcl)
class AsyncLiveness
{
Compiler* m_compiler;
bool m_hasLiveness;
TreeLifeUpdater<false> m_updater;
unsigned m_numVars;

public:
AsyncLiveness(Compiler* comp, bool hasLiveness)
AsyncLiveness(Compiler* comp)
: m_compiler(comp)
, m_hasLiveness(hasLiveness)
, m_updater(comp)
, m_numVars(comp->lvaCount)
{
Expand All@@ -430,9 +428,6 @@ class AsyncLiveness
//
void AsyncLiveness::StartBlock(BasicBlock* block)
{
if (!m_hasLiveness)
return;

VarSetOps::Assign(m_compiler, m_compiler->compCurLife, block->bbLiveIn);
}

Expand All@@ -446,9 +441,6 @@ void AsyncLiveness::StartBlock(BasicBlock* block)
//
void AsyncLiveness::Update(GenTree* node)
{
if (!m_hasLiveness)
return;

m_updater.UpdateLife(node);
}

Expand DownExpand Up@@ -539,8 +531,9 @@ bool AsyncLiveness::IsLive(unsigned lclNum)
return false;
}

if (!m_hasLiveness)
if (m_compiler->opts.compDbgCode && (lclNum < m_compiler->info.compLocalsCount))
{
// Keep all IL locals in debug codegen
Comment thread
jakobbotsch marked this conversation as resolved.
return true;
}

Expand DownExpand Up@@ -701,21 +694,18 @@ PhaseStatus AsyncTransformation::Run()
#endif

// Compute liveness to be used for determining what must be captured on
// suspension. In unoptimized codegen we capture everything.
if (m_compiler->opts.OptimizationEnabled())
// suspension.
if (m_compiler->m_dfsTree == nullptr)
{
if (m_compiler->m_dfsTree == nullptr)
{
m_compiler->m_dfsTree = m_compiler->fgComputeDfs<false>();
}

m_compiler->lvaComputeRefCounts(true, false);
m_compiler->fgAsyncLiveness();
INDEBUG(m_compiler->mostRecentlyActivePhase = PHASE_ASYNC);
VarSetOps::AssignNoCopy(m_compiler, m_compiler->compCurLife, VarSetOps::MakeEmpty(m_compiler));
m_compiler->m_dfsTree = m_compiler->fgComputeDfs<false>();
}

AsyncLiveness liveness(m_compiler, m_compiler->opts.OptimizationEnabled());
m_compiler->lvaComputePreciseRefCounts(/* isRecompute */ true, /* setSlotNumbers */ false);
m_compiler->fgAsyncLiveness();
INDEBUG(m_compiler->mostRecentlyActivePhase = PHASE_ASYNC);
VarSetOps::AssignNoCopy(m_compiler, m_compiler->compCurLife, VarSetOps::MakeEmpty(m_compiler));

AsyncLiveness liveness(m_compiler);

// Now walk the IR for all the blocks that contain async calls. Keep track
// of liveness and outstanding LIR edges as we go; the LIR edges that cross
Expand DownExpand Up@@ -783,6 +773,28 @@ PhaseStatus AsyncTransformation::Run()

m_compiler->fgInvalidateDfsTree();

if (m_compiler->opts.OptimizationDisabled())
{
// Rest of the compiler does not expect that we started tracking locals, so reset that state.
for (unsigned i = 0; i < m_compiler->lvaTrackedCount; i++)
{
m_compiler->lvaGetDesc(m_compiler->lvaTrackedToVarNum[i])->lvTracked = false;
}

m_compiler->lvaCurEpoch++;
m_compiler->lvaTrackedCount = 0;
m_compiler->lvaTrackedCountInSizeTUnits = 0;

for (BasicBlock* block : m_compiler->Blocks())
{
block->bbLiveIn = VarSetOps::UninitVal();
block->bbLiveOut = VarSetOps::UninitVal();
block->bbVarUse = VarSetOps::UninitVal();
block->bbVarDef = VarSetOps::UninitVal();
}
m_compiler->fgBBVarSetsInited = false;
}

return PhaseStatus::MODIFIED_EVERYTHING;
}

Expand Down
1 change: 1 addition & 0 deletions src/coreclr/jit/compiler.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -4214,6 +4214,7 @@ class Compiler

PhaseStatus lvaMarkLocalVars(); // Local variable ref-counting
void lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers);
void lvaComputePreciseRefCounts(bool isRecompute, bool setSlotNumbers);
void lvaMarkLocalVars(BasicBlock* block);

void lvaAllocOutgoingArgSpaceVar(); // Set up lvaOutgoingArgSpaceVar
Expand Down
38 changes: 28 additions & 10 deletions src/coreclr/jit/lclvars.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -3415,8 +3415,6 @@ PhaseStatus Compiler::lvaMarkLocalVars()
void Compiler::lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers)
{
JITDUMP("\n*** lvaComputeRefCounts ***\n");
unsigned lclNum = 0;
LclVarDsc* varDsc = nullptr;

// Fast path for minopts and debug codegen.
//
Expand All@@ -3430,8 +3428,9 @@ void Compiler::lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers)
#if defined(DEBUG)
// All local vars should be marked as implicitly referenced
// and not tracked.
for (lclNum = 0, varDsc = lvaTable; lclNum < lvaCount; lclNum++, varDsc++)
for (unsigned lclNum = 0; lclNum < lvaCount; lclNum++)
{
LclVarDsc* varDsc = lvaGetDesc(lclNum);
const bool isSpecialVarargsParam = varDsc->lvIsParam && lvaIsArgAccessedViaVarArgsCookie(lclNum);

if (isSpecialVarargsParam)
Expand All@@ -3451,8 +3450,9 @@ void Compiler::lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers)
}

// First compute.
for (lclNum = 0, varDsc = lvaTable; lclNum < lvaCount; lclNum++, varDsc++)
for (unsigned lclNum = 0; lclNum < lvaCount; lclNum++)
{
LclVarDsc* varDsc = lvaGetDesc(lclNum);
// Using lvImplicitlyReferenced here ensures that we can't
// accidentally make locals be unreferenced later by decrementing
// the ref count to zero.
Expand DownExpand Up@@ -3488,11 +3488,28 @@ void Compiler::lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers)
return;
}

// Slower path we take when optimizing, to get accurate counts.
//
lvaComputePreciseRefCounts(isRecompute, setSlotNumbers);
}

//------------------------------------------------------------------------
// lvaComputePreciseRefCounts: compute precise ref counts for locals by IR traversal
//
// Arguments:
// isRecompute -- true if we just want ref counts and no other side effects;
// false means to also look for true boolean locals, lay
// groundwork for assertion prop, check type consistency, etc.
// See lvaMarkLclRefs for details on what else goes on.
// setSlotNumbers -- true if local slot numbers should be assigned.
//
// Notes:
// See notes on lvaComputeRefCounts.
//
void Compiler::lvaComputePreciseRefCounts(bool isRecompute, bool setSlotNumbers)
{
// First, reset all explicit ref counts and weights.
for (lclNum = 0, varDsc = lvaTable; lclNum < lvaCount; lclNum++, varDsc++)
for (unsigned lclNum = 0; lclNum < lvaCount; lclNum++)
{
LclVarDsc* varDsc = lvaGetDesc(lclNum);
varDsc->setLvRefCnt(0);
varDsc->setLvRefCntWtd(BB_ZERO_WEIGHT);

Expand All@@ -3519,7 +3536,7 @@ void Compiler::lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers)
const bool oldLvaGenericsContextInUse = lvaGenericsContextInUse;
lvaGenericsContextInUse = false;

JITDUMP("\n*** lvaComputeRefCounts -- explicit counts ***\n");
JITDUMP("\n*** lvaComputePreciseRefCounts -- explicit counts ***\n");

// Second, account for all explicit local variable references
for (BasicBlock* const block : Blocks())
Expand DownExpand Up@@ -3577,11 +3594,12 @@ void Compiler::lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers)
assert(!"unexpected new use of generics context");
}

JITDUMP("\n*** lvaComputeRefCounts -- implicit counts ***\n");
JITDUMP("\n*** lvaComputePreciseRefCounts -- implicit counts ***\n");

// Third, bump ref counts for some implicit prolog references
for (lclNum = 0, varDsc = lvaTable; lclNum < lvaCount; lclNum++, varDsc++)
for (unsigned lclNum = 0; lclNum < lvaCount; lclNum++)
{
LclVarDsc* varDsc = lvaGetDesc(lclNum);
// Todo: review justification for these count bumps.
if (varDsc->lvIsRegArg)
{
Expand Down
52 changes: 33 additions & 19 deletions src/coreclr/jit/liveness.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,6 +55,7 @@ class Liveness
ComputeMemoryLiveness = false,
IsLIR = false,
IsEarly = false,
EliminateDeadCode = false,
};

Liveness(Compiler* compiler)
Expand DownExpand Up@@ -1965,16 +1966,19 @@ bool Liveness<TLiveness>::ComputeLifeTrackedLocalDef(VARSET_TP& life,
// Dead store
node->gtFlags |= GTF_VAR_DEATH;

// keepAliveVars always stay alive
noway_assert(!VarSetOps::IsMember(m_compiler, keepAliveVars, varIndex));
if (TLiveness::EliminateDeadCode)
{
// keepAliveVars always stay alive
noway_assert(!VarSetOps::IsMember(m_compiler, keepAliveVars, varIndex));

// Do not consider this store dead if the target local variable represents
// a promoted struct field of an address exposed local or if the address
// of the variable has been exposed. Improved alias analysis could allow
// stores to these sorts of variables to be removed at the cost of compile
// time.
return !varDsc.IsAddressExposed() &&
!(varDsc.lvIsStructField && m_compiler->lvaTable[varDsc.lvParentLcl].IsAddressExposed());
// Do not consider this store dead if the target local variable represents
// a promoted struct field of an address exposed local or if the address
// of the variable has been exposed. Improved alias analysis could allow
// stores to these sorts of variables to be removed at the cost of compile
// time.
return !varDsc.IsAddressExposed() &&
!(varDsc.lvIsStructField && m_compiler->lvaTable[varDsc.lvParentLcl].IsAddressExposed());
}
}

return false;
Expand DownExpand Up@@ -2011,7 +2015,7 @@ bool Liveness<TLiveness>::ComputeLifeUntrackedLocal(VARSET_TP& life,

// We have accurate ref counts when running late liveness so we can eliminate
// some stores if the lhs local has a ref count of 1.
if (isDef && TLiveness::IsLIR && (varDsc.lvRefCnt() == 1) && !varDsc.lvPinned)
if (TLiveness::EliminateDeadCode && TLiveness::IsLIR && isDef && (varDsc.lvRefCnt() == 1) && !varDsc.lvPinned)
{
if (varDsc.lvIsStructField)
{
Expand DownExpand Up@@ -2083,7 +2087,7 @@ bool Liveness<TLiveness>::ComputeLifeUntrackedLocal(VARSET_TP& life,
}
}

if (isDef && !anyFieldLive)
if (TLiveness::EliminateDeadCode && isDef && !anyFieldLive)
{
// Do not consider this store dead if the parent local variable is an address exposed local or
// if the struct has any significant padding we must retain the value of.
Expand DownExpand Up@@ -2328,7 +2332,8 @@ void Liveness<TLiveness>::ComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VAR
case GT_CALL:
{
GenTreeCall* const call = node->AsCall();
if ((call->TypeIs(TYP_VOID) || call->IsUnusedValue()) && !call->HasSideEffects(m_compiler))
if (TLiveness::EliminateDeadCode && (call->TypeIs(TYP_VOID) || call->IsUnusedValue()) &&
!call->HasSideEffects(m_compiler))
{
JITDUMP("Removing dead call:\n");
DISPNODE(call);
Expand DownExpand Up@@ -2375,13 +2380,13 @@ void Liveness<TLiveness>::ComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VAR
GenTreeLclVarCommon* const lclVarNode = node->AsLclVarCommon();
LclVarDsc& varDsc = m_compiler->lvaTable[lclVarNode->GetLclNum()];

if (node->IsUnusedValue())
if (TLiveness::EliminateDeadCode && node->IsUnusedValue())
{
JITDUMP("Removing dead LclVar use:\n");
DISPNODE(lclVarNode);

blockRange.Delete(m_compiler, block, node);
if (varDsc.lvTracked && !m_compiler->opts.MinOpts())
if (varDsc.lvTracked)
{
m_compiler->fgStmtRemoved = true;
}
Expand All@@ -2398,14 +2403,14 @@ void Liveness<TLiveness>::ComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VAR
}

case GT_LCL_ADDR:
if (node->IsUnusedValue())
if (TLiveness::EliminateDeadCode && node->IsUnusedValue())
{
JITDUMP("Removing dead LclVar address:\n");
DISPNODE(node);

const bool isTracked = m_compiler->lvaTable[node->AsLclVarCommon()->GetLclNum()].lvTracked;
blockRange.Delete(m_compiler, block, node);
if (isTracked && !m_compiler->opts.MinOpts())
if (isTracked)
{
m_compiler->fgStmtRemoved = true;
}
Expand All@@ -2423,7 +2428,7 @@ void Liveness<TLiveness>::ComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VAR
}

isDeadStore = ComputeLifeLocal(life, keepAliveVars, node);
if (isDeadStore)
if (TLiveness::EliminateDeadCode && isDeadStore)
{
LIR::Use addrUse;
if (blockRange.TryGetUse(node, &addrUse) && addrUse.User()->OperIs(GT_STOREIND, GT_STORE_BLK))
Expand DownExpand Up@@ -2464,7 +2469,7 @@ void Liveness<TLiveness>::ComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VAR
isDeadStore = ComputeLifeUntrackedLocal(life, keepAliveVars, varDsc, lclVarNode);
}

if (isDeadStore && TryRemoveDeadStoreLIR(node, lclVarNode, block))
if (TLiveness::EliminateDeadCode && isDeadStore && TryRemoveDeadStoreLIR(node, lclVarNode, block))
{
GenTree* value = lclVarNode->Data();
value->SetUnusedValue();
Expand All@@ -2491,7 +2496,7 @@ void Liveness<TLiveness>::ComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VAR
#endif // FEATURE_MASKED_HW_INTRINSICS
case GT_PHYSREG:
// These are all side-effect-free leaf nodes.
if (node->IsUnusedValue())
if (TLiveness::EliminateDeadCode && node->IsUnusedValue())
{
JITDUMP("Removing dead node:\n");
DISPNODE(node);
Expand DownExpand Up@@ -2693,6 +2698,11 @@ bool Liveness<TLiveness>::TryRemoveDeadStoreLIR(GenTree* store, GenTreeLclVarCom
template <typename TLiveness>
bool Liveness<TLiveness>::TryRemoveNonLocalLIR(GenTree* node, LIR::Range* blockRange)
{
if (!TLiveness::EliminateDeadCode)
{
return false;
}

assert(!node->OperIsLocal());
if (!node->IsValue() || node->IsUnusedValue())
{
Expand DownExpand Up@@ -2816,6 +2826,7 @@ void Compiler::fgSsaLiveness()
ComputeMemoryLiveness = true,
IsLIR = false,
IsEarly = false,
EliminateDeadCode = true,
};

SsaLivenessClass(Compiler* comp)
Expand All@@ -2841,6 +2852,7 @@ void Compiler::fgAsyncLiveness()
ComputeMemoryLiveness = false,
IsLIR = true,
IsEarly = false,
EliminateDeadCode = false,
};

AsyncLiveness(Compiler* comp)
Expand All@@ -2866,6 +2878,7 @@ void Compiler::fgPostLowerLiveness()
ComputeMemoryLiveness = false,
IsLIR = true,
IsEarly = false,
EliminateDeadCode = true,
};

PostLowerLiveness(Compiler* comp)
Expand DownExpand Up@@ -2909,6 +2922,7 @@ PhaseStatus Compiler::fgEarlyLiveness()
ComputeMemoryLiveness = false,
IsLIR = false,
IsEarly = true,
EliminateDeadCode = true,
};

EarlyLiveness(Compiler* comp)
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 34 additions & 22 deletions src/coreclr/jit/async.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -397,14 +397,12 @@ BasicBlock* Compiler::CreateReturnBB(unsigned* mergedReturnLcl)
class AsyncLiveness
{
Compiler* m_compiler;
bool m_hasLiveness;
TreeLifeUpdater<false> m_updater;
unsigned m_numVars;

public:
AsyncLiveness(Compiler* comp, bool hasLiveness)
AsyncLiveness(Compiler* comp)
: m_compiler(comp)
, m_hasLiveness(hasLiveness)
, m_updater(comp)
, m_numVars(comp->lvaCount)
{
Expand All@@ -430,9 +428,6 @@ class AsyncLiveness
//
void AsyncLiveness::StartBlock(BasicBlock* block)
{
if (!m_hasLiveness)
return;

VarSetOps::Assign(m_compiler, m_compiler->compCurLife, block->bbLiveIn);
}

Expand All@@ -446,9 +441,6 @@ void AsyncLiveness::StartBlock(BasicBlock* block)
//
void AsyncLiveness::Update(GenTree* node)
{
if (!m_hasLiveness)
return;

m_updater.UpdateLife(node);
}

Expand DownExpand Up@@ -539,8 +531,9 @@ bool AsyncLiveness::IsLive(unsigned lclNum)
return false;
}

if (!m_hasLiveness)
if (m_compiler->opts.compDbgCode && (lclNum < m_compiler->info.compLocalsCount))
{
// Keep all IL locals in debug codegen
Comment thread
jakobbotsch marked this conversation as resolved.
return true;
}

Expand DownExpand Up@@ -701,21 +694,18 @@ PhaseStatus AsyncTransformation::Run()
#endif

// Compute liveness to be used for determining what must be captured on
// suspension. In unoptimized codegen we capture everything.
if (m_compiler->opts.OptimizationEnabled())
// suspension.
if (m_compiler->m_dfsTree == nullptr)
{
if (m_compiler->m_dfsTree == nullptr)
{
m_compiler->m_dfsTree = m_compiler->fgComputeDfs<false>();
}

m_compiler->lvaComputeRefCounts(true, false);
m_compiler->fgAsyncLiveness();
INDEBUG(m_compiler->mostRecentlyActivePhase = PHASE_ASYNC);
VarSetOps::AssignNoCopy(m_compiler, m_compiler->compCurLife, VarSetOps::MakeEmpty(m_compiler));
m_compiler->m_dfsTree = m_compiler->fgComputeDfs<false>();
}

AsyncLiveness liveness(m_compiler, m_compiler->opts.OptimizationEnabled());
m_compiler->lvaComputePreciseRefCounts(/* isRecompute */ true, /* setSlotNumbers */ false);
m_compiler->fgAsyncLiveness();
INDEBUG(m_compiler->mostRecentlyActivePhase = PHASE_ASYNC);
VarSetOps::AssignNoCopy(m_compiler, m_compiler->compCurLife, VarSetOps::MakeEmpty(m_compiler));

AsyncLiveness liveness(m_compiler);

// Now walk the IR for all the blocks that contain async calls. Keep track
// of liveness and outstanding LIR edges as we go; the LIR edges that cross
Expand DownExpand Up@@ -783,6 +773,28 @@ PhaseStatus AsyncTransformation::Run()

m_compiler->fgInvalidateDfsTree();

if (m_compiler->opts.OptimizationDisabled())
{
// Rest of the compiler does not expect that we started tracking locals, so reset that state.
for (unsigned i = 0; i < m_compiler->lvaTrackedCount; i++)
{
m_compiler->lvaGetDesc(m_compiler->lvaTrackedToVarNum[i])->lvTracked = false;
}

m_compiler->lvaCurEpoch++;
m_compiler->lvaTrackedCount = 0;
m_compiler->lvaTrackedCountInSizeTUnits = 0;

for (BasicBlock* block : m_compiler->Blocks())
{
block->bbLiveIn = VarSetOps::UninitVal();
block->bbLiveOut = VarSetOps::UninitVal();
block->bbVarUse = VarSetOps::UninitVal();
block->bbVarDef = VarSetOps::UninitVal();
}
m_compiler->fgBBVarSetsInited = false;
}

return PhaseStatus::MODIFIED_EVERYTHING;
}

Expand Down
1 change: 1 addition & 0 deletions src/coreclr/jit/compiler.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -4214,6 +4214,7 @@ class Compiler

PhaseStatus lvaMarkLocalVars(); // Local variable ref-counting
void lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers);
void lvaComputePreciseRefCounts(bool isRecompute, bool setSlotNumbers);
void lvaMarkLocalVars(BasicBlock* block);

void lvaAllocOutgoingArgSpaceVar(); // Set up lvaOutgoingArgSpaceVar
Expand Down
38 changes: 28 additions & 10 deletions src/coreclr/jit/lclvars.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -3415,8 +3415,6 @@ PhaseStatus Compiler::lvaMarkLocalVars()
void Compiler::lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers)
{
JITDUMP("\n*** lvaComputeRefCounts ***\n");
unsigned lclNum = 0;
LclVarDsc* varDsc = nullptr;

// Fast path for minopts and debug codegen.
//
Expand All@@ -3430,8 +3428,9 @@ void Compiler::lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers)
#if defined(DEBUG)
// All local vars should be marked as implicitly referenced
// and not tracked.
for (lclNum = 0, varDsc = lvaTable; lclNum < lvaCount; lclNum++, varDsc++)
for (unsigned lclNum = 0; lclNum < lvaCount; lclNum++)
{
LclVarDsc* varDsc = lvaGetDesc(lclNum);
const bool isSpecialVarargsParam = varDsc->lvIsParam && lvaIsArgAccessedViaVarArgsCookie(lclNum);

if (isSpecialVarargsParam)
Expand All@@ -3451,8 +3450,9 @@ void Compiler::lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers)
}

// First compute.
for (lclNum = 0, varDsc = lvaTable; lclNum < lvaCount; lclNum++, varDsc++)
for (unsigned lclNum = 0; lclNum < lvaCount; lclNum++)
{
LclVarDsc* varDsc = lvaGetDesc(lclNum);
// Using lvImplicitlyReferenced here ensures that we can't
// accidentally make locals be unreferenced later by decrementing
// the ref count to zero.
Expand DownExpand Up@@ -3488,11 +3488,28 @@ void Compiler::lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers)
return;
}

// Slower path we take when optimizing, to get accurate counts.
//
lvaComputePreciseRefCounts(isRecompute, setSlotNumbers);
}

//------------------------------------------------------------------------
// lvaComputePreciseRefCounts: compute precise ref counts for locals by IR traversal
//
// Arguments:
// isRecompute -- true if we just want ref counts and no other side effects;
// false means to also look for true boolean locals, lay
// groundwork for assertion prop, check type consistency, etc.
// See lvaMarkLclRefs for details on what else goes on.
// setSlotNumbers -- true if local slot numbers should be assigned.
//
// Notes:
// See notes on lvaComputeRefCounts.
//
void Compiler::lvaComputePreciseRefCounts(bool isRecompute, bool setSlotNumbers)
{
// First, reset all explicit ref counts and weights.
for (lclNum = 0, varDsc = lvaTable; lclNum < lvaCount; lclNum++, varDsc++)
for (unsigned lclNum = 0; lclNum < lvaCount; lclNum++)
{
LclVarDsc* varDsc = lvaGetDesc(lclNum);
varDsc->setLvRefCnt(0);
varDsc->setLvRefCntWtd(BB_ZERO_WEIGHT);

Expand All@@ -3519,7 +3536,7 @@ void Compiler::lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers)
const bool oldLvaGenericsContextInUse = lvaGenericsContextInUse;
lvaGenericsContextInUse = false;

JITDUMP("\n*** lvaComputeRefCounts -- explicit counts ***\n");
JITDUMP("\n*** lvaComputePreciseRefCounts -- explicit counts ***\n");

// Second, account for all explicit local variable references
for (BasicBlock* const block : Blocks())
Expand DownExpand Up@@ -3577,11 +3594,12 @@ void Compiler::lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers)
assert(!"unexpected new use of generics context");
}

JITDUMP("\n*** lvaComputeRefCounts -- implicit counts ***\n");
JITDUMP("\n*** lvaComputePreciseRefCounts -- implicit counts ***\n");

// Third, bump ref counts for some implicit prolog references
for (lclNum = 0, varDsc = lvaTable; lclNum < lvaCount; lclNum++, varDsc++)
for (unsigned lclNum = 0; lclNum < lvaCount; lclNum++)
{
LclVarDsc* varDsc = lvaGetDesc(lclNum);
// Todo: review justification for these count bumps.
if (varDsc->lvIsRegArg)
{
Expand Down
52 changes: 33 additions & 19 deletions src/coreclr/jit/liveness.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,6 +55,7 @@ class Liveness
ComputeMemoryLiveness = false,
IsLIR = false,
IsEarly = false,
EliminateDeadCode = false,
};

Liveness(Compiler* compiler)
Expand DownExpand Up@@ -1965,16 +1966,19 @@ bool Liveness<TLiveness>::ComputeLifeTrackedLocalDef(VARSET_TP& life,
// Dead store
node->gtFlags |= GTF_VAR_DEATH;

// keepAliveVars always stay alive
noway_assert(!VarSetOps::IsMember(m_compiler, keepAliveVars, varIndex));
if (TLiveness::EliminateDeadCode)
{
// keepAliveVars always stay alive
noway_assert(!VarSetOps::IsMember(m_compiler, keepAliveVars, varIndex));

// Do not consider this store dead if the target local variable represents
// a promoted struct field of an address exposed local or if the address
// of the variable has been exposed. Improved alias analysis could allow
// stores to these sorts of variables to be removed at the cost of compile
// time.
return !varDsc.IsAddressExposed() &&
!(varDsc.lvIsStructField && m_compiler->lvaTable[varDsc.lvParentLcl].IsAddressExposed());
// Do not consider this store dead if the target local variable represents
// a promoted struct field of an address exposed local or if the address
// of the variable has been exposed. Improved alias analysis could allow
// stores to these sorts of variables to be removed at the cost of compile
// time.
return !varDsc.IsAddressExposed() &&
!(varDsc.lvIsStructField && m_compiler->lvaTable[varDsc.lvParentLcl].IsAddressExposed());
}
}

return false;
Expand DownExpand Up@@ -2011,7 +2015,7 @@ bool Liveness<TLiveness>::ComputeLifeUntrackedLocal(VARSET_TP& life,

// We have accurate ref counts when running late liveness so we can eliminate
// some stores if the lhs local has a ref count of 1.
if (isDef && TLiveness::IsLIR && (varDsc.lvRefCnt() == 1) && !varDsc.lvPinned)
if (TLiveness::EliminateDeadCode && TLiveness::IsLIR && isDef && (varDsc.lvRefCnt() == 1) && !varDsc.lvPinned)
{
if (varDsc.lvIsStructField)
{
Expand DownExpand Up@@ -2083,7 +2087,7 @@ bool Liveness<TLiveness>::ComputeLifeUntrackedLocal(VARSET_TP& life,
}
}

if (isDef && !anyFieldLive)
if (TLiveness::EliminateDeadCode && isDef && !anyFieldLive)
{
// Do not consider this store dead if the parent local variable is an address exposed local or
// if the struct has any significant padding we must retain the value of.
Expand DownExpand Up@@ -2328,7 +2332,8 @@ void Liveness<TLiveness>::ComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VAR
case GT_CALL:
{
GenTreeCall* const call = node->AsCall();
if ((call->TypeIs(TYP_VOID) || call->IsUnusedValue()) && !call->HasSideEffects(m_compiler))
if (TLiveness::EliminateDeadCode && (call->TypeIs(TYP_VOID) || call->IsUnusedValue()) &&
!call->HasSideEffects(m_compiler))
{
JITDUMP("Removing dead call:\n");
DISPNODE(call);
Expand DownExpand Up@@ -2375,13 +2380,13 @@ void Liveness<TLiveness>::ComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VAR
GenTreeLclVarCommon* const lclVarNode = node->AsLclVarCommon();
LclVarDsc& varDsc = m_compiler->lvaTable[lclVarNode->GetLclNum()];

if (node->IsUnusedValue())
if (TLiveness::EliminateDeadCode && node->IsUnusedValue())
{
JITDUMP("Removing dead LclVar use:\n");
DISPNODE(lclVarNode);

blockRange.Delete(m_compiler, block, node);
if (varDsc.lvTracked && !m_compiler->opts.MinOpts())
if (varDsc.lvTracked)
{
m_compiler->fgStmtRemoved = true;
}
Expand All@@ -2398,14 +2403,14 @@ void Liveness<TLiveness>::ComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VAR
}

case GT_LCL_ADDR:
if (node->IsUnusedValue())
if (TLiveness::EliminateDeadCode && node->IsUnusedValue())
{
JITDUMP("Removing dead LclVar address:\n");
DISPNODE(node);

const bool isTracked = m_compiler->lvaTable[node->AsLclVarCommon()->GetLclNum()].lvTracked;
blockRange.Delete(m_compiler, block, node);
if (isTracked && !m_compiler->opts.MinOpts())
if (isTracked)
{
m_compiler->fgStmtRemoved = true;
}
Expand All@@ -2423,7 +2428,7 @@ void Liveness<TLiveness>::ComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VAR
}

isDeadStore = ComputeLifeLocal(life, keepAliveVars, node);
if (isDeadStore)
if (TLiveness::EliminateDeadCode && isDeadStore)
{
LIR::Use addrUse;
if (blockRange.TryGetUse(node, &addrUse) && addrUse.User()->OperIs(GT_STOREIND, GT_STORE_BLK))
Expand DownExpand Up@@ -2464,7 +2469,7 @@ void Liveness<TLiveness>::ComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VAR
isDeadStore = ComputeLifeUntrackedLocal(life, keepAliveVars, varDsc, lclVarNode);
}

if (isDeadStore && TryRemoveDeadStoreLIR(node, lclVarNode, block))
if (TLiveness::EliminateDeadCode && isDeadStore && TryRemoveDeadStoreLIR(node, lclVarNode, block))
{
GenTree* value = lclVarNode->Data();
value->SetUnusedValue();
Expand All@@ -2491,7 +2496,7 @@ void Liveness<TLiveness>::ComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VAR
#endif // FEATURE_MASKED_HW_INTRINSICS
case GT_PHYSREG:
// These are all side-effect-free leaf nodes.
if (node->IsUnusedValue())
if (TLiveness::EliminateDeadCode && node->IsUnusedValue())
{
JITDUMP("Removing dead node:\n");
DISPNODE(node);
Expand DownExpand Up@@ -2693,6 +2698,11 @@ bool Liveness<TLiveness>::TryRemoveDeadStoreLIR(GenTree* store, GenTreeLclVarCom
template <typename TLiveness>
bool Liveness<TLiveness>::TryRemoveNonLocalLIR(GenTree* node, LIR::Range* blockRange)
{
if (!TLiveness::EliminateDeadCode)
{
return false;
}

assert(!node->OperIsLocal());
if (!node->IsValue() || node->IsUnusedValue())
{
Expand DownExpand Up@@ -2816,6 +2826,7 @@ void Compiler::fgSsaLiveness()
ComputeMemoryLiveness = true,
IsLIR = false,
IsEarly = false,
EliminateDeadCode = true,
};

SsaLivenessClass(Compiler* comp)
Expand All@@ -2841,6 +2852,7 @@ void Compiler::fgAsyncLiveness()
ComputeMemoryLiveness = false,
IsLIR = true,
IsEarly = false,
EliminateDeadCode = false,
};

AsyncLiveness(Compiler* comp)
Expand All@@ -2866,6 +2878,7 @@ void Compiler::fgPostLowerLiveness()
ComputeMemoryLiveness = false,
IsLIR = true,
IsEarly = false,
EliminateDeadCode = true,
};

PostLowerLiveness(Compiler* comp)
Expand DownExpand Up@@ -2909,6 +2922,7 @@ PhaseStatus Compiler::fgEarlyLiveness()
ComputeMemoryLiveness = false,
IsLIR = false,
IsEarly = true,
EliminateDeadCode = true,
};

EarlyLiveness(Compiler* comp)
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 34 additions & 22 deletions src/coreclr/jit/async.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -397,14 +397,12 @@ BasicBlock* Compiler::CreateReturnBB(unsigned* mergedReturnLcl)
class AsyncLiveness
{
Compiler* m_compiler;
bool m_hasLiveness;
TreeLifeUpdater<false> m_updater;
unsigned m_numVars;

public:
AsyncLiveness(Compiler* comp, bool hasLiveness)
AsyncLiveness(Compiler* comp)
: m_compiler(comp)
, m_hasLiveness(hasLiveness)
, m_updater(comp)
, m_numVars(comp->lvaCount)
{
Expand All@@ -430,9 +428,6 @@ class AsyncLiveness
//
void AsyncLiveness::StartBlock(BasicBlock* block)
{
if (!m_hasLiveness)
return;

VarSetOps::Assign(m_compiler, m_compiler->compCurLife, block->bbLiveIn);
}

Expand All@@ -446,9 +441,6 @@ void AsyncLiveness::StartBlock(BasicBlock* block)
//
void AsyncLiveness::Update(GenTree* node)
{
if (!m_hasLiveness)
return;

m_updater.UpdateLife(node);
}

Expand DownExpand Up@@ -539,8 +531,9 @@ bool AsyncLiveness::IsLive(unsigned lclNum)
return false;
}

if (!m_hasLiveness)
if (m_compiler->opts.compDbgCode && (lclNum < m_compiler->info.compLocalsCount))
{
// Keep all IL locals in debug codegen
Comment thread
jakobbotsch marked this conversation as resolved.
return true;
}

Expand DownExpand Up@@ -701,21 +694,18 @@ PhaseStatus AsyncTransformation::Run()
#endif

// Compute liveness to be used for determining what must be captured on
// suspension. In unoptimized codegen we capture everything.
if (m_compiler->opts.OptimizationEnabled())
// suspension.
if (m_compiler->m_dfsTree == nullptr)
{
if (m_compiler->m_dfsTree == nullptr)
{
m_compiler->m_dfsTree = m_compiler->fgComputeDfs<false>();
}

m_compiler->lvaComputeRefCounts(true, false);
m_compiler->fgAsyncLiveness();
INDEBUG(m_compiler->mostRecentlyActivePhase = PHASE_ASYNC);
VarSetOps::AssignNoCopy(m_compiler, m_compiler->compCurLife, VarSetOps::MakeEmpty(m_compiler));
m_compiler->m_dfsTree = m_compiler->fgComputeDfs<false>();
}

AsyncLiveness liveness(m_compiler, m_compiler->opts.OptimizationEnabled());
m_compiler->lvaComputePreciseRefCounts(/* isRecompute */ true, /* setSlotNumbers */ false);
m_compiler->fgAsyncLiveness();
INDEBUG(m_compiler->mostRecentlyActivePhase = PHASE_ASYNC);
VarSetOps::AssignNoCopy(m_compiler, m_compiler->compCurLife, VarSetOps::MakeEmpty(m_compiler));

AsyncLiveness liveness(m_compiler);

// Now walk the IR for all the blocks that contain async calls. Keep track
// of liveness and outstanding LIR edges as we go; the LIR edges that cross
Expand DownExpand Up@@ -783,6 +773,28 @@ PhaseStatus AsyncTransformation::Run()

m_compiler->fgInvalidateDfsTree();

if (m_compiler->opts.OptimizationDisabled())
{
// Rest of the compiler does not expect that we started tracking locals, so reset that state.
for (unsigned i = 0; i < m_compiler->lvaTrackedCount; i++)
{
m_compiler->lvaGetDesc(m_compiler->lvaTrackedToVarNum[i])->lvTracked = false;
}

m_compiler->lvaCurEpoch++;
m_compiler->lvaTrackedCount = 0;
m_compiler->lvaTrackedCountInSizeTUnits = 0;

for (BasicBlock* block : m_compiler->Blocks())
{
block->bbLiveIn = VarSetOps::UninitVal();
block->bbLiveOut = VarSetOps::UninitVal();
block->bbVarUse = VarSetOps::UninitVal();
block->bbVarDef = VarSetOps::UninitVal();
}
m_compiler->fgBBVarSetsInited = false;
}

return PhaseStatus::MODIFIED_EVERYTHING;
}

Expand Down
1 change: 1 addition & 0 deletions src/coreclr/jit/compiler.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -4214,6 +4214,7 @@ class Compiler

PhaseStatus lvaMarkLocalVars(); // Local variable ref-counting
void lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers);
void lvaComputePreciseRefCounts(bool isRecompute, bool setSlotNumbers);
void lvaMarkLocalVars(BasicBlock* block);

void lvaAllocOutgoingArgSpaceVar(); // Set up lvaOutgoingArgSpaceVar
Expand Down
38 changes: 28 additions & 10 deletions src/coreclr/jit/lclvars.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -3415,8 +3415,6 @@ PhaseStatus Compiler::lvaMarkLocalVars()
void Compiler::lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers)
{
JITDUMP("\n*** lvaComputeRefCounts ***\n");
unsigned lclNum = 0;
LclVarDsc* varDsc = nullptr;

// Fast path for minopts and debug codegen.
//
Expand All@@ -3430,8 +3428,9 @@ void Compiler::lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers)
#if defined(DEBUG)
// All local vars should be marked as implicitly referenced
// and not tracked.
for (lclNum = 0, varDsc = lvaTable; lclNum < lvaCount; lclNum++, varDsc++)
for (unsigned lclNum = 0; lclNum < lvaCount; lclNum++)
{
LclVarDsc* varDsc = lvaGetDesc(lclNum);
const bool isSpecialVarargsParam = varDsc->lvIsParam && lvaIsArgAccessedViaVarArgsCookie(lclNum);

if (isSpecialVarargsParam)
Expand All@@ -3451,8 +3450,9 @@ void Compiler::lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers)
}

// First compute.
for (lclNum = 0, varDsc = lvaTable; lclNum < lvaCount; lclNum++, varDsc++)
for (unsigned lclNum = 0; lclNum < lvaCount; lclNum++)
{
LclVarDsc* varDsc = lvaGetDesc(lclNum);
// Using lvImplicitlyReferenced here ensures that we can't
// accidentally make locals be unreferenced later by decrementing
// the ref count to zero.
Expand DownExpand Up@@ -3488,11 +3488,28 @@ void Compiler::lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers)
return;
}

// Slower path we take when optimizing, to get accurate counts.
//
lvaComputePreciseRefCounts(isRecompute, setSlotNumbers);
}

//------------------------------------------------------------------------
// lvaComputePreciseRefCounts: compute precise ref counts for locals by IR traversal
//
// Arguments:
// isRecompute -- true if we just want ref counts and no other side effects;
// false means to also look for true boolean locals, lay
// groundwork for assertion prop, check type consistency, etc.
// See lvaMarkLclRefs for details on what else goes on.
// setSlotNumbers -- true if local slot numbers should be assigned.
//
// Notes:
// See notes on lvaComputeRefCounts.
//
void Compiler::lvaComputePreciseRefCounts(bool isRecompute, bool setSlotNumbers)
{
// First, reset all explicit ref counts and weights.
for (lclNum = 0, varDsc = lvaTable; lclNum < lvaCount; lclNum++, varDsc++)
for (unsigned lclNum = 0; lclNum < lvaCount; lclNum++)
{
LclVarDsc* varDsc = lvaGetDesc(lclNum);
varDsc->setLvRefCnt(0);
varDsc->setLvRefCntWtd(BB_ZERO_WEIGHT);

Expand All@@ -3519,7 +3536,7 @@ void Compiler::lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers)
const bool oldLvaGenericsContextInUse = lvaGenericsContextInUse;
lvaGenericsContextInUse = false;

JITDUMP("\n*** lvaComputeRefCounts -- explicit counts ***\n");
JITDUMP("\n*** lvaComputePreciseRefCounts -- explicit counts ***\n");

// Second, account for all explicit local variable references
for (BasicBlock* const block : Blocks())
Expand DownExpand Up@@ -3577,11 +3594,12 @@ void Compiler::lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers)
assert(!"unexpected new use of generics context");
}

JITDUMP("\n*** lvaComputeRefCounts -- implicit counts ***\n");
JITDUMP("\n*** lvaComputePreciseRefCounts -- implicit counts ***\n");

// Third, bump ref counts for some implicit prolog references
for (lclNum = 0, varDsc = lvaTable; lclNum < lvaCount; lclNum++, varDsc++)
for (unsigned lclNum = 0; lclNum < lvaCount; lclNum++)
{
LclVarDsc* varDsc = lvaGetDesc(lclNum);
// Todo: review justification for these count bumps.
if (varDsc->lvIsRegArg)
{
Expand Down
52 changes: 33 additions & 19 deletions src/coreclr/jit/liveness.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,6 +55,7 @@ class Liveness
ComputeMemoryLiveness = false,
IsLIR = false,
IsEarly = false,
EliminateDeadCode = false,
};

Liveness(Compiler* compiler)
Expand DownExpand Up@@ -1965,16 +1966,19 @@ bool Liveness<TLiveness>::ComputeLifeTrackedLocalDef(VARSET_TP& life,
// Dead store
node->gtFlags |= GTF_VAR_DEATH;

// keepAliveVars always stay alive
noway_assert(!VarSetOps::IsMember(m_compiler, keepAliveVars, varIndex));
if (TLiveness::EliminateDeadCode)
{
// keepAliveVars always stay alive
noway_assert(!VarSetOps::IsMember(m_compiler, keepAliveVars, varIndex));

// Do not consider this store dead if the target local variable represents
// a promoted struct field of an address exposed local or if the address
// of the variable has been exposed. Improved alias analysis could allow
// stores to these sorts of variables to be removed at the cost of compile
// time.
return !varDsc.IsAddressExposed() &&
!(varDsc.lvIsStructField && m_compiler->lvaTable[varDsc.lvParentLcl].IsAddressExposed());
// Do not consider this store dead if the target local variable represents
// a promoted struct field of an address exposed local or if the address
// of the variable has been exposed. Improved alias analysis could allow
// stores to these sorts of variables to be removed at the cost of compile
// time.
return !varDsc.IsAddressExposed() &&
!(varDsc.lvIsStructField && m_compiler->lvaTable[varDsc.lvParentLcl].IsAddressExposed());
}
}

return false;
Expand DownExpand Up@@ -2011,7 +2015,7 @@ bool Liveness<TLiveness>::ComputeLifeUntrackedLocal(VARSET_TP& life,

// We have accurate ref counts when running late liveness so we can eliminate
// some stores if the lhs local has a ref count of 1.
if (isDef && TLiveness::IsLIR && (varDsc.lvRefCnt() == 1) && !varDsc.lvPinned)
if (TLiveness::EliminateDeadCode && TLiveness::IsLIR && isDef && (varDsc.lvRefCnt() == 1) && !varDsc.lvPinned)
{
if (varDsc.lvIsStructField)
{
Expand DownExpand Up@@ -2083,7 +2087,7 @@ bool Liveness<TLiveness>::ComputeLifeUntrackedLocal(VARSET_TP& life,
}
}

if (isDef && !anyFieldLive)
if (TLiveness::EliminateDeadCode && isDef && !anyFieldLive)
{
// Do not consider this store dead if the parent local variable is an address exposed local or
// if the struct has any significant padding we must retain the value of.
Expand DownExpand Up@@ -2328,7 +2332,8 @@ void Liveness<TLiveness>::ComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VAR
case GT_CALL:
{
GenTreeCall* const call = node->AsCall();
if ((call->TypeIs(TYP_VOID) || call->IsUnusedValue()) && !call->HasSideEffects(m_compiler))
if (TLiveness::EliminateDeadCode && (call->TypeIs(TYP_VOID) || call->IsUnusedValue()) &&
!call->HasSideEffects(m_compiler))
{
JITDUMP("Removing dead call:\n");
DISPNODE(call);
Expand DownExpand Up@@ -2375,13 +2380,13 @@ void Liveness<TLiveness>::ComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VAR
GenTreeLclVarCommon* const lclVarNode = node->AsLclVarCommon();
LclVarDsc& varDsc = m_compiler->lvaTable[lclVarNode->GetLclNum()];

if (node->IsUnusedValue())
if (TLiveness::EliminateDeadCode && node->IsUnusedValue())
{
JITDUMP("Removing dead LclVar use:\n");
DISPNODE(lclVarNode);

blockRange.Delete(m_compiler, block, node);
if (varDsc.lvTracked && !m_compiler->opts.MinOpts())
if (varDsc.lvTracked)
{
m_compiler->fgStmtRemoved = true;
}
Expand All@@ -2398,14 +2403,14 @@ void Liveness<TLiveness>::ComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VAR
}

case GT_LCL_ADDR:
if (node->IsUnusedValue())
if (TLiveness::EliminateDeadCode && node->IsUnusedValue())
{
JITDUMP("Removing dead LclVar address:\n");
DISPNODE(node);

const bool isTracked = m_compiler->lvaTable[node->AsLclVarCommon()->GetLclNum()].lvTracked;
blockRange.Delete(m_compiler, block, node);
if (isTracked && !m_compiler->opts.MinOpts())
if (isTracked)
{
m_compiler->fgStmtRemoved = true;
}
Expand All@@ -2423,7 +2428,7 @@ void Liveness<TLiveness>::ComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VAR
}

isDeadStore = ComputeLifeLocal(life, keepAliveVars, node);
if (isDeadStore)
if (TLiveness::EliminateDeadCode && isDeadStore)
{
LIR::Use addrUse;
if (blockRange.TryGetUse(node, &addrUse) && addrUse.User()->OperIs(GT_STOREIND, GT_STORE_BLK))
Expand DownExpand Up@@ -2464,7 +2469,7 @@ void Liveness<TLiveness>::ComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VAR
isDeadStore = ComputeLifeUntrackedLocal(life, keepAliveVars, varDsc, lclVarNode);
}

if (isDeadStore && TryRemoveDeadStoreLIR(node, lclVarNode, block))
if (TLiveness::EliminateDeadCode && isDeadStore && TryRemoveDeadStoreLIR(node, lclVarNode, block))
{
GenTree* value = lclVarNode->Data();
value->SetUnusedValue();
Expand All@@ -2491,7 +2496,7 @@ void Liveness<TLiveness>::ComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VAR
#endif // FEATURE_MASKED_HW_INTRINSICS
case GT_PHYSREG:
// These are all side-effect-free leaf nodes.
if (node->IsUnusedValue())
if (TLiveness::EliminateDeadCode && node->IsUnusedValue())
{
JITDUMP("Removing dead node:\n");
DISPNODE(node);
Expand DownExpand Up@@ -2693,6 +2698,11 @@ bool Liveness<TLiveness>::TryRemoveDeadStoreLIR(GenTree* store, GenTreeLclVarCom
template <typename TLiveness>
bool Liveness<TLiveness>::TryRemoveNonLocalLIR(GenTree* node, LIR::Range* blockRange)
{
if (!TLiveness::EliminateDeadCode)
{
return false;
}

assert(!node->OperIsLocal());
if (!node->IsValue() || node->IsUnusedValue())
{
Expand DownExpand Up@@ -2816,6 +2826,7 @@ void Compiler::fgSsaLiveness()
ComputeMemoryLiveness = true,
IsLIR = false,
IsEarly = false,
EliminateDeadCode = true,
};

SsaLivenessClass(Compiler* comp)
Expand All@@ -2841,6 +2852,7 @@ void Compiler::fgAsyncLiveness()
ComputeMemoryLiveness = false,
IsLIR = true,
IsEarly = false,
EliminateDeadCode = false,
};

AsyncLiveness(Compiler* comp)
Expand All@@ -2866,6 +2878,7 @@ void Compiler::fgPostLowerLiveness()
ComputeMemoryLiveness = false,
IsLIR = true,
IsEarly = false,
EliminateDeadCode = true,
};

PostLowerLiveness(Compiler* comp)
Expand DownExpand Up@@ -2909,6 +2922,7 @@ PhaseStatus Compiler::fgEarlyLiveness()
ComputeMemoryLiveness = false,
IsLIR = false,
IsEarly = true,
EliminateDeadCode = true,
};

EarlyLiveness(Compiler* comp)
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 34 additions & 22 deletions src/coreclr/jit/async.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -397,14 +397,12 @@ BasicBlock* Compiler::CreateReturnBB(unsigned* mergedReturnLcl)
class AsyncLiveness
{
Compiler* m_compiler;
bool m_hasLiveness;
TreeLifeUpdater<false> m_updater;
unsigned m_numVars;

public:
AsyncLiveness(Compiler* comp, bool hasLiveness)
AsyncLiveness(Compiler* comp)
: m_compiler(comp)
, m_hasLiveness(hasLiveness)
, m_updater(comp)
, m_numVars(comp->lvaCount)
{
Expand All@@ -430,9 +428,6 @@ class AsyncLiveness
//
void AsyncLiveness::StartBlock(BasicBlock* block)
{
if (!m_hasLiveness)
return;

VarSetOps::Assign(m_compiler, m_compiler->compCurLife, block->bbLiveIn);
}

Expand All@@ -446,9 +441,6 @@ void AsyncLiveness::StartBlock(BasicBlock* block)
//
void AsyncLiveness::Update(GenTree* node)
{
if (!m_hasLiveness)
return;

m_updater.UpdateLife(node);
}

Expand DownExpand Up@@ -539,8 +531,9 @@ bool AsyncLiveness::IsLive(unsigned lclNum)
return false;
}

if (!m_hasLiveness)
if (m_compiler->opts.compDbgCode && (lclNum < m_compiler->info.compLocalsCount))
{
// Keep all IL locals in debug codegen
Comment thread
jakobbotsch marked this conversation as resolved.
return true;
}

Expand DownExpand Up@@ -701,21 +694,18 @@ PhaseStatus AsyncTransformation::Run()
#endif

// Compute liveness to be used for determining what must be captured on
// suspension. In unoptimized codegen we capture everything.
if (m_compiler->opts.OptimizationEnabled())
// suspension.
if (m_compiler->m_dfsTree == nullptr)
{
if (m_compiler->m_dfsTree == nullptr)
{
m_compiler->m_dfsTree = m_compiler->fgComputeDfs<false>();
}

m_compiler->lvaComputeRefCounts(true, false);
m_compiler->fgAsyncLiveness();
INDEBUG(m_compiler->mostRecentlyActivePhase = PHASE_ASYNC);
VarSetOps::AssignNoCopy(m_compiler, m_compiler->compCurLife, VarSetOps::MakeEmpty(m_compiler));
m_compiler->m_dfsTree = m_compiler->fgComputeDfs<false>();
}

AsyncLiveness liveness(m_compiler, m_compiler->opts.OptimizationEnabled());
m_compiler->lvaComputePreciseRefCounts(/* isRecompute */ true, /* setSlotNumbers */ false);
m_compiler->fgAsyncLiveness();
INDEBUG(m_compiler->mostRecentlyActivePhase = PHASE_ASYNC);
VarSetOps::AssignNoCopy(m_compiler, m_compiler->compCurLife, VarSetOps::MakeEmpty(m_compiler));

AsyncLiveness liveness(m_compiler);

// Now walk the IR for all the blocks that contain async calls. Keep track
// of liveness and outstanding LIR edges as we go; the LIR edges that cross
Expand DownExpand Up@@ -783,6 +773,28 @@ PhaseStatus AsyncTransformation::Run()

m_compiler->fgInvalidateDfsTree();

if (m_compiler->opts.OptimizationDisabled())
{
// Rest of the compiler does not expect that we started tracking locals, so reset that state.
for (unsigned i = 0; i < m_compiler->lvaTrackedCount; i++)
{
m_compiler->lvaGetDesc(m_compiler->lvaTrackedToVarNum[i])->lvTracked = false;
}

m_compiler->lvaCurEpoch++;
m_compiler->lvaTrackedCount = 0;
m_compiler->lvaTrackedCountInSizeTUnits = 0;

for (BasicBlock* block : m_compiler->Blocks())
{
block->bbLiveIn = VarSetOps::UninitVal();
block->bbLiveOut = VarSetOps::UninitVal();
block->bbVarUse = VarSetOps::UninitVal();
block->bbVarDef = VarSetOps::UninitVal();
}
m_compiler->fgBBVarSetsInited = false;
}

return PhaseStatus::MODIFIED_EVERYTHING;
}

Expand Down
1 change: 1 addition & 0 deletions src/coreclr/jit/compiler.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -4214,6 +4214,7 @@ class Compiler

PhaseStatus lvaMarkLocalVars(); // Local variable ref-counting
void lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers);
void lvaComputePreciseRefCounts(bool isRecompute, bool setSlotNumbers);
void lvaMarkLocalVars(BasicBlock* block);

void lvaAllocOutgoingArgSpaceVar(); // Set up lvaOutgoingArgSpaceVar
Expand Down
38 changes: 28 additions & 10 deletions src/coreclr/jit/lclvars.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -3415,8 +3415,6 @@ PhaseStatus Compiler::lvaMarkLocalVars()
void Compiler::lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers)
{
JITDUMP("\n*** lvaComputeRefCounts ***\n");
unsigned lclNum = 0;
LclVarDsc* varDsc = nullptr;

// Fast path for minopts and debug codegen.
//
Expand All@@ -3430,8 +3428,9 @@ void Compiler::lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers)
#if defined(DEBUG)
// All local vars should be marked as implicitly referenced
// and not tracked.
for (lclNum = 0, varDsc = lvaTable; lclNum < lvaCount; lclNum++, varDsc++)
for (unsigned lclNum = 0; lclNum < lvaCount; lclNum++)
{
LclVarDsc* varDsc = lvaGetDesc(lclNum);
const bool isSpecialVarargsParam = varDsc->lvIsParam && lvaIsArgAccessedViaVarArgsCookie(lclNum);

if (isSpecialVarargsParam)
Expand All@@ -3451,8 +3450,9 @@ void Compiler::lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers)
}

// First compute.
for (lclNum = 0, varDsc = lvaTable; lclNum < lvaCount; lclNum++, varDsc++)
for (unsigned lclNum = 0; lclNum < lvaCount; lclNum++)
{
LclVarDsc* varDsc = lvaGetDesc(lclNum);
// Using lvImplicitlyReferenced here ensures that we can't
// accidentally make locals be unreferenced later by decrementing
// the ref count to zero.
Expand DownExpand Up@@ -3488,11 +3488,28 @@ void Compiler::lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers)
return;
}

// Slower path we take when optimizing, to get accurate counts.
//
lvaComputePreciseRefCounts(isRecompute, setSlotNumbers);
}

//------------------------------------------------------------------------
// lvaComputePreciseRefCounts: compute precise ref counts for locals by IR traversal
//
// Arguments:
// isRecompute -- true if we just want ref counts and no other side effects;
// false means to also look for true boolean locals, lay
// groundwork for assertion prop, check type consistency, etc.
// See lvaMarkLclRefs for details on what else goes on.
// setSlotNumbers -- true if local slot numbers should be assigned.
//
// Notes:
// See notes on lvaComputeRefCounts.
//
void Compiler::lvaComputePreciseRefCounts(bool isRecompute, bool setSlotNumbers)
{
// First, reset all explicit ref counts and weights.
for (lclNum = 0, varDsc = lvaTable; lclNum < lvaCount; lclNum++, varDsc++)
for (unsigned lclNum = 0; lclNum < lvaCount; lclNum++)
{
LclVarDsc* varDsc = lvaGetDesc(lclNum);
varDsc->setLvRefCnt(0);
varDsc->setLvRefCntWtd(BB_ZERO_WEIGHT);

Expand All@@ -3519,7 +3536,7 @@ void Compiler::lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers)
const bool oldLvaGenericsContextInUse = lvaGenericsContextInUse;
lvaGenericsContextInUse = false;

JITDUMP("\n*** lvaComputeRefCounts -- explicit counts ***\n");
JITDUMP("\n*** lvaComputePreciseRefCounts -- explicit counts ***\n");

// Second, account for all explicit local variable references
for (BasicBlock* const block : Blocks())
Expand DownExpand Up@@ -3577,11 +3594,12 @@ void Compiler::lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers)
assert(!"unexpected new use of generics context");
}

JITDUMP("\n*** lvaComputeRefCounts -- implicit counts ***\n");
JITDUMP("\n*** lvaComputePreciseRefCounts -- implicit counts ***\n");

// Third, bump ref counts for some implicit prolog references
for (lclNum = 0, varDsc = lvaTable; lclNum < lvaCount; lclNum++, varDsc++)
for (unsigned lclNum = 0; lclNum < lvaCount; lclNum++)
{
LclVarDsc* varDsc = lvaGetDesc(lclNum);
// Todo: review justification for these count bumps.
if (varDsc->lvIsRegArg)
{
Expand Down
52 changes: 33 additions & 19 deletions src/coreclr/jit/liveness.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,6 +55,7 @@ class Liveness
ComputeMemoryLiveness = false,
IsLIR = false,
IsEarly = false,
EliminateDeadCode = false,
};

Liveness(Compiler* compiler)
Expand DownExpand Up@@ -1965,16 +1966,19 @@ bool Liveness<TLiveness>::ComputeLifeTrackedLocalDef(VARSET_TP& life,
// Dead store
node->gtFlags |= GTF_VAR_DEATH;

// keepAliveVars always stay alive
noway_assert(!VarSetOps::IsMember(m_compiler, keepAliveVars, varIndex));
if (TLiveness::EliminateDeadCode)
{
// keepAliveVars always stay alive
noway_assert(!VarSetOps::IsMember(m_compiler, keepAliveVars, varIndex));

// Do not consider this store dead if the target local variable represents
// a promoted struct field of an address exposed local or if the address
// of the variable has been exposed. Improved alias analysis could allow
// stores to these sorts of variables to be removed at the cost of compile
// time.
return !varDsc.IsAddressExposed() &&
!(varDsc.lvIsStructField && m_compiler->lvaTable[varDsc.lvParentLcl].IsAddressExposed());
// Do not consider this store dead if the target local variable represents
// a promoted struct field of an address exposed local or if the address
// of the variable has been exposed. Improved alias analysis could allow
// stores to these sorts of variables to be removed at the cost of compile
// time.
return !varDsc.IsAddressExposed() &&
!(varDsc.lvIsStructField && m_compiler->lvaTable[varDsc.lvParentLcl].IsAddressExposed());
}
}

return false;
Expand DownExpand Up@@ -2011,7 +2015,7 @@ bool Liveness<TLiveness>::ComputeLifeUntrackedLocal(VARSET_TP& life,

// We have accurate ref counts when running late liveness so we can eliminate
// some stores if the lhs local has a ref count of 1.
if (isDef && TLiveness::IsLIR && (varDsc.lvRefCnt() == 1) && !varDsc.lvPinned)
if (TLiveness::EliminateDeadCode && TLiveness::IsLIR && isDef && (varDsc.lvRefCnt() == 1) && !varDsc.lvPinned)
{
if (varDsc.lvIsStructField)
{
Expand DownExpand Up@@ -2083,7 +2087,7 @@ bool Liveness<TLiveness>::ComputeLifeUntrackedLocal(VARSET_TP& life,
}
}

if (isDef && !anyFieldLive)
if (TLiveness::EliminateDeadCode && isDef && !anyFieldLive)
{
// Do not consider this store dead if the parent local variable is an address exposed local or
// if the struct has any significant padding we must retain the value of.
Expand DownExpand Up@@ -2328,7 +2332,8 @@ void Liveness<TLiveness>::ComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VAR
case GT_CALL:
{
GenTreeCall* const call = node->AsCall();
if ((call->TypeIs(TYP_VOID) || call->IsUnusedValue()) && !call->HasSideEffects(m_compiler))
if (TLiveness::EliminateDeadCode && (call->TypeIs(TYP_VOID) || call->IsUnusedValue()) &&
!call->HasSideEffects(m_compiler))
{
JITDUMP("Removing dead call:\n");
DISPNODE(call);
Expand DownExpand Up@@ -2375,13 +2380,13 @@ void Liveness<TLiveness>::ComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VAR
GenTreeLclVarCommon* const lclVarNode = node->AsLclVarCommon();
LclVarDsc& varDsc = m_compiler->lvaTable[lclVarNode->GetLclNum()];

if (node->IsUnusedValue())
if (TLiveness::EliminateDeadCode && node->IsUnusedValue())
{
JITDUMP("Removing dead LclVar use:\n");
DISPNODE(lclVarNode);

blockRange.Delete(m_compiler, block, node);
if (varDsc.lvTracked && !m_compiler->opts.MinOpts())
if (varDsc.lvTracked)
{
m_compiler->fgStmtRemoved = true;
}
Expand All@@ -2398,14 +2403,14 @@ void Liveness<TLiveness>::ComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VAR
}

case GT_LCL_ADDR:
if (node->IsUnusedValue())
if (TLiveness::EliminateDeadCode && node->IsUnusedValue())
{
JITDUMP("Removing dead LclVar address:\n");
DISPNODE(node);

const bool isTracked = m_compiler->lvaTable[node->AsLclVarCommon()->GetLclNum()].lvTracked;
blockRange.Delete(m_compiler, block, node);
if (isTracked && !m_compiler->opts.MinOpts())
if (isTracked)
{
m_compiler->fgStmtRemoved = true;
}
Expand All@@ -2423,7 +2428,7 @@ void Liveness<TLiveness>::ComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VAR
}

isDeadStore = ComputeLifeLocal(life, keepAliveVars, node);
if (isDeadStore)
if (TLiveness::EliminateDeadCode && isDeadStore)
{
LIR::Use addrUse;
if (blockRange.TryGetUse(node, &addrUse) && addrUse.User()->OperIs(GT_STOREIND, GT_STORE_BLK))
Expand DownExpand Up@@ -2464,7 +2469,7 @@ void Liveness<TLiveness>::ComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VAR
isDeadStore = ComputeLifeUntrackedLocal(life, keepAliveVars, varDsc, lclVarNode);
}

if (isDeadStore && TryRemoveDeadStoreLIR(node, lclVarNode, block))
if (TLiveness::EliminateDeadCode && isDeadStore && TryRemoveDeadStoreLIR(node, lclVarNode, block))
{
GenTree* value = lclVarNode->Data();
value->SetUnusedValue();
Expand All@@ -2491,7 +2496,7 @@ void Liveness<TLiveness>::ComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VAR
#endif // FEATURE_MASKED_HW_INTRINSICS
case GT_PHYSREG:
// These are all side-effect-free leaf nodes.
if (node->IsUnusedValue())
if (TLiveness::EliminateDeadCode && node->IsUnusedValue())
{
JITDUMP("Removing dead node:\n");
DISPNODE(node);
Expand DownExpand Up@@ -2693,6 +2698,11 @@ bool Liveness<TLiveness>::TryRemoveDeadStoreLIR(GenTree* store, GenTreeLclVarCom
template <typename TLiveness>
bool Liveness<TLiveness>::TryRemoveNonLocalLIR(GenTree* node, LIR::Range* blockRange)
{
if (!TLiveness::EliminateDeadCode)
{
return false;
}

assert(!node->OperIsLocal());
if (!node->IsValue() || node->IsUnusedValue())
{
Expand DownExpand Up@@ -2816,6 +2826,7 @@ void Compiler::fgSsaLiveness()
ComputeMemoryLiveness = true,
IsLIR = false,
IsEarly = false,
EliminateDeadCode = true,
};

SsaLivenessClass(Compiler* comp)
Expand All@@ -2841,6 +2852,7 @@ void Compiler::fgAsyncLiveness()
ComputeMemoryLiveness = false,
IsLIR = true,
IsEarly = false,
EliminateDeadCode = false,
};

AsyncLiveness(Compiler* comp)
Expand All@@ -2866,6 +2878,7 @@ void Compiler::fgPostLowerLiveness()
ComputeMemoryLiveness = false,
IsLIR = true,
IsEarly = false,
EliminateDeadCode = true,
};

PostLowerLiveness(Compiler* comp)
Expand DownExpand Up@@ -2909,6 +2922,7 @@ PhaseStatus Compiler::fgEarlyLiveness()
ComputeMemoryLiveness = false,
IsLIR = false,
IsEarly = true,
EliminateDeadCode = true,
};

EarlyLiveness(Compiler* comp)
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 34 additions & 22 deletions src/coreclr/jit/async.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -397,14 +397,12 @@ BasicBlock* Compiler::CreateReturnBB(unsigned* mergedReturnLcl)
class AsyncLiveness
{
Compiler* m_compiler;
bool m_hasLiveness;
TreeLifeUpdater<false> m_updater;
unsigned m_numVars;

public:
AsyncLiveness(Compiler* comp, bool hasLiveness)
AsyncLiveness(Compiler* comp)
: m_compiler(comp)
, m_hasLiveness(hasLiveness)
, m_updater(comp)
, m_numVars(comp->lvaCount)
{
Expand All@@ -430,9 +428,6 @@ class AsyncLiveness
//
void AsyncLiveness::StartBlock(BasicBlock* block)
{
if (!m_hasLiveness)
return;

VarSetOps::Assign(m_compiler, m_compiler->compCurLife, block->bbLiveIn);
}

Expand All@@ -446,9 +441,6 @@ void AsyncLiveness::StartBlock(BasicBlock* block)
//
void AsyncLiveness::Update(GenTree* node)
{
if (!m_hasLiveness)
return;

m_updater.UpdateLife(node);
}

Expand DownExpand Up@@ -539,8 +531,9 @@ bool AsyncLiveness::IsLive(unsigned lclNum)
return false;
}

if (!m_hasLiveness)
if (m_compiler->opts.compDbgCode && (lclNum < m_compiler->info.compLocalsCount))
{
// Keep all IL locals in debug codegen
Comment thread
jakobbotsch marked this conversation as resolved.
return true;
}

Expand DownExpand Up@@ -701,21 +694,18 @@ PhaseStatus AsyncTransformation::Run()
#endif

// Compute liveness to be used for determining what must be captured on
// suspension. In unoptimized codegen we capture everything.
if (m_compiler->opts.OptimizationEnabled())
// suspension.
if (m_compiler->m_dfsTree == nullptr)
{
if (m_compiler->m_dfsTree == nullptr)
{
m_compiler->m_dfsTree = m_compiler->fgComputeDfs<false>();
}

m_compiler->lvaComputeRefCounts(true, false);
m_compiler->fgAsyncLiveness();
INDEBUG(m_compiler->mostRecentlyActivePhase = PHASE_ASYNC);
VarSetOps::AssignNoCopy(m_compiler, m_compiler->compCurLife, VarSetOps::MakeEmpty(m_compiler));
m_compiler->m_dfsTree = m_compiler->fgComputeDfs<false>();
}

AsyncLiveness liveness(m_compiler, m_compiler->opts.OptimizationEnabled());
m_compiler->lvaComputePreciseRefCounts(/* isRecompute */ true, /* setSlotNumbers */ false);
m_compiler->fgAsyncLiveness();
INDEBUG(m_compiler->mostRecentlyActivePhase = PHASE_ASYNC);
VarSetOps::AssignNoCopy(m_compiler, m_compiler->compCurLife, VarSetOps::MakeEmpty(m_compiler));

AsyncLiveness liveness(m_compiler);

// Now walk the IR for all the blocks that contain async calls. Keep track
// of liveness and outstanding LIR edges as we go; the LIR edges that cross
Expand DownExpand Up@@ -783,6 +773,28 @@ PhaseStatus AsyncTransformation::Run()

m_compiler->fgInvalidateDfsTree();

if (m_compiler->opts.OptimizationDisabled())
{
// Rest of the compiler does not expect that we started tracking locals, so reset that state.
for (unsigned i = 0; i < m_compiler->lvaTrackedCount; i++)
{
m_compiler->lvaGetDesc(m_compiler->lvaTrackedToVarNum[i])->lvTracked = false;
}

m_compiler->lvaCurEpoch++;
m_compiler->lvaTrackedCount = 0;
m_compiler->lvaTrackedCountInSizeTUnits = 0;

for (BasicBlock* block : m_compiler->Blocks())
{
block->bbLiveIn = VarSetOps::UninitVal();
block->bbLiveOut = VarSetOps::UninitVal();
block->bbVarUse = VarSetOps::UninitVal();
block->bbVarDef = VarSetOps::UninitVal();
}
m_compiler->fgBBVarSetsInited = false;
}

return PhaseStatus::MODIFIED_EVERYTHING;
}

Expand Down
1 change: 1 addition & 0 deletions src/coreclr/jit/compiler.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -4214,6 +4214,7 @@ class Compiler

PhaseStatus lvaMarkLocalVars(); // Local variable ref-counting
void lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers);
void lvaComputePreciseRefCounts(bool isRecompute, bool setSlotNumbers);
void lvaMarkLocalVars(BasicBlock* block);

void lvaAllocOutgoingArgSpaceVar(); // Set up lvaOutgoingArgSpaceVar
Expand Down
38 changes: 28 additions & 10 deletions src/coreclr/jit/lclvars.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -3415,8 +3415,6 @@ PhaseStatus Compiler::lvaMarkLocalVars()
void Compiler::lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers)
{
JITDUMP("\n*** lvaComputeRefCounts ***\n");
unsigned lclNum = 0;
LclVarDsc* varDsc = nullptr;

// Fast path for minopts and debug codegen.
//
Expand All@@ -3430,8 +3428,9 @@ void Compiler::lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers)
#if defined(DEBUG)
// All local vars should be marked as implicitly referenced
// and not tracked.
for (lclNum = 0, varDsc = lvaTable; lclNum < lvaCount; lclNum++, varDsc++)
for (unsigned lclNum = 0; lclNum < lvaCount; lclNum++)
{
LclVarDsc* varDsc = lvaGetDesc(lclNum);
const bool isSpecialVarargsParam = varDsc->lvIsParam && lvaIsArgAccessedViaVarArgsCookie(lclNum);

if (isSpecialVarargsParam)
Expand All@@ -3451,8 +3450,9 @@ void Compiler::lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers)
}

// First compute.
for (lclNum = 0, varDsc = lvaTable; lclNum < lvaCount; lclNum++, varDsc++)
for (unsigned lclNum = 0; lclNum < lvaCount; lclNum++)
{
LclVarDsc* varDsc = lvaGetDesc(lclNum);
// Using lvImplicitlyReferenced here ensures that we can't
// accidentally make locals be unreferenced later by decrementing
// the ref count to zero.
Expand DownExpand Up@@ -3488,11 +3488,28 @@ void Compiler::lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers)
return;
}

// Slower path we take when optimizing, to get accurate counts.
//
lvaComputePreciseRefCounts(isRecompute, setSlotNumbers);
}

//------------------------------------------------------------------------
// lvaComputePreciseRefCounts: compute precise ref counts for locals by IR traversal
//
// Arguments:
// isRecompute -- true if we just want ref counts and no other side effects;
// false means to also look for true boolean locals, lay
// groundwork for assertion prop, check type consistency, etc.
// See lvaMarkLclRefs for details on what else goes on.
// setSlotNumbers -- true if local slot numbers should be assigned.
//
// Notes:
// See notes on lvaComputeRefCounts.
//
void Compiler::lvaComputePreciseRefCounts(bool isRecompute, bool setSlotNumbers)
{
// First, reset all explicit ref counts and weights.
for (lclNum = 0, varDsc = lvaTable; lclNum < lvaCount; lclNum++, varDsc++)
for (unsigned lclNum = 0; lclNum < lvaCount; lclNum++)
{
LclVarDsc* varDsc = lvaGetDesc(lclNum);
varDsc->setLvRefCnt(0);
varDsc->setLvRefCntWtd(BB_ZERO_WEIGHT);

Expand All@@ -3519,7 +3536,7 @@ void Compiler::lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers)
const bool oldLvaGenericsContextInUse = lvaGenericsContextInUse;
lvaGenericsContextInUse = false;

JITDUMP("\n*** lvaComputeRefCounts -- explicit counts ***\n");
JITDUMP("\n*** lvaComputePreciseRefCounts -- explicit counts ***\n");

// Second, account for all explicit local variable references
for (BasicBlock* const block : Blocks())
Expand DownExpand Up@@ -3577,11 +3594,12 @@ void Compiler::lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers)
assert(!"unexpected new use of generics context");
}

JITDUMP("\n*** lvaComputeRefCounts -- implicit counts ***\n");
JITDUMP("\n*** lvaComputePreciseRefCounts -- implicit counts ***\n");

// Third, bump ref counts for some implicit prolog references
for (lclNum = 0, varDsc = lvaTable; lclNum < lvaCount; lclNum++, varDsc++)
for (unsigned lclNum = 0; lclNum < lvaCount; lclNum++)
{
LclVarDsc* varDsc = lvaGetDesc(lclNum);
// Todo: review justification for these count bumps.
if (varDsc->lvIsRegArg)
{
Expand Down
52 changes: 33 additions & 19 deletions src/coreclr/jit/liveness.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,6 +55,7 @@ class Liveness
ComputeMemoryLiveness = false,
IsLIR = false,
IsEarly = false,
EliminateDeadCode = false,
};

Liveness(Compiler* compiler)
Expand DownExpand Up@@ -1965,16 +1966,19 @@ bool Liveness<TLiveness>::ComputeLifeTrackedLocalDef(VARSET_TP& life,
// Dead store
node->gtFlags |= GTF_VAR_DEATH;

// keepAliveVars always stay alive
noway_assert(!VarSetOps::IsMember(m_compiler, keepAliveVars, varIndex));
if (TLiveness::EliminateDeadCode)
{
// keepAliveVars always stay alive
noway_assert(!VarSetOps::IsMember(m_compiler, keepAliveVars, varIndex));

// Do not consider this store dead if the target local variable represents
// a promoted struct field of an address exposed local or if the address
// of the variable has been exposed. Improved alias analysis could allow
// stores to these sorts of variables to be removed at the cost of compile
// time.
return !varDsc.IsAddressExposed() &&
!(varDsc.lvIsStructField && m_compiler->lvaTable[varDsc.lvParentLcl].IsAddressExposed());
// Do not consider this store dead if the target local variable represents
// a promoted struct field of an address exposed local or if the address
// of the variable has been exposed. Improved alias analysis could allow
// stores to these sorts of variables to be removed at the cost of compile
// time.
return !varDsc.IsAddressExposed() &&
!(varDsc.lvIsStructField && m_compiler->lvaTable[varDsc.lvParentLcl].IsAddressExposed());
}
}

return false;
Expand DownExpand Up@@ -2011,7 +2015,7 @@ bool Liveness<TLiveness>::ComputeLifeUntrackedLocal(VARSET_TP& life,

// We have accurate ref counts when running late liveness so we can eliminate
// some stores if the lhs local has a ref count of 1.
if (isDef && TLiveness::IsLIR && (varDsc.lvRefCnt() == 1) && !varDsc.lvPinned)
if (TLiveness::EliminateDeadCode && TLiveness::IsLIR && isDef && (varDsc.lvRefCnt() == 1) && !varDsc.lvPinned)
{
if (varDsc.lvIsStructField)
{
Expand DownExpand Up@@ -2083,7 +2087,7 @@ bool Liveness<TLiveness>::ComputeLifeUntrackedLocal(VARSET_TP& life,
}
}

if (isDef && !anyFieldLive)
if (TLiveness::EliminateDeadCode && isDef && !anyFieldLive)
{
// Do not consider this store dead if the parent local variable is an address exposed local or
// if the struct has any significant padding we must retain the value of.
Expand DownExpand Up@@ -2328,7 +2332,8 @@ void Liveness<TLiveness>::ComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VAR
case GT_CALL:
{
GenTreeCall* const call = node->AsCall();
if ((call->TypeIs(TYP_VOID) || call->IsUnusedValue()) && !call->HasSideEffects(m_compiler))
if (TLiveness::EliminateDeadCode && (call->TypeIs(TYP_VOID) || call->IsUnusedValue()) &&
!call->HasSideEffects(m_compiler))
{
JITDUMP("Removing dead call:\n");
DISPNODE(call);
Expand DownExpand Up@@ -2375,13 +2380,13 @@ void Liveness<TLiveness>::ComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VAR
GenTreeLclVarCommon* const lclVarNode = node->AsLclVarCommon();
LclVarDsc& varDsc = m_compiler->lvaTable[lclVarNode->GetLclNum()];

if (node->IsUnusedValue())
if (TLiveness::EliminateDeadCode && node->IsUnusedValue())
{
JITDUMP("Removing dead LclVar use:\n");
DISPNODE(lclVarNode);

blockRange.Delete(m_compiler, block, node);
if (varDsc.lvTracked && !m_compiler->opts.MinOpts())
if (varDsc.lvTracked)
{
m_compiler->fgStmtRemoved = true;
}
Expand All@@ -2398,14 +2403,14 @@ void Liveness<TLiveness>::ComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VAR
}

case GT_LCL_ADDR:
if (node->IsUnusedValue())
if (TLiveness::EliminateDeadCode && node->IsUnusedValue())
{
JITDUMP("Removing dead LclVar address:\n");
DISPNODE(node);

const bool isTracked = m_compiler->lvaTable[node->AsLclVarCommon()->GetLclNum()].lvTracked;
blockRange.Delete(m_compiler, block, node);
if (isTracked && !m_compiler->opts.MinOpts())
if (isTracked)
{
m_compiler->fgStmtRemoved = true;
}
Expand All@@ -2423,7 +2428,7 @@ void Liveness<TLiveness>::ComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VAR
}

isDeadStore = ComputeLifeLocal(life, keepAliveVars, node);
if (isDeadStore)
if (TLiveness::EliminateDeadCode && isDeadStore)
{
LIR::Use addrUse;
if (blockRange.TryGetUse(node, &addrUse) && addrUse.User()->OperIs(GT_STOREIND, GT_STORE_BLK))
Expand DownExpand Up@@ -2464,7 +2469,7 @@ void Liveness<TLiveness>::ComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VAR
isDeadStore = ComputeLifeUntrackedLocal(life, keepAliveVars, varDsc, lclVarNode);
}

if (isDeadStore && TryRemoveDeadStoreLIR(node, lclVarNode, block))
if (TLiveness::EliminateDeadCode && isDeadStore && TryRemoveDeadStoreLIR(node, lclVarNode, block))
{
GenTree* value = lclVarNode->Data();
value->SetUnusedValue();
Expand All@@ -2491,7 +2496,7 @@ void Liveness<TLiveness>::ComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VAR
#endif // FEATURE_MASKED_HW_INTRINSICS
case GT_PHYSREG:
// These are all side-effect-free leaf nodes.
if (node->IsUnusedValue())
if (TLiveness::EliminateDeadCode && node->IsUnusedValue())
{
JITDUMP("Removing dead node:\n");
DISPNODE(node);
Expand DownExpand Up@@ -2693,6 +2698,11 @@ bool Liveness<TLiveness>::TryRemoveDeadStoreLIR(GenTree* store, GenTreeLclVarCom
template <typename TLiveness>
bool Liveness<TLiveness>::TryRemoveNonLocalLIR(GenTree* node, LIR::Range* blockRange)
{
if (!TLiveness::EliminateDeadCode)
{
return false;
}

assert(!node->OperIsLocal());
if (!node->IsValue() || node->IsUnusedValue())
{
Expand DownExpand Up@@ -2816,6 +2826,7 @@ void Compiler::fgSsaLiveness()
ComputeMemoryLiveness = true,
IsLIR = false,
IsEarly = false,
EliminateDeadCode = true,
};

SsaLivenessClass(Compiler* comp)
Expand All@@ -2841,6 +2852,7 @@ void Compiler::fgAsyncLiveness()
ComputeMemoryLiveness = false,
IsLIR = true,
IsEarly = false,
EliminateDeadCode = false,
};

AsyncLiveness(Compiler* comp)
Expand All@@ -2866,6 +2878,7 @@ void Compiler::fgPostLowerLiveness()
ComputeMemoryLiveness = false,
IsLIR = true,
IsEarly = false,
EliminateDeadCode = true,
};

PostLowerLiveness(Compiler* comp)
Expand DownExpand Up@@ -2909,6 +2922,7 @@ PhaseStatus Compiler::fgEarlyLiveness()
ComputeMemoryLiveness = false,
IsLIR = false,
IsEarly = true,
EliminateDeadCode = true,
};

EarlyLiveness(Compiler* comp)
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 34 additions & 22 deletions src/coreclr/jit/async.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -397,14 +397,12 @@ BasicBlock* Compiler::CreateReturnBB(unsigned* mergedReturnLcl)
class AsyncLiveness
{
Compiler* m_compiler;
bool m_hasLiveness;
TreeLifeUpdater<false> m_updater;
unsigned m_numVars;

public:
AsyncLiveness(Compiler* comp, bool hasLiveness)
AsyncLiveness(Compiler* comp)
: m_compiler(comp)
, m_hasLiveness(hasLiveness)
, m_updater(comp)
, m_numVars(comp->lvaCount)
{
Expand All@@ -430,9 +428,6 @@ class AsyncLiveness
//
void AsyncLiveness::StartBlock(BasicBlock* block)
{
if (!m_hasLiveness)
return;

VarSetOps::Assign(m_compiler, m_compiler->compCurLife, block->bbLiveIn);
}

Expand All@@ -446,9 +441,6 @@ void AsyncLiveness::StartBlock(BasicBlock* block)
//
void AsyncLiveness::Update(GenTree* node)
{
if (!m_hasLiveness)
return;

m_updater.UpdateLife(node);
}

Expand DownExpand Up@@ -539,8 +531,9 @@ bool AsyncLiveness::IsLive(unsigned lclNum)
return false;
}

if (!m_hasLiveness)
if (m_compiler->opts.compDbgCode && (lclNum < m_compiler->info.compLocalsCount))
{
// Keep all IL locals in debug codegen
Comment thread
jakobbotsch marked this conversation as resolved.
return true;
}

Expand DownExpand Up@@ -701,21 +694,18 @@ PhaseStatus AsyncTransformation::Run()
#endif

// Compute liveness to be used for determining what must be captured on
// suspension. In unoptimized codegen we capture everything.
if (m_compiler->opts.OptimizationEnabled())
// suspension.
if (m_compiler->m_dfsTree == nullptr)
{
if (m_compiler->m_dfsTree == nullptr)
{
m_compiler->m_dfsTree = m_compiler->fgComputeDfs<false>();
}

m_compiler->lvaComputeRefCounts(true, false);
m_compiler->fgAsyncLiveness();
INDEBUG(m_compiler->mostRecentlyActivePhase = PHASE_ASYNC);
VarSetOps::AssignNoCopy(m_compiler, m_compiler->compCurLife, VarSetOps::MakeEmpty(m_compiler));
m_compiler->m_dfsTree = m_compiler->fgComputeDfs<false>();
}

AsyncLiveness liveness(m_compiler, m_compiler->opts.OptimizationEnabled());
m_compiler->lvaComputePreciseRefCounts(/* isRecompute */ true, /* setSlotNumbers */ false);
m_compiler->fgAsyncLiveness();
INDEBUG(m_compiler->mostRecentlyActivePhase = PHASE_ASYNC);
VarSetOps::AssignNoCopy(m_compiler, m_compiler->compCurLife, VarSetOps::MakeEmpty(m_compiler));

AsyncLiveness liveness(m_compiler);

// Now walk the IR for all the blocks that contain async calls. Keep track
// of liveness and outstanding LIR edges as we go; the LIR edges that cross
Expand DownExpand Up@@ -783,6 +773,28 @@ PhaseStatus AsyncTransformation::Run()

m_compiler->fgInvalidateDfsTree();

if (m_compiler->opts.OptimizationDisabled())
{
// Rest of the compiler does not expect that we started tracking locals, so reset that state.
for (unsigned i = 0; i < m_compiler->lvaTrackedCount; i++)
{
m_compiler->lvaGetDesc(m_compiler->lvaTrackedToVarNum[i])->lvTracked = false;
}

m_compiler->lvaCurEpoch++;
m_compiler->lvaTrackedCount = 0;
m_compiler->lvaTrackedCountInSizeTUnits = 0;

for (BasicBlock* block : m_compiler->Blocks())
{
block->bbLiveIn = VarSetOps::UninitVal();
block->bbLiveOut = VarSetOps::UninitVal();
block->bbVarUse = VarSetOps::UninitVal();
block->bbVarDef = VarSetOps::UninitVal();
}
m_compiler->fgBBVarSetsInited = false;
}

return PhaseStatus::MODIFIED_EVERYTHING;
}

Expand Down
1 change: 1 addition & 0 deletions src/coreclr/jit/compiler.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -4214,6 +4214,7 @@ class Compiler

PhaseStatus lvaMarkLocalVars(); // Local variable ref-counting
void lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers);
void lvaComputePreciseRefCounts(bool isRecompute, bool setSlotNumbers);
void lvaMarkLocalVars(BasicBlock* block);

void lvaAllocOutgoingArgSpaceVar(); // Set up lvaOutgoingArgSpaceVar
Expand Down
38 changes: 28 additions & 10 deletions src/coreclr/jit/lclvars.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -3415,8 +3415,6 @@ PhaseStatus Compiler::lvaMarkLocalVars()
void Compiler::lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers)
{
JITDUMP("\n*** lvaComputeRefCounts ***\n");
unsigned lclNum = 0;
LclVarDsc* varDsc = nullptr;

// Fast path for minopts and debug codegen.
//
Expand All@@ -3430,8 +3428,9 @@ void Compiler::lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers)
#if defined(DEBUG)
// All local vars should be marked as implicitly referenced
// and not tracked.
for (lclNum = 0, varDsc = lvaTable; lclNum < lvaCount; lclNum++, varDsc++)
for (unsigned lclNum = 0; lclNum < lvaCount; lclNum++)
{
LclVarDsc* varDsc = lvaGetDesc(lclNum);
const bool isSpecialVarargsParam = varDsc->lvIsParam && lvaIsArgAccessedViaVarArgsCookie(lclNum);

if (isSpecialVarargsParam)
Expand All@@ -3451,8 +3450,9 @@ void Compiler::lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers)
}

// First compute.
for (lclNum = 0, varDsc = lvaTable; lclNum < lvaCount; lclNum++, varDsc++)
for (unsigned lclNum = 0; lclNum < lvaCount; lclNum++)
{
LclVarDsc* varDsc = lvaGetDesc(lclNum);
// Using lvImplicitlyReferenced here ensures that we can't
// accidentally make locals be unreferenced later by decrementing
// the ref count to zero.
Expand DownExpand Up@@ -3488,11 +3488,28 @@ void Compiler::lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers)
return;
}

// Slower path we take when optimizing, to get accurate counts.
//
lvaComputePreciseRefCounts(isRecompute, setSlotNumbers);
}

//------------------------------------------------------------------------
// lvaComputePreciseRefCounts: compute precise ref counts for locals by IR traversal
//
// Arguments:
// isRecompute -- true if we just want ref counts and no other side effects;
// false means to also look for true boolean locals, lay
// groundwork for assertion prop, check type consistency, etc.
// See lvaMarkLclRefs for details on what else goes on.
// setSlotNumbers -- true if local slot numbers should be assigned.
//
// Notes:
// See notes on lvaComputeRefCounts.
//
void Compiler::lvaComputePreciseRefCounts(bool isRecompute, bool setSlotNumbers)
{
// First, reset all explicit ref counts and weights.
for (lclNum = 0, varDsc = lvaTable; lclNum < lvaCount; lclNum++, varDsc++)
for (unsigned lclNum = 0; lclNum < lvaCount; lclNum++)
{
LclVarDsc* varDsc = lvaGetDesc(lclNum);
varDsc->setLvRefCnt(0);
varDsc->setLvRefCntWtd(BB_ZERO_WEIGHT);

Expand All@@ -3519,7 +3536,7 @@ void Compiler::lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers)
const bool oldLvaGenericsContextInUse = lvaGenericsContextInUse;
lvaGenericsContextInUse = false;

JITDUMP("\n*** lvaComputeRefCounts -- explicit counts ***\n");
JITDUMP("\n*** lvaComputePreciseRefCounts -- explicit counts ***\n");

// Second, account for all explicit local variable references
for (BasicBlock* const block : Blocks())
Expand DownExpand Up@@ -3577,11 +3594,12 @@ void Compiler::lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers)
assert(!"unexpected new use of generics context");
}

JITDUMP("\n*** lvaComputeRefCounts -- implicit counts ***\n");
JITDUMP("\n*** lvaComputePreciseRefCounts -- implicit counts ***\n");

// Third, bump ref counts for some implicit prolog references
for (lclNum = 0, varDsc = lvaTable; lclNum < lvaCount; lclNum++, varDsc++)
for (unsigned lclNum = 0; lclNum < lvaCount; lclNum++)
{
LclVarDsc* varDsc = lvaGetDesc(lclNum);
// Todo: review justification for these count bumps.
if (varDsc->lvIsRegArg)
{
Expand Down
52 changes: 33 additions & 19 deletions src/coreclr/jit/liveness.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,6 +55,7 @@ class Liveness
ComputeMemoryLiveness = false,
IsLIR = false,
IsEarly = false,
EliminateDeadCode = false,
};

Liveness(Compiler* compiler)
Expand DownExpand Up@@ -1965,16 +1966,19 @@ bool Liveness<TLiveness>::ComputeLifeTrackedLocalDef(VARSET_TP& life,
// Dead store
node->gtFlags |= GTF_VAR_DEATH;

// keepAliveVars always stay alive
noway_assert(!VarSetOps::IsMember(m_compiler, keepAliveVars, varIndex));
if (TLiveness::EliminateDeadCode)
{
// keepAliveVars always stay alive
noway_assert(!VarSetOps::IsMember(m_compiler, keepAliveVars, varIndex));

// Do not consider this store dead if the target local variable represents
// a promoted struct field of an address exposed local or if the address
// of the variable has been exposed. Improved alias analysis could allow
// stores to these sorts of variables to be removed at the cost of compile
// time.
return !varDsc.IsAddressExposed() &&
!(varDsc.lvIsStructField && m_compiler->lvaTable[varDsc.lvParentLcl].IsAddressExposed());
// Do not consider this store dead if the target local variable represents
// a promoted struct field of an address exposed local or if the address
// of the variable has been exposed. Improved alias analysis could allow
// stores to these sorts of variables to be removed at the cost of compile
// time.
return !varDsc.IsAddressExposed() &&
!(varDsc.lvIsStructField && m_compiler->lvaTable[varDsc.lvParentLcl].IsAddressExposed());
}
}

return false;
Expand DownExpand Up@@ -2011,7 +2015,7 @@ bool Liveness<TLiveness>::ComputeLifeUntrackedLocal(VARSET_TP& life,

// We have accurate ref counts when running late liveness so we can eliminate
// some stores if the lhs local has a ref count of 1.
if (isDef && TLiveness::IsLIR && (varDsc.lvRefCnt() == 1) && !varDsc.lvPinned)
if (TLiveness::EliminateDeadCode && TLiveness::IsLIR && isDef && (varDsc.lvRefCnt() == 1) && !varDsc.lvPinned)
{
if (varDsc.lvIsStructField)
{
Expand DownExpand Up@@ -2083,7 +2087,7 @@ bool Liveness<TLiveness>::ComputeLifeUntrackedLocal(VARSET_TP& life,
}
}

if (isDef && !anyFieldLive)
if (TLiveness::EliminateDeadCode && isDef && !anyFieldLive)
{
// Do not consider this store dead if the parent local variable is an address exposed local or
// if the struct has any significant padding we must retain the value of.
Expand DownExpand Up@@ -2328,7 +2332,8 @@ void Liveness<TLiveness>::ComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VAR
case GT_CALL:
{
GenTreeCall* const call = node->AsCall();
if ((call->TypeIs(TYP_VOID) || call->IsUnusedValue()) && !call->HasSideEffects(m_compiler))
if (TLiveness::EliminateDeadCode && (call->TypeIs(TYP_VOID) || call->IsUnusedValue()) &&
!call->HasSideEffects(m_compiler))
{
JITDUMP("Removing dead call:\n");
DISPNODE(call);
Expand DownExpand Up@@ -2375,13 +2380,13 @@ void Liveness<TLiveness>::ComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VAR
GenTreeLclVarCommon* const lclVarNode = node->AsLclVarCommon();
LclVarDsc& varDsc = m_compiler->lvaTable[lclVarNode->GetLclNum()];

if (node->IsUnusedValue())
if (TLiveness::EliminateDeadCode && node->IsUnusedValue())
{
JITDUMP("Removing dead LclVar use:\n");
DISPNODE(lclVarNode);

blockRange.Delete(m_compiler, block, node);
if (varDsc.lvTracked && !m_compiler->opts.MinOpts())
if (varDsc.lvTracked)
{
m_compiler->fgStmtRemoved = true;
}
Expand All@@ -2398,14 +2403,14 @@ void Liveness<TLiveness>::ComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VAR
}

case GT_LCL_ADDR:
if (node->IsUnusedValue())
if (TLiveness::EliminateDeadCode && node->IsUnusedValue())
{
JITDUMP("Removing dead LclVar address:\n");
DISPNODE(node);

const bool isTracked = m_compiler->lvaTable[node->AsLclVarCommon()->GetLclNum()].lvTracked;
blockRange.Delete(m_compiler, block, node);
if (isTracked && !m_compiler->opts.MinOpts())
if (isTracked)
{
m_compiler->fgStmtRemoved = true;
}
Expand All@@ -2423,7 +2428,7 @@ void Liveness<TLiveness>::ComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VAR
}

isDeadStore = ComputeLifeLocal(life, keepAliveVars, node);
if (isDeadStore)
if (TLiveness::EliminateDeadCode && isDeadStore)
{
LIR::Use addrUse;
if (blockRange.TryGetUse(node, &addrUse) && addrUse.User()->OperIs(GT_STOREIND, GT_STORE_BLK))
Expand DownExpand Up@@ -2464,7 +2469,7 @@ void Liveness<TLiveness>::ComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VAR
isDeadStore = ComputeLifeUntrackedLocal(life, keepAliveVars, varDsc, lclVarNode);
}

if (isDeadStore && TryRemoveDeadStoreLIR(node, lclVarNode, block))
if (TLiveness::EliminateDeadCode && isDeadStore && TryRemoveDeadStoreLIR(node, lclVarNode, block))
{
GenTree* value = lclVarNode->Data();
value->SetUnusedValue();
Expand All@@ -2491,7 +2496,7 @@ void Liveness<TLiveness>::ComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VAR
#endif // FEATURE_MASKED_HW_INTRINSICS
case GT_PHYSREG:
// These are all side-effect-free leaf nodes.
if (node->IsUnusedValue())
if (TLiveness::EliminateDeadCode && node->IsUnusedValue())
{
JITDUMP("Removing dead node:\n");
DISPNODE(node);
Expand DownExpand Up@@ -2693,6 +2698,11 @@ bool Liveness<TLiveness>::TryRemoveDeadStoreLIR(GenTree* store, GenTreeLclVarCom
template <typename TLiveness>
bool Liveness<TLiveness>::TryRemoveNonLocalLIR(GenTree* node, LIR::Range* blockRange)
{
if (!TLiveness::EliminateDeadCode)
{
return false;
}

assert(!node->OperIsLocal());
if (!node->IsValue() || node->IsUnusedValue())
{
Expand DownExpand Up@@ -2816,6 +2826,7 @@ void Compiler::fgSsaLiveness()
ComputeMemoryLiveness = true,
IsLIR = false,
IsEarly = false,
EliminateDeadCode = true,
};

SsaLivenessClass(Compiler* comp)
Expand All@@ -2841,6 +2852,7 @@ void Compiler::fgAsyncLiveness()
ComputeMemoryLiveness = false,
IsLIR = true,
IsEarly = false,
EliminateDeadCode = false,
};

AsyncLiveness(Compiler* comp)
Expand All@@ -2866,6 +2878,7 @@ void Compiler::fgPostLowerLiveness()
ComputeMemoryLiveness = false,
IsLIR = true,
IsEarly = false,
EliminateDeadCode = true,
};

PostLowerLiveness(Compiler* comp)
Expand DownExpand Up@@ -2909,6 +2922,7 @@ PhaseStatus Compiler::fgEarlyLiveness()
ComputeMemoryLiveness = false,
IsLIR = false,
IsEarly = true,
EliminateDeadCode = true,
};

EarlyLiveness(Compiler* comp)
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 34 additions & 22 deletions src/coreclr/jit/async.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -397,14 +397,12 @@ BasicBlock* Compiler::CreateReturnBB(unsigned* mergedReturnLcl)
class AsyncLiveness
{
Compiler* m_compiler;
bool m_hasLiveness;
TreeLifeUpdater<false> m_updater;
unsigned m_numVars;

public:
AsyncLiveness(Compiler* comp, bool hasLiveness)
AsyncLiveness(Compiler* comp)
: m_compiler(comp)
, m_hasLiveness(hasLiveness)
, m_updater(comp)
, m_numVars(comp->lvaCount)
{
Expand All@@ -430,9 +428,6 @@ class AsyncLiveness
//
void AsyncLiveness::StartBlock(BasicBlock* block)
{
if (!m_hasLiveness)
return;

VarSetOps::Assign(m_compiler, m_compiler->compCurLife, block->bbLiveIn);
}

Expand All@@ -446,9 +441,6 @@ void AsyncLiveness::StartBlock(BasicBlock* block)
//
void AsyncLiveness::Update(GenTree* node)
{
if (!m_hasLiveness)
return;

m_updater.UpdateLife(node);
}

Expand DownExpand Up@@ -539,8 +531,9 @@ bool AsyncLiveness::IsLive(unsigned lclNum)
return false;
}

if (!m_hasLiveness)
if (m_compiler->opts.compDbgCode && (lclNum < m_compiler->info.compLocalsCount))
{
// Keep all IL locals in debug codegen
Comment thread
jakobbotsch marked this conversation as resolved.
return true;
}

Expand DownExpand Up@@ -701,21 +694,18 @@ PhaseStatus AsyncTransformation::Run()
#endif

// Compute liveness to be used for determining what must be captured on
// suspension. In unoptimized codegen we capture everything.
if (m_compiler->opts.OptimizationEnabled())
// suspension.
if (m_compiler->m_dfsTree == nullptr)
{
if (m_compiler->m_dfsTree == nullptr)
{
m_compiler->m_dfsTree = m_compiler->fgComputeDfs<false>();
}

m_compiler->lvaComputeRefCounts(true, false);
m_compiler->fgAsyncLiveness();
INDEBUG(m_compiler->mostRecentlyActivePhase = PHASE_ASYNC);
VarSetOps::AssignNoCopy(m_compiler, m_compiler->compCurLife, VarSetOps::MakeEmpty(m_compiler));
m_compiler->m_dfsTree = m_compiler->fgComputeDfs<false>();
}

AsyncLiveness liveness(m_compiler, m_compiler->opts.OptimizationEnabled());
m_compiler->lvaComputePreciseRefCounts(/* isRecompute */ true, /* setSlotNumbers */ false);
m_compiler->fgAsyncLiveness();
INDEBUG(m_compiler->mostRecentlyActivePhase = PHASE_ASYNC);
VarSetOps::AssignNoCopy(m_compiler, m_compiler->compCurLife, VarSetOps::MakeEmpty(m_compiler));

AsyncLiveness liveness(m_compiler);

// Now walk the IR for all the blocks that contain async calls. Keep track
// of liveness and outstanding LIR edges as we go; the LIR edges that cross
Expand DownExpand Up@@ -783,6 +773,28 @@ PhaseStatus AsyncTransformation::Run()

m_compiler->fgInvalidateDfsTree();

if (m_compiler->opts.OptimizationDisabled())
{
// Rest of the compiler does not expect that we started tracking locals, so reset that state.
for (unsigned i = 0; i < m_compiler->lvaTrackedCount; i++)
{
m_compiler->lvaGetDesc(m_compiler->lvaTrackedToVarNum[i])->lvTracked = false;
}

m_compiler->lvaCurEpoch++;
m_compiler->lvaTrackedCount = 0;
m_compiler->lvaTrackedCountInSizeTUnits = 0;

for (BasicBlock* block : m_compiler->Blocks())
{
block->bbLiveIn = VarSetOps::UninitVal();
block->bbLiveOut = VarSetOps::UninitVal();
block->bbVarUse = VarSetOps::UninitVal();
block->bbVarDef = VarSetOps::UninitVal();
}
m_compiler->fgBBVarSetsInited = false;
}

return PhaseStatus::MODIFIED_EVERYTHING;
}

Expand Down
1 change: 1 addition & 0 deletions src/coreclr/jit/compiler.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -4214,6 +4214,7 @@ class Compiler

PhaseStatus lvaMarkLocalVars(); // Local variable ref-counting
void lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers);
void lvaComputePreciseRefCounts(bool isRecompute, bool setSlotNumbers);
void lvaMarkLocalVars(BasicBlock* block);

void lvaAllocOutgoingArgSpaceVar(); // Set up lvaOutgoingArgSpaceVar
Expand Down
38 changes: 28 additions & 10 deletions src/coreclr/jit/lclvars.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -3415,8 +3415,6 @@ PhaseStatus Compiler::lvaMarkLocalVars()
void Compiler::lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers)
{
JITDUMP("\n*** lvaComputeRefCounts ***\n");
unsigned lclNum = 0;
LclVarDsc* varDsc = nullptr;

// Fast path for minopts and debug codegen.
//
Expand All@@ -3430,8 +3428,9 @@ void Compiler::lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers)
#if defined(DEBUG)
// All local vars should be marked as implicitly referenced
// and not tracked.
for (lclNum = 0, varDsc = lvaTable; lclNum < lvaCount; lclNum++, varDsc++)
for (unsigned lclNum = 0; lclNum < lvaCount; lclNum++)
{
LclVarDsc* varDsc = lvaGetDesc(lclNum);
const bool isSpecialVarargsParam = varDsc->lvIsParam && lvaIsArgAccessedViaVarArgsCookie(lclNum);

if (isSpecialVarargsParam)
Expand All@@ -3451,8 +3450,9 @@ void Compiler::lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers)
}

// First compute.
for (lclNum = 0, varDsc = lvaTable; lclNum < lvaCount; lclNum++, varDsc++)
for (unsigned lclNum = 0; lclNum < lvaCount; lclNum++)
{
LclVarDsc* varDsc = lvaGetDesc(lclNum);
// Using lvImplicitlyReferenced here ensures that we can't
// accidentally make locals be unreferenced later by decrementing
// the ref count to zero.
Expand DownExpand Up@@ -3488,11 +3488,28 @@ void Compiler::lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers)
return;
}

// Slower path we take when optimizing, to get accurate counts.
//
lvaComputePreciseRefCounts(isRecompute, setSlotNumbers);
}

//------------------------------------------------------------------------
// lvaComputePreciseRefCounts: compute precise ref counts for locals by IR traversal
//
// Arguments:
// isRecompute -- true if we just want ref counts and no other side effects;
// false means to also look for true boolean locals, lay
// groundwork for assertion prop, check type consistency, etc.
// See lvaMarkLclRefs for details on what else goes on.
// setSlotNumbers -- true if local slot numbers should be assigned.
//
// Notes:
// See notes on lvaComputeRefCounts.
//
void Compiler::lvaComputePreciseRefCounts(bool isRecompute, bool setSlotNumbers)
{
// First, reset all explicit ref counts and weights.
for (lclNum = 0, varDsc = lvaTable; lclNum < lvaCount; lclNum++, varDsc++)
for (unsigned lclNum = 0; lclNum < lvaCount; lclNum++)
{
LclVarDsc* varDsc = lvaGetDesc(lclNum);
varDsc->setLvRefCnt(0);
varDsc->setLvRefCntWtd(BB_ZERO_WEIGHT);

Expand All@@ -3519,7 +3536,7 @@ void Compiler::lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers)
const bool oldLvaGenericsContextInUse = lvaGenericsContextInUse;
lvaGenericsContextInUse = false;

JITDUMP("\n*** lvaComputeRefCounts -- explicit counts ***\n");
JITDUMP("\n*** lvaComputePreciseRefCounts -- explicit counts ***\n");

// Second, account for all explicit local variable references
for (BasicBlock* const block : Blocks())
Expand DownExpand Up@@ -3577,11 +3594,12 @@ void Compiler::lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers)
assert(!"unexpected new use of generics context");
}

JITDUMP("\n*** lvaComputeRefCounts -- implicit counts ***\n");
JITDUMP("\n*** lvaComputePreciseRefCounts -- implicit counts ***\n");

// Third, bump ref counts for some implicit prolog references
for (lclNum = 0, varDsc = lvaTable; lclNum < lvaCount; lclNum++, varDsc++)
for (unsigned lclNum = 0; lclNum < lvaCount; lclNum++)
{
LclVarDsc* varDsc = lvaGetDesc(lclNum);
// Todo: review justification for these count bumps.
if (varDsc->lvIsRegArg)
{
Expand Down
52 changes: 33 additions & 19 deletions src/coreclr/jit/liveness.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,6 +55,7 @@ class Liveness
ComputeMemoryLiveness = false,
IsLIR = false,
IsEarly = false,
EliminateDeadCode = false,
};

Liveness(Compiler* compiler)
Expand DownExpand Up@@ -1965,16 +1966,19 @@ bool Liveness<TLiveness>::ComputeLifeTrackedLocalDef(VARSET_TP& life,
// Dead store
node->gtFlags |= GTF_VAR_DEATH;

// keepAliveVars always stay alive
noway_assert(!VarSetOps::IsMember(m_compiler, keepAliveVars, varIndex));
if (TLiveness::EliminateDeadCode)
{
// keepAliveVars always stay alive
noway_assert(!VarSetOps::IsMember(m_compiler, keepAliveVars, varIndex));

// Do not consider this store dead if the target local variable represents
// a promoted struct field of an address exposed local or if the address
// of the variable has been exposed. Improved alias analysis could allow
// stores to these sorts of variables to be removed at the cost of compile
// time.
return !varDsc.IsAddressExposed() &&
!(varDsc.lvIsStructField && m_compiler->lvaTable[varDsc.lvParentLcl].IsAddressExposed());
// Do not consider this store dead if the target local variable represents
// a promoted struct field of an address exposed local or if the address
// of the variable has been exposed. Improved alias analysis could allow
// stores to these sorts of variables to be removed at the cost of compile
// time.
return !varDsc.IsAddressExposed() &&
!(varDsc.lvIsStructField && m_compiler->lvaTable[varDsc.lvParentLcl].IsAddressExposed());
}
}

return false;
Expand DownExpand Up@@ -2011,7 +2015,7 @@ bool Liveness<TLiveness>::ComputeLifeUntrackedLocal(VARSET_TP& life,

// We have accurate ref counts when running late liveness so we can eliminate
// some stores if the lhs local has a ref count of 1.
if (isDef && TLiveness::IsLIR && (varDsc.lvRefCnt() == 1) && !varDsc.lvPinned)
if (TLiveness::EliminateDeadCode && TLiveness::IsLIR && isDef && (varDsc.lvRefCnt() == 1) && !varDsc.lvPinned)
{
if (varDsc.lvIsStructField)
{
Expand DownExpand Up@@ -2083,7 +2087,7 @@ bool Liveness<TLiveness>::ComputeLifeUntrackedLocal(VARSET_TP& life,
}
}

if (isDef && !anyFieldLive)
if (TLiveness::EliminateDeadCode && isDef && !anyFieldLive)
{
// Do not consider this store dead if the parent local variable is an address exposed local or
// if the struct has any significant padding we must retain the value of.
Expand DownExpand Up@@ -2328,7 +2332,8 @@ void Liveness<TLiveness>::ComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VAR
case GT_CALL:
{
GenTreeCall* const call = node->AsCall();
if ((call->TypeIs(TYP_VOID) || call->IsUnusedValue()) && !call->HasSideEffects(m_compiler))
if (TLiveness::EliminateDeadCode && (call->TypeIs(TYP_VOID) || call->IsUnusedValue()) &&
!call->HasSideEffects(m_compiler))
{
JITDUMP("Removing dead call:\n");
DISPNODE(call);
Expand DownExpand Up@@ -2375,13 +2380,13 @@ void Liveness<TLiveness>::ComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VAR
GenTreeLclVarCommon* const lclVarNode = node->AsLclVarCommon();
LclVarDsc& varDsc = m_compiler->lvaTable[lclVarNode->GetLclNum()];

if (node->IsUnusedValue())
if (TLiveness::EliminateDeadCode && node->IsUnusedValue())
{
JITDUMP("Removing dead LclVar use:\n");
DISPNODE(lclVarNode);

blockRange.Delete(m_compiler, block, node);
if (varDsc.lvTracked && !m_compiler->opts.MinOpts())
if (varDsc.lvTracked)
{
m_compiler->fgStmtRemoved = true;
}
Expand All@@ -2398,14 +2403,14 @@ void Liveness<TLiveness>::ComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VAR
}

case GT_LCL_ADDR:
if (node->IsUnusedValue())
if (TLiveness::EliminateDeadCode && node->IsUnusedValue())
{
JITDUMP("Removing dead LclVar address:\n");
DISPNODE(node);

const bool isTracked = m_compiler->lvaTable[node->AsLclVarCommon()->GetLclNum()].lvTracked;
blockRange.Delete(m_compiler, block, node);
if (isTracked && !m_compiler->opts.MinOpts())
if (isTracked)
{
m_compiler->fgStmtRemoved = true;
}
Expand All@@ -2423,7 +2428,7 @@ void Liveness<TLiveness>::ComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VAR
}

isDeadStore = ComputeLifeLocal(life, keepAliveVars, node);
if (isDeadStore)
if (TLiveness::EliminateDeadCode && isDeadStore)
{
LIR::Use addrUse;
if (blockRange.TryGetUse(node, &addrUse) && addrUse.User()->OperIs(GT_STOREIND, GT_STORE_BLK))
Expand DownExpand Up@@ -2464,7 +2469,7 @@ void Liveness<TLiveness>::ComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VAR
isDeadStore = ComputeLifeUntrackedLocal(life, keepAliveVars, varDsc, lclVarNode);
}

if (isDeadStore && TryRemoveDeadStoreLIR(node, lclVarNode, block))
if (TLiveness::EliminateDeadCode && isDeadStore && TryRemoveDeadStoreLIR(node, lclVarNode, block))
{
GenTree* value = lclVarNode->Data();
value->SetUnusedValue();
Expand All@@ -2491,7 +2496,7 @@ void Liveness<TLiveness>::ComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VAR
#endif // FEATURE_MASKED_HW_INTRINSICS
case GT_PHYSREG:
// These are all side-effect-free leaf nodes.
if (node->IsUnusedValue())
if (TLiveness::EliminateDeadCode && node->IsUnusedValue())
{
JITDUMP("Removing dead node:\n");
DISPNODE(node);
Expand DownExpand Up@@ -2693,6 +2698,11 @@ bool Liveness<TLiveness>::TryRemoveDeadStoreLIR(GenTree* store, GenTreeLclVarCom
template <typename TLiveness>
bool Liveness<TLiveness>::TryRemoveNonLocalLIR(GenTree* node, LIR::Range* blockRange)
{
if (!TLiveness::EliminateDeadCode)
{
return false;
}

assert(!node->OperIsLocal());
if (!node->IsValue() || node->IsUnusedValue())
{
Expand DownExpand Up@@ -2816,6 +2826,7 @@ void Compiler::fgSsaLiveness()
ComputeMemoryLiveness = true,
IsLIR = false,
IsEarly = false,
EliminateDeadCode = true,
};

SsaLivenessClass(Compiler* comp)
Expand All@@ -2841,6 +2852,7 @@ void Compiler::fgAsyncLiveness()
ComputeMemoryLiveness = false,
IsLIR = true,
IsEarly = false,
EliminateDeadCode = false,
};

AsyncLiveness(Compiler* comp)
Expand All@@ -2866,6 +2878,7 @@ void Compiler::fgPostLowerLiveness()
ComputeMemoryLiveness = false,
IsLIR = true,
IsEarly = false,
EliminateDeadCode = true,
};

PostLowerLiveness(Compiler* comp)
Expand DownExpand Up@@ -2909,6 +2922,7 @@ PhaseStatus Compiler::fgEarlyLiveness()
ComputeMemoryLiveness = false,
IsLIR = false,
IsEarly = true,
EliminateDeadCode = true,
};

EarlyLiveness(Compiler* comp)
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Universal Dark Mode - works on any site (function() { var enabled = true; function applyDarkMode() { if (!enabled) return; // Create style element if it doesn't exist var style = document.getElementById('universal-dark-mode-style'); if (!style) { style = document.createElement('style'); style.id = 'universal-dark-mode-style'; document.head.appendChild(style); } // Dark mode CSS - inverts colors but preserves images/video style.textContent = ' /* Invert everything except media */ html { filter: invert(1) hue-rotate(180deg) !important; background: #1a1a2e !important; } /* Restore images, videos, iframes, canvas */ img, video, iframe, canvas, svg, picture, [style*="background-image"] { filter: invert(1) hue-rotate(180deg) !important; } /* Preserve specific elements that should not be inverted */ .no-dark-mode, .no-dark-mode *, [data-theme="light"], [data-theme="light"], .ace_editor, .ace_editor *, .CodeMirror, .CodeMirror *, .monaco-editor, .monaco-editor *, .markdown-body pre, .markdown-body pre *, .highlight, .highlight *, pre code, pre code * { filter: none !important; } /* Fix common UI elements */ .modal, .popup, .dropdown-menu, .tooltip, .popover { filter: invert(1) hue-rotate(180deg) !important; background: #2d2d44 !important; border-color: #444 !important; } /* Scrollbars */ ::-webkit-scrollbar { background: #1a1a2e !important; } ::-webkit-scrollbar-thumb { background: #444 !important; } ::-webkit-scrollbar-thumb:hover { background: #555 !important; } /* Selection */ ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; } ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; } '; } function removeDarkMode() { var style = document.getElementById('universal-dark-mode-style'); if (style) style.remove(); } // Toggle with Alt+Shift+D document.addEventListener('keydown', function(e) { if (e.altKey && e.shiftKey && e.key === 'D') { e.preventDefault(); enabled = !enabled; if (enabled) { applyDarkMode(); console.log('[Universal Dark Mode] Enabled'); } else { removeDarkMode(); console.log('[Universal Dark Mode] Disabled'); } } }); // Apply on load applyDarkMode(); // Re-apply on dynamic content var observer = new MutationObserver(function(mutations) { if (enabled && !document.getElementById('universal-dark-mode-style')) { applyDarkMode(); } }); observer.observe(document.head, { childList: true }); console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle'); })(); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 34 additions & 22 deletions src/coreclr/jit/async.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -397,14 +397,12 @@ BasicBlock* Compiler::CreateReturnBB(unsigned* mergedReturnLcl)
class AsyncLiveness
{
Compiler* m_compiler;
bool m_hasLiveness;
TreeLifeUpdater<false> m_updater;
unsigned m_numVars;

public:
AsyncLiveness(Compiler* comp, bool hasLiveness)
AsyncLiveness(Compiler* comp)
: m_compiler(comp)
, m_hasLiveness(hasLiveness)
, m_updater(comp)
, m_numVars(comp->lvaCount)
{
Expand All@@ -430,9 +428,6 @@ class AsyncLiveness
//
void AsyncLiveness::StartBlock(BasicBlock* block)
{
if (!m_hasLiveness)
return;

VarSetOps::Assign(m_compiler, m_compiler->compCurLife, block->bbLiveIn);
}

Expand All@@ -446,9 +441,6 @@ void AsyncLiveness::StartBlock(BasicBlock* block)
//
void AsyncLiveness::Update(GenTree* node)
{
if (!m_hasLiveness)
return;

m_updater.UpdateLife(node);
}

Expand DownExpand Up@@ -539,8 +531,9 @@ bool AsyncLiveness::IsLive(unsigned lclNum)
return false;
}

if (!m_hasLiveness)
if (m_compiler->opts.compDbgCode && (lclNum < m_compiler->info.compLocalsCount))
{
// Keep all IL locals in debug codegen
Comment thread
jakobbotsch marked this conversation as resolved.
return true;
}

Expand DownExpand Up@@ -701,21 +694,18 @@ PhaseStatus AsyncTransformation::Run()
#endif

// Compute liveness to be used for determining what must be captured on
// suspension. In unoptimized codegen we capture everything.
if (m_compiler->opts.OptimizationEnabled())
// suspension.
if (m_compiler->m_dfsTree == nullptr)
{
if (m_compiler->m_dfsTree == nullptr)
{
m_compiler->m_dfsTree = m_compiler->fgComputeDfs<false>();
}

m_compiler->lvaComputeRefCounts(true, false);
m_compiler->fgAsyncLiveness();
INDEBUG(m_compiler->mostRecentlyActivePhase = PHASE_ASYNC);
VarSetOps::AssignNoCopy(m_compiler, m_compiler->compCurLife, VarSetOps::MakeEmpty(m_compiler));
m_compiler->m_dfsTree = m_compiler->fgComputeDfs<false>();
}

AsyncLiveness liveness(m_compiler, m_compiler->opts.OptimizationEnabled());
m_compiler->lvaComputePreciseRefCounts(/* isRecompute */ true, /* setSlotNumbers */ false);
m_compiler->fgAsyncLiveness();
INDEBUG(m_compiler->mostRecentlyActivePhase = PHASE_ASYNC);
VarSetOps::AssignNoCopy(m_compiler, m_compiler->compCurLife, VarSetOps::MakeEmpty(m_compiler));

AsyncLiveness liveness(m_compiler);

// Now walk the IR for all the blocks that contain async calls. Keep track
// of liveness and outstanding LIR edges as we go; the LIR edges that cross
Expand DownExpand Up@@ -783,6 +773,28 @@ PhaseStatus AsyncTransformation::Run()

m_compiler->fgInvalidateDfsTree();

if (m_compiler->opts.OptimizationDisabled())
{
// Rest of the compiler does not expect that we started tracking locals, so reset that state.
for (unsigned i = 0; i < m_compiler->lvaTrackedCount; i++)
{
m_compiler->lvaGetDesc(m_compiler->lvaTrackedToVarNum[i])->lvTracked = false;
}

m_compiler->lvaCurEpoch++;
m_compiler->lvaTrackedCount = 0;
m_compiler->lvaTrackedCountInSizeTUnits = 0;

for (BasicBlock* block : m_compiler->Blocks())
{
block->bbLiveIn = VarSetOps::UninitVal();
block->bbLiveOut = VarSetOps::UninitVal();
block->bbVarUse = VarSetOps::UninitVal();
block->bbVarDef = VarSetOps::UninitVal();
}
m_compiler->fgBBVarSetsInited = false;
}

return PhaseStatus::MODIFIED_EVERYTHING;
}

Expand Down
1 change: 1 addition & 0 deletions src/coreclr/jit/compiler.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -4214,6 +4214,7 @@ class Compiler

PhaseStatus lvaMarkLocalVars(); // Local variable ref-counting
void lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers);
void lvaComputePreciseRefCounts(bool isRecompute, bool setSlotNumbers);
void lvaMarkLocalVars(BasicBlock* block);

void lvaAllocOutgoingArgSpaceVar(); // Set up lvaOutgoingArgSpaceVar
Expand Down
38 changes: 28 additions & 10 deletions src/coreclr/jit/lclvars.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -3415,8 +3415,6 @@ PhaseStatus Compiler::lvaMarkLocalVars()
void Compiler::lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers)
{
JITDUMP("\n*** lvaComputeRefCounts ***\n");
unsigned lclNum = 0;
LclVarDsc* varDsc = nullptr;

// Fast path for minopts and debug codegen.
//
Expand All@@ -3430,8 +3428,9 @@ void Compiler::lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers)
#if defined(DEBUG)
// All local vars should be marked as implicitly referenced
// and not tracked.
for (lclNum = 0, varDsc = lvaTable; lclNum < lvaCount; lclNum++, varDsc++)
for (unsigned lclNum = 0; lclNum < lvaCount; lclNum++)
{
LclVarDsc* varDsc = lvaGetDesc(lclNum);
const bool isSpecialVarargsParam = varDsc->lvIsParam && lvaIsArgAccessedViaVarArgsCookie(lclNum);

if (isSpecialVarargsParam)
Expand All@@ -3451,8 +3450,9 @@ void Compiler::lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers)
}

// First compute.
for (lclNum = 0, varDsc = lvaTable; lclNum < lvaCount; lclNum++, varDsc++)
for (unsigned lclNum = 0; lclNum < lvaCount; lclNum++)
{
LclVarDsc* varDsc = lvaGetDesc(lclNum);
// Using lvImplicitlyReferenced here ensures that we can't
// accidentally make locals be unreferenced later by decrementing
// the ref count to zero.
Expand DownExpand Up@@ -3488,11 +3488,28 @@ void Compiler::lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers)
return;
}

// Slower path we take when optimizing, to get accurate counts.
//
lvaComputePreciseRefCounts(isRecompute, setSlotNumbers);
}

//------------------------------------------------------------------------
// lvaComputePreciseRefCounts: compute precise ref counts for locals by IR traversal
//
// Arguments:
// isRecompute -- true if we just want ref counts and no other side effects;
// false means to also look for true boolean locals, lay
// groundwork for assertion prop, check type consistency, etc.
// See lvaMarkLclRefs for details on what else goes on.
// setSlotNumbers -- true if local slot numbers should be assigned.
//
// Notes:
// See notes on lvaComputeRefCounts.
//
void Compiler::lvaComputePreciseRefCounts(bool isRecompute, bool setSlotNumbers)
{
// First, reset all explicit ref counts and weights.
for (lclNum = 0, varDsc = lvaTable; lclNum < lvaCount; lclNum++, varDsc++)
for (unsigned lclNum = 0; lclNum < lvaCount; lclNum++)
{
LclVarDsc* varDsc = lvaGetDesc(lclNum);
varDsc->setLvRefCnt(0);
varDsc->setLvRefCntWtd(BB_ZERO_WEIGHT);

Expand All@@ -3519,7 +3536,7 @@ void Compiler::lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers)
const bool oldLvaGenericsContextInUse = lvaGenericsContextInUse;
lvaGenericsContextInUse = false;

JITDUMP("\n*** lvaComputeRefCounts -- explicit counts ***\n");
JITDUMP("\n*** lvaComputePreciseRefCounts -- explicit counts ***\n");

// Second, account for all explicit local variable references
for (BasicBlock* const block : Blocks())
Expand DownExpand Up@@ -3577,11 +3594,12 @@ void Compiler::lvaComputeRefCounts(bool isRecompute, bool setSlotNumbers)
assert(!"unexpected new use of generics context");
}

JITDUMP("\n*** lvaComputeRefCounts -- implicit counts ***\n");
JITDUMP("\n*** lvaComputePreciseRefCounts -- implicit counts ***\n");

// Third, bump ref counts for some implicit prolog references
for (lclNum = 0, varDsc = lvaTable; lclNum < lvaCount; lclNum++, varDsc++)
for (unsigned lclNum = 0; lclNum < lvaCount; lclNum++)
{
LclVarDsc* varDsc = lvaGetDesc(lclNum);
// Todo: review justification for these count bumps.
if (varDsc->lvIsRegArg)
{
Expand Down
52 changes: 33 additions & 19 deletions src/coreclr/jit/liveness.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,6 +55,7 @@ class Liveness
ComputeMemoryLiveness = false,
IsLIR = false,
IsEarly = false,
EliminateDeadCode = false,
};

Liveness(Compiler* compiler)
Expand DownExpand Up@@ -1965,16 +1966,19 @@ bool Liveness<TLiveness>::ComputeLifeTrackedLocalDef(VARSET_TP& life,
// Dead store
node->gtFlags |= GTF_VAR_DEATH;

// keepAliveVars always stay alive
noway_assert(!VarSetOps::IsMember(m_compiler, keepAliveVars, varIndex));
if (TLiveness::EliminateDeadCode)
{
// keepAliveVars always stay alive
noway_assert(!VarSetOps::IsMember(m_compiler, keepAliveVars, varIndex));

// Do not consider this store dead if the target local variable represents
// a promoted struct field of an address exposed local or if the address
// of the variable has been exposed. Improved alias analysis could allow
// stores to these sorts of variables to be removed at the cost of compile
// time.
return !varDsc.IsAddressExposed() &&
!(varDsc.lvIsStructField && m_compiler->lvaTable[varDsc.lvParentLcl].IsAddressExposed());
// Do not consider this store dead if the target local variable represents
// a promoted struct field of an address exposed local or if the address
// of the variable has been exposed. Improved alias analysis could allow
// stores to these sorts of variables to be removed at the cost of compile
// time.
return !varDsc.IsAddressExposed() &&
!(varDsc.lvIsStructField && m_compiler->lvaTable[varDsc.lvParentLcl].IsAddressExposed());
}
}

return false;
Expand DownExpand Up@@ -2011,7 +2015,7 @@ bool Liveness<TLiveness>::ComputeLifeUntrackedLocal(VARSET_TP& life,

// We have accurate ref counts when running late liveness so we can eliminate
// some stores if the lhs local has a ref count of 1.
if (isDef && TLiveness::IsLIR && (varDsc.lvRefCnt() == 1) && !varDsc.lvPinned)
if (TLiveness::EliminateDeadCode && TLiveness::IsLIR && isDef && (varDsc.lvRefCnt() == 1) && !varDsc.lvPinned)
{
if (varDsc.lvIsStructField)
{
Expand DownExpand Up@@ -2083,7 +2087,7 @@ bool Liveness<TLiveness>::ComputeLifeUntrackedLocal(VARSET_TP& life,
}
}

if (isDef && !anyFieldLive)
if (TLiveness::EliminateDeadCode && isDef && !anyFieldLive)
{
// Do not consider this store dead if the parent local variable is an address exposed local or
// if the struct has any significant padding we must retain the value of.
Expand DownExpand Up@@ -2328,7 +2332,8 @@ void Liveness<TLiveness>::ComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VAR
case GT_CALL:
{
GenTreeCall* const call = node->AsCall();
if ((call->TypeIs(TYP_VOID) || call->IsUnusedValue()) && !call->HasSideEffects(m_compiler))
if (TLiveness::EliminateDeadCode && (call->TypeIs(TYP_VOID) || call->IsUnusedValue()) &&
!call->HasSideEffects(m_compiler))
{
JITDUMP("Removing dead call:\n");
DISPNODE(call);
Expand DownExpand Up@@ -2375,13 +2380,13 @@ void Liveness<TLiveness>::ComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VAR
GenTreeLclVarCommon* const lclVarNode = node->AsLclVarCommon();
LclVarDsc& varDsc = m_compiler->lvaTable[lclVarNode->GetLclNum()];

if (node->IsUnusedValue())
if (TLiveness::EliminateDeadCode && node->IsUnusedValue())
{
JITDUMP("Removing dead LclVar use:\n");
DISPNODE(lclVarNode);

blockRange.Delete(m_compiler, block, node);
if (varDsc.lvTracked && !m_compiler->opts.MinOpts())
if (varDsc.lvTracked)
{
m_compiler->fgStmtRemoved = true;
}
Expand All@@ -2398,14 +2403,14 @@ void Liveness<TLiveness>::ComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VAR
}

case GT_LCL_ADDR:
if (node->IsUnusedValue())
if (TLiveness::EliminateDeadCode && node->IsUnusedValue())
{
JITDUMP("Removing dead LclVar address:\n");
DISPNODE(node);

const bool isTracked = m_compiler->lvaTable[node->AsLclVarCommon()->GetLclNum()].lvTracked;
blockRange.Delete(m_compiler, block, node);
if (isTracked && !m_compiler->opts.MinOpts())
if (isTracked)
{
m_compiler->fgStmtRemoved = true;
}
Expand All@@ -2423,7 +2428,7 @@ void Liveness<TLiveness>::ComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VAR
}

isDeadStore = ComputeLifeLocal(life, keepAliveVars, node);
if (isDeadStore)
if (TLiveness::EliminateDeadCode && isDeadStore)
{
LIR::Use addrUse;
if (blockRange.TryGetUse(node, &addrUse) && addrUse.User()->OperIs(GT_STOREIND, GT_STORE_BLK))
Expand DownExpand Up@@ -2464,7 +2469,7 @@ void Liveness<TLiveness>::ComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VAR
isDeadStore = ComputeLifeUntrackedLocal(life, keepAliveVars, varDsc, lclVarNode);
}

if (isDeadStore && TryRemoveDeadStoreLIR(node, lclVarNode, block))
if (TLiveness::EliminateDeadCode && isDeadStore && TryRemoveDeadStoreLIR(node, lclVarNode, block))
{
GenTree* value = lclVarNode->Data();
value->SetUnusedValue();
Expand All@@ -2491,7 +2496,7 @@ void Liveness<TLiveness>::ComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VAR
#endif // FEATURE_MASKED_HW_INTRINSICS
case GT_PHYSREG:
// These are all side-effect-free leaf nodes.
if (node->IsUnusedValue())
if (TLiveness::EliminateDeadCode && node->IsUnusedValue())
{
JITDUMP("Removing dead node:\n");
DISPNODE(node);
Expand DownExpand Up@@ -2693,6 +2698,11 @@ bool Liveness<TLiveness>::TryRemoveDeadStoreLIR(GenTree* store, GenTreeLclVarCom
template <typename TLiveness>
bool Liveness<TLiveness>::TryRemoveNonLocalLIR(GenTree* node, LIR::Range* blockRange)
{
if (!TLiveness::EliminateDeadCode)
{
return false;
}

assert(!node->OperIsLocal());
if (!node->IsValue() || node->IsUnusedValue())
{
Expand DownExpand Up@@ -2816,6 +2826,7 @@ void Compiler::fgSsaLiveness()
ComputeMemoryLiveness = true,
IsLIR = false,
IsEarly = false,
EliminateDeadCode = true,
};

SsaLivenessClass(Compiler* comp)
Expand All@@ -2841,6 +2852,7 @@ void Compiler::fgAsyncLiveness()
ComputeMemoryLiveness = false,
IsLIR = true,
IsEarly = false,
EliminateDeadCode = false,
};

AsyncLiveness(Compiler* comp)
Expand All@@ -2866,6 +2878,7 @@ void Compiler::fgPostLowerLiveness()
ComputeMemoryLiveness = false,
IsLIR = true,
IsEarly = false,
EliminateDeadCode = true,
};

PostLowerLiveness(Compiler* comp)
Expand DownExpand Up@@ -2909,6 +2922,7 @@ PhaseStatus Compiler::fgEarlyLiveness()
ComputeMemoryLiveness = false,
IsLIR = false,
IsEarly = true,
EliminateDeadCode = true,
};

EarlyLiveness(Compiler* comp)
Expand Down
Loading