[lttng-dev] How do tracepoint macros interact with the optimizer?
zhenya1007 at gmail.com
Thu Nov 17 15:34:59 UTC 2016
Dear LTTNG users and developers,
I would like to know how the tracepoint macro interacts with the compiler's
code optimizer (I am specifically interested in GCC 4.9 if that makes a
Suppose I add a tracepoint to the section of code that the optimizer would
have eliminated, and then compile with optimization. What happens? Does
the optimizer eliminate the statement(s) that the tracepoint macro expands
to? Or does the tracepoint macro do something to force the optimizer to
keep the statement(s) in? (e.g., declare some variable volatile, or some
Now essentially the same question about local variables. To make things
simple, let's imagine that my tracepoint definition has a single variable
declared inside TP_ARGS, i.e., something like:
TP_ARGS (int, foo_arg),
TP_FIELDS( ctf_integer(int, foo, foo_arg)))
Let's also imagine that, in my code, I have an automatic local variable,
(let's call it `bar`) that would normally be "optimized out", and I add a
tracepoint statement that references "bar", and compile with optimization.
What happens? Specifically, can it happen that the optimizer is now
prevented from "optimizing out" `bar`, and is, e.g., forced to
stack-allocated it (rather than keeping it in a register, or whatever other
techniques it employs to "optimize it out").
Please Cc me on replies as I am not subscribed to the list.
Thank you in advance!
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the lttng-dev