Skip to content

Commit

Permalink
DIBuilder: Don't rauw null pointers with empty arrays in finalize().
Browse files Browse the repository at this point in the history
This makes the IR a little easier to read.

llvm-svn: 241470
  • Loading branch information
adrian-prantl committed Jul 6, 2015
1 parent fbdab43 commit 4276d4a
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions llvm/lib/IR/DIBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,14 @@ void DIBuilder::finalize() {
for (unsigned I = 0, E = AllRetainTypes.size(); I < E; I++)
if (RetainSet.insert(AllRetainTypes[I]).second)
RetainValues.push_back(AllRetainTypes[I]);
CUNode->replaceRetainedTypes(MDTuple::get(VMContext, RetainValues));

if (!RetainValues.empty())
CUNode->replaceRetainedTypes(MDTuple::get(VMContext, RetainValues));

DISubprogramArray SPs = MDTuple::get(VMContext, AllSubprograms);
CUNode->replaceSubprograms(SPs.get());
if (!AllSubprograms.empty())
CUNode->replaceSubprograms(SPs.get());

for (auto *SP : SPs) {
if (MDTuple *Temp = SP->getVariables().get()) {
const auto &PV = PreservedVariables.lookup(SP);
Expand All @@ -103,11 +107,13 @@ void DIBuilder::finalize() {
}
}

CUNode->replaceGlobalVariables(MDTuple::get(VMContext, AllGVs));
if (!AllGVs.empty())
CUNode->replaceGlobalVariables(MDTuple::get(VMContext, AllGVs));

CUNode->replaceImportedEntities(MDTuple::get(
VMContext, SmallVector<Metadata *, 16>(AllImportedModules.begin(),
AllImportedModules.end())));
if (!AllImportedModules.empty())
CUNode->replaceImportedEntities(MDTuple::get(
VMContext, SmallVector<Metadata *, 16>(AllImportedModules.begin(),
AllImportedModules.end())));

// Now that all temp nodes have been replaced or deleted, resolve remaining
// cycles.
Expand Down

0 comments on commit 4276d4a

Please sign in to comment.