Page MenuHomePhabricator

Add -finstrument-function-entry-bare flag
ClosedPublic

Authored by hans on Nov 20 2017, 4:48 PM.

Details

Summary

This is an instrumentation flag, similar to -finstrument-functions, but it only inserts calls on function entry, the calls are inserted post-inlining, and they don't take any arugments.

This is intended for users who want to instrument function entry with minimal overhead.

(-pg would be another alternative, but foces frame pointer emission and affects linking, so is probably best left alone to be used for generating gcov data.)

Diff Detail

Repository
rL LLVM

Event Timeline

hans created this revision.Nov 20 2017, 4:48 PM
pasko accepted this revision.Nov 21 2017, 4:40 AM

Instrumenting the function entry post-inlining, without function exit, and with no parameters is exactly what we need. The __cyg_profile_func_enter_bare sounds good to me as a name. Thank you!

Unnecessary thoughts just to get a feeling we are on the same page: this could theoretically be made more orthogonal where -finstrument-functions-after-inlining could regulate whether the call is pre- or post-inlining, but I don't see how pre-inlining without parameters would be usable without too much DWARF digging, which is not too practical.

This revision is now accepted and ready to land.Nov 21 2017, 4:40 AM
mattcary added a subscriber: mattcary.EditedNov 21 2017, 7:36 AM

It looks like there also has to be a change to llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp?

(I realize that seems to be in a slightly different part of the tree than clang, but have no idea how to best coordinate the change)

Index: lib/Transforms/Utils/EntryExitInstrumenter.cpp

  • lib/Transforms/Utils/EntryExitInstrumenter.cpp (revision 318760)

+++ lib/Transforms/Utils/EntryExitInstrumenter.cpp (working copy)
@@ -51,6 +51,10 @@

CallInst::Create(Fn, ArrayRef<Value *>(Args), "", InsertionPt);
return;

+ } else if (Func == "__cyg_profile_func_enter_bare") {
+ Constant *Fn = M.getOrInsertFunction(Func, Type::getVoidTy(C));
+ CallInst::Create(Fn, "", InsertionPt);
+ return;

}
 
// We only know how to call a fixed set of instrumentation functions, because
hans added a comment.Nov 21 2017, 8:52 AM

Reid, are you happy with this too?

Instrumenting the function entry post-inlining, without function exit, and with no parameters is exactly what we need. The __cyg_profile_func_enter_bare sounds good to me as a name. Thank you!

Great!

Unnecessary thoughts just to get a feeling we are on the same page: this could theoretically be made more orthogonal where -finstrument-functions-after-inlining could regulate whether the call is pre- or post-inlining, but I don't see how pre-inlining without parameters would be usable without too much DWARF digging, which is not too practical.

The way I think about them, these flags all enable separate instrumentations (though you can only enable one at a time), they don't modify eachother as I think that might end up messier for the user.

It looks like there also has to be a change to llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp?

Yes, I'll land that in llvm once we're happy with this. I just wanted to make sure we get the flag and function names right, then the rest is trivial.

rnk accepted this revision.Nov 21 2017, 8:58 AM

Yep, looks good. :)

This revision was automatically updated to reflect the committed changes.