diff --git a/llvm/include/llvm/Analysis/MemorySSA.h b/llvm/include/llvm/Analysis/MemorySSA.h --- a/llvm/include/llvm/Analysis/MemorySSA.h +++ b/llvm/include/llvm/Analysis/MemorySSA.h @@ -797,7 +797,7 @@ void verifyPrevDefInPhis(Function &F) const; void verifyDefUses(Function &F) const; void verifyDomination(Function &F) const; - void verifyOrdering(Function &F) const; + void verifyOrderingAndDomination(Function &F) const; void verifyDominationNumbers(const Function &F) const; // This is used by the use optimizer and updater. diff --git a/llvm/lib/Analysis/MemorySSA.cpp b/llvm/lib/Analysis/MemorySSA.cpp --- a/llvm/lib/Analysis/MemorySSA.cpp +++ b/llvm/lib/Analysis/MemorySSA.cpp @@ -1872,7 +1872,7 @@ void MemorySSA::verifyMemorySSA() const { verifyDefUses(F); verifyDomination(F); - verifyOrdering(F); + verifyOrderingAndDomination(F); verifyDominationNumbers(F); verifyPrevDefInPhis(F); // Previously, the verification used to also verify that the clobberingAccess @@ -1961,8 +1961,10 @@ /// Verify that the order and existence of MemoryAccesses matches the /// order and existence of memory affecting instructions. -void MemorySSA::verifyOrdering(Function &F) const { -#ifndef NDEBUG +/// Verify the domination properties of MemorySSA by checking that each +/// definition dominates all of its uses. +void MemorySSA::verifyOrderingAndDomination(Function &F) const { +#if !defined(NDEBUG) // Walk all the blocks, comparing what the lookups think and what the access // lists think, as well as the order in the blocks vs the order in the access // lists. @@ -1975,6 +1977,8 @@ if (Phi) { ActualAccesses.push_back(Phi); ActualDefs.push_back(Phi); + for (const Use &U : Phi->uses()) + assert(dominates(Phi, U) && "Memory PHI does not dominate it's uses"); } for (Instruction &I : B) { @@ -1985,8 +1989,11 @@ "access list or defs list"); if (MA) { ActualAccesses.push_back(MA); - if (isa(MA)) + if (MemoryAccess *MD = dyn_cast(MA)) { + for (const Use &U : MD->uses()) + assert(dominates(MD, U) && "Memory Def does not dominate it's uses"); ActualDefs.push_back(MA); + } } } // Either we hit the assert, really have no accesses, or we have both @@ -2027,7 +2034,7 @@ /// Verify the domination properties of MemorySSA by checking that each /// definition dominates all of its uses. void MemorySSA::verifyDomination(Function &F) const { -#ifndef NDEBUG +#if 0 for (BasicBlock &B : F) { // Phi nodes are attached to basic blocks if (MemoryPhi *MP = getMemoryAccess(&B))