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