From 189fea951f6a8c9430dcce876274c373f1bc42e7 Mon Sep 17 00:00:00 2001 From: Henry Zongaro Date: Wed, 24 Nov 2021 06:15:53 -0800 Subject: [PATCH] Use getLiveRangeInfo to find pending push symRefs that are dead 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 --- .../optimizer/EscapeAnalysisTools.cpp | 81 ++++++++++++++++--- 1 file changed, 71 insertions(+), 10 deletions(-) diff --git a/runtime/compiler/optimizer/EscapeAnalysisTools.cpp b/runtime/compiler/optimizer/EscapeAnalysisTools.cpp index 94d25570e2a..49f9f8659ff 100644 --- a/runtime/compiler/optimizer/EscapeAnalysisTools.cpp +++ b/runtime/compiler/optimizer/EscapeAnalysisTools.cpp @@ -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 @@ -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) { @@ -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 @@ -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(); @@ -103,6 +116,12 @@ 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); @@ -110,8 +129,25 @@ void TR_EscapeAnalysisTools::insertFakeEscapeForOSR(TR::Block *block, TR::Node * 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> *symbolReferences, DefiningMap *induceDefiningMap, TR_BitVector *deadSymRefs) @@ -123,6 +159,7 @@ void TR_EscapeAnalysisTools::processSymbolReferences(TR_ArraygetSymbol(); + if ((p->isAuto() || p->isParm()) && p->getDataType() == TR::Address) { // If no DefiningMap is available for the current sym ref, or the @@ -137,6 +174,18 @@ void TR_EscapeAnalysisTools::processSymbolReferences(TR_ArrayisSet(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 @@ -153,6 +202,18 @@ void TR_EscapeAnalysisTools::processSymbolReferences(TR_ArrayisSet(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))); + } } } }