This is an archive of the discontinued LLVM Phabricator instance.

[XRay][compiler-rt] FDRLogWriter Abstraction
ClosedPublic

Authored by dberris on Sep 18 2018, 12:18 AM.

Details

Summary

This change introduces an FDRLogWriter type which is responsible for
serialising metadata and function records to character buffers. This is
the first step in a refactoring of the implementation of the FDR runtime
to allow for more granular testing of the individual components of the
implementation.

The main contribution of this change is a means of hiding the details of
how specific records are written to a buffer, and for managing the
extents of these buffers. We make use of C++ features (templates and
some metaprogramming) to reduce repetition in the act of writing out
specific kinds of records to the buffer.

In this process, we make a number of changes across both LLVM and
compiler-rt to allow us to use the Trace abstraction defined in the
LLVM project in the testing of the runtime implementation. This gives us
a closer end-to-end test which version-locks the runtime implementation
with the loading implementation in LLVM.

We also allow using gmock in compiler-rt unit tests, by adding the
requisite definitions in the AddCompilerRT.cmake module.

Finally, we've gone ahead and updated the FDR logging implementation to
use the FDRLogWriter for the lowest-level record-writing details.

Following patches will isolate the state machine transitions which
manage the set-up and tear-down of the buffers we're using in multiple
threads.

Diff Detail

Repository
rL LLVM

Event Timeline

dberris created this revision.Sep 18 2018, 12:18 AM
This revision is now accepted and ready to land.Sep 18 2018, 12:49 AM
dberris updated this revision to Diff 165915.Sep 18 2018, 3:17 AM
dberris edited the summary of this revision. (Show Details)

Update the FDR logging implementation to use the FDRLogWriter implementation. This is ready for another look.

mboerger added inline comments.Sep 18 2018, 5:18 AM
compiler-rt/lib/xray/xray_fdr_log_writer.h
35 ↗(On Diff #165915)

Shouldn't this be: std::forward(T)

dberris updated this revision to Diff 165945.Sep 18 2018, 5:42 AM
dberris marked an inline comment as done.

Address comments by @mboerger.

compiler-rt/lib/xray/xray_fdr_log_writer.h
35 ↗(On Diff #165915)

Good catch, yes!

dberris updated this revision to Diff 165946.Sep 18 2018, 5:58 AM

Update test to reflect usage in fdr logging runtime.

This revision was automatically updated to reflect the committed changes.