[lld] r346578 - [PDB] Simplify some ghash code, NFC

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 9 17:36:02 PST 2018


Author: rnk
Date: Fri Nov  9 17:36:02 2018
New Revision: 346578

URL: http://llvm.org/viewvc/llvm-project?rev=346578&view=rev
Log:
[PDB] Simplify some ghash code, NFC

Instead of calling the same function twice with different parameters,
make the parameters depend on the condition.

Modified:
    lld/trunk/COFF/PDB.cpp

Modified: lld/trunk/COFF/PDB.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/PDB.cpp?rev=346578&r1=346577&r2=346578&view=diff
==============================================================================
--- lld/trunk/COFF/PDB.cpp (original)
+++ lld/trunk/COFF/PDB.cpp Fri Nov  9 17:36:02 2018
@@ -158,6 +158,20 @@ public:
   void addSections(ArrayRef<OutputSection *> OutputSections,
                    ArrayRef<uint8_t> SectionTable);
 
+  /// Get the type table or the global type table if /DEBUG:GHASH is enabled.
+  TypeCollection &getTypeTable() {
+    if (Config->DebugGHashes)
+      return GlobalTypeTable;
+    return TypeTable;
+  }
+
+  /// Get the ID table or the global ID table if /DEBUG:GHASH is enabled.
+  TypeCollection &getIDTable() {
+    if (Config->DebugGHashes)
+      return GlobalIDTable;
+    return IDTable;
+  }
+
   /// Write the PDB to disk and store the Guid generated for it in *Guid.
   void commit(codeview::GUID *Guid);
 
@@ -1166,17 +1180,12 @@ void DebugSHandler::handleDebugS(lld::co
       NewFpoFrames.push_back(std::move(FDS));
       break;
     }
-    case DebugSubsectionKind::Symbols:
-      if (Config->DebugGHashes) {
-        mergeSymbolRecords(Linker.Alloc, &File, Linker.Builder.getGsiBuilder(),
-                           IndexMap, Linker.GlobalIDTable,
-                           StringTableReferences, SS.getRecordData());
-      } else {
-        mergeSymbolRecords(Linker.Alloc, &File, Linker.Builder.getGsiBuilder(),
-                           IndexMap, Linker.IDTable, StringTableReferences,
-                           SS.getRecordData());
-      }
+    case DebugSubsectionKind::Symbols: {
+      mergeSymbolRecords(Linker.Alloc, &File, Linker.Builder.getGsiBuilder(),
+                         IndexMap, Linker.getIDTable(), StringTableReferences,
+                         SS.getRecordData());
       break;
+    }
     default:
       // FIXME: Process the rest of the subsections.
       break;
@@ -1339,13 +1348,8 @@ void PDBLinker::addObjectsToPDB() {
 
   // Construct TPI and IPI stream contents.
   ScopedTimer T2(TpiStreamLayoutTimer);
-  if (Config->DebugGHashes) {
-    addTypeInfo(Builder.getTpiBuilder(), GlobalTypeTable);
-    addTypeInfo(Builder.getIpiBuilder(), GlobalIDTable);
-  } else {
-    addTypeInfo(Builder.getTpiBuilder(), TypeTable);
-    addTypeInfo(Builder.getIpiBuilder(), IDTable);
-  }
+  addTypeInfo(Builder.getTpiBuilder(), getTypeTable());
+  addTypeInfo(Builder.getIpiBuilder(), getIDTable());
   T2.stop();
 
   ScopedTimer T3(GlobalsLayoutTimer);




More information about the llvm-commits mailing list