[PATCH] D61635: [ELF] Reorder BitcodeFiles.empty() to call thinLTOCreateEmptyIndexFiles() in only one place
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 7 03:03:39 PDT 2019
MaskRay created this revision.
MaskRay added a reviewer: ruiu.
Herald added subscribers: llvm-commits, arphaman, dexonsmith, steven_wu, arichardson, inglorion, emaste.
Herald added a reviewer: espindola.
Herald added a project: LLVM.
It makes the --plugin-opt=obj-path= and --plugin-opt=thinlto-index-only=
behavior more consistent - the files will be created in the
BitcodeFiles.empty() case, but I assume whether it behaves this way is
not required by anyone.
LTOObj->run() cannot run with empty BitcodeFiles. There would be an error:
ld.lld: error: No available targets are compatible with triple ""
Repository:
rLLD LLVM Linker
https://reviews.llvm.org/D61635
Files:
ELF/LTO.cpp
ELF/LTO.h
ELF/SymbolTable.cpp
Index: ELF/SymbolTable.cpp
===================================================================
--- ELF/SymbolTable.cpp
+++ ELF/SymbolTable.cpp
@@ -115,12 +115,6 @@
// Because all bitcode files that the program consists of are passed
// to the compiler at once, it can do whole-program optimization.
template <class ELFT> void SymbolTable::addCombinedLTOObject() {
- if (BitcodeFiles.empty()) {
- if (Config->ThinLTOIndexOnly)
- thinLTOCreateEmptyIndexFiles();
- return;
- }
-
// Compile bitcode files and replace bitcode symbols.
LTO.reset(new BitcodeCompiler);
for (BitcodeFile *F : BitcodeFiles)
Index: ELF/LTO.h
===================================================================
--- ELF/LTO.h
+++ ELF/LTO.h
@@ -56,8 +56,6 @@
std::unique_ptr<llvm::raw_fd_ostream> IndexFile;
llvm::DenseSet<StringRef> ThinIndices;
};
-
-void thinLTOCreateEmptyIndexFiles();
} // namespace elf
} // namespace lld
Index: ELF/LTO.cpp
===================================================================
--- ELF/LTO.cpp
+++ ELF/LTO.cpp
@@ -214,7 +214,7 @@
// 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.
-void elf::thinLTOCreateEmptyIndexFiles() {
+static void thinLTOCreateEmptyIndexFiles() {
for (LazyObjFile *F : LazyObjFiles) {
if (F->AddedToLink || !isBitcode(F->MB))
continue;
@@ -249,12 +249,13 @@
Files[Task] = std::move(MB);
}));
- checkError(LTOObj->run(
- [&](size_t Task) {
- return llvm::make_unique<lto::NativeObjectStream>(
- llvm::make_unique<raw_svector_ostream>(Buf[Task]));
- },
- Cache));
+ if (!BitcodeFiles.empty())
+ checkError(LTOObj->run(
+ [&](size_t Task) {
+ return llvm::make_unique<lto::NativeObjectStream>(
+ llvm::make_unique<raw_svector_ostream>(Buf[Task]));
+ },
+ Cache));
// Emit empty index files for non-indexed files
for (StringRef S : ThinIndices) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61635.198422.patch
Type: text/x-patch
Size: 2123 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190507/b3a740ee/attachment-0001.bin>
More information about the llvm-commits
mailing list