This is an archive of the discontinued LLVM Phabricator instance.

[esan] Add circular buffer data structure
ClosedPublic

Authored by bruening on May 24 2016, 10:21 AM.

Details

Summary

Adds a new class, CircularBuffer, for holding a wrap-around fixed-size
sequence of a primitive data type. This will be used initially by the
working set tool.

Adds a unit test for CircularBuffer, including infrastructure support to
include esan headers and to link with the esan library by pretending to
want the working set tool.

Diff Detail

Repository
rL LLVM

Event Timeline

bruening updated this revision to Diff 58264.May 24 2016, 10:21 AM
bruening retitled this revision from to [esan] Add circular buffer data structure.
bruening updated this object.
bruening added a reviewer: aizatsky.
bruening added subscribers: llvm-commits, eugenis, kcc and 2 others.
aizatsky added inline comments.May 24 2016, 2:56 PM
lib/esan/esan_circular_buffer.h
20 ↗(On Diff #58264)

Document that you need to call "initialize/free" rather than rely on constructors/destructors.

26 ↗(On Diff #58264)

If you plan to have local-instances of this class (which I assume you don't), then please follow the tsan pattern with in-place new and

static ALIGNED(16) char thread_registry_placeholder[sizeof(ThreadRegistry)];

This would result in much better reusable utility class.

filcab added a subscriber: filcab.May 25 2016, 9:25 AM

LGTM.

Unsure if I'd place the unit test like that, or just in the same dir as the regular esan tests.
ASan (and I guess the other sanitizers') unit tests are very different from regular tests.

bruening updated this revision to Diff 58557.May 25 2016, 7:33 PM
bruening marked 2 inline comments as done.

Add placement new support.

filcab accepted this revision.May 26 2016, 9:10 AM
filcab added a reviewer: filcab.
This revision is now accepted and ready to land.May 26 2016, 9:10 AM
This revision was automatically updated to reflect the committed changes.
vitalybuka added inline comments.May 31 2016, 4:43 PM
compiler-rt/trunk/lib/esan/esan_circular_buffer.h
43

private: free() ?

bruening added inline comments.May 31 2016, 5:55 PM
compiler-rt/trunk/lib/esan/esan_circular_buffer.h
43

See the comment at lines 19-22: one usage pattern is to explicitly call free so it needs to be public.