Index: lib/Transforms/IPO/Inliner.cpp =================================================================== --- lib/Transforms/IPO/Inliner.cpp +++ lib/Transforms/IPO/Inliner.cpp @@ -296,6 +296,17 @@ if (InlineHint && HintThreshold > Threshold && !Caller->hasFnAttribute(Attribute::MinSize)) Threshold = HintThreshold; + // If profile information is available, use that to prioritize hot functions. + // FIXME: The heuristic used here is based on preliminary SPEC tuning and + // may not be optimal. Replace this with a well-tuned heuristic based on + // *callsite* hotness and not callee hotness. + auto EntryCount = Callee->getEntryCount(); + auto MaxFunctionCount = Callee->getParent()->getMaximumFunctionCount(); + if (EntryCount && MaxFunctionCount && + EntryCount.getValue() >= + (uint64_t)(0.3 * (double)MaxFunctionCount.getValue())) { + Threshold = HintThreshold; + } // Listen to the cold attribute when it would decrease the threshold. bool ColdCallee = Callee && !Callee->isDeclaration() &&