diff --git a/llvm/lib/CodeGen/DwarfEHPrepare.cpp b/llvm/lib/CodeGen/DwarfEHPrepare.cpp --- a/llvm/lib/CodeGen/DwarfEHPrepare.cpp +++ b/llvm/lib/CodeGen/DwarfEHPrepare.cpp @@ -153,7 +153,7 @@ 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 @@ 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 @@ 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 @@ const TargetLowering &TLI = *TM.getSubtargetImpl(F)->getTargetLowering(); DominatorTree *DT = nullptr; const TargetTransformInfo *TTI = nullptr; + if (auto *DTWP = getAnalysisIfAvailable()) + DT = &DTWP->getDomTree(); if (OptLevel != CodeGenOpt::None) { - DT = &getAnalysis().getDomTree(); + if (!DT) + DT = &getAnalysis().getDomTree(); TTI = &getAnalysis().getTTI(F); } return prepareDwarfEH(OptLevel, RewindFunction, F, TLI, DT, TTI); @@ -308,9 +301,8 @@ if (OptLevel != CodeGenOpt::None) { AU.addRequired(); AU.addRequired(); - if (RequireAndPreserveDomTree) - AU.addPreserved(); } + AU.addPreserved(); } StringRef getPassName() const override { diff --git a/llvm/test/CodeGen/ARM/O3-pipeline.ll b/llvm/test/CodeGen/ARM/O3-pipeline.ll --- 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 --- 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