From 519b019a0a6cd50b34c90d1ec7004bb802d680e8 Mon Sep 17 00:00:00 2001 From: Alina Sbirlea Date: Thu, 11 Jun 2020 18:16:33 -0700 Subject: [PATCH] Verify MemorySSA after all updates. Verify after completing all updates. Resolves PR46275. --- llvm/lib/Transforms/Utils/LoopUtils.cpp | 4 ++-- llvm/test/Analysis/MemorySSA/pr46275.ll | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 llvm/test/Analysis/MemorySSA/pr46275.ll diff --git a/llvm/lib/Transforms/Utils/LoopUtils.cpp b/llvm/lib/Transforms/Utils/LoopUtils.cpp index d7ea9923ed2e..16603bfd0eb1 100644 --- a/llvm/lib/Transforms/Utils/LoopUtils.cpp +++ b/llvm/lib/Transforms/Utils/LoopUtils.cpp @@ -622,11 +622,11 @@ void llvm::deleteDeadLoop(Loop *L, DominatorTree *DT, ScalarEvolution *SE, if (MSSA) { MSSAU->applyUpdates({{DominatorTree::Delete, Preheader, L->getHeader()}}, *DT); - if (VerifyMemorySSA) - MSSA->verifyMemorySSA(); SmallSetVector DeadBlockSet(L->block_begin(), L->block_end()); MSSAU->removeBlocks(DeadBlockSet); + if (VerifyMemorySSA) + MSSA->verifyMemorySSA(); } } diff --git a/llvm/test/Analysis/MemorySSA/pr46275.ll b/llvm/test/Analysis/MemorySSA/pr46275.ll new file mode 100644 index 000000000000..01b71b6a38e5 --- /dev/null +++ b/llvm/test/Analysis/MemorySSA/pr46275.ll @@ -0,0 +1,23 @@ +; RUN: opt -S -memoryssa -loop-deletion -loop-simplifycfg -verify-memoryssa < %s | FileCheck %s +; REQUIRES: asserts + +; CHECK-LABEL: @foo() +define void @foo() { +entry: + br i1 false, label %for.body.lr.ph, label %for.end + +for.body.lr.ph: ; preds = %entry + br label %for.body + +for.body: ; preds = %for.body, %for.body.lr.ph + call void @foo() + call void @foo() + br i1 false, label %for.body, label %for.cond.for.end_crit_edge + +for.cond.for.end_crit_edge: ; preds = %for.body + unreachable + +for.end: ; preds = %entry + ret void +} +