未验证 提交 ba0778a2 编写于 作者: J Jakob Botsch Nielsen 提交者: GitHub

JIT: Update gtHasLocalsWithAddrOp to use GenTreeVisitor (#75672)

Also change it to check for any local, not just GT_LCL_VAR.
上级 24a9b2f3
...@@ -5900,8 +5900,6 @@ private: ...@@ -5900,8 +5900,6 @@ private:
// the variable is not enregistered, and is therefore not promoted independently. // the variable is not enregistered, and is therefore not promoted independently.
void fgLclFldAssign(unsigned lclNum); void fgLclFldAssign(unsigned lclNum);
static fgWalkPreFn gtHasLocalsWithAddrOpCB;
enum TypeProducerKind enum TypeProducerKind
{ {
TPK_Unknown = 0, // May not be a RuntimeType TPK_Unknown = 0, // May not be a RuntimeType
......
...@@ -2724,48 +2724,49 @@ AGAIN: ...@@ -2724,48 +2724,49 @@ AGAIN:
return result; return result;
} }
struct AddrTakenDsc //------------------------------------------------------------------------------
{ // gtHasLocalsWithAddrOp:
Compiler* comp; // Check if this tree contains locals with lvHasLdAddrOp or
bool hasAddrTakenLcl; // IsAddressExposed() flags set. Does a full tree walk.
}; //
// Paramters:
/* static */ // tree - the tree
Compiler::fgWalkResult Compiler::gtHasLocalsWithAddrOpCB(GenTree** pTree, fgWalkData* data) //
// Return Value:
// True if any sub tree is such a local.
//
bool Compiler::gtHasLocalsWithAddrOp(GenTree* tree)
{ {
GenTree* tree = *pTree; struct LocalsWithAddrOpVisitor : GenTreeVisitor<LocalsWithAddrOpVisitor>
Compiler* comp = data->compiler;
if (tree->gtOper == GT_LCL_VAR)
{ {
const LclVarDsc* varDsc = comp->lvaGetDesc(tree->AsLclVarCommon()); enum
if (varDsc->lvHasLdAddrOp || varDsc->IsAddressExposed())
{ {
((AddrTakenDsc*)data->pCallbackData)->hasAddrTakenLcl = true; DoPreOrder = true,
return WALK_ABORT; DoLclVarsOnly = true,
} };
}
return WALK_CONTINUE;
}
/***************************************************************************** bool HasAddrTakenLocal = false;
*
* Return true if this tree contains locals with lvHasLdAddrOp or IsAddressExposed()
* flag(s) set.
*/
bool Compiler::gtHasLocalsWithAddrOp(GenTree* tree) LocalsWithAddrOpVisitor(Compiler* comp) : GenTreeVisitor(comp)
{ {
AddrTakenDsc desc; }
desc.comp = this; fgWalkResult PreOrderVisit(GenTree** use, GenTree* user)
desc.hasAddrTakenLcl = false; {
LclVarDsc* varDsc = m_compiler->lvaGetDesc((*use)->AsLclVarCommon());
if (varDsc->lvHasLdAddrOp || varDsc->IsAddressExposed())
{
HasAddrTakenLocal = true;
return WALK_ABORT;
}
fgWalkTreePre(&tree, gtHasLocalsWithAddrOpCB, &desc); return WALK_CONTINUE;
}
};
return desc.hasAddrTakenLcl; LocalsWithAddrOpVisitor visitor(this);
visitor.WalkTree(&tree, nullptr);
return visitor.HasAddrTakenLocal;
} }
#ifdef DEBUG #ifdef DEBUG
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册