summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/Transforms/Utils/MemorySSA.h10
-rw-r--r--llvm/lib/Transforms/Utils/MemorySSA.cpp14
2 files changed, 16 insertions, 8 deletions
diff --git a/llvm/include/llvm/Transforms/Utils/MemorySSA.h b/llvm/include/llvm/Transforms/Utils/MemorySSA.h
index abf42743df6..82e4cc26f5c 100644
--- a/llvm/include/llvm/Transforms/Utils/MemorySSA.h
+++ b/llvm/include/llvm/Transforms/Utils/MemorySSA.h
@@ -522,15 +522,19 @@ public:
/// whether MemoryAccess \p A dominates MemoryAccess \p B.
bool locallyDominates(const MemoryAccess *A, const MemoryAccess *B) const;
+ /// \brief Verify that MemorySSA is self consistent (IE definitions dominate
+ /// all uses, uses appear in the right places). This is used by unit tests.
+ void verifyMemorySSA() const;
+
protected:
// Used by Memory SSA annotater, dumpers, and wrapper pass
friend class MemorySSAAnnotatedWriter;
friend class MemorySSAPrinterPass;
- void verifyDefUses(Function &F);
- void verifyDomination(Function &F);
+ void verifyDefUses(Function &F) const;
+ void verifyDomination(Function &F) const;
private:
- void verifyUseInDefs(MemoryAccess *, MemoryAccess *);
+ void verifyUseInDefs(MemoryAccess *, MemoryAccess *) const;
using AccessMap =
DenseMap<const BasicBlock *, std::unique_ptr<AccessListType>>;
diff --git a/llvm/lib/Transforms/Utils/MemorySSA.cpp b/llvm/lib/Transforms/Utils/MemorySSA.cpp
index 54133f0df93..faa25b5ade8 100644
--- a/llvm/lib/Transforms/Utils/MemorySSA.cpp
+++ b/llvm/lib/Transforms/Utils/MemorySSA.cpp
@@ -439,9 +439,14 @@ void MemorySSA::dump() const {
F.print(dbgs(), &Writer);
}
+void MemorySSA::verifyMemorySSA() const {
+ verifyDefUses(F);
+ verifyDomination(F);
+}
+
/// \brief Verify the domination properties of MemorySSA by checking that each
/// definition dominates all of its uses.
-void MemorySSA::verifyDomination(Function &F) {
+void MemorySSA::verifyDomination(Function &F) const {
for (BasicBlock &B : F) {
// Phi nodes are attached to basic blocks
if (MemoryPhi *MP = getMemoryAccess(&B)) {
@@ -496,7 +501,7 @@ void MemorySSA::verifyDomination(Function &F) {
/// llvm_unreachable is used instead of asserts because this may be called in
/// a build without asserts. In that case, we don't want this to turn into a
/// nop.
-void MemorySSA::verifyUseInDefs(MemoryAccess *Def, MemoryAccess *Use) {
+void MemorySSA::verifyUseInDefs(MemoryAccess *Def, MemoryAccess *Use) const {
// The live on entry use may cause us to get a NULL def here
if (!Def) {
if (!isLiveOnEntryDef(Use))
@@ -510,7 +515,7 @@ void MemorySSA::verifyUseInDefs(MemoryAccess *Def, MemoryAccess *Use) {
/// \brief Verify the immediate use information, by walking all the memory
/// accesses and verifying that, for each use, it appears in the
/// appropriate def's use list
-void MemorySSA::verifyDefUses(Function &F) {
+void MemorySSA::verifyDefUses(Function &F) const {
for (BasicBlock &B : F) {
// Phi nodes are attached to basic blocks
if (MemoryPhi *Phi = getMemoryAccess(&B))
@@ -655,8 +660,7 @@ bool MemorySSAPrinterPass::runOnFunction(Function &F) {
Walker.reset(MSSA->buildMemorySSA(AA, DT));
if (VerifyMemorySSA) {
- MSSA->verifyDefUses(F);
- MSSA->verifyDomination(F);
+ MSSA->verifyMemorySSA();
}
return false;
OpenPOWER on IntegriCloud