[clang] [Hlsl][Spirv] Don't emit global variables for structs containing resources (PR #234797)
Helena Kotas via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 6 16:00:45 PST 2026
================
@@ -0,0 +1,24 @@
+// When processing a struct containing resources, we should split members recursively into
+// their own global variables, and not emit a global of struct or array of
+// struct type which contains a resource
+
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s --implicit-check-not='@g =' --implicit-check-not='@array ='
+// RUN: %clang_cc1 -triple spirv1.6-unknown-vulkan1.3-compute -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s --implicit-check-not='@g =' --implicit-check-not='@array ='
+// RUN: %if spirv-registered-target && spirv-val %{ %clang_cc1 -triple spirv1.6-unknown-vulkan1.3-compute -O3 -emit-obj -o %t.spv %s && spirv-val --target-env vulkan1.3 %t.spv %}
+
+// CHECK: @_ZL5g.Buf = internal global
+// CHECK: @_ZL11array.0.Buf = internal global
+// CHECK: @_ZL11array.1.Buf = internal global
----------------
hekota wrote:
Are you missing a `CHECK-NOT` for the `g` and `array` globals? Otherwise, I think this test succeeds even without your change.
https://github.com/llvm/llvm-project/pull/234797
More information about the cfe-commits
mailing list