Skip to content

Commit d3d856a

Browse files
authored
Clean up external users of GlobalValue::getGUID(StringRef) (#129644)
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: * 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. There are a few cases where neither 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.
1 parent ed3c870 commit d3d856a

31 files changed

+130
-94
lines changed

bolt/lib/Rewrite/PseudoProbeRewriter.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ void PseudoProbeRewriter::parsePseudoProbe(bool ProfiledOnly) {
147147
if (!Name)
148148
continue;
149149
SymName = *Name;
150-
uint64_t GUID = Function::getGUID(SymName);
150+
uint64_t GUID = Function::getGUIDAssumingExternalLinkage(SymName);
151151
FuncStartAddrs[GUID] = F->getAddress();
152152
if (ProfiledOnly && HasProfile)
153153
GuidFilter.insert(GUID);
@@ -173,7 +173,7 @@ void PseudoProbeRewriter::parsePseudoProbe(bool ProfiledOnly) {
173173
const GUIDProbeFunctionMap &GUID2Func = ProbeDecoder.getGUID2FuncDescMap();
174174
// Checks GUID in GUID2Func and returns it if it's present or null otherwise.
175175
auto checkGUID = [&](StringRef SymName) -> uint64_t {
176-
uint64_t GUID = Function::getGUID(SymName);
176+
uint64_t GUID = Function::getGUIDAssumingExternalLinkage(SymName);
177177
if (GUID2Func.find(GUID) == GUID2Func.end())
178178
return 0;
179179
return GUID;
@@ -435,7 +435,7 @@ void PseudoProbeRewriter::encodePseudoProbes() {
435435
for (const BinaryFunction *F : BC.getAllBinaryFunctions()) {
436436
const uint64_t Addr =
437437
F->isEmitted() ? F->getOutputAddress() : F->getAddress();
438-
FuncStartAddrs[Function::getGUID(
438+
FuncStartAddrs[Function::getGUIDAssumingExternalLinkage(
439439
NameResolver::restore(F->getOneName()))] = Addr;
440440
}
441441
DummyDecoder.buildAddress2ProbeMap(

llvm/examples/OrcV2Examples/LLJITWithThinLTOSummaries/LLJITWithThinLTOSummaries.cpp

+8-4
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ class DuplicateDefinitionInSummary
7777

7878
void log(raw_ostream &OS) const override {
7979
OS << "Duplicate symbol for global value '" << GlobalValueName
80-
<< "' (GUID: " << GlobalValue::getGUID(GlobalValueName) << ") in:\n";
80+
<< "' (GUID: "
81+
<< GlobalValue::getGUIDAssumingExternalLinkage(GlobalValueName)
82+
<< ") in:\n";
8183
for (const std::string &Path : ModulePaths) {
8284
OS << " " << Path << "\n";
8385
}
@@ -110,8 +112,9 @@ class DefinitionNotFoundInSummary
110112
}
111113

112114
void log(raw_ostream &OS) const override {
113-
OS << "No symbol for global value '" << GlobalValueName
114-
<< "' (GUID: " << GlobalValue::getGUID(GlobalValueName) << ") in:\n";
115+
OS << "No symbol for global value '" << GlobalValueName << "' (GUID: "
116+
<< GlobalValue::getGUIDAssumingExternalLinkage(GlobalValueName)
117+
<< ") in:\n";
115118
for (const std::string &Path : ModulePaths) {
116119
OS << " " << Path << "\n";
117120
}
@@ -135,7 +138,8 @@ char DefinitionNotFoundInSummary::ID = 0;
135138
Expected<StringRef> getMainModulePath(StringRef FunctionName,
136139
ModuleSummaryIndex &Index) {
137140
// Summaries use unmangled names.
138-
GlobalValue::GUID G = GlobalValue::getGUID(FunctionName);
141+
GlobalValue::GUID G =
142+
GlobalValue::getGUIDAssumingExternalLinkage(FunctionName);
139143
ValueInfo VI = Index.getValueInfo(G);
140144

141145
// We need a unique definition, otherwise don't try further.

llvm/include/llvm/IR/GlobalValue.h

+14-9
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,11 @@ class GlobalValue : public Constant {
570570
return Name;
571571
}
572572

573+
/// Declare a type to represent a global unique identifier for a global value.
574+
/// This is a 64 bits hash that is used by PGO and ThinLTO to have a compact
575+
/// unique way to identify a symbol.
576+
using GUID = uint64_t;
577+
573578
/// Return the modified name for a global value suitable to be
574579
/// used as the key for a global lookup (e.g. profile or ThinLTO).
575580
/// The value's original name is \c Name and has linkage of type
@@ -578,22 +583,22 @@ class GlobalValue : public Constant {
578583
GlobalValue::LinkageTypes Linkage,
579584
StringRef FileName);
580585

586+
private:
581587
/// Return the modified name for this global value suitable to be
582588
/// used as the key for a global lookup (e.g. profile or ThinLTO).
583589
std::string getGlobalIdentifier() const;
584590

585-
/// Declare a type to represent a global unique identifier for a global value.
586-
/// This is a 64 bits hash that is used by PGO and ThinLTO to have a compact
587-
/// unique way to identify a symbol.
588-
using GUID = uint64_t;
589-
590-
/// Return a 64-bit global unique ID constructed from global value name
591-
/// (i.e. returned by getGlobalIdentifier()).
592-
static GUID getGUID(StringRef GlobalName);
591+
public:
592+
/// Return a 64-bit global unique ID constructed from the name of a global
593+
/// symbol. Since this call doesn't supply the linkage or defining filename,
594+
/// the GUID computation will assume that the global has external linkage.
595+
static GUID getGUIDAssumingExternalLinkage(StringRef GlobalName);
593596

594597
/// Return a 64-bit global unique ID constructed from global value name
595598
/// (i.e. returned by getGlobalIdentifier()).
596-
GUID getGUID() const { return getGUID(getGlobalIdentifier()); }
599+
GUID getGUID() const {
600+
return getGUIDAssumingExternalLinkage(getGlobalIdentifier());
601+
}
597602

598603
/// @name Materialization
599604
/// Materialization is used to construct functions only as they're needed.

llvm/include/llvm/IR/ModuleSummaryIndex.h

+15-10
Original file line numberDiff line numberDiff line change
@@ -1321,14 +1321,14 @@ class CfiFunctionIndex {
13211321

13221322
template <typename... Args> void emplace(Args &&...A) {
13231323
StringRef S(std::forward<Args>(A)...);
1324-
GlobalValue::GUID GUID =
1325-
GlobalValue::getGUID(GlobalValue::dropLLVMManglingEscape(S));
1324+
GlobalValue::GUID GUID = GlobalValue::getGUIDAssumingExternalLinkage(
1325+
GlobalValue::dropLLVMManglingEscape(S));
13261326
Index[GUID].emplace(S);
13271327
}
13281328

13291329
size_t count(StringRef S) const {
1330-
GlobalValue::GUID GUID =
1331-
GlobalValue::getGUID(GlobalValue::dropLLVMManglingEscape(S));
1330+
GlobalValue::GUID GUID = GlobalValue::getGUIDAssumingExternalLinkage(
1331+
GlobalValue::dropLLVMManglingEscape(S));
13321332
auto I = Index.find(GUID);
13331333
if (I == Index.end())
13341334
return 0;
@@ -1731,8 +1731,10 @@ class ModuleSummaryIndex {
17311731
/// Add a global value summary for a value of the given name.
17321732
void addGlobalValueSummary(StringRef ValueName,
17331733
std::unique_ptr<GlobalValueSummary> Summary) {
1734-
addGlobalValueSummary(getOrInsertValueInfo(GlobalValue::getGUID(ValueName)),
1735-
std::move(Summary));
1734+
addGlobalValueSummary(
1735+
getOrInsertValueInfo(
1736+
GlobalValue::getGUIDAssumingExternalLinkage(ValueName)),
1737+
std::move(Summary));
17361738
}
17371739

17381740
/// Add a global value summary for the given ValueInfo.
@@ -1869,19 +1871,22 @@ class ModuleSummaryIndex {
18691871
/// This accessor can mutate the map and therefore should not be used in
18701872
/// the ThinLTO backends.
18711873
TypeIdSummary &getOrInsertTypeIdSummary(StringRef TypeId) {
1872-
auto TidIter = TypeIdMap.equal_range(GlobalValue::getGUID(TypeId));
1874+
auto TidIter = TypeIdMap.equal_range(
1875+
GlobalValue::getGUIDAssumingExternalLinkage(TypeId));
18731876
for (auto &[GUID, TypeIdPair] : make_range(TidIter))
18741877
if (TypeIdPair.first == TypeId)
18751878
return TypeIdPair.second;
1876-
auto It = TypeIdMap.insert({GlobalValue::getGUID(TypeId),
1877-
{TypeIdSaver.save(TypeId), TypeIdSummary()}});
1879+
auto It =
1880+
TypeIdMap.insert({GlobalValue::getGUIDAssumingExternalLinkage(TypeId),
1881+
{TypeIdSaver.save(TypeId), TypeIdSummary()}});
18781882
return It->second.second;
18791883
}
18801884

18811885
/// This returns either a pointer to the type id summary (if present in the
18821886
/// summary map) or null (if not present). This may be used when importing.
18831887
const TypeIdSummary *getTypeIdSummary(StringRef TypeId) const {
1884-
auto TidIter = TypeIdMap.equal_range(GlobalValue::getGUID(TypeId));
1888+
auto TidIter = TypeIdMap.equal_range(
1889+
GlobalValue::getGUIDAssumingExternalLinkage(TypeId));
18851890
for (const auto &[GUID, TypeIdPair] : make_range(TidIter))
18861891
if (TypeIdPair.first == TypeId)
18871892
return &TypeIdPair.second;

llvm/include/llvm/IR/ModuleSummaryIndexYAML.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ template <> struct CustomMappingTraits<TypeIdSummaryMapTy> {
314314
static void inputOne(IO &io, StringRef Key, TypeIdSummaryMapTy &V) {
315315
TypeIdSummary TId;
316316
io.mapRequired(Key.str().c_str(), TId);
317-
V.insert({GlobalValue::getGUID(Key), {Key, TId}});
317+
V.insert({GlobalValue::getGUIDAssumingExternalLinkage(Key), {Key, TId}});
318318
}
319319
static void output(IO &io, TypeIdSummaryMapTy &V) {
320320
for (auto &TidIter : V)

llvm/include/llvm/ProfileData/SampleProf.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1299,7 +1299,7 @@ class FunctionSamples {
12991299
static inline FunctionId getRepInFormat(StringRef Name) {
13001300
if (Name.empty() || !FunctionSamples::UseMD5)
13011301
return FunctionId(Name);
1302-
return FunctionId(Function::getGUID(Name));
1302+
return FunctionId(Function::getGUIDAssumingExternalLinkage(Name));
13031303
}
13041304

13051305
raw_ostream &operator<<(raw_ostream &OS, const FunctionSamples &FS);

llvm/include/llvm/Transforms/Utils/SampleProfileLoaderBaseImpl.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,12 @@ class PseudoProbeManager {
109109
}
110110

111111
const PseudoProbeDescriptor *getDesc(StringRef FProfileName) const {
112-
return getDesc(Function::getGUID(FProfileName));
112+
return getDesc(Function::getGUIDAssumingExternalLinkage(FProfileName));
113113
}
114114

115115
const PseudoProbeDescriptor *getDesc(const Function &F) const {
116-
return getDesc(Function::getGUID(FunctionSamples::getCanonicalFnName(F)));
116+
return getDesc(Function::getGUIDAssumingExternalLinkage(
117+
FunctionSamples::getCanonicalFnName(F)));
117118
}
118119

119120
bool profileIsHashMismatched(const PseudoProbeDescriptor &FuncDesc,

llvm/lib/Analysis/CtxProfAnalysis.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ PreservedAnalyses AssignGUIDPass::run(Module &M, ModuleAnalysisManager &MAM) {
436436
GlobalValue::GUID AssignGUIDPass::getGUID(const Function &F) {
437437
if (F.isDeclaration()) {
438438
assert(GlobalValue::isExternalLinkage(F.getLinkage()));
439-
return GlobalValue::getGUID(F.getGlobalIdentifier());
439+
return F.getGUID();
440440
}
441441
auto *MD = F.getMetadata(GUIDMetadataName);
442442
assert(MD && "guid not found for defined function");

llvm/lib/Analysis/ModuleSummaryAnalysis.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,8 @@ static void addIntrinsicToSummary(
222222
auto *TypeId = dyn_cast<MDString>(TypeMDVal->getMetadata());
223223
if (!TypeId)
224224
break;
225-
GlobalValue::GUID Guid = GlobalValue::getGUID(TypeId->getString());
225+
GlobalValue::GUID Guid =
226+
GlobalValue::getGUIDAssumingExternalLinkage(TypeId->getString());
226227

227228
// Produce a summary from type.test intrinsics. We only summarize type.test
228229
// intrinsics that are used other than by an llvm.assume intrinsic.
@@ -250,7 +251,8 @@ static void addIntrinsicToSummary(
250251
auto *TypeId = dyn_cast<MDString>(TypeMDVal->getMetadata());
251252
if (!TypeId)
252253
break;
253-
GlobalValue::GUID Guid = GlobalValue::getGUID(TypeId->getString());
254+
GlobalValue::GUID Guid =
255+
GlobalValue::getGUIDAssumingExternalLinkage(TypeId->getString());
254256

255257
SmallVector<DevirtCallSite, 4> DevirtCalls;
256258
SmallVector<Instruction *, 4> LoadedPtrs;
@@ -904,7 +906,8 @@ static void computeAliasSummary(ModuleSummaryIndex &Index, const GlobalAlias &A,
904906

905907
// Set LiveRoot flag on entries matching the given value name.
906908
static void setLiveRoot(ModuleSummaryIndex &Index, StringRef Name) {
907-
if (ValueInfo VI = Index.getValueInfo(GlobalValue::getGUID(Name)))
909+
if (ValueInfo VI =
910+
Index.getValueInfo(GlobalValue::getGUIDAssumingExternalLinkage(Name)))
908911
for (const auto &Summary : VI.getSummaryList())
909912
Summary->setLive(true);
910913
}

llvm/lib/AsmParser/LLParser.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -9049,7 +9049,7 @@ bool LLParser::parseTypeIdEntry(unsigned ID) {
90499049
for (auto TIDRef : FwdRefTIDs->second) {
90509050
assert(!*TIDRef.first &&
90519051
"Forward referenced type id GUID expected to be 0");
9052-
*TIDRef.first = GlobalValue::getGUID(Name);
9052+
*TIDRef.first = GlobalValue::getGUIDAssumingExternalLinkage(Name);
90539053
}
90549054
ForwardRefTypeIds.erase(FwdRefTIDs);
90559055
}
@@ -9154,7 +9154,7 @@ bool LLParser::parseTypeIdCompatibleVtableEntry(unsigned ID) {
91549154
for (auto TIDRef : FwdRefTIDs->second) {
91559155
assert(!*TIDRef.first &&
91569156
"Forward referenced type id GUID expected to be 0");
9157-
*TIDRef.first = GlobalValue::getGUID(Name);
9157+
*TIDRef.first = GlobalValue::getGUIDAssumingExternalLinkage(Name);
91589158
}
91599159
ForwardRefTypeIds.erase(FwdRefTIDs);
91609160
}
@@ -9470,7 +9470,7 @@ bool LLParser::addGlobalValueToIndex(
94709470
assert(
94719471
(!GlobalValue::isLocalLinkage(Linkage) || !SourceFileName.empty()) &&
94729472
"Need a source_filename to compute GUID for local");
9473-
GUID = GlobalValue::getGUID(
9473+
GUID = GlobalValue::getGUIDAssumingExternalLinkage(
94749474
GlobalValue::getGlobalIdentifier(Name, Linkage, SourceFileName));
94759475
VI = Index->getOrInsertValueInfo(GUID, Index->saveString(Name));
94769476
}

llvm/lib/Bitcode/Reader/BitcodeReader.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -7166,10 +7166,10 @@ void ModuleSummaryIndexBitcodeReader::setValueGUID(
71667166
StringRef SourceFileName) {
71677167
std::string GlobalId =
71687168
GlobalValue::getGlobalIdentifier(ValueName, Linkage, SourceFileName);
7169-
auto ValueGUID = GlobalValue::getGUID(GlobalId);
7169+
auto ValueGUID = GlobalValue::getGUIDAssumingExternalLinkage(GlobalId);
71707170
auto OriginalNameID = ValueGUID;
71717171
if (GlobalValue::isLocalLinkage(Linkage))
7172-
OriginalNameID = GlobalValue::getGUID(ValueName);
7172+
OriginalNameID = GlobalValue::getGUIDAssumingExternalLinkage(ValueName);
71737173
if (PrintSummaryGUIDs)
71747174
dbgs() << "GUID " << ValueGUID << "(" << OriginalNameID << ") is "
71757175
<< ValueName << "\n";

llvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ void PseudoProbeHandler::emitPseudoProbe(uint64_t Guid, uint64_t Index,
3434
// Use caching to avoid redundant md5 computation for build speed.
3535
uint64_t &CallerGuid = NameGuidMap[Name];
3636
if (!CallerGuid)
37-
CallerGuid = Function::getGUID(Name);
37+
CallerGuid = Function::getGUIDAssumingExternalLinkage(Name);
3838
uint64_t CallerProbeId = PseudoProbeDwarfDiscriminator::extractProbeIndex(
3939
InlinedAt->getDiscriminator());
4040
ReversedInlineStack.emplace_back(CallerGuid, CallerProbeId);

llvm/lib/CodeGen/PseudoProbeInserter.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class PseudoProbeInserter : public MachineFunctionPass {
129129
private:
130130
uint64_t getFuncGUID(Module *M, DILocation *DL) {
131131
auto Name = DL->getSubprogramLinkageName();
132-
return Function::getGUID(Name);
132+
return Function::getGUIDAssumingExternalLinkage(Name);
133133
}
134134

135135
bool ShouldRun = false;

llvm/lib/IR/AsmWriter.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -3226,7 +3226,7 @@ void AssemblyWriter::printModuleSummaryIndex() {
32263226

32273227
// Print the TypeIdCompatibleVtableMap entries.
32283228
for (auto &TId : TheIndex->typeIdCompatibleVtableMap()) {
3229-
auto GUID = GlobalValue::getGUID(TId.first);
3229+
auto GUID = GlobalValue::getGUIDAssumingExternalLinkage(TId.first);
32303230
Out << "^" << Machine.getTypeIdCompatibleVtableSlot(TId.first)
32313231
<< " = typeidCompatibleVTable: (name: \"" << TId.first << "\"";
32323232
printTypeIdCompatibleVtableSummary(TId.second);

llvm/lib/IR/Globals.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,9 @@ void GlobalValue::copyAttributesFrom(const GlobalValue *Src) {
7373
removeSanitizerMetadata();
7474
}
7575

76-
GlobalValue::GUID GlobalValue::getGUID(StringRef GlobalName) {
77-
return MD5Hash(GlobalName);
76+
GlobalValue::GUID
77+
GlobalValue::getGUIDAssumingExternalLinkage(StringRef GlobalIdentifier) {
78+
return MD5Hash(GlobalIdentifier);
7879
}
7980

8081
void GlobalValue::removeFromParent() {

llvm/lib/LTO/LTO.cpp

+8-6
Original file line numberDiff line numberDiff line change
@@ -1043,8 +1043,9 @@ Error LTO::addThinLTO(BitcodeModule BM, ArrayRef<InputFile::Symbol> Syms,
10431043
SymbolResolution Res = *ResITmp++;
10441044

10451045
if (!Sym.getIRName().empty()) {
1046-
auto GUID = GlobalValue::getGUID(GlobalValue::getGlobalIdentifier(
1047-
Sym.getIRName(), GlobalValue::ExternalLinkage, ""));
1046+
auto GUID = GlobalValue::getGUIDAssumingExternalLinkage(
1047+
GlobalValue::getGlobalIdentifier(Sym.getIRName(),
1048+
GlobalValue::ExternalLinkage, ""));
10481049
if (Res.Prevailing)
10491050
ThinLTO.PrevailingModuleForGUID[GUID] = BM.getModuleIdentifier();
10501051
}
@@ -1064,8 +1065,9 @@ Error LTO::addThinLTO(BitcodeModule BM, ArrayRef<InputFile::Symbol> Syms,
10641065
SymbolResolution Res = *ResI++;
10651066

10661067
if (!Sym.getIRName().empty()) {
1067-
auto GUID = GlobalValue::getGUID(GlobalValue::getGlobalIdentifier(
1068-
Sym.getIRName(), GlobalValue::ExternalLinkage, ""));
1068+
auto GUID = GlobalValue::getGUIDAssumingExternalLinkage(
1069+
GlobalValue::getGlobalIdentifier(Sym.getIRName(),
1070+
GlobalValue::ExternalLinkage, ""));
10691071
if (Res.Prevailing) {
10701072
assert(ThinLTO.PrevailingModuleForGUID[GUID] ==
10711073
BM.getModuleIdentifier());
@@ -1174,7 +1176,7 @@ Error LTO::run(AddStreamFn AddStream, FileCache Cache) {
11741176
if (Res.second.IRName.empty())
11751177
continue;
11761178

1177-
GlobalValue::GUID GUID = GlobalValue::getGUID(
1179+
GlobalValue::GUID GUID = GlobalValue::getGUIDAssumingExternalLinkage(
11781180
GlobalValue::dropLLVMManglingEscape(Res.second.IRName));
11791181

11801182
if (Res.second.VisibleOutsideSummary && Res.second.Prevailing)
@@ -1950,7 +1952,7 @@ Error LTO::runThinLTO(AddStreamFn AddStream, FileCache Cache,
19501952
if (Res.second.Partition != GlobalResolution::External ||
19511953
!Res.second.isPrevailingIRSymbol())
19521954
continue;
1953-
auto GUID = GlobalValue::getGUID(
1955+
auto GUID = GlobalValue::getGUIDAssumingExternalLinkage(
19541956
GlobalValue::dropLLVMManglingEscape(Res.second.IRName));
19551957
// Mark exported unless index-based analysis determined it to be dead.
19561958
if (ThinLTO.CombinedIndex.isGUIDLive(GUID))

llvm/lib/LTO/ThinLTOCodeGenerator.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,8 @@ addUsedSymbolToPreservedGUID(const lto::InputFile &File,
295295
DenseSet<GlobalValue::GUID> &PreservedGUID) {
296296
for (const auto &Sym : File.symbols()) {
297297
if (Sym.isUsed())
298-
PreservedGUID.insert(GlobalValue::getGUID(Sym.getIRName()));
298+
PreservedGUID.insert(
299+
GlobalValue::getGUIDAssumingExternalLinkage(Sym.getIRName()));
299300
}
300301
}
301302

@@ -308,8 +309,9 @@ static void computeGUIDPreservedSymbols(const lto::InputFile &File,
308309
// compute the GUID for the symbol.
309310
for (const auto &Sym : File.symbols()) {
310311
if (PreservedSymbols.count(Sym.getName()) && !Sym.getIRName().empty())
311-
GUIDs.insert(GlobalValue::getGUID(GlobalValue::getGlobalIdentifier(
312-
Sym.getIRName(), GlobalValue::ExternalLinkage, "")));
312+
GUIDs.insert(GlobalValue::getGUIDAssumingExternalLinkage(
313+
GlobalValue::getGlobalIdentifier(Sym.getIRName(),
314+
GlobalValue::ExternalLinkage, "")));
313315
}
314316
}
315317

llvm/lib/ProfileData/InstrProf.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -557,8 +557,8 @@ Error InstrProfSymtab::addVTableWithName(GlobalVariable &VTable,
557557
return E;
558558

559559
bool Inserted = true;
560-
std::tie(std::ignore, Inserted) =
561-
MD5VTableMap.try_emplace(GlobalValue::getGUID(Name), &VTable);
560+
std::tie(std::ignore, Inserted) = MD5VTableMap.try_emplace(
561+
GlobalValue::getGUIDAssumingExternalLinkage(Name), &VTable);
562562
if (!Inserted)
563563
LLVM_DEBUG(dbgs() << "GUID conflict within one module");
564564
return Error::success();
@@ -676,7 +676,7 @@ Error InstrProfSymtab::addFuncWithName(Function &F, StringRef PGOFuncName,
676676
auto NameToGUIDMap = [&](StringRef Name) -> Error {
677677
if (Error E = addFuncName(Name))
678678
return E;
679-
MD5FuncMap.emplace_back(Function::getGUID(Name), &F);
679+
MD5FuncMap.emplace_back(Function::getGUIDAssumingExternalLinkage(Name), &F);
680680
return Error::success();
681681
};
682682
if (Error E = NameToGUIDMap(PGOFuncName))

0 commit comments

Comments
 (0)