| 96 | } |
| 97 | |
| 98 | void TransformationReplaceIrrelevantId::Apply( |
| 99 | opt::IRContext* ir_context, |
| 100 | TransformationContext* /* transformation_context */) const { |
| 101 | // Find the instruction. |
| 102 | auto instruction_to_change = |
| 103 | FindInstructionContainingUse(message_.id_use_descriptor(), ir_context); |
| 104 | |
| 105 | // Replace the instruction. |
| 106 | instruction_to_change->SetInOperand( |
| 107 | message_.id_use_descriptor().in_operand_index(), |
| 108 | {message_.replacement_id()}); |
| 109 | |
| 110 | ir_context->get_def_use_mgr()->EraseUseRecordsOfOperandIds( |
| 111 | instruction_to_change); |
| 112 | ir_context->get_def_use_mgr()->AnalyzeInstUse(instruction_to_change); |
| 113 | |
| 114 | // No analyses need to be invalidated, since the transformation is local to a |
| 115 | // block, and the def-use analysis has been updated. |
| 116 | } |
| 117 | |
| 118 | protobufs::Transformation TransformationReplaceIrrelevantId::ToMessage() const { |
| 119 | protobufs::Transformation result; |
nothing calls this directly
no test coverage detected