Import Tint changes from Dawn
Changes:
- 9f8fc29c18dc783f5652f51abbd84e032d26c184 [tint][fuzz][ast] Add Renamer fuzzer by Ben Clayton <bclayton@google.com>
- 27182a6a388998ee89780d47aeba752c06a3e964 [tint][fuzz][ast] Add VertexPulling fuzzer by Ben Clayton <bclayton@google.com>
- 63433b96c2cfb869dffa499526e6334f3c66b3ab [tint][fuzz][ast] Add SingleEntryPoint fuzzer by Ben Clayton <bclayton@google.com>
- f413875fd1a6f998a26b78ac20089c0ee3ee542b [tint][fuzz][ast] Add VectorizeScalarMatrixInitializers f... by Ben Clayton <bclayton@google.com>
- d484de5f2b9ad370252fe961caa005f2d551128b [tint][fuzz][ast] Add Unshadow fuzzer by Ben Clayton <bclayton@google.com>
- 863163d7c083bdb2b6005b99328da543fb6d98c2 [tint][fuzz][ast] Add Std140 fuzzer by Ben Clayton <bclayton@google.com>
- 04d18e8749e2822e6886ff7c5057a45523d39183 [tint][fuzz][ast] Add RemoveUnreachableStatements fuzzer by Ben Clayton <bclayton@google.com>
- 91bcb31e731e4c4fc6cf6fd23a5f120c688cc643 [tint][fuzz][ast] Add RemovePhonies fuzzer by Ben Clayton <bclayton@google.com>
- f9712da0c62a8e8dfa824ecca20215b0316b57fa [tint][fuzz][ast] Add RemoveContinueInSwitch fuzzer by Ben Clayton <bclayton@google.com>
- 3ede0c5bbce449eac3facc375e4e12b5246b68e4 [tint][fuzz][ast] Add PromoteSideEffectsToDecl fuzzer by Ben Clayton <bclayton@google.com>
- 4cd472b4926ffab21197032c5eaca0f196d4b574 [tint][ast] Fix PromoteInitializersToLet for short-circui... by Ben Clayton <bclayton@google.com>
- 08b3dd96132c74161448cb82b7d59e254c4c4f07 [tint][fuzz][ast] Add (disabled) PromoteInitializersToLet... by Ben Clayton <bclayton@google.com>
- 73244e2d11ccd8be4cb9bd5e16e2b40ea5344353 [tint][fuzz][ast] Add PreservePadding fuzzer by Ben Clayton <bclayton@google.com>
- 5ed1dccb79adac8db9440ea8bc802c0fd26e0c0f [tint][fuzz][ast] Add OffsetFirstIndex fuzzer by Ben Clayton <bclayton@google.com>
GitOrigin-RevId: 9f8fc29c18dc783f5652f51abbd84e032d26c184
Change-Id: Ia3241a06c926c298671828ff0a8f90586c10eb31
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/186101
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: dan sinclair <dsinclair@google.com>
Commit-Queue: dan sinclair <dsinclair@google.com>
diff --git a/src/tint/fuzzers/transform_builder.h b/src/tint/fuzzers/transform_builder.h
index c716084..41dd8a8 100644
--- a/src/tint/fuzzers/transform_builder.h
+++ b/src/tint/fuzzers/transform_builder.h
@@ -208,7 +208,7 @@
DataBuilder* b) {
ast::transform::VertexAttributeDescriptor desc{};
desc.format = b->enum_class<ast::transform::VertexFormat>(
- static_cast<uint8_t>(ast::transform::VertexFormat::kLastEntry) + 1);
+ static_cast<uint8_t>(ast::transform::VertexFormat::kUnorm10_10_10_2) + 1);
desc.offset = b->build<uint32_t>();
desc.shader_location = b->build<uint32_t>();
return desc;
@@ -221,7 +221,7 @@
ast::transform::VertexBufferLayoutDescriptor desc;
desc.array_stride = b->build<uint32_t>();
desc.step_mode = b->enum_class<ast::transform::VertexStepMode>(
- static_cast<uint8_t>(ast::transform::VertexStepMode::kLastEntry) + 1);
+ static_cast<uint8_t>(ast::transform::VertexStepMode::kInstance) + 1);
desc.attributes =
b->vector<ast::transform::VertexAttributeDescriptor>(GenerateVertexAttributeDescriptor);
return desc;
diff --git a/src/tint/lang/wgsl/ast/transform/BUILD.cmake b/src/tint/lang/wgsl/ast/transform/BUILD.cmake
index 9f17000..62c3a3e 100644
--- a/src/tint/lang/wgsl/ast/transform/BUILD.cmake
+++ b/src/tint/lang/wgsl/ast/transform/BUILD.cmake
@@ -262,6 +262,19 @@
lang/wgsl/ast/transform/first_index_offset_fuzz.cc
lang/wgsl/ast/transform/fold_constants_fuzz.cc
lang/wgsl/ast/transform/multiplanar_external_texture_fuzz.cc
+ lang/wgsl/ast/transform/offset_first_index_fuzz.cc
+ lang/wgsl/ast/transform/preserve_padding_fuzz.cc
+ lang/wgsl/ast/transform/promote_initializers_to_let_fuzz.cc
+ lang/wgsl/ast/transform/promote_side_effects_to_decl_fuzz.cc
+ lang/wgsl/ast/transform/remove_continue_in_switch_fuzz.cc
+ lang/wgsl/ast/transform/remove_phonies_fuzz.cc
+ lang/wgsl/ast/transform/remove_unreachable_statements_fuzz.cc
+ lang/wgsl/ast/transform/renamer_fuzz.cc
+ lang/wgsl/ast/transform/single_entry_point_fuzz.cc
+ lang/wgsl/ast/transform/std140_fuzz.cc
+ lang/wgsl/ast/transform/unshadow_fuzz.cc
+ lang/wgsl/ast/transform/vectorize_scalar_matrix_initializers_fuzz.cc
+ lang/wgsl/ast/transform/vertex_pulling_fuzz.cc
lang/wgsl/ast/transform/zero_init_workgroup_memory_fuzz.cc
)
diff --git a/src/tint/lang/wgsl/ast/transform/BUILD.gn b/src/tint/lang/wgsl/ast/transform/BUILD.gn
index 76bcf95..3db4a21 100644
--- a/src/tint/lang/wgsl/ast/transform/BUILD.gn
+++ b/src/tint/lang/wgsl/ast/transform/BUILD.gn
@@ -252,6 +252,19 @@
"first_index_offset_fuzz.cc",
"fold_constants_fuzz.cc",
"multiplanar_external_texture_fuzz.cc",
+ "offset_first_index_fuzz.cc",
+ "preserve_padding_fuzz.cc",
+ "promote_initializers_to_let_fuzz.cc",
+ "promote_side_effects_to_decl_fuzz.cc",
+ "remove_continue_in_switch_fuzz.cc",
+ "remove_phonies_fuzz.cc",
+ "remove_unreachable_statements_fuzz.cc",
+ "renamer_fuzz.cc",
+ "single_entry_point_fuzz.cc",
+ "std140_fuzz.cc",
+ "unshadow_fuzz.cc",
+ "vectorize_scalar_matrix_initializers_fuzz.cc",
+ "vertex_pulling_fuzz.cc",
"zero_init_workgroup_memory_fuzz.cc",
]
deps = [
diff --git a/src/tint/lang/wgsl/ast/transform/offset_first_index.cc b/src/tint/lang/wgsl/ast/transform/offset_first_index.cc
index 9779347..9c9cfab 100644
--- a/src/tint/lang/wgsl/ast/transform/offset_first_index.cc
+++ b/src/tint/lang/wgsl/ast/transform/offset_first_index.cc
@@ -156,6 +156,8 @@
return resolver::Resolve(b);
}
+OffsetFirstIndex::Config::Config() = default;
+
OffsetFirstIndex::Config::Config(std::optional<int32_t> first_vertex_off,
std::optional<int32_t> first_instance_off)
: first_vertex_offset(first_vertex_off), first_instance_offset(first_instance_off) {}
diff --git a/src/tint/lang/wgsl/ast/transform/offset_first_index.h b/src/tint/lang/wgsl/ast/transform/offset_first_index.h
index 72d2e96..cf70af1 100644
--- a/src/tint/lang/wgsl/ast/transform/offset_first_index.h
+++ b/src/tint/lang/wgsl/ast/transform/offset_first_index.h
@@ -29,6 +29,7 @@
#define SRC_TINT_LANG_WGSL_AST_TRANSFORM_OFFSET_FIRST_INDEX_H_
#include "src/tint/lang/wgsl/ast/transform/transform.h"
+#include "src/tint/utils/reflection/reflection.h"
namespace tint::ast::transform {
@@ -47,7 +48,7 @@
/// For D3D, this affects both firstVertex and firstInstance. For OpenGL,
/// it applies to only firstInstance. For this reason, the first_vertex_offset
/// and first_instance_offset are optional, where std::nullopt indicates that
-/// no subsitution is to be performed.
+/// no substitution is to be performed.
///
/// Before:
/// ```
@@ -80,6 +81,9 @@
/// Transform configuration options
struct Config final : public Castable<Config, ast::transform::Data> {
/// Constructor
+ Config();
+
+ /// Constructor
/// @param first_vertex_off Offset of the firstVertex push constant
/// @param first_instance_off Location of the firstInstance push constant
Config(std::optional<int32_t> first_vertex_off, std::optional<int32_t> first_instance_off);
@@ -88,10 +92,13 @@
~Config() override;
/// Offset of the firstVertex push constant
- const std::optional<uint32_t> first_vertex_offset;
+ std::optional<uint32_t> first_vertex_offset;
/// Offset of the firstInstance push constant
- const std::optional<uint32_t> first_instance_offset;
+ std::optional<uint32_t> first_instance_offset;
+
+ /// Reflection for this struct
+ TINT_REFLECT(Config, first_vertex_offset, first_instance_offset);
};
/// Constructor
diff --git a/src/tint/lang/wgsl/ast/transform/offset_first_index_fuzz.cc b/src/tint/lang/wgsl/ast/transform/offset_first_index_fuzz.cc
new file mode 100644
index 0000000..04c13a2
--- /dev/null
+++ b/src/tint/lang/wgsl/ast/transform/offset_first_index_fuzz.cc
@@ -0,0 +1,66 @@
+// Copyright 2024 The Dawn & Tint Authors
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice, this
+// list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// 3. Neither the name of the copyright holder nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include "src/tint/cmd/fuzz/wgsl/fuzz.h"
+#include "src/tint/lang/wgsl/ast/transform/offset_first_index.h"
+
+namespace tint::ast::transform {
+namespace {
+
+bool CanRun(const Program& program, const OffsetFirstIndex::Config& config) {
+ if ((config.first_instance_offset.value_or(0) & 3) != 0 ||
+ (config.first_vertex_offset.value_or(0) & 3) != 0) {
+ return false; // Misaligned
+ }
+
+ if (config.first_instance_offset.has_value() &&
+ config.first_instance_offset == config.first_vertex_offset) {
+ return false; // Offset collision
+ }
+ return true;
+}
+
+void OffsetFirstIndexFuzzer(const Program& program, const OffsetFirstIndex::Config& config) {
+ if (!CanRun(program, config)) {
+ return;
+ }
+
+ DataMap inputs;
+ inputs.Add<OffsetFirstIndex::Config>(std::move(config));
+
+ DataMap outputs;
+ if (auto result = OffsetFirstIndex{}.Apply(program, inputs, outputs)) {
+ if (!result->IsValid()) {
+ TINT_ICE() << "OffsetFirstIndex returned invalid program:\n" << result->Diagnostics();
+ }
+ }
+}
+
+} // namespace
+} // namespace tint::ast::transform
+
+TINT_WGSL_PROGRAM_FUZZER(tint::ast::transform::OffsetFirstIndexFuzzer);
diff --git a/src/tint/lang/wgsl/ast/transform/preserve_padding_fuzz.cc b/src/tint/lang/wgsl/ast/transform/preserve_padding_fuzz.cc
new file mode 100644
index 0000000..486a65a
--- /dev/null
+++ b/src/tint/lang/wgsl/ast/transform/preserve_padding_fuzz.cc
@@ -0,0 +1,46 @@
+// Copyright 2024 The Dawn & Tint Authors
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice, this
+// list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// 3. Neither the name of the copyright holder nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include "src/tint/cmd/fuzz/wgsl/fuzz.h"
+#include "src/tint/lang/wgsl/ast/transform/preserve_padding.h"
+
+namespace tint::ast::transform {
+namespace {
+
+void PreservePaddingFuzzer(const Program& program) {
+ DataMap outputs;
+ if (auto result = PreservePadding{}.Apply(program, DataMap{}, outputs)) {
+ if (!result->IsValid()) {
+ TINT_ICE() << "PreservePadding returned invalid program:\n" << result->Diagnostics();
+ }
+ }
+}
+
+} // namespace
+} // namespace tint::ast::transform
+
+TINT_WGSL_PROGRAM_FUZZER(tint::ast::transform::PreservePaddingFuzzer);
diff --git a/src/tint/lang/wgsl/ast/transform/promote_initializers_to_let.cc b/src/tint/lang/wgsl/ast/transform/promote_initializers_to_let.cc
index 5094e8d..82e4e83 100644
--- a/src/tint/lang/wgsl/ast/transform/promote_initializers_to_let.cc
+++ b/src/tint/lang/wgsl/ast/transform/promote_initializers_to_let.cc
@@ -62,16 +62,17 @@
return false;
}
+ if (expr->Type()->HoldsAbstract()) {
+ // Do not hoist expressions that are not materialized, as doing so would cause
+ // premature materialization.
+ return false;
+ }
+
// Check whether the expression is an array or structure constructor
{
// Follow const-chains
auto* root_expr = expr;
if (expr->Stage() == core::EvaluationStage::kConstant) {
- if (expr->Type()->HoldsAbstract()) {
- // Do not hoist expressions that are not materialized, as doing so would cause
- // premature materialization.
- return false;
- }
while (auto* user = root_expr->UnwrapMaterialize()->As<sem::VariableUser>()) {
root_expr = user->Variable()->Initializer();
}
@@ -112,12 +113,13 @@
continue;
}
- if (sem->Stage() == core::EvaluationStage::kConstant) {
- // Expression is constant. We only need to hoist expressions if they're the
- // outermost constant expression in a chain. Remove the immediate child nodes of the
- // expression from const_chains, and add this expression to the const_chains. As we
- // visit leaf-expressions first, this means the content of const_chains only
- // contains the outer-most constant expressions.
+ if (sem->Stage() == core::EvaluationStage::kConstant ||
+ sem->Stage() == core::EvaluationStage::kNotEvaluated) {
+ // Expression is constant or not evaluated. We only need to hoist expressions if
+ // they're the outermost constant expression in a chain. Remove the immediate child
+ // nodes of the expression from const_chains, and add this expression to the
+ // const_chains. As we visit leaf-expressions first, this means the content of
+ // const_chains only contains the outer-most constant expressions.
auto* expr = sem->Declaration();
bool ok = TraverseExpressions(expr, [&](const Expression* child) {
const_chains.Remove(child);
@@ -126,7 +128,9 @@
if (!ok) {
return resolver::Resolve(b);
}
- const_chains.Add(expr);
+ if (sem->Stage() == core::EvaluationStage::kConstant) {
+ const_chains.Add(expr);
+ }
} else if (should_hoist(sem)) {
to_hoist.Push(sem);
}
diff --git a/src/tint/lang/wgsl/ast/transform/promote_initializers_to_let.h b/src/tint/lang/wgsl/ast/transform/promote_initializers_to_let.h
index db2e128..4ce1988 100644
--- a/src/tint/lang/wgsl/ast/transform/promote_initializers_to_let.h
+++ b/src/tint/lang/wgsl/ast/transform/promote_initializers_to_let.h
@@ -35,7 +35,7 @@
/// A transform that hoists array and structure initializers, and identifiers resolving to a
/// 'const' array to a 'let' variable, declared just before the statement of usage.
/// This transform is used by backends that do not support expressions that operate on an immediate
-/// array or structure. For example, the following is not immediately expressable for HLSL:
+/// array or structure. For example, the following is not immediately expressible for HLSL:
/// `array<i32, 2>(1, 2)[0]`
/// @see crbug.com/tint/406
class PromoteInitializersToLet final : public Castable<PromoteInitializersToLet, Transform> {
diff --git a/src/tint/lang/wgsl/ast/transform/promote_initializers_to_let_fuzz.cc b/src/tint/lang/wgsl/ast/transform/promote_initializers_to_let_fuzz.cc
new file mode 100644
index 0000000..bf928e6
--- /dev/null
+++ b/src/tint/lang/wgsl/ast/transform/promote_initializers_to_let_fuzz.cc
@@ -0,0 +1,47 @@
+// Copyright 2024 The Dawn & Tint Authors
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice, this
+// list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// 3. Neither the name of the copyright holder nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include "src/tint/cmd/fuzz/wgsl/fuzz.h"
+#include "src/tint/lang/wgsl/ast/transform/promote_initializers_to_let.h"
+
+namespace tint::ast::transform {
+namespace {
+
+void PromoteInitializersToLetFuzzer(const Program& program) {
+ DataMap outputs;
+ if (auto result = PromoteInitializersToLet{}.Apply(program, DataMap{}, outputs)) {
+ if (!result->IsValid()) {
+ TINT_ICE() << "PromoteInitializersToLet returned invalid program:\n"
+ << result->Diagnostics();
+ }
+ }
+}
+
+} // namespace
+} // namespace tint::ast::transform
+
+TINT_WGSL_PROGRAM_FUZZER(tint::ast::transform::PromoteInitializersToLetFuzzer);
diff --git a/src/tint/lang/wgsl/ast/transform/promote_initializers_to_let_test.cc b/src/tint/lang/wgsl/ast/transform/promote_initializers_to_let_test.cc
index 0b9f24f..ded078e 100644
--- a/src/tint/lang/wgsl/ast/transform/promote_initializers_to_let_test.cc
+++ b/src/tint/lang/wgsl/ast/transform/promote_initializers_to_let_test.cc
@@ -1397,5 +1397,14 @@
EXPECT_FALSE(ShouldRun<PromoteInitializersToLet>(src));
}
+TEST_F(PromoteInitializersToLetTest, Bug2241) {
+ auto* src = R"(
+fn f () {
+ let v = false && array<i32, array(array(6))[0][0]>()[0] == 0;
+}
+)";
+ EXPECT_FALSE(ShouldRun<PromoteInitializersToLet>(src));
+}
+
} // namespace
} // namespace tint::ast::transform
diff --git a/src/tint/lang/wgsl/ast/transform/promote_side_effects_to_decl.h b/src/tint/lang/wgsl/ast/transform/promote_side_effects_to_decl.h
index 63035d3..c488745 100644
--- a/src/tint/lang/wgsl/ast/transform/promote_side_effects_to_decl.h
+++ b/src/tint/lang/wgsl/ast/transform/promote_side_effects_to_decl.h
@@ -36,6 +36,8 @@
/// declarations before the statement of usage with the goal of ensuring
/// left-to-right order of evaluation, while respecting short-circuit
/// evaluation.
+/// As `@diagnostic` statements can be decomposed, this transform requires that the
+/// DisableUniformityAnalysis transform is run first.
class PromoteSideEffectsToDecl final : public Castable<PromoteSideEffectsToDecl, Transform> {
public:
/// Constructor
diff --git a/src/tint/lang/wgsl/ast/transform/promote_side_effects_to_decl_fuzz.cc b/src/tint/lang/wgsl/ast/transform/promote_side_effects_to_decl_fuzz.cc
new file mode 100644
index 0000000..57a15f8
--- /dev/null
+++ b/src/tint/lang/wgsl/ast/transform/promote_side_effects_to_decl_fuzz.cc
@@ -0,0 +1,65 @@
+// Copyright 2024 The Dawn & Tint Authors
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice, this
+// list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// 3. Neither the name of the copyright holder nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include "src/tint/cmd/fuzz/wgsl/fuzz.h"
+#include "src/tint/lang/wgsl/ast/module.h"
+#include "src/tint/lang/wgsl/ast/transform/promote_side_effects_to_decl.h"
+#include "src/tint/lang/wgsl/extension.h"
+#include "src/tint/lang/wgsl/sem/module.h"
+
+namespace tint::ast::transform {
+namespace {
+
+bool CanRun(const Program& program) {
+ if (!program.Sem().Module()->Extensions().Contains(
+ wgsl::Extension::kChromiumDisableUniformityAnalysis)) {
+ return false; // Requires 'chromium_disable_uniformity_analysis'
+ }
+ if (program.AST().HasOverrides()) {
+ return false; // Overrides are not supported.
+ }
+ return true;
+}
+
+void PromoteSideEffectsToDeclFuzzer(const Program& program) {
+ if (!CanRun(program)) {
+ return;
+ }
+
+ DataMap outputs;
+ if (auto result = PromoteSideEffectsToDecl{}.Apply(program, DataMap{}, outputs)) {
+ if (!result->IsValid()) {
+ TINT_ICE() << "PromoteSideEffectsToDecl returned invalid program:\n"
+ << result->Diagnostics();
+ }
+ }
+}
+
+} // namespace
+} // namespace tint::ast::transform
+
+TINT_WGSL_PROGRAM_FUZZER(tint::ast::transform::PromoteSideEffectsToDeclFuzzer);
diff --git a/src/tint/lang/wgsl/ast/transform/remove_continue_in_switch_fuzz.cc b/src/tint/lang/wgsl/ast/transform/remove_continue_in_switch_fuzz.cc
new file mode 100644
index 0000000..049b57c
--- /dev/null
+++ b/src/tint/lang/wgsl/ast/transform/remove_continue_in_switch_fuzz.cc
@@ -0,0 +1,47 @@
+// Copyright 2024 The Dawn & Tint Authors
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice, this
+// list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// 3. Neither the name of the copyright holder nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include "src/tint/cmd/fuzz/wgsl/fuzz.h"
+#include "src/tint/lang/wgsl/ast/transform/remove_continue_in_switch.h"
+
+namespace tint::ast::transform {
+namespace {
+
+void RemoveContinueInSwitchFuzzer(const Program& program) {
+ DataMap outputs;
+ if (auto result = RemoveContinueInSwitch{}.Apply(program, DataMap{}, outputs)) {
+ if (!result->IsValid()) {
+ TINT_ICE() << "RemoveContinueInSwitch returned invalid program:\n"
+ << result->Diagnostics();
+ }
+ }
+}
+
+} // namespace
+} // namespace tint::ast::transform
+
+TINT_WGSL_PROGRAM_FUZZER(tint::ast::transform::RemoveContinueInSwitchFuzzer);
diff --git a/src/tint/lang/wgsl/ast/transform/remove_phonies_fuzz.cc b/src/tint/lang/wgsl/ast/transform/remove_phonies_fuzz.cc
new file mode 100644
index 0000000..92faf38
--- /dev/null
+++ b/src/tint/lang/wgsl/ast/transform/remove_phonies_fuzz.cc
@@ -0,0 +1,46 @@
+// Copyright 2024 The Dawn & Tint Authors
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice, this
+// list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// 3. Neither the name of the copyright holder nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include "src/tint/cmd/fuzz/wgsl/fuzz.h"
+#include "src/tint/lang/wgsl/ast/transform/remove_phonies.h"
+
+namespace tint::ast::transform {
+namespace {
+
+void RemovePhoniesFuzzer(const Program& program) {
+ DataMap outputs;
+ if (auto result = RemovePhonies{}.Apply(program, DataMap{}, outputs)) {
+ if (!result->IsValid()) {
+ TINT_ICE() << "RemovePhonies returned invalid program:\n" << result->Diagnostics();
+ }
+ }
+}
+
+} // namespace
+} // namespace tint::ast::transform
+
+TINT_WGSL_PROGRAM_FUZZER(tint::ast::transform::RemovePhoniesFuzzer);
diff --git a/src/tint/lang/wgsl/ast/transform/remove_unreachable_statements_fuzz.cc b/src/tint/lang/wgsl/ast/transform/remove_unreachable_statements_fuzz.cc
new file mode 100644
index 0000000..c61d8aa
--- /dev/null
+++ b/src/tint/lang/wgsl/ast/transform/remove_unreachable_statements_fuzz.cc
@@ -0,0 +1,63 @@
+// Copyright 2024 The Dawn & Tint Authors
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice, this
+// list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// 3. Neither the name of the copyright holder nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include "src/tint/cmd/fuzz/wgsl/fuzz.h"
+#include "src/tint/lang/wgsl/ast/loop_statement.h"
+#include "src/tint/lang/wgsl/ast/transform/remove_unreachable_statements.h"
+
+namespace tint::ast::transform {
+namespace {
+
+bool CanRun(const Program& program) {
+ for (auto* node : program.ASTNodes().Objects()) {
+ if (auto* loop = node->As<LoopStatement>()) {
+ if (loop->continuing) {
+ return false; // TODO(crbug.com/tint/2242)
+ }
+ }
+ }
+ return true;
+}
+
+void RemoveUnreachableStatementsFuzzer(const Program& program) {
+ if (!CanRun(program)) {
+ return;
+ }
+
+ DataMap outputs;
+ if (auto result = RemoveUnreachableStatements{}.Apply(program, DataMap{}, outputs)) {
+ if (!result->IsValid()) {
+ TINT_ICE() << "RemoveUnreachableStatements returned invalid program:\n"
+ << result->Diagnostics();
+ }
+ }
+}
+
+} // namespace
+} // namespace tint::ast::transform
+
+TINT_WGSL_PROGRAM_FUZZER(tint::ast::transform::RemoveUnreachableStatementsFuzzer);
diff --git a/src/tint/lang/wgsl/ast/transform/renamer.cc b/src/tint/lang/wgsl/ast/transform/renamer.cc
index 423df11..25485b2 100644
--- a/src/tint/lang/wgsl/ast/transform/renamer.cc
+++ b/src/tint/lang/wgsl/ast/transform/renamer.cc
@@ -1264,6 +1264,7 @@
Renamer::Data::Data(const Data&) = default;
Renamer::Data::~Data() = default;
+Renamer::Config::Config() = default;
Renamer::Config::Config(Target t, bool pu) : target(t), preserve_unicode(pu) {}
Renamer::Config::Config(Target t, bool pu, Remappings&& remappings)
: target(t), preserve_unicode(pu), requested_names(std::move(remappings)) {}
diff --git a/src/tint/lang/wgsl/ast/transform/renamer.h b/src/tint/lang/wgsl/ast/transform/renamer.h
index 3a390c3..ac5e2d4 100644
--- a/src/tint/lang/wgsl/ast/transform/renamer.h
+++ b/src/tint/lang/wgsl/ast/transform/renamer.h
@@ -32,6 +32,7 @@
#include <unordered_map>
#include "src/tint/lang/wgsl/ast/transform/transform.h"
+#include "src/tint/utils/reflection/reflection.h"
namespace tint::ast::transform {
@@ -74,6 +75,9 @@
/// If omitted, then the renamer will use Target::kAll.
struct Config final : public Castable<Config, transform::Data> {
/// Constructor
+ Config();
+
+ /// Constructor
/// @param tgt the targets to rename
/// @param keep_unicode if false, symbols with non-ascii code-points are
/// renamed
@@ -92,13 +96,16 @@
~Config() override;
/// The targets to rename
- Target const target = Target::kAll;
+ Target target = Target::kAll;
/// If false, symbols with non-ascii code-points are renamed.
bool preserve_unicode = false;
/// Requested renaming rules
- const Remappings requested_names = {};
+ Remappings requested_names = {};
+
+ /// Reflection for this class
+ TINT_REFLECT(Config, target, preserve_unicode, requested_names);
};
/// Constructor using a the configuration provided in the input Data
@@ -115,4 +122,11 @@
} // namespace tint::ast::transform
+namespace tint {
+
+/// Reflection for Target
+TINT_REFLECT_ENUM_RANGE(tint::ast::transform::Renamer::Target, kAll, kMslKeywords);
+
+} // namespace tint
+
#endif // SRC_TINT_LANG_WGSL_AST_TRANSFORM_RENAMER_H_
diff --git a/src/tint/lang/wgsl/ast/transform/renamer_fuzz.cc b/src/tint/lang/wgsl/ast/transform/renamer_fuzz.cc
new file mode 100644
index 0000000..9986efd
--- /dev/null
+++ b/src/tint/lang/wgsl/ast/transform/renamer_fuzz.cc
@@ -0,0 +1,48 @@
+// Copyright 2024 The Dawn & Tint Authors
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice, this
+// list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// 3. Neither the name of the copyright holder nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include "src/tint/cmd/fuzz/wgsl/fuzz.h"
+#include "src/tint/lang/wgsl/ast/module.h"
+#include "src/tint/lang/wgsl/ast/transform/renamer.h"
+
+namespace tint::ast::transform {
+
+void RenamerFuzzer(const Program& program, const Renamer::Config& config) {
+ DataMap inputs;
+ inputs.Add<Renamer::Config>(config);
+
+ DataMap outputs;
+ if (auto result = Renamer{}.Apply(program, DataMap{}, outputs)) {
+ // Note: We're not ensuring that the returned program is valid, as the renaming is likely to
+ // cause resolver failures. Just ensure that the transform doesn't crash or upset
+ // sanitizers.
+ }
+}
+
+} // namespace tint::ast::transform
+
+TINT_WGSL_PROGRAM_FUZZER(tint::ast::transform::RenamerFuzzer);
diff --git a/src/tint/lang/wgsl/ast/transform/single_entry_point_fuzz.cc b/src/tint/lang/wgsl/ast/transform/single_entry_point_fuzz.cc
new file mode 100644
index 0000000..5cec2bb
--- /dev/null
+++ b/src/tint/lang/wgsl/ast/transform/single_entry_point_fuzz.cc
@@ -0,0 +1,67 @@
+// Copyright 2024 The Dawn & Tint Authors
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice, this
+// list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// 3. Neither the name of the copyright holder nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include <cstdint>
+#include "src/tint/api/common/binding_point.h"
+#include "src/tint/cmd/fuzz/wgsl/fuzz.h"
+#include "src/tint/lang/wgsl/ast/identifier.h"
+#include "src/tint/lang/wgsl/ast/module.h"
+#include "src/tint/lang/wgsl/ast/transform/single_entry_point.h"
+
+namespace tint::ast::transform {
+namespace {
+
+void SingleEntryPointFuzzer(const Program& program, uint8_t entry_point_index) {
+ std::string entry_point;
+ for (auto* fn : program.AST().Functions()) {
+ if (fn->IsEntryPoint()) {
+ if (entry_point_index-- == 0) {
+ entry_point = fn->name->symbol.Name();
+ break;
+ }
+ }
+ }
+
+ if (entry_point.empty()) {
+ return;
+ }
+
+ DataMap inputs;
+ inputs.Add<SingleEntryPoint::Config>(std::move(entry_point));
+
+ DataMap outputs;
+ if (auto result = SingleEntryPoint{}.Apply(program, inputs, outputs)) {
+ if (!result->IsValid()) {
+ TINT_ICE() << "SingleEntryPoint returned invalid program:\n" << result->Diagnostics();
+ }
+ }
+}
+
+} // namespace
+} // namespace tint::ast::transform
+
+TINT_WGSL_PROGRAM_FUZZER(tint::ast::transform::SingleEntryPointFuzzer);
diff --git a/src/tint/lang/wgsl/ast/transform/std140.h b/src/tint/lang/wgsl/ast/transform/std140.h
index df0abf6..2846429 100644
--- a/src/tint/lang/wgsl/ast/transform/std140.h
+++ b/src/tint/lang/wgsl/ast/transform/std140.h
@@ -40,7 +40,8 @@
/// `matNxM<f16>` matrices are the only type that violate std140-layout, this transformation is
/// sufficient to have any WGSL structure be std140-layout conformant.
///
-/// @note This transform requires the PromoteSideEffectsToDecl transform to have been run first.
+/// @note This transform requires the DirectVariableAccess and PromoteSideEffectsToDecl transforms
+/// to have been run first.
class Std140 final : public Castable<Std140, Transform> {
public:
/// Constructor
diff --git a/src/tint/lang/wgsl/ast/transform/std140_fuzz.cc b/src/tint/lang/wgsl/ast/transform/std140_fuzz.cc
new file mode 100644
index 0000000..aedf74c
--- /dev/null
+++ b/src/tint/lang/wgsl/ast/transform/std140_fuzz.cc
@@ -0,0 +1,68 @@
+// Copyright 2024 The Dawn & Tint Authors
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice, this
+// list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// 3. Neither the name of the copyright holder nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include "src/tint/cmd/fuzz/wgsl/fuzz.h"
+#include "src/tint/lang/core/address_space.h"
+#include "src/tint/lang/core/type/pointer.h"
+#include "src/tint/lang/wgsl/ast/module.h"
+#include "src/tint/lang/wgsl/ast/transform/std140.h"
+#include "src/tint/lang/wgsl/sem/function.h"
+
+namespace tint::ast::transform {
+namespace {
+
+bool CanRun(const Program& program) {
+ for (auto* fn : program.AST().Functions()) {
+ auto* sem_fn = program.Sem().Get(fn);
+ for (auto* param : sem_fn->Parameters()) {
+ if (auto* ptr = param->Type()->As<core::type::Pointer>()) {
+ if (ptr->AddressSpace() == core::AddressSpace::kUniform) {
+ return false; // Requires the DirectVariableAccess transform
+ }
+ }
+ }
+ }
+ return true;
+}
+
+void Std140Fuzzer(const Program& program) {
+ if (!CanRun(program)) {
+ return;
+ }
+
+ DataMap outputs;
+ if (auto result = Std140{}.Apply(program, DataMap{}, outputs)) {
+ if (!result->IsValid()) {
+ TINT_ICE() << "Std140 returned invalid program:\n" << result->Diagnostics();
+ }
+ }
+}
+
+} // namespace
+} // namespace tint::ast::transform
+
+TINT_WGSL_PROGRAM_FUZZER(tint::ast::transform::Std140Fuzzer);
diff --git a/src/tint/lang/wgsl/ast/transform/unshadow_fuzz.cc b/src/tint/lang/wgsl/ast/transform/unshadow_fuzz.cc
new file mode 100644
index 0000000..064ffaf
--- /dev/null
+++ b/src/tint/lang/wgsl/ast/transform/unshadow_fuzz.cc
@@ -0,0 +1,46 @@
+// Copyright 2024 The Dawn & Tint Authors
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice, this
+// list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// 3. Neither the name of the copyright holder nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include "src/tint/cmd/fuzz/wgsl/fuzz.h"
+#include "src/tint/lang/wgsl/ast/transform/unshadow.h"
+
+namespace tint::ast::transform {
+namespace {
+
+void UnshadowFuzzer(const Program& program) {
+ DataMap outputs;
+ if (auto result = Unshadow{}.Apply(program, DataMap{}, outputs)) {
+ if (!result->IsValid()) {
+ TINT_ICE() << "Unshadow returned invalid program:\n" << result->Diagnostics();
+ }
+ }
+}
+
+} // namespace
+} // namespace tint::ast::transform
+
+TINT_WGSL_PROGRAM_FUZZER(tint::ast::transform::UnshadowFuzzer);
diff --git a/src/tint/lang/wgsl/ast/transform/vectorize_scalar_matrix_initializers_fuzz.cc b/src/tint/lang/wgsl/ast/transform/vectorize_scalar_matrix_initializers_fuzz.cc
new file mode 100644
index 0000000..407538c
--- /dev/null
+++ b/src/tint/lang/wgsl/ast/transform/vectorize_scalar_matrix_initializers_fuzz.cc
@@ -0,0 +1,47 @@
+// Copyright 2024 The Dawn & Tint Authors
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice, this
+// list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// 3. Neither the name of the copyright holder nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include "src/tint/cmd/fuzz/wgsl/fuzz.h"
+#include "src/tint/lang/wgsl/ast/transform/vectorize_scalar_matrix_initializers.h"
+
+namespace tint::ast::transform {
+namespace {
+
+void VectorizeScalarMatrixInitializersFuzzer(const Program& program) {
+ DataMap outputs;
+ if (auto result = VectorizeScalarMatrixInitializers{}.Apply(program, DataMap{}, outputs)) {
+ if (!result->IsValid()) {
+ TINT_ICE() << "VectorizeScalarMatrixInitializers returned invalid program:\n"
+ << result->Diagnostics();
+ }
+ }
+}
+
+} // namespace
+} // namespace tint::ast::transform
+
+TINT_WGSL_PROGRAM_FUZZER(tint::ast::transform::VectorizeScalarMatrixInitializersFuzzer);
diff --git a/src/tint/lang/wgsl/ast/transform/vertex_pulling.h b/src/tint/lang/wgsl/ast/transform/vertex_pulling.h
index 13016a7..a0b77a1 100644
--- a/src/tint/lang/wgsl/ast/transform/vertex_pulling.h
+++ b/src/tint/lang/wgsl/ast/transform/vertex_pulling.h
@@ -71,13 +71,11 @@
kSint32x3, // sint32x3
kSint32x4, // sint32x4
kUnorm10_10_10_2, // unorm10-10-10-2
-
- kLastEntry = kSint32x4,
};
/// Describes if a vertex attributes increments with vertex index or instance
/// index
-enum class VertexStepMode { kVertex, kInstance, kLastEntry = kInstance };
+enum class VertexStepMode { kVertex, kInstance };
/// Describes a vertex attribute within a buffer
struct VertexAttributeDescriptor {
@@ -198,4 +196,14 @@
} // namespace tint::ast::transform
+namespace tint {
+
+/// Reflection for VertexFormat
+TINT_REFLECT_ENUM_RANGE(tint::ast::transform::VertexFormat, kUint8x2, kUnorm10_10_10_2);
+
+/// Reflection for VertexStepMode
+TINT_REFLECT_ENUM_RANGE(tint::ast::transform::VertexStepMode, kVertex, kInstance);
+
+} // namespace tint
+
#endif // SRC_TINT_LANG_WGSL_AST_TRANSFORM_VERTEX_PULLING_H_
diff --git a/src/tint/lang/wgsl/ast/transform/vertex_pulling_fuzz.cc b/src/tint/lang/wgsl/ast/transform/vertex_pulling_fuzz.cc
new file mode 100644
index 0000000..68de96f
--- /dev/null
+++ b/src/tint/lang/wgsl/ast/transform/vertex_pulling_fuzz.cc
@@ -0,0 +1,47 @@
+// Copyright 2024 The Dawn & Tint Authors
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// 1. Redistributions of source code must retain the above copyright notice, this
+// list of conditions and the following disclaimer.
+//
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+// this list of conditions and the following disclaimer in the documentation
+// and/or other materials provided with the distribution.
+//
+// 3. Neither the name of the copyright holder nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#include "src/tint/cmd/fuzz/wgsl/fuzz.h"
+#include "src/tint/lang/wgsl/ast/module.h"
+#include "src/tint/lang/wgsl/ast/transform/vertex_pulling.h"
+
+namespace tint::ast::transform {
+
+void VertexPullingFuzzer(const Program& program, const VertexPulling::Config& config) {
+ DataMap inputs;
+ inputs.Add<VertexPulling::Config>(config);
+
+ DataMap outputs;
+ if (auto result = VertexPulling{}.Apply(program, DataMap{}, outputs)) {
+ // Note: We're not ensuring that the returned program is valid, as the rules for this are
+ // complicated. Just ensure that the transform doesn't crash or upset sanitizers.
+ }
+}
+
+} // namespace tint::ast::transform
+
+TINT_WGSL_PROGRAM_FUZZER(tint::ast::transform::VertexPullingFuzzer);