[PATCH] D39287: Use CountingFunctionInserter both mcount and cygprofile calls, before and after inlining

Hans Wennborg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 10 16:51:16 PST 2017


hans updated this revision to Diff 122554.
hans marked 2 inline comments as done.
hans added a comment.
Herald added a subscriber: mehdi_amini.

Rebasing and addressing comments.

I've also added the pass in PassManagerBuilder::populateFunctionPassManager() because I realized that's how Clang sets up the passes.

One thing that worries me is that this set-up is pretty fragile against how the passes are run. I think it will currently work, but if the pass were to somehow run more than once, the instrumentation could get inserted multiple times. One way to avoid that would be to remove the attribute (or probably faster, give it an empty value?) when the pass "consumes" the attribute. Does that sound reasonable?

I also looked into consolidating this with the FEntryInserter pass which inserts calls to __fentry__. That turned out to be tricky however, because the calls are supposed to be inserted before the function prologue, which means the pass operates on MachineFunctions and inserts MachineInstrs. So I've left that out.

I've updated the Clang-side patch here: https://reviews.llvm.org/D39331


https://reviews.llvm.org/D39287

Files:
  include/llvm/CodeGen/Passes.h
  include/llvm/InitializePasses.h
  include/llvm/LinkAllPasses.h
  include/llvm/Transforms/Scalar.h
  include/llvm/Transforms/Utils/EntryExitInstrumenter.h
  lib/CodeGen/CMakeLists.txt
  lib/CodeGen/CodeGen.cpp
  lib/CodeGen/CountingFunctionInserter.cpp
  lib/CodeGen/TargetPassConfig.cpp
  lib/Passes/PassBuilder.cpp
  lib/Passes/PassRegistry.def
  lib/Transforms/IPO/PassManagerBuilder.cpp
  lib/Transforms/Scalar/Scalar.cpp
  lib/Transforms/Utils/CMakeLists.txt
  lib/Transforms/Utils/EntryExitInstrumenter.cpp
  test/CodeGen/PowerPC/mcount-insertion.ll
  test/CodeGen/X86/O0-pipeline.ll
  test/Transforms/CountingFunctionInserter/mcount.ll
  tools/llc/llc.cpp
  tools/opt/opt.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39287.122554.patch
Type: text/x-patch
Size: 22376 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171111/ad88b816/attachment.bin>


More information about the llvm-commits mailing list