[llvm] [MemProf] Allow cloning of callsites in recursive cycles (PR #121985)

Snehasish Kumar via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 7 13:14:43 PST 2025


================
@@ -3370,6 +3391,20 @@ void CallsiteContextGraph<DerivedCCG, FuncTy, CallTy>::identifyClones(
 
   assert(Node->AllocTypes != (uint8_t)AllocationType::None);
 
+  DenseSet<uint32_t> RecursiveContextIds;
+  // If we are not skipping recursive callsites, and have also enabled
+  // skipping of recursive contexts, look for context ids that show up in
+  // multiple caller edges.
+  if (!SkipRecursiveCallsites && SkipRecursiveContexts) {
+    DenseSet<uint32_t> AllCallerContextIds;
+    for (auto &CE : Node->CallerEdges) {
+      AllCallerContextIds.reserve(CE->getContextIds().size());
----------------
snehasish wrote:

`AllCallerContextIds` is reused across each CallerEdge without being cleared. I guess the intent here is to reserve it to the size of the largest one? Can you document the intent here?

https://github.com/llvm/llvm-project/pull/121985


More information about the llvm-commits mailing list