Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add an assert to catch the missing places
  • Loading branch information
kunalspathak committed Sep 2, 2021
commit af3faa2edef21ae16f8081279e1808db884f7c18
3 changes: 3 additions & 0 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,9 @@ class LclVarDsc
unsigned char lvUnusedStruct : 1; // All references to this promoted struct are through its field locals.
// I.e. there is no longer any reference to the struct directly.
// In this case we can simply remove this struct local.

unsigned char lvUndoneStructPromotion : 1; // The struct promotion was undone and hence there should be no
// reference to the fields of this struct.
#endif

unsigned char lvLRACandidate : 1; // Tracked for linear scan register allocation purposes
Expand Down
10 changes: 10 additions & 0 deletions src/coreclr/jit/lclvars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4075,6 +4075,16 @@ void Compiler::lvaMarkLclRefs(GenTree* tree, BasicBlock* block, Statement* stmt,

varDsc->incRefCnts(weight, this);

#ifdef DEBUG
if (varDsc->lvIsStructField)
{
// If ref count was increased for struct field, ensure that the
// parent struct is still promoted.
LclVarDsc* parentStruct = &lvaTable[varDsc->lvParentLcl];
assert(!parentStruct->lvUndoneStructPromotion);
}
#endif

if (!isRecompute)
{
if (lvaVarAddrExposed(lclNum))
Expand Down
9 changes: 8 additions & 1 deletion src/coreclr/jit/morph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17535,6 +17535,8 @@ void Compiler::fgRetypeImplicitByRefArgs()

void Compiler::fgMarkDemotedImplicitByRefArgs()
{
JITDUMP("\n*************** In fgMarkDemotedImplicitByRefArgs()\n");

#if (defined(TARGET_AMD64) && !defined(UNIX_AMD64_ABI)) || defined(TARGET_ARM64)

for (unsigned lclNum = 0; lclNum < info.compArgsCount; lclNum++)
Expand All @@ -17543,6 +17545,8 @@ void Compiler::fgMarkDemotedImplicitByRefArgs()

if (lvaIsImplicitByRefLocal(lclNum))
{
JITDUMP("Clearing annotation for V%02d\n", lclNum);

if (varDsc->lvPromoted)
{
// The parameter is simply a pointer now, so clear lvPromoted. It was left set
Expand All @@ -17569,7 +17573,8 @@ void Compiler::fgMarkDemotedImplicitByRefArgs()
LclVarDsc* structVarDsc = &lvaTable[structLclNum];
structVarDsc->lvAddrExposed = false;
#ifdef DEBUG
structVarDsc->lvUnusedStruct = true;
structVarDsc->lvUnusedStruct = true;
structVarDsc->lvUndoneStructPromotion = true;
#endif // DEBUG

unsigned fieldLclStart = structVarDsc->lvFieldLclStart;
Expand All @@ -17578,6 +17583,8 @@ void Compiler::fgMarkDemotedImplicitByRefArgs()

for (unsigned fieldLclNum = fieldLclStart; fieldLclNum < fieldLclStop; ++fieldLclNum)
{
JITDUMP("Fixing pointer for field V%02d from V%02d to V%02d\n", fieldLclNum, lclNum, structLclNum);

// Fix the pointer to the parent local.
LclVarDsc* fieldVarDsc = &lvaTable[fieldLclNum];
assert(fieldVarDsc->lvParentLcl == lclNum);
Expand Down