This is an archive of the discontinued LLVM Phabricator instance.

Statistic: Only print statistics on exit for -stats
ClosedPublic

Authored by MatzeB on Sep 21 2016, 7:22 PM.

Details

Summary

Previously enabling the statistics with EnableStatistics() would lead to
them getting printed to stderr/-info-output-file on exit. However
frontends may want a way to enable statistics and do the printing on
their own instead of the forced printing on exit.

This changes the code so that only the -stats option enables printing on
exit, EnableStatistics() only enables the tracking but requires invoking
one of the PrintStatistics() variants.

Also remove the -stats-json option; I am about to propose a better
system for clang which supersedes it.

Diff Detail

Repository
rL LLVM

Event Timeline

MatzeB updated this revision to Diff 72134.Sep 21 2016, 7:22 PM
MatzeB retitled this revision from to Statistic: Only print statistics on exit for -stats.
MatzeB updated this object.
MatzeB added a reviewer: bruno.
MatzeB set the repository for this revision to rL LLVM.
MatzeB added a subscriber: llvm-commits.
bruno edited edge metadata.Sep 23 2016, 10:55 AM

Hi Matthias,

Thanks for working on this.
You probably want to update Other/statistic.ll to remove the -stats-json tests?

What's your plan regarding the forthcoming output on a file? It seems to me that we can default to JSON whenever the output is anything but the default stderr.

Hi Matthias,

Thanks for working on this.
You probably want to update Other/statistic.ll to remove the -stats-json tests?

What's your plan regarding the forthcoming output on a file? It seems to me that we can default to JSON whenever the output is anything but the default stderr.

My plan is getting this: https://reviews.llvm.org/D24820. This leaves the choice to the frontend which can either call PrintStatistics(OS) or PrintStatisticsJSON(OS). I consider the -stats llvm option as an easy ad-hoc measure to get some statistics printed; For bigger data gathering you should have support from your frontend to choose a sensible filename to write the statistics to in a machine parseable format.

Hi Matthias,

Thanks for working on this.
You probably want to update Other/statistic.ll to remove the -stats-json tests?

What's your plan regarding the forthcoming output on a file? It seems to me that we can default to JSON whenever the output is anything but the default stderr.

My plan is getting this: https://reviews.llvm.org/D24820. This leaves the choice to the frontend which can either call PrintStatistics(OS) or PrintStatisticsJSON(OS). I consider the -stats llvm option as an easy ad-hoc measure to get some statistics printed; For bigger data gathering you should have support from your frontend to choose a sensible filename to write the statistics to in a machine parseable format.

It seems useful to me to allow json stats to be collected when running from llc and opt as well, don't you think?

Hi Matthias,

Thanks for working on this.
You probably want to update Other/statistic.ll to remove the -stats-json tests?

What's your plan regarding the forthcoming output on a file? It seems to me that we can default to JSON whenever the output is anything but the default stderr.

My plan is getting this: https://reviews.llvm.org/D24820. This leaves the choice to the frontend which can either call PrintStatistics(OS) or PrintStatisticsJSON(OS). I consider the -stats llvm option as an easy ad-hoc measure to get some statistics printed; For bigger data gathering you should have support from your frontend to choose a sensible filename to write the statistics to in a machine parseable format.

It seems useful to me to allow json stats to be collected when running from llc and opt as well, don't you think?

I was thinking of -stats-json as a stopgap measure until we have frontend integration. But sure we can keep it in, I must admit we should probably have it for the unittest anyway.

bruno added a comment.Sep 23 2016, 1:52 PM

I was thinking of -stats-json as a stopgap measure until we have frontend integration. But sure we can keep it in, I must admit we should probably have it for the unittest anyway.

Why not something similar as the FE? That is, if "-stat=file" then default to json, otherwise default stderr output?

MatzeB updated this revision to Diff 72370.Sep 23 2016, 3:22 PM
MatzeB edited edge metadata.

Leave the -stats-json option in, simplifying the patch.

bruno accepted this revision.Sep 26 2016, 9:52 AM
bruno edited edge metadata.

LGTM

This revision is now accepted and ready to land.Sep 26 2016, 9:52 AM
This revision was automatically updated to reflect the committed changes.