[llvm] [InstCombine] Make test resilient to metadata presence (PR #157607)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 12 08:00:01 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: Mircea Trofin (mtrofin)
<details>
<summary>Changes</summary>
Adding `!prof` annotations to `Transforms/InstCombine/2004-09-20-BadLoadCombine2.ll`, and removed `llvm-dis` in favor of using `-S`
The prof annotations don’t change the intent of the test, but make it resilient to the `profcheck` bot that would have otherwise introduced a branch_weights profile of `i32 1, i32 1`, which would have matched the grep.
Added a profile presence test, too.
---
Full diff: https://github.com/llvm/llvm-project/pull/157607.diff
2 Files Affected:
- (modified) llvm/test/Transforms/InstCombine/2004-09-20-BadLoadCombine2.ll (+8-4)
- (modified) llvm/utils/profcheck-xfail.txt (-1)
``````````diff
diff --git a/llvm/test/Transforms/InstCombine/2004-09-20-BadLoadCombine2.ll b/llvm/test/Transforms/InstCombine/2004-09-20-BadLoadCombine2.ll
index f558e35ebe015..0b4c852664c2f 100644
--- a/llvm/test/Transforms/InstCombine/2004-09-20-BadLoadCombine2.ll
+++ b/llvm/test/Transforms/InstCombine/2004-09-20-BadLoadCombine2.ll
@@ -1,16 +1,17 @@
-; RUN: opt < %s -passes=instcombine,mem2reg,simplifycfg -simplifycfg-require-and-preserve-domtree=1 | \
-; RUN: llvm-dis | grep -v store | not grep "i32 1"
+; RUN: opt %s -passes=instcombine,mem2reg,simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S \
+; RUN: | grep -v store | not grep "i32 1"
+; RUN: opt %s -passes=instcombine,mem2reg,simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S | FileCheck %s
; Test to make sure that instcombine does not accidentally propagate the load
; into the PHI, which would break the program.
-define i32 @test(i1 %C) {
+define i32 @test(i1 %C) !prof !0 {
entry:
%X = alloca i32 ; <ptr> [#uses=3]
%X2 = alloca i32 ; <ptr> [#uses=2]
store i32 1, ptr %X
store i32 2, ptr %X2
- br i1 %C, label %cond_true.i, label %cond_continue.i
+ br i1 %C, label %cond_true.i, label %cond_continue.i, !prof !1
cond_true.i: ; preds = %entry
br label %cond_continue.i
@@ -22,4 +23,7 @@ cond_continue.i: ; preds = %cond_true.i, %entry
ret i32 %tmp.3
}
+; CHECK: %spec.select = select i1 %C, ptr %X, ptr %X2, !prof !1
+!0 = !{!"function_entry_count", i64 1000}
+!1 = !{!"branch_weights", i32 2, i32 7}
\ No newline at end of file
diff --git a/llvm/utils/profcheck-xfail.txt b/llvm/utils/profcheck-xfail.txt
index 258e9bcd0b34f..0f2a380a58dcb 100644
--- a/llvm/utils/profcheck-xfail.txt
+++ b/llvm/utils/profcheck-xfail.txt
@@ -831,7 +831,6 @@ Transforms/IndVarSimplify/invalidate-modified-lcssa-phi.ll
Transforms/IndVarSimplify/pr45835.ll
Transforms/IndVarSimplify/preserving-debugloc-rem-div.ll
Transforms/Inline/optimization-remarks-hotness-threshold.ll
-Transforms/InstCombine/2004-09-20-BadLoadCombine2.ll
Transforms/InstCombine/2004-09-20-BadLoadCombine.ll
Transforms/InstCombine/2005-04-07-UDivSelectCrash.ll
Transforms/InstCombine/2011-02-14-InfLoop.ll
``````````
</details>
https://github.com/llvm/llvm-project/pull/157607
More information about the llvm-commits
mailing list