[llvm] 976926e - [Test] Clear out br i1 undef from tests to avoid UB
Max Kazantsev via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 22 21:40:46 PDT 2021
Author: Max Kazantsev
Date: 2021-06-23T11:33:57+07:00
New Revision: 976926e8ee3e3c9f7c391281eab89e0d1b02092a
URL: https://github.com/llvm/llvm-project/commit/976926e8ee3e3c9f7c391281eab89e0d1b02092a
DIFF: https://github.com/llvm/llvm-project/commit/976926e8ee3e3c9f7c391281eab89e0d1b02092a.diff
LOG: [Test] Clear out br i1 undef from tests to avoid UB
We don't want to test possible unexpected impact of such
branches. Replacing them with regular conditions. Idea by
Nikita Popov.
Added:
Modified:
llvm/test/Transforms/LoopDeletion/eval_first_iteration.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/LoopDeletion/eval_first_iteration.ll b/llvm/test/Transforms/LoopDeletion/eval_first_iteration.ll
index 15ebd7db7624..be13d0277a95 100644
--- a/llvm/test/Transforms/LoopDeletion/eval_first_iteration.ll
+++ b/llvm/test/Transforms/LoopDeletion/eval_first_iteration.ll
@@ -655,7 +655,7 @@ failure:
unreachable
}
-define i32 @test_multiple_pred_2() {
+define i32 @test_multiple_pred_2(i1 %cond, i1 %cond2) {
; CHECK-LABEL: @test_multiple_pred_2(
; CHECK-NEXT: entry:
; CHECK-NEXT: br label [[LOOP:%.*]]
@@ -665,13 +665,13 @@ define i32 @test_multiple_pred_2() {
; CHECK-NEXT: [[IS_POSITIVE:%.*]] = icmp sgt i32 [[SUB]], 0
; CHECK-NEXT: br i1 [[IS_POSITIVE]], label [[IF_TRUE:%.*]], label [[IF_FALSE:%.*]]
; CHECK: if.true:
-; CHECK-NEXT: br i1 undef, label [[IF_TRUE_1:%.*]], label [[IF_TRUE_2:%.*]]
+; CHECK-NEXT: br i1 [[COND:%.*]], label [[IF_TRUE_1:%.*]], label [[IF_TRUE_2:%.*]]
; CHECK: if.true.1:
; CHECK-NEXT: br label [[BACKEDGE:%.*]]
; CHECK: if.true.2:
; CHECK-NEXT: br label [[BACKEDGE]]
; CHECK: if.false:
-; CHECK-NEXT: br i1 undef, label [[IF_FALSE_1:%.*]], label [[IF_FALSE_2:%.*]]
+; CHECK-NEXT: br i1 [[COND2:%.*]], label [[IF_FALSE_1:%.*]], label [[IF_FALSE_2:%.*]]
; CHECK: if.false.1:
; CHECK-NEXT: br label [[BACKEDGE]]
; CHECK: if.false.2:
@@ -700,7 +700,7 @@ loop: ; preds = %backedge, %entry
br i1 %is.positive, label %if.true, label %if.false
if.true:
- br i1 undef, label %if.true.1, label %if.true.2
+ br i1 %cond, label %if.true.1, label %if.true.2
if.true.1:
br label %backedge
@@ -709,7 +709,7 @@ if.true.2:
br label %backedge
if.false: ; preds = %loop
- br i1 undef, label %if.false.1, label %if.false.2
+ br i1 %cond2, label %if.false.1, label %if.false.2
if.false.1:
br label %backedge
@@ -732,7 +732,7 @@ failure:
}
; TODO: We can break the backedge here by assuming that undef = sub.
-define i32 @test_multiple_pred_undef_1() {
+define i32 @test_multiple_pred_undef_1(i1 %cond, i1 %cond2) {
; CHECK-LABEL: @test_multiple_pred_undef_1(
; CHECK-NEXT: entry:
; CHECK-NEXT: br label [[LOOP:%.*]]
@@ -742,13 +742,13 @@ define i32 @test_multiple_pred_undef_1() {
; CHECK-NEXT: [[IS_POSITIVE:%.*]] = icmp sgt i32 [[SUB]], 0
; CHECK-NEXT: br i1 [[IS_POSITIVE]], label [[IF_TRUE:%.*]], label [[IF_FALSE:%.*]]
; CHECK: if.true:
-; CHECK-NEXT: br i1 undef, label [[IF_TRUE_1:%.*]], label [[IF_TRUE_2:%.*]]
+; CHECK-NEXT: br i1 [[COND:%.*]], label [[IF_TRUE_1:%.*]], label [[IF_TRUE_2:%.*]]
; CHECK: if.true.1:
; CHECK-NEXT: br label [[BACKEDGE]]
; CHECK: if.true.2:
; CHECK-NEXT: br label [[BACKEDGE]]
; CHECK: if.false:
-; CHECK-NEXT: br i1 undef, label [[IF_FALSE_1:%.*]], label [[IF_FALSE_2:%.*]]
+; CHECK-NEXT: br i1 [[COND2:%.*]], label [[IF_FALSE_1:%.*]], label [[IF_FALSE_2:%.*]]
; CHECK: if.false.1:
; CHECK-NEXT: br label [[BACKEDGE]]
; CHECK: if.false.2:
@@ -774,7 +774,7 @@ loop: ; preds = %backedge, %entry
br i1 %is.positive, label %if.true, label %if.false
if.true:
- br i1 undef, label %if.true.1, label %if.true.2
+ br i1 %cond, label %if.true.1, label %if.true.2
if.true.1:
br label %backedge
@@ -783,7 +783,7 @@ if.true.2:
br label %backedge
if.false: ; preds = %loop
- br i1 undef, label %if.false.1, label %if.false.2
+ br i1 %cond2, label %if.false.1, label %if.false.2
if.false.1:
br label %backedge
@@ -806,7 +806,7 @@ failure:
}
; TODO: We can break the backedge here by assuming that undef = sub.
-define i32 @test_multiple_pred_undef_2() {
+define i32 @test_multiple_pred_undef_2(i1 %cond, i1 %cond2) {
; CHECK-LABEL: @test_multiple_pred_undef_2(
; CHECK-NEXT: entry:
; CHECK-NEXT: br label [[LOOP:%.*]]
@@ -816,13 +816,13 @@ define i32 @test_multiple_pred_undef_2() {
; CHECK-NEXT: [[IS_POSITIVE:%.*]] = icmp sgt i32 [[SUB]], 0
; CHECK-NEXT: br i1 [[IS_POSITIVE]], label [[IF_TRUE:%.*]], label [[IF_FALSE:%.*]]
; CHECK: if.true:
-; CHECK-NEXT: br i1 undef, label [[IF_TRUE_1:%.*]], label [[IF_TRUE_2:%.*]]
+; CHECK-NEXT: br i1 [[COND:%.*]], label [[IF_TRUE_1:%.*]], label [[IF_TRUE_2:%.*]]
; CHECK: if.true.1:
; CHECK-NEXT: br label [[BACKEDGE]]
; CHECK: if.true.2:
; CHECK-NEXT: br label [[BACKEDGE]]
; CHECK: if.false:
-; CHECK-NEXT: br i1 undef, label [[IF_FALSE_1:%.*]], label [[IF_FALSE_2:%.*]]
+; CHECK-NEXT: br i1 [[COND2:%.*]], label [[IF_FALSE_1:%.*]], label [[IF_FALSE_2:%.*]]
; CHECK: if.false.1:
; CHECK-NEXT: br label [[BACKEDGE]]
; CHECK: if.false.2:
@@ -848,7 +848,7 @@ loop: ; preds = %backedge, %entry
br i1 %is.positive, label %if.true, label %if.false
if.true:
- br i1 undef, label %if.true.1, label %if.true.2
+ br i1 %cond, label %if.true.1, label %if.true.2
if.true.1:
br label %backedge
@@ -857,7 +857,7 @@ if.true.2:
br label %backedge
if.false: ; preds = %loop
- br i1 undef, label %if.false.1, label %if.false.2
+ br i1 %cond2, label %if.false.1, label %if.false.2
if.false.1:
br label %backedge
@@ -880,7 +880,7 @@ failure:
}
; TODO: We can break the backedge here by exploiting undef.
-define i32 @test_multiple_pred_undef_3() {
+define i32 @test_multiple_pred_undef_3(i1 %cond, i1 %cond2) {
; CHECK-LABEL: @test_multiple_pred_undef_3(
; CHECK-NEXT: entry:
; CHECK-NEXT: br label [[LOOP:%.*]]
@@ -890,13 +890,13 @@ define i32 @test_multiple_pred_undef_3() {
; CHECK-NEXT: [[IS_POSITIVE:%.*]] = icmp sgt i32 [[SUB]], 0
; CHECK-NEXT: br i1 [[IS_POSITIVE]], label [[IF_TRUE:%.*]], label [[IF_FALSE:%.*]]
; CHECK: if.true:
-; CHECK-NEXT: br i1 undef, label [[IF_TRUE_1:%.*]], label [[IF_TRUE_2:%.*]]
+; CHECK-NEXT: br i1 [[COND:%.*]], label [[IF_TRUE_1:%.*]], label [[IF_TRUE_2:%.*]]
; CHECK: if.true.1:
; CHECK-NEXT: br label [[BACKEDGE]]
; CHECK: if.true.2:
; CHECK-NEXT: br label [[BACKEDGE]]
; CHECK: if.false:
-; CHECK-NEXT: br i1 undef, label [[IF_FALSE_1:%.*]], label [[IF_FALSE_2:%.*]]
+; CHECK-NEXT: br i1 [[COND2:%.*]], label [[IF_FALSE_1:%.*]], label [[IF_FALSE_2:%.*]]
; CHECK: if.false.1:
; CHECK-NEXT: br label [[BACKEDGE]]
; CHECK: if.false.2:
@@ -922,7 +922,7 @@ loop: ; preds = %backedge, %entry
br i1 %is.positive, label %if.true, label %if.false
if.true:
- br i1 undef, label %if.true.1, label %if.true.2
+ br i1 %cond, label %if.true.1, label %if.true.2
if.true.1:
br label %backedge
@@ -931,7 +931,7 @@ if.true.2:
br label %backedge
if.false: ; preds = %loop
- br i1 undef, label %if.false.1, label %if.false.2
+ br i1 %cond2, label %if.false.1, label %if.false.2
if.false.1:
br label %backedge
More information about the llvm-commits
mailing list