[LPM][LegacyPM] Reenable LCSSA Verification

This was disabled about a decade ago due to issues with LoopSink.
LoopSink has since had its LegacyPM version removed and is now a
function pass due to not needing too much loop infrastructure. So we can
try enabling this again to prevent backsliding on important cases while
we work on switching to the NewPM which does enforce these things.

Eventually we will want to add assertions here for LoopStrengthReduce,
but given it does not correctly preserve LCSSA, postpone that for now.

Reviewers: arsenm, Meinersbur, nikic, fhahn

Pull Request: https://github.com/llvm/llvm-project/pull/191667
diff --git a/llvm/lib/Analysis/LoopPass.cpp b/llvm/lib/Analysis/LoopPass.cpp
index d8680aa..85c15c5 100644
--- a/llvm/lib/Analysis/LoopPass.cpp
+++ b/llvm/lib/Analysis/LoopPass.cpp
@@ -130,7 +130,7 @@
   auto &LIWP = getAnalysis<LoopInfoWrapperPass>();
   LI = &LIWP.getLoopInfo();
   Module &M = *F.getParent();
-#if 0
+#ifndef NDEBUG
   DominatorTree *DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
 #endif
   bool Changed = false;
@@ -239,9 +239,7 @@
         // is that LPPassManager might run passes which do not require LCSSA
         // form (LoopPassPrinter for example). We should skip verification for
         // such passes.
-        // FIXME: Loop-sink currently break LCSSA. Fix it and reenable the
-        // verification!
-#if 0
+#ifndef NDEBUG
         if (mustPreserveAnalysisID(LCSSAVerificationPass::ID))
           assert(CurrentLoop->isRecursivelyLCSSAForm(*DT, *LI));
 #endif