[lld] r331817 - Add support for LTO plugin option obj-path

Rumeet Dhindsa via llvm-commits llvm-commits at lists.llvm.org
Tue May 8 15:37:57 PDT 2018


Author: rdhindsa
Date: Tue May  8 15:37:57 2018
New Revision: 331817

URL: http://llvm.org/viewvc/llvm-project?rev=331817&view=rev
Log:
Add support for LTO plugin option obj-path

Differential Revision: https://reviews.llvm.org/D46598

Modified:
    lld/trunk/ELF/Config.h
    lld/trunk/ELF/Driver.cpp
    lld/trunk/ELF/LTO.cpp
    lld/trunk/test/ELF/lto/thinlto.ll

Modified: lld/trunk/ELF/Config.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Config.h?rev=331817&r1=331816&r2=331817&view=diff
==============================================================================
--- lld/trunk/ELF/Config.h (original)
+++ lld/trunk/ELF/Config.h Tue May  8 15:37:57 2018
@@ -86,6 +86,7 @@ struct Configuration {
   llvm::StringRef Init;
   llvm::StringRef LTOAAPipeline;
   llvm::StringRef LTONewPmPasses;
+  llvm::StringRef LTOObjPath;
   llvm::StringRef LTOSampleProfile;
   llvm::StringRef MapFile;
   llvm::StringRef OutputFile;

Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=331817&r1=331816&r2=331817&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Tue May  8 15:37:57 2018
@@ -796,6 +796,8 @@ void LinkerDriver::readConfigs(opt::Inpu
       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=")) {

Modified: lld/trunk/ELF/LTO.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LTO.cpp?rev=331817&r1=331816&r2=331817&view=diff
==============================================================================
--- lld/trunk/ELF/LTO.cpp (original)
+++ lld/trunk/ELF/LTO.cpp Tue May  8 15:37:57 2018
@@ -279,8 +279,8 @@ std::vector<InputFile *> BitcodeCompiler
         openFile(Path + ".imports");
     }
 
-    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

Modified: lld/trunk/test/ELF/lto/thinlto.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/lto/thinlto.ll?rev=331817&r1=331816&r2=331817&view=diff
==============================================================================
--- lld/trunk/test/ELF/lto/thinlto.ll (original)
+++ lld/trunk/test/ELF/lto/thinlto.ll Tue May  8 15:37:57 2018
@@ -49,11 +49,6 @@
 ; RUN: not ls %t2.o.thinlto.bc
 ; RUN: not ls %t4.o.thinlto.bc
 
-; Ensure lld generates one regular LTO file via splitting for ThinLTO builds
-; RUN: rm -f %t.lto.o
-; RUN: ld.lld -save-temps --plugin-opt=thinlto-index-only -shared %t.o %t2.o -o %t
-; RUN: llvm-readobj -h %t.lto.o | FileCheck %s --check-prefix=FORMAT
-
 ; First force single-threaded mode
 ; RUN: rm -f %t.lto.o %t1.lto.o
 ; RUN: ld.lld -save-temps --thinlto-jobs=1 -shared %t.o %t2.o -o %t
@@ -71,6 +66,12 @@
 ; stable on the final output file itself.
 ; RUN: ld.lld -shared %t.o %t2.o -o %t2
 
+; Test to ensure that thinlto-index-only with obj-path creates the file.
+; RUN: rm -f %t5.o
+; RUN: ld.lld --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




More information about the llvm-commits mailing list