Skip to content

[llvm-profdata] Disable -all-functions by default #138105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions llvm/docs/ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ Changes to the LLVM tools
* llvm-strip now supports continuing to process files on encountering an error.
* In llvm-objcopy/llvm-strip's ELF port, `--discard-locals` and `--discard-all` now allow and preserve symbols referenced by relocations.
([#47468](https://github.com/llvm/llvm-project/issues/47468))
* llvm-profdata's `show` subcommand no longer assumes `--all-functions` if a `--function` filter isn't specified.

Changes to LLDB
---------------------------------
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/tools/llvm-profdata/forward-compatible.test
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
REQUIRES: zlib
RUN: llvm-profdata show -sample %S/Inputs/unknown.section.extbin.profdata | FileCheck %s
RUN: llvm-profdata show -sample %S/Inputs/unknown.section.compressed.extbin.profdata | FileCheck %s
RUN: llvm-profdata show -sample -all-functions %S/Inputs/unknown.section.extbin.profdata | FileCheck %s
RUN: llvm-profdata show -sample -all-functions %S/Inputs/unknown.section.compressed.extbin.profdata | FileCheck %s
RUN: llvm-profdata show -sample -show-sec-info-only %S/Inputs/unknown.section.extbin.profdata | FileCheck %s -check-prefix=HDR
RUN: llvm-profdata show -sample -show-sec-info-only %S/Inputs/unknown.section.compressed.extbin.profdata | FileCheck %s -check-prefix=HDR-COMPRESS

Expand Down
6 changes: 3 additions & 3 deletions llvm/test/tools/llvm-profdata/gcc-gcov-sample-profile.test
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Tests for sample profiles encoded in GCC's gcov format.

1- Show all functions. This profile has a single main() function with several
inlined callees.
RUN: llvm-profdata show --sample %p/Inputs/gcc-sample-profile.gcov | FileCheck %s --check-prefix=SHOW1
RUN: llvm-profdata show --sample -all-functions %p/Inputs/gcc-sample-profile.gcov | FileCheck %s --check-prefix=SHOW1
SHOW1: Function: main: 364084, 0, 6 sampled lines
SHOW1: 2.3: inlined callee: _Z3fool: 243786, 0, 3 sampled lines
SHOW1: 1.3: inlined callee: _Z3bari: 0, 0, 2 sampled lines
Expand All @@ -14,8 +14,8 @@ SHOW1: 1.8: inlined callee: _Z3bari: 0, 0, 2 sampled lines

2- Convert the profile to text encoding and check that they are both
identical.
RUN: llvm-profdata merge --sample %p/Inputs/gcc-sample-profile.gcov --text -o - | llvm-profdata show --sample - -o %t-text
RUN: llvm-profdata show --sample %p/Inputs/gcc-sample-profile.gcov -o %t-gcov
RUN: llvm-profdata merge --sample %p/Inputs/gcc-sample-profile.gcov --text -o - | llvm-profdata show --sample -all-functions - -o %t-text
RUN: llvm-profdata show --sample -all-functions %p/Inputs/gcc-sample-profile.gcov -o %t-gcov
RUN: diff %t-text %t-gcov

4- Merge the gcov and text encodings of the profile and check that the
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/tools/llvm-profdata/inline-samples.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ RUN: llvm-profdata merge --sample %p/Inputs/inline-samples.afdo -o %t.profbin

2- Show all functions. This profile has a single main() function with several
inlined callees.
RUN: llvm-profdata show --sample %t.profbin | FileCheck %s --check-prefix=SHOW1
RUN: llvm-profdata show --sample -all-functions %t.profbin | FileCheck %s --check-prefix=SHOW1
SHOW1: Function: main: 366846, 0, 6 sampled lines
SHOW1: 2.3: inlined callee: _Z3fool: 246044, 0, 3 sampled lines
SHOW1: 1.3: inlined callee: _Z3bari: 0, 0, 2 sampled lines
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/tools/llvm-profdata/overflow-sample.test
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Tests for overflow when merging sampled profiles.

1- Merge profile having maximum counts with itself and verify overflow detected
RUN: llvm-profdata merge -sample %p/Inputs/overflow-sample.proftext %p/Inputs/overflow-sample.proftext -o %t.out 2>&1 | FileCheck %s -check-prefix=MERGE_OVERFLOW
RUN: llvm-profdata show -sample %t.out | FileCheck %s --check-prefix=SHOW_OVERFLOW
RUN: llvm-profdata show -sample -all-functions %t.out | FileCheck %s --check-prefix=SHOW_OVERFLOW
MERGE_OVERFLOW: {{.*}}: main: Counter overflow
SHOW_OVERFLOW-DAG: Function: main: 2000, 0, 2 sampled lines
SHOW_OVERFLOW-DAG: Samples collected in the function's body {
Expand All @@ -23,7 +23,7 @@ SHOW_OVERFLOW-DAG: No inlined callsites in this function

2- Merge profile having maximum counts by itself and verify no overflow
RUN: llvm-profdata merge -sample %p/Inputs/overflow-sample.proftext -o %t.out 2>&1 | FileCheck %s -allow-empty -check-prefix=MERGE_NO_OVERFLOW
RUN: llvm-profdata show -sample %t.out | FileCheck %s --check-prefix=SHOW_NO_OVERFLOW
RUN: llvm-profdata show -sample -all-functions %t.out | FileCheck %s --check-prefix=SHOW_NO_OVERFLOW
MERGE_NO_OVERFLOW-NOT: {{.*}}: main: Counter overflow
SHOW_NO_OVERFLOW-DAG: Function: main: 1000, 0, 2 sampled lines
SHOW_NO_OVERFLOW-DAG: Samples collected in the function's body {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ REQUIRES: zlib
; RUN: llvm-profdata merge -sample -extbinary -compress-all-sections -prof-sym-list=%S/Inputs/profile-symbol-list-1.text %S/Inputs/sample-profile.proftext -o %t.1.output
; RUN: llvm-profdata merge -sample -extbinary -compress-all-sections -prof-sym-list=%S/Inputs/profile-symbol-list-2.text %S/Inputs/sample-profile.proftext -o %t.2.output
; RUN: llvm-profdata merge -sample -extbinary -compress-all-sections %t.1.output %t.2.output -o %t.3.output
; RUN: llvm-profdata show -sample -show-prof-sym-list %t.3.output > %t.4.output
; RUN: llvm-profdata show -all-functions -sample -show-prof-sym-list %t.3.output > %t.4.output
; RUN: diff -b %S/Inputs/profile-symbol-list.expected %t.4.output
2 changes: 1 addition & 1 deletion llvm/test/tools/llvm-profdata/profile-symbol-list.test
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
; RUN: llvm-profdata merge -sample -extbinary -prof-sym-list=%S/Inputs/profile-symbol-list-1.text %S/Inputs/sample-profile.proftext -o %t.1.output
; RUN: llvm-profdata merge -sample -extbinary -prof-sym-list=%S/Inputs/profile-symbol-list-2.text %S/Inputs/sample-profile.proftext -o %t.2.output
; RUN: llvm-profdata merge -sample -extbinary %t.1.output %t.2.output -o %t.3.output
; RUN: llvm-profdata show -sample -show-prof-sym-list %t.3.output > %t.4.output
; RUN: llvm-profdata show -sample -all-functions -show-prof-sym-list %t.3.output > %t.4.output
; RUN: diff -b %S/Inputs/profile-symbol-list.expected %t.4.output
; RUN: llvm-profdata merge -sample -extbinary --drop-profile-symbol-list %t.1.output %t.2.output -o %t.5.output
; RUN: llvm-profdata show -sample -show-sec-info-only %t.5.output | FileCheck %s -check-prefix=NOSYMLIST
Expand Down
22 changes: 11 additions & 11 deletions llvm/test/tools/llvm-profdata/sample-fs.test
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Basic tests for sample profiles using fs discriminators.

1- Show command and keep all the discrimiantor bits
RUN: llvm-profdata show --sample %p/Inputs/sample-fs.proftext -profile-isfs | FileCheck %s --check-prefix=SHOW1
RUN: llvm-profdata show --sample %p/Inputs/sample-fs.proftext -profile-isfs -fs-discriminator-pass=PassLast | FileCheck %s --check-prefix=SHOW1
RUN: llvm-profdata show --sample -all-functions %p/Inputs/sample-fs.proftext -profile-isfs | FileCheck %s --check-prefix=SHOW1
RUN: llvm-profdata show --sample -all-functions %p/Inputs/sample-fs.proftext -profile-isfs -fs-discriminator-pass=PassLast | FileCheck %s --check-prefix=SHOW1
SHOW1: Function: main: 6436, 0, 6 sampled lines
SHOW1: Samples collected in the function's body {
SHOW1: 4: 534
Expand All @@ -14,7 +14,7 @@ SHOW1: 5.738209025: 2150
SHOW1: }

2- Show command and keep only the base discriminator bits
RUN: llvm-profdata show --sample %p/Inputs/sample-fs.proftext -profile-isfs -fs-discriminator-pass=Base | FileCheck %s --check-prefix=SHOW2
RUN: llvm-profdata show --sample -all-functions %p/Inputs/sample-fs.proftext -profile-isfs -fs-discriminator-pass=Base | FileCheck %s --check-prefix=SHOW2
SHOW2: Function: main: 6436, 0, 4 sampled lines
SHOW2: Samples collected in the function's body {
SHOW2: 4: 534
Expand All @@ -24,7 +24,7 @@ SHOW2: 5.1: 3225
SHOW2: }

