spirv-fuzz: Fix to operand id type (#3937)

Fixes #3934.
This commit is contained in:
Alastair Donaldson 2020-10-19 17:33:25 +01:00 committed by GitHub
parent cd1d3b6e0c
commit 5d7893b376
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -117,7 +117,7 @@ void TransformationReplaceBranchFromDeadBlockWithExit::Apply(
opt::Instruction::OperandList new_terminator_in_operands;
if (message_.opcode() == SpvOpReturnValue) {
new_terminator_in_operands.push_back(
{SPV_OPERAND_TYPE_TYPE_ID, {message_.return_value_id()}});
{SPV_OPERAND_TYPE_ID, {message_.return_value_id()}});
}
auto terminator = block->terminator();
terminator->SetOpcode(static_cast<SpvOp>(message_.opcode()));

View File

@ -337,6 +337,12 @@ TEST(TransformationReplaceBranchFromDeadBlockWithExitTest,
ASSERT_TRUE(fuzzerutil::IsValidAndWellFormed(context.get(), validator_options,
kConsoleMessageConsumer));
opt::Instruction* return_value_inst =
context->get_instr_block(201)->terminator();
ASSERT_EQ(SpvOpReturnValue, return_value_inst->opcode());
ASSERT_EQ(SPV_OPERAND_TYPE_ID, return_value_inst->GetInOperand(0).type);
ASSERT_EQ(400, return_value_inst->GetSingleWordInOperand(0));
std::string after_transformation = R"(
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"