Program analysis tools can be valuable for debugging program correctness and performance issues, even more so for multi-threaded programs. Some of these tools need to know about certain events in the program. For example, race detection for Intel® Cilk™ Plus programs requires knowing precisely when spawn and sync events happen. Similar events are necessary to analyze Intel® TBB programs and OpenMP.
To facilitate interoperation of compilers and such tools, we have posted an open specification open specification of a feature for communicating such events from the compiled code to the analysis tool. The feature consists of two compiler intrinsics and an extension to the executable format. We're already using the feature in:
- The Intel compiler implementation of Cilk Plus.
and of course working on adding it to the Cilk Plus development branch of GCC, so that code generated by that GCC branch will be analyzable by the aforementioned Intel tools. See the link "Intrinsics for Low Overhead Tool Annotations" on the page Intel® Cilk™ Plus Specification for the specification.
The feature is not limited to Cilk Plus -- it's a general mechanism for communicating events. Better yet, it exists as a compiler intrinsic function, so that you can mark up your own code with your own events, and not just rely on ones created by the compiler. Of course you’ll need an analysis tool that understands your events. We’re working on a library to make it easy for users of Pin to decode the events.
The feature avoids the overhead of the traditional approach of reporting an event with a subroutine call, which incurs run-time overhead even if the subroutine does nothing when the program is not being analyzed. The feature creates a table in the executable of where the events are, and optionally a no-op instruction that can be overwritten by a tool like Pin if you need to instrument the event. We've been careful to design the extension to the executable format so that only the compiler and analysis tool need to understand it. Other parts of the tool chain such as the assembler and linker do not have to understand it, unless they attempt a level of code rewriting not normally seen in such tools.
The specification is intended to enable compilers to generate the annotations and program analysis tools to consume the annotations. As an example, it shows how we use the annotation mechanism to mark Intel® Cilk™ Plus programs.
So if you are interested in program analysis tools, please take a look at the specification.