3- Show command and keep only the base discriminator bits and first pass of FS discriminator
RUN: llvm-profdata show --sample %p/Inputs/sample-fs.proftext -profile-isfs -fs-discriminator-pass=Pass1 | FileCheck %s --check-prefix=SHOW3
RUN: llvm-profdata show --sample -all-functions %p/Inputs/sample-fs.proftext -profile-isfs -fs-discriminator-pass=Pass1 | FileCheck %s --check-prefix=SHOW3
Function: main: 6436, 0, 6 sampled lines
SHOW3: Samples collected in the function's body {
SHOW3: 4: 534
Expand All @@ -36,20 +36,20 @@ SHOW3: 5.11521: 2150
SHOW3: }

4- Merge command and keep all the discrimiantor bits
RUN: llvm-profdata merge --sample %p/Inputs/sample-fs.proftext -profile-isfs -fs-discriminator-pass=PassLast --binary -o - | llvm-profdata show --sample - -o %t1-binary_1
RUN: llvm-profdata merge --sample %p/Inputs/sample-fs.proftext -profile-isfs --binary -o - | llvm-profdata show --sample - -o %t1-binary_2
RUN: llvm-profdata show --sample %p/Inputs/sample-fs.proftext -profile-isfs -o %t1-text
RUN: llvm-profdata merge --sample %p/Inputs/sample-fs.proftext -profile-isfs -fs-discriminator-pass=PassLast --binary -o - | llvm-profdata show --sample -all-functions - -o %t1-binary_1
RUN: llvm-profdata merge --sample %p/Inputs/sample-fs.proftext -profile-isfs --binary -o - | llvm-profdata show --sample -all-functions - -o %t1-binary_2
RUN: llvm-profdata show --sample -all-functions %p/Inputs/sample-fs.proftext -profile-isfs -o %t1-text
RUN: diff %t1-binary_1 %t1-text
RUN: diff %t1-binary_2 %t1-text

