[llvm-dev] Basic block execution over time

Jonas Wagner via llvm-dev llvm-dev at lists.llvm.org
Sat Oct 29 05:29:44 PDT 2016


Hi,

I believe the easiest way to do this is using the new `trace_pc`
functionality from SanitizerCoverage. See
http://clang.llvm.org/docs/SanitizerCoverage.html#tracing-pcs for some
documentation about that.

In short:

- Compile your program with the `-fsanitize-coverage=trace-pc` flag.
- This adds a call to a function called `__sanitizer_cov_trace_pc` to every
edge in the control-flow graph.
- You can define this function in any way you want (just write C code, and
link it to the application)
- In particular, you can use `__builtin_return_address` to find where the
function was called from. You're then free to dump that address to a file
descriptor, store it in a memory buffer, ...

Cheers,
Jonas

On Fri, Oct 28, 2016 at 5:20 PM Raul Garcia via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

> Hello All,
>
> How can I keep track of the different basic blocks of a program executed
> over time?
> Or in other words, how can I annotate the block name (block_a) and the
> time/cycle at which that blocs (block_a) was executed, and do this for all
> the blocks on a reasonable simple program?
>
> Regards, Raul.
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20161029/bc7d5bd2/attachment.html>


More information about the llvm-dev mailing list