Skip to content

Commit

Permalink
Allow inliner policy to decide whether to remove differing targets
Browse files Browse the repository at this point in the history
Previously, for direct calls, targets that appear to be a different
method from the one specified by the call node's symbol reference would
always be removed.

This behaviour is still the default, but the new query allows downstream
projects to customize the conditions under which those targets are
removed, e.g. by exempting certain methods.
  • Loading branch information
jdmpapin committed May 21, 2021
1 parent 092787c commit d4f24cc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
15 changes: 10 additions & 5 deletions compiler/optimizer/Inliner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4061,6 +4061,15 @@ bool OMR_InlinerPolicy::canInlineMethodWhileInstrumenting(TR_ResolvedMethod *met
return true;
}

bool OMR_InlinerPolicy::shouldRemoveDifferingTargets(TR::Node *callNode)
{
//if ilgen and localopts decided that this was a direct call
//there isn't much sense to deal with more than one target
//either find a matching one
//or make any target look like callsite's calleeSymbol
return !callNode->getOpCode().isCallIndirect();
}

void TR_InlinerBase::applyPolicyToTargets(TR_CallStack *callStack, TR_CallSite *callsite)
{
for (int32_t i=0; i<callsite->numTargets(); i++)
Expand Down Expand Up @@ -4417,11 +4426,7 @@ TR_CallSite* TR_InlinerBase::findAndUpdateCallSiteInGraph(TR_CallStack *callStac
if (callNode->getSymbolReference()->getSymbol()->castToMethodSymbol()->isInterface() && callsite->_initialCalleeSymbol)
debugTrace(tracer(), "findAndUpdateCallSiteInGraph: BAD: Interface call has an initialCalleeSYmbol %p for calNode %p", callsite->_initialCalleeSymbol, callNode);

//if ilgen and localopts decided that this was a direct call
//there isn't much sense to deal with more than one target
//either find a matching one
//or make any target look like callsite's calleeSymbol
if (!callNode->getOpCode().isCallIndirect())
if (getPolicy()->shouldRemoveDifferingTargets(callNode))
{
//find a matching target if there's any
for (int32_t i = 0 ; i < callsite->numTargets() ; i++)
Expand Down
1 change: 1 addition & 0 deletions compiler/optimizer/Inliner.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,7 @@ class OMR_InlinerPolicy : public TR::OptimizationPolicy, public OMR_InlinerHelpe
bool aggressiveSmallAppOpts() { return comp()->getOption(TR_AggressiveOpts); }
virtual bool willBeInlinedInCodeGen(TR::RecognizedMethod method);
virtual bool canInlineMethodWhileInstrumenting(TR_ResolvedMethod *method);
virtual bool shouldRemoveDifferingTargets(TR::Node *callNode);

/** \brief
* Determines whether to skip generation of HCR guards for a particular callee during inlining.
Expand Down

0 comments on commit d4f24cc

Please sign in to comment.