DebugInfo: Avoid re-looking up the DwarfUnit when emitting pubnames/pubtypes
llvm-svn: 203620
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 93cd89e..45a90dc 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -2212,6 +2212,9 @@
const StringMap<const DIE *> &(DwarfUnit::*Accessor)() const) {
for (const auto &NU : CUMap) {
DwarfCompileUnit *TheU = NU.second;
+
+ const auto &Globals = (TheU->*Accessor)();
+
if (auto Skeleton = static_cast<DwarfCompileUnit *>(TheU->getSkeleton()))
TheU = Skeleton;
unsigned ID = TheU->getUniqueID();
@@ -2237,7 +2240,7 @@
Asm->EmitLabelDifference(TheU->getLabelEnd(), TheU->getLabelBegin(), 4);
// Emit the pubnames for this compilation unit.
- for (const auto &GI : (getUnits()[ID]->*Accessor)()) {
+ for (const auto &GI : Globals) {
const char *Name = GI.getKeyData();
const DIE *Entity = GI.second;