diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-07-01 13:22:02 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-07-01 13:22:02 +0000 |
commit | 9df3605dea17e84f8183581f6103bd0c79e2a606 (patch) | |
tree | 70a2f36ce9eb9bb213603cd7f2f120af53fc176f /tools | |
parent | 08bbd35a80bf7765fe0d3043f9eb5a2f2786b649 (diff) |
Notes
Diffstat (limited to 'tools')
23 files changed, 304 insertions, 115 deletions
diff --git a/tools/bugpoint/ToolRunner.cpp b/tools/bugpoint/ToolRunner.cpp index 10532ef8395b..70b18e3dbbf9 100644 --- a/tools/bugpoint/ToolRunner.cpp +++ b/tools/bugpoint/ToolRunner.cpp @@ -861,7 +861,7 @@ Error CC::MakeSharedObject(const std::string &InputFile, FileType fileType, errs() << "\n";); if (RunProgramWithTimeout(CCPath, &CCArgs[0], "", "", "")) return ProcessFailure(CCPath, &CCArgs[0]); - return Error::success();; + return Error::success(); } /// create - Try to find the CC executable diff --git a/tools/dsymutil/DwarfLinker.cpp b/tools/dsymutil/DwarfLinker.cpp index ba5c63846b50..86621e3260f0 100644 --- a/tools/dsymutil/DwarfLinker.cpp +++ b/tools/dsymutil/DwarfLinker.cpp @@ -2212,7 +2212,7 @@ void DwarfLinker::keepDIEAndDependencies(RelocationManager &RelocMgr, // Then we need to mark all the DIEs referenced by this DIE's // attributes as kept. - DataExtractor Data = Unit.getDebugInfoExtractor(); + DWARFDataExtractor Data = Unit.getDebugInfoExtractor(); const auto *Abbrev = Die.getAbbreviationDeclarationPtr(); uint32_t Offset = Die.getOffset() + getULEB128Size(Abbrev->getCode()); @@ -2729,7 +2729,7 @@ DIE *DwarfLinker::DIECloner::cloneDIE( } // Extract and clone every attribute. - DataExtractor Data = U.getDebugInfoExtractor(); + DWARFDataExtractor Data = U.getDebugInfoExtractor(); // Point to the next DIE (generally there is always at least a NULL // entry after the current one). If this is a lone // DW_TAG_compile_unit without any children, point to the next unit. @@ -2743,7 +2743,8 @@ DIE *DwarfLinker::DIECloner::cloneDIE( // it. After testing, it seems there is no performance downside to // doing the copy unconditionally, and it makes the code simpler. SmallString<40> DIECopy(Data.getData().substr(Offset, NextOffset - Offset)); - Data = DataExtractor(DIECopy, Data.isLittleEndian(), Data.getAddressSize()); + Data = + DWARFDataExtractor(DIECopy, Data.isLittleEndian(), Data.getAddressSize()); // Modify the copy with relocated addresses. if (RelocMgr.applyValidRelocs(DIECopy, Offset, Data.isLittleEndian())) { // If we applied relocations, we store the value of high_pc that was @@ -2872,8 +2873,8 @@ void DwarfLinker::patchRangesForUnit(const CompileUnit &Unit, DWARFDebugRangeList RangeList; const auto &FunctionRanges = Unit.getFunctionRanges(); unsigned AddressSize = Unit.getOrigUnit().getAddressByteSize(); - DataExtractor RangeExtractor(OrigDwarf.getRangeSection().Data, - OrigDwarf.isLittleEndian(), AddressSize); + DWARFDataExtractor RangeExtractor(OrigDwarf.getRangeSection(), + OrigDwarf.isLittleEndian(), AddressSize); auto InvalidRange = FunctionRanges.end(), CurrRange = InvalidRange; DWARFUnit &OrigUnit = Unit.getOrigUnit(); auto OrigUnitDie = OrigUnit.getUnitDIE(false); @@ -2887,7 +2888,7 @@ void DwarfLinker::patchRangesForUnit(const CompileUnit &Unit, for (const auto &RangeAttribute : Unit.getRangesAttributes()) { uint32_t Offset = RangeAttribute.get(); RangeAttribute.set(Streamer->getRangesSectionSize()); - RangeList.extract(RangeExtractor, &Offset, OrigDwarf.getRangeSection().Relocs); + RangeList.extract(RangeExtractor, &Offset); const auto &Entries = RangeList.getEntries(); if (!Entries.empty()) { const DWARFDebugRangeList::RangeListEntry &First = Entries.front(); @@ -2983,11 +2984,10 @@ void DwarfLinker::patchLineTableForUnit(CompileUnit &Unit, // Parse the original line info for the unit. DWARFDebugLine::LineTable LineTable; uint32_t StmtOffset = *StmtList; - StringRef LineData = OrigDwarf.getLineSection().Data; - DataExtractor LineExtractor(LineData, OrigDwarf.isLittleEndian(), - Unit.getOrigUnit().getAddressByteSize()); - LineTable.parse(LineExtractor, &OrigDwarf.getLineSection().Relocs, - &StmtOffset); + DWARFDataExtractor LineExtractor(OrigDwarf.getLineSection(), + OrigDwarf.isLittleEndian(), + Unit.getOrigUnit().getAddressByteSize()); + LineTable.parse(LineExtractor, &StmtOffset); // This vector is the output line table. std::vector<DWARFDebugLine::Row> NewRows; @@ -3086,6 +3086,7 @@ void DwarfLinker::patchLineTableForUnit(CompileUnit &Unit, LineTable.Prologue.OpcodeBase > 13) reportWarning("line table parameters mismatch. Cannot emit."); else { + StringRef LineData = OrigDwarf.getLineSection().Data; MCDwarfLineTableParams Params; Params.DWARF2LineOpcodeBase = LineTable.Prologue.OpcodeBase; Params.DWARF2LineBase = LineTable.Prologue.LineBase; diff --git a/tools/llc/llc.cpp b/tools/llc/llc.cpp index e71c3c5bb705..f13a19213c69 100644 --- a/tools/llc/llc.cpp +++ b/tools/llc/llc.cpp @@ -149,6 +149,11 @@ static cl::opt<bool> PassRemarksWithHotness( cl::desc("With PGO, include profile count in optimization remarks"), cl::Hidden); +static cl::opt<unsigned> PassRemarksHotnessThreshold( + "pass-remarks-hotness-threshold", + cl::desc("Minimum profile count required for an optimization remark to be output"), + cl::Hidden); + static cl::opt<std::string> RemarksFilename("pass-remarks-output", cl::desc("YAML output filename for pass remarks"), @@ -323,7 +328,10 @@ int main(int argc, char **argv) { Context.setInlineAsmDiagnosticHandler(InlineAsmDiagHandler, &HasError); if (PassRemarksWithHotness) - Context.setDiagnosticHotnessRequested(true); + Context.setDiagnosticsHotnessRequested(true); + + if (PassRemarksHotnessThreshold) + Context.setDiagnosticsHotnessThreshold(PassRemarksHotnessThreshold); std::unique_ptr<tool_output_file> YamlFile; if (RemarksFilename != "") { diff --git a/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp b/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp index 22bc6f7043ee..528247c2dbc3 100644 --- a/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp +++ b/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp @@ -125,6 +125,7 @@ static const char *GetBlockName(unsigned BlockID, return "FULL_LTO_GLOBALVAL_SUMMARY_BLOCK"; case bitc::MODULE_STRTAB_BLOCK_ID: return "MODULE_STRTAB_BLOCK"; case bitc::STRTAB_BLOCK_ID: return "STRTAB_BLOCK"; + case bitc::SYMTAB_BLOCK_ID: return "SYMTAB_BLOCK"; } } @@ -393,6 +394,11 @@ static const char *GetCodeName(unsigned CodeID, unsigned BlockID, default: return nullptr; case bitc::STRTAB_BLOB: return "BLOB"; } + case bitc::SYMTAB_BLOCK_ID: + switch(CodeID) { + default: return nullptr; + case bitc::SYMTAB_BLOB: return "BLOB"; + } } #undef STRINGIFY_CODE } diff --git a/tools/llvm-lto2/CMakeLists.txt b/tools/llvm-lto2/CMakeLists.txt index cdd97c9fef5c..9be12d71ed79 100644 --- a/tools/llvm-lto2/CMakeLists.txt +++ b/tools/llvm-lto2/CMakeLists.txt @@ -1,5 +1,6 @@ set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} + BitReader Core Linker LTO diff --git a/tools/llvm-lto2/LLVMBuild.txt b/tools/llvm-lto2/LLVMBuild.txt index 42b0b9e26cca..d51aa2290675 100644 --- a/tools/llvm-lto2/LLVMBuild.txt +++ b/tools/llvm-lto2/LLVMBuild.txt @@ -19,4 +19,4 @@ type = Tool name = llvm-lto2 parent = Tools -required_libraries = Core Linker LTO MC Object Support all-targets +required_libraries = BitReader Core Linker LTO MC Object Support all-targets diff --git a/tools/llvm-lto2/llvm-lto2.cpp b/tools/llvm-lto2/llvm-lto2.cpp index bbfece517c80..5426e040cd7c 100644 --- a/tools/llvm-lto2/llvm-lto2.cpp +++ b/tools/llvm-lto2/llvm-lto2.cpp @@ -16,9 +16,10 @@ // //===----------------------------------------------------------------------===// -#include "llvm/LTO/Caching.h" +#include "llvm/Bitcode/BitcodeReader.h" #include "llvm/CodeGen/CommandFlags.h" #include "llvm/IR/DiagnosticPrinter.h" +#include "llvm/LTO/Caching.h" #include "llvm/LTO/LTO.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/FileSystem.h" @@ -298,6 +299,17 @@ static int run(int argc, char **argv) { static int dumpSymtab(int argc, char **argv) { for (StringRef F : make_range(argv + 1, argv + argc)) { std::unique_ptr<MemoryBuffer> MB = check(MemoryBuffer::getFile(F), F); + BitcodeFileContents BFC = check(getBitcodeFileContents(*MB), F); + + if (BFC.Symtab.size() >= sizeof(irsymtab::storage::Header)) { + auto *Hdr = reinterpret_cast<const irsymtab::storage::Header *>( + BFC.Symtab.data()); + outs() << "version: " << Hdr->Version << '\n'; + if (Hdr->Version == irsymtab::storage::Header::kCurrentVersion) + outs() << "producer: " << Hdr->Producer.get(BFC.StrtabForSymtab) + << '\n'; + } + std::unique_ptr<InputFile> Input = check(InputFile::create(MB->getMemBufferRef()), F); diff --git a/tools/llvm-nm/CMakeLists.txt b/tools/llvm-nm/CMakeLists.txt index 10019562565d..08bcd5f30898 100644 --- a/tools/llvm-nm/CMakeLists.txt +++ b/tools/llvm-nm/CMakeLists.txt @@ -3,6 +3,7 @@ set(LLVM_LINK_COMPONENTS AllTargetsDescs AllTargetsInfos Core + Demangle Object Support ) diff --git a/tools/llvm-nm/llvm-nm.cpp b/tools/llvm-nm/llvm-nm.cpp index 513e1b87558f..ea47891250f7 100644 --- a/tools/llvm-nm/llvm-nm.cpp +++ b/tools/llvm-nm/llvm-nm.cpp @@ -18,6 +18,7 @@ #include "llvm/ADT/StringSwitch.h" #include "llvm/BinaryFormat/COFF.h" +#include "llvm/Demangle/Demangle.h" #include "llvm/IR/Function.h" #include "llvm/IR/GlobalAlias.h" #include "llvm/IR/GlobalVariable.h" @@ -124,6 +125,10 @@ cl::opt<bool> NoSort("no-sort", cl::desc("Show symbols in order encountered")); cl::alias NoSortp("p", cl::desc("Alias for --no-sort"), cl::aliasopt(NoSort), cl::Grouping); +cl::opt<bool> Demangle("demangle", cl::desc("Demangle C++ symbol names")); +cl::alias DemangleC("C", cl::desc("Alias for --demangle"), cl::aliasopt(Demangle), + cl::Grouping); + cl::opt<bool> ReverseSort("reverse-sort", cl::desc("Sort in reverse order")); cl::alias ReverseSortr("r", cl::desc("Alias for --reverse-sort"), cl::aliasopt(ReverseSort), cl::Grouping); @@ -659,6 +664,24 @@ static void darwinPrintStab(MachOObjectFile *MachO, SymbolListT::iterator I) { outs() << Str; } +static Optional<std::string> demangle(StringRef Name, bool StripUnderscore) { + if (StripUnderscore && Name.size() > 0 && Name[0] == '_') + Name = Name.substr(1); + + if (!Name.startswith("_Z")) + return None; + + int Status; + char *Undecorated = + itaniumDemangle(Name.str().c_str(), nullptr, nullptr, &Status); + if (Status != 0) + return None; + + std::string S(Undecorated); + free(Undecorated); + return S; +} + static bool symbolIsDefined(const NMSymbol &Sym) { return Sym.TypeChar != 'U' && Sym.TypeChar != 'w' && Sym.TypeChar != 'v'; } @@ -724,6 +747,12 @@ static void sortAndPrintSymbolList(SymbolicFile &Obj, bool printName, for (SymbolListT::iterator I = SymbolList.begin(), E = SymbolList.end(); I != E; ++I) { uint32_t SymFlags; + std::string Name = I->Name.str(); + MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(&Obj); + if (Demangle) { + if (Optional<std::string> Opt = demangle(I->Name, MachO)) + Name = *Opt; + } if (I->Sym.getRawDataRefImpl().p) SymFlags = I->Sym.getFlags(); else @@ -745,9 +774,10 @@ static void sortAndPrintSymbolList(SymbolicFile &Obj, bool printName, outs() << CurrentFilename << ": "; } } - if ((JustSymbolName || (UndefinedOnly && isa<MachOObjectFile>(Obj) && - OutputFormat != darwin)) && OutputFormat != posix) { - outs() << I->Name << "\n"; + if ((JustSymbolName || + (UndefinedOnly && MachO && OutputFormat != darwin)) && + OutputFormat != posix) { + outs() << Name << "\n"; continue; } @@ -767,7 +797,6 @@ static void sortAndPrintSymbolList(SymbolicFile &Obj, bool printName, } } - MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(&Obj); // Otherwise, print the symbol address and size. if (symbolIsDefined(*I)) { if (Obj.isIR()) @@ -789,7 +818,7 @@ static void sortAndPrintSymbolList(SymbolicFile &Obj, bool printName, darwinPrintSymbol(Obj, I, SymbolAddrStr, printBlanks, printDashes, printFormat); } else if (OutputFormat == posix) { - outs() << I->Name << " " << I->TypeChar << " "; + outs() << Name << " " << I->TypeChar << " "; if (MachO) outs() << SymbolAddrStr << " " << "0" /* SymbolSizeStr */ << "\n"; else @@ -804,7 +833,7 @@ static void sortAndPrintSymbolList(SymbolicFile &Obj, bool printName, outs() << I->TypeChar; if (I->TypeChar == '-' && MachO) darwinPrintStab(MachO, I); - outs() << " " << I->Name; + outs() << " " << Name; if (I->TypeChar == 'I' && MachO) { outs() << " (indirect for "; if (I->Sym.getRawDataRefImpl().p) { @@ -818,7 +847,7 @@ static void sortAndPrintSymbolList(SymbolicFile &Obj, bool printName, } outs() << "\n"; } else if (OutputFormat == sysv) { - std::string PaddedName(I->Name); + std::string PaddedName(Name); while (PaddedName.length() < 20) PaddedName += " "; outs() << PaddedName << "|" << SymbolAddrStr << "| " << I->TypeChar diff --git a/tools/llvm-objdump/llvm-objdump.cpp b/tools/llvm-objdump/llvm-objdump.cpp index 6a9151570908..be5635a3d4c6 100644 --- a/tools/llvm-objdump/llvm-objdump.cpp +++ b/tools/llvm-objdump/llvm-objdump.cpp @@ -41,6 +41,7 @@ #include "llvm/Object/ELFObjectFile.h" #include "llvm/Object/MachO.h" #include "llvm/Object/ObjectFile.h" +#include "llvm/Object/Wasm.h" #include "llvm/Support/Casting.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" @@ -886,6 +887,18 @@ static void printRelocationTargetName(const MachOObjectFile *O, fmt << S; } +static std::error_code getRelocationValueString(const WasmObjectFile *Obj, + const RelocationRef &RelRef, + SmallVectorImpl<char> &Result) { + const wasm::WasmRelocation& Rel = Obj->getWasmRelocation(RelRef); + std::string fmtbuf; + raw_string_ostream fmt(fmtbuf); + fmt << Rel.Index << (Rel.Addend < 0 ? "" : "+") << Rel.Addend; + fmt.flush(); + Result.append(fmtbuf.begin(), fmtbuf.end()); + return std::error_code(); +} + static std::error_code getRelocationValueString(const MachOObjectFile *Obj, const RelocationRef &RelRef, SmallVectorImpl<char> &Result) { @@ -1071,8 +1084,11 @@ static std::error_code getRelocationValueString(const RelocationRef &Rel, return getRelocationValueString(ELF, Rel, Result); if (auto *COFF = dyn_cast<COFFObjectFile>(Obj)) return getRelocationValueString(COFF, Rel, Result); - auto *MachO = cast<MachOObjectFile>(Obj); - return getRelocationValueString(MachO, Rel, Result); + if (auto *Wasm = dyn_cast<WasmObjectFile>(Obj)) + return getRelocationValueString(Wasm, Rel, Result); + if (auto *MachO = dyn_cast<MachOObjectFile>(Obj)) + return getRelocationValueString(MachO, Rel, Result); + llvm_unreachable("unknown object file format"); } /// @brief Indicates whether this relocation should hidden when listing diff --git a/tools/llvm-pdbutil/DumpOutputStyle.cpp b/tools/llvm-pdbutil/DumpOutputStyle.cpp index f76635f9e511..a1f919b4dd06 100644 --- a/tools/llvm-pdbutil/DumpOutputStyle.cpp +++ b/tools/llvm-pdbutil/DumpOutputStyle.cpp @@ -37,6 +37,7 @@ #include "llvm/DebugInfo/CodeView/SymbolVisitorCallbackPipeline.h" #include "llvm/DebugInfo/CodeView/SymbolVisitorCallbacks.h" #include "llvm/DebugInfo/CodeView/TypeDumpVisitor.h" +#include "llvm/DebugInfo/CodeView/TypeIndexDiscovery.h" #include "llvm/DebugInfo/CodeView/TypeVisitorCallbackPipeline.h" #include "llvm/DebugInfo/MSF/MappedBlockStream.h" #include "llvm/DebugInfo/PDB/Native/DbiModuleDescriptor.h" @@ -116,12 +117,14 @@ Error DumpOutputStyle::dump() { return EC; } - if (opts::dump::DumpTypes || opts::dump::DumpTypeExtras) { + if (opts::dump::DumpTypes || !opts::dump::DumpTypeIndex.empty() || + opts::dump::DumpTypeExtras) { if (auto EC = dumpTpiStream(StreamTPI)) return EC; } - if (opts::dump::DumpIds || opts::dump::DumpIdExtras) { + if (opts::dump::DumpIds || !opts::dump::DumpIdIndex.empty() || + opts::dump::DumpIdExtras) { if (auto EC = dumpTpiStream(StreamIPI)) return EC; } @@ -620,6 +623,76 @@ Error DumpOutputStyle::dumpStringTable() { return Error::success(); } +static void buildDepSet(LazyRandomTypeCollection &Types, + ArrayRef<TypeIndex> Indices, + std::map<TypeIndex, CVType> &DepSet) { + SmallVector<TypeIndex, 4> DepList; + for (const auto &I : Indices) { + TypeIndex TI(I); + if (DepSet.find(TI) != DepSet.end() || TI.isSimple() || TI.isNoneType()) + continue; + + CVType Type = Types.getType(TI); + DepSet[TI] = Type; + codeview::discoverTypeIndices(Type, DepList); + buildDepSet(Types, DepList, DepSet); + } +} + +static void dumpFullTypeStream(LinePrinter &Printer, + LazyRandomTypeCollection &Types, + TpiStream &Stream, bool Bytes, bool Extras) { + Printer.formatLine("Showing {0:N} records", Stream.getNumTypeRecords()); + uint32_t Width = + NumDigits(TypeIndex::FirstNonSimpleIndex + Stream.getNumTypeRecords()); + + MinimalTypeDumpVisitor V(Printer, Width + 2, Bytes, Extras, Types, + Stream.getHashValues()); + + if (auto EC = codeview::visitTypeStream(Types, V)) { + Printer.formatLine("An error occurred dumping type records: {0}", + toString(std::move(EC))); + } +} + +static void dumpPartialTypeStream(LinePrinter &Printer, + LazyRandomTypeCollection &Types, + TpiStream &Stream, ArrayRef<TypeIndex> TiList, + bool Bytes, bool Extras, bool Deps) { + uint32_t Width = + NumDigits(TypeIndex::FirstNonSimpleIndex + Stream.getNumTypeRecords()); + + MinimalTypeDumpVisitor V(Printer, Width + 2, Bytes, Extras, Types, + Stream.getHashValues()); + + if (opts::dump::DumpTypeDependents) { + // If we need to dump all dependents, then iterate each index and find + // all dependents, adding them to a map ordered by TypeIndex. + std::map<TypeIndex, CVType> DepSet; + buildDepSet(Types, TiList, DepSet); + + Printer.formatLine( + "Showing {0:N} records and their dependents ({1:N} records total)", + TiList.size(), DepSet.size()); + + for (auto &Dep : DepSet) { + if (auto EC = codeview::visitTypeRecord(Dep.second, Dep.first, V)) + Printer.formatLine("An error occurred dumping type record {0}: {1}", + Dep.first, toString(std::move(EC))); + } + } else { + Printer.formatLine("Showing {0:N} records.", TiList.size()); + + for (const auto &I : TiList) { + TypeIndex TI(I); + CVType Type = Types.getType(TI); + if (auto EC = codeview::visitTypeRecord(Type, TI, V)) + Printer.formatLine("An error occurred dumping type record {0}: {1}", TI, + toString(std::move(EC))); + } + } +} + Error DumpOutputStyle::dumpTpiStream(uint32_t StreamIdx) { assert(StreamIdx == StreamTPI || StreamIdx == StreamIPI); @@ -659,27 +732,13 @@ Error DumpOutputStyle::dumpTpiStream(uint32_t StreamIdx) { auto &Types = Err(initializeTypes(StreamIdx)); - if (DumpTypes) { - P.formatLine("Showing {0:N} records", Stream.getNumTypeRecords()); - uint32_t Width = - NumDigits(TypeIndex::FirstNonSimpleIndex + Stream.getNumTypeRecords()); - - MinimalTypeDumpVisitor V(P, Width + 2, DumpBytes, DumpExtras, Types, - Stream.getHashValues()); - - 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))); - } + if (DumpTypes || !Indices.empty()) { + if (Indices.empty()) + dumpFullTypeStream(P, Types, Stream, DumpBytes, DumpExtras); + else { + std::vector<TypeIndex> TiList(Indices.begin(), Indices.end()); + dumpPartialTypeStream(P, Types, Stream, TiList, DumpBytes, DumpExtras, + opts::dump::DumpTypeDependents); } } @@ -775,7 +834,8 @@ Error DumpOutputStyle::dumpModuleSyms() { Pipeline.addCallbackToPipeline(Deserializer); Pipeline.addCallbackToPipeline(Dumper); CVSymbolVisitor Visitor(Pipeline); - if (auto EC = Visitor.visitSymbolStream(ModS.getSymbolArray())) { + auto SS = ModS.getSymbolsSubstream(); + if (auto EC = Visitor.visitSymbolStream(ModS.getSymbolArray(), SS.Offset)) { P.formatLine("Error while processing symbol records. {0}", toString(std::move(EC))); continue; @@ -804,13 +864,14 @@ Error DumpOutputStyle::dumpPublics() { Pipeline.addCallbackToPipeline(Deserializer); Pipeline.addCallbackToPipeline(Dumper); CVSymbolVisitor Visitor(Pipeline); + auto ExpectedSymbols = Publics.getSymbolArray(); if (!ExpectedSymbols) { P.formatLine("Could not read public symbol record stream"); return Error::success(); } - if (auto EC = Visitor.visitSymbolStream(*ExpectedSymbols)) + if (auto EC = Visitor.visitSymbolStream(*ExpectedSymbols, 0)) P.formatLine("Error while processing public symbol records. {0}", toString(std::move(EC))); diff --git a/tools/llvm-pdbutil/DumpOutputStyle.h b/tools/llvm-pdbutil/DumpOutputStyle.h index 296a6c14942e..4c52289f052e 100644 --- a/tools/llvm-pdbutil/DumpOutputStyle.h +++ b/tools/llvm-pdbutil/DumpOutputStyle.h @@ -37,8 +37,6 @@ private: Error dumpFileSummary(); Error dumpStreamSummary(); - Error dumpBlockRanges(); - Error dumpStreamBytes(); Error dumpStringTable(); Error dumpLines(); Error dumpInlineeLines(); diff --git a/tools/llvm-pdbutil/MinimalSymbolDumper.cpp b/tools/llvm-pdbutil/MinimalSymbolDumper.cpp index 7f5412d59885..ab7045ca4492 100644 --- a/tools/llvm-pdbutil/MinimalSymbolDumper.cpp +++ b/tools/llvm-pdbutil/MinimalSymbolDumper.cpp @@ -367,11 +367,17 @@ static std::string formatGaps(uint32_t IndentLevel, } Error MinimalSymbolDumper::visitSymbolBegin(codeview::CVSymbol &Record) { + return visitSymbolBegin(Record, 0); +} + +Error MinimalSymbolDumper::visitSymbolBegin(codeview::CVSymbol &Record, + uint32_t Offset) { // formatLine puts the newline at the beginning, so we use formatLine here // to start a new line, and then individual visit methods use format to // append to the existing line. - P.formatLine("- {0} [size = {1}]", getSymbolKindName(Record.Type), - Record.length()); + P.formatLine("{0} | {1} [size = {2}]", + fmt_align(Offset, AlignStyle::Right, 6), + getSymbolKindName(Record.Type), Record.length()); P.Indent(); return Error::success(); } @@ -394,28 +400,28 @@ std::string MinimalSymbolDumper::typeIndex(TypeIndex TI) const { Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, BlockSym &Block) { P.format(" `{0}`", Block.Name); - AutoIndent Indent(P); - P.formatLine("parent = {0}, addr = {1}", Block.Parent, + AutoIndent Indent(P, 7); + P.formatLine("parent = {0}, end = {1}", Block.Parent, Block.End); + P.formatLine("code size = {0}, addr = {1}", Block.CodeSize, formatSegmentOffset(Block.Segment, Block.CodeOffset)); - P.formatLine("code size = {0}, end = {1}", Block.CodeSize, Block.End); return Error::success(); } Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, Thunk32Sym &Thunk) { P.format(" `{0}`", Thunk.Name); - AutoIndent Indent(P); - P.formatLine("parent = {0}, addr = {1}", Thunk.Parent, - formatSegmentOffset(Thunk.Segment, Thunk.Offset)); - P.formatLine("kind = {0}, size = {1}, end = {2}, next = {3}", - formatThunkOrdinal(Thunk.Thunk), Thunk.Length, Thunk.End, + AutoIndent Indent(P, 7); + P.formatLine("parent = {0}, end = {1}, next = {2}", Thunk.Parent, Thunk.End, Thunk.Next); + P.formatLine("kind = {0}, size = {1}, addr = {2}", + formatThunkOrdinal(Thunk.Thunk), Thunk.Length, + formatSegmentOffset(Thunk.Segment, Thunk.Offset)); return Error::success(); } Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, TrampolineSym &Tramp) { - AutoIndent Indent(P); + AutoIndent Indent(P, 7); P.formatLine("type = {0}, size = {1}, source = {2}, target = {3}", formatTrampolineType(Tramp.Type), Tramp.Size, formatSegmentOffset(Tramp.ThunkSection, Tramp.ThunkOffset), @@ -427,7 +433,7 @@ Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, SectionSym &Section) { P.format(" `{0}`", Section.Name); - AutoIndent Indent(P); + AutoIndent Indent(P, 7); P.formatLine("length = {0}, alignment = {1}, rva = {2}, section # = {3}, " "characteristics = {4}", Section.Length, Section.Alignment, Section.Rva, @@ -437,7 +443,7 @@ Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, CoffGroupSym &CG) { P.format(" `{0}`", CG.Name); - AutoIndent Indent(P); + AutoIndent Indent(P, 7); P.formatLine("length = {0}, addr = {1}, characteristics = {2}", CG.Size, formatSegmentOffset(CG.Segment, CG.Offset), CG.Characteristics); return Error::success(); @@ -446,7 +452,7 @@ Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, CoffGroupSym &CG) { Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, BPRelativeSym &BPRel) { P.format(" `{0}`", BPRel.Name); - AutoIndent Indent(P); + AutoIndent Indent(P, 7); P.formatLine("type = {0}, offset = {1}", typeIndex(BPRel.Type), BPRel.Offset); return Error::success(); } @@ -459,7 +465,7 @@ Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, CallSiteInfoSym &CSI) { - AutoIndent Indent(P); + AutoIndent Indent(P, 7); P.formatLine("type = {0}, addr = {1}", typeIndex(CSI.Type), formatSegmentOffset(CSI.Segment, CSI.CodeOffset)); return Error::success(); @@ -467,6 +473,7 @@ Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, EnvBlockSym &EnvBlock) { + AutoIndent Indent(P, 7); for (const auto &Entry : EnvBlock.Fields) { P.formatLine("- {0}", Entry); } @@ -475,7 +482,7 @@ Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, FileStaticSym &FS) { P.format(" `{0}`", FS.Name); - AutoIndent Indent(P); + AutoIndent Indent(P, 7); P.formatLine("type = {0}, file name offset = {1}, flags = {2}", typeIndex(FS.Index), FS.ModFilenameOffset, formatLocalSymFlags(P.getIndentLevel() + 9, FS.Flags)); @@ -484,7 +491,7 @@ Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, FileStaticSym &FS) { Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, ExportSym &Export) { P.format(" `{0}`", Export.Name); - AutoIndent Indent(P); + AutoIndent Indent(P, 7); P.formatLine("ordinal = {0}, flags = {1}", Export.Ordinal, formatExportFlags(P.getIndentLevel() + 9, Export.Flags)); return Error::success(); @@ -492,7 +499,7 @@ Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, ExportSym &Export) { Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, Compile2Sym &Compile2) { - AutoIndent Indent(P); + AutoIndent Indent(P, 7); SourceLanguage Lang = static_cast<SourceLanguage>( Compile2.Flags & CompileSym2Flags::SourceLanguageMask); P.formatLine("machine = {0}, ver = {1}, language = {2}", @@ -512,7 +519,7 @@ Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, Compile3Sym &Compile3) { - AutoIndent Indent(P); + AutoIndent Indent(P, 7); SourceLanguage Lang = static_cast<SourceLanguage>( Compile3.Flags & CompileSym3Flags::SourceLanguageMask); P.formatLine("machine = {0}, Ver = {1}, language = {2}", @@ -531,7 +538,7 @@ Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, ConstantSym &Constant) { P.format(" `{0}`", Constant.Name); - AutoIndent Indent(P); + AutoIndent Indent(P, 7); P.formatLine("type = {0}, value = {1}", typeIndex(Constant.Type), Constant.Value.toString(10)); return Error::success(); @@ -539,7 +546,7 @@ Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, DataSym &Data) { P.format(" `{0}`", Data.Name); - AutoIndent Indent(P); + AutoIndent Indent(P, 7); P.formatLine("type = {0}, addr = {1}", typeIndex(Data.Type), formatSegmentOffset(Data.Segment, Data.DataOffset)); return Error::success(); @@ -553,7 +560,7 @@ Error MinimalSymbolDumper::visitKnownRecord( Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, DefRangeFramePointerRelSym &Def) { - AutoIndent Indent(P); + AutoIndent Indent(P, 7); P.formatLine("offset = {0}, range = {1}", Def.Offset, formatRange(Def.Range)); P.formatLine("gaps = {2}", Def.Offset, formatGaps(P.getIndentLevel() + 9, Def.Gaps)); @@ -562,7 +569,7 @@ Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, DefRangeRegisterRelSym &Def) { - AutoIndent Indent(P); + AutoIndent Indent(P, 7); P.formatLine("register = {0}, base ptr = {1}, offset in parent = {2}, has " "spilled udt = {3}", uint16_t(Def.Hdr.Register), int32_t(Def.Hdr.BasePointerOffset), @@ -574,7 +581,7 @@ Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, Error MinimalSymbolDumper::visitKnownRecord( CVSymbol &CVR, DefRangeRegisterSym &DefRangeRegister) { - AutoIndent Indent(P); + AutoIndent Indent(P, 7); P.formatLine("register = {0}, may have no name = {1}, range start = " "{2}, length = {3}", uint16_t(DefRangeRegister.Hdr.Register), @@ -589,7 +596,7 @@ Error MinimalSymbolDumper::visitKnownRecord( Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, DefRangeSubfieldRegisterSym &Def) { - AutoIndent Indent(P); + AutoIndent Indent(P, 7); bool NoName = !!(Def.Hdr.MayHaveNoName == 0); P.formatLine("register = {0}, may have no name = {1}, offset in parent = {2}", uint16_t(Def.Hdr.Register), NoName, @@ -601,7 +608,7 @@ Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, DefRangeSubfieldSym &Def) { - AutoIndent Indent(P); + AutoIndent Indent(P, 7); P.formatLine("program = {0}, offset in parent = {1}, range = {2}", Def.Program, Def.OffsetInParent, formatRange(Def.Range)); P.formatLine("gaps = {0}", formatGaps(P.getIndentLevel() + 9, Def.Gaps)); @@ -609,7 +616,7 @@ Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, } Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, DefRangeSym &Def) { - AutoIndent Indent(P); + AutoIndent Indent(P, 7); P.formatLine("program = {0}, range = {1}", Def.Program, formatRange(Def.Range)); P.formatLine("gaps = {0}", formatGaps(P.getIndentLevel() + 9, Def.Gaps)); @@ -617,7 +624,7 @@ Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, DefRangeSym &Def) { } Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, FrameCookieSym &FC) { - AutoIndent Indent(P); + AutoIndent Indent(P, 7); P.formatLine("code offset = {0}, Register = {1}, kind = {2}, flags = {3}", FC.CodeOffset, FC.Register, formatCookieKind(FC.CookieKind), FC.Flags); @@ -625,7 +632,7 @@ Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, FrameCookieSym &FC) { } Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, FrameProcSym &FP) { - AutoIndent Indent(P); + AutoIndent Indent(P, 7); P.formatLine("size = {0}, padding size = {1}, offset to padding = {2}", FP.TotalFrameBytes, FP.PaddingFrameBytes, FP.OffsetToPadding); P.formatLine("bytes of callee saved registers = {0}, exception handler addr " @@ -640,7 +647,7 @@ Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, FrameProcSym &FP) { Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, HeapAllocationSiteSym &HAS) { - AutoIndent Indent(P); + AutoIndent Indent(P, 7); P.formatLine("type = {0}, addr = {1} call size = {2}", typeIndex(HAS.Type), formatSegmentOffset(HAS.Segment, HAS.CodeOffset), HAS.CallInstructionSize); @@ -648,7 +655,7 @@ Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, } Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, InlineSiteSym &IS) { - AutoIndent Indent(P); + AutoIndent Indent(P, 7); auto Bytes = makeArrayRef(IS.AnnotationData); StringRef Annotations(reinterpret_cast<const char *>(Bytes.begin()), Bytes.size()); @@ -662,7 +669,7 @@ Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, InlineSiteSym &IS) { Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, RegisterSym &Register) { P.format(" `{0}`", Register.Name); - AutoIndent Indent(P); + AutoIndent Indent(P, 7); P.formatLine("register = {0}, type = {1}", formatRegisterId(Register.Register), typeIndex(Register.Index)); return Error::success(); @@ -671,7 +678,7 @@ Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, PublicSym32 &Public) { P.format(" `{0}`", Public.Name); - AutoIndent Indent(P); + AutoIndent Indent(P, 7); P.formatLine("flags = {0}, addr = {1}", formatPublicSymFlags(P.getIndentLevel() + 9, Public.Flags), formatSegmentOffset(Public.Segment, Public.Offset)); @@ -680,7 +687,7 @@ Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, ProcRefSym &PR) { P.format(" `{0}`", PR.Name); - AutoIndent Indent(P); + AutoIndent Indent(P, 7); P.formatLine("module = {0}, sum name = {1}, offset = {2}", PR.Module, PR.SumName, PR.SymOffset); return Error::success(); @@ -689,7 +696,7 @@ Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, ProcRefSym &PR) { Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, LabelSym &Label) { P.format(" `{0}` (addr = {1})", Label.Name, formatSegmentOffset(Label.Segment, Label.CodeOffset)); - AutoIndent Indent(P); + AutoIndent Indent(P, 7); P.formatLine("flags = {0}", formatProcSymFlags(P.getIndentLevel() + 9, Label.Flags)); return Error::success(); @@ -697,7 +704,7 @@ Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, LabelSym &Label) { Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, LocalSym &Local) { P.format(" `{0}`", Local.Name); - AutoIndent Indent(P); + AutoIndent Indent(P, 7); std::string FlagStr = formatLocalSymFlags(P.getIndentLevel() + 9, Local.Flags); @@ -713,10 +720,11 @@ Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, ProcSym &Proc) { P.format(" `{0}`", Proc.Name); - AutoIndent Indent(P); - P.formatLine("parent = {0}, addr = {1}, code size = {2}, end = {3}", - Proc.Parent, formatSegmentOffset(Proc.Segment, Proc.CodeOffset), - Proc.CodeSize, Proc.End); + AutoIndent Indent(P, 7); + P.formatLine("parent = {0}, end = {1}, addr = {2}, code size = {3}", + Proc.Parent, Proc.End, + formatSegmentOffset(Proc.Segment, Proc.CodeOffset), + Proc.CodeSize); P.formatLine("debug start = {0}, debug end = {1}, flags = {2}", Proc.DbgStart, Proc.DbgEnd, formatProcSymFlags(P.getIndentLevel() + 9, Proc.Flags)); @@ -729,7 +737,7 @@ Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, } Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, CallerSym &Caller) { - AutoIndent Indent(P); + AutoIndent Indent(P, 7); for (const auto &I : Caller.Indices) { P.formatLine("callee: {0}", typeIndex(I)); } @@ -739,7 +747,7 @@ Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, CallerSym &Caller) { Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, RegRelativeSym &RegRel) { P.format(" `{0}`", RegRel.Name); - AutoIndent Indent(P); + AutoIndent Indent(P, 7); P.formatLine("type = {0}, register = {1}, offset = {2}", typeIndex(RegRel.Type), formatRegisterId(RegRel.Register), RegRel.Offset); @@ -749,7 +757,7 @@ Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, ThreadLocalDataSym &Data) { P.format(" `{0}`", Data.Name); - AutoIndent Indent(P); + AutoIndent Indent(P, 7); P.formatLine("type = {0}, addr = {1}", typeIndex(Data.Type), formatSegmentOffset(Data.Segment, Data.DataOffset)); return Error::success(); @@ -757,7 +765,7 @@ Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, Error MinimalSymbolDumper::visitKnownRecord(CVSymbol &CVR, UDTSym &UDT) { P.format(" `{0}`", UDT.Name); - AutoIndent Indent(P); + AutoIndent Indent(P, 7); P.formatLine("original type = {0}", UDT.Type); return Error::success(); } diff --git a/tools/llvm-pdbutil/MinimalSymbolDumper.h b/tools/llvm-pdbutil/MinimalSymbolDumper.h index 451f2da6fd1d..5e30959ea9c0 100644 --- a/tools/llvm-pdbutil/MinimalSymbolDumper.h +++ b/tools/llvm-pdbutil/MinimalSymbolDumper.h @@ -27,6 +27,7 @@ public: : P(P), Types(Types) {} Error visitSymbolBegin(codeview::CVSymbol &Record) override; + Error visitSymbolBegin(codeview::CVSymbol &Record, uint32_t Offset) override; Error visitSymbolEnd(codeview::CVSymbol &Record) override; #define SYMBOL_RECORD(EnumName, EnumVal, Name) \ diff --git a/tools/llvm-pdbutil/MinimalTypeDumper.cpp b/tools/llvm-pdbutil/MinimalTypeDumper.cpp index 22d3a4557c52..1af53e35ed11 100644 --- a/tools/llvm-pdbutil/MinimalTypeDumper.cpp +++ b/tools/llvm-pdbutil/MinimalTypeDumper.cpp @@ -377,7 +377,7 @@ Error MinimalTypeDumpVisitor::visitKnownRecord(CVType &CVR, Error MinimalTypeDumpVisitor::visitKnownRecord(CVType &CVR, MemberFunctionRecord &MF) { P.formatLine("return type = {0}, # args = {1}, param list = {2}", - MF.ParameterCount, MF.ArgumentList, MF.ReturnType); + MF.ReturnType, MF.ParameterCount, MF.ArgumentList); P.formatLine("class type = {0}, this type = {1}, this adjust = {2}", MF.ClassType, MF.ThisType, MF.ThisPointerAdjustment); P.formatLine("calling conv = {0}, options = {1}", diff --git a/tools/llvm-pdbutil/PdbYaml.cpp b/tools/llvm-pdbutil/PdbYaml.cpp index b4a41fbfdb8f..315ae2e6711f 100644 --- a/tools/llvm-pdbutil/PdbYaml.cpp +++ b/tools/llvm-pdbutil/PdbYaml.cpp @@ -30,8 +30,6 @@ using namespace llvm::pdb; using namespace llvm::pdb::yaml; using namespace llvm::yaml; -LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(uint32_t) -LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::StringRef) LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::pdb::yaml::NamedStreamMapping) LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::pdb::yaml::PdbDbiModuleInfo) LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::pdb::yaml::StreamBlockList) diff --git a/tools/llvm-pdbutil/llvm-pdbutil.cpp b/tools/llvm-pdbutil/llvm-pdbutil.cpp index 4a176fb13590..ad11ad498000 100644 --- a/tools/llvm-pdbutil/llvm-pdbutil.cpp +++ b/tools/llvm-pdbutil/llvm-pdbutil.cpp @@ -419,6 +419,13 @@ cl::list<uint32_t> DumpIdIndex( cl::desc("only dump ids with the specified hexadecimal type index"), cl::cat(TypeOptions), cl::sub(DumpSubcommand)); +cl::opt<bool> DumpTypeDependents( + "dependents", + cl::desc("In conjunection with -type-index and -id-index, dumps the entire " + "dependency graph for the specified index instead of " + "just the single record with the specified index"), + cl::cat(TypeOptions), cl::sub(DumpSubcommand)); + // SYMBOL OPTIONS cl::opt<bool> DumpPublics("publics", cl::desc("dump Publics stream data"), cl::cat(SymbolOptions), cl::sub(DumpSubcommand)); diff --git a/tools/llvm-pdbutil/llvm-pdbutil.h b/tools/llvm-pdbutil/llvm-pdbutil.h index 837d8ebbaf9e..9ee5866bbeff 100644 --- a/tools/llvm-pdbutil/llvm-pdbutil.h +++ b/tools/llvm-pdbutil/llvm-pdbutil.h @@ -135,6 +135,7 @@ 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> DumpTypeDependents; extern llvm::cl::opt<bool> DumpIds; extern llvm::cl::opt<bool> DumpIdData; diff --git a/tools/llvm-readobj/COFFDumper.cpp b/tools/llvm-readobj/COFFDumper.cpp index daa7a643a72f..e5ff3e4186de 100644 --- a/tools/llvm-readobj/COFFDumper.cpp +++ b/tools/llvm-readobj/COFFDumper.cpp @@ -335,6 +335,7 @@ static const EnumEntry<COFF::MachineTypes> ImageFileMachineType[] = { LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_MACHINE_AM33 ), LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_MACHINE_AMD64 ), LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_MACHINE_ARM ), + LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_MACHINE_ARM64 ), LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_MACHINE_ARMNT ), LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_MACHINE_EBC ), LLVM_READOBJ_ENUM_ENT(COFF, IMAGE_FILE_MACHINE_I386 ), @@ -678,6 +679,7 @@ void COFFDumper::printDOSHeader(const dos_header *DH) { template <class PEHeader> void COFFDumper::printPEHeader(const PEHeader *Hdr) { DictScope D(W, "ImageOptionalHeader"); + W.printHex ("Magic", Hdr->Magic); W.printNumber("MajorLinkerVersion", Hdr->MajorLinkerVersion); W.printNumber("MinorLinkerVersion", Hdr->MinorLinkerVersion); W.printNumber("SizeOfCode", Hdr->SizeOfCode); diff --git a/tools/llvm-readobj/WasmDumper.cpp b/tools/llvm-readobj/WasmDumper.cpp index 21614297e467..14603f8a2b09 100644 --- a/tools/llvm-readobj/WasmDumper.cpp +++ b/tools/llvm-readobj/WasmDumper.cpp @@ -183,6 +183,7 @@ void WasmDumper::printSymbol(const SymbolRef &Sym) { WasmSymbol Symbol = Obj->getWasmSymbol(Sym.getRawDataRefImpl()); W.printString("Name", Symbol.Name); W.printEnum("Type", static_cast<unsigned>(Symbol.Type), makeArrayRef(WasmSymbolTypes)); + W.printHex("Flags", Symbol.Flags); } } diff --git a/tools/obj2yaml/wasm2yaml.cpp b/tools/obj2yaml/wasm2yaml.cpp index ad0075caac1d..1df6afcf3c46 100644 --- a/tools/obj2yaml/wasm2yaml.cpp +++ b/tools/obj2yaml/wasm2yaml.cpp @@ -77,6 +77,8 @@ std::unique_ptr<WasmYAML::CustomSection> WasmDumper::dumpCustomSection(const Was LinkingSec->SymbolInfos.push_back(Info); } } + LinkingSec->DataSize = Obj.linkingData().DataSize; + LinkingSec->DataAlignment = Obj.linkingData().DataAlignment; CustomSec = std::move(LinkingSec); } else { CustomSec = make_unique<WasmYAML::CustomSection>(WasmSec.Name); diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp index 9d489ab5a2d2..24cce58047f1 100644 --- a/tools/opt/opt.cpp +++ b/tools/opt/opt.cpp @@ -242,6 +242,11 @@ static cl::opt<bool> PassRemarksWithHotness( cl::desc("With PGO, include profile count in optimization remarks"), cl::Hidden); +static cl::opt<unsigned> PassRemarksHotnessThreshold( + "pass-remarks-hotness-threshold", + cl::desc("Minimum profile count required for an optimization remark to be output"), + cl::Hidden); + static cl::opt<std::string> RemarksFilename("pass-remarks-output", cl::desc("YAML output filename for pass remarks"), @@ -420,7 +425,10 @@ int main(int argc, char **argv) { Context.enableDebugTypeODRUniquing(); if (PassRemarksWithHotness) - Context.setDiagnosticHotnessRequested(true); + Context.setDiagnosticsHotnessRequested(true); + + if (PassRemarksHotnessThreshold) + Context.setDiagnosticsHotnessThreshold(PassRemarksHotnessThreshold); std::unique_ptr<tool_output_file> YamlFile; if (RemarksFilename != "") { diff --git a/tools/yaml2obj/yaml2wasm.cpp b/tools/yaml2obj/yaml2wasm.cpp index cf591e16317c..110700d40c32 100644 --- a/tools/yaml2obj/yaml2wasm.cpp +++ b/tools/yaml2obj/yaml2wasm.cpp @@ -110,22 +110,52 @@ static int writeInitExpr(const wasm::WasmInitExpr &InitExpr, raw_ostream &OS) { return 0; } +class SubSectionWriter { + raw_ostream &OS; + std::string OutString; + raw_string_ostream StringStream; + +public: + SubSectionWriter(raw_ostream &OS) : OS(OS), StringStream(OutString) {} + + void Done() { + StringStream.flush(); + encodeULEB128(OutString.size(), OS); + OS << OutString; + OutString.clear(); + } + + raw_ostream& GetStream() { + return StringStream; + } +}; + int WasmWriter::writeSectionContent(raw_ostream &OS, WasmYAML::LinkingSection &Section) { writeStringRef(Section.Name, OS); + + SubSectionWriter SubSection(OS); + + // DATA_SIZE subsection + encodeULEB128(wasm::WASM_DATA_SIZE, OS); + encodeULEB128(Section.DataSize, SubSection.GetStream()); + SubSection.Done(); + + // DATA_ALIGNMENT subsection + encodeULEB128(wasm::WASM_DATA_ALIGNMENT, OS); + encodeULEB128(Section.DataAlignment, SubSection.GetStream()); + SubSection.Done(); + + // SYMBOL_INFO subsection if (Section.SymbolInfos.size()) { encodeULEB128(wasm::WASM_SYMBOL_INFO, OS); - std::string OutString; - raw_string_ostream StringStream(OutString); - encodeULEB128(Section.SymbolInfos.size(), StringStream); + encodeULEB128(Section.SymbolInfos.size(), SubSection.GetStream()); for (const WasmYAML::SymbolInfo &Info : Section.SymbolInfos) { - writeStringRef(Info.Name, StringStream); - encodeULEB128(Info.Flags, StringStream); + writeStringRef(Info.Name, SubSection.GetStream()); + encodeULEB128(Info.Flags, SubSection.GetStream()); } - StringStream.flush(); - encodeULEB128(OutString.size(), OS); - OS << OutString; + SubSection.Done(); } return 0; } @@ -134,18 +164,16 @@ int WasmWriter::writeSectionContent(raw_ostream &OS, WasmYAML::NameSection &Sect writeStringRef(Section.Name, OS); if (Section.FunctionNames.size()) { encodeULEB128(wasm::WASM_NAMES_FUNCTION, OS); - std::string OutString; - raw_string_ostream StringStream(OutString); - encodeULEB128(Section.FunctionNames.size(), StringStream); + SubSectionWriter SubSection(OS); + + encodeULEB128(Section.FunctionNames.size(), SubSection.GetStream()); for (const WasmYAML::NameEntry &NameEntry : Section.FunctionNames) { - encodeULEB128(NameEntry.Index, StringStream); - writeStringRef(NameEntry.Name, StringStream); + encodeULEB128(NameEntry.Index, SubSection.GetStream()); + writeStringRef(NameEntry.Name, SubSection.GetStream()); } - StringStream.flush(); - encodeULEB128(OutString.size(), OS); - OS << OutString; + SubSection.Done(); } return 0; } |