spirv-fuzz: Fix in operand type assertion (#3666)

spvtools::fuzz::MakeIdUseDescriptorFromUse asserts if the id use type is
SPV_OPERAND_TYPE_ID. The problem is that not all id types are covered by
this condition. The bug was found because the first operand of an OpControlBarrier
instruction has SPV_OPERAND_TYPE_SCOPE_ID as type. Therefore, to cover
all cases the spvIsInIdType function is used.

Fixes #3665.
This commit is contained in:
André Perez 2020-08-11 14:37:01 -03:00 committed by GitHub
parent f505538677
commit fd3cabd8b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -52,7 +52,7 @@ protobufs::IdUseDescriptor MakeIdUseDescriptorFromUse(
opt::IRContext* context, opt::Instruction* inst, opt::IRContext* context, opt::Instruction* inst,
uint32_t in_operand_index) { uint32_t in_operand_index) {
const auto& in_operand = inst->GetInOperand(in_operand_index); const auto& in_operand = inst->GetInOperand(in_operand_index);
assert(in_operand.type == SPV_OPERAND_TYPE_ID); assert(spvIsInIdType(in_operand.type));
return MakeIdUseDescriptor(in_operand.words[0], return MakeIdUseDescriptor(in_operand.words[0],
MakeInstructionDescriptor(context, inst), MakeInstructionDescriptor(context, inst),
in_operand_index); in_operand_index);