aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenFunction.cpp
diff options
context:
space:
mode:
authorRoman Divacky <rdivacky@freebsd.org>2011-02-10 16:52:03 +0000
committerRoman Divacky <rdivacky@freebsd.org>2011-02-10 16:52:03 +0000
commit178e0160b7fc5b14c664c339d7f9b18fad8bdca8 (patch)
tree82954a5fdb9fcc7e3d84a4aedba728c3fb51d645 /clang/lib/CodeGen/CodeGenFunction.cpp
parent89d9f360cdc5369eda8cbbee3794fa33dc629dc2 (diff)
downloadllvm-178e0160b7fc5b14c664c339d7f9b18fad8bdca8.zip
llvm-178e0160b7fc5b14c664c339d7f9b18fad8bdca8.tar.gz
llvm-178e0160b7fc5b14c664c339d7f9b18fad8bdca8.tar.bz2
Implement mcount profiling, enabled via -pg.
llvm-svn: 125282
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
index 66114c8..364f269 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/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,