diff options
| author | Teresa Johnson <tejohnson@google.com> | 2016-08-20 01:24:07 +0000 |
|---|---|---|
| committer | Teresa Johnson <tejohnson@google.com> | 2016-08-20 01:24:07 +0000 |
| commit | 765941a841ee6b48a31aa639bc79c5a4dbe9ebb3 (patch) | |
| tree | 523c204f9683733b318e400f9bbc97082d6f9ff9 | |
| parent | 1f76caf3dd0c3935df409aa698c8f87c754b1dc7 (diff) | |
| download | bcm5719-llvm-765941a841ee6b48a31aa639bc79c5a4dbe9ebb3.tar.gz bcm5719-llvm-765941a841ee6b48a31aa639bc79c5a4dbe9ebb3.zip | |
[gold/ThinLTO] Restore ThinLTO file management in gold plugin
Summary:
The gold-plugin changes added along with the new LTO API in r278338 had
the effect of removing the management of the PluginInputFile that
ensured the files weren't released back to gold until the backend
threads were complete. Add back the old file handling.
Fixes PR29020.
Reviewers: mehdi_amini
Subscribers: mehdi_amini, llvm-commits, hjl.tools
Differential Revision: https://reviews.llvm.org/D23721
llvm-svn: 279356
| -rw-r--r-- | llvm/test/tools/gold/X86/thinlto.ll | 10 | ||||
| -rw-r--r-- | llvm/tools/gold/gold-plugin.cpp | 11 |
2 files changed, 20 insertions, 1 deletions
diff --git a/llvm/test/tools/gold/X86/thinlto.ll b/llvm/test/tools/gold/X86/thinlto.ll index 9b0d96db47c..9418b5f5af7 100644 --- a/llvm/test/tools/gold/X86/thinlto.ll +++ b/llvm/test/tools/gold/X86/thinlto.ll @@ -35,6 +35,16 @@ ; RUN: llvm-bcanalyzer -dump %t4.index.bc | FileCheck %s --check-prefix=COMBINED ; RUN: llvm-nm %t4 | FileCheck %s --check-prefix=NM +; Check with --no-map-whole-files +; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \ +; RUN: --plugin-opt=save-temps \ +; RUN: --plugin-opt=thinlto \ +; RUN: --plugin-opt=jobs=1 \ +; RUN: --no-map-whole-files \ +; RUN: -shared %t.o %t2.o -o %t4 +; RUN: llvm-bcanalyzer -dump %t4.index.bc | FileCheck %s --check-prefix=COMBINED +; RUN: llvm-nm %t4 | FileCheck %s --check-prefix=NM + ; Next force multi-threaded mode ; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \ ; RUN: --plugin-opt=save-temps \ diff --git a/llvm/tools/gold/gold-plugin.cpp b/llvm/tools/gold/gold-plugin.cpp index 9ca28266d6e..440190a4b50 100644 --- a/llvm/tools/gold/gold-plugin.cpp +++ b/llvm/tools/gold/gold-plugin.cpp @@ -818,10 +818,19 @@ static ld_plugin_status allSymbolsReadHook() { if (unsigned NumOpts = options::extra.size()) cl::ParseCommandLineOptions(NumOpts, &options::extra[0]); + // Map to own RAII objects that manage the file opening and releasing + // interfaces with gold. This is needed only for ThinLTO mode, since + // unlike regular LTO, where addModule will result in the opened file + // being merged into a new combined module, we need to keep these files open + // through Lto->run(). + DenseMap<void *, std::unique_ptr<PluginInputFile>> HandleToInputFile; + std::unique_ptr<LTO> Lto = createLTO(); for (claimed_file &F : Modules) { - PluginInputFile InputFile(F.handle); + if (options::thinlto && !HandleToInputFile.count(F.leader_handle)) + HandleToInputFile.insert(std::make_pair( + F.leader_handle, llvm::make_unique<PluginInputFile>(F.handle))); const void *View = getSymbolsAndView(F); if (!View) continue; |

