Skip to content
Merged
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
21 changes: 19 additions & 2 deletions src/coreclr/jit/copyprop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ void Compiler::optCopyPropPushDef(GenTreeOp* asg,
{
assert((lclNode->gtFlags & GTF_VAR_DEF) != 0);

// Quirk: do not collect defs from PHIs. Preserves previous behavior.
// TODO-CQ: design better heuristics for propagation and remove this condition.
if (!asg->IsPhiDefn())
{
ssaDefNum = GetSsaNumForLocalVarDef(lclNode);
Expand Down Expand Up @@ -480,10 +480,27 @@ void Compiler::optVnCopyProp()
// TODO-Cleanup: Move this function from Compiler to this class.
m_compiler->optBlockCopyPropPopStacks(block, &m_curSsaName);
}

void PropagateCopies()
{
WalkTree();

#ifdef DEBUG
// Verify the definitions remaining are only those we pushed for parameters.
for (LclNumToLiveDefsMap::KeyIterator iter = m_curSsaName.Begin(); !iter.Equal(m_curSsaName.End()); ++iter)
{
unsigned lclNum = iter.Get();
assert(m_compiler->lvaGetDesc(lclNum)->lvIsParam || (lclNum == m_compiler->info.compThisArg));

CopyPropSsaDefStack* defStack = iter.GetValue();
assert(defStack->Height() == 1);
}
#endif // DEBUG
}
};

CopyPropDomTreeVisitor visitor(this);
visitor.WalkTree();
visitor.PropagateCopies();

// Tracked variable count increases after CopyProp, so don't keep a shorter array around.
// Destroy (release) the varset.
Expand Down