[llvm] r373341 - [Dominators][CodeGen] Add MachinePostDominatorTree verification
Jakub Kuderski via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 1 08:23:28 PDT 2019
Author: kuhar
Date: Tue Oct 1 08:23:27 2019
New Revision: 373341
URL: http://llvm.org/viewvc/llvm-project?rev=373341&view=rev
Log:
[Dominators][CodeGen] Add MachinePostDominatorTree verification
Summary:
This patch implements Machine PostDominator Tree verification and ensures that the verification doesn't fail the in-tree tests.
MPDT verification can be enabled using `verify-machine-dom-info` -- the same flag used by Machine Dominator Tree verification.
Flipping the flag revealed that MachineSink falsely claimed to preserve CFG and MDT/MPDT. This patch fixes that.
Reviewers: arsenm, hliao, rampitec, vpykhtin, grosser
Reviewed By: hliao
Subscribers: wdng, hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D68235
Modified:
llvm/trunk/include/llvm/CodeGen/MachinePostDominators.h
llvm/trunk/lib/CodeGen/MachineDominators.cpp
llvm/trunk/lib/CodeGen/MachinePostDominators.cpp
llvm/trunk/lib/CodeGen/MachineSink.cpp
llvm/trunk/test/CodeGen/AArch64/O3-pipeline.ll
Modified: llvm/trunk/include/llvm/CodeGen/MachinePostDominators.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachinePostDominators.h?rev=373341&r1=373340&r2=373341&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/MachinePostDominators.h (original)
+++ llvm/trunk/include/llvm/CodeGen/MachinePostDominators.h Tue Oct 1 08:23:27 2019
@@ -85,6 +85,7 @@ public:
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
Modified: llvm/trunk/lib/CodeGen/MachineDominators.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineDominators.cpp?rev=373341&r1=373340&r2=373341&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineDominators.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineDominators.cpp Tue Oct 1 08:23:27 2019
@@ -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<bool, true> VerifyMachineDomInfoX(
"verify-machine-dom-info", cl::location(VerifyMachineDomInfo), cl::Hidden,
cl::desc("Verify machine dominator info (time consuming)"));
Modified: llvm/trunk/lib/CodeGen/MachinePostDominators.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachinePostDominators.cpp?rev=373341&r1=373340&r2=373341&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachinePostDominators.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachinePostDominators.cpp Tue Oct 1 08:23:27 2019
@@ -13,13 +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;
+} // namespace llvm
char MachinePostDominatorTree::ID = 0;
@@ -63,6 +63,15 @@ MachineBasicBlock *MachinePostDominatorT
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);
Modified: llvm/trunk/lib/CodeGen/MachineSink.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineSink.cpp?rev=373341&r1=373340&r2=373341&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineSink.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineSink.cpp Tue Oct 1 08:23:27 2019
@@ -115,15 +115,12 @@ namespace {
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>();
Modified: llvm/trunk/test/CodeGen/AArch64/O3-pipeline.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/O3-pipeline.ll?rev=373341&r1=373340&r2=373341&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AArch64/O3-pipeline.ll (original)
+++ llvm/trunk/test/CodeGen/AArch64/O3-pipeline.ll Tue Oct 1 08:23:27 2019
@@ -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
More information about the llvm-commits
mailing list