From 704da43eadc1d922acbff678bbed175c1db0d704 Mon Sep 17 00:00:00 2001 From: Annabelle Huo Date: Tue, 5 Mar 2024 13:44:29 -0500 Subject: [PATCH] Do not swing down volatile nodes Volatile nodes should always be anchored under a treetop to avoid any interference with other optimization passes (e.g. PRE). Fixes eclipse-openj9/openj9#18777 Signed-off-by: Annabelle Huo --- compiler/optimizer/DeadTreesElimination.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/compiler/optimizer/DeadTreesElimination.cpp b/compiler/optimizer/DeadTreesElimination.cpp index c9c5942548e..bdd6c22f013 100644 --- a/compiler/optimizer/DeadTreesElimination.cpp +++ b/compiler/optimizer/DeadTreesElimination.cpp @@ -265,6 +265,9 @@ static bool isSafeToReplaceNode(TR::Node *currentNode, TR::TreeTop *curTreeTop, return false; bool mayBeVolatileReference = currentNode->mightHaveVolatileSymbolReference(); + // Do not swing down volatile nodes + if (mayBeVolatileReference) + return false; // Now scan forwards through the trees looking for the next use and checking // to see if any symbols in the subtree are getting modified; if so it is not @@ -303,8 +306,8 @@ static bool isSafeToReplaceNode(TR::Node *currentNode, TR::TreeTop *curTreeTop, * => xload/xloadi a.volatileField * ... */ - if (mayBeVolatileReference && !canMoveIfVolatile) - return false; + //if (mayBeVolatileReference && !canMoveIfVolatile) + // return false; if (nodeInSubTree) {