[cfe-commits] [patch] Implement -finstrument-functions
Chris Lattner
clattner at apple.com
Fri Jun 18 22:04:53 PDT 2010
On Jun 18, 2010, at 8:41 PM, Nelson Elhage wrote:
>
> This patch implements the -finstrument-functions flag, which adds calls
> to instrument function entry and exit.
Oh no! Why did you implement this in clang instead of as an llvm optimization pass??
Haha, just kidding ;-)
Overall, the patch looks great. Please copy the comments for ShouldInstrumentFunction/EmitFunctionInstrumentation from the header into the implementation. Here are a few minor coding changes:
+void CodeGenFunction::EmitFunctionInstrumentation(const char *Fn) {
...
+ PointerTy = llvm::PointerType::getUnqual(
+ llvm::Type::getInt8Ty(VMContext));
This can use Type::getInt8PtrTy(VMContext)
+ llvm::Constant *F = CGM.getModule().getOrInsertFunction(Fn, FunctionTy);
This should probably use CodeGenModule::CreateRuntimeFunction instead of doing it manually.
+ if (Builder.isNamePreserving())
+ CallSite->setName("callsite");
You should be able to pass the name directly into the call to "CreateCall"
+ llvm::ConstantExpr::getBitCast(CurFn, PointerTy),
This can go away when you use CreateRuntimeFunction.
+static void HandleNoInstrumentFunctionAttr(Decl *d, const AttributeList &Attr, Sema &S) {
+ // check the attribute arguments.
Please stay in 80 cols.
Otherwise, the patch looks great! Thanks for adding this, please send in a revised patch and I'm happy to commit it for you if you don't already have commit access.
-Chris
More information about the cfe-commits
mailing list