[llvm] a270fdf - [memprof] Simplify control flow in readMemProf (NFC) (#149764)

via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 21 09:11:12 PDT 2025


Author: Kazu Hirata
Date: 2025-07-21T09:11:08-07:00
New Revision: a270fdf3fe58dff7093c8bc1c7ffbd03c0268d66

URL: https://github.com/llvm/llvm-project/commit/a270fdf3fe58dff7093c8bc1c7ffbd03c0268d66
DIFF: https://github.com/llvm/llvm-project/commit/a270fdf3fe58dff7093c8bc1c7ffbd03c0268d66.diff

LOG: [memprof] Simplify control flow in readMemProf (NFC) (#149764)

Now that readMemProf calls two helper functions handleAllocSite and
handleCallSite, we can simplify the control flow.  We don't need to
use "continue" anymore.

Added: 
    

Modified: 
    llvm/lib/Transforms/Instrumentation/MemProfUse.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Instrumentation/MemProfUse.cpp b/llvm/lib/Transforms/Instrumentation/MemProfUse.cpp
index 6e57b99c3233f..a9a0731f16d90 100644
--- a/llvm/lib/Transforms/Instrumentation/MemProfUse.cpp
+++ b/llvm/lib/Transforms/Instrumentation/MemProfUse.cpp
@@ -653,20 +653,15 @@ static void readMemprof(Module &M, Function &F,
       // allocation context with the same leaf.
       if (AllocInfoIter != LocHashToAllocInfo.end() &&
           // Only consider allocations which support hinting.
-          isAllocationWithHotColdVariant(CI->getCalledFunction(), TLI)) {
+          isAllocationWithHotColdVariant(CI->getCalledFunction(), TLI))
         handleAllocSite(I, CI, InlinedCallStack, Ctx, ORE, MaxColdSize,
                         AllocInfoIter->second, FullStackIdToAllocMatchInfo);
-        continue;
-      }
-
-      if (CallSitesIter == LocHashToCallSites.end())
-        continue;
-
-      // Otherwise, add callsite metadata. If we reach here then we found the
-      // instruction's leaf location in the callsites map and not the allocation
-      // map.
-      handleCallSite(I, CalledFunction, InlinedCallStack, CallSitesIter->second,
-                     M, MatchedCallSites);
+      else if (CallSitesIter != LocHashToCallSites.end())
+        // Otherwise, add callsite metadata. If we reach here then we found the
+        // instruction's leaf location in the callsites map and not the
+        // allocation map.
+        handleCallSite(I, CalledFunction, InlinedCallStack,
+                       CallSitesIter->second, M, MatchedCallSites);
     }
   }
 }


        


More information about the llvm-commits mailing list