[PATCH] D22825: Add a counter-function insertion pass

Hal Finkel via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 26 10:58:28 PDT 2016


hfinkel created this revision.
hfinkel added reviewers: rjmccall, honggyu.kim, majnemer.
hfinkel added a subscriber: llvm-commits.
Herald added subscribers: nemanjai, mcrosier.

As discussed in D22666, our current mechanism to support -pg profiling, where we insert calls to mcount(), or some similar function, is fundamentally broken. We insert these calls in the frontend, which means they get duplicated when inlining, and so the accumulated execution counts for the inlined-into functions are wrong.

Because we don't want the presence of these functions to affect optimizaton, they should be inserted in the backend. Here's a pass which would do just that. The knowledge of the name of the counting function lives in the frontend, so I'm passing it here as a function attribute. This should be easy to add in the frontend, work correctly with LTO, etc.

https://reviews.llvm.org/D22825

Files:
  include/llvm/CodeGen/Passes.h
  include/llvm/InitializePasses.h
  include/llvm/LinkAllPasses.h
  lib/CodeGen/CMakeLists.txt
  lib/CodeGen/CodeGen.cpp
  lib/CodeGen/CountingFunctionInserter.cpp
  lib/CodeGen/TargetPassConfig.cpp
  test/CodeGen/PowerPC/mcount-insertion.ll
  test/Transforms/CountingFunctionInserter/mcount.ll
  tools/llc/llc.cpp
  tools/opt/opt.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22825.65556.patch
Type: text/x-patch
Size: 7558 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160726/de11eea9/attachment.bin>


More information about the llvm-commits mailing list