MCPcopy Create free account
hub / github.com/KhronosGroup/SPIRV-Tools / CanInsertOpcodeBeforeInstruction

Function CanInsertOpcodeBeforeInstruction

source/fuzz/fuzzer_util.cpp:287–306  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

285}
286
287bool CanInsertOpcodeBeforeInstruction(
288 spv::Op opcode, const opt::BasicBlock::iterator& instruction_in_block) {
289 if (instruction_in_block->PreviousNode() &&
290 (instruction_in_block->PreviousNode()->opcode() == spv::Op::OpLoopMerge ||
291 instruction_in_block->PreviousNode()->opcode() ==
292 spv::Op::OpSelectionMerge)) {
293 // We cannot insert directly after a merge instruction.
294 return false;
295 }
296 if (opcode != spv::Op::OpVariable &&
297 instruction_in_block->opcode() == spv::Op::OpVariable) {
298 // We cannot insert a non-OpVariable instruction directly before a
299 // variable; variables in a function must be contiguous in the entry block.
300 return false;
301 }
302 // We cannot insert a non-OpPhi instruction directly before an OpPhi, because
303 // OpPhi instructions need to be contiguous at the start of a block.
304 return opcode == spv::Op::OpPhi ||
305 instruction_in_block->opcode() != spv::Op::OpPhi;
306}
307
308bool CanMakeSynonymOf(opt::IRContext* ir_context,
309 const TransformationContext& transformation_context,

Callers 15

ApplyMethod · 0.85
IsApplicableMethod · 0.85
IsApplicableMethod · 0.85
ApplyMethod · 0.85
IsApplicableMethod · 0.85
ApplyMethod · 0.85
ApplyMethod · 0.85
ApplyMethod · 0.85
IsApplicableMethod · 0.85
ApplyMethod · 0.85

Calls 2

PreviousNodeMethod · 0.80
opcodeMethod · 0.45

Tested by

no test coverage detected