| 285 | } |
| 286 | |
| 287 | bool 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 | |
| 308 | bool CanMakeSynonymOf(opt::IRContext* ir_context, |
| 309 | const TransformationContext& transformation_context, |
no test coverage detected