Skip to content

Conversation

@nilanjana87
Copy link
Contributor

@nilanjana87 nilanjana87 commented Jul 2, 2025

Since profile inference improves sample coverage, it can be turned on by default.

Ref. to part1 of this patch: #145957
Discourse conversation: https://discourse.llvm.org/t/turn-on-fsample-profile-use-profi-by-default/86508/2

Copy link
Member

@MaskRay MaskRay left a comment

Choose a reason for hiding this comment

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

Driver change looks reasonable if samplepgo maintainers decide to proceed.

Copy link

@snehasish snehasish left a comment

Choose a reason for hiding this comment

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

LGTM, please give downstream users ~1w to add the opt out flag to build configs before landing this.

CC @llvm/pr-subscribers-pgo for visibility.

@nilanjana87 nilanjana87 marked this pull request as ready for review July 4, 2025 00:25
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' labels Jul 4, 2025
@llvmbot
Copy link
Member

llvmbot commented Jul 4, 2025

@llvm/pr-subscribers-pgo

@llvm/pr-subscribers-clang

Author: Nilanjana Basu (nilanjana87)

Changes

Since profile inference improves sample coverage, it can be turned on by default.

Ref. to part1 of this patch: #145957
Discourse conversation: https://discourse.llvm.org/t/turn-on-fsample-profile-use-profi-by-default/86508/2


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

2 Files Affected:

  • (modified) clang/lib/Driver/ToolChains/Clang.cpp (+1-1)
  • (modified) clang/test/Driver/pgo-sample-use-profi.c (+4-4)
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 42323b2fe63bc..96ea7e9a849cc 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -6282,7 +6282,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
 
   if (getLastProfileSampleUseArg(Args) &&
       Args.hasFlag(options::OPT_fsample_profile_use_profi,
-                   options::OPT_fno_sample_profile_use_profi, false)) {
+                   options::OPT_fno_sample_profile_use_profi, true)) {
     CmdArgs.push_back("-mllvm");
     CmdArgs.push_back("-sample-profile-use-profi");
   }
diff --git a/clang/test/Driver/pgo-sample-use-profi.c b/clang/test/Driver/pgo-sample-use-profi.c
index a8c8e81f96dcb..a695cb16a2564 100644
--- a/clang/test/Driver/pgo-sample-use-profi.c
+++ b/clang/test/Driver/pgo-sample-use-profi.c
@@ -1,12 +1,12 @@
 /// Test if profi flag is enabled/disabled correctly based on user-specified configuration.
-/// Ensure that profi flag is disabled by default
+/// Ensure that profi flag is enabled by default
 
 // Target specific checks:
-// RUN: %clang --target=x86_64 -c -fprofile-sample-use=/dev/null -### %s 2>&1 | FileCheck %s --check-prefixes=CHECK-NO-PROFI
-// RUN: %clang --target=AArch64 -c -fprofile-sample-use=/dev/null -### %s 2>&1 | FileCheck %s --check-prefixes=CHECK-NO-PROFI
+// RUN: %clang --target=x86_64 -c -fprofile-sample-use=/dev/null -### %s 2>&1 | FileCheck %s
+// RUN: %clang --target=AArch64 -c -fprofile-sample-use=/dev/null -### %s 2>&1 | FileCheck %s
 
 // Target agnostic checks:
-// RUN: %clang -c -fprofile-sample-use=/dev/null -### %s 2>&1 | FileCheck %s --check-prefixes=CHECK-NO-PROFI
+// RUN: %clang -c -fprofile-sample-use=/dev/null -### %s 2>&1 | FileCheck %s
 // RUN: %clang -c -fsample-profile-use-profi -fprofile-sample-use=/dev/null -### %s 2>&1 | FileCheck %s
 // RUN: %clang -c -fno-sample-profile-use-profi -fsample-profile-use-profi -fprofile-sample-use=/dev/null -### %s 2>&1 | FileCheck %s
 

@llvmbot
Copy link
Member

llvmbot commented Jul 4, 2025

