[PATCH] added enter-leave pass to instrument entering and leaving functions
Bob Haarman via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 5 14:26:21 PST 2015
Hi Diego,
Thanks for taking a look! Responses inline, below.
On 2015-11-05 07:11 , Diego Novillo wrote:
> I've got a few high-level questions before I get into the patch itself.
>
> - What's the goal of this pass? Tracing? Handwritten profiling of
> whole functions?
We have several cases where developers end up wanting some custom code
to be run when specific code paths are entered or left. One example of
this is instrumenting all functions that use the network to gather some
information such as how long the networked request took and logging that
information through a custom logging framework. Developers have been
writing code for this by hand, but we can save some developer effort and
keep the source code of the application closer to its core logic by
having the appropriate calls automatically generated. By injecting
function calls and leaving the implementation of these functions to the
developer, we can accommodate present and future use cases.
> - What semantics do you want to have wrt languages that use mangling
> to separate member functions, overloading, namespaces, etc?
As a start, I focused on just having this work on the (possibly mangled)
symbol level. Since the code that actually inserts the instrumentation
is separate from the parser, we can later do something more advanced,
such as allowing C++ or Objective C signatures and deriving the mangled
name from there.
> - The pass seems to do nothing else but insert these calls, wouldn't
> it make more sense to do this as a clang tool? It would give you more
> expressive power for the user to specify where they want to insert the
> enter/leave functions.
Since this is generically applicable, regardless of programming
language, I figured I would implement it as an IR pass in LLVM. That
way, we have no dependency on Clang and we can also make this
functionality available to other front ends.
> - Should all exit points be instrumented? What happens in the case of
> exceptions or noreturn points in the function flow?
We do eventually want to instrument all exit points. I decided to just
handle returns for the first iteration. I have some code in the works to
handle non-local control flow, but it's not quite ready to go yet.
Cheers,
Bob
More information about the llvm-commits
mailing list