[llvm-dev] Reining in profile instrumentation

Vedant Kumar via llvm-dev llvm-dev at lists.llvm.org
Tue Dec 13 15:11:48 PST 2016


> On Dec 13, 2016, at 3:46 AM, Martin J. O'Riordan via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> 
> When either ‘-pg’ or ‘-finstrument-functions’ is used, the compiler inserts the appropriate profiling hooks.  This happens prior to inlining, so the hooks remain in place.

Have you tried compiling with -fprofile-generate? It enables IR-based profiling
instrumentation, which has supported pre-inlining since r275588. That should
mitigate the issue you're seeing with excessive instrumentation.


> Normally this is fine, but with C++ and the heavy use of inline functions and templates, there can be a vast number of trivial functions that are normally optimised away; but with the instrumentation hooks present, this does not happen and the code becomes severely larger and more expensive to execute.  Also, because of this, the program being profiled does not even approximately resemble the normal program with no profiling hooks, so the data gathered is of little use.

The pre-inlining should address this issue. E.g, if A calls B, B calls C, and
B+C are inlined into A, then the profile you'd get back is {1, 0, 0}. Without
pre-inlining, you'd get back {1, 1, 1}.

That said, I don't know what kinds of issues this would cause in practice. I'd
really like to hear about how the performance of your optimized application
changes when you turn pre-inlining on during the instrumentation step.

You can experiment with this with -mllvm -disable-preinline.

 
> My question is whether there are any mechanisms in LLVM to control what functions get instrumented; for instance ‘#pragma’s that can be added to the code, especially headers, that can be used to disable the instrumentation of large groups of functions.  Or an option to remove the instrumentation during inlining?

Not that I'm aware of. One option is to not pass -fprofile-blah into
translation units you don't want instrumented.

best,
vedant

>  
> But I really do need a way of preventing the instrumentation of large numbers of functions is a simple way.
>  
> Thanks,
>  
>             MartinO
>  
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev



More information about the llvm-dev mailing list