diff options
author | Fangrui Song <i@maskray.me> | 2021-01-27 10:43:51 -0800 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2021-01-27 10:43:51 -0800 |
commit | 54fb3ca96e261f7107cb1b5778c34cb0e0808be6 (patch) | |
tree | 8d6091e77327a0695d974602db03808433461666 /llvm/lib | |
parent | 0b50fa99452f7f3077e62348b6cf6850a65930af (diff) | |
download | llvm-54fb3ca96e261f7107cb1b5778c34cb0e0808be6.zip llvm-54fb3ca96e261f7107cb1b5778c34cb0e0808be6.tar.gz llvm-54fb3ca96e261f7107cb1b5778c34cb0e0808be6.tar.bz2 |
[ThinLTO] Add Visibility bits to GlobalValueSummary::GVFlags
Imported functions and variable get the visibility from the module supplying the
definition. However, non-imported definitions do not get the visibility from
(ELF) the most constraining visibility among all modules (Mach-O) the visibility
of the prevailing definition.
This patch
* adds visibility bits to GlobalValueSummary::GVFlags
* computes the result visibility and propagates it to all definitions
Protected/hidden can imply dso_local which can enable some optimizations (this
is stronger than GVFlags::DSOLocal because the implied dso_local can be
leveraged for ELF -shared while default visibility dso_local has to be cleared
for ELF -shared).
Note: we don't have summaries for declarations, so for ELF if a declaration has
the most constraining visibility, the result visibility may not be that one.
Differential Revision: https://reviews.llvm.org/D92900
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Analysis/ModuleSummaryAnalysis.cpp | 32 | ||||
-rw-r--r-- | llvm/lib/AsmParser/LLLexer.cpp | 1 | ||||
-rw-r--r-- | llvm/lib/AsmParser/LLParser.cpp | 21 | ||||
-rw-r--r-- | llvm/lib/AsmParser/LLToken.h | 1 | ||||
-rw-r--r-- | llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 9 | ||||
-rw-r--r-- | llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | 5 | ||||
-rw-r--r-- | llvm/lib/IR/AsmWriter.cpp | 13 | ||||
-rw-r--r-- | llvm/lib/IR/ModuleSummaryIndex.cpp | 14 | ||||
-rw-r--r-- | llvm/lib/LTO/LTO.cpp | 41 | ||||
-rw-r--r-- | llvm/lib/LTO/ThinLTOCodeGenerator.cpp | 4 | ||||
-rw-r--r-- | llvm/lib/Transforms/IPO/FunctionImport.cpp | 13 |
11 files changed, 121 insertions, 33 deletions
diff --git a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp index 5f7746e..00fc416 100644 --- a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp +++ b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp @@ -459,9 +459,10 @@ static void computeFunctionSummary( bool NonRenamableLocal = isNonRenamableLocal(F); bool NotEligibleForImport = NonRenamableLocal || HasInlineAsmMaybeReferencingInternal; - GlobalValueSummary::GVFlags Flags(F.getLinkage(), NotEligibleForImport, - /* Live = */ false, F.isDSOLocal(), - F.hasLinkOnceODRLinkage() && F.hasGlobalUnnamedAddr()); + GlobalValueSummary::GVFlags Flags( + F.getLinkage(), F.getVisibility(), NotEligibleForImport, + /* Live = */ false, F.isDSOLocal(), + F.hasLinkOnceODRLinkage() && F.hasGlobalUnnamedAddr()); FunctionSummary::FFlags FunFlags{ F.hasFnAttribute(Attribute::ReadNone), F.hasFnAttribute(Attribute::ReadOnly), @@ -580,9 +581,10 @@ static void computeVariableSummary(ModuleSummaryIndex &Index, SmallPtrSet<const User *, 8> Visited; bool HasBlockAddress = findRefEdges(Index, &V, RefEdges, Visited); bool NonRenamableLocal = isNonRenamableLocal(V); - GlobalValueSummary::GVFlags Flags(V.getLinkage(), NonRenamableLocal, - /* Live = */ false, V.isDSOLocal(), - V.hasLinkOnceODRLinkage() && V.hasGlobalUnnamedAddr()); + GlobalValueSummary::GVFlags Flags( + V.getLinkage(), V.getVisibility(), NonRenamableLocal, + /* Live = */ false, V.isDSOLocal(), + V.hasLinkOnceODRLinkage() && V.hasGlobalUnnamedAddr()); VTableFuncList VTableFuncs; // If splitting is not enabled, then we compute the summary information @@ -622,9 +624,10 @@ static void computeAliasSummary(ModuleSummaryIndex &Index, const GlobalAlias &A, DenseSet<GlobalValue::GUID> &CantBePromoted) { bool NonRenamableLocal = isNonRenamableLocal(A); - GlobalValueSummary::GVFlags Flags(A.getLinkage(), NonRenamableLocal, - /* Live = */ false, A.isDSOLocal(), - A.hasLinkOnceODRLinkage() && A.hasGlobalUnnamedAddr()); + GlobalValueSummary::GVFlags Flags( + A.getLinkage(), A.getVisibility(), NonRenamableLocal, + /* Live = */ false, A.isDSOLocal(), + A.hasLinkOnceODRLinkage() && A.hasGlobalUnnamedAddr()); auto AS = std::make_unique<AliasSummary>(Flags); auto *Aliasee = A.getBaseObject(); auto AliaseeVI = Index.getValueInfo(Aliasee->getGUID()); @@ -697,11 +700,12 @@ ModuleSummaryIndex llvm::buildModuleSummaryIndex( if (!GV) return; assert(GV->isDeclaration() && "Def in module asm already has definition"); - GlobalValueSummary::GVFlags GVFlags(GlobalValue::InternalLinkage, - /* NotEligibleToImport = */ true, - /* Live = */ true, - /* Local */ GV->isDSOLocal(), - GV->hasLinkOnceODRLinkage() && GV->hasGlobalUnnamedAddr()); + GlobalValueSummary::GVFlags GVFlags( + GlobalValue::InternalLinkage, GlobalValue::DefaultVisibility, + /* NotEligibleToImport = */ true, + /* Live = */ true, + /* Local */ GV->isDSOLocal(), + GV->hasLinkOnceODRLinkage() && GV->hasGlobalUnnamedAddr()); CantBePromoted.insert(GV->getGUID()); // Create the appropriate summary type. if (Function *F = dyn_cast<Function>(GV)) { diff --git a/llvm/lib/AsmParser/LLLexer.cpp b/llvm/lib/AsmParser/LLLexer.cpp index 427de74..f1e2c0b 100644 --- a/llvm/lib/AsmParser/LLLexer.cpp +++ b/llvm/lib/AsmParser/LLLexer.cpp @@ -751,6 +751,7 @@ lltok::Kind LLLexer::LexIdentifier() { KEYWORD(flags); KEYWORD(blockcount); KEYWORD(linkage); + KEYWORD(visibility); KEYWORD(notEligibleToImport); KEYWORD(live); KEYWORD(dsoLocal); diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp index 2a3fb8f..1ee5455 100644 --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -8517,7 +8517,8 @@ bool LLParser::parseFunctionSummary(std::string Name, GlobalValue::GUID GUID, StringRef ModulePath; GlobalValueSummary::GVFlags GVFlags = GlobalValueSummary::GVFlags( - /*Linkage=*/GlobalValue::ExternalLinkage, /*NotEligibleToImport=*/false, + GlobalValue::ExternalLinkage, GlobalValue::DefaultVisibility, + /*NotEligibleToImport=*/false, /*Live=*/false, /*IsLocal=*/false, /*CanAutoHide=*/false); unsigned InstCount; std::vector<FunctionSummary::EdgeTy> Calls; @@ -8593,7 +8594,8 @@ bool LLParser::parseVariableSummary(std::string Name, GlobalValue::GUID GUID, StringRef ModulePath; GlobalValueSummary::GVFlags GVFlags = GlobalValueSummary::GVFlags( - /*Linkage=*/GlobalValue::ExternalLinkage, /*NotEligibleToImport=*/false, + GlobalValue::ExternalLinkage, GlobalValue::DefaultVisibility, + /*NotEligibleToImport=*/false, /*Live=*/false, /*IsLocal=*/false, /*CanAutoHide=*/false); GlobalVarSummary::GVarFlags GVarFlags(/*ReadOnly*/ false, /* WriteOnly */ false, @@ -8651,7 +8653,8 @@ bool LLParser::parseAliasSummary(std::string Name, GlobalValue::GUID GUID, StringRef ModulePath; GlobalValueSummary::GVFlags GVFlags = GlobalValueSummary::GVFlags( - /*Linkage=*/GlobalValue::ExternalLinkage, /*NotEligibleToImport=*/false, + GlobalValue::ExternalLinkage, GlobalValue::DefaultVisibility, + /*NotEligibleToImport=*/false, /*Live=*/false, /*IsLocal=*/false, /*CanAutoHide=*/false); if (parseToken(lltok::colon, "expected ':' here") || parseToken(lltok::lparen, "expected '(' here") || @@ -9339,8 +9342,9 @@ bool LLParser::parseVFuncId(FunctionSummary::VFuncId &VFuncId, /// GVFlags /// ::= 'flags' ':' '(' 'linkage' ':' OptionalLinkageAux ',' -/// 'notEligibleToImport' ':' Flag ',' 'live' ':' Flag ',' -/// 'dsoLocal' ':' Flag ',' 'canAutoHide' ':' Flag ')' +/// 'visibility' ':' Flag 'notEligibleToImport' ':' Flag ',' +/// 'live' ':' Flag ',' 'dsoLocal' ':' Flag ',' +/// 'canAutoHide' ':' Flag ',' ')' bool LLParser::parseGVFlags(GlobalValueSummary::GVFlags &GVFlags) { assert(Lex.getKind() == lltok::kw_flags); Lex.Lex(); @@ -9361,6 +9365,13 @@ bool LLParser::parseGVFlags(GlobalValueSummary::GVFlags &GVFlags) { assert(HasLinkage && "Linkage not optional in summary entry"); Lex.Lex(); break; + case lltok::kw_visibility: + Lex.Lex(); + if (parseToken(lltok::colon, "expected ':'")) + return true; + parseOptionalVisibility(Flag); + GVFlags.Visibility = Flag; + break; case lltok::kw_notEligibleToImport: Lex.Lex(); if (parseToken(lltok::colon, "expected ':'") || parseFlag(Flag)) diff --git a/llvm/lib/AsmParser/LLToken.h b/llvm/lib/AsmParser/LLToken.h index 5149f86..0b09dc8 100644 --- a/llvm/lib/AsmParser/LLToken.h +++ b/llvm/lib/AsmParser/LLToken.h @@ -384,6 +384,7 @@ enum Kind { kw_flags, kw_blockcount, kw_linkage, + kw_visibility, kw_notEligibleToImport, kw_live, kw_dsoLocal, diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index f280020..b33c6b7 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -968,13 +968,17 @@ static FunctionSummary::FFlags getDecodedFFlags(uint64_t RawFlags) { return Flags; } -/// Decode the flags for GlobalValue in the summary. +// Decode the flags for GlobalValue in the summary. The bits for each attribute: +// +// linkage: [0,4), notEligibleToImport: 4, live: 5, local: 6, canAutoHide: 7, +// visibility: [8, 10). static GlobalValueSummary::GVFlags getDecodedGVSummaryFlags(uint64_t RawFlags, uint64_t Version) { // Summary were not emitted before LLVM 3.9, we don't need to upgrade Linkage // like getDecodedLinkage() above. Any future change to the linkage enum and // to getDecodedLinkage() will need to be taken into account here as above. auto Linkage = GlobalValue::LinkageTypes(RawFlags & 0xF); // 4 bits + auto Visibility = GlobalValue::VisibilityTypes((RawFlags >> 8) & 3); // 2 bits RawFlags = RawFlags >> 4; bool NotEligibleToImport = (RawFlags & 0x1) || Version < 3; // The Live flag wasn't introduced until version 3. For dead stripping @@ -984,7 +988,8 @@ static GlobalValueSummary::GVFlags getDecodedGVSummaryFlags(uint64_t RawFlags, bool Local = (RawFlags & 0x4); bool AutoHide = (RawFlags & 0x8); - return GlobalValueSummary::GVFlags(Linkage, NotEligibleToImport, Live, Local, AutoHide); + return GlobalValueSummary::GVFlags(Linkage, Visibility, NotEligibleToImport, + Live, Local, AutoHide); } // Decode the flags for GlobalVariable in the summary diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp index 37ecb99..19e7e18 100644 --- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -1044,7 +1044,8 @@ static uint64_t getEncodedFFlags(FunctionSummary::FFlags Flags) { return RawFlags; } -// Decode the flags for GlobalValue in the summary +// Decode the flags for GlobalValue in the summary. See getDecodedGVSummaryFlags +// in BitcodeReader.cpp. static uint64_t getEncodedGVSummaryFlags(GlobalValueSummary::GVFlags Flags) { uint64_t RawFlags = 0; @@ -1058,6 +1059,8 @@ static uint64_t getEncodedGVSummaryFlags(GlobalValueSummary::GVFlags Flags) { // account here as well. RawFlags = (RawFlags << 4) | Flags.Linkage; // 4 bits + RawFlags |= (Flags.Visibility << 8); // 2 bits + return RawFlags; } diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp index 69abf876..777c240 100644 --- a/llvm/lib/IR/AsmWriter.cpp +++ b/llvm/lib/IR/AsmWriter.cpp @@ -3163,6 +3163,17 @@ static std::string getLinkageNameWithSpace(GlobalValue::LinkageTypes LT) { return getLinkageName(LT) + " "; } +static const char *getVisibilityName(GlobalValue::VisibilityTypes Vis) { + switch (Vis) { + case GlobalValue::DefaultVisibility: + return "default"; + case GlobalValue::HiddenVisibility: + return "hidden"; + case GlobalValue::ProtectedVisibility: + return "protected"; + } +} + void AssemblyWriter::printFunctionSummary(const FunctionSummary *FS) { Out << ", insts: " << FS->instCount(); @@ -3331,6 +3342,8 @@ void AssemblyWriter::printSummary(const GlobalValueSummary &Summary) { Out << "(module: ^" << Machine.getModulePathSlot(Summary.modulePath()) << ", flags: ("; Out << "linkage: " << getLinkageName(LT); + Out << ", visibility: " + << getVisibilityName((GlobalValue::VisibilityTypes)GVFlags.Visibility); Out << ", notEligibleToImport: " << GVFlags.NotEligibleToImport; Out << ", live: " << GVFlags.Live; Out << ", dsoLocal: " << GVFlags.DSOLocal; diff --git a/llvm/lib/IR/ModuleSummaryIndex.cpp b/llvm/lib/IR/ModuleSummaryIndex.cpp index 5d21ca7..df3e801 100644 --- a/llvm/lib/IR/ModuleSummaryIndex.cpp +++ b/llvm/lib/IR/ModuleSummaryIndex.cpp @@ -40,6 +40,18 @@ constexpr uint32_t FunctionSummary::ParamAccess::RangeWidth; FunctionSummary FunctionSummary::ExternalNode = FunctionSummary::makeDummyFunctionSummary({}); +GlobalValue::VisibilityTypes ValueInfo::getELFVisibility() const { + bool HasProtected = false; + for (const auto &S : make_pointee_range(getSummaryList())) { + if (S.getVisibility() == GlobalValue::HiddenVisibility) + return GlobalValue::HiddenVisibility; + if (S.getVisibility() == GlobalValue::ProtectedVisibility) + HasProtected = true; + } + return HasProtected ? GlobalValue::ProtectedVisibility + : GlobalValue::DefaultVisibility; +} + bool ValueInfo::isDSOLocal() const { // Need to check all summaries are local in case of hash collisions. return getSummaryList().size() && @@ -564,6 +576,8 @@ void ModuleSummaryIndex::exportToDot( if (Flags.Live && hasConstantFlag(SummaryIt.second)) A.addComment("constant"); } + if (Flags.Visibility) + A.addComment("visibility"); if (Flags.DSOLocal) A.addComment("dsoLocal"); if (Flags.CanAutoHide) diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp index 9103d11..363a1e6 100644 --- a/llvm/lib/LTO/LTO.cpp +++ b/llvm/lib/LTO/LTO.cpp @@ -203,6 +203,7 @@ void llvm::computeLTOCacheKey( auto AddUsedThings = [&](GlobalValueSummary *GS) { if (!GS) return; + AddUnsigned(GS->getVisibility()); AddUnsigned(GS->isLive()); AddUnsigned(GS->canAutoHide()); for (const ValueInfo &VI : GS->refs()) { @@ -315,12 +316,16 @@ void llvm::computeLTOCacheKey( } static void thinLTOResolvePrevailingGUID( - ValueInfo VI, DenseSet<GlobalValueSummary *> &GlobalInvolvedWithAlias, + const Config &C, ValueInfo VI, + DenseSet<GlobalValueSummary *> &GlobalInvolvedWithAlias, function_ref<bool(GlobalValue::GUID, const GlobalValueSummary *)> isPrevailing, function_ref<void(StringRef, GlobalValue::GUID, GlobalValue::LinkageTypes)> recordNewLinkage, const DenseSet<GlobalValue::GUID> &GUIDPreservedSymbols) { + GlobalValue::VisibilityTypes Visibility = + C.VisibilityScheme == Config::ELF ? VI.getELFVisibility() + : GlobalValue::DefaultVisibility; for (auto &S : VI.getSummaryList()) { GlobalValue::LinkageTypes OriginalLinkage = S->linkage(); // Ignore local and appending linkage values since the linker @@ -352,14 +357,33 @@ static void thinLTOResolvePrevailingGUID( S->setCanAutoHide(VI.canAutoHide() && !GUIDPreservedSymbols.count(VI.getGUID())); } + if (C.VisibilityScheme == Config::FromPrevailing) + Visibility = S->getVisibility(); } // Alias and aliasee can't be turned into available_externally. else if (!isa<AliasSummary>(S.get()) && !GlobalInvolvedWithAlias.count(S.get())) S->setLinkage(GlobalValue::AvailableExternallyLinkage); + + // For ELF, set visibility to the computed visibility from summaries. We + // don't track visibility from declarations so this may be more relaxed than + // the most constraining one. + if (C.VisibilityScheme == Config::ELF) + S->setVisibility(Visibility); + if (S->linkage() != OriginalLinkage) recordNewLinkage(S->modulePath(), VI.getGUID(), S->linkage()); } + + if (C.VisibilityScheme == Config::FromPrevailing) { + for (auto &S : VI.getSummaryList()) { + GlobalValue::LinkageTypes OriginalLinkage = S->linkage(); + if (GlobalValue::isLocalLinkage(OriginalLinkage) || + GlobalValue::isAppendingLinkage(S->linkage())) + continue; + S->setVisibility(Visibility); + } + } } /// Resolve linkage for prevailing symbols in the \p Index. @@ -369,7 +393,7 @@ static void thinLTOResolvePrevailingGUID( // referencing them because of the import. We make sure we always emit at least // one copy. void llvm::thinLTOResolvePrevailingInIndex( - ModuleSummaryIndex &Index, + const Config &C, ModuleSummaryIndex &Index, function_ref<bool(GlobalValue::GUID, const GlobalValueSummary *)> isPrevailing, function_ref<void(StringRef, GlobalValue::GUID, GlobalValue::LinkageTypes)> @@ -385,9 +409,9 @@ void llvm::thinLTOResolvePrevailingInIndex( GlobalInvolvedWithAlias.insert(&AS->getAliasee()); for (auto &I : Index) - thinLTOResolvePrevailingGUID(Index.getValueInfo(I), GlobalInvolvedWithAlias, - isPrevailing, recordNewLinkage, - GUIDPreservedSymbols); + thinLTOResolvePrevailingGUID(C, Index.getValueInfo(I), + GlobalInvolvedWithAlias, isPrevailing, + recordNewLinkage, GUIDPreservedSymbols); } static bool isWeakObjectWithRWAccess(GlobalValueSummary *GVS) { @@ -587,8 +611,11 @@ Error LTO::add(std::unique_ptr<InputFile> Input, if (Conf.ResolutionFile) writeToResolutionFile(*Conf.ResolutionFile, Input.get(), Res); - if (RegularLTO.CombinedModule->getTargetTriple().empty()) + if (RegularLTO.CombinedModule->getTargetTriple().empty()) { RegularLTO.CombinedModule->setTargetTriple(Input->getTargetTriple()); + if (Triple(Input->getTargetTriple()).isOSBinFormatELF()) + Conf.VisibilityScheme = Config::ELF; + } const SymbolResolution *ResI = Res.begin(); for (unsigned I = 0; I != Input->Mods.size(); ++I) @@ -1441,7 +1468,7 @@ Error LTO::runThinLTO(AddStreamFn AddStream, NativeObjectCache Cache, GlobalValue::LinkageTypes NewLinkage) { ResolvedODR[ModuleIdentifier][GUID] = NewLinkage; }; - thinLTOResolvePrevailingInIndex(ThinLTO.CombinedIndex, isPrevailing, + thinLTOResolvePrevailingInIndex(Conf, ThinLTO.CombinedIndex, isPrevailing, recordNewLinkage, GUIDPreservedSymbols); generateParamAccessSummary(ThinLTO.CombinedIndex); diff --git a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp index 38f4969..2ccb87a 100644 --- a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp +++ b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp @@ -507,7 +507,9 @@ static void resolvePrevailingInIndex( ResolvedODR[ModuleIdentifier][GUID] = NewLinkage; }; - thinLTOResolvePrevailingInIndex(Index, isPrevailing, recordNewLinkage, + // TODO Conf.VisibilityScheme can be lto::Config::ELF for ELF. + lto::Config Conf; + thinLTOResolvePrevailingInIndex(Conf, Index, isPrevailing, recordNewLinkage, GUIDPreservedSymbols); } diff --git a/llvm/lib/Transforms/IPO/FunctionImport.cpp b/llvm/lib/Transforms/IPO/FunctionImport.cpp index 1834303..e1273f0 100644 --- a/llvm/lib/Transforms/IPO/FunctionImport.cpp +++ b/llvm/lib/Transforms/IPO/FunctionImport.cpp @@ -1000,7 +1000,6 @@ bool llvm::convertToDeclaration(GlobalValue &GV) { return true; } -/// Fixup prevailing symbol linkages in \p TheModule based on summary analysis. void llvm::thinLTOResolvePrevailingInModule( Module &TheModule, const GVSummaryMapTy &DefinedGlobals) { auto updateLinkage = [&](GlobalValue &GV) { @@ -1009,8 +1008,6 @@ void llvm::thinLTOResolvePrevailingInModule( if (GS == DefinedGlobals.end()) return; auto NewLinkage = GS->second->linkage(); - if (NewLinkage == GV.getLinkage()) - return; if (GlobalValue::isLocalLinkage(GV.getLinkage()) || // Don't internalize anything here, because the code below // lacks necessary correctness checks. Leave this job to @@ -1020,6 +1017,16 @@ void llvm::thinLTOResolvePrevailingInModule( GV.isDeclaration()) return; + // Set the potentially more constraining visibility computed from summaries. + // The DefaultVisibility condition is because older GlobalValueSummary does + // not record DefaultVisibility and we don't want to change protected/hidden + // to default. + if (GS->second->getVisibility() != GlobalValue::DefaultVisibility) + GV.setVisibility(GS->second->getVisibility()); + + if (NewLinkage == GV.getLinkage()) + return; + // Check for a non-prevailing def that has interposable linkage // (e.g. non-odr weak or linkonce). In that case we can't simply // convert to available_externally, since it would lose the |