summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFangrui Song <maskray@google.com>2019-05-07 10:40:26 +0000
committerFangrui Song <maskray@google.com>2019-05-07 10:40:26 +0000
commitf3994e4dfa0214b2a09a0e327ba37e6b38bbcdb3 (patch)
treed121c5f3cc500e4705f0be25144e20a9ba48061b
parentc5ac14eef874dda3b7053c788bda04f46aa034d9 (diff)
downloadbcm5719-llvm-f3994e4dfa0214b2a09a0e327ba37e6b38bbcdb3.tar.gz
bcm5719-llvm-f3994e4dfa0214b2a09a0e327ba37e6b38bbcdb3.zip
[ELF] Reorder BitcodeFiles.empty() to call thinLTOCreateEmptyIndexFiles() in only one place
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 "" Differential Revision: https://reviews.llvm.org/D61635 llvm-svn: 360129
-rw-r--r--lld/ELF/LTO.cpp15
-rw-r--r--lld/ELF/LTO.h2
-rw-r--r--lld/ELF/SymbolTable.cpp6
3 files changed, 8 insertions, 15 deletions
diff --git a/lld/ELF/LTO.cpp b/lld/ELF/LTO.cpp
index 4f641d647de..ea0d17e81aa 100644
--- a/lld/ELF/LTO.cpp
+++ b/lld/ELF/LTO.cpp
@@ -214,7 +214,7 @@ void BitcodeCompiler::add(BitcodeFile &F) {
// 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 @@ std::vector<InputFile *> BitcodeCompiler::compile() {
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) {
diff --git a/lld/ELF/LTO.h b/lld/ELF/LTO.h
index 1df1d2bbcfd..0f0b5bce718 100644
--- a/lld/ELF/LTO.h
+++ b/lld/ELF/LTO.h
@@ -56,8 +56,6 @@ private:
std::unique_ptr<llvm::raw_fd_ostream> IndexFile;
llvm::DenseSet<StringRef> ThinIndices;
};
-
-void thinLTOCreateEmptyIndexFiles();
} // namespace elf
} // namespace lld
diff --git a/lld/ELF/SymbolTable.cpp b/lld/ELF/SymbolTable.cpp
index 1b017b07f58..6e69b25c61e 100644
--- a/lld/ELF/SymbolTable.cpp
+++ b/lld/ELF/SymbolTable.cpp
@@ -115,12 +115,6 @@ template <class ELFT> void SymbolTable::addFile(InputFile *File) {
// 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)
OpenPOWER on IntegriCloud