[llvm] [MemProf] Stop cloning traversal on single allocation type (PR #126131)

Teresa Johnson via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 6 13:06:36 PST 2025


https://github.com/teresajohnson created https://github.com/llvm/llvm-project/pull/126131

We were previously checking this after recursing on all callers, but if
we already have a single allocation type there is no need to even look
at any callers. Didn't show a significant improvement overall, but it
does reduce the count of times we enter the identifyClones and do other
checks.


>From 3eeb41b1b51578522aa0e9f1ad6fde90ae9dc205 Mon Sep 17 00:00:00 2001
From: Teresa Johnson <tejohnson at google.com>
Date: Thu, 6 Feb 2025 13:01:09 -0800
Subject: [PATCH] [MemProf] Stop cloning traversal on single allocation type

We were previously checking this after recursing on all callers, but if
we already have a single allocation type there is no need to even look
at any callers. Didn't show a significant improvement overall, but it
does reduce the count of times we enter the identifyClones and do other
checks.
---
 llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp b/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
index f6764be9b273e7..d748b162d78094 100644
--- a/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
+++ b/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
@@ -3407,6 +3407,10 @@ void CallsiteContextGraph<DerivedCCG, FuncTy, CallTy>::identifyClones(
   if (!Node->hasCall())
     return;
 
+  // No need to look at any callers if allocation type already unambiguous.
+  if (hasSingleAllocType(Node->AllocTypes))
+    return;
+
 #ifndef NDEBUG
   auto Insert =
 #endif



More information about the llvm-commits mailing list