[llvm] r305611 - Remove some dead code / includes.

Zachary Turner via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 16 16:42:15 PDT 2017


Author: zturner
Date: Fri Jun 16 18:42:15 2017
New Revision: 305611

URL: http://llvm.org/viewvc/llvm-project?rev=305611&view=rev
Log:
Remove some dead code / includes.

I'm trying to get rid of the TypeDatabase class, so the first
step is to minimize its footprint.

Removed:
    llvm/trunk/tools/llvm-pdbutil/CompactTypeDumpVisitor.cpp
    llvm/trunk/tools/llvm-pdbutil/CompactTypeDumpVisitor.h
Modified:
    llvm/trunk/lib/DebugInfo/CodeView/CVTypeVisitor.cpp
    llvm/trunk/lib/DebugInfo/CodeView/TypeDumpVisitor.cpp
    llvm/trunk/tools/llvm-pdbutil/Analyze.cpp
    llvm/trunk/tools/llvm-pdbutil/CMakeLists.txt
    llvm/trunk/tools/llvm-pdbutil/RawOutputStyle.cpp
    llvm/trunk/tools/llvm-pdbutil/RawOutputStyle.h
    llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.cpp
    llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.h
    llvm/trunk/tools/llvm-readobj/COFFDumper.cpp

Modified: llvm/trunk/lib/DebugInfo/CodeView/CVTypeVisitor.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/CVTypeVisitor.cpp?rev=305611&r1=305610&r2=305611&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/CodeView/CVTypeVisitor.cpp (original)
+++ llvm/trunk/lib/DebugInfo/CodeView/CVTypeVisitor.cpp Fri Jun 16 18:42:15 2017
@@ -12,8 +12,6 @@
 #include "llvm/ADT/TinyPtrVector.h"
 #include "llvm/DebugInfo/CodeView/CodeViewError.h"
 #include "llvm/DebugInfo/CodeView/TypeCollection.h"
-#include "llvm/DebugInfo/CodeView/TypeDatabase.h"
-#include "llvm/DebugInfo/CodeView/TypeDatabaseVisitor.h"
 #include "llvm/DebugInfo/CodeView/TypeDeserializer.h"
 #include "llvm/DebugInfo/CodeView/TypeRecordMapping.h"
 #include "llvm/DebugInfo/CodeView/TypeServerHandler.h"

Modified: llvm/trunk/lib/DebugInfo/CodeView/TypeDumpVisitor.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/CodeView/TypeDumpVisitor.cpp?rev=305611&r1=305610&r2=305611&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/CodeView/TypeDumpVisitor.cpp (original)
+++ llvm/trunk/lib/DebugInfo/CodeView/TypeDumpVisitor.cpp Fri Jun 16 18:42:15 2017
@@ -13,8 +13,6 @@
 #include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"
 #include "llvm/DebugInfo/CodeView/Formatters.h"
 #include "llvm/DebugInfo/CodeView/TypeCollection.h"
-#include "llvm/DebugInfo/CodeView/TypeDatabase.h"
-#include "llvm/DebugInfo/CodeView/TypeDatabaseVisitor.h"
 #include "llvm/DebugInfo/CodeView/TypeIndex.h"
 #include "llvm/DebugInfo/CodeView/TypeRecord.h"
 #include "llvm/Support/BinaryByteStream.h"

Modified: llvm/trunk/tools/llvm-pdbutil/Analyze.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbutil/Analyze.cpp?rev=305611&r1=305610&r2=305611&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbutil/Analyze.cpp (original)
+++ llvm/trunk/tools/llvm-pdbutil/Analyze.cpp Fri Jun 16 18:42:15 2017
@@ -12,10 +12,8 @@
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"
-#include "llvm/DebugInfo/CodeView/TypeDatabase.h"
-#include "llvm/DebugInfo/CodeView/TypeDatabaseVisitor.h"
+#include "llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h"
 #include "llvm/DebugInfo/CodeView/TypeRecord.h"
-#include "llvm/DebugInfo/CodeView/TypeVisitorCallbackPipeline.h"
 #include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h"
 #include "llvm/DebugInfo/PDB/Native/PDBFile.h"
 #include "llvm/DebugInfo/PDB/Native/RawError.h"
