diff options
Diffstat (limited to 'llvm/lib/LTO/LTO.cpp')
-rw-r--r-- | llvm/lib/LTO/LTO.cpp | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp index 1e345e7dd89..9c59ec40274 100644 --- a/llvm/lib/LTO/LTO.cpp +++ b/llvm/lib/LTO/LTO.cpp @@ -146,9 +146,11 @@ void llvm::computeLTOCacheKey( // Include the hash for the current module auto ModHash = Index.getModuleHash(ModuleID); Hasher.update(ArrayRef<uint8_t>((uint8_t *)&ModHash[0], sizeof(ModHash))); - for (auto F : ExportList) + for (const auto &VI : ExportList) { + auto GUID = VI.getGUID(); // The export list can impact the internalization, be conservative here - Hasher.update(ArrayRef<uint8_t>((uint8_t *)&F, sizeof(F))); + Hasher.update(ArrayRef<uint8_t>((uint8_t *)&GUID, sizeof(GUID))); + } // Include the hash for every module we import functions from. The set of // imported symbols for each module may affect code generation and is @@ -383,12 +385,12 @@ static bool isWeakObjectWithRWAccess(GlobalValueSummary *GVS) { } static void thinLTOInternalizeAndPromoteGUID( - GlobalValueSummaryList &GVSummaryList, GlobalValue::GUID GUID, - function_ref<bool(StringRef, GlobalValue::GUID)> isExported, + GlobalValueSummaryList &GVSummaryList, ValueInfo VI, + function_ref<bool(StringRef, ValueInfo)> isExported, function_ref<bool(GlobalValue::GUID, const GlobalValueSummary *)> isPrevailing) { for (auto &S : GVSummaryList) { - if (isExported(S->modulePath(), GUID)) { + if (isExported(S->modulePath(), VI)) { if (GlobalValue::isLocalLinkage(S->linkage())) S->setLinkage(GlobalValue::ExternalLinkage); } else if (EnableLTOInternalization && @@ -396,7 +398,7 @@ static void thinLTOInternalizeAndPromoteGUID( // doesn't resolve them. !GlobalValue::isLocalLinkage(S->linkage()) && (!GlobalValue::isInterposableLinkage(S->linkage()) || - isPrevailing(GUID, S.get())) && + isPrevailing(VI.getGUID(), S.get())) && S->linkage() != GlobalValue::AppendingLinkage && // We can't internalize available_externally globals because this // can break function pointer equality. @@ -415,12 +417,12 @@ static void thinLTOInternalizeAndPromoteGUID( // as external and non-exported values as internal. void llvm::thinLTOInternalizeAndPromoteInIndex( ModuleSummaryIndex &Index, - function_ref<bool(StringRef, GlobalValue::GUID)> isExported, + function_ref<bool(StringRef, ValueInfo)> isExported, function_ref<bool(GlobalValue::GUID, const GlobalValueSummary *)> isPrevailing) { for (auto &I : Index) - thinLTOInternalizeAndPromoteGUID(I.second.SummaryList, I.first, isExported, - isPrevailing); + thinLTOInternalizeAndPromoteGUID( + I.second.SummaryList, Index.getValueInfo(I), isExported, isPrevailing); } // Requires a destructor for std::vector<InputModule>. @@ -1330,11 +1332,10 @@ Error LTO::runThinLTO(AddStreamFn AddStream, NativeObjectCache Cache, ExportedGUIDs.insert( GlobalValue::getGUID(GlobalValue::dropLLVMManglingEscape(Def))); - auto isExported = [&](StringRef ModuleIdentifier, GlobalValue::GUID GUID) { + auto isExported = [&](StringRef ModuleIdentifier, ValueInfo VI) { const auto &ExportList = ExportLists.find(ModuleIdentifier); - return (ExportList != ExportLists.end() && - ExportList->second.count(GUID)) || - ExportedGUIDs.count(GUID); + return (ExportList != ExportLists.end() && ExportList->second.count(VI)) || + ExportedGUIDs.count(VI.getGUID()); }; // Update local devirtualized targets that were exported by cross-module |