aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-06-03 15:20:36 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-06-03 15:20:36 +0000
commitd288ef4c1788d3a951a7558c68312c2d320612b1 (patch)
treeece909a5200f95f85f0813599a9500620f4d9217 /tools
parentf382538d471e38a9b98f016c4caebd24c8d60b62 (diff)
downloadsrc-d288ef4c1788d3a951a7558c68312c2d320612b1.tar.gz
src-d288ef4c1788d3a951a7558c68312c2d320612b1.zip
Notes
Diffstat (limited to 'tools')
-rw-r--r--tools/llc/llc.cpp3
-rw-r--r--tools/llvm-config/llvm-config.cpp2
-rw-r--r--tools/llvm-lto2/llvm-lto2.cpp8
-rw-r--r--tools/llvm-pdbdump/LLVMOutputStyle.cpp14
-rw-r--r--tools/llvm-pdbdump/PdbYaml.cpp4
-rw-r--r--tools/llvm-pdbdump/PdbYaml.h5
-rw-r--r--tools/llvm-pdbdump/YAMLOutputStyle.cpp143
-rw-r--r--tools/llvm-pdbdump/YAMLOutputStyle.h3
-rw-r--r--tools/llvm-pdbdump/fuzzer/llvm-pdbdump-fuzzer.cpp2
-rw-r--r--tools/llvm-pdbdump/llvm-pdbdump.cpp68
-rw-r--r--tools/llvm-readobj/COFFDumper.cpp3
11 files changed, 60 insertions, 195 deletions
diff --git a/tools/llc/llc.cpp b/tools/llc/llc.cpp
index 589005943045..e10d112dcf90 100644
--- a/tools/llc/llc.cpp
+++ b/tools/llc/llc.cpp
@@ -304,6 +304,9 @@ int main(int argc, char **argv) {
initializeScalarizeMaskedMemIntrinPass(*Registry);
initializeExpandReductionsPass(*Registry);
+ // Initialize debugging passes.
+ initializeScavengerTestPass(*Registry);
+
// Register the target printer for --version.
cl::AddExtraVersionPrinter(TargetRegistry::printRegisteredTargetsForVersion);
diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp
index 888da7143c9f..08b096afb052 100644
--- a/tools/llvm-config/llvm-config.cpp
+++ b/tools/llvm-config/llvm-config.cpp
@@ -333,7 +333,7 @@ int main(int argc, char **argv) {
} else {
ActivePrefix = CurrentExecPrefix;
ActiveIncludeDir = ActivePrefix + "/include";
- SmallString<PATH_MAX> path(StringRef(LLVM_TOOLS_INSTALL_DIR));
+ SmallString<256> path(StringRef(LLVM_TOOLS_INSTALL_DIR));
sys::fs::make_absolute(ActivePrefix, path);
ActiveBinDir = path.str();
ActiveLibDir = ActivePrefix + "/lib" + LLVM_LIBDIR_SUFFIX;
diff --git a/tools/llvm-lto2/llvm-lto2.cpp b/tools/llvm-lto2/llvm-lto2.cpp
index 3d2643db85bd..89f85157e1df 100644
--- a/tools/llvm-lto2/llvm-lto2.cpp
+++ b/tools/llvm-lto2/llvm-lto2.cpp
@@ -99,6 +99,11 @@ static cl::opt<bool> OptRemarksWithHotness(
cl::desc("Whether to include hotness informations in the remarks.\n"
"Has effect only if -pass-remarks-output is specified."));
+static cl::opt<bool>
+ UseNewPM("use-new-pm",
+ cl::desc("Run LTO passes using the new pass manager"),
+ cl::init(false), cl::Hidden);
+
static void check(Error E, std::string Msg) {
if (!E)
return;
@@ -196,6 +201,7 @@ static int run(int argc, char **argv) {
Conf.AAPipeline = AAPipeline;
Conf.OptLevel = OptLevel - '0';
+ Conf.UseNewPM = UseNewPM;
switch (CGOptLevel) {
case '0':
Conf.CGOptLevel = CodeGenOpt::None;
@@ -351,7 +357,7 @@ int main(int argc, char **argv) {
// FIXME: This should use llvm::cl subcommands, but it isn't currently
// possible to pass an argument not associated with a subcommand to a
- // subcommand (e.g. -lto-use-new-pm).
+ // subcommand (e.g. -use-new-pm).
if (argc < 2)
return usage();
diff --git a/tools/llvm-pdbdump/LLVMOutputStyle.cpp b/tools/llvm-pdbdump/LLVMOutputStyle.cpp
index d95eca1aeddb..31c342cd0f5a 100644
--- a/tools/llvm-pdbdump/LLVMOutputStyle.cpp
+++ b/tools/llvm-pdbdump/LLVMOutputStyle.cpp
@@ -483,8 +483,8 @@ Error LLVMOutputStyle::dumpStreamBytes() {
if (SI >= File.getNumStreams())
return make_error<RawError>(raw_error_code::no_stream);
- auto S = MappedBlockStream::createIndexedStream(File.getMsfLayout(),
- File.getMsfBuffer(), SI);
+ auto S = MappedBlockStream::createIndexedStream(
+ File.getMsfLayout(), File.getMsfBuffer(), SI, File.getAllocator());
if (!S)
continue;
DictScope DD(P, "Stream");
@@ -791,7 +791,7 @@ Error LLVMOutputStyle::dumpDbiStream() {
if (HasModuleDI && (ShouldDumpSymbols || opts::raw::DumpLineInfo)) {
auto ModStreamData = MappedBlockStream::createIndexedStream(
File.getMsfLayout(), File.getMsfBuffer(),
- Modi.getModuleStreamIndex());
+ Modi.getModuleStreamIndex(), File.getAllocator());
ModuleDebugStreamRef ModS(Modi, std::move(ModStreamData));
if (auto EC = ModS.reload())
@@ -804,7 +804,8 @@ Error LLVMOutputStyle::dumpDbiStream() {
auto &Types = *ExpectedTypes;
ListScope SS(P, "Symbols");
- codeview::CVSymbolDumper SD(P, Types, nullptr, false);
+ codeview::CVSymbolDumper SD(P, Types, CodeViewContainer::Pdb, nullptr,
+ false);
bool HadError = false;
for (auto S : ModS.symbols(&HadError)) {
DictScope LL(P, "");
@@ -830,8 +831,7 @@ Error LLVMOutputStyle::dumpDbiStream() {
return ExpectedTypes.takeError();
auto &IpiItems = *ExpectedTypes;
C13RawVisitor V(P, File, IpiItems);
- if (auto EC =
- codeview::visitDebugSubsections(ModS.linesAndChecksums(), V))
+ if (auto EC = codeview::visitDebugSubsections(ModS.subsections(), V))
return EC;
}
}
@@ -952,7 +952,7 @@ Error LLVMOutputStyle::dumpPublicsStream() {
return ExpectedTypes.takeError();
auto &Tpi = *ExpectedTypes;
- codeview::CVSymbolDumper SD(P, Tpi, nullptr, false);
+ codeview::CVSymbolDumper SD(P, Tpi, CodeViewContainer::Pdb, nullptr, false);
bool HadError = false;
for (auto S : Publics->getSymbols(&HadError)) {
DictScope DD(P, "");
diff --git a/tools/llvm-pdbdump/PdbYaml.cpp b/tools/llvm-pdbdump/PdbYaml.cpp
index e288063e2afa..b4a41fbfdb8f 100644
--- a/tools/llvm-pdbdump/PdbYaml.cpp
+++ b/tools/llvm-pdbdump/PdbYaml.cpp
@@ -12,6 +12,7 @@
#include "llvm/ADT/StringExtras.h"
#include "llvm/DebugInfo/CodeView/CVSymbolVisitor.h"
#include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"
+#include "llvm/DebugInfo/CodeView/DebugStringTableSubsection.h"
#include "llvm/DebugInfo/CodeView/SymbolDeserializer.h"
#include "llvm/DebugInfo/CodeView/SymbolVisitorCallbackPipeline.h"
#include "llvm/DebugInfo/CodeView/TypeSerializer.h"
@@ -21,6 +22,7 @@
#include "llvm/DebugInfo/PDB/Native/TpiHashing.h"
#include "llvm/DebugInfo/PDB/PDBExtras.h"
#include "llvm/DebugInfo/PDB/PDBTypes.h"
+#include "llvm/ObjectYAML/CodeViewYAMLDebugSections.h"
#include "llvm/ObjectYAML/CodeViewYAMLTypes.h"
using namespace llvm;
@@ -220,6 +222,6 @@ void MappingTraits<PdbDbiModuleInfo>::mapping(IO &IO, PdbDbiModuleInfo &Obj) {
IO.mapRequired("Module", Obj.Mod);
IO.mapOptional("ObjFile", Obj.Obj, Obj.Mod);
IO.mapOptional("SourceFiles", Obj.SourceFiles);
- IO.mapOptional("LineInfo", Obj.FileLineInfo);
+ IO.mapOptional("Subsections", Obj.Subsections);
IO.mapOptional("Modi", Obj.Modi);
}
diff --git a/tools/llvm-pdbdump/PdbYaml.h b/tools/llvm-pdbdump/PdbYaml.h
index deb500ec2074..62ed608916fc 100644
--- a/tools/llvm-pdbdump/PdbYaml.h
+++ b/tools/llvm-pdbdump/PdbYaml.h
@@ -28,6 +28,9 @@
#include <vector>
namespace llvm {
+namespace codeview {
+class DebugStringTableSubsection;
+}
namespace pdb {
namespace yaml {
@@ -68,7 +71,7 @@ struct PdbDbiModuleInfo {
StringRef Obj;
StringRef Mod;
std::vector<StringRef> SourceFiles;
- Optional<CodeViewYAML::SourceFileInfo> FileLineInfo;
+ std::vector<CodeViewYAML::YAMLDebugSubsection> Subsections;
Optional<PdbModiStream> Modi;
};
diff --git a/tools/llvm-pdbdump/YAMLOutputStyle.cpp b/tools/llvm-pdbdump/YAMLOutputStyle.cpp
index 18839a7679d3..ee72b90b12d1 100644
--- a/tools/llvm-pdbdump/YAMLOutputStyle.cpp
+++ b/tools/llvm-pdbdump/YAMLOutputStyle.cpp
@@ -101,117 +101,6 @@ Error YAMLOutputStyle::dump() {
return Error::success();
}
-namespace {
-class C13YamlVisitor : public C13DebugFragmentVisitor {
-public:
- C13YamlVisitor(CodeViewYAML::SourceFileInfo &Info, PDBFile &F)
- : C13DebugFragmentVisitor(F), Info(Info) {}
-
- Error handleFileChecksums() override {
- for (const auto &C : *Checksums) {
- CodeViewYAML::SourceFileChecksumEntry Entry;
- if (auto Result = getNameFromStringTable(C.FileNameOffset))
- Entry.FileName = *Result;
- else
- return Result.takeError();
-
- Entry.Kind = C.Kind;
- Entry.ChecksumBytes.Bytes = C.Checksum;
- Info.FileChecksums.push_back(Entry);
- }
- return Error::success();
- }
-
- Error handleLines() override {
- for (const auto &LF : Lines) {
- Info.LineFragments.emplace_back();
- auto &Fragment = Info.LineFragments.back();
-
- Fragment.CodeSize = LF.header()->CodeSize;
- Fragment.Flags =
- static_cast<codeview::LineFlags>(uint16_t(LF.header()->Flags));
- Fragment.RelocOffset = LF.header()->RelocOffset;
- Fragment.RelocSegment = LF.header()->RelocSegment;
-
- for (const auto &L : LF) {
- Fragment.Blocks.emplace_back();
- auto &Block = Fragment.Blocks.back();
-
- if (auto Result = getNameFromChecksumsBuffer(L.NameIndex))
- Block.FileName = *Result;
- else
- return Result.takeError();
-
- for (const auto &N : L.LineNumbers) {
- CodeViewYAML::SourceLineEntry Line;
- Line.Offset = N.Offset;
- codeview::LineInfo LI(N.Flags);
- Line.LineStart = LI.getStartLine();
- Line.EndDelta = LI.getLineDelta();
- Line.IsStatement = LI.isStatement();
- Block.Lines.push_back(Line);
- }
-
- if (LF.hasColumnInfo()) {
- for (const auto &C : L.Columns) {
- CodeViewYAML::SourceColumnEntry Column;
- Column.StartColumn = C.StartColumn;
- Column.EndColumn = C.EndColumn;
- Block.Columns.push_back(Column);
- }
- }
- }
- }
- return Error::success();
- }
-
- Error handleInlineeLines() override {
- for (const auto &ILF : InlineeLines) {
- Info.Inlinees.emplace_back();
- auto &Inlinee = Info.Inlinees.back();
-
- Inlinee.HasExtraFiles = ILF.hasExtraFiles();
- for (const auto &IL : ILF) {
- Inlinee.Sites.emplace_back();
- auto &Site = Inlinee.Sites.back();
- if (auto Result = getNameFromChecksumsBuffer(IL.Header->FileID))
- Site.FileName = *Result;
- else
- return Result.takeError();
-
- Site.Inlinee = IL.Header->Inlinee.getIndex();
- Site.SourceLineNum = IL.Header->SourceLineNum;
- if (ILF.hasExtraFiles()) {
- for (const auto &EF : IL.ExtraFiles) {
- if (auto Result = getNameFromChecksumsBuffer(EF))
- Site.ExtraFiles.push_back(*Result);
- else
- return Result.takeError();
- }
- }
- }
- }
- return Error::success();
- }
-
-private:
- CodeViewYAML::SourceFileInfo &Info;
-};
-}
-
-Expected<Optional<CodeViewYAML::SourceFileInfo>>
-YAMLOutputStyle::getFileLineInfo(const pdb::ModuleDebugStreamRef &ModS) {
- if (!ModS.hasLineInfo())
- return None;
-
- CodeViewYAML::SourceFileInfo Info;
- C13YamlVisitor Visitor(Info, File);
- if (auto EC =
- codeview::visitDebugSubsections(ModS.linesAndChecksums(), Visitor))
- return std::move(EC);
-
- return Info;
-}
Error YAMLOutputStyle::dumpFileHeaders() {
if (opts::pdb2yaml::NoFileHeaders)
@@ -236,14 +125,17 @@ Error YAMLOutputStyle::dumpFileHeaders() {
}
Error YAMLOutputStyle::dumpStringTable() {
- if (!opts::pdb2yaml::StringTable)
+ bool RequiresStringTable = opts::pdb2yaml::DbiModuleSourceFileInfo ||
+ opts::pdb2yaml::DbiModuleSourceLineInfo;
+ bool RequestedStringTable = opts::pdb2yaml::StringTable;
+ if (!RequiresStringTable && !RequestedStringTable)
return Error::success();
- Obj.StringTable.emplace();
auto ExpectedST = File.getStringTable();
if (!ExpectedST)
return ExpectedST.takeError();
+ Obj.StringTable.emplace();
const auto &ST = ExpectedST.get();
for (auto ID : ST.name_ids()) {
auto S = ST.getStringForID(ID);
@@ -337,17 +229,30 @@ Error YAMLOutputStyle::dumpDbiStream() {
continue;
auto ModStreamData = msf::MappedBlockStream::createIndexedStream(
- File.getMsfLayout(), File.getMsfBuffer(), ModiStream);
+ File.getMsfLayout(), File.getMsfBuffer(), ModiStream,
+ File.getAllocator());
pdb::ModuleDebugStreamRef ModS(MI, std::move(ModStreamData));
if (auto EC = ModS.reload())
return EC;
- if (opts::pdb2yaml::DbiModuleSourceLineInfo) {
- auto ExpectedInfo = getFileLineInfo(ModS);
- if (!ExpectedInfo)
- return ExpectedInfo.takeError();
- DMI.FileLineInfo = *ExpectedInfo;
+ auto ExpectedST = File.getStringTable();
+ if (!ExpectedST)
+ return ExpectedST.takeError();
+ if (opts::pdb2yaml::DbiModuleSourceLineInfo &&
+ ModS.hasDebugSubsections()) {
+ auto ExpectedChecksums = ModS.findChecksumsSubsection();
+ if (!ExpectedChecksums)
+ return ExpectedChecksums.takeError();
+
+ for (const auto &SS : ModS.subsections()) {
+ auto Converted =
+ CodeViewYAML::YAMLDebugSubsection::fromCodeViewSubection(
+ ExpectedST->getStringTable(), *ExpectedChecksums, SS);
+ if (!Converted)
+ return Converted.takeError();
+ DMI.Subsections.push_back(*Converted);
+ }
}
if (opts::pdb2yaml::DbiModuleSyms) {
diff --git a/tools/llvm-pdbdump/YAMLOutputStyle.h b/tools/llvm-pdbdump/YAMLOutputStyle.h
index 6e4067c48f88..3690e3529d4a 100644
--- a/tools/llvm-pdbdump/YAMLOutputStyle.h
+++ b/tools/llvm-pdbdump/YAMLOutputStyle.h
@@ -27,9 +27,6 @@ public:
Error dump() override;
private:
- Expected<Optional<CodeViewYAML::SourceFileInfo>>
- getFileLineInfo(const pdb::ModuleDebugStreamRef &ModS);
-
Error dumpStringTable();
Error dumpFileHeaders();
Error dumpStreamMetadata();
diff --git a/tools/llvm-pdbdump/fuzzer/llvm-pdbdump-fuzzer.cpp b/tools/llvm-pdbdump/fuzzer/llvm-pdbdump-fuzzer.cpp
index 14cd222d138a..5f09416a9ff6 100644
--- a/tools/llvm-pdbdump/fuzzer/llvm-pdbdump-fuzzer.cpp
+++ b/tools/llvm-pdbdump/fuzzer/llvm-pdbdump-fuzzer.cpp
@@ -85,7 +85,7 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) {
for (auto &Modi : DS.modules()) {
auto ModStreamData = pdb::MappedBlockStream::createIndexedStream(
- Modi.Info.getModuleStreamIndex(), *File);
+ Modi.Info.getModuleStreamIndex(), *File, File->getAllocator());
if (!ModStreamData) {
consumeError(ModStreamData.takeError());
return 0;
diff --git a/tools/llvm-pdbdump/llvm-pdbdump.cpp b/tools/llvm-pdbdump/llvm-pdbdump.cpp
index 0b2b766a3c52..4626de9c4440 100644
--- a/tools/llvm-pdbdump/llvm-pdbdump.cpp
+++ b/tools/llvm-pdbdump/llvm-pdbdump.cpp
@@ -476,7 +476,6 @@ static void yamlToPdb(StringRef Path) {
std::unique_ptr<MemoryBuffer> &Buffer = ErrorOrBuffer.get();
llvm::yaml::Input In(Buffer->getBuffer());
- In.setContext(&Allocator);
pdb::yaml::PdbObject YamlObj(Allocator);
In >> YamlObj;
@@ -535,67 +534,16 @@ static void yamlToPdb(StringRef Path) {
ExitOnErr(DbiBuilder.addModuleSourceFile(MI.Mod, S));
if (MI.Modi.hasValue()) {
const auto &ModiStream = *MI.Modi;
- for (auto Symbol : ModiStream.Symbols)
- ModiBuilder.addSymbol(Symbol.toCodeViewSymbol(Allocator));
- }
- if (MI.FileLineInfo.hasValue()) {
- const auto &FLI = *MI.FileLineInfo;
-
- // File Checksums must be emitted before line information, because line
- // info records use offsets into the checksum buffer to reference a file's
- // source file name.
- auto Checksums = llvm::make_unique<DebugChecksumsSubsection>(Strings);
- auto &ChecksumRef = *Checksums;
- if (!FLI.FileChecksums.empty()) {
- for (auto &FC : FLI.FileChecksums)
- Checksums->addChecksum(FC.FileName, FC.Kind, FC.ChecksumBytes.Bytes);
- }
- ModiBuilder.setC13FileChecksums(std::move(Checksums));
-
- for (const auto &Fragment : FLI.LineFragments) {
- auto Lines =
- llvm::make_unique<DebugLinesSubsection>(ChecksumRef, Strings);
- Lines->setCodeSize(Fragment.CodeSize);
- Lines->setRelocationAddress(Fragment.RelocSegment,
- Fragment.RelocOffset);
- Lines->setFlags(Fragment.Flags);
- for (const auto &LC : Fragment.Blocks) {
- Lines->createBlock(LC.FileName);
- if (Lines->hasColumnInfo()) {
- for (const auto &Item : zip(LC.Lines, LC.Columns)) {
- auto &L = std::get<0>(Item);
- auto &C = std::get<1>(Item);
- uint32_t LE = L.LineStart + L.EndDelta;
- Lines->addLineAndColumnInfo(
- L.Offset, LineInfo(L.LineStart, LE, L.IsStatement),
- C.StartColumn, C.EndColumn);
- }
- } else {
- for (const auto &L : LC.Lines) {
- uint32_t LE = L.LineStart + L.EndDelta;
- Lines->addLineInfo(L.Offset,
- LineInfo(L.LineStart, LE, L.IsStatement));
- }
- }
- }
- ModiBuilder.addC13Fragment(std::move(Lines));
+ for (auto Symbol : ModiStream.Symbols) {
+ ModiBuilder.addSymbol(
+ Symbol.toCodeViewSymbol(Allocator, CodeViewContainer::Pdb));
}
+ }
- for (const auto &Inlinee : FLI.Inlinees) {
- auto Inlinees = llvm::make_unique<DebugInlineeLinesSubsection>(
- ChecksumRef, Inlinee.HasExtraFiles);
- for (const auto &Site : Inlinee.Sites) {
- Inlinees->addInlineSite(TypeIndex(Site.Inlinee), Site.FileName,
- Site.SourceLineNum);
- if (!Inlinee.HasExtraFiles)
- continue;
-
- for (auto EF : Site.ExtraFiles) {
- Inlinees->addExtraFile(EF);
- }
- }
- ModiBuilder.addC13Fragment(std::move(Inlinees));
- }
+ auto CodeViewSubsections =
+ ExitOnErr(CodeViewYAML::convertSubsectionList(MI.Subsections, Strings));
+ for (auto &SS : CodeViewSubsections) {
+ ModiBuilder.addDebugSubsection(std::move(SS));
}
}
diff --git a/tools/llvm-readobj/COFFDumper.cpp b/tools/llvm-readobj/COFFDumper.cpp
index 663f7b4c8a82..bc07bd296ad2 100644
--- a/tools/llvm-readobj/COFFDumper.cpp
+++ b/tools/llvm-readobj/COFFDumper.cpp
@@ -978,7 +978,8 @@ void COFFDumper::printCodeViewSymbolsSubsection(StringRef Subsection,
Subsection.bytes_end());
auto CODD = llvm::make_unique<COFFObjectDumpDelegate>(*this, Section, Obj,
SectionContents);
- CVSymbolDumper CVSD(W, Types, std::move(CODD), opts::CodeViewSubsectionBytes);
+ CVSymbolDumper CVSD(W, Types, CodeViewContainer::ObjectFile, std::move(CODD),
+ opts::CodeViewSubsectionBytes);
CVSymbolArray Symbols;
BinaryStreamReader Reader(BinaryData, llvm::support::little);
if (auto EC = Reader.readArray(Symbols, Reader.getLength())) {