2- Merge command and keep only the base discriminator bits
RUN: llvm-profdata merge --sample %p/Inputs/sample-fs.proftext -profile-isfs -fs-discriminator-pass=Base --binary -o - | llvm-profdata show --sample - -o %t2-binary
RUN: llvm-profdata show --sample %p/Inputs/sample-fs.proftext -profile-isfs -fs-discriminator-pass=Base -o %t2-text
RUN: llvm-profdata merge --sample %p/Inputs/sample-fs.proftext -profile-isfs -fs-discriminator-pass=Base --binary -o - | llvm-profdata show --sample -all-functions - -o %t2-binary
RUN: llvm-profdata show --sample -all-functions %p/Inputs/sample-fs.proftext -profile-isfs -fs-discriminator-pass=Base -o %t2-text
RUN: diff %t2-binary %t2-text

3- Merge command and keep only the base discriminator bits and first pass of FS discriminator
RUN: llvm-profdata merge --sample %p/Inputs/sample-fs.proftext -profile-isfs -fs-discriminator-pass=Pass1 --binary -o - | llvm-profdata show --sample - -o %t3-binary
RUN: llvm-profdata show --sample %p/Inputs/sample-fs.proftext -profile-isfs -fs-discriminator-pass=Pass1 -o %t3-text
RUN: llvm-profdata merge --sample %p/Inputs/sample-fs.proftext -profile-isfs -fs-discriminator-pass=Pass1 --binary -o - | llvm-profdata show --sample -all-functions - -o %t3-binary
RUN: llvm-profdata show --sample -all-functions %p/Inputs/sample-fs.proftext -profile-isfs -fs-discriminator-pass=Pass1 -o %t3-text
RUN: diff %t3-binary %t3-text

