[PATCH] D22744: CodeExtractor : Add ability to preserve profile data.
David Li via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 26 15:19:51 PDT 2016
davidxl added inline comments.
================
Comment at: include/llvm/Analysis/BlockFrequencyInfo.h:67
@@ +66,3 @@
+ /// the enclosing function's count (if available) and returns the value.
+ Optional<uint64_t> getFreqToProfileCount(uint64_t Freq) const;
+
----------------
nit: perhaps just freqToProfileCount or getProfileCountFromFreq?
================
Comment at: include/llvm/Analysis/BlockFrequencyInfoImpl.h:485
@@ -484,1 +484,3 @@
const BlockNode &Node) const;
+ Optional<uint64_t> getFreqToProfileCount(const Function &F,
+ uint64_t Freq) const;
----------------
Same here
================
Comment at: lib/Transforms/Utils/CodeExtractor.cpp:696
@@ +695,3 @@
+ if (BFI)
+ BPI = const_cast<BranchProbabilityInfo*>(BFI->getBPI());
+
----------------
clang-format? add space
================
Comment at: lib/Transforms/Utils/CodeExtractor.cpp:699
@@ +698,3 @@
+ // Calculate the entry of the new function before we change the root block.
+ BlockFrequency EntryCount;
+ if (BFI) {
----------------
EntryCount --> EntryFreq
================
Comment at: lib/Transforms/Utils/CodeExtractor.cpp:756
@@ +755,3 @@
+ if (BFI) {
+ Optional<uint64_t> OptEntryCount =
+ BFI->getFreqToProfileCount(EntryCount.getFrequency());
----------------
nit: OptEntryCount --> EntryCount
================
Comment at: lib/Transforms/Utils/CodeExtractor.cpp:758
@@ +757,3 @@
+ BFI->getFreqToProfileCount(EntryCount.getFrequency());
+ newFunction->setEntryCount(OptEntryCount ? OptEntryCount.getValue() : 0);
+ BFI->setBlockFreq(codeReplacer, EntryCount.getFrequency());
----------------
When EntryCount does not exist, skip it instead of setting it to 0.
================
Comment at: lib/Transforms/Utils/CodeExtractor.cpp:766
@@ -725,1 +765,3 @@
+ // Update the branch weights for the exit block.
+ TerminatorInst *TI = codeReplacer->getTerminator();
----------------
Move this into a helper function
https://reviews.llvm.org/D22744
More information about the llvm-commits
mailing list