[PATCH] D34080: [ThinLTO] Add dump-summary command to llvm-lto2 tool
Charles Saternos via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 19 05:31:07 PDT 2017
ncharlie updated this revision to Diff 103023.
ncharlie marked an inline comment as done.
ncharlie added a comment.
Added comment.
https://reviews.llvm.org/D34080
Files:
test/tools/llvm-lto2/X86/dump-summary.ll
tools/llvm-lto2/llvm-lto2.cpp
Index: tools/llvm-lto2/llvm-lto2.cpp
===================================================================
--- tools/llvm-lto2/llvm-lto2.cpp
+++ tools/llvm-lto2/llvm-lto2.cpp
@@ -16,9 +16,11 @@
//
//===----------------------------------------------------------------------===//
-#include "llvm/LTO/Caching.h"
+#include "llvm/Bitcode/BitcodeReader.h"
#include "llvm/CodeGen/CommandFlags.h"
#include "llvm/IR/DiagnosticPrinter.h"
+#include "llvm/IR/ModuleSummaryIndexYAML.h"
+#include "llvm/LTO/Caching.h"
#include "llvm/LTO/LTO.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/FileSystem.h"
@@ -132,7 +134,7 @@
}
static int usage() {
- errs() << "Available subcommands: dump-symtab run\n";
+ errs() << "Available subcommands: dump-symtab dump-summary run\n";
return 1;
}
@@ -351,6 +353,20 @@
return 0;
}
+// Used to dump module summaries in YAML for debugging purposes.
+static int dumpSummary(int argc, char **argv) {
+ for (StringRef F : make_range(argv + 1, argv + argc)) {
+ std::unique_ptr<MemoryBuffer> MB = check(MemoryBuffer::getFile(F), F);
+ std::unique_ptr<ModuleSummaryIndex> Index =
+ check(getModuleSummaryIndex(*MB), F);
+
+ yaml::Output Out(outs());
+ Out << *Index;
+ }
+
+ return 0;
+}
+
int main(int argc, char **argv) {
InitializeAllTargets();
InitializeAllTargetMCs();
@@ -368,6 +384,8 @@
argv[1] = argv[0];
if (Subcommand == "dump-symtab")
return dumpSymtab(argc - 1, argv + 1);
+ if (Subcommand == "dump-summary")
+ return dumpSummary(argc - 1, argv + 1);
if (Subcommand == "run")
return run(argc - 1, argv + 1);
return usage();
Index: test/tools/llvm-lto2/X86/dump-summary.ll
===================================================================
--- /dev/null
+++ test/tools/llvm-lto2/X86/dump-summary.ll
@@ -0,0 +1,19 @@
+; RUN: opt -module-summary %s -o %t.o
+; RUN: llvm-lto2 dump-summary %t.o | FileCheck %s
+
+; CHECK: Linkage: 0
+; CHECK: NotEligibleToImport: false
+; CHECK: Live: false
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+ at G = constant i32 2048, align 4
+ at a = weak alias i32, i32* @G
+
+define void @boop() {
+ tail call void @afun()
+ ret void
+}
+
+declare void @afun()
+declare void @testtest()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34080.103023.patch
Type: text/x-patch
Size: 2296 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170619/35211910/attachment.bin>
More information about the llvm-commits
mailing list