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 May 20, 2022
1 parent 2181a2a commit 189fea9
Showing 1 changed file with 71 additions and 10 deletions.
81 changes: 71 additions & 10 deletions runtime/compiler/optimizer/EscapeAnalysisTools.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019, 2020 IBM Corp. and others
* Copyright (c) 2019, 2022 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 @@ -29,10 +29,10 @@
#include "il/AutomaticSymbol.hpp"

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

void TR_EscapeAnalysisTools::insertFakeEscapeForLoads(TR::Block *block, TR::Node *node, NodeDeque *loads)
{
Expand Down Expand Up @@ -82,10 +82,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);
}
}

// Gather all live autos and pending pushes at this point for inlined methods in _loads
Expand All @@ -95,6 +102,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);
byteCodeIndex = _comp->getInlinedCallSite(inlinedIndex)._byteCodeInfo.getByteCodeIndex();
inlinedIndex = _comp->getInlinedCallSite(inlinedIndex)._byteCodeInfo.getCallerIndex();
Expand All @@ -103,15 +116,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);
}
insertFakeEscapeForLoads(block, induceCall, _loads);
}

void TR_EscapeAnalysisTools::processAutosAndPendingPushes(TR::ResolvedMethodSymbol *rms, DefiningMap *induceDefiningMap, TR_OSRMethodData *methodData, int32_t byteCodeIndex)
{
processSymbolReferences(rms->getAutoSymRefs(), induceDefiningMap, methodData->getLiveRangeInfo(byteCodeIndex));
processSymbolReferences(rms->getPendingPushSymRefs(), induceDefiningMap, methodData->getPendingPushLivenessInfo(byteCodeIndex));
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);
processSymbolReferences(rms->getPendingPushSymRefs(), induceDefiningMap, deadSymRefs);
}

void TR_EscapeAnalysisTools::processSymbolReferences(TR_Array<List<TR::SymbolReference>> *symbolReferences, DefiningMap *induceDefiningMap, TR_BitVector *deadSymRefs)
Expand All @@ -123,6 +159,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)
{
// If no DefiningMap is available for the current sym ref, or the
Expand All @@ -137,6 +174,18 @@ void TR_EscapeAnalysisTools::processSymbolReferences(TR_Array<List<TR::SymbolRef
if (deadSymRefs == NULL || !deadSymRefs->isSet(symRef->getReferenceNumber()))
{
_loads->push_back(TR::Node::createWithSymRef(TR::aload, 0, symRef));

if (_comp->trace(OMR::escapeAnalysis) || _comp->getOption(TR_TraceOSR))
{
traceMsg(_comp, "In processSymbolReferences, loading symRef #%d\n", symRef->getReferenceNumber());
}
}
else
{
if (_comp->trace(OMR::escapeAnalysis) || _comp->getOption(TR_TraceOSR))
{
traceMsg(_comp, "In processSymbolReferences, symRef #%d is dead\n", symRef->getReferenceNumber());
}
}
}
else
Expand All @@ -153,6 +202,18 @@ void TR_EscapeAnalysisTools::processSymbolReferences(TR_Array<List<TR::SymbolRef
&& (deadSymRefs == NULL || !deadSymRefs->isSet(definingSymRefNum)))
{
_loads->push_back(TR::Node::createWithSymRef(TR::aload, 0, definingSymRef));

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

0 comments on commit 189fea9

Please sign in to comment.