Skip to content

Commit

Permalink
Manage additional blocks in OSR infrastructure
Browse files Browse the repository at this point in the history
If OSR exception edge removal is run sufficiently
late, blocks may have been added between OSR
catch and code blocks. In this situation, the
assumptions made by DeadStoreCleanup may be
invalid, so it should stop.

Moreover, OSR exception edge removal should not
run if infrastructure has already been removed.

Signed-off-by: Nicholas Coughlin <[email protected]>
  • Loading branch information
Nicholas Coughlin committed Oct 23, 2017
1 parent 4a9ac58 commit 35e988e
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion compiler/optimizer/OSRDefAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1574,6 +1574,13 @@ int32_t TR_OSRExceptionEdgeRemoval::perform()
return 0;
}

if (comp()->osrInfrastructureRemoved())
{
if (comp()->getOption(TR_TraceOSR))
traceMsg(comp(), "OSR infrastructure removed -- returning from OSR exception edge removal analysis since we have already removed OSR infrastructure.\n");
return 0;
}

if (comp()->isPeekingMethod())
{
if (comp()->getOption(TR_TraceOSR))
Expand Down Expand Up @@ -1656,7 +1663,6 @@ int32_t TR_OSRExceptionEdgeRemoval::perform()
for (auto edge = block->getPredecessors().begin(); edge != block->getPredecessors().end(); ++edge)
{
TR::Block *osrBlock = toBlock((*edge)->getFrom());
TR_ASSERT(osrBlock && (osrBlock->isOSRCodeBlock() || osrBlock->isOSRCatchBlock()), "Predecessors to an OSR code block should be OSR code or catch blocks");
if (osrBlock->isOSRCodeBlock() && addDeadStores(osrBlock, alwaysDead, !firstPass))
osrBlocks.push(osrBlock);
else if (osrBlock->isOSRCatchBlock())
Expand All @@ -1670,9 +1676,18 @@ int32_t TR_OSRExceptionEdgeRemoval::perform()
firstPass = false;
}
}
else
{
// Another block was found in the OSR infrastructure, give up
alwaysDead.empty();
break;
}
firstPass = false;
}

if (alwaysDead.isEmpty())
continue;

// Remove loads that are always dead
for (int32_t i = 0 ; i < prepareForOSR->getNumChildren(); ++i)
{
Expand Down

0 comments on commit 35e988e

Please sign in to comment.