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>
This commit is contained in:
James Price 2021-09-07 18:59:21 +00:00
parent 3646400342
commit 1b9ed7de4a
1 changed files with 39 additions and 0 deletions

View File

@ -158,6 +158,45 @@ fn main() {
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;