From: Chris Lattner Date: Wed, 23 Jun 2010 05:21:28 +0000 (+0000) Subject: polish the -finstrument-functions implementation, patch by Nelson Elhage! X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8dab6571b2cab96f44d0a1d6e3edbfdb68b7ed6b;p=clang polish the -finstrument-functions implementation, patch by Nelson Elhage! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106618 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp index 8a0b41a7ca..704de3531c 100644 --- a/lib/CodeGen/CodeGenFunction.cpp +++ b/lib/CodeGen/CodeGenFunction.cpp @@ -180,11 +180,14 @@ void CodeGenFunction::EmitFunctionInstrumentation(const char *Fn) { if (!ShouldInstrumentFunction()) return; + const llvm::PointerType *PointerTy; const llvm::FunctionType *FunctionTy; std::vector ProfileFuncArgs; - ProfileFuncArgs.push_back(CurFn->getType()); - ProfileFuncArgs.push_back(llvm::Type::getInt8PtrTy(VMContext)); + // void __cyg_profile_func_{enter,exit} (void *this_fn, void *call_site); + PointerTy = llvm::Type::getInt8PtrTy(VMContext); + ProfileFuncArgs.push_back(PointerTy); + ProfileFuncArgs.push_back(PointerTy); FunctionTy = llvm::FunctionType::get( llvm::Type::getVoidTy(VMContext), ProfileFuncArgs, false); @@ -195,7 +198,9 @@ void CodeGenFunction::EmitFunctionInstrumentation(const char *Fn) { llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext), 0), "callsite"); - Builder.CreateCall2(F, CurFn, CallSite); + Builder.CreateCall2(F, + llvm::ConstantExpr::getBitCast(CurFn, PointerTy), + CallSite); } void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy,