// locate our parent node and update it so that it points to newTree.
if (newTree != tree)
{
- GenTree** link = gtFindLink(stmt, tree);
+ FindLinkData linkData = gtFindLink(stmt, tree);
+ GenTree** link = linkData.result;
noway_assert(link != nullptr);
// Replace the old operand with the newTree
static fgWalkPreFn gtMarkColonCond;
static fgWalkPreFn gtClearColonCond;
- GenTree** gtFindLink(GenTreeStmt* stmt, GenTree* node);
+ struct FindLinkData
+ {
+ GenTree* nodeToFind;
+ GenTree** result;
+ GenTree* parent;
+ };
+
+ FindLinkData gtFindLink(GenTreeStmt* stmt, GenTree* node);
bool gtHasCatchArg(GenTree* tree);
typedef ArrayStack<GenTree*> GenTreeStack;
fgArgTabEntry* thisArgTabEntry = gtArgEntryByArgNum(call, argNum);
GenTree* result = thisArgTabEntry->node;
+ // Assert if we used DEBUG_DESTROY_NODE.
+ assert(result->gtOper != GT_COUNT);
+
#if !FEATURE_FIXED_OUT_ARGS && defined(DEBUG)
// Check that call->fgArgInfo used in gtArgEntryByArgNum was not
// left outdated by assertion propogation updates.
index++;
}
#endif // !FEATURE_FIXED_OUT_ARGS && defined(DEBUG)
+
return result;
}
}
return WALK_CONTINUE;
}
-struct FindLinkData
-{
- GenTree* nodeToFind;
- GenTree** result;
-};
-
/*****************************************************************************
*
* Callback used by the tree walker to implement fgFindLink()
*/
static Compiler::fgWalkResult gtFindLinkCB(GenTree** pTree, Compiler::fgWalkData* cbData)
{
- FindLinkData* data = (FindLinkData*)cbData->pCallbackData;
+ Compiler::FindLinkData* data = (Compiler::FindLinkData*)cbData->pCallbackData;
if (*pTree == data->nodeToFind)
{
data->result = pTree;
+ data->parent = cbData->parent;
return Compiler::WALK_ABORT;
}
return Compiler::WALK_CONTINUE;
}
-GenTree** Compiler::gtFindLink(GenTreeStmt* stmt, GenTree* node)
+Compiler::FindLinkData Compiler::gtFindLink(GenTreeStmt* stmt, GenTree* node)
{
- FindLinkData data = {node, nullptr};
+ FindLinkData data = {node, nullptr, nullptr};
fgWalkResult result = fgWalkTreePre(&stmt->gtStmtExpr, gtFindLinkCB, &data);
if (result == WALK_ABORT)
{
assert(data.nodeToFind == *data.result);
- return data.result;
+ return data;
}
else
{
- return nullptr;
+ return {node, nullptr, nullptr};
}
}
// Walk the statement 'stmt' and find the pointer
// in the tree is pointing to 'exp'
//
- GenTree** link = m_pCompiler->gtFindLink(stmt, exp);
+ Compiler::FindLinkData linkData = m_pCompiler->gtFindLink(stmt, exp);
+ GenTree** link = linkData.result;
#ifdef DEBUG
if (link == nullptr)