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

Method CloneAndMapLocals

source/opt/inline_pass.cpp:156–185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

154}
155
156bool InlinePass::CloneAndMapLocals(
157 Function* calleeFn, std::vector<std::unique_ptr<Instruction>>* new_vars,
158 std::unordered_map<uint32_t, uint32_t>* callee2caller,
159 analysis::DebugInlinedAtContext* inlined_at_ctx) {
160 auto callee_block_itr = calleeFn->begin();
161 auto callee_var_itr = callee_block_itr->begin();
162 while (callee_var_itr->opcode() == spv::Op::OpVariable ||
163 callee_var_itr->GetCommonDebugOpcode() ==
164 CommonDebugInfoDebugDeclare) {
165 if (callee_var_itr->opcode() != spv::Op::OpVariable) {
166 ++callee_var_itr;
167 continue;
168 }
169
170 std::unique_ptr<Instruction> var_inst(callee_var_itr->Clone(context()));
171 uint32_t newId = context()->TakeNextId();
172 if (newId == 0) {
173 return false;
174 }
175 get_decoration_mgr()->CloneDecorations(callee_var_itr->result_id(), newId);
176 var_inst->SetResultId(newId);
177 var_inst->UpdateDebugInlinedAt(
178 context()->get_debug_info_mgr()->BuildDebugInlinedAtChain(
179 callee_var_itr->GetDebugInlinedAt(), inlined_at_ctx));
180 (*callee2caller)[callee_var_itr->result_id()] = newId;
181 new_vars->push_back(std::move(var_inst));
182 ++callee_var_itr;
183 }
184 return true;
185}
186
187uint32_t InlinePass::CreateReturnVar(
188 Function* calleeFn, std::vector<std::unique_ptr<Instruction>>* new_vars) {

Callers

nothing calls this directly

Calls 13

GetCommonDebugOpcodeMethod · 0.80
CloneDecorationsMethod · 0.80
UpdateDebugInlinedAtMethod · 0.80
get_debug_info_mgrMethod · 0.80
beginMethod · 0.45
opcodeMethod · 0.45
CloneMethod · 0.45
TakeNextIdMethod · 0.45
result_idMethod · 0.45
SetResultIdMethod · 0.45
GetDebugInlinedAtMethod · 0.45

Tested by

no test coverage detected