[PATCH] D147469: [DebugInfo] don't make an MDTuple just to leak it

Jameson Nash via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 3 13:42:59 PDT 2023


vtjnash created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
vtjnash requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

There does not seem to be any purpose to allocating this object, which
is Metadata, so LLVM will simply leak it until the context is destroyed
(the subprogram metadata it contains are distinct, so there is little
chance of it being reused later). This should not have a functional
change.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147469

Files:
  llvm/include/llvm/IR/DIBuilder.h
  llvm/lib/IR/DIBuilder.cpp


Index: llvm/lib/IR/DIBuilder.cpp
===================================================================
--- llvm/lib/IR/DIBuilder.cpp
+++ llvm/lib/IR/DIBuilder.cpp
@@ -96,8 +96,7 @@
   if (!RetainValues.empty())
     CUNode->replaceRetainedTypes(MDTuple::get(VMContext, RetainValues));
 
-  DISubprogramArray SPs = MDTuple::get(VMContext, AllSubprograms);
-  for (auto *SP : SPs)
+  for (auto *SP : AllSubprograms)
     finalizeSubprogram(SP);
   for (auto *N : RetainValues)
     if (auto *SP = dyn_cast<DISubprogram>(N))
Index: llvm/include/llvm/IR/DIBuilder.h
===================================================================
--- llvm/include/llvm/IR/DIBuilder.h
+++ llvm/include/llvm/IR/DIBuilder.h
@@ -52,7 +52,7 @@
     SmallVector<TrackingMDNodeRef, 4> AllEnumTypes;
     /// Track the RetainTypes, since they can be updated later on.
     SmallVector<TrackingMDNodeRef, 4> AllRetainTypes;
-    SmallVector<Metadata *, 4> AllSubprograms;
+    SmallVector<DISubprogram *, 4> AllSubprograms;
     SmallVector<Metadata *, 4> AllGVs;
     SmallVector<TrackingMDNodeRef, 4> AllImportedModules;
     /// Map Macro parent (which can be DIMacroFile or nullptr) to a list of


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147469.510594.patch
Type: text/x-patch
Size: 1172 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230403/eae5a8ec/attachment.bin>


More information about the llvm-commits mailing list