I remember we also spent some time discussing the counter intrinsics, and whether we could produce a different set of intrinsics in the frontend, and produce the counters later in the pipeline to avoid duplicate counters. I didn't completely follow that discussion; I haven't spent much time looking at the counter intrinsics or how they're lowered.
It seemed like we got a lot of questions related to why we aren't using debug info. :) It might be possible to come up with some sort of hybrid which trades off runtime overhead for lower resolution, without completely throwing away regions like gcov does. But it would be a big project, and the end result would still have a lot of the same problems as actual gcov in terms of the optimizer destroying necessary info.
_______________________________________________
LLVM Developers mailing list
llvm...@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
On 25 Oct 2017, at 10:06, Vedant Kumar <v...@apple.com> wrote:Hi Dean,We didn't discuss using XRay instrumentation during the BoF but it is an interesting idea (by the way, thanks for your talk about XRay internals!). XRay provides the advantage of being able to turn profiling on and off, but I'm not sure how the resulting data could be used.
The code coverage feature is highly dependent on the frontend's profile counter placement. The mapping between counters and parts of the AST is used to gather accurate information about regions within a line. For example, the coverage tool can show you that the l.h.s of "true || false" is evaluated once, and the r.h.s isn't evaluated. This works with arbitrarily nested short-circuit operators.
It might be possible to use XRay instrumentation to gather profile data, but I think it will be challenging to precisely map that data back to the AST nodes the frontend knows about. The problem is similar to the one I've outlined in section 3 ("Optimizing profile counter placement"). The idea there is to map a minimal set of counters placed by IR PGO back to AST nodes: the one sketch of a solution I have still depends on running the frontend counter placement pass to achieve this.What are your thoughts on this?
On Oct 25, 2017, at 3:47 AM, Dean Michael Berris <dean....@gmail.com> wrote:
On 25 Oct 2017, at 10:06, Vedant Kumar <v...@apple.com> wrote:Hi Dean,We didn't discuss using XRay instrumentation during the BoF but it is an interesting idea (by the way, thanks for your talk about XRay internals!). XRay provides the advantage of being able to turn profiling on and off, but I'm not sure how the resulting data could be used.The talk was my pleasure -- hopefully when the video comes out, more people can get up to speed on the intricacies involved in making things work. :)The dynamic control might not be as important as being able to patch pre-main and get execution coverage.The code coverage feature is highly dependent on the frontend's profile counter placement. The mapping between counters and parts of the AST is used to gather accurate information about regions within a line. For example, the coverage tool can show you that the l.h.s of "true || false" is evaluated once, and the r.h.s isn't evaluated. This works with arbitrarily nested short-circuit operators.Yes, this is cool stuff. The way we try to do this in XRay is at least to do the following:- When we're lowering the functions into assembler, we're able to maintain a side-table (separate section) that maps where the instrumentation points are. The instrumentation points are currently only automatically placed for function entry and exits. We use heuristics to figure out which functions get instrumented, but can be flag-controlled.- XRay also has support for inserting intrinsics at the IR level that mark "custom events" which take a pointer and a size -- the handler in the XRay runtime can then do what it deems useful to do at these custom event pointer.
The downside to this intrinsic is that it behaves as a function call, and might cause some (re)ordering issues or prevent some important optimisations for code motion. Maybe coverage mode runs don't necessarily care about the optimisations that happen and this is not an issue.
It seems to me that the combination of emitting custom events along with a handler implementation at a basic block level and still be able to correlate information more precisely to the AST (source-level) might be good to do. DWARF info might not be the best thing to use to determine whether a specific sub-line path was taken, but it's certainly helpful. The best I can think of at least with XRay as something to build upon is a way of also marking where at source-level certain branches/blocks are. This might be doable in a compact manner as a CFG path, and if there's a consistent numbering of the CFG paths those could be used to track the counters/latches in some sort of table.I don't have a very clear picture yet in my head how that table might look like or how that's different compared to the way it's being done now, so I'll have to sit on it a bit longer and maybe whiteboard/sketch it out a bit more.
It might be possible to use XRay instrumentation to gather profile data, but I think it will be challenging to precisely map that data back to the AST nodes the frontend knows about. The problem is similar to the one I've outlined in section 3 ("Optimizing profile counter placement"). The idea there is to map a minimal set of counters placed by IR PGO back to AST nodes: the one sketch of a solution I have still depends on running the frontend counter placement pass to achieve this.What are your thoughts on this?There's probably a representation we can use that will indicate which paths in a CFG for a function were visited, and associating which parts of the AST have been covered already. Assuming for example that we can give all paths from a function's entry to a function's exits a unique number (for that function) then we can certainly re-create that path as we're going through the execution path and collect that information for coverage/reconstruction purposes.The advantage of using XRay in the collection path is so you can process the data either in the handler implementation(s) while the program is running and collecting the pre-computed coverage paths somehow (through files, or in memory collection) or even collecting a bit more information and processing it offline (things like collecting frequency and some PMU data while you're at it).
Hi
I’m interested in implementing the solution for the header problem described in (1.) to emit coverage mappings to a side file and unique them when generating coverage reports. As you also mentioned this would require modifying the build workflow. Can you explain how do you suggest changing the build workflow? I tried objcopy-ing the profile data sections from the “.o” files and relinking them again them again but that caused the (just to see if it is possible) but the output raw profile data was not written into.
I’m open to trying any suggestion.
Thanks
A
Hi
I’m interested in implementing the solution for the header problem described in (1.) to emit coverage mappings to a side file and unique them when generating coverage reports. As you also mentioned this would require modifying the build workflow. Can you explain how do you suggest changing the build workflow? I tried objcopy-ing the profile data sections from the “.o” files and relinking them again them again but that caused the (just to see if it is possible) but the output raw profile data was not written into.
I’m open to trying any suggestion.
On Oct 25, 2017, at 3:21 PM, Reid Kleckner <r...@google.com> wrote:On Wed, Oct 25, 2017 at 2:45 PM, Moshtaghi, Alireza via llvm-dev <llvm...@lists.llvm.org> wrote:Hi
I’m interested in implementing the solution for the header problem described in (1.) to emit coverage mappings to a side file and unique them when generating coverage reports. As you also mentioned this would require modifying the build workflow. Can you explain how do you suggest changing the build workflow? I tried objcopy-ing the profile data sections from the “.o” files and relinking them again them again but that caused the (just to see if it is possible) but the output raw profile data was not written into.
I’m open to trying any suggestion.
Isn't that exactly what emitting the coverage data as linkonce_odr accomplishes?
On Oct 24, 2017, at 1:24 PM, Vedant Kumar <v...@apple.com> wrote:Hello,Our goals for the code coverage BoF (10/19) were to find areas where we can improve the coverage tooling, and to learn more about how coverage is used. I'd like to thank all of the attendees for their input and for making the BoF productive. Special thanks to Mandeep Grang, who volunteered as a mic runner at the last minute.In this email I'll share my (rough) notes and outline some future plans. Please feel free to ask for clarifications or to add your own notes.Here are the slides from the BoF:1. The header problemCoverage instrumentation overhead is roughly quadratic in the number of translation units in a project. The problem is that coverage mappings for template instantiations and static inline functions from headers are pulled into every TU. This bloats the profile metadata sections (which can slow down profile I/O), results in large binaries, and causes long link times (or link failures).We could solve this problem by maintaining an external coverage database and discarding duplicate coverage mappings from the DB. Another idea is to emit coverage mappings to a side file and unique them when generating coverage reports. Both ideas require changes to the build workflow.A third option is to emit named coverage mappings with linkonce_odr linkage (for languages with an ODR). This would be a format-breaking change but it wouldn't affect the build workflow. My plan is to try and evaluate this idea in the coming week.
On Oct 30, 2017, at 1:41 PM, Vedant Kumar <v...@apple.com> wrote:
On Oct 24, 2017, at 1:24 PM, Vedant Kumar <v...@apple.com> wrote:Hello,Our goals for the code coverage BoF (10/19) were to find areas where we can improve the coverage tooling, and to learn more about how coverage is used. I'd like to thank all of the attendees for their input and for making the BoF productive. Special thanks to Mandeep Grang, who volunteered as a mic runner at the last minute.In this email I'll share my (rough) notes and outline some future plans. Please feel free to ask for clarifications or to add your own notes.Here are the slides from the BoF:1. The header problemCoverage instrumentation overhead is roughly quadratic in the number of translation units in a project. The problem is that coverage mappings for template instantiations and static inline functions from headers are pulled into every TU. This bloats the profile metadata sections (which can slow down profile I/O), results in large binaries, and causes long link times (or link failures).We could solve this problem by maintaining an external coverage database and discarding duplicate coverage mappings from the DB. Another idea is to emit coverage mappings to a side file and unique them when generating coverage reports. Both ideas require changes to the build workflow.A third option is to emit named coverage mappings with linkonce_odr linkage (for languages with an ODR). This would be a format-breaking change but it wouldn't affect the build workflow. My plan is to try and evaluate this idea in the coming week.Following up on this thread:I found that marking coverage mappings, function records, and names of functions from headers as linkonce_odr results in decent binary size savings. I tested this idea out and reported my results here: https://bugs.llvm.org/show_bug.cgi?id=34533. I think this is the solution we should go with, but am curious to know what others think.thanks,vedant