diff --git a/fuzzers/BUILD.gn b/fuzzers/BUILD.gn index 2f6eae58a9..64eefc8e74 100644 --- a/fuzzers/BUILD.gn +++ b/fuzzers/BUILD.gn @@ -66,11 +66,6 @@ if (build_with_chromium) { deps = [ ":tint_fuzzer_common" ] } - fuzzer_test("tint_bound_array_accessors_fuzzer") { - sources = [ "tint_bound_array_accessors_fuzzer.cc" ] - deps = [ ":tint_fuzzer_common" ] - } - fuzzer_test("tint_first_index_offset_fuzzer") { sources = [ "tint_first_index_offset_fuzzer.cc" ] deps = [ ":tint_fuzzer_common" ] @@ -86,6 +81,11 @@ if (build_with_chromium) { deps = [ ":tint_fuzzer_common" ] } + fuzzer_test("tint_robustness_fuzzer") { + sources = [ "tint_robustness_fuzzer.cc" ] + deps = [ ":tint_fuzzer_common" ] + } + fuzzer_test("tint_single_entry_point_fuzzer") { sources = [ "tint_single_entry_point_fuzzer.cc" ] deps = [ ":tint_fuzzer_common" ] @@ -187,7 +187,7 @@ if (build_with_chromium) { deps += [ ":tint_all_transforms_fuzzer", ":tint_binding_remapper_fuzzer", - ":tint_bound_array_accessors_fuzzer", + ":tint_robustness_fuzzer", ":tint_first_index_offset_fuzzer", ":tint_inspector_fuzzer", ":tint_renamer_fuzzer", diff --git a/fuzzers/CMakeLists.txt b/fuzzers/CMakeLists.txt index 8588b4540c..ccaae93d1a 100644 --- a/fuzzers/CMakeLists.txt +++ b/fuzzers/CMakeLists.txt @@ -32,10 +32,10 @@ endif() if (${TINT_BUILD_WGSL_READER} AND ${TINT_BUILD_SPV_WRITER}) add_tint_fuzzer(tint_all_transforms_fuzzer) add_tint_fuzzer(tint_binding_remapper_fuzzer) - add_tint_fuzzer(tint_bound_array_accessors_fuzzer) add_tint_fuzzer(tint_first_index_offset_fuzzer) add_tint_fuzzer(tint_inspector_fuzzer) add_tint_fuzzer(tint_renamer_fuzzer) + add_tint_fuzzer(tint_robustness_fuzzer) add_tint_fuzzer(tint_single_entry_point_fuzzer) add_tint_fuzzer(tint_spirv_transform_fuzzer) add_tint_fuzzer(tint_vertex_pulling_fuzzer) diff --git a/fuzzers/tint_all_transforms_fuzzer.cc b/fuzzers/tint_all_transforms_fuzzer.cc index 9e2dc502e4..dfdf4deed6 100644 --- a/fuzzers/tint_all_transforms_fuzzer.cc +++ b/fuzzers/tint_all_transforms_fuzzer.cc @@ -30,7 +30,7 @@ bool AddPlatformIndependentPasses(Config* config) { ExtractSingleEntryPointInputs(&config->reader, &config->inputs); ExtractVertexPullingInputs(&config->reader, &config->inputs); - config->manager.Add(); + config->manager.Add(); config->manager.Add(); config->manager.Add(); config->manager.Add(); diff --git a/fuzzers/tint_bound_array_accessors_fuzzer.cc b/fuzzers/tint_robustness_fuzzer.cc similarity index 93% rename from fuzzers/tint_bound_array_accessors_fuzzer.cc rename to fuzzers/tint_robustness_fuzzer.cc index 2040320928..a763c2974e 100644 --- a/fuzzers/tint_bound_array_accessors_fuzzer.cc +++ b/fuzzers/tint_robustness_fuzzer.cc @@ -19,7 +19,7 @@ namespace fuzzers { extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { tint::transform::Manager transform_manager; - transform_manager.Add(); + transform_manager.Add(); tint::fuzzers::CommonFuzzer fuzzer(InputFormat::kWGSL, OutputFormat::kSpv); fuzzer.SetTransformManager(&transform_manager, {}); diff --git a/include/tint/tint.h b/include/tint/tint.h index ff1991e76b..9a51bbeabb 100644 --- a/include/tint/tint.h +++ b/include/tint/tint.h @@ -25,10 +25,10 @@ #include "src/reader/reader.h" #include "src/sem/type_manager.h" #include "src/transform/binding_remapper.h" -#include "src/transform/bound_array_accessors.h" #include "src/transform/first_index_offset.h" #include "src/transform/manager.h" #include "src/transform/renamer.h" +#include "src/transform/robustness.h" #include "src/transform/single_entry_point.h" #include "src/transform/vertex_pulling.h" #include "src/writer/writer.h" diff --git a/samples/main.cc b/samples/main.cc index 3ad5aa89a7..e80d9f4911 100644 --- a/samples/main.cc +++ b/samples/main.cc @@ -87,9 +87,9 @@ const char kUsage[] = R"(Usage: tint [options] -o -- Output file name. Use "-" for standard output --transform -- Runs transforms, name list is comma separated Available transforms: - bound_array_accessors first_index_offset renamer + robustness --parse-only -- Stop after parsing the input --dump-ast -- Dump the generated AST to stdout --demangle -- Preserve original source names. Demangle them. @@ -704,14 +704,14 @@ int main(int argc, const char** argv) { // be run that needs user input. Should we find a way to support that here // maybe through a provided file? - if (name == "bound_array_accessors") { - transform_manager.Add(); - } else if (name == "first_index_offset") { + if (name == "first_index_offset") { transform_inputs.Add(0, 0); transform_manager.Add(); } else if (name == "renamer") { transform_manager.Add(); + } else if (name == "robustness") { + transform_manager.Add(); } else { std::cerr << "Unknown transform name: " << name << std::endl; return 1; diff --git a/src/BUILD.gn b/src/BUILD.gn index f838efbdb9..5b1a3d5d15 100644 --- a/src/BUILD.gn +++ b/src/BUILD.gn @@ -554,8 +554,6 @@ libtint_source_set("libtint_core_all_src") { "transform/array_length_from_uniform.h", "transform/binding_remapper.cc", "transform/binding_remapper.h", - "transform/bound_array_accessors.cc", - "transform/bound_array_accessors.h", "transform/calculate_array_length.cc", "transform/calculate_array_length.h", "transform/canonicalize_entry_point_io.cc", @@ -578,6 +576,8 @@ libtint_source_set("libtint_core_all_src") { "transform/promote_initializers_to_const_var.h", "transform/renamer.cc", "transform/renamer.h", + "transform/robustness.cc", + "transform/robustness.h", "transform/simplify.cc", "transform/simplify.h", "transform/single_entry_point.cc", diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c808b4397e..914e1984ef 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -279,8 +279,6 @@ set(TINT_LIB_SRCS transform/array_length_from_uniform.h transform/binding_remapper.cc transform/binding_remapper.h - transform/bound_array_accessors.cc - transform/bound_array_accessors.h transform/calculate_array_length.cc transform/calculate_array_length.h transform/canonicalize_entry_point_io.cc @@ -303,6 +301,8 @@ set(TINT_LIB_SRCS transform/promote_initializers_to_const_var.h transform/renamer.cc transform/renamer.h + transform/robustness.cc + transform/robustness.h transform/simplify.cc transform/simplify.h transform/single_entry_point.cc @@ -866,7 +866,6 @@ if(${TINT_BUILD_TESTS}) list(APPEND TINT_TEST_SRCS transform/array_length_from_uniform_test.cc transform/binding_remapper_test.cc - transform/bound_array_accessors_test.cc transform/calculate_array_length_test.cc transform/canonicalize_entry_point_io_test.cc transform/decompose_memory_access_test.cc @@ -877,6 +876,7 @@ if(${TINT_BUILD_TESTS}) transform/pad_array_elements_test.cc transform/promote_initializers_to_const_var_test.cc transform/renamer_test.cc + transform/robustness_test.cc transform/simplify_test.cc transform/single_entry_point_test.cc transform/test_helper.h diff --git a/src/transform/bound_array_accessors.cc b/src/transform/robustness.cc similarity index 90% rename from src/transform/bound_array_accessors.cc rename to src/transform/robustness.cc index 5ad5020c5b..e59ea5d394 100644 --- a/src/transform/bound_array_accessors.cc +++ b/src/transform/robustness.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/transform/bound_array_accessors.h" +#include "src/transform/robustness.h" #include #include @@ -20,15 +20,15 @@ #include "src/program_builder.h" #include "src/sem/expression.h" -TINT_INSTANTIATE_TYPEINFO(tint::transform::BoundArrayAccessors); +TINT_INSTANTIATE_TYPEINFO(tint::transform::Robustness); namespace tint { namespace transform { -BoundArrayAccessors::BoundArrayAccessors() = default; -BoundArrayAccessors::~BoundArrayAccessors() = default; +Robustness::Robustness() = default; +Robustness::~Robustness() = default; -void BoundArrayAccessors::Run(CloneContext& ctx, const DataMap&, DataMap&) { +void Robustness::Run(CloneContext& ctx, const DataMap&, DataMap&) { ctx.ReplaceAll([&](ast::ArrayAccessorExpression* expr) { return Transform(expr, &ctx); }); @@ -36,7 +36,7 @@ void BoundArrayAccessors::Run(CloneContext& ctx, const DataMap&, DataMap&) { ctx.Clone(); } -ast::ArrayAccessorExpression* BoundArrayAccessors::Transform( +ast::ArrayAccessorExpression* Robustness::Transform( ast::ArrayAccessorExpression* expr, CloneContext* ctx) { auto& diags = ctx->dst->Diagnostics(); diff --git a/src/transform/bound_array_accessors.h b/src/transform/robustness.h similarity index 85% rename from src/transform/bound_array_accessors.h rename to src/transform/robustness.h index 87803e65a6..b489d07972 100644 --- a/src/transform/bound_array_accessors.h +++ b/src/transform/robustness.h @@ -12,8 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -#ifndef SRC_TRANSFORM_BOUND_ARRAY_ACCESSORS_H_ -#define SRC_TRANSFORM_BOUND_ARRAY_ACCESSORS_H_ +#ifndef SRC_TRANSFORM_ROBUSTNESS_H_ +#define SRC_TRANSFORM_ROBUSTNESS_H_ #include "src/ast/array_accessor_expression.h" #include "src/transform/transform.h" @@ -25,12 +25,12 @@ namespace transform { /// the bounds of the array. Any access before the start of the array will clamp /// to zero and any access past the end of the array will clamp to /// (array length - 1). -class BoundArrayAccessors : public Castable { +class Robustness : public Castable { public: /// Constructor - BoundArrayAccessors(); + Robustness(); /// Destructor - ~BoundArrayAccessors() override; + ~Robustness() override; protected: /// Runs the transform using the CloneContext built for transforming a @@ -46,7 +46,9 @@ class BoundArrayAccessors : public Castable { CloneContext* ctx); }; +using BoundArrayAccessors = Robustness; + } // namespace transform } // namespace tint -#endif // SRC_TRANSFORM_BOUND_ARRAY_ACCESSORS_H_ +#endif // SRC_TRANSFORM_ROBUSTNESS_H_ diff --git a/src/transform/bound_array_accessors_test.cc b/src/transform/robustness_test.cc similarity index 74% rename from src/transform/bound_array_accessors_test.cc rename to src/transform/robustness_test.cc index f8b8f89e56..18ac30b3ca 100644 --- a/src/transform/bound_array_accessors_test.cc +++ b/src/transform/robustness_test.cc @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "src/transform/bound_array_accessors.h" +#include "src/transform/robustness.h" #include "src/transform/test_helper.h" @@ -20,9 +20,9 @@ namespace tint { namespace transform { namespace { -using BoundArrayAccessorsTest = TransformTest; +using RobustnessTest = TransformTest; -TEST_F(BoundArrayAccessorsTest, Ptrs_Clamp) { +TEST_F(RobustnessTest, Ptrs_Clamp) { auto* src = R"( var a : array; @@ -43,12 +43,12 @@ fn f() { } )"; - auto got = Run(src); + auto got = Run(src); EXPECT_EQ(expect, str(got)); } -TEST_F(BoundArrayAccessorsTest, Array_Idx_Nested_Scalar) { +TEST_F(RobustnessTest, Array_Idx_Nested_Scalar) { auto* src = R"( var a : array; @@ -73,12 +73,12 @@ fn f() { } )"; - auto got = Run(src); + auto got = Run(src); EXPECT_EQ(expect, str(got)); } -TEST_F(BoundArrayAccessorsTest, Array_Idx_Scalar) { +TEST_F(RobustnessTest, Array_Idx_Scalar) { auto* src = R"( var a : array; @@ -95,12 +95,12 @@ fn f() { } )"; - auto got = Run(src); + auto got = Run(src); EXPECT_EQ(expect, str(got)); } -TEST_F(BoundArrayAccessorsTest, Array_Idx_Expr) { +TEST_F(RobustnessTest, Array_Idx_Expr) { auto* src = R"( var a : array; @@ -121,12 +121,12 @@ fn f() { } )"; - auto got = Run(src); + auto got = Run(src); EXPECT_EQ(expect, str(got)); } -TEST_F(BoundArrayAccessorsTest, Array_Idx_Negative) { +TEST_F(RobustnessTest, Array_Idx_Negative) { auto* src = R"( var a : array; @@ -143,12 +143,12 @@ fn f() { } )"; - auto got = Run(src); + auto got = Run(src); EXPECT_EQ(expect, str(got)); } -TEST_F(BoundArrayAccessorsTest, Array_Idx_OutOfBounds) { +TEST_F(RobustnessTest, Array_Idx_OutOfBounds) { auto* src = R"( var a : array; @@ -165,12 +165,12 @@ fn f() { } )"; - auto got = Run(src); + auto got = Run(src); EXPECT_EQ(expect, str(got)); } -TEST_F(BoundArrayAccessorsTest, Vector_Idx_Scalar) { +TEST_F(RobustnessTest, Vector_Idx_Scalar) { auto* src = R"( var a : vec3; @@ -187,12 +187,12 @@ fn f() { } )"; - auto got = Run(src); + auto got = Run(src); EXPECT_EQ(expect, str(got)); } -TEST_F(BoundArrayAccessorsTest, Vector_Idx_Expr) { +TEST_F(RobustnessTest, Vector_Idx_Expr) { auto* src = R"( var a : vec3; @@ -213,12 +213,12 @@ fn f() { } )"; - auto got = Run(src); + auto got = Run(src); EXPECT_EQ(expect, str(got)); } -TEST_F(BoundArrayAccessorsTest, Vector_Swizzle_Idx_Scalar) { +TEST_F(RobustnessTest, Vector_Swizzle_Idx_Scalar) { auto* src = R"( var a : vec3; @@ -235,12 +235,12 @@ fn f() { } )"; - auto got = Run(src); + auto got = Run(src); EXPECT_EQ(expect, str(got)); } -TEST_F(BoundArrayAccessorsTest, Vector_Swizzle_Idx_Var) { +TEST_F(RobustnessTest, Vector_Swizzle_Idx_Var) { auto* src = R"( var a : vec3; @@ -261,11 +261,11 @@ fn f() { } )"; - auto got = Run(src); + auto got = Run(src); EXPECT_EQ(expect, str(got)); } -TEST_F(BoundArrayAccessorsTest, Vector_Swizzle_Idx_Expr) { +TEST_F(RobustnessTest, Vector_Swizzle_Idx_Expr) { auto* src = R"( var a : vec3; @@ -286,12 +286,12 @@ fn f() { } )"; - auto got = Run(src); + auto got = Run(src); EXPECT_EQ(expect, str(got)); } -TEST_F(BoundArrayAccessorsTest, Vector_Idx_Negative) { +TEST_F(RobustnessTest, Vector_Idx_Negative) { auto* src = R"( var a : vec3; @@ -308,12 +308,12 @@ fn f() { } )"; - auto got = Run(src); + auto got = Run(src); EXPECT_EQ(expect, str(got)); } -TEST_F(BoundArrayAccessorsTest, Vector_Idx_OutOfBounds) { +TEST_F(RobustnessTest, Vector_Idx_OutOfBounds) { auto* src = R"( var a : vec3; @@ -330,12 +330,12 @@ fn f() { } )"; - auto got = Run(src); + auto got = Run(src); EXPECT_EQ(expect, str(got)); } -TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Scalar) { +TEST_F(RobustnessTest, Matrix_Idx_Scalar) { auto* src = R"( var a : mat3x2; @@ -352,12 +352,12 @@ fn f() { } )"; - auto got = Run(src); + auto got = Run(src); EXPECT_EQ(expect, str(got)); } -TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Expr_Column) { +TEST_F(RobustnessTest, Matrix_Idx_Expr_Column) { auto* src = R"( var a : mat3x2; @@ -378,12 +378,12 @@ fn f() { } )"; - auto got = Run(src); + auto got = Run(src); EXPECT_EQ(expect, str(got)); } -TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Expr_Row) { +TEST_F(RobustnessTest, Matrix_Idx_Expr_Row) { auto* src = R"( var a : mat3x2; @@ -404,12 +404,12 @@ fn f() { } )"; - auto got = Run(src); + auto got = Run(src); EXPECT_EQ(expect, str(got)); } -TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Negative_Column) { +TEST_F(RobustnessTest, Matrix_Idx_Negative_Column) { auto* src = R"( var a : mat3x2; @@ -426,12 +426,12 @@ fn f() { } )"; - auto got = Run(src); + auto got = Run(src); EXPECT_EQ(expect, str(got)); } -TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Negative_Row) { +TEST_F(RobustnessTest, Matrix_Idx_Negative_Row) { auto* src = R"( var a : mat3x2; @@ -448,12 +448,12 @@ fn f() { } )"; - auto got = Run(src); + auto got = Run(src); EXPECT_EQ(expect, str(got)); } -TEST_F(BoundArrayAccessorsTest, Matrix_Idx_OutOfBounds_Column) { +TEST_F(RobustnessTest, Matrix_Idx_OutOfBounds_Column) { auto* src = R"( var a : mat3x2; @@ -470,12 +470,12 @@ fn f() { } )"; - auto got = Run(src); + auto got = Run(src); EXPECT_EQ(expect, str(got)); } -TEST_F(BoundArrayAccessorsTest, Matrix_Idx_OutOfBounds_Row) { +TEST_F(RobustnessTest, Matrix_Idx_OutOfBounds_Row) { auto* src = R"( var a : mat3x2; @@ -492,13 +492,13 @@ fn f() { } )"; - auto got = Run(src); + auto got = Run(src); EXPECT_EQ(expect, str(got)); } // TODO(dsinclair): Implement when constant_id exists -TEST_F(BoundArrayAccessorsTest, DISABLED_Vector_Constant_Id_Clamps) { +TEST_F(RobustnessTest, DISABLED_Vector_Constant_Id_Clamps) { // [[override(1300)]] let idx : i32; // var a : vec3 // var b : f32 = a[idx] @@ -507,7 +507,7 @@ TEST_F(BoundArrayAccessorsTest, DISABLED_Vector_Constant_Id_Clamps) { } // TODO(dsinclair): Implement when constant_id exists -TEST_F(BoundArrayAccessorsTest, DISABLED_Array_Constant_Id_Clamps) { +TEST_F(RobustnessTest, DISABLED_Array_Constant_Id_Clamps) { // [[override(1300)]] let idx : i32; // var a : array // var b : f32 = a[idx] @@ -516,7 +516,7 @@ TEST_F(BoundArrayAccessorsTest, DISABLED_Array_Constant_Id_Clamps) { } // TODO(dsinclair): Implement when constant_id exists -TEST_F(BoundArrayAccessorsTest, DISABLED_Matrix_Column_Constant_Id_Clamps) { +TEST_F(RobustnessTest, DISABLED_Matrix_Column_Constant_Id_Clamps) { // [[override(1300)]] let idx : i32; // var a : mat3x2 // var b : f32 = a[idx][1] @@ -525,7 +525,7 @@ TEST_F(BoundArrayAccessorsTest, DISABLED_Matrix_Column_Constant_Id_Clamps) { } // TODO(dsinclair): Implement when constant_id exists -TEST_F(BoundArrayAccessorsTest, DISABLED_Matrix_Row_Constant_Id_Clamps) { +TEST_F(RobustnessTest, DISABLED_Matrix_Row_Constant_Id_Clamps) { // [[override(1300)]] let idx : i32; // var a : mat3x2 // var b : f32 = a[1][idx] @@ -533,7 +533,7 @@ TEST_F(BoundArrayAccessorsTest, DISABLED_Matrix_Row_Constant_Id_Clamps) { // -> var b : f32 = a[1][min(u32(idx), 0, 1)] } -TEST_F(BoundArrayAccessorsTest, RuntimeArray_Clamps) { +TEST_F(RobustnessTest, RuntimeArray_Clamps) { auto* src = R"( [[block]] struct S { @@ -561,24 +561,24 @@ fn f() { } )"; - auto got = Run(src); + auto got = Run(src); EXPECT_EQ(expect, str(got)); } // TODO(dsinclair): Clamp atomics when available. -TEST_F(BoundArrayAccessorsTest, DISABLED_Atomics_Clamp) { +TEST_F(RobustnessTest, DISABLED_Atomics_Clamp) { FAIL(); } // TODO(dsinclair): Clamp texture coord values. Depends on: // https://github.com/gpuweb/gpuweb/issues/1107 -TEST_F(BoundArrayAccessorsTest, DISABLED_TextureCoord_Clamp) { +TEST_F(RobustnessTest, DISABLED_TextureCoord_Clamp) { FAIL(); } // TODO(dsinclair): Test for scoped variables when Lexical Scopes implemented -TEST_F(BoundArrayAccessorsTest, DISABLED_Scoped_Variable) { +TEST_F(RobustnessTest, DISABLED_Scoped_Variable) { // var a : array; // var i : u32; // { @@ -593,7 +593,7 @@ TEST_F(BoundArrayAccessorsTest, DISABLED_Scoped_Variable) { } // Check that existing use of min() and arrayLength() do not get renamed. -TEST_F(BoundArrayAccessorsTest, DontRenameSymbols) { +TEST_F(RobustnessTest, DontRenameSymbols) { auto* src = R"( [[block]] struct S { @@ -630,7 +630,7 @@ fn f() { } )"; - auto got = Run(src); + auto got = Run(src); EXPECT_EQ(expect, str(got)); } diff --git a/test/BUILD.gn b/test/BUILD.gn index fba82209de..dd4bcfc6d7 100644 --- a/test/BUILD.gn +++ b/test/BUILD.gn @@ -278,7 +278,6 @@ tint_unittests_source_set("tint_unittests_core_src") { "../src/traits_test.cc", "../src/transform/array_length_from_uniform_test.cc", "../src/transform/binding_remapper_test.cc", - "../src/transform/bound_array_accessors_test.cc", "../src/transform/calculate_array_length_test.cc", "../src/transform/canonicalize_entry_point_io_test.cc", "../src/transform/decompose_memory_access_test.cc", @@ -288,6 +287,7 @@ tint_unittests_source_set("tint_unittests_core_src") { "../src/transform/pad_array_elements_test.cc", "../src/transform/promote_initializers_to_const_var_test.cc", "../src/transform/renamer_test.cc", + "../src/transform/robustness_test.cc", "../src/transform/simplify_test.cc", "../src/transform/single_entry_point_test.cc", "../src/transform/test_helper.h",