[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
This commit is contained in:
Roman Lebedev 2021-01-28 13:45:53 +03:00
parent 8cfa963463
commit 6617529a1d
No known key found for this signature in database
GPG Key ID: 083C3EBB4A1689E0
3 changed files with 8 additions and 18 deletions

View File

@ -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,7 +285,10 @@ public:
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) {
if (!DT)
DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
TTI = &getAnalysis<TargetTransformInfoWrapperPass>().getTTI(F);
}
@ -308,9 +301,8 @@ public:
if (OptLevel != CodeGenOpt::None) {
AU.addRequired<DominatorTreeWrapperPass>();
AU.addRequired<TargetTransformInfoWrapperPass>();
if (RequireAndPreserveDomTree)
AU.addPreserved<DominatorTreeWrapperPass>();
}
AU.addPreserved<DominatorTreeWrapperPass>();
}
StringRef getPassName() const override {

View File

@ -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

View File

@ -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