[llvm] r326738 - Re-commit: Make STATISTIC() values available programmatically

Greg Bedwell via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 7 04:02:30 PST 2018


Unfortunately, I think that this now breaks for multi-config generators
(sadly, I don't think we have any public buildbots building using these).
I've tried it on Windows with cmake -G "Visual Studio 14 2015 Win64", but
I'd guess the same thing would happen with cmake -G "Xcode".  If I build
"Debug" I get a whole bunch of check-all failures along the lines of:

  # command stderr:

C:\work\public-git\upstream-llvm\llvm\tools\clang\test\Analysis\stats.c:7:11:
error: expected string not found in input

  // CHECK: ... Statistics Collected ...

            ^

  <stdin>:1:1: note: scanning from here


The issue basically comes down to the fact that with a multi-config
generator, it's not actually known at CMake time whether
LLVM_ENABLE_ASSERTIONS is true or not, as the IDE will let the user decide
whether to build Debug or Release from the already generated project at
build time.  I assume this is why we had all those checks on NDEBUG at the
same time as LLVM_ENABLE_STATS previously.

-Greg



On 5 March 2018 at 19:38, Daniel Sanders via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: dsanders
> Date: Mon Mar  5 11:38:16 2018
> New Revision: 326738
>
> URL: http://llvm.org/viewvc/llvm-project?rev=326738&view=rev
> Log:
> Re-commit: Make STATISTIC() values available programmatically
>
> Summary:
> 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.
>
> Reviewers: qcolombet, rtereshin, aditya_nandakumar, bogner
>
> Reviewed By: rtereshin, bogner
>
> Subscribers: llvm-commits, mgorny
>
> Differential Revision: https://reviews.llvm.org/D43901
>
> This re-commit fixes a missing include of <vector> which it seems clang
> didn't
> mind but G++ and MSVC objected to. It seems that, clang was ok with
> std::vector
> only being forward declared at the point of use since it was fully defined
> eventually but G++/MSVC both rejected it at the point of use.
>
> Added:
>     llvm/trunk/unittests/ADT/StatisticTest.cpp
>       - copied unchanged from r326725, llvm/trunk/unittests/ADT/
> StatisticTest.cpp
> Modified:
>     llvm/trunk/cmake/modules/HandleLLVMOptions.cmake
>     llvm/trunk/include/llvm/ADT/Statistic.h
>     llvm/trunk/include/llvm/Config/llvm-config.h.cmake
>     llvm/trunk/lib/Support/Statistic.cpp
>     llvm/trunk/unittests/ADT/CMakeLists.txt
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180307/756808cd/attachment.html>


More information about the llvm-commits mailing list