<div dir="ltr">You're welcome! :-)<div><br></div><div>Alina</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Sep 15, 2021 at 11:17 AM Philip Reames <<a href="mailto:listmail@philipreames.com">listmail@philipreames.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Thank you!<br>
<br>
Philip<br>
<br>
On 9/15/21 11:11 AM, Alina Sbirlea via llvm-commits wrote:<br>
> Author: Alina Sbirlea<br>
> Date: 2021-09-15T11:09:54-07:00<br>
> New Revision: b759381b7515fc60ae41b78f162bab38bafa6baa<br>
><br>
> URL: <a href="https://github.com/llvm/llvm-project/commit/b759381b7515fc60ae41b78f162bab38bafa6baa" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/b759381b7515fc60ae41b78f162bab38bafa6baa</a><br>
> DIFF: <a href="https://github.com/llvm/llvm-project/commit/b759381b7515fc60ae41b78f162bab38bafa6baa.diff" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/b759381b7515fc60ae41b78f162bab38bafa6baa.diff</a><br>
><br>
> LOG: [MemorySSA] Add verification levels to MemorySSA. [NFC]<br>
><br>
> Add two levels of verification for MemorySSA: Fast and Full.<br>
> The defaults are kept the same. Full verification always occurs under<br>
> EXPENSIVE_CHECKS, but now it can also be requested in a specific pass for<br>
> debugging purposes.<br>
><br>
> Added:<br>
> <br>
><br>
> Modified:<br>
> llvm/include/llvm/Analysis/MemorySSA.h<br>
> llvm/lib/Analysis/MemorySSA.cpp<br>
><br>
> Removed:<br>
> <br>
><br>
><br>
> ################################################################################<br>
> diff --git a/llvm/include/llvm/Analysis/MemorySSA.h b/llvm/include/llvm/Analysis/MemorySSA.h<br>
> index afa89af63672..48aeef371e3d 100644<br>
> --- a/llvm/include/llvm/Analysis/MemorySSA.h<br>
> +++ b/llvm/include/llvm/Analysis/MemorySSA.h<br>
> @@ -783,9 +783,10 @@ class MemorySSA {<br>
> /// dominates Use \p B.<br>
> bool dominates(const MemoryAccess *A, const Use &B) const;<br>
> <br>
> + enum class VerificationLevel { Fast, Full };<br>
> /// Verify that MemorySSA is self consistent (IE definitions dominate<br>
> /// all uses, uses appear in the right places). This is used by unit tests.<br>
> - void verifyMemorySSA() const;<br>
> + void verifyMemorySSA(VerificationLevel = VerificationLevel::Fast) const;<br>
> <br>
> /// Used in various insertion functions to specify whether we are talking<br>
> /// about the beginning or end of a block.<br>
> @@ -796,7 +797,8 @@ class MemorySSA {<br>
> friend class MemorySSAPrinterLegacyPass;<br>
> friend class MemorySSAUpdater;<br>
> <br>
> - void verifyOrderingDominationAndDefUses(Function &F) const;<br>
> + void verifyOrderingDominationAndDefUses(<br>
> + Function &F, VerificationLevel = VerificationLevel::Fast) const;<br>
> void verifyDominationNumbers(const Function &F) const;<br>
> void verifyPrevDefInPhis(Function &F) const;<br>
> <br>
><br>
> diff --git a/llvm/lib/Analysis/MemorySSA.cpp b/llvm/lib/Analysis/MemorySSA.cpp<br>
> index 4dc2a427caa2..b97cd0c6b186 100644<br>
> --- a/llvm/lib/Analysis/MemorySSA.cpp<br>
> +++ b/llvm/lib/Analysis/MemorySSA.cpp<br>
> @@ -1896,10 +1896,17 @@ void MemorySSA::print(raw_ostream &OS) const {<br>
> LLVM_DUMP_METHOD void MemorySSA::dump() const { print(dbgs()); }<br>
> #endif<br>
> <br>
> -void MemorySSA::verifyMemorySSA() const {<br>
> - verifyOrderingDominationAndDefUses(F);<br>
> +void MemorySSA::verifyMemorySSA(VerificationLevel VL) const {<br>
> +#if !defined(NDEBUG) && defined(EXPENSIVE_CHECKS)<br>
> + VL = VerificationLevel::Full;<br>
> +#endif<br>
> +<br>
> +#ifndef NDEBUG<br>
> + verifyOrderingDominationAndDefUses(F, VL);<br>
> verifyDominationNumbers(F);<br>
> - verifyPrevDefInPhis(F);<br>
> + if (VL == VerificationLevel::Full)<br>
> + verifyPrevDefInPhis(F);<br>
> +#endif<br>
> // Previously, the verification used to also verify that the clobberingAccess<br>
> // cached by MemorySSA is the same as the clobberingAccess found at a later<br>
> // query to AA. This does not hold true in general due to the current fragility<br>
> @@ -1913,7 +1920,6 @@ void MemorySSA::verifyMemorySSA() const {<br>
> }<br>
> <br>
> void MemorySSA::verifyPrevDefInPhis(Function &F) const {<br>
> -#if !defined(NDEBUG) && defined(EXPENSIVE_CHECKS)<br>
> for (const BasicBlock &BB : F) {<br>
> if (MemoryPhi *Phi = getMemoryAccess(&BB)) {<br>
> for (unsigned I = 0, E = Phi->getNumIncomingValues(); I != E; ++I) {<br>
> @@ -1943,13 +1949,11 @@ void MemorySSA::verifyPrevDefInPhis(Function &F) const {<br>
> }<br>
> }<br>
> }<br>
> -#endif<br>
> }<br>
> <br>
> /// Verify that all of the blocks we believe to have valid domination numbers<br>
> /// actually have valid domination numbers.<br>
> void MemorySSA::verifyDominationNumbers(const Function &F) const {<br>
> -#ifndef NDEBUG<br>
> if (BlockNumberingValid.empty())<br>
> return;<br>
> <br>
> @@ -1981,7 +1985,6 @@ void MemorySSA::verifyDominationNumbers(const Function &F) const {<br>
> <br>
> assert(ValidBlocks.empty() &&<br>
> "All valid BasicBlocks should exist in F -- dangling pointers?");<br>
> -#endif<br>
> }<br>
> <br>
> /// Verify ordering: the order and existence of MemoryAccesses matches the<br>
> @@ -1990,8 +1993,8 @@ void MemorySSA::verifyDominationNumbers(const Function &F) const {<br>
> /// Verify def-uses: the immediate use information - walk all the memory<br>
> /// accesses and verifying that, for each use, it appears in the appropriate<br>
> /// def's use list<br>
> -void MemorySSA::verifyOrderingDominationAndDefUses(Function &F) const {<br>
> -#if !defined(NDEBUG)<br>
> +void MemorySSA::verifyOrderingDominationAndDefUses(Function &F,<br>
> + VerificationLevel VL) const {<br>
> // Walk all the blocks, comparing what the lookups think and what the access<br>
> // lists think, as well as the order in the blocks vs the order in the access<br>
> // lists.<br>
> @@ -2008,17 +2011,17 @@ void MemorySSA::verifyOrderingDominationAndDefUses(Function &F) const {<br>
> // Verify domination<br>
> for (const Use &U : Phi->uses())<br>
> assert(dominates(Phi, U) && "Memory PHI does not dominate it's uses");<br>
> -#if defined(EXPENSIVE_CHECKS)<br>
> - // Verify def-uses.<br>
> - assert(Phi->getNumOperands() == static_cast<unsigned>(std::distance(<br>
> - pred_begin(&B), pred_end(&B))) &&<br>
> - "Incomplete MemoryPhi Node");<br>
> - for (unsigned I = 0, E = Phi->getNumIncomingValues(); I != E; ++I) {<br>
> - verifyUseInDefs(Phi->getIncomingValue(I), Phi);<br>
> - assert(is_contained(predecessors(&B), Phi->getIncomingBlock(I)) &&<br>
> - "Incoming phi block not a block predecessor");<br>
> + // Verify def-uses for full verify.<br>
> + if (VL == VerificationLevel::Full) {<br>
> + assert(Phi->getNumOperands() == static_cast<unsigned>(std::distance(<br>
> + pred_begin(&B), pred_end(&B))) &&<br>
> + "Incomplete MemoryPhi Node");<br>
> + for (unsigned I = 0, E = Phi->getNumIncomingValues(); I != E; ++I) {<br>
> + verifyUseInDefs(Phi->getIncomingValue(I), Phi);<br>
> + assert(is_contained(predecessors(&B), Phi->getIncomingBlock(I)) &&<br>
> + "Incoming phi block not a block predecessor");<br>
> + }<br>
> }<br>
> -#endif<br>
> }<br>
> <br>
> for (Instruction &I : B) {<br>
> @@ -2038,10 +2041,9 @@ void MemorySSA::verifyOrderingDominationAndDefUses(Function &F) const {<br>
> assert(dominates(MD, U) &&<br>
> "Memory Def does not dominate it's uses");<br>
> }<br>
> -#if defined(EXPENSIVE_CHECKS)<br>
> - // Verify def-uses.<br>
> - verifyUseInDefs(MA->getDefiningAccess(), MA);<br>
> -#endif<br>
> + // Verify def-uses for full verify.<br>
> + if (VL == VerificationLevel::Full)<br>
> + verifyUseInDefs(MA->getDefiningAccess(), MA);<br>
> }<br>
> }<br>
> // Either we hit the assert, really have no accesses, or we have both<br>
> @@ -2076,13 +2078,11 @@ void MemorySSA::verifyOrderingDominationAndDefUses(Function &F) const {<br>
> }<br>
> ActualDefs.clear();<br>
> }<br>
> -#endif<br>
> }<br>
> <br>
> /// Verify the def-use lists in MemorySSA, by verifying that \p Use<br>
> /// appears in the use list of \p Def.<br>
> void MemorySSA::verifyUseInDefs(MemoryAccess *Def, MemoryAccess *Use) const {<br>
> -#ifndef NDEBUG<br>
> // The live on entry use may cause us to get a NULL def here<br>
> if (!Def)<br>
> assert(isLiveOnEntryDef(Use) &&<br>
> @@ -2090,7 +2090,6 @@ void MemorySSA::verifyUseInDefs(MemoryAccess *Def, MemoryAccess *Use) const {<br>
> else<br>
> assert(is_contained(Def->users(), Use) &&<br>
> "Did not find use in def's use list");<br>
> -#endif<br>
> }<br>
> <br>
> /// Perform a local numbering on blocks so that instruction ordering can be<br>
><br>
><br>
> <br>
> _______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
> <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>