[lld] r354917 - Output ELF files after ThinLTO is run.
Bill Wendling via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 26 11:29:14 PST 2019
Author: void
Date: Tue Feb 26 11:29:14 2019
New Revision: 354917
URL: http://llvm.org/viewvc/llvm-project?rev=354917&view=rev
Log:
Output ELF files after ThinLTO is run.
Summary:
The gold linker allowed you to output the ELF files after LTO was run. It did
it by using the 'obj-path' option. This replicates that behavior.
Reviewers: espindola, ruiu, MaskRay, pcc
Reviewed By: MaskRay, pcc
Subscribers: grimar, emaste, inglorion, arichardson, steven_wu, dexonsmith, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D56046
Added:
lld/trunk/test/ELF/lto/Inputs/obj-path.ll
lld/trunk/test/ELF/lto/obj-path.ll
Modified:
lld/trunk/ELF/LTO.cpp
Modified: lld/trunk/ELF/LTO.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LTO.cpp?rev=354917&r1=354916&r2=354917&view=diff
==============================================================================
--- lld/trunk/ELF/LTO.cpp (original)
+++ lld/trunk/ELF/LTO.cpp Tue Feb 26 11:29:14 2019
@@ -276,20 +276,23 @@ std::vector<InputFile *> BitcodeCompiler
if (!Config->ThinLTOCacheDir.empty())
pruneCache(Config->ThinLTOCacheDir, Config->ThinLTOCachePolicy);
- std::vector<InputFile *> Ret;
- for (unsigned I = 0; I != MaxTasks; ++I) {
- if (Buf[I].empty())
- continue;
- if (Config->SaveTemps) {
- if (I == 0)
- saveBuffer(Buf[I], Config->OutputFile + ".lto.o");
- else
- saveBuffer(Buf[I], Config->OutputFile + Twine(I) + ".lto.o");
- }
- InputFile *Obj = createObjectFile(MemoryBufferRef(Buf[I], "lto.tmp"));
- Ret.push_back(Obj);
+ if (!Config->LTOObjPath.empty()) {
+ saveBuffer(Buf[0], Config->LTOObjPath);
+ for (unsigned I = 1; I != MaxTasks; ++I)
+ saveBuffer(Buf[I], Config->LTOObjPath + Twine(I));
+ }
+
+ if (Config->SaveTemps) {
+ saveBuffer(Buf[0], Config->OutputFile + ".lto.o");
+ for (unsigned I = 1; I != MaxTasks; ++I)
+ saveBuffer(Buf[I], Config->OutputFile + Twine(I) + ".lto.o");
}
+ std::vector<InputFile *> Ret;
+ for (unsigned I = 0; I != MaxTasks; ++I)
+ if (!Buf[I].empty())
+ Ret.push_back(createObjectFile(MemoryBufferRef(Buf[I], "lto.tmp")));
+
for (std::unique_ptr<MemoryBuffer> &File : Files)
if (File)
Ret.push_back(createObjectFile(*File));
Added: lld/trunk/test/ELF/lto/Inputs/obj-path.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/lto/Inputs/obj-path.ll?rev=354917&view=auto
==============================================================================
--- lld/trunk/test/ELF/lto/Inputs/obj-path.ll (added)
+++ lld/trunk/test/ELF/lto/Inputs/obj-path.ll Tue Feb 26 11:29:14 2019
@@ -0,0 +1,7 @@
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define void @g() {
+entry:
+ ret void
+}
Added: lld/trunk/test/ELF/lto/obj-path.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/lto/obj-path.ll?rev=354917&view=auto
==============================================================================
--- lld/trunk/test/ELF/lto/obj-path.ll (added)
+++ lld/trunk/test/ELF/lto/obj-path.ll Tue Feb 26 11:29:14 2019
@@ -0,0 +1,35 @@
+; REQUIRES: x86
+
+; RUN: opt -module-summary %s -o %t1.o
+; RUN: opt -module-summary %p/Inputs/obj-path.ll -o %t2.o
+
+; Test to ensure that obj-path creates the ELF file.
+; RUN: rm -f %t4.o
+; RUN: ld.lld --plugin-opt=obj-path=%t4.o -shared %t1.o %t2.o -o %t3
+; RUN: llvm-readobj -t %t3 | FileCheck %s
+; RUN: llvm-readobj -h %t4.o1 | FileCheck %s -check-prefix=ELF1
+; RUN: llvm-readobj -h %t4.o2 | FileCheck %s -check-prefix=ELF2
+; RUN: llvm-nm %t4.o1 2>&1 | FileCheck %s -check-prefix=NM1
+; RUN: llvm-nm %t4.o2 2>&1 | FileCheck %s -check-prefix=NM2
+
+; CHECK: Name: g
+; CHECK-NEXT: Value: 0x1010
+; CHECK: Name: f
+; CHECK-NEXT: Value: 0x1000
+
+; NM1: T f
+; ELF1: Format: ELF64-x86-64
+
+; NM2: T g
+; ELF2: Format: ELF64-x86-64
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+declare void @g(...)
+
+define void @f() {
+entry:
+ call void (...) @g()
+ ret void
+}
More information about the llvm-commits
mailing list