From: Zachary Turner Date: Fri, 16 Jun 2017 23:42:15 +0000 (+0000) Subject: Remove some dead code / includes. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bd5fe95fd222b4aec858abe3d93d348e49cadab2;p=llvm Remove some dead code / includes. I'm trying to get rid of the TypeDatabase class, so the first step is to minimize its footprint. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305611 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/DebugInfo/CodeView/CVTypeVisitor.cpp b/lib/DebugInfo/CodeView/CVTypeVisitor.cpp index f0debd9e970..22f166a2335 100644 --- a/lib/DebugInfo/CodeView/CVTypeVisitor.cpp +++ b/lib/DebugInfo/CodeView/CVTypeVisitor.cpp @@ -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" diff --git a/lib/DebugInfo/CodeView/TypeDumpVisitor.cpp b/lib/DebugInfo/CodeView/TypeDumpVisitor.cpp index 04b0384d819..58996670501 100644 --- a/lib/DebugInfo/CodeView/TypeDumpVisitor.cpp +++ b/lib/DebugInfo/CodeView/TypeDumpVisitor.cpp @@ -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" diff --git a/tools/llvm-pdbutil/Analyze.cpp b/tools/llvm-pdbutil/Analyze.cpp index b503cdcbf1e..6c603dd8542 100644 --- a/tools/llvm-pdbutil/Analyze.cpp +++ b/tools/llvm-pdbutil/Analyze.cpp @@ -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( + 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", diff --git a/tools/llvm-pdbutil/CMakeLists.txt b/tools/llvm-pdbutil/CMakeLists.txt index d09fa31d8b6..94e74412b50 100644 --- a/tools/llvm-pdbutil/CMakeLists.txt +++ b/tools/llvm-pdbutil/CMakeLists.txt @@ -9,7 +9,6 @@ set(LLVM_LINK_COMPONENTS add_llvm_tool(llvm-pdbutil Analyze.cpp - CompactTypeDumpVisitor.cpp Diff.cpp llvm-pdbutil.cpp FormatUtil.cpp diff --git a/tools/llvm-pdbutil/CompactTypeDumpVisitor.cpp b/tools/llvm-pdbutil/CompactTypeDumpVisitor.cpp deleted file mode 100644 index 6dd54e0dbec..00000000000 --- a/tools/llvm-pdbutil/CompactTypeDumpVisitor.cpp +++ /dev/null @@ -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 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(); -} diff --git a/tools/llvm-pdbutil/CompactTypeDumpVisitor.h b/tools/llvm-pdbutil/CompactTypeDumpVisitor.h deleted file mode 100644 index 41ccea0c2e9..00000000000 --- a/tools/llvm-pdbutil/CompactTypeDumpVisitor.h +++ /dev/null @@ -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 diff --git a/tools/llvm-pdbutil/RawOutputStyle.cpp b/tools/llvm-pdbutil/RawOutputStyle.cpp index b204a89ec31..515125739b3 100644 --- a/tools/llvm-pdbutil/RawOutputStyle.cpp +++ b/tools/llvm-pdbutil/RawOutputStyle.cpp @@ -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(uint32_t StreamIdx) { bool DumpTypes = false; bool DumpBytes = false; bool DumpExtras = false; + std::vector 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(uint32_t StreamIdx) { 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(uint32_t StreamIdx) { MinimalTypeDumpVisitor V(P, Width + 2, DumpBytes, DumpExtras, Types, Stream.getHashValues()); - Optional 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(uint32_t StreamIdx) { } Expected -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); diff --git a/tools/llvm-pdbutil/RawOutputStyle.h b/tools/llvm-pdbutil/RawOutputStyle.h index 803f588961b..68ba15ddcbd 100644 --- a/tools/llvm-pdbutil/RawOutputStyle.h +++ b/tools/llvm-pdbutil/RawOutputStyle.h @@ -15,7 +15,6 @@ #include "llvm/ADT/Optional.h" #include "llvm/ADT/SmallVector.h" -#include "llvm/DebugInfo/CodeView/TypeDatabase.h" #include @@ -34,8 +33,7 @@ public: Error dump() override; private: - Expected - initializeTypeDatabase(uint32_t SN); + Expected initializeTypes(uint32_t SN); Error dumpFileSummary(); Error dumpStreamSummary(); diff --git a/tools/llvm-pdbutil/llvm-pdbutil.cpp b/tools/llvm-pdbutil/llvm-pdbutil.cpp index 9088783876e..b04add54993 100644 --- a/tools/llvm-pdbutil/llvm-pdbutil.cpp +++ b/tools/llvm-pdbutil/llvm-pdbutil.cpp @@ -306,6 +306,11 @@ cl::opt DumpTypeExtras("type-extras", cl::desc("dump type hashes and index offsets"), cl::cat(TypeOptions), cl::sub(RawSubcommand)); +cl::list DumpTypeIndex( + "type-index", cl::ZeroOrMore, + cl::desc("only dump types with the specified hexadecimal type index"), + cl::cat(TypeOptions), cl::sub(RawSubcommand)); + cl::opt DumpIds("ids", cl::desc("dump CodeView type records from IPI stream"), cl::cat(TypeOptions), cl::sub(RawSubcommand)); @@ -317,6 +322,10 @@ cl::opt cl::opt DumpIdExtras("id-extras", cl::desc("dump id hashes and index offsets"), cl::cat(TypeOptions), cl::sub(RawSubcommand)); +cl::list 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 DumpPublics("publics", cl::desc("dump Publics stream data"), diff --git a/tools/llvm-pdbutil/llvm-pdbutil.h b/tools/llvm-pdbutil/llvm-pdbutil.h index a41b032d2b1..e6197617d2d 100644 --- a/tools/llvm-pdbutil/llvm-pdbutil.h +++ b/tools/llvm-pdbutil/llvm-pdbutil.h @@ -111,9 +111,12 @@ extern llvm::cl::opt DumpStringTable; extern llvm::cl::opt DumpTypes; extern llvm::cl::opt DumpTypeData; extern llvm::cl::opt DumpTypeExtras; +extern llvm::cl::list DumpTypeIndex; + extern llvm::cl::opt DumpIds; extern llvm::cl::opt DumpIdData; extern llvm::cl::opt DumpIdExtras; +extern llvm::cl::list DumpIdIndex; extern llvm::cl::opt DumpSymbols; extern llvm::cl::opt DumpSymRecordBytes; extern llvm::cl::opt DumpPublics; diff --git a/tools/llvm-readobj/COFFDumper.cpp b/tools/llvm-readobj/COFFDumper.cpp index 216c9adad9a..cd8c02affd4 100644 --- a/tools/llvm-readobj/COFFDumper.cpp +++ b/tools/llvm-readobj/COFFDumper.cpp @@ -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"