Skip to content

Commit

Permalink
[DebugInfo] don't make an MDTuple just to leak it
Browse files Browse the repository at this point in the history
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.

This seems to be left over from an earlier design, when it used to call
```
CUNode->replaceSubprograms(SPs.get());
```
here also. (removed in http://reviews.llvm.org/D19034)

Reviewed By: aprantl

Differential Revision: https://reviews.llvm.org/D147469
  • Loading branch information
vtjnash committed Apr 4, 2023
1 parent b2f5ab6 commit 9eda46b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion llvm/include/llvm/IR/DIBuilder.h
Expand Up @@ -52,7 +52,7 @@ namespace llvm {
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
Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/IR/DIBuilder.cpp
Expand Up @@ -96,8 +96,7 @@ void DIBuilder::finalize() {
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))
Expand Down

0 comments on commit 9eda46b

Please sign in to comment.