| 378 | } |
| 379 | |
| 380 | std::unique_ptr<BasicBlock> InlinePass::InlineReturn( |
| 381 | const std::unordered_map<uint32_t, uint32_t>& callee2caller, |
| 382 | std::vector<std::unique_ptr<BasicBlock>>* new_blocks, |
| 383 | std::unique_ptr<BasicBlock> new_blk_ptr, |
| 384 | analysis::DebugInlinedAtContext* inlined_at_ctx, Function* calleeFn, |
| 385 | const Instruction* inst, uint32_t returnVarId) { |
| 386 | // Store return value to return variable. |
| 387 | if (inst->opcode() == spv::Op::OpReturnValue) { |
| 388 | assert(returnVarId != 0); |
| 389 | uint32_t valId = inst->GetInOperand(kSpvReturnValueId).words[0]; |
| 390 | const auto mapItr = callee2caller.find(valId); |
| 391 | if (mapItr != callee2caller.end()) { |
| 392 | valId = mapItr->second; |
| 393 | } |
| 394 | AddStore(returnVarId, valId, &new_blk_ptr, inst->dbg_line_inst(), |
| 395 | context()->get_debug_info_mgr()->BuildDebugScope( |
| 396 | inst->GetDebugScope(), inlined_at_ctx)); |
| 397 | } |
| 398 | |
| 399 | uint32_t returnLabelId = 0; |
| 400 | for (auto callee_block_itr = calleeFn->begin(); |
| 401 | callee_block_itr != calleeFn->end(); ++callee_block_itr) { |
| 402 | if (spvOpcodeIsAbort(callee_block_itr->tail()->opcode())) { |
| 403 | returnLabelId = context()->TakeNextId(); |
| 404 | break; |
| 405 | } |
| 406 | } |
| 407 | if (returnLabelId == 0) return new_blk_ptr; |
| 408 | |
| 409 | if (inst->opcode() == spv::Op::OpReturn || |
| 410 | inst->opcode() == spv::Op::OpReturnValue) |
| 411 | AddBranch(returnLabelId, &new_blk_ptr); |
| 412 | new_blocks->push_back(std::move(new_blk_ptr)); |
| 413 | return MakeUnique<BasicBlock>(NewLabel(returnLabelId)); |
| 414 | } |
| 415 | |
| 416 | bool InlinePass::InlineEntryBlock( |
| 417 | const std::unordered_map<uint32_t, uint32_t>& callee2caller, |
nothing calls this directly
no test coverage detected