Page MenuHomePhabricator

D56435.id180703.diff
No OneTemporary

File Metadata

Created
Tue, Oct 22, 12:42 AM

D56435.id180703.diff

Index: lib/Transforms/IPO/SampleProfile.cpp
===================================================================
--- lib/Transforms/IPO/SampleProfile.cpp
+++ lib/Transforms/IPO/SampleProfile.cpp
@@ -218,6 +218,7 @@
const FunctionSamples *findCalleeFunctionSamples(const Instruction &I) const;
std::vector<const FunctionSamples *>
findIndirectCallFunctionSamples(const Instruction &I, uint64_t &Sum) const;
+ mutable DenseMap<const DILocation *, const FunctionSamples *> DILocation2SampleMap;
const FunctionSamples *findFunctionSamples(const Instruction &I) const;
bool inlineCallInstruction(Instruction *I);
bool inlineHotFunctions(Function &F,
@@ -724,7 +725,12 @@
if (!DIL)
return Samples;
- return Samples->findFunctionSamples(DIL);
+ auto it = DILocation2SampleMap.find(DIL);
+ if (it != DILocation2SampleMap.end())
+ return it->second;
+ const FunctionSamples *s = Samples->findFunctionSamples(DIL);
+ DILocation2SampleMap.try_emplace(DIL, s);
+ return s;
}
bool SampleProfileLoader::inlineCallInstruction(Instruction *I) {

Event Timeline