summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/xray/tests
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2018-12-05 10:19:55 +0000
committerHans Wennborg <hans@hanshq.net>2018-12-05 10:19:55 +0000
commit83ff22c2973738e301b6f547f73e4e807475d2a4 (patch)
treedc1ef0b44d9412ae4a6be30242d043e0e5b33588 /compiler-rt/lib/xray/tests
parent0e216854f93fd6d50974bc83a74b189789c588d6 (diff)
downloadbcm5719-llvm-83ff22c2973738e301b6f547f73e4e807475d2a4.tar.gz
bcm5719-llvm-83ff22c2973738e301b6f547f73e4e807475d2a4.zip
Revert r348335 "[XRay] Move-only Allocator, FunctionCallTrie, and Array"
.. and also the follow-ups r348336 r348338. It broke stand-alone compiler-rt builds with GCC 4.8: In file included from /work/llvm/projects/compiler-rt/lib/xray/xray_function_call_trie.h:20:0,                  from /work/llvm/projects/compiler-rt/lib/xray/xray_profile_collector.h:21,                  from /work/llvm/projects/compiler-rt/lib/xray/xray_profile_collector.cc:15: /work/llvm/projects/compiler-rt/lib/xray/xray_segmented_array.h: In instantiation of ‘T* __xray::Array<T>::AppendEmplace(Args&& ...) [with Args = {const __xray::FunctionCallTrie::mergeInto(__xray::FunctionCallTrie&) const::NodeAndTarget&}; T = __xray::FunctionCallTrie::mergeInto(__xray::FunctionCallTrie&) const::NodeAndTarget]’: /work/llvm/projects/compiler-rt/lib/xray/xray_segmented_array.h:383:71:   required from ‘T* __xray::Array<T>::Append(const T&) [with T = __xray::FunctionCallTrie::mergeInto(__xray::FunctionCallTrie&) const::NodeAndTarget]’ /work/llvm/projects/compiler-rt/lib/xray/xray_function_call_trie.h:517:54:   required from here /work/llvm/projects/compiler-rt/lib/xray/xray_segmented_array.h:378:5: error: could not convert ‘{std::forward<const __xray::FunctionCallTrie::mergeInto(__xray::FunctionCallTrie&) const::NodeAndTarget&>((* & args#0))}’ from ‘<brace-enclosed initializer list>’ to ‘__xray::FunctionCallTrie::mergeInto(__xray::FunctionCallTrie&) const::NodeAndTarget’      new (AlignedOffset) T{std::forward<Args>(args)...};      ^ /work/llvm/projects/compiler-rt/lib/xray/xray_segmented_array.h: In instantiation of ‘T* __xray::Array<T>::AppendEmplace(Args&& ...) [with Args = {const __xray::profileCollectorService::{anonymous}::ThreadTrie&}; T = __xray::profileCollectorService::{anonymous}::ThreadTrie]’: /work/llvm/projects/compiler-rt/lib/xray/xray_segmented_array.h:383:71:   required from ‘T* __xray::Array<T>::Append(const T&) [with T = __xray::profileCollectorService::{anonymous}::ThreadTrie]’ /work/llvm/projects/compiler-rt/lib/xray/xray_profile_collector.cc:98:34:   required from here /work/llvm/projects/compiler-rt/lib/xray/xray_segmented_array.h:378:5: error: could not convert ‘{std::forward<const __xray::profileCollectorService::{anonymous}::ThreadTrie&>((* & args#0))}’ from ‘<brace-enclosed initializer list>’ to ‘__xray::profileCollectorService::{anonymous}::ThreadTrie’ /work/llvm/projects/compiler-rt/lib/xray/xray_segmented_array.h: In instantiation of ‘T* __xray::Array<T>::AppendEmplace(Args&& ...) [with Args = {const __xray::profileCollectorService::{anonymous}::ProfileBuffer&}; T = __xray::profileCollectorService::{anonymous}::ProfileBuffer]’: /work/llvm/projects/compiler-rt/lib/xray/xray_segmented_array.h:383:71:   required from ‘T* __xray::Array<T>::Append(const T&) [with T = __xray::profileCollectorService::{anonymous}::ProfileBuffer] ’ /work/llvm/projects/compiler-rt/lib/xray/xray_profile_collector.cc:244:44:   required from here /work/llvm/projects/compiler-rt/lib/xray/xray_segmented_array.h:378:5: error: could not convert ‘{std::forward<const __xray::profileCollectorService::{anonymous}::ProfileBuffer&>((* & args#0))}’ from ‘<brace-enclosed initializer list>’ to ‘__xray::profileCollectorService::{anonymous}::ProfileBuffer’ > Summary: > This change makes the allocator and function call trie implementations > move-aware and remove the FunctionCallTrie's reliance on a > heap-allocated set of allocators. > > The change makes it possible to always have storage associated with > Allocator instances, not necessarily having heap-allocated memory > obtainable from these allocator instances. We also use thread-local > uninitialised storage. > > We've also re-worked the segmented array implementation to have more > precondition and post-condition checks when built in debug mode. This > enables us to better implement some of the operations with surrounding > documentation as well. The `trim` algorithm now has more documentation > on the implementation, reducing the requirement to handle special > conditions, and being more rigorous on the computations involved. > > In this change we also introduce an initialisation guard, through which > we prevent an initialisation operation from racing with a cleanup > operation. > > We also ensure that the ThreadTries array is not destroyed while copies > into the elements are still being performed by other threads submitting > profiles. > > Note that this change still has an issue with accessing thread-local > storage from signal handlers that are instrumented with XRay. We also > learn that with the testing of this patch, that there will be cases > where calls to mmap(...) (through internal_mmap(...)) might be called in > signal handlers, but are not async-signal-safe. Subsequent patches will > address this, by re-using the `BufferQueue` type used in the FDR mode > implementation for pre-allocated memory segments per active, tracing > thread. > > We still want to land this change despite the known issues, with fixes > forthcoming. > > Reviewers: mboerger, jfb > > Subscribers: jfb, llvm-commits > > Differential Revision: https://reviews.llvm.org/D54989 llvm-svn: 348346
Diffstat (limited to 'compiler-rt/lib/xray/tests')
-rw-r--r--compiler-rt/lib/xray/tests/unit/function_call_trie_test.cc30
-rw-r--r--compiler-rt/lib/xray/tests/unit/segmented_array_test.cc86
2 files changed, 0 insertions, 116 deletions
diff --git a/compiler-rt/lib/xray/tests/unit/function_call_trie_test.cc b/compiler-rt/lib/xray/tests/unit/function_call_trie_test.cc
index 01be691228f..9b0f21090fb 100644
--- a/compiler-rt/lib/xray/tests/unit/function_call_trie_test.cc
+++ b/compiler-rt/lib/xray/tests/unit/function_call_trie_test.cc
@@ -309,36 +309,6 @@ TEST(FunctionCallTrieTest, MergeInto) {
EXPECT_EQ(F2.Callees.size(), 0u);
}
-TEST(FunctionCallTrieTest, PlacementNewOnAlignedStorage) {
- profilingFlags()->setDefaults();
- typename std::aligned_storage<sizeof(FunctionCallTrie::Allocators),
- alignof(FunctionCallTrie::Allocators)>::type
- AllocatorsStorage;
- new (&AllocatorsStorage)
- FunctionCallTrie::Allocators(FunctionCallTrie::InitAllocators());
- auto *A =
- reinterpret_cast<FunctionCallTrie::Allocators *>(&AllocatorsStorage);
-
- typename std::aligned_storage<sizeof(FunctionCallTrie),
- alignof(FunctionCallTrie)>::type FCTStorage;
- new (&FCTStorage) FunctionCallTrie(*A);
- auto *T = reinterpret_cast<FunctionCallTrie *>(&FCTStorage);
-
- // Put some data into it.
- T->enterFunction(1, 0, 0);
- T->exitFunction(1, 1, 0);
-
- // Re-initialize the objects in storage.
- T->~FunctionCallTrie();
- A->~Allocators();
- new (A) FunctionCallTrie::Allocators(FunctionCallTrie::InitAllocators());
- new (T) FunctionCallTrie(*A);
-
- // Then put some data into it again.
- T->enterFunction(1, 0, 0);
- T->exitFunction(1, 1, 0);
-}
-
} // namespace
} // namespace __xray
diff --git a/compiler-rt/lib/xray/tests/unit/segmented_array_test.cc b/compiler-rt/lib/xray/tests/unit/segmented_array_test.cc
index 73120aafc8e..80991b1b97a 100644
--- a/compiler-rt/lib/xray/tests/unit/segmented_array_test.cc
+++ b/compiler-rt/lib/xray/tests/unit/segmented_array_test.cc
@@ -221,91 +221,5 @@ TEST(SegmentedArrayTest, SimulateStackBehaviour) {
}
}
-TEST(SegmentedArrayTest, PlacementNewOnAlignedStorage) {
- using AllocatorType = typename Array<ShadowStackEntry>::AllocatorType;
- typename std::aligned_storage<sizeof(AllocatorType),
- alignof(AllocatorType)>::type AllocatorStorage;
- new (&AllocatorStorage) AllocatorType(1 << 10);
- auto *A = reinterpret_cast<AllocatorType *>(&AllocatorStorage);
- typename std::aligned_storage<sizeof(Array<ShadowStackEntry>),
- alignof(Array<ShadowStackEntry>)>::type
- ArrayStorage;
- new (&ArrayStorage) Array<ShadowStackEntry>(*A);
- auto *Data = reinterpret_cast<Array<ShadowStackEntry> *>(&ArrayStorage);
-
- static uint64_t Dummy = 0;
- constexpr uint64_t Max = 9;
-
- for (uint64_t i = 0; i < Max; ++i) {
- auto P = Data->Append({i, &Dummy});
- ASSERT_NE(P, nullptr);
- ASSERT_EQ(P->NodePtr, &Dummy);
- auto &Back = Data->back();
- ASSERT_EQ(Back.NodePtr, &Dummy);
- ASSERT_EQ(Back.EntryTSC, i);
- }
-
- // Simulate a stack by checking the data from the end as we're trimming.
- auto Counter = Max;
- ASSERT_EQ(Data->size(), size_t(Max));
- while (!Data->empty()) {
- const auto &Top = Data->back();
- uint64_t *TopNode = Top.NodePtr;
- EXPECT_EQ(TopNode, &Dummy) << "Counter = " << Counter;
- Data->trim(1);
- --Counter;
- ASSERT_EQ(Data->size(), size_t(Counter));
- }
-
- // Once the stack is exhausted, we re-use the storage.
- for (uint64_t i = 0; i < Max; ++i) {
- auto P = Data->Append({i, &Dummy});
- ASSERT_NE(P, nullptr);
- ASSERT_EQ(P->NodePtr, &Dummy);
- auto &Back = Data->back();
- ASSERT_EQ(Back.NodePtr, &Dummy);
- ASSERT_EQ(Back.EntryTSC, i);
- }
-
- // We re-initialize the storage, by calling the destructor and
- // placement-new'ing again.
- Data->~Array();
- A->~AllocatorType();
- new (A) AllocatorType(1 << 10);
- new (Data) Array<ShadowStackEntry>(*A);
-
- // Then re-do the test.
- for (uint64_t i = 0; i < Max; ++i) {
- auto P = Data->Append({i, &Dummy});
- ASSERT_NE(P, nullptr);
- ASSERT_EQ(P->NodePtr, &Dummy);
- auto &Back = Data->back();
- ASSERT_EQ(Back.NodePtr, &Dummy);
- ASSERT_EQ(Back.EntryTSC, i);
- }
-
- // Simulate a stack by checking the data from the end as we're trimming.
- Counter = Max;
- ASSERT_EQ(Data->size(), size_t(Max));
- while (!Data->empty()) {
- const auto &Top = Data->back();
- uint64_t *TopNode = Top.NodePtr;
- EXPECT_EQ(TopNode, &Dummy) << "Counter = " << Counter;
- Data->trim(1);
- --Counter;
- ASSERT_EQ(Data->size(), size_t(Counter));
- }
-
- // Once the stack is exhausted, we re-use the storage.
- for (uint64_t i = 0; i < Max; ++i) {
- auto P = Data->Append({i, &Dummy});
- ASSERT_NE(P, nullptr);
- ASSERT_EQ(P->NodePtr, &Dummy);
- auto &Back = Data->back();
- ASSERT_EQ(Back.NodePtr, &Dummy);
- ASSERT_EQ(Back.EntryTSC, i);
- }
-}
-
} // namespace
} // namespace __xray
OpenPOWER on IntegriCloud