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

Method InlineReturn

source/opt/inline_pass.cpp:380–414  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

378}
379
380std::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
416bool InlinePass::InlineEntryBlock(
417 const std::unordered_map<uint32_t, uint32_t>& callee2caller,

Callers

nothing calls this directly

Calls 10

spvOpcodeIsAbortFunction · 0.85
dbg_line_instMethod · 0.80
BuildDebugScopeMethod · 0.80
get_debug_info_mgrMethod · 0.80
opcodeMethod · 0.45
endMethod · 0.45
beginMethod · 0.45
tailMethod · 0.45
TakeNextIdMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected