https://github.com/HaohaiWen updated 
https://github.com/llvm/llvm-project/pull/162588

>From c72d01cead8d1c348d2e9df2bcd27e4e1ca739dc Mon Sep 17 00:00:00 2001
From: Haohai Wen <[email protected]>
Date: Thu, 9 Oct 2025 10:52:30 +0800
Subject: [PATCH 1/3] [clang][doc] Simplify Sampling-PGO use example

The -fprofile-sample-use implies codegenoptions::LocTrackingOnly. No need
to explicitly specify -g if debug info is not required in final binary.

Also fix -fuse-ld=lld.
---
 clang/docs/UsersManual.rst | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 12c2ada062625..94f517829fc24 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -2778,7 +2778,7 @@ usual build cycle when using sample profilers for 
optimization:
 
      > clang-cl /O2 -gdwarf -gline-tables-only ^
        /clang:-fdebug-info-for-profiling 
/clang:-funique-internal-linkage-names ^
-       code.cc /Fe:code /fuse-ld=lld /link /debug:dwarf
+       code.cc /Fe:code -fuse-ld=lld /link /debug:dwarf
 
 .. note::
 
@@ -2867,7 +2867,7 @@ usual build cycle when using sample profilers for 
optimization:
 
    .. code-block:: console
 
-     $ clang++ -O2 -gline-tables-only \
+     $ clang++ -O2 \
        -fdebug-info-for-profiling -funique-internal-linkage-names \
        -fprofile-sample-use=code.prof code.cc -o code
 
@@ -2875,7 +2875,7 @@ usual build cycle when using sample profilers for 
optimization:
 
    .. code-block:: winbatch
 
-     > clang-cl /O2 -gdwarf -gline-tables-only ^
+     > clang-cl /O2 ^
        /clang:-fdebug-info-for-profiling 
/clang:-funique-internal-linkage-names ^
        -fprofile-sample-use=code.prof code.cc /Fe:code -fuse-ld=lld /link 
/debug:dwarf
 
@@ -2886,7 +2886,7 @@ usual build cycle when using sample profilers for 
optimization:
 
    .. code-block:: console
 
-     $ clang++ -fsample-profile-use-profi -O2 -gline-tables-only \
+     $ clang++ -fsample-profile-use-profi -O2 \
        -fdebug-info-for-profiling -funique-internal-linkage-names \
        -fprofile-sample-use=code.prof code.cc -o code
 
@@ -2894,7 +2894,7 @@ usual build cycle when using sample profilers for 
optimization:
 
    .. code-block:: winbatch
 
-     > clang-cl /clang:-fsample-profile-use-profi /O2 -gdwarf 
-gline-tables-only ^
+     > clang-cl /clang:-fsample-profile-use-profi /O2 ^
        /clang:-fdebug-info-for-profiling 
/clang:-funique-internal-linkage-names ^
        -fprofile-sample-use=code.prof code.cc /Fe:code -fuse-ld=lld /link 
/debug:dwarf
 

>From 72c3bfb9097ff25310783b802becc18561764ae0 Mon Sep 17 00:00:00 2001
From: Haohai Wen <[email protected]>
Date: Thu, 9 Oct 2025 11:11:06 +0800
Subject: [PATCH 2/3] Fix doc

---
 clang/docs/UsersManual.rst | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 94f517829fc24..ecda5331369d0 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -2861,7 +2861,9 @@ usual build cycle when using sample profilers for 
optimization:
    that executes faster than the original one. Note that you are not
    required to build the code with the exact same arguments that you
    used in the first step. The only requirement is that you build the code
-   with the same debug info options and ``-fprofile-sample-use``.
+   with the same debug info options and ``-fprofile-sample-use``. ``-gdwarf``
+   and ``-gline-tables-only`` can be omitted if you do not need debug info
+   in the final binary.
 
    On Linux:
 

>From cbdce982368a20a2564e0ba36d770317624baba6 Mon Sep 17 00:00:00 2001
From: Haohai Wen <[email protected]>
Date: Fri, 10 Oct 2025 09:09:58 +0800
Subject: [PATCH 3/3] Address comments

---
 clang/docs/UsersManual.rst | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index ecda5331369d0..5745e4b38b826 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -2879,7 +2879,7 @@ usual build cycle when using sample profilers for 
optimization:
 
      > clang-cl /O2 ^
        /clang:-fdebug-info-for-profiling 
/clang:-funique-internal-linkage-names ^
-       -fprofile-sample-use=code.prof code.cc /Fe:code -fuse-ld=lld /link 
/debug:dwarf
+       -fprofile-sample-use=code.prof code.cc /Fe:code
 
    [OPTIONAL] Sampling-based profiles can have inaccuracies or missing block/
    edge counters. The profile inference algorithm (profi) can be used to infer
@@ -2898,7 +2898,7 @@ usual build cycle when using sample profilers for 
optimization:
 
      > clang-cl /clang:-fsample-profile-use-profi /O2 ^
        /clang:-fdebug-info-for-profiling 
/clang:-funique-internal-linkage-names ^
-       -fprofile-sample-use=code.prof code.cc /Fe:code -fuse-ld=lld /link 
/debug:dwarf
+       -fprofile-sample-use=code.prof code.cc /Fe:code
 
 Sample Profile Formats
 """"""""""""""""""""""

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to