Skip to content

Commit

Permalink
Avoid calling getEnclosingBlock
Browse files Browse the repository at this point in the history
While performing analysis for flush elimination,
LocalFlushElimination::examineNode called TR::TreeTop::getEnclosingBlock
on the current TR::TreeTop.  As that method walks through the linked
list chaining together the TR::TreeTops to find the corresponding
BBStart, calling it in nested loops becomes very expensive when large
blocks are encountered.

Fixed this by passing the current block as an argument to
LocalFlushElimination::examineNode

Signed-off-by:  Henry Zongaro <[email protected]>
  • Loading branch information
hzongaro committed Dec 12, 2022
1 parent 7cafd4b commit 42b0411
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions runtime/compiler/optimizer/EscapeAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9153,7 +9153,7 @@ int32_t TR_LocalFlushElimination::perform()
_allocationInfo->empty();
}

examineNode(node, treeTop, visited);
examineNode(node, treeTop, block, visited);
}

FlushCandidate *flushCandidate;
Expand All @@ -9174,7 +9174,7 @@ int32_t TR_LocalFlushElimination::perform()
}


bool TR_LocalFlushElimination::examineNode(TR::Node *node, TR::TreeTop *tt, TR::NodeChecklist& visited)
bool TR_LocalFlushElimination::examineNode(TR::Node *node, TR::TreeTop *tt, TR::Block *currBlock, TR::NodeChecklist& visited)
{
if (visited.contains(node))
return true;
Expand Down Expand Up @@ -9356,7 +9356,7 @@ bool TR_LocalFlushElimination::examineNode(TR::Node *node, TR::TreeTop *tt, TR::
{
if (reachingFlushCandidate->isOptimallyPlaced() ||
reachingFlushCandidate->getFlush()->getNode()->getAllocation() == NULL ||
reachingFlushCandidate->getBlockNum() != tt->getEnclosingBlock()->getNumber())
reachingFlushCandidate->getBlockNum() != currBlock->getNumber())
continue;
reachingCandidate = getCandidate(_candidates, reachingFlushCandidate);
if (!reachingCandidate)
Expand Down Expand Up @@ -9531,7 +9531,7 @@ bool TR_LocalFlushElimination::examineNode(TR::Node *node, TR::TreeTop *tt, TR::
{
TR::Node *child = node->getChild(i);

if (!examineNode(child, tt, visited))
if (!examineNode(child, tt, currBlock, visited))
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion runtime/compiler/optimizer/EscapeAnalysis.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ class TR_LocalFlushElimination
TR_LocalFlushElimination(TR_EscapeAnalysis *, int32_t numAllocations);

virtual int32_t perform();
bool examineNode(TR::Node *, TR::TreeTop *, TR::NodeChecklist& visited);
bool examineNode(TR::Node *, TR::TreeTop *, TR::Block *, TR::NodeChecklist& visited);

TR::Optimizer * optimizer() { return _escapeAnalysis->optimizer(); }
TR::Compilation * comp() { return _escapeAnalysis->comp(); }
Expand Down

0 comments on commit 42b0411

Please sign in to comment.