[PATCH] D46598: Add support for LTO plugin option obj-path
Rumeet Dhindsa via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 8 13:36:46 PDT 2018
rdhindsa created this revision.
rdhindsa added reviewers: pcc, ruiu.
Herald added subscribers: llvm-commits, eraman, arichardson, inglorion, emaste.
Herald added a reviewer: espindola.
Add support for LTO plugin option obj-path
Repository:
rLLD LLVM Linker
https://reviews.llvm.org/D46598
Files:
lld/ELF/Config.h
lld/ELF/Driver.cpp
lld/ELF/LTO.cpp
lld/test/ELF/lto/thinlto.ll
Index: lld/test/ELF/lto/thinlto.ll
===================================================================
--- lld/test/ELF/lto/thinlto.ll
+++ lld/test/ELF/lto/thinlto.ll
@@ -71,6 +71,18 @@
; stable on the final output file itself.
; RUN: ld.lld -shared %t.o %t2.o -o %t2
+; Test --plugin-opt=obj-path to ensure unique object files generated.
+; RUN: rm -f %t5.o %t5.o1
+; RUN: ld.lld --plugin-opt=jobs=2 --plugin-opt=obj-path=%t5.o -shared %t.o %t2.o -o %t4
+; RUN: llvm-nm %t5.o1 | FileCheck %s --check-prefix=NM1
+; RUN: llvm-nm %t5.o2 | FileCheck %s --check-prefix=NM2
+
+; Test to ensure that thinlto-index-only with obj-path creates the file.
+; RUN: rm -f %t5.o %t5.o1
+; RUN: ld.lld --plugin-opt=jobs=2 --plugin-opt=thinlto-index-only --plugin-opt=obj-path=%t5.o -shared %t.o %t2.o -o %t4
+; RUN: llvm-readobj -h %t5.o | FileCheck %s --check-prefix=FORMAT
+; RUN: llvm-nm %t5.o | count 0
+
; NM: T f
; NM1: T f
; NM1-NOT: U g
Index: lld/ELF/LTO.cpp
===================================================================
--- lld/ELF/LTO.cpp
+++ lld/ELF/LTO.cpp
@@ -282,6 +282,9 @@
if (Config->SaveTemps)
saveBuffer(Buff[0], Config->OutputFile + ".lto.o");
+ if (!Config->LTOObjPath.empty())
+ saveBuffer(Buff[0], Config->LTOObjPath);
+
// ThinLTO with index only option is required to generate only the index
// files. After that, we exit from linker and ThinLTO backend runs in a
// distributed environment.
@@ -296,6 +299,12 @@
for (unsigned I = 0; I != MaxTasks; ++I) {
if (Buff[I].empty())
continue;
+ if (!Config->LTOObjPath.empty()) {
+ if (I == 0)
+ saveBuffer(Buff[I], Config->LTOObjPath);
+ else
+ saveBuffer(Buff[I], std::string(Config->LTOObjPath) + utostr(I));
+ }
if (Config->SaveTemps) {
if (I == 0)
saveBuffer(Buff[I], Config->OutputFile + ".lto.o");
Index: lld/ELF/Driver.cpp
===================================================================
--- lld/ELF/Driver.cpp
+++ lld/ELF/Driver.cpp
@@ -796,6 +796,8 @@
Config->LTODebugPassManager = true;
} else if (S.startswith("sample-profile=")) {
Config->LTOSampleProfile = S.substr(15);
+ } else if (S.startswith("obj-path=")) {
+ Config->LTOObjPath = S.substr(9);
} else if (S == "thinlto-index-only") {
Config->ThinLTOIndexOnly = true;
} else if (S.startswith("thinlto-index-only=")) {
Index: lld/ELF/Config.h
===================================================================
--- lld/ELF/Config.h
+++ lld/ELF/Config.h
@@ -86,6 +86,7 @@
llvm::StringRef Init;
llvm::StringRef LTOAAPipeline;
llvm::StringRef LTONewPmPasses;
+ llvm::StringRef LTOObjPath;
llvm::StringRef LTOSampleProfile;
llvm::StringRef MapFile;
llvm::StringRef OutputFile;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46598.145768.patch
Type: text/x-patch
Size: 2777 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180508/c4adee40/attachment-0001.bin>
More information about the llvm-commits
mailing list