diff options
author | Sean Silva <chisophugis@gmail.com> | 2016-08-02 02:15:45 +0000 |
---|---|---|
committer | Sean Silva <chisophugis@gmail.com> | 2016-08-02 02:15:45 +0000 |
commit | f801575fd059cbfe17b38a8bf1cb3e2de585fb20 (patch) | |
tree | 40f70936fa434d9649cd297255c914757e9b957a /llvm/lib/Transforms/IPO/PartialInlining.cpp | |
parent | 07784904282c8b0793b0edfdc0220eadfadb205c (diff) | |
download | bcm5719-llvm-f801575fd059cbfe17b38a8bf1cb3e2de585fb20.tar.gz bcm5719-llvm-f801575fd059cbfe17b38a8bf1cb3e2de585fb20.zip |
CodeExtractor : Add ability to preserve profile data.
Added ability to estimate the entry count of the extracted function and
the branch probabilities of the exit branches.
Patch by River Riddle!
Differential Revision: https://reviews.llvm.org/D22744
llvm-svn: 277411
Diffstat (limited to 'llvm/lib/Transforms/IPO/PartialInlining.cpp')
-rw-r--r-- | llvm/lib/Transforms/IPO/PartialInlining.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/IPO/PartialInlining.cpp b/llvm/lib/Transforms/IPO/PartialInlining.cpp index 6c762e47f46..7ef3fc1fc2a 100644 --- a/llvm/lib/Transforms/IPO/PartialInlining.cpp +++ b/llvm/lib/Transforms/IPO/PartialInlining.cpp @@ -14,6 +14,9 @@ #include "llvm/Transforms/IPO/PartialInlining.h" #include "llvm/ADT/Statistic.h" +#include "llvm/Analysis/BlockFrequencyInfo.h" +#include "llvm/Analysis/BranchProbabilityInfo.h" +#include "llvm/Analysis/LoopInfo.h" #include "llvm/IR/CFG.h" #include "llvm/IR/Dominators.h" #include "llvm/IR/Instructions.h" @@ -133,9 +136,15 @@ Function *PartialInlinerImpl::unswitchFunction(Function *F) { DominatorTree DT; DT.recalculate(*DuplicateFunction); + // Manually calculate a BlockFrequencyInfo and BranchProbabilityInfo. + LoopInfo LI(DT); + BranchProbabilityInfo BPI(*DuplicateFunction, LI); + BlockFrequencyInfo BFI(*DuplicateFunction, BPI, LI); + // Extract the body of the if. Function *ExtractedFunction = - CodeExtractor(ToExtract, &DT).extractCodeRegion(); + CodeExtractor(ToExtract, &DT, /*AggregateArgs*/ false, &BFI, &BPI) + .extractCodeRegion(); // Inline the top-level if test into all callers. std::vector<User *> Users(DuplicateFunction->user_begin(), @@ -181,8 +190,8 @@ bool PartialInlinerImpl::run(Module &M) { if (Recursive) continue; - if (Function *newFunc = unswitchFunction(CurrFunc)) { - Worklist.push_back(newFunc); + if (Function *NewFunc = unswitchFunction(CurrFunc)) { + Worklist.push_back(NewFunc); Changed = true; } } |