[llvm] 774b12c - [memprof] Initialize AllocInfoIter and CallSitesIter (NFC) (#124972)

via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 29 14:31:04 PST 2025


Author: Kazu Hirata
Date: 2025-01-29T14:31:00-08:00
New Revision: 774b12c4a06bd68f314bd741be0eb77a1cb49b7d

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

LOG: [memprof] Initialize AllocInfoIter and CallSitesIter (NFC) (#124972)

This patch initializes AllocInfoIter and CallSitesIter to their
respective end().  I'm doing this not because I'm worried about
uninitialized iterators, but because the resulting code looks shorter
and makes it clear which data structure each iterator is associated
with.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Instrumentation/MemProfiler.cpp b/llvm/lib/Transforms/Instrumentation/MemProfiler.cpp
index 9a7eec76cc1d1d..91c48338d03208 100644
--- a/llvm/lib/Transforms/Instrumentation/MemProfiler.cpp
+++ b/llvm/lib/Transforms/Instrumentation/MemProfiler.cpp
@@ -1096,9 +1096,8 @@ readMemprof(Module &M, Function &F, IndexedInstrProfReader *MemProfReader,
       // can happen because we don't currently have discriminators to
       // distinguish the case when a single line/col maps to both an allocation
       // and another callsite).
-      std::map<uint64_t, std::set<const AllocationInfo *>>::iterator
-          AllocInfoIter;
-      decltype(LocHashToCallSites)::iterator CallSitesIter;
+      auto AllocInfoIter = LocHashToAllocInfo.end();
+      auto CallSitesIter = LocHashToCallSites.end();
       for (const DILocation *DIL = I.getDebugLoc(); DIL != nullptr;
            DIL = DIL->getInlinedAt()) {
         // Use C++ linkage name if possible. Need to compile with


        


More information about the llvm-commits mailing list