Implement mcount profiling, enabled via -pg.

llvm-svn: 125282
This commit is contained in:
Roman Divacky
2011-02-10 16:52:03 +00:00
parent 89d9f360cd
commit 178e0160b7
9 changed files with 50 additions and 7 deletions

View File

@@ -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,