@@ -73,16 +71,14 @@ Error AnalysisStyle::dump() {
   if (!Tpi)
     return Tpi.takeError();
 
-  TypeDatabase TypeDB(Tpi->getNumTypeRecords());
-  TypeDatabaseVisitor DBV(TypeDB);
-  TypeVisitorCallbackPipeline Pipeline;
   HashLookupVisitor Hasher(*Tpi);
-  // Add them to the database
-  Pipeline.addCallbackToPipeline(DBV);
-  // Store their hash values
-  Pipeline.addCallbackToPipeline(Hasher);
 
-  if (auto EC = codeview::visitTypeStream(Tpi->typeArray(), Pipeline))
+  uint32_t RecordCount = Tpi->getNumTypeRecords();
+  auto Offsets = Tpi->getTypeIndexOffsets();
+  auto Types = llvm::make_unique<LazyRandomTypeCollection>(
+      Tpi->typeArray(), RecordCount, Offsets);
+
+  if (auto EC = codeview::visitTypeStream(*Types, Hasher))
     return EC;
 
   auto &Adjusters = Tpi->getHashAdjusters();
@@ -109,7 +105,7 @@ Error AnalysisStyle::dump() {
       }
       StringRef LeafName = getLeafTypeName(R.Record.Type);
       uint32_t TI = R.TI.getIndex();
-      StringRef TypeName = TypeDB.getTypeName(R.TI);
+      StringRef TypeName = Types->getTypeName(R.TI);
       outs() << formatv("{0,-6} {1} ({2:x}) {3}\n", Prefix, LeafName, TI,
                         TypeName);
     }
