msl/module-scope-var: Add unit test for folding &*
As noted in the CL that folded &* during this transform, we were
missing a unit test for this:
https://dawn-review.googlesource.com/c/tint/+/60520
Bug: tint:1086
Change-Id: I61941d40dbcc478e8cc2672144186e5c0f10e587
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/63584
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
diff --git a/src/transform/module_scope_var_to_entry_point_param_test.cc b/src/transform/module_scope_var_to_entry_point_param_test.cc
index ab0f93a..13119d5 100644
--- a/src/transform/module_scope_var_to_entry_point_param_test.cc
+++ b/src/transform/module_scope_var_to_entry_point_param_test.cc
@@ -158,6 +158,45 @@
EXPECT_EQ(expect, str(got));
}
+TEST_F(ModuleScopeVarToEntryPointParamTest, FoldAddressOfDeref) {
+ auto* src = R"(
+var<private> v : f32;
+
+fn bar(p : ptr<private, f32>) {
+ (*p) = 0.0;
+}
+
+fn foo() {
+ bar(&v);
+}
+
+[[stage(compute), workgroup_size(1)]]
+fn main() {
+ foo();
+}
+)";
+
+ auto* expect = R"(
+fn bar(p : ptr<private, f32>) {
+ *(p) = 0.0;
+}
+
+fn foo(tint_symbol : ptr<private, f32>) {
+ bar(tint_symbol);
+}
+
+[[stage(compute), workgroup_size(1)]]
+fn main() {
+ [[internal(disable_validation__ignore_storage_class)]] var<private> tint_symbol_1 : f32;
+ foo(&(tint_symbol_1));
+}
+)";
+
+ auto got = Run<ModuleScopeVarToEntryPointParam>(src);
+
+ EXPECT_EQ(expect, str(got));
+}
+
TEST_F(ModuleScopeVarToEntryPointParamTest, UnusedVariables) {
auto* src = R"(
var<private> p : f32;