[clang] [CIR] Emit OpenCL file scope global variables (PR #228125)
Steffen Larsen via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 1 23:34:11 PDT 2026
================
@@ -11,6 +11,21 @@
typedef global int *global_int_ptr;
+constant int const_gv = 42;
+global int global_gv = 7;
+global int tentative_gv;
+const sampler_t sampler_gv = 0;
+
+// CIR-DAG: cir.global constant external lang_address_space(offload_constant) @const_gv = #cir.int<42> : !s32i
+// CIR-DAG: cir.global external lang_address_space(offload_global) @global_gv = #cir.int<7> : !s32i
+// CIR-DAG: cir.global external lang_address_space(offload_global) @tentative_gv = #cir.int<0> : !s32i
+// CIR-NOT: @sampler_gv
+
+// LLVM-DAG: @const_gv = addrspace(2) constant i32 42
+// LLVM-DAG: @global_gv = addrspace(1) global i32 7
+// LLVM-DAG: @tentative_gv = addrspace(1) global i32 0
+// LLVM-NOT: @sampler_gv
----------------
steffenlarsen wrote:
Though they do carry address spaces and that is relevant in on itself, I think it would either be more fitting to have these in their own test or have a global variable test as well.
https://github.com/llvm/llvm-project/pull/228125
More information about the cfe-commits
mailing list