[PATCH] D114201: [LTO] Add a function `LTOCodeGenerator::getMergedModule`
Shilei Tian via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 10 14:56:46 PST 2021
tianshilei1992 updated this revision to Diff 393601.
tianshilei1992 added a comment.
add an option in `llvm-lto` to dump linked module
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D114201/new/
https://reviews.llvm.org/D114201
Files:
llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h
llvm/tools/llvm-lto/llvm-lto.cpp
Index: llvm/tools/llvm-lto/llvm-lto.cpp
===================================================================
--- llvm/tools/llvm-lto/llvm-lto.cpp
+++ llvm/tools/llvm-lto/llvm-lto.cpp
@@ -197,6 +197,11 @@
cl::desc("Write merged LTO module to file before CodeGen"),
cl::cat(LTOCategory));
+static cl::opt<bool>
+ DumpLinkedModule("dump-linked-module", cl::init(false),
+ cl::desc("Dump linked LTO module before optimize"),
+ cl::cat(LTOCategory));
+
static cl::list<std::string> InputFilenames(cl::Positional, cl::OneOrMore,
cl::desc("<input bitcode files>"),
cl::cat(LTOCategory));
@@ -316,11 +321,11 @@
if (!CurrentActivity.empty())
OS << ' ' << CurrentActivity;
OS << ": ";
-
+
DiagnosticPrinterRawOStream DP(OS);
DI.print(DP);
OS << '\n';
-
+
if (DI.getSeverity() == DS_Error)
exit(1);
return true;
@@ -1115,6 +1120,14 @@
error("error compiling the code");
} else {
+ if (DumpLinkedModule) {
+ if (SaveLinkedModuleFile)
+ error(": -dump-linked-module must be used without -dump-linked-module");
+
+ Module &M = CodeGen.getMergedModule();
+ M.dump();
+ }
+
if (Parallelism != 1)
error("-j must be specified together with -o");
Index: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h
===================================================================
--- llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h
+++ llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h
@@ -193,6 +193,8 @@
void resetMergedModule() { MergedModule.reset(); }
void DiagnosticHandler(const DiagnosticInfo &DI);
+ Module &getMergedModule() { return *MergedModule; }
+
private:
/// Verify the merged module on first call.
///
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114201.393601.patch
Type: text/x-patch
Size: 1905 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211210/c00b8bb7/attachment.bin>
More information about the llvm-commits
mailing list