[PATCH] D35155: [ProfileData] Add new option to dump top N hottest functions

Vedant Kumar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 10 13:16:57 PDT 2017


vsk added inline comments.


================
Comment at: test/tools/llvm-profdata/c-general.test:13
 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
 RUN: llvm-profdata show %p/Inputs/c-general.profraw -o - --function=switches | FileCheck %s -check-prefix=SWITCHES -check-prefix=CHECK
----------------
Add --check-prefix=TOPN?


================
Comment at: test/tools/llvm-profdata/c-general.test:14
+RUN: llvm-profdata show %p/Inputs/c-general.profraw --topn=3 -o - | FileCheck %s
 RUN: llvm-profdata show %p/Inputs/c-general.profraw -o - --function=switches | FileCheck %s -check-prefix=SWITCHES -check-prefix=CHECK
 
----------------
I think --topn and --all-functions should be mutually incompatible.


================
Comment at: tools/llvm-profdata/llvm-profdata.cpp:528
+  };
+  std::make_heap(HottestFuncs.begin(), HottestFuncs.end(), MinCmp);
+
----------------
Wdyt of using a std::priority_queue, s.t the function with the lowest count is always at the top? While adding records into the PQ, you'd do `if PQ.size() > TopN: PQ.pop()`. It wouldn't be functionally different, just less typing.


https://reviews.llvm.org/D35155





More information about the llvm-commits mailing list