[llvm] 6617529 - [CodeGen][DwarfEHPrepare] Preserve Dominator Tree
Roman Lebedev via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 28 03:16:37 PST 2021
Author: Roman Lebedev
Date: 2021-01-28T14:11:34+03:00
New Revision: 6617529a1dfe6605bd2b4064c7832ace4b0eb564
URL: https://github.com/llvm/llvm-project/commit/6617529a1dfe6605bd2b4064c7832ace4b0eb564
DIFF: https://github.com/llvm/llvm-project/commit/6617529a1dfe6605bd2b4064c7832ace4b0eb564.diff
LOG: [CodeGen][DwarfEHPrepare] Preserve Dominator Tree
Now that D94827 has flipped the switch, and SimplifyCFG is officially marked
as production-ready regarding Dominator Tree preservation,
we can update this user pass to also preserve Dominator Tree.
This is a geomean compile-time win of `-0.05%`..`-0.08%`.
https://llvm-compile-time-tracker.com/compare.php?from=51a25846c198cff00abad0936f975167357afa6f&to=082499aac236a5c141e50a9e77870d5be2de5f0b&stat=instructions
Differential Revision: https://reviews.llvm.org/D95548
Added:
Modified:
llvm/lib/CodeGen/DwarfEHPrepare.cpp
llvm/test/CodeGen/ARM/O3-pipeline.ll
llvm/test/CodeGen/X86/opt-pipeline.ll
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/DwarfEHPrepare.cpp b/llvm/lib/CodeGen/DwarfEHPrepare.cpp
index 97e0162f35a1..99d2522548c3 100644
--- a/llvm/lib/CodeGen/DwarfEHPrepare.cpp
+++ b/llvm/lib/CodeGen/DwarfEHPrepare.cpp
@@ -153,7 +153,7 @@ size_t DwarfEHPrepare::pruneUnreachableResumes(
BasicBlock *BB = RI->getParent();
new UnreachableInst(Ctx, RI);
RI->eraseFromParent();
- simplifyCFG(BB, *TTI, RequireAndPreserveDomTree ? DTU : nullptr);
+ simplifyCFG(BB, *TTI, DTU);
}
}
Resumes.resize(ResumesLeft);
@@ -242,25 +242,15 @@ bool DwarfEHPrepare::InsertUnwindResumeCalls() {
CI->setDoesNotReturn();
new UnreachableInst(Ctx, UnwindBB);
- if (DTU && RequireAndPreserveDomTree)
+ if (DTU)
DTU->applyUpdates(Updates);
return true;
}
bool DwarfEHPrepare::run() {
- assert(((OptLevel == CodeGenOpt::None || !RequireAndPreserveDomTree) ||
- (DTU &&
- DTU->getDomTree().verify(DominatorTree::VerificationLevel::Full))) &&
- "Original domtree is invalid?");
-
bool Changed = InsertUnwindResumeCalls();
- assert(((OptLevel == CodeGenOpt::None || !RequireAndPreserveDomTree) ||
- (DTU &&
- DTU->getDomTree().verify(DominatorTree::VerificationLevel::Full))) &&
- "Original domtree is invalid?");
-
return Changed;
}
@@ -268,7 +258,7 @@ static bool prepareDwarfEH(CodeGenOpt::Level OptLevel,
FunctionCallee &RewindFunction, Function &F,
const TargetLowering &TLI, DominatorTree *DT,
const TargetTransformInfo *TTI) {
- DomTreeUpdater DTU(DT, DomTreeUpdater::UpdateStrategy::Eager);
+ DomTreeUpdater DTU(DT, DomTreeUpdater::UpdateStrategy::Lazy);
return DwarfEHPrepare(OptLevel, RewindFunction, F, TLI, DT ? &DTU : nullptr,
TTI)
@@ -295,8 +285,11 @@ class DwarfEHPrepareLegacyPass : public FunctionPass {
const TargetLowering &TLI = *TM.getSubtargetImpl(F)->getTargetLowering();
DominatorTree *DT = nullptr;
const TargetTransformInfo *TTI = nullptr;
+ if (auto *DTWP = getAnalysisIfAvailable<DominatorTreeWrapperPass>())
+ DT = &DTWP->getDomTree();
if (OptLevel != CodeGenOpt::None) {
- DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
+ if (!DT)
+ DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
TTI = &getAnalysis<TargetTransformInfoWrapperPass>().getTTI(F);
}
return prepareDwarfEH(OptLevel, RewindFunction, F, TLI, DT, TTI);
@@ -308,9 +301,8 @@ class DwarfEHPrepareLegacyPass : public FunctionPass {
if (OptLevel != CodeGenOpt::None) {
AU.addRequired<DominatorTreeWrapperPass>();
AU.addRequired<TargetTransformInfoWrapperPass>();
- if (RequireAndPreserveDomTree)
- AU.addPreserved<DominatorTreeWrapperPass>();
}
+ AU.addPreserved<DominatorTreeWrapperPass>();
}
StringRef getPassName() const override {
diff --git a/llvm/test/CodeGen/ARM/O3-pipeline.ll b/llvm/test/CodeGen/ARM/O3-pipeline.ll
index 8011ad797b0c..5055ae93263e 100644
--- a/llvm/test/CodeGen/ARM/O3-pipeline.ll
+++ b/llvm/test/CodeGen/ARM/O3-pipeline.ll
@@ -55,7 +55,6 @@
; CHECK-NEXT: Dominator Tree Construction
; CHECK-NEXT: Exception handling preparation
; CHECK-NEXT: Merge internal globals
-; CHECK-NEXT: Dominator Tree Construction
; CHECK-NEXT: Natural Loop Information
; CHECK-NEXT: Scalar Evolution Analysis
; CHECK-NEXT: Lazy Branch Probability Analysis
diff --git a/llvm/test/CodeGen/X86/opt-pipeline.ll b/llvm/test/CodeGen/X86/opt-pipeline.ll
index 9abf60777763..066a9cd335b5 100644
--- a/llvm/test/CodeGen/X86/opt-pipeline.ll
+++ b/llvm/test/CodeGen/X86/opt-pipeline.ll
@@ -69,7 +69,6 @@
; CHECK-NEXT: Safe Stack instrumentation pass
; CHECK-NEXT: Insert stack protectors
; CHECK-NEXT: Module Verifier
-; CHECK-NEXT: Dominator Tree Construction
; CHECK-NEXT: Basic Alias Analysis (stateless AA impl)
; CHECK-NEXT: Function Alias Analysis Results
; CHECK-NEXT: Natural Loop Information
More information about the llvm-commits
mailing list