diff options
author | Roman Divacky <rdivacky@freebsd.org> | 2011-02-10 16:52:03 +0000 |
---|---|---|
committer | Roman Divacky <rdivacky@freebsd.org> | 2011-02-10 16:52:03 +0000 |
commit | be4c8705e499b55548467eb7adaa23cbc6edfef9 (patch) | |
tree | 180fd2910e4cbbdcd9dca8d8e7d54e347c7a3ccc /lib/CodeGen/CodeGenFunction.cpp | |
parent | 9186ff310cf0ad92ec7f39b2c9dcb7e848195052 (diff) |
Implement mcount profiling, enabled via -pg.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125282 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r-- | lib/CodeGen/CodeGenFunction.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp index 66114c87a4..364f2697e6 100644 --- a/lib/CodeGen/CodeGenFunction.cpp +++ b/lib/CodeGen/CodeGenFunction.cpp @@ -210,6 +210,15 @@ void CodeGenFunction::EmitFunctionInstrumentation(const char *Fn) { CallSite); } +void CodeGenFunction::EmitMCountInstrumentation() { + llvm::FunctionType *FTy = + llvm::FunctionType::get(llvm::Type::getVoidTy(getLLVMContext()), false); + + llvm::Constant *MCountFn = CGM.CreateRuntimeFunction(FTy, + Target.getMCountName()); + Builder.CreateCall(MCountFn); +} + void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy, llvm::Function *Fn, const FunctionArgList &Args, @@ -260,6 +269,9 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy, EmitFunctionInstrumentation("__cyg_profile_func_enter"); + if (CGM.getCodeGenOpts().InstrumentForProfiling) + EmitMCountInstrumentation(); + // FIXME: Leaked. // CC info is ignored, hopefully? CurFnInfo = &CGM.getTypes().getFunctionInfo(FnRetTy, Args, |