Skip to content

Commit

Permalink
Merge pull request #95 from ncough/eaLoopCheck
Browse files Browse the repository at this point in the history
Correct escape analysis loop check
  • Loading branch information
andrewcraik authored Sep 25, 2017
2 parents a0c8d18 + 494b696 commit c01ae1b
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions runtime/tr.source/trj9/optimizer/EscapeAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,17 @@

extern void createGuardSiteForRemovedGuard(TR::Compilation *comp, TR::Node* ifNode);

static bool blockIsInLoop(TR::Block *block)
{
for (TR_Structure *s = block->getStructureOf()->getParent(); s; s = s->getParent())
{
TR_RegionStructure *region = s->asRegion();
if (region->isNaturalLoop() || region->containsInternalCycles())
return true;
}
return false;
}

TR_EscapeAnalysis::TR_EscapeAnalysis(TR::OptimizationManager *manager)
: TR::Optimization(manager),
_newObjectNoZeroInitSymRef(NULL),
Expand Down Expand Up @@ -1048,8 +1059,8 @@ int32_t TR_EscapeAnalysis::performAnalysisOnce()
if (comp()->getStartBlock() && !_candidates.isEmpty())
{
TR::Block *block = comp()->getStartBlock();
bool isInLoop = (block->getStructureOf()->getContainingLoop() != NULL);
if (isInLoop)

if (blockIsInLoop(block))
{
comp()->getFlowGraph()->setStructure(NULL);
TR::Block *firstBlockReplacement = toBlock(comp()->getFlowGraph()->addNode(
Expand Down Expand Up @@ -1418,15 +1429,9 @@ void TR_EscapeAnalysis::findCandidates()
{
candidate->setExplicitlyInitialized();
}
for (TR_Structure *s = _curBlock->getStructureOf()->getParent(); s; s = s->getParent())
{
TR_RegionStructure *region = s->asRegion();
if (region->isNaturalLoop() || region->containsInternalCycles())
{
candidate->setInsideALoop();
break;
}
}

if (blockIsInLoop(_curBlock))
candidate->setInsideALoop();

if (inAColdBlock)
candidate->setInAColdBlock(true);
Expand Down

0 comments on commit c01ae1b

Please sign in to comment.