Skip to content

Commit b30116d

Browse files
hekotasmallp-o-p
authored andcommitted
[HLSL] Remove old resource annotations for UAVs and SRVs (llvm#114139)
UAVs and SRVs have already been converted to use LLVM target types and we can disable generating of the !hlsl.uavs and !hlsl.srvs! annotations. This will enable adding tests for structured buffers with user defined types that this old resource annotations code does not handle (it crashes). Part 1 of llvm#114126
1 parent 058be3a commit b30116d

File tree

8 files changed

+10
-110
lines changed

8 files changed

+10
-110
lines changed

clang/lib/CodeGen/CGHLSLRuntime.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,16 @@ void CGHLSLRuntime::annotateHLSLResource(const VarDecl *D, GlobalVariable *GV) {
306306
continue;
307307

308308
llvm::hlsl::ResourceClass RC = AttrResType->getAttrs().ResourceClass;
309+
if (RC == llvm::hlsl::ResourceClass::UAV ||
310+
RC == llvm::hlsl::ResourceClass::SRV)
311+
// UAVs and SRVs have already been converted to use LLVM target types,
312+
// we can disable generating of these resource annotations. This will
313+
// enable progress on structured buffers with user defined types this
314+
// resource annotations code does not handle and it crashes.
315+
// This whole function is going to be removed as soon as cbuffers are
316+
// converted to target types (llvm/llvm-project #114126).
317+
return;
318+
309319
bool IsROV = AttrResType->getAttrs().IsROV;
310320
llvm::hlsl::ResourceKind RK = HLSLResAttr->getResourceKind();
311321
llvm::hlsl::ElementType ET = calculateElementType(CGM.getContext(), Ty);

clang/test/CodeGenHLSL/builtins/RWBuffer-annotations.hlsl

Lines changed: 0 additions & 24 deletions
This file was deleted.

clang/test/CodeGenHLSL/builtins/RWBuffer-elementtype.hlsl

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,3 @@ void main(int GI : SV_GroupIndex) {
5454
BufF16x2[GI] = 0;
5555
BufF32x3[GI] = 0;
5656
}
57-
58-
// CHECK: !{{[0-9]+}} = !{ptr @BufI16, i32 10, i32 2,
59-
// CHECK: !{{[0-9]+}} = !{ptr @BufU16, i32 10, i32 3,
60-
// CHECK: !{{[0-9]+}} = !{ptr @BufI32, i32 10, i32 4,
61-
// CHECK: !{{[0-9]+}} = !{ptr @BufU32, i32 10, i32 5,
62-
// CHECK: !{{[0-9]+}} = !{ptr @BufI64, i32 10, i32 6,
63-
// CHECK: !{{[0-9]+}} = !{ptr @BufU64, i32 10, i32 7,
64-
// CHECK: !{{[0-9]+}} = !{ptr @BufF16, i32 10, i32 8,
65-
// CHECK: !{{[0-9]+}} = !{ptr @BufF32, i32 10, i32 9,
66-
// CHECK: !{{[0-9]+}} = !{ptr @BufF64, i32 10, i32 10,
67-
// CHECK: !{{[0-9]+}} = !{ptr @BufI16x4, i32 10, i32 2,
68-
// CHECK: !{{[0-9]+}} = !{ptr @BufU32x3, i32 10, i32 5,
69-
// CHECK: !{{[0-9]+}} = !{ptr @BufF16x2, i32 10, i32 8,
70-
// CHECK: !{{[0-9]+}} = !{ptr @BufF32x3, i32 10, i32 9,

clang/test/CodeGenHLSL/builtins/RWStructuredBuffer-elementtype.hlsl

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,3 @@ void main(int GI : SV_GroupIndex) {
5454
BufF16x2[GI] = 0;
5555
BufF32x3[GI] = 0;
5656
}
57-
58-
// CHECK: !{{[0-9]+}} = !{ptr @BufI16, i32 10, i32 2,
59-
// CHECK: !{{[0-9]+}} = !{ptr @BufU16, i32 10, i32 3,
60-
// CHECK: !{{[0-9]+}} = !{ptr @BufI32, i32 10, i32 4,
61-
// CHECK: !{{[0-9]+}} = !{ptr @BufU32, i32 10, i32 5,
62-
// CHECK: !{{[0-9]+}} = !{ptr @BufI64, i32 10, i32 6,
63-
// CHECK: !{{[0-9]+}} = !{ptr @BufU64, i32 10, i32 7,
64-
// CHECK: !{{[0-9]+}} = !{ptr @BufF16, i32 10, i32 8,
65-
// CHECK: !{{[0-9]+}} = !{ptr @BufF32, i32 10, i32 9,
66-
// CHECK: !{{[0-9]+}} = !{ptr @BufF64, i32 10, i32 10,
67-
// CHECK: !{{[0-9]+}} = !{ptr @BufI16x4, i32 10, i32 2,
68-
// CHECK: !{{[0-9]+}} = !{ptr @BufU32x3, i32 10, i32 5,
69-
// CHECK: !{{[0-9]+}} = !{ptr @BufF16x2, i32 10, i32 8,
70-
// CHECK: !{{[0-9]+}} = !{ptr @BufF32x3, i32 10, i32 9,

clang/test/CodeGenHLSL/builtins/RasterizerOrderedBuffer-annotations.hlsl

Lines changed: 0 additions & 20 deletions
This file was deleted.

clang/test/CodeGenHLSL/builtins/StructuredBuffer-annotations.hlsl

Lines changed: 0 additions & 22 deletions
This file was deleted.

clang/test/CodeGenHLSL/builtins/StructuredBuffer-elementtype.hlsl

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,3 @@ void main(int GI : SV_GroupIndex) {
5454
half2 v12 = BufF16x2[GI];
5555
float3 v13 = BufF32x3[GI];
5656
}
57-
58-
// CHECK: !{{[0-9]+}} = !{ptr @BufI16, i32 10, i32 2,
59-
// CHECK: !{{[0-9]+}} = !{ptr @BufU16, i32 10, i32 3,
60-
// CHECK: !{{[0-9]+}} = !{ptr @BufI32, i32 10, i32 4,
61-
// CHECK: !{{[0-9]+}} = !{ptr @BufU32, i32 10, i32 5,
62-
// CHECK: !{{[0-9]+}} = !{ptr @BufI64, i32 10, i32 6,
63-
// CHECK: !{{[0-9]+}} = !{ptr @BufU64, i32 10, i32 7,
64-
// CHECK: !{{[0-9]+}} = !{ptr @BufF16, i32 10, i32 8,
65-
// CHECK: !{{[0-9]+}} = !{ptr @BufF32, i32 10, i32 9,
66-
// CHECK: !{{[0-9]+}} = !{ptr @BufF64, i32 10, i32 10,
67-
// CHECK: !{{[0-9]+}} = !{ptr @BufI16x4, i32 10, i32 2,
68-
// CHECK: !{{[0-9]+}} = !{ptr @BufU32x3, i32 10, i32 5,
69-
// CHECK: !{{[0-9]+}} = !{ptr @BufF16x2, i32 10, i32 8,
70-
// CHECK: !{{[0-9]+}} = !{ptr @BufF32x3, i32 10, i32 9,

clang/test/CodeGenHLSL/cbuf.hlsl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,4 @@ float foo() {
2323
}
2424

2525
// CHECK: !hlsl.cbufs = !{![[CBMD:[0-9]+]]}
26-
// CHECK: !hlsl.srvs = !{![[TBMD:[0-9]+]]}
2726
// CHECK: ![[CBMD]] = !{ptr @[[CB]], i32 13, i32 0, i1 false, i32 0, i32 2}
28-
// CHECK: ![[TBMD]] = !{ptr @[[TB]], i32 15, i32 0, i1 false, i32 2, i32 1}

0 commit comments

Comments
 (0)