[clang] [Clang][LTO] Assign GUIDs after post-opt bitcode linking (PR #211155)
Shilei Tian via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 21 18:48:45 PDT 2026
https://github.com/shiltian created https://github.com/llvm/llvm-project/pull/211155
Run AssignGUIDPass after LinkInModulesPass so newly linked globals have
GUIDs before LTO summary emission.
>From cd9537fde57c50aa92987d96b451a659b6f18054 Mon Sep 17 00:00:00 2001
From: Shilei Tian <i at tianshilei.me>
Date: Tue, 21 Jul 2026 21:48:12 -0400
Subject: [PATCH] [Clang][LTO] Assign GUIDs after post-opt bitcode linking
Run AssignGUIDPass after LinkInModulesPass so newly linked globals have
GUIDs before LTO summary emission.
---
clang/lib/CodeGen/BackendUtil.cpp | 5 ++++-
clang/test/CodeGen/linking-bitcode-postopt.cpp | 2 +-
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp
index 2b755fa916e55..068b1b4c262c8 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -91,6 +91,7 @@
#include "llvm/Transforms/Scalar/EarlyCSE.h"
#include "llvm/Transforms/Scalar/GVN.h"
#include "llvm/Transforms/Scalar/JumpThreading.h"
+#include "llvm/Transforms/Utils/AssignGUID.h"
#include "llvm/Transforms/Utils/Debugify.h"
#include "llvm/Transforms/Utils/ModuleUtils.h"
#include <limits>
@@ -1139,8 +1140,10 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
}
// Link against bitcodes supplied via the -mlink-builtin-bitcode option
- if (CodeGenOpts.LinkBitcodePostopt)
+ if (CodeGenOpts.LinkBitcodePostopt) {
MPM.addPass(LinkInModulesPass(BC));
+ MPM.addPass(AssignGUIDPass());
+ }
if (LangOpts.HIPStdPar && !LangOpts.CUDAIsDevice &&
LangOpts.HIPStdParInterposeAlloc)
diff --git a/clang/test/CodeGen/linking-bitcode-postopt.cpp b/clang/test/CodeGen/linking-bitcode-postopt.cpp
index a0486ed0c9a83..0b0026d25a9c9 100644
--- a/clang/test/CodeGen/linking-bitcode-postopt.cpp
+++ b/clang/test/CodeGen/linking-bitcode-postopt.cpp
@@ -13,7 +13,7 @@
// RUN: -mlink-builtin-bitcode-postopt \
// RUN: %s 2>&1 | FileCheck --check-prefixes=OPTION-POSITIVE %s
-// OPTION-POSITIVE: LinkInModulesPass
+// OPTION-POSITIVE: LinkInModulesPass,assign-guid
// RUN: %clang_cc1 -triple amdgcn-- -emit-llvm-bc -o /dev/null \
// RUN: -mllvm -print-pipeline-passes \
More information about the cfe-commits
mailing list