diff --git a/compiler-rt/test/profile/ContinuousSyncMode/multi-threaded.cpp b/compiler-rt/test/profile/ContinuousSyncMode/multi-threaded.cpp index 7387f47c13edb..003e8281b3207 100644 --- a/compiler-rt/test/profile/ContinuousSyncMode/multi-threaded.cpp +++ b/compiler-rt/test/profile/ContinuousSyncMode/multi-threaded.cpp @@ -3,7 +3,7 @@ // RUN: rm -rf %t.dir // RUN: %clangxx_pgogen=%t.dir -fprofile-continuous -lpthread %s -o %t.exe -mllvm -disable-vp -fprofile-update=atomic // RUN: %run %t.exe -// RUN: llvm-profdata show --counts --function=accum %t.dir/default_*.profraw | FileCheck %s +// RUN: llvm-profdata show --counts --function accum %t.dir/default_*.profraw | FileCheck %s // CHECK: Block counts: [100000, 4] #include diff --git a/compiler-rt/test/profile/Darwin/instrprof-debug-info-correlate.c b/compiler-rt/test/profile/Darwin/instrprof-debug-info-correlate.c index 1e9bd11d3f49c..5d2f232328338 100644 --- a/compiler-rt/test/profile/Darwin/instrprof-debug-info-correlate.c +++ b/compiler-rt/test/profile/Darwin/instrprof-debug-info-correlate.c @@ -1,7 +1,7 @@ // Value profiling is currently not supported in lightweight mode. // RUN: %clang_pgogen -o %t -g -mllvm --profile-correlate=debug-info -mllvm --disable-vp=true %S/../Inputs/instrprof-debug-info-correlate-main.cpp %S/../Inputs/instrprof-debug-info-correlate-foo.cpp // RUN: env LLVM_PROFILE_FILE=%t.proflite %run %t -// RUN: llvm-profdata merge -o %t.profdata --debug-info=%t.dSYM %t.proflite +// RUN: llvm-profdata merge -o %t.profdata --debug-info %t.dSYM %t.proflite // RUN: %clang_pgogen -o %t.normal -mllvm --disable-vp=true %S/../Inputs/instrprof-debug-info-correlate-main.cpp %S/../Inputs/instrprof-debug-info-correlate-foo.cpp // RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t.normal @@ -13,7 +13,7 @@ // RUN: %clang_pgogen -o %t.cov -g -mllvm --profile-correlate=debug-info -mllvm -pgo-function-entry-coverage -mllvm --disable-vp=true %S/../Inputs/instrprof-debug-info-correlate-main.cpp %S/../Inputs/instrprof-debug-info-correlate-foo.cpp // RUN: env LLVM_PROFILE_FILE=%t.cov.proflite %run %t.cov -// RUN: llvm-profdata merge -o %t.cov.profdata --debug-info=%t.cov.dSYM %t.cov.proflite +// RUN: llvm-profdata merge -o %t.cov.profdata --debug-info %t.cov.dSYM %t.cov.proflite // RUN: %clang_pgogen -o %t.cov.normal -mllvm --pgo-function-entry-coverage -mllvm --disable-vp=true %S/../Inputs/instrprof-debug-info-correlate-main.cpp %S/../Inputs/instrprof-debug-info-correlate-foo.cpp // RUN: env LLVM_PROFILE_FILE=%t.cov.profraw %run %t.cov.normal @@ -32,7 +32,7 @@ // RUN: rm -rf %t.profdir && mkdir %t.profdir // RUN: env LLVM_PROFILE_FILE=%t.profdir/%m.proflite %run %t // RUN: env LLVM_PROFILE_FILE=%t.profdir/%m.proflite %run %t -// RUN: llvm-profdata merge -o %t.profdata --debug-info=%t.dSYM %t.profdir/ +// RUN: llvm-profdata merge -o %t.profdata --debug-info %t.dSYM %t.profdir/ // RUN: llvm-profdata show --all-functions --counts %t.normal.profdata > %t.normal.functions // RUN: llvm-profdata show --all-functions --counts %t.profdata > %t.functions @@ -41,7 +41,7 @@ // RUN: rm -rf %t.profdir && mkdir %t.profdir // RUN: env LLVM_PROFILE_FILE=%t.profdir/%m.cov.proflite %run %t.cov // RUN: env LLVM_PROFILE_FILE=%t.profdir/%m.cov.proflite %run %t.cov -// RUN: llvm-profdata merge -o %t.cov.profdata --debug-info=%t.cov.dSYM %t.profdir/ +// RUN: llvm-profdata merge -o %t.cov.profdata --debug-info %t.cov.dSYM %t.profdir/ // RUN: llvm-profdata show --all-functions --counts %t.cov.normal.profdata > %t.cov.normal.functions // RUN: llvm-profdata show --all-functions --counts %t.cov.profdata > %t.cov.functions diff --git a/compiler-rt/test/profile/Linux/instrprof-debug-info-correlate-warnings.ll b/compiler-rt/test/profile/Linux/instrprof-debug-info-correlate-warnings.ll index 7a8569975c82b..ea2d0f5eaa9c8 100644 --- a/compiler-rt/test/profile/Linux/instrprof-debug-info-correlate-warnings.ll +++ b/compiler-rt/test/profile/Linux/instrprof-debug-info-correlate-warnings.ll @@ -1,7 +1,7 @@ ; RUN: split-file %s %t ; RUN: %clang %t/a.ll -o %t/a.out -; RUN: llvm-profdata merge --debug-info=%t/a.out %t/a.proftext --max-debug-info-correlation-warnings=2 -o %t/a.profdata 2>&1 | FileCheck %s --implicit-check-not=warning --check-prefixes=CHECK,LIMIT -; RUN: llvm-profdata merge --debug-info=%t/a.out %t/a.proftext --max-debug-info-correlation-warnings=0 -o %t/a.profdata 2>&1 | FileCheck %s --implicit-check-not=warning --check-prefixes=CHECK,NOLIMIT +; RUN: llvm-profdata merge --debug-info %t/a.out %t/a.proftext --max-debug-info-correlation-warnings 2 -o %t/a.profdata 2>&1 | FileCheck %s --implicit-check-not=warning --check-prefixes=CHECK,LIMIT +; RUN: llvm-profdata merge --debug-info %t/a.out %t/a.proftext --max-debug-info-correlation-warnings 0 -o %t/a.profdata 2>&1 | FileCheck %s --implicit-check-not=warning --check-prefixes=CHECK,NOLIMIT ; CHECK: warning: Incomplete DIE for function None: ; CHECK: warning: Incomplete DIE for function no_cfg: CFGHash=None diff --git a/compiler-rt/test/profile/Linux/instrprof-debug-info-correlate.c b/compiler-rt/test/profile/Linux/instrprof-debug-info-correlate.c index 194f980df9681..5c21d38d08282 100644 --- a/compiler-rt/test/profile/Linux/instrprof-debug-info-correlate.c +++ b/compiler-rt/test/profile/Linux/instrprof-debug-info-correlate.c @@ -5,7 +5,7 @@ // RUN: %clang_pgogen -o %t.d4 -g -gdwarf-4 -mllvm --profile-correlate=debug-info -mllvm --disable-vp=true %S/../Inputs/instrprof-debug-info-correlate-main.cpp %S/../Inputs/instrprof-debug-info-correlate-foo.cpp // RUN: env LLVM_PROFILE_FILE=%t.d4.proflite %run %t.d4 -// RUN: llvm-profdata merge -o %t.d4.profdata --debug-info=%t.d4 %t.d4.proflite +// RUN: llvm-profdata merge -o %t.d4.profdata --debug-info %t.d4 %t.d4.proflite // RUN: llvm-profdata show --all-functions --counts %t.normal.profdata > %t.normal.dump // RUN: llvm-profdata show --all-functions --counts %t.d4.profdata > %t.d4.dump @@ -13,7 +13,7 @@ // RUN: %clang_pgogen -o %t -g -mllvm --profile-correlate=debug-info -mllvm --disable-vp=true %S/../Inputs/instrprof-debug-info-correlate-main.cpp %S/../Inputs/instrprof-debug-info-correlate-foo.cpp // RUN: env LLVM_PROFILE_FILE=%t.proflite %run %t -// RUN: llvm-profdata merge -o %t.profdata --debug-info=%t %t.proflite +// RUN: llvm-profdata merge -o %t.profdata --debug-info %t %t.proflite // RUN: llvm-profdata show --all-functions --counts %t.normal.profdata > %t.normal2.dump // RUN: llvm-profdata show --all-functions --counts %t.profdata > %t.prof.dump @@ -21,7 +21,7 @@ // RUN: %clang_pgogen -o %t.cov -g -mllvm --profile-correlate=debug-info -mllvm -pgo-function-entry-coverage -mllvm --disable-vp=true %S/../Inputs/instrprof-debug-info-correlate-main.cpp %S/../Inputs/instrprof-debug-info-correlate-foo.cpp // RUN: env LLVM_PROFILE_FILE=%t.cov.proflite %run %t.cov -// RUN: llvm-profdata merge -o %t.cov.profdata --debug-info=%t.cov %t.cov.proflite +// RUN: llvm-profdata merge -o %t.cov.profdata --debug-info %t.cov %t.cov.proflite // RUN: %clang_pgogen -o %t.cov.normal -mllvm --pgo-function-entry-coverage -mllvm --disable-vp=true %S/../Inputs/instrprof-debug-info-correlate-main.cpp %S/../Inputs/instrprof-debug-info-correlate-foo.cpp // RUN: env LLVM_PROFILE_FILE=%t.cov.profraw %run %t.cov.normal @@ -40,7 +40,7 @@ // RUN: rm -rf %t.profdir && mkdir %t.profdir // RUN: env LLVM_PROFILE_FILE=%t.profdir/%m.proflite %run %t // RUN: env LLVM_PROFILE_FILE=%t.profdir/%m.proflite %run %t -// RUN: llvm-profdata merge -o %t.profdata --debug-info=%t %t.profdir/ +// RUN: llvm-profdata merge -o %t.profdata --debug-info %t %t.profdir/ // RUN: llvm-profdata show --all-functions --counts %t.normal.profdata > %t.normal3.dump // RUN: llvm-profdata show --all-functions --counts %t.profdata > %t.prof3.dump @@ -49,7 +49,7 @@ // RUN: rm -rf %t.profdir && mkdir %t.profdir // RUN: env LLVM_PROFILE_FILE=%t.profdir/%m.cov.proflite %run %t.cov // RUN: env LLVM_PROFILE_FILE=%t.profdir/%m.cov.proflite %run %t.cov -// RUN: llvm-profdata merge -o %t.cov.profdata --debug-info=%t.cov %t.profdir/ +// RUN: llvm-profdata merge -o %t.cov.profdata --debug-info %t.cov %t.profdir/ // RUN: llvm-profdata show --all-functions --counts %t.cov.normal.profdata > %t.cov.normal2.dump // RUN: llvm-profdata show --all-functions --counts %t.cov.profdata > %t.cov2.dump diff --git a/compiler-rt/test/profile/Linux/instrprof-instr-suppl.test b/compiler-rt/test/profile/Linux/instrprof-instr-suppl.test index 10650a345ab4b..54bfd47225422 100644 --- a/compiler-rt/test/profile/Linux/instrprof-instr-suppl.test +++ b/compiler-rt/test/profile/Linux/instrprof-instr-suppl.test @@ -34,8 +34,8 @@ // The instrPGO profile counter of function foo should be scaled up. Note the // scaling factor of a function is computed based on instrPGO profiles and // invariant to samplePGO profile counters. -// RUN: llvm-profdata merge -supplement-instr-with-sample=sampleprof.proftext \ -// RUN: -suppl-min-size-threshold=0 -instr-prof-cold-threshold=1 \ +// RUN: llvm-profdata merge -supplement-instr-with-sample sampleprof.proftext \ +// RUN: -suppl-min-size-threshold 0 -instr-prof-cold-threshold 1 \ // RUN: main.profdata -o merge.profdata // RUN: llvm-profdata show -all-functions -counts merge.profdata | FileCheck %s --check-prefix=SUPPL diff --git a/compiler-rt/test/profile/Linux/instrprof-show-debug-info-correlation.c b/compiler-rt/test/profile/Linux/instrprof-show-debug-info-correlation.c index 93bf40f98d3ab..a58a1bbabf7c9 100644 --- a/compiler-rt/test/profile/Linux/instrprof-show-debug-info-correlation.c +++ b/compiler-rt/test/profile/Linux/instrprof-show-debug-info-correlation.c @@ -1,9 +1,9 @@ // RUN: %clang_pgogen -o %t -g -mllvm --profile-correlate=debug-info -mllvm --disable-vp=true %s -// RUN: llvm-profdata show --debug-info=%t --detailed-summary --show-prof-sym-list | FileCheck %s -// RUN: llvm-profdata show --debug-info=%t --show-format=yaml | FileCheck %s --match-full-lines --check-prefix YAML +// RUN: llvm-profdata show --debug-info %t --detailed-summary --show-prof-sym-list | FileCheck %s +// RUN: llvm-profdata show --debug-info %t --show-format yaml | FileCheck %s --match-full-lines --check-prefix YAML // RUN: %clang_pgogen -o %t.no.dbg -mllvm --profile-correlate=debug-info -mllvm --disable-vp=true %s -// RUN: not llvm-profdata show --debug-info=%t.no.dbg 2>&1 | FileCheck %s --check-prefix NO-DBG +// RUN: not llvm-profdata show --debug-info %t.no.dbg 2>&1 | FileCheck %s --check-prefix NO-DBG // NO-DBG: unable to correlate profile: could not find any profile data metadata in correlated file // YAML: Probes: diff --git a/compiler-rt/test/profile/Linux/instrprof-value-merge-lld.c b/compiler-rt/test/profile/Linux/instrprof-value-merge-lld.c index b664eb78734de..4559b3fda360e 100644 --- a/compiler-rt/test/profile/Linux/instrprof-value-merge-lld.c +++ b/compiler-rt/test/profile/Linux/instrprof-value-merge-lld.c @@ -12,4 +12,4 @@ // RUN: env LLVM_PROFILE_FILE=%t.profdir/default_%m.profraw %run %t // RUN: env LLVM_PROFILE_FILE=%t.profdir/default_%m.profraw %run %t 1 // RUN: env LLVM_PROFILE_FILE=%t.profdir/default_%m.profraw %run %t 1 -// RUN: llvm-profdata show -counts -function=main -ic-targets -memop-sizes %t.profdir/default_*.profraw | FileCheck %S/Inputs/instrprof-value-merge.c +// RUN: llvm-profdata show -counts -function main -ic-targets -memop-sizes %t.profdir/default_*.profraw | FileCheck %S/Inputs/instrprof-value-merge.c diff --git a/compiler-rt/test/profile/Linux/instrprof-value-merge.c b/compiler-rt/test/profile/Linux/instrprof-value-merge.c index dc239e88c676b..97e0e013f4090 100644 --- a/compiler-rt/test/profile/Linux/instrprof-value-merge.c +++ b/compiler-rt/test/profile/Linux/instrprof-value-merge.c @@ -7,7 +7,7 @@ // RUN: env LLVM_PROFILE_FILE=%t.profdir/default_%m.profraw %run %t // RUN: env LLVM_PROFILE_FILE=%t.profdir/default_%m.profraw %run %t 1 // RUN: env LLVM_PROFILE_FILE=%t.profdir/default_%m.profraw %run %t 1 -// RUN: llvm-profdata show -counts -function=main -ic-targets -memop-sizes %t.profdir/default_*.profraw | FileCheck %S/Inputs/instrprof-value-merge.c +// RUN: llvm-profdata show -counts -function main -ic-targets -memop-sizes %t.profdir/default_*.profraw | FileCheck %S/Inputs/instrprof-value-merge.c /// -z start-stop-gc requires binutils 2.37. Don't test the option for now. /// TODO: Add -Wl,--gc-sections. @@ -18,7 +18,7 @@ // RUN: env LLVM_PROFILE_FILE=%t.profdir/default_%m.profraw %run %t // RUN: env LLVM_PROFILE_FILE=%t.profdir/default_%m.profraw %run %t 1 // RUN: env LLVM_PROFILE_FILE=%t.profdir/default_%m.profraw %run %t 1 -// RUN: llvm-profdata show -counts -function=main -ic-targets -memop-sizes %t.profdir/default_*.profraw | FileCheck %S/Inputs/instrprof-value-merge.c +// RUN: llvm-profdata show -counts -function main -ic-targets -memop-sizes %t.profdir/default_*.profraw | FileCheck %S/Inputs/instrprof-value-merge.c // RUN: %clang_pgogen -o %t -O3 %S/Inputs/instrprof-value-merge.c -no-pie -fuse-ld=gold -ffunction-sections -fdata-sections // RUN: rm -rf %t.profdir @@ -27,4 +27,4 @@ // RUN: env LLVM_PROFILE_FILE=%t.profdir/default_%m.profraw %run %t // RUN: env LLVM_PROFILE_FILE=%t.profdir/default_%m.profraw %run %t 1 // RUN: env LLVM_PROFILE_FILE=%t.profdir/default_%m.profraw %run %t 1 -// RUN: llvm-profdata show -counts -function=main -ic-targets -memop-sizes %t.profdir/default_*.profraw | FileCheck %S/Inputs/instrprof-value-merge.c +// RUN: llvm-profdata show -counts -function main -ic-targets -memop-sizes %t.profdir/default_*.profraw | FileCheck %S/Inputs/instrprof-value-merge.c diff --git a/compiler-rt/test/profile/Linux/instrprof-vtable-value-prof.cpp b/compiler-rt/test/profile/Linux/instrprof-vtable-value-prof.cpp index e6a4af7b631e9..069050703a361 100644 --- a/compiler-rt/test/profile/Linux/instrprof-vtable-value-prof.cpp +++ b/compiler-rt/test/profile/Linux/instrprof-vtable-value-prof.cpp @@ -11,23 +11,23 @@ // RUN: env LLVM_PROFILE_FILE=test.profraw ./test // Show vtable profiles from raw profile. -// RUN: llvm-profdata show --function=main --ic-targets --show-vtables test.profraw | FileCheck %s --check-prefixes=COMMON,RAW +// RUN: llvm-profdata show --function main --ic-targets --show-vtables test.profraw | FileCheck %s --check-prefixes=COMMON,RAW // Generate indexed profile from raw profile and show the data. // RUN: llvm-profdata merge --keep-vtable-symbols test.profraw -o test.profdata -// RUN: llvm-profdata show --function=main --ic-targets --show-vtables test.profdata | FileCheck %s --check-prefixes=COMMON,INDEXED +// RUN: llvm-profdata show --function main --ic-targets --show-vtables test.profdata | FileCheck %s --check-prefixes=COMMON,INDEXED // Generate text profile from raw and indexed profiles respectively and show the data. // RUN: llvm-profdata merge --keep-vtable-symbols --text test.profraw -o raw.proftext -// RUN: llvm-profdata show --function=main --ic-targets --show-vtables --text raw.proftext | FileCheck %s --check-prefix=ICTEXT +// RUN: llvm-profdata show --function main --ic-targets --show-vtables --text raw.proftext | FileCheck %s --check-prefix=ICTEXT // RUN: llvm-profdata merge --keep-vtable-symbols --text test.profdata -o indexed.proftext -// RUN: llvm-profdata show --function=main --ic-targets --show-vtables --text indexed.proftext | FileCheck %s --check-prefix=ICTEXT +// RUN: llvm-profdata show --function main --ic-targets --show-vtables --text indexed.proftext | FileCheck %s --check-prefix=ICTEXT // Generate indexed profile from text profiles and show the data // RUN: llvm-profdata merge --keep-vtable-symbols --binary raw.proftext -o text.profraw -// RUN: llvm-profdata show --function=main --ic-targets --show-vtables text.profraw | FileCheck %s --check-prefixes=COMMON,INDEXED +// RUN: llvm-profdata show --function main --ic-targets --show-vtables text.profraw | FileCheck %s --check-prefixes=COMMON,INDEXED // RUN: llvm-profdata merge --keep-vtable-symbols --binary indexed.proftext -o text.profdata -// RUN: llvm-profdata show --function=main --ic-targets --show-vtables text.profdata | FileCheck %s --check-prefixes=COMMON,INDEXED +// RUN: llvm-profdata show --function main --ic-targets --show-vtables text.profdata | FileCheck %s --check-prefixes=COMMON,INDEXED // COMMON: Counters: // COMMON-NEXT: main: diff --git a/compiler-rt/test/profile/Windows/instrprof-multiprocess.test b/compiler-rt/test/profile/Windows/instrprof-multiprocess.test index ae5ebd45bec95..50a404ba885f3 100644 --- a/compiler-rt/test/profile/Windows/instrprof-multiprocess.test +++ b/compiler-rt/test/profile/Windows/instrprof-multiprocess.test @@ -1,7 +1,7 @@ RUN: %clang_profgen %S/Inputs/instrprof-multiprocess.c -o %t RUN: rm -f %t_*.profraw RUN: env LLVM_PROFILE_FILE=%t_%m.profraw %run %t -RUN: llvm-profdata show --counts -function=foo %t_*.profraw | FileCheck %s +RUN: llvm-profdata show --counts -function foo %t_*.profraw | FileCheck %s CHECK: Counters: CHECK: foo: diff --git a/compiler-rt/test/profile/infinite_loop.c b/compiler-rt/test/profile/infinite_loop.c index 0e3981c712f6b..7a0e916977074 100644 --- a/compiler-rt/test/profile/infinite_loop.c +++ b/compiler-rt/test/profile/infinite_loop.c @@ -1,6 +1,6 @@ // RUN: %clang_pgogen -O2 -o %t %s // RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t -// RUN: llvm-profdata show -function main -counts %t.profraw| FileCheck %s +// RUN: llvm-profdata show -function main -counts %t.profraw| FileCheck %s void exit(int); int g; diff --git a/compiler-rt/test/profile/instrprof-binary-correlate-debuginfod.c b/compiler-rt/test/profile/instrprof-binary-correlate-debuginfod.c index 09fb39cc3d076..0890c7b6ddbd8 100644 --- a/compiler-rt/test/profile/instrprof-binary-correlate-debuginfod.c +++ b/compiler-rt/test/profile/instrprof-binary-correlate-debuginfod.c @@ -37,5 +37,5 @@ // MISSING-CORRELATION-KIND: error: Expected --correlate when --debug-file-directory is provided // Test error for llvm-profdata merge profile correlation with mixing correlation options. -// RUN: not llvm-profdata merge -o %t.error.profdata --binary-file=%t.correlate.exe --debug-file-directory %t --correlate=binary %t.correlate.profraw 2>&1 | FileCheck %s --check-prefix=MIXING-FLAGS +// RUN: not llvm-profdata merge -o %t.error.profdata --binary-file %t.correlate.exe --debug-file-directory %t --correlate=binary %t.correlate.profraw 2>&1 | FileCheck %s --check-prefix=MIXING-FLAGS // MIXING-FLAGS: error: Expected only one of -binary-file, -debuginfod or -debug-file-directory diff --git a/compiler-rt/test/profile/instrprof-binary-correlate.c b/compiler-rt/test/profile/instrprof-binary-correlate.c index 0e96745a9b58f..0ad5f4efffed3 100644 --- a/compiler-rt/test/profile/instrprof-binary-correlate.c +++ b/compiler-rt/test/profile/instrprof-binary-correlate.c @@ -9,7 +9,7 @@ // With -profile-correlate=binary flag // RUN: %clang -o %t-1.exe -fprofile-instr-generate -fcoverage-mapping -mllvm -profile-correlate=binary %S/Inputs/instrprof-debug-info-correlate-main.cpp %S/Inputs/instrprof-debug-info-correlate-foo.cpp // RUN: env LLVM_PROFILE_FILE=%t-1.profraw %run %t-1.exe -// RUN: llvm-profdata merge -o %t-1.profdata --binary-file=%t-1.exe %t-1.profraw +// RUN: llvm-profdata merge -o %t-1.profdata --binary-file %t-1.exe %t-1.profraw // RUN: llvm-cov report --instr-profile=%t-1.profdata %t-1.exe > %t-1.report // RUN: llvm-cov show --instr-profile=%t-1.profdata %t-1.exe > %t-1.show // RUN: llvm-profdata show --all-functions --counts %t.normal.profdata > %t.normal.profdata.show @@ -21,7 +21,7 @@ // Strip above binary and run // RUN: llvm-strip %t-1.exe -o %t-2.exe // RUN: env LLVM_PROFILE_FILE=%t-2.profraw %run %t-2.exe -// RUN: llvm-profdata merge -o %t-2.profdata --binary-file=%t-1.exe %t-2.profraw +// RUN: llvm-profdata merge -o %t-2.profdata --binary-file %t-1.exe %t-2.profraw // RUN: llvm-cov report --instr-profile=%t-2.profdata %t-1.exe > %t-2.report // RUN: llvm-cov show --instr-profile=%t-2.profdata %t-1.exe > %t-2.show // RUN: llvm-profdata show --all-functions --counts %t-2.profdata > %t-2.profdata.show @@ -39,7 +39,7 @@ // RUN: rm -rf %t.profdir && mkdir %t.profdir // RUN: env LLVM_PROFILE_FILE=%t.profdir/%m-4.profraw %run %t-2.exe // RUN: env LLVM_PROFILE_FILE=%t.profdir/%m-4.profraw %run %t-2.exe -// RUN: llvm-profdata merge -o %t-4.profdata --binary-file=%t-1.exe %t.profdir +// RUN: llvm-profdata merge -o %t-4.profdata --binary-file %t-1.exe %t.profdir // RUN: llvm-cov report --instr-profile=%t-4.profdata %t-1.exe > %t-4.report // RUN: llvm-cov show --instr-profile=%t-4.profdata %t-1.exe > %t-4.show // RUN: llvm-profdata show --all-functions --counts %t.normal.merged.profdata > %t.normal.merged.profdata.show diff --git a/compiler-rt/test/profile/instrprof-timestamp.c b/compiler-rt/test/profile/instrprof-timestamp.c index ad14e6646782c..8b037ef7760cd 100644 --- a/compiler-rt/test/profile/instrprof-timestamp.c +++ b/compiler-rt/test/profile/instrprof-timestamp.c @@ -2,14 +2,14 @@ // RUN: %clang_pgogen -o %t -mllvm -pgo-temporal-instrumentation %s // RUN: env LLVM_PROFILE_FILE=%t.0.profraw %run %t n // RUN: env LLVM_PROFILE_FILE=%t.1.profraw %run %t y -// RUN: llvm-profdata merge -o %t.profdata %t.0.profraw --weighted-input=5,%t.1.profraw +// RUN: llvm-profdata merge -o %t.profdata %t.0.profraw --weighted-input 5,%t.1.profraw // RUN: llvm-profdata show --temporal-profile-traces %t.profdata | FileCheck %s --implicit-check-not=unused // RUN: rm -f %t.profdata // RUN: %clang_pgogen -o %t -mllvm -pgo-temporal-instrumentation -mllvm -pgo-block-coverage %s // RUN: env LLVM_PROFILE_FILE=%t.0.profraw %run %t n // RUN: env LLVM_PROFILE_FILE=%t.1.profraw %run %t y -// RUN: llvm-profdata merge -o %t.profdata %t.0.profraw --weighted-input=5,%t.1.profraw +// RUN: llvm-profdata merge -o %t.profdata %t.0.profraw --weighted-input 5,%t.1.profraw // RUN: llvm-profdata show --temporal-profile-traces %t.profdata | FileCheck %s --implicit-check-not=unused extern void exit(int); diff --git a/llvm/test/Transforms/PGOProfile/data-access-profile.ll b/llvm/test/Transforms/PGOProfile/data-access-profile.ll index 7c062a90024ae..25bb2134e7ec4 100644 --- a/llvm/test/Transforms/PGOProfile/data-access-profile.ll +++ b/llvm/test/Transforms/PGOProfile/data-access-profile.ll @@ -4,8 +4,8 @@ ; RUN: rm -rf %t && split-file %s %t && cd %t ;; Read text profiles and merge them into indexed profiles. -; RUN: llvm-profdata merge --memprof-version=4 memprof.yaml -o memprof.profdata -; RUN: llvm-profdata merge --memprof-version=4 memprof-no-dap.yaml -o memprof-no-dap.profdata +; RUN: llvm-profdata merge --memprof-version 4 memprof.yaml -o memprof.profdata +; RUN: llvm-profdata merge --memprof-version 4 memprof-no-dap.yaml -o memprof-no-dap.profdata ;; Run optimizer pass on an IR module without IR functions, and test that global ;; variables in the module could be annotated (i.e., no early return), diff --git a/llvm/test/Transforms/PGOProfile/memprof.ll b/llvm/test/Transforms/PGOProfile/memprof.ll index a1f0f1d403c8f..531bc9d8631cb 100644 --- a/llvm/test/Transforms/PGOProfile/memprof.ll +++ b/llvm/test/Transforms/PGOProfile/memprof.ll @@ -98,7 +98,7 @@ ; RUN: opt < %s -passes='memprof-use' -pgo-warn-missing-function -S -stats 2>&1 | FileCheck %s --check-prefixes=ALL,MEMPROFONLY,MEMPROFSTATS ;; Make sure we use a specific random hotness seed if requested. -; RUN: llvm-profdata merge -memprof-random-hotness -memprof-random-hotness-seed=1730170724 %S/Inputs/memprof.memprofraw --profiled-binary %S/Inputs/memprof.exe -o %t.memprofdatarand2 2>&1 | FileCheck %s --check-prefix=RAND2 +; RUN: llvm-profdata merge -memprof-random-hotness -memprof-random-hotness-seed 1730170724 %S/Inputs/memprof.memprofraw --profiled-binary %S/Inputs/memprof.exe -o %t.memprofdatarand2 2>&1 | FileCheck %s --check-prefix=RAND2 ; RAND2: random hotness seed = 1730170724 ; RUN: opt < %s -passes='memprof-use' -pgo-warn-missing-function -S -stats 2>&1 | FileCheck %s --check-prefixes=MEMPROFRAND2,ALL,MEMPROFONLY,MEMPROFSTATS diff --git a/llvm/test/Transforms/PGOProfile/memprof_annotate_indirect_call.test b/llvm/test/Transforms/PGOProfile/memprof_annotate_indirect_call.test index 4677eebff3cfe..f1cfdf23e2754 100644 --- a/llvm/test/Transforms/PGOProfile/memprof_annotate_indirect_call.test +++ b/llvm/test/Transforms/PGOProfile/memprof_annotate_indirect_call.test @@ -1,12 +1,12 @@ ; RUN: split-file %s %t ;; Basic functionality with flag toggle -; RUN: llvm-profdata merge --memprof-version=4 %t/basic.yaml -o %t/basic.memprofdata +; RUN: llvm-profdata merge --memprof-version 4 %t/basic.yaml -o %t/basic.memprofdata ; RUN: opt < %t/basic.ll -passes='memprof-use' -memprof-attach-calleeguids=false -S 2>&1 | FileCheck %s --check-prefix=CHECK-DISABLE ; RUN: opt < %t/basic.ll -passes='memprof-use' -memprof-attach-calleeguids=true -S 2>&1 | FileCheck %s --check-prefix=CHECK-ENABLE --dump-input-filter=all ;; FDO conflict handling -; RUN: llvm-profdata merge --memprof-version=4 %t/fdo_conflict.yaml -o %t/fdo_conflict.memprofdata +; RUN: llvm-profdata merge --memprof-version 4 %t/fdo_conflict.yaml -o %t/fdo_conflict.memprofdata ; RUN: opt < %t/fdo_conflict.ll -passes='memprof-use' -memprof-attach-calleeguids=true -S 2>&1 | FileCheck %s --check-prefix=CHECK-FDO ;--- basic.yaml diff --git a/llvm/test/Transforms/PGOProfile/memprof_max_cold_threshold.test b/llvm/test/Transforms/PGOProfile/memprof_max_cold_threshold.test index 8f1cabf9a4e87..2d803bae363ca 100644 --- a/llvm/test/Transforms/PGOProfile/memprof_max_cold_threshold.test +++ b/llvm/test/Transforms/PGOProfile/memprof_max_cold_threshold.test @@ -6,7 +6,7 @@ ; RUN: split-file %s %t ;; Specify version 4 so that a summary is generated. -; RUN: llvm-profdata merge --memprof-version=4 %t/memprof_max_cold_threshold.yaml -o %t/memprof_max_cold_threshold.memprofdata +; RUN: llvm-profdata merge --memprof-version 4 %t/memprof_max_cold_threshold.yaml -o %t/memprof_max_cold_threshold.memprofdata ; RUN: llvm-profdata show --memory %t/memprof_max_cold_threshold.memprofdata | FileCheck %s --check-prefixes=SUMMARY ; SUMMARY: # MemProfSummary: diff --git a/llvm/test/Transforms/PGOProfile/suppl-profile.ll b/llvm/test/Transforms/PGOProfile/suppl-profile.ll index 9e00ceec92b99..1cabd069289b8 100644 --- a/llvm/test/Transforms/PGOProfile/suppl-profile.ll +++ b/llvm/test/Transforms/PGOProfile/suppl-profile.ll @@ -1,13 +1,13 @@ ; Supplement instr profile suppl-profile.proftext with sample profile ; sample-profile.proftext. ; For hot functions: -; RUN: llvm-profdata merge -instr -suppl-min-size-threshold=0 \ -; RUN: -supplement-instr-with-sample=%p/Inputs/sample-profile-hot.proftext \ +; RUN: llvm-profdata merge -instr -suppl-min-size-threshold 0 \ +; RUN: -supplement-instr-with-sample %p/Inputs/sample-profile-hot.proftext \ ; RUN: %S/Inputs/suppl-profile.proftext -o %t.profdata ; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.profdata -S | FileCheck %s --check-prefix=HOT ; For warm functions: -; RUN: llvm-profdata merge -instr -suppl-min-size-threshold=0 \ -; RUN: -supplement-instr-with-sample=%p/Inputs/sample-profile-warm.proftext \ +; RUN: llvm-profdata merge -instr -suppl-min-size-threshold 0 \ +; RUN: -supplement-instr-with-sample %p/Inputs/sample-profile-warm.proftext \ ; RUN: %S/Inputs/suppl-profile.proftext -o %t1.profdata ; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t1.profdata -S | FileCheck %s --check-prefix=WARM diff --git a/llvm/test/Transforms/SampleProfile/compressed-profile-symbol-list.ll b/llvm/test/Transforms/SampleProfile/compressed-profile-symbol-list.ll index 016016fc5063e..2bdce84f36467 100644 --- a/llvm/test/Transforms/SampleProfile/compressed-profile-symbol-list.ll +++ b/llvm/test/Transforms/SampleProfile/compressed-profile-symbol-list.ll @@ -1,4 +1,4 @@ ; REQUIRES: zlib ; Append inline.prof with profile symbol list and save it after compression. -; RUN: llvm-profdata merge --sample --prof-sym-list=%S/Inputs/profile-symbol-list.text --compress-all-sections=true --extbinary %S/Inputs/inline.prof --output=%t.profdata +; RUN: llvm-profdata merge --sample --prof-sym-list %S/Inputs/profile-symbol-list.text --compress-all-sections --extbinary %S/Inputs/inline.prof -o %t.profdata ; RUN: opt < %S/Inputs/profile-symbol-list.ll -passes=sample-profile -profile-accurate-for-symsinlist -sample-profile-file=%t.profdata -S | FileCheck %S/Inputs/profile-symbol-list.ll diff --git a/llvm/test/Transforms/SampleProfile/csspgo-inline.ll b/llvm/test/Transforms/SampleProfile/csspgo-inline.ll index deabc275d99c9..8b5f6db0d3ff0 100644 --- a/llvm/test/Transforms/SampleProfile/csspgo-inline.ll +++ b/llvm/test/Transforms/SampleProfile/csspgo-inline.ll @@ -10,7 +10,7 @@ ; RUN: llvm-profdata merge --sample --extbinary --use-md5 %S/Inputs/profile-context-tracker.prof -o %t.md5 ; RUN: opt < %s -passes=sample-profile -sample-profile-file=%t.md5 -sample-profile-inline-size -sample-profile-prioritized-inline=0 -profile-sample-accurate -S -pass-remarks=inline -o /dev/null 2>&1 | FileCheck %s --check-prefix=INLINE-BASE -; RUN: llvm-profdata merge --sample --text --convert-sample-profile-layout=nest %S/Inputs/profile-context-tracker.prof -o %t.prof +; RUN: llvm-profdata merge --sample --text --convert-sample-profile-layout nest %S/Inputs/profile-context-tracker.prof -o %t.prof ; RUN: opt < %s -passes=sample-profile -sample-profile-file=%t.prof -sample-profile-inline-size -sample-profile-prioritized-inline=0 -profile-sample-accurate -S -pass-remarks=inline -o /dev/null 2>&1 | FileCheck %s --check-prefix=INLINE-BASE ; With new FDO early inliner, callee entry count is used to drive inlining instead of callee total samples, so we get less inlining for given profile diff --git a/llvm/test/Transforms/SampleProfile/csspgo-use-preinliner.ll b/llvm/test/Transforms/SampleProfile/csspgo-use-preinliner.ll index e4ee93970d6f7..f197d255e499d 100644 --- a/llvm/test/Transforms/SampleProfile/csspgo-use-preinliner.ll +++ b/llvm/test/Transforms/SampleProfile/csspgo-use-preinliner.ll @@ -3,7 +3,7 @@ ; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/csspgo-use-preinliner.prof -pass-remarks=inline -sample-profile-prioritized-inline -profile-sample-accurate -sample-profile-use-preinliner=0 -S 2>&1 | FileCheck %s --check-prefix=DEFAULT ; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/csspgo-use-preinliner.prof -pass-remarks=inline -sample-profile-prioritized-inline -profile-sample-accurate -sample-profile-use-preinliner=1 -S 2>&1 | FileCheck %s --check-prefix=PREINLINE -; RUN: llvm-profdata merge --sample --text --convert-sample-profile-layout=nest -generate-merged-base-profiles=0 %S/Inputs/csspgo-use-preinliner.prof -o %t.prof +; RUN: llvm-profdata merge --sample --text --convert-sample-profile-layout nest %S/Inputs/csspgo-use-preinliner.prof -o %t.prof ; RUN: opt < %s -passes=sample-profile -sample-profile-file=%t.prof -pass-remarks=inline -sample-profile-prioritized-inline -profile-sample-accurate -sample-profile-use-preinliner=0 -S 2>&1 | FileCheck %s --check-prefix=DEFAULT ; RUN: opt < %s -passes=sample-profile -sample-profile-file=%t.prof -pass-remarks=inline -sample-profile-prioritized-inline -profile-sample-accurate -sample-profile-use-preinliner=1 -S 2>&1 | FileCheck %s --check-prefix=PREINLINE diff --git a/llvm/test/Transforms/SampleProfile/profile-correlation-irreducible-loops.ll b/llvm/test/Transforms/SampleProfile/profile-correlation-irreducible-loops.ll index ef2fcc6a9e248..7ee030b42cbc9 100644 --- a/llvm/test/Transforms/SampleProfile/profile-correlation-irreducible-loops.ll +++ b/llvm/test/Transforms/SampleProfile/profile-correlation-irreducible-loops.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/profile-correlation-irreducible-loops.prof -sample-profile-use-profi=0 | opt -passes='print' -disable-output -use-iterative-bfi-inference 2>&1 | FileCheck %s +; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/profile-correlation-irreducible-loops.prof -sample-profile-use-profi=0 | opt -passes='print' -disable-output -use-iterative-bfi-inference 2>&1 | FileCheck %s ; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/profile-correlation-irreducible-loops.prof -sample-profile-use-profi=0 -S | FileCheck %s --check-prefix=CHECK2 ; RUN: opt < %s -passes='print' -use-iterative-bfi-inference -disable-output 2>&1 | FileCheck %s --check-prefix=CHECK3 diff --git a/llvm/test/Transforms/SampleProfile/profile-sample-accurate.ll b/llvm/test/Transforms/SampleProfile/profile-sample-accurate.ll index 71defe66395cb..a1b0747b2ff51 100644 --- a/llvm/test/Transforms/SampleProfile/profile-sample-accurate.ll +++ b/llvm/test/Transforms/SampleProfile/profile-sample-accurate.ll @@ -1,6 +1,6 @@ ; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/profsampleacc.extbinary.afdo -profile-summary-cutoff-hot=900000 -profile-sample-accurate -S | FileCheck %s --check-prefix=CALL_SUM_IS_HOT -; RUN: llvm-profdata merge -sample -extbinary -prof-sym-list=%S/Inputs/profile-symbol-list.text %S/Inputs/profsampleacc.extbinary.afdo -o %t.symlist.afdo +; RUN: llvm-profdata merge -sample -extbinary -prof-sym-list %S/Inputs/profile-symbol-list.text %S/Inputs/profsampleacc.extbinary.afdo -o %t.symlist.afdo ; RUN: opt < %s -passes=sample-profile -sample-profile-file=%t.symlist.afdo -profile-summary-cutoff-hot=600000 -profile-accurate-for-symsinlist -S | FileCheck %s --check-prefix=PROFSYMLIST ; RUN: opt < %s -passes=sample-profile -sample-profile-file=%t.symlist.afdo -profile-accurate-for-symsinlist -profile-symbol-list-cutoff=2 -S | FileCheck %s --check-prefix=PSLCUTOFF2 ; RUN: opt < %s -passes=sample-profile -sample-profile-file=%t.symlist.afdo -profile-accurate-for-symsinlist -profile-symbol-list-cutoff=3 -S | FileCheck %s --check-prefix=PSLCUTOFF3 diff --git a/llvm/test/Transforms/SampleProfile/pseudo-probe-inline.ll b/llvm/test/Transforms/SampleProfile/pseudo-probe-inline.ll index b4083f26d9912..7b427ddfa345c 100644 --- a/llvm/test/Transforms/SampleProfile/pseudo-probe-inline.ll +++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-inline.ll @@ -1,14 +1,14 @@ -; RUN: opt < %s -passes=pseudo-probe,sample-profile -sample-profile-file=%S/Inputs/pseudo-probe-inline.prof -S -pass-remarks=sample-profile -sample-profile-prioritized-inline=0 -pass-remarks-output=%t.opt.yaml 2>&1 | FileCheck %s +; RUN: opt < %s -passes=pseudo-probe,sample-profile -sample-profile-file=%S/Inputs/pseudo-probe-inline.prof -S -pass-remarks=sample-profile -sample-profile-prioritized-inline=0 -pass-remarks-output %t.opt.yaml 2>&1 | FileCheck %s ; RUN: FileCheck %s -check-prefixes=YAML,YAML-NO-ANNOTATE < %t.opt.yaml ; RUN: llvm-profdata merge --sample --extbinary %S/Inputs/pseudo-probe-inline.prof -o %t2 -; RUN: opt < %s -passes=pseudo-probe,sample-profile -sample-profile-file=%t2 -S -pass-remarks=sample-profile -sample-profile-prioritized-inline=0 -pass-remarks-output=%t2.opt.yaml 2>&1 | FileCheck %s +; RUN: opt < %s -passes=pseudo-probe,sample-profile -sample-profile-file=%t2 -S -pass-remarks=sample-profile -sample-profile-prioritized-inline=0 -pass-remarks-output %t2.opt.yaml 2>&1 | FileCheck %s ; RUN: FileCheck %s -check-prefixes=YAML,YAML-NO-ANNOTATE < %t2.opt.yaml -; RUN: opt < %s -passes=pseudo-probe,sample-profile -annotate-sample-profile-inline-phase=true -sample-profile-file=%S/Inputs/pseudo-probe-inline.prof -S -pass-remarks=sample-profile -sample-profile-prioritized-inline=0 -pass-remarks-output=%t3.opt.yaml 2>&1 | FileCheck %s +; RUN: opt < %s -passes=pseudo-probe,sample-profile -annotate-sample-profile-inline-phase=true -sample-profile-file=%S/Inputs/pseudo-probe-inline.prof -S -pass-remarks=sample-profile -sample-profile-prioritized-inline=0 -pass-remarks-output %t3.opt.yaml 2>&1 | FileCheck %s ; RUN: FileCheck %s -check-prefixes=YAML,YAML-ANNOTATE < %t3.opt.yaml -; RUN: opt < %s -passes=pseudo-probe,sample-profile -annotate-sample-profile-inline-phase=true -sample-profile-file=%t2 -S -pass-remarks=sample-profile -sample-profile-prioritized-inline=0 -pass-remarks-output=%t4.opt.yaml 2>&1 | FileCheck %s +; RUN: opt < %s -passes=pseudo-probe,sample-profile -annotate-sample-profile-inline-phase=true -sample-profile-file=%t2 -S -pass-remarks=sample-profile -sample-profile-prioritized-inline=0 -pass-remarks-output %t4.opt.yaml 2>&1 | FileCheck %s ; RUN: FileCheck %s -check-prefixes=YAML,YAML-ANNOTATE < %t4.opt.yaml @factor = dso_local global i32 3, align 4 diff --git a/llvm/test/Transforms/SampleProfile/pseudo-probe-profile.ll b/llvm/test/Transforms/SampleProfile/pseudo-probe-profile.ll index 66dbc49a1d210..ed98fd1697935 100644 --- a/llvm/test/Transforms/SampleProfile/pseudo-probe-profile.ll +++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-profile.ll @@ -1,4 +1,4 @@ -; RUN: opt < %s -passes=pseudo-probe,sample-profile -sample-profile-file=%S/Inputs/pseudo-probe-profile.prof -pass-remarks=sample-profile -pass-remarks-output=%t.opt.yaml -sample-profile-use-profi=0 -S -o %t +; RUN: opt < %s -passes=pseudo-probe,sample-profile -sample-profile-file=%S/Inputs/pseudo-probe-profile.prof -pass-remarks=sample-profile -pass-remarks-output %t.opt.yaml -sample-profile-use-profi=0 -S -o %t ; RUN: FileCheck %s --input-file %t ; RUN: FileCheck %s -check-prefix=YAML --input-file %t.opt.yaml ; RUN: opt < %t -passes=sample-profile -sample-profile-file=%S/Inputs/pseudo-probe-profile.prof -sample-profile-remove-probe -S | FileCheck %s -check-prefix=REMOVE-PROBE diff --git a/llvm/test/Transforms/SampleProfile/pseudo-probe-stale-profile-toplev-func.ll b/llvm/test/Transforms/SampleProfile/pseudo-probe-stale-profile-toplev-func.ll index 15a19477f7509..8c041314a583c 100644 --- a/llvm/test/Transforms/SampleProfile/pseudo-probe-stale-profile-toplev-func.ll +++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-stale-profile-toplev-func.ll @@ -1,6 +1,6 @@ ; REQUIRES: asserts && x86-registered-target ; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/pseudo-probe-stale-profile-toplev-func.prof --salvage-stale-profile --salvage-unused-profile -report-profile-staleness -S --debug-only=sample-profile,sample-profile-matcher,sample-profile-impl -pass-remarks=inline --min-call-count-for-cg-matching=0 --min-func-count-for-cg-matching=0 --load-func-profile-for-cg-matching 2>&1 | FileCheck %s -check-prefix=CHECK-TEXT -; RUN: llvm-profdata merge --sample %S/Inputs/pseudo-probe-stale-profile-toplev-func.prof -extbinary -o %t.extbinary +; RUN: llvm-profdata merge --sample -extbinary %S/Inputs/pseudo-probe-stale-profile-toplev-func.prof -o %t.extbinary ; RUN: opt < %s -passes=sample-profile -sample-profile-file=%t.extbinary --salvage-stale-profile --salvage-unused-profile -report-profile-staleness -S --debug-only=sample-profile,sample-profile-matcher,sample-profile-impl -pass-remarks=inline --min-call-count-for-cg-matching=0 --min-func-count-for-cg-matching=0 --load-func-profile-for-cg-matching 2>&1 | FileCheck %s -check-prefix=CHECK-EXTBIN ; CHECK-TEXT: Run stale profile matching for main diff --git a/llvm/test/Transforms/SampleProfile/remarks-hotness.ll b/llvm/test/Transforms/SampleProfile/remarks-hotness.ll index 36fb3c5818170..4b544cab578e1 100644 --- a/llvm/test/Transforms/SampleProfile/remarks-hotness.ll +++ b/llvm/test/Transforms/SampleProfile/remarks-hotness.ll @@ -4,7 +4,7 @@ ; RUN: rm -f %t.yaml %t.hot.yaml ; RUN: opt %s --passes='sample-profile,cgscc(inline)' \ ; RUN: --sample-profile-file=%S/Inputs/remarks-hotness.prof \ -; RUN: -S --pass-remarks-filter=inline --pass-remarks-output=%t.yaml \ +; RUN: -S --pass-remarks-filter=inline --pass-remarks-output %t.yaml \ ; RUN: -pass-remarks-with-hotness --disable-output ; RUN: FileCheck %s -check-prefix=YAML-PASS < %t.yaml ; RUN: FileCheck %s -check-prefix=YAML-MISS < %t.yaml @@ -12,7 +12,7 @@ ;; test 'auto' threshold ; RUN: opt %s --passes='sample-profile,cgscc(inline)' \ ; RUN: --sample-profile-file=%S/Inputs/remarks-hotness.prof \ -; RUN: -S --pass-remarks-filter=inline --pass-remarks-output=%t.hot.yaml \ +; RUN: -S --pass-remarks-filter=inline --pass-remarks-output %t.hot.yaml \ ; RUN: --pass-remarks-with-hotness --pass-remarks-hotness-threshold=auto --disable-output ; RUN: FileCheck %s -check-prefix=YAML-PASS < %t.hot.yaml ; RUN: not FileCheck %s -check-prefix=YAML-MISS < %t.hot.yaml diff --git a/llvm/test/Transforms/SampleProfile/remarks.ll b/llvm/test/Transforms/SampleProfile/remarks.ll index decf4b1aadbd9..493afafa2ed06 100644 --- a/llvm/test/Transforms/SampleProfile/remarks.ll +++ b/llvm/test/Transforms/SampleProfile/remarks.ll @@ -1,7 +1,7 @@ -; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/remarks.prof -S -pass-remarks=sample-profile -pass-remarks-output=%t.opt.yaml 2>&1 | FileCheck %s +; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/remarks.prof -S -pass-remarks=sample-profile -pass-remarks-output %t.opt.yaml 2>&1 | FileCheck %s ; RUN: FileCheck %s -check-prefixes=YAML,YAML-NO-ANNOTATE < %t.opt.yaml -; RUN: opt < %s -passes=sample-profile -annotate-sample-profile-inline-phase -sample-profile-file=%S/Inputs/remarks.prof -S -pass-remarks=sample-profile -pass-remarks-output=%t.opt.yaml 2>&1 | FileCheck %s +; RUN: opt < %s -passes=sample-profile -annotate-sample-profile-inline-phase -sample-profile-file=%S/Inputs/remarks.prof -S -pass-remarks=sample-profile -pass-remarks-output %t.opt.yaml 2>&1 | FileCheck %s ; RUN: FileCheck %s -check-prefixes=YAML,YAML-ANNOTATE < %t.opt.yaml ; Original test case. diff --git a/llvm/test/Transforms/SampleProfile/uncompressed-profile-symbol-list.ll b/llvm/test/Transforms/SampleProfile/uncompressed-profile-symbol-list.ll index 66bd22522fe8c..47b373b0ffbb9 100644 --- a/llvm/test/Transforms/SampleProfile/uncompressed-profile-symbol-list.ll +++ b/llvm/test/Transforms/SampleProfile/uncompressed-profile-symbol-list.ll @@ -1,3 +1,3 @@ ; Append inline.prof with profile symbol list and save it without compression. -; RUN: llvm-profdata merge --sample --prof-sym-list=%S/Inputs/profile-symbol-list.text --compress-all-sections=false --extbinary %S/Inputs/inline.prof --output=%t.profdata +; RUN: llvm-profdata merge --sample --prof-sym-list %S/Inputs/profile-symbol-list.text --extbinary %S/Inputs/inline.prof -o %t.profdata ; RUN: opt < %S/Inputs/profile-symbol-list.ll -passes=sample-profile -profile-accurate-for-symsinlist -sample-profile-file=%t.profdata -S | FileCheck %S/Inputs/profile-symbol-list.ll diff --git a/llvm/test/tools/llvm-profdata/c-general.test b/llvm/test/tools/llvm-profdata/c-general.test index ab4849fac034f..0aa6a104201c5 100644 --- a/llvm/test/tools/llvm-profdata/c-general.test +++ b/llvm/test/tools/llvm-profdata/c-general.test @@ -9,8 +9,8 @@ $ clang -o a.out -fprofile-instr-generate $CFE_TESTDIR/c-general.c -mllvm -enabl $ LLVM_PROFILE_FILE=$TESTDIR/Inputs/c-general.profraw ./a.out RUN: llvm-profdata show %p/Inputs/c-general.profraw -o - | FileCheck %s -RUN: llvm-profdata show %p/Inputs/c-general.profraw --topn=3 -o - | FileCheck %s --check-prefix=TOPN -RUN: llvm-profdata show %p/Inputs/c-general.profraw -o - --function=switches | FileCheck %s -check-prefixes=SWITCHES,CHECK +RUN: llvm-profdata show %p/Inputs/c-general.profraw --topn 3 -o - | FileCheck %s --check-prefix=TOPN +RUN: llvm-profdata show %p/Inputs/c-general.profraw -o - --function switches | FileCheck %s -check-prefixes=SWITCHES,CHECK SWITCHES-LABEL: Counters: SWITCHES-NEXT: switches: diff --git a/llvm/test/tools/llvm-profdata/cs-sample-nested-profile.test b/llvm/test/tools/llvm-profdata/cs-sample-nested-profile.test index d2b07cf05fd24..38b770a65840f 100644 --- a/llvm/test/tools/llvm-profdata/cs-sample-nested-profile.test +++ b/llvm/test/tools/llvm-profdata/cs-sample-nested-profile.test @@ -1,14 +1,14 @@ -RUN: llvm-profdata merge --sample --text -output=%t.proftext %S/Inputs/cs-sample-preinline.proftext --convert-sample-profile-layout=nest -generate-merged-base-profiles=0 +RUN: llvm-profdata merge --sample --text -o %t.proftext %S/Inputs/cs-sample-preinline.proftext --convert-sample-profile-layout nest RUN: FileCheck %s < %t.proftext --match-full-lines --strict-whitespace -RUN: llvm-profdata merge --sample --text -output=%t.probe.proftext %S/Inputs/cs-sample-preinline-probe.proftext --convert-sample-profile-layout=nest -generate-merged-base-profiles=0 +RUN: llvm-profdata merge --sample --text -o %t.probe.proftext %S/Inputs/cs-sample-preinline-probe.proftext --convert-sample-profile-layout nest RUN: FileCheck %s < %t.probe.proftext --match-full-lines --strict-whitespace -check-prefix=PROBE -RUN: llvm-profdata merge --sample --extbinary -output=%t.profbin %S/Inputs/cs-sample-preinline.proftext --convert-sample-profile-layout=nest -generate-merged-base-profiles=0 -RUN: llvm-profdata merge --sample --text -output=%t2.proftext %t.profbin +RUN: llvm-profdata merge --sample --extbinary -o %t.profbin %S/Inputs/cs-sample-preinline.proftext --convert-sample-profile-layout nest +RUN: llvm-profdata merge --sample --text -o %t2.proftext %t.profbin RUN: FileCheck %s < %t2.proftext --match-full-lines --strict-whitespace RUN: llvm-profdata show --sample -show-sec-info-only %t.profbin | FileCheck %s -check-prefix=PREINLINE -RUN: llvm-profdata merge --sample --text -output=%t3.proftext %S/Inputs/cs-sample-preinline.proftext --convert-sample-profile-layout=nest -generate-merged-base-profiles=1 +RUN: llvm-profdata merge --sample --text -o %t3.proftext %S/Inputs/cs-sample-preinline.proftext --convert-sample-profile-layout nest -generate-merged-base-profiles RUN: FileCheck %s < %t3.proftext --match-full-lines --strict-whitespace -check-prefix=RECOUNT -RUN: llvm-profdata merge --sample --extbinary -output=%t2.profbin %S/Inputs/cs-sample-preinline.proftext --convert-sample-profile-layout=nest -generate-merged-base-profiles=1 +RUN: llvm-profdata merge --sample --extbinary -o %t2.profbin %S/Inputs/cs-sample-preinline.proftext --convert-sample-profile-layout nest -generate-merged-base-profiles RUN: llvm-profdata show -sample -detailed-summary %S/Inputs/cs-sample-preinline.proftext | FileCheck %s -check-prefix=SUMMARY RUN: llvm-profdata show -sample -detailed-summary %t2.profbin | FileCheck %s -check-prefix=SUMMARY-NEST RUN: llvm-profdata show -sample -detailed-summary %t3.proftext | FileCheck %s -check-prefix=SUMMARY-NEST diff --git a/llvm/test/tools/llvm-profdata/cs-sample-profile.test b/llvm/test/tools/llvm-profdata/cs-sample-profile.test index ce69a1ffd61a6..a5fe0e9955e1b 100644 --- a/llvm/test/tools/llvm-profdata/cs-sample-profile.test +++ b/llvm/test/tools/llvm-profdata/cs-sample-profile.test @@ -1,4 +1,4 @@ -RUN: llvm-profdata merge --sample --text -output=%t.proftext %S/Inputs/cs-sample.proftext +RUN: llvm-profdata merge -sample --text -o %t.proftext %S/Inputs/cs-sample.proftext RUN: diff -b %t.proftext %S/Inputs/cs-sample.proftext RUN: llvm-profdata merge --sample --extbinary %p/Inputs/cs-sample.proftext -o %t.prof && llvm-profdata merge --sample --text %t.prof -o %t1.proftext RUN: diff -b %t1.proftext %S/Inputs/cs-sample.proftext diff --git a/llvm/test/tools/llvm-profdata/cs-sample-trimmer.test b/llvm/test/tools/llvm-profdata/cs-sample-trimmer.test index a25c89d96d7f8..1d8d7e3a2be1c 100644 --- a/llvm/test/tools/llvm-profdata/cs-sample-trimmer.test +++ b/llvm/test/tools/llvm-profdata/cs-sample-trimmer.test @@ -1,11 +1,11 @@ -RUN: llvm-profdata merge --sample --text -output=%t.proftext %S/Inputs/cs-sample.proftext +RUN: llvm-profdata merge -sample --text -o %t.proftext %S/Inputs/cs-sample.proftext RUN: diff -b %t.proftext %S/Inputs/cs-sample.proftext -RUN: llvm-profdata merge --sample --text -output=%t.proftext %S/Inputs/cs-sample.proftext -sample-merge-cold-context -profile-summary-cold-count=500 +RUN: llvm-profdata merge -sample --text -o %t.proftext %S/Inputs/cs-sample.proftext -sample-merge-cold-context -profile-summary-cold-count 500 RUN: FileCheck %s --input-file %t.proftext --check-prefixes=CHECK-TRIM,CHECK-MERGE -RUN: llvm-profdata merge --sample --text -output=%t.proftext %S/Inputs/cs-sample.proftext -sample-merge-cold-context -sample-trim-cold-context -profile-summary-cold-count=500 +RUN: llvm-profdata merge -sample --text -o %t.proftext %S/Inputs/cs-sample.proftext -sample-merge-cold-context -sample-trim-cold-context -profile-summary-cold-count 500 RUN: FileCheck %s --input-file %t.proftext --check-prefixes=CHECK-TRIM,CHECK-END -RUN: llvm-profdata merge --sample --text -output=%t.proftext %S/Inputs/cs-sample.proftext -sample-merge-cold-context -sample-trim-cold-context -profile-summary-cutoff-cold=990000 +RUN: llvm-profdata merge -sample --text -o %t.proftext %S/Inputs/cs-sample.proftext -sample-merge-cold-context -sample-trim-cold-context -profile-summary-cutoff-cold 990000 RUN: FileCheck %s --input-file %t.proftext --check-prefixes=CHECK-TRIM,CHECK-END CHECK-TRIM: [main:3 @ _Z5funcAi:1 @ _Z8funcLeafi]:1467299:11 diff --git a/llvm/test/tools/llvm-profdata/cutoff.test b/llvm/test/tools/llvm-profdata/cutoff.test index 9d59ede4e8428..2595371bc04ff 100644 --- a/llvm/test/tools/llvm-profdata/cutoff.test +++ b/llvm/test/tools/llvm-profdata/cutoff.test @@ -1,11 +1,11 @@ Basic tests for cutoff options in show command. -RUN: llvm-profdata show -value-cutoff=1 %p/Inputs/cutoff.proftext | FileCheck %s -check-prefixes=CUTOFF1,CHECK -RUN: llvm-profdata show -value-cutoff=1000 %p/Inputs/cutoff.proftext | FileCheck %s -check-prefixes=CUTOFF1000,CHECK -RUN: llvm-profdata show -all-functions -value-cutoff=1 %p/Inputs/cutoff.proftext | FileCheck %s -check-prefixes=CUTOFF1FUNC,CUTOFF1,CHECK -RUN: llvm-profdata show -all-functions -value-cutoff=1000 %p/Inputs/cutoff.proftext | FileCheck %s -check-prefixes=CUTOFF1000FUNC,CUTOFF1000,CHECK -RUN: llvm-profdata show -value-cutoff=1 -list-below-cutoff %p/Inputs/cutoff.proftext | FileCheck %s -check-prefixes=BELOW1,CUTOFF1,CHECK -RUN: llvm-profdata show -value-cutoff=1000 -list-below-cutoff %p/Inputs/cutoff.proftext | FileCheck %s -check-prefixes=BELOW1000,CUTOFF1000,CHECK +RUN: llvm-profdata show -value-cutoff 1 %p/Inputs/cutoff.proftext | FileCheck %s -check-prefixes=CUTOFF1,CHECK +RUN: llvm-profdata show -value-cutoff 1000 %p/Inputs/cutoff.proftext | FileCheck %s -check-prefixes=CUTOFF1000,CHECK +RUN: llvm-profdata show -all-functions -value-cutoff 1 %p/Inputs/cutoff.proftext | FileCheck %s -check-prefixes=CUTOFF1FUNC,CUTOFF1,CHECK +RUN: llvm-profdata show -all-functions -value-cutoff 1000 %p/Inputs/cutoff.proftext | FileCheck %s -check-prefixes=CUTOFF1000FUNC,CUTOFF1000,CHECK +RUN: llvm-profdata show -value-cutoff 1 -list-below-cutoff %p/Inputs/cutoff.proftext | FileCheck %s -check-prefixes=BELOW1,CUTOFF1,CHECK +RUN: llvm-profdata show -value-cutoff 1000 -list-below-cutoff %p/Inputs/cutoff.proftext | FileCheck %s -check-prefixes=BELOW1000,CUTOFF1000,CHECK CUTOFF1FUNC-NOT: bar CUTOFF1FUNC: Functions shown: 2 CUTOFF1000FUNC-NOT: bar diff --git a/llvm/test/tools/llvm-profdata/general.proftext b/llvm/test/tools/llvm-profdata/general.proftext index 89762f2540f6a..7fe3b988c3db7 100644 --- a/llvm/test/tools/llvm-profdata/general.proftext +++ b/llvm/test/tools/llvm-profdata/general.proftext @@ -1,6 +1,6 @@ -# RUN: llvm-profdata merge -sparse=true %s -o %t.profdata +# RUN: llvm-profdata merge -sparse %s -o %t.profdata -# RUN: llvm-profdata merge -sparse=false %s -o %t.profdata.dense +# RUN: llvm-profdata merge %s -o %t.profdata.dense # RUN: llvm-profdata show %t.profdata --function function_count_only --counts | FileCheck %s -check-prefix=FUNC_COUNT_ONLY function_count_only @@ -79,10 +79,10 @@ hex_hash # DETAILED-SUMMARY: 6 blocks (60.00%) with count >= 72057594037927936 account for 99.99% of the total counts. # DETAILED-SUMMARY: 6 blocks (60.00%) with count >= 72057594037927936 account for 99.999% of the total counts. -# RUN: llvm-profdata show --detailed-summary --detailed-summary-cutoffs=600000 %t.profdata | FileCheck %s -check-prefix=DETAILED-SUMMARY-2 +# RUN: llvm-profdata show --detailed-summary --detailed-summary-cutoffs 600000 %t.profdata | FileCheck %s -check-prefix=DETAILED-SUMMARY-2 # DETAILED-SUMMARY-2: 2 blocks (28.57%) with count >= 1152921504606846976 account for 60% of the total counts. # -# RUN: llvm-profdata show --detailed-summary --detailed-summary-cutoffs=600000,900000,999999 %t.profdata | FileCheck %s -check-prefix=DETAILED-SUMMARY-3 +# RUN: llvm-profdata show --detailed-summary --detailed-summary-cutoffs 600000,900000,999999 %t.profdata | FileCheck %s -check-prefix=DETAILED-SUMMARY-3 # DETAILED-SUMMARY-3: 2 blocks (28.57%) with count >= 1152921504606846976 account for 60% of the total counts. # DETAILED-SUMMARY-3: 4 blocks (57.14%) with count >= 288230376151711744 account for 90% of the total counts. # DETAILED-SUMMARY-3: 6 blocks (85.71%) with count >= 72057594037927936 account for 99.9999% of the total counts. diff --git a/llvm/test/tools/llvm-profdata/help.test b/llvm/test/tools/llvm-profdata/help.test new file mode 100644 index 0000000000000..cc2fead5e0b8e --- /dev/null +++ b/llvm/test/tools/llvm-profdata/help.test @@ -0,0 +1,22 @@ +# RUN: llvm-profdata --help | FileCheck %s --check-prefix=TOP +# RUN: llvm-profdata merge --help | FileCheck %s --check-prefix=MERGE +# RUN: llvm-profdata show --help | FileCheck %s --check-prefix=SHOW + +# TOP: OVERVIEW: LLVM profile data +# TOP: USAGE: llvm-profdata [subcommand] [options] +# TOP: SUBCOMMANDS: +# TOP-DAG: merge - Takes several profiles and merge them together. +# TOP-DAG: show - Takes a profile data file and displays the profiles. + +# MERGE: OVERVIEW: LLVM profile data +# MERGE: Takes several profiles and merge them together. +# MERGE: OPTIONS: +# MERGE-DAG: -instr +# MERGE-DAG: -output +# MERGE-DAG: -sample + +# SHOW: OVERVIEW: LLVM profile data +# SHOW: Takes a profile data file and displays the profiles. +# SHOW: OPTIONS: +# SHOW-DAG: -output +# SHOW-DAG: --show-format diff --git a/llvm/test/tools/llvm-profdata/input-dir.test b/llvm/test/tools/llvm-profdata/input-dir.test index 93918c1c8892d..515ab3e8f3674 100644 --- a/llvm/test/tools/llvm-profdata/input-dir.test +++ b/llvm/test/tools/llvm-profdata/input-dir.test @@ -13,7 +13,7 @@ RUN: echo ' ' > %t.dir2/foo RUN: echo ' ' > %t.dir2/subdir/baz RUN: llvm-profdata merge -f %t.input -dump-input-file-list -o /dev/null | FileCheck %s -RUN: llvm-profdata merge -weighted-input=2,%t.dir2 -dump-input-file-list -o /dev/null %t.dir1 | FileCheck %s +RUN: llvm-profdata merge -weighted-input 2,%t.dir2 -dump-input-file-list -o /dev/null %t.dir1 | FileCheck %s CHECK-DAG: 1,{{.*}}.dir1{{[/\\]}}bar CHECK-DAG: 1,{{.*}}.dir1{{[/\\]}}foo diff --git a/llvm/test/tools/llvm-profdata/malformed-num-counters-zero.test b/llvm/test/tools/llvm-profdata/malformed-num-counters-zero.test index 157c13b926a7e..416abde7b4dd7 100644 --- a/llvm/test/tools/llvm-profdata/malformed-num-counters-zero.test +++ b/llvm/test/tools/llvm-profdata/malformed-num-counters-zero.test @@ -80,13 +80,13 @@ RUN: printf '\3\0foo\0\0\0' >> %t-good.profraw RUN: not llvm-profdata merge %t-bad.profraw %t-good.profraw -o %t.profdata 2>&1 | FileCheck %s --check-prefix=ANY ANY: {{.*}} excessively large counter value suggests corrupted profile data: 72057594037927937 -// -failure-mode=all only fails if there is a warning for every input file. -RUN: not llvm-profdata merge %t-bad.profraw -failure-mode=all -o %t.profdata 2>&1 | FileCheck %s --check-prefix=ALL-ERR +// -failure-mode all only fails if there is a warning for every input file. +RUN: not llvm-profdata merge %t-bad.profraw -failure-mode all -o %t.profdata 2>&1 | FileCheck %s --check-prefix=ALL-ERR ALL-ERR: {{.*}} excessively large counter value suggests corrupted profile data: 72057594037927937 -RUN: llvm-profdata merge %t-bad.profraw %t-good.profraw -failure-mode=all -o %t.profdata 2>&1 | FileCheck %s --check-prefix=ALL-WARN +RUN: llvm-profdata merge %t-bad.profraw %t-good.profraw -failure-mode all -o %t.profdata 2>&1 | FileCheck %s --check-prefix=ALL-WARN ALL-WARN: {{.*}} excessively large counter value suggests corrupted profile data: 72057594037927937 -// -failure-mode=warn does not fail at all. It only prints warnings. -RUN: llvm-profdata merge %t-bad.profraw -failure-mode=warn -o %t.profdata 2>&1 | FileCheck %s --check-prefix=WARN +// -failure-mode warn does not fail at all. It only prints warnings. +RUN: llvm-profdata merge %t-bad.profraw -failure-mode warn -o %t.profdata 2>&1 | FileCheck %s --check-prefix=WARN WARN: {{.*}} excessively large counter value suggests corrupted profile data: 72057594037927937 diff --git a/llvm/test/tools/llvm-profdata/memop-size-prof.proftext b/llvm/test/tools/llvm-profdata/memop-size-prof.proftext index 79dc0f8a16324..4c6c61870a312 100644 --- a/llvm/test/tools/llvm-profdata/memop-size-prof.proftext +++ b/llvm/test/tools/llvm-profdata/memop-size-prof.proftext @@ -1,9 +1,9 @@ -# RUN: llvm-profdata show -memop-sizes -ic-targets -function=foo %s | FileCheck %s --check-prefixes=MEMOP,MEMOP_SUM,ICALL,ICALL_SUM -# RUN: llvm-profdata show -memop-sizes -ic-targets -counts -text -function=foo %s | FileCheck %s --check-prefixes=TEXT,MEMOP_TEXT,ICALL_TEXT +# RUN: llvm-profdata show -memop-sizes -ic-targets -function foo %s | FileCheck %s --check-prefixes=MEMOP,MEMOP_SUM,ICALL,ICALL_SUM +# RUN: llvm-profdata show -memop-sizes -ic-targets -counts -text -function foo %s | FileCheck %s --check-prefixes=TEXT,MEMOP_TEXT,ICALL_TEXT # RUN: llvm-profdata merge -o %t.profdata %s -# RUN: llvm-profdata show -memop-sizes -ic-targets -function=foo %t.profdata | FileCheck %s --check-prefixes=MEMOP,MEMOP_SUM,ICALL,ICALL_SUM +# RUN: llvm-profdata show -memop-sizes -ic-targets -function foo %t.profdata | FileCheck %s --check-prefixes=MEMOP,MEMOP_SUM,ICALL,ICALL_SUM # RUN: llvm-profdata merge -o %t.proftext -text %s -# RUN: llvm-profdata show -memop-sizes -ic-targets -function=foo %t.proftext| FileCheck %s --check-prefixes=MEMOP,MEMOP_SUM,ICALL,ICALL_SUM +# RUN: llvm-profdata show -memop-sizes -ic-targets -function foo %t.proftext| FileCheck %s --check-prefixes=MEMOP,MEMOP_SUM,ICALL,ICALL_SUM # IR level Instrumentation Flag :ir diff --git a/llvm/test/tools/llvm-profdata/memprof-merge-versions.test b/llvm/test/tools/llvm-profdata/memprof-merge-versions.test index 0a65872016259..91db00b44cb9b 100644 --- a/llvm/test/tools/llvm-profdata/memprof-merge-versions.test +++ b/llvm/test/tools/llvm-profdata/memprof-merge-versions.test @@ -7,16 +7,16 @@ RUN: echo "1" >> %t.proftext RUN: echo "1" >> %t.proftext To update the inputs used below run Inputs/update_memprof_inputs.sh /path/to/updated/clang -RUN: llvm-profdata merge %t.proftext %p/Inputs/basic.memprofraw --memprof-version=2 --profiled-binary %p/Inputs/basic.memprofexe -o %t.prof.v2 +RUN: llvm-profdata merge %t.proftext %p/Inputs/basic.memprofraw --memprof-version 2 --profiled-binary %p/Inputs/basic.memprofexe -o %t.prof.v2 RUN: llvm-profdata show %t.prof.v2 | FileCheck %s -RUN: llvm-profdata merge %t.proftext %p/Inputs/basic.memprofraw --memprof-version=2 --memprof-full-schema --profiled-binary %p/Inputs/basic.memprofexe -o %t.prof.v2 +RUN: llvm-profdata merge %t.proftext %p/Inputs/basic.memprofraw --memprof-version 2 --memprof-full-schema --profiled-binary %p/Inputs/basic.memprofexe -o %t.prof.v2 RUN: llvm-profdata show %t.prof.v2 | FileCheck %s -RUN: llvm-profdata merge %t.proftext %p/Inputs/basic.memprofraw --memprof-version=3 --profiled-binary %p/Inputs/basic.memprofexe -o %t.prof.v3 +RUN: llvm-profdata merge %t.proftext %p/Inputs/basic.memprofraw --memprof-version 3 --profiled-binary %p/Inputs/basic.memprofexe -o %t.prof.v3 RUN: llvm-profdata show %t.prof.v3 | FileCheck %s -RUN: llvm-profdata merge %t.proftext %p/Inputs/basic.memprofraw --memprof-version=3 --memprof-full-schema --profiled-binary %p/Inputs/basic.memprofexe -o %t.prof.v3 +RUN: llvm-profdata merge %t.proftext %p/Inputs/basic.memprofraw --memprof-version 3 --memprof-full-schema --profiled-binary %p/Inputs/basic.memprofexe -o %t.prof.v3 RUN: llvm-profdata show %t.prof.v3 | FileCheck %s Check to see if llvm-profdata produces V3 by default. diff --git a/llvm/test/tools/llvm-profdata/memprof-yaml.test b/llvm/test/tools/llvm-profdata/memprof-yaml.test index 69b3131a87f3d..3b24a5c5402c0 100644 --- a/llvm/test/tools/llvm-profdata/memprof-yaml.test +++ b/llvm/test/tools/llvm-profdata/memprof-yaml.test @@ -3,35 +3,35 @@ ; Verify that the YAML output is identical to the YAML input. ; memprof-in.yaml has both heap profile records and data access profiles. -; RUN: llvm-profdata merge --memprof-version=4 %t/memprof-in.yaml -o %t/memprof-out.indexed +; RUN: llvm-profdata merge --memprof-version 4 %t/memprof-in.yaml -o %t/memprof-out.indexed ; RUN: llvm-profdata show --memory %t/memprof-out.indexed > %t/memprof-out.yaml ; RUN: diff -b %t/memprof-in.yaml %t/memprof-out.yaml ; Merge text profile as v3 binary profile. Test that the merged v3 profile ; are identical to memprof-in-v3.yaml, and doesn't have callee guids or dap. -; RUN: llvm-profdata merge --memprof-version=3 %t/memprof-in.yaml -o %t/memprof-out-v3.indexed +; RUN: llvm-profdata merge --memprof-version 3 %t/memprof-in.yaml -o %t/memprof-out-v3.indexed ; RUN: llvm-profdata show --memory %t/memprof-out-v3.indexed > %t/memprof-out-v3.yaml ; RUN: diff -b %t/memprof-out-v3.yaml %t/memprof-in-v3.yaml ; Make sure we can ingest a YAML profile containing AllocSites only. ; That is, CallSites are missing. -; RUN: llvm-profdata merge --memprof-version=4 %t/memprof-in-alloc-sites-only.yaml -o %t/memprof-out-alloc-sites-only.indexed +; RUN: llvm-profdata merge --memprof-version 4 %t/memprof-in-alloc-sites-only.yaml -o %t/memprof-out-alloc-sites-only.indexed ; RUN: llvm-profdata show --memory %t/memprof-out-alloc-sites-only.indexed > %t/memprof-out-alloc-sites-only.yaml ; RUN: diff -b %t/memprof-out-alloc-sites-only.yaml %t/memprof-in-alloc-sites-only.yaml ; Make sure we can ingest a YAML profile containing CallSites only. ; That is, AllocSites are missing. -; RUN: llvm-profdata merge --memprof-version=4 %t/memprof-in-call-sites-only.yaml -o %t/memprof-out-call-sites-only.indexed +; RUN: llvm-profdata merge --memprof-version 4 %t/memprof-in-call-sites-only.yaml -o %t/memprof-out-call-sites-only.indexed ; RUN: llvm-profdata show --memory %t/memprof-out-call-sites-only.indexed > %t/memprof-out-call-sites-only.yaml ; RUN: diff -b %t/memprof-out-call-sites-only.yaml %t/memprof-in-call-sites-only.yaml ; memprof-in-no-dap.yaml has empty data access profiles. -; RUN: llvm-profdata merge --memprof-version=4 %t/memprof-in-no-dap.yaml -o %t/memprof-out.indexed +; RUN: llvm-profdata merge --memprof-version 4 %t/memprof-in-no-dap.yaml -o %t/memprof-out.indexed ; RUN: llvm-profdata show --memory %t/memprof-out.indexed > %t/memprof-out-no-dap.yaml ; RUN: diff -b %t/memprof-in-no-dap.yaml %t/memprof-out-no-dap.yaml ; memprof-in-no-heap.yaml has empty heap access profiles. -; RUN: llvm-profdata merge --memprof-version=4 %t/memprof-in-no-heap.yaml -o %t/memprof-out-no-heap.indexed +; RUN: llvm-profdata merge --memprof-version 4 %t/memprof-in-no-heap.yaml -o %t/memprof-out-no-heap.indexed ; RUN: llvm-profdata show --memory %t/memprof-out-no-heap.indexed > %t/memprof-out-no-heap.yaml ; RUN: diff -b %t/memprof-in-no-heap.yaml %t/memprof-out-no-heap.yaml diff --git a/llvm/test/tools/llvm-profdata/merge-filter.test b/llvm/test/tools/llvm-profdata/merge-filter.test index 5c47c6a75a7c4..87cb24d435248 100644 --- a/llvm/test/tools/llvm-profdata/merge-filter.test +++ b/llvm/test/tools/llvm-profdata/merge-filter.test @@ -1,28 +1,28 @@ Test llvm-profdata merge with function filters. -RUN: llvm-profdata merge --sample %p/Inputs/sample-profile.proftext --text --function="_Z3.*" | FileCheck %s --check-prefix=CHECK-FILTER1 -RUN: llvm-profdata merge --sample %p/Inputs/sample-profile.proftext --text --no-function="main" | FileCheck %s --check-prefix=CHECK-FILTER1 +RUN: llvm-profdata merge --sample %p/Inputs/sample-profile.proftext --text --function "_Z3.*" | FileCheck %s --check-prefix=CHECK-FILTER1 +RUN: llvm-profdata merge --sample %p/Inputs/sample-profile.proftext --text --no-function "main" | FileCheck %s --check-prefix=CHECK-FILTER1 CHECK-FILTER1: _Z3bari:20301:1437 CHECK-NEXT: 1: 1437 CHECK-NEXT: _Z3fooi:7711:610 CHECK-NEXT: 1: 610 CHECK-NOT: main -RUN: llvm-profdata merge --sample %p/Inputs/sample-profile.proftext --text --function="_Z3.*" --no-function="fooi$" | FileCheck %s --check-prefix=CHECK-FILTER2 +RUN: llvm-profdata merge --sample %p/Inputs/sample-profile.proftext --text -function "_Z3.*" --no-function "fooi$" | FileCheck %s --check-prefix=CHECK-FILTER2 CHECK-FILTER2: _Z3bari:20301:1437 CHECK-NEXT: 1: 1437 CHECK-NOT: main CHECK-NOT: _Z3fooi -RUN: llvm-profdata merge --sample --extbinary --use-md5 -output=%t.0.profdata %p/Inputs/sample-profile.proftext -RUN: llvm-profdata merge --sample %t.0.profdata --text --function="_Z3fooi" | FileCheck %s --check-prefix=CHECK-FILTER-MD5 +RUN: llvm-profdata merge --sample --extbinary --use-md5 -o %t.0.profdata %p/Inputs/sample-profile.proftext +RUN: llvm-profdata merge --sample %t.0.profdata --text --function "_Z3fooi" | FileCheck %s --check-prefix=CHECK-FILTER-MD5 CHECK-FILTER-MD5: 1228452328526475178:7711:610 CHECK-NEXT: 1: 610 CHECK-NOT: 15822663052811949562 CHECK-NOT: 3727899762981752933 -RUN: llvm-profdata merge --instr %p/Inputs/basic.proftext --text --function="foo" | FileCheck %s --check-prefix=CHECK-FILTER3 -RUN: llvm-profdata merge --instr %p/Inputs/basic.proftext --text --no-function="main" | FileCheck %s --check-prefix=CHECK-FILTER3 +RUN: llvm-profdata merge --instr %p/Inputs/basic.proftext --text --function "foo" | FileCheck %s --check-prefix=CHECK-FILTER3 +RUN: llvm-profdata merge --instr %p/Inputs/basic.proftext --text --no-function "main" | FileCheck %s --check-prefix=CHECK-FILTER3 CHECK-FILTER3: foo CHECK-NEXT: # Func Hash: CHECK-NEXT: 10 @@ -41,7 +41,7 @@ CHECK-NEXT: # Counter Values: CHECK-NEXT: 500500 CHECK-NEXT: 180100 -RUN: llvm-profdata merge --instr %p/Inputs/basic.proftext --text --function="foo" --no-function="^foo$" | FileCheck %s --check-prefix=CHECK-FILTER4 +RUN: llvm-profdata merge --instr %p/Inputs/basic.proftext --text -function "foo" --no-function "^foo$" | FileCheck %s --check-prefix=CHECK-FILTER4 CHECK-FILTER4: foo2 CHECK-NEXT: # Func Hash: CHECK-NEXT: 10 @@ -51,7 +51,7 @@ CHECK-NEXT: # Counter Values: CHECK-NEXT: 500500 CHECK-NEXT: 180100 -RUN: llvm-profdata merge --sample %p/Inputs/cs-sample.proftext --text --function="main.*@.*_Z5funcBi" | FileCheck %s --check-prefix=CHECK-FILTER5 +RUN: llvm-profdata merge -sample %p/Inputs/cs-sample.proftext --text --function "main.*@.*_Z5funcBi" | FileCheck %s --check-prefix=CHECK-FILTER5 CHECK-FILTER5: [main:3.1 @ _Z5funcBi:1 @ _Z8funcLeafi]:500853:20 CHECK-NEXT: 0: 15 CHECK-NEXT: 1: 15 diff --git a/llvm/test/tools/llvm-profdata/merge-incompatible.test b/llvm/test/tools/llvm-profdata/merge-incompatible.test index fca72a452069e..fab3b198c1b15 100644 --- a/llvm/test/tools/llvm-profdata/merge-incompatible.test +++ b/llvm/test/tools/llvm-profdata/merge-incompatible.test @@ -4,5 +4,5 @@ CHECK: ir-basic.proftext: Merge IR generated profile with Clang generated profil // We get a slightly different error message when using multiple threads because // we do not know which files have incompatible kinds. -RUN: not llvm-profdata merge %p/Inputs/fe-basic.proftext %p/Inputs/ir-basic.proftext --num-threads=2 -o /dev/null 2>&1 | FileCheck %s --check-prefix=THREADS +RUN: not llvm-profdata merge %p/Inputs/fe-basic.proftext %p/Inputs/ir-basic.proftext --num-threads 2 -o /dev/null 2>&1 | FileCheck %s --check-prefix=THREADS THREADS: unsupported instrumentation profile format version diff --git a/llvm/test/tools/llvm-profdata/merge-probe-profile.test b/llvm/test/tools/llvm-profdata/merge-probe-profile.test index d05c950728747..b69a5feb680b3 100644 --- a/llvm/test/tools/llvm-profdata/merge-probe-profile.test +++ b/llvm/test/tools/llvm-profdata/merge-probe-profile.test @@ -24,4 +24,4 @@ MERGE2: 6: 12 _Z3barv:8 _Z3foov:4 MERGE2: !CFGChecksum: 563022570642068 RUN: llvm-profdata show --sample -show-sec-info-only %t | FileCheck %s -CHECK: FunctionMetadata {{.*}} Flags: {probe} \ No newline at end of file +CHECK: FunctionMetadata {{.*}} Flags: {probe} diff --git a/llvm/test/tools/llvm-profdata/merge-traces.proftext b/llvm/test/tools/llvm-profdata/merge-traces.proftext index 3512f33cd06a9..fcb6034130af8 100644 --- a/llvm/test/tools/llvm-profdata/merge-traces.proftext +++ b/llvm/test/tools/llvm-profdata/merge-traces.proftext @@ -1,23 +1,23 @@ -# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size=2 %s --text | FileCheck %s --check-prefixes=CHECK,SEEN1,SAMPLE1 +# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size 2 %s --text | FileCheck %s --check-prefixes=CHECK,SEEN1,SAMPLE1 # Merge %s twice so it has two traces -# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size=2 %s %s --text | FileCheck %s --check-prefixes=CHECK,SEEN2,SAMPLE2 -# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size=2 %s %s -o %t-2.profdata +# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size 2 %s %s --text | FileCheck %s --check-prefixes=CHECK,SEEN2,SAMPLE2 +# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size 2 %s %s -o %t-2.profdata -# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size=2 %s %s %s --text | FileCheck %s --check-prefixes=CHECK,SEEN3,SAMPLE2 -# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size=2 %t-2.profdata %s --text | FileCheck %s --check-prefixes=CHECK,SEEN3,SAMPLE2 -# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size=2 %s %t-2.profdata --text | FileCheck %s --check-prefixes=CHECK,SEEN3,SAMPLE2 +# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size 2 %s %s %s --text | FileCheck %s --check-prefixes=CHECK,SEEN3,SAMPLE2 +# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size 2 %t-2.profdata %s --text | FileCheck %s --check-prefixes=CHECK,SEEN3,SAMPLE2 +# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size 2 %s %t-2.profdata --text | FileCheck %s --check-prefixes=CHECK,SEEN3,SAMPLE2 -# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size=2 %s %s %s %s --text | FileCheck %s --check-prefixes=CHECK,SEEN4,SAMPLE2 -# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size=2 %t-2.profdata %s %s --text | FileCheck %s --check-prefixes=CHECK,SEEN4,SAMPLE2 -# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size=2 %t-2.profdata %t-2.profdata --text | FileCheck %s --check-prefixes=CHECK,SEEN4,SAMPLE2 +# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size 2 %s %s %s %s --text | FileCheck %s --check-prefixes=CHECK,SEEN4,SAMPLE2 +# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size 2 %t-2.profdata %s %s --text | FileCheck %s --check-prefixes=CHECK,SEEN4,SAMPLE2 +# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size 2 %t-2.profdata %t-2.profdata --text | FileCheck %s --check-prefixes=CHECK,SEEN4,SAMPLE2 # Test that we can increase the reservoir size, even if inputs are sampled -# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size=2 %s %s %s %s -o %t-4.profdata -# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size=4 %t-4.profdata %t-4.profdata --text | FileCheck %s --check-prefixes=CHECK,SEEN8,SAMPLE4 +# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size 2 %s %s %s %s -o %t-4.profdata +# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size 4 %t-4.profdata %t-4.profdata --text | FileCheck %s --check-prefixes=CHECK,SEEN8,SAMPLE4 # Test that decreasing the reservoir size truncates traces -# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size=1 %t-4.profdata --text | FileCheck %s --check-prefixes=CHECK,SEEN4,SAMPLE1 +# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size 1 %t-4.profdata --text | FileCheck %s --check-prefixes=CHECK,SEEN4,SAMPLE1 # CHECK: :temporal_prof_traces # CHECK: # Num Temporal Profile Traces: diff --git a/llvm/test/tools/llvm-profdata/merge_empty_profile.test b/llvm/test/tools/llvm-profdata/merge_empty_profile.test index 013a4dcda6554..922f6bbb297c3 100644 --- a/llvm/test/tools/llvm-profdata/merge_empty_profile.test +++ b/llvm/test/tools/llvm-profdata/merge_empty_profile.test @@ -2,14 +2,14 @@ RUN: touch %t_empty.proftext RUN: llvm-profdata merge -text -o - %t_empty.proftext %p/Inputs/clang_profile.proftext | FileCheck %s -check-prefix=CLANG_PROF_TEXT -RUN: llvm-profdata merge -text -o - %t_empty.proftext %p/Inputs/clang_profile.proftext --num-threads=2 | FileCheck %s -check-prefix=CLANG_PROF_TEXT +RUN: llvm-profdata merge -text -o - %t_empty.proftext %p/Inputs/clang_profile.proftext --num-threads 2 | FileCheck %s -check-prefix=CLANG_PROF_TEXT CLANG_PROF_TEXT: main CLANG_PROF_TEXT: 0 CLANG_PROF_TEXT: 1 CLANG_PROF_TEXT: 1 RUN: llvm-profdata merge -text -o - %t_empty.proftext %p/Inputs/IR_profile.proftext | FileCheck %s -check-prefix=IR_PROF_TEXT -RUN: llvm-profdata merge -text -o - %t_empty.proftext %p/Inputs/IR_profile.proftext --num-threads=2 | FileCheck %s -check-prefix=IR_PROF_TEXT +RUN: llvm-profdata merge -text -o - %t_empty.proftext %p/Inputs/IR_profile.proftext --num-threads 2 | FileCheck %s -check-prefix=IR_PROF_TEXT IR_PROF_TEXT: :ir IR_PROF_TEXT: main IR_PROF_TEXT: 0 diff --git a/llvm/test/tools/llvm-profdata/overlap.test b/llvm/test/tools/llvm-profdata/overlap.test index 6470e3f19712b..1d94a0dafea11 100644 --- a/llvm/test/tools/llvm-profdata/overlap.test +++ b/llvm/test/tools/llvm-profdata/overlap.test @@ -1,6 +1,6 @@ RUN: llvm-profdata overlap %p/Inputs/overlap_1.proftext %p/Inputs/overlap_2.proftext | FileCheck %s -check-prefix=OVERLAP -RUN: llvm-profdata overlap -function=main %p/Inputs/overlap_1.proftext %p/Inputs/overlap_2.proftext | FileCheck %s --check-prefixes=MAINFUNC,OVERLAP -RUN: llvm-profdata overlap -value-cutoff=15000 %p/Inputs/overlap_1.proftext %p/Inputs/overlap_2.proftext | FileCheck %s --check-prefixes=MAINFUNC,OVERLAP +RUN: llvm-profdata overlap -function main %p/Inputs/overlap_1.proftext %p/Inputs/overlap_2.proftext | FileCheck %s --check-prefixes=MAINFUNC,OVERLAP +RUN: llvm-profdata overlap -value-cutoff 15000 %p/Inputs/overlap_1.proftext %p/Inputs/overlap_2.proftext | FileCheck %s --check-prefixes=MAINFUNC,OVERLAP RUN: llvm-profdata merge %p/Inputs/overlap_1.proftext -o %t_1.profdata RUN: llvm-profdata merge %p/Inputs/overlap_2.proftext -o %t_2.profdata RUN: llvm-profdata overlap %t_1.profdata %t_2.profdata | FileCheck %s -check-prefix=OVERLAP diff --git a/llvm/test/tools/llvm-profdata/profile-symbol-list-compress.test b/llvm/test/tools/llvm-profdata/profile-symbol-list-compress.test index 8383bcc1a2fbe..127fadfcddc8b 100644 --- a/llvm/test/tools/llvm-profdata/profile-symbol-list-compress.test +++ b/llvm/test/tools/llvm-profdata/profile-symbol-list-compress.test @@ -1,6 +1,6 @@ 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 -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: diff -b %S/Inputs/profile-symbol-list.expected %t.4.output @@ -8,8 +8,8 @@ REQUIRES: zlib ;; Generate two SampleFDO binary profiles and merge them. ;; Tests that the vtable counters in the merged profile are the aggregated ;; result from both sources. -; RUN: llvm-profdata merge -sample -extbinary -compress-all-sections -extbinary-write-vtable-type-prof -prof-sym-list=%S/Inputs/profile-symbol-list-1.text %S/Inputs/sample-profile-ext.proftext -o %t.1.output -; RUN: llvm-profdata merge -sample -extbinary -compress-all-sections -extbinary-write-vtable-type-prof -prof-sym-list=%S/Inputs/profile-symbol-list-2.text %S/Inputs/sample-profile-ext.proftext -o %t.2.output +; RUN: llvm-profdata merge -sample -extbinary -compress-all-sections -extbinary-write-vtable-type-prof -prof-sym-list %S/Inputs/profile-symbol-list-1.text %S/Inputs/sample-profile-ext.proftext -o %t.1.output +; RUN: llvm-profdata merge -sample -extbinary -compress-all-sections -extbinary-write-vtable-type-prof -prof-sym-list %S/Inputs/profile-symbol-list-2.text %S/Inputs/sample-profile-ext.proftext -o %t.2.output ; RUN: llvm-profdata merge -sample -extbinary -compress-all-sections -extbinary-write-vtable-type-prof %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: diff -b %S/Inputs/profile-symbol-list-ext.expected %t.4.output diff --git a/llvm/test/tools/llvm-profdata/profile-symbol-list.test b/llvm/test/tools/llvm-profdata/profile-symbol-list.test index 6845531066c76..a61c946c51323 100644 --- a/llvm/test/tools/llvm-profdata/profile-symbol-list.test +++ b/llvm/test/tools/llvm-profdata/profile-symbol-list.test @@ -1,5 +1,5 @@ -; 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 -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: diff -b %S/Inputs/profile-symbol-list.expected %t.4.output @@ -11,8 +11,8 @@ ;; Generate two SampleFDO binary profiles and merge them. ;; Tests that the vtable counters in the merged profile are the aggregated ;; result from both sources. -; RUN: llvm-profdata merge -sample -extbinary -extbinary-write-vtable-type-prof -prof-sym-list=%S/Inputs/profile-symbol-list-1.text %S/Inputs/sample-profile-ext.proftext -o %t.1.output -; RUN: llvm-profdata merge -sample -extbinary -extbinary-write-vtable-type-prof -prof-sym-list=%S/Inputs/profile-symbol-list-2.text %S/Inputs/sample-profile-ext.proftext -o %t.2.output +; RUN: llvm-profdata merge -sample -extbinary -extbinary-write-vtable-type-prof -prof-sym-list %S/Inputs/profile-symbol-list-1.text %S/Inputs/sample-profile-ext.proftext -o %t.1.output +; RUN: llvm-profdata merge -sample -extbinary -extbinary-write-vtable-type-prof -prof-sym-list %S/Inputs/profile-symbol-list-2.text %S/Inputs/sample-profile-ext.proftext -o %t.2.output ; RUN: llvm-profdata merge -sample -extbinary -extbinary-write-vtable-type-prof %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: diff -b %S/Inputs/profile-symbol-list-ext.expected %t.4.output diff --git a/llvm/test/tools/llvm-profdata/roundtrip-compress.test b/llvm/test/tools/llvm-profdata/roundtrip-compress.test index cf0c344e7874b..699fd4829382f 100644 --- a/llvm/test/tools/llvm-profdata/roundtrip-compress.test +++ b/llvm/test/tools/llvm-profdata/roundtrip-compress.test @@ -1,10 +1,10 @@ REQUIRES: zlib # Round trip from text --> compressed extbinary --> text -RUN: llvm-profdata merge --sample --extbinary -compress-all-sections -output=%t.1.profdata %S/Inputs/sample-profile.proftext -RUN: llvm-profdata merge --sample --text -output=%t.1.proftext %t.1.profdata +RUN: llvm-profdata merge --sample --extbinary -compress-all-sections -o %t.1.profdata %S/Inputs/sample-profile.proftext +RUN: llvm-profdata merge --sample --text -o %t.1.proftext %t.1.profdata RUN: diff -b %t.1.proftext %S/Inputs/sample-profile.proftext # Round trip from text --> binary --> compressed extbinary --> text -RUN: llvm-profdata merge --sample --binary -output=%t.2.profdata %S/Inputs/sample-profile.proftext -RUN: llvm-profdata merge --sample --extbinary -compress-all-sections -output=%t.3.profdata %t.2.profdata -RUN: llvm-profdata merge --sample --text -output=%t.2.proftext %t.3.profdata +RUN: llvm-profdata merge --sample --binary -o %t.2.profdata %S/Inputs/sample-profile.proftext +RUN: llvm-profdata merge --sample --extbinary -compress-all-sections -o %t.3.profdata %t.2.profdata +RUN: llvm-profdata merge --sample --text -o %t.2.proftext %t.3.profdata RUN: diff -b %t.2.proftext %S/Inputs/sample-profile.proftext diff --git a/llvm/test/tools/llvm-profdata/roundtrip.test b/llvm/test/tools/llvm-profdata/roundtrip.test index eb55534763877..ab1b2d30cf5dd 100644 --- a/llvm/test/tools/llvm-profdata/roundtrip.test +++ b/llvm/test/tools/llvm-profdata/roundtrip.test @@ -1,24 +1,24 @@ RUN: llvm-profdata merge -o %t.0.profdata %S/Inputs/IR_profile.proftext -RUN: llvm-profdata show -o %t.0.proftext -all-functions -text %t.0.profdata +RUN: llvm-profdata show -o %t.0.proftext -all-functions -text %t.0.profdata RUN: diff -b %t.0.proftext %S/Inputs/IR_profile.proftext RUN: llvm-profdata merge -o %t.1.profdata %t.0.proftext -RUN: llvm-profdata show -o %t.1.proftext -all-functions -text %t.1.profdata +RUN: llvm-profdata show -o %t.1.proftext -all-functions -text %t.1.profdata RUN: diff -b %t.1.proftext %S/Inputs/IR_profile.proftext -RUN: llvm-profdata merge --sample --binary -output=%t.2.profdata %S/Inputs/sample-profile.proftext -RUN: llvm-profdata merge --sample --text -output=%t.2.proftext %t.2.profdata +RUN: llvm-profdata merge --sample --binary -o %t.2.profdata %S/Inputs/sample-profile.proftext +RUN: llvm-profdata merge --sample --text -o %t.2.proftext %t.2.profdata RUN: diff -b %t.2.proftext %S/Inputs/sample-profile.proftext # Round trip from text --> extbinary --> text -RUN: llvm-profdata merge --sample --extbinary -output=%t.3.profdata %S/Inputs/sample-profile.proftext -RUN: llvm-profdata merge --sample --text -output=%t.3.proftext %t.3.profdata +RUN: llvm-profdata merge --sample --extbinary -o %t.3.profdata %S/Inputs/sample-profile.proftext +RUN: llvm-profdata merge --sample --text -o %t.3.proftext %t.3.profdata RUN: diff -b %t.3.proftext %S/Inputs/sample-profile.proftext # Round trip from text --> binary --> extbinary --> text -RUN: llvm-profdata merge --sample --binary -output=%t.4.profdata %S/Inputs/sample-profile.proftext -RUN: llvm-profdata merge --sample --extbinary -output=%t.5.profdata %t.4.profdata -RUN: llvm-profdata merge --sample --text -output=%t.4.proftext %t.5.profdata +RUN: llvm-profdata merge --sample --binary -o %t.4.profdata %S/Inputs/sample-profile.proftext +RUN: llvm-profdata merge --sample --extbinary -o %t.5.profdata %t.4.profdata +RUN: llvm-profdata merge --sample --text -o %t.4.proftext %t.5.profdata RUN: diff -b %t.4.proftext %S/Inputs/sample-profile.proftext # Round trip from text --> extbinary --> text. # The vtable profile is supported by ext-binary profile but not raw binary profile format, # so we don't use raw binary profile format in this roundtrip. -RUN: llvm-profdata merge --sample --extbinary -extbinary-write-vtable-type-prof --output=%t.5.profdata %S/Inputs/sample-profile-ext.proftext -RUN: llvm-profdata merge --sample --text --output=%t.5.proftext %t.5.profdata +RUN: llvm-profdata merge --sample --extbinary -extbinary-write-vtable-type-prof -o %t.5.profdata %S/Inputs/sample-profile-ext.proftext +RUN: llvm-profdata merge --sample --text -o %t.5.proftext %t.5.profdata RUN: diff -b %t.5.proftext %S/Inputs/sample-profile-ext.proftext diff --git a/llvm/test/tools/llvm-profdata/sample-flatten-profile.test b/llvm/test/tools/llvm-profdata/sample-flatten-profile.test index f99021bc6b723..d55e3c47c99c3 100644 --- a/llvm/test/tools/llvm-profdata/sample-flatten-profile.test +++ b/llvm/test/tools/llvm-profdata/sample-flatten-profile.test @@ -1,8 +1,8 @@ -; RUN: llvm-profdata merge --sample --convert-sample-profile-layout=flat --text %S/Inputs/sample-flatten-profile.proftext -o - | FileCheck %s --match-full-lines --strict-whitespace -; RUN: llvm-profdata merge --sample --extbinary %S/Inputs/sample-flatten-profile.proftext -o %t2 && llvm-profdata merge --sample --convert-sample-profile-layout=flat --text %t2 -o - | FileCheck %s --match-full-lines --strict-whitespace +; RUN: llvm-profdata merge --sample --convert-sample-profile-layout flat --text %S/Inputs/sample-flatten-profile.proftext -o - | FileCheck %s --match-full-lines --strict-whitespace +; RUN: llvm-profdata merge --sample --extbinary %S/Inputs/sample-flatten-profile.proftext -o %t2 && llvm-profdata merge --sample --convert-sample-profile-layout flat --text %t2 -o - | FileCheck %s --match-full-lines --strict-whitespace -; RUN: llvm-profdata merge --sample --convert-sample-profile-layout=flat --text %S/Inputs/sample-flatten-profile-cs.proftext -o - | FileCheck %s --match-full-lines --strict-whitespace --check-prefix=CHECK-CS -; RUN: llvm-profdata merge --sample --extbinary %S/Inputs/sample-flatten-profile-cs.proftext -o %t2 && llvm-profdata merge --sample --convert-sample-profile-layout=flat --text %t2 -o - | FileCheck %s --match-full-lines --strict-whitespace --check-prefix=CHECK-CS +; RUN: llvm-profdata merge --sample --convert-sample-profile-layout flat --text %S/Inputs/sample-flatten-profile-cs.proftext -o - | FileCheck %s --match-full-lines --strict-whitespace --check-prefix=CHECK-CS +; RUN: llvm-profdata merge --sample --extbinary %S/Inputs/sample-flatten-profile-cs.proftext -o %t2 && llvm-profdata merge --sample --convert-sample-profile-layout flat --text %t2 -o - | FileCheck %s --match-full-lines --strict-whitespace --check-prefix=CHECK-CS ; CHECK:baz:169:10 ; CHECK-NEXT: 1: 10 diff --git a/llvm/test/tools/llvm-profdata/sample-fs.test b/llvm/test/tools/llvm-profdata/sample-fs.test index d3d038b17ab70..b52da76191cc1 100644 --- a/llvm/test/tools/llvm-profdata/sample-fs.test +++ b/llvm/test/tools/llvm-profdata/sample-fs.test @@ -2,7 +2,7 @@ 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 %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 @@ -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 %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 @@ -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 %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 @@ -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 -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: 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 - -o %t2-binary +RUN: llvm-profdata show --sample %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 - -o %t3-binary +RUN: llvm-profdata show --sample %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 diff --git a/llvm/test/tools/llvm-profdata/sample-hot-func-list.test b/llvm/test/tools/llvm-profdata/sample-hot-func-list.test index 91a8d817d55f6..e66e7db8bc1d8 100644 --- a/llvm/test/tools/llvm-profdata/sample-hot-func-list.test +++ b/llvm/test/tools/llvm-profdata/sample-hot-func-list.test @@ -21,7 +21,7 @@ ; CS-NEXT: 500853 (25.44%) 74946 20 main:3.1 @ _Z5funcBi:1 @ _Z8funcLeafi -; RUN: llvm-profdata show --sample --topn=2 %S/Inputs/sample-hot-func-list.proftext | FileCheck %s --match-full-lines --strict-whitespace --check-prefix=TOPN +; RUN: llvm-profdata show --sample --topn 2 %S/Inputs/sample-hot-func-list.proftext | FileCheck %s --match-full-lines --strict-whitespace --check-prefix=TOPN ; TOPN:8 out of 10 functions with profile (80.00%) are considered hot functions (max sample >= 470). ; TOPN-NEXT:355251 out of 356026 profile counts (99.78%) are from hot functions. @@ -29,7 +29,7 @@ ; TOPN-NEXT: 184019 (51.69%) 2300 534 main ; TOPN-NEXT: 97401 (27.36%) 10640 3035 Func3 -; RUN: llvm-profdata show --sample --topn=1 %S/Inputs/cs-sample.proftext | FileCheck %s --match-full-lines --strict-whitespace --check-prefix=CS-TOPN +; RUN: llvm-profdata show -sample --topn 1 %S/Inputs/cs-sample.proftext | FileCheck %s --match-full-lines --strict-whitespace --check-prefix=CS-TOPN ; CS-TOPN:2 out of 8 functions with profile (25.00%) are considered hot functions (max sample >= 23324). ; CS-TOPN-NEXT:1968152 out of 1968919 profile counts (99.96%) are from hot functions. diff --git a/llvm/test/tools/llvm-profdata/sample-overlap.test b/llvm/test/tools/llvm-profdata/sample-overlap.test index 859b705e5f3bd..36123f7fac3b2 100644 --- a/llvm/test/tools/llvm-profdata/sample-overlap.test +++ b/llvm/test/tools/llvm-profdata/sample-overlap.test @@ -40,7 +40,7 @@ ; OVERLAP1: hot blocks unique in base profile: 0 ; OVERLAP1: hot blocks unique in test profile: 0 -; RUN: llvm-profdata overlap --sample --similarity-cutoff=800000 %S/Inputs/sample-overlap-0.proftext %S/Inputs/sample-overlap-2.proftext | FileCheck %s --check-prefix=OVERLAP2 --match-full-lines --strict-whitespace +; RUN: llvm-profdata overlap --sample --similarity-cutoff 800000 %S/Inputs/sample-overlap-0.proftext %S/Inputs/sample-overlap-2.proftext | FileCheck %s --check-prefix=OVERLAP2 --match-full-lines --strict-whitespace ; OVERLAP2:Program level: ; OVERLAP2: Whole program profile similarity: 63.720% ; OVERLAP2: Whole program sample overlap: 29.649% @@ -65,7 +65,7 @@ ; OVERLAP2:78.15% 26.29% 48.09% 9.98% 0.00% 0.00% 10896 1087 main ; OVERLAP2:10.31% 34.76% 75.55% 100.00% 0.00% 0.00% 1437 1437 _Z3bari -; RUN: llvm-profdata overlap --sample --value-cutoff=1000 %S/Inputs/sample-overlap-0.proftext %S/Inputs/sample-overlap-3.proftext | FileCheck %s --check-prefix=OVERLAP3 --match-full-lines --strict-whitespace +; RUN: llvm-profdata overlap --sample --value-cutoff 1000 %S/Inputs/sample-overlap-0.proftext %S/Inputs/sample-overlap-3.proftext | FileCheck %s --check-prefix=OVERLAP3 --match-full-lines --strict-whitespace ; OVERLAP3:Program level: ; OVERLAP3: Whole program profile similarity: 14.301% ; OVERLAP3: Whole program sample overlap: 6.040% @@ -90,7 +90,7 @@ ; OVERLAP3:10.31% 11.02% 99.29% 100.00% 0.00% 0.00% 1437 1437 _Z3bari ; OVERLAP3:0.00% 83.54% 0.00% 0.00% 0.00% 100.00% 0 10896 main2 -; RUN: llvm-profdata overlap --sample --function=main %S/Inputs/sample-overlap-0.proftext %S/Inputs/sample-overlap-4.proftext | FileCheck %s --check-prefix=OVERLAP4 --match-full-lines --strict-whitespace +; RUN: llvm-profdata overlap --sample --function main %S/Inputs/sample-overlap-0.proftext %S/Inputs/sample-overlap-4.proftext | FileCheck %s --check-prefix=OVERLAP4 --match-full-lines --strict-whitespace ; OVERLAP4:Program level: ; OVERLAP4: Whole program profile similarity: 17.302% ; OVERLAP4: Whole program sample overlap: 8.134% diff --git a/llvm/test/tools/llvm-profdata/sample-profile-basic.test b/llvm/test/tools/llvm-profdata/sample-profile-basic.test index 0b0d37aac36cf..bf501f42883f2 100644 --- a/llvm/test/tools/llvm-profdata/sample-profile-basic.test +++ b/llvm/test/tools/llvm-profdata/sample-profile-basic.test @@ -9,7 +9,7 @@ SHOW1-DAG: Function: _Z3bari: 20301, 1437, 1 sampled lines SHOW1-DAG: 1: 1437 2- Show only bar -RUN: llvm-profdata show --sample --function=_Z3bari %p/Inputs/sample-profile.proftext | FileCheck %s --check-prefix=SHOW2 +RUN: llvm-profdata show --sample --function _Z3bari %p/Inputs/sample-profile.proftext | FileCheck %s --check-prefix=SHOW2 SHOW2: Function: _Z3bari: 20301, 1437, 1 sampled lines SHOW2: 1: 1437 SHOW2-NOT: Function: main: 184019, 0, 7 sampled lines diff --git a/llvm/test/tools/llvm-profdata/sample-profile-json.test b/llvm/test/tools/llvm-profdata/sample-profile-json.test index 9e96693faace6..d114b6056ed6e 100644 --- a/llvm/test/tools/llvm-profdata/sample-profile-json.test +++ b/llvm/test/tools/llvm-profdata/sample-profile-json.test @@ -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 --show-format json %p/Inputs/sample-profile.proftext | FileCheck %s --check-prefix=JSON JSON: [ JSON-NEXT: { JSON-NEXT: "name": "main", diff --git a/llvm/test/tools/llvm-profdata/sample-split-layout.test b/llvm/test/tools/llvm-profdata/sample-split-layout.test index 51091e9f25c02..ea6193b840b3b 100644 --- a/llvm/test/tools/llvm-profdata/sample-split-layout.test +++ b/llvm/test/tools/llvm-profdata/sample-split-layout.test @@ -1,6 +1,5 @@ -RUN: llvm-profdata merge --sample --extbinary --split-layout %p/Inputs/sample-profile.proftext -o %t-output - -RUN: llvm-profdata merge --sample --text --split-layout %t-output | FileCheck %s +RUN: llvm-profdata merge --sample --extbinary --split-layout %p/Inputs/sample-profile.proftext -o %t-o +RUN: llvm-profdata merge --sample --text --split-layout %t-o | FileCheck %s CHECK: main:184019:0 CHECK-NEXT: 4: 534 CHECK-NEXT: 4.2: 534 diff --git a/llvm/test/tools/llvm-profdata/show-order-error.proftext b/llvm/test/tools/llvm-profdata/show-order-error.proftext index 633f1a9949b6f..ff1d3f163d184 100644 --- a/llvm/test/tools/llvm-profdata/show-order-error.proftext +++ b/llvm/test/tools/llvm-profdata/show-order-error.proftext @@ -1,4 +1,4 @@ -# RUN: not llvm-profdata order %s --num-test-traces=10 2>&1 | FileCheck %s +# RUN: not llvm-profdata order %s --num-test-traces 10 2>&1 | FileCheck %s # CHECK: --num-test-traces must be smaller than the total number of traces diff --git a/llvm/test/tools/llvm-profdata/show-order.proftext b/llvm/test/tools/llvm-profdata/show-order.proftext index 28eb1b9b42af7..59750b2f42e8b 100644 --- a/llvm/test/tools/llvm-profdata/show-order.proftext +++ b/llvm/test/tools/llvm-profdata/show-order.proftext @@ -1,4 +1,4 @@ -# RUN: llvm-profdata order %s --num-test-traces=1 | FileCheck %s +# RUN: llvm-profdata order %s --num-test-traces 1 | FileCheck %s # CHECK: # Total area under the page fault curve: 4.000000e+00 diff --git a/llvm/test/tools/llvm-profdata/show-prof-info.test b/llvm/test/tools/llvm-profdata/show-prof-info.test index 2b38dee5d865e..24b919feb9362 100644 --- a/llvm/test/tools/llvm-profdata/show-prof-info.test +++ b/llvm/test/tools/llvm-profdata/show-prof-info.test @@ -1,5 +1,5 @@ REQUIRES: zlib -; RUN: llvm-profdata merge -sample -extbinary -use-md5 -compress-all-sections -gen-partial-profile -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 -use-md5 -compress-all-sections -gen-partial-profile -prof-sym-list %S/Inputs/profile-symbol-list-1.text %S/Inputs/sample-profile.proftext -o %t.1.output ; RUN: wc -c < %t.1.output > %t.txt ; RUN: llvm-profdata show -sample -show-sec-info-only %t.1.output >> %t.txt ; RUN: FileCheck %s --input-file=%t.txt diff --git a/llvm/test/tools/llvm-profdata/suppl-instr-with-sample-flatten.test b/llvm/test/tools/llvm-profdata/suppl-instr-with-sample-flatten.test index 4a394d7bce5c5..001a87a44ee19 100644 --- a/llvm/test/tools/llvm-profdata/suppl-instr-with-sample-flatten.test +++ b/llvm/test/tools/llvm-profdata/suppl-instr-with-sample-flatten.test @@ -3,7 +3,7 @@ with flattening. Test bar.cc:bar's counters will be set to PseudoHot. RUN: llvm-profdata merge \ -RUN: -supplement-instr-with-sample=%p/Inputs/flatten_sample.proftext \ +RUN: -supplement-instr-with-sample %p/Inputs/flatten_sample.proftext \ RUN: %p/Inputs/flatten_instr.proftext -o %t RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s --check-prefix=FLATTEN diff --git a/llvm/test/tools/llvm-profdata/suppl-instr-with-sample-static-func.test b/llvm/test/tools/llvm-profdata/suppl-instr-with-sample-static-func.test index 2d500df28a92b..dc043f4d1fadb 100644 --- a/llvm/test/tools/llvm-profdata/suppl-instr-with-sample-static-func.test +++ b/llvm/test/tools/llvm-profdata/suppl-instr-with-sample-static-func.test @@ -1,16 +1,16 @@ Some basic tests for supplementing instrumentation profile with sample profile for static funcs. -RUN: llvm-profdata merge -supplement-instr-with-sample=%p/Inputs/NoFUnique.afdotext -suppl-min-size-threshold=2 %p/Inputs/NoFUnique.proftext -o %t1 -RUN: llvm-profdata show -function=foo -counts %t1 | FileCheck %s +RUN: llvm-profdata merge -supplement-instr-with-sample %p/Inputs/NoFUnique.afdotext -suppl-min-size-threshold 2 %p/Inputs/NoFUnique.proftext -o %t1 +RUN: llvm-profdata show -function foo -counts %t1 | FileCheck %s -RUN: llvm-profdata merge -supplement-instr-with-sample=%p/Inputs/FUnique.afdotext -suppl-min-size-threshold=2 %p/Inputs/FUnique.proftext -o %t2 -RUN: llvm-profdata show -function=foo -counts %t2 | FileCheck %s +RUN: llvm-profdata merge -supplement-instr-with-sample %p/Inputs/FUnique.afdotext -suppl-min-size-threshold 2 %p/Inputs/FUnique.proftext -o %t2 +RUN: llvm-profdata show -function foo -counts %t2 | FileCheck %s -RUN: llvm-profdata merge -supplement-instr-with-sample=%p/Inputs/NoFUnique.afdotext -suppl-min-size-threshold=2 %p/Inputs/FUnique.proftext -o %t3 -RUN: llvm-profdata show -function=foo -counts %t3 | FileCheck %s +RUN: llvm-profdata merge -supplement-instr-with-sample %p/Inputs/NoFUnique.afdotext -suppl-min-size-threshold 2 %p/Inputs/FUnique.proftext -o %t3 +RUN: llvm-profdata show -function foo -counts %t3 | FileCheck %s -RUN: llvm-profdata merge -supplement-instr-with-sample=%p/Inputs/FUnique.afdotext -suppl-min-size-threshold=2 %p/Inputs/NoFUnique.proftext -o %t4 -RUN: llvm-profdata show -function=foo -counts %t4 | FileCheck %s +RUN: llvm-profdata merge -supplement-instr-with-sample %p/Inputs/FUnique.afdotext -suppl-min-size-threshold 2 %p/Inputs/NoFUnique.proftext -o %t4 +RUN: llvm-profdata show -function foo -counts %t4 | FileCheck %s CHECK: Counters: 3 CHECK-NEXT: Instrumentation level: diff --git a/llvm/test/tools/llvm-profdata/suppl-instr-with-sample.test b/llvm/test/tools/llvm-profdata/suppl-instr-with-sample.test index c22646e45849e..85a55bc879338 100644 --- a/llvm/test/tools/llvm-profdata/suppl-instr-with-sample.test +++ b/llvm/test/tools/llvm-profdata/suppl-instr-with-sample.test @@ -2,8 +2,8 @@ Some basic tests for supplementing instrumentation profile with sample profile. Test all of goo's counters will be set to PseudoHot. RUN: llvm-profdata merge \ -RUN: -supplement-instr-with-sample=%p/Inputs/mix_sample.proftext \ -RUN: -suppl-min-size-threshold=0 %p/Inputs/mix_instr.proftext -o %t +RUN: -supplement-instr-with-sample %p/Inputs/mix_sample.proftext \ +RUN: -suppl-min-size-threshold 0 %p/Inputs/mix_instr.proftext -o %t RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s --check-prefix=MIX1 MIX1: foo: @@ -22,9 +22,9 @@ MIX1-NEXT: Block counts: [3000, 1000, 2000, 500] Test when the zero counter ratio of foo is higher than zero-counter-threshold. RUN: llvm-profdata merge \ -RUN: -supplement-instr-with-sample=%p/Inputs/mix_sample.proftext \ -RUN: -suppl-min-size-threshold=0 -zero-counter-threshold=0.5 \ -RUN: -instr-prof-cold-threshold=30 %p/Inputs/mix_instr.proftext -o %t +RUN: -supplement-instr-with-sample %p/Inputs/mix_sample.proftext \ +RUN: -suppl-min-size-threshold 0 -zero-counter-threshold 0.5 \ +RUN: -instr-prof-cold-threshold 30 %p/Inputs/mix_instr.proftext -o %t RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s --check-prefix=MIX2 MIX2: foo: @@ -44,9 +44,9 @@ MIX2-NEXT: Block counts: [3000, 1000, 2000, 500] Test when the zero counter ratio of foo is lower than zero-counter-threshold. RUN: llvm-profdata merge \ -RUN: -supplement-instr-with-sample=%p/Inputs/mix_sample.proftext \ -RUN: -suppl-min-size-threshold=0 -zero-counter-threshold=0.7 \ -RUN: -instr-prof-cold-threshold=30 %p/Inputs/mix_instr.proftext -o %t +RUN: -supplement-instr-with-sample %p/Inputs/mix_sample.proftext \ +RUN: -suppl-min-size-threshold 0 -zero-counter-threshold 0.7 \ +RUN: -instr-prof-cold-threshold 30 %p/Inputs/mix_instr.proftext -o %t RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s --check-prefix=MIX3 MIX3: foo: @@ -66,9 +66,9 @@ MIX3-NEXT: Block counts: [3000, 1000, 2000, 500] Test foo's profile won't be adjusted because its size is smaller than suppl-min-size-threshold. RUN: llvm-profdata merge \ -RUN: -supplement-instr-with-sample=%p/Inputs/mix_sample.proftext \ -RUN: -suppl-min-size-threshold=2 -zero-counter-threshold=0.7 \ -RUN: -instr-prof-cold-threshold=30 %p/Inputs/mix_instr_small.proftext -o %t +RUN: -supplement-instr-with-sample %p/Inputs/mix_sample.proftext \ +RUN: -suppl-min-size-threshold 2 -zero-counter-threshold 0.7 \ +RUN: -instr-prof-cold-threshold 30 %p/Inputs/mix_instr_small.proftext -o %t RUN: llvm-profdata show %t -all-functions -counts | FileCheck %s --check-prefix=MIX4 MIX4: foo: @@ -87,8 +87,8 @@ MIX4-NEXT: Block counts: [0] Test profile summary won't be affected by pseudo counters. RUN: llvm-profdata merge \ -RUN: -supplement-instr-with-sample=%p/Inputs/mix_sample.proftext \ -RUN: -suppl-min-size-threshold=0 %p/Inputs/mix_instr.proftext -o %t +RUN: -supplement-instr-with-sample %p/Inputs/mix_sample.proftext \ +RUN: -suppl-min-size-threshold 0 %p/Inputs/mix_instr.proftext -o %t RUN: llvm-profdata show %t -detailed-summary | FileCheck %s --check-prefix=MIX5 MIX5: Instrumentation level: IR diff --git a/llvm/test/tools/llvm-profdata/text-format-errors.test b/llvm/test/tools/llvm-profdata/text-format-errors.test index 4a75edd70ff40..b5bda920c4857 100644 --- a/llvm/test/tools/llvm-profdata/text-format-errors.test +++ b/llvm/test/tools/llvm-profdata/text-format-errors.test @@ -5,7 +5,7 @@ RUN: not llvm-profdata show %p/Inputs/invalid-count-later.proftext 2>&1 | FileCh INVALID-COUNT-LATER-SHOW: error: {{.*}}invalid-count-later.proftext: malformed instrumentation profile data RUN: not llvm-profdata merge %p/Inputs/invalid-count-later.proftext %p/Inputs/invalid-count-later.proftext -o %t.out 2>&1 | FileCheck %s --check-prefix=INVALID-COUNT-LATER-MERGE -RUN: not llvm-profdata merge -failure-mode=all %p/Inputs/invalid-count-later.proftext %p/Inputs/invalid-count-later.proftext -o %t.out 2>&1 | FileCheck %s --check-prefix=INVALID-COUNT-LATER-MERGE +RUN: not llvm-profdata merge -failure-mode all %p/Inputs/invalid-count-later.proftext %p/Inputs/invalid-count-later.proftext -o %t.out 2>&1 | FileCheck %s --check-prefix=INVALID-COUNT-LATER-MERGE INVALID-COUNT-LATER-MERGE: warning: {{.*}}invalid-count-later.proftext: malformed instrumentation profile data INVALID-COUNT-LATER-MERGE-NEXT: warning: {{.*}}invalid-count-later.proftext: malformed instrumentation profile data INVALID-COUNT-LATER-MERGE-NEXT: error: no profile can be merged diff --git a/llvm/test/tools/llvm-profdata/trace-limit.proftext b/llvm/test/tools/llvm-profdata/trace-limit.proftext index 6b4f974add169..3ab0f19d6c5d4 100644 --- a/llvm/test/tools/llvm-profdata/trace-limit.proftext +++ b/llvm/test/tools/llvm-profdata/trace-limit.proftext @@ -1,14 +1,14 @@ -# RUN: llvm-profdata merge --temporal-profile-max-trace-length=0 %s -o %t.profdata +# RUN: llvm-profdata merge --temporal-profile-max-trace-length 0 %s -o %t.profdata # RUN: llvm-profdata show --temporal-profile-traces %t.profdata | FileCheck %s --check-prefix=NONE -# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size=2 %s %s %s %s -o %t.profdata -# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size=2 --temporal-profile-max-trace-length=0 %t.profdata -o %t.profdata +# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size 2 %s %s %s %s -o %t.profdata +# RUN: llvm-profdata merge --temporal-profile-trace-reservoir-size 2 --temporal-profile-max-trace-length 0 %t.profdata -o %t.profdata # RUN: llvm-profdata show --temporal-profile-traces %t.profdata | FileCheck %s --check-prefix=NONE -# RUN: llvm-profdata merge --temporal-profile-max-trace-length=2 %s -o %t.profdata +# RUN: llvm-profdata merge --temporal-profile-max-trace-length 2 %s -o %t.profdata # RUN: llvm-profdata show --temporal-profile-traces %t.profdata | FileCheck %s --check-prefixes=CHECK,SOME -# RUN: llvm-profdata merge --temporal-profile-max-trace-length=1000 %s -o %t.profdata +# RUN: llvm-profdata merge --temporal-profile-max-trace-length 1000 %s -o %t.profdata # RUN: llvm-profdata show --temporal-profile-traces %t.profdata | FileCheck %s --check-prefixes=CHECK,ALL # NONE: Temporal Profile Traces (samples=0 seen=0): diff --git a/llvm/test/tools/llvm-profdata/vtable-value-prof.test b/llvm/test/tools/llvm-profdata/vtable-value-prof.test index 5ed4a356e1041..185f630283a0a 100644 --- a/llvm/test/tools/llvm-profdata/vtable-value-prof.test +++ b/llvm/test/tools/llvm-profdata/vtable-value-prof.test @@ -4,15 +4,15 @@ RUN: llvm-profdata merge --keep-vtable-symbols %S/Inputs/vtable-value-prof.proftext -o %t/indexed.profdata ; Show indexed profiles -RUN: llvm-profdata show --function=main --ic-targets --show-vtables %t/indexed.profdata | FileCheck %s --check-prefix=INDEXED +RUN: llvm-profdata show --function main --ic-targets --show-vtables %t/indexed.profdata | FileCheck %s --check-prefix=INDEXED ; Show text profiles -RUN: llvm-profdata show --function=main --ic-targets --show-vtables --text %S/Inputs/vtable-value-prof.proftext | FileCheck %s --check-prefix=ICTEXT +RUN: llvm-profdata show --function main --ic-targets --show-vtables --text %S/Inputs/vtable-value-prof.proftext | FileCheck %s --check-prefix=ICTEXT ; Convert indexed profiles to its textual output and show it. RUN: llvm-profdata merge --keep-vtable-symbols --text -o %t/text-from-indexed.proftext %t/indexed.profdata -RUN: llvm-profdata show --function=main --ic-targets --show-vtables %t/text-from-indexed.proftext | FileCheck %s --check-prefix=INDEXED -RUN: llvm-profdata show --function=main --ic-targets --show-vtables --text %t/text-from-indexed.proftext | FileCheck %s --check-prefix=ICTEXT +RUN: llvm-profdata show --function main --ic-targets --show-vtables %t/text-from-indexed.proftext | FileCheck %s --check-prefix=INDEXED +RUN: llvm-profdata show --function main --ic-targets --show-vtables --text %t/text-from-indexed.proftext | FileCheck %s --check-prefix=ICTEXT INDEXED: Counters: INDEXED-NEXT: main: diff --git a/llvm/test/tools/llvm-profdata/weight-instr.test b/llvm/test/tools/llvm-profdata/weight-instr.test index 3f6979a071d29..92fb83838b2fe 100644 --- a/llvm/test/tools/llvm-profdata/weight-instr.test +++ b/llvm/test/tools/llvm-profdata/weight-instr.test @@ -1,13 +1,13 @@ Tests for weighted merge of instrumented profiles. 1- Merge the foo and bar profiles with unity weight and verify the combined output -RUN: llvm-profdata merge -instr -weighted-input=1,%p/Inputs/weight-instr-bar.profdata -weighted-input=1,%p/Inputs/weight-instr-foo.profdata -o %t +RUN: llvm-profdata merge -instr -weighted-input 1,%p/Inputs/weight-instr-bar.profdata -weighted-input 1,%p/Inputs/weight-instr-foo.profdata -o %t RUN: llvm-profdata show -instr -all-functions %t > %t.out1 RUN: FileCheck %s -check-prefixes=1X_1X_WEIGHT,1X_1X_WEIGHT-1 < %t.out1 RUN: FileCheck %s -check-prefixes=1X_1X_WEIGHT,1X_1X_WEIGHT-2 < %t.out1 RUN: FileCheck %s -check-prefixes=1X_1X_WEIGHT,1X_1X_WEIGHT-3 < %t.out1 RUN: FileCheck %s -check-prefixes=1X_1X_WEIGHT,1X_1X_WEIGHT-4 < %t.out1 -RUN: llvm-profdata merge -instr -weighted-input=1,%p/Inputs/weight-instr-bar.profdata %p/Inputs/weight-instr-foo.profdata -o %t +RUN: llvm-profdata merge -instr -weighted-input 1,%p/Inputs/weight-instr-bar.profdata %p/Inputs/weight-instr-foo.profdata -o %t RUN: llvm-profdata show -instr -all-functions %t > %t.out2 RUN: FileCheck %s -check-prefixes=1X_1X_WEIGHT,1X_1X_WEIGHT-1 < %t.out2 RUN: FileCheck %s -check-prefixes=1X_1X_WEIGHT,1X_1X_WEIGHT-2 < %t.out2 @@ -36,7 +36,7 @@ RUN: FileCheck %s -check-prefixes=1X_1X_WEIGHT,1X_1X_WEIGHT-4 < %t.out2 1X_1X_WEIGHT-NEXT: Maximum internal block count: 267914296 2- Merge the foo and bar profiles with weight 3x and 5x respectively and verify the combined output -RUN: llvm-profdata merge -instr -weighted-input=3,%p/Inputs/weight-instr-bar.profdata -weighted-input=5,%p/Inputs/weight-instr-foo.profdata -o %t +RUN: llvm-profdata merge -instr -weighted-input 3,%p/Inputs/weight-instr-bar.profdata -weighted-input 5,%p/Inputs/weight-instr-foo.profdata -o %t RUN: llvm-profdata show -instr -all-functions %t > %t.out3 RUN: FileCheck %s -check-prefixes=3X_5X_WEIGHT,3X_5X_WEIGHT-1 < %t.out3 RUN: FileCheck %s -check-prefixes=3X_5X_WEIGHT,3X_5X_WEIGHT-2 < %t.out3 @@ -65,15 +65,15 @@ RUN: FileCheck %s -check-prefixes=3X_5X_WEIGHT,3X_5X_WEIGHT-4 < %t.out3 3X_5X_WEIGHT-NEXT: Maximum internal block count: 1339571480 3- Bad merge: invalid weight -RUN: not llvm-profdata merge -instr -weighted-input=3,%p/Inputs/weight-instr-bar.profdata -weighted-input=0,%p/Inputs/weight-instr-foo.profdata -o %t.out 2>&1 | FileCheck %s -check-prefix=INVALID_WEIGHT -RUN: not llvm-profdata merge -instr -weighted-input=3,%p/Inputs/weight-instr-bar.profdata -weighted-input=0.75,%p/Inputs/weight-instr-foo.profdata -o %t.out 2>&1 | FileCheck %s -check-prefix=INVALID_WEIGHT -RUN: not llvm-profdata merge -instr -weighted-input=3,%p/Inputs/weight-instr-bar.profdata -weighted-input=-5,%p/Inputs/weight-instr-foo.profdata -o %t.out 2>&1 | FileCheck %s -check-prefix=INVALID_WEIGHT -RUN: not llvm-profdata merge -instr -weighted-input=3,%p/Inputs/weight-instr-bar.profdata -weighted-input=,%p/Inputs/weight-instr-foo.profdata -o %t.out 2>&1 | FileCheck %s -check-prefix=INVALID_WEIGHT -RUN: not llvm-profdata merge -instr -weighted-input=3,%p/Inputs/weight-instr-bar.profdata -weighted-input=%p/Inputs/weight-instr-foo.profdata -o %t.out 2>&1 | FileCheck %s -check-prefix=INVALID_WEIGHT +RUN: not llvm-profdata merge -instr -weighted-input 3,%p/Inputs/weight-instr-bar.profdata -weighted-input 0,%p/Inputs/weight-instr-foo.profdata -o %t.out 2>&1 | FileCheck %s -check-prefix=INVALID_WEIGHT +RUN: not llvm-profdata merge -instr -weighted-input 3,%p/Inputs/weight-instr-bar.profdata -weighted-input 0.75,%p/Inputs/weight-instr-foo.profdata -o %t.out 2>&1 | FileCheck %s -check-prefix=INVALID_WEIGHT +RUN: not llvm-profdata merge -instr -weighted-input 3,%p/Inputs/weight-instr-bar.profdata -weighted-input -5,%p/Inputs/weight-instr-foo.profdata -o %t.out 2>&1 | FileCheck %s -check-prefix=INVALID_WEIGHT +RUN: not llvm-profdata merge -instr -weighted-input 3,%p/Inputs/weight-instr-bar.profdata -weighted-input ,%p/Inputs/weight-instr-foo.profdata -o %t.out 2>&1 | FileCheck %s -check-prefix=INVALID_WEIGHT +RUN: not llvm-profdata merge -instr -weighted-input 3,%p/Inputs/weight-instr-bar.profdata -weighted-input %p/Inputs/weight-instr-foo.profdata -o %t.out 2>&1 | FileCheck %s -check-prefix=INVALID_WEIGHT INVALID_WEIGHT: error: input weight must be a positive integer 4- Bad merge: input path does not exist -RUN: not llvm-profdata merge -instr -weighted-input=3,%p/Inputs/does-not-exist.profdata -weighted-input=2,%p/Inputs/does-not-exist-either.profdata -o %t.out 2>&1 | FileCheck -DMSG=%errc_ENOENT %s -check-prefix=INVALID_INPUT +RUN: not llvm-profdata merge -instr -weighted-input 3,%p/Inputs/does-not-exist.profdata -weighted-input 2,%p/Inputs/does-not-exist-either.profdata -o %t.out 2>&1 | FileCheck -DMSG=%errc_ENOENT %s -check-prefix=INVALID_INPUT INVALID_INPUT: {{.*}}: {{.*}}does-not-exist.profdata: [[MSG]] 5- No inputs diff --git a/llvm/test/tools/llvm-profdata/weight-sample.test b/llvm/test/tools/llvm-profdata/weight-sample.test index 4c28a4a1ebf40..e5d74c372af10 100644 --- a/llvm/test/tools/llvm-profdata/weight-sample.test +++ b/llvm/test/tools/llvm-profdata/weight-sample.test @@ -1,8 +1,8 @@ Tests for weighted merge of sample profiles. 1- Merge the foo and bar profiles with unity weight and verify the combined output -RUN: llvm-profdata merge -sample -text -weighted-input=1,%p/Inputs/weight-sample-bar.proftext -weighted-input=1,%p/Inputs/weight-sample-foo.proftext -o - | FileCheck %s -check-prefix=1X_1X_WEIGHT -RUN: llvm-profdata merge -sample -text -weighted-input=1,%p/Inputs/weight-sample-bar.proftext %p/Inputs/weight-sample-foo.proftext -o - | FileCheck %s -check-prefix=1X_1X_WEIGHT +RUN: llvm-profdata merge -sample -text -weighted-input 1,%p/Inputs/weight-sample-bar.proftext -weighted-input 1,%p/Inputs/weight-sample-foo.proftext -o - | FileCheck %s -check-prefix=1X_1X_WEIGHT +RUN: llvm-profdata merge -sample -text -weighted-input 1,%p/Inputs/weight-sample-bar.proftext %p/Inputs/weight-sample-foo.proftext -o - | FileCheck %s -check-prefix=1X_1X_WEIGHT 1X_1X_WEIGHT-DAG: foo:1763288:35327 1X_1X_WEIGHT-DAG: 7: 35327 1X_1X_WEIGHT-DAG: 8: 35327 @@ -21,7 +21,7 @@ RUN: llvm-profdata merge -sample -text -weighted-input=1,%p/Inputs/weight-sample 1X_1X_WEIGHT-DAG: 25: 36666 2- Merge the foo and bar profiles with weight 3x and 5x respectively and verify the combined output -RUN: llvm-profdata merge -sample -text -weighted-input=3,%p/Inputs/weight-sample-bar.proftext -weighted-input=5,%p/Inputs/weight-sample-foo.proftext -o - | FileCheck %s -check-prefix=3X_5X_WEIGHT +RUN: llvm-profdata merge -sample -text -weighted-input 3,%p/Inputs/weight-sample-bar.proftext -weighted-input 5,%p/Inputs/weight-sample-foo.proftext -o - | FileCheck %s -check-prefix=3X_5X_WEIGHT 3X_5X_WEIGHT-DAG: foo:8816440:176635 3X_5X_WEIGHT-DAG: 7: 176635 3X_5X_WEIGHT-DAG: 8: 176635 @@ -40,15 +40,15 @@ RUN: llvm-profdata merge -sample -text -weighted-input=3,%p/Inputs/weight-sample 3X_5X_WEIGHT-DAG: 25: 109998 3- Bad merge: invalid weight -RUN: not llvm-profdata merge -sample -weighted-input=3,%p/Inputs/weight-sample-bar.proftext -weighted-input=0,%p/Inputs/weight-sample-foo.proftext -o %t.out 2>&1 | FileCheck %s -check-prefix=INVALID_WEIGHT -RUN: not llvm-profdata merge -sample -weighted-input=3,%p/Inputs/weight-sample-bar.proftext -weighted-input=0.75,%p/Inputs/weight-sample-foo.proftext -o %t.out 2>&1 | FileCheck %s -check-prefix=INVALID_WEIGHT -RUN: not llvm-profdata merge -sample -weighted-input=3,%p/Inputs/weight-sample-bar.proftext -weighted-input=-5,%p/Inputs/weight-sample-foo.proftext -o %t.out 2>&1 | FileCheck %s -check-prefix=INVALID_WEIGHT -RUN: not llvm-profdata merge -sample -weighted-input=3,%p/Inputs/weight-sample-bar.proftext -weighted-input=,%p/Inputs/weight-sample-foo.proftext -o %t.out 2>&1 | FileCheck %s -check-prefix=INVALID_WEIGHT -RUN: not llvm-profdata merge -sample -weighted-input=3,%p/Inputs/weight-sample-bar.proftext -weighted-input=%p/Inputs/weight-sample-foo.proftext -o %t.out 2>&1 | FileCheck %s -check-prefix=INVALID_WEIGHT +RUN: not llvm-profdata merge -sample -weighted-input 3,%p/Inputs/weight-sample-bar.proftext -weighted-input 0,%p/Inputs/weight-sample-foo.proftext -o %t.out 2>&1 | FileCheck %s -check-prefix=INVALID_WEIGHT +RUN: not llvm-profdata merge -sample -weighted-input 3,%p/Inputs/weight-sample-bar.proftext -weighted-input 0.75,%p/Inputs/weight-sample-foo.proftext -o %t.out 2>&1 | FileCheck %s -check-prefix=INVALID_WEIGHT +RUN: not llvm-profdata merge -sample -weighted-input 3,%p/Inputs/weight-sample-bar.proftext -weighted-input -5,%p/Inputs/weight-sample-foo.proftext -o %t.out 2>&1 | FileCheck %s -check-prefix=INVALID_WEIGHT +RUN: not llvm-profdata merge -sample -weighted-input 3,%p/Inputs/weight-sample-bar.proftext -weighted-input ,%p/Inputs/weight-sample-foo.proftext -o %t.out 2>&1 | FileCheck %s -check-prefix=INVALID_WEIGHT +RUN: not llvm-profdata merge -sample -weighted-input 3,%p/Inputs/weight-sample-bar.proftext -weighted-input %p/Inputs/weight-sample-foo.proftext -o %t.out 2>&1 | FileCheck %s -check-prefix=INVALID_WEIGHT INVALID_WEIGHT: error: input weight must be a positive integer 4- Bad merge: input path does not exist -RUN: not llvm-profdata merge -sample -weighted-input=3,%p/Inputs/does-not-exist.proftext -weighted-input=2,%p/Inputs/does-not-exist-either.proftext -o %t.out 2>&1 | FileCheck -DMSG=%errc_ENOENT %s -check-prefix=INVALID_INPUT +RUN: not llvm-profdata merge -sample -weighted-input 3,%p/Inputs/does-not-exist.proftext -weighted-input 2,%p/Inputs/does-not-exist-either.proftext -o %t.out 2>&1 | FileCheck -DMSG=%errc_ENOENT %s -check-prefix=INVALID_INPUT INVALID_INPUT: {{.*}}: {{.*}}does-not-exist.proftext: [[MSG]] 5- No inputs diff --git a/llvm/test/tools/llvm-profgen/afdo-with-vtable-pie.test b/llvm/test/tools/llvm-profgen/afdo-with-vtable-pie.test index dbef3aac66786..37ca02ad91717 100644 --- a/llvm/test/tools/llvm-profgen/afdo-with-vtable-pie.test +++ b/llvm/test/tools/llvm-profgen/afdo-with-vtable-pie.test @@ -3,7 +3,7 @@ RUN: --data-access-perftrace=%p/Inputs/pie-dap-perf.txt \ RUN: --binary=%p/Inputs/dap-pie.bin --format=text --pid=1725662 \ RUN: -ignore-stack-samples -use-dwarf-correlation -o %t.afdo -RUN: llvm-profdata show --sample --function=_Z9loop_funciii %t.afdo 2>&1 | FileCheck %s --dump-input=always +RUN: llvm-profdata show --sample --function _Z9loop_funciii %t.afdo 2>&1 | FileCheck %s --dump-input=always RUN: not llvm-profgen --perfscript=%p/Inputs/pie-lbr-perf.script \ RUN: --data-access-perftrace=%p/Inputs/pie-dap-perf.txt \ diff --git a/llvm/test/tools/llvm-profgen/afdo-with-vtable.test b/llvm/test/tools/llvm-profgen/afdo-with-vtable.test index 799d59d56526e..f703fea2c8cd9 100644 --- a/llvm/test/tools/llvm-profgen/afdo-with-vtable.test +++ b/llvm/test/tools/llvm-profgen/afdo-with-vtable.test @@ -2,7 +2,7 @@ RUN: llvm-profgen --perfscript=%p/Inputs/lbr-perf-for-dap.script --data-access-p RUN: --binary=%p/Inputs/dap.bin --format=text --pid=3446532 \ RUN: -ignore-stack-samples -use-dwarf-correlation -o %t.afdo -RUN: llvm-profdata show --sample --function=_Z9loop_funciii %t.afdo 2>&1 | FileCheck %s +RUN: llvm-profdata show --sample --function _Z9loop_funciii %t.afdo 2>&1 | FileCheck %s RUN: not llvm-profgen --perfscript=%p/Inputs/lbr-perf-for-dap.script --data-access-perftrace=%p/Inputs/dap-perf-trace.txt \ RUN: --binary=%p/Inputs/dap.bin --format=text --pid=3446532 \ diff --git a/llvm/test/tools/llvm-profgen/cs-extbinary.test b/llvm/test/tools/llvm-profgen/cs-extbinary.test index 654b7d4cf2fa4..d5e2b6a9a98e3 100644 --- a/llvm/test/tools/llvm-profgen/cs-extbinary.test +++ b/llvm/test/tools/llvm-profgen/cs-extbinary.test @@ -1,14 +1,14 @@ ; test for dwarf-based cs profile ; RUN: llvm-profgen --format=extbinary --perfscript=%S/Inputs/recursion-compression-noprobe.perfscript --binary=%S/Inputs/recursion-compression-noprobe.perfbin --output=%t1 --profile-summary-hot-count=0 --csspgo-preinliner=0 --gen-cs-nested-profile=0 -; RUN: llvm-profdata merge --sample --text --output=%t2 %t1 +; RUN: llvm-profdata merge --sample --text -o %t2 %t1 ; RUN: FileCheck %S/recursion-compression-noprobe.test --input-file %t2 -; RUN: llvm-profdata merge --sample --extbinary --output=%t3 %t2 && llvm-profdata merge --sample --text --output=%t4 %t3 +; RUN: llvm-profdata merge --sample --extbinary -o %t3 %t2 && llvm-profdata merge --sample --text -o %t4 %t3 ; RUN: diff -b %t2 %t4 ; test for probe-based cs profile ; RUN: llvm-profgen --format=extbinary --perfscript=%S/Inputs/recursion-compression-pseudoprobe.perfscript --binary=%S/Inputs/recursion-compression-pseudoprobe.perfbin --output=%t5 --profile-summary-hot-count=0 --csspgo-preinliner=0 --gen-cs-nested-profile=0 -; RUN: llvm-profdata merge --sample --text --output=%t6 %t5 +; RUN: llvm-profdata merge --sample --text -o %t6 %t5 ; RUN: FileCheck %S/recursion-compression-pseudoprobe.test --input-file %t6 -; RUN: llvm-profdata merge --sample --extbinary --output=%t7 %t6 && llvm-profdata merge --sample --text --output=%t8 %t7 +; RUN: llvm-profdata merge --sample --extbinary -o %t7 %t6 && llvm-profdata merge --sample --text -o %t8 %t7 ; RUN: diff -b %t6 %t8 diff --git a/llvm/test/tools/llvm-profgen/noinline-cs-noprobe.test b/llvm/test/tools/llvm-profgen/noinline-cs-noprobe.test index f4682787553d2..d95870eb3dd30 100644 --- a/llvm/test/tools/llvm-profgen/noinline-cs-noprobe.test +++ b/llvm/test/tools/llvm-profgen/noinline-cs-noprobe.test @@ -14,8 +14,8 @@ ; RUN: llvm-profgen --format=text --perfscript=%S/Inputs/noinline-cs-noprobe.perfscript --binary=%S/Inputs/noinline-cs-noprobe.perfbin --output=%t1 --profile-summary-cold-count=0 ; RUN: llvm-profgen --format=extbinary --perfscript=%S/Inputs/noinline-cs-noprobe.perfscript --binary=%S/Inputs/noinline-cs-noprobe.perfbin --output=%t2 --profile-summary-cold-count=0 -use-md5 ; RUN: llvm-profdata show --sample -show-sec-info-only %t2 | FileCheck %s --check-prefix=CHECK-MD5 -; RUN: llvm-profdata show --sample -detailed-summary --function=dummy %t1 > %t.summary -; RUN: llvm-profdata show --sample -detailed-summary --function=dummy %t2 > %t2.summary +; RUN: llvm-profdata show --sample -detailed-summary --function dummy %t1 > %t.summary +; RUN: llvm-profdata show --sample -detailed-summary --function dummy %t2 > %t2.summary ; RUN: diff -b %t.summary %t2.summary diff --git a/llvm/tools/llvm-profdata/CMakeLists.txt b/llvm/tools/llvm-profdata/CMakeLists.txt index e5aa858f3d39c..ed7df8528e4a8 100644 --- a/llvm/tools/llvm-profdata/CMakeLists.txt +++ b/llvm/tools/llvm-profdata/CMakeLists.txt @@ -2,14 +2,20 @@ set(LLVM_LINK_COMPONENTS Core Object ProfileData + Option Support ) +set(LLVM_TARGET_DEFINITIONS Opts.td) +tablegen(LLVM Opts.inc -gen-opt-parser-defs) +add_public_tablegen_target(ProfdataOptsTableGen) + add_llvm_tool(llvm-profdata llvm-profdata.cpp DEPENDS intrinsics_gen + ProfdataOptsTableGen ) target_link_libraries(llvm-profdata PRIVATE LLVMDebuginfod) diff --git a/llvm/tools/llvm-profdata/Opts.td b/llvm/tools/llvm-profdata/Opts.td new file mode 100644 index 0000000000000..ef49e1aa31d61 --- /dev/null +++ b/llvm/tools/llvm-profdata/Opts.td @@ -0,0 +1,366 @@ +include "llvm/Option/OptParser.td" + +def Show : SubCommand<"show", + "Takes a profile data file and displays the profiles. " + "See detailed documentation in " + "https://llvm.org/docs/CommandGuide/llvm-profdata.html" + "#profdata-show">; +def Order : SubCommand<"order", + "Reads temporal profiling traces from a profile and " + "outputs a function order that reduces page faults. " + "See detailed documentation in " + "https://llvm.org/docs/CommandGuide/llvm-profdata.html" + "#profdata-order">; +def Overlap : SubCommand<"overlap", + "Computes the overlap between two profiles. See " + "detailed documentation in " + "https://llvm.org/docs/CommandGuide/llvm-profdata.html" + "#profdata-overlap">; +def Merge : SubCommand<"merge", + "Takes several profiles and merge them together. See " + "detailed documentation in " + "https://llvm.org/docs/CommandGuide/llvm-profdata.html" + "#profdata-merge">; + +def help : Flag<["--"], "help">, HelpText<"Display this help">; +def version : Flag<["--"], "version">, HelpText<"Display the version">; + +def output : JoinedOrSeparate<["-", "--"], "output", + [Show, Order, Overlap, Merge]>, + MetaVarName<"">, + HelpText<"Output file">; +def : JoinedOrSeparate<["-"], "o", [Show, Order, Overlap, Merge]>, + Alias, HelpText<"Alias for --output">; + +def instr : Flag<["-", "--"], "instr", [Show, Overlap, Merge]>, + HelpText<"Instrumentation profile (default)">; +def sample : Flag<["-", "--"], "sample", [Show, Overlap, Merge]>, + HelpText<"Sample profile">; +def memory : Flag<["--"], "memory", [Show]>, + HelpText<"MemProf memory access profile">; + +def max_debug_info_correlation_warnings + : JoinedOrSeparate<["--"], "max-debug-info-correlation-warnings", + [Show, Merge]>, + HelpText<"Maximum number of warnings to emit when correlating profile " + "from debug info (0 = no limit)">, + MetaVarName<"">; +def profiled_binary + : JoinedOrSeparate<["--"], "profiled-binary", [Show, Merge]>, + HelpText<"Path to binary from which the profile was collected.">, + MetaVarName<"">; +def debug_info + : JoinedOrSeparate<["--"], "debug-info", [Show, Merge]>, + HelpText<"For show, read and extract profile metadata from debug info. " + "For merge, correlate the raw profile using the provided " + "debug info.">, + MetaVarName<"">; +def binary_file + : JoinedOrSeparate<["--"], "binary-file", [Merge]>, + HelpText<"Use the provided unstripped binary to correlate the raw " + "profile.">, + MetaVarName<"">; +def debug_file_directory + : JoinedOrSeparate<["--"], "debug-file-directory", + [Show, Order, Overlap, Merge]>, + HelpText<"Directories to search for object files by build ID">, + MetaVarName<"">; +def debuginfod : Flag<["--"], "debuginfod", [Merge]>, + HelpText<"Enable debuginfod">; +def correlate : JoinedOrSeparate<["--"], "correlate", + [Show, Order, Overlap, Merge]>, + HelpText<"Use debug-info or binary correlation to correlate " + "profiles with build id fetcher">, + MetaVarName<"">; +def function : JoinedOrSeparate<["-", "--"], "function", + [Show, Overlap, Merge]>, + HelpText<"Only functions matching the filter are shown or " + "merged.">, + MetaVarName<"">; + +def weighted_input + : JoinedOrSeparate<["-", "--"], "weighted-input", [Merge]>, + HelpText<",">, MetaVarName<",">; +def binary : Flag<["-", "--"], "binary", [Merge]>, + HelpText<"Binary encoding">; +def extbinary : Flag<["-", "--"], "extbinary", [Merge]>, + HelpText<"Extensible binary encoding (default)">; +def text : Flag<["-", "--"], "text", [Show, Merge]>, + HelpText<"Text output format">; +def gcc : Flag<["-", "--"], "gcc", [Merge]>, + HelpText<"GCC encoding (only meaningful for -sample)">; +def input_files + : JoinedOrSeparate<["-", "--"], "input-files", [Merge]>, + HelpText<"Path to file containing newline-separated " + "[,] entries">, + MetaVarName<"">; +def : JoinedOrSeparate<["-"], "f", [Merge]>, Alias, + HelpText<"Alias for --input-files">; +def dump_input_file_list : Flag<["-", "--"], "dump-input-file-list", [Merge]>, + HelpText<"Dump the list of input files and their " + "weights, then exit">; + +def remapping_file + : JoinedOrSeparate<["--"], "remapping-file", [Merge]>, + HelpText<"Symbol remapping file">, MetaVarName<"">; +def : JoinedOrSeparate<["-"], "r", [Merge]>, Alias, + HelpText<"Alias for --remapping-file">; +def use_md5 : Flag<["-", "--"], "use-md5", [Merge]>, + HelpText<"Use MD5 to represent strings in the name table " + "(only meaningful for -extbinary)">; + +def compress_all_sections + : Flag<["-", "--"], "compress-all-sections", [Merge]>, + HelpText<"Compress all sections when writing the profile (only " + "meaningful for -extbinary)">; + +def sample_merge_cold_context + : Flag<["-", "--"], "sample-merge-cold-context", [Merge]>, + HelpText<"Merge context sample profiles whose count is below cold " + "threshold">; + +def sample_trim_cold_context + : Flag<["-", "--"], "sample-trim-cold-context", [Merge]>, + HelpText<"Trim context sample profiles whose count is below cold " + "threshold">; + +def sample_frame_depth_for_cold_context + : JoinedOrSeparate<["--"], "sample-frame-depth-for-cold-context", + [Merge]>, + HelpText<"Keep the last K frames while merging cold profile. 1 means " + "the context-less base profile">, + MetaVarName<"">; +def output_size_limit + : JoinedOrSeparate<["--"], "output-size-limit", [Merge]>, + HelpText<"Trim cold functions until profile size is below specified " + "limit in bytes">, + MetaVarName<"">; +def gen_partial_profile + : Flag<["-", "--"], "gen-partial-profile", [Merge]>, + HelpText<"Generate a partial profile (only meaningful for -extbinary)">; + +def split_layout : Flag<["--"], "split-layout", [Merge]>, + HelpText<"Split the profile into sections with and without " + "inlined functions (only meaningful for " + "-extbinary)">; + +def supplement_instr_with_sample + : JoinedOrSeparate<["-", "--"], "supplement-instr-with-sample", [Merge]>, + HelpText<"Supplement an instr profile with a sample profile. Output " + "will be in instr format.">, + MetaVarName<"">; +def zero_counter_threshold + : JoinedOrSeparate<["-", "--"], "zero-counter-threshold", [Merge]>, + HelpText<"Ratio of zero counters required to drop a function when " + "supplementing instr profiles">, + MetaVarName<"">; +def suppl_min_size_threshold + : JoinedOrSeparate<["-", "--"], "suppl-min-size-threshold", [Merge]>, + HelpText<"Assume functions smaller than this threshold can be inlined " + "and will not be adjusted based on sample profile.">, + MetaVarName<"">; +def instr_prof_cold_threshold + : JoinedOrSeparate<["-", "--"], "instr-prof-cold-threshold", [Merge]>, + HelpText<"User specified cold threshold for instr profile to override " + "the cold threshold from profile summary.">, + MetaVarName<"">; +def temporal_profile_trace_reservoir_size + : JoinedOrSeparate<["--"], "temporal-profile-trace-reservoir-size", + [Merge]>, + HelpText<"Maximum number of stored temporal profile traces (default: " + "100)">, + MetaVarName<"">; +def temporal_profile_max_trace_length + : JoinedOrSeparate<["--"], "temporal-profile-max-trace-length", + [Merge]>, + HelpText<"Maximum length of a single temporal profile trace " + "(default: 10000)">, + MetaVarName<"">; +def no_function : JoinedOrSeparate<["--"], "no-function", [Merge]>, + HelpText<"Exclude functions matching the filter from the " + "output.">, + MetaVarName<"">; +def failure_mode + : JoinedOrSeparate<["-", "--"], "failure-mode", [Merge]>, + HelpText<"Failure mode: warn, any, or all">, + MetaVarName<"">; +def sparse + : Flag<["-", "--"], "sparse", [Merge]>, + HelpText<"Generate a sparse profile (only meaningful for -instr)">; + +def profile_isfs : Flag<["-", "--"], "profile-isfs", [Show, Merge]>, + HelpText<"Profile uses flow-sensitive discriminators">; + + +def generate_merged_base_profiles + : Flag<["-", "--"], "generate-merged-base-profiles", [Merge]>, + HelpText<"Generate merged base profiles when creating nested " + "context-sensitive profiles">; + + +def profile_symbol_list_cutoff + : JoinedOrSeparate<["--"], "profile-symbol-list-cutoff", [Merge]>, + HelpText<"Maximum number of symbols to keep in the profile symbol list">; + +def profile_summary_cutoff_hot + : JoinedOrSeparate<["--"], "profile-summary-cutoff-hot", + [Show, Merge]>, + HelpText<"Percentile (times 10000) for determining hot threshold">; + +def profile_summary_cutoff_cold + : JoinedOrSeparate<["-", "--"], "profile-summary-cutoff-cold", + [Show, Merge]>, + HelpText<"Percentile (times 10000) for determining cold threshold">; + +def profile_summary_hot_count + : JoinedOrSeparate<["--"], "profile-summary-hot-count", + [Show, Merge]>, + HelpText<"Override hot count derived from summary cutoffs">; + +def profile_summary_cold_count + : JoinedOrSeparate<["-", "--"], "profile-summary-cold-count", + [Show, Merge]>, + HelpText<"Override cold count derived from summary cutoffs">; + +def profile_summary_contextless + : JoinedOrSeparate<["--"], "profile-summary-contextless", + [Show, Merge]>, + HelpText<"Merge context profiles before calculating summary thresholds">; + +def profile_summary_huge_working_set_size_threshold + : JoinedOrSeparate<["--"], + "profile-summary-huge-working-set-size-threshold", + [Show, Merge]>, + HelpText<"Threshold for huge working set size used in profile summary">; + +def profile_summary_large_working_set_size_threshold + : JoinedOrSeparate<["--"], + "profile-summary-large-working-set-size-threshold", + [Show, Merge]>, + HelpText<"Threshold for large working set size used in profile summary">; + +def num_threads : JoinedOrSeparate<["-", "--"], "num-threads", [Merge]>, + HelpText<"Number of merge threads to use (default: autodetect)">, + MetaVarName<"">; +def : JoinedOrSeparate<["-"], "j", [Merge]>, Alias, + HelpText<"Alias for --num-threads">; +def prof_sym_list + : JoinedOrSeparate<["-", "--"], "prof-sym-list", [Merge]>, + HelpText<"Path to file containing the list of function symbols used to " + "populate profile symbol list">, + MetaVarName<"">; +def convert_sample_profile_layout + : JoinedOrSeparate<["--"], "convert-sample-profile-layout", [Merge]>, + HelpText<"Convert the generated profile to a new layout: nest or flat">, + MetaVarName<"">; +def drop_profile_symbol_list + : Flag<["--"], "drop-profile-symbol-list", [Merge]>, + HelpText<"Drop the profile symbol list when merging AutoFDO profiles " + "(only meaningful for -sample)">; + +def keep_vtable_symbols + : Flag<["--"], "keep-vtable-symbols", [Merge]>, + HelpText<"Keep the vtable symbols in indexed profiles">; + +def write_prev_version + : Flag<["--"], "write-prev-version", [Merge]>, + HelpText<"Write the previous version of indexed format for forward " + "compatibility.">; + +def memprof_version + : JoinedOrSeparate<["--"], "memprof-version", [Merge]>, + HelpText<"Specify the version of the memprof format to use (2, 3, or 4)">, + MetaVarName<"">; +def memprof_full_schema + : Flag<["--"], "memprof-full-schema", [Merge]>, + HelpText<"Use the full schema for serialization">; + +def memprof_random_hotness + : Flag<["-", "--"], "memprof-random-hotness", [Merge]>, + HelpText<"Generate random hotness values">; + +def memprof_random_hotness_seed + : JoinedOrSeparate<["-", "--"], "memprof-random-hotness-seed", [Merge]>, + HelpText<"Random hotness seed to use (0 to generate new seed)">, + MetaVarName<"">; + +def similarity_cutoff + : JoinedOrSeparate<["--"], "similarity-cutoff", [Overlap]>, + HelpText<"List overlapped functions with similarities below the cutoff " + "(percentage times 10000).">, + MetaVarName<"">; +def cs : Flag<["-", "--"], "cs", [Overlap]>, + HelpText<"For context sensitive PGO counts. Does not work with " + "CSSPGO.">; +def value_cutoff + : JoinedOrSeparate<["-", "--"], "value-cutoff", [Show, Overlap]>, + HelpText<"Cutoff value used for filtering. Meaning depends on subcommand">, + MetaVarName<"">; + +def counts : Flag<["-", "--"], "counts", [Show]>, + HelpText<"Show counter values for shown functions">; +def show_format + : JoinedOrSeparate<["--"], "show-format", [Show]>, + HelpText<"Emit output in the selected format: text, json, or yaml">, + MetaVarName<"">; +def json : Flag<["--"], "json", [Show]>, + HelpText<"Show sample profile data in JSON format " + "(deprecated, use --show-format=json)">; +def ic_targets : Flag<["-", "--"], "ic-targets", [Show]>, + HelpText<"Show indirect call site target values">; +def show_vtables : Flag<["--"], "show-vtables", [Show]>, + HelpText<"Show vtable names for shown functions">; +def extbinary_write_vtable_type_prof + : Flag<["-", "--"], "extbinary-write-vtable-type-prof", [Merge]>, + HelpText<"Include vtable type profile data in ext-binary sample profile">; + +def memop_sizes : Flag<["-", "--"], "memop-sizes", [Show]>, + HelpText<"Show profiled sizes of memory intrinsic calls">; +def detailed_summary : Flag<["-", "--"], "detailed-summary", [Show]>, + HelpText<"Show detailed profile summary">; +def detailed_summary_cutoffs + : JoinedOrSeparate<["--"], "detailed-summary-cutoffs", [Show]>, + HelpText<"Cutoff percentages (times 10000) for generating detailed " + "summary">, + MetaVarName<"">; +def hot_func_list : Flag<["--"], "hot-func-list", [Show]>, + HelpText<"Show profile summary of a list of hot functions">; +def all_functions : Flag<["-", "--"], "all-functions", [Show]>, + HelpText<"Details for each and every function">; +def showcs : Flag<["-", "--"], "showcs", [Show]>, + HelpText<"Show context sensitive counts">; +def topn : JoinedOrSeparate<["--"], "topn", [Show]>, + HelpText<"Show the list of functions with the largest internal counts">, + MetaVarName<"">; +def list_below_cutoff + : Flag<["-", "--"], "list-below-cutoff", [Show]>, + HelpText<"Only output names of functions whose max count values are " + "below the cutoff value">; +def show_prof_sym_list + : Flag<["-", "--"], "show-prof-sym-list", [Show]>, + HelpText<"Show profile symbol list if it exists in the profile.">; +def show_sec_info_only + : Flag<["-", "--"], "show-sec-info-only", [Show]>, + HelpText<"Show the information of each section in the sample profile " + "(extbinary sample profiles only)">; +def binary_ids : Flag<["--"], "binary-ids", [Show]>, + HelpText<"Show binary ids in the profile.">; +def temporal_profile_traces + : Flag<["--"], "temporal-profile-traces", [Show]>, + HelpText<"Show temporal profile traces in the profile.">; +def covered : Flag<["--"], "covered", [Show]>, + HelpText<"Show only the functions that have been executed.">; +def profile_version : Flag<["--"], "profile-version", [Show]>, + HelpText<"Show profile version.">; + +def num_test_traces + : JoinedOrSeparate<["--"], "num-test-traces", [Order]>, + HelpText<"Keep aside the last traces when computing " + "function order to evaluate that order">, + MetaVarName<"">; + +def fs_discriminator_pass + : Joined<["-", "--"], "fs-discriminator-pass=", [Show, Overlap, Merge]>, + Values<"base,pass1,pass2,pass3,passlast">, + HelpText<"Zero out the discriminator bits for the FS discriminator " + "pass beyond this value.">; diff --git a/llvm/tools/llvm-profdata/llvm-profdata.cpp b/llvm/tools/llvm-profdata/llvm-profdata.cpp index 74c4732ca129a..ffeaf422b8204 100644 --- a/llvm/tools/llvm-profdata/llvm-profdata.cpp +++ b/llvm/tools/llvm-profdata/llvm-profdata.cpp @@ -14,9 +14,14 @@ #include "llvm/ADT/SmallSet.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" +#include "llvm/ADT/StringSwitch.h" #include "llvm/Debuginfod/HTTPClient.h" #include "llvm/IR/LLVMContext.h" #include "llvm/Object/Binary.h" +#include "llvm/Option/Arg.h" +#include "llvm/Option/ArgList.h" +#include "llvm/Option/OptTable.h" +#include "llvm/Option/Option.h" #include "llvm/ProfileData/DataAccessProf.h" #include "llvm/ProfileData/InstrProfCorrelator.h" #include "llvm/ProfileData/InstrProfReader.h" @@ -36,6 +41,7 @@ #include "llvm/Support/Format.h" #include "llvm/Support/FormattedStream.h" #include "llvm/Support/InitLLVM.h" +#include "llvm/Support/LLVMDriver.h" #include "llvm/Support/MD5.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Path.h" @@ -47,35 +53,13 @@ #include "llvm/Support/raw_ostream.h" #include #include +#include #include using namespace llvm; +using namespace llvm::opt; using ProfCorrelatorKind = InstrProfCorrelator::ProfCorrelatorKind; -// https://llvm.org/docs/CommandGuide/llvm-profdata.html has documentations -// on each subcommand. -cl::SubCommand ShowSubcommand( - "show", - "Takes a profile data file and displays the profiles. See detailed " - "documentation in " - "https://llvm.org/docs/CommandGuide/llvm-profdata.html#profdata-show"); -cl::SubCommand OrderSubcommand( - "order", - "Reads temporal profiling traces from a profile and outputs a function " - "order that reduces the number of page faults for those traces. See " - "detailed documentation in " - "https://llvm.org/docs/CommandGuide/llvm-profdata.html#profdata-order"); -cl::SubCommand OverlapSubcommand( - "overlap", - "Computes and displays the overlap between two profiles. See detailed " - "documentation in " - "https://llvm.org/docs/CommandGuide/llvm-profdata.html#profdata-overlap"); -cl::SubCommand MergeSubcommand( - "merge", - "Takes several profiles and merge them together. See detailed " - "documentation in " - "https://llvm.org/docs/CommandGuide/llvm-profdata.html#profdata-merge"); - namespace { enum ProfileKinds { instr, sample, memory }; enum FailureMode { warnOnly, failIfAnyAreInvalid, failIfAllAreInvalid }; @@ -90,408 +74,132 @@ enum ProfileFormat { }; enum class ShowFormat { Text, Json, Yaml }; -} // namespace -// Common options. -cl::opt OutputFilename("output", cl::value_desc("output"), - cl::init("-"), cl::desc("Output file"), - cl::sub(ShowSubcommand), - cl::sub(OrderSubcommand), - cl::sub(OverlapSubcommand), - cl::sub(MergeSubcommand)); -// NOTE: cl::alias must not have cl::sub(), since aliased option's cl::sub() -// will be used. llvm::cl::alias::done() method asserts this condition. -static cl::alias OutputFilenameA("o", cl::desc("Alias for --output"), - cl::aliasopt(OutputFilename)); - -// Options common to at least two commands. -static cl::opt ProfileKind( - cl::desc("Profile kind:"), cl::sub(MergeSubcommand), - cl::sub(OverlapSubcommand), cl::init(instr), - cl::values(clEnumVal(instr, "Instrumentation profile (default)"), - clEnumVal(sample, "Sample profile"))); -static cl::opt Filename(cl::Positional, - cl::desc(""), - cl::sub(ShowSubcommand), - cl::sub(OrderSubcommand)); -static cl::opt MaxDbgCorrelationWarnings( - "max-debug-info-correlation-warnings", - cl::desc("The maximum number of warnings to emit when correlating " - "profile from debug info (0 = no limit)"), - cl::sub(MergeSubcommand), cl::sub(ShowSubcommand), cl::init(5)); -static cl::opt ProfiledBinary( - "profiled-binary", cl::init(""), - cl::desc("Path to binary from which the profile was collected."), - cl::sub(ShowSubcommand), cl::sub(MergeSubcommand)); -static cl::opt DebugInfoFilename( - "debug-info", cl::init(""), - cl::desc( - "For show, read and extract profile metadata from debug info and show " - "the functions it found. For merge, use the provided debug info to " - "correlate the raw profile."), - cl::sub(ShowSubcommand), cl::sub(MergeSubcommand)); -static cl::opt - BinaryFilename("binary-file", cl::init(""), - cl::desc("For merge, use the provided unstripped binary to " - "correlate the raw profile."), - cl::sub(MergeSubcommand)); -static cl::list DebugFileDirectory( - "debug-file-directory", - cl::desc("Directories to search for object files by build ID")); -static cl::opt DebugInfod("debuginfod", cl::init(false), cl::Hidden, - cl::sub(MergeSubcommand), - cl::desc("Enable debuginfod")); -static cl::opt BIDFetcherProfileCorrelate( - "correlate", - cl::desc("Use debug-info or binary correlation to correlate profiles with " - "build id fetcher"), - cl::init(InstrProfCorrelator::NONE), - cl::values(clEnumValN(InstrProfCorrelator::NONE, "", - "No profile correlation"), - clEnumValN(InstrProfCorrelator::DEBUG_INFO, "debug-info", - "Use debug info to correlate"), - clEnumValN(InstrProfCorrelator::BINARY, "binary", - "Use binary to correlate"))); -static cl::opt FuncNameFilter( - "function", - cl::desc("Only functions matching the filter are shown in the output. For " - "overlapping CSSPGO, this takes a function name with calling " - "context."), - cl::sub(ShowSubcommand), cl::sub(OverlapSubcommand), - cl::sub(MergeSubcommand)); - -// TODO: Consider creating a template class (e.g., MergeOption, ShowOption) to -// factor out the common cl::sub in cl::opt constructor for subcommand-specific -// options. - -// Options specific to merge subcommand. -static cl::list InputFilenames(cl::Positional, - cl::sub(MergeSubcommand), - cl::desc("")); -static cl::list - WeightedInputFilenames("weighted-input", cl::sub(MergeSubcommand), - cl::desc(",")); -static cl::opt OutputFormat( - cl::desc("Format of output profile"), cl::sub(MergeSubcommand), - cl::init(PF_Ext_Binary), - cl::values(clEnumValN(PF_Binary, "binary", "Binary encoding"), - clEnumValN(PF_Ext_Binary, "extbinary", - "Extensible binary encoding " - "(default)"), - clEnumValN(PF_Text, "text", "Text encoding"), - clEnumValN(PF_GCC, "gcc", - "GCC encoding (only meaningful for -sample)"))); -static cl::opt - InputFilenamesFile("input-files", cl::init(""), cl::sub(MergeSubcommand), - cl::desc("Path to file containing newline-separated " - "[,] entries")); -static cl::alias InputFilenamesFileA("f", cl::desc("Alias for --input-files"), - cl::aliasopt(InputFilenamesFile)); -static cl::opt DumpInputFileList( - "dump-input-file-list", cl::init(false), cl::Hidden, - cl::sub(MergeSubcommand), - cl::desc("Dump the list of input files and their weights, then exit")); -static cl::opt RemappingFile("remapping-file", - cl::value_desc("file"), - cl::sub(MergeSubcommand), - cl::desc("Symbol remapping file")); -static cl::alias RemappingFileA("r", cl::desc("Alias for --remapping-file"), - cl::aliasopt(RemappingFile)); -static cl::opt - UseMD5("use-md5", cl::init(false), cl::Hidden, - cl::desc("Choose to use MD5 to represent string in name table (only " - "meaningful for -extbinary)"), - cl::sub(MergeSubcommand)); -static cl::opt CompressAllSections( - "compress-all-sections", cl::init(false), cl::Hidden, - cl::sub(MergeSubcommand), - cl::desc("Compress all sections when writing the profile (only " - "meaningful for -extbinary)")); -static cl::opt SampleMergeColdContext( - "sample-merge-cold-context", cl::init(false), cl::Hidden, - cl::sub(MergeSubcommand), - cl::desc( - "Merge context sample profiles whose count is below cold threshold")); -static cl::opt SampleTrimColdContext( - "sample-trim-cold-context", cl::init(false), cl::Hidden, - cl::sub(MergeSubcommand), - cl::desc( - "Trim context sample profiles whose count is below cold threshold")); -static cl::opt SampleColdContextFrameDepth( - "sample-frame-depth-for-cold-context", cl::init(1), - cl::sub(MergeSubcommand), - cl::desc("Keep the last K frames while merging cold profile. 1 means the " - "context-less base profile")); -static cl::opt OutputSizeLimit( - "output-size-limit", cl::init(0), cl::Hidden, cl::sub(MergeSubcommand), - cl::desc("Trim cold functions until profile size is below specified " - "limit in bytes. This uses a heursitic and functions may be " - "excessively trimmed")); -static cl::opt GenPartialProfile( - "gen-partial-profile", cl::init(false), cl::Hidden, - cl::sub(MergeSubcommand), - cl::desc("Generate a partial profile (only meaningful for -extbinary)")); -static cl::opt SplitLayout( - "split-layout", cl::init(false), cl::Hidden, cl::sub(MergeSubcommand), - cl::desc("Split the profile to two sections with one containing sample " - "profiles with inlined functions and the other without (only " - "meaningful for -extbinary)")); -static cl::opt SupplInstrWithSample( - "supplement-instr-with-sample", cl::init(""), cl::Hidden, - cl::sub(MergeSubcommand), - cl::desc("Supplement an instr profile with sample profile, to correct " - "the profile unrepresentativeness issue. The sample " - "profile is the input of the flag. Output will be in instr " - "format (The flag only works with -instr)")); -static cl::opt ZeroCounterThreshold( - "zero-counter-threshold", cl::init(0.7), cl::Hidden, - cl::sub(MergeSubcommand), - cl::desc("For the function which is cold in instr profile but hot in " - "sample profile, if the ratio of the number of zero counters " - "divided by the total number of counters is above the " - "threshold, the profile of the function will be regarded as " - "being harmful for performance and will be dropped.")); -static cl::opt SupplMinSizeThreshold( - "suppl-min-size-threshold", cl::init(10), cl::Hidden, - cl::sub(MergeSubcommand), - cl::desc("If the size of a function is smaller than the threshold, " - "assume it can be inlined by PGO early inliner and it won't " - "be adjusted based on sample profile.")); -static cl::opt InstrProfColdThreshold( - "instr-prof-cold-threshold", cl::init(0), cl::Hidden, - cl::sub(MergeSubcommand), - cl::desc("User specified cold threshold for instr profile which will " - "override the cold threshold got from profile summary. ")); -// WARNING: This reservoir size value is propagated to any input indexed -// profiles for simplicity. Changing this value between invocations could -// result in sample bias. -static cl::opt TemporalProfTraceReservoirSize( - "temporal-profile-trace-reservoir-size", cl::init(100), - cl::sub(MergeSubcommand), - cl::desc("The maximum number of stored temporal profile traces (default: " - "100)")); -static cl::opt TemporalProfMaxTraceLength( - "temporal-profile-max-trace-length", cl::init(10000), - cl::sub(MergeSubcommand), - cl::desc("The maximum length of a single temporal profile trace " - "(default: 10000)")); -static cl::opt FuncNameNegativeFilter( - "no-function", cl::init(""), cl::sub(MergeSubcommand), - cl::desc("Exclude functions matching the filter from the output.")); - -static cl::opt - FailMode("failure-mode", cl::init(failIfAnyAreInvalid), - cl::desc("Failure mode:"), cl::sub(MergeSubcommand), - cl::values(clEnumValN(warnOnly, "warn", - "Do not fail and just print warnings."), - clEnumValN(failIfAnyAreInvalid, "any", - "Fail if any profile is invalid."), - clEnumValN(failIfAllAreInvalid, "all", - "Fail only if all profiles are invalid."))); - -static cl::opt OutputSparse( - "sparse", cl::init(false), cl::sub(MergeSubcommand), - cl::desc("Generate a sparse profile (only meaningful for -instr)")); -static cl::opt NumThreads( - "num-threads", cl::init(0), cl::sub(MergeSubcommand), - cl::desc("Number of merge threads to use (default: autodetect)")); -static cl::alias NumThreadsA("j", cl::desc("Alias for --num-threads"), - cl::aliasopt(NumThreads)); - -static cl::opt ProfileSymbolListFile( - "prof-sym-list", cl::init(""), cl::sub(MergeSubcommand), - cl::desc("Path to file containing the list of function symbols " - "used to populate profile symbol list")); - -static cl::opt ProfileLayout( - "convert-sample-profile-layout", - cl::desc("Convert the generated profile to a profile with a new layout"), - cl::sub(MergeSubcommand), cl::init(SPL_None), - cl::values( - clEnumValN(SPL_Nest, "nest", - "Nested profile, the input should be CS flat profile"), - clEnumValN(SPL_Flat, "flat", - "Profile with nested inlinee flatten out"))); - -static cl::opt DropProfileSymbolList( - "drop-profile-symbol-list", cl::init(false), cl::Hidden, - cl::sub(MergeSubcommand), - cl::desc("Drop the profile symbol list when merging AutoFDO profiles " - "(only meaningful for -sample)")); - -static cl::opt KeepVTableSymbols( - "keep-vtable-symbols", cl::init(false), cl::Hidden, - cl::sub(MergeSubcommand), - cl::desc("If true, keep the vtable symbols in indexed profiles")); - -// Temporary support for writing the previous version of the format, to enable -// some forward compatibility. -// TODO: Consider enabling this with future version changes as well, to ease -// deployment of newer versions of llvm-profdata. -static cl::opt DoWritePrevVersion( - "write-prev-version", cl::init(false), cl::Hidden, - cl::desc("Write the previous version of indexed format, to enable " - "some forward compatibility.")); - -static cl::opt MemProfVersionRequested( - "memprof-version", cl::Hidden, cl::sub(MergeSubcommand), - cl::desc("Specify the version of the memprof format to use"), - cl::init(memprof::Version3), - cl::values(clEnumValN(memprof::Version2, "2", "version 2"), - clEnumValN(memprof::Version3, "3", "version 3"), - clEnumValN(memprof::Version4, "4", "version 4"))); - -static cl::opt MemProfFullSchema( - "memprof-full-schema", cl::Hidden, cl::sub(MergeSubcommand), - cl::desc("Use the full schema for serialization"), cl::init(false)); - -static cl::opt - MemprofGenerateRandomHotness("memprof-random-hotness", cl::init(false), - cl::Hidden, cl::sub(MergeSubcommand), - cl::desc("Generate random hotness values")); -static cl::opt MemprofGenerateRandomHotnessSeed( - "memprof-random-hotness-seed", cl::init(0), cl::Hidden, - cl::sub(MergeSubcommand), - cl::desc("Random hotness seed to use (0 to generate new seed)")); - -// Options specific to overlap subcommand. -static cl::opt BaseFilename(cl::Positional, cl::Required, - cl::desc(""), - cl::sub(OverlapSubcommand)); -static cl::opt TestFilename(cl::Positional, cl::Required, - cl::desc(""), - cl::sub(OverlapSubcommand)); - -static cl::opt SimilarityCutoff( - "similarity-cutoff", cl::init(0), - cl::desc("For sample profiles, list function names (with calling context " - "for csspgo) for overlapped functions " - "with similarities below the cutoff (percentage times 10000)."), - cl::sub(OverlapSubcommand)); - -static cl::opt IsCS( - "cs", cl::init(false), - cl::desc("For context sensitive PGO counts. Does not work with CSSPGO."), - cl::sub(OverlapSubcommand)); - -static cl::opt OverlapValueCutoff( - "value-cutoff", cl::init(-1), - cl::desc( - "Function level overlap information for every function (with calling " - "context for csspgo) in test " - "profile with max count value greater than the parameter value"), - cl::sub(OverlapSubcommand)); - -// Options specific to show subcommand. -static cl::opt - ShowCounts("counts", cl::init(false), - cl::desc("Show counter values for shown functions"), - cl::sub(ShowSubcommand)); -static cl::opt - SFormat("show-format", cl::init(ShowFormat::Text), - cl::desc("Emit output in the selected format if supported"), - cl::sub(ShowSubcommand), - cl::values(clEnumValN(ShowFormat::Text, "text", - "emit normal text output (default)"), - clEnumValN(ShowFormat::Json, "json", "emit JSON"), - clEnumValN(ShowFormat::Yaml, "yaml", "emit YAML"))); -// TODO: Consider replacing this with `--show-format=text-encoding`. -static cl::opt - TextFormat("text", cl::init(false), - cl::desc("Show instr profile data in text dump format"), - cl::sub(ShowSubcommand)); -static cl::opt - JsonFormat("json", - cl::desc("Show sample profile data in the JSON format " - "(deprecated, please use --show-format=json)"), - cl::sub(ShowSubcommand)); -static cl::opt ShowIndirectCallTargets( - "ic-targets", cl::init(false), - cl::desc("Show indirect call site target values for shown functions"), - cl::sub(ShowSubcommand)); -static cl::opt - ShowVTables("show-vtables", cl::init(false), - cl::desc("Show vtable names for shown functions"), - cl::sub(ShowSubcommand)); -static cl::opt ShowMemOPSizes( - "memop-sizes", cl::init(false), - cl::desc("Show the profiled sizes of the memory intrinsic calls " - "for shown functions"), - cl::sub(ShowSubcommand)); -static cl::opt - ShowDetailedSummary("detailed-summary", cl::init(false), - cl::desc("Show detailed profile summary"), - cl::sub(ShowSubcommand)); -static cl::list DetailedSummaryCutoffs( - cl::CommaSeparated, "detailed-summary-cutoffs", - cl::desc( - "Cutoff percentages (times 10000) for generating detailed summary"), - cl::value_desc("800000,901000,999999"), cl::sub(ShowSubcommand)); -static cl::opt - ShowHotFuncList("hot-func-list", cl::init(false), - cl::desc("Show profile summary of a list of hot functions"), - cl::sub(ShowSubcommand)); -static cl::opt - ShowAllFunctions("all-functions", cl::init(false), - cl::desc("Details for each and every function"), - cl::sub(ShowSubcommand)); -static cl::opt ShowCS("showcs", cl::init(false), - cl::desc("Show context sensitive counts"), - cl::sub(ShowSubcommand)); -static cl::opt ShowProfileKind( - cl::desc("Profile kind supported by show:"), cl::sub(ShowSubcommand), - cl::init(instr), - cl::values(clEnumVal(instr, "Instrumentation profile (default)"), - clEnumVal(sample, "Sample profile"), - clEnumVal(memory, "MemProf memory access profile"))); -static cl::opt TopNFunctions( - "topn", cl::init(0), - cl::desc("Show the list of functions with the largest internal counts"), - cl::sub(ShowSubcommand)); -static cl::opt ShowValueCutoff( - "value-cutoff", cl::init(0), - cl::desc("Set the count value cutoff. Functions with the maximum count " - "less than this value will not be printed out. (Default is 0)"), - cl::sub(ShowSubcommand)); -static cl::opt OnlyListBelow( - "list-below-cutoff", cl::init(false), - cl::desc("Only output names of functions whose max count values are " - "below the cutoff value"), - cl::sub(ShowSubcommand)); -static cl::opt ShowProfileSymbolList( - "show-prof-sym-list", cl::init(false), - cl::desc("Show profile symbol list if it exists in the profile. "), - cl::sub(ShowSubcommand)); -static cl::opt ShowSectionInfoOnly( - "show-sec-info-only", cl::init(false), - cl::desc("Show the information of each section in the sample profile. " - "The flag is only usable when the sample profile is in " - "extbinary format"), - cl::sub(ShowSubcommand)); -static cl::opt ShowBinaryIds("binary-ids", cl::init(false), - cl::desc("Show binary ids in the profile. "), - cl::sub(ShowSubcommand)); -static cl::opt ShowTemporalProfTraces( - "temporal-profile-traces", - cl::desc("Show temporal profile traces in the profile."), - cl::sub(ShowSubcommand)); - -static cl::opt - ShowCovered("covered", cl::init(false), - cl::desc("Show only the functions that have been executed."), - cl::sub(ShowSubcommand)); - -static cl::opt ShowProfileVersion("profile-version", cl::init(false), - cl::desc("Show profile version. "), - cl::sub(ShowSubcommand)); - -// Options specific to order subcommand. -static cl::opt - NumTestTraces("num-test-traces", cl::init(0), - cl::desc("Keep aside the last traces in " - "the profile when computing the function order and " - "instead use them to evaluate that order"), - cl::sub(OrderSubcommand)); +enum ID { + OPT_INVALID = 0, +#define OPTION(PREFIXES, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, \ + VISIBILITY, PARAM, HELPTEXT, HELPTEXTSFORVARIANTS, METAVAR, \ + VALUES, SUBCOMMANDIDS_OFFSET) \ + OPT_##ID, +#include "Opts.inc" +#undef OPTION +}; + +#define OPTTABLE_STR_TABLE_CODE +#include "Opts.inc" +#undef OPTTABLE_STR_TABLE_CODE + +#define OPTTABLE_PREFIXES_TABLE_CODE +#include "Opts.inc" +#undef OPTTABLE_PREFIXES_TABLE_CODE + +#define OPTTABLE_SUBCOMMAND_IDS_TABLE_CODE +#include "Opts.inc" +#undef OPTTABLE_SUBCOMMAND_IDS_TABLE_CODE + +#define OPTTABLE_SUBCOMMANDS_CODE +#include "Opts.inc" +#undef OPTTABLE_SUBCOMMANDS_CODE + +static constexpr opt::OptTable::Info InfoTable[] = { +#define OPTION(...) LLVM_CONSTRUCT_OPT_INFO(__VA_ARGS__), +#include "Opts.inc" +#undef OPTION +}; + +class ProfdataOptTable : public opt::GenericOptTable { +public: + ProfdataOptTable() + : opt::GenericOptTable(OptionStrTable, OptionPrefixesTable, InfoTable, + /*IgnoreCase=*/false, OptionSubCommands, + OptionSubCommandIDsTable) { + setGroupedShortOptions(true); + setDashDashParsing(true); + } +}; + +static std::string ProgramName; + +static std::string OutputFilename = "-"; +static ProfileKinds ProfileKind = instr; +static std::string Filename; +static unsigned MaxDbgCorrelationWarnings = 5; +static std::string ProfiledBinary; +static std::string DebugInfoFilename; +static std::string BinaryFilename; +static std::vector DebugFileDirectory; +static bool DebugInfod = false; +static ProfCorrelatorKind BIDFetcherProfileCorrelate = + InstrProfCorrelator::NONE; +static std::string FuncNameFilter; + +static std::vector InputFilenames; +static std::vector WeightedInputFilenames; +static ProfileFormat OutputFormat = PF_Ext_Binary; +static std::string InputFilenamesFile; +static bool DumpInputFileList = false; +static std::string RemappingFile; +static bool UseMD5 = false; +static bool CompressAllSections = false; +static bool SampleMergeColdContext = false; +static bool SampleTrimColdContext = false; +static uint32_t SampleColdContextFrameDepth = 1; +static size_t OutputSizeLimit = 0; +static bool GenPartialProfile = false; +static bool SplitLayout = false; +static std::string SupplInstrWithSample; +static float ZeroCounterThreshold = 0.7f; +static unsigned SupplMinSizeThreshold = 10; +static unsigned InstrProfColdThreshold = 0; +static uint64_t TemporalProfTraceReservoirSize = 100; +static uint64_t TemporalProfMaxTraceLength = 10000; +static std::string FuncNameNegativeFilter; +static FailureMode FailMode = failIfAnyAreInvalid; +static bool OutputSparse = false; +static unsigned NumThreads = 0; +static std::string ProfileSymbolListFile; +static SampleProfileLayout ProfileLayout = SPL_None; +static bool DropProfileSymbolList = false; +static bool KeepVTableSymbols = false; +static bool DoWritePrevVersion = false; +static memprof::IndexedVersion MemProfVersionRequested = memprof::Version3; +static bool MemProfFullSchema = false; +static bool MemprofGenerateRandomHotness = false; +static unsigned MemprofGenerateRandomHotnessSeed = 0; + +static std::string BaseFilename; +static std::string TestFilename; +static unsigned long long SimilarityCutoff = 0; +static bool IsCS = false; +static unsigned long long OverlapValueCutoff = + std::numeric_limits::max(); + +static bool ShowCounts = false; +static ShowFormat SFormat = ShowFormat::Text; +static bool TextFormat = false; +static bool JsonFormat = false; +static bool ShowIndirectCallTargets = false; +static bool ShowVTables = false; +static bool ShowMemOPSizes = false; +static bool ShowDetailedSummary = false; +static std::vector DetailedSummaryCutoffs; +static bool ShowHotFuncList = false; +static bool ShowAllFunctions = false; +static bool ShowCS = false; +static ProfileKinds ShowProfileKind = instr; +static uint32_t TopNFunctions = 0; +static uint32_t ShowValueCutoff = 0; +static bool OnlyListBelow = false; +static bool ShowProfileSymbolList = false; +static bool ShowSectionInfoOnly = false; +static bool ShowBinaryIds = false; +static bool ShowTemporalProfTraces = false; +static bool ShowCovered = false; +static bool ShowProfileVersion = false; + +static unsigned NumTestTraces = 0; +static FSDiscriminatorPass FSDiscriminatorPassOption = PassLast; +} // namespace // We use this string to indicate that there are // multiple static functions map to the same name. @@ -637,7 +345,7 @@ class SymbolRemapper { return New.empty() ? Name : FunctionId(New); } }; -} +} // namespace struct WeightedFile { std::string Filename; @@ -973,8 +681,6 @@ static void mergeInstrProfile(const WeightedFileVector &Inputs, SymbolRemapper *Remapper, int MaxDbgCorrelationWarnings, const StringRef ProfiledBinary) { - const uint64_t TraceReservoirSize = TemporalProfTraceReservoirSize.getValue(); - const uint64_t MaxTraceLength = TemporalProfMaxTraceLength.getValue(); if (OutputFormat == PF_Compact_Binary) exitWithError("Compact Binary is deprecated"); if (OutputFormat != PF_Binary && OutputFormat != PF_Ext_Binary && @@ -1042,8 +748,8 @@ static void mergeInstrProfile(const WeightedFileVector &Inputs, SmallVector, 4> Contexts; for (unsigned I = 0; I < NumThreads; ++I) Contexts.emplace_back(std::make_unique( - OutputSparse, ErrorLock, WriterErrorCodes, TraceReservoirSize, - MaxTraceLength)); + OutputSparse, ErrorLock, WriterErrorCodes, + TemporalProfTraceReservoirSize, TemporalProfMaxTraceLength)); if (NumThreads == 1) { for (const auto &Input : Inputs) @@ -1171,21 +877,8 @@ const uint64_t HotPercentileIdx = 11; using sampleprof::FSDiscriminatorPass; -// Internal options to set FSDiscriminatorPass. Used in merge and show -// commands. -static cl::opt FSDiscriminatorPassOption( - "fs-discriminator-pass", cl::init(PassLast), cl::Hidden, - cl::desc("Zero out the discriminator bits for the FS discrimiantor " - "pass beyond this value. The enum values are defined in " - "Support/Discriminator.h"), - cl::values(clEnumVal(Base, "Use base discriminators only"), - clEnumVal(Pass1, "Use base and pass 1 discriminators"), - clEnumVal(Pass2, "Use base and pass 1-2 discriminators"), - clEnumVal(Pass3, "Use base and pass 1-3 discriminators"), - clEnumVal(PassLast, "Use all discriminator bits (default)"))); - static unsigned getDiscriminatorMask() { - return getN1Bits(getFSPassBitEnd(FSDiscriminatorPassOption.getValue())); + return getN1Bits(getFSPassBitEnd(FSDiscriminatorPassOption)); } /// Adjust the instr profile in \p WC based on the sample profile in @@ -1786,7 +1479,8 @@ static int merge_main(StringRef ProgName) { parseInputFilenamesFile(Buffer.get(), WeightedInputs); if (WeightedInputs.empty()) - exitWithError("no input files specified. See " + ProgName + " merge -help"); + exitWithError("no input files specified. See " + ProgName + + " merge --help"); if (DumpInputFileList) { for (auto &WF : WeightedInputs) @@ -3376,8 +3070,8 @@ static int showDebugInfoCorrelation(const std::string &Filename, static int show_main(StringRef ProgName) { if (Filename.empty() && DebugInfoFilename.empty()) exitWithError( - "the positional argument '' is required unless '--" + - DebugInfoFilename.ArgStr + "' is provided"); + "the positional argument '' is required unless " + "'--debug-info' is provided"); if (Filename == OutputFilename) { errs() << ProgName @@ -3424,8 +3118,8 @@ static int order_main() { ArrayRef Traces = Reader->getTemporalProfTraces(); if (NumTestTraces && NumTestTraces >= Traces.size()) exitWithError( - "--" + NumTestTraces.ArgStr + - " must be smaller than the total number of traces: expected: < " + + "--num-test-traces must be smaller than the total number of traces: " + "expected: < " + Twine(Traces.size()) + ", actual: " + Twine(NumTestTraces)); ArrayRef TestTraces = Traces.take_back(NumTestTraces); Traces = Traces.drop_back(NumTestTraces); @@ -3471,32 +3165,556 @@ static int order_main() { return 0; } -int main(int argc, const char *argv[]) { - InitLLVM X(argc, argv); - StringRef ProgName(sys::path::filename(argv[0])); +static void reportCmdLineError(const Twine &Message) { + WithColor::error(errs(), ProgramName) << Message << "\n"; +} + +template +static bool parseNumericOption(const opt::Arg *A, T &Value) { + if (!A) + return true; + StringRef V = A->getValue(); + T Parsed{}; + if (!llvm::to_integer(V, Parsed, 0)) { + if (!std::numeric_limits::is_signed && V == "-1") { + Value = std::numeric_limits::max(); + return true; + } + reportCmdLineError(Twine("invalid argument '") + V + "' for option '" + + A->getSpelling() + "'"); + return false; + } + Value = Parsed; + return true; +} + +static bool applyLibraryOptions(const opt::InputArgList &Args) { + SmallVector CLStrings; + CLStrings.push_back(ProgramName); + + auto AddFlag = [&](unsigned OptID, StringRef Spelling) { + if (Args.hasArg(OptID)) + CLStrings.push_back(Spelling.str()); + }; + auto AddUInt = [&](unsigned OptID, StringRef Spelling) -> bool { + if (const opt::Arg *A = Args.getLastArg(OptID)) { + uint64_t Value = 0; + if (!parseNumericOption(A, Value)) + return false; + CLStrings.push_back((Spelling + Twine("=") + Twine(Value)).str()); + } + return true; + }; + auto AddInt = [&](unsigned OptID, StringRef Spelling) -> bool { + if (const opt::Arg *A = Args.getLastArg(OptID)) { + int Value = 0; + if (!parseNumericOption(A, Value)) + return false; + CLStrings.push_back((Spelling + Twine("=") + Twine(Value)).str()); + } + return true; + }; + + AddFlag(OPT_profile_isfs, "--profile-isfs"); + AddFlag(OPT_generate_merged_base_profiles, "--generate-merged-base-profiles"); + if (!AddUInt(OPT_profile_symbol_list_cutoff, "--profile-symbol-list-cutoff")) + return false; + AddFlag(OPT_extbinary_write_vtable_type_prof, + "--extbinary-write-vtable-type-prof"); + + AddFlag(OPT_profile_summary_contextless, "--profile-summary-contextless"); + if (!AddInt(OPT_profile_summary_cutoff_hot, "--profile-summary-cutoff-hot")) + return false; + if (!AddInt(OPT_profile_summary_cutoff_cold, "--profile-summary-cutoff-cold")) + return false; + if (!AddUInt(OPT_profile_summary_hot_count, "--profile-summary-hot-count")) + return false; + if (!AddUInt(OPT_profile_summary_cold_count, "--profile-summary-cold-count")) + return false; + if (!AddUInt(OPT_profile_summary_huge_working_set_size_threshold, + "--profile-summary-huge-working-set-size-threshold")) + return false; + if (!AddUInt(OPT_profile_summary_large_working_set_size_threshold, + "--profile-summary-large-working-set-size-threshold")) + return false; + + if (CLStrings.size() == 1) + return true; + + SmallVector CLArgs; + for (std::string &S : CLStrings) + CLArgs.push_back(S.data()); + + return cl::ParseCommandLineOptions(CLArgs.size(), CLArgs.data(), + /*Overview=*/"", /*Errs=*/nullptr, + /*VFS=*/nullptr, + /*EnvVar=*/nullptr, + /*LongOptionsUseDoubleDash=*/false); +} + +static bool parseFloatOption(const opt::Arg *A, float &Value) { + if (!A) + return true; + StringRef V = A->getValue(); + double Parsed; + if (V.getAsDouble(Parsed)) { + reportCmdLineError(Twine("invalid argument '") + V + "' for option '" + + A->getSpelling() + "'"); + return false; + } + Value = static_cast(Parsed); + return true; +} + +static bool parseCutoffValues(const opt::InputArgList &Args, + std::vector &Cutoffs) { + Cutoffs.clear(); + for (const opt::Arg *A : Args.filtered(OPT_detailed_summary_cutoffs)) { + SmallVector Parts; + StringRef(A->getValue()) + .split(Parts, ',', /*MaxSplit=*/-1, + /*KeepEmpty=*/false); + for (StringRef Part : Parts) { + uint32_t Parsed; + if (!llvm::to_integer(Part, Parsed, 0)) { + reportCmdLineError(Twine("invalid argument '") + Part + + "' for option '" + A->getSpelling() + "'"); + return false; + } + Cutoffs.push_back(Parsed); + } + } + return true; +} + +static bool parseFSDiscriminatorPassArg(const opt::InputArgList &Args) { + const opt::Arg *A = Args.getLastArg(OPT_fs_discriminator_pass); + if (!A) + return true; + + std::string Value = StringRef(A->getValue()).lower(); + auto Parsed = StringSwitch>(Value) + .Case("base", FSDiscriminatorPass::Base) + .Case("pass1", FSDiscriminatorPass::Pass1) + .Case("pass2", FSDiscriminatorPass::Pass2) + .Case("pass3", FSDiscriminatorPass::Pass3) + .Case("passlast", FSDiscriminatorPass::PassLast) + .Default(std::nullopt); + if (!Parsed) { + reportCmdLineError(Twine("invalid argument '") + A->getValue() + + "' for option '" + A->getSpelling() + "'"); + return false; + } + FSDiscriminatorPassOption = *Parsed; + return true; +} - if (argc < 2) { - errs() - << ProgName - << ": No subcommand specified! Run llvm-profdata --help for usage.\n"; +static bool validateSubcommandOptions(const opt::InputArgList &Args, + StringRef Subcommand) { + bool Valid = true; + for (const opt::Arg *A : Args) { + if (A->getOption().matches(OPT_UNKNOWN) || + A->getOption().matches(OPT_INPUT)) + continue; + if (A->getOption().isRegisteredSC(Subcommand)) + continue; + reportCmdLineError(Twine("unknown command line argument '") + + A->getSpelling() + "' for subcommand '" + Subcommand + + "'. Try: '" + ProgramName + " " + Subcommand + + " --help'"); + Valid = false; + } + return Valid; +} + +static bool parseMergeOptions(const opt::InputArgList &Args, + ArrayRef Positionals) { + OutputFilename = Args.getLastArgValue(OPT_output, "-").str(); + if (const opt::Arg *A = Args.getLastArg(OPT_sample, OPT_instr)) + ProfileKind = A->getOption().matches(OPT_sample) ? sample : instr; + if (!applyLibraryOptions(Args)) + return false; + + if (!parseNumericOption( + Args.getLastArg(OPT_max_debug_info_correlation_warnings), + MaxDbgCorrelationWarnings)) + return false; + ProfiledBinary = Args.getLastArgValue(OPT_profiled_binary).str(); + DebugInfoFilename = Args.getLastArgValue(OPT_debug_info).str(); + BinaryFilename = Args.getLastArgValue(OPT_binary_file).str(); + DebugFileDirectory = Args.getAllArgValues(OPT_debug_file_directory); + DebugInfod = Args.hasArg(OPT_debuginfod); + + if (const opt::Arg *A = Args.getLastArg(OPT_correlate)) { + StringRef V = A->getValue(); + auto Parsed = StringSwitch>(V) + .Case("", InstrProfCorrelator::NONE) + .Case("debug-info", InstrProfCorrelator::DEBUG_INFO) + .Case("binary", InstrProfCorrelator::BINARY) + .Default(std::nullopt); + if (!Parsed) { + reportCmdLineError(Twine("invalid argument '") + V + "' for option '" + + A->getSpelling() + "'"); + return false; + } + BIDFetcherProfileCorrelate = *Parsed; + } + + FuncNameFilter = Args.getLastArgValue(OPT_function).str(); + InputFilenames.clear(); + InputFilenames.reserve(Positionals.size()); + for (StringRef Pos : Positionals) + InputFilenames.emplace_back(Pos.str()); + WeightedInputFilenames = Args.getAllArgValues(OPT_weighted_input); + + OutputFormat = PF_Ext_Binary; + if (const opt::Arg *Fmt = + Args.getLastArg(OPT_binary, OPT_extbinary, OPT_text, OPT_gcc)) { + if (Fmt->getOption().matches(OPT_binary)) + OutputFormat = PF_Binary; + else if (Fmt->getOption().matches(OPT_gcc)) + OutputFormat = PF_GCC; + else if (Fmt->getOption().matches(OPT_text)) + OutputFormat = PF_Text; + else + OutputFormat = PF_Ext_Binary; + } + + InputFilenamesFile = Args.getLastArgValue(OPT_input_files).str(); + DumpInputFileList = Args.hasArg(OPT_dump_input_file_list); + RemappingFile = Args.getLastArgValue(OPT_remapping_file).str(); + UseMD5 = Args.hasArg(OPT_use_md5); + CompressAllSections = Args.hasArg(OPT_compress_all_sections); + SampleMergeColdContext = Args.hasArg(OPT_sample_merge_cold_context); + SampleTrimColdContext = Args.hasArg(OPT_sample_trim_cold_context); + if (!parseNumericOption( + Args.getLastArg(OPT_sample_frame_depth_for_cold_context), + SampleColdContextFrameDepth)) + return false; + if (!parseNumericOption(Args.getLastArg(OPT_output_size_limit), + OutputSizeLimit)) + return false; + GenPartialProfile = Args.hasArg(OPT_gen_partial_profile); + SplitLayout = Args.hasArg(OPT_split_layout); + SupplInstrWithSample = + Args.getLastArgValue(OPT_supplement_instr_with_sample).str(); + if (!parseFloatOption(Args.getLastArg(OPT_zero_counter_threshold), + ZeroCounterThreshold)) + return false; + if (!parseNumericOption(Args.getLastArg(OPT_suppl_min_size_threshold), + SupplMinSizeThreshold)) + return false; + if (!parseNumericOption(Args.getLastArg(OPT_instr_prof_cold_threshold), + InstrProfColdThreshold)) + return false; + if (!parseNumericOption( + Args.getLastArg(OPT_temporal_profile_trace_reservoir_size), + TemporalProfTraceReservoirSize)) + return false; + if (!parseNumericOption( + Args.getLastArg(OPT_temporal_profile_max_trace_length), + TemporalProfMaxTraceLength)) + return false; + FuncNameNegativeFilter = Args.getLastArgValue(OPT_no_function).str(); + + StringRef FailureModeValue = Args.getLastArgValue(OPT_failure_mode, "any"); + auto ParsedFailMode = + StringSwitch>(FailureModeValue) + .Case("warn", warnOnly) + .Case("any", failIfAnyAreInvalid) + .Case("all", failIfAllAreInvalid) + .Default(std::nullopt); + if (!ParsedFailMode) { + reportCmdLineError(Twine("invalid argument '") + FailureModeValue + + "' for option '--failure-mode'"); + return false; + } + FailMode = *ParsedFailMode; + + OutputSparse = Args.hasArg(OPT_sparse); + if (!parseNumericOption(Args.getLastArg(OPT_num_threads), NumThreads)) + return false; + ProfileSymbolListFile = Args.getLastArgValue(OPT_prof_sym_list).str(); + + if (const opt::Arg *A = Args.getLastArg(OPT_convert_sample_profile_layout)) { + StringRef Layout = A->getValue(); + auto ParsedLayout = StringSwitch>(Layout) + .Case("nest", SPL_Nest) + .Case("flat", SPL_Flat) + .Default(std::nullopt); + if (!ParsedLayout) { + reportCmdLineError(Twine("invalid argument '") + Layout + + "' for option '" + A->getSpelling() + "'"); + return false; + } + ProfileLayout = *ParsedLayout; + } + + DropProfileSymbolList = Args.hasArg(OPT_drop_profile_symbol_list); + KeepVTableSymbols = Args.hasArg(OPT_keep_vtable_symbols); + DoWritePrevVersion = Args.hasArg(OPT_write_prev_version); + + if (const opt::Arg *A = Args.getLastArg(OPT_memprof_version)) { + StringRef Version = A->getValue(); + auto ParsedVersion = + StringSwitch>(Version) + .Case("2", memprof::Version2) + .Case("3", memprof::Version3) + .Case("4", memprof::Version4) + .Default(std::nullopt); + if (!ParsedVersion) { + reportCmdLineError(Twine("invalid argument '") + Version + + "' for option '" + A->getSpelling() + "'"); + return false; + } + MemProfVersionRequested = *ParsedVersion; + } + + MemProfFullSchema = Args.hasArg(OPT_memprof_full_schema); + MemprofGenerateRandomHotness = Args.hasArg(OPT_memprof_random_hotness); + if (!parseNumericOption(Args.getLastArg(OPT_memprof_random_hotness_seed), + MemprofGenerateRandomHotnessSeed)) + return false; + + if (!parseFSDiscriminatorPassArg(Args)) + return false; + + return true; +} + +static bool parseShowOptions(const opt::InputArgList &Args, + ArrayRef Positionals) { + OutputFilename = Args.getLastArgValue(OPT_output, "-").str(); + DebugInfoFilename = Args.getLastArgValue(OPT_debug_info).str(); + ProfiledBinary = Args.getLastArgValue(OPT_profiled_binary).str(); + FuncNameFilter = Args.getLastArgValue(OPT_function).str(); + if (!Positionals.empty()) { + Filename = Positionals.front().str(); + if (Positionals.size() > 1) { + reportCmdLineError("too many positional arguments"); + return false; + } + } + if (Filename.empty() && DebugInfoFilename.empty()) { + reportCmdLineError( + "the positional argument '' is required unless " + "'--debug-info' is provided"); + return false; + } + if (!Filename.empty() && OutputFilename == Filename) { + reportCmdLineError("show: Input file name cannot be the same as the " + "output file name!"); + return false; + } + + if (!parseNumericOption( + Args.getLastArg(OPT_max_debug_info_correlation_warnings), + MaxDbgCorrelationWarnings)) + return false; + if (!applyLibraryOptions(Args)) + return false; + + ShowCounts = Args.hasArg(OPT_counts); + if (const opt::Arg *A = Args.getLastArg(OPT_show_format)) { + StringRef Value = A->getValue(); + auto Parsed = StringSwitch>(Value) + .Case("text", ShowFormat::Text) + .Case("json", ShowFormat::Json) + .Case("yaml", ShowFormat::Yaml) + .Default(std::nullopt); + if (!Parsed) { + reportCmdLineError(Twine("invalid argument '") + Value + + "' for option '" + A->getSpelling() + "'"); + return false; + } + SFormat = *Parsed; + } + TextFormat = Args.hasArg(OPT_text); + JsonFormat = Args.hasArg(OPT_json); + ShowIndirectCallTargets = Args.hasArg(OPT_ic_targets); + ShowVTables = Args.hasArg(OPT_show_vtables); + ShowMemOPSizes = Args.hasArg(OPT_memop_sizes); + ShowDetailedSummary = Args.hasArg(OPT_detailed_summary); + if (!parseCutoffValues(Args, DetailedSummaryCutoffs)) + return false; + ShowHotFuncList = Args.hasArg(OPT_hot_func_list); + ShowAllFunctions = Args.hasArg(OPT_all_functions); + ShowCS = Args.hasArg(OPT_showcs); + if (!parseNumericOption(Args.getLastArg(OPT_topn), TopNFunctions)) + return false; + if (!parseNumericOption(Args.getLastArg(OPT_value_cutoff), ShowValueCutoff)) + return false; + OnlyListBelow = Args.hasArg(OPT_list_below_cutoff); + ShowProfileSymbolList = Args.hasArg(OPT_show_prof_sym_list); + ShowSectionInfoOnly = Args.hasArg(OPT_show_sec_info_only); + ShowBinaryIds = Args.hasArg(OPT_binary_ids); + ShowTemporalProfTraces = Args.hasArg(OPT_temporal_profile_traces); + ShowCovered = Args.hasArg(OPT_covered); + ShowProfileVersion = Args.hasArg(OPT_profile_version); + + if (const opt::Arg *A = Args.getLastArg(OPT_memory, OPT_sample, OPT_instr)) { + if (A->getOption().matches(OPT_memory)) + ShowProfileKind = memory; + else if (A->getOption().matches(OPT_sample)) + ShowProfileKind = sample; + else + ShowProfileKind = instr; + } + + if (!parseFSDiscriminatorPassArg(Args)) + return false; + + return true; +} + +static bool parseOverlapOptions(const opt::InputArgList &Args, + ArrayRef Positionals) { + OutputFilename = Args.getLastArgValue(OPT_output, "-").str(); + if (Positionals.size() != 2) { + reportCmdLineError("overlap requires two positional profile filenames"); + return false; + } + BaseFilename = Positionals[0].str(); + TestFilename = Positionals[1].str(); + + if (const opt::Arg *A = Args.getLastArg(OPT_sample, OPT_instr)) + ProfileKind = A->getOption().matches(OPT_sample) ? sample : instr; + + FuncNameFilter = Args.getLastArgValue(OPT_function).str(); + if (!parseNumericOption(Args.getLastArg(OPT_similarity_cutoff), + SimilarityCutoff)) + return false; + IsCS = Args.hasArg(OPT_cs); + if (!parseNumericOption(Args.getLastArg(OPT_value_cutoff), + OverlapValueCutoff)) + return false; + + if (!parseFSDiscriminatorPassArg(Args)) + return false; + + return true; +} + +static bool parseOrderOptions(const opt::InputArgList &Args, + ArrayRef Positionals) { + OutputFilename = Args.getLastArgValue(OPT_output, "-").str(); + if (!Positionals.empty()) { + Filename = Positionals.front().str(); + if (Positionals.size() > 1) { + reportCmdLineError("too many positional arguments"); + return false; + } + } + if (!parseNumericOption(Args.getLastArg(OPT_num_test_traces), NumTestTraces)) + return false; + return true; +} + +int llvm_profdata_main(int argc, char **argv, const llvm::ToolContext &) { + ProgramName = sys::path::stem(argv[0]).str(); + + ProfdataOptTable Tbl; + + if (argc == 1) { + errs() << ProgramName << ": No subcommand specified! Run " << ProgramName + << " --help for usage.\n"; return 1; } - cl::ParseCommandLineOptions(argc, argv, "LLVM profile data\n"); + bool HadSubcommandError = false; + SmallVector OtherPositionals; + auto HandleMultipleSubcommands = [&](ArrayRef SubCommands) { + HadSubcommandError = true; + WithColor::error(errs(), ProgramName) << "multiple subcommands specified:"; + for (StringRef SC : SubCommands) + errs() << " '" << SC << "'"; + errs() << "\n"; + }; + auto HandleOtherPositionals = [&](ArrayRef Positionals) { + OtherPositionals.append(Positionals.begin(), Positionals.end()); + }; - if (ShowSubcommand) - return show_main(ProgName); + unsigned MissingArgIndex = 0; + unsigned MissingArgCount = 0; + ArrayRef ArgsArr = ArrayRef(argv + 1, argc - 1); + opt::InputArgList Args = + Tbl.ParseArgs(ArgsArr, MissingArgIndex, MissingArgCount); - if (OrderSubcommand) - return order_main(); + StringRef Subcommand = Args.getSubCommand( + Tbl.getSubCommands(), HandleMultipleSubcommands, HandleOtherPositionals); + if (HadSubcommandError) + return 1; - if (OverlapSubcommand) - return overlap_main(); + if (Args.hasArg(OPT_help)) { + std::string Usage = ProgramName + " [subcommand] [options]"; + Tbl.printHelp(outs(), Usage.c_str(), "LLVM profile data", + /*ShowHidden=*/false, /*ShowAllAliases=*/false, Visibility(), + Subcommand); + return 0; + } + + bool HadParseError = false; + if (MissingArgCount) { + WithColor::error(errs(), ProgramName) + << Args.getArgString(MissingArgIndex) << ": missing argument\n"; + HadParseError = true; + } + + bool HasUnknownOptions = false; + for (const opt::Arg *A : Args.filtered(OPT_UNKNOWN)) { + HasUnknownOptions = true; + errs() << ProgramName << ": Unknown option `" << A->getAsString(Args) + << "'\n"; + } + if (HasUnknownOptions) { + errs() << "See `" << ProgramName << " --help`.\n"; + HadParseError = true; + } + if (HadParseError) + return 1; + + if (Args.hasArg(OPT_version)) { + outs() << ProgramName << '\n'; + cl::PrintVersionMessage(); + return 0; + } - if (MergeSubcommand) - return merge_main(ProgName); + if (Subcommand.empty()) { + errs() << ProgramName << ": No subcommand specified! Run " << ProgramName + << " --help for usage.\n"; + return 1; + } - errs() << ProgName - << ": Unknown command. Run llvm-profdata --help for usage.\n"; + if (!validateSubcommandOptions(Args, Subcommand)) + return 1; + + if (Subcommand == "merge") { + if (!parseMergeOptions(Args, OtherPositionals)) + return 1; + return merge_main(ProgramName); + } + if (Subcommand == "show") { + if (!parseShowOptions(Args, OtherPositionals)) + return 1; + return show_main(ProgramName); + } + if (Subcommand == "overlap") { + if (!parseOverlapOptions(Args, OtherPositionals)) + return 1; + return overlap_main(); + } + if (Subcommand == "order") { + if (!parseOrderOptions(Args, OtherPositionals)) + return 1; + return order_main(); + } + + errs() << ProgramName << ": Unknown command. Run " << ProgramName + << " --help for usage.\n"; return 1; } + +int main(int argc, char **argv) { + InitLLVM X(argc, argv); + return llvm_profdata_main(argc, argv, {argv[0], nullptr, false}); +}