[PATCH] D46559: Do not instantiate ObjectFiles when we exit immediately.
Rui Ueyama via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon May 7 16:34:12 PDT 2018
ruiu created this revision.
ruiu added a reviewer: rdhindsa.
Herald added subscribers: arichardson, emaste.
Herald added a reviewer: espindola.
I don't believe we don't need to call saveBuffer nor createObjectFile
for thinlto-index-only mode, because we don't create object files for
that mode.
https://reviews.llvm.org/D46559
Files:
lld/ELF/LTO.cpp
Index: lld/ELF/LTO.cpp
===================================================================
--- lld/ELF/LTO.cpp
+++ lld/ELF/LTO.cpp
@@ -227,7 +227,6 @@
// Merge all the bitcode files we have seen, codegen the result
// and return the resulting ObjectFile(s).
std::vector<InputFile *> BitcodeCompiler::compile() {
- std::vector<InputFile *> Ret;
unsigned MaxTasks = LTOObj->getMaxTasks();
Buff.resize(MaxTasks);
Files.resize(MaxTasks);
@@ -253,19 +252,6 @@
if (!Config->ThinLTOCacheDir.empty())
pruneCache(Config->ThinLTOCacheDir, Config->ThinLTOCachePolicy);
- for (unsigned I = 0; I != MaxTasks; ++I) {
- if (Buff[I].empty())
- continue;
- if (Config->SaveTemps) {
- if (I == 0)
- saveBuffer(Buff[I], Config->OutputFile + ".lto.o");
- else
- saveBuffer(Buff[I], Config->OutputFile + Twine(I) + ".lto.o");
- }
- InputFile *Obj = createObjectFile(MemoryBufferRef(Buff[I], "lto.tmp"));
- Ret.push_back(Obj);
- }
-
// If LazyObjFile has not been added to link, emit empty index files.
// This is needed because this is what GNU gold plugin does and we have a
// distributed build system that depends on that behavior.
@@ -286,15 +272,29 @@
if (Config->ThinLTOEmitImportsFiles)
openFile(Path + ".imports");
}
-
// 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.
if (IndexFile)
IndexFile->close();
return {};
}
+ std::vector<InputFile *> Ret;
+
+ for (unsigned I = 0; I != MaxTasks; ++I) {
+ if (Buff[I].empty())
+ continue;
+ if (Config->SaveTemps) {
+ if (I == 0)
+ saveBuffer(Buff[I], Config->OutputFile + ".lto.o");
+ else
+ saveBuffer(Buff[I], Config->OutputFile + Twine(I) + ".lto.o");
+ }
+ InputFile *Obj = createObjectFile(MemoryBufferRef(Buff[I], "lto.tmp"));
+ Ret.push_back(Obj);
+ }
+
for (std::unique_ptr<MemoryBuffer> &File : Files)
if (File)
Ret.push_back(createObjectFile(*File));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46559.145588.patch
Type: text/x-patch
Size: 2112 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180507/30442bb1/attachment.bin>
More information about the llvm-commits
mailing list