[tint][ast][msl] Skip the MSL fuzzer if the program has multiple entry points
Bug: 342435250
Change-Id: I96e3b46ce15d9678206278a21bc0a03a35da6ce0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/189820
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: James Price <jrprice@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
diff --git a/src/tint/cmd/fuzz/wgsl/fuzz.cc b/src/tint/cmd/fuzz/wgsl/fuzz.cc
index 20de4f5..b5467bc 100644
--- a/src/tint/cmd/fuzz/wgsl/fuzz.cc
+++ b/src/tint/cmd/fuzz/wgsl/fuzz.cc
@@ -36,6 +36,7 @@
#include "src/tint/lang/wgsl/ast/alias.h"
#include "src/tint/lang/wgsl/ast/function.h"
#include "src/tint/lang/wgsl/ast/identifier.h"
+#include "src/tint/lang/wgsl/ast/module.h"
#include "src/tint/lang/wgsl/ast/struct.h"
#include "src/tint/lang/wgsl/ast/variable.h"
#include "src/tint/lang/wgsl/builtin_fn.h"
@@ -104,6 +105,19 @@
break; // Early exit - nothing more to find.
}
}
+
+ // Check for multiple entry points
+ bool entry_point_found = false;
+ for (auto* fn : program.AST().Functions()) {
+ if (fn->IsEntryPoint()) {
+ if (entry_point_found) {
+ out.Add(ProgramProperties::kMultipleEntryPoints);
+ break;
+ }
+ entry_point_found = true;
+ }
+ }
+
return out;
}
diff --git a/src/tint/cmd/fuzz/wgsl/fuzz.h b/src/tint/cmd/fuzz/wgsl/fuzz.h
index a24514b..aa3cbc6 100644
--- a/src/tint/cmd/fuzz/wgsl/fuzz.h
+++ b/src/tint/cmd/fuzz/wgsl/fuzz.h
@@ -61,6 +61,8 @@
kBuiltinFnsShadowed,
/// The program has builtin types which have been shadowed
kBuiltinTypesShadowed,
+ /// The program has multiple entry points
+ kMultipleEntryPoints,
};
/// Context holds information about the fuzzer options and the input program.
diff --git a/src/tint/lang/msl/writer/writer_ast_fuzz.cc b/src/tint/lang/msl/writer/writer_ast_fuzz.cc
index 937a4a8..12c1a55 100644
--- a/src/tint/lang/msl/writer/writer_ast_fuzz.cc
+++ b/src/tint/lang/msl/writer/writer_ast_fuzz.cc
@@ -35,8 +35,10 @@
namespace tint::msl::writer {
namespace {
-void ASTFuzzer(const tint::Program& program, Options options) {
- if (program.AST().HasOverrides()) {
+void ASTFuzzer(const tint::Program& program, const fuzz::wgsl::Context& context, Options options) {
+ if (program.AST().HasOverrides() ||
+ context.program_properties.Contains(fuzz::wgsl::ProgramProperties::kMultipleEntryPoints)) {
+ // MSL writer assumes the SubstituteOverride and SingleEntryPoint transforms have been run
return;
}