Index: llvm/trunk/include/llvm/CodeGen/MachinePostDominators.h =================================================================== --- llvm/trunk/include/llvm/CodeGen/MachinePostDominators.h +++ llvm/trunk/include/llvm/CodeGen/MachinePostDominators.h @@ -85,6 +85,7 @@ bool runOnMachineFunction(MachineFunction &MF) override; void getAnalysisUsage(AnalysisUsage &AU) const override; void releaseMemory() override { PDT.reset(nullptr); } + void verifyAnalysis() const override; void print(llvm::raw_ostream &OS, const Module *M = nullptr) const override; }; } //end of namespace llvm Index: llvm/trunk/lib/CodeGen/MachineDominators.cpp =================================================================== --- llvm/trunk/lib/CodeGen/MachineDominators.cpp +++ llvm/trunk/lib/CodeGen/MachineDominators.cpp @@ -18,12 +18,15 @@ using namespace llvm; +namespace llvm { // Always verify dominfo if expensive checking is enabled. #ifdef EXPENSIVE_CHECKS -static bool VerifyMachineDomInfo = true; +bool VerifyMachineDomInfo = true; #else -static bool VerifyMachineDomInfo = false; +bool VerifyMachineDomInfo = false; #endif +} // namespace llvm + static cl::opt VerifyMachineDomInfoX( "verify-machine-dom-info", cl::location(VerifyMachineDomInfo), cl::Hidden, cl::desc("Verify machine dominator info (time consuming)")); Index: llvm/trunk/lib/CodeGen/MachinePostDominators.cpp =================================================================== --- llvm/trunk/lib/CodeGen/MachinePostDominators.cpp +++ llvm/trunk/lib/CodeGen/MachinePostDominators.cpp @@ -13,13 +13,13 @@ #include "llvm/CodeGen/MachinePostDominators.h" -#include "llvm/ADT/STLExtras.h" - using namespace llvm; namespace llvm { template class DominatorTreeBase; // PostDomTreeBase -} + +extern bool VerifyMachineDomInfo; +} // namespace llvm char MachinePostDominatorTree::ID = 0; @@ -63,6 +63,15 @@ return NCD; } +void MachinePostDominatorTree::verifyAnalysis() const { + if (PDT && VerifyMachineDomInfo) + if (!PDT->verify(PostDomTreeT::VerificationLevel::Basic)) { + errs() << "MachinePostDominatorTree verification failed\n"; + + abort(); + } +} + void MachinePostDominatorTree::print(llvm::raw_ostream &OS, const Module *M) const { PDT->print(OS); Index: llvm/trunk/lib/CodeGen/MachineSink.cpp =================================================================== --- llvm/trunk/lib/CodeGen/MachineSink.cpp +++ llvm/trunk/lib/CodeGen/MachineSink.cpp @@ -115,15 +115,12 @@ bool runOnMachineFunction(MachineFunction &MF) override; void getAnalysisUsage(AnalysisUsage &AU) const override { - AU.setPreservesCFG(); MachineFunctionPass::getAnalysisUsage(AU); AU.addRequired(); AU.addRequired(); AU.addRequired(); AU.addRequired(); AU.addRequired(); - AU.addPreserved(); - AU.addPreserved(); AU.addPreserved(); if (UseBlockFreqInfo) AU.addRequired(); Index: llvm/trunk/test/CodeGen/AArch64/O3-pipeline.ll =================================================================== --- llvm/trunk/test/CodeGen/AArch64/O3-pipeline.ll +++ llvm/trunk/test/CodeGen/AArch64/O3-pipeline.ll @@ -114,6 +114,7 @@ ; CHECK-NEXT: Live Variable Analysis ; CHECK-NEXT: Eliminate PHI nodes for register allocation ; CHECK-NEXT: Two-Address instruction pass +; CHECK-NEXT: MachineDominator Tree Construction ; CHECK-NEXT: Slot index numbering ; CHECK-NEXT: Live Interval Analysis ; CHECK-NEXT: Simple Register Coalescing