Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 2 additions & 0 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -10858,6 +10858,8 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
public:
struct ShadowParamVarInfo
{
static const unsigned NO_SHADOW_COPY = UINT_MAX;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: why not just use BAD_VAR_NUM?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose no reason. Deleted it.


FixedBitVect* assignGroup; // the closure set of variables whose values depend on each other
unsigned shadowCopy; // Lcl var num, valid only if not set to NO_SHADOW_COPY

Expand Down
18 changes: 12 additions & 6 deletions src/coreclr/jit/copyprop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ void Compiler::optCopyProp(Statement* stmt,
}

if ((gsShadowVarInfo != nullptr) && newLclVarDsc->lvIsParam &&
(gsShadowVarInfo[newLclNum].shadowCopy == lclNum))
(gsShadowVarInfo[newLclNum].shadowCopy != ShadowParamVarInfo::NO_SHADOW_COPY))
{
continue;
}
Expand All @@ -172,11 +172,6 @@ void Compiler::optCopyProp(Statement* stmt,
continue;
}

if (newLclDefNode->TypeGet() != tree->TypeGet())
{
continue;
}

ValueNum lclDefVN = varDsc->GetPerSsaData(tree->GetSsaNum())->m_vnPair.GetConservative();
if (newLclDefVN != lclDefVN)
{
Expand Down Expand Up @@ -226,6 +221,17 @@ void Compiler::optCopyProp(Statement* stmt,
continue;
}

var_types newLclType = newLclVarDsc->TypeGet();
if (!newLclVarDsc->lvNormalizeOnLoad())
{
newLclType = genActualType(newLclType);
}

if (newLclType != tree->TypeGet())
{
continue;
}

#ifdef DEBUG
if (verbose)
{
Expand Down
10 changes: 4 additions & 6 deletions src/coreclr/jit/gschecks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ void Compiler::gsGSChecksInitCookie()
info.compCompHnd->getGSCookie(&gsGlobalSecurityCookieVal, &gsGlobalSecurityCookieAddr);
}

const unsigned NO_SHADOW_COPY = UINT_MAX;

/*****************************************************************************
* gsCopyShadowParams
* The current function has an unsafe buffer on the stack. Search for vulnerable
Expand Down Expand Up @@ -368,7 +366,7 @@ void Compiler::gsParamsToShadows()
for (UINT lclNum = 0; lclNum < lvaOldCount; lclNum++)
{
LclVarDsc* varDsc = lvaGetDesc(lclNum);
gsShadowVarInfo[lclNum].shadowCopy = NO_SHADOW_COPY;
gsShadowVarInfo[lclNum].shadowCopy = ShadowParamVarInfo::NO_SHADOW_COPY;

// Only care about params whose values are on the stack
if (!ShadowParamVarInfo::mayNeedShadowCopy(varDsc))
Expand Down Expand Up @@ -452,7 +450,7 @@ void Compiler::gsParamsToShadows()
unsigned int lclNum = tree->AsLclVarCommon()->GetLclNum();
unsigned int shadowLclNum = m_compiler->gsShadowVarInfo[lclNum].shadowCopy;

if (shadowLclNum != NO_SHADOW_COPY)
if (shadowLclNum != Compiler::ShadowParamVarInfo::NO_SHADOW_COPY)
{
LclVarDsc* varDsc = m_compiler->lvaGetDesc(lclNum);
assert(ShadowParamVarInfo::mayNeedShadowCopy(varDsc));
Expand Down Expand Up @@ -492,7 +490,7 @@ void Compiler::gsParamsToShadows()
const LclVarDsc* varDsc = lvaGetDesc(lclNum);

const unsigned shadowVarNum = gsShadowVarInfo[lclNum].shadowCopy;
if (shadowVarNum == NO_SHADOW_COPY)
if (shadowVarNum == ShadowParamVarInfo::NO_SHADOW_COPY)
{
continue;
}
Expand Down Expand Up @@ -544,7 +542,7 @@ void Compiler::gsParamsToShadows()
const LclVarDsc* varDsc = lvaGetDesc(lclNum);

const unsigned shadowVarNum = gsShadowVarInfo[lclNum].shadowCopy;
if (shadowVarNum == NO_SHADOW_COPY)
if (shadowVarNum == ShadowParamVarInfo::NO_SHADOW_COPY)
{
continue;
}
Expand Down