diff options
| author | Adrian Prantl <aprantl@apple.com> | 2015-07-06 16:36:02 +0000 |
|---|---|---|
| committer | Adrian Prantl <aprantl@apple.com> | 2015-07-06 16:36:02 +0000 |
| commit | 4276d4a8d08b7640eb57cabf6988a5cf65b228b6 (patch) | |
| tree | adf57de33acf99c026e27666afc5710ea107deee /llvm/lib | |
| parent | fbdab437f01fea995c6778b62444ea57bfe25a66 (diff) | |
| download | bcm5719-llvm-4276d4a8d08b7640eb57cabf6988a5cf65b228b6.tar.gz bcm5719-llvm-4276d4a8d08b7640eb57cabf6988a5cf65b228b6.zip | |
DIBuilder: Don't rauw null pointers with empty arrays in finalize().
This makes the IR a little easier to read.
llvm-svn: 241470
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/IR/DIBuilder.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/llvm/lib/IR/DIBuilder.cpp b/llvm/lib/IR/DIBuilder.cpp index 1aa7685b629..453ea00a003 100644 --- a/llvm/lib/IR/DIBuilder.cpp +++ b/llvm/lib/IR/DIBuilder.cpp @@ -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); @@ -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. |

