[llvm] [DirectX] Implement Shader Flag Analysis for `UAVsAtEveryStage` (PR #137085)

Deric C. via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 25 11:33:47 PDT 2025


================
@@ -0,0 +1,39 @@
+; RUN: opt -S --passes="print-dx-shader-flags" 2>&1 %s | FileCheck %s
+; RUN: llc %s --filetype=obj -o - | obj2yaml | FileCheck %s --check-prefix=DXC
+
+; This test ensures that a library shader with a UAV gets the module and
+; shader feature flag UAVsAtEveryStage when the DXIL validator version is < 1.8
+
+target triple = "dxil-pc-shadermodel6.5-library"
+
+; CHECK:      Combined Shader Flags for Module
+; CHECK-NEXT: Shader Flags Value: 0x00010000
+
+; CHECK: Note: shader requires additional functionality:
+; CHECK:        UAVs at every shader stage
+
+; CHECK: Function test : 0x00000000
+define void @test() "hlsl.export" {
+  ; RWBuffer<float> Buf : register(u0, space0)
+  %buf0 = call target("dx.TypedBuffer", float, 1, 0, 1)
+       @llvm.dx.resource.handlefrombinding.tdx.TypedBuffer_f32_1_0t(
+           i32 0, i32 0, i32 1, i32 0, i1 false)
+  ret void
+}
+
+!dx.valver = !{!1}
+!1 = !{i32 1, i32 7}
+
+; Set dx.resmayalias to prevent the shader flag ResMayNotAlias from being set,
+; as to not distract from the shader flag that is actually being tested
+!llvm.module.flags = !{!0}
+!0 = !{i32 1, !"dx.resmayalias", i32 1}
+
+; DXC: - Name:            SFI0
+; DXC-NEXT:     Size:            8
+; DXC-NEXT:     Flags:
+; DXC-NOT:   {{[A-Za-z]+: +true}}
----------------
Icohedron wrote:

Yea, I think I agree.
A separate PR should also be made to remove similar checks from other shader flag tests like [doubles.ll](https://github.com/llvm/llvm-project/blob/3e4e365fac0503d9fcd9bb34ee1c27bf17d95e3a/llvm/test/CodeGen/DirectX/ShaderFlags/doubles.ll#L25-L27)

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


More information about the llvm-commits mailing list