Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TODO-List-Cleanup] Delete NumChildren, GetChild and gtGetChildPointer #61875

Merged
merged 5 commits into from
Nov 30, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 0 additions & 8 deletions src/coreclr/jit/block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -841,14 +841,6 @@ Statement* BasicBlock::lastStmt() const
return result;
}

//------------------------------------------------------------------------
// BasicBlock::firstNode: Returns the first node in the block.
//
GenTree* BasicBlock::firstNode() const
{
return IsLIR() ? GetFirstLIRNode() : Compiler::fgGetFirstNode(firstStmt()->GetRootNode());
}

//------------------------------------------------------------------------
// BasicBlock::lastNode: Returns the last node in the block.
//
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/jit/block.h
Original file line number Diff line number Diff line change
Expand Up @@ -1248,7 +1248,6 @@ struct BasicBlock : private LIR::Range
return StatementList(FirstNonPhiDef());
}

GenTree* firstNode() const;
GenTree* lastNode() const;

bool endsWithJmpMethod(Compiler* comp) const;
Expand Down
17 changes: 5 additions & 12 deletions src/coreclr/jit/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8942,8 +8942,6 @@ BasicBlock* dbBlock;

GenTree* dFindTree(GenTree* tree, unsigned id)
{
GenTree* child;

if (tree == nullptr)
{
return nullptr;
Expand All @@ -8955,18 +8953,13 @@ GenTree* dFindTree(GenTree* tree, unsigned id)
return tree;
}

unsigned childCount = tree->NumChildren();
for (unsigned childIndex = 0; childIndex < childCount; childIndex++)
{
child = tree->GetChild(childIndex);
GenTree* child = nullptr;
tree->VisitOperands([&child, id](GenTree* operand) -> GenTree::VisitResult {
child = dFindTree(child, id);
if (child != nullptr)
{
return child;
}
}
return (child != nullptr) ? GenTree::VisitResult::Abort : GenTree::VisitResult::Continue;
});

return nullptr;
return child;
}

GenTree* dFindTree(unsigned id)
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -3626,7 +3626,7 @@ class Compiler
void gtDispBlockStmts(BasicBlock* block);
void gtGetArgMsg(GenTreeCall* call, GenTree* arg, unsigned argNum, char* bufp, unsigned bufLength);
void gtGetLateArgMsg(GenTreeCall* call, GenTree* arg, int argNum, char* bufp, unsigned bufLength);
void gtDispArgList(GenTreeCall* call, IndentStack* indentStack);
void gtDispArgList(GenTreeCall* call, GenTree* lastCallOperand, IndentStack* indentStack);
void gtDispFieldSeq(FieldSeqNode* pfsn);

void gtDispRange(LIR::ReadOnlyRange const& range);
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/jit/compiler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4254,6 +4254,7 @@ void GenTree::VisitOperands(TVisitor visitor)
case GT_BOX:
case GT_ALLOCOBJ:
case GT_INIT_VAL:
case GT_RUNTIMELOOKUP:
case GT_JTRUE:
case GT_SWITCH:
case GT_NULLCHECK:
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/earlyprop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ bool Compiler::optIsNullCheckFoldingLegal(GenTree* tree,
assert(fgStmtListThreaded);
while (canRemoveNullCheck && (currentTree != tree) && (currentTree != nullptr))
{
if ((*nullCheckParent == nullptr) && (nullCheckTree->gtGetChildPointer(currentTree) != nullptr))
if ((*nullCheckParent == nullptr) && currentTree->TryGetUse(nullCheckTree))
{
*nullCheckParent = currentTree;
}
Expand Down
43 changes: 18 additions & 25 deletions src/coreclr/jit/flowgraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4426,32 +4426,29 @@ void Compiler::fgSetBlockOrder(BasicBlock* block)
// Return Value:
// The first node in execution order, that belongs to tree.
//
// Assumptions:
// 'tree' must either be a leaf, or all of its constituent nodes must be contiguous
// in execution order.
// TODO-Cleanup: Add a debug-only method that verifies this.

/* static */
GenTree* Compiler::fgGetFirstNode(GenTree* tree)
// Notes:
// This function is only correct for HIR trees.
//
/* static */ GenTree* Compiler::fgGetFirstNode(GenTree* tree)
{
GenTree* child = tree;
while (child->NumChildren() > 0)
GenTree* firstNode = tree;
while (true)
{
if ((child->OperIsBinary() || child->OperIsMultiOp()) && child->IsReverseOp())
{
child = child->GetChild(1);
}
else
auto operandsBegin = firstNode->OperandsBegin();
auto operandsEnd = firstNode->OperandsEnd();

if (operandsBegin == operandsEnd)
{
child = child->GetChild(0);
break;
}

firstNode = *operandsBegin;
}
return child;

return firstNode;
}

/*****************************************************************************/
/*static*/
Compiler::fgWalkResult Compiler::fgChkThrowCB(GenTree** pTree, fgWalkData* data)
/*static*/ Compiler::fgWalkResult Compiler::fgChkThrowCB(GenTree** pTree, fgWalkData* data)
{
GenTree* tree = *pTree;

Expand Down Expand Up @@ -4493,9 +4490,7 @@ Compiler::fgWalkResult Compiler::fgChkThrowCB(GenTree** pTree, fgWalkData* data)
return Compiler::WALK_CONTINUE;
}

/*****************************************************************************/
/*static*/
Compiler::fgWalkResult Compiler::fgChkLocAllocCB(GenTree** pTree, fgWalkData* data)
/*static*/ Compiler::fgWalkResult Compiler::fgChkLocAllocCB(GenTree** pTree, fgWalkData* data)
{
GenTree* tree = *pTree;

Expand All @@ -4507,9 +4502,7 @@ Compiler::fgWalkResult Compiler::fgChkLocAllocCB(GenTree** pTree, fgWalkData* da
return Compiler::WALK_CONTINUE;
}

/*****************************************************************************/
/*static*/
Compiler::fgWalkResult Compiler::fgChkQmarkCB(GenTree** pTree, fgWalkData* data)
/*static*/ Compiler::fgWalkResult Compiler::fgChkQmarkCB(GenTree** pTree, fgWalkData* data)
{
GenTree* tree = *pTree;

Expand Down
Loading