[cfe-commits] r106618 - /cfe/trunk/lib/CodeGen/CodeGenFunction.cpp

Chris Lattner sabre at nondot.org
Tue Jun 22 22:21:28 PDT 2010


Author: lattner
Date: Wed Jun 23 00:21:28 2010
New Revision: 106618

URL: http://llvm.org/viewvc/llvm-project?rev=106618&view=rev
Log:
polish the -finstrument-functions implementation, patch by Nelson Elhage!

Modified:
    cfe/trunk/lib/CodeGen/CodeGenFunction.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=106618&r1=106617&r2=106618&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Wed Jun 23 00:21:28 2010
@@ -180,11 +180,14 @@
   if (!ShouldInstrumentFunction())
     return;
 
+  const llvm::PointerType *PointerTy;
   const llvm::FunctionType *FunctionTy;
   std::vector<const llvm::Type*> 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 @@
     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,





More information about the cfe-commits mailing list