spirv-reader: Error for OpSpecConstantComposite expression

This is not currently supported, so produce a meaningful error message
instead of crashing.

Bug: oss-fuzz:55819
Bug: tint:111
Change-Id: Ib245a47edbbe6ef972844f940ea1d674e6b08a76
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/131222
Commit-Queue: James Price <jrprice@google.com>
Reviewed-by: David Neto <dneto@google.com>
Kokoro: James Price <jrprice@google.com>
This commit is contained in:
James Price 2023-05-08 17:48:30 +00:00 committed by Dawn LUCI CQ
parent 8aa6bf2119
commit a187e9e281
2 changed files with 12 additions and 2 deletions

View File

@ -4075,6 +4075,12 @@ TypedExpression FunctionEmitter::EmitGlslStd450ExtInst(const spvtools::opt::Inst
// All parameters to GLSL.std.450 extended instructions are IDs. // All parameters to GLSL.std.450 extended instructions are IDs.
for (uint32_t iarg = 2; iarg < inst.NumInOperands(); ++iarg) { for (uint32_t iarg = 2; iarg < inst.NumInOperands(); ++iarg) {
TypedExpression operand = MakeOperand(inst, iarg); TypedExpression operand = MakeOperand(inst, iarg);
if (!operand.expr) {
if (!failed()) {
Fail() << "unexpected failure to make an operand";
}
return {};
}
if (first_operand_type == nullptr) { if (first_operand_type == nullptr) {
first_operand_type = operand.type; first_operand_type = operand.type;
} }

View File

@ -1891,8 +1891,6 @@ TypedExpression ParserImpl::MakeConstantExpression(uint32_t id) {
} }
auto source = GetSourceForInst(inst); auto source = GetSourceForInst(inst);
// TODO(dneto): Handle spec constants too?
auto* original_ast_type = ConvertType(inst->type_id()); auto* original_ast_type = ConvertType(inst->type_id());
if (original_ast_type == nullptr) { if (original_ast_type == nullptr) {
return {}; return {};
@ -1952,6 +1950,12 @@ TypedExpression ParserImpl::MakeConstantExpression(uint32_t id) {
declared_constant_composites_.insert({id, decl->name->symbol}); declared_constant_composites_.insert({id, decl->name->symbol});
return {original_ast_type, builder_.Expr(name)}; return {original_ast_type, builder_.Expr(name)};
} }
case spv::Op::OpSpecConstantComposite:
case spv::Op::OpSpecConstantOp: {
// TODO(crbug.com/tint/111): Handle OpSpecConstantOp and OpSpecConstantComposite here.
Fail() << "unimplemented: OpSpecConstantOp and OpSpecConstantComposite";
return {};
}
default: default:
break; break;
} }