@@ -119,8 +115,8 @@ Error AnalysisStyle::dump() {
   outs() << "Dumping hash adjustment chains\n";
   for (const auto &A : Tpi->getHashAdjusters()) {
     TypeIndex TI(A.second);
-    StringRef TypeName = TypeDB.getTypeName(TI);
-    const CVType &HeadRecord = TypeDB.getTypeRecord(TI);
+    StringRef TypeName = Types->getTypeName(TI);
+    const CVType &HeadRecord = Types->getType(TI);
     assert(HeadRecord.Hash.hasValue());
 
     auto CollisionsIter = Hasher.Lookup.find(*HeadRecord.Hash);
@@ -134,10 +130,10 @@ Error AnalysisStyle::dump() {
     for (const auto &Chain : Collisions) {
       if (Chain.TI == TI)
         continue;
-      const CVType &TailRecord = TypeDB.getTypeRecord(Chain.TI);
+      const CVType &TailRecord = Types->getType(Chain.TI);
       outs() << formatv("           {0:x} {1} {2}\n", Chain.TI.getIndex(),
                         getLeafTypeName(TailRecord.Type),
-                        TypeDB.getTypeName(Chain.TI));
+                        Types->getTypeName(Chain.TI));
     }
   }
   outs() << formatv("There are {0} orphaned hash adjusters\n",

Modified: llvm/trunk/tools/llvm-pdbutil/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbutil/CMakeLists.txt?rev=305611&r1=305610&r2=305611&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbutil/CMakeLists.txt (original)
+++ llvm/trunk/tools/llvm-pdbutil/CMakeLists.txt Fri Jun 16 18:42:15 2017
@@ -9,7 +9,6 @@ set(LLVM_LINK_COMPONENTS
 
 add_llvm_tool(llvm-pdbutil
   Analyze.cpp
-  CompactTypeDumpVisitor.cpp
   Diff.cpp
   llvm-pdbutil.cpp
   FormatUtil.cpp

Removed: llvm/trunk/tools/llvm-pdbutil/CompactTypeDumpVisitor.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbutil/CompactTypeDumpVisitor.cpp?rev=305610&view=auto
==============================================================================
--- llvm/trunk/tools/llvm-pdbutil/CompactTypeDumpVisitor.cpp (original)
+++ llvm/trunk/tools/llvm-pdbutil/CompactTypeDumpVisitor.cpp (removed)
@@ -1,59 +0,0 @@
-//===-- CompactTypeDumpVisitor.cpp - CodeView type info dumper --*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "CompactTypeDumpVisitor.h"
-#include "llvm/DebugInfo/CodeView/TypeDatabase.h"
-#include "llvm/Support/FormatVariadic.h"
-#include "llvm/Support/ScopedPrinter.h"
-
-using namespace llvm;
-using namespace llvm::codeview;
-using namespace llvm::pdb;
-
-static const EnumEntry<TypeLeafKind> LeafTypeNames[] = {
-#define CV_TYPE(enum, val) {#enum, enum},
-#include "llvm/DebugInfo/CodeView/CodeViewTypes.def"
-};
-
-static StringRef getLeafName(TypeLeafKind K) {
-  for (const auto &E : LeafTypeNames) {
-    if (E.Value == K)
-      return E.Name;
-  }
-  return StringRef();
-}
-
-CompactTypeDumpVisitor::CompactTypeDumpVisitor(TypeCollection &Types,
-                                               ScopedPrinter *W)
-    : CompactTypeDumpVisitor(Types, TypeIndex(TypeIndex::FirstNonSimpleIndex),
-                             W) {}
-
-CompactTypeDumpVisitor::CompactTypeDumpVisitor(TypeCollection &Types,
-                                               TypeIndex FirstTI,
-                                               ScopedPrinter *W)
-    : W(W), TI(FirstTI), Offset(0), Types(Types) {}
-
-Error CompactTypeDumpVisitor::visitTypeBegin(CVType &Record) {
-  return Error::success();
-}
-
-Error CompactTypeDumpVisitor::visitTypeEnd(CVType &Record) {
-  uint32_t I = TI.getIndex();
-  StringRef Leaf = getLeafName(Record.Type);
-  StringRef Name = Types.getTypeName(TI);
-  W->printString(
-      llvm::formatv("Index: {0:x} ({1:N} bytes, offset {2:N}) {3} \"{4}\"", I,
-                    Record.length(), Offset, Leaf, Name)
-          .str());
-
-  Offset += Record.length();
-  TI.setIndex(TI.getIndex() + 1);
-
-  return Error::success();
-}

Removed: llvm/trunk/tools/llvm-pdbutil/CompactTypeDumpVisitor.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbutil/CompactTypeDumpVisitor.h?rev=305610&view=auto
==============================================================================
--- llvm/trunk/tools/llvm-pdbutil/CompactTypeDumpVisitor.h (original)
+++ llvm/trunk/tools/llvm-pdbutil/CompactTypeDumpVisitor.h (removed)
@@ -1,49 +0,0 @@
-//===-- CompactTypeDumpVisitor.h - CodeView type info dumper ----*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_DEBUGINFO_CODEVIEW_COMPACTTYPEDUMPVISITOR_H
-#define LLVM_DEBUGINFO_CODEVIEW_COMPACTTYPEDUMPVISITOR_H
-
-#include "llvm/DebugInfo/CodeView/TypeIndex.h"
-#include "llvm/DebugInfo/CodeView/TypeRecord.h"
-#include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h"
-
-namespace llvm {
-class ScopedPrinter;
-namespace codeview {
-class TypeCollection;
-}
-
-namespace pdb {
-
-/// Dumper for CodeView type streams found in COFF object files and PDB files.
-/// Dumps records on a single line, and ignores member records.
-class CompactTypeDumpVisitor : public codeview::TypeVisitorCallbacks {
-public:
-  CompactTypeDumpVisitor(codeview::TypeCollection &Types, ScopedPrinter *W);
-  CompactTypeDumpVisitor(codeview::TypeCollection &Types,
-                         codeview::TypeIndex FirstTI, ScopedPrinter *W);
-
-  /// Paired begin/end actions for all types. Receives all record data,
-  /// including the fixed-length record prefix.
-  Error visitTypeBegin(codeview::CVType &Record) override;
-  Error visitTypeEnd(codeview::CVType &Record) override;
-
-private:
-  ScopedPrinter *W;
-
-  codeview::TypeIndex TI;
-  uint32_t Offset;
-  codeview::TypeCollection &Types;
-};
-
-} // end namespace pdb
-} // end namespace llvm
-
-#endif

Modified: llvm/trunk/tools/llvm-pdbutil/RawOutputStyle.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbutil/RawOutputStyle.cpp?rev=305611&r1=305610&r2=305611&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbutil/RawOutputStyle.cpp (original)
+++ llvm/trunk/tools/llvm-pdbutil/RawOutputStyle.cpp Fri Jun 16 18:42:15 2017
@@ -9,7 +9,6 @@
 
 #include "RawOutputStyle.h"
 
-#include "CompactTypeDumpVisitor.h"
 #include "FormatUtil.h"
 #include "MinimalSymbolDumper.h"
 #include "MinimalTypeDumper.h"
@@ -730,18 +729,23 @@ Error RawOutputStyle::dumpTpiStream(uint
   bool DumpTypes = false;
   bool DumpBytes = false;
   bool DumpExtras = false;
+  std::vector<uint32_t> Indices;
   if (StreamIdx == StreamTPI) {
     printHeader(P, "Types (TPI Stream)");
     Present = File.hasPDBTpiStream();
     DumpTypes = opts::raw::DumpTypes;
     DumpBytes = opts::raw::DumpTypeData;
     DumpExtras = opts::raw::DumpTypeExtras;
+    Indices.assign(opts::raw::DumpTypeIndex.begin(),
+                   opts::raw::DumpTypeIndex.end());
   } else if (StreamIdx == StreamIPI) {
     printHeader(P, "Types (IPI Stream)");
     Present = File.hasPDBIpiStream();
     DumpTypes = opts::raw::DumpIds;
     DumpBytes = opts::raw::DumpIdData;
     DumpExtras = opts::raw::DumpIdExtras;
+    Indices.assign(opts::raw::DumpIdIndex.begin(),
+                   opts::raw::DumpIdIndex.end());
   }
 
   AutoIndent Indent(P);
@@ -755,7 +759,7 @@ Error RawOutputStyle::dumpTpiStream(uint
   auto &Stream = Err((StreamIdx == StreamTPI) ? File.getPDBTpiStream()
                                               : File.getPDBIpiStream());
 
-  auto &Types = Err(initializeTypeDatabase(StreamIdx));
+  auto &Types = Err(initializeTypes(StreamIdx));
 
   if (DumpTypes) {
     P.formatLine("Showing {0:N} records", Stream.getNumTypeRecords());
@@ -765,10 +769,19 @@ Error RawOutputStyle::dumpTpiStream(uint
     MinimalTypeDumpVisitor V(P, Width + 2, DumpBytes, DumpExtras, Types,
                              Stream.getHashValues());
 
-    Optional<TypeIndex> I = Types.getFirst();
-    if (auto EC = codeview::visitTypeStream(Types, V)) {
-      P.formatLine("An error occurred dumping type records: {0}",
-                   toString(std::move(EC)));
+    if (Indices.empty()) {
+      if (auto EC = codeview::visitTypeStream(Types, V)) {
+        P.formatLine("An error occurred dumping type records: {0}",
+                     toString(std::move(EC)));
+      }
+    } else {
+      for (const auto &I : Indices) {
+        TypeIndex TI(I);
+        CVType Type = Types.getType(TI);
+        if (auto EC = codeview::visitTypeRecord(Type, TI, V))
+          P.formatLine("An error occurred dumping type record {0}: {1}", TI,
+                       toString(std::move(EC)));
+      }
     }
   }
 
@@ -801,7 +814,7 @@ Error RawOutputStyle::dumpTpiStream(uint
 }
 
 Expected<codeview::LazyRandomTypeCollection &>
-RawOutputStyle::initializeTypeDatabase(uint32_t SN) {
+RawOutputStyle::initializeTypes(uint32_t SN) {
   auto &TypeCollection = (SN == StreamTPI) ? TpiTypes : IpiTypes;
   auto Tpi =
       (SN == StreamTPI) ? File.getPDBTpiStream() : File.getPDBIpiStream();
@@ -832,7 +845,7 @@ Error RawOutputStyle::dumpModuleSyms() {
 
   auto &Stream = Err(File.getPDBDbiStream());
 
-  auto &Types = Err(initializeTypeDatabase(StreamTPI));
+  auto &Types = Err(initializeTypes(StreamTPI));
 
   const DbiModuleList &Modules = Stream.modules();
   uint32_t Count = Modules.getModuleCount();
@@ -884,7 +897,7 @@ Error RawOutputStyle::dumpPublics() {
 
   ExitOnError Err("Error dumping publics stream");
 
-  auto &Types = Err(initializeTypeDatabase(StreamTPI));
+  auto &Types = Err(initializeTypes(StreamTPI));
   auto &Publics = Err(File.getPDBPublicsStream());
   SymbolVisitorCallbackPipeline Pipeline;
   SymbolDeserializer Deserializer(nullptr, CodeViewContainer::Pdb);

Modified: llvm/trunk/tools/llvm-pdbutil/RawOutputStyle.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbutil/RawOutputStyle.h?rev=305611&r1=305610&r2=305611&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbutil/RawOutputStyle.h (original)
+++ llvm/trunk/tools/llvm-pdbutil/RawOutputStyle.h Fri Jun 16 18:42:15 2017
@@ -15,7 +15,6 @@
 
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallVector.h"
-#include "llvm/DebugInfo/CodeView/TypeDatabase.h"
 
 #include <string>
 
@@ -34,8 +33,7 @@ public:
   Error dump() override;
 
 private:
-  Expected<codeview::LazyRandomTypeCollection &>
-  initializeTypeDatabase(uint32_t SN);
+  Expected<codeview::LazyRandomTypeCollection &> initializeTypes(uint32_t SN);
 
   Error dumpFileSummary();
   Error dumpStreamSummary();

Modified: llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.cpp?rev=305611&r1=305610&r2=305611&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.cpp (original)
+++ llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.cpp Fri Jun 16 18:42:15 2017
@@ -306,6 +306,11 @@ cl::opt<bool> DumpTypeExtras("type-extra
                              cl::desc("dump type hashes and index offsets"),
                              cl::cat(TypeOptions), cl::sub(RawSubcommand));
 
+cl::list<uint32_t> DumpTypeIndex(
+    "type-index", cl::ZeroOrMore,
+    cl::desc("only dump types with the specified hexadecimal type index"),
+    cl::cat(TypeOptions), cl::sub(RawSubcommand));
+
 cl::opt<bool> DumpIds("ids",
                       cl::desc("dump CodeView type records from IPI stream"),
                       cl::cat(TypeOptions), cl::sub(RawSubcommand));
@@ -317,6 +322,10 @@ cl::opt<bool>
 cl::opt<bool> DumpIdExtras("id-extras",
                            cl::desc("dump id hashes and index offsets"),
                            cl::cat(TypeOptions), cl::sub(RawSubcommand));
+cl::list<uint32_t> DumpIdIndex(
+    "id-index", cl::ZeroOrMore,
+    cl::desc("only dump ids with the specified hexadecimal type index"),
+    cl::cat(TypeOptions), cl::sub(RawSubcommand));
 
 // SYMBOL OPTIONS
 cl::opt<bool> DumpPublics("publics", cl::desc("dump Publics stream data"),

Modified: llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.h?rev=305611&r1=305610&r2=305611&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.h (original)
+++ llvm/trunk/tools/llvm-pdbutil/llvm-pdbutil.h Fri Jun 16 18:42:15 2017
@@ -111,9 +111,12 @@ extern llvm::cl::opt<bool> DumpStringTab
 extern llvm::cl::opt<bool> DumpTypes;
 extern llvm::cl::opt<bool> DumpTypeData;
 extern llvm::cl::opt<bool> DumpTypeExtras;
+extern llvm::cl::list<uint32_t> DumpTypeIndex;
+
 extern llvm::cl::opt<bool> DumpIds;
 extern llvm::cl::opt<bool> DumpIdData;
 extern llvm::cl::opt<bool> DumpIdExtras;
+extern llvm::cl::list<uint32_t> DumpIdIndex;
 extern llvm::cl::opt<bool> DumpSymbols;
 extern llvm::cl::opt<bool> DumpSymRecordBytes;
 extern llvm::cl::opt<bool> DumpPublics;

Modified: llvm/trunk/tools/llvm-readobj/COFFDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/COFFDumper.cpp?rev=305611&r1=305610&r2=305611&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/COFFDumper.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/COFFDumper.cpp Fri Jun 16 18:42:15 2017
@@ -36,7 +36,6 @@
 #include "llvm/DebugInfo/CodeView/SymbolDumpDelegate.h"
 #include "llvm/DebugInfo/CodeView/SymbolDumper.h"
 #include "llvm/DebugInfo/CodeView/SymbolRecord.h"
-#include "llvm/DebugInfo/CodeView/TypeDatabase.h"
 #include "llvm/DebugInfo/CodeView/TypeDumpVisitor.h"
 #include "llvm/DebugInfo/CodeView/TypeIndex.h"
 #include "llvm/DebugInfo/CodeView/TypeRecord.h"




More information about the llvm-commits mailing list