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 | f4b6540880694856324f9c80407394e7a5ae46ae (patch) | |
tree | 28a7ba04c4c5898134f83baa42bb4dd1b96186a9 /tools/gold | |
parent | 746d3be625236d0a26b580adabb8469801f8d5e7 (diff) |
[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
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279356 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/gold')
-rw-r--r-- | tools/gold/gold-plugin.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/tools/gold/gold-plugin.cpp b/tools/gold/gold-plugin.cpp index 9ca28266d6ed..440190a4b503 100644 --- a/tools/gold/gold-plugin.cpp +++ b/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; |