diff options
author | Hans Wennborg <hans@hanshq.net> | 2017-11-21 17:30:34 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2017-11-21 17:30:34 +0000 |
commit | c0f88500bdb216836cae033024f43b0024812b55 (patch) | |
tree | 545a6ca5bb07abb45f7251e11245302caf6953e1 /lib/CodeGen/CodeGenFunction.cpp | |
parent | f301ed91f8ffc6899d8e6dc0753e77b84a7092e6 (diff) |
Add -finstrument-function-entry-bare flag
This is an instrumentation flag that's similar to
-finstrument-functions, but it only inserts calls on function entry, the
calls are inserted post-inlining, and they don't take any arugments.
This is intended for users who want to instrument function entry with
minimal overhead.
(-pg would be another alternative, but forces frame pointer emission and
affects link flags, so is probably best left alone to be used for
generating gcov data.)
Differential revision: https://reviews.llvm.org/D40276
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@318785 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r-- | lib/CodeGen/CodeGenFunction.cpp | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp index 8544da3da7..6b8359141b 100644 --- a/lib/CodeGen/CodeGenFunction.cpp +++ b/lib/CodeGen/CodeGenFunction.cpp @@ -355,10 +355,11 @@ void CodeGenFunction::FinishFunction(SourceLocation EndLoc) { llvm::DebugLoc Loc = EmitReturnBlock(); if (ShouldInstrumentFunction()) { - CurFn->addFnAttr(!CGM.getCodeGenOpts().InstrumentFunctionsAfterInlining - ? "instrument-function-exit" - : "instrument-function-exit-inlined", - "__cyg_profile_func_exit"); + if (CGM.getCodeGenOpts().InstrumentFunctions) + CurFn->addFnAttr("instrument-function-exit", "__cyg_profile_func_exit"); + if (CGM.getCodeGenOpts().InstrumentFunctionsAfterInlining) + CurFn->addFnAttr("instrument-function-exit-inlined", + "__cyg_profile_func_exit"); } // Emit debug descriptor for function end. @@ -443,7 +444,8 @@ void CodeGenFunction::FinishFunction(SourceLocation EndLoc) { /// instrumented with __cyg_profile_func_* calls bool CodeGenFunction::ShouldInstrumentFunction() { if (!CGM.getCodeGenOpts().InstrumentFunctions && - !CGM.getCodeGenOpts().InstrumentFunctionsAfterInlining) + !CGM.getCodeGenOpts().InstrumentFunctionsAfterInlining && + !CGM.getCodeGenOpts().InstrumentFunctionEntryBare) return false; if (!CurFuncDecl || CurFuncDecl->hasAttr<NoInstrumentFunctionAttr>()) return false; @@ -982,10 +984,14 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, } if (ShouldInstrumentFunction()) { - Fn->addFnAttr(!CGM.getCodeGenOpts().InstrumentFunctionsAfterInlining - ? "instrument-function-entry" - : "instrument-function-entry-inlined", - "__cyg_profile_func_enter"); + if (CGM.getCodeGenOpts().InstrumentFunctions) + CurFn->addFnAttr("instrument-function-entry", "__cyg_profile_func_enter"); + if (CGM.getCodeGenOpts().InstrumentFunctionsAfterInlining) + CurFn->addFnAttr("instrument-function-entry-inlined", + "__cyg_profile_func_enter"); + if (CGM.getCodeGenOpts().InstrumentFunctionEntryBare) + CurFn->addFnAttr("instrument-function-entry-inlined", + "__cyg_profile_func_enter_bare"); } // Since emitting the mcount call here impacts optimizations such as function |