transform: Rename BoundArrayAccessors to Robustness

We will want this transform to do more bounds and argument sanitization.

Bug: tint:748
Change-Id: I38cb9623622e9f5ab85d8cd420d669ca6be77099
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56543
Auto-Submit: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
Ben Clayton 2021-06-30 13:23:36 +00:00 committed by Tint LUCI CQ
parent 863e285013
commit 0273f1a604
12 changed files with 87 additions and 85 deletions

View File

@ -66,11 +66,6 @@ if (build_with_chromium) {
deps = [ ":tint_fuzzer_common" ] 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") { fuzzer_test("tint_first_index_offset_fuzzer") {
sources = [ "tint_first_index_offset_fuzzer.cc" ] sources = [ "tint_first_index_offset_fuzzer.cc" ]
deps = [ ":tint_fuzzer_common" ] deps = [ ":tint_fuzzer_common" ]
@ -86,6 +81,11 @@ if (build_with_chromium) {
deps = [ ":tint_fuzzer_common" ] 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") { fuzzer_test("tint_single_entry_point_fuzzer") {
sources = [ "tint_single_entry_point_fuzzer.cc" ] sources = [ "tint_single_entry_point_fuzzer.cc" ]
deps = [ ":tint_fuzzer_common" ] deps = [ ":tint_fuzzer_common" ]
@ -187,7 +187,7 @@ if (build_with_chromium) {
deps += [ deps += [
":tint_all_transforms_fuzzer", ":tint_all_transforms_fuzzer",
":tint_binding_remapper_fuzzer", ":tint_binding_remapper_fuzzer",
":tint_bound_array_accessors_fuzzer", ":tint_robustness_fuzzer",
":tint_first_index_offset_fuzzer", ":tint_first_index_offset_fuzzer",
":tint_inspector_fuzzer", ":tint_inspector_fuzzer",
":tint_renamer_fuzzer", ":tint_renamer_fuzzer",

View File

@ -32,10 +32,10 @@ endif()
if (${TINT_BUILD_WGSL_READER} AND ${TINT_BUILD_SPV_WRITER}) if (${TINT_BUILD_WGSL_READER} AND ${TINT_BUILD_SPV_WRITER})
add_tint_fuzzer(tint_all_transforms_fuzzer) add_tint_fuzzer(tint_all_transforms_fuzzer)
add_tint_fuzzer(tint_binding_remapper_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_first_index_offset_fuzzer)
add_tint_fuzzer(tint_inspector_fuzzer) add_tint_fuzzer(tint_inspector_fuzzer)
add_tint_fuzzer(tint_renamer_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_single_entry_point_fuzzer)
add_tint_fuzzer(tint_spirv_transform_fuzzer) add_tint_fuzzer(tint_spirv_transform_fuzzer)
add_tint_fuzzer(tint_vertex_pulling_fuzzer) add_tint_fuzzer(tint_vertex_pulling_fuzzer)

View File

@ -30,7 +30,7 @@ bool AddPlatformIndependentPasses(Config* config) {
ExtractSingleEntryPointInputs(&config->reader, &config->inputs); ExtractSingleEntryPointInputs(&config->reader, &config->inputs);
ExtractVertexPullingInputs(&config->reader, &config->inputs); ExtractVertexPullingInputs(&config->reader, &config->inputs);
config->manager.Add<transform::BoundArrayAccessors>(); config->manager.Add<transform::Robustness>();
config->manager.Add<transform::FirstIndexOffset>(); config->manager.Add<transform::FirstIndexOffset>();
config->manager.Add<transform::BindingRemapper>(); config->manager.Add<transform::BindingRemapper>();
config->manager.Add<transform::Renamer>(); config->manager.Add<transform::Renamer>();

View File

@ -19,7 +19,7 @@ namespace fuzzers {
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
tint::transform::Manager transform_manager; tint::transform::Manager transform_manager;
transform_manager.Add<tint::transform::BoundArrayAccessors>(); transform_manager.Add<tint::transform::Robustness>();
tint::fuzzers::CommonFuzzer fuzzer(InputFormat::kWGSL, OutputFormat::kSpv); tint::fuzzers::CommonFuzzer fuzzer(InputFormat::kWGSL, OutputFormat::kSpv);
fuzzer.SetTransformManager(&transform_manager, {}); fuzzer.SetTransformManager(&transform_manager, {});

View File

@ -25,10 +25,10 @@
#include "src/reader/reader.h" #include "src/reader/reader.h"
#include "src/sem/type_manager.h" #include "src/sem/type_manager.h"
#include "src/transform/binding_remapper.h" #include "src/transform/binding_remapper.h"
#include "src/transform/bound_array_accessors.h"
#include "src/transform/first_index_offset.h" #include "src/transform/first_index_offset.h"
#include "src/transform/manager.h" #include "src/transform/manager.h"
#include "src/transform/renamer.h" #include "src/transform/renamer.h"
#include "src/transform/robustness.h"
#include "src/transform/single_entry_point.h" #include "src/transform/single_entry_point.h"
#include "src/transform/vertex_pulling.h" #include "src/transform/vertex_pulling.h"
#include "src/writer/writer.h" #include "src/writer/writer.h"

View File

@ -87,9 +87,9 @@ const char kUsage[] = R"(Usage: tint [options] <input-file>
-o <name> -- Output file name. Use "-" for standard output -o <name> -- Output file name. Use "-" for standard output
--transform <name list> -- Runs transforms, name list is comma separated --transform <name list> -- Runs transforms, name list is comma separated
Available transforms: Available transforms:
bound_array_accessors
first_index_offset first_index_offset
renamer renamer
robustness
--parse-only -- Stop after parsing the input --parse-only -- Stop after parsing the input
--dump-ast -- Dump the generated AST to stdout --dump-ast -- Dump the generated AST to stdout
--demangle -- Preserve original source names. Demangle them. --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 // be run that needs user input. Should we find a way to support that here
// maybe through a provided file? // maybe through a provided file?
if (name == "bound_array_accessors") { if (name == "first_index_offset") {
transform_manager.Add<tint::transform::BoundArrayAccessors>();
} else if (name == "first_index_offset") {
transform_inputs.Add<tint::transform::FirstIndexOffset::BindingPoint>(0, transform_inputs.Add<tint::transform::FirstIndexOffset::BindingPoint>(0,
0); 0);
transform_manager.Add<tint::transform::FirstIndexOffset>(); transform_manager.Add<tint::transform::FirstIndexOffset>();
} else if (name == "renamer") { } else if (name == "renamer") {
transform_manager.Add<tint::transform::Renamer>(); transform_manager.Add<tint::transform::Renamer>();
} else if (name == "robustness") {
transform_manager.Add<tint::transform::Robustness>();
} else { } else {
std::cerr << "Unknown transform name: " << name << std::endl; std::cerr << "Unknown transform name: " << name << std::endl;
return 1; return 1;

View File

@ -554,8 +554,6 @@ libtint_source_set("libtint_core_all_src") {
"transform/array_length_from_uniform.h", "transform/array_length_from_uniform.h",
"transform/binding_remapper.cc", "transform/binding_remapper.cc",
"transform/binding_remapper.h", "transform/binding_remapper.h",
"transform/bound_array_accessors.cc",
"transform/bound_array_accessors.h",
"transform/calculate_array_length.cc", "transform/calculate_array_length.cc",
"transform/calculate_array_length.h", "transform/calculate_array_length.h",
"transform/canonicalize_entry_point_io.cc", "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/promote_initializers_to_const_var.h",
"transform/renamer.cc", "transform/renamer.cc",
"transform/renamer.h", "transform/renamer.h",
"transform/robustness.cc",
"transform/robustness.h",
"transform/simplify.cc", "transform/simplify.cc",
"transform/simplify.h", "transform/simplify.h",
"transform/single_entry_point.cc", "transform/single_entry_point.cc",

View File

@ -279,8 +279,6 @@ set(TINT_LIB_SRCS
transform/array_length_from_uniform.h transform/array_length_from_uniform.h
transform/binding_remapper.cc transform/binding_remapper.cc
transform/binding_remapper.h transform/binding_remapper.h
transform/bound_array_accessors.cc
transform/bound_array_accessors.h
transform/calculate_array_length.cc transform/calculate_array_length.cc
transform/calculate_array_length.h transform/calculate_array_length.h
transform/canonicalize_entry_point_io.cc transform/canonicalize_entry_point_io.cc
@ -303,6 +301,8 @@ set(TINT_LIB_SRCS
transform/promote_initializers_to_const_var.h transform/promote_initializers_to_const_var.h
transform/renamer.cc transform/renamer.cc
transform/renamer.h transform/renamer.h
transform/robustness.cc
transform/robustness.h
transform/simplify.cc transform/simplify.cc
transform/simplify.h transform/simplify.h
transform/single_entry_point.cc transform/single_entry_point.cc
@ -866,7 +866,6 @@ if(${TINT_BUILD_TESTS})
list(APPEND TINT_TEST_SRCS list(APPEND TINT_TEST_SRCS
transform/array_length_from_uniform_test.cc transform/array_length_from_uniform_test.cc
transform/binding_remapper_test.cc transform/binding_remapper_test.cc
transform/bound_array_accessors_test.cc
transform/calculate_array_length_test.cc transform/calculate_array_length_test.cc
transform/canonicalize_entry_point_io_test.cc transform/canonicalize_entry_point_io_test.cc
transform/decompose_memory_access_test.cc transform/decompose_memory_access_test.cc
@ -877,6 +876,7 @@ if(${TINT_BUILD_TESTS})
transform/pad_array_elements_test.cc transform/pad_array_elements_test.cc
transform/promote_initializers_to_const_var_test.cc transform/promote_initializers_to_const_var_test.cc
transform/renamer_test.cc transform/renamer_test.cc
transform/robustness_test.cc
transform/simplify_test.cc transform/simplify_test.cc
transform/single_entry_point_test.cc transform/single_entry_point_test.cc
transform/test_helper.h transform/test_helper.h

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#include "src/transform/bound_array_accessors.h" #include "src/transform/robustness.h"
#include <algorithm> #include <algorithm>
#include <utility> #include <utility>
@ -20,15 +20,15 @@
#include "src/program_builder.h" #include "src/program_builder.h"
#include "src/sem/expression.h" #include "src/sem/expression.h"
TINT_INSTANTIATE_TYPEINFO(tint::transform::BoundArrayAccessors); TINT_INSTANTIATE_TYPEINFO(tint::transform::Robustness);
namespace tint { namespace tint {
namespace transform { namespace transform {
BoundArrayAccessors::BoundArrayAccessors() = default; Robustness::Robustness() = default;
BoundArrayAccessors::~BoundArrayAccessors() = 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) { ctx.ReplaceAll([&](ast::ArrayAccessorExpression* expr) {
return Transform(expr, &ctx); return Transform(expr, &ctx);
}); });
@ -36,7 +36,7 @@ void BoundArrayAccessors::Run(CloneContext& ctx, const DataMap&, DataMap&) {
ctx.Clone(); ctx.Clone();
} }
ast::ArrayAccessorExpression* BoundArrayAccessors::Transform( ast::ArrayAccessorExpression* Robustness::Transform(
ast::ArrayAccessorExpression* expr, ast::ArrayAccessorExpression* expr,
CloneContext* ctx) { CloneContext* ctx) {
auto& diags = ctx->dst->Diagnostics(); auto& diags = ctx->dst->Diagnostics();

View File

@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#ifndef SRC_TRANSFORM_BOUND_ARRAY_ACCESSORS_H_ #ifndef SRC_TRANSFORM_ROBUSTNESS_H_
#define SRC_TRANSFORM_BOUND_ARRAY_ACCESSORS_H_ #define SRC_TRANSFORM_ROBUSTNESS_H_
#include "src/ast/array_accessor_expression.h" #include "src/ast/array_accessor_expression.h"
#include "src/transform/transform.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 /// 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 /// to zero and any access past the end of the array will clamp to
/// (array length - 1). /// (array length - 1).
class BoundArrayAccessors : public Castable<BoundArrayAccessors, Transform> { class Robustness : public Castable<Robustness, Transform> {
public: public:
/// Constructor /// Constructor
BoundArrayAccessors(); Robustness();
/// Destructor /// Destructor
~BoundArrayAccessors() override; ~Robustness() override;
protected: protected:
/// Runs the transform using the CloneContext built for transforming a /// Runs the transform using the CloneContext built for transforming a
@ -46,7 +46,9 @@ class BoundArrayAccessors : public Castable<BoundArrayAccessors, Transform> {
CloneContext* ctx); CloneContext* ctx);
}; };
using BoundArrayAccessors = Robustness;
} // namespace transform } // namespace transform
} // namespace tint } // namespace tint
#endif // SRC_TRANSFORM_BOUND_ARRAY_ACCESSORS_H_ #endif // SRC_TRANSFORM_ROBUSTNESS_H_

View File

@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#include "src/transform/bound_array_accessors.h" #include "src/transform/robustness.h"
#include "src/transform/test_helper.h" #include "src/transform/test_helper.h"
@ -20,9 +20,9 @@ namespace tint {
namespace transform { namespace transform {
namespace { namespace {
using BoundArrayAccessorsTest = TransformTest; using RobustnessTest = TransformTest;
TEST_F(BoundArrayAccessorsTest, Ptrs_Clamp) { TEST_F(RobustnessTest, Ptrs_Clamp) {
auto* src = R"( auto* src = R"(
var<private> a : array<f32, 3>; var<private> a : array<f32, 3>;
@ -43,12 +43,12 @@ fn f() {
} }
)"; )";
auto got = Run<BoundArrayAccessors>(src); auto got = Run<Robustness>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
TEST_F(BoundArrayAccessorsTest, Array_Idx_Nested_Scalar) { TEST_F(RobustnessTest, Array_Idx_Nested_Scalar) {
auto* src = R"( auto* src = R"(
var<private> a : array<f32, 3>; var<private> a : array<f32, 3>;
@ -73,12 +73,12 @@ fn f() {
} }
)"; )";
auto got = Run<BoundArrayAccessors>(src); auto got = Run<Robustness>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
TEST_F(BoundArrayAccessorsTest, Array_Idx_Scalar) { TEST_F(RobustnessTest, Array_Idx_Scalar) {
auto* src = R"( auto* src = R"(
var<private> a : array<f32, 3>; var<private> a : array<f32, 3>;
@ -95,12 +95,12 @@ fn f() {
} }
)"; )";
auto got = Run<BoundArrayAccessors>(src); auto got = Run<Robustness>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
TEST_F(BoundArrayAccessorsTest, Array_Idx_Expr) { TEST_F(RobustnessTest, Array_Idx_Expr) {
auto* src = R"( auto* src = R"(
var<private> a : array<f32, 3>; var<private> a : array<f32, 3>;
@ -121,12 +121,12 @@ fn f() {
} }
)"; )";
auto got = Run<BoundArrayAccessors>(src); auto got = Run<Robustness>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
TEST_F(BoundArrayAccessorsTest, Array_Idx_Negative) { TEST_F(RobustnessTest, Array_Idx_Negative) {
auto* src = R"( auto* src = R"(
var<private> a : array<f32, 3>; var<private> a : array<f32, 3>;
@ -143,12 +143,12 @@ fn f() {
} }
)"; )";
auto got = Run<BoundArrayAccessors>(src); auto got = Run<Robustness>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
TEST_F(BoundArrayAccessorsTest, Array_Idx_OutOfBounds) { TEST_F(RobustnessTest, Array_Idx_OutOfBounds) {
auto* src = R"( auto* src = R"(
var<private> a : array<f32, 3>; var<private> a : array<f32, 3>;
@ -165,12 +165,12 @@ fn f() {
} }
)"; )";
auto got = Run<BoundArrayAccessors>(src); auto got = Run<Robustness>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
TEST_F(BoundArrayAccessorsTest, Vector_Idx_Scalar) { TEST_F(RobustnessTest, Vector_Idx_Scalar) {
auto* src = R"( auto* src = R"(
var<private> a : vec3<f32>; var<private> a : vec3<f32>;
@ -187,12 +187,12 @@ fn f() {
} }
)"; )";
auto got = Run<BoundArrayAccessors>(src); auto got = Run<Robustness>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
TEST_F(BoundArrayAccessorsTest, Vector_Idx_Expr) { TEST_F(RobustnessTest, Vector_Idx_Expr) {
auto* src = R"( auto* src = R"(
var<private> a : vec3<f32>; var<private> a : vec3<f32>;
@ -213,12 +213,12 @@ fn f() {
} }
)"; )";
auto got = Run<BoundArrayAccessors>(src); auto got = Run<Robustness>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
TEST_F(BoundArrayAccessorsTest, Vector_Swizzle_Idx_Scalar) { TEST_F(RobustnessTest, Vector_Swizzle_Idx_Scalar) {
auto* src = R"( auto* src = R"(
var<private> a : vec3<f32>; var<private> a : vec3<f32>;
@ -235,12 +235,12 @@ fn f() {
} }
)"; )";
auto got = Run<BoundArrayAccessors>(src); auto got = Run<Robustness>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
TEST_F(BoundArrayAccessorsTest, Vector_Swizzle_Idx_Var) { TEST_F(RobustnessTest, Vector_Swizzle_Idx_Var) {
auto* src = R"( auto* src = R"(
var<private> a : vec3<f32>; var<private> a : vec3<f32>;
@ -261,11 +261,11 @@ fn f() {
} }
)"; )";
auto got = Run<BoundArrayAccessors>(src); auto got = Run<Robustness>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
TEST_F(BoundArrayAccessorsTest, Vector_Swizzle_Idx_Expr) { TEST_F(RobustnessTest, Vector_Swizzle_Idx_Expr) {
auto* src = R"( auto* src = R"(
var<private> a : vec3<f32>; var<private> a : vec3<f32>;
@ -286,12 +286,12 @@ fn f() {
} }
)"; )";
auto got = Run<BoundArrayAccessors>(src); auto got = Run<Robustness>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
TEST_F(BoundArrayAccessorsTest, Vector_Idx_Negative) { TEST_F(RobustnessTest, Vector_Idx_Negative) {
auto* src = R"( auto* src = R"(
var<private> a : vec3<f32>; var<private> a : vec3<f32>;
@ -308,12 +308,12 @@ fn f() {
} }
)"; )";
auto got = Run<BoundArrayAccessors>(src); auto got = Run<Robustness>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
TEST_F(BoundArrayAccessorsTest, Vector_Idx_OutOfBounds) { TEST_F(RobustnessTest, Vector_Idx_OutOfBounds) {
auto* src = R"( auto* src = R"(
var<private> a : vec3<f32>; var<private> a : vec3<f32>;
@ -330,12 +330,12 @@ fn f() {
} }
)"; )";
auto got = Run<BoundArrayAccessors>(src); auto got = Run<Robustness>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Scalar) { TEST_F(RobustnessTest, Matrix_Idx_Scalar) {
auto* src = R"( auto* src = R"(
var<private> a : mat3x2<f32>; var<private> a : mat3x2<f32>;
@ -352,12 +352,12 @@ fn f() {
} }
)"; )";
auto got = Run<BoundArrayAccessors>(src); auto got = Run<Robustness>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Expr_Column) { TEST_F(RobustnessTest, Matrix_Idx_Expr_Column) {
auto* src = R"( auto* src = R"(
var<private> a : mat3x2<f32>; var<private> a : mat3x2<f32>;
@ -378,12 +378,12 @@ fn f() {
} }
)"; )";
auto got = Run<BoundArrayAccessors>(src); auto got = Run<Robustness>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Expr_Row) { TEST_F(RobustnessTest, Matrix_Idx_Expr_Row) {
auto* src = R"( auto* src = R"(
var<private> a : mat3x2<f32>; var<private> a : mat3x2<f32>;
@ -404,12 +404,12 @@ fn f() {
} }
)"; )";
auto got = Run<BoundArrayAccessors>(src); auto got = Run<Robustness>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Negative_Column) { TEST_F(RobustnessTest, Matrix_Idx_Negative_Column) {
auto* src = R"( auto* src = R"(
var<private> a : mat3x2<f32>; var<private> a : mat3x2<f32>;
@ -426,12 +426,12 @@ fn f() {
} }
)"; )";
auto got = Run<BoundArrayAccessors>(src); auto got = Run<Robustness>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
TEST_F(BoundArrayAccessorsTest, Matrix_Idx_Negative_Row) { TEST_F(RobustnessTest, Matrix_Idx_Negative_Row) {
auto* src = R"( auto* src = R"(
var<private> a : mat3x2<f32>; var<private> a : mat3x2<f32>;
@ -448,12 +448,12 @@ fn f() {
} }
)"; )";
auto got = Run<BoundArrayAccessors>(src); auto got = Run<Robustness>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
TEST_F(BoundArrayAccessorsTest, Matrix_Idx_OutOfBounds_Column) { TEST_F(RobustnessTest, Matrix_Idx_OutOfBounds_Column) {
auto* src = R"( auto* src = R"(
var<private> a : mat3x2<f32>; var<private> a : mat3x2<f32>;
@ -470,12 +470,12 @@ fn f() {
} }
)"; )";
auto got = Run<BoundArrayAccessors>(src); auto got = Run<Robustness>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
TEST_F(BoundArrayAccessorsTest, Matrix_Idx_OutOfBounds_Row) { TEST_F(RobustnessTest, Matrix_Idx_OutOfBounds_Row) {
auto* src = R"( auto* src = R"(
var<private> a : mat3x2<f32>; var<private> a : mat3x2<f32>;
@ -492,13 +492,13 @@ fn f() {
} }
)"; )";
auto got = Run<BoundArrayAccessors>(src); auto got = Run<Robustness>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
// TODO(dsinclair): Implement when constant_id exists // 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; // [[override(1300)]] let idx : i32;
// var a : vec3<f32> // var a : vec3<f32>
// var b : f32 = a[idx] // var b : f32 = a[idx]
@ -507,7 +507,7 @@ TEST_F(BoundArrayAccessorsTest, DISABLED_Vector_Constant_Id_Clamps) {
} }
// TODO(dsinclair): Implement when constant_id exists // 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; // [[override(1300)]] let idx : i32;
// var a : array<f32, 4> // var a : array<f32, 4>
// var b : f32 = a[idx] // var b : f32 = a[idx]
@ -516,7 +516,7 @@ TEST_F(BoundArrayAccessorsTest, DISABLED_Array_Constant_Id_Clamps) {
} }
// TODO(dsinclair): Implement when constant_id exists // 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; // [[override(1300)]] let idx : i32;
// var a : mat3x2<f32> // var a : mat3x2<f32>
// var b : f32 = a[idx][1] // 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 // 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; // [[override(1300)]] let idx : i32;
// var a : mat3x2<f32> // var a : mat3x2<f32>
// var b : f32 = a[1][idx] // 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)] // -> var b : f32 = a[1][min(u32(idx), 0, 1)]
} }
TEST_F(BoundArrayAccessorsTest, RuntimeArray_Clamps) { TEST_F(RobustnessTest, RuntimeArray_Clamps) {
auto* src = R"( auto* src = R"(
[[block]] [[block]]
struct S { struct S {
@ -561,24 +561,24 @@ fn f() {
} }
)"; )";
auto got = Run<BoundArrayAccessors>(src); auto got = Run<Robustness>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }
// TODO(dsinclair): Clamp atomics when available. // TODO(dsinclair): Clamp atomics when available.
TEST_F(BoundArrayAccessorsTest, DISABLED_Atomics_Clamp) { TEST_F(RobustnessTest, DISABLED_Atomics_Clamp) {
FAIL(); FAIL();
} }
// TODO(dsinclair): Clamp texture coord values. Depends on: // TODO(dsinclair): Clamp texture coord values. Depends on:
// https://github.com/gpuweb/gpuweb/issues/1107 // https://github.com/gpuweb/gpuweb/issues/1107
TEST_F(BoundArrayAccessorsTest, DISABLED_TextureCoord_Clamp) { TEST_F(RobustnessTest, DISABLED_TextureCoord_Clamp) {
FAIL(); FAIL();
} }
// TODO(dsinclair): Test for scoped variables when Lexical Scopes implemented // 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<f32, 3>; // var a : array<f32, 3>;
// var i : u32; // 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. // Check that existing use of min() and arrayLength() do not get renamed.
TEST_F(BoundArrayAccessorsTest, DontRenameSymbols) { TEST_F(RobustnessTest, DontRenameSymbols) {
auto* src = R"( auto* src = R"(
[[block]] [[block]]
struct S { struct S {
@ -630,7 +630,7 @@ fn f() {
} }
)"; )";
auto got = Run<BoundArrayAccessors>(src); auto got = Run<Robustness>(src);
EXPECT_EQ(expect, str(got)); EXPECT_EQ(expect, str(got));
} }

View File

@ -278,7 +278,6 @@ tint_unittests_source_set("tint_unittests_core_src") {
"../src/traits_test.cc", "../src/traits_test.cc",
"../src/transform/array_length_from_uniform_test.cc", "../src/transform/array_length_from_uniform_test.cc",
"../src/transform/binding_remapper_test.cc", "../src/transform/binding_remapper_test.cc",
"../src/transform/bound_array_accessors_test.cc",
"../src/transform/calculate_array_length_test.cc", "../src/transform/calculate_array_length_test.cc",
"../src/transform/canonicalize_entry_point_io_test.cc", "../src/transform/canonicalize_entry_point_io_test.cc",
"../src/transform/decompose_memory_access_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/pad_array_elements_test.cc",
"../src/transform/promote_initializers_to_const_var_test.cc", "../src/transform/promote_initializers_to_const_var_test.cc",
"../src/transform/renamer_test.cc", "../src/transform/renamer_test.cc",
"../src/transform/robustness_test.cc",
"../src/transform/simplify_test.cc", "../src/transform/simplify_test.cc",
"../src/transform/single_entry_point_test.cc", "../src/transform/single_entry_point_test.cc",
"../src/transform/test_helper.h", "../src/transform/test_helper.h",