diff options
Diffstat (limited to 'compiler-rt/lib/xray/tests/unit/function_call_trie_test.cc')
-rw-r--r-- | compiler-rt/lib/xray/tests/unit/function_call_trie_test.cc | 30 |
1 files changed, 30 insertions, 0 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 9b0f21090fb..01be691228f 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,6 +309,36 @@ 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 |