[llvm] 64397d8 - [SimpleLoopUnswitch] Verify LoopInfo after turning guards to branches

Dmitry Makogon via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 8 04:43:54 PDT 2023


Author: Dmitry Makogon
Date: 2023-06-08T18:29:19+07:00
New Revision: 64397d8f25ef6eb1052c20a646589ab9d70cc0d7

URL: https://github.com/llvm/llvm-project/commit/64397d8f25ef6eb1052c20a646589ab9d70cc0d7
DIFF: https://github.com/llvm/llvm-project/commit/64397d8f25ef6eb1052c20a646589ab9d70cc0d7.diff

LOG: [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.

Added: 
    

Modified: 
    llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
    llvm/test/Transforms/SimpleLoopUnswitch/guards.ll
    llvm/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch-skip-selects-in-guards.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
index 6034b6b880ce6..176c66fa3e3fa 100644
--- a/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
+++ b/llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp
@@ -2735,6 +2735,7 @@ static BranchInst *turnGuardIntoBranch(IntrinsicInst *GI, Loop &L,
       MSSAU->getMemorySSA()->verifyMemorySSA();
   }
 
+  LI.verify(DT);
   ++NumGuards;
   return CheckBI;
 }

diff  --git a/llvm/test/Transforms/SimpleLoopUnswitch/guards.ll b/llvm/test/Transforms/SimpleLoopUnswitch/guards.ll
index 0123d2246ad23..d6ce893bbce24 100644
--- a/llvm/test/Transforms/SimpleLoopUnswitch/guards.ll
+++ b/llvm/test/Transforms/SimpleLoopUnswitch/guards.ll
@@ -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) {

diff  --git a/llvm/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch-skip-selects-in-guards.ll b/llvm/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch-skip-selects-in-guards.ll
index a1012cae3a956..171a1fd435862 100644
--- a/llvm/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch-skip-selects-in-guards.ll
+++ b/llvm/test/Transforms/SimpleLoopUnswitch/nontrivial-unswitch-skip-selects-in-guards.ll
@@ -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 {


        


More information about the llvm-commits mailing list