From d9ad8a0755032b6ef8ddbe486eb59f425eae77c4 Mon Sep 17 00:00:00 2001 From: Jackie Midroni Date: Wed, 28 Aug 2024 19:14:46 -0400 Subject: [PATCH] Bug fix (https://github.com/eclipse-openj9/openj9/issues/19947) A crash was occuring in Unsafe.get/put() case (6) when trying to modify the CFG to include the newly generated directAccessBlock. To avoid this, we can simply append the directAccessTreeTop onto the previous block (beforeCallBlock), which elimiates the need to update the CFG, since no new blocks are added. Additionally, without this commit, these two blocks (in addition to the one after the directAccessBlock, joinBlock), would get merged during block simplication anyways: so this fix eliminates the need to perform that optimization later down the line. Signed-off-by: midronij --- .../compiler/optimizer/InlinerTempForJ9.cpp | 26 +++---------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/runtime/compiler/optimizer/InlinerTempForJ9.cpp b/runtime/compiler/optimizer/InlinerTempForJ9.cpp index 7d94f317d60..0f9d9a66e01 100644 --- a/runtime/compiler/optimizer/InlinerTempForJ9.cpp +++ b/runtime/compiler/optimizer/InlinerTempForJ9.cpp @@ -1065,17 +1065,8 @@ TR_J9InlinerPolicy::genCodeForUnsafeGetPut(TR::Node* unsafeAddress, //SPECIAL CASE if (!directAccessWithConversionTreeTop && conversionNeeded) { - //Generating block for arrayDirectAccess (direct access with conversion) - arrayDirectAccessBlock = TR::Block::createEmptyBlock(callNodeTreeTop->getNode(), comp(), - joinBlock->getFrequency()); - arrayDirectAccessBlock->append(arrayDirectAccessTreeTop); - beforeCallBlock->getExit()->insertTreeTopsAfterMe(arrayDirectAccessBlock->getEntry(), arrayDirectAccessBlock->getExit()); - - //add arrayDirectAccessBlock to cfg - cfg->addNode(arrayDirectAccessBlock); - cfg->addEdge(TR::CFGEdge::createEdge(beforeCallBlock, arrayDirectAccessBlock, trMemory())); - cfg->addEdge(TR::CFGEdge::createEdge(arrayDirectAccessBlock, joinBlock, trMemory())); - cfg->removeEdge(beforeCallBlock, joinBlock); + //Since no runtime tests are being performed, we can simply append the arrayDirectAccessTreeTop to beforeCallBlock + beforeCallBlock->append(arrayDirectAccessTreeTop); } else { @@ -1093,17 +1084,8 @@ TR_J9InlinerPolicy::genCodeForUnsafeGetPut(TR::Node* unsafeAddress, } else // CASE (6) { - //Generating block for direct access - directAccessBlock = TR::Block::createEmptyBlock(callNodeTreeTop->getNode(), comp(), - joinBlock->getFrequency()); - directAccessBlock->append(directAccessTreeTop); - beforeCallBlock->getExit()->insertTreeTopsAfterMe(directAccessBlock->getEntry(), directAccessBlock->getExit()); - - //add directAccessBlock to cfg - cfg->addNode(directAccessBlock); - cfg->addEdge(TR::CFGEdge::createEdge(beforeCallBlock, directAccessBlock, trMemory())); - cfg->addEdge(TR::CFGEdge::createEdge(directAccessBlock, joinBlock, trMemory())); - cfg->removeEdge(beforeCallBlock, joinBlock); + //Since no runtime tests are being performed, we can simply append the directAccessTreeTop to beforeCallBlock + beforeCallBlock->append(directAccessTreeTop); } if (directAccessBlock)