================
@@ -456,3 +463,170 @@ declare void @_ZN5Base35func3Ev(ptr)
   // 1 call instruction from the entry block.
   EXPECT_EQ(F->front().size(), OrigEntryBBSize + 4);
 }
+
+using namespace llvm::ctx_profile;
+
+class ContextManager final {
+  std::vector<std::unique_ptr<char[]>> Nodes;
+  std::map<GUID, const ContextNode *> Roots;
+
+public:
+  ContextNode *createNode(GUID Guid, uint32_t NrCounters, uint32_t NrCallsites,
+                          ContextNode *Next = nullptr) {
+    auto AllocSize = ContextNode::getAllocSize(NrCounters, NrCallsites);
+    auto *Mem = Nodes.emplace_back(std::make_unique<char[]>(AllocSize)).get();
+    std::memset(Mem, 0, AllocSize);
----------------
snehasish wrote:

I think you don't need the memset here.

The make_unique above will zero initialize the memory. See the documentation at 
https://en.cppreference.com/w/cpp/memory/unique_ptr/make_unique

"2) Constructs an array of the given dynamic size. The array elements are 
value-initialized. This overload participates in overload resolution only if T 
is an array of unknown bound."

Also most (all?) implementations of placement new will zero out the memory 
before constructing the object as far as I remember.

https://github.com/llvm/llvm-project/pull/105469
_______________________________________________
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to