[llvm] Clean up external users of GlobalValue::getGUID(StringRef) (PR #129644)
Owen Rodley via llvm-commits
llvm-commits at lists.llvm.org
Sun Apr 13 18:04:07 PDT 2025
https://github.com/orodley updated https://github.com/llvm/llvm-project/pull/129644
>From 34413705d1bf700a9a44c209945353c386e39c59 Mon Sep 17 00:00:00 2001
From: Owen Rodley <orodley at google.com>
Date: Mon, 3 Mar 2025 14:47:26 +1100
Subject: [PATCH] Clean up external users of GlobalValue::getGUID(StringRef)
See https://discourse.llvm.org/t/rfc-keep-globalvalue-guids-stable/84801
for context.
This is a non-functional change which just changes the interface of
GlobalValue, in preparation for future functional changes. This part
touches a fair few users, so is split out for ease of review. Future
changes to the GlobalValue implementation can then be focused purely on
that class.
This does the following:
* Make global identifier computation nominally private. There are a few
users we can't remove yet, but we rename the method to make it clear
that new users shouldn't be added.
* Rename GlobalValue::getGUID(StringRef) to
getGUIDAssumingExternalLinkage. This is simply making explicit at the
callsite what is currently implicit.
* Where possible, migrate users to directly calling getGUID on a
GlobalValue instance.
* Otherwise, where possible, have them call the newly renamed
getGUIDAssumingExternalLinkage, to make the assumption explicit.
* Where users don't actually need the gloalIdentifier and just need the
name, call getName() instead.
* There are a few cases where none of the above are possible, as the
caller saves and reconstructs the necessary information to compute the
GUID themselves. We want to migrate these callers eventually, but for
this first step we leave them be and allow them to call our nominally
private global identifier computation method.
---
bolt/lib/Rewrite/PseudoProbeRewriter.cpp | 6 ++---
.../LLJITWithThinLTOSummaries.cpp | 12 ++++++---
llvm/include/llvm/IR/GlobalValue.h | 23 ++++++++++-------
llvm/include/llvm/IR/ModuleSummaryIndex.h | 25 +++++++++++--------
llvm/include/llvm/IR/ModuleSummaryIndexYAML.h | 2 +-
llvm/include/llvm/ProfileData/SampleProf.h | 2 +-
.../Utils/SampleProfileLoaderBaseImpl.h | 5 ++--
llvm/lib/Analysis/CtxProfAnalysis.cpp | 2 +-
llvm/lib/Analysis/ModuleSummaryAnalysis.cpp | 9 ++++---
llvm/lib/AsmParser/LLParser.cpp | 6 ++---
llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 4 +--
.../CodeGen/AsmPrinter/PseudoProbePrinter.cpp | 2 +-
llvm/lib/CodeGen/PseudoProbeInserter.cpp | 2 +-
llvm/lib/IR/AsmWriter.cpp | 2 +-
llvm/lib/IR/Globals.cpp | 5 ++--
llvm/lib/LTO/LTO.cpp | 14 ++++++-----
llvm/lib/LTO/ThinLTOCodeGenerator.cpp | 8 +++---
llvm/lib/ProfileData/InstrProf.cpp | 6 ++---
llvm/lib/ProfileData/MemProf.cpp | 2 +-
llvm/lib/ProfileData/SampleProfReader.cpp | 2 +-
llvm/lib/Target/Mips/MipsSEISelDAGToDAG.cpp | 3 ++-
llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp | 5 ++--
llvm/lib/Target/SPIRV/SPIRVCallLowering.cpp | 2 +-
llvm/lib/Transforms/IPO/FunctionImport.cpp | 12 +++++----
llvm/lib/Transforms/IPO/LowerTypeTests.cpp | 8 +++---
.../IPO/MemProfContextDisambiguation.cpp | 9 ++++---
llvm/lib/Transforms/IPO/SampleProfile.cpp | 16 ++++++------
.../lib/Transforms/IPO/SampleProfileProbe.cpp | 2 +-
.../lib/Transforms/IPO/WholeProgramDevirt.cpp | 15 ++++++-----
.../Instrumentation/MemProfiler.cpp | 4 +--
llvm/tools/llvm-profgen/ProfiledBinary.cpp | 9 ++++---
31 files changed, 130 insertions(+), 94 deletions(-)
diff --git a/bolt/lib/Rewrite/PseudoProbeRewriter.cpp b/bolt/lib/Rewrite/PseudoProbeRewriter.cpp
index 9d6e914624a33..ee021fee3cea5 100644
--- a/bolt/lib/Rewrite/PseudoProbeRewriter.cpp
+++ b/bolt/lib/Rewrite/PseudoProbeRewriter.cpp
@@ -147,7 +147,7 @@ void PseudoProbeRewriter::parsePseudoProbe(bool ProfiledOnly) {
if (!Name)
continue;
SymName = *Name;
- uint64_t GUID = Function::getGUID(SymName);
+ uint64_t GUID = Function::getGUIDAssumingExternalLinkage(SymName);
FuncStartAddrs[GUID] = F->getAddress();
if (ProfiledOnly && HasProfile)
GuidFilter.insert(GUID);
@@ -173,7 +173,7 @@ void PseudoProbeRewriter::parsePseudoProbe(bool ProfiledOnly) {
const GUIDProbeFunctionMap &GUID2Func = ProbeDecoder.getGUID2FuncDescMap();
// Checks GUID in GUID2Func and returns it if it's present or null otherwise.
auto checkGUID = [&](StringRef SymName) -> uint64_t {
- uint64_t GUID = Function::getGUID(SymName);
+ uint64_t GUID = Function::getGUIDAssumingExternalLinkage(SymName);
if (GUID2Func.find(GUID) == GUID2Func.end())
return 0;
return GUID;
@@ -435,7 +435,7 @@ void PseudoProbeRewriter::encodePseudoProbes() {
for (const BinaryFunction *F : BC.getAllBinaryFunctions()) {
const uint64_t Addr =
F->isEmitted() ? F->getOutputAddress() : F->getAddress();
- FuncStartAddrs[Function::getGUID(
+ FuncStartAddrs[Function::getGUIDAssumingExternalLinkage(
NameResolver::restore(F->getOneName()))] = Addr;
}
DummyDecoder.buildAddress2ProbeMap(
diff --git a/llvm/examples/OrcV2Examples/LLJITWithThinLTOSummaries/LLJITWithThinLTOSummaries.cpp b/llvm/examples/OrcV2Examples/LLJITWithThinLTOSummaries/LLJITWithThinLTOSummaries.cpp
index 78152af052c07..c55aa73d50277 100644
--- a/llvm/examples/OrcV2Examples/LLJITWithThinLTOSummaries/LLJITWithThinLTOSummaries.cpp
+++ b/llvm/examples/OrcV2Examples/LLJITWithThinLTOSummaries/LLJITWithThinLTOSummaries.cpp
@@ -77,7 +77,9 @@ class DuplicateDefinitionInSummary
void log(raw_ostream &OS) const override {
OS << "Duplicate symbol for global value '" << GlobalValueName
- << "' (GUID: " << GlobalValue::getGUID(GlobalValueName) << ") in:\n";
+ << "' (GUID: "
+ << GlobalValue::getGUIDAssumingExternalLinkage(GlobalValueName)
+ << ") in:\n";
for (const std::string &Path : ModulePaths) {
OS << " " << Path << "\n";
}
@@ -110,8 +112,9 @@ class DefinitionNotFoundInSummary
}
void log(raw_ostream &OS) const override {
- OS << "No symbol for global value '" << GlobalValueName
- << "' (GUID: " << GlobalValue::getGUID(GlobalValueName) << ") in:\n";
+ OS << "No symbol for global value '" << GlobalValueName << "' (GUID: "
+ << GlobalValue::getGUIDAssumingExternalLinkage(GlobalValueName)
+ << ") in:\n";
for (const std::string &Path : ModulePaths) {
OS << " " << Path << "\n";
}
@@ -135,7 +138,8 @@ char DefinitionNotFoundInSummary::ID = 0;
Expected<StringRef> getMainModulePath(StringRef FunctionName,
ModuleSummaryIndex &Index) {
// Summaries use unmangled names.
- GlobalValue::GUID G = GlobalValue::getGUID(FunctionName);
+ GlobalValue::GUID G =
+ GlobalValue::getGUIDAssumingExternalLinkage(FunctionName);
ValueInfo VI = Index.getValueInfo(G);
// We need a unique definition, otherwise don't try further.
diff --git a/llvm/include/llvm/IR/GlobalValue.h b/llvm/include/llvm/IR/GlobalValue.h
index 2176e2c2cfbfc..d9ecbb9f8f936 100644
--- a/llvm/include/llvm/IR/GlobalValue.h
+++ b/llvm/include/llvm/IR/GlobalValue.h
@@ -570,6 +570,11 @@ class GlobalValue : public Constant {
return Name;
}
+ /// Declare a type to represent a global unique identifier for a global value.
+ /// This is a 64 bits hash that is used by PGO and ThinLTO to have a compact
+ /// unique way to identify a symbol.
+ using GUID = uint64_t;
+
/// Return the modified name for a global value suitable to be
/// used as the key for a global lookup (e.g. profile or ThinLTO).
/// The value's original name is \c Name and has linkage of type
@@ -578,22 +583,22 @@ class GlobalValue : public Constant {
GlobalValue::LinkageTypes Linkage,
StringRef FileName);
+private:
/// Return the modified name for this global value suitable to be
/// used as the key for a global lookup (e.g. profile or ThinLTO).
std::string getGlobalIdentifier() const;
- /// Declare a type to represent a global unique identifier for a global value.
- /// This is a 64 bits hash that is used by PGO and ThinLTO to have a compact
- /// unique way to identify a symbol.
- using GUID = uint64_t;
-
- /// Return a 64-bit global unique ID constructed from global value name
- /// (i.e. returned by getGlobalIdentifier()).
- static GUID getGUID(StringRef GlobalName);
+public:
+ /// Return a 64-bit global unique ID constructed from the name of a global
+ /// symbol. Since this call doesn't supply the linkage or defining filename,
+ /// the GUID computation will assume that the global has external linkage.
+ static GUID getGUIDAssumingExternalLinkage(StringRef GlobalName);
/// Return a 64-bit global unique ID constructed from global value name
/// (i.e. returned by getGlobalIdentifier()).
- GUID getGUID() const { return getGUID(getGlobalIdentifier()); }
+ GUID getGUID() const {
+ return getGUIDAssumingExternalLinkage(getGlobalIdentifier());
+ }
/// @name Materialization
/// Materialization is used to construct functions only as they're needed.
diff --git a/llvm/include/llvm/IR/ModuleSummaryIndex.h b/llvm/include/llvm/IR/ModuleSummaryIndex.h
index 7aa36345268cd..5a03ae2e53367 100644
--- a/llvm/include/llvm/IR/ModuleSummaryIndex.h
+++ b/llvm/include/llvm/IR/ModuleSummaryIndex.h
@@ -1339,14 +1339,14 @@ class CfiFunctionIndex {
template <typename... Args> void emplace(Args &&...A) {
StringRef S(std::forward<Args>(A)...);
- GlobalValue::GUID GUID =
- GlobalValue::getGUID(GlobalValue::dropLLVMManglingEscape(S));
+ GlobalValue::GUID GUID = GlobalValue::getGUIDAssumingExternalLinkage(
+ GlobalValue::dropLLVMManglingEscape(S));
Index[GUID].emplace(S);
}
size_t count(StringRef S) const {
- GlobalValue::GUID GUID =
- GlobalValue::getGUID(GlobalValue::dropLLVMManglingEscape(S));
+ GlobalValue::GUID GUID = GlobalValue::getGUIDAssumingExternalLinkage(
+ GlobalValue::dropLLVMManglingEscape(S));
auto I = Index.find(GUID);
if (I == Index.end())
return 0;
@@ -1749,8 +1749,10 @@ class ModuleSummaryIndex {
/// Add a global value summary for a value of the given name.
void addGlobalValueSummary(StringRef ValueName,
std::unique_ptr<GlobalValueSummary> Summary) {
- addGlobalValueSummary(getOrInsertValueInfo(GlobalValue::getGUID(ValueName)),
- std::move(Summary));
+ addGlobalValueSummary(
+ getOrInsertValueInfo(
+ GlobalValue::getGUIDAssumingExternalLinkage(ValueName)),
+ std::move(Summary));
}
/// Add a global value summary for the given ValueInfo.
@@ -1887,19 +1889,22 @@ class ModuleSummaryIndex {
/// This accessor can mutate the map and therefore should not be used in
/// the ThinLTO backends.
TypeIdSummary &getOrInsertTypeIdSummary(StringRef TypeId) {
- auto TidIter = TypeIdMap.equal_range(GlobalValue::getGUID(TypeId));
+ auto TidIter = TypeIdMap.equal_range(
+ GlobalValue::getGUIDAssumingExternalLinkage(TypeId));
for (auto &[GUID, TypeIdPair] : make_range(TidIter))
if (TypeIdPair.first == TypeId)
return TypeIdPair.second;
- auto It = TypeIdMap.insert({GlobalValue::getGUID(TypeId),
- {TypeIdSaver.save(TypeId), TypeIdSummary()}});
+ auto It =
+ TypeIdMap.insert({GlobalValue::getGUIDAssumingExternalLinkage(TypeId),
+ {TypeIdSaver.save(TypeId), TypeIdSummary()}});
return It->second.second;
}
/// This returns either a pointer to the type id summary (if present in the
/// summary map) or null (if not present). This may be used when importing.
const TypeIdSummary *getTypeIdSummary(StringRef TypeId) const {
- auto TidIter = TypeIdMap.equal_range(GlobalValue::getGUID(TypeId));
+ auto TidIter = TypeIdMap.equal_range(
+ GlobalValue::getGUIDAssumingExternalLinkage(TypeId));
for (const auto &[GUID, TypeIdPair] : make_range(TidIter))
if (TypeIdPair.first == TypeId)
return &TypeIdPair.second;
diff --git a/llvm/include/llvm/IR/ModuleSummaryIndexYAML.h b/llvm/include/llvm/IR/ModuleSummaryIndexYAML.h
index d5a91763a981c..531de514822e8 100644
--- a/llvm/include/llvm/IR/ModuleSummaryIndexYAML.h
+++ b/llvm/include/llvm/IR/ModuleSummaryIndexYAML.h
@@ -314,7 +314,7 @@ template <> struct CustomMappingTraits<TypeIdSummaryMapTy> {
static void inputOne(IO &io, StringRef Key, TypeIdSummaryMapTy &V) {
TypeIdSummary TId;
io.mapRequired(Key.str().c_str(), TId);
- V.insert({GlobalValue::getGUID(Key), {Key, TId}});
+ V.insert({GlobalValue::getGUIDAssumingExternalLinkage(Key), {Key, TId}});
}
static void output(IO &io, TypeIdSummaryMapTy &V) {
for (auto &TidIter : V)
diff --git a/llvm/include/llvm/ProfileData/SampleProf.h b/llvm/include/llvm/ProfileData/SampleProf.h
index e7b154dff0697..008d464d0c582 100644
--- a/llvm/include/llvm/ProfileData/SampleProf.h
+++ b/llvm/include/llvm/ProfileData/SampleProf.h
@@ -1299,7 +1299,7 @@ class FunctionSamples {
static inline FunctionId getRepInFormat(StringRef Name) {
if (Name.empty() || !FunctionSamples::UseMD5)
return FunctionId(Name);
- return FunctionId(Function::getGUID(Name));
+ return FunctionId(Function::getGUIDAssumingExternalLinkage(Name));
}
raw_ostream &operator<<(raw_ostream &OS, const FunctionSamples &FS);
diff --git a/llvm/include/llvm/Transforms/Utils/SampleProfileLoaderBaseImpl.h b/llvm/include/llvm/Transforms/Utils/SampleProfileLoaderBaseImpl.h
index d714dba4a9687..12d1031fd37a0 100644
--- a/llvm/include/llvm/Transforms/Utils/SampleProfileLoaderBaseImpl.h
+++ b/llvm/include/llvm/Transforms/Utils/SampleProfileLoaderBaseImpl.h
@@ -109,11 +109,12 @@ class PseudoProbeManager {
}
const PseudoProbeDescriptor *getDesc(StringRef FProfileName) const {
- return getDesc(Function::getGUID(FProfileName));
+ return getDesc(Function::getGUIDAssumingExternalLinkage(FProfileName));
}
const PseudoProbeDescriptor *getDesc(const Function &F) const {
- return getDesc(Function::getGUID(FunctionSamples::getCanonicalFnName(F)));
+ return getDesc(Function::getGUIDAssumingExternalLinkage(
+ FunctionSamples::getCanonicalFnName(F)));
}
bool profileIsHashMismatched(const PseudoProbeDescriptor &FuncDesc,
diff --git a/llvm/lib/Analysis/CtxProfAnalysis.cpp b/llvm/lib/Analysis/CtxProfAnalysis.cpp
index d203e277546ea..2a56e337b6b84 100644
--- a/llvm/lib/Analysis/CtxProfAnalysis.cpp
+++ b/llvm/lib/Analysis/CtxProfAnalysis.cpp
@@ -64,7 +64,7 @@ PreservedAnalyses AssignGUIDPass::run(Module &M, ModuleAnalysisManager &MAM) {
GlobalValue::GUID AssignGUIDPass::getGUID(const Function &F) {
if (F.isDeclaration()) {
assert(GlobalValue::isExternalLinkage(F.getLinkage()));
- return GlobalValue::getGUID(F.getGlobalIdentifier());
+ return F.getGUID();
}
auto *MD = F.getMetadata(GUIDMetadataName);
assert(MD && "guid not found for defined function");
diff --git a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
index 5693e235836bf..5d740a9bb7d13 100644
--- a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
+++ b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
@@ -222,7 +222,8 @@ static void addIntrinsicToSummary(
auto *TypeId = dyn_cast<MDString>(TypeMDVal->getMetadata());
if (!TypeId)
break;
- GlobalValue::GUID Guid = GlobalValue::getGUID(TypeId->getString());
+ GlobalValue::GUID Guid =
+ GlobalValue::getGUIDAssumingExternalLinkage(TypeId->getString());
// Produce a summary from type.test intrinsics. We only summarize type.test
// intrinsics that are used other than by an llvm.assume intrinsic.
@@ -250,7 +251,8 @@ static void addIntrinsicToSummary(
auto *TypeId = dyn_cast<MDString>(TypeMDVal->getMetadata());
if (!TypeId)
break;
- GlobalValue::GUID Guid = GlobalValue::getGUID(TypeId->getString());
+ GlobalValue::GUID Guid =
+ GlobalValue::getGUIDAssumingExternalLinkage(TypeId->getString());
SmallVector<DevirtCallSite, 4> DevirtCalls;
SmallVector<Instruction *, 4> LoadedPtrs;
@@ -904,7 +906,8 @@ static void computeAliasSummary(ModuleSummaryIndex &Index, const GlobalAlias &A,
// Set LiveRoot flag on entries matching the given value name.
static void setLiveRoot(ModuleSummaryIndex &Index, StringRef Name) {
- if (ValueInfo VI = Index.getValueInfo(GlobalValue::getGUID(Name)))
+ if (ValueInfo VI =
+ Index.getValueInfo(GlobalValue::getGUIDAssumingExternalLinkage(Name)))
for (const auto &Summary : VI.getSummaryList())
Summary->setLive(true);
}
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp
index af0422f09bc4f..370d124dc42b4 100644
--- a/llvm/lib/AsmParser/LLParser.cpp
+++ b/llvm/lib/AsmParser/LLParser.cpp
@@ -9049,7 +9049,7 @@ bool LLParser::parseTypeIdEntry(unsigned ID) {
for (auto TIDRef : FwdRefTIDs->second) {
assert(!*TIDRef.first &&
"Forward referenced type id GUID expected to be 0");
- *TIDRef.first = GlobalValue::getGUID(Name);
+ *TIDRef.first = GlobalValue::getGUIDAssumingExternalLinkage(Name);
}
ForwardRefTypeIds.erase(FwdRefTIDs);
}
@@ -9154,7 +9154,7 @@ bool LLParser::parseTypeIdCompatibleVtableEntry(unsigned ID) {
for (auto TIDRef : FwdRefTIDs->second) {
assert(!*TIDRef.first &&
"Forward referenced type id GUID expected to be 0");
- *TIDRef.first = GlobalValue::getGUID(Name);
+ *TIDRef.first = GlobalValue::getGUIDAssumingExternalLinkage(Name);
}
ForwardRefTypeIds.erase(FwdRefTIDs);
}
@@ -9470,7 +9470,7 @@ bool LLParser::addGlobalValueToIndex(
assert(
(!GlobalValue::isLocalLinkage(Linkage) || !SourceFileName.empty()) &&
"Need a source_filename to compute GUID for local");
- GUID = GlobalValue::getGUID(
+ GUID = GlobalValue::getGUIDAssumingExternalLinkage(
GlobalValue::getGlobalIdentifier(Name, Linkage, SourceFileName));
VI = Index->getOrInsertValueInfo(GUID, Index->saveString(Name));
}
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 5c62ef4ad8e4e..7a4647617f3de 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -7166,10 +7166,10 @@ void ModuleSummaryIndexBitcodeReader::setValueGUID(
StringRef SourceFileName) {
std::string GlobalId =
GlobalValue::getGlobalIdentifier(ValueName, Linkage, SourceFileName);
- auto ValueGUID = GlobalValue::getGUID(GlobalId);
+ auto ValueGUID = GlobalValue::getGUIDAssumingExternalLinkage(GlobalId);
auto OriginalNameID = ValueGUID;
if (GlobalValue::isLocalLinkage(Linkage))
- OriginalNameID = GlobalValue::getGUID(ValueName);
+ OriginalNameID = GlobalValue::getGUIDAssumingExternalLinkage(ValueName);
if (PrintSummaryGUIDs)
dbgs() << "GUID " << ValueGUID << "(" << OriginalNameID << ") is "
<< ValueName << "\n";
diff --git a/llvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.cpp
index 5dda38383a656..618deef2a74ea 100644
--- a/llvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.cpp
@@ -34,7 +34,7 @@ void PseudoProbeHandler::emitPseudoProbe(uint64_t Guid, uint64_t Index,
// Use caching to avoid redundant md5 computation for build speed.
uint64_t &CallerGuid = NameGuidMap[Name];
if (!CallerGuid)
- CallerGuid = Function::getGUID(Name);
+ CallerGuid = Function::getGUIDAssumingExternalLinkage(Name);
uint64_t CallerProbeId = PseudoProbeDwarfDiscriminator::extractProbeIndex(
InlinedAt->getDiscriminator());
ReversedInlineStack.emplace_back(CallerGuid, CallerProbeId);
diff --git a/llvm/lib/CodeGen/PseudoProbeInserter.cpp b/llvm/lib/CodeGen/PseudoProbeInserter.cpp
index 913e0035b046f..c911e8453613d 100644
--- a/llvm/lib/CodeGen/PseudoProbeInserter.cpp
+++ b/llvm/lib/CodeGen/PseudoProbeInserter.cpp
@@ -129,7 +129,7 @@ class PseudoProbeInserter : public MachineFunctionPass {
private:
uint64_t getFuncGUID(Module *M, DILocation *DL) {
auto Name = DL->getSubprogramLinkageName();
- return Function::getGUID(Name);
+ return Function::getGUIDAssumingExternalLinkage(Name);
}
bool ShouldRun = false;
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp
index ac8aa0d35ea30..f1637afa3f565 100644
--- a/llvm/lib/IR/AsmWriter.cpp
+++ b/llvm/lib/IR/AsmWriter.cpp
@@ -3226,7 +3226,7 @@ void AssemblyWriter::printModuleSummaryIndex() {
// Print the TypeIdCompatibleVtableMap entries.
for (auto &TId : TheIndex->typeIdCompatibleVtableMap()) {
- auto GUID = GlobalValue::getGUID(TId.first);
+ auto GUID = GlobalValue::getGUIDAssumingExternalLinkage(TId.first);
Out << "^" << Machine.getTypeIdCompatibleVtableSlot(TId.first)
<< " = typeidCompatibleVTable: (name: \"" << TId.first << "\"";
printTypeIdCompatibleVtableSummary(TId.second);
diff --git a/llvm/lib/IR/Globals.cpp b/llvm/lib/IR/Globals.cpp
index 401f8ac58bce8..7b799c70a3318 100644
--- a/llvm/lib/IR/Globals.cpp
+++ b/llvm/lib/IR/Globals.cpp
@@ -73,8 +73,9 @@ void GlobalValue::copyAttributesFrom(const GlobalValue *Src) {
removeSanitizerMetadata();
}
-GlobalValue::GUID GlobalValue::getGUID(StringRef GlobalName) {
- return MD5Hash(GlobalName);
+GlobalValue::GUID
+GlobalValue::getGUIDAssumingExternalLinkage(StringRef GlobalIdentifier) {
+ return MD5Hash(GlobalIdentifier);
}
void GlobalValue::removeFromParent() {
diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp
index 4b6a87edeff87..613e2d971c8b8 100644
--- a/llvm/lib/LTO/LTO.cpp
+++ b/llvm/lib/LTO/LTO.cpp
@@ -1043,8 +1043,9 @@ Error LTO::addThinLTO(BitcodeModule BM, ArrayRef<InputFile::Symbol> Syms,
SymbolResolution Res = *ResITmp++;
if (!Sym.getIRName().empty()) {
- auto GUID = GlobalValue::getGUID(GlobalValue::getGlobalIdentifier(
- Sym.getIRName(), GlobalValue::ExternalLinkage, ""));
+ auto GUID = GlobalValue::getGUIDAssumingExternalLinkage(
+ GlobalValue::getGlobalIdentifier(Sym.getIRName(),
+ GlobalValue::ExternalLinkage, ""));
if (Res.Prevailing)
ThinLTO.PrevailingModuleForGUID[GUID] = BM.getModuleIdentifier();
}
@@ -1064,8 +1065,9 @@ Error LTO::addThinLTO(BitcodeModule BM, ArrayRef<InputFile::Symbol> Syms,
SymbolResolution Res = *ResI++;
if (!Sym.getIRName().empty()) {
- auto GUID = GlobalValue::getGUID(GlobalValue::getGlobalIdentifier(
- Sym.getIRName(), GlobalValue::ExternalLinkage, ""));
+ auto GUID = GlobalValue::getGUIDAssumingExternalLinkage(
+ GlobalValue::getGlobalIdentifier(Sym.getIRName(),
+ GlobalValue::ExternalLinkage, ""));
if (Res.Prevailing) {
assert(ThinLTO.PrevailingModuleForGUID[GUID] ==
BM.getModuleIdentifier());
@@ -1174,7 +1176,7 @@ Error LTO::run(AddStreamFn AddStream, FileCache Cache) {
if (Res.second.IRName.empty())
continue;
- GlobalValue::GUID GUID = GlobalValue::getGUID(
+ GlobalValue::GUID GUID = GlobalValue::getGUIDAssumingExternalLinkage(
GlobalValue::dropLLVMManglingEscape(Res.second.IRName));
if (Res.second.VisibleOutsideSummary && Res.second.Prevailing)
@@ -1950,7 +1952,7 @@ Error LTO::runThinLTO(AddStreamFn AddStream, FileCache Cache,
if (Res.second.Partition != GlobalResolution::External ||
!Res.second.isPrevailingIRSymbol())
continue;
- auto GUID = GlobalValue::getGUID(
+ auto GUID = GlobalValue::getGUIDAssumingExternalLinkage(
GlobalValue::dropLLVMManglingEscape(Res.second.IRName));
// Mark exported unless index-based analysis determined it to be dead.
if (ThinLTO.CombinedIndex.isGUIDLive(GUID))
diff --git a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
index 9e7f8187fe49c..42dba0abe245f 100644
--- a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
+++ b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp
@@ -295,7 +295,8 @@ addUsedSymbolToPreservedGUID(const lto::InputFile &File,
DenseSet<GlobalValue::GUID> &PreservedGUID) {
for (const auto &Sym : File.symbols()) {
if (Sym.isUsed())
- PreservedGUID.insert(GlobalValue::getGUID(Sym.getIRName()));
+ PreservedGUID.insert(
+ GlobalValue::getGUIDAssumingExternalLinkage(Sym.getIRName()));
}
}
@@ -308,8 +309,9 @@ static void computeGUIDPreservedSymbols(const lto::InputFile &File,
// compute the GUID for the symbol.
for (const auto &Sym : File.symbols()) {
if (PreservedSymbols.count(Sym.getName()) && !Sym.getIRName().empty())
- GUIDs.insert(GlobalValue::getGUID(GlobalValue::getGlobalIdentifier(
- Sym.getIRName(), GlobalValue::ExternalLinkage, "")));
+ GUIDs.insert(GlobalValue::getGUIDAssumingExternalLinkage(
+ GlobalValue::getGlobalIdentifier(Sym.getIRName(),
+ GlobalValue::ExternalLinkage, "")));
}
}
diff --git a/llvm/lib/ProfileData/InstrProf.cpp b/llvm/lib/ProfileData/InstrProf.cpp
index 1e427ca63c5cf..19f892fff047f 100644
--- a/llvm/lib/ProfileData/InstrProf.cpp
+++ b/llvm/lib/ProfileData/InstrProf.cpp
@@ -516,8 +516,8 @@ Error InstrProfSymtab::addVTableWithName(GlobalVariable &VTable,
return E;
bool Inserted = true;
- std::tie(std::ignore, Inserted) =
- MD5VTableMap.try_emplace(GlobalValue::getGUID(Name), &VTable);
+ std::tie(std::ignore, Inserted) = MD5VTableMap.try_emplace(
+ GlobalValue::getGUIDAssumingExternalLinkage(Name), &VTable);
if (!Inserted)
LLVM_DEBUG(dbgs() << "GUID conflict within one module");
return Error::success();
@@ -635,7 +635,7 @@ Error InstrProfSymtab::addFuncWithName(Function &F, StringRef PGOFuncName,
auto NameToGUIDMap = [&](StringRef Name) -> Error {
if (Error E = addFuncName(Name))
return E;
- MD5FuncMap.emplace_back(Function::getGUID(Name), &F);
+ MD5FuncMap.emplace_back(Function::getGUIDAssumingExternalLinkage(Name), &F);
return Error::success();
};
if (Error E = NameToGUIDMap(PGOFuncName))
diff --git a/llvm/lib/ProfileData/MemProf.cpp b/llvm/lib/ProfileData/MemProf.cpp
index 0af08ca51481f..c3a2767fd8130 100644
--- a/llvm/lib/ProfileData/MemProf.cpp
+++ b/llvm/lib/ProfileData/MemProf.cpp
@@ -263,7 +263,7 @@ GlobalValue::GUID IndexedMemProfRecord::getGUID(const StringRef FunctionName) {
// We use the function guid which we expect to be a uint64_t. At
// this time, it is the lower 64 bits of the md5 of the canonical
// function name.
- return Function::getGUID(CanonicalName);
+ return Function::getGUIDAssumingExternalLinkage(CanonicalName);
}
Expected<MemProfSchema> readMemProfSchema(const unsigned char *&Buffer) {
diff --git a/llvm/lib/ProfileData/SampleProfReader.cpp b/llvm/lib/ProfileData/SampleProfReader.cpp
index d97cc479442e4..343104ea25d1f 100644
--- a/llvm/lib/ProfileData/SampleProfReader.cpp
+++ b/llvm/lib/ProfileData/SampleProfReader.cpp
@@ -908,7 +908,7 @@ std::error_code SampleProfileReaderExtBinaryBase::readFuncProfiles(
DenseSet<uint64_t> FuncGuidsToUse;
if (useMD5()) {
for (auto Name : FuncsToUse)
- FuncGuidsToUse.insert(Function::getGUID(Name));
+ FuncGuidsToUse.insert(Function::getGUIDAssumingExternalLinkage(Name));
}
// For each function in current module, load all context profiles for
diff --git a/llvm/lib/Target/Mips/MipsSEISelDAGToDAG.cpp b/llvm/lib/Target/Mips/MipsSEISelDAGToDAG.cpp
index 738fabea25bf7..8f201e532b779 100644
--- a/llvm/lib/Target/Mips/MipsSEISelDAGToDAG.cpp
+++ b/llvm/lib/Target/Mips/MipsSEISelDAGToDAG.cpp
@@ -176,7 +176,8 @@ void MipsSEDAGToDAGISel::processFunctionAfterISel(MachineFunction &MF) {
case Mips::JAL:
case Mips::JAL_MM:
if (MI.getOperand(0).isGlobal() &&
- MI.getOperand(0).getGlobal()->getGlobalIdentifier() == "_mcount")
+ MI.getOperand(0).getGlobal()->hasExternalLinkage() &&
+ MI.getOperand(0).getGlobal()->getName() == "_mcount")
emitMCountABI(MI, MBB, MF);
break;
case Mips::JALRPseudo:
diff --git a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
index f07331bf6c6b5..85155c900e23a 100644
--- a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
+++ b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
@@ -3139,9 +3139,8 @@ bool PPCAIXAsmPrinter::doInitialization(Module &M) {
if (Aliasee->hasCommonLinkage()) {
report_fatal_error("Aliases to common variables are not allowed on AIX:"
"\n\tAlias attribute for " +
- Alias.getGlobalIdentifier() +
- " is invalid because " + Aliasee->getName() +
- " is common.",
+ Alias.getName() + " is invalid because " +
+ Aliasee->getName() + " is common.",
false);
}
diff --git a/llvm/lib/Target/SPIRV/SPIRVCallLowering.cpp b/llvm/lib/Target/SPIRV/SPIRVCallLowering.cpp
index 5ec8c22dbf473..b824b9aeda660 100644
--- a/llvm/lib/Target/SPIRV/SPIRVCallLowering.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVCallLowering.cpp
@@ -454,7 +454,7 @@ bool SPIRVCallLowering::lowerFormalArguments(MachineIRBuilder &MIRBuilder,
? SPIRV::LinkageType::LinkOnceODR
: SPIRV::LinkageType::Export);
buildOpDecorate(FuncVReg, MIRBuilder, SPIRV::Decoration::LinkageAttributes,
- {static_cast<uint32_t>(LnkTy)}, F.getGlobalIdentifier());
+ {static_cast<uint32_t>(LnkTy)}, F.getName());
}
// Handle function pointers decoration
diff --git a/llvm/lib/Transforms/IPO/FunctionImport.cpp b/llvm/lib/Transforms/IPO/FunctionImport.cpp
index 12da7f57a8f61..8aeeb4e4ec82c 100644
--- a/llvm/lib/Transforms/IPO/FunctionImport.cpp
+++ b/llvm/lib/Transforms/IPO/FunctionImport.cpp
@@ -19,6 +19,7 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/Bitcode/BitcodeReader.h"
#include "llvm/IR/AutoUpgrade.h"
+#include "llvm/IR/Constants.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GlobalAlias.h"
#include "llvm/IR/GlobalObject.h"
@@ -607,7 +608,7 @@ class WorkloadImportsManager : public ModuleImportsManager {
if (PotentialCandidates.empty()) {
LLVM_DEBUG(dbgs() << "[Workload] Not importing " << VI.name()
<< " because can't find eligible Callee. Guid is: "
- << Function::getGUID(VI.name()) << "\n");
+ << VI.getGUID() << "\n");
continue;
}
/// We will prefer importing the prevailing candidate, if not, we'll
@@ -660,8 +661,7 @@ class WorkloadImportsManager : public ModuleImportsManager {
continue;
}
LLVM_DEBUG(dbgs() << "[Workload][Including]" << VI.name() << " from "
- << ExportingModule << " : "
- << Function::getGUID(VI.name()) << "\n");
+ << ExportingModule << " : " << VI.getGUID() << "\n");
ImportList.addDefinition(ExportingModule, VI.getGUID());
GVI.onImportingSummary(*GVS);
if (ExportLists)
@@ -1807,7 +1807,8 @@ void llvm::thinLTOInternalizeModule(Module &TheModule,
std::string OrigId = GlobalValue::getGlobalIdentifier(
OrigName, GlobalValue::InternalLinkage,
TheModule.getSourceFileName());
- GS = DefinedGlobals.find(GlobalValue::getGUID(OrigId));
+ GS = DefinedGlobals.find(
+ GlobalValue::getGUIDAssumingExternalLinkage(OrigId));
if (GS == DefinedGlobals.end()) {
// Also check the original non-promoted non-globalized name. In some
// cases a preempted weak value is linked in as a local copy because
@@ -1815,7 +1816,8 @@ void llvm::thinLTOInternalizeModule(Module &TheModule,
// In that case, since it was originally not a local value, it was
// recorded in the index using the original name.
// FIXME: This may not be needed once PR27866 is fixed.
- GS = DefinedGlobals.find(GlobalValue::getGUID(OrigName));
+ GS = DefinedGlobals.find(
+ GlobalValue::getGUIDAssumingExternalLinkage(OrigName));
assert(GS != DefinedGlobals.end());
}
}
diff --git a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
index 7cf7d74acfcfa..6711325cb4b97 100644
--- a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
+++ b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
@@ -2114,7 +2114,8 @@ bool LowerTypeTestsModule::lower() {
->getValue()
->getUniqueInteger()
.getZExtValue());
- const GlobalValue::GUID GUID = GlobalValue::getGUID(
+ const GlobalValue::GUID GUID =
+ GlobalValue::getGUIDAssumingExternalLinkage(
GlobalValue::dropLLVMManglingEscape(FunctionName));
// Do not emit jumptable entries for functions that are not-live and
// have no live references (and are not exported with cross-DSO CFI.)
@@ -2320,8 +2321,9 @@ bool LowerTypeTestsModule::lower() {
DenseMap<GlobalValue::GUID, TinyPtrVector<Metadata *>> MetadataByGUID;
for (auto &P : TypeIdInfo) {
if (auto *TypeId = dyn_cast<MDString>(P.first))
- MetadataByGUID[GlobalValue::getGUID(TypeId->getString())].push_back(
- TypeId);
+ MetadataByGUID[GlobalValue::getGUIDAssumingExternalLinkage(
+ TypeId->getString())]
+ .push_back(TypeId);
}
for (auto &P : *ExportSummary) {
diff --git a/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp b/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
index a5e0251277d8f..1abe3b230b37a 100644
--- a/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
+++ b/llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
@@ -4608,7 +4608,8 @@ static ValueInfo findValueInfoForFunc(const Function &F, const Module &M,
// See if theFn was internalized, by checking index directly with
// original name (this avoids the name adjustment done by getGUID() for
// internal symbols).
- TheFnVI = ImportSummary->getValueInfo(GlobalValue::getGUID(F.getName()));
+ TheFnVI = ImportSummary->getValueInfo(
+ GlobalValue::getGUIDAssumingExternalLinkage(F.getName()));
if (TheFnVI)
return TheFnVI;
// Now query with the original name before any promotion was performed.
@@ -4639,7 +4640,8 @@ static ValueInfo findValueInfoForFunc(const Function &F, const Module &M,
SrcFile = dyn_cast<MDString>(SrcFileMD->getOperand(0))->getString();
std::string OrigId = GlobalValue::getGlobalIdentifier(
OrigName, GlobalValue::InternalLinkage, SrcFile);
- TheFnVI = ImportSummary->getValueInfo(GlobalValue::getGUID(OrigId));
+ TheFnVI = ImportSummary->getValueInfo(
+ GlobalValue::getGUIDAssumingExternalLinkage(OrigId));
// Internal func in original module may have gotten a numbered suffix if we
// imported an external function with the same name. This happens
// automatically during IR linking for naming conflicts. It would have to
@@ -4650,7 +4652,8 @@ static ValueInfo findValueInfoForFunc(const Function &F, const Module &M,
OrigName = F.getName().rsplit('.').first;
OrigId = GlobalValue::getGlobalIdentifier(
OrigName, GlobalValue::InternalLinkage, SrcFile);
- TheFnVI = ImportSummary->getValueInfo(GlobalValue::getGUID(OrigId));
+ TheFnVI = ImportSummary->getValueInfo(
+ GlobalValue::getGUIDAssumingExternalLinkage(OrigId));
}
// The only way we may not have a VI is if this is a declaration created for
// an imported reference. For distributed ThinLTO we may not have a VI for
diff --git a/llvm/lib/Transforms/IPO/SampleProfile.cpp b/llvm/lib/Transforms/IPO/SampleProfile.cpp
index d89da7621990a..4947a0da3bdb0 100644
--- a/llvm/lib/Transforms/IPO/SampleProfile.cpp
+++ b/llvm/lib/Transforms/IPO/SampleProfile.cpp
@@ -361,7 +361,7 @@ class GUIDToFuncNameMapper {
for (const auto &F : CurrentModule) {
StringRef OrigName = F.getName();
CurrentGUIDToFuncNameMap.insert(
- {Function::getGUID(OrigName), OrigName});
+ {Function::getGUIDAssumingExternalLinkage(OrigName), OrigName});
// Local to global var promotion used by optimization like thinlto
// will rename the var and add suffix like ".llvm.xxx" to the
@@ -373,7 +373,7 @@ class GUIDToFuncNameMapper {
StringRef CanonName = FunctionSamples::getCanonicalFnName(F);
if (CanonName != OrigName)
CurrentGUIDToFuncNameMap.insert(
- {Function::getGUID(CanonName), CanonName});
+ {Function::getGUIDAssumingExternalLinkage(CanonName), CanonName});
}
// Update GUIDToFuncNameMap for each function including inlinees.
@@ -820,7 +820,7 @@ static bool doesHistoryAllowICP(const Instruction &Inst, StringRef Candidate) {
// If the promotion candidate has NOMORE_ICP_MAGICNUM count in the
// metadata, it means the candidate has been promoted for this
// indirect call.
- if (V.Value == Function::getGUID(Candidate))
+ if (V.Value == Function::getGUIDAssumingExternalLinkage(Candidate))
return false;
NumPromoted++;
// If already have MaxNumPromotions promotion, don't do it anymore.
@@ -951,7 +951,8 @@ bool SampleProfileLoader::tryPromoteAndInlineCandidate(
// For promoted target, set its value with NOMORE_ICP_MAGICNUM count
// in the value profile metadata so the target won't be promoted again.
SmallVector<InstrProfValueData, 1> SortedCallTargets = {InstrProfValueData{
- Function::getGUID(R->second->getName()), NOMORE_ICP_MAGICNUM}};
+ Function::getGUIDAssumingExternalLinkage(R->second->getName()),
+ NOMORE_ICP_MAGICNUM}};
updateIDTMetaData(CI, SortedCallTargets, 0);
auto *DI = &pgo::promoteIndirectCall(
@@ -1038,8 +1039,8 @@ void SampleProfileLoader::findExternalInlineCandidate(
// Samples may not exist for replayed function, if so
// just add the direct GUID and move on
if (!Samples) {
- InlinedGUIDs.insert(
- Function::getGUID(CB->getCalledFunction()->getName()));
+ InlinedGUIDs.insert(Function::getGUIDAssumingExternalLinkage(
+ CB->getCalledFunction()->getName()));
return;
}
// Otherwise, drop the threshold to import everything that we can
@@ -2280,7 +2281,8 @@ bool SampleProfileLoader::runOnFunction(Function &F, ModuleAnalysisManager *AM)
// cold in sampled binary will actually not be cold after current build.
StringRef CanonName = FunctionSamples::getCanonicalFnName(F);
if ((FunctionSamples::UseMD5 &&
- GUIDsInProfile.count(Function::getGUID(CanonName))) ||
+ GUIDsInProfile.count(
+ Function::getGUIDAssumingExternalLinkage(CanonName))) ||
(!FunctionSamples::UseMD5 && NamesInProfile.count(CanonName)))
initialEntryCount = -1;
}
diff --git a/llvm/lib/Transforms/IPO/SampleProfileProbe.cpp b/llvm/lib/Transforms/IPO/SampleProfileProbe.cpp
index e15aa0472088c..70be19a6c027f 100644
--- a/llvm/lib/Transforms/IPO/SampleProfileProbe.cpp
+++ b/llvm/lib/Transforms/IPO/SampleProfileProbe.cpp
@@ -352,7 +352,7 @@ void SampleProfileProber::instrumentOneFunc(Function &F, TargetMachine *TM) {
if (FName.empty())
FName = SP->getName();
}
- uint64_t Guid = Function::getGUID(FName);
+ uint64_t Guid = Function::getGUIDAssumingExternalLinkage(FName);
// Assign an artificial debug line to a probe that doesn't come with a real
// line. A probe not having a debug line will get an incomplete inline
diff --git a/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp b/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
index 0680b2c558807..49c9515fa6a0b 100644
--- a/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
+++ b/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
@@ -2243,7 +2243,8 @@ DevirtModule::lookUpFunctionValueInfo(Function *TheFn,
"Caller guarantees ExportSummary is not nullptr");
const auto TheFnGUID = TheFn->getGUID();
- const auto TheFnGUIDWithExportedName = GlobalValue::getGUID(TheFn->getName());
+ const auto TheFnGUIDWithExportedName =
+ GlobalValue::getGUIDAssumingExternalLinkage(TheFn->getName());
// Look up ValueInfo with the GUID in the current linkage.
ValueInfo TheFnVI = ExportSummary->getValueInfo(TheFnGUID);
// If no entry is found and GUID is different from GUID computed using
@@ -2344,8 +2345,9 @@ bool DevirtModule::run() {
DenseMap<GlobalValue::GUID, TinyPtrVector<Metadata *>> MetadataByGUID;
for (auto &P : TypeIdMap) {
if (auto *TypeId = dyn_cast<MDString>(P.first))
- MetadataByGUID[GlobalValue::getGUID(TypeId->getString())].push_back(
- TypeId);
+ MetadataByGUID[GlobalValue::getGUIDAssumingExternalLinkage(
+ TypeId->getString())]
+ .push_back(TypeId);
}
for (auto &P : *ExportSummary) {
@@ -2428,8 +2430,8 @@ bool DevirtModule::run() {
// llvm.type.test intrinsics to the function summaries so that the
// LowerTypeTests pass will export them.
if (ExportSummary && isa<MDString>(S.first.TypeID)) {
- auto GUID =
- GlobalValue::getGUID(cast<MDString>(S.first.TypeID)->getString());
+ auto GUID = GlobalValue::getGUIDAssumingExternalLinkage(
+ cast<MDString>(S.first.TypeID)->getString());
for (auto *FS : S.second.CSInfo.SummaryTypeCheckedLoadUsers)
FS->addTypeTest(GUID);
for (auto &CCS : S.second.ConstCSInfo)
@@ -2485,7 +2487,8 @@ void DevirtIndex::run() {
DenseMap<GlobalValue::GUID, std::vector<StringRef>> NameByGUID;
for (const auto &P : ExportSummary.typeIdCompatibleVtableMap()) {
- NameByGUID[GlobalValue::getGUID(P.first)].push_back(P.first);
+ NameByGUID[GlobalValue::getGUIDAssumingExternalLinkage(P.first)].push_back(
+ P.first);
// Create the type id summary resolution regardlness of whether we can
// devirtualize, so that lower type tests knows the type id is used on
// a global and not Unsat. We do this here rather than in the loop over the
diff --git a/llvm/lib/Transforms/Instrumentation/MemProfiler.cpp b/llvm/lib/Transforms/Instrumentation/MemProfiler.cpp
index 46b524d054493..8b90d87d34563 100644
--- a/llvm/lib/Transforms/Instrumentation/MemProfiler.cpp
+++ b/llvm/lib/Transforms/Instrumentation/MemProfiler.cpp
@@ -972,7 +972,7 @@ readMemprof(Module &M, Function &F, IndexedInstrProfReader *MemProfReader,
// 'unique-internal-linkage-names' can make MemProf work better for local
// linkage function.
auto FuncName = F.getName();
- auto FuncGUID = Function::getGUID(FuncName);
+ auto FuncGUID = Function::getGUIDAssumingExternalLinkage(FuncName);
std::optional<memprof::MemProfRecord> MemProfRec;
auto Err = MemProfReader->getMemProfRecord(FuncGUID).moveInto(MemProfRec);
if (Err) {
@@ -1098,7 +1098,7 @@ readMemprof(Module &M, Function &F, IndexedInstrProfReader *MemProfReader,
StringRef Name = DIL->getScope()->getSubprogram()->getLinkageName();
if (Name.empty())
Name = DIL->getScope()->getSubprogram()->getName();
- auto CalleeGUID = Function::getGUID(Name);
+ auto CalleeGUID = Function::getGUIDAssumingExternalLinkage(Name);
auto StackId = computeStackId(CalleeGUID, GetOffset(DIL),
ProfileHasColumns ? DIL->getColumn() : 0);
// Check if we have found the profile's leaf frame. If yes, collect
diff --git a/llvm/tools/llvm-profgen/ProfiledBinary.cpp b/llvm/tools/llvm-profgen/ProfiledBinary.cpp
index 472e49a49cf70..6847ba1b21b1f 100644
--- a/llvm/tools/llvm-profgen/ProfiledBinary.cpp
+++ b/llvm/tools/llvm-profgen/ProfiledBinary.cpp
@@ -409,17 +409,18 @@ void ProfiledBinary::decodePseudoProbe(const ELFObjectFileBase *Obj) {
FuncStartAddresses = SymbolStartAddrs;
} else {
for (auto &F : DisassembleFunctionSet) {
- auto GUID = Function::getGUID(F.first());
+ auto GUID = Function::getGUIDAssumingExternalLinkage(F.first());
if (auto StartAddr = SymbolStartAddrs.lookup(GUID)) {
FuncStartAddresses[GUID] = StartAddr;
FuncRange &Range = StartAddrToFuncRangeMap[StartAddr];
- GuidFilter.insert(Function::getGUID(Range.getFuncName()));
+ GuidFilter.insert(
+ Function::getGUIDAssumingExternalLinkage(Range.getFuncName()));
}
}
}
} else {
for (auto *F : ProfiledFunctions) {
- GuidFilter.insert(Function::getGUID(F->FuncName));
+ GuidFilter.insert(Function::getGUIDAssumingExternalLinkage(F->FuncName));
for (auto &Range : F->Ranges) {
auto GUIDs = StartAddrToSymMap.equal_range(Range.first);
for (const auto &[StartAddr, Func] : make_range(GUIDs))
@@ -774,7 +775,7 @@ void ProfiledBinary::populateElfSymbolAddressList(
for (const SymbolRef &Symbol : Obj->symbols()) {
const uint64_t Addr = unwrapOrError(Symbol.getAddress(), FileName);
const StringRef Name = unwrapOrError(Symbol.getName(), FileName);
- uint64_t GUID = Function::getGUID(Name);
+ uint64_t GUID = Function::getGUIDAssumingExternalLinkage(Name);
SymbolStartAddrs[GUID] = Addr;
StartAddrToSymMap.emplace(Addr, GUID);
}
More information about the llvm-commits
mailing list