OSDN Git Service

Rename CountingFunctionInserter and use for both mcount and cygprofile calls, before...
authorHans Wennborg <hans@hanshq.net>
Tue, 14 Nov 2017 21:09:45 +0000 (21:09 +0000)
committerHans Wennborg <hans@hanshq.net>
Tue, 14 Nov 2017 21:09:45 +0000 (21:09 +0000)
commit5765d84997d27e040834eacf0f4010a39fc67aac
tree02d5b1e830049f2e91f52483786fe4a9ed670bc1
parent9c5d8478b13cf3e97b79bde0cae37d7b6eb0674f
Rename CountingFunctionInserter and use for both mcount and cygprofile calls, before and after inlining

Clang implements the -finstrument-functions flag inherited from GCC, which
inserts calls to __cyg_profile_func_{enter,exit} on function entry and exit.

This is useful for getting a trace of how the functions in a program are
executed. Normally, the calls remain even if a function is inlined into another
function, but it is useful to be able to turn this off for users who are
interested in a lower-level trace, i.e. one that reflects what functions are
called post-inlining. (We use this to generate link order files for Chromium.)

LLVM already has a pass for inserting similar instrumentation calls to
mcount(), which it does after inlining. This patch renames and extends that
pass to handle calls both to mcount and the cygprofile functions, before and/or
after inlining as controlled by function attributes.

Differential Revision: https://reviews.llvm.org/D39287

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@318195 91177308-0d34-0410-b5e6-96231b3b80d8
20 files changed:
include/llvm/CodeGen/Passes.h
include/llvm/InitializePasses.h
include/llvm/LinkAllPasses.h
include/llvm/Transforms/Scalar.h
include/llvm/Transforms/Utils/EntryExitInstrumenter.h [new file with mode: 0644]
lib/CodeGen/CMakeLists.txt
lib/CodeGen/CodeGen.cpp
lib/CodeGen/CountingFunctionInserter.cpp [deleted file]
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 [new file with mode: 0644]
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