#include "source/opt/inline_pass.h"
#include <unordered_set>
#include <utility>
#include "source/cfa.h"
#include "source/opt/reflect.h"
#include "source/util/make_unique.h"
namespace spvtools {
namespace opt {
namespace {
constexpr int kSpvFunctionCallFunctionId = …;
constexpr int kSpvFunctionCallArgumentId = …;
constexpr int kSpvReturnValueId = …;
}
uint32_t InlinePass::AddPointerToType(uint32_t type_id,
spv::StorageClass storage_class) { … }
void InlinePass::AddBranch(uint32_t label_id,
std::unique_ptr<BasicBlock>* block_ptr) { … }
void InlinePass::AddBranchCond(uint32_t cond_id, uint32_t true_id,
uint32_t false_id,
std::unique_ptr<BasicBlock>* block_ptr) { … }
void InlinePass::AddLoopMerge(uint32_t merge_id, uint32_t continue_id,
std::unique_ptr<BasicBlock>* block_ptr) { … }
void InlinePass::AddStore(uint32_t ptr_id, uint32_t val_id,
std::unique_ptr<BasicBlock>* block_ptr,
const Instruction* line_inst,
const DebugScope& dbg_scope) { … }
void InlinePass::AddLoad(uint32_t type_id, uint32_t resultId, uint32_t ptr_id,
std::unique_ptr<BasicBlock>* block_ptr,
const Instruction* line_inst,
const DebugScope& dbg_scope) { … }
std::unique_ptr<Instruction> InlinePass::NewLabel(uint32_t label_id) { … }
uint32_t InlinePass::GetFalseId() { … }
void InlinePass::MapParams(
Function* calleeFn, BasicBlock::iterator call_inst_itr,
std::unordered_map<uint32_t, uint32_t>* callee2caller) { … }
bool InlinePass::CloneAndMapLocals(
Function* calleeFn, std::vector<std::unique_ptr<Instruction>>* new_vars,
std::unordered_map<uint32_t, uint32_t>* callee2caller,
analysis::DebugInlinedAtContext* inlined_at_ctx) { … }
uint32_t InlinePass::CreateReturnVar(
Function* calleeFn, std::vector<std::unique_ptr<Instruction>>* new_vars) { … }
bool InlinePass::IsSameBlockOp(const Instruction* inst) const { … }
bool InlinePass::CloneSameBlockOps(
std::unique_ptr<Instruction>* inst,
std::unordered_map<uint32_t, uint32_t>* postCallSB,
std::unordered_map<uint32_t, Instruction*>* preCallSB,
std::unique_ptr<BasicBlock>* block_ptr) { … }
void InlinePass::MoveInstsBeforeEntryBlock(
std::unordered_map<uint32_t, Instruction*>* preCallSB,
BasicBlock* new_blk_ptr, BasicBlock::iterator call_inst_itr,
UptrVectorIterator<BasicBlock> call_block_itr) { … }
std::unique_ptr<BasicBlock> InlinePass::AddGuardBlock(
std::vector<std::unique_ptr<BasicBlock>>* new_blocks,
std::unordered_map<uint32_t, uint32_t>* callee2caller,
std::unique_ptr<BasicBlock> new_blk_ptr, uint32_t entry_blk_label_id) { … }
InstructionList::iterator InlinePass::AddStoresForVariableInitializers(
const std::unordered_map<uint32_t, uint32_t>& callee2caller,
analysis::DebugInlinedAtContext* inlined_at_ctx,
std::unique_ptr<BasicBlock>* new_blk_ptr,
UptrVectorIterator<BasicBlock> callee_first_block_itr) { … }
bool InlinePass::InlineSingleInstruction(
const std::unordered_map<uint32_t, uint32_t>& callee2caller,
BasicBlock* new_blk_ptr, const Instruction* inst, uint32_t dbg_inlined_at) { … }
std::unique_ptr<BasicBlock> InlinePass::InlineReturn(
const std::unordered_map<uint32_t, uint32_t>& callee2caller,
std::vector<std::unique_ptr<BasicBlock>>* new_blocks,
std::unique_ptr<BasicBlock> new_blk_ptr,
analysis::DebugInlinedAtContext* inlined_at_ctx, Function* calleeFn,
const Instruction* inst, uint32_t returnVarId) { … }
bool InlinePass::InlineEntryBlock(
const std::unordered_map<uint32_t, uint32_t>& callee2caller,
std::unique_ptr<BasicBlock>* new_blk_ptr,
UptrVectorIterator<BasicBlock> callee_first_block,
analysis::DebugInlinedAtContext* inlined_at_ctx) { … }
std::unique_ptr<BasicBlock> InlinePass::InlineBasicBlocks(
std::vector<std::unique_ptr<BasicBlock>>* new_blocks,
const std::unordered_map<uint32_t, uint32_t>& callee2caller,
std::unique_ptr<BasicBlock> new_blk_ptr,
analysis::DebugInlinedAtContext* inlined_at_ctx, Function* calleeFn) { … }
bool InlinePass::MoveCallerInstsAfterFunctionCall(
std::unordered_map<uint32_t, Instruction*>* preCallSB,
std::unordered_map<uint32_t, uint32_t>* postCallSB,
std::unique_ptr<BasicBlock>* new_blk_ptr,
BasicBlock::iterator call_inst_itr, bool multiBlocks) { … }
void InlinePass::MoveLoopMergeInstToFirstBlock(
std::vector<std::unique_ptr<BasicBlock>>* new_blocks) { … }
void InlinePass::UpdateSingleBlockLoopContinueTarget(
uint32_t new_id, std::vector<std::unique_ptr<BasicBlock>>* new_blocks) { … }
bool InlinePass::GenInlineCode(
std::vector<std::unique_ptr<BasicBlock>>* new_blocks,
std::vector<std::unique_ptr<Instruction>>* new_vars,
BasicBlock::iterator call_inst_itr,
UptrVectorIterator<BasicBlock> call_block_itr) { … }
bool InlinePass::IsInlinableFunctionCall(const Instruction* inst) { … }
void InlinePass::UpdateSucceedingPhis(
std::vector<std::unique_ptr<BasicBlock>>& new_blocks) { … }
bool InlinePass::HasNoReturnInLoop(Function* func) { … }
void InlinePass::AnalyzeReturns(Function* func) { … }
bool InlinePass::IsInlinableFunction(Function* func) { … }
bool InlinePass::ContainsAbortOtherThanUnreachable(Function* func) const { … }
void InlinePass::InitializeInline() { … }
InlinePass::InlinePass() { … }
}
}