blob: a83b2a73d20e875becc72cee024c3da61ff760c1 [file] [log] [blame]
James Price7a47fa82021-05-26 15:41:02 +00001#include <metal_stdlib>
2
3using namespace metal;
James Price0e22bdb2023-03-20 21:46:01 +00004struct tint_private_vars_struct {
5 int a;
6 int b;
7 int c;
8};
9
10void uses_a(thread tint_private_vars_struct* const tint_private_vars) {
11 (*(tint_private_vars)).a = as_type<int>((as_type<uint>((*(tint_private_vars)).a) + as_type<uint>(1)));
James Price7a47fa82021-05-26 15:41:02 +000012}
13
James Price0e22bdb2023-03-20 21:46:01 +000014void uses_b(thread tint_private_vars_struct* const tint_private_vars) {
15 (*(tint_private_vars)).b = as_type<int>((as_type<uint>((*(tint_private_vars)).b) * as_type<uint>(2)));
James Price7a47fa82021-05-26 15:41:02 +000016}
17
James Price0e22bdb2023-03-20 21:46:01 +000018void uses_a_and_b(thread tint_private_vars_struct* const tint_private_vars) {
19 (*(tint_private_vars)).b = (*(tint_private_vars)).a;
James Price7a47fa82021-05-26 15:41:02 +000020}
21
22void no_uses() {
23}
24
James Price0e22bdb2023-03-20 21:46:01 +000025void outer(thread tint_private_vars_struct* const tint_private_vars) {
26 (*(tint_private_vars)).a = 0;
27 uses_a(tint_private_vars);
28 uses_a_and_b(tint_private_vars);
29 uses_b(tint_private_vars);
James Price7a47fa82021-05-26 15:41:02 +000030 no_uses();
31}
32
33kernel void main1() {
James Price0e22bdb2023-03-20 21:46:01 +000034 thread tint_private_vars_struct tint_private_vars = {};
35 tint_private_vars.a = 42;
36 uses_a(&(tint_private_vars));
James Price7a47fa82021-05-26 15:41:02 +000037 return;
38}
39
40kernel void main2() {
James Price0e22bdb2023-03-20 21:46:01 +000041 thread tint_private_vars_struct tint_private_vars = {};
42 tint_private_vars.b = 7;
43 uses_b(&(tint_private_vars));
James Price7a47fa82021-05-26 15:41:02 +000044 return;
45}
46
47kernel void main3() {
James Price0e22bdb2023-03-20 21:46:01 +000048 thread tint_private_vars_struct tint_private_vars = {};
49 outer(&(tint_private_vars));
James Price7a47fa82021-05-26 15:41:02 +000050 no_uses();
51 return;
52}
53
54kernel void main4() {
55 no_uses();
56 return;
57}
58