[SimpleLoopUnswitch] Verify LoopInfo after turning guards to branches

SplitBlockAndInsertIfThen doesn't correctly update LoopInfo when called
with Unreachable=true, which is the case when we turn guards to branches
in SimpleLoopUnswitch.

This adds LoopInfo verification before returning from turnGuardIntoBranch.
This commit is contained in:
Dmitry Makogon committed 2023-06-08 18:29:19 +07:00
1 parent f7cfa3a7ab
commit 64397d8f25
3 files changed
+5

No files matched your search

@@ -2735,6 +2735,7 @@ static BranchInst *turnGuardIntoBranch(IntrinsicInst *GI, Loop &L,
MSSAU->getMemorySSA()->verifyMemorySSA();
}
LI.verify(DT);
++NumGuards;
return CheckBI;
}
@@ -2,6 +2,9 @@
; RUN: opt -passes='simple-loop-unswitch<nontrivial>' -simple-loop-unswitch-guards -S < %s | FileCheck %s
; RUN: opt -passes='loop-mssa(simple-loop-unswitch<nontrivial>),verify<loops>' -simple-loop-unswitch-guards -verify-memoryssa -S < %s | FileCheck %s
; XFAIL: *
; REQUIRES: asserts
declare void @llvm.experimental.guard(i1, ...)
define void @test_simple_case(i1 %cond, i32 %N) {
@@ -7,6 +7,7 @@ declare ptr @pluto()
declare void @llvm.experimental.guard(i1, ...)
declare void @widget()
; XFAIL: *
; REQUIRES: asserts
define void @foo(ptr addrspace(1) %arg, i64 %arg1) personality ptr @pluto {