summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/xray
Commit message (Collapse)AuthorAgeFilesLines
...
* [XRay] Migrate FDR runtime to use refactored controllerDean Michael Berris2018-10-303-650/+238
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This change completes the refactoring of the FDR runtime to support the following: - Generational buffer management. - Centralised and well-tested controller implementation. In this change we've had to: - Greatly simplify the code in xray_fdr_logging.cc to only implement the glue code for calling into the controller. - Implement the custom and typed event logging functions in the FDRLogWriter. - Imbue the `XRAY_NEVER_INSTRUMENT` attribute onto all functions in the controller implementation. Reviewers: mboerger, eizan, jfb Subscribers: jfb, llvm-commits Differential Revision: https://reviews.llvm.org/D53858 llvm-svn: 345568
* [XRay] Guard call to postCurrentThreadFCT()Dean Michael Berris2018-10-291-5/+16
| | | | | | | | | | | | | | | | | | | | | Summary: Some cases where `postCurrentThreadFCT()` are not guarded by our recursion guard. We've observed that sometimes these can lead to deadlocks when some functions (like memcpy()) gets outlined and the version of memcpy is XRay-instrumented, which can be materialised by the compiler in the implementation of lower-level components used by the profiling runtime. This change ensures that all calls to `postCurrentThreadFCT` are guarded by our thread-recursion guard, to prevent deadlocks. Reviewers: mboerger, eizan Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D53805 llvm-svn: 345489
* [XRay] Use more portable control blockDean Michael Berris2018-10-293-60/+75
| | | | | | | | | | | | | | | | | | | | Summary: In D53560, we assumed a specific layout for memory without using an explicit structure. This follow-up change uses more portable layout control by using unions in a struct, and consolidating the memory management code in the buffer queue. We also take the opportunity to improve the documentation on the types and operations, along with simplifying some of the logic in the buffer queue implementation. Reviewers: mboerger, eizan Subscribers: jfb, llvm-commits Differential Revision: https://reviews.llvm.org/D53802 llvm-svn: 345485
* [XRay] Refcount backing store for buffersDean Michael Berris2018-10-282-8/+67
| | | | | | | | | | | | | | | | | | | | Summary: This change implements the ref-counting for backing stores associated with generational buffer management. We do this as an implementation detail of the buffer queue, instead of exposing this to the interface. This change allows us to keep the buffer queue interface and usage model the same. Depends on D53551. Reviewers: mboerger, eizan Subscribers: jfb, llvm-commits Differential Revision: https://reviews.llvm.org/D53560 llvm-svn: 345471
* [XRay] Support generational buffers in FDR controllerDean Michael Berris2018-10-272-41/+80
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This is an intermediary step in the full support for generational buffer management in the FDR runtime. This change makes the FDR controller aware of the new generation number in the buffers handed out by the BufferQueue type. In the process of making this change, we've realised that the cleanest way of ensuring that the backing store per generation is live while all the threads that need access to it will need reference counting to tie the backing store to the lifetime of all threads that have a handle on buffers associated with the memory. We also learn that we're missing the edge-case in the function exit handler's implementation where the first record being written into the buffer is a function exit, which is caught/fixed by the test for generational buffer management. We still haven't wired the controller into the FDR mode runtime, which will need the reference counting on the backing store implemented to ensure that we're being conservatively thread-safe with this approach. Depends on D52974. Reviewers: mboerger, eizan Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D53551 llvm-svn: 345445
* [XRay] Account for virtual memory re-useDean Michael Berris2018-10-221-3/+1
| | | | | | | Change the assumption when releasing memory to a buffer queue that new generations might not be able to re-use the memory mapped addresses. llvm-svn: 344882
* [XRay][compiler-rt] Generational Buffer ManagementDean Michael Berris2018-10-224-64/+238
| | | | | | | | | | | | | | | | | | | | | | | | Summary: This change updates the buffer queue implementation to support using a generation number to identify the lifetime of buffers. This first part introduces the notion of the generation number, without changing the way we handle the buffers yet. What's missing here is the cleanup of the buffers. Ideally we'll keep the two most recent generations. We need to ensure that before we do any writes to the buffers, that we check the generation number(s) first. Those changes will follow-on from this change. Depends on D52588. Reviewers: mboerger, eizan Subscribers: llvm-commits, jfb Differential Revision: https://reviews.llvm.org/D52974 llvm-svn: 344881
* [XRay] Handle allocator exhaustion in segmented arrayDean Michael Berris2018-10-223-5/+48
| | | | | | | | | | | | | | | | | Summary: This change allows us to handle allocator exhaustion properly in the segmented array implementation. Before this change, we relied on the caller of the `trim` function to provide a valid number of elements to trim. This change allows us to do the right thing in case the elements to trim is greater than the size of the container. Reviewers: mboerger, eizan Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D53484 llvm-svn: 344880
* Revert commit r344670 as the test fails on a bot ↵Douglas Yung2018-10-194-233/+62
| | | | | | http://lab.llvm.org:8011/builders/clang-cmake-armv7-full/builds/2683/. llvm-svn: 344771
* [XRay][compiler-rt] Generational Buffer ManagementDean Michael Berris2018-10-174-62/+233
| | | | | | | | | | | | | | | | | | | | | | | | Summary: This change updates the buffer queue implementation to support using a generation number to identify the lifetime of buffers. This first part introduces the notion of the generation number, without changing the way we handle the buffers yet. What's missing here is the cleanup of the buffers. Ideally we'll keep the two most recent generations. We need to ensure that before we do any writes to the buffers, that we check the generation number(s) first. Those changes will follow-on from this change. Depends on D52588. Reviewers: mboerger, eizan Subscribers: llvm-commits, jfb Differential Revision: https://reviews.llvm.org/D52974 llvm-svn: 344670
* [XRay] Use fully qualified name for LogWriterPetr Hosek2018-10-161-1/+1
| | | | | | This avoids the build error in newer versions of GCC. llvm-svn: 344579
* [XRay] Encapsulate all FD log related logic into a classPetr Hosek2018-10-165-105/+84
| | | | | | | | | | This abstracts away the file descriptor related logic which makes it easier to port XRay to platform that don't use file descriptors or file system for writing the log data, such as Fuchsia. Differential Revision: https://reviews.llvm.org/D52161 llvm-svn: 344578
* [XRay][compiler-rt] FDR Mode ControllerDean Michael Berris2018-10-158-29/+758
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This change implements a controller for abstracting away the details of what happens when tracing with FDR mode. This controller type allows us to test in isolation the various cases where we're encountering function entry, exit, and other kinds of events we are handling when FDR mode is enabled. This change introduces a number of testing facilities we've needed to better support expressing the conditions we need for the unit tests. We leave some TODOs for moving those utilities into the LLVM project, sitting in the `Testing` library, to make matching conditions on XRay `Trace` instances through googlemock more manageable and declarative. We don't wire in the controller right away, to allow us to incrementally update the implementation(s) as we increase testing coverage of the controller type. There's a need to re-think the way we're managing buffers in a multi-threaded environment, which is more invasive than this implementation. This step in the process allows us to encode our assumptions in the implementation of the controller, and then evolve the buffer queue implementation to support generational buffer management to ensure we can continue to support the cases we're already supporting with the controller. Reviewers: mboerger, eizan Subscribers: mgorny, llvm-commits, jfb Differential Revision: https://reviews.llvm.org/D52588 llvm-svn: 344488
* Introduce internal_sysctlbyname in place of sysctlbynameKamil Rytarowski2018-10-051-5/+6
| | | | | | | | | | | | | | | | | | Summary: This change will allow to install sysctlbyname() interceptors more easily in sanitizers. Reviewers: vitalybuka, joerg Reviewed By: vitalybuka Subscribers: kubamracek, llvm-commits, #sanitizers Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D52793 llvm-svn: 343840
* Remove a path-length limitation for the xray logfile.Douglas Yung2018-10-011-3/+2
| | | | | | | | | | | | Reviewers: MaskRay Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D52728 Patch by Jeremy Morse! llvm-svn: 343524
* [XRay] Guard local variables with `static` and struct with unnamed namespacesFangrui Song2018-09-282-6/+11
| | | | | | | | | | | | | | | | | Summary: This is for coding standard conformance, and for fixing an ODR violation issue: __xray::ThreadLocalData is defined twice and differently in xray_fdr_logging.cc and xray_basic_logging.cc Reviewers: dberris, mboerger, eizan Reviewed By: dberris Subscribers: delcypher, jfb, llvm-commits, #sanitizers Differential Revision: https://reviews.llvm.org/D52639 llvm-svn: 343289
* [XRay] Add LD_LIBRARY_PATH to env variables for Unit TestsDean Michael Berris2018-09-271-5/+5
| | | | | | | | | | | | | | | | | Summary: This change allows us to use the library path from which the LLVM libraries are installed, in case the LLVM installation generates shared libraries. This should address llvm.org/PR39070. Reviewers: mboerger, eizan Subscribers: mgorny, jfb, llvm-commits Differential Revision: https://reviews.llvm.org/D52597 llvm-svn: 343280
* [XRay] Clean up XRay build configurationDean Michael Berris2018-09-242-16/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This change spans both LLVM and compiler-rt, where we do the following: - Add XRay to the LLVMBuild system, to allow for distributing the XRay trace loading library along with the LLVM distributions. - Use `llvm-config` better in the compiler-rt XRay implementation, to depend on the potentially already-distributed LLVM XRay library. While this is tested with the standalone compiler-rt build, it does require that the LLVMXRay library (and LLVMSupport as well) are available during the build. In case the static libraries are available, the unit tests will build and work fine. We're still having issues with attempting to use a shared library version of the LLVMXRay library since the shared library might not be accessible from the standard shared library lookup paths. The larger change here is the inclusion of the LLVMXRay library in the distribution, which allows for building tools around the XRay traces and profiles that the XRay runtime already generates. Reviewers: echristo, beanz Subscribers: mgorny, hiraditya, mboerger, llvm-commits Differential Revision: https://reviews.llvm.org/D52349 llvm-svn: 342859
* [XRay][compiler-rt] Update use of internal_mmapDean Michael Berris2018-09-214-36/+41
| | | | | | | | | | | | | | | | | | | | | | | | Summary: The implementation of `internal_mmap(...)` deviates from the contract of `mmap(...)` -- i.e. error returns are actually the equivalent of `errno` results. We update how XRay uses `internal_mmap(...)` to better handle these error conditions. In the process, we change the default pointers we're using from `char*` to `uint8_t*` to prevent potential usage of the pointers in the string library functions that expect to operate on `char*`. We also take the chance to "promote" sizes of individual `internal_mmap` requests to at least page size bytes, consistent with the expectations of calls to `mmap`. Reviewers: cryptoad, mboerger Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D52361 llvm-svn: 342745
* [XRay][compiler-rt] FDRLogWriter AbstractionDean Michael Berris2018-09-206-88/+289
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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. We also add the terminfo library detection along with inclusion of the appropriate compiler flags for header include lookup. 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. Reviewers: mboerger, eizan Subscribers: mgorny, jfb, llvm-commits Differential Revision: https://reviews.llvm.org/D52220 llvm-svn: 342617
* Revert "[XRay][compiler-rt] FDRLogWriter Abstraction" and 1 more.Evgeniy Stepanov2018-09-196-284/+87
| | | | | | | | Revert the following 2 commits to fix standalone compiler-rt build: * r342523 [XRay] Detect terminfo library * r342518 [XRay][compiler-rt] FDRLogWriter Abstraction llvm-svn: 342596
* [XRay] Detect terminfo libraryDean Michael Berris2018-09-191-1/+6
| | | | | | | | | Instead of assuming `-ltinfo` works, check whether there's terminfo support on the host where LLVMSupport is compiled. Follow-up to D52220. llvm-svn: 342523
* [XRay][compiler-rt] FDRLogWriter AbstractionDean Michael Berris2018-09-186-87/+279
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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. Reviewers: mboerger, eizan Subscribers: mgorny, jfb, llvm-commits Differential Revision: https://reviews.llvm.org/D52220 llvm-svn: 342518
* [XRay] Simplify FDR buffer managementDean Michael Berris2018-09-174-102/+95
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This change makes XRay FDR mode use a single backing store for the buffer queue, and have indexes into that backing store instead. We also remove the reliance on the internal allocator implementation in the FDR mode logging implementation. In the process of making this change we found an inconsistency with the way we're returning buffers to the queue, and how we're setting the extents. We take the chance to simplify the way we're managing the extents of each buffer. It turns out we do not need the indirection for the extents, so we co-host the atomic 64-bit int with the buffer object. It also seems that we've not been returning the buffers for the thread running the flush functionality when writing out the files, so we can run into a situation where we could be missing data. We consolidate all the allocation routines now into xray_allocator.h, where we used to have routines defined in xray_buffer_queue.cc. Reviewers: mboerger, eizan Subscribers: jfb, llvm-commits Differential Revision: https://reviews.llvm.org/D52077 llvm-svn: 342356
* [XRay] Fix FDR initializationDean Michael Berris2018-09-171-3/+14
| | | | | | Follow-up to D51606. llvm-svn: 342355
* [XRay] Remove the deprecated __xray_log_init APIPetr Hosek2018-09-155-323/+72
| | | | | | | | | This API has been deprecated three months ago and shouldn't be used anymore, all clients should migrate to the new string based API. Differential Revision: https://reviews.llvm.org/D51606 llvm-svn: 342318
* [XRay] Bug fixes for FDR custom event and arg-loggingDean Michael Berris2018-09-131-18/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This change has a number of fixes for FDR mode in compiler-rt along with changes to the tooling handling the traces in llvm. In the runtime, we do the following: - Advance the "last record" pointer appropriately when writing the custom event data in the log. - Add XRAY_NEVER_INSTRUMENT in the rewinding routine. - When collecting the argument of functions appropriately marked, we should not attempt to rewind them (and reset the counts of functions that can be re-wound). In the tooling, we do the following: - Remove the state logic in BlockIndexer and instead rely on the presence/absence of records to indicate blocks. - Move the verifier into a loop associated with each block. Reviewers: mboerger, eizan Subscribers: llvm-commits, hiraditya Differential Revision: https://reviews.llvm.org/D51965 llvm-svn: 342122
* [XRay] XRAY_NEVER_INSTRUMENT more functions, consolidate allocatorsDean Michael Berris2018-09-075-101/+144
| | | | | | | | | | | | | | | | | | | | | | Summary: In this change we apply `XRAY_NEVER_INSTRUMENT` to more functions in the profiling implementation to ensure that these never get instrumented if the compiler used to build the library is capable of doing XRay instrumentation. We also consolidate all the allocators into a single header (xray_allocator.h) which sidestep the use of the internal allocator implementation in sanitizer_common. This addresses more cases mentioned in llvm.org/PR38577. Reviewers: mboerger, eizan Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D51776 llvm-svn: 341647
* [Xray] Darwin providing defined value for weak symbols to fix linkage issueDavid Carlier2018-09-051-0/+9
| | | | | | - Temporary hack to make the buildbot failure stop on Darwin. llvm-svn: 341445
* [Xray] Darwin fix variable typoDavid Carlier2018-08-301-1/+1
| | | | llvm-svn: 341090
* [Xray] Darwin improving slightly the supportDavid Carlier2018-08-302-3/+6
| | | | | | | | | | | | | using sysctl to get the tic frequency data. still linkage issue for X-ray_init not resolved. Reviewers: dberris, kubamracek Reviewed By: dberris Differential Revision: https://reviews.llvm.org/D51399 llvm-svn: 341019
* [XRay][compiler-rt] Remove uses of internal allocator in profiling modeDean Michael Berris2018-08-281-24/+30
| | | | | | | | | | | | | | | | | | Summary: This change removes further cases where the profiling mode implementation relied on dynamic memory allocation. We're using thread-local aligned (uninitialized) memory instead, which we initialize appropriately with placement new. Addresses llvm.org/PR38577. Reviewers: eizan, kpw Subscribers: jfb, llvm-commits Differential Revision: https://reviews.llvm.org/D51278 llvm-svn: 340814
* [XRay][compiler-rt] Stash flags as well in x86_64 trampolineDean Michael Berris2018-08-281-0/+2
| | | | | | | | | | | | | | | | Summary: This change saves and restores the full flags register in x86_64 mode. This makes running instrumented signal handlers safer, and avoids flags set during the execution of the event handlers from polluting the instrumented call's flags state. Reviewers: kpw, eizan, jfb Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D51277 llvm-svn: 340812
* [XRay][compiler-rt] Avoid InternalAlloc(...) in Profiling ModeDean Michael Berris2018-08-172-102/+112
| | | | | | | | | | | | | | | | | | | | | | | | Summary: We avoid using dynamic memory allocated with the internal allocator in the profile collection service used by profiling mode. We use aligned storage for globals and in-struct storage of objects we dynamically initialize. We also remove the dependency on `Vector<...>` which also internally uses the dynamic allocator in sanitizer_common (InternalAlloc) in favour of the XRay allocator and segmented array implementation. This change addresses llvm.org/PR38577. Reviewers: eizan Reviewed By: eizan Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D50782 llvm-svn: 339978
* [XRay][compiler-rt] Remove MAP_NORESERVE from XRay allocationsDean Michael Berris2018-08-162-27/+3
| | | | | | | | | | | | | | | | | | | Summary: This reverses an earlier decision to allow seg-faulting from the XRay-allocated memory if it turns out that the system cannot provide physical memory backing that cannot be swapped in/out on Linux. This addresses http://llvm.org/PR38588. Reviewers: eizan Reviewed By: eizan Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D50831 llvm-svn: 339869
* [XRay][compiler-rt] Update test to use similar structureDean Michael Berris2018-07-311-3/+3
| | | | | | This is a follow-up to D50037. llvm-svn: 338349
* [XRay][compiler-rt] Profiling Mode: Include file header in buffersDean Michael Berris2018-07-313-21/+64
| | | | | | | | | | | | | | | | | Summary: This change provides access to the file header even in the in-memory buffer processing. This allows in-memory processing of the buffers to also check the version, and the format, of the profile data. Reviewers: eizan, kpw Reviewed By: eizan Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D50037 llvm-svn: 338347
* [XRay][compiler-rt] FDR Mode: Use mmap instead of internal allocatorDean Michael Berris2018-07-301-11/+44
| | | | | | | | | | | | | | | | | | | | | Summary: This change moves FDR mode to use `internal_mmap(...)` from sanitizer_common instead of the internal allocator interface. We're doing this to sidestep the alignment issues we encounter with the `InternalAlloc(...)` functions returning pointers that have some magic bytes at the beginning. XRay copies bytes into the buffer memory, and does not require the magic bytes tracking the other sanitizers use when allocating/deallocating buffers. Reviewers: kpw, eizan Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D49972 llvm-svn: 338228
* [Xray] fix c99 warning build about flexible array semanticsDavid Carlier2018-07-201-1/+1
| | | | | | | | | | Reviewers: dberris Reviewed By: dberris Differential Revision: https://reviews.llvm.org/D49590 llvm-svn: 337536
* [XRay][compiler-rt] Profiling: No files when emptyDean Michael Berris2018-07-191-23/+27
| | | | | | | | | This change makes it so that the profiling mode implementation will only write files when there are buffers to write. Before this change, we'd always open a file even if there were no profiles collected when flushing. llvm-svn: 337443
* [XRay][compiler-rt] FDR Mode: Add extents metadata to bufferDean Michael Berris2018-07-191-2/+30
| | | | | | | | | | | | When providing raw access to the FDR mode buffers, we used to not include the extents metadata record. This oversight means that processing the buffers in-memory will lose important information that would have been written in files. This change exposes the metadata record by serializing the data similarly to how we would do it when flushing to files. llvm-svn: 337441
* [Xray] Fix allocator build, MAP_NORESERVE flag is not always supportedDavid Carlier2018-07-191-1/+6
| | | | | | | | | | | | MAP_NORESERVE is not supported or a no-op on BSD. Reviewers: dberris Reviewed By: dberris Differential Revision: https://reviews.llvm.org/D49494 llvm-svn: 337440
* [XRay][compiler-rt] Segmented Array: Simplify and OptimiseDean Michael Berris2018-07-185-232/+215
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This is a follow-on to D49217 which simplifies and optimises the implementation of the segmented array. In this patch we co-locate the book-keeping for segments in the `__xray::Array<T>` with the data it's managing. We take the chance in this patch to actually rename `Chunk` to `Segment` to better align with the high-level description of the segmented array. With measurements using benchmarks landed in D48879, we've identified that calls to `pthread_getspecific` started dominating the cycles, which led us to revert the change made in D49217 to use C++ thread_local initialisation instead (it reduces the cost by a huge margin, since we save one PLT-based call to pthread functions in the hot path). In particular, this is in `__xray::getThreadLocalData()`. We also took the opportunity to remove the least-common-multiple based calculation and instead pack as much data into segments of the array. This greatly simplifies the API of the container which hides as much of the implementation details as possible. For instance, we calculate the number of elements we need for the each segment internally in the Array instead of making it part of the type. With the changes here, we're able to get a measurable improvement on the performance of profiling mode on top of what D48879 already provides. Depends on D48879. Reviewers: kpw, eizan Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D49363 llvm-svn: 337343
* [XRay][compiler-rt] Simplify Allocator ImplementationDean Michael Berris2018-07-1810-216/+245
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This change simplifies the XRay Allocator implementation to self-manage an mmap'ed memory segment instead of using the internal allocator implementation in sanitizer_common. We've found through benchmarks and profiling these benchmarks in D48879 that using the internal allocator in sanitizer_common introduces a bottleneck on allocating memory through a central spinlock. This change allows thread-local allocators to eliminate contention on the centralized allocator. To get the most benefit from this approach, we also use a managed allocator for the chunk elements used by the segmented array implementation. This gives us the chance to amortize the cost of allocating memory when creating these internal segmented array data structures. We also took the opportunity to remove the preallocation argument from the allocator API, simplifying the usage of the allocator throughout the profiling implementation. In this change we also tweak some of the flag values to reduce the amount of maximum memory we use/need for each thread, when requesting memory through mmap. Depends on D48956. Reviewers: kpw, eizan Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D49217 llvm-svn: 337342
* [XRay][compiler-rt] FDR Mode: Allow multiple runsDean Michael Berris2018-07-181-33/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Fix a bug in FDR mode which didn't allow for re-initialising the logging in the same process. This change ensures that: - When we flush the FDR mode logging, that the state of the logging implementation is `XRAY_LOG_UNINITIALIZED`. - Fix up the thread-local initialisation to use aligned storage and `pthread_getspecific` as well as `pthread_setspecific` for the thread-specific data. - Actually use the pointer provided to the thread-exit cleanup handling, instead of assuming that the thread has thread-local data associated with it, and reaching at thread-exit time. In this change we also have an explicit test for two consecutive sessions for FDR mode tracing, and ensuring both sessions succeed. Reviewers: kpw, eizan Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D49359 llvm-svn: 337341
* [CMake] Use cxx-headers as a depedency for C++ headersPetr Hosek2018-07-161-2/+2
| | | | | | | | | | | | We no longer pass CLANG_DEFAULT_CXX_STDLIB to the runtimes build as it was causing issues so we can no longer use this variable. We instead use cxx-headers as a dependency whenever this is available since both XRay and libFuzzer are built as static libraries so this is sufficient. Differential Revision: https://reviews.llvm.org/D49346 llvm-svn: 337199
* Test commitHenry Zhu2018-07-161-1/+1
| | | | llvm-svn: 337176
* [XRay][compiler-rt] Use `SANITIZER_CXX_ABI_LIBRARY` for XRay unit testsDean Michael Berris2018-07-161-2/+2
| | | | | | | | | | | | | | | | | | Summary: Fix a TODO in CMake config for XRay tests to use the detected C++ ABI library in the tests. Also make the tests depend on the llvm-xray target when built in-tree. Reviewers: kpw, eizan Reviewed By: eizan Subscribers: mgorny, llvm-commits Differential Revision: https://reviews.llvm.org/D49358 llvm-svn: 337142
* [XRay][compiler-rt] Add PID field to llvm-xray tool and add PID metadata ↵Dean Michael Berris2018-07-134-9/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | record entry in FDR mode Summary: llvm-xray changes: - account-mode - process-id {...} shows after thread-id - convert-mode - process {...} shows after thread - parses FDR and basic mode pid entries - Checks version number for FDR log parsing. Basic logging changes: - Update header version from 2 -> 3 FDR logging changes: - Update header version from 2 -> 3 - in writeBufferPreamble, there is an additional PID Metadata record (after thread id record and tsc record) Test cases changes: - fdr-mode.cc, fdr-single-thread.cc, fdr-thread-order.cc modified to catch process id output in the log. Reviewers: dberris Reviewed By: dberris Subscribers: hiraditya, llvm-commits, #sanitizers Differential Revision: https://reviews.llvm.org/D49153 llvm-svn: 336974
* [XRay][compiler-rt] Profiling Mode: Flush logs on exitDean Michael Berris2018-07-133-34/+79
| | | | | | | | | | | | | | | | | Summary: This change adds support for writing out profiles at program exit. Depends on D48653. Reviewers: kpw, eizan Reviewed By: kpw Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D48956 llvm-svn: 336969
OpenPOWER on IntegriCloud