From 28f0fe47012b1001a6047780a54c4d2b5b5c91c7 Mon Sep 17 00:00:00 2001 From: Tristan Labelle Date: Tue, 30 Apr 2019 10:50:43 -0700 Subject: [PATCH] Crashes and precise test updates (#2081) Adds crash tests for bugs #2077, and #2061. Removes crash test for closed bug #1882. Adds a bunch of tests for "precise" attribute, whose effects I just learned about. Lead to filing bugs #2078, #2079 and #2080 due to divergences in behavior with FXC. --- .../declarations/precise/array_elements.hlsl | 13 +++++++++++ .../declarations/precise/initializer.hlsl | 13 +++++++++++ .../batch/declarations/precise/matrix.hlsl | 19 ++++++++++++++++ .../declarations/precise/misc/precise.hlsl | 11 ---------- .../precise/propagate_to_consumers.hlsl | 13 +++++++++++ .../precise/propagate_to_producers.hlsl | 14 ++++++++++++ .../propagate_to_producers_interproc.hlsl | 22 +++++++++++++++++++ .../declarations/precise/static_variable.hlsl | 14 ++++++++++++ .../declarations/precise/struct_field.hlsl | 13 +++++++++++ .../precise/subsequent_assignment.hlsl | 15 +++++++++++++ .../batch/declarations/precise/vector.hlsl | 15 +++++++++++++ .../crashes/appendstructuredbuffer_bool.hlsl | 6 ----- .../crashes/interlocked_nonint.hlsl | 21 ++++++++++++++++++ .../crashes/static_array_resources.hlsl | 7 ++++++ 14 files changed, 179 insertions(+), 17 deletions(-) create mode 100644 tools/clang/test/CodeGenHLSL/batch/declarations/precise/array_elements.hlsl create mode 100644 tools/clang/test/CodeGenHLSL/batch/declarations/precise/initializer.hlsl create mode 100644 tools/clang/test/CodeGenHLSL/batch/declarations/precise/matrix.hlsl delete mode 100644 tools/clang/test/CodeGenHLSL/batch/declarations/precise/misc/precise.hlsl create mode 100644 tools/clang/test/CodeGenHLSL/batch/declarations/precise/propagate_to_consumers.hlsl create mode 100644 tools/clang/test/CodeGenHLSL/batch/declarations/precise/propagate_to_producers.hlsl create mode 100644 tools/clang/test/CodeGenHLSL/batch/declarations/precise/propagate_to_producers_interproc.hlsl create mode 100644 tools/clang/test/CodeGenHLSL/batch/declarations/precise/static_variable.hlsl create mode 100644 tools/clang/test/CodeGenHLSL/batch/declarations/precise/struct_field.hlsl create mode 100644 tools/clang/test/CodeGenHLSL/batch/declarations/precise/subsequent_assignment.hlsl create mode 100644 tools/clang/test/CodeGenHLSL/batch/declarations/precise/vector.hlsl delete mode 100644 tools/clang/test/CodeGenHLSL/crashes/appendstructuredbuffer_bool.hlsl create mode 100644 tools/clang/test/CodeGenHLSL/crashes/interlocked_nonint.hlsl create mode 100644 tools/clang/test/CodeGenHLSL/crashes/static_array_resources.hlsl diff --git a/tools/clang/test/CodeGenHLSL/batch/declarations/precise/array_elements.hlsl b/tools/clang/test/CodeGenHLSL/batch/declarations/precise/array_elements.hlsl new file mode 100644 index 000000000..adb66d13c --- /dev/null +++ b/tools/clang/test/CodeGenHLSL/batch/declarations/precise/array_elements.hlsl @@ -0,0 +1,13 @@ +// RUN: %dxc -E main -T vs_6_0 %s | FileCheck %s + +// Test that precise modifier on an array has an effect. + +// CHECK-NOT: fmul fast float +// CHECK: fmul float +// CHECK-NOT: fmul fast float + +float main(float f : IN) : OUT +{ + precise float a[1] = { f * f }; + return a[0]; +} \ No newline at end of file diff --git a/tools/clang/test/CodeGenHLSL/batch/declarations/precise/initializer.hlsl b/tools/clang/test/CodeGenHLSL/batch/declarations/precise/initializer.hlsl new file mode 100644 index 000000000..69a3909cc --- /dev/null +++ b/tools/clang/test/CodeGenHLSL/batch/declarations/precise/initializer.hlsl @@ -0,0 +1,13 @@ +// RUN: %dxc -E main -T vs_6_0 %s | FileCheck %s + +// Test that precise applies to the initializer of the variable. + +// CHECK-NOT: fmul fast float +// CHECK: fmul float +// CHECK-NOT: fmul fast float + +float main(float f : IN) : OUT +{ + precise float result = f * f; + return result; +} \ No newline at end of file diff --git a/tools/clang/test/CodeGenHLSL/batch/declarations/precise/matrix.hlsl b/tools/clang/test/CodeGenHLSL/batch/declarations/precise/matrix.hlsl new file mode 100644 index 000000000..266c93a55 --- /dev/null +++ b/tools/clang/test/CodeGenHLSL/batch/declarations/precise/matrix.hlsl @@ -0,0 +1,19 @@ +// RUN: %dxc -E main -T vs_6_0 %s | FileCheck %s | XFail GitHub #2080 + +// Test that precise modifier on a matrix has an effect. + +// CHECK-NOT: fmul fast float +// CHECK: fmul float +// CHECK-NOT: fmul fast float +// CHECK: fmul float +// CHECK-NOT: fmul fast float +// CHECK: fmul float +// CHECK-NOT: fmul fast float +// CHECK: fmul float +// CHECK-NOT: fmul fast float + +float2x2 main(float2x2 m : IN) : OUT +{ + precise float2x2 result = m * m; + return result; +} \ No newline at end of file diff --git a/tools/clang/test/CodeGenHLSL/batch/declarations/precise/misc/precise.hlsl b/tools/clang/test/CodeGenHLSL/batch/declarations/precise/misc/precise.hlsl deleted file mode 100644 index 7d4910e1a..000000000 --- a/tools/clang/test/CodeGenHLSL/batch/declarations/precise/misc/precise.hlsl +++ /dev/null @@ -1,11 +0,0 @@ -// RUN: %dxc -E main -T ps_6_0 %s | FileCheck %s - -// Make sure no fast on fadd -// CHECK: fadd float - -float x : register(b0); - -float main(float4 col : COLOR) : SV_Target { - precise float result = x + col; - return result; -} \ No newline at end of file diff --git a/tools/clang/test/CodeGenHLSL/batch/declarations/precise/propagate_to_consumers.hlsl b/tools/clang/test/CodeGenHLSL/batch/declarations/precise/propagate_to_consumers.hlsl new file mode 100644 index 000000000..1f8bc7c30 --- /dev/null +++ b/tools/clang/test/CodeGenHLSL/batch/declarations/precise/propagate_to_consumers.hlsl @@ -0,0 +1,13 @@ +// RUN: %dxc -E main -T vs_6_0 %s | FileCheck %s | XFail GitHub #2079 + +// Test that precise propagates to operations consuming the value. + +// CHECK-NOT: fmul fast float +// CHECK: fmul float +// CHECK-NOT: fmul fast float + +float main(float f : IN) : OUT +{ + precise float pf = f; + return pf * pf; +} \ No newline at end of file diff --git a/tools/clang/test/CodeGenHLSL/batch/declarations/precise/propagate_to_producers.hlsl b/tools/clang/test/CodeGenHLSL/batch/declarations/precise/propagate_to_producers.hlsl new file mode 100644 index 000000000..261fcdc0a --- /dev/null +++ b/tools/clang/test/CodeGenHLSL/batch/declarations/precise/propagate_to_producers.hlsl @@ -0,0 +1,14 @@ +// RUN: %dxc -E main -T vs_6_0 %s | FileCheck %s + +// Test that precise applies to instructions producing the value. + +// CHECK-NOT: fmul fast float +// CHECK: fmul float +// CHECK-NOT: fmul fast float + +float main(float f : IN) : OUT +{ + float square = f * f; + precise float result = square; + return result; +} \ No newline at end of file diff --git a/tools/clang/test/CodeGenHLSL/batch/declarations/precise/propagate_to_producers_interproc.hlsl b/tools/clang/test/CodeGenHLSL/batch/declarations/precise/propagate_to_producers_interproc.hlsl new file mode 100644 index 000000000..e8445bdad --- /dev/null +++ b/tools/clang/test/CodeGenHLSL/batch/declarations/precise/propagate_to_producers_interproc.hlsl @@ -0,0 +1,22 @@ +// RUN: %dxc -E main -T vs_6_0 %s | FileCheck %s + +// Test that precise applies retroactively to instructions +// producing a given value, interprocedurally. + +// CHECK-NOT: fmul fast float +// CHECK: fmul float +// CHECK-NOT: fmul fast float + +float square(float f) { return f * f; } + +float make_precise(float f) +{ + precise float pf = f; + return f; +} + +float main(float f : IN) : OUT +{ + float result = square(f); + return make_precise(result); +} \ No newline at end of file diff --git a/tools/clang/test/CodeGenHLSL/batch/declarations/precise/static_variable.hlsl b/tools/clang/test/CodeGenHLSL/batch/declarations/precise/static_variable.hlsl new file mode 100644 index 000000000..c50336d03 --- /dev/null +++ b/tools/clang/test/CodeGenHLSL/batch/declarations/precise/static_variable.hlsl @@ -0,0 +1,14 @@ +// RUN: %dxc -E main -T vs_6_0 %s | FileCheck %s | XFail GitHub #2078 + +// Test that the precise modifier applies to static variables. + +// CHECK-NOT: fmul fast float +// CHECK: fmul float +// CHECK-NOT: fmul fast float + +static precise float g; +float main(float f : IN) : OUT +{ + g = f * f; + return g; +} \ No newline at end of file diff --git a/tools/clang/test/CodeGenHLSL/batch/declarations/precise/struct_field.hlsl b/tools/clang/test/CodeGenHLSL/batch/declarations/precise/struct_field.hlsl new file mode 100644 index 000000000..d386e8ffa --- /dev/null +++ b/tools/clang/test/CodeGenHLSL/batch/declarations/precise/struct_field.hlsl @@ -0,0 +1,13 @@ +// RUN: %dxc -E main -T vs_6_0 %s | FileCheck %s + +// Test that precise modifier on a struct field has an effect. + +// CHECK-NOT: fmul fast float +// CHECK: fmul float +// CHECK-NOT: fmul fast float + +float main(float f : IN) : OUT +{ + struct { precise float f; } s = { f * f }; + return s.f; +} \ No newline at end of file diff --git a/tools/clang/test/CodeGenHLSL/batch/declarations/precise/subsequent_assignment.hlsl b/tools/clang/test/CodeGenHLSL/batch/declarations/precise/subsequent_assignment.hlsl new file mode 100644 index 000000000..f15f073bf --- /dev/null +++ b/tools/clang/test/CodeGenHLSL/batch/declarations/precise/subsequent_assignment.hlsl @@ -0,0 +1,15 @@ +// RUN: %dxc -E main -T vs_6_0 %s | FileCheck %s + +// Test that precise applies to the value producers +// after the initial assignment. + +// CHECK-NOT: fmul fast float +// CHECK: fmul float +// CHECK-NOT: fmul fast float + +float main(float f : IN) : OUT +{ + precise float result = 0; + result = f * f; + return result; +} \ No newline at end of file diff --git a/tools/clang/test/CodeGenHLSL/batch/declarations/precise/vector.hlsl b/tools/clang/test/CodeGenHLSL/batch/declarations/precise/vector.hlsl new file mode 100644 index 000000000..da7405b7c --- /dev/null +++ b/tools/clang/test/CodeGenHLSL/batch/declarations/precise/vector.hlsl @@ -0,0 +1,15 @@ +// RUN: %dxc -E main -T vs_6_0 %s | FileCheck %s + +// Test that precise modifier on a vector has an effect. + +// CHECK-NOT: fmul fast float +// CHECK: fmul float +// CHECK-NOT: fmul fast float +// CHECK: fmul float +// CHECK-NOT: fmul fast float + +float2 main(float2 v : IN) : OUT +{ + precise float2 result = v * v; + return result; +} \ No newline at end of file diff --git a/tools/clang/test/CodeGenHLSL/crashes/appendstructuredbuffer_bool.hlsl b/tools/clang/test/CodeGenHLSL/crashes/appendstructuredbuffer_bool.hlsl deleted file mode 100644 index e0854fc75..000000000 --- a/tools/clang/test/CodeGenHLSL/crashes/appendstructuredbuffer_bool.hlsl +++ /dev/null @@ -1,6 +0,0 @@ -// RUN: %dxc -E main -T vs_6_2 %s | FileCheck %s - -// Repro of GitHub #1882 - -AppendStructuredBuffer buf; -void main() { buf.Append(true); } \ No newline at end of file diff --git a/tools/clang/test/CodeGenHLSL/crashes/interlocked_nonint.hlsl b/tools/clang/test/CodeGenHLSL/crashes/interlocked_nonint.hlsl new file mode 100644 index 000000000..d3a9d5dae --- /dev/null +++ b/tools/clang/test/CodeGenHLSL/crashes/interlocked_nonint.hlsl @@ -0,0 +1,21 @@ +// RUN: %dxc -E main -T vs_6_2 %s | FileCheck %s + +// Repro of GitHub #2077 + +groupshared uint gs_uint; +groupshared int gs_int; +groupshared bool gs_bool; +groupshared float gs_float; +groupshared int16_t gs_int16; +groupshared int64_t gs_int64; + +void main() +{ + InterlockedAdd(gs_uint, 1); + InterlockedAdd(gs_int, 1); + // All the below crash + InterlockedAdd(gs_bool, 1); + InterlockedAdd(gs_float, 1); + InterlockedAdd(gs_int16, 1); + InterlockedAdd(gs_int64, 1); +} diff --git a/tools/clang/test/CodeGenHLSL/crashes/static_array_resources.hlsl b/tools/clang/test/CodeGenHLSL/crashes/static_array_resources.hlsl new file mode 100644 index 000000000..85781501b --- /dev/null +++ b/tools/clang/test/CodeGenHLSL/crashes/static_array_resources.hlsl @@ -0,0 +1,7 @@ +// RUN: %dxc -E main -T vs_6_2 %s | FileCheck %s + +// Repro of GitHub #2061 + +Buffer buf; +static Buffer bufs[1]; +void main() { bufs[0] = buf; } \ No newline at end of file