diff options
author | Hans Wennborg <hans@hanshq.net> | 2017-11-14 21:09:45 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2017-11-14 21:09:45 +0000 |
commit | 5765d84997d27e040834eacf0f4010a39fc67aac (patch) | |
tree | 02d5b1e830049f2e91f52483786fe4a9ed670bc1 /test/CodeGen/PowerPC | |
parent | 9c5d8478b13cf3e97b79bde0cae37d7b6eb0674f (diff) |
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
Diffstat (limited to 'test/CodeGen/PowerPC')
-rw-r--r-- | test/CodeGen/PowerPC/mcount-insertion.ll | 40 |
1 files changed, 35 insertions, 5 deletions
diff --git a/test/CodeGen/PowerPC/mcount-insertion.ll b/test/CodeGen/PowerPC/mcount-insertion.ll index 04e8571d6f4..cbb7947be21 100644 --- a/test/CodeGen/PowerPC/mcount-insertion.ll +++ b/test/CodeGen/PowerPC/mcount-insertion.ll @@ -1,16 +1,46 @@ -; RUN: llc < %s | FileCheck %s +; RUN: opt -ee-instrument < %s | opt -inline | llc | FileCheck %s + +; The run-line mimics how Clang might run the instrumentation passes. + target datalayout = "E-m:e-i64:64-n32:64" target triple = "powerpc64-bgq-linux" -define void @test1() #0 { + +define void @leaf_function() #0 { entry: ret void -; CHECK-LABEL: @test1 +; CHECK-LABEL: leaf_function: ; CHECK: bl mcount -; CHECK-NOT: mcount +; CHECK-NOT: bl +; CHECK: bl __cyg_profile_func_enter +; CHECK-NOT: bl +; CHECK: bl __cyg_profile_func_exit +; CHECK-NOT: bl ; CHECK: blr } -attributes #0 = { "counting-function"="mcount" } +define void @root_function() #0 { +entry: + call void @leaf_function() + ret void + +; CHECK-LABEL: root_function: +; CHECK: bl mcount +; CHECK-NOT: bl +; CHECK: bl __cyg_profile_func_enter +; CHECK-NOT: bl + +; Entry and exit calls, inlined from @leaf_function() +; CHECK: bl __cyg_profile_func_enter +; CHECK-NOT: bl +; CHECK: bl __cyg_profile_func_exit +; CHECK-NOT: bl + +; CHECK: bl __cyg_profile_func_exit +; CHECK-NOT: bl +; CHECK: blr +} + +attributes #0 = { "instrument-function-entry-inlined"="mcount" "instrument-function-entry"="__cyg_profile_func_enter" "instrument-function-exit"="__cyg_profile_func_exit" } |