[llvm] [SPIRV] Emit intrinsics for globals only in function that references them (PR #178143)

Marcos Maronas via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 28 03:12:37 PST 2026


Juan Manuel Martinez =?utf-8?q?Caamaño?=,
Juan Manuel Martinez =?utf-8?q?Caamaño?Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/178143 at github.com>


================
@@ -62,6 +62,83 @@ namespace llvm::SPIRV {
 } // namespace llvm::SPIRV
 
 namespace {
+// This class keeps track of which functions reference which global variables.
+class GlobalVariableReferences {
+  template <typename T1, typename T2>
+  using OneToManyMapTy = DenseMap<T1, SmallPtrSet<T2, 4>>;
+
+  OneToManyMapTy<GlobalVariable *, Function *> GlobalIsReferencedByFun;
+
+  void collectGlobalReferences(
+      GlobalVariable *GV,
----------------
maarquitos14 wrote:

Can we make it `const`? It shouldn't be modified here and it conveys the intention clearly.

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


More information about the llvm-commits mailing list