Add storage_class error reporting to generators and transform.

With the experimental push_contants PR we will have AST which can not be
generated by all backends. Historically this would trigger the fuzzers as
an error. This CL changes the storage_class to an error from an ICE and
updates the code so the fuzzers only error on ICE or Fatal errors.

Change-Id: I2039a3d4cb457d805d38e2d6a790121318d1f07d
Bug: tint:1620
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/97281
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Dan Sinclair <dsinclair@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
dan sinclair 2022-07-27 18:54:05 +00:00 committed by Dawn LUCI CQ
parent f330229de5
commit 8dbd4d0280
4 changed files with 9 additions and 25 deletions

View File

@ -219,12 +219,7 @@ int CommonFuzzer::Run(const uint8_t* data, size_t size) {
switch (output_) {
case OutputFormat::kWGSL: {
#if TINT_BUILD_WGSL_WRITER
auto result = writer::wgsl::Generate(&program, options_wgsl_);
generated_wgsl_ = std::move(result.wgsl);
if (!result.success) {
VALIDITY_ERROR(program.Diagnostics(),
"WGSL writer errored on validated input:\n" + result.error);
}
writer::wgsl::Generate(&program, options_wgsl_);
#endif // TINT_BUILD_WGSL_WRITER
break;
}
@ -232,10 +227,6 @@ int CommonFuzzer::Run(const uint8_t* data, size_t size) {
#if TINT_BUILD_SPV_WRITER
auto result = writer::spirv::Generate(&program, options_spirv_);
generated_spirv_ = std::move(result.spirv);
if (!result.success) {
VALIDITY_ERROR(program.Diagnostics(),
"SPIR-V writer errored on validated input:\n" + result.error);
}
if (!SPIRVToolsValidationCheck(program, generated_spirv_)) {
VALIDITY_ERROR(program.Diagnostics(),
@ -247,12 +238,7 @@ int CommonFuzzer::Run(const uint8_t* data, size_t size) {
}
case OutputFormat::kHLSL: {
#if TINT_BUILD_HLSL_WRITER
auto result = writer::hlsl::Generate(&program, options_hlsl_);
generated_hlsl_ = std::move(result.hlsl);
if (!result.success) {
VALIDITY_ERROR(program.Diagnostics(),
"HLSL writer errored on validated input:\n" + result.error);
}
writer::hlsl::Generate(&program, options_hlsl_);
#endif // TINT_BUILD_HLSL_WRITER
break;
}
@ -266,12 +252,7 @@ int CommonFuzzer::Run(const uint8_t* data, size_t size) {
input_program = &*flattened;
}
auto result = writer::msl::Generate(input_program, options_msl_);
generated_msl_ = std::move(result.msl);
if (!result.success) {
VALIDITY_ERROR(input_program->Diagnostics(),
"MSL writer errored on validated input:\n" + result.error);
}
writer::msl::Generate(input_program, options_msl_);
#endif // TINT_BUILD_MSL_WRITER
break;
}

View File

@ -219,9 +219,10 @@ struct ModuleScopeVarToEntryPointParam::State {
case ast::StorageClass::kHandle:
case ast::StorageClass::kWorkgroup:
break;
default:
default: {
TINT_ICE(Transform, ctx.dst->Diagnostics())
<< "unhandled module-scope storage class (" << sc << ")";
}
}
// Use a pointer for non-handle types.

View File

@ -1932,10 +1932,11 @@ bool GeneratorImpl::EmitGlobalVariable(const ast::Variable* global) {
case ast::StorageClass::kIn:
case ast::StorageClass::kOut:
return EmitIOVariable(sem);
default:
default: {
TINT_ICE(Writer, diagnostics_)
<< "unhandled storage class " << sem->StorageClass();
return false;
}
}
},
[&](const ast::Let* let) { return EmitProgramConstVariable(let); },

View File

@ -2849,10 +2849,11 @@ bool GeneratorImpl::EmitGlobalVariable(const ast::Variable* global) {
return EmitPrivateVariable(sem);
case ast::StorageClass::kWorkgroup:
return EmitWorkgroupVariable(sem);
default:
default: {
TINT_ICE(Writer, diagnostics_)
<< "unhandled storage class " << sem->StorageClass();
return false;
}
}
},
[&](const ast::Override* override) { return EmitOverride(override); },