[llvm] [MemProf] Ensure all callsite clones are assigned a function clone (PR #150735)

Snehasish Kumar via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 26 10:43:50 PDT 2025


================
@@ -2060,6 +2062,18 @@ static bool isMemProfClone(const Function &F) {
   return F.getName().contains(MemProfCloneSuffix);
 }
 
+// Return the clone number of the given function by extracting it from the
+// memprof suffix. Assumes the caller has already confirmed it is a memprof
+// clone.
+static unsigned getMemProfCloneNum(const Function &F) {
+  assert(isMemProfClone(F));
+  auto Pos = F.getName().find_last_of('.');
+  assert(Pos > 0);
+  unsigned CloneNo;
+  F.getName().drop_front(Pos + 1).getAsInteger(10, CloneNo);
----------------
snehasish wrote:

We should assert on the return value of getAsInteger to ensure it was parsed correctly. Note that, unintuitively, it returns true on error.

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


More information about the llvm-commits mailing list