4- ProfileIsFS is set properly in extbinary format from the internal option
Expand Down
8 changes: 4 additions & 4 deletions llvm/test/tools/llvm-profdata/sample-profile-basic.test
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Basic tests for sample profiles.

1- Show all functions
RUN: llvm-profdata show --sample %p/Inputs/sample-profile.proftext | FileCheck %s --check-prefix=SHOW1
RUN: llvm-profdata show --sample -all-functions %p/Inputs/sample-profile.proftext | FileCheck %s --check-prefix=SHOW1
SHOW1-DAG: Function: main: 184019, 0, 7 sampled lines
SHOW1-DAG: 9: 2064, calls: _Z3bari:1471 _Z3fooi:631
SHOW1-DAG: Function: _Z3fooi: 7711, 610, 1 sampled lines
Expand All @@ -17,8 +17,8 @@ SHOW2-NOT: Function: _Z3fooi: 7711, 610, 1 sampled lines

3- Convert the profile to binary encoding and check that they are both
identical.
RUN: llvm-profdata merge --sample %p/Inputs/sample-profile.proftext --binary -o - | llvm-profdata show --sample - -o %t-binary
RUN: llvm-profdata show --sample %p/Inputs/sample-profile.proftext -o %t-text
RUN: llvm-profdata merge --sample %p/Inputs/sample-profile.proftext --binary -o - | llvm-profdata show --sample -all-functions - -o %t-binary
RUN: llvm-profdata show --sample -all-functions %p/Inputs/sample-profile.proftext -o %t-text
RUN: diff %t-binary %t-text

4- Merge the binary and text encodings of the profile and check that the
Expand All @@ -31,5 +31,5 @@ MERGE1: _Z3bari:40602:2874
MERGE1: _Z3fooi:15422:1220

5- Detect invalid text encoding (e.g. instrumentation profile text format).
RUN: not llvm-profdata show --sample %p/Inputs/foo3bar3-1.proftext 2>&1 | FileCheck %s --check-prefix=BADTEXT
RUN: not llvm-profdata show --sample -all-functions %p/Inputs/foo3bar3-1.proftext 2>&1 | FileCheck %s --check-prefix=BADTEXT
BADTEXT: error: {{.+}}: Unrecognized sample profile encoding format
4 changes: 2 additions & 2 deletions llvm/test/tools/llvm-profdata/sample-profile-json.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
RUN: llvm-profdata show --sample --json %p/Inputs/sample-profile.proftext | FileCheck %s --check-prefix=JSON
RUN: llvm-profdata show --sample --show-format=json %p/Inputs/sample-profile.proftext | FileCheck %s --check-prefix=JSON
RUN: llvm-profdata show --sample -all-functions --json %p/Inputs/sample-profile.proftext | FileCheck %s --check-prefix=JSON
RUN: llvm-profdata show --sample -all-functions --show-format=json %p/Inputs/sample-profile.proftext | FileCheck %s --check-prefix=JSON
JSON: [
JSON-NEXT: {
JSON-NEXT: "name": "main",
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-profdata/llvm-profdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3243,7 +3243,7 @@ static int showSampleProfile(ShowFormat SFormat, raw_fd_ostream &OS) {
if (std::error_code EC = Reader->read())
exitWithErrorCode(EC, Filename);

if (ShowAllFunctions || FuncNameFilter.empty()) {
if (ShowAllFunctions) {
if (SFormat == ShowFormat::Json)
Reader->dumpJson(OS);
else
Expand Down
Loading