diff options
| author | Teresa Johnson <tejohnson@google.com> | 2019-05-10 20:08:24 +0000 |
|---|---|---|
| committer | Teresa Johnson <tejohnson@google.com> | 2019-05-10 20:08:24 +0000 |
| commit | 37b80122bd1225eb8889d42b4fd5d7d383a329e7 (patch) | |
| tree | 6ccf622e3818974d1cb31b009f828f959bd333a9 /llvm/lib/LTO/ThinLTOCodeGenerator.cpp | |
| parent | bcb9bbc01122a3386ac2e321f8b505b1fb246298 (diff) | |
| download | bcm5719-llvm-37b80122bd1225eb8889d42b4fd5d7d383a329e7.tar.gz bcm5719-llvm-37b80122bd1225eb8889d42b4fd5d7d383a329e7.zip | |
[ThinLTO] Auto-hide prevailing linkonce_odr only when all copies eligible
Summary:
We hit undefined references building with ThinLTO when one source file
contained explicit instantiations of a template method (weak_odr) but
there were also implicit instantiations in another file (linkonce_odr),
and the latter was the prevailing copy. In this case the symbol was
marked hidden when the prevailing linkonce_odr copy was promoted to
weak_odr. It led to unsats when the resulting shared library was linked
with other code that contained a reference (expecting to be resolved due
to the explicit instantiation).
Add a CanAutoHide flag to the GV summary to allow the thin link to
identify when all copies are eligible for auto-hiding (because they were
all originally linkonce_odr global unnamed addr), and only do the
auto-hide in that case.
Most of the changes here are due to plumbing the new flag through the
bitcode and llvm assembly, and resulting test changes. I augmented the
existing auto-hide test to check for this situation.
Reviewers: pcc
Subscribers: mehdi_amini, inglorion, eraman, dexonsmith, arphaman, dang, llvm-commits, steven_wu, wmi
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D59709
llvm-svn: 360466
Diffstat (limited to 'llvm/lib/LTO/ThinLTOCodeGenerator.cpp')
| -rw-r--r-- | llvm/lib/LTO/ThinLTOCodeGenerator.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp index 43b20fbbdda..df18dd3f9ca 100644 --- a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp +++ b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp @@ -457,7 +457,8 @@ ProcessThinLTOModule(Module &TheModule, ModuleSummaryIndex &Index, static void resolvePrevailingInIndex( ModuleSummaryIndex &Index, StringMap<std::map<GlobalValue::GUID, GlobalValue::LinkageTypes>> - &ResolvedODR) { + &ResolvedODR, + const DenseSet<GlobalValue::GUID> &GUIDPreservedSymbols) { DenseMap<GlobalValue::GUID, const GlobalValueSummary *> PrevailingCopy; computePrevailingCopies(Index, PrevailingCopy); @@ -476,7 +477,8 @@ static void resolvePrevailingInIndex( ResolvedODR[ModuleIdentifier][GUID] = NewLinkage; }; - thinLTOResolvePrevailingInIndex(Index, isPrevailing, recordNewLinkage); + thinLTOResolvePrevailingInIndex(Index, isPrevailing, recordNewLinkage, + GUIDPreservedSymbols); } // Initialize the TargetMachine builder for a given Triple @@ -630,7 +632,7 @@ void ThinLTOCodeGenerator::promote(Module &TheModule, ModuleSummaryIndex &Index, // Resolve prevailing symbols StringMap<std::map<GlobalValue::GUID, GlobalValue::LinkageTypes>> ResolvedODR; - resolvePrevailingInIndex(Index, ResolvedODR); + resolvePrevailingInIndex(Index, ResolvedODR, GUIDPreservedSymbols); thinLTOResolvePrevailingInModule( TheModule, ModuleToDefinedGVSummaries[ModuleIdentifier]); @@ -786,7 +788,7 @@ void ThinLTOCodeGenerator::internalize(Module &TheModule, // Resolve prevailing symbols StringMap<std::map<GlobalValue::GUID, GlobalValue::LinkageTypes>> ResolvedODR; - resolvePrevailingInIndex(Index, ResolvedODR); + resolvePrevailingInIndex(Index, ResolvedODR, GUIDPreservedSymbols); // Promote the exported values in the index, so that they are promoted // in the module. @@ -945,7 +947,7 @@ void ThinLTOCodeGenerator::run() { // Resolve prevailing symbols, this has to be computed early because it // impacts the caching. - resolvePrevailingInIndex(*Index, ResolvedODR); + resolvePrevailingInIndex(*Index, ResolvedODR, GUIDPreservedSymbols); // Use global summary-based analysis to identify symbols that can be // internalized (because they aren't exported or preserved as per callback). |

