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

Method Apply

source/fuzz/transformation_composite_insert.cpp:108–144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

106}
107
108void TransformationCompositeInsert::Apply(
109 opt::IRContext* ir_context,
110 TransformationContext* transformation_context) const {
111 // |message_.struct_fresh_id| must be fresh.
112 assert(fuzzerutil::IsFreshId(ir_context, message_.fresh_id()) &&
113 "|message_.fresh_id| must be fresh");
114
115 std::vector<uint32_t> index =
116 fuzzerutil::RepeatedFieldToVector(message_.index());
117 opt::Instruction::OperandList in_operands;
118 in_operands.push_back({SPV_OPERAND_TYPE_ID, {message_.object_id()}});
119 in_operands.push_back({SPV_OPERAND_TYPE_ID, {message_.composite_id()}});
120 for (auto i : index) {
121 in_operands.push_back({SPV_OPERAND_TYPE_LITERAL_INTEGER, {i}});
122 }
123 auto composite_type_id =
124 fuzzerutil::GetTypeId(ir_context, message_.composite_id());
125
126 auto insert_before =
127 FindInstruction(message_.instruction_to_insert_before(), ir_context);
128 auto new_instruction = MakeUnique<opt::Instruction>(
129 ir_context, spv::Op::OpCompositeInsert, composite_type_id,
130 message_.fresh_id(), std::move(in_operands));
131 auto new_instruction_ptr = new_instruction.get();
132 insert_before->InsertBefore(std::move(new_instruction));
133
134 fuzzerutil::UpdateModuleIdBound(ir_context, message_.fresh_id());
135
136 // Inform the def-use manager about the new instruction and record its basic
137 // block.
138 ir_context->get_def_use_mgr()->AnalyzeInstDefUse(new_instruction_ptr);
139 ir_context->set_instr_block(new_instruction_ptr,
140 ir_context->get_instr_block(insert_before));
141
142 // Add data synonym facts that arise from the insertion.
143 AddDataSynonymFacts(ir_context, transformation_context);
144}
145
146protobufs::Transformation TransformationCompositeInsert::ToMessage() const {
147 protobufs::Transformation result;

Callers

nothing calls this directly

Calls 12

IsFreshIdFunction · 0.85
RepeatedFieldToVectorFunction · 0.85
GetTypeIdFunction · 0.85
FindInstructionFunction · 0.85
UpdateModuleIdBoundFunction · 0.85
getMethod · 0.80
AnalyzeInstDefUseMethod · 0.80
set_instr_blockMethod · 0.80
get_instr_blockMethod · 0.80
push_backMethod · 0.45
InsertBeforeMethod · 0.45
get_def_use_mgrMethod · 0.45

Tested by

no test coverage detected