Skip to content

Commit 0f3d0cf

Browse files
authored
[clang][doc] Simplify Sampling-PGO use example (#162588)
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.
1 parent 3a9440b commit 0f3d0cf

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

clang/docs/UsersManual.rst

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2778,7 +2778,7 @@ usual build cycle when using sample profilers for optimization:
27782778
27792779
> clang-cl /O2 -gdwarf -gline-tables-only ^
27802780
/clang:-fdebug-info-for-profiling /clang:-funique-internal-linkage-names ^
2781-
code.cc /Fe:code /fuse-ld=lld /link /debug:dwarf
2781+
code.cc /Fe:code -fuse-ld=lld /link /debug:dwarf
27822782
27832783
.. note::
27842784

@@ -2861,23 +2861,25 @@ usual build cycle when using sample profilers for optimization:
28612861
that executes faster than the original one. Note that you are not
28622862
required to build the code with the exact same arguments that you
28632863
used in the first step. The only requirement is that you build the code
2864-
with the same debug info options and ``-fprofile-sample-use``.
2864+
with the same debug info options and ``-fprofile-sample-use``. ``-gdwarf``
2865+
and ``-gline-tables-only`` can be omitted if you do not need debug info
2866+
in the final binary.
28652867

28662868
On Linux:
28672869

28682870
.. code-block:: console
28692871
2870-
$ clang++ -O2 -gline-tables-only \
2872+
$ clang++ -O2 \
28712873
-fdebug-info-for-profiling -funique-internal-linkage-names \
28722874
-fprofile-sample-use=code.prof code.cc -o code
28732875
28742876
On Windows:
28752877

28762878
.. code-block:: winbatch
28772879
2878-
> clang-cl /O2 -gdwarf -gline-tables-only ^
2880+
> clang-cl /O2 ^
28792881
/clang:-fdebug-info-for-profiling /clang:-funique-internal-linkage-names ^
2880-
-fprofile-sample-use=code.prof code.cc /Fe:code -fuse-ld=lld /link /debug:dwarf
2882+
-fprofile-sample-use=code.prof code.cc /Fe:code
28812883
28822884
[OPTIONAL] Sampling-based profiles can have inaccuracies or missing block/
28832885
edge counters. The profile inference algorithm (profi) can be used to infer
@@ -2886,17 +2888,17 @@ usual build cycle when using sample profilers for optimization:
28862888

28872889
.. code-block:: console
28882890
2889-
$ clang++ -fsample-profile-use-profi -O2 -gline-tables-only \
2891+
$ clang++ -fsample-profile-use-profi -O2 \
28902892
-fdebug-info-for-profiling -funique-internal-linkage-names \
28912893
-fprofile-sample-use=code.prof code.cc -o code
28922894
28932895
On Windows:
28942896

28952897
.. code-block:: winbatch
28962898
2897-
> clang-cl /clang:-fsample-profile-use-profi /O2 -gdwarf -gline-tables-only ^
2899+
> clang-cl /clang:-fsample-profile-use-profi /O2 ^
28982900
/clang:-fdebug-info-for-profiling /clang:-funique-internal-linkage-names ^
2899-
-fprofile-sample-use=code.prof code.cc /Fe:code -fuse-ld=lld /link /debug:dwarf
2901+
-fprofile-sample-use=code.prof code.cc /Fe:code
29002902
29012903
Sample Profile Formats
29022904
""""""""""""""""""""""

0 commit comments

Comments
 (0)