diff options
| author | Easwaran Raman <eraman@google.com> | 2016-05-26 22:57:11 +0000 |
|---|---|---|
| committer | Easwaran Raman <eraman@google.com> | 2016-05-26 22:57:11 +0000 |
| commit | 5fe04a1d8e9dc41720ff90561a6136ef7e8c6504 (patch) | |
| tree | 1f65799e04145a45104efd4ab894645e085b40b9 /llvm/lib/Transforms | |
| parent | ceeb52112763ed8a3288d481fb5bf2304d191f19 (diff) | |
| download | bcm5719-llvm-5fe04a1d8e9dc41720ff90561a6136ef7e8c6504.tar.gz bcm5719-llvm-5fe04a1d8e9dc41720ff90561a6136ef7e8c6504.zip | |
Attach profile summary in IR based instrumentation pass.
Differential revision: http://reviews.llvm.org/D20655
llvm-svn: 270933
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp index 835f75edcd2..9e13dcc5ed5 100644 --- a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp +++ b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp @@ -67,6 +67,7 @@ #include "llvm/IR/Module.h" #include "llvm/Pass.h" #include "llvm/ProfileData/InstrProfReader.h" +#include "llvm/ProfileData/ProfileCommon.h" #include "llvm/Support/BranchProbability.h" #include "llvm/Support/Debug.h" #include "llvm/Support/JamCRC.h" @@ -478,6 +479,9 @@ public: // Return the function hotness from the profile. FuncFreqAttr getFuncFreqAttr() const { return FreqAttr; } + // Return the profile record for this function; + InstrProfRecord &getProfileRecord() { return ProfileRecord; } + private: Function &F; Module *M; @@ -883,6 +887,7 @@ static bool annotateAllFunctions( std::vector<Function *> HotFunctions; std::vector<Function *> ColdFunctions; + InstrProfSummaryBuilder Builder(ProfileSummaryBuilder::DefaultCutoffs); for (auto &F : M) { if (F.isDeclaration()) continue; @@ -890,13 +895,15 @@ static bool annotateAllFunctions( auto *BFI = LookupBFI(F); PGOUseFunc Func(F, &M, BPI, BFI); setPGOCountOnFunc(Func, PGOReader.get()); + if (!Func.getProfileRecord().Counts.empty()) + Builder.addRecord(Func.getProfileRecord()); PGOUseFunc::FuncFreqAttr FreqAttr = Func.getFuncFreqAttr(); if (FreqAttr == PGOUseFunc::FFA_Cold) ColdFunctions.push_back(&F); else if (FreqAttr == PGOUseFunc::FFA_Hot) HotFunctions.push_back(&F); } - + M.setProfileSummary(Builder.getSummary()->getMD(M.getContext())); // Set function hotness attribute from the profile. for (auto &F : HotFunctions) { F->addFnAttr(llvm::Attribute::InlineHint); |

