@@ -2387,6 +2387,7 @@ static int overlap_main(int argc, const char *argv[]) {
2387
2387
return 0 ;
2388
2388
}
2389
2389
2390
+ namespace show_llvmprofdata {
2390
2391
namespace {
2391
2392
struct ValueSitesStats {
2392
2393
ValueSitesStats ()
@@ -2447,14 +2448,101 @@ static void showValueSitesStats(raw_fd_ostream &OS, uint32_t VK,
2447
2448
}
2448
2449
}
2449
2450
2450
- static int showInstrProfile (
2451
- const std::string &Filename, bool ShowCounts, uint32_t TopN,
2452
- bool ShowIndirectCallTargets, bool ShowMemOPSizes, bool ShowDetailedSummary,
2453
- std::vector<uint32_t > DetailedSummaryCutoffs, bool ShowAllFunctions,
2454
- bool ShowCS, uint64_t ValueCutoff, bool OnlyListBelow,
2455
- const std::string &ShowFunction, bool TextFormat, bool ShowBinaryIds,
2456
- bool ShowCovered, bool ShowProfileVersion, bool ShowTemporalProfTraces,
2457
- ShowFormat SFormat, raw_fd_ostream &OS) {
2451
+ cl::opt<std::string> Filename (cl::Positional, cl::desc(" <profdata-file>" ));
2452
+
2453
+ cl::opt<bool > ShowCounts (" counts" , cl::init(false ),
2454
+ cl::desc(" Show counter values for shown functions" ));
2455
+ cl::opt<ShowFormat>
2456
+ SFormat (" show-format" , cl::init(ShowFormat::Text),
2457
+ cl::desc(" Emit output in the selected format if supported" ),
2458
+ cl::values(clEnumValN(ShowFormat::Text, " text" ,
2459
+ " emit normal text output (default)" ),
2460
+ clEnumValN(ShowFormat::Json, " json" , " emit JSON" ),
2461
+ clEnumValN(ShowFormat::Yaml, " yaml" , " emit YAML" )));
2462
+ // TODO: Consider replacing this with `--show-format=text-encoding`.
2463
+ cl::opt<bool >
2464
+ TextFormat (" text" , cl::init(false ),
2465
+ cl::desc(" Show instr profile data in text dump format" ));
2466
+ cl::opt<bool >
2467
+ JsonFormat (" json" , cl::desc(" Show sample profile data in the JSON format "
2468
+ " (deprecated, please use --show-format=json)" ));
2469
+ cl::opt<bool > ShowIndirectCallTargets (
2470
+ " ic-targets" , cl::init(false ),
2471
+ cl::desc(" Show indirect call site target values for shown functions" ));
2472
+ cl::opt<bool > ShowMemOPSizes (
2473
+ " memop-sizes" , cl::init(false ),
2474
+ cl::desc(" Show the profiled sizes of the memory intrinsic calls "
2475
+ " for shown functions" ));
2476
+ cl::opt<bool > ShowDetailedSummary (" detailed-summary" , cl::init(false ),
2477
+ cl::desc(" Show detailed profile summary" ));
2478
+ cl::list<uint32_t > DetailedSummaryCutoffs (
2479
+ cl::CommaSeparated, " detailed-summary-cutoffs" ,
2480
+ cl::desc (
2481
+ " Cutoff percentages (times 10000) for generating detailed summary" ),
2482
+ cl::value_desc(" 800000,901000,999999" ));
2483
+ cl::opt<bool > ShowHotFuncList (
2484
+ " hot-func-list" , cl::init(false ),
2485
+ cl::desc(" Show profile summary of a list of hot functions" ));
2486
+ cl::opt<bool > ShowAllFunctions (" all-functions" , cl::init(false ),
2487
+ cl::desc(" Details for every function" ));
2488
+ cl::opt<bool > ShowCS (" showcs" , cl::init(false ),
2489
+ cl::desc(" Show context sensitive counts" ));
2490
+ cl::opt<std::string> ShowFunction (" function" ,
2491
+ cl::desc (" Details for matching functions" ));
2492
+
2493
+ cl::opt<std::string> OutputFilename (" output" , cl::value_desc(" output" ),
2494
+ cl::init(" -" ), cl::desc(" Output file" ));
2495
+ cl::alias OutputFilenameA (" o" , cl::desc(" Alias for --output" ),
2496
+ cl::aliasopt(OutputFilename));
2497
+ cl::opt<ProfileKinds> ProfileKind (
2498
+ cl::desc (" Profile kind:" ), cl::init(instr),
2499
+ cl::values(clEnumVal(instr, " Instrumentation profile (default)" ),
2500
+ clEnumVal(sample, " Sample profile" ),
2501
+ clEnumVal(memory, " MemProf memory access profile" )));
2502
+ cl::opt<uint32_t > TopNFunctions (
2503
+ " topn" , cl::init(0 ),
2504
+ cl::desc(" Show the list of functions with the largest internal counts" ));
2505
+ cl::opt<uint32_t > ValueCutoff (
2506
+ " value-cutoff" , cl::init(0 ),
2507
+ cl::desc(" Set the count value cutoff. Functions with the maximum count "
2508
+ " less than this value will not be printed out. (Default is 0)" ));
2509
+ cl::opt<bool > OnlyListBelow (
2510
+ " list-below-cutoff" , cl::init(false ),
2511
+ cl::desc(" Only output names of functions whose max count values are "
2512
+ " below the cutoff value" ));
2513
+ cl::opt<bool > ShowProfileSymbolList (
2514
+ " show-prof-sym-list" , cl::init(false ),
2515
+ cl::desc(" Show profile symbol list if it exists in the profile. " ));
2516
+ cl::opt<bool > ShowSectionInfoOnly (
2517
+ " show-sec-info-only" , cl::init(false ),
2518
+ cl::desc(" Show the information of each section in the sample profile. "
2519
+ " The flag is only usable when the sample profile is in "
2520
+ " extbinary format" ));
2521
+ cl::opt<bool > ShowBinaryIds (" binary-ids" , cl::init(false ),
2522
+ cl::desc(" Show binary ids in the profile. " ));
2523
+ cl::opt<bool > ShowTemporalProfTraces (
2524
+ " temporal-profile-traces" ,
2525
+ cl::desc (" Show temporal profile traces in the profile." ));
2526
+ cl::opt<std::string> DebugInfoFilename (
2527
+ " debug-info" , cl::init(" " ),
2528
+ cl::desc(" Read and extract profile metadata from debug info and show "
2529
+ " the functions it found." ));
2530
+ cl::opt<unsigned > MaxDbgCorrelationWarnings (
2531
+ " max-debug-info-correlation-warnings" ,
2532
+ cl::desc (" The maximum number of warnings to emit when correlating "
2533
+ " profile from debug info (0 = no limit)" ),
2534
+ cl::init(5 ));
2535
+ cl::opt<bool >
2536
+ ShowCovered (" covered" , cl::init(false ),
2537
+ cl::desc(" Show only the functions that have been executed." ));
2538
+ cl::opt<std::string> ProfiledBinary (
2539
+ " profiled-binary" , cl::init(" " ),
2540
+ cl::desc(" Path to binary from which the profile was collected." ));
2541
+ cl::opt<bool > ShowProfileVersion (" profile-version" , cl::init(false ),
2542
+ cl::desc(" Show profile version. " ));
2543
+
2544
+ static int showInstrProfile (const std::string &Filename, ShowFormat SFormat,
2545
+ raw_fd_ostream &OS) {
2458
2546
if (SFormat == ShowFormat::Json)
2459
2547
exitWithError (" JSON output is not supported for instr profiles" );
2460
2548
if (SFormat == ShowFormat::Yaml)
@@ -2559,8 +2647,8 @@ static int showInstrProfile(
2559
2647
} else if (OnlyListBelow)
2560
2648
continue ;
2561
2649
2562
- if (TopN ) {
2563
- if (HottestFuncs.size () == TopN ) {
2650
+ if (TopNFunctions ) {
2651
+ if (HottestFuncs.size () == TopNFunctions ) {
2564
2652
if (HottestFuncs.top ().second < FuncMax) {
2565
2653
HottestFuncs.pop ();
2566
2654
HottestFuncs.emplace (std::make_pair (std::string (Func.Name ), FuncMax));
@@ -2636,13 +2724,13 @@ static int showInstrProfile(
2636
2724
OS << " Maximum function count: " << PS->getMaxFunctionCount () << " \n " ;
2637
2725
OS << " Maximum internal block count: " << PS->getMaxInternalCount () << " \n " ;
2638
2726
2639
- if (TopN ) {
2727
+ if (TopNFunctions ) {
2640
2728
std::vector<std::pair<std::string, uint64_t >> SortedHottestFuncs;
2641
2729
while (!HottestFuncs.empty ()) {
2642
2730
SortedHottestFuncs.emplace_back (HottestFuncs.top ());
2643
2731
HottestFuncs.pop ();
2644
2732
}
2645
- OS << " Top " << TopN
2733
+ OS << " Top " << TopNFunctions
2646
2734
<< " functions with the largest internal block counts: \n " ;
2647
2735
for (auto &hotfunc : llvm::reverse (SortedHottestFuncs))
2648
2736
OS << " " << hotfunc.first << " , max count = " << hotfunc.second << " \n " ;
@@ -2832,13 +2920,8 @@ static int showHotFunctionList(const sampleprof::SampleProfileMap &Profiles,
2832
2920
return 0 ;
2833
2921
}
2834
2922
2835
- static int showSampleProfile (const std::string &Filename, bool ShowCounts,
2836
- uint32_t TopN, bool ShowAllFunctions,
2837
- bool ShowDetailedSummary,
2838
- const std::string &ShowFunction,
2839
- bool ShowProfileSymbolList,
2840
- bool ShowSectionInfoOnly, bool ShowHotFuncList,
2841
- ShowFormat SFormat, raw_fd_ostream &OS) {
2923
+ static int showSampleProfile (const std::string &Filename, ShowFormat SFormat,
2924
+ raw_fd_ostream &OS) {
2842
2925
if (SFormat == ShowFormat::Yaml)
2843
2926
exitWithError (" YAML output is not supported for sample profiles" );
2844
2927
using namespace sampleprof ;
@@ -2886,15 +2969,14 @@ static int showSampleProfile(const std::string &Filename, bool ShowCounts,
2886
2969
PS.printDetailedSummary (OS);
2887
2970
}
2888
2971
2889
- if (ShowHotFuncList || TopN)
2890
- showHotFunctionList (Reader->getProfiles (), Reader->getSummary (), TopN, OS);
2972
+ if (ShowHotFuncList || TopNFunctions)
2973
+ showHotFunctionList (Reader->getProfiles (), Reader->getSummary (),
2974
+ TopNFunctions, OS);
2891
2975
2892
2976
return 0 ;
2893
2977
}
2894
2978
2895
- static int showMemProfProfile (const std::string &Filename,
2896
- const std::string &ProfiledBinary,
2897
- ShowFormat SFormat, raw_fd_ostream &OS) {
2979
+ static int showMemProfProfile (const std::string &Filename, raw_fd_ostream &OS) {
2898
2980
if (SFormat == ShowFormat::Json)
2899
2981
exitWithError (" JSON output is not supported for MemProf" );
2900
2982
auto ReaderOr = llvm::memprof::RawMemProfReader::create (
@@ -2913,10 +2995,7 @@ static int showMemProfProfile(const std::string &Filename,
2913
2995
}
2914
2996
2915
2997
static int showDebugInfoCorrelation (const std::string &Filename,
2916
- bool ShowDetailedSummary,
2917
- bool ShowProfileSymbolList,
2918
- int MaxDbgCorrelationWarnings,
2919
- ShowFormat SFormat, raw_fd_ostream &OS) {
2998
+ raw_fd_ostream &OS) {
2920
2999
if (SFormat == ShowFormat::Json)
2921
3000
exitWithError (" JSON output is not supported for debug info correlation" );
2922
3001
std::unique_ptr<InstrProfCorrelator> Correlator;
@@ -2950,101 +3029,8 @@ static int showDebugInfoCorrelation(const std::string &Filename,
2950
3029
return 0 ;
2951
3030
}
2952
3031
2953
- static int show_main (int argc, const char *argv[]) {
2954
- cl::opt<std::string> Filename (cl::Positional, cl::desc (" <profdata-file>" ));
2955
-
2956
- cl::opt<bool > ShowCounts (" counts" , cl::init (false ),
2957
- cl::desc (" Show counter values for shown functions" ));
2958
- cl::opt<ShowFormat> SFormat (
2959
- " show-format" , cl::init (ShowFormat::Text),
2960
- cl::desc (" Emit output in the selected format if supported" ),
2961
- cl::values (clEnumValN (ShowFormat::Text, " text" ,
2962
- " emit normal text output (default)" ),
2963
- clEnumValN (ShowFormat::Json, " json" , " emit JSON" ),
2964
- clEnumValN (ShowFormat::Yaml, " yaml" , " emit YAML" )));
2965
- // TODO: Consider replacing this with `--show-format=text-encoding`.
2966
- cl::opt<bool > TextFormat (
2967
- " text" , cl::init (false ),
2968
- cl::desc (" Show instr profile data in text dump format" ));
2969
- cl::opt<bool > JsonFormat (
2970
- " json" , cl::desc (" Show sample profile data in the JSON format "
2971
- " (deprecated, please use --show-format=json)" ));
2972
- cl::opt<bool > ShowIndirectCallTargets (
2973
- " ic-targets" , cl::init (false ),
2974
- cl::desc (" Show indirect call site target values for shown functions" ));
2975
- cl::opt<bool > ShowMemOPSizes (
2976
- " memop-sizes" , cl::init (false ),
2977
- cl::desc (" Show the profiled sizes of the memory intrinsic calls "
2978
- " for shown functions" ));
2979
- cl::opt<bool > ShowDetailedSummary (" detailed-summary" , cl::init (false ),
2980
- cl::desc (" Show detailed profile summary" ));
2981
- cl::list<uint32_t > DetailedSummaryCutoffs (
2982
- cl::CommaSeparated, " detailed-summary-cutoffs" ,
2983
- cl::desc (
2984
- " Cutoff percentages (times 10000) for generating detailed summary" ),
2985
- cl::value_desc (" 800000,901000,999999" ));
2986
- cl::opt<bool > ShowHotFuncList (
2987
- " hot-func-list" , cl::init (false ),
2988
- cl::desc (" Show profile summary of a list of hot functions" ));
2989
- cl::opt<bool > ShowAllFunctions (" all-functions" , cl::init (false ),
2990
- cl::desc (" Details for every function" ));
2991
- cl::opt<bool > ShowCS (" showcs" , cl::init (false ),
2992
- cl::desc (" Show context sensitive counts" ));
2993
- cl::opt<std::string> ShowFunction (" function" ,
2994
- cl::desc (" Details for matching functions" ));
2995
-
2996
- cl::opt<std::string> OutputFilename (" output" , cl::value_desc (" output" ),
2997
- cl::init (" -" ), cl::desc (" Output file" ));
2998
- cl::alias OutputFilenameA (" o" , cl::desc (" Alias for --output" ),
2999
- cl::aliasopt (OutputFilename));
3000
- cl::opt<ProfileKinds> ProfileKind (
3001
- cl::desc (" Profile kind:" ), cl::init (instr),
3002
- cl::values (clEnumVal (instr, " Instrumentation profile (default)" ),
3003
- clEnumVal (sample, " Sample profile" ),
3004
- clEnumVal (memory, " MemProf memory access profile" )));
3005
- cl::opt<uint32_t > TopNFunctions (
3006
- " topn" , cl::init (0 ),
3007
- cl::desc (" Show the list of functions with the largest internal counts" ));
3008
- cl::opt<uint32_t > ValueCutoff (
3009
- " value-cutoff" , cl::init (0 ),
3010
- cl::desc (" Set the count value cutoff. Functions with the maximum count "
3011
- " less than this value will not be printed out. (Default is 0)" ));
3012
- cl::opt<bool > OnlyListBelow (
3013
- " list-below-cutoff" , cl::init (false ),
3014
- cl::desc (" Only output names of functions whose max count values are "
3015
- " below the cutoff value" ));
3016
- cl::opt<bool > ShowProfileSymbolList (
3017
- " show-prof-sym-list" , cl::init (false ),
3018
- cl::desc (" Show profile symbol list if it exists in the profile. " ));
3019
- cl::opt<bool > ShowSectionInfoOnly (
3020
- " show-sec-info-only" , cl::init (false ),
3021
- cl::desc (" Show the information of each section in the sample profile. "
3022
- " The flag is only usable when the sample profile is in "
3023
- " extbinary format" ));
3024
- cl::opt<bool > ShowBinaryIds (" binary-ids" , cl::init (false ),
3025
- cl::desc (" Show binary ids in the profile. " ));
3026
- cl::opt<bool > ShowTemporalProfTraces (
3027
- " temporal-profile-traces" ,
3028
- cl::desc (" Show temporal profile traces in the profile." ));
3029
- cl::opt<std::string> DebugInfoFilename (
3030
- " debug-info" , cl::init (" " ),
3031
- cl::desc (" Read and extract profile metadata from debug info and show "
3032
- " the functions it found." ));
3033
- cl::opt<unsigned > MaxDbgCorrelationWarnings (
3034
- " max-debug-info-correlation-warnings" ,
3035
- cl::desc (" The maximum number of warnings to emit when correlating "
3036
- " profile from debug info (0 = no limit)" ),
3037
- cl::init (5 ));
3038
- cl::opt<bool > ShowCovered (
3039
- " covered" , cl::init (false ),
3040
- cl::desc (" Show only the functions that have been executed." ));
3041
- cl::opt<std::string> ProfiledBinary (
3042
- " profiled-binary" , cl::init (" " ),
3043
- cl::desc (" Path to binary from which the profile was collected." ));
3044
- cl::opt<bool > ShowProfileVersion (" profile-version" , cl::init (false ),
3045
- cl::desc (" Show profile version. " ));
3032
+ static int main (int argc, const char *argv[]) {
3046
3033
cl::ParseCommandLineOptions (argc, argv, " LLVM profile data summary\n " );
3047
-
3048
3034
if (Filename.empty () && DebugInfoFilename.empty ())
3049
3035
exitWithError (
3050
3036
" the positional argument '<profdata-file>' is required unless '--" +
@@ -3067,25 +3053,17 @@ static int show_main(int argc, const char *argv[]) {
3067
3053
WithColor::warning () << " -function argument ignored: showing all functions\n " ;
3068
3054
3069
3055
if (!DebugInfoFilename.empty ())
3070
- return showDebugInfoCorrelation (DebugInfoFilename, ShowDetailedSummary,
3071
- ShowProfileSymbolList,
3072
- MaxDbgCorrelationWarnings, SFormat, OS);
3056
+ return showDebugInfoCorrelation (DebugInfoFilename, OS);
3073
3057
3074
3058
if (ProfileKind == instr)
3075
- return showInstrProfile (
3076
- Filename, ShowCounts, TopNFunctions, ShowIndirectCallTargets,
3077
- ShowMemOPSizes, ShowDetailedSummary, DetailedSummaryCutoffs,
3078
- ShowAllFunctions, ShowCS, ValueCutoff, OnlyListBelow, ShowFunction,
3079
- TextFormat, ShowBinaryIds, ShowCovered, ShowProfileVersion,
3080
- ShowTemporalProfTraces, SFormat, OS);
3059
+ return showInstrProfile (Filename, SFormat, OS);
3081
3060
if (ProfileKind == sample)
3082
- return showSampleProfile (Filename, ShowCounts, TopNFunctions,
3083
- ShowAllFunctions, ShowDetailedSummary,
3084
- ShowFunction, ShowProfileSymbolList,
3085
- ShowSectionInfoOnly, ShowHotFuncList, SFormat, OS);
3086
- return showMemProfProfile (Filename, ProfiledBinary, SFormat, OS);
3061
+ return showSampleProfile (Filename, SFormat, OS);
3062
+ return showMemProfProfile (Filename, SFormat, OS);
3087
3063
}
3088
3064
3065
+ } // namespace show_llvmprofdata
3066
+
3089
3067
static int order_main (int argc, const char *argv[]) {
3090
3068
cl::opt<std::string> Filename (cl::Positional, cl::desc (" <profdata-file>" ));
3091
3069
cl::opt<std::string> OutputFilename (" output" , cl::value_desc (" output" ),
@@ -3130,7 +3108,7 @@ typedef int (*llvm_profdata_subcommand)(int, const char *[]);
3130
3108
static std::tuple<StringRef, llvm_profdata_subcommand>
3131
3109
llvm_profdata_subcommands[] = {
3132
3110
{" merge" , merge_main},
3133
- {" show" , show_main },
3111
+ {" show" , show_llvmprofdata::main },
3134
3112
{" order" , order_main},
3135
3113
{" overlap" , overlap_main},
3136
3114
};
0 commit comments