James Price | 7a47fa8 | 2021-05-26 15:41:02 +0000 | [diff] [blame] | 1 | #include <metal_stdlib> |
| 2 | |
| 3 | using namespace metal; |
James Price | 0e22bdb | 2023-03-20 21:46:01 +0000 | [diff] [blame] | 4 | struct tint_private_vars_struct { |
| 5 | int a; |
| 6 | int b; |
| 7 | int c; |
| 8 | }; |
| 9 | |
| 10 | void 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 Price | 7a47fa8 | 2021-05-26 15:41:02 +0000 | [diff] [blame] | 12 | } |
| 13 | |
James Price | 0e22bdb | 2023-03-20 21:46:01 +0000 | [diff] [blame] | 14 | void 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 Price | 7a47fa8 | 2021-05-26 15:41:02 +0000 | [diff] [blame] | 16 | } |
| 17 | |
James Price | 0e22bdb | 2023-03-20 21:46:01 +0000 | [diff] [blame] | 18 | void uses_a_and_b(thread tint_private_vars_struct* const tint_private_vars) { |
| 19 | (*(tint_private_vars)).b = (*(tint_private_vars)).a; |
James Price | 7a47fa8 | 2021-05-26 15:41:02 +0000 | [diff] [blame] | 20 | } |
| 21 | |
| 22 | void no_uses() { |
| 23 | } |
| 24 | |
James Price | 0e22bdb | 2023-03-20 21:46:01 +0000 | [diff] [blame] | 25 | void 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 Price | 7a47fa8 | 2021-05-26 15:41:02 +0000 | [diff] [blame] | 30 | no_uses(); |
| 31 | } |
| 32 | |
| 33 | kernel void main1() { |
James Price | 0e22bdb | 2023-03-20 21:46:01 +0000 | [diff] [blame] | 34 | thread tint_private_vars_struct tint_private_vars = {}; |
| 35 | tint_private_vars.a = 42; |
| 36 | uses_a(&(tint_private_vars)); |
James Price | 7a47fa8 | 2021-05-26 15:41:02 +0000 | [diff] [blame] | 37 | return; |
| 38 | } |
| 39 | |
| 40 | kernel void main2() { |
James Price | 0e22bdb | 2023-03-20 21:46:01 +0000 | [diff] [blame] | 41 | thread tint_private_vars_struct tint_private_vars = {}; |
| 42 | tint_private_vars.b = 7; |
| 43 | uses_b(&(tint_private_vars)); |
James Price | 7a47fa8 | 2021-05-26 15:41:02 +0000 | [diff] [blame] | 44 | return; |
| 45 | } |
| 46 | |
| 47 | kernel void main3() { |
James Price | 0e22bdb | 2023-03-20 21:46:01 +0000 | [diff] [blame] | 48 | thread tint_private_vars_struct tint_private_vars = {}; |
| 49 | outer(&(tint_private_vars)); |
James Price | 7a47fa8 | 2021-05-26 15:41:02 +0000 | [diff] [blame] | 50 | no_uses(); |
| 51 | return; |
| 52 | } |
| 53 | |
| 54 | kernel void main4() { |
| 55 | no_uses(); |
| 56 | return; |
| 57 | } |
| 58 | |