Index: test/tools/llvm-lto2/X86/dump-summary.ll =================================================================== --- /dev/null +++ test/tools/llvm-lto2/X86/dump-summary.ll @@ -0,0 +1,17 @@ +; RUN: opt -module-summary %s -o %t.o +; RUN: llvm-lto2 dump-summary %t.o | egrep 'Linkage:\s+0' +; RUN: llvm-lto2 dump-summary %t.o | egrep 'Live:\s+false' +; RUN: llvm-lto2 dump-summary %t.o | egrep 'NotEligibleToImport:\s+false' + +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" +@G = constant i32 2048, align 4 +@a = weak alias i32, i32* @G + +define void @boop() { + tail call void @afun() + ret void +} + +declare void @afun() +declare void @testtest() 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,19 @@ return 0; } +static int dumpSummary(int argc, char **argv) { + for (StringRef F : make_range(argv + 1, argv + argc)) { + std::unique_ptr MB = check(MemoryBuffer::getFile(F), F); + std::unique_ptr Index = + check(getModuleSummaryIndex(*MB), F); + + yaml::Output Out(outs()); + Out << *Index; + } + + return 0; +} + int main(int argc, char **argv) { InitializeAllTargets(); InitializeAllTargetMCs(); @@ -368,6 +383,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();