[llvm-branch-commits] [clang] [HLSL] Introduce address space `hlsl_constant(2)` for constant buffer declarations (PR #123411)

Helena Kotas via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Jan 22 10:36:34 PST 2025


================
@@ -1,16 +1,21 @@
 // RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.3-library %s \
 // RUN:   -emit-llvm -disable-llvm-passes -o - | FileCheck %s
 
-// CHECK-DAG: @[[CB:.+]] = external constant { float }
+// RUN: %clang_cc1 -finclude-default-header -triple spirv-pc-vulkan-library %s \
+// RUN:   -emit-llvm -disable-llvm-passes -o - | FileCheck %s
 
 cbuffer A {
-    float a;
-  // CHECK-DAG:@_ZL1b = internal global float 3.000000e+00, align 4
+  // CHECK: @a = external addrspace(2) externally_initialized global float, align 4
+  float a;
+  // CHECK: @_ZL1b = internal global float 3.000000e+00, align 4
   static float b = 3;
----------------
hekota wrote:

Ideally no, but DXC currently allows it (https://godbolt.org/z/G6G4eob7b) and at this point Clang does as well.
We have an issue tracking it here: https://github.com/llvm/llvm-project/issues/118524

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


More information about the llvm-branch-commits mailing list