[clang] [llvm] Compute GUIDs once and store in metadata (PR #184065)

Owen Rodley via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 14 22:49:22 PDT 2026


================
@@ -4612,12 +4590,22 @@ void ModuleBitcodeWriterBase::writePerModuleFunctionSummaryRecord(
       /*WriteContextSizeInfoIndex*/ true, CallStackPos, CallStackCount);
 }
 
+static GlobalValue::GUID getOrComputeGUID(const GlobalValue &V) {
+  auto MaybeGUID = V.getGUIDIfAssigned();
+  return MaybeGUID ? *MaybeGUID
+                   : GlobalValue::getGUIDAssumingExternalLinkage(V.getName());
+}
+
 // Collect the global value references in the given variable's initializer,
 // and emit them in a summary record.
 void ModuleBitcodeWriterBase::writeModuleLevelReferences(
     const GlobalVariable &V, SmallVector<uint64_t, 64> &NameVals,
     unsigned FSModRefsAbbrev, unsigned FSModVTableRefsAbbrev) {
-  auto VI = Index->getValueInfo(V.getGUID());
+  // Be a little lenient here, to accomodate older files without GUIDs
----------------
orodley wrote:

Mainly for tests, but I recall from our discussions that we also want to be backwards-compatible with old bitcode files?

https://github.com/llvm/llvm-project/pull/184065


More information about the cfe-commits mailing list