]> granicus.if.org Git - clang/commit
[Frontend] Fix mcount inlining bug
authorHonggyu Kim <hong.gyu.kim@lge.com>
Thu, 1 Sep 2016 11:29:21 +0000 (11:29 +0000)
committerHonggyu Kim <hong.gyu.kim@lge.com>
Thu, 1 Sep 2016 11:29:21 +0000 (11:29 +0000)
commit3752b19a9d76733a32732781edd8aa218451b61d
treebacd250702fc729f182c40551fa46247316d064e
parent6f75e6dfd196db1df92974ff9c5a5b3c69ca682d
[Frontend] Fix mcount inlining bug

Since some profiling tools, such as gprof, ftrace, and uftrace, use
-pg option to generate a mcount function call at the entry of each
function. Function invocation can be detected by this hook function.

But mcount insertion is done before function inlining phase in clang,
sometime a function that already has a mcount call can be inlined in the
middle of another function.

This patch adds an attribute "counting-function" to each function
rather than emitting the mcount call directly in frontend so that this
attribute can be processed in backend. Then the mcount calls can be
properly inserted in backend after all the other optimizations are
completed.

Link: https://llvm.org/bugs/show_bug.cgi?id=28660
Reviewers: hans, rjmccall, hfinkel, rengolin, compnerd

Subscribers: shenhan, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@280355 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/CodeGenFunction.cpp
test/CodeGen/mcount.c
test/Frontend/gnu-mcount.c