summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-dis/llvm-dis.cpp
diff options
context:
space:
mode:
authorTeresa Johnson <tejohnson@google.com>2018-05-26 02:34:13 +0000
committerTeresa Johnson <tejohnson@google.com>2018-05-26 02:34:13 +0000
commit08d5b4ef0d0839761e3b7546efcd3ee0454742ea (patch)
tree1962452dfea56ccff172d7612ec1a8c982de27e2 /llvm/tools/llvm-dis/llvm-dis.cpp
parentffebfe10c1cfc2eae92ddd0dc1b212595ac47864 (diff)
downloadbcm5719-llvm-08d5b4ef0d0839761e3b7546efcd3ee0454742ea.tar.gz
bcm5719-llvm-08d5b4ef0d0839761e3b7546efcd3ee0454742ea.zip
[ThinLTO] Print module summary index to assembly
Summary: Implements AsmWriter support for printing the module summary index to assembly with the format discussed in the RFC "LLVM Assembly format for ThinLTO Summary". Implements just enough of the parsing support to recognize and ignore the summary entries. As agreed in the RFC thread, this will be the behavior when assembling the IR. A follow on change will implement parsing/assembling of the summary entries for use by tools that currently build the summary index from bitcode. Reviewers: dexonsmith, pcc Subscribers: inglorion, eraman, steven_wu, dblaikie, llvm-commits Differential Revision: https://reviews.llvm.org/D46699 llvm-svn: 333335
Diffstat (limited to 'llvm/tools/llvm-dis/llvm-dis.cpp')
-rw-r--r--llvm/tools/llvm-dis/llvm-dis.cpp32
1 files changed, 17 insertions, 15 deletions
diff --git a/llvm/tools/llvm-dis/llvm-dis.cpp b/llvm/tools/llvm-dis/llvm-dis.cpp
index f254a761f87..8143a2a5a93 100644
--- a/llvm/tools/llvm-dis/llvm-dis.cpp
+++ b/llvm/tools/llvm-dis/llvm-dis.cpp
@@ -147,19 +147,6 @@ struct LLVMDisDiagnosticHandler : public DiagnosticHandler {
static ExitOnError ExitOnErr;
-static std::unique_ptr<Module> openInputFile(LLVMContext &Context) {
- std::unique_ptr<MemoryBuffer> MB =
- ExitOnErr(errorOrToExpected(MemoryBuffer::getFileOrSTDIN(InputFilename)));
- std::unique_ptr<Module> M = ExitOnErr(getOwningLazyBitcodeModule(
- std::move(MB), Context,
- /*ShouldLazyLoadMetadata=*/true, SetImporting));
- if (MaterializeMetadata)
- ExitOnErr(M->materializeMetadata());
- else
- ExitOnErr(M->materializeAll());
- return M;
-}
-
int main(int argc, char **argv) {
InitLLVM X(argc, argv);
@@ -170,7 +157,19 @@ int main(int argc, char **argv) {
llvm::make_unique<LLVMDisDiagnosticHandler>(argv[0]));
cl::ParseCommandLineOptions(argc, argv, "llvm .bc -> .ll disassembler\n");
- std::unique_ptr<Module> M = openInputFile(Context);
+ std::unique_ptr<MemoryBuffer> MB =
+ ExitOnErr(errorOrToExpected(MemoryBuffer::getFileOrSTDIN(InputFilename)));
+ std::unique_ptr<Module> M = ExitOnErr(getLazyBitcodeModule(
+ *MB, Context, /*ShouldLazyLoadMetadata=*/true, SetImporting));
+ if (MaterializeMetadata)
+ ExitOnErr(M->materializeMetadata());
+ else
+ ExitOnErr(M->materializeAll());
+
+ BitcodeLTOInfo LTOInfo = ExitOnErr(getBitcodeLTOInfo(*MB));
+ std::unique_ptr<ModuleSummaryIndex> Index;
+ if (LTOInfo.HasSummary)
+ Index = ExitOnErr(getModuleSummaryIndex(*MB));
// Just use stdout. We won't actually print anything on it.
if (DontPrint)
@@ -199,8 +198,11 @@ int main(int argc, char **argv) {
Annotator.reset(new CommentWriter());
// All that llvm-dis does is write the assembly to a file.
- if (!DontPrint)
+ if (!DontPrint) {
M->print(Out->os(), Annotator.get(), PreserveAssemblyUseListOrder);
+ if (Index)
+ Index->print(Out->os());
+ }
// Declare success.
Out->keep();
OpenPOWER on IntegriCloud