From 35e988e4e88e1b2ffe12895206dae448b3f0ab6c Mon Sep 17 00:00:00 2001 From: Nicholas Coughlin Date: Mon, 23 Oct 2017 13:37:11 -0400 Subject: [PATCH] Manage additional blocks in OSR infrastructure 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 --- compiler/optimizer/OSRDefAnalysis.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/compiler/optimizer/OSRDefAnalysis.cpp b/compiler/optimizer/OSRDefAnalysis.cpp index 4604d5c8ea9..c445c606d2a 100644 --- a/compiler/optimizer/OSRDefAnalysis.cpp +++ b/compiler/optimizer/OSRDefAnalysis.cpp @@ -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)) @@ -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()) @@ -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) {