@llvm/pr-subscribers-clang-driver

Author: Nilanjana Basu (nilanjana87)

Changes

Since profile inference improves sample coverage, it can be turned on by default.

Ref. to part1 of this patch: #145957
Discourse conversation: https://discourse.llvm.org/t/turn-on-fsample-profile-use-profi-by-default/86508/2


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

2 Files Affected:

  • (modified) clang/lib/Driver/ToolChains/Clang.cpp (+1-1)
  • (modified) clang/test/Driver/pgo-sample-use-profi.c (+4-4)
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 42323b2fe63bc..96ea7e9a849cc 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -6282,7 +6282,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
 
   if (getLastProfileSampleUseArg(Args) &&
       Args.hasFlag(options::OPT_fsample_profile_use_profi,
-                   options::OPT_fno_sample_profile_use_profi, false)) {
+                   options::OPT_fno_sample_profile_use_profi, true)) {
     CmdArgs.push_back("-mllvm");
     CmdArgs.push_back("-sample-profile-use-profi");
   }
diff --git a/clang/test/Driver/pgo-sample-use-profi.c b/clang/test/Driver/pgo-sample-use-profi.c
index a8c8e81f96dcb..a695cb16a2564 100644
--- a/clang/test/Driver/pgo-sample-use-profi.c
+++ b/clang/test/Driver/pgo-sample-use-profi.c
@@ -1,12 +1,12 @@
 /// Test if profi flag is enabled/disabled correctly based on user-specified configuration.
-/// Ensure that profi flag is disabled by default
+/// Ensure that profi flag is enabled by default
 
 // Target specific checks:
-// RUN: %clang --target=x86_64 -c -fprofile-sample-use=/dev/null -### %s 2>&1 | FileCheck %s --check-prefixes=CHECK-NO-PROFI
-// RUN: %clang --target=AArch64 -c -fprofile-sample-use=/dev/null -### %s 2>&1 | FileCheck %s --check-prefixes=CHECK-NO-PROFI
+// RUN: %clang --target=x86_64 -c -fprofile-sample-use=/dev/null -### %s 2>&1 | FileCheck %s
+// RUN: %clang --target=AArch64 -c -fprofile-sample-use=/dev/null -### %s 2>&1 | FileCheck %s
 
 // Target agnostic checks:
-// RUN: %clang -c -fprofile-sample-use=/dev/null -### %s 2>&1 | FileCheck %s --check-prefixes=CHECK-NO-PROFI
+// RUN: %clang -c -fprofile-sample-use=/dev/null -### %s 2>&1 | FileCheck %s
 // RUN: %clang -c -fsample-profile-use-profi -fprofile-sample-use=/dev/null -### %s 2>&1 | FileCheck %s
 // RUN: %clang -c -fno-sample-profile-use-profi -fsample-profile-use-profi -fprofile-sample-use=/dev/null -### %s 2>&1 | FileCheck %s
 

@nilanjana87 nilanjana87 requested a review from teresajohnson July 4, 2025 00:27
@nilanjana87 nilanjana87 added the PGO Profile Guided Optimizations label Jul 4, 2025
@nilanjana87 nilanjana87 force-pushed the users/nbasu/enable-profi-for-sample-pgo-p2 branch from c28bdc7 to 3d2ca80 Compare July 9, 2025 01:44
@nilanjana87
Copy link
Contributor Author

nilanjana87 commented Jul 9, 2025

Heads up: I'll merge this patch tomorrow. Let me know if any of the downstream users need more time before this goes in.

LGTM, please give downstream users ~1w to add the opt out flag to build configs before landing this.

CC @llvm/pr-subscribers-pgo for visibility.

@nilanjana87 nilanjana87 merged commit 2fc4a4a into main Jul 9, 2025
9 checks passed
@nilanjana87 nilanjana87 deleted the users/nbasu/enable-profi-for-sample-pgo-p2 branch July 9, 2025 21:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang Clang issues not falling into any other category PGO Profile Guided Optimizations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants