[clang] [llvm] [HLSL][NFC] Update resource metadata tests to not use obsolete annotations (PR #130222)
Helena Kotas via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 10 18:17:02 PDT 2025
https://github.com/hekota updated https://github.com/llvm/llvm-project/pull/130222
>From 99539251dcf58aab9a88973f9162156ae6f1aa77 Mon Sep 17 00:00:00 2001
From: Helena Kotas <hekotas at microsoft.com>
Date: Thu, 6 Mar 2025 18:22:07 -0800
Subject: [PATCH 1/3] [HLSL][NFC] Update resource metadata tests to not use
obsolete metadata annotations
---
clang/test/CodeGenHLSL/cbuffer.hlsl | 78 +++++++++-
.../DirectX/Metadata/cbuffer_metadata.ll | 80 +++++++++++
.../CodeGen/DirectX/Metadata/srv_metadata.ll | 103 +++++++++++++
.../CodeGen/DirectX/Metadata/uav_metadata.ll | 135 ++++++++++++++++++
llvm/test/CodeGen/DirectX/UAVMetadata.ll | 77 ----------
llvm/test/CodeGen/DirectX/cbuf.ll | 37 -----
.../CodeGen/DirectX/legacy_cb_layout_0.ll | 14 --
.../CodeGen/DirectX/legacy_cb_layout_1.ll | 37 -----
.../CodeGen/DirectX/legacy_cb_layout_2.ll | 51 -------
.../CodeGen/DirectX/legacy_cb_layout_3.ll | 81 -----------
10 files changed, 394 insertions(+), 299 deletions(-)
create mode 100644 llvm/test/CodeGen/DirectX/Metadata/cbuffer_metadata.ll
create mode 100644 llvm/test/CodeGen/DirectX/Metadata/srv_metadata.ll
create mode 100644 llvm/test/CodeGen/DirectX/Metadata/uav_metadata.ll
delete mode 100644 llvm/test/CodeGen/DirectX/UAVMetadata.ll
delete mode 100644 llvm/test/CodeGen/DirectX/cbuf.ll
delete mode 100644 llvm/test/CodeGen/DirectX/legacy_cb_layout_0.ll
delete mode 100644 llvm/test/CodeGen/DirectX/legacy_cb_layout_1.ll
delete mode 100644 llvm/test/CodeGen/DirectX/legacy_cb_layout_2.ll
delete mode 100644 llvm/test/CodeGen/DirectX/legacy_cb_layout_3.ll
diff --git a/clang/test/CodeGenHLSL/cbuffer.hlsl b/clang/test/CodeGenHLSL/cbuffer.hlsl
index 38093c6dfacd7..b5e435619438f 100644
--- a/clang/test/CodeGenHLSL/cbuffer.hlsl
+++ b/clang/test/CodeGenHLSL/cbuffer.hlsl
@@ -20,6 +20,14 @@
// CHECK: %anon = type <{ float }>
// CHECK: %anon.0 = type <{ <2 x i32> }>
+// CHECK: %__cblayout_CB_A = type <{ [2 x double], [3 x <3 x float>], float, [3 x double], half, [1 x <2 x double>], float, [2 x <3 x half>], <3 x half> }>
+// CHECK: %__cblayout_CB_B = type <{ [3 x <3 x double>], <3 x half> }>
+// CHECK: %__cblayout_CB_C = type <{ i32, target("dx.Layout", %F, 96, 0, 16, 28, 32, 56, 64, 80, 84, 90), half, target("dx.Layout", %G, 258, 0, 48, 64, 256), double }>
+
+// CHECK: %F = type <{ double, <3 x float>, float, <3 x double>, half, <2 x double>, float, <3 x half>, <3 x half> }>
+// CHECK: %G = type <{ target("dx.Layout", %E, 36, 0, 8, 16, 20, 22, 24, 32), [1 x float], [2 x target("dx.Layout", %F, 96, 0, 16, 28, 32, 56, 64, 80, 84, 90)], half }>
+// CHECK: %E = type <{ float, double, float, half, i16, i64, i32 }>
+
cbuffer CBScalars : register(b1, space5) {
float a1;
double a2;
@@ -155,6 +163,64 @@ cbuffer CBMix {
uint16_t f9;
};
+// CHECK: @CB_A.cb = external constant target("dx.CBuffer", target("dx.Layout", %__cblayout_CB_A, 188, 0, 32, 76, 80, 120, 128, 144, 160, 182))
+
+cbuffer CB_A {
+ double B0[2];
+ float3 B1[3];
+ float B2;
+ double B3[3];
+ half B4;
+ double2 B5[1];
+ float B6;
+ half3 B7[2];
+ half3 B8;
+}
+
+// CHECK: @CB_B.cb = external constant target("dx.CBuffer", target("dx.Layout", %__cblayout_CB_B, 94, 0, 88))
+cbuffer CB_B {
+ double3 B9[3];
+ half3 B10;
+}
+
+struct E {
+ float A0;
+ double A1;
+ float A2;
+ half A3;
+ int16_t A4;
+ int64_t A5;
+ int A6;
+};
+
+struct F {
+ double B0;
+ float3 B1;
+ float B2;
+ double3 B3;
+ half B4;
+ double2 B5;
+ float B6;
+ half3 B7;
+ half3 B8;
+};
+
+struct G {
+ E C0;
+ float C1[1];
+ F C2[2];
+ half C3;
+};
+
+// CHECK: @CB_C.cb = external constant target("dx.CBuffer", target("dx.Layout", %__cblayout_CB_C, 400, 0, 16, 112, 128, 392))
+cbuffer CB_C {
+ int D0;
+ F D1;
+ half D2;
+ G D3;
+ double D4;
+}
+
// CHECK: define internal void @_init_resource_CBScalars.cb()
// CHECK-NEXT: entry:
// CHECK-NEXT: %[[HANDLE1:.*]] = call target("dx.CBuffer", target("dx.Layout", %__cblayout_CBScalars, 56, 0, 8, 16, 24, 32, 36, 40, 48))
@@ -171,7 +237,7 @@ RWBuffer<float> Buf;
[numthreads(4,1,1)]
void main() {
- Buf[0] = a1 + b1.z + c1[2] + a.f1.y + f1;
+ Buf[0] = a1 + b1.z + c1[2] + a.f1.y + f1 + B1[0].x + B10.z + D1.B2;
}
// CHECK: define internal void @_GLOBAL__sub_I_cbuffer.hlsl()
@@ -179,7 +245,8 @@ void main() {
// CHECK-NEXT: call void @_init_resource_CBScalars.cb()
// CHECK-NEXT: call void @_init_resource_CBArrays.cb()
-// CHECK: !hlsl.cbs = !{![[CBSCALARS:[0-9]+]], ![[CBVECTORS:[0-9]+]], ![[CBARRAYS:[0-9]+]], ![[CBSTRUCTS:[0-9]+]], ![[CBMIX:[0-9]+]]}
+// CHECK: !hlsl.cbs = !{![[CBSCALARS:[0-9]+]], ![[CBVECTORS:[0-9]+]], ![[CBARRAYS:[0-9]+]], ![[CBSTRUCTS:[0-9]+]], ![[CBMIX:[0-9]+]],
+// CHECK-SAME: ![[CB_A:[0-9]+]], ![[CB_B:[0-9]+]], ![[CB_C:[0-9]+]]}
// CHECK: ![[CBSCALARS]] = !{ptr @CBScalars.cb, ptr addrspace(2) @a1, ptr addrspace(2) @a2, ptr addrspace(2) @a3, ptr addrspace(2) @a4,
// CHECK-SAME: ptr addrspace(2) @a5, ptr addrspace(2) @a6, ptr addrspace(2) @a7, ptr addrspace(2) @a8}
@@ -195,3 +262,10 @@ void main() {
// CHECK: ![[CBMIX]] = !{ptr @CBMix.cb, ptr addrspace(2) @test, ptr addrspace(2) @f1, ptr addrspace(2) @f2, ptr addrspace(2) @f3,
// CHECK-SAME: ptr addrspace(2) @f4, ptr addrspace(2) @f5, ptr addrspace(2) @f6, ptr addrspace(2) @f7, ptr addrspace(2) @f8, ptr addrspace(2) @f9}
+
+// CHECK: ![[CB_A]] = !{ptr @CB_A.cb, ptr addrspace(2) @B0, ptr addrspace(2) @B1, ptr addrspace(2) @B2, ptr addrspace(2) @B3, ptr addrspace(2) @B4,
+// CHECK-SAME: ptr addrspace(2) @B5, ptr addrspace(2) @B6, ptr addrspace(2) @B7, ptr addrspace(2) @B8}
+
+// CHECK: ![[CB_B]] = !{ptr @CB_B.cb, ptr addrspace(2) @B9, ptr addrspace(2) @B10}
+
+// CHECK: ![[CB_C]] = !{ptr @CB_C.cb, ptr addrspace(2) @D0, ptr addrspace(2) @D1, ptr addrspace(2) @D2, ptr addrspace(2) @D3, ptr addrspace(2) @D4}
diff --git a/llvm/test/CodeGen/DirectX/Metadata/cbuffer_metadata.ll b/llvm/test/CodeGen/DirectX/Metadata/cbuffer_metadata.ll
new file mode 100644
index 0000000000000..b3dda74bf8bbf
--- /dev/null
+++ b/llvm/test/CodeGen/DirectX/Metadata/cbuffer_metadata.ll
@@ -0,0 +1,80 @@
+; RUN: opt -S -dxil-translate-metadata < %s | FileCheck %s
+; RUN: opt -S --passes="dxil-pretty-printer" < %s 2>&1 | FileCheck %s --check-prefix=PRINT
+; RUN: llc %s --filetype=asm -o - < %s 2>&1 | FileCheck %s --check-prefixes=CHECK,PRINT
+
+target datalayout = "e-m:e-p:32:32-i1:32-i8:8-i16:16-i32:32-i64:64-f16:16-f32:32-f64:64-n8:16:32:64"
+target triple = "dxil-pc-shadermodel6.6-compute"
+
+%__cblayout_CB1 = type <{ float, i32, double, <2 x i32> }>
+ at CB1.cb = external constant target("dx.CBuffer", target("dx.Layout", %__cblayout_CB1, 24, 0, 4, 8, 16))
+
+%__cblayout_CB2 = type <{ float, double, float, half, i16, i64, i32 }>
+ at CB2.cb = external constant target("dx.CBuffer", target("dx.Layout", %__cblayout_CB2, 36, 0, 8, 16, 20, 22, 24, 32))
+
+%__cblayout_CB3 = type <{ double, <3 x float>, float, <3 x double>, half, <2 x double>, float, <3 x half>, <3 x half> }>
+ at CB3.cb = external constant target("dx.CBuffer", target("dx.Layout", %__cblayout_CB3, 96, 0, 16, 28, 32, 56, 64, 80, 84, 90))
+
+; PRINT:; Resource Bindings:
+; PRINT-NEXT:;
+; PRINT-NEXT:; Name Type Format Dim ID HLSL Bind Count
+; PRINT-NEXT:; ------------------------------ ---------- ------- ----------- ------- -------------- ------
+; PRINT-NEXT:; cbuffer NA NA CB0 cb0 1
+; PRINT-NEXT:; cbuffer NA NA CB1 cb1 1
+; PRINT-NEXT:; cbuffer NA NA CB2 cb5,space15 1
+
+define void @test() #0 {
+
+ ; cbuffer CB1 : register(b0) {
+ ; float a;
+ ; int b;
+ ; double c;
+ ; int2 d;
+ ; }
+ %CB1.cb_h = call target("dx.CBuffer", target("dx.Layout", %__cblayout_CB1, 24, 0, 4, 8, 16))
+ @llvm.dx.resource.handlefrombinding.tdx.CBuffer_tdx.Layout_s___cblayout_CB1s_24_0_4_8_16tt(
+ i32 0, i32 0, i32 1, i32 0, i1 false)
+ store target("dx.CBuffer", target("dx.Layout", %__cblayout_CB1, 24, 0, 4, 8, 16)) %CB1.cb_h, ptr @CB1.cb, align 4
+
+ ; cbuffer CB2 : register(b0) {
+ ; float a;
+ ; double b;
+ ; float c;
+ ; half d;
+ ; uint16_t e;
+ ; int64_t f;
+ ; int g;
+ ;}
+
+ %CB2.cb_h = call target("dx.CBuffer", target("dx.Layout", %__cblayout_CB2, 36, 0, 8, 16, 20, 22, 24, 32))
+ @llvm.dx.resource.handlefrombinding.tdx.CBuffer_tdx.Layout_s___cblayout_CB2s_36_0_8_16_20_22_24_32tt(
+ i32 0, i32 1, i32 1, i32 0, i1 false)
+ store target("dx.CBuffer", target("dx.Layout", %__cblayout_CB2, 36, 0, 8, 16, 20, 22, 24, 32)) %CB2.cb_h, ptr @CB2.cb, align 4
+
+ ; cbuffer CB3 : register(b5) {
+ ; double B0;
+ ; float3 B1;
+ ; float B2;
+ ; double3 B3;
+ ; half B4;
+ ; double2 B5;
+ ; float B6;
+ ; half3 B7;
+ ; half3 B8;
+ ; }
+ %CB3.cb_h = call target("dx.CBuffer", target("dx.Layout", %__cblayout_CB3, 96, 0, 16, 28, 32, 56, 64, 80, 84, 90))
+ @llvm.dx.resource.handlefrombinding.tdx.CBuffer_tdx.Layout_s___cblayout_CB3s_96_0_16_28_32_56_64_80_84_90tt(
+ i32 15, i32 5, i32 1, i32 0, i1 false)
+ store target("dx.CBuffer", target("dx.Layout", %__cblayout_CB3, 96, 0, 16, 28, 32, 56, 64, 80, 84, 90)) %CB3.cb_h, ptr @CB3.cb, align 4
+
+ ret void
+}
+
+attributes #0 = { noinline nounwind "hlsl.shader"="compute" }
+
+; CHECK: !dx.resources = !{[[ResList:[!][0-9]+]]}
+
+; CHECK: [[ResList]] = !{null, null, [[CBList:[!][0-9]+]], null}
+; CHECK: [[CBList]] = !{![[CB1:[0-9]+]], ![[CB2:[0-9]+]], ![[CB3:[0-9]+]]}
+; CHECK: ![[CB1]] = !{i32 0, ptr @0, !"", i32 0, i32 0, i32 1, i32 24, null}
+; CHECK: ![[CB2]] = !{i32 1, ptr @1, !"", i32 0, i32 1, i32 1, i32 36, null}
+; CHECK: ![[CB3]] = !{i32 2, ptr @2, !"", i32 15, i32 5, i32 1, i32 96, null}
diff --git a/llvm/test/CodeGen/DirectX/Metadata/srv_metadata.ll b/llvm/test/CodeGen/DirectX/Metadata/srv_metadata.ll
new file mode 100644
index 0000000000000..e1344035e01a7
--- /dev/null
+++ b/llvm/test/CodeGen/DirectX/Metadata/srv_metadata.ll
@@ -0,0 +1,103 @@
+; RUN: opt -S -dxil-translate-metadata < %s | FileCheck %s
+; RUN: opt -S --passes="dxil-pretty-printer" < %s 2>&1 | FileCheck %s --check-prefix=PRINT
+; RUN: llc %s --filetype=asm -o - < %s 2>&1 | FileCheck %s --check-prefixes=CHECK,PRINT
+
+target datalayout = "e-m:e-p:32:32-i1:32-i8:8-i16:16-i32:32-i64:64-f16:16-f32:32-f64:64-n8:16:32:64"
+target triple = "dxil-pc-shadermodel6.6-compute"
+
+%"class.hlsl::Buffer" = type { target("dx.TypedBuffer", <4 x half>, 0, 0, 0) }
+%"class.hlsl::Buffer.1" = type { target("dx.TypedBuffer", <2 x float>, 0, 0, 0) }
+%"class.hlsl::Buffer.2" = type { target("dx.TypedBuffer", double, 0, 0, 0) }
+%"class.hlsl::Buffer.3" = type { target("dx.TypedBuffer", i32, 0, 0, 1) }
+%"class.hlsl::ByteAddressBuffer" = type { target("dx.RawBuffer", i8, 0, 0) }
+%"class.hlsl::StructuredBuffer" = type { target("dx.RawBuffer", i16, 0, 0) }
+%"class.hlsl::Buffer.4" = type { target("dx.TypedBuffer", i64, 0, 0, 0) }
+
+ at Zero = internal global %"class.hlsl::Buffer" poison, align 4
+ at One = internal global %"class.hlsl::Buffer.1" poison, align 4
+ at Two = internal global %"class.hlsl::Buffer.2" poison, align 4
+ at Three = internal global %"class.hlsl::Buffer.3" poison, align 4
+ at Four = internal global %"class.hlsl::ByteAddressBuffer" poison, align 4
+ at Five = internal global %"class.hlsl::StructuredBuffer" poison, align 4
+ at Six = internal global %"class.hlsl::Buffer.4" poison, align 4
+
+; PRINT:; Resource Bindings:
+; PRINT-NEXT:;
+; PRINT-NEXT:; Name Type Format Dim ID HLSL Bind Count
+; PRINT-NEXT:; ------------------------------ ---------- ------- ----------- ------- -------------- ------
+; PRINT-NEXT:; SRV f16 buf T0 t0 1
+; PRINT-NEXT:; SRV f32 buf T1 t1 1
+; PRINT-NEXT:; SRV f64 buf T2 t2 1
+; PRINT-NEXT:; SRV i32 buf T3 t3 1
+; PRINT-NEXT:; SRV byte r/o T4 t5 1
+; PRINT-NEXT:; SRV struct r/o T5 t6 1
+; PRINT-NEXT:; SRV u64 buf T6 t10,space2 1
+
+define void @test() #0 {
+ ; RWBuffer<half4> Buf : register(u0)
+ %Zero_h = call target("dx.TypedBuffer", <4 x half>, 0, 0, 0)
+ @llvm.dx.resource.handlefrombinding.tdx.TypedBuffer_v4f16_0_0_0t(
+ i32 0, i32 0, i32 1, i32 0, i1 false)
+ store target("dx.TypedBuffer", <4 x half>, 0, 0, 0) %Zero_h, ptr @Zero, align 4
+
+ ; RWBuffer<float4> Buf : register(u1)
+ %One_h = call target("dx.TypedBuffer", <2 x float>, 0, 0, 0)
+ @llvm.dx.resource.handlefrombinding.tdx.TypedBuffer_v2f32_0_0_0t(
+ i32 0, i32 1, i32 1, i32 0, i1 false)
+ store target("dx.TypedBuffer", <2 x float>, 0, 0, 0) %One_h, ptr @One, align 4
+
+ ; RWBuffer<double> Two : register(u2);
+ %Two_h = call target("dx.TypedBuffer", double, 0, 0, 0)
+ @llvm.dx.resource.handlefrombinding.tdx.TypedBuffer_f64_0_0_0t(
+ i32 0, i32 2, i32 1, i32 0, i1 false)
+ store target("dx.TypedBuffer", double, 0, 0, 0) %Two_h, ptr @Two, align 4
+
+ ; RWBuffer<int4> Three : register(u3);
+ %Three_h = call target("dx.TypedBuffer", <4 x i32>, 0, 0, 1)
+ @llvm.dx.resource.handlefrombinding.tdx.TypedBuffer_i32_0_0_1t(
+ i32 0, i32 3, i32 1, i32 0, i1 false)
+ store target("dx.TypedBuffer", <4 x i32>, 0, 0, 1) %Three_h, ptr @Three, align 4
+
+ ; ByteAddressBuffer Four : register(u4)
+ %Four_h = call target("dx.RawBuffer", i8, 0, 0)
+ @llvm.dx.resource.handlefrombinding.tdx.RawBuffer_i8_0_0t(
+ i32 0, i32 5, i32 1, i32 0, i1 false)
+ store target("dx.RawBuffer", i8, 0, 0) %Four_h, ptr @Four, align 4
+
+; StructuredBuffer<int16_t> Five : register(u6);
+ %Five_h = call target("dx.RawBuffer", i16, 0, 0)
+ @llvm.dx.resource.handlefrombinding.tdx.RawBuffer_i16_0_0t(
+ i32 0, i32 6, i32 1, i32 0, i1 false)
+ store target("dx.RawBuffer", i16, 0, 0) %Five_h, ptr @Five, align 4
+
+ ; RWBuffer<double> Two : register(u2);
+ %Six_h = call target("dx.TypedBuffer", i64, 0, 0, 0)
+ @llvm.dx.resource.handlefrombinding.tdx.TypedBuffer_f64_0_0_0t(
+ i32 2, i32 10, i32 1, i32 0, i1 false)
+ store target("dx.TypedBuffer", i64, 0, 0, 0) %Six_h, ptr @Six, align 4
+
+ ret void
+}
+
+attributes #0 = { noinline nounwind "hlsl.shader"="compute" }
+
+; CHECK: !dx.resources = !{[[ResList:[!][0-9]+]]}
+
+; CHECK: [[ResList]] = !{[[SRVList:[!][0-9]+]], null, null, null}
+; CHECK: [[SRVList]] = !{![[Zero:[0-9]+]], ![[One:[0-9]+]], ![[Two:[0-9]+]],
+; CHECK-SAME: ![[Three:[0-9]+]], ![[Four:[0-9]+]], ![[Five:[0-9]+]],
+; CHECK-SAME: ![[Six:[0-9]+]]}
+
+; CHECK: ![[Zero]] = !{i32 0, ptr @0, !"", i32 0, i32 0, i32 1, i32 10, i32 0, ![[Half:[0-9]+]]}
+; CHECK: ![[Half]] = !{i32 0, i32 8}
+; CHECK: ![[One]] = !{i32 1, ptr @1, !"", i32 0, i32 1, i32 1, i32 10, i32 0, ![[Float:[0-9]+]]}
+; CHECK: ![[Float]] = !{i32 0, i32 9}
+; CHECK: ![[Two]] = !{i32 2, ptr @2, !"", i32 0, i32 2, i32 1, i32 10, i32 0, ![[Double:[0-9]+]]}
+; CHECK: ![[Double]] = !{i32 0, i32 10}
+; CHECK: ![[Three]] = !{i32 3, ptr @3, !"", i32 0, i32 3, i32 1, i32 10, i32 0, ![[I32:[0-9]+]]}
+; CHECK: ![[I32]] = !{i32 0, i32 4}
+; CHECK: ![[Four]] = !{i32 4, ptr @4, !"", i32 0, i32 5, i32 1, i32 11, i32 0, null}
+; CHECK: ![[Five]] = !{i32 5, ptr @5, !"", i32 0, i32 6, i32 1, i32 12, i32 0, ![[FiveStride:[0-9]+]]}
+; CHECK: ![[FiveStride]] = !{i32 1, i32 2}
+; CHECK: ![[Six]] = !{i32 6, ptr @6, !"", i32 2, i32 10, i32 1, i32 10, i32 0, ![[U64:[0-9]+]]}
+; CHECK: ![[U64]] = !{i32 0, i32 7}
diff --git a/llvm/test/CodeGen/DirectX/Metadata/uav_metadata.ll b/llvm/test/CodeGen/DirectX/Metadata/uav_metadata.ll
new file mode 100644
index 0000000000000..2c98c5d4a1809
--- /dev/null
+++ b/llvm/test/CodeGen/DirectX/Metadata/uav_metadata.ll
@@ -0,0 +1,135 @@
+; RUN: opt -S -dxil-translate-metadata < %s | FileCheck %s
+; RUN: opt -S --passes="dxil-pretty-printer" < %s 2>&1 | FileCheck %s --check-prefix=PRINT
+; RUN: llc %s --filetype=asm -o - < %s 2>&1 | FileCheck %s --check-prefixes=CHECK,PRINT
+
+target datalayout = "e-m:e-p:32:32-i1:32-i8:8-i16:16-i32:32-i64:64-f16:16-f32:32-f64:64-n8:16:32:64"
+target triple = "dxil-pc-shadermodel6.6-compute"
+
+%"class.hlsl::RWBuffer" = type { target("dx.TypedBuffer", <4 x half>, 1, 0, 0) }
+%"class.hlsl::RWBuffer.1" = type { target("dx.TypedBuffer", <2 x float>, 1, 0, 0) }
+%"class.hlsl::RWBuffer.2" = type { target("dx.TypedBuffer", double, 1, 0, 0) }
+%"class.hlsl::RWBuffer.3" = type { target("dx.TypedBuffer", i32, 1, 0, 1) }
+%"class.hlsl::RWByteAddressBuffer" = type { target("dx.RawBuffer", i8, 1, 0) }
+%"class.hlsl::RWStructuredBuffer" = type { target("dx.RawBuffer", i16, 1, 0) }
+%"class.hlsl::RasterizerOrderedBuffer" = type { target("dx.TypedBuffer", <4 x i32>, 1, 1, 1) }
+%"class.hlsl::RasterizerOrderedStructuredBuffer" = type { target("dx.RawBuffer", <4 x i32>, 1, 1) }
+%"class.hlsl::RasterizerOrderedByteAddressBuffer" = type { target("dx.RawBuffer", i8, 1, 1) }
+%"class.hlsl::RWBuffer.4" = type { target("dx.TypedBuffer", i64, 1, 0, 0) }
+
+ at Zero = internal global %"class.hlsl::RWBuffer" poison, align 4
+ at One = internal global %"class.hlsl::RWBuffer.1" poison, align 4
+ at Two = internal global %"class.hlsl::RWBuffer.2" poison, align 4
+ at Three = internal global %"class.hlsl::RWBuffer.3" poison, align 4
+ at Four = internal global %"class.hlsl::RWByteAddressBuffer" poison, align 4
+ at Five = internal global %"class.hlsl::RWStructuredBuffer" poison, align 4
+ at Six = internal global %"class.hlsl::RasterizerOrderedBuffer" poison, align 4
+ at Seven = internal global %"class.hlsl::RasterizerOrderedStructuredBuffer" poison, align 4
+ at Eight = internal global %"class.hlsl::RasterizerOrderedByteAddressBuffer" poison, align 4
+ at Nine = internal global %"class.hlsl::RWBuffer.4" poison, align 4
+
+; PRINT:; Resource Bindings:
+; PRINT-NEXT:;
+; PRINT-NEXT:; Name Type Format Dim ID HLSL Bind Count
+; PRINT-NEXT:; ------------------------------ ---------- ------- ----------- ------- -------------- ------
+; PRINT-NEXT:; UAV f16 buf U0 u0 1
+; PRINT-NEXT:; UAV f32 buf U1 u1 1
+; PRINT-NEXT:; UAV f64 buf U2 u2 1
+; PRINT-NEXT:; UAV i32 buf U3 u3 1
+; PRINT-NEXT:; UAV byte r/w U4 u5 1
+; PRINT-NEXT:; UAV struct r/w U5 u6 1
+; PRINT-NEXT:; UAV i32 buf U6 u7 1
+; PRINT-NEXT:; UAV struct r/w U7 u8 1
+; PRINT-NEXT:; UAV byte r/w U8 u9 1
+; PRINT-NEXT:; UAV u64 buf U9 u10,space2 1
+
+define void @test() #0 {
+ ; RWBuffer<half4> Zero : register(u0)
+ %Zero_h = call target("dx.TypedBuffer", <4 x half>, 1, 0, 0)
+ @llvm.dx.resource.handlefrombinding.tdx.TypedBuffer_v4f16_1_0_0t(
+ i32 0, i32 0, i32 1, i32 0, i1 false)
+ store target("dx.TypedBuffer", <4 x half>, 1, 0, 0) %Zero_h, ptr @Zero, align 4
+
+ ; RWBuffer<float4> One : register(u1)
+ %One_h = call target("dx.TypedBuffer", <2 x float>, 1, 0, 0)
+ @llvm.dx.resource.handlefrombinding.tdx.TypedBuffer_v2f32_1_0_0t(
+ i32 0, i32 1, i32 1, i32 0, i1 false)
+ store target("dx.TypedBuffer", <2 x float>, 1, 0, 0) %One_h, ptr @One, align 4
+
+ ; RWBuffer<double> Two : register(u2);
+ %Two_h = call target("dx.TypedBuffer", double, 1, 0, 0)
+ @llvm.dx.resource.handlefrombinding.tdx.TypedBuffer_f64_1_0_0t(
+ i32 0, i32 2, i32 1, i32 0, i1 false)
+ store target("dx.TypedBuffer", double, 1, 0, 0) %Two_h, ptr @Two, align 4
+
+ ; RWBuffer<int4> Three : register(u3);
+ %Three_h = call target("dx.TypedBuffer", <4 x i32>, 1, 0, 1)
+ @llvm.dx.resource.handlefrombinding.tdx.TypedBuffer_i32_1_0_1t(
+ i32 0, i32 3, i32 1, i32 0, i1 false)
+ store target("dx.TypedBuffer", <4 x i32>, 1, 0, 1) %Three_h, ptr @Three, align 4
+
+ ; ByteAddressBuffer Four : register(u5)
+ %Four_h = call target("dx.RawBuffer", i8, 1, 0)
+ @llvm.dx.resource.handlefrombinding.tdx.RawBuffer_i8_1_0t(
+ i32 0, i32 5, i32 1, i32 0, i1 false)
+ store target("dx.RawBuffer", i8, 1, 0) %Four_h, ptr @Four, align 4
+
+ ; RWStructuredBuffer<int16_t> Five : register(u6);
+ %Five_h = call target("dx.RawBuffer", i16, 1, 0)
+ @llvm.dx.resource.handlefrombinding.tdx.RawBuffer_i16_1_0t(
+ i32 0, i32 6, i32 1, i32 0, i1 false)
+ store target("dx.RawBuffer", i16, 1, 0) %Five_h, ptr @Five, align 4
+
+ ; RasterizerOrderedBuffer<int4> Six : register(u7);
+ %Six_h = call target("dx.TypedBuffer", <4 x i32>, 1, 1, 1)
+ @llvm.dx.resource.handlefrombinding.tdx.TypedBuffer_v4i32_1_1_1t(
+ i32 0, i32 7, i32 1, i32 0, i1 false)
+ store target("dx.TypedBuffer", <4 x i32>, 1, 1, 1) %Six_h, ptr @Six, align 4
+
+ ; RasterizerOrderedStructuredBuffer<uint4> Seven : register(u3, space10);
+ %Seven_h = call target("dx.RawBuffer", <4 x i32>, 1, 1)
+ @llvm.dx.resource.handlefrombinding.tdx.RawBuffer_v4i32_1_1t(
+ i32 0, i32 8, i32 1, i32 0, i1 false)
+ store target("dx.RawBuffer", <4 x i32>, 1, 1) %Seven_h, ptr @Seven, align 4
+
+ ; RasterizerOrderedByteAddressBuffer Eight : register(u9);
+ %Eight_h = call target("dx.RawBuffer", i8, 1, 1)
+ @llvm.dx.resource.handlefrombinding.tdx.RawBuffer_i8_1_1t(
+ i32 0, i32 9, i32 1, i32 0, i1 false)
+ store target("dx.RawBuffer", i8, 1, 1) %Eight_h, ptr @Eight, align 4
+
+ ; RWBuffer<double> Nine : register(u2);
+ %Nine_h = call target("dx.TypedBuffer", i64, 1, 0, 0)
+ @llvm.dx.resource.handlefrombinding.tdx.TypedBuffer_f64_1_0_0t(
+ i32 2, i32 10, i32 1, i32 0, i1 false)
+ store target("dx.TypedBuffer", i64, 1, 0, 0) %Nine_h, ptr @Nine, align 4
+
+ ret void
+}
+
+attributes #0 = { noinline nounwind "hlsl.shader"="compute" }
+
+; CHECK: !dx.resources = !{[[ResList:[!][0-9]+]]}
+
+; CHECK: [[ResList]] = !{null, [[UAVList:[!][0-9]+]], null, null}
+; CHECK: [[UAVList]] = !{![[Zero:[0-9]+]], ![[One:[0-9]+]], ![[Two:[0-9]+]],
+; CHECK-SAME: ![[Three:[0-9]+]], ![[Four:[0-9]+]], ![[Five:[0-9]+]],
+; CHECK-SAME: ![[Six:[0-9]+]], ![[Seven:[0-9]+]], ![[Eight:[0-9]+]],
+; CHECK-SAME: ![[Nine:[0-9]+]]}
+
+; CHECK: ![[Zero]] = !{i32 0, ptr @0, !"", i32 0, i32 0, i32 1, i32 10, i1 false, i1 false, i1 false, ![[Half:[0-9]+]]}
+; CHECK: ![[Half]] = !{i32 0, i32 8}
+; CHECK: ![[One]] = !{i32 1, ptr @1, !"", i32 0, i32 1, i32 1, i32 10, i1 false, i1 false, i1 false, ![[Float:[0-9]+]]}
+; CHECK: ![[Float]] = !{i32 0, i32 9}
+; CHECK: ![[Two]] = !{i32 2, ptr @2, !"", i32 0, i32 2, i32 1, i32 10, i1 false, i1 false, i1 false, ![[Double:[0-9]+]]}
+; CHECK: ![[Double]] = !{i32 0, i32 10}
+; CHECK: ![[Three]] = !{i32 3, ptr @3, !"", i32 0, i32 3, i32 1, i32 10, i1 false, i1 false, i1 false, ![[I32:[0-9]+]]}
+; CHECK: ![[I32]] = !{i32 0, i32 4}
+; CHECK: ![[Four]] = !{i32 4, ptr @4, !"", i32 0, i32 5, i32 1, i32 11, i1 false, i1 false, i1 false, null}
+; CHECK: ![[Five]] = !{i32 5, ptr @5, !"", i32 0, i32 6, i32 1, i32 12, i1 false, i1 false, i1 false, ![[FiveStride:[0-9]+]]}
+; CHECK: ![[FiveStride]] = !{i32 1, i32 2}
+; CHECK: ![[Six]] = !{i32 6, ptr @6, !"", i32 0, i32 7, i32 1, i32 10, i1 false, i1 false, i1 true, ![[I32]]}
+; CHECK: ![[Seven]] = !{i32 7, ptr @7, !"", i32 0, i32 8, i32 1, i32 12, i1 false, i1 false, i1 true, ![[SevenStride:[0-9]+]]}
+; CHECK: ![[SevenStride]] = !{i32 1, i32 16}
+; CHECK: ![[Eight]] = !{i32 8, ptr @8, !"", i32 0, i32 9, i32 1, i32 11, i1 false, i1 false, i1 true, null}
+; CHECK: ![[Nine]] = !{i32 9, ptr @9, !"", i32 2, i32 10, i32 1, i32 10, i1 false, i1 false, i1 false, ![[U64:[0-9]+]]}
+; CHECK: ![[U64]] = !{i32 0, i32 7}
diff --git a/llvm/test/CodeGen/DirectX/UAVMetadata.ll b/llvm/test/CodeGen/DirectX/UAVMetadata.ll
deleted file mode 100644
index 2c242ec08eda5..0000000000000
--- a/llvm/test/CodeGen/DirectX/UAVMetadata.ll
+++ /dev/null
@@ -1,77 +0,0 @@
-; RUN: opt -S -dxil-translate-metadata < %s | FileCheck %s
-; RUN: opt -S --passes="dxil-pretty-printer" < %s 2>&1 | FileCheck %s --check-prefix=PRINT
-; RUN: llc %s --filetype=asm -o - < %s 2>&1 | FileCheck %s --check-prefixes=CHECK,PRINT
-
-target datalayout = "e-m:e-p:32:32-i1:32-i8:8-i16:16-i32:32-i64:64-f16:16-f32:32-f64:64-n8:16:32:64"
-target triple = "dxil-pc-shadermodel6.0-library"
-
-%"class.hlsl::RWBuffer" = type { ptr }
-
-
-; PRINT:; Resource Bindings:
-; PRINT-NEXT:;
-; PRINT-NEXT:; Name Type Format Dim ID HLSL Bind Count
-; PRINT-NEXT:; ------------------------------ ---------- ------- ----------- ------- -------------- ------
-; PRINT-NEXT:; UAV f16 buf U0 u0 1
-; PRINT-NEXT:; UAV f32 buf U1 u1 1
-; PRINT-NEXT:; UAV f64 buf U2 u2 1
-; PRINT-NEXT:; UAV i1 buf U3 u3 2
-; PRINT-NEXT:; UAV byte r/w U4 u5 1
-; PRINT-NEXT:; UAV struct r/w U5 u6 1
-; PRINT-NEXT:; UAV i32 buf U6 u7 1
-; PRINT-NEXT:; UAV struct r/w U7 u8 1
-; PRINT-NEXT:; UAV byte r/w U8 u9 1
-; PRINT-NEXT:; UAV u64 buf U9 u10,space2 1
-
- at Zero = local_unnamed_addr global %"class.hlsl::RWBuffer" zeroinitializer, align 4
- at One = local_unnamed_addr global %"class.hlsl::RWBuffer" zeroinitializer, align 4
- at Two = local_unnamed_addr global %"class.hlsl::RWBuffer" zeroinitializer, align 4
- at Three = local_unnamed_addr global [2 x %"class.hlsl::RWBuffer"] zeroinitializer, align 4
- at Four = local_unnamed_addr global %"class.hlsl::RWBuffer" zeroinitializer, align 4
- at Five = local_unnamed_addr global %"class.hlsl::RWBuffer" zeroinitializer, align 4
- at Six = local_unnamed_addr global %"class.hlsl::RWBuffer" zeroinitializer, align 4
- at Seven = local_unnamed_addr global %"class.hlsl::RWBuffer" zeroinitializer, align 4
- at Eight = local_unnamed_addr global %"class.hlsl::RWBuffer" zeroinitializer, align 4
- at Nine = local_unnamed_addr global %"class.hlsl::RWBuffer" zeroinitializer, align 4
-
-
-!hlsl.uavs = !{!0, !1, !2, !3, !4, !5, !6, !7, !8, !9}
-
-!0 = !{ptr @Zero, i32 10, i32 8, i1 false, i32 0, i32 0}
-!1 = !{ptr @One, i32 10, i32 9, i1 false, i32 1, i32 0}
-!2 = !{ptr @Two, i32 10, i32 10, i1 false, i32 2, i32 0}
-!3 = !{ptr @Three, i32 10, i32 1, i1 false, i32 3, i32 0}
-!4 = !{ptr @Four, i32 11, i32 2, i1 false, i32 5, i32 0}
-!5 = !{ptr @Five, i32 12, i32 3, i1 false, i32 6, i32 0}
-!6 = !{ptr @Six, i32 10, i32 4, i1 true, i32 7, i32 0}
-!7 = !{ptr @Seven, i32 12, i32 5, i1 true, i32 8, i32 0}
-!8 = !{ptr @Eight, i32 11, i32 6, i1 true, i32 9, i32 0}
-!9 = !{ptr @Nine, i32 10, i32 7, i1 false, i32 10, i32 2}
-
-; CHECK: !dx.resources = !{[[ResList:[!][0-9]+]]}
-
-; CHECK: [[ResList]] = !{null, [[UAVList:[!][0-9]+]], null, null}
-; CHECK: [[UAVList]] = !{[[Zero:[!][0-9]+]], [[One:[!][0-9]+]],
-; CHECK-SAME: [[Two:[!][0-9]+]], [[Three:[!][0-9]+]], [[Four:[!][0-9]+]],
-; CHECK-SAME: [[Five:[!][0-9]+]], [[Six:[!][0-9]+]], [[Seven:[!][0-9]+]],
-; CHECK-SAME: [[Eight:[!][0-9]+]], [[Nine:[!][0-9]+]]}
-; CHECK: [[Zero]] = !{i32 0, ptr @Zero, !"", i32 0, i32 0, i32 1, i32 10, i1 false, i1 false, i1 false, [[Half:[!][0-9]+]]}
-; CHECK: [[Half]] = !{i32 0, i32 8}
-; CHECK: [[One]] = !{i32 1, ptr @One, !"", i32 0, i32 1, i32 1, i32 10, i1 false, i1 false, i1 false, [[Float:[!][0-9]+]]}
-; CHECK: [[Float]] = !{i32 0, i32 9}
-; CHECK: [[Two]] = !{i32 2, ptr @Two, !"", i32 0, i32 2, i32 1, i32 10, i1 false, i1 false, i1 false, [[Double:[!][0-9]+]]}
-; CHECK: [[Double]] = !{i32 0, i32 10}
-; CHECK: [[Three]] = !{i32 3, ptr @Three, !"", i32 0, i32 3, i32 2, i32 10, i1 false, i1 false, i1 false, [[Bool:[!][0-9]+]]}
-; CHECK: [[Bool]] = !{i32 0, i32 1}
-; CHECK: [[Four]] = !{i32 4, ptr @Four, !"", i32 0, i32 5, i32 1, i32 11, i1 false, i1 false, i1 false, [[I16:[!][0-9]+]]}
-; CHECK: [[I16]] = !{i32 0, i32 2}
-; CHECK: [[Five]] = !{i32 5, ptr @Five, !"", i32 0, i32 6, i32 1, i32 12, i1 false, i1 false, i1 false, [[U16:[!][0-9]+]]}
-; CHECK: [[U16]] = !{i32 0, i32 3}
-; CHECK: [[Six]] = !{i32 6, ptr @Six, !"", i32 0, i32 7, i32 1, i32 10, i1 false, i1 false, i1 true, [[I32:[!][0-9]+]]}
-; CHECK: [[I32]] = !{i32 0, i32 4}
-; CHECK: [[Seven]] = !{i32 7, ptr @Seven, !"", i32 0, i32 8, i32 1, i32 12, i1 false, i1 false, i1 true, [[U32:[!][0-9]+]]}
-; CHECK: [[U32]] = !{i32 0, i32 5}
-; CHECK: [[Eight]] = !{i32 8, ptr @Eight, !"", i32 0, i32 9, i32 1, i32 11, i1 false, i1 false, i1 true, [[I64:[!][0-9]+]]}
-; CHECK: [[I64]] = !{i32 0, i32 6}
-; CHECK: [[Nine]] = !{i32 9, ptr @Nine, !"", i32 2, i32 10, i32 1, i32 10, i1 false, i1 false, i1 false, [[U64:[!][0-9]+]]}
-; CHECK: [[U64]] = !{i32 0, i32 7}
diff --git a/llvm/test/CodeGen/DirectX/cbuf.ll b/llvm/test/CodeGen/DirectX/cbuf.ll
deleted file mode 100644
index 7589da5e15bd7..0000000000000
--- a/llvm/test/CodeGen/DirectX/cbuf.ll
+++ /dev/null
@@ -1,37 +0,0 @@
-; RUN: opt -S -dxil-translate-metadata < %s | FileCheck %s --check-prefix=DXILMD
-; RUN: opt -S --passes="dxil-pretty-printer" < %s 2>&1 | FileCheck %s --check-prefix=PRINT
-
-target datalayout = "e-m:e-p:32:32-i1:32-i8:8-i16:16-i32:32-i64:64-f16:16-f32:32-f64:64-n8:16:32:64"
-target triple = "dxil-unknown-shadermodel6.7-library"
-
-; Make sure the size is 24 = 16 + 8 (float,i32,double -> 16 and int2 -> 8)
-; DXILMD:!{i32 0, ptr @A.cb., !"", i32 1, i32 2, i32 1, i32 24}
-
-; Make sure match register(b2, space1) with ID 0.
-; PRINT:cbuffer NA NA CB0 cb2,space1 1
-
- at A.cb. = external constant { float, i32, double, <2 x i32> }
-
-; Function Attrs: noinline nounwind optnone
-define noundef float @"?foo@@YAMXZ"() #0 {
-entry:
- %0 = load float, ptr @A.cb., align 4
- %conv = fpext float %0 to double
- %1 = load double, ptr getelementptr inbounds ({ float, i32, double, <2 x i32> }, ptr @A.cb., i32 0, i32 2), align 8
- %2 = load <2 x i32>, ptr getelementptr inbounds ({ float, i32, double, <2 x i32> }, ptr @A.cb., i32 0, i32 3), align 8
- %3 = extractelement <2 x i32> %2, i32 1
- %conv1 = sitofp i32 %3 to double
- %4 = call double @llvm.fmuladd.f64(double %1, double %conv1, double %conv)
- %conv2 = fptrunc double %4 to float
- ret float %conv2
-}
-
-; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn
-declare double @llvm.fmuladd.f64(double, double, double) #1
-
-attributes #0 = { noinline nounwind }
-attributes #1 = { nocallback nofree nosync nounwind readnone speculatable willreturn }
-
-!hlsl.cbufs = !{!1}
-
-!1 = !{ptr @A.cb., !"A.cb.ty", i32 13, i1 false, i32 2, i32 1}
diff --git a/llvm/test/CodeGen/DirectX/legacy_cb_layout_0.ll b/llvm/test/CodeGen/DirectX/legacy_cb_layout_0.ll
deleted file mode 100644
index 1a618092c5fed..0000000000000
--- a/llvm/test/CodeGen/DirectX/legacy_cb_layout_0.ll
+++ /dev/null
@@ -1,14 +0,0 @@
-; RUN: opt -S -dxil-translate-metadata < %s | FileCheck %s --check-prefix=DXILMD
-
-target datalayout = "e-m:e-p:32:32-i1:32-i8:8-i16:16-i32:32-i64:64-f16:16-f32:32-f64:64-n8:16:32:64"
-target triple = "dxil-unknown-shadermodel6.7-library"
-
-; Make sure the size is 36 = 16 + 16 + 4 (float, double -> 16, float, half, i16, i64 -> 16 and int -> 4)
-; DXILMD:!{i32 0, ptr @A.cb., !"", i32 0, i32 2, i32 1, i32 36}
-
- at A.cb. = external local_unnamed_addr constant { float, double, float, half, i16, i64, i32 }
-
-
-!hlsl.cbufs = !{!1}
-
-!1 = !{ptr @A.cb., !"A.cb.ty", i32 13, i1 false, i32 2, i32 0}
diff --git a/llvm/test/CodeGen/DirectX/legacy_cb_layout_1.ll b/llvm/test/CodeGen/DirectX/legacy_cb_layout_1.ll
deleted file mode 100644
index 6886f2690209d..0000000000000
--- a/llvm/test/CodeGen/DirectX/legacy_cb_layout_1.ll
+++ /dev/null
@@ -1,37 +0,0 @@
-; RUN: opt -S -dxil-translate-metadata < %s | FileCheck %s --check-prefix=DXILMD
-
-target datalayout = "e-m:e-p:32:32-i1:32-i8:8-i16:16-i32:32-i64:64-f16:16-f32:32-f64:64-n8:16:32:64"
-target triple = "dxil-unknown-shadermodel6.7-library"
-
-;
-; cbuffer B
-; {
-;
-; struct B
-; {
-;
-; double B0; ; Offset: 0
-; float3 B1; ; Offset: 16
-; float B2; ; Offset: 28
-; double3 B3; ; Offset: 32
-; half B4; ; Offset: 56
-; double2 B5; ; Offset: 64
-; float B6; ; Offset: 80
-; half3 B7; ; Offset: 84
-; half3 B8; ; Offset: 90
-;
-; } B; ; Offset: 0 Size: 96
-;
-; }
-;
-
-
-; Make sure the size is 96
-; DXILMD:!{i32 0, ptr @B.cb., !"", i32 0, i32 1, i32 1, i32 96}
-
- at B.cb. = external local_unnamed_addr constant { double, <3 x float>, float, <3 x double>, half, <2 x double>, float, <3 x half>, <3 x half> }
-
-
-!hlsl.cbufs = !{!0}
-
-!0 = !{ptr @B.cb., !"B.cb.ty", i32 13, i1 false, i32 1, i32 0}
diff --git a/llvm/test/CodeGen/DirectX/legacy_cb_layout_2.ll b/llvm/test/CodeGen/DirectX/legacy_cb_layout_2.ll
deleted file mode 100644
index 3b08b25542201..0000000000000
--- a/llvm/test/CodeGen/DirectX/legacy_cb_layout_2.ll
+++ /dev/null
@@ -1,51 +0,0 @@
-; RUN: opt -S -dxil-translate-metadata < %s | FileCheck %s --check-prefix=DXILMD
-
-target datalayout = "e-m:e-p:32:32-i1:32-i8:8-i16:16-i32:32-i64:64-f16:16-f32:32-f64:64-n8:16:32:64"
-target triple = "dxil-unknown-shadermodel6.7-library"
-
-; cbuffer B
-; {
-;
-; struct B
-; {
-;
-; double B0[2]; ; Offset: 0
-; float3 B1[3]; ; Offset: 32
-; float B2; ; Offset: 76
-; double B3[3]; ; Offset: 80
-; half B4; ; Offset: 120
-; double2 B5[1]; ; Offset: 128
-; float B6; ; Offset: 144
-; half3 B7[2]; ; Offset: 160
-; half3 B8; ; Offset: 182
-;
-; } B; ; Offset: 0 Size: 188
-;
-; }
-;
-; cbuffer B
-; {
-;
-; struct B.0
-; {
-;
-; double3 B9[3]; ; Offset: 0
-; half3 B10; ; Offset: 88
-;
-; } B; ; Offset: 0 Size: 94
-;
-; }
-
-
-; Make sure the size is 188.
-; DXILMD:!{i32 0, ptr @B.cb., !"", i32 0, i32 1, i32 1, i32 188}
-; Make sure the size is 94.
-; DXILMD:!{i32 1, ptr @B.cb..1, !"", i32 0, i32 2, i32 1, i32 94}
-
- at B.cb. = external local_unnamed_addr constant { [2 x double], [3 x <3 x float>], float, [3 x double], half, [1 x <2 x double>], float, [2 x <3 x half>], <3 x half> }
- at B.cb..1 = external local_unnamed_addr constant { [3 x <3 x double>], <3 x half> }
-
-!hlsl.cbufs = !{!0, !1}
-
-!0 = !{ptr @B.cb., !"B.cb.ty", i32 13, i1 false, i32 1, i32 0}
-!1 = !{ptr @B.cb..1, !"B.cb.ty", i32 13, i1 false, i32 2, i32 0}
diff --git a/llvm/test/CodeGen/DirectX/legacy_cb_layout_3.ll b/llvm/test/CodeGen/DirectX/legacy_cb_layout_3.ll
deleted file mode 100644
index f01afbdab9673..0000000000000
--- a/llvm/test/CodeGen/DirectX/legacy_cb_layout_3.ll
+++ /dev/null
@@ -1,81 +0,0 @@
-; RUN: opt -S -dxil-translate-metadata < %s | FileCheck %s --check-prefix=DXILMD
-
-target datalayout = "e-m:e-p:32:32-i1:32-i8:8-i16:16-i32:32-i64:64-f16:16-f32:32-f64:64-n8:16:32:64"
-target triple = "dxil-unknown-shadermodel6.7-library"
-
-; cbuffer D
-; {
-;
-; struct D
-; {
-;
-; int D0; ; Offset: 0
-; struct struct.B
-; {
-;
-; double B0; ; Offset: 16
-; float3 B1; ; Offset: 32
-; float B2; ; Offset: 44
-; double3 B3; ; Offset: 48
-; half B4; ; Offset: 72
-; double2 B5; ; Offset: 80
-; float B6; ; Offset: 96
-; half3 B7; ; Offset: 100
-; half3 B8; ; Offset: 106
-;
-; } D1; ; Offset: 16
-;
-; half D2; ; Offset: 112
-; struct struct.C
-; {
-;
-; struct struct.A
-; {
-;
-; float A0; ; Offset: 128
-; double A1; ; Offset: 136
-; float A2; ; Offset: 144
-; half A3; ; Offset: 148
-; int16_t A4; ; Offset: 150
-; int64_t A5; ; Offset: 152
-; int A6; ; Offset: 160
-;
-; } C0; ; Offset: 128
-;
-; float C1[1]; ; Offset: 176
-; struct struct.B
-; {
-;
-; double B0; ; Offset: 192
-; float3 B1; ; Offset: 208
-; float B2; ; Offset: 220
-; double3 B3; ; Offset: 224
-; half B4; ; Offset: 248
-; double2 B5; ; Offset: 256
-; float B6; ; Offset: 272
-; half3 B7; ; Offset: 276
-; half3 B8; ; Offset: 282
-;
-; } C2[2];; ; Offset: 192
-;
-; half C3; ; Offset: 384
-;
-; } D3; ; Offset: 128
-;
-; double D4; ; Offset: 392
-;
-; } D; ; Offset: 0 Size: 400
-
-
-; Make sure the size is 400
-; DXILMD:!{i32 0, ptr @D.cb., !"", i32 0, i32 1, i32 1, i32 400}
-
-
-%struct.B = type <{ double, <3 x float>, float, <3 x double>, half, <2 x double>, float, <3 x half>, <3 x half> }>
-%struct.C = type <{ %struct.A, [1 x float], [2 x %struct.B], half }>
-%struct.A = type <{ float, double, float, half, i16, i64, i32 }>
-
- at D.cb. = external local_unnamed_addr constant { i32, %struct.B, half, %struct.C, double }
-
-!hlsl.cbufs = !{!0}
-!0 = !{ptr @D.cb., !"D.cb.ty", i32 13, i1 false, i32 1, i32 0}
>From d97dce71027e26ac47a3e1c93ef845b71d15ae78 Mon Sep 17 00:00:00 2001
From: Helena Kotas <hekotas at microsoft.com>
Date: Fri, 7 Mar 2025 12:33:25 -0800
Subject: [PATCH 2/3] code review feedback - omit overload mangling and update
comments to match code
---
.../DirectX/Metadata/cbuffer_metadata.ll | 9 ++---
.../CodeGen/DirectX/Metadata/srv_metadata.ll | 33 ++++++++-----------
.../CodeGen/DirectX/Metadata/uav_metadata.ll | 30 ++++++-----------
3 files changed, 26 insertions(+), 46 deletions(-)
diff --git a/llvm/test/CodeGen/DirectX/Metadata/cbuffer_metadata.ll b/llvm/test/CodeGen/DirectX/Metadata/cbuffer_metadata.ll
index b3dda74bf8bbf..816cf04df4780 100644
--- a/llvm/test/CodeGen/DirectX/Metadata/cbuffer_metadata.ll
+++ b/llvm/test/CodeGen/DirectX/Metadata/cbuffer_metadata.ll
@@ -31,8 +31,7 @@ define void @test() #0 {
; int2 d;
; }
%CB1.cb_h = call target("dx.CBuffer", target("dx.Layout", %__cblayout_CB1, 24, 0, 4, 8, 16))
- @llvm.dx.resource.handlefrombinding.tdx.CBuffer_tdx.Layout_s___cblayout_CB1s_24_0_4_8_16tt(
- i32 0, i32 0, i32 1, i32 0, i1 false)
+ @llvm.dx.resource.handlefrombinding(i32 0, i32 0, i32 1, i32 0, i1 false)
store target("dx.CBuffer", target("dx.Layout", %__cblayout_CB1, 24, 0, 4, 8, 16)) %CB1.cb_h, ptr @CB1.cb, align 4
; cbuffer CB2 : register(b0) {
@@ -46,8 +45,7 @@ define void @test() #0 {
;}
%CB2.cb_h = call target("dx.CBuffer", target("dx.Layout", %__cblayout_CB2, 36, 0, 8, 16, 20, 22, 24, 32))
- @llvm.dx.resource.handlefrombinding.tdx.CBuffer_tdx.Layout_s___cblayout_CB2s_36_0_8_16_20_22_24_32tt(
- i32 0, i32 1, i32 1, i32 0, i1 false)
+ @llvm.dx.resource.handlefrombinding(i32 0, i32 1, i32 1, i32 0, i1 false)
store target("dx.CBuffer", target("dx.Layout", %__cblayout_CB2, 36, 0, 8, 16, 20, 22, 24, 32)) %CB2.cb_h, ptr @CB2.cb, align 4
; cbuffer CB3 : register(b5) {
@@ -62,8 +60,7 @@ define void @test() #0 {
; half3 B8;
; }
%CB3.cb_h = call target("dx.CBuffer", target("dx.Layout", %__cblayout_CB3, 96, 0, 16, 28, 32, 56, 64, 80, 84, 90))
- @llvm.dx.resource.handlefrombinding.tdx.CBuffer_tdx.Layout_s___cblayout_CB3s_96_0_16_28_32_56_64_80_84_90tt(
- i32 15, i32 5, i32 1, i32 0, i1 false)
+ @llvm.dx.resource.handlefrombinding(i32 15, i32 5, i32 1, i32 0, i1 false)
store target("dx.CBuffer", target("dx.Layout", %__cblayout_CB3, 96, 0, 16, 28, 32, 56, 64, 80, 84, 90)) %CB3.cb_h, ptr @CB3.cb, align 4
ret void
diff --git a/llvm/test/CodeGen/DirectX/Metadata/srv_metadata.ll b/llvm/test/CodeGen/DirectX/Metadata/srv_metadata.ll
index e1344035e01a7..812c15cf3f42c 100644
--- a/llvm/test/CodeGen/DirectX/Metadata/srv_metadata.ll
+++ b/llvm/test/CodeGen/DirectX/Metadata/srv_metadata.ll
@@ -34,46 +34,39 @@ target triple = "dxil-pc-shadermodel6.6-compute"
; PRINT-NEXT:; SRV u64 buf T6 t10,space2 1
define void @test() #0 {
- ; RWBuffer<half4> Buf : register(u0)
+ ; Buffer<half4> Buf : register(u0)
%Zero_h = call target("dx.TypedBuffer", <4 x half>, 0, 0, 0)
- @llvm.dx.resource.handlefrombinding.tdx.TypedBuffer_v4f16_0_0_0t(
- i32 0, i32 0, i32 1, i32 0, i1 false)
+ @llvm.dx.resource.handlefrombinding(i32 0, i32 0, i32 1, i32 0, i1 false)
store target("dx.TypedBuffer", <4 x half>, 0, 0, 0) %Zero_h, ptr @Zero, align 4
- ; RWBuffer<float4> Buf : register(u1)
+ ; Buffer<float4> Buf : register(u1)
%One_h = call target("dx.TypedBuffer", <2 x float>, 0, 0, 0)
- @llvm.dx.resource.handlefrombinding.tdx.TypedBuffer_v2f32_0_0_0t(
- i32 0, i32 1, i32 1, i32 0, i1 false)
+ @llvm.dx.resource.handlefrombinding(i32 0, i32 1, i32 1, i32 0, i1 false)
store target("dx.TypedBuffer", <2 x float>, 0, 0, 0) %One_h, ptr @One, align 4
- ; RWBuffer<double> Two : register(u2);
+ ; Buffer<double> Two : register(u2);
%Two_h = call target("dx.TypedBuffer", double, 0, 0, 0)
- @llvm.dx.resource.handlefrombinding.tdx.TypedBuffer_f64_0_0_0t(
- i32 0, i32 2, i32 1, i32 0, i1 false)
+ @llvm.dx.resource.handlefrombinding(i32 0, i32 2, i32 1, i32 0, i1 false)
store target("dx.TypedBuffer", double, 0, 0, 0) %Two_h, ptr @Two, align 4
- ; RWBuffer<int4> Three : register(u3);
+ ; Buffer<int4> Three : register(u3);
%Three_h = call target("dx.TypedBuffer", <4 x i32>, 0, 0, 1)
- @llvm.dx.resource.handlefrombinding.tdx.TypedBuffer_i32_0_0_1t(
- i32 0, i32 3, i32 1, i32 0, i1 false)
+ @llvm.dx.resource.handlefrombinding(i32 0, i32 3, i32 1, i32 0, i1 false)
store target("dx.TypedBuffer", <4 x i32>, 0, 0, 1) %Three_h, ptr @Three, align 4
; ByteAddressBuffer Four : register(u4)
%Four_h = call target("dx.RawBuffer", i8, 0, 0)
- @llvm.dx.resource.handlefrombinding.tdx.RawBuffer_i8_0_0t(
- i32 0, i32 5, i32 1, i32 0, i1 false)
+ @llvm.dx.resource.handlefrombinding(i32 0, i32 5, i32 1, i32 0, i1 false)
store target("dx.RawBuffer", i8, 0, 0) %Four_h, ptr @Four, align 4
-; StructuredBuffer<int16_t> Five : register(u6);
+ ; StructuredBuffer<int16_t> Five : register(u6);
%Five_h = call target("dx.RawBuffer", i16, 0, 0)
- @llvm.dx.resource.handlefrombinding.tdx.RawBuffer_i16_0_0t(
- i32 0, i32 6, i32 1, i32 0, i1 false)
+ @llvm.dx.resource.handlefrombinding(i32 0, i32 6, i32 1, i32 0, i1 false)
store target("dx.RawBuffer", i16, 0, 0) %Five_h, ptr @Five, align 4
- ; RWBuffer<double> Two : register(u2);
+ ; Buffer<double> Two : register(u2);
%Six_h = call target("dx.TypedBuffer", i64, 0, 0, 0)
- @llvm.dx.resource.handlefrombinding.tdx.TypedBuffer_f64_0_0_0t(
- i32 2, i32 10, i32 1, i32 0, i1 false)
+ @llvm.dx.resource.handlefrombinding(i32 2, i32 10, i32 1, i32 0, i1 false)
store target("dx.TypedBuffer", i64, 0, 0, 0) %Six_h, ptr @Six, align 4
ret void
diff --git a/llvm/test/CodeGen/DirectX/Metadata/uav_metadata.ll b/llvm/test/CodeGen/DirectX/Metadata/uav_metadata.ll
index 2c98c5d4a1809..63a2bdad0bc59 100644
--- a/llvm/test/CodeGen/DirectX/Metadata/uav_metadata.ll
+++ b/llvm/test/CodeGen/DirectX/Metadata/uav_metadata.ll
@@ -45,62 +45,52 @@ target triple = "dxil-pc-shadermodel6.6-compute"
define void @test() #0 {
; RWBuffer<half4> Zero : register(u0)
%Zero_h = call target("dx.TypedBuffer", <4 x half>, 1, 0, 0)
- @llvm.dx.resource.handlefrombinding.tdx.TypedBuffer_v4f16_1_0_0t(
- i32 0, i32 0, i32 1, i32 0, i1 false)
+ @llvm.dx.resource.handlefrombinding(i32 0, i32 0, i32 1, i32 0, i1 false)
store target("dx.TypedBuffer", <4 x half>, 1, 0, 0) %Zero_h, ptr @Zero, align 4
; RWBuffer<float4> One : register(u1)
%One_h = call target("dx.TypedBuffer", <2 x float>, 1, 0, 0)
- @llvm.dx.resource.handlefrombinding.tdx.TypedBuffer_v2f32_1_0_0t(
- i32 0, i32 1, i32 1, i32 0, i1 false)
+ @llvm.dx.resource.handlefrombinding(i32 0, i32 1, i32 1, i32 0, i1 false)
store target("dx.TypedBuffer", <2 x float>, 1, 0, 0) %One_h, ptr @One, align 4
; RWBuffer<double> Two : register(u2);
%Two_h = call target("dx.TypedBuffer", double, 1, 0, 0)
- @llvm.dx.resource.handlefrombinding.tdx.TypedBuffer_f64_1_0_0t(
- i32 0, i32 2, i32 1, i32 0, i1 false)
+ @llvm.dx.resource.handlefrombinding(i32 0, i32 2, i32 1, i32 0, i1 false)
store target("dx.TypedBuffer", double, 1, 0, 0) %Two_h, ptr @Two, align 4
; RWBuffer<int4> Three : register(u3);
%Three_h = call target("dx.TypedBuffer", <4 x i32>, 1, 0, 1)
- @llvm.dx.resource.handlefrombinding.tdx.TypedBuffer_i32_1_0_1t(
- i32 0, i32 3, i32 1, i32 0, i1 false)
+ @llvm.dx.resource.handlefrombinding(i32 0, i32 3, i32 1, i32 0, i1 false)
store target("dx.TypedBuffer", <4 x i32>, 1, 0, 1) %Three_h, ptr @Three, align 4
; ByteAddressBuffer Four : register(u5)
%Four_h = call target("dx.RawBuffer", i8, 1, 0)
- @llvm.dx.resource.handlefrombinding.tdx.RawBuffer_i8_1_0t(
- i32 0, i32 5, i32 1, i32 0, i1 false)
+ @llvm.dx.resource.handlefrombinding(i32 0, i32 5, i32 1, i32 0, i1 false)
store target("dx.RawBuffer", i8, 1, 0) %Four_h, ptr @Four, align 4
; RWStructuredBuffer<int16_t> Five : register(u6);
%Five_h = call target("dx.RawBuffer", i16, 1, 0)
- @llvm.dx.resource.handlefrombinding.tdx.RawBuffer_i16_1_0t(
- i32 0, i32 6, i32 1, i32 0, i1 false)
+ @llvm.dx.resource.handlefrombinding(i32 0, i32 6, i32 1, i32 0, i1 false)
store target("dx.RawBuffer", i16, 1, 0) %Five_h, ptr @Five, align 4
; RasterizerOrderedBuffer<int4> Six : register(u7);
%Six_h = call target("dx.TypedBuffer", <4 x i32>, 1, 1, 1)
- @llvm.dx.resource.handlefrombinding.tdx.TypedBuffer_v4i32_1_1_1t(
- i32 0, i32 7, i32 1, i32 0, i1 false)
+ @llvm.dx.resource.handlefrombinding(i32 0, i32 7, i32 1, i32 0, i1 false)
store target("dx.TypedBuffer", <4 x i32>, 1, 1, 1) %Six_h, ptr @Six, align 4
; RasterizerOrderedStructuredBuffer<uint4> Seven : register(u3, space10);
%Seven_h = call target("dx.RawBuffer", <4 x i32>, 1, 1)
- @llvm.dx.resource.handlefrombinding.tdx.RawBuffer_v4i32_1_1t(
- i32 0, i32 8, i32 1, i32 0, i1 false)
+ @llvm.dx.resource.handlefrombinding(i32 0, i32 8, i32 1, i32 0, i1 false)
store target("dx.RawBuffer", <4 x i32>, 1, 1) %Seven_h, ptr @Seven, align 4
; RasterizerOrderedByteAddressBuffer Eight : register(u9);
%Eight_h = call target("dx.RawBuffer", i8, 1, 1)
- @llvm.dx.resource.handlefrombinding.tdx.RawBuffer_i8_1_1t(
- i32 0, i32 9, i32 1, i32 0, i1 false)
+ @llvm.dx.resource.handlefrombinding(i32 0, i32 9, i32 1, i32 0, i1 false)
store target("dx.RawBuffer", i8, 1, 1) %Eight_h, ptr @Eight, align 4
; RWBuffer<double> Nine : register(u2);
%Nine_h = call target("dx.TypedBuffer", i64, 1, 0, 0)
- @llvm.dx.resource.handlefrombinding.tdx.TypedBuffer_f64_1_0_0t(
- i32 2, i32 10, i32 1, i32 0, i1 false)
+ @llvm.dx.resource.handlefrombinding(i32 2, i32 10, i32 1, i32 0, i1 false)
store target("dx.TypedBuffer", i64, 1, 0, 0) %Nine_h, ptr @Nine, align 4
ret void
>From 6efe82bb9e49bd45f6716615191b087cb785cbe2 Mon Sep 17 00:00:00 2001
From: Helena Kotas <hekotas at microsoft.com>
Date: Mon, 10 Mar 2025 18:16:42 -0700
Subject: [PATCH 3/3] Add test case with resource array; fix more comments
---
.../CodeGen/DirectX/Metadata/srv_metadata.ll | 27 +++++++++++++------
.../CodeGen/DirectX/Metadata/uav_metadata.ll | 13 ++++++++-
2 files changed, 31 insertions(+), 9 deletions(-)
diff --git a/llvm/test/CodeGen/DirectX/Metadata/srv_metadata.ll b/llvm/test/CodeGen/DirectX/Metadata/srv_metadata.ll
index 812c15cf3f42c..cfdaeb488179d 100644
--- a/llvm/test/CodeGen/DirectX/Metadata/srv_metadata.ll
+++ b/llvm/test/CodeGen/DirectX/Metadata/srv_metadata.ll
@@ -32,43 +32,53 @@ target triple = "dxil-pc-shadermodel6.6-compute"
; PRINT-NEXT:; SRV byte r/o T4 t5 1
; PRINT-NEXT:; SRV struct r/o T5 t6 1
; PRINT-NEXT:; SRV u64 buf T6 t10,space2 1
+; PRINT-NEXT:; SRV f32 buf T7 t4,space3 100
define void @test() #0 {
- ; Buffer<half4> Buf : register(u0)
+ ; Buffer<half4> Buf : register(t0)
%Zero_h = call target("dx.TypedBuffer", <4 x half>, 0, 0, 0)
@llvm.dx.resource.handlefrombinding(i32 0, i32 0, i32 1, i32 0, i1 false)
store target("dx.TypedBuffer", <4 x half>, 0, 0, 0) %Zero_h, ptr @Zero, align 4
- ; Buffer<float4> Buf : register(u1)
+ ; Buffer<float4> Buf : register(t1)
%One_h = call target("dx.TypedBuffer", <2 x float>, 0, 0, 0)
@llvm.dx.resource.handlefrombinding(i32 0, i32 1, i32 1, i32 0, i1 false)
store target("dx.TypedBuffer", <2 x float>, 0, 0, 0) %One_h, ptr @One, align 4
- ; Buffer<double> Two : register(u2);
+ ; Buffer<double> Two : register(t2);
%Two_h = call target("dx.TypedBuffer", double, 0, 0, 0)
@llvm.dx.resource.handlefrombinding(i32 0, i32 2, i32 1, i32 0, i1 false)
store target("dx.TypedBuffer", double, 0, 0, 0) %Two_h, ptr @Two, align 4
- ; Buffer<int4> Three : register(u3);
+ ; Buffer<int4> Three : register(t3);
%Three_h = call target("dx.TypedBuffer", <4 x i32>, 0, 0, 1)
@llvm.dx.resource.handlefrombinding(i32 0, i32 3, i32 1, i32 0, i1 false)
store target("dx.TypedBuffer", <4 x i32>, 0, 0, 1) %Three_h, ptr @Three, align 4
- ; ByteAddressBuffer Four : register(u4)
+ ; ByteAddressBuffer Four : register(t4)
%Four_h = call target("dx.RawBuffer", i8, 0, 0)
@llvm.dx.resource.handlefrombinding(i32 0, i32 5, i32 1, i32 0, i1 false)
store target("dx.RawBuffer", i8, 0, 0) %Four_h, ptr @Four, align 4
- ; StructuredBuffer<int16_t> Five : register(u6);
+ ; StructuredBuffer<int16_t> Five : register(t6);
%Five_h = call target("dx.RawBuffer", i16, 0, 0)
@llvm.dx.resource.handlefrombinding(i32 0, i32 6, i32 1, i32 0, i1 false)
store target("dx.RawBuffer", i16, 0, 0) %Five_h, ptr @Five, align 4
- ; Buffer<double> Two : register(u2);
+ ; Buffer<double> Six : register(t10, space2);
%Six_h = call target("dx.TypedBuffer", i64, 0, 0, 0)
@llvm.dx.resource.handlefrombinding(i32 2, i32 10, i32 1, i32 0, i1 false)
store target("dx.TypedBuffer", i64, 0, 0, 0) %Six_h, ptr @Six, align 4
+ ; Buffer<float4> Array[100] : register(t4, space3);
+ ; Buffer<float4> B1 = Array[30];
+ ; Buffer<float4> B1 = Array[42];
+ ; resource array accesses should produce one metadata entry
+ %Array_30_h = call target("dx.TypedBuffer", <4 x float>, 0, 0, 0)
+ @llvm.dx.resource.handlefrombinding(i32 3, i32 4, i32 100, i32 30, i1 false)
+ %Array_42_h = call target("dx.TypedBuffer", <4 x float>, 0, 0, 0)
+ @llvm.dx.resource.handlefrombinding(i32 3, i32 4, i32 100, i32 42, i1 false)
+
ret void
}
@@ -79,7 +89,7 @@ attributes #0 = { noinline nounwind "hlsl.shader"="compute" }
; CHECK: [[ResList]] = !{[[SRVList:[!][0-9]+]], null, null, null}
; CHECK: [[SRVList]] = !{![[Zero:[0-9]+]], ![[One:[0-9]+]], ![[Two:[0-9]+]],
; CHECK-SAME: ![[Three:[0-9]+]], ![[Four:[0-9]+]], ![[Five:[0-9]+]],
-; CHECK-SAME: ![[Six:[0-9]+]]}
+; CHECK-SAME: ![[Six:[0-9]+]], ![[Array:[0-9]+]]}
; CHECK: ![[Zero]] = !{i32 0, ptr @0, !"", i32 0, i32 0, i32 1, i32 10, i32 0, ![[Half:[0-9]+]]}
; CHECK: ![[Half]] = !{i32 0, i32 8}
@@ -94,3 +104,4 @@ attributes #0 = { noinline nounwind "hlsl.shader"="compute" }
; CHECK: ![[FiveStride]] = !{i32 1, i32 2}
; CHECK: ![[Six]] = !{i32 6, ptr @6, !"", i32 2, i32 10, i32 1, i32 10, i32 0, ![[U64:[0-9]+]]}
; CHECK: ![[U64]] = !{i32 0, i32 7}
+; CHECK: ![[Array]] = !{i32 7, ptr @7, !"", i32 3, i32 4, i32 100, i32 10, i32 0, ![[Float]]}
diff --git a/llvm/test/CodeGen/DirectX/Metadata/uav_metadata.ll b/llvm/test/CodeGen/DirectX/Metadata/uav_metadata.ll
index 63a2bdad0bc59..e2f7cffb50f3c 100644
--- a/llvm/test/CodeGen/DirectX/Metadata/uav_metadata.ll
+++ b/llvm/test/CodeGen/DirectX/Metadata/uav_metadata.ll
@@ -41,6 +41,7 @@ target triple = "dxil-pc-shadermodel6.6-compute"
; PRINT-NEXT:; UAV struct r/w U7 u8 1
; PRINT-NEXT:; UAV byte r/w U8 u9 1
; PRINT-NEXT:; UAV u64 buf U9 u10,space2 1
+; PRINT-NEXT:; UAV f32 buf U10 u4,space3 100
define void @test() #0 {
; RWBuffer<half4> Zero : register(u0)
@@ -93,6 +94,15 @@ define void @test() #0 {
@llvm.dx.resource.handlefrombinding(i32 2, i32 10, i32 1, i32 0, i1 false)
store target("dx.TypedBuffer", i64, 1, 0, 0) %Nine_h, ptr @Nine, align 4
+ ; RWBuffer<float4> Array[100] : register(u4, space3);
+ ; RWBuffer<float4> B1 = Array[30];
+ ; RWBuffer<float4> B1 = Array[42];
+ ; resource array accesses should produce one metadata entry
+ %Array_30_h = call target("dx.TypedBuffer", <4 x float>, 1, 0, 0)
+ @llvm.dx.resource.handlefrombinding(i32 3, i32 4, i32 100, i32 30, i1 false)
+ %Array_42_h = call target("dx.TypedBuffer", <4 x float>, 1, 0, 0)
+ @llvm.dx.resource.handlefrombinding(i32 3, i32 4, i32 100, i32 42, i1 false)
+
ret void
}
@@ -104,7 +114,7 @@ attributes #0 = { noinline nounwind "hlsl.shader"="compute" }
; CHECK: [[UAVList]] = !{![[Zero:[0-9]+]], ![[One:[0-9]+]], ![[Two:[0-9]+]],
; CHECK-SAME: ![[Three:[0-9]+]], ![[Four:[0-9]+]], ![[Five:[0-9]+]],
; CHECK-SAME: ![[Six:[0-9]+]], ![[Seven:[0-9]+]], ![[Eight:[0-9]+]],
-; CHECK-SAME: ![[Nine:[0-9]+]]}
+; CHECK-SAME: ![[Nine:[0-9]+]], ![[Array:[0-9]+]]}
; CHECK: ![[Zero]] = !{i32 0, ptr @0, !"", i32 0, i32 0, i32 1, i32 10, i1 false, i1 false, i1 false, ![[Half:[0-9]+]]}
; CHECK: ![[Half]] = !{i32 0, i32 8}
@@ -123,3 +133,4 @@ attributes #0 = { noinline nounwind "hlsl.shader"="compute" }
; CHECK: ![[Eight]] = !{i32 8, ptr @8, !"", i32 0, i32 9, i32 1, i32 11, i1 false, i1 false, i1 true, null}
; CHECK: ![[Nine]] = !{i32 9, ptr @9, !"", i32 2, i32 10, i32 1, i32 10, i1 false, i1 false, i1 false, ![[U64:[0-9]+]]}
; CHECK: ![[U64]] = !{i32 0, i32 7}
+; CHECK: ![[Array]] = !{i32 10, ptr @10, !"", i32 3, i32 4, i32 100, i32 10, i1 false, i1 false, i1 false, ![[Float]]}
More information about the cfe-commits
mailing list