diff options
author | Eugene Leviant <eleviant@accesssoftek.com> | 2018-11-16 07:08:00 +0000 |
---|---|---|
committer | Eugene Leviant <eleviant@accesssoftek.com> | 2018-11-16 07:08:00 +0000 |
commit | bf46e7410c8a1d26c4a434261baaae28a904d657 (patch) | |
tree | a8037e2560e4fd3aee808885ae87901c8e857afa /llvm/lib/LTO/ThinLTOCodeGenerator.cpp | |
parent | 079c37da5870239d0332870e6c8cea877b335600 (diff) | |
download | bcm5719-llvm-bf46e7410c8a1d26c4a434261baaae28a904d657.tar.gz bcm5719-llvm-bf46e7410c8a1d26c4a434261baaae28a904d657.zip |
[ThinLTO] Internalize readonly globals
An attempt to recommit r346584 after failure on OSX build bot.
Fixed cache key computation in ThinLTOCodeGenerator and added
test case
llvm-svn: 347033
Diffstat (limited to 'llvm/lib/LTO/ThinLTOCodeGenerator.cpp')
-rw-r--r-- | llvm/lib/LTO/ThinLTOCodeGenerator.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp index 8017527bf22..0cb47f2b34b 100644 --- a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp +++ b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp @@ -298,7 +298,7 @@ public: const FunctionImporter::ImportMapTy &ImportList, const FunctionImporter::ExportSetTy &ExportList, const std::map<GlobalValue::GUID, GlobalValue::LinkageTypes> &ResolvedODR, - const GVSummaryMapTy &DefinedFunctions, + const GVSummaryMapTy &DefinedGVSummaries, const DenseSet<GlobalValue::GUID> &PreservedSymbols, unsigned OptLevel, bool Freestanding, const TargetMachineBuilder &TMBuilder) { if (CachePath.empty()) @@ -368,6 +368,10 @@ public: for (auto &Entry : ImportList) { auto ModHash = Index.getModuleHash(Entry.first()); Hasher.update(ArrayRef<uint8_t>((uint8_t *)&ModHash[0], sizeof(ModHash))); + for (auto Guid : Entry.second) + if (auto *GVS = dyn_cast<GlobalVarSummary>( + Index.getGlobalValueSummary(Guid, false))) + AddUnsigned(GVS->isReadOnly()); } // Include the hash for the resolved ODR. @@ -380,11 +384,15 @@ public: // Include the hash for the preserved symbols. for (auto &Entry : PreservedSymbols) { - if (DefinedFunctions.count(Entry)) + if (DefinedGVSummaries.count(Entry)) Hasher.update( ArrayRef<uint8_t>((const uint8_t *)&Entry, sizeof(GlobalValue::GUID))); } + for (auto &Entry : DefinedGVSummaries) + if (auto *GVS = dyn_cast<GlobalVarSummary>(Entry.second)) + AddUnsigned(GVS->isReadOnly()); + // This choice of file name allows the cache to be pruned (see pruneCache() // in include/llvm/Support/CachePruning.h). sys::path::append(EntryPath, CachePath, @@ -646,7 +654,8 @@ static void computeDeadSymbolsInIndex( auto isPrevailing = [&](GlobalValue::GUID G) { return PrevailingType::Unknown; }; - computeDeadSymbols(Index, GUIDPreservedSymbols, isPrevailing); + computeDeadSymbolsWithConstProp(Index, GUIDPreservedSymbols, isPrevailing, + /* ImportEnabled = */ true); } /** @@ -983,13 +992,13 @@ void ThinLTOCodeGenerator::run() { auto ModuleIdentifier = ModuleBuffer.getBufferIdentifier(); auto &ExportList = ExportLists[ModuleIdentifier]; - auto &DefinedFunctions = ModuleToDefinedGVSummaries[ModuleIdentifier]; + auto &DefinedGVSummaries = ModuleToDefinedGVSummaries[ModuleIdentifier]; // The module may be cached, this helps handling it. ModuleCacheEntry CacheEntry(CacheOptions.Path, *Index, ModuleIdentifier, ImportLists[ModuleIdentifier], ExportList, ResolvedODR[ModuleIdentifier], - DefinedFunctions, GUIDPreservedSymbols, + DefinedGVSummaries, GUIDPreservedSymbols, OptLevel, Freestanding, TMBuilder); auto CacheEntryPath = CacheEntry.getEntryPath(); |