summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorFlorian Hahn <flo@fhahn.com>2019-01-24 11:22:08 +0000
committerFlorian Hahn <flo@fhahn.com>2019-01-24 11:22:08 +0000
commitbed7f9eab2a18bcc8ba00917b8db8929b138eaff (patch)
treebb1123b836dc8ba144d3be35315de5f06f807d47 /llvm/lib/Transforms
parentc514adef056eec32cf6f748ba581b3d6e6814351 (diff)
downloadbcm5719-llvm-bed7f9eab2a18bcc8ba00917b8db8929b138eaff.tar.gz
bcm5719-llvm-bed7f9eab2a18bcc8ba00917b8db8929b138eaff.zip
Revert "[HotColdSplitting] Get DT and PDT from the pass manager."
This reverts commit a6982414edf315c39ae93f3c3322476217119e99 (llvm-svn: 352036), because it causes a memory leak in the pass manager. Failing bot http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/10351/steps/check-llvm%20asan/logs/stdio llvm-svn: 352041
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/IPO/HotColdSplitting.cpp41
1 files changed, 9 insertions, 32 deletions
diff --git a/llvm/lib/Transforms/IPO/HotColdSplitting.cpp b/llvm/lib/Transforms/IPO/HotColdSplitting.cpp
index 0ff902d735c..710a9e72569 100644
--- a/llvm/lib/Transforms/IPO/HotColdSplitting.cpp
+++ b/llvm/lib/Transforms/IPO/HotColdSplitting.cpp
@@ -168,11 +168,8 @@ public:
HotColdSplitting(ProfileSummaryInfo *ProfSI,
function_ref<BlockFrequencyInfo *(Function &)> GBFI,
function_ref<TargetTransformInfo &(Function &)> GTTI,
- function_ref<DominatorTree *(Function &)> GetDT,
- function_ref<PostDominatorTree *(Function &)> GetPDT,
std::function<OptimizationRemarkEmitter &(Function &)> *GORE)
- : PSI(ProfSI), GetBFI(GBFI), GetTTI(GTTI), GetDT(GetDT), GetPDT(GetPDT),
- GetORE(GORE) {}
+ : PSI(ProfSI), GetBFI(GBFI), GetTTI(GTTI), GetORE(GORE) {}
bool run(Module &M);
private:
@@ -185,8 +182,6 @@ private:
ProfileSummaryInfo *PSI;
function_ref<BlockFrequencyInfo *(Function &)> GetBFI;
function_ref<TargetTransformInfo &(Function &)> GetTTI;
- function_ref<DominatorTree *(Function &)> GetDT;
- function_ref<PostDominatorTree *(Function &)> GetPDT;
std::function<OptimizationRemarkEmitter &(Function &)> *GetORE;
};
@@ -200,8 +195,6 @@ public:
void getAnalysisUsage(AnalysisUsage &AU) const override {
AU.addRequired<AssumptionCacheTracker>();
AU.addRequired<BlockFrequencyInfoWrapperPass>();
- AU.addRequired<DominatorTreeWrapperPass>();
- AU.addRequired<PostDominatorTreeWrapperPass>();
AU.addRequired<ProfileSummaryInfoWrapperPass>();
AU.addRequired<TargetTransformInfoWrapperPass>();
}
@@ -469,11 +462,12 @@ bool HotColdSplitting::outlineColdRegions(Function &F, bool HasProfileSummary) {
ReversePostOrderTraversal<Function *> RPOT(&F);
// Calculate domtrees lazily. This reduces compile-time significantly.
- DominatorTree *DT = nullptr;
- PostDominatorTree *PDT = nullptr;
+ std::unique_ptr<DominatorTree> DT;
+ std::unique_ptr<PostDominatorTree> PDT;
// Calculate BFI lazily (it's only used to query ProfileSummaryInfo). This
- // reduces compile-time significantly.
+ // reduces compile-time significantly. TODO: When we *do* use BFI, we should
+ // be able to salvage its domtrees instead of recomputing them.
BlockFrequencyInfo *BFI = nullptr;
if (HasProfileSummary)
BFI = GetBFI(F);
@@ -498,9 +492,9 @@ bool HotColdSplitting::outlineColdRegions(Function &F, bool HasProfileSummary) {
});
if (!DT)
- DT = GetDT(F);
+ DT = make_unique<DominatorTree>(F);
if (!PDT)
- PDT = GetPDT(F);
+ PDT = make_unique<PostDominatorTree>(F);
auto Region = OutliningRegion::create(*BB, *DT, *PDT);
if (Region.empty())
@@ -601,13 +595,6 @@ bool HotColdSplittingLegacyPass::runOnModule(Module &M) {
auto GBFI = [this](Function &F) {
return &this->getAnalysis<BlockFrequencyInfoWrapperPass>(F).getBFI();
};
- auto GetDT = [this](Function &F) {
- return &this->getAnalysis<DominatorTreeWrapperPass>(F).getDomTree();
- };
- auto GetPDT = [this](Function &F) {
- return &this->getAnalysis<PostDominatorTreeWrapperPass>(F).getPostDomTree();
- };
-
std::unique_ptr<OptimizationRemarkEmitter> ORE;
std::function<OptimizationRemarkEmitter &(Function &)> GetORE =
[&ORE](Function &F) -> OptimizationRemarkEmitter & {
@@ -615,7 +602,7 @@ bool HotColdSplittingLegacyPass::runOnModule(Module &M) {
return *ORE.get();
};
- return HotColdSplitting(PSI, GBFI, GTTI, GetDT, GetPDT, &GetORE).run(M);
+ return HotColdSplitting(PSI, GBFI, GTTI, &GetORE).run(M);
}
PreservedAnalyses
@@ -636,14 +623,6 @@ HotColdSplittingPass::run(Module &M, ModuleAnalysisManager &AM) {
return FAM.getResult<TargetIRAnalysis>(F);
};
- auto GetDT = [&FAM](Function &F) {
- return &FAM.getResult<DominatorTreeAnalysis>(F);
- };
-
- auto GetPDT = [&FAM](Function &F) {
- return &FAM.getResult<PostDominatorTreeAnalysis>(F);
- };
-
std::unique_ptr<OptimizationRemarkEmitter> ORE;
std::function<OptimizationRemarkEmitter &(Function &)> GetORE =
[&ORE](Function &F) -> OptimizationRemarkEmitter & {
@@ -653,7 +632,7 @@ HotColdSplittingPass::run(Module &M, ModuleAnalysisManager &AM) {
ProfileSummaryInfo *PSI = &AM.getResult<ProfileSummaryAnalysis>(M);
- if (HotColdSplitting(PSI, GBFI, GTTI, GetDT, GetPDT, &GetORE).run(M))
+ if (HotColdSplitting(PSI, GBFI, GTTI, &GetORE).run(M))
return PreservedAnalyses::none();
return PreservedAnalyses::all();
}
@@ -663,8 +642,6 @@ INITIALIZE_PASS_BEGIN(HotColdSplittingLegacyPass, "hotcoldsplit",
"Hot Cold Splitting", false, false)
INITIALIZE_PASS_DEPENDENCY(ProfileSummaryInfoWrapperPass)
INITIALIZE_PASS_DEPENDENCY(BlockFrequencyInfoWrapperPass)
-INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
-INITIALIZE_PASS_DEPENDENCY(PostDominatorTreeWrapperPass)
INITIALIZE_PASS_END(HotColdSplittingLegacyPass, "hotcoldsplit",
"Hot Cold Splitting", false, false)
OpenPOWER on IntegriCloud