Skip to content

[llvm] Remove br i1 undef from regression tests #116161

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Nov 15, 2024

Conversation

leewei05
Copy link
Contributor

This PR removes tests with br i1 undef under llvm/tests/Transforms/HotColdSplit and llvm/tests/Transforms/I*.

@nunoplopes @regehr

@leewei05 leewei05 requested a review from nunoplopes November 14, 2024 04:40
@llvmbot llvmbot added llvm:instcombine Covers the InstCombine, InstSimplify and AggressiveInstCombine passes llvm:transforms labels Nov 14, 2024
@llvmbot
Copy link
Member

llvmbot commented Nov 14, 2024

@llvm/pr-subscribers-llvm-transforms

Author: Lee Wei (leewei05)

Changes

This PR removes tests with br i1 undef under llvm/tests/Transforms/HotColdSplit and llvm/tests/Transforms/I*.

@nunoplopes @regehr


Patch is 106.30 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/116161.diff

61 Files Affected:

  • (modified) llvm/test/Transforms/HotColdSplit/X86/do-not-split.ll (+22-22)
  • (modified) llvm/test/Transforms/HotColdSplit/addr-taken.ll (+2-2)
  • (modified) llvm/test/Transforms/HotColdSplit/apply-noreturn-bonus.ll (+3-3)
  • (modified) llvm/test/Transforms/HotColdSplit/apply-penalty-for-inputs.ll (+4-4)
  • (modified) llvm/test/Transforms/HotColdSplit/apply-penalty-for-outputs.ll (+2-2)
  • (modified) llvm/test/Transforms/HotColdSplit/eh-typeid-for.ll (+2-2)
  • (modified) llvm/test/Transforms/HotColdSplit/forward-dfs-reaches-marked-block.ll (+3-3)
  • (modified) llvm/test/Transforms/HotColdSplit/lifetime-markers-on-inputs-2.ll (+17-17)
  • (modified) llvm/test/Transforms/HotColdSplit/lifetime-markers-on-inputs-3.ll (+2-2)
  • (modified) llvm/test/Transforms/HotColdSplit/minsize.ll (+2-2)
  • (modified) llvm/test/Transforms/HotColdSplit/outline-cold-asm.ll (+2-2)
  • (modified) llvm/test/Transforms/HotColdSplit/outline-disjoint-diamonds.ll (+5-5)
  • (modified) llvm/test/Transforms/HotColdSplit/phi-with-distinct-outlined-values.ll (+2-2)
  • (modified) llvm/test/Transforms/HotColdSplit/section-splitting-custom.ll (+3-3)
  • (modified) llvm/test/Transforms/HotColdSplit/section-splitting-default.ll (+3-3)
  • (modified) llvm/test/Transforms/HotColdSplit/split-cold-2.ll (+3-3)
  • (modified) llvm/test/Transforms/HotColdSplit/succ-block-with-self-edge.ll (+8-8)
  • (modified) llvm/test/Transforms/HotColdSplit/swifterror.ll (+4-4)
  • (modified) llvm/test/Transforms/IndVarSimplify/2003-12-10-RemoveInstrCrash.ll (+2-2)
  • (modified) llvm/test/Transforms/IndVarSimplify/2003-12-15-Crash.ll (+3-3)
  • (modified) llvm/test/Transforms/IndVarSimplify/2005-11-18-Crash.ll (+2-2)
  • (modified) llvm/test/Transforms/IndVarSimplify/2006-12-10-BitCast.ll (+2-2)
  • (modified) llvm/test/Transforms/IndVarSimplify/2009-05-24-useafterfree.ll (+3-3)
  • (modified) llvm/test/Transforms/IndVarSimplify/2011-09-10-widen-nsw.ll (+3-3)
  • (modified) llvm/test/Transforms/IndVarSimplify/2011-09-19-vectoriv.ll (+2-2)
  • (modified) llvm/test/Transforms/IndVarSimplify/2011-10-27-lftrnull.ll (+15-12)
  • (modified) llvm/test/Transforms/IndVarSimplify/2014-06-21-congruent-constant.ll (+2-2)
  • (modified) llvm/test/Transforms/IndVarSimplify/2020-12-15-trunc-bug-expensive-range-inference.ll (+3-3)
  • (modified) llvm/test/Transforms/IndVarSimplify/AArch64/widen-loop-comp.ll (+3-3)
  • (modified) llvm/test/Transforms/IndVarSimplify/X86/2011-11-15-multiexit.ll (+3-3)
  • (modified) llvm/test/Transforms/IndVarSimplify/X86/eliminate-trunc.ll (+5-5)
  • (modified) llvm/test/Transforms/IndVarSimplify/X86/iv-widen.ll (+6-6)
  • (modified) llvm/test/Transforms/IndVarSimplify/X86/pr24804.ll (+3-3)
  • (modified) llvm/test/Transforms/IndVarSimplify/X86/pr24956.ll (+2-2)
  • (modified) llvm/test/Transforms/IndVarSimplify/X86/pr25576.ll (+2-2)
  • (modified) llvm/test/Transforms/IndVarSimplify/X86/variable-stride-ivs-1.ll (+4-4)
  • (modified) llvm/test/Transforms/IndVarSimplify/X86/verify-scev.ll (+83-83)
  • (modified) llvm/test/Transforms/IndVarSimplify/avoid-i0.ll (+3-3)
  • (modified) llvm/test/Transforms/IndVarSimplify/const_phi.ll (+2-2)
  • (modified) llvm/test/Transforms/IndVarSimplify/crash.ll (+5-5)
  • (modified) llvm/test/Transforms/IndVarSimplify/divide-pointer.ll (+8-8)
  • (modified) llvm/test/Transforms/IndVarSimplify/eliminate-comparison.ll (+10-4)
  • (modified) llvm/test/Transforms/IndVarSimplify/lcssa-preservation.ll (+3-5)
  • (modified) llvm/test/Transforms/IndVarSimplify/loop_evaluate11.ll (+2-2)
  • (modified) llvm/test/Transforms/IndVarSimplify/loop_evaluate7.ll (+7-7)
  • (modified) llvm/test/Transforms/IndVarSimplify/loop_evaluate8.ll (+7-7)
  • (modified) llvm/test/Transforms/IndVarSimplify/no-iv-rewrite.ll (+22-19)
  • (modified) llvm/test/Transforms/IndVarSimplify/phi-uses-value-multiple-times.ll (+3-3)
  • (modified) llvm/test/Transforms/IndVarSimplify/pr25578.ll (+6-6)
  • (modified) llvm/test/Transforms/IndVarSimplify/pr26974.ll (+5-5)
  • (modified) llvm/test/Transforms/IndVarSimplify/pr40454.ll (+11-7)
  • (modified) llvm/test/Transforms/IndVarSimplify/sentinel.ll (+12-7)
  • (modified) llvm/test/Transforms/IndVarSimplify/single-element-range.ll (+2-2)
  • (modified) llvm/test/Transforms/Inline/infinite-loop-two-predecessors.ll (+3-3)
  • (modified) llvm/test/Transforms/Inline/inline-indirect-chain.ll (+8-8)
  • (modified) llvm/test/Transforms/Inline/inline-invoke-with-asm-call.ll (+2-2)
  • (modified) llvm/test/Transforms/Inline/inline_cleanup.ll (+9-9)
  • (modified) llvm/test/Transforms/Inline/pr33637.ll (+2-2)
  • (modified) llvm/test/Transforms/Inline/pr53206.ll (+3-3)
  • (modified) llvm/test/Transforms/InstSimplify/dead-code-removal.ll (+3-3)
  • (modified) llvm/test/Transforms/InstSimplify/require-dominator.ll (+2-2)
diff --git a/llvm/test/Transforms/HotColdSplit/X86/do-not-split.ll b/llvm/test/Transforms/HotColdSplit/X86/do-not-split.ll
index d343351c57db8e..d7c87567108c90 100644
--- a/llvm/test/Transforms/HotColdSplit/X86/do-not-split.ll
+++ b/llvm/test/Transforms/HotColdSplit/X86/do-not-split.ll
@@ -9,9 +9,9 @@ target triple = "x86_64-apple-macosx10.14.0"
 ; The cold region is too small to split.
 ; CHECK-LABEL: @foo
 ; CHECK-NOT: foo.cold.1
-define void @foo() {
+define void @foo(i1 %arg) {
 entry:
-  br i1 undef, label %if.then, label %if.end
+  br i1 %arg, label %if.then, label %if.end
 
 if.then:                                          ; preds = %entry
   unreachable
@@ -23,9 +23,9 @@ if.end:                                           ; preds = %entry
 ; The cold region is still too small to split.
 ; CHECK-LABEL: @bar
 ; CHECK-NOT: bar.cold.1
-define void @bar() {
+define void @bar(i1 %arg) {
 entry:
-  br i1 undef, label %if.then, label %if.end
+  br i1 %arg, label %if.then, label %if.end
 
 if.then:                                          ; preds = %entry
   call void @sink()
@@ -38,9 +38,9 @@ if.end:                                           ; preds = %entry
 ; Make sure we don't try to outline the entire function.
 ; CHECK-LABEL: @fun
 ; CHECK-NOT: fun.cold.1
-define void @fun() {
+define void @fun(i1 %arg) {
 entry:
-  br i1 undef, label %if.then, label %if.end
+  br i1 %arg, label %if.then, label %if.end
 
 if.then:                                          ; preds = %entry
   call void @sink()
@@ -63,9 +63,9 @@ entry:
 ; Do not split `noinline` functions.
 ; CHECK-LABEL: @noinline_func
 ; CHECK-NOT: noinline_func.cold.1
-define void @noinline_func() noinline {
+define void @noinline_func(i1 %arg) noinline {
 entry:
-  br i1 undef, label %if.then, label %if.end
+  br i1 %arg, label %if.then, label %if.end
 
 if.then:                                          ; preds = %entry
   call void @sink()
@@ -78,9 +78,9 @@ if.end:                                           ; preds = %entry
 ; Do not split `alwaysinline` functions.
 ; CHECK-LABEL: @alwaysinline_func
 ; CHECK-NOT: alwaysinline_func.cold.1
-define void @alwaysinline_func() alwaysinline {
+define void @alwaysinline_func(i1 %arg) alwaysinline {
 entry:
-  br i1 undef, label %if.then, label %if.end
+  br i1 %arg, label %if.then, label %if.end
 
 if.then:                                          ; preds = %entry
   call void @sink()
@@ -105,10 +105,10 @@ loop:
 ; Don't count debug intrinsics towards the outlining threshold.
 ; CHECK-LABEL: @dont_count_debug_intrinsics
 ; CHECK-NOT: dont_count_debug_intrinsics.cold.1
-define void @dont_count_debug_intrinsics(i32 %arg1) !dbg !6 {
+define void @dont_count_debug_intrinsics(i32 %arg1, i1 %arg) !dbg !6 {
 entry:
   %var = add i32 0, 0, !dbg !11
-  br i1 undef, label %if.then, label %if.end
+  br i1 %arg, label %if.then, label %if.end
 
 if.then:                                          ; preds = %entry
   ret void
@@ -122,9 +122,9 @@ if.end:                                           ; preds = %entry
 
 ; CHECK-LABEL: @sanitize_address
 ; CHECK-NOT: sanitize_address.cold.1
-define void @sanitize_address() sanitize_address {
+define void @sanitize_address(i1 %arg) sanitize_address {
 entry:
-  br i1 undef, label %if.then, label %if.end
+  br i1 %arg, label %if.then, label %if.end
 
 if.then:                                          ; preds = %entry
   call void @sink()
@@ -136,9 +136,9 @@ if.end:                                           ; preds = %entry
 
 ; CHECK-LABEL: @sanitize_hwaddress
 ; CHECK-NOT: sanitize_hwaddress.cold.1
-define void @sanitize_hwaddress() sanitize_hwaddress {
+define void @sanitize_hwaddress(i1 %arg) sanitize_hwaddress {
 entry:
-  br i1 undef, label %if.then, label %if.end
+  br i1 %arg, label %if.then, label %if.end
 
 if.then:                                          ; preds = %entry
   call void @sink()
@@ -150,9 +150,9 @@ if.end:                                           ; preds = %entry
 
 ; CHECK-LABEL: @sanitize_thread
 ; CHECK-NOT: sanitize_thread.cold.1
-define void @sanitize_thread() sanitize_thread {
+define void @sanitize_thread(i1 %arg) sanitize_thread {
 entry:
-  br i1 undef, label %if.then, label %if.end
+  br i1 %arg, label %if.then, label %if.end
 
 if.then:                                          ; preds = %entry
   call void @sink()
@@ -164,9 +164,9 @@ if.end:                                           ; preds = %entry
 
 ; CHECK-LABEL: @sanitize_memory
 ; CHECK-NOT: sanitize_memory.cold.1
-define void @sanitize_memory() sanitize_memory {
+define void @sanitize_memory(i1 %arg) sanitize_memory {
 entry:
-  br i1 undef, label %if.then, label %if.end
+  br i1 %arg, label %if.then, label %if.end
 
 if.then:                                          ; preds = %entry
   call void @sink()
@@ -180,9 +180,9 @@ declare void @llvm.trap() cold noreturn
 
 ; CHECK-LABEL: @nosanitize_call
 ; CHECK-NOT: nosanitize_call.cold.1
-define void @nosanitize_call() sanitize_memory {
+define void @nosanitize_call(i1 %arg) sanitize_memory {
 entry:
-  br i1 undef, label %if.then, label %if.end
+  br i1 %arg, label %if.then, label %if.end
 
 if.then:                                          ; preds = %entry
   call void @llvm.trap(), !nosanitize !2
diff --git a/llvm/test/Transforms/HotColdSplit/addr-taken.ll b/llvm/test/Transforms/HotColdSplit/addr-taken.ll
index 5a33af55e7b4a4..f2fe953ff719de 100644
--- a/llvm/test/Transforms/HotColdSplit/addr-taken.ll
+++ b/llvm/test/Transforms/HotColdSplit/addr-taken.ll
@@ -9,8 +9,8 @@ define void @foo() noreturn cold {
 }
 
 ; CHECK: define {{.*}} @bar.cold.1{{.*}}#[[outlined_func_attr]]
-define void @bar() {
-  br i1 undef, label %normal, label %exit
+define void @bar(i1 %arg) {
+  br i1 %arg, label %normal, label %exit
 
 normal:
   unreachable
diff --git a/llvm/test/Transforms/HotColdSplit/apply-noreturn-bonus.ll b/llvm/test/Transforms/HotColdSplit/apply-noreturn-bonus.ll
index b9666deae118a0..cefccd71d8a216 100644
--- a/llvm/test/Transforms/HotColdSplit/apply-noreturn-bonus.ll
+++ b/llvm/test/Transforms/HotColdSplit/apply-noreturn-bonus.ll
@@ -3,14 +3,14 @@
 
 declare void @sink() cold
 
-define void @foo(i32 %arg) {
+define void @foo(i32 %arg, i1 %arg2) {
 entry:
-  br i1 undef, label %cold1, label %exit
+  br i1 %arg2, label %cold1, label %exit
 
 cold1:
   ; CHECK: Applying bonus for: 4 non-returning terminators
   call void @sink()
-  br i1 undef, label %cold2, label %cold3
+  br i1 %arg2, label %cold2, label %cold3
 
 cold2:
   br label %cold4
diff --git a/llvm/test/Transforms/HotColdSplit/apply-penalty-for-inputs.ll b/llvm/test/Transforms/HotColdSplit/apply-penalty-for-inputs.ll
index 34b74d17398203..48f965440882d2 100644
--- a/llvm/test/Transforms/HotColdSplit/apply-penalty-for-inputs.ll
+++ b/llvm/test/Transforms/HotColdSplit/apply-penalty-for-inputs.ll
@@ -5,9 +5,9 @@ declare void @sink(ptr, i32, i32) cold
 
 @g = global i32 0
 
-define void @foo(i32 %arg) {
+define void @foo(i32 %arg, i1 %arg2) {
   %local = load i32, ptr @g
-  br i1 undef, label %cold, label %exit
+  br i1 %arg2, label %cold, label %exit
 
 cold:
   ; CHECK: Applying penalty for splitting: 2
@@ -21,8 +21,8 @@ exit:
   ret void
 }
 
-define void @bar(ptr %p1, i32 %p2, i32 %p3) {
-  br i1 undef, label %cold, label %exit
+define void @bar(ptr %p1, i32 %p2, i32 %p3, i1 %arg) {
+  br i1 %arg, label %cold, label %exit
 
 cold:
   ; CHECK: Applying penalty for splitting: 2
diff --git a/llvm/test/Transforms/HotColdSplit/apply-penalty-for-outputs.ll b/llvm/test/Transforms/HotColdSplit/apply-penalty-for-outputs.ll
index 9575cbff3a6195..96d73088e7874c 100644
--- a/llvm/test/Transforms/HotColdSplit/apply-penalty-for-outputs.ll
+++ b/llvm/test/Transforms/HotColdSplit/apply-penalty-for-outputs.ll
@@ -5,9 +5,9 @@ declare void @sink() cold
 
 @g = global i32 0
 
-define i32 @foo(i32 %arg) {
+define i32 @foo(i32 %arg, i1 %arg2) {
 entry:
-  br i1 undef, label %cold, label %exit
+  br i1 %arg2, label %cold, label %exit
 
 cold:
   ; CHECK: Applying penalty for splitting: 2
diff --git a/llvm/test/Transforms/HotColdSplit/eh-typeid-for.ll b/llvm/test/Transforms/HotColdSplit/eh-typeid-for.ll
index a2ed286f36434b..e5f06c552ca83f 100644
--- a/llvm/test/Transforms/HotColdSplit/eh-typeid-for.ll
+++ b/llvm/test/Transforms/HotColdSplit/eh-typeid-for.ll
@@ -6,9 +6,9 @@
 
 ; CHECK-LABEL: @fun
 ; CHECK-NOT: call {{.*}}@fun.cold.1
-define void @fun() {
+define void @fun(i1 %arg) {
 entry:
-  br i1 undef, label %if.then, label %if.else
+  br i1 %arg, label %if.then, label %if.else
 
 if.then:
   ret void
diff --git a/llvm/test/Transforms/HotColdSplit/forward-dfs-reaches-marked-block.ll b/llvm/test/Transforms/HotColdSplit/forward-dfs-reaches-marked-block.ll
index 57aea5d1b3ec4a..013957f0a64da7 100644
--- a/llvm/test/Transforms/HotColdSplit/forward-dfs-reaches-marked-block.ll
+++ b/llvm/test/Transforms/HotColdSplit/forward-dfs-reaches-marked-block.ll
@@ -5,9 +5,9 @@ target triple = "x86_64-apple-macosx10.14.0"
 
 ; CHECK-LABEL: define {{.*}}@fun
 ; CHECK: call {{.*}}@fun.cold.1(
-define void @fun() {
+define void @fun(i1 %arg) {
 entry:
-  br i1 undef, label %if.then, label %if.else
+  br i1 %arg, label %if.then, label %if.else
 
 if.then:
   ; This will be marked by the inverse DFS on sink-predecesors.
@@ -17,7 +17,7 @@ sink:
   call void @sink()
 
   ; Do not allow the forward-DFS on sink-successors to mark the block again.
-  br i1 undef, label %if.then, label %if.then.exit
+  br i1 %arg, label %if.then, label %if.then.exit
 
 if.then.exit:
   ret void
diff --git a/llvm/test/Transforms/HotColdSplit/lifetime-markers-on-inputs-2.ll b/llvm/test/Transforms/HotColdSplit/lifetime-markers-on-inputs-2.ll
index 8d99c80546ad9e..e42db78c195bcb 100644
--- a/llvm/test/Transforms/HotColdSplit/lifetime-markers-on-inputs-2.ll
+++ b/llvm/test/Transforms/HotColdSplit/lifetime-markers-on-inputs-2.ll
@@ -34,14 +34,14 @@ declare void @use(ptr)
 ;          \      /
 ;            exit
 ;          (lt.end)
-define void @only_lifetime_start_is_cold() {
+define void @only_lifetime_start_is_cold(i1 %arg) {
 ; CHECK-LABEL: @only_lifetime_start_is_cold(
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    [[LOCAL1:%.*]] = alloca i256
-; CHECK-NEXT:    br i1 undef, label [[CODEREPL:%.*]], label [[NO_EXTRACT1:%.*]]
+; CHECK-NEXT:    [[LOCAL1:%.*]] = alloca i256, align 8
+; CHECK-NEXT:    br i1 [[ARG:%.*]], label [[CODEREPL:%.*]], label [[NO_EXTRACT1:%.*]]
 ; CHECK:       codeRepl:
 ; CHECK-NEXT:    call void @llvm.lifetime.start.p0(i64 -1, ptr [[LOCAL1]])
-; CHECK-NEXT:    [[TARGETBLOCK:%.*]] = call i1 @only_lifetime_start_is_cold.cold.1(ptr [[LOCAL1]]) #3
+; CHECK-NEXT:    [[TARGETBLOCK:%.*]] = call i1 @only_lifetime_start_is_cold.cold.1(ptr [[LOCAL1]], i1 [[ARG]]) #[[ATTR3:[0-9]+]]
 ; CHECK-NEXT:    br i1 [[TARGETBLOCK]], label [[NO_EXTRACT1]], label [[EXIT:%.*]]
 ; CHECK:       no-extract1:
 ; CHECK-NEXT:    br label [[EXIT]]
@@ -51,13 +51,13 @@ define void @only_lifetime_start_is_cold() {
 ;
 entry:
   %local1 = alloca i256
-  br i1 undef, label %extract1, label %no-extract1
+  br i1 %arg, label %extract1, label %no-extract1
 
 extract1:
   ; lt.start
   call void @llvm.lifetime.start.p0(i64 1, ptr %local1)
   call void @cold_use(ptr %local1)
-  br i1 undef, label %extract2, label %no-extract1
+  br i1 %arg, label %extract2, label %no-extract1
 
 extract2:
   br label %exit
@@ -92,17 +92,17 @@ exit:
 ;    (lt.end)
 ;        \         /
 ;            exit
-define void @only_lifetime_end_is_cold() {
+define void @only_lifetime_end_is_cold(i1 %arg) {
 ; CHECK-LABEL: @only_lifetime_end_is_cold(
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    [[LOCAL1:%.*]] = alloca i256
+; CHECK-NEXT:    [[LOCAL1:%.*]] = alloca i256, align 8
 ; CHECK-NEXT:    call void @llvm.lifetime.start.p0(i64 1, ptr [[LOCAL1]])
-; CHECK-NEXT:    br i1 undef, label [[NO_EXTRACT1:%.*]], label [[CODEREPL:%.*]]
+; CHECK-NEXT:    br i1 [[ARG:%.*]], label [[NO_EXTRACT1:%.*]], label [[CODEREPL:%.*]]
 ; CHECK:       no-extract1:
 ; CHECK-NEXT:    call void @llvm.lifetime.end.p0(i64 1, ptr [[LOCAL1]])
 ; CHECK-NEXT:    br label [[EXIT:%.*]]
 ; CHECK:       codeRepl:
-; CHECK-NEXT:    call void @only_lifetime_end_is_cold.cold.1(ptr [[LOCAL1]]) #3
+; CHECK-NEXT:    call void @only_lifetime_end_is_cold.cold.1(ptr [[LOCAL1]]) #[[ATTR3]]
 ; CHECK-NEXT:    br label [[EXIT]]
 ; CHECK:       exit:
 ; CHECK-NEXT:    ret void
@@ -111,7 +111,7 @@ entry:
   ; lt.start
   %local1 = alloca i256
   call void @llvm.lifetime.start.p0(i64 1, ptr %local1)
-  br i1 undef, label %no-extract1, label %extract1
+  br i1 %arg, label %no-extract1, label %extract1
 
 no-extract1:
   ; lt.end
@@ -130,17 +130,17 @@ exit:
 
 ; In this CFG, splitting will extract the blocks extract{1,2,3}. Lifting the
 ; lifetime.end marker would be a miscompile.
-define void @do_not_lift_lifetime_end() {
+define void @do_not_lift_lifetime_end(i1 %arg) {
 ; CHECK-LABEL: @do_not_lift_lifetime_end(
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    [[LOCAL1:%.*]] = alloca i256
+; CHECK-NEXT:    [[LOCAL1:%.*]] = alloca i256, align 8
 ; CHECK-NEXT:    call void @llvm.lifetime.start.p0(i64 1, ptr [[LOCAL1]])
 ; CHECK-NEXT:    br label [[HEADER:%.*]]
 ; CHECK:       header:
 ; CHECK-NEXT:    call void @use(ptr [[LOCAL1]])
-; CHECK-NEXT:    br i1 undef, label [[EXIT:%.*]], label [[CODEREPL:%.*]]
+; CHECK-NEXT:    br i1 [[ARG:%.*]], label [[EXIT:%.*]], label [[CODEREPL:%.*]]
 ; CHECK:       codeRepl:
-; CHECK-NEXT:    [[TARGETBLOCK:%.*]] = call i1 @do_not_lift_lifetime_end.cold.1(ptr [[LOCAL1]]) #3
+; CHECK-NEXT:    [[TARGETBLOCK:%.*]] = call i1 @do_not_lift_lifetime_end.cold.1(ptr [[LOCAL1]], i1 [[ARG]]) #[[ATTR3]]
 ; CHECK-NEXT:    br i1 [[TARGETBLOCK]], label [[HEADER]], label [[EXIT]]
 ; CHECK:       exit:
 ; CHECK-NEXT:    ret void
@@ -155,11 +155,11 @@ header:
   ; If the lifetime.end marker is lifted, this use becomes dead the second time
   ; the header block is executed.
   call void @use(ptr %local1)
-  br i1 undef, label %exit, label %extract1
+  br i1 %arg, label %exit, label %extract1
 
 extract1:
   call void @cold_use(ptr %local1)
-  br i1 undef, label %extract2, label %extract3
+  br i1 %arg, label %extract2, label %extract3
 
 extract2:
   ; Backedge.
diff --git a/llvm/test/Transforms/HotColdSplit/lifetime-markers-on-inputs-3.ll b/llvm/test/Transforms/HotColdSplit/lifetime-markers-on-inputs-3.ll
index 51ee47a7d2eda2..26faaa326141fc 100644
--- a/llvm/test/Transforms/HotColdSplit/lifetime-markers-on-inputs-3.ll
+++ b/llvm/test/Transforms/HotColdSplit/lifetime-markers-on-inputs-3.ll
@@ -12,11 +12,11 @@ declare void @use(ptr, ptr)
 declare void @use2(ptr, ptr) cold
 
 ; CHECK-LABEL: define {{.*}}@foo(
-define void @foo() {
+define void @foo(i1 %arg) {
 entry:
   %local1 = alloca ptr
   %local2 = alloca ptr
-  br i1 undef, label %normalPath, label %outlinedPath
+  br i1 %arg, label %normalPath, label %outlinedPath
 
 normalPath:
   call void @use(ptr %local1, ptr %local2)
diff --git a/llvm/test/Transforms/HotColdSplit/minsize.ll b/llvm/test/Transforms/HotColdSplit/minsize.ll
index 7ac666672d4b5f..e3d394cfd916f5 100644
--- a/llvm/test/Transforms/HotColdSplit/minsize.ll
+++ b/llvm/test/Transforms/HotColdSplit/minsize.ll
@@ -5,9 +5,9 @@ target triple = "x86_64-apple-macosx10.14.0"
 
 ; CHECK-LABEL: @fun
 ; CHECK: call void @fun.cold.1
-define void @fun() {
+define void @fun(i1 %arg) {
 entry:
-  br i1 undef, label %if.then, label %if.else
+  br i1 %arg, label %if.then, label %if.else
 
 if.then:
   ret void
diff --git a/llvm/test/Transforms/HotColdSplit/outline-cold-asm.ll b/llvm/test/Transforms/HotColdSplit/outline-cold-asm.ll
index 6a88fc13f0f204..7f2433501a69e2 100644
--- a/llvm/test/Transforms/HotColdSplit/outline-cold-asm.ll
+++ b/llvm/test/Transforms/HotColdSplit/outline-cold-asm.ll
@@ -9,9 +9,9 @@ target triple = "x86_64-apple-macosx10.14.0"
 ; CHECK-LABEL: define {{.*}}@fun.cold.1(
 ; CHECK: asm ""
 
-define void @fun() {
+define void @fun(i1 %arg) {
 entry:
-  br i1 undef, label %if.then, label %if.else
+  br i1 %arg, label %if.then, label %if.else
 
 if.then:
   ret void
diff --git a/llvm/test/Transforms/HotColdSplit/outline-disjoint-diamonds.ll b/llvm/test/Transforms/HotColdSplit/outline-disjoint-diamonds.ll
index 55013aa96551d0..f69ba111d0e96d 100644
--- a/llvm/test/Transforms/HotColdSplit/outline-disjoint-diamonds.ll
+++ b/llvm/test/Transforms/HotColdSplit/outline-disjoint-diamonds.ll
@@ -5,15 +5,15 @@
 ; CHECK-NEXT: unreachable
 ; CHECK: call {{.*}}@fun.cold.2(
 ; CHECK-NEXT: unreachable
-define void @fun() {
+define void @fun(i1 %arg) {
 entry:
-  br i1 undef, label %A.then, label %A.else
+  br i1 %arg, label %A.then, label %A.else
 
 A.else:
   br label %A.then4
 
 A.then4:
-  br i1 undef, label %A.then5, label %A.end
+  br i1 %arg, label %A.then5, label %A.end
 
 A.then5:
   br label %A.cleanup
@@ -26,7 +26,7 @@ A.cleanup:
   unreachable
 
 A.then:
-  br i1 undef, label %B.then, label %B.else
+  br i1 %arg, label %B.then, label %B.else
 
 B.then:
   ret void
@@ -35,7 +35,7 @@ B.else:
   br label %B.then4
 
 B.then4:
-  br i1 undef, label %B.then5, label %B.end
+  br i1 %arg, label %B.then5, label %B.end
 
 B.then5:
   br label %B.cleanup
diff --git a/llvm/test/Transforms/HotColdSplit/phi-with-distinct-outlined-values.ll b/llvm/test/Transforms/HotColdSplit/phi-with-distinct-outlined-values.ll
index 81e34bbfadb111..7c07cd35a527c2 100644
--- a/llvm/test/Transforms/HotColdSplit/phi-with-distinct-outlined-values.ll
+++ b/llvm/test/Transforms/HotColdSplit/phi-with-distinct-outlined-values.ll
@@ -11,7 +11,7 @@ target triple = "x86_64-apple-macosx10.14.0"
 ; CHECK: %p.ce = phi i32 [ 1, %coldbb ], [ 3, %coldbb2 ]
 ; CHECK-NEXT: store i32 %p.ce, ptr %p.ce.out
 
-define void @foo(i32 %cond) {
+define void @foo(i32 %cond, i1 %arg) {
 entry:
   %tobool = icmp eq i32 %cond, 0
   br i1 %tobool, label %if.end, label %coldbb
@@ -19,7 +19,7 @@ entry:
 coldbb:
   call void @sink()
   call void @sideeffect()
-  br i1 undef, label %if.end, label %coldbb2
+  br i1 %arg, label %if.end, label %coldbb2
 
 coldbb2:
   br label %if.end
diff --git a/llvm/test/Transforms/HotColdSplit/section-splitting-custom.ll b/llvm/test/Transforms/HotColdSplit/section-splitting-custom.ll
index d7836d0994b866..c794d40b28ec3c 100644
--- a/llvm/test/Transforms/HotColdSplit/section-splitting-custom.ll
+++ b/llvm/test/Transforms/HotColdSplit/section-splitting-custom.ll
@@ -14,9 +14,9 @@
 ; CHECK: define {{.*}}@fun.cold.1{{.*}} [[cold_attr:#[0-9]+]] section "__cold_custom"
 ; CHECK: attributes [[cold_attr]] = { {{.*}}noreturn
 
-define void @fun() {
+define void @fun(i1 %arg) {
 entry:
-  br i1 undef, label %if.then, label %if.else
+  br i1 %arg, label %if.then, label %if.else
 
 if.then:
   ret void
@@ -25,7 +25,7 @@ if.else:
   br label %if.then4
 
 if.then4:
-  br i1 undef, label %if.then5, label %if.end
+  br i1 %arg, label %if.then5, label %if.end
 
 if.then5:
   br label %cleanup
diff --git a/llvm/test/Transforms/HotColdSplit/section-splitting-default.ll b/llvm/test/Transforms/HotColdSplit/section-splitting-default.ll
index 2cdccce93d8d79..87c7b7034f0474 100644
--- a/llvm/test/Transforms/HotColdSplit/section-splitting-default.ll
+++ b/llvm/test/Transforms/HotColdSplit/section-splitting-default.ll
@@ -13,9 +13,9 @@
 ; CHECK: define {{.*}}@fun.cold.1{{.*}} [[cold_attr:#[0-9]+]] section "__llvm_cold"
 ; CHECK: attributes [[cold_attr]] = { {{.*}}noreturn
 
-define void @fun() {
+define void @fun(i1 %arg) {
 entry:
-  br i1 undef, label %if.then, label %if.else
+  br i1 %arg, label %if.then, label %if.else
 
 if.then:
   ret void
@@ -24,7 +24,7 @@ if.else:
   br label %if.then4
 
 if.then4:
-  br i1 undef, label %if.then5, label %if.end
+  br i1 %arg, label %if.then5, label %if.end
 
 if.then5:
   br label %cleanup
diff --git a/llvm/test/Transforms/HotColdSplit/split-cold-2.ll b/llvm/test/Transforms/HotColdSplit/split-cold-2.ll
index 44dfd6b668a3d8..603447a89b1de0 100644
--- a/llvm/test/Transforms/HotColdSplit/split-cold-2.ll
+++ b/llvm/test/Transforms/HotColdSplit/split-cold-2.ll
@@ -11,9 +11,9 @@
 ; CHECK: define internal {{.*}}@fun.cold.1{{.*}} [[cold_attr:#[0-9]+]]
 ; CHECK: attributes [[cold_attr]] = { {{.*}}noreturn
 
-define void @fun() {
+define void @fun(i1 %arg) {
 entry:
-  br i1 undef, label %if.then, label %if.else
+  br i1 %arg, label %if.then, label %if.else
 
 if.then:
   ret void
@@ -22,7 +22,7 @@ if.else:
   br label %if.then4
 
 if.then4:
-  br i1 undef, label %if.then5, label %if.end
+  br i1 %arg, label %if.then5, label %if.end
 
 if.the...
[truncated]


if.then165: ; preds = %while.body
br i1 undef, label %while.cond, label %for.body.lr.ph.i81
br i1 %arg, label %while.cond, label %for.body.lr.ph.i81
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the icmp undef below makes the br UB

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nunoplopes A question here, for this case https://alive2.llvm.org/ce/z/RvwJpB

  1. Does infinite loop be seen as Undefined Behavior for Alive2? I remembered John told me that Alive2 unrolls loops twice and after that Alive2 just gives up.

There are two icmp undef cases here. The first one was icmp ult i32 0, undef, so I replaced it with false. The second one was icmp ult i32 %inc.i125, undef, so I replaced it with %arg.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

infinite loops are only UB if the function is marked as terminating (the mostprogress attribute).
By default, Alive2 only unrolls once. It can be changed with a flag.

All that said, it would be be best to have loops that are not infinite.

@nunoplopes nunoplopes merged commit 8ee638f into llvm:main Nov 15, 2024
8 checks passed
@leewei05 leewei05 deleted the remove-br-undef-transforms-4 branch November 15, 2024 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
llvm:instcombine Covers the InstCombine, InstSimplify and AggressiveInstCombine passes llvm:transforms
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants