| 154 | } |
| 155 | |
| 156 | bool 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 | |
| 187 | uint32_t InlinePass::CreateReturnVar( |
| 188 | Function* calleeFn, std::vector<std::unique_ptr<Instruction>>* new_vars) { |
nothing calls this directly
no test coverage detected