[fuzz] Enable IR validation assertions

These assertions are not enabled by default in Release mode builds
(which the fuzzers often use), which means we may miss some
issues. Use the new runtime flag to enable them all of the time.

Bug: 467330780
Change-Id: I003e6916e8695ba59c97ce7b97edeb2f9b9ea34e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/299538
Reviewed-by: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: James Price <jrprice@google.com>
diff --git a/src/tint/cmd/fuzz/ir/fuzz.cc b/src/tint/cmd/fuzz/ir/fuzz.cc
index bbcc05d..69e4830 100644
--- a/src/tint/cmd/fuzz/ir/fuzz.cc
+++ b/src/tint/cmd/fuzz/ir/fuzz.cc
@@ -73,7 +73,13 @@
                 return;
             }
 
-            auto ir = tint::wgsl::reader::ProgramToLoweredIR(program);
+            // Enable validation assertions.
+            // Any validation failure after this point is a bug in Tint which we want to find.
+            tint::wgsl::reader::IROptions ir_options{
+                .enable_validation_asserts = true,
+            };
+
+            auto ir = tint::wgsl::reader::ProgramToLoweredIR(program, ir_options);
             if (ir != Success) {
                 return;
             }
@@ -159,6 +165,10 @@
                     return;
                 }
 
+                // Enable validation assertions.
+                // Any validation failure after this point is a bug in Tint which we want to find.
+                mod.enable_validation_asserts = true;
+
                 if (auto result = fuzzer.fn(mod, context, data); result != Success) {
                     if (context.options.verbose) {
                         std::cout << "   Failed to execute fuzzer: " << result.Failure() << "\n";