[llvm] 4ef47ea - [Test] Add one more loop deletion irreducible CFG test
Max Kazantsev via llvm-commits
llvm-commits at lists.llvm.org
Mon May 31 21:11:41 PDT 2021
Author: Max Kazantsev
Date: 2021-06-01T11:11:15+07:00
New Revision: 4ef47eaed9528932127c5072e340f1bc5f7e9684
URL: https://github.com/llvm/llvm-project/commit/4ef47eaed9528932127c5072e340f1bc5f7e9684
DIFF: https://github.com/llvm/llvm-project/commit/4ef47eaed9528932127c5072e340f1bc5f7e9684.diff
LOG: [Test] Add one more loop deletion irreducible CFG test
Added:
Modified:
llvm/test/Transforms/LoopDeletion/irreducible-cfg.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/LoopDeletion/irreducible-cfg.ll b/llvm/test/Transforms/LoopDeletion/irreducible-cfg.ll
index b0d34bb3e249..3122f66916f6 100644
--- a/llvm/test/Transforms/LoopDeletion/irreducible-cfg.ll
+++ b/llvm/test/Transforms/LoopDeletion/irreducible-cfg.ll
@@ -3,13 +3,13 @@
; RUN: opt < %s -passes='loop(loop-deletion)' -S | FileCheck %s
; Make sure we do not get the miscompile on this test with irreducible CFG.
-define i16 @test(i16 %j, i16 %k, i16 %recurs) { ; If we have %j: 1, %k: 1, %recurs: 0
-; CHECK-LABEL: @test(
+define i16 @test_01(i16 %j, i16 %k, i16 %recurs) { ; If we have %j: 1, %k: 1, %recurs: 0
+; CHECK-LABEL: @test_01(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[TOBOOL_NOT:%.*]] = icmp eq i16 [[RECURS:%.*]], 0
; CHECK-NEXT: br i1 [[TOBOOL_NOT]], label [[IF_END:%.*]], label [[IF_THEN:%.*]]
; CHECK: if.then:
-; CHECK-NEXT: [[CALL:%.*]] = tail call i16 @test(i16 0, i16 0, i16 0)
+; CHECK-NEXT: [[CALL:%.*]] = tail call i16 @test_01(i16 0, i16 0, i16 0)
; CHECK-NEXT: br label [[IF_END]]
; CHECK: if.end:
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i16 [[J:%.*]], 0
@@ -38,7 +38,7 @@ entry:
br i1 %tobool.not, label %if.end, label %if.then ; -> if.end
if.then: ; preds = %entry
- %call = tail call i16 @test(i16 0, i16 0, i16 0)
+ %call = tail call i16 @test_01(i16 0, i16 0, i16 0)
br label %if.end
if.end: ; preds = %if.then, %entry
@@ -67,3 +67,177 @@ bb13: ; preds = %bb4
%result.1.lcssa = phi i16 [ %result.1, %bb4 ]
ret i16 %result.1.lcssa
}
+
+; Another nasty case of irreducible CFG. Make sure we do not crash here.
+define void @test_02() {
+; CHECK-LABEL: @test_02(
+; CHECK-NEXT: bb:
+; CHECK-NEXT: br label [[BB17:%.*]]
+; CHECK: bb1:
+; CHECK-NEXT: ret void
+; CHECK: bb2:
+; CHECK-NEXT: unreachable
+; CHECK: bb3:
+; CHECK-NEXT: unreachable
+; CHECK: bb4:
+; CHECK-NEXT: unreachable
+; CHECK: bb5:
+; CHECK-NEXT: unreachable
+; CHECK: bb6:
+; CHECK-NEXT: unreachable
+; CHECK: bb7:
+; CHECK-NEXT: unreachable
+; CHECK: bb8:
+; CHECK-NEXT: unreachable
+; CHECK: bb9:
+; CHECK-NEXT: switch i8 undef, label [[BB13:%.*]] [
+; CHECK-NEXT: i8 3, label [[BB10:%.*]]
+; CHECK-NEXT: i8 43, label [[BB10]]
+; CHECK-NEXT: i8 37, label [[BB11:%.*]]
+; CHECK-NEXT: i8 2, label [[BB12:%.*]]
+; CHECK-NEXT: i8 4, label [[BB12]]
+; CHECK-NEXT: i8 20, label [[BB12]]
+; CHECK-NEXT: i8 42, label [[BB12]]
+; CHECK-NEXT: i8 44, label [[BB12]]
+; CHECK-NEXT: i8 54, label [[BB12]]
+; CHECK-NEXT: ]
+; CHECK: bb10:
+; CHECK-NEXT: unreachable
+; CHECK: bb11:
+; CHECK-NEXT: unreachable
+; CHECK: bb12:
+; CHECK-NEXT: br label [[BB19:%.*]]
+; CHECK: bb13:
+; CHECK-NEXT: unreachable
+; CHECK: bb14:
+; CHECK-NEXT: unreachable
+; CHECK: bb15:
+; CHECK-NEXT: unreachable
+; CHECK: bb16:
+; CHECK-NEXT: br label [[BB17]]
+; CHECK: bb17:
+; CHECK-NEXT: [[TMP:%.*]] = icmp sgt i32 0, 1
+; CHECK-NEXT: br i1 [[TMP]], label [[BB18:%.*]], label [[BB19]]
+; CHECK: bb18:
+; CHECK-NEXT: br label [[BB20:%.*]]
+; CHECK: bb19:
+; CHECK-NEXT: br label [[BB20]]
+; CHECK: bb20:
+; CHECK-NEXT: switch i8 undef, label [[BB16:%.*]] [
+; CHECK-NEXT: i8 0, label [[BB1:%.*]]
+; CHECK-NEXT: i8 1, label [[BB1]]
+; CHECK-NEXT: i8 8, label [[BB1]]
+; CHECK-NEXT: i8 9, label [[BB1]]
+; CHECK-NEXT: i8 12, label [[BB1]]
+; CHECK-NEXT: i8 13, label [[BB1]]
+; CHECK-NEXT: i8 40, label [[BB1]]
+; CHECK-NEXT: i8 41, label [[BB1]]
+; CHECK-NEXT: i8 52, label [[BB1]]
+; CHECK-NEXT: i8 53, label [[BB1]]
+; CHECK-NEXT: i8 55, label [[BB15:%.*]]
+; CHECK-NEXT: i8 15, label [[BB14:%.*]]
+; CHECK-NEXT: i8 29, label [[BB9:%.*]]
+; CHECK-NEXT: i8 37, label [[BB8:%.*]]
+; CHECK-NEXT: i8 69, label [[BB3:%.*]]
+; CHECK-NEXT: i8 89, label [[BB7:%.*]]
+; CHECK-NEXT: i8 85, label [[BB6:%.*]]
+; CHECK-NEXT: i8 81, label [[BB5:%.*]]
+; CHECK-NEXT: i8 65, label [[BB2:%.*]]
+; CHECK-NEXT: i8 73, label [[BB4:%.*]]
+; CHECK-NEXT: ]
+;
+bb:
+ br label %bb17
+
+bb1: ; preds = %bb20, %bb20, %bb20, %bb20, %bb20, %bb20, %bb20, %bb20, %bb20, %bb20
+ ret void
+
+bb2: ; preds = %bb20
+ unreachable
+
+bb3: ; preds = %bb20
+ unreachable
+
+bb4: ; preds = %bb20
+ unreachable
+
+bb5: ; preds = %bb20
+ unreachable
+
+bb6: ; preds = %bb20
+ unreachable
+
+bb7: ; preds = %bb20
+ unreachable
+
+bb8: ; preds = %bb20
+ unreachable
+
+bb9: ; preds = %bb20
+ switch i8 undef, label %bb13 [
+ i8 3, label %bb10
+ i8 43, label %bb10
+ i8 37, label %bb11
+ i8 2, label %bb12
+ i8 4, label %bb12
+ i8 20, label %bb12
+ i8 42, label %bb12
+ i8 44, label %bb12
+ i8 54, label %bb12
+ ]
+
+bb10: ; preds = %bb9, %bb9
+ unreachable
+
+bb11: ; preds = %bb9
+ unreachable
+
+bb12: ; preds = %bb9, %bb9, %bb9, %bb9, %bb9, %bb9
+ br label %bb19
+
+bb13: ; preds = %bb9
+ unreachable
+
+bb14: ; preds = %bb20
+ unreachable
+
+bb15: ; preds = %bb20
+ unreachable
+
+bb16: ; preds = %bb20
+ br label %bb17
+
+bb17: ; preds = %bb16, %bb
+ %tmp = icmp sgt i32 0, 1
+ br i1 %tmp, label %bb18, label %bb19
+
+bb18: ; preds = %bb17
+ br label %bb20
+
+bb19: ; preds = %bb17, %bb12
+ br label %bb20
+
+bb20: ; preds = %bb19, %bb18
+ switch i8 undef, label %bb16 [
+ i8 0, label %bb1
+ i8 1, label %bb1
+ i8 8, label %bb1
+ i8 9, label %bb1
+ i8 12, label %bb1
+ i8 13, label %bb1
+ i8 40, label %bb1
+ i8 41, label %bb1
+ i8 52, label %bb1
+ i8 53, label %bb1
+ i8 55, label %bb15
+ i8 15, label %bb14
+ i8 29, label %bb9
+ i8 37, label %bb8
+ i8 69, label %bb3
+ i8 89, label %bb7
+ i8 85, label %bb6
+ i8 81, label %bb5
+ i8 65, label %bb2
+ i8 73, label %bb4
+ ]
+}
More information about the llvm-commits
mailing list