Search code examples
compiler-constructionclangllvmllvm-ir

Where can I find the llvm -stats information


I am running the command line

opt test.bc -loop-vectorize -o test2.bc -stats 

to check the statistics collected by the LLVM loop vectorize pass. However, after running the command, I only get the test2.bc without getting any stats printed. May I know where should I look for these stats?

Thanks in advance, T


Solution

  • They should be printed on your terminal after the command has finished executing. However, your LLVM needs to be built with assertions enabled, documented here:

    Note that in order to use the ‘-stats‘ option, LLVM must be compiled with assertions enabled.

    This corresponds to this cmake flag, if you are building LLVM from source:

    -DLLVM_ENABLE_ASSERTIONS=On
    

    Moreover, you can query a specific LLVM installation for its assertion mode using:

    llvm-config --assertion-mode
    

    If assertions are enabled, then it should return ON.

    For code introspection of this feature, the corresponding preprocessor definition is

    LLVM_ENABLE_STATS
    

    or when NDEBUG is not defined, as seen in the include/llvm/Support/Statistic.h header file.