Skip to content

Conversation

alanzhao1
Copy link
Contributor

@alanzhao1 alanzhao1 commented Sep 4, 2025

The build configuration described in
https://discourse.llvm.org/t/rfc-profile-information-propagation-unittesting/73595/11 causes this test to fail because that build configuration injects profile metadata which show up in the output. To fix this we just change the assertion to tolerate the presence of profile metadata.

Tracking issue: #147390

…ropagation unittests

The build configuration described in
https://discourse.llvm.org/t/rfc-profile-information-propagation-unittesting/73595/11
causes this test to fail because that build configuration injects
profile metadata which show up in the output. To fix this we just change
the assertion to tolerate the presence of profile metadata.

Tracking issue: llvm#147390
@alanzhao1 alanzhao1 requested a review from mtrofin September 4, 2025 18:10
@alanzhao1 alanzhao1 changed the title [nfc] Make function-specialization3.ll test compatible with profile p… [nfc] Make function-specialization3.ll test compatible with profile propagation unittests Sep 4, 2025
@llvmbot
Copy link
Member

llvmbot commented Sep 4, 2025

@llvm/pr-subscribers-function-specialization

@llvm/pr-subscribers-llvm-transforms

Author: Alan Zhao (alanzhao1)

Changes

The build configuration described in
https://discourse.llvm.org/t/rfc-profile-information-propagation-unittesting/73595/11 causes this test to fail because that build configuration injects profile metadata which show up in the output. To fix this we just change the assertion to tolerate the presence of profile metadata.

Tracking issue: #147390


Full diff: https://github.com/llvm/llvm-project/pull/156942.diff

1 Files Affected:

  • (modified) llvm/test/Transforms/FunctionSpecialization/function-specialization3.ll (+2-2)
diff --git a/llvm/test/Transforms/FunctionSpecialization/function-specialization3.ll b/llvm/test/Transforms/FunctionSpecialization/function-specialization3.ll
index 8e075edaa6844..a26f07bfeb878 100644
--- a/llvm/test/Transforms/FunctionSpecialization/function-specialization3.ll
+++ b/llvm/test/Transforms/FunctionSpecialization/function-specialization3.ll
@@ -34,14 +34,14 @@ return:
 
 ; FORCE-NOT: define internal i32 @foo(
 ;
-; FORCE:      define internal i32 @foo.specialized.1(i32 %x, ptr %b) {
+; FORCE:      define internal i32 @foo.specialized.1(i32 %x, ptr %b) {{(!prof !0 )?}}{
 ; FORCE-NEXT: entry:
 ; FORCE-NEXT:   %0 = load i32, ptr @A, align 4
 ; FORCE-NEXT:   %add = add nsw i32 %x, %0
 ; FORCE-NEXT:   ret i32 %add
 ; FORCE-NEXT: }
 ;
-; FORCE:      define internal i32 @foo.specialized.2(i32 %x, ptr %b) {
+; FORCE:      define internal i32 @foo.specialized.2(i32 %x, ptr %b) {{(!prof !0 )?}}{
 ; FORCE-NEXT: entry:
 ; FORCE-NEXT:   %0 = load i32, ptr @B, align 4
 ; FORCE-NEXT:   %add = add nsw i32 %x, %0

@alanzhao1
Copy link
Contributor Author

This test does indeed to be an issue with the build config not replacing FileCheck if FileCheck is not in the same line; this test passes with the following diff:

diff --git a/llvm/test/Transforms/FunctionSpecialization/function-specialization3.ll b/llvm/test/Transforms/FunctionSpecialization/function-specialization3.ll
index 8e075edaa684..6720a2f11219 100644
--- a/llvm/test/Transforms/FunctionSpecialization/function-specialization3.ll
+++ b/llvm/test/Transforms/FunctionSpecialization/function-specialization3.ll
@@ -1,7 +1,5 @@
-; RUN: opt -passes="ipsccp<func-spec>" -S < %s | \
-; RUN:   FileCheck %s --check-prefixes=COMMON,DISABLED
-; RUN: opt -passes="ipsccp<func-spec>" -force-specialization -S < %s | \
-; RUN:   FileCheck %s --check-prefixes=COMMON,FORCE
+; RUN: opt -passes="ipsccp<func-spec>" -S < %s | FileCheck %s --check-prefixes=COMMON,DISABLED
+; RUN: opt -passes="ipsccp<func-spec>" -force-specialization -S < %s | FileCheck %s --check-prefixes=COMMON,FORCE

 ; Test for specializing a constant global

@mtrofin
Copy link
Member

mtrofin commented Sep 4, 2025

Could we, alternatively:

  • change the test to actually have function entry counts (and branch weights)
  • verify that the entry counts of the specializations are accordingly adjusted (i.e. if the original was called 1000 times, and the branch probs are, say, 20% - 80%, then the entry counts of the specializations should be 200 and 800)

@alanzhao1
Copy link
Contributor Author

change the test to actually have function entry counts (and branch weights)

I'll create a separate PR for that as the original issue (the test failing with profile propagation unittests) is fixed with #156985

@alanzhao1 alanzhao1 closed this Sep 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants