Skip to content

Commit

Permalink
Use getLiveRangeInfo to find pending push symRefs that are dead
Browse files Browse the repository at this point in the history
The calls to processSymbolReferences load references to symRefs that are
live in order to create fake escapes for those symRefs at that point.
Determining whether a symRef is live relies on a TR_BitVector that lists
the symRefs that are dead at that point in the IL.  For autos, that
TR_BitVector was being retrieved by calling
TR_OSRMethodData::getLiveRangeInfo(), but for pending push symRefs,
TR_OSRMethodData::getPendingPushLivenessInfo() was being called.  When
OSRDefAnalysis builds the vector of dead symRefs for both autos and
pending pushes, it stores them in the LiveRangeInfo of the
TR_OSRMethodData; the PendingPushLivenessInfo actually contains
information about which pending push symRefs are live at particular
points, not those that are dead.

This change corrects the calls to processSymbolReferences by using the
result of TR_OSRMethodData::getLiveRangeInfo() for both autos and for
pending pushes.

Also added some additional logging that's enabled under either traceOSR
or traceEscapeAnalysis.

Signed-off-by:  Henry Zongaro <[email protected]>
  • Loading branch information
hzongaro committed Sep 12, 2023
1 parent dce0276 commit 3a635d3
Showing 1 changed file with 69 additions and 8 deletions.
77 changes: 69 additions & 8 deletions runtime/compiler/optimizer/EscapeAnalysisTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
#include "il/AutomaticSymbol.hpp"

TR_EscapeAnalysisTools::TR_EscapeAnalysisTools(TR::Compilation *comp)
{
_comp = comp;
}
{
_comp = comp;
}

void TR_EscapeAnalysisTools::insertFakeEscapeForLoads(TR::Block *block, TR::Node *node, TR_BitVector &symRefsToLoad)
{
Expand Down Expand Up @@ -78,10 +78,17 @@ void TR_EscapeAnalysisTools::insertFakeEscapeForOSR(TR::Block *block, TR::Node *
static char *disableEADefiningMap = feGetEnv("TR_DisableEAEscapeHelperDefiningMap");
DefiningMap *induceDefiningMap = !disableEADefiningMap ? osrMethodData->getDefiningMap() : NULL;

if (_comp->trace(OMR::escapeAnalysis) && induceDefiningMap)
if (_comp->trace(OMR::escapeAnalysis) || _comp->getOption(TR_TraceOSR))
{
traceMsg(_comp, "definingMap at induceCall n%dn %d:%d\n", induceCall->getGlobalIndex(), induceCall->getByteCodeInfo().getCallerIndex(), induceCall->getByteCodeInfo().getByteCodeIndex());
_comp->getOSRCompilationData()->printMap(induceDefiningMap);
if (induceDefiningMap)
{
traceMsg(_comp, "insertFakeEscapeForOSR: definingMap at induceCall n%dn %d:%d\n", induceCall->getGlobalIndex(), inlinedIndex, byteCodeIndex);
_comp->getOSRCompilationData()->printMap(induceDefiningMap);
}
else
{
traceMsg(_comp, "insertFakeEscapeForOSR: definingMap at induceCall n%dn %d:%d is EMPTY\n", induceCall->getGlobalIndex(), inlinedIndex, byteCodeIndex);
}
}

TR_BitVector symRefsToLoad(0, _comp->trMemory()->currentStackRegion(), growable);
Expand All @@ -93,6 +100,12 @@ void TR_EscapeAnalysisTools::insertFakeEscapeForOSR(TR::Block *block, TR::Node *
TR::ResolvedMethodSymbol *rms = _comp->getInlinedResolvedMethodSymbol(inlinedIndex);
TR_ASSERT_FATAL(rms, "Unknown resolved method during escapetools");
TR_OSRMethodData *methodData = osrCompilationData->findOSRMethodData(inlinedIndex, rms);

if (_comp->trace(OMR::escapeAnalysis) || _comp->getOption(TR_TraceOSR))
{
traceMsg(_comp, "Calling processAutosAndPendingPushes: At %d:%d, ResolvedMethodSymbol [%p] and OSRMethodData [%p]\n", inlinedIndex, byteCodeIndex, rms, methodData);
}

processAutosAndPendingPushes(rms, induceDefiningMap, methodData, byteCodeIndex, symRefsToLoad);
byteCodeIndex = _comp->getInlinedCallSite(inlinedIndex)._byteCodeInfo.getByteCodeIndex();
inlinedIndex = _comp->getInlinedCallSite(inlinedIndex)._byteCodeInfo.getCallerIndex();
Expand All @@ -101,15 +114,38 @@ void TR_EscapeAnalysisTools::insertFakeEscapeForOSR(TR::Block *block, TR::Node *
// handle the outermost method
{
TR_OSRMethodData *methodData = osrCompilationData->findOSRMethodData(-1, _comp->getMethodSymbol());

if (_comp->trace(OMR::escapeAnalysis) || _comp->getOption(TR_TraceOSR))
{
traceMsg(_comp, "Calling processAutosAndPendingPushes: At %d:%d, ResolvedMethodSymbol [%p] and OSRMethodData [%p]\n", -1, byteCodeIndex, _comp->getMethodSymbol(), methodData);
}

processAutosAndPendingPushes(_comp->getMethodSymbol(), induceDefiningMap, methodData, byteCodeIndex, symRefsToLoad);
}
insertFakeEscapeForLoads(block, induceCall, symRefsToLoad);
}

void TR_EscapeAnalysisTools::processAutosAndPendingPushes(TR::ResolvedMethodSymbol *rms, DefiningMap *induceDefiningMap, TR_OSRMethodData *methodData, int32_t byteCodeIndex, TR_BitVector &symRefsToLoad)
{
processSymbolReferences(rms->getAutoSymRefs(), induceDefiningMap, methodData->getLiveRangeInfo(byteCodeIndex), symRefsToLoad);
processSymbolReferences(rms->getPendingPushSymRefs(), induceDefiningMap, methodData->getPendingPushLivenessInfo(byteCodeIndex), symRefsToLoad);
TR_BitVector *deadSymRefs = methodData->getLiveRangeInfo(byteCodeIndex);

if (_comp->trace(OMR::escapeAnalysis) || _comp->getOption(TR_TraceOSR))
{
traceMsg(_comp, "Calling processSymbolReferences for auto symRefs and pending push symRefs. deadSymRefs at this point:\n");

if (deadSymRefs)
{
deadSymRefs->print(_comp);
traceMsg(_comp, "\n");
}
else
{
traceMsg(_comp, "NULL\n");
}
}

processSymbolReferences(rms->getAutoSymRefs(), induceDefiningMap, deadSymRefs, symRefsToLoad);
processSymbolReferences(rms->getPendingPushSymRefs(), induceDefiningMap, deadSymRefs, symRefsToLoad);
}

void TR_EscapeAnalysisTools::processSymbolReferences(TR_Array<List<TR::SymbolReference>> *symbolReferences, DefiningMap *induceDefiningMap, TR_BitVector *deadSymRefs, TR_BitVector &symRefsToLoad)
Expand All @@ -121,6 +157,7 @@ void TR_EscapeAnalysisTools::processSymbolReferences(TR_Array<List<TR::SymbolRef
for (TR::SymbolReference* symRef = autosIt.getFirst(); symRef; symRef = autosIt.getNext())
{
TR::Symbol *p = symRef->getSymbol();

if ((p->isAuto() || p->isParm()) && p->getDataType() == TR::Address)
{
int32_t symRefNum = symRef->getReferenceNumber();
Expand All @@ -137,6 +174,18 @@ void TR_EscapeAnalysisTools::processSymbolReferences(TR_Array<List<TR::SymbolRef
if (deadSymRefs == NULL || !deadSymRefs->isSet(symRefNum))
{
symRefsToLoad.set(symRefNum);

if (_comp->trace(OMR::escapeAnalysis) || _comp->getOption(TR_TraceOSR))
{
traceMsg(_comp, "In processSymbolReferences, adding symRef #%d to symRefsToLoad\n", symRef->getReferenceNumber());
}
}
else
{
if (_comp->trace(OMR::escapeAnalysis) || _comp->getOption(TR_TraceOSR))
{
traceMsg(_comp, "In processSymbolReferences, symRef #%d is dead - not added to symRefsToLoad\n", symRef->getReferenceNumber());
}
}
}
else
Expand All @@ -154,6 +203,18 @@ void TR_EscapeAnalysisTools::processSymbolReferences(TR_Array<List<TR::SymbolRef
&& (deadSymRefs == NULL || !deadSymRefs->isSet(definingSymRefNum)))
{
symRefsToLoad.set(symRefNum);

if (_comp->trace(OMR::escapeAnalysis) || _comp->getOption(TR_TraceOSR))
{
traceMsg(_comp, "In processSymbolReferences, adding definingSymRef #%d to symRefsToLoad\n", definingSymRefNum);
}
}
else
{
if (_comp->trace(OMR::escapeAnalysis) || _comp->getOption(TR_TraceOSR))
{
traceMsg(_comp, "In processSymbolReferences, definingSymRef #%d - isAuto == %d; isParm == %d; dead == %d - not added to symRefsToLoad\n", definingSymRefNum, definingSym->isAuto(), definingSym->isParm(), (deadSymRefs != NULL && deadSymRefs->isSet(definingSymRefNum)));
}
}
}
}
Expand Down

0 comments on commit 3a635d3

Please sign in to comment.