forked from OSchip/llvm-project
[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:
parent
8cfa963463
commit
6617529a1d
|
@ -153,7 +153,7 @@ size_t DwarfEHPrepare::pruneUnreachableResumes(
|
||||||
BasicBlock *BB = RI->getParent();
|
BasicBlock *BB = RI->getParent();
|
||||||
new UnreachableInst(Ctx, RI);
|
new UnreachableInst(Ctx, RI);
|
||||||
RI->eraseFromParent();
|
RI->eraseFromParent();
|
||||||
simplifyCFG(BB, *TTI, RequireAndPreserveDomTree ? DTU : nullptr);
|
simplifyCFG(BB, *TTI, DTU);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Resumes.resize(ResumesLeft);
|
Resumes.resize(ResumesLeft);
|
||||||
|
@ -242,25 +242,15 @@ bool DwarfEHPrepare::InsertUnwindResumeCalls() {
|
||||||
CI->setDoesNotReturn();
|
CI->setDoesNotReturn();
|
||||||
new UnreachableInst(Ctx, UnwindBB);
|
new UnreachableInst(Ctx, UnwindBB);
|
||||||
|
|
||||||
if (DTU && RequireAndPreserveDomTree)
|
if (DTU)
|
||||||
DTU->applyUpdates(Updates);
|
DTU->applyUpdates(Updates);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DwarfEHPrepare::run() {
|
bool DwarfEHPrepare::run() {
|
||||||
assert(((OptLevel == CodeGenOpt::None || !RequireAndPreserveDomTree) ||
|
|
||||||
(DTU &&
|
|
||||||
DTU->getDomTree().verify(DominatorTree::VerificationLevel::Full))) &&
|
|
||||||
"Original domtree is invalid?");
|
|
||||||
|
|
||||||
bool Changed = InsertUnwindResumeCalls();
|
bool Changed = InsertUnwindResumeCalls();
|
||||||
|
|
||||||
assert(((OptLevel == CodeGenOpt::None || !RequireAndPreserveDomTree) ||
|
|
||||||
(DTU &&
|
|
||||||
DTU->getDomTree().verify(DominatorTree::VerificationLevel::Full))) &&
|
|
||||||
"Original domtree is invalid?");
|
|
||||||
|
|
||||||
return Changed;
|
return Changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,7 +258,7 @@ static bool prepareDwarfEH(CodeGenOpt::Level OptLevel,
|
||||||
FunctionCallee &RewindFunction, Function &F,
|
FunctionCallee &RewindFunction, Function &F,
|
||||||
const TargetLowering &TLI, DominatorTree *DT,
|
const TargetLowering &TLI, DominatorTree *DT,
|
||||||
const TargetTransformInfo *TTI) {
|
const TargetTransformInfo *TTI) {
|
||||||
DomTreeUpdater DTU(DT, DomTreeUpdater::UpdateStrategy::Eager);
|
DomTreeUpdater DTU(DT, DomTreeUpdater::UpdateStrategy::Lazy);
|
||||||
|
|
||||||
return DwarfEHPrepare(OptLevel, RewindFunction, F, TLI, DT ? &DTU : nullptr,
|
return DwarfEHPrepare(OptLevel, RewindFunction, F, TLI, DT ? &DTU : nullptr,
|
||||||
TTI)
|
TTI)
|
||||||
|
@ -295,7 +285,10 @@ public:
|
||||||
const TargetLowering &TLI = *TM.getSubtargetImpl(F)->getTargetLowering();
|
const TargetLowering &TLI = *TM.getSubtargetImpl(F)->getTargetLowering();
|
||||||
DominatorTree *DT = nullptr;
|
DominatorTree *DT = nullptr;
|
||||||
const TargetTransformInfo *TTI = nullptr;
|
const TargetTransformInfo *TTI = nullptr;
|
||||||
|
if (auto *DTWP = getAnalysisIfAvailable<DominatorTreeWrapperPass>())
|
||||||
|
DT = &DTWP->getDomTree();
|
||||||
if (OptLevel != CodeGenOpt::None) {
|
if (OptLevel != CodeGenOpt::None) {
|
||||||
|
if (!DT)
|
||||||
DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
|
DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
|
||||||
TTI = &getAnalysis<TargetTransformInfoWrapperPass>().getTTI(F);
|
TTI = &getAnalysis<TargetTransformInfoWrapperPass>().getTTI(F);
|
||||||
}
|
}
|
||||||
|
@ -308,9 +301,8 @@ public:
|
||||||
if (OptLevel != CodeGenOpt::None) {
|
if (OptLevel != CodeGenOpt::None) {
|
||||||
AU.addRequired<DominatorTreeWrapperPass>();
|
AU.addRequired<DominatorTreeWrapperPass>();
|
||||||
AU.addRequired<TargetTransformInfoWrapperPass>();
|
AU.addRequired<TargetTransformInfoWrapperPass>();
|
||||||
if (RequireAndPreserveDomTree)
|
|
||||||
AU.addPreserved<DominatorTreeWrapperPass>();
|
|
||||||
}
|
}
|
||||||
|
AU.addPreserved<DominatorTreeWrapperPass>();
|
||||||
}
|
}
|
||||||
|
|
||||||
StringRef getPassName() const override {
|
StringRef getPassName() const override {
|
||||||
|
|
|
@ -55,7 +55,6 @@
|
||||||
; CHECK-NEXT: Dominator Tree Construction
|
; CHECK-NEXT: Dominator Tree Construction
|
||||||
; CHECK-NEXT: Exception handling preparation
|
; CHECK-NEXT: Exception handling preparation
|
||||||
; CHECK-NEXT: Merge internal globals
|
; CHECK-NEXT: Merge internal globals
|
||||||
; CHECK-NEXT: Dominator Tree Construction
|
|
||||||
; CHECK-NEXT: Natural Loop Information
|
; CHECK-NEXT: Natural Loop Information
|
||||||
; CHECK-NEXT: Scalar Evolution Analysis
|
; CHECK-NEXT: Scalar Evolution Analysis
|
||||||
; CHECK-NEXT: Lazy Branch Probability Analysis
|
; CHECK-NEXT: Lazy Branch Probability Analysis
|
||||||
|
|
|
@ -69,7 +69,6 @@
|
||||||
; CHECK-NEXT: Safe Stack instrumentation pass
|
; CHECK-NEXT: Safe Stack instrumentation pass
|
||||||
; CHECK-NEXT: Insert stack protectors
|
; CHECK-NEXT: Insert stack protectors
|
||||||
; CHECK-NEXT: Module Verifier
|
; CHECK-NEXT: Module Verifier
|
||||||
; CHECK-NEXT: Dominator Tree Construction
|
|
||||||
; CHECK-NEXT: Basic Alias Analysis (stateless AA impl)
|
; CHECK-NEXT: Basic Alias Analysis (stateless AA impl)
|
||||||
; CHECK-NEXT: Function Alias Analysis Results
|
; CHECK-NEXT: Function Alias Analysis Results
|
||||||
; CHECK-NEXT: Natural Loop Information
|
; CHECK-NEXT: Natural Loop Information
|
||||||
|
|
Loading…
Reference in New Issue