[llvm] r296742 - Do not verify MachimeDominatorTree if it is not calculated
Serge Pavlov via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 2 04:00:11 PST 2017
Author: sepavloff
Date: Thu Mar 2 06:00:10 2017
New Revision: 296742
URL: http://llvm.org/viewvc/llvm-project?rev=296742&view=rev
Log:
Do not verify MachimeDominatorTree if it is not calculated
If dominator tree is not calculated or is invalidated, set corresponding
pointer in the pass state to nullptr. Such pointer value will indicate
that operations with dominator tree are not allowed. In particular, it
allows to skip verification for such pass state. The dominator tree is
not calculated if the machine dominator pass was skipped, it occures in
the case of entities with linkage available_externally.
The change fixes some test fails observed when expensive checks
are enabled.
Differential Revision: https://reviews.llvm.org/D29280
Modified:
llvm/trunk/include/llvm/CodeGen/MachineDominators.h
llvm/trunk/lib/CodeGen/MachineDominators.cpp
llvm/trunk/test/CodeGen/Generic/externally_available.ll
Modified: llvm/trunk/include/llvm/CodeGen/MachineDominators.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineDominators.h?rev=296742&r1=296741&r2=296742&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/MachineDominators.h (original)
+++ llvm/trunk/include/llvm/CodeGen/MachineDominators.h Thu Mar 2 06:00:10 2017
@@ -21,6 +21,7 @@
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/Support/GenericDomTree.h"
#include "llvm/Support/GenericDomTreeConstruction.h"
+#include <memory>
namespace llvm {
@@ -60,7 +61,7 @@ class MachineDominatorTree : public Mach
mutable SmallSet<MachineBasicBlock *, 32> NewBBs;
/// The DominatorTreeBase that is used to compute a normal dominator tree
- DominatorTreeBase<MachineBasicBlock>* DT;
+ std::unique_ptr<DominatorTreeBase<MachineBasicBlock>> DT;
/// \brief Apply all the recorded critical edges to the DT.
/// This updates the underlying DT information in a way that uses
@@ -74,9 +75,9 @@ public:
MachineDominatorTree();
- ~MachineDominatorTree() override;
-
DominatorTreeBase<MachineBasicBlock> &getBase() {
+ if (!DT)
+ DT.reset(new DominatorTreeBase<MachineBasicBlock>(false));
applySplitCriticalEdges();
return *DT;
}
@@ -244,21 +245,6 @@ public:
CriticalEdgesToSplit.push_back({FromBB, ToBB, NewBB});
}
- /// \brief Returns *false* if the other dominator tree matches this dominator
- /// tree.
- inline bool compare(const MachineDominatorTree &Other) const {
- const MachineDomTreeNode *R = getRootNode();
- const MachineDomTreeNode *OtherR = Other.getRootNode();
-
- if (!R || !OtherR || R->getBlock() != OtherR->getBlock())
- return true;
-
- if (DT->compare(*Other.DT))
- return true;
-
- return false;
- }
-
/// \brief Verify the correctness of the domtree by re-computing it.
///
/// This should only be used for debugging as it aborts the program if the
Modified: llvm/trunk/lib/CodeGen/MachineDominators.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineDominators.cpp?rev=296742&r1=296741&r2=296742&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineDominators.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineDominators.cpp Thu Mar 2 06:00:10 2017
@@ -49,32 +49,29 @@ void MachineDominatorTree::getAnalysisUs
bool MachineDominatorTree::runOnMachineFunction(MachineFunction &F) {
CriticalEdgesToSplit.clear();
NewBBs.clear();
+ DT.reset(new DominatorTreeBase<MachineBasicBlock>(false));
DT->recalculate(F);
-
return false;
}
MachineDominatorTree::MachineDominatorTree()
: MachineFunctionPass(ID) {
initializeMachineDominatorTreePass(*PassRegistry::getPassRegistry());
- DT = new DominatorTreeBase<MachineBasicBlock>(false);
-}
-
-MachineDominatorTree::~MachineDominatorTree() {
- delete DT;
}
void MachineDominatorTree::releaseMemory() {
- DT->releaseMemory();
+ CriticalEdgesToSplit.clear();
+ DT.reset(nullptr);
}
void MachineDominatorTree::verifyAnalysis() const {
- if (VerifyMachineDomInfo)
+ if (DT && VerifyMachineDomInfo)
verifyDomTree();
}
void MachineDominatorTree::print(raw_ostream &OS, const Module*) const {
- DT->print(OS);
+ if (DT)
+ DT->print(OS);
}
void MachineDominatorTree::applySplitCriticalEdges() const {
@@ -143,15 +140,18 @@ void MachineDominatorTree::applySplitCri
}
void MachineDominatorTree::verifyDomTree() const {
+ if (!DT)
+ return;
MachineFunction &F = *getRoot()->getParent();
- MachineDominatorTree OtherDT;
- OtherDT.DT->recalculate(F);
- if (compare(OtherDT)) {
+ DominatorTreeBase<MachineBasicBlock> OtherDT(false);
+ OtherDT.recalculate(F);
+ if (getRootNode()->getBlock() != OtherDT.getRootNode()->getBlock() ||
+ DT->compare(OtherDT)) {
errs() << "MachineDominatorTree is not up to date!\nComputed:\n";
- print(errs(), nullptr);
+ DT->print(errs());
errs() << "\nActual:\n";
- OtherDT.print(errs(), nullptr);
+ OtherDT.print(errs());
abort();
}
}
Modified: llvm/trunk/test/CodeGen/Generic/externally_available.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Generic/externally_available.ll?rev=296742&r1=296741&r2=296742&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/Generic/externally_available.ll (original)
+++ llvm/trunk/test/CodeGen/Generic/externally_available.ll Thu Mar 2 06:00:10 2017
@@ -1,4 +1,4 @@
-; RUN: llc < %s | not grep test_
+; RUN: llc -verify-machine-dom-info < %s | not grep test_
; test_function should not be emitted to the .s file.
define available_externally i32 @test_function() {
More information about the llvm-commits
mailing list