mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2024-10-18 11:10:05 +00:00
spirv-fuzz: Make adding equation instructions more efficient (#4190)
Avoids unnecessary invalidation of analyses.
This commit is contained in:
parent
e8ab7101f6
commit
db2a706467
@ -84,13 +84,19 @@ void TransformationEquationInstruction::Apply(
|
||||
rhs_id.push_back(id);
|
||||
}
|
||||
|
||||
FindInstruction(message_.instruction_to_insert_before(), ir_context)
|
||||
->InsertBefore(MakeUnique<opt::Instruction>(
|
||||
ir_context, static_cast<SpvOp>(message_.opcode()),
|
||||
MaybeGetResultTypeId(ir_context), message_.fresh_id(),
|
||||
std::move(in_operands)));
|
||||
auto new_instruction = MakeUnique<opt::Instruction>(
|
||||
ir_context, static_cast<SpvOp>(message_.opcode()),
|
||||
MaybeGetResultTypeId(ir_context), message_.fresh_id(),
|
||||
std::move(in_operands));
|
||||
auto new_instruction_ptr = new_instruction.get();
|
||||
|
||||
ir_context->InvalidateAnalysesExceptFor(opt::IRContext::kAnalysisNone);
|
||||
auto insert_before =
|
||||
FindInstruction(message_.instruction_to_insert_before(), ir_context);
|
||||
insert_before->InsertBefore(std::move(new_instruction));
|
||||
|
||||
ir_context->get_def_use_mgr()->AnalyzeInstDefUse(new_instruction_ptr);
|
||||
ir_context->set_instr_block(new_instruction_ptr,
|
||||
ir_context->get_instr_block(insert_before));
|
||||
|
||||
// Add an equation fact as long as the result id is not irrelevant (it could
|
||||
// be if we are inserting into a dead block).
|
||||
|
Loading…
Reference in New Issue
Block a user