Skip to content

Commit

Permalink
Merge pull request #16547 from hzongaro/flush-elimination-assertion
Browse files Browse the repository at this point in the history
Allow allocationFence to be reenabled by Local Flush Elimination
  • Loading branch information
vijaysun-omr committed Jan 13, 2023
2 parents 0e5cdb4 + b7e819d commit acf3290
Showing 1 changed file with 32 additions and 12 deletions.
44 changes: 32 additions & 12 deletions runtime/compiler/optimizer/EscapeAnalysis.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2022 IBM Corp. and others
* Copyright (c) 2000, 2023 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -6000,7 +6000,7 @@ bool TR_EscapeAnalysis::fixupNode(TR::Node *node, TR::Node *parent, TR::NodeChec
if (candidate->isLocalAllocation())
{
if (trace())
traceMsg(comp(), "Redundant flush node [%p] found! Set omitSync flag on redundant flush node.\n", node);
traceMsg(comp(), "Redundant flush node [%p] found for candidate [%p]! Set omitSync flag on redundant flush node.\n", node, candidate->_node);

node->setOmitSync(true);
node->setAllocation(NULL);
Expand All @@ -6015,7 +6015,7 @@ bool TR_EscapeAnalysis::fixupNode(TR::Node *node, TR::Node *parent, TR::NodeChec
node->setLocalObjectMonitor(true);
requestOpt(OMR::redundantMonitorElimination);
if (trace())
traceMsg(comp(), "Mark monitor node [%p] as local object monitor\n", node);
traceMsg(comp(), "Mark monitor node [%p] for candidate [%p] as local object monitor\n", node, candidate->_node);
}
#endif
}
Expand All @@ -6040,12 +6040,12 @@ bool TR_EscapeAnalysis::fixupNode(TR::Node *node, TR::Node *parent, TR::NodeChec
flushTT->join(afterInsertionPoint);
insertionPoint->join(flushTT);
if (trace())
traceMsg(comp(), "Adding flush node %p to cold block_%d\n", flush,coldBlk->getNumber());
traceMsg(comp(), "Adding flush node %p for candidate %p to cold block_%d\n", flush, candidate->_node, coldBlk->getNumber());
setHasFlushOnEntry(coldBlk->getNumber());
}
}
if (trace())
traceMsg(comp(), "Remove redundant flush node [%p]\n", node);
traceMsg(comp(), "Remove redundant flush node [%p] for candidate [%p]\n", node, candidate->_node);
removeThisNode = true;

}
Expand Down Expand Up @@ -8631,7 +8631,7 @@ TR_FlowSensitiveEscapeAnalysis::TR_FlowSensitiveEscapeAnalysis(TR::Compilation *
afNode->setAllocation(candidate->_node);
afNode->setOmitSync(false);
if (trace())
traceMsg(comp, "Restoring AF node %p for allocation %p above node %p.\n", afNode, tt->getNode() );
traceMsg(comp, "Restoring AF node %p for allocation %p above node %p.\n", afNode, candidate->_node, tt->getNode());
}
else
{
Expand All @@ -8649,7 +8649,7 @@ TR_FlowSensitiveEscapeAnalysis::TR_FlowSensitiveEscapeAnalysis(TR::Compilation *
TR::Node *afNode = TR::Node::createAllocationFence(candidate->_node, candidate->_node);
tt->insertBefore(TR::TreeTop::create(comp, afNode, NULL, NULL));
if (trace())
traceMsg(comp, "Inserted AF node %p above %p (%s).\n", afNode, tt->getNode(), tt->getNode()->getOpCode().getName() );
traceMsg(comp, "Inserted AF node %p for candidate %p above %p (%s).\n", afNode, candidate->_node, tt->getNode(), tt->getNode()->getOpCode().getName() );
//fprintf( stderr, "Inserted AF node %p above %p (%s).\n", afNode, tt->getNode(), tt->getNode()->getOpCode().getName() );
}
}
Expand Down Expand Up @@ -9328,6 +9328,10 @@ bool TR_LocalFlushElimination::examineNode(TR::Node *node, TR::TreeTop *tt, TR::
if (trace())
{
traceMsg(comp(), "\nConsidering Flush %p for allocation %p (index %d)\n", flushCandidate->getFlush()->getNode(), candidate->_node, candidate->_index);
if (nodeHasSync)
{
traceMsg(comp(), "Also analyzing for nodeHasSync node %p; nodeHasVolatile %d\n", node, nodeHasVolatile);
}
traceMsg(comp(), "Allocation info at this stage : \n");
_allocationInfo->print(comp());
traceMsg(comp(), "\n");
Expand Down Expand Up @@ -9443,10 +9447,26 @@ bool TR_LocalFlushElimination::examineNode(TR::Node *node, TR::TreeTop *tt, TR::
{
if (tt->getPrevTreeTop()->getNode()->getOpCodeValue() == TR::allocationFence)
{
tt->getPrevTreeTop()->getNode()->setAllocation(NULL); // Existing AllocationFence is now needed by more then one allocation
if (trace())
traceMsg(comp(), "(local) Setting AF node %p allocation to ALL above treeTop %p (node %p).\n", tt->getPrevTreeTop()->getNode(), tt, node );
TR_ASSERT_FATAL(tt->getPrevTreeTop()->getNode()->canOmitSync()==false, "(local) Disabled AllocationFence %p found.\n", tt->getPrevTreeTop()->getNode());
TR::Node *afNode = tt->getPrevTreeTop()->getNode();

if (afNode->canOmitSync())
{
afNode->setAllocation(candidate->_node);
afNode->setOmitSync(false);

if (trace())
{
traceMsg(comp(), "(local) Restoring AF node %p for allocation %p above node %p.\n", afNode, candidate->_node, tt->getNode());
}
}
else
{
afNode->setAllocation(NULL); // Existing AllocationFence is now needed by more then one allocation
if (trace())
{
traceMsg(comp(), "(local) Setting AF node %p allocation to ALL above %p.\n", afNode, tt->getNode() );
}
}
}
else
{
Expand All @@ -9457,7 +9477,7 @@ bool TR_LocalFlushElimination::examineNode(TR::Node *node, TR::TreeTop *tt, TR::
TR::Node *afNode = TR::Node::createAllocationFence(candidate->_node, candidate->_node);
tt->insertBefore(TR::TreeTop::create(comp(), afNode, NULL, NULL));
if (trace())
traceMsg(comp(), "(local) Inserted AF node %p above node %p (%s).\n", afNode, node, node->getOpCode().getName() );
traceMsg(comp(), "(local) Inserted AF node %p for candidate %p above node %p (%s).\n", afNode, candidate->_node, node, node->getOpCode().getName() );
//fprintf( stderr, "(local) Inserted AF node %p above node %p (%s).\n", afNode, node, node->getOpCode().getName() );
}
}
Expand Down

0 comments on commit acf3290

Please sign in to comment.