2
0
Эх сурвалжийг харах

Misc codegen test improvements (#1918)

* Added "crashes" test directory.
* Renamed a few tests.
* Added a test for initialization of structs with empty fields.
* Added a test for numerical conversions in inout arguments.
* Moved the builtin type inheritance test from codegen to front-end tests.
Tristan Labelle 6 жил өмнө
parent
commit
c9d744fd88

+ 12 - 0
tools/clang/test/CodeGenHLSL/crashes/aggregate_truncation_conversion.hlsl

@@ -0,0 +1,12 @@
+// RUN: %dxc -E main -T vs_6_2 %s | FileCheck %s
+
+// Repro of GitHub #1799
+
+struct S1 { int a; };
+struct S2 { int a, b; };
+
+void main()
+{
+    S2 s2;
+    (S1)s2;
+}

+ 6 - 0
tools/clang/test/CodeGenHLSL/crashes/appendstructuredbuffer_bool.hlsl

@@ -0,0 +1,6 @@
+// RUN: %dxc -E main -T vs_6_2 %s | FileCheck %s
+
+// Repro of GitHub #1882
+
+AppendStructuredBuffer<bool> buf;
+void main() { buf.Append(true); }

+ 8 - 0
tools/clang/test/CodeGenHLSL/crashes/derived_to_base_argument_conversion.hlsl

@@ -0,0 +1,8 @@
+// RUN: %dxc -E main -T vs_6_2 %s | FileCheck %s
+
+// Repro of GitHub #1843
+
+struct Base {};
+struct Derived : Base { int a; };
+void f(Base b) {}
+void main() { Derived d; f(d); }

+ 8 - 0
tools/clang/test/CodeGenHLSL/crashes/equivalent_struct_argument_conversion.hlsl

@@ -0,0 +1,8 @@
+// RUN: %dxc -E main -T vs_6_2 %s | FileCheck %s
+
+// Repro of GitHub #1842
+
+struct S1 { int a, b; };
+struct S2 { int a, b; };
+void foo(S2 s) {}
+void main() { S1 s; foo(s); }

+ 6 - 0
tools/clang/test/CodeGenHLSL/crashes/inout_vector_numerical_conversion.hlsl

@@ -0,0 +1,6 @@
+// RUN: %dxc -E main -T vs_6_2 %s | FileCheck %s
+
+// Repro of GitHub #1916
+
+void inc_i32x2(inout int2 val) { val++; }
+void main(inout float2 f32x2 : F32X2) { inc_i32x2(f32x2); }

+ 7 - 0
tools/clang/test/CodeGenHLSL/crashes/matrix_to_aggregate_conversion.hlsl

@@ -0,0 +1,7 @@
+// RUN: %dxc -E main -T vs_6_2 %s | FileCheck %s
+
+// Repro of GitHub #1799
+
+typedef int ix4[4];
+void f(ix4) {}
+void main() { f((ix4)int2x2(1,2,3,4)); }

+ 5 - 0
tools/clang/test/CodeGenHLSL/crashes/run_all.cmd

@@ -0,0 +1,5 @@
+@echo off
+rem We can't run the whole directory at once because crashes stop execution.
+for /f "usebackq delims=|" %%f in (`dir /b "%~dp0"`) do (
+    %HLSL_SRC_DIR%\utils\hct\hcttest.cmd file-check "%~dp0\%%f"
+)

+ 9 - 0
tools/clang/test/CodeGenHLSL/crashes/static_const_struct_bool_matrix_subscript.hlsl

@@ -0,0 +1,9 @@
+// RUN: %dxc -E main -T vs_6_0 %s | FileCheck %s
+
+// Repro of GitHub #1881
+
+bool main() : OUT
+{
+    static const struct { bool2x2 x; } sm = { false, true, false, true };
+    return sm.x._11;
+}

+ 0 - 34
tools/clang/test/CodeGenHLSL/declarations/structs/builtin_types_no_inheritance.hlsl

@@ -1,34 +0,0 @@
-// RUN: %dxc -T vs_6_0 -E main %s | FileCheck %s
-
-// CHECK: error: base 'vector' is marked 'final'
-// CHECK: error: base 'matrix' is marked 'final'
-// CHECK: error: base 'Texture3D' is marked 'final'
-// CHECK: error: base 'ByteAddressBuffer' is marked 'final'
-// CHECK: error: base 'StructuredBuffer' is marked 'final'
-// CHECK: error: base 'SamplerState' is marked 'final'
-// CHECK: error: base 'TriangleStream' is marked 'final'
-// CHECK: error: base 'InputPatch' is marked 'final'
-// CHECK: error: base 'OutputPatch' is marked 'final'
-// CHECK: error: base 'RayDesc' is marked 'final'
-// CHECK: error: base 'BuiltInTriangleIntersectionAttributes' is marked 'final'
-// CHECK: error: base 'RaytracingAccelerationStructure' is marked 'final'
-// CHECK: error: base 'GlobalRootSignature' is marked 'final'
-
-struct F2 : float2 {};
-struct F4x4 : float4x4 {};
-struct Tex3D : Texture3D<float> {};
-struct BABuf : ByteAddressBuffer {};
-struct StructBuf : StructuredBuffer<int> {};
-struct Samp : SamplerState {};
-
-struct Vertex { float3 pos : POSITION; };
-struct GSTS : TriangleStream<Vertex> {};
-struct HSIP : InputPatch<Vertex, 16> {};
-struct HSOP : OutputPatch<Vertex, 16> {};
-
-struct RD : RayDesc {};
-struct BITIA : BuiltInTriangleIntersectionAttributes {};
-struct RTAS : RaytracingAccelerationStructure {};
-struct GRS : GlobalRootSignature {};
-
-void main() {}

+ 0 - 0
tools/clang/test/CodeGenHLSL/declarations/structs/declaration_in_return_type.hlsl → tools/clang/test/CodeGenHLSL/declarations/structs/declaration_in_return_type_error.hlsl


+ 20 - 0
tools/clang/test/CodeGenHLSL/declarations/structs/init_with_empty_field.hlsl

@@ -0,0 +1,20 @@
+// RUN: %dxc -E main -T vs_6_0 %s | FileCheck %s
+
+// Regression test for GitHub #1873, which caused an error
+// when initializing a struct containing an empty struct field.
+
+int2 main() : OUT
+{
+    struct
+    {
+        struct {} _1;
+        int x;
+        struct {} _2;
+        int y;
+        struct {} _3;
+    } s = { 1, 2 };
+
+    // CHECK: @dx.op.storeOutput.i32(i32 5, i32 0, i32 0, i8 0, i32 1)
+    // CHECK: @dx.op.storeOutput.i32(i32 5, i32 0, i32 0, i8 1, i32 2)
+    return int2(s.x, s.y);
+}

+ 13 - 0
tools/clang/test/CodeGenHLSL/expressions/conversions_and_casts/inout_numerical.hlsl

@@ -0,0 +1,13 @@
+// RUN: %dxc -E main -T vs_6_2 %s | FileCheck %s
+
+// Test that numerical conversions happen when binding to inout parameters,
+// both converting into and out of the parameter type.
+
+void inc_i32(inout int val) { val++; }
+void main(inout float f32 : F32)
+{
+    // CHECK: fptosi
+    // CHECK: add
+    // CHECK: sitofp
+    inc_i32(f32);
+}

+ 0 - 0
tools/clang/test/CodeGenHLSL/expressions/conversions_and_casts/numerical_indirect.hlsl → tools/clang/test/CodeGenHLSL/expressions/conversions_and_casts/numerical_flat_conversion.hlsl


+ 0 - 0
tools/clang/test/CodeGenHLSL/expressions/conversions_and_casts/numerical_to_compound_roundtrip.hlsl → tools/clang/test/CodeGenHLSL/expressions/conversions_and_casts/numerical_to_aggregate_roundtrip.hlsl


+ 20 - 0
tools/clang/test/HLSL/builtin-types-no-inheritance.hlsl

@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -Wno-unused-value -fsyntax-only -ffreestanding -verify -verify-ignore-unexpected=note %s
+
+struct F2 : float2 {}; // expected-error {{base 'vector' is marked 'final'}}
+struct F4x4 : float4x4 {}; // expected-error {{base 'matrix' is marked 'final'}}
+struct Tex3D : Texture3D<float> {};  // expected-error {{base 'Texture3D' is marked 'final'}}
+struct BABuf : ByteAddressBuffer {}; // expected-error {{base 'ByteAddressBuffer' is marked 'final'}}
+struct StructBuf : StructuredBuffer<int> {}; // expected-error {{base 'StructuredBuffer' is marked 'final'}}
+struct Samp : SamplerState {}; // expected-error {{base 'SamplerState' is marked 'final'}}
+
+struct Vertex { float3 pos : POSITION; };
+struct GSTS : TriangleStream<Vertex> {}; // expected-error {{base 'TriangleStream' is marked 'final'}}
+struct HSIP : InputPatch<Vertex, 16> {}; // expected-error {{base 'InputPatch' is marked 'final'}}
+struct HSOP : OutputPatch<Vertex, 16> {}; // expected-error {{base 'OutputPatch' is marked 'final'}}
+
+struct RD : RayDesc {}; // expected-error {{base 'RayDesc' is marked 'final'}}
+struct BITIA : BuiltInTriangleIntersectionAttributes {}; // expected-error {{base 'BuiltInTriangleIntersectionAttributes' is marked 'final'}}
+struct RTAS : RaytracingAccelerationStructure {}; // expected-error {{base 'RaytracingAccelerationStructure' is marked 'final'}}
+struct GRS : GlobalRootSignature {}; // expected-error {{base 'GlobalRootSignature' is marked 'final'}}
+
+void main() {}

+ 5 - 0
tools/clang/unittests/HLSL/VerifierTest.cpp

@@ -36,6 +36,7 @@ public:
 
   TEST_METHOD(RunArrayLength)
   TEST_METHOD(RunAttributes)
+  TEST_METHOD(RunBuiltinTypesNoInheritance)
   TEST_METHOD(RunConstExpr)
   TEST_METHOD(RunConstAssign)
   TEST_METHOD(RunConstDefault)
@@ -143,6 +144,10 @@ TEST_F(VerifierTest, RunAttributes) {
   CheckVerifiesHLSL(L"attributes.hlsl");
 }
 
+TEST_F(VerifierTest, RunBuiltinTypesNoInheritance) {
+  CheckVerifiesHLSL(L"builtin-types-no-inheritance.hlsl");
+}
+
 TEST_F(VerifierTest, RunConstExpr) {
   CheckVerifiesHLSL(L"const-expr.hlsl");
 }