test: Add tests to verify variables are zero initialized

Bug: tint:938
Fixed: tint:759
Change-Id: I5794d7f40ec154c55240b163316ed45c7f14b190
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56547
Reviewed-by: James Price <jrprice@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
Ben Clayton
2021-06-30 15:59:40 +00:00
committed by Tint LUCI CQ
parent 71a1f58537
commit fb4e751258
75 changed files with 1198 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
[[stage(compute), workgroup_size(1)]]
fn main() {
var v : array<i32, 3>;
ignore(v);
}

View File

@@ -0,0 +1,10 @@
struct tint_array_wrapper {
int arr[3];
};
[numthreads(1, 1, 1)]
void main() {
tint_array_wrapper v = {{0, 0, 0}};
v;
return;
}

View File

@@ -0,0 +1,13 @@
#include <metal_stdlib>
using namespace metal;
struct tint_array_wrapper {
int arr[3];
};
kernel void tint_symbol() {
tint_array_wrapper v = {};
(void) v;
return;
}

View File

@@ -0,0 +1,26 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 14
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %main "main"
OpExecutionMode %main LocalSize 1 1 1
OpName %main "main"
OpName %v "v"
OpDecorate %_arr_int_uint_3 ArrayStride 4
%void = OpTypeVoid
%1 = OpTypeFunction %void
%int = OpTypeInt 32 1
%uint = OpTypeInt 32 0
%uint_3 = OpConstant %uint 3
%_arr_int_uint_3 = OpTypeArray %int %uint_3
%_ptr_Function__arr_int_uint_3 = OpTypePointer Function %_arr_int_uint_3
%11 = OpConstantNull %_arr_int_uint_3
%main = OpFunction %void None %1
%4 = OpLabel
%v = OpVariable %_ptr_Function__arr_int_uint_3 Function %11
%13 = OpLoad %_arr_int_uint_3 %v
OpReturn
OpFunctionEnd

View File

@@ -0,0 +1,5 @@
[[stage(compute), workgroup_size(1)]]
fn main() {
var v : array<i32, 3>;
ignore(v);
}

View File

@@ -0,0 +1,5 @@
[[stage(compute), workgroup_size(1)]]
fn main() {
var v : mat2x3<f32>;
ignore(v);
}

View File

@@ -0,0 +1,6 @@
[numthreads(1, 1, 1)]
void main() {
float2x3 v = float2x3(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
v;
return;
}

View File

@@ -0,0 +1,9 @@
#include <metal_stdlib>
using namespace metal;
kernel void tint_symbol() {
float2x3 v = float2x3(0.0f);
(void) v;
return;
}

View File

@@ -0,0 +1,24 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 13
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %main "main"
OpExecutionMode %main LocalSize 1 1 1
OpName %main "main"
OpName %v "v"
%void = OpTypeVoid
%1 = OpTypeFunction %void
%float = OpTypeFloat 32
%v3float = OpTypeVector %float 3
%mat2v3float = OpTypeMatrix %v3float 2
%_ptr_Function_mat2v3float = OpTypePointer Function %mat2v3float
%10 = OpConstantNull %mat2v3float
%main = OpFunction %void None %1
%4 = OpLabel
%v = OpVariable %_ptr_Function_mat2v3float Function %10
%12 = OpLoad %mat2v3float %v
OpReturn
OpFunctionEnd

View File

@@ -0,0 +1,5 @@
[[stage(compute), workgroup_size(1)]]
fn main() {
var v : mat2x3<f32>;
ignore(v);
}

View File

@@ -0,0 +1,5 @@
[[stage(compute), workgroup_size(1)]]
fn main() {
var v : i32;
ignore(v);
}

View File

@@ -0,0 +1,6 @@
[numthreads(1, 1, 1)]
void main() {
int v = 0;
v;
return;
}

View File

@@ -0,0 +1,9 @@
#include <metal_stdlib>
using namespace metal;
kernel void tint_symbol() {
int v = 0;
(void) v;
return;
}

View File

@@ -0,0 +1,22 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 11
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %main "main"
OpExecutionMode %main LocalSize 1 1 1
OpName %main "main"
OpName %v "v"
%void = OpTypeVoid
%1 = OpTypeFunction %void
%int = OpTypeInt 32 1
%_ptr_Function_int = OpTypePointer Function %int
%8 = OpConstantNull %int
%main = OpFunction %void None %1
%4 = OpLabel
%v = OpVariable %_ptr_Function_int Function %8
%10 = OpLoad %int %v
OpReturn
OpFunctionEnd

View File

@@ -0,0 +1,5 @@
[[stage(compute), workgroup_size(1)]]
fn main() {
var v : i32;
ignore(v);
}

View File

@@ -0,0 +1,10 @@
struct S {
a : i32;
b : f32;
};
[[stage(compute), workgroup_size(1)]]
fn main() {
var v : S;
ignore(v);
}

View File

@@ -0,0 +1,11 @@
struct S {
int a;
float b;
};
[numthreads(1, 1, 1)]
void main() {
S v = {0, 0.0f};
v;
return;
}

View File

@@ -0,0 +1,14 @@
#include <metal_stdlib>
using namespace metal;
struct S {
int a;
float b;
};
kernel void tint_symbol() {
S v = {};
(void) v;
return;
}

View File

@@ -0,0 +1,29 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 13
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %main "main"
OpExecutionMode %main LocalSize 1 1 1
OpName %main "main"
OpName %S "S"
OpMemberName %S 0 "a"
OpMemberName %S 1 "b"
OpName %v "v"
OpMemberDecorate %S 0 Offset 0
OpMemberDecorate %S 1 Offset 4
%void = OpTypeVoid
%1 = OpTypeFunction %void
%int = OpTypeInt 32 1
%float = OpTypeFloat 32
%S = OpTypeStruct %int %float
%_ptr_Function_S = OpTypePointer Function %S
%10 = OpConstantNull %S
%main = OpFunction %void None %1
%4 = OpLabel
%v = OpVariable %_ptr_Function_S Function %10
%12 = OpLoad %S %v
OpReturn
OpFunctionEnd

View File

@@ -0,0 +1,10 @@
struct S {
a : i32;
b : f32;
};
[[stage(compute), workgroup_size(1)]]
fn main() {
var v : S;
ignore(v);
}

View File

@@ -0,0 +1,5 @@
[[stage(compute), workgroup_size(1)]]
fn main() {
var v : vec3<i32>;
ignore(v);
}

View File

@@ -0,0 +1,6 @@
[numthreads(1, 1, 1)]
void main() {
int3 v = int3(0, 0, 0);
v;
return;
}

View File

@@ -0,0 +1,9 @@
#include <metal_stdlib>
using namespace metal;
kernel void tint_symbol() {
int3 v = 0;
(void) v;
return;
}

View File

@@ -0,0 +1,23 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 12
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %main "main"
OpExecutionMode %main LocalSize 1 1 1
OpName %main "main"
OpName %v "v"
%void = OpTypeVoid
%1 = OpTypeFunction %void
%int = OpTypeInt 32 1
%v3int = OpTypeVector %int 3
%_ptr_Function_v3int = OpTypePointer Function %v3int
%9 = OpConstantNull %v3int
%main = OpFunction %void None %1
%4 = OpLabel
%v = OpVariable %_ptr_Function_v3int Function %9
%11 = OpLoad %v3int %v
OpReturn
OpFunctionEnd

View File

@@ -0,0 +1,5 @@
[[stage(compute), workgroup_size(1)]]
fn main() {
var v : vec3<i32>;
ignore(v);
}