diff --git a/hphp/runtime/vm/jit/irtranslator.cpp b/hphp/runtime/vm/jit/irtranslator.cpp index b013a7730..f25059e95 100644 --- a/hphp/runtime/vm/jit/irtranslator.cpp +++ b/hphp/runtime/vm/jit/irtranslator.cpp @@ -1225,7 +1225,7 @@ Translator::translateFCall(const NormalizedInstruction& i) { * the call. */ if (i.calleeTrace) { - if (!m_hhbcTrans->isInlining()) { + if (!i.calleeTrace->m_inliningFailed && !m_hhbcTrans->isInlining()) { assert(shouldIRInline(curFunc(), i.funcd, *i.calleeTrace)); m_hhbcTrans->beginInlining(numArgs, i.funcd, returnBcOffset); diff --git a/hphp/runtime/vm/jit/translator.cpp b/hphp/runtime/vm/jit/translator.cpp index c96b03c6a..2a1c66aec 100644 --- a/hphp/runtime/vm/jit/translator.cpp +++ b/hphp/runtime/vm/jit/translator.cpp @@ -32,6 +32,7 @@ #include "hphp/util/biased_coin.h" #include "hphp/runtime/base/runtime_option.h" +#include "hphp/runtime/base/stats.h" #include "hphp/runtime/base/types.h" #include "hphp/runtime/ext/ext_continuation.h" #include "hphp/runtime/ext/ext_collections.h" @@ -2707,7 +2708,9 @@ Translator::getOperandConstraintCategory(NormalizedInstruction* instr, // Note: instead of pessimizing calls that may be inlined with // DataTypeSpecific, we could apply the operand constraints of // the callee in constrainDep. - return instr->calleeTrace ? DataTypeSpecific : DataTypeGeneric; + return (instr->calleeTrace && !instr->calleeTrace->m_inliningFailed) + ? DataTypeSpecific + : DataTypeGeneric; case OpFCallArray: return DataTypeGeneric; @@ -3174,6 +3177,12 @@ void Translator::analyzeCallee(TraceletContext& tas, * want to do that unnecessarily. */ if (!shouldIRInline(callerFunc, target, *subTrace)) { + if (UNLIKELY(Stats::enabledAny() && getenv("HHVM_STATS_FAILEDINL"))) { + subTrace->m_inliningFailed = true; + // Save the trace for stats purposes but don't waste time doing any + // further processing since we know we won't inline it. + fcall->calleeTrace = std::move(subTrace); + } return; } diff --git a/hphp/runtime/vm/jit/translator.h b/hphp/runtime/vm/jit/translator.h index 780573488..d671c831f 100644 --- a/hphp/runtime/vm/jit/translator.h +++ b/hphp/runtime/vm/jit/translator.h @@ -529,6 +529,13 @@ struct Tracelet : private boost::noncopyable { */ bool m_analysisFailed; + /* + * If IR inlining failed we may still need access to the trace for profiling + * purposes if stats are enabled so maintain this to verify that we should use + * this Tracelet for inlining purposes. + */ + bool m_inliningFailed; + // Track which NormalizedInstructions and DynLocations are owned by this // Tracelet; used for cleanup purposes boost::ptr_vector m_instrs; @@ -537,7 +544,8 @@ struct Tracelet : private boost::noncopyable { Tracelet() : m_stackChange(0), m_arState(), - m_analysisFailed(false) { } + m_analysisFailed(false), + m_inliningFailed(false){ } void constructLiveRanges(); bool isLiveAfterInstr(Location l, const NormalizedInstruction& i) const;