msl: Fold &* when converting module-scope vars

This transform was previously converting this code:
```
var<private> v : f32;
fn foo() {
  bar(&v);
}
```

into this:
```
fn foo(vp : ptr<private, f32>) {
  bar(&*vp); // Invalid, since ptr args must be &ident
}
```

Fixed: tint:1086
Change-Id: Ic9efafa219c89a11a4d6e1d11fc69b3c0b9a5464
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/60520
Kokoro: Kokoro <noreply+kokoro@google.com>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
diff --git a/src/transform/msl.cc b/src/transform/msl.cc
index 5c86a03..54f20b2 100644
--- a/src/transform/msl.cc
+++ b/src/transform/msl.cc
@@ -181,6 +181,23 @@
     }
   }
 
+  // Build a list of `&ident` expressions. We'll use this later to avoid
+  // generating expressions of the form `&*ident`, which break WGSL validation
+  // rules when this expression is passed to a function.
+  // TODO(jrprice): We should add support for bidirectional SEM tree traversal
+  // so that we can do this on the fly instead.
+  std::unordered_map<ast::IdentifierExpression*, ast::UnaryOpExpression*>
+      ident_to_address_of;
+  for (auto* node : ctx.src->ASTNodes().Objects()) {
+    auto* address_of = node->As<ast::UnaryOpExpression>();
+    if (!address_of || address_of->op() != ast::UnaryOp::kAddressOf) {
+      continue;
+    }
+    if (auto* ident = address_of->expr()->As<ast::IdentifierExpression>()) {
+      ident_to_address_of[ident] = address_of;
+    }
+  }
+
   for (auto* func_ast : functions_to_process) {
     auto* func_sem = ctx.src->Sem().Get(func_ast);
     bool is_entry_point = func_ast->IsEntryPoint();
@@ -241,6 +258,15 @@
         if (user->Stmt()->Function() == func_ast) {
           ast::Expression* expr = ctx.dst->Expr(new_var_symbol);
           if (!is_entry_point && !store_type->is_handle()) {
+            // If this identifier is used by an address-of operator, just remove
+            // the address-of instead of adding a deref, since we already have a
+            // pointer.
+            auto* ident = user->Declaration()->As<ast::IdentifierExpression>();
+            if (ident_to_address_of.count(ident)) {
+              ctx.Replace(ident_to_address_of[ident], expr);
+              continue;
+            }
+
             expr = ctx.dst->Deref(expr);
           }
           ctx.Replace(user->Declaration(), expr);
diff --git a/test/bug/tint/1086.wgsl b/test/bug/tint/1086.wgsl
new file mode 100644
index 0000000..6273135
--- /dev/null
+++ b/test/bug/tint/1086.wgsl
@@ -0,0 +1,14 @@
+var<private> v : f32;
+
+fn x(p : ptr<private, f32>) {
+  (*p) = 0.0;
+}
+
+fn g() {
+  x(&v);
+}
+
+[[stage(fragment)]]
+fn f() {
+  g();
+}
diff --git a/test/bug/tint/1086.wgsl.expected.hlsl b/test/bug/tint/1086.wgsl.expected.hlsl
new file mode 100644
index 0000000..c161767
--- /dev/null
+++ b/test/bug/tint/1086.wgsl.expected.hlsl
@@ -0,0 +1,14 @@
+static float v = 0.0f;
+
+void x(inout float p) {
+  p = 0.0f;
+}
+
+void g() {
+  x(v);
+}
+
+void f() {
+  g();
+  return;
+}
diff --git a/test/bug/tint/1086.wgsl.expected.msl b/test/bug/tint/1086.wgsl.expected.msl
new file mode 100644
index 0000000..b75a05c
--- /dev/null
+++ b/test/bug/tint/1086.wgsl.expected.msl
@@ -0,0 +1,17 @@
+#include <metal_stdlib>
+
+using namespace metal;
+void x(thread float* const p) {
+  *(p) = 0.0f;
+}
+
+void g(thread float* const tint_symbol) {
+  x(tint_symbol);
+}
+
+fragment void f() {
+  thread float tint_symbol_1 = 0.0f;
+  g(&(tint_symbol_1));
+  return;
+}
+
diff --git a/test/bug/tint/1086.wgsl.expected.spvasm b/test/bug/tint/1086.wgsl.expected.spvasm
new file mode 100644
index 0000000..c2a13c6
--- /dev/null
+++ b/test/bug/tint/1086.wgsl.expected.spvasm
@@ -0,0 +1,38 @@
+; SPIR-V
+; Version: 1.3
+; Generator: Google Tint Compiler; 0
+; Bound: 20
+; Schema: 0
+               OpCapability Shader
+               OpMemoryModel Logical GLSL450
+               OpEntryPoint Fragment %f "f"
+               OpExecutionMode %f OriginUpperLeft
+               OpName %v "v"
+               OpName %x "x"
+               OpName %p "p"
+               OpName %g "g"
+               OpName %f "f"
+      %float = OpTypeFloat 32
+%_ptr_Private_float = OpTypePointer Private %float
+          %4 = OpConstantNull %float
+          %v = OpVariable %_ptr_Private_float Private %4
+       %void = OpTypeVoid
+          %5 = OpTypeFunction %void %_ptr_Private_float
+    %float_0 = OpConstant %float 0
+         %12 = OpTypeFunction %void
+          %x = OpFunction %void None %5
+          %p = OpFunctionParameter %_ptr_Private_float
+          %9 = OpLabel
+               OpStore %p %float_0
+               OpReturn
+               OpFunctionEnd
+          %g = OpFunction %void None %12
+         %14 = OpLabel
+         %15 = OpFunctionCall %void %x %v
+               OpReturn
+               OpFunctionEnd
+          %f = OpFunction %void None %12
+         %18 = OpLabel
+         %19 = OpFunctionCall %void %g
+               OpReturn
+               OpFunctionEnd
diff --git a/test/bug/tint/1086.wgsl.expected.wgsl b/test/bug/tint/1086.wgsl.expected.wgsl
new file mode 100644
index 0000000..dbc74be
--- /dev/null
+++ b/test/bug/tint/1086.wgsl.expected.wgsl
@@ -0,0 +1,14 @@
+var<private> v : f32;
+
+fn x(p : ptr<private, f32>) {
+  *(p) = 0.0;
+}
+
+fn g() {
+  x(&(v));
+}
+
+[[stage(fragment)]]
+fn f() {
+  g();
+}
diff --git a/test/intrinsics/gen/atomicAdd/794055.wgsl.expected.msl b/test/intrinsics/gen/atomicAdd/794055.wgsl.expected.msl
index 3ea62a4..833e7a1 100644
--- a/test/intrinsics/gen/atomicAdd/794055.wgsl.expected.msl
+++ b/test/intrinsics/gen/atomicAdd/794055.wgsl.expected.msl
@@ -2,7 +2,7 @@
 
 using namespace metal;
 void atomicAdd_794055(threadgroup atomic_int* const tint_symbol_1) {
-  int res = atomic_fetch_add_explicit(&(*(tint_symbol_1)), 1, memory_order_relaxed);
+  int res = atomic_fetch_add_explicit(tint_symbol_1, 1, memory_order_relaxed);
 }
 
 kernel void compute_main(uint local_invocation_index [[thread_index_in_threadgroup]]) {
diff --git a/test/intrinsics/gen/atomicAdd/d5db1d.wgsl.expected.msl b/test/intrinsics/gen/atomicAdd/d5db1d.wgsl.expected.msl
index 4e6657e..ed759ba 100644
--- a/test/intrinsics/gen/atomicAdd/d5db1d.wgsl.expected.msl
+++ b/test/intrinsics/gen/atomicAdd/d5db1d.wgsl.expected.msl
@@ -2,7 +2,7 @@
 
 using namespace metal;
 void atomicAdd_d5db1d(threadgroup atomic_uint* const tint_symbol_1) {
-  uint res = atomic_fetch_add_explicit(&(*(tint_symbol_1)), 1u, memory_order_relaxed);
+  uint res = atomic_fetch_add_explicit(tint_symbol_1, 1u, memory_order_relaxed);
 }
 
 kernel void compute_main(uint local_invocation_index [[thread_index_in_threadgroup]]) {
diff --git a/test/intrinsics/gen/atomicAnd/34edd3.wgsl.expected.msl b/test/intrinsics/gen/atomicAnd/34edd3.wgsl.expected.msl
index a0c92bc..4d0eeda 100644
--- a/test/intrinsics/gen/atomicAnd/34edd3.wgsl.expected.msl
+++ b/test/intrinsics/gen/atomicAnd/34edd3.wgsl.expected.msl
@@ -2,7 +2,7 @@
 
 using namespace metal;
 void atomicAnd_34edd3(threadgroup atomic_uint* const tint_symbol_1) {
-  uint res = atomic_fetch_and_explicit(&(*(tint_symbol_1)), 1u, memory_order_relaxed);
+  uint res = atomic_fetch_and_explicit(tint_symbol_1, 1u, memory_order_relaxed);
 }
 
 kernel void compute_main(uint local_invocation_index [[thread_index_in_threadgroup]]) {
diff --git a/test/intrinsics/gen/atomicAnd/45a819.wgsl.expected.msl b/test/intrinsics/gen/atomicAnd/45a819.wgsl.expected.msl
index 61f1513..d861eae 100644
--- a/test/intrinsics/gen/atomicAnd/45a819.wgsl.expected.msl
+++ b/test/intrinsics/gen/atomicAnd/45a819.wgsl.expected.msl
@@ -2,7 +2,7 @@
 
 using namespace metal;
 void atomicAnd_45a819(threadgroup atomic_int* const tint_symbol_1) {
-  int res = atomic_fetch_and_explicit(&(*(tint_symbol_1)), 1, memory_order_relaxed);
+  int res = atomic_fetch_and_explicit(tint_symbol_1, 1, memory_order_relaxed);
 }
 
 kernel void compute_main(uint local_invocation_index [[thread_index_in_threadgroup]]) {
diff --git a/test/intrinsics/gen/atomicCompareExchangeWeak/89ea3b.wgsl.expected.msl b/test/intrinsics/gen/atomicCompareExchangeWeak/89ea3b.wgsl.expected.msl
index 498a795..a9f790f 100644
--- a/test/intrinsics/gen/atomicCompareExchangeWeak/89ea3b.wgsl.expected.msl
+++ b/test/intrinsics/gen/atomicCompareExchangeWeak/89ea3b.wgsl.expected.msl
@@ -10,7 +10,7 @@
 }
 
 void atomicCompareExchangeWeak_89ea3b(threadgroup atomic_int* const tint_symbol_1) {
-  int2 res = atomicCompareExchangeWeak_1(&(*(tint_symbol_1)), 1, 1);
+  int2 res = atomicCompareExchangeWeak_1(tint_symbol_1, 1, 1);
 }
 
 kernel void compute_main(uint local_invocation_index [[thread_index_in_threadgroup]]) {
diff --git a/test/intrinsics/gen/atomicCompareExchangeWeak/b2ab2c.wgsl.expected.msl b/test/intrinsics/gen/atomicCompareExchangeWeak/b2ab2c.wgsl.expected.msl
index 069071c..1f38df8 100644
--- a/test/intrinsics/gen/atomicCompareExchangeWeak/b2ab2c.wgsl.expected.msl
+++ b/test/intrinsics/gen/atomicCompareExchangeWeak/b2ab2c.wgsl.expected.msl
@@ -10,7 +10,7 @@
 }
 
 void atomicCompareExchangeWeak_b2ab2c(threadgroup atomic_uint* const tint_symbol_1) {
-  uint2 res = atomicCompareExchangeWeak_1(&(*(tint_symbol_1)), 1u, 1u);
+  uint2 res = atomicCompareExchangeWeak_1(tint_symbol_1, 1u, 1u);
 }
 
 kernel void compute_main(uint local_invocation_index [[thread_index_in_threadgroup]]) {
diff --git a/test/intrinsics/gen/atomicExchange/0a5dca.wgsl.expected.msl b/test/intrinsics/gen/atomicExchange/0a5dca.wgsl.expected.msl
index b6b483b..577ae12 100644
--- a/test/intrinsics/gen/atomicExchange/0a5dca.wgsl.expected.msl
+++ b/test/intrinsics/gen/atomicExchange/0a5dca.wgsl.expected.msl
@@ -2,7 +2,7 @@
 
 using namespace metal;
 void atomicExchange_0a5dca(threadgroup atomic_uint* const tint_symbol_1) {
-  uint res = atomic_exchange_explicit(&(*(tint_symbol_1)), 1u, memory_order_relaxed);
+  uint res = atomic_exchange_explicit(tint_symbol_1, 1u, memory_order_relaxed);
 }
 
 kernel void compute_main(uint local_invocation_index [[thread_index_in_threadgroup]]) {
diff --git a/test/intrinsics/gen/atomicExchange/e114ba.wgsl.expected.msl b/test/intrinsics/gen/atomicExchange/e114ba.wgsl.expected.msl
index 806d868..ed4cb6f 100644
--- a/test/intrinsics/gen/atomicExchange/e114ba.wgsl.expected.msl
+++ b/test/intrinsics/gen/atomicExchange/e114ba.wgsl.expected.msl
@@ -2,7 +2,7 @@
 
 using namespace metal;
 void atomicExchange_e114ba(threadgroup atomic_int* const tint_symbol_1) {
-  int res = atomic_exchange_explicit(&(*(tint_symbol_1)), 1, memory_order_relaxed);
+  int res = atomic_exchange_explicit(tint_symbol_1, 1, memory_order_relaxed);
 }
 
 kernel void compute_main(uint local_invocation_index [[thread_index_in_threadgroup]]) {
diff --git a/test/intrinsics/gen/atomicLoad/361bf1.wgsl.expected.msl b/test/intrinsics/gen/atomicLoad/361bf1.wgsl.expected.msl
index 144084f..a3a6422 100644
--- a/test/intrinsics/gen/atomicLoad/361bf1.wgsl.expected.msl
+++ b/test/intrinsics/gen/atomicLoad/361bf1.wgsl.expected.msl
@@ -2,7 +2,7 @@
 
 using namespace metal;
 void atomicLoad_361bf1(threadgroup atomic_uint* const tint_symbol_1) {
-  uint res = atomic_load_explicit(&(*(tint_symbol_1)), memory_order_relaxed);
+  uint res = atomic_load_explicit(tint_symbol_1, memory_order_relaxed);
 }
 
 kernel void compute_main(uint local_invocation_index [[thread_index_in_threadgroup]]) {
diff --git a/test/intrinsics/gen/atomicLoad/afcc03.wgsl.expected.msl b/test/intrinsics/gen/atomicLoad/afcc03.wgsl.expected.msl
index e2b1e2e..2bb6995 100644
--- a/test/intrinsics/gen/atomicLoad/afcc03.wgsl.expected.msl
+++ b/test/intrinsics/gen/atomicLoad/afcc03.wgsl.expected.msl
@@ -2,7 +2,7 @@
 
 using namespace metal;
 void atomicLoad_afcc03(threadgroup atomic_int* const tint_symbol_1) {
-  int res = atomic_load_explicit(&(*(tint_symbol_1)), memory_order_relaxed);
+  int res = atomic_load_explicit(tint_symbol_1, memory_order_relaxed);
 }
 
 kernel void compute_main(uint local_invocation_index [[thread_index_in_threadgroup]]) {
diff --git a/test/intrinsics/gen/atomicMax/a89cc3.wgsl.expected.msl b/test/intrinsics/gen/atomicMax/a89cc3.wgsl.expected.msl
index 32a298a..7e7430e 100644
--- a/test/intrinsics/gen/atomicMax/a89cc3.wgsl.expected.msl
+++ b/test/intrinsics/gen/atomicMax/a89cc3.wgsl.expected.msl
@@ -2,7 +2,7 @@
 
 using namespace metal;
 void atomicMax_a89cc3(threadgroup atomic_int* const tint_symbol_1) {
-  int res = atomic_fetch_max_explicit(&(*(tint_symbol_1)), 1, memory_order_relaxed);
+  int res = atomic_fetch_max_explicit(tint_symbol_1, 1, memory_order_relaxed);
 }
 
 kernel void compute_main(uint local_invocation_index [[thread_index_in_threadgroup]]) {
diff --git a/test/intrinsics/gen/atomicMax/beccfc.wgsl.expected.msl b/test/intrinsics/gen/atomicMax/beccfc.wgsl.expected.msl
index c672d6d..146b1ef 100644
--- a/test/intrinsics/gen/atomicMax/beccfc.wgsl.expected.msl
+++ b/test/intrinsics/gen/atomicMax/beccfc.wgsl.expected.msl
@@ -2,7 +2,7 @@
 
 using namespace metal;
 void atomicMax_beccfc(threadgroup atomic_uint* const tint_symbol_1) {
-  uint res = atomic_fetch_max_explicit(&(*(tint_symbol_1)), 1u, memory_order_relaxed);
+  uint res = atomic_fetch_max_explicit(tint_symbol_1, 1u, memory_order_relaxed);
 }
 
 kernel void compute_main(uint local_invocation_index [[thread_index_in_threadgroup]]) {
diff --git a/test/intrinsics/gen/atomicMin/278235.wgsl.expected.msl b/test/intrinsics/gen/atomicMin/278235.wgsl.expected.msl
index 077c2eb..9188683 100644
--- a/test/intrinsics/gen/atomicMin/278235.wgsl.expected.msl
+++ b/test/intrinsics/gen/atomicMin/278235.wgsl.expected.msl
@@ -2,7 +2,7 @@
 
 using namespace metal;
 void atomicMin_278235(threadgroup atomic_int* const tint_symbol_1) {
-  int res = atomic_fetch_min_explicit(&(*(tint_symbol_1)), 1, memory_order_relaxed);
+  int res = atomic_fetch_min_explicit(tint_symbol_1, 1, memory_order_relaxed);
 }
 
 kernel void compute_main(uint local_invocation_index [[thread_index_in_threadgroup]]) {
diff --git a/test/intrinsics/gen/atomicMin/69d383.wgsl.expected.msl b/test/intrinsics/gen/atomicMin/69d383.wgsl.expected.msl
index 920e3a9..6261ee3 100644
--- a/test/intrinsics/gen/atomicMin/69d383.wgsl.expected.msl
+++ b/test/intrinsics/gen/atomicMin/69d383.wgsl.expected.msl
@@ -2,7 +2,7 @@
 
 using namespace metal;
 void atomicMin_69d383(threadgroup atomic_uint* const tint_symbol_1) {
-  uint res = atomic_fetch_min_explicit(&(*(tint_symbol_1)), 1u, memory_order_relaxed);
+  uint res = atomic_fetch_min_explicit(tint_symbol_1, 1u, memory_order_relaxed);
 }
 
 kernel void compute_main(uint local_invocation_index [[thread_index_in_threadgroup]]) {
diff --git a/test/intrinsics/gen/atomicOr/5e3d61.wgsl.expected.msl b/test/intrinsics/gen/atomicOr/5e3d61.wgsl.expected.msl
index 4a46d47..7947b57 100644
--- a/test/intrinsics/gen/atomicOr/5e3d61.wgsl.expected.msl
+++ b/test/intrinsics/gen/atomicOr/5e3d61.wgsl.expected.msl
@@ -2,7 +2,7 @@
 
 using namespace metal;
 void atomicOr_5e3d61(threadgroup atomic_uint* const tint_symbol_1) {
-  uint res = atomic_fetch_or_explicit(&(*(tint_symbol_1)), 1u, memory_order_relaxed);
+  uint res = atomic_fetch_or_explicit(tint_symbol_1, 1u, memory_order_relaxed);
 }
 
 kernel void compute_main(uint local_invocation_index [[thread_index_in_threadgroup]]) {
diff --git a/test/intrinsics/gen/atomicOr/d09248.wgsl.expected.msl b/test/intrinsics/gen/atomicOr/d09248.wgsl.expected.msl
index 8795bb0..5669df1 100644
--- a/test/intrinsics/gen/atomicOr/d09248.wgsl.expected.msl
+++ b/test/intrinsics/gen/atomicOr/d09248.wgsl.expected.msl
@@ -2,7 +2,7 @@
 
 using namespace metal;
 void atomicOr_d09248(threadgroup atomic_int* const tint_symbol_1) {
-  int res = atomic_fetch_or_explicit(&(*(tint_symbol_1)), 1, memory_order_relaxed);
+  int res = atomic_fetch_or_explicit(tint_symbol_1, 1, memory_order_relaxed);
 }
 
 kernel void compute_main(uint local_invocation_index [[thread_index_in_threadgroup]]) {
diff --git a/test/intrinsics/gen/atomicStore/726882.wgsl.expected.msl b/test/intrinsics/gen/atomicStore/726882.wgsl.expected.msl
index 0404bec..55d79c0 100644
--- a/test/intrinsics/gen/atomicStore/726882.wgsl.expected.msl
+++ b/test/intrinsics/gen/atomicStore/726882.wgsl.expected.msl
@@ -2,7 +2,7 @@
 
 using namespace metal;
 void atomicStore_726882(threadgroup atomic_uint* const tint_symbol_1) {
-  atomic_store_explicit(&(*(tint_symbol_1)), 1u, memory_order_relaxed);
+  atomic_store_explicit(tint_symbol_1, 1u, memory_order_relaxed);
 }
 
 kernel void compute_main(uint local_invocation_index [[thread_index_in_threadgroup]]) {
diff --git a/test/intrinsics/gen/atomicStore/8bea94.wgsl.expected.msl b/test/intrinsics/gen/atomicStore/8bea94.wgsl.expected.msl
index b4fc6b9..c8f7b55 100644
--- a/test/intrinsics/gen/atomicStore/8bea94.wgsl.expected.msl
+++ b/test/intrinsics/gen/atomicStore/8bea94.wgsl.expected.msl
@@ -2,7 +2,7 @@
 
 using namespace metal;
 void atomicStore_8bea94(threadgroup atomic_int* const tint_symbol_1) {
-  atomic_store_explicit(&(*(tint_symbol_1)), 1, memory_order_relaxed);
+  atomic_store_explicit(tint_symbol_1, 1, memory_order_relaxed);
 }
 
 kernel void compute_main(uint local_invocation_index [[thread_index_in_threadgroup]]) {
diff --git a/test/intrinsics/gen/atomicXor/75dc95.wgsl.expected.msl b/test/intrinsics/gen/atomicXor/75dc95.wgsl.expected.msl
index ec7c6b9..b87b3d2 100644
--- a/test/intrinsics/gen/atomicXor/75dc95.wgsl.expected.msl
+++ b/test/intrinsics/gen/atomicXor/75dc95.wgsl.expected.msl
@@ -2,7 +2,7 @@
 
 using namespace metal;
 void atomicXor_75dc95(threadgroup atomic_int* const tint_symbol_1) {
-  int res = atomic_fetch_xor_explicit(&(*(tint_symbol_1)), 1, memory_order_relaxed);
+  int res = atomic_fetch_xor_explicit(tint_symbol_1, 1, memory_order_relaxed);
 }
 
 kernel void compute_main(uint local_invocation_index [[thread_index_in_threadgroup]]) {
diff --git a/test/intrinsics/gen/atomicXor/c8e6be.wgsl.expected.msl b/test/intrinsics/gen/atomicXor/c8e6be.wgsl.expected.msl
index b4016cb..b7220c7 100644
--- a/test/intrinsics/gen/atomicXor/c8e6be.wgsl.expected.msl
+++ b/test/intrinsics/gen/atomicXor/c8e6be.wgsl.expected.msl
@@ -2,7 +2,7 @@
 
 using namespace metal;
 void atomicXor_c8e6be(threadgroup atomic_uint* const tint_symbol_1) {
-  uint res = atomic_fetch_xor_explicit(&(*(tint_symbol_1)), 1u, memory_order_relaxed);
+  uint res = atomic_fetch_xor_explicit(tint_symbol_1, 1u, memory_order_relaxed);
 }
 
 kernel void compute_main(uint local_invocation_index [[thread_index_in_threadgroup]]) {
diff --git a/test/intrinsics/gen/frexp/0da285.wgsl.expected.msl b/test/intrinsics/gen/frexp/0da285.wgsl.expected.msl
index 289d3c1..db21f10 100644
--- a/test/intrinsics/gen/frexp/0da285.wgsl.expected.msl
+++ b/test/intrinsics/gen/frexp/0da285.wgsl.expected.msl
@@ -14,7 +14,7 @@
 }
 
 void frexp_0da285(threadgroup int* const tint_symbol_1) {
-  float res = tint_frexp(1.0f, &(*(tint_symbol_1)));
+  float res = tint_frexp(1.0f, tint_symbol_1);
 }
 
 kernel void compute_main(uint local_invocation_index [[thread_index_in_threadgroup]]) {
diff --git a/test/intrinsics/gen/frexp/40fc9b.wgsl.expected.msl b/test/intrinsics/gen/frexp/40fc9b.wgsl.expected.msl
index bc6a8ba..ded1f19 100644
--- a/test/intrinsics/gen/frexp/40fc9b.wgsl.expected.msl
+++ b/test/intrinsics/gen/frexp/40fc9b.wgsl.expected.msl
@@ -14,7 +14,7 @@
 }
 
 void frexp_40fc9b(threadgroup int3* const tint_symbol_1) {
-  float3 res = tint_frexp(float3(), &(*(tint_symbol_1)));
+  float3 res = tint_frexp(float3(), tint_symbol_1);
 }
 
 kernel void compute_main(uint local_invocation_index [[thread_index_in_threadgroup]]) {
diff --git a/test/intrinsics/gen/frexp/6efa09.wgsl.expected.msl b/test/intrinsics/gen/frexp/6efa09.wgsl.expected.msl
index 3911450..047a0ee 100644
--- a/test/intrinsics/gen/frexp/6efa09.wgsl.expected.msl
+++ b/test/intrinsics/gen/frexp/6efa09.wgsl.expected.msl
@@ -18,7 +18,7 @@
 };
 
 void frexp_6efa09(thread int3* const tint_symbol_2) {
-  float3 res = tint_frexp(float3(), &(*(tint_symbol_2)));
+  float3 res = tint_frexp(float3(), tint_symbol_2);
 }
 
 vertex tint_symbol vertex_main() {
diff --git a/test/intrinsics/gen/frexp/a2a617.wgsl.expected.msl b/test/intrinsics/gen/frexp/a2a617.wgsl.expected.msl
index 5ab05d4..8ec2844 100644
--- a/test/intrinsics/gen/frexp/a2a617.wgsl.expected.msl
+++ b/test/intrinsics/gen/frexp/a2a617.wgsl.expected.msl
@@ -18,7 +18,7 @@
 };
 
 void frexp_a2a617(thread int* const tint_symbol_2) {
-  float res = tint_frexp(1.0f, &(*(tint_symbol_2)));
+  float res = tint_frexp(1.0f, tint_symbol_2);
 }
 
 vertex tint_symbol vertex_main() {
diff --git a/test/intrinsics/gen/frexp/a3f940.wgsl.expected.msl b/test/intrinsics/gen/frexp/a3f940.wgsl.expected.msl
index a5947cf..fb24d37 100644
--- a/test/intrinsics/gen/frexp/a3f940.wgsl.expected.msl
+++ b/test/intrinsics/gen/frexp/a3f940.wgsl.expected.msl
@@ -14,7 +14,7 @@
 }
 
 void frexp_a3f940(threadgroup int2* const tint_symbol_1) {
-  float2 res = tint_frexp(float2(), &(*(tint_symbol_1)));
+  float2 res = tint_frexp(float2(), tint_symbol_1);
 }
 
 kernel void compute_main(uint local_invocation_index [[thread_index_in_threadgroup]]) {
diff --git a/test/intrinsics/gen/frexp/b45525.wgsl.expected.msl b/test/intrinsics/gen/frexp/b45525.wgsl.expected.msl
index 537576a..44aca08 100644
--- a/test/intrinsics/gen/frexp/b45525.wgsl.expected.msl
+++ b/test/intrinsics/gen/frexp/b45525.wgsl.expected.msl
@@ -18,7 +18,7 @@
 };
 
 void frexp_b45525(thread int4* const tint_symbol_2) {
-  float4 res = tint_frexp(float4(), &(*(tint_symbol_2)));
+  float4 res = tint_frexp(float4(), tint_symbol_2);
 }
 
 vertex tint_symbol vertex_main() {
diff --git a/test/intrinsics/gen/frexp/b87f4e.wgsl.expected.msl b/test/intrinsics/gen/frexp/b87f4e.wgsl.expected.msl
index 82dae49..1edfa88 100644
--- a/test/intrinsics/gen/frexp/b87f4e.wgsl.expected.msl
+++ b/test/intrinsics/gen/frexp/b87f4e.wgsl.expected.msl
@@ -14,7 +14,7 @@
 }
 
 void frexp_b87f4e(threadgroup int4* const tint_symbol_1) {
-  float4 res = tint_frexp(float4(), &(*(tint_symbol_1)));
+  float4 res = tint_frexp(float4(), tint_symbol_1);
 }
 
 kernel void compute_main(uint local_invocation_index [[thread_index_in_threadgroup]]) {
diff --git a/test/intrinsics/gen/frexp/c084e3.wgsl.expected.msl b/test/intrinsics/gen/frexp/c084e3.wgsl.expected.msl
index 3bd387e..407ee45 100644
--- a/test/intrinsics/gen/frexp/c084e3.wgsl.expected.msl
+++ b/test/intrinsics/gen/frexp/c084e3.wgsl.expected.msl
@@ -18,7 +18,7 @@
 };
 
 void frexp_c084e3(thread int2* const tint_symbol_2) {
-  float2 res = tint_frexp(float2(), &(*(tint_symbol_2)));
+  float2 res = tint_frexp(float2(), tint_symbol_2);
 }
 
 vertex tint_symbol vertex_main() {
diff --git a/test/intrinsics/gen/modf/1d59e5.wgsl.expected.msl b/test/intrinsics/gen/modf/1d59e5.wgsl.expected.msl
index 57eba73..9d2ffc9 100644
--- a/test/intrinsics/gen/modf/1d59e5.wgsl.expected.msl
+++ b/test/intrinsics/gen/modf/1d59e5.wgsl.expected.msl
@@ -14,7 +14,7 @@
 }
 
 void modf_1d59e5(threadgroup float4* const tint_symbol_1) {
-  float4 res = tint_modf(float4(), &(*(tint_symbol_1)));
+  float4 res = tint_modf(float4(), tint_symbol_1);
 }
 
 kernel void compute_main(uint local_invocation_index [[thread_index_in_threadgroup]]) {
diff --git a/test/intrinsics/gen/modf/3d00e2.wgsl.expected.msl b/test/intrinsics/gen/modf/3d00e2.wgsl.expected.msl
index 10b1b38..6b31676 100644
--- a/test/intrinsics/gen/modf/3d00e2.wgsl.expected.msl
+++ b/test/intrinsics/gen/modf/3d00e2.wgsl.expected.msl
@@ -18,7 +18,7 @@
 };
 
 void modf_3d00e2(thread float4* const tint_symbol_2) {
-  float4 res = tint_modf(float4(), &(*(tint_symbol_2)));
+  float4 res = tint_modf(float4(), tint_symbol_2);
 }
 
 vertex tint_symbol vertex_main() {
diff --git a/test/intrinsics/gen/modf/5e8476.wgsl.expected.msl b/test/intrinsics/gen/modf/5e8476.wgsl.expected.msl
index 531930f..b8f6053 100644
--- a/test/intrinsics/gen/modf/5e8476.wgsl.expected.msl
+++ b/test/intrinsics/gen/modf/5e8476.wgsl.expected.msl
@@ -18,7 +18,7 @@
 };
 
 void modf_5e8476(thread float* const tint_symbol_2) {
-  float res = tint_modf(1.0f, &(*(tint_symbol_2)));
+  float res = tint_modf(1.0f, tint_symbol_2);
 }
 
 vertex tint_symbol vertex_main() {
diff --git a/test/intrinsics/gen/modf/9c6a91.wgsl.expected.msl b/test/intrinsics/gen/modf/9c6a91.wgsl.expected.msl
index b702b5c..d3c4857 100644
--- a/test/intrinsics/gen/modf/9c6a91.wgsl.expected.msl
+++ b/test/intrinsics/gen/modf/9c6a91.wgsl.expected.msl
@@ -18,7 +18,7 @@
 };
 
 void modf_9c6a91(thread float2* const tint_symbol_2) {
-  float2 res = tint_modf(float2(), &(*(tint_symbol_2)));
+  float2 res = tint_modf(float2(), tint_symbol_2);
 }
 
 vertex tint_symbol vertex_main() {
diff --git a/test/intrinsics/gen/modf/9cecfc.wgsl.expected.msl b/test/intrinsics/gen/modf/9cecfc.wgsl.expected.msl
index 2a8186e..f332522 100644
--- a/test/intrinsics/gen/modf/9cecfc.wgsl.expected.msl
+++ b/test/intrinsics/gen/modf/9cecfc.wgsl.expected.msl
@@ -18,7 +18,7 @@
 };
 
 void modf_9cecfc(thread float3* const tint_symbol_2) {
-  float3 res = tint_modf(float3(), &(*(tint_symbol_2)));
+  float3 res = tint_modf(float3(), tint_symbol_2);
 }
 
 vertex tint_symbol vertex_main() {
diff --git a/test/intrinsics/gen/modf/a128ab.wgsl.expected.msl b/test/intrinsics/gen/modf/a128ab.wgsl.expected.msl
index ee30ac1..c475584 100644
--- a/test/intrinsics/gen/modf/a128ab.wgsl.expected.msl
+++ b/test/intrinsics/gen/modf/a128ab.wgsl.expected.msl
@@ -14,7 +14,7 @@
 }
 
 void modf_a128ab(threadgroup float2* const tint_symbol_1) {
-  float2 res = tint_modf(float2(), &(*(tint_symbol_1)));
+  float2 res = tint_modf(float2(), tint_symbol_1);
 }
 
 kernel void compute_main(uint local_invocation_index [[thread_index_in_threadgroup]]) {
diff --git a/test/intrinsics/gen/modf/bb9088.wgsl.expected.msl b/test/intrinsics/gen/modf/bb9088.wgsl.expected.msl
index 2b5fa5a..10b3ff5 100644
--- a/test/intrinsics/gen/modf/bb9088.wgsl.expected.msl
+++ b/test/intrinsics/gen/modf/bb9088.wgsl.expected.msl
@@ -14,7 +14,7 @@
 }
 
 void modf_bb9088(threadgroup float3* const tint_symbol_1) {
-  float3 res = tint_modf(float3(), &(*(tint_symbol_1)));
+  float3 res = tint_modf(float3(), tint_symbol_1);
 }
 
 kernel void compute_main(uint local_invocation_index [[thread_index_in_threadgroup]]) {
diff --git a/test/intrinsics/gen/modf/e38ae6.wgsl.expected.msl b/test/intrinsics/gen/modf/e38ae6.wgsl.expected.msl
index 7c09c24..bb6ccdf 100644
--- a/test/intrinsics/gen/modf/e38ae6.wgsl.expected.msl
+++ b/test/intrinsics/gen/modf/e38ae6.wgsl.expected.msl
@@ -14,7 +14,7 @@
 }
 
 void modf_e38ae6(threadgroup float* const tint_symbol_1) {
-  float res = tint_modf(1.0f, &(*(tint_symbol_1)));
+  float res = tint_modf(1.0f, tint_symbol_1);
 }
 
 kernel void compute_main(uint local_invocation_index [[thread_index_in_threadgroup]]) {