[llvm] 6bad175 - [SPIRV][DX] Share one test between backends (#65975)

via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 21 03:15:59 PDT 2023


Author: Nathan Gauër
Date: 2023-09-21T12:15:55+02:00
New Revision: 6bad175a872d9443b07069cd67c4682af594deb0

URL: https://github.com/llvm/llvm-project/commit/6bad175a872d9443b07069cd67c4682af594deb0
DIFF: https://github.com/llvm/llvm-project/commit/6bad175a872d9443b07069cd67c4682af594deb0.diff

LOG: [SPIRV][DX] Share one test between backends (#65975)

One big issue with DirectXShaderCompiler was test coverage: DXIL and
SPIR-V backends had their own tests. When a bug was found in one, the
other wasn't always checked. This lead to unequal support of HLSL for
both backends. We'd like to avoid those issues here, hence the
test-sharing.

By default, all the tests in this folder are marked as requiring
DirectX. But as SPIR-V support grows, each test drop this requirement,
and check the SPIR-V behavior.

I would have preferred to mark new tests as XFAIL for SPIR-V by default,
so we could differentiate real unsupported tests (as SPIR-V has no
equivalent), from newly added tests. But the way LIT is built, I don't
think this is possible.

---------

Signed-off-by: Nathan Gauër <brioche at google.com>

Added: 
    llvm/test/Frontend/HLSL/empty_cs_entry.ll
    llvm/test/Frontend/HLSL/lit.local.cfg

Modified: 
    

Removed: 
    llvm/test/CodeGen/DirectX/empty_cs_entry.ll


################################################################################
diff  --git a/llvm/test/CodeGen/DirectX/empty_cs_entry.ll b/llvm/test/CodeGen/DirectX/empty_cs_entry.ll
deleted file mode 100644
index 5fe8461c1eaef5d..000000000000000
--- a/llvm/test/CodeGen/DirectX/empty_cs_entry.ll
+++ /dev/null
@@ -1,17 +0,0 @@
-; RUN: opt -S -dxil-metadata-emit < %s | FileCheck %s
-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-compute"
-
-;CHECK:!dx.entryPoints = !{![[entry:[0-9]+]]}
-
-;CHECK:![[entry]] = !{ptr @entry, !"entry", null, null, ![[extra:[0-9]+]]}
-;CHECK:![[extra]] = !{i32 4, ![[numthreads:[0-9]+]]}
-;CHECK:![[numthreads]] = !{i32 1, i32 2, i32 1}
-
-; Function Attrs: noinline nounwind
-define void @entry() #0 {
-entry:
-  ret void
-}
-
-attributes #0 = { noinline nounwind "hlsl.numthreads"="1,2,1" "hlsl.shader"="compute" }

diff  --git a/llvm/test/Frontend/HLSL/empty_cs_entry.ll b/llvm/test/Frontend/HLSL/empty_cs_entry.ll
new file mode 100644
index 000000000000000..45b0faeaa44d441
--- /dev/null
+++ b/llvm/test/Frontend/HLSL/empty_cs_entry.ll
@@ -0,0 +1,27 @@
+; RUN: %if directx-registered-target %{ opt -S -dxil-metadata-emit < %s | FileCheck %s --check-prefix=DXIL-CHECK %}
+; RUN: %if spirv-registered-target   %{ llc %s -mtriple=spirv-unknown-unknown -o - | FileCheck %s --check-prefix=SPIRV-CHECK %}
+
+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-compute"
+
+;DXIL-CHECK:!dx.entryPoints = !{![[entry:[0-9]+]]}
+
+;DXIL-CHECK:![[entry]] = !{ptr @entry, !"entry", null, null, ![[extra:[0-9]+]]}
+;DXIL-CHECK:![[extra]] = !{i32 4, ![[numthreads:[0-9]+]]}
+;DXIL-CHECK:![[numthreads]] = !{i32 1, i32 2, i32 1}
+
+;SPIRV-CHECK:                     OpCapability Shader
+;SPIRV-CHECK:                     OpMemoryModel Logical GLSL450
+;SPIRV-CHECK:                     OpEntryPoint GLCompute [[main:%[0-9]+]] "entry"
+;SPIRV-CHECK:                     OpExecutionMode [[main]] LocalSize 1 2 1
+;SPIRV-CHECK:  [[void:%[0-9]+]] = OpTypeVoid
+;SPIRV-CHECK: [[ftype:%[0-9]+]] = OpTypeFunction [[void]]
+;SPIRV-CHECK:          [[main]] = OpFunction [[void]] DontInline [[ftype]]
+
+; Function Attrs: noinline nounwind
+define void @entry() #0 {
+entry:
+  ret void
+}
+
+attributes #0 = { noinline nounwind "hlsl.numthreads"="1,2,1" "hlsl.shader"="compute" }

diff  --git a/llvm/test/Frontend/HLSL/lit.local.cfg b/llvm/test/Frontend/HLSL/lit.local.cfg
new file mode 100644
index 000000000000000..64cee7df91dc963
--- /dev/null
+++ b/llvm/test/Frontend/HLSL/lit.local.cfg
@@ -0,0 +1,2 @@
+if not "DirectX" in config.root.targets and not "SPIRV" in config.root.targets:
+    config.unsupported = True


        


More information about the llvm-commits mailing list