[PATCH] D84789: [LTO] Don't apply LTOPostLink module flag during writeMergedModule
Steven Wu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 26 11:18:34 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG476ca330894b: [LTO] Don't apply LTOPostLink module flag during writeMergedModule (authored by steven_wu).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D84789/new/
https://reviews.llvm.org/D84789
Files:
llvm/lib/LTO/LTOCodeGenerator.cpp
llvm/test/LTO/ARM/lto-linking-metadata.ll
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
@@ -181,6 +181,10 @@
cl::desc("Save ThinLTO generated object files using filenames created in "
"the given directory."));
+static cl::opt<bool> SaveLinkedModuleFile(
+ "save-linked-module", cl::init(false),
+ cl::desc("Write linked LTO module to file before optimize"));
+
static cl::opt<bool>
SaveModuleFile("save-merged-module", cl::init(false),
cl::desc("Write merged LTO module to file before CodeGen"));
@@ -1029,6 +1033,15 @@
CodeGen.setFileType(FT.getValue());
if (!OutputFilename.empty()) {
+ if (SaveLinkedModuleFile) {
+ std::string ModuleFilename = OutputFilename;
+ ModuleFilename += ".linked.bc";
+ std::string ErrMsg;
+
+ if (!CodeGen.writeMergedModules(ModuleFilename))
+ error("writing linked module failed.");
+ }
+
if (!CodeGen.optimize(DisableVerify, DisableInline, DisableGVNLoadPRE,
DisableLTOVectorization)) {
// Diagnostic messages should have been printed by the handler.
Index: llvm/test/LTO/ARM/lto-linking-metadata.ll
===================================================================
--- llvm/test/LTO/ARM/lto-linking-metadata.ll
+++ llvm/test/LTO/ARM/lto-linking-metadata.ll
@@ -1,7 +1,8 @@
; RUN: opt %s -o %t1.bc
-; RUN: llvm-lto %t1.bc -o %t1.save.opt -save-merged-module -O1 --exported-symbol=foo
+; RUN: llvm-lto %t1.bc -o %t1.save.opt -save-linked-module -save-merged-module -O1 --exported-symbol=foo
; RUN: llvm-dis < %t1.save.opt.merged.bc | FileCheck %s
+; RUN: llvm-dis < %t1.save.opt.linked.bc | FileCheck %s --check-prefix=CHECK-LINKED
; RUN: llvm-lto2 run %t1.bc -o %t.out.o -save-temps \
; RUN: -r=%t1.bc,foo,pxl
@@ -17,3 +18,6 @@
; CHECK: !llvm.module.flags = !{[[MD_NUM:![0-9]+]]}
; CHECK: [[MD_NUM]] = !{i32 1, !"LTOPostLink", i32 1}
+
+; CHECK-LINKED: @foo
+; CHECK-LINKED-NOT: LTOPostLink
Index: llvm/lib/LTO/LTOCodeGenerator.cpp
===================================================================
--- llvm/lib/LTO/LTOCodeGenerator.cpp
+++ llvm/lib/LTO/LTOCodeGenerator.cpp
@@ -466,8 +466,6 @@
internalizeModule(*MergedModule, mustPreserveGV);
- MergedModule->addModuleFlag(Module::Error, "LTOPostLink", 1);
-
ScopeRestrictionsDone = true;
}
@@ -559,6 +557,9 @@
// Mark which symbols can not be internalized
this->applyScopeRestrictions();
+ // Write LTOPostLink flag for passes that require all the modules.
+ MergedModule->addModuleFlag(Module::Error, "LTOPostLink", 1);
+
// Instantiate the pass manager to organize the passes.
legacy::PassManager passes;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84789.288052.patch
Type: text/x-patch
Size: 2773 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200826/a8083f9c/attachment.bin>
More information about the llvm-commits
mailing list