[PATCH] D68235: [Dominators][CodeGen] Add MachinePostDominatorTree verification

Jakub Kuderski via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 30 11:34:22 PDT 2019


kuhar updated this revision to Diff 222466.
kuhar added a comment.

Fix a typo


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68235/new/

https://reviews.llvm.org/D68235

Files:
  llvm/include/llvm/CodeGen/MachinePostDominators.h
  llvm/lib/CodeGen/MachineDominators.cpp
  llvm/lib/CodeGen/MachinePostDominators.cpp
  llvm/lib/CodeGen/MachineSink.cpp
  llvm/test/CodeGen/AArch64/O3-pipeline.ll


Index: llvm/test/CodeGen/AArch64/O3-pipeline.ll
===================================================================
--- llvm/test/CodeGen/AArch64/O3-pipeline.ll
+++ llvm/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
Index: llvm/lib/CodeGen/MachineSink.cpp
===================================================================
--- llvm/lib/CodeGen/MachineSink.cpp
+++ llvm/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<AAResultsWrapperPass>();
       AU.addRequired<MachineDominatorTree>();
       AU.addRequired<MachinePostDominatorTree>();
       AU.addRequired<MachineLoopInfo>();
       AU.addRequired<MachineBranchProbabilityInfo>();
-      AU.addPreserved<MachineDominatorTree>();
-      AU.addPreserved<MachinePostDominatorTree>();
       AU.addPreserved<MachineLoopInfo>();
       if (UseBlockFreqInfo)
         AU.addRequired<MachineBlockFrequencyInfo>();
Index: llvm/lib/CodeGen/MachinePostDominators.cpp
===================================================================
--- llvm/lib/CodeGen/MachinePostDominators.cpp
+++ llvm/lib/CodeGen/MachinePostDominators.cpp
@@ -13,14 +13,13 @@
 
 #include "llvm/CodeGen/MachinePostDominators.h"
 
-#include "llvm/ADT/STLExtras.h"
-
 using namespace llvm;
 
 namespace llvm {
 template class DominatorTreeBase<MachineBasicBlock, true>; // PostDomTreeBase
 }
 
+extern bool VerifyMachineDomInfo;
 char MachinePostDominatorTree::ID = 0;
 
 //declare initializeMachinePostDominatorTreePass
@@ -63,6 +62,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/lib/CodeGen/MachineDominators.cpp
===================================================================
--- llvm/lib/CodeGen/MachineDominators.cpp
+++ llvm/lib/CodeGen/MachineDominators.cpp
@@ -20,9 +20,9 @@
 
 // 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
 static cl::opt<bool, true> VerifyMachineDomInfoX(
     "verify-machine-dom-info", cl::location(VerifyMachineDomInfo), cl::Hidden,
Index: llvm/include/llvm/CodeGen/MachinePostDominators.h
===================================================================
--- llvm/include/llvm/CodeGen/MachinePostDominators.h
+++ llvm/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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68235.222466.patch
Type: text/x-patch
Size: 3651 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190930/ee1cafd4/attachment.bin>


More information about the llvm-commits mailing list