diff --git a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp index 9b40fc03da6bb..675f6e1975535 100644 --- a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp +++ b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp @@ -2522,12 +2522,14 @@ static void unswitchNontrivialInvariants( if (MSSAU && VerifyMemorySSA) MSSAU->getMemorySSA()->verifyMemorySSA(); +#ifdef EXPENSIVE_CHECKS // This transformation has a high risk of corrupting the dominator tree, and // the below steps to rebuild loop structures will result in hard to debug // errors in that case so verify that the dominator tree is sane first. // FIXME: Remove this when the bugs stop showing up and rely on existing // verification steps. assert(DT.verify(DominatorTree::VerificationLevel::Fast)); +#endif if (BI && !PartiallyInvariant) { // If we unswitched a branch which collapses the condition to a known @@ -2633,7 +2635,7 @@ static void unswitchNontrivialInvariants( OuterL = OuterL->getParentLoop()) UpdateLoop(*OuterL); -#ifndef NDEBUG +#ifdef EXPENSIVE_CHECKS // Verify the entire loop structure to catch any incorrect updates before we // progress in the pass pipeline. LI.verify(DT); @@ -3709,9 +3711,11 @@ PreservedAnalyses SimpleLoopUnswitchPass::run(Loop &L, LoopAnalysisManager &AM, if (AR.MSSA && VerifyMemorySSA) AR.MSSA->verifyMemorySSA(); +#ifdef EXPENSIVE_CHECKS // Historically this pass has had issues with the dominator tree so verify it // in asserts builds. assert(AR.DT.verify(DominatorTree::VerificationLevel::Fast)); +#endif auto PA = getLoopPassPreservedAnalyses(); if (AR.MSSA)