[PATCH] D43901: Make STATISTIC() values available programmatically

Daniel Sanders via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 28 13:35:12 PST 2018


dsanders created this revision.
dsanders added reviewers: qcolombet, rtereshin, aditya_nandakumar, bogner.
Herald added a subscriber: mgorny.

It can be useful for tools to be able to retrieve the values of variables
declared via STATISTIC() directly without having to emit them and parse
them back. Use cases include:

- Needing to report specific statistics to a test harness
- Wanting to post-process statistics. For example, to produce a percentage of functions that were fully selected by GlobalISel

Make this possible by adding llvm::GetStatistics() which returns an
iterator_range that can be used to inspect the statistics that have been
touched during execution. When statistics are disabled (NDEBUG and not
LLVM_ENABLE_STATISTICS) this method will return an empty range.

This patch doesn't address the effect of multiple compilations within the same
process. In such situations, the statistics will be cumulative for all
compilations up to the GetStatistics() call.


Repository:
  rL LLVM

https://reviews.llvm.org/D43901

Files:
  include/llvm/ADT/StatisticInfo.h
  lib/Support/Statistic.cpp
  unittests/ADT/CMakeLists.txt
  unittests/ADT/StatisticTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43901.136384.patch
Type: text/x-patch
Size: 6806 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180228/faf11202/attachment.bin>


More information about the llvm-commits mailing list