This is an archive of the discontinued LLVM Phabricator instance.

[ProfileData] Add new option to dump top N hottest functions
ClosedPublic

Authored by davidxl on Jul 7 2017, 3:17 PM.

Details

Summary

The command line is:

llvm-profdata show --topn=<N>  <profile_data>

This is useful for user to do focused analysis. With top function names dumped, user can use option --counters --function=<FuncName> to dump counters of the specified function and do comparisons.

Diff Detail

Repository
rL LLVM

Event Timeline

davidxl created this revision.Jul 7 2017, 3:17 PM
davide added a subscriber: davide.Jul 9 2017, 9:48 AM
vsk added inline comments.Jul 10 2017, 1:16 PM
test/tools/llvm-profdata/c-general.test
13 ↗(On Diff #105714)

Add --check-prefix=TOPN?

14 ↗(On Diff #105714)

I think --topn and --all-functions should be mutually incompatible.

tools/llvm-profdata/llvm-profdata.cpp
528 ↗(On Diff #105714)

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.

davidxl marked 2 inline comments as done.Jul 11 2017, 10:43 AM
davidxl added inline comments.
test/tools/llvm-profdata/c-general.test
14 ↗(On Diff #105714)

They are compatible. One use case is to dump them together into one file. User can first look at the top functions and examine the counter details for the function of interest.

davidxl updated this revision to Diff 106067.Jul 11 2017, 10:44 AM

Addressed review feedback.

vsk accepted this revision.Jul 11 2017, 11:25 AM

Lgtm with two nitpicks.

test/tools/llvm-profdata/c-general.test
14 ↗(On Diff #105714)

Ah ok.

tools/llvm-profdata/llvm-profdata.cpp
508 ↗(On Diff #106067)

The coding standards have an explicit rule against 'using namespace std', which is more stylistic than practical when applied to implementation files, but still important for consistency.

629 ↗(On Diff #106067)

const auto &

This revision is now accepted and ready to land.Jul 11 2017, 11:25 AM
vsk added a comment.Jul 11 2017, 11:28 AM

Oh, the --topn flag also needs a short entry in docs/CommandGuide/llvm-profdata.rst.

davidxl marked 2 inline comments as done.Jul 11 2017, 12:39 PM

Added documentation.

This revision was automatically updated to reflect the committed changes.