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

Teresa Johnson via cfe-commits cfe-commits at lists.llvm.org
Fri May 1 12:17:02 PDT 2026


================
@@ -4920,6 +4935,38 @@ void ModuleBitcodeWriterBase::writePerModuleGlobalValueSummary() {
   Stream.ExitBlock();
 }
 
+void ModuleBitcodeWriterBase::writeGUIDList() {
+  const ValueEnumerator::ValueList &Vals = VE.getValues();
+  const size_t Max = Vals.size();
+
+  std::vector<GlobalValue::GUID> GUIDs(Max, 0);
+  for (const GlobalValue &GV : M.global_values()) {
+    GlobalValue::GUID GUID;
+    if (auto MaybeGUID = GV.getGUIDIfAssigned(); MaybeGUID)
+      GUID = *MaybeGUID;
+    else
+      continue;
----------------
teresajohnson wrote:

Restructure this so you do the continue first to simplify the control flow.

I.e.

auto MaybeGUID = GV.getGUIDIfAssigned();
if (!MaybeGUID)
  continue;

GUID = *MaybeGUID;



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


More information about the cfe-commits mailing list