mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2024-10-18 19:20:05 +00:00
Reduce instruction create and deletion during inlining.
When inlining a function call the instructions in the same basic block as the call get cloned. The clone is added to the set of new blocks containing the inlined code, and the original instructions are deleted. This PR will change this so that we simply move the instructions to the new blocks. This saves on the creation and deletion of the instructions. Contributes to #1328.
This commit is contained in:
parent
c1b936637e
commit
51ecc7318f
@ -317,8 +317,10 @@ void InlinePass::GenInlineCode(
|
||||
if (firstBlock) {
|
||||
// Copy contents of original caller block up to call instruction.
|
||||
for (auto cii = call_block_itr->begin(); cii != call_inst_itr;
|
||||
++cii) {
|
||||
std::unique_ptr<ir::Instruction> cp_inst(cii->Clone(context()));
|
||||
cii = call_block_itr->begin()) {
|
||||
ir::Instruction* inst = &*cii;
|
||||
inst->RemoveFromList();
|
||||
std::unique_ptr<ir::Instruction> cp_inst(inst);
|
||||
// Remember same-block ops for possible regeneration.
|
||||
if (IsSameBlockOp(&*cp_inst)) {
|
||||
auto* sb_inst_ptr = cp_inst.get();
|
||||
@ -425,9 +427,10 @@ void InlinePass::GenInlineCode(
|
||||
AddLoad(calleeTypeId, resId, returnVarId, &new_blk_ptr);
|
||||
}
|
||||
// Copy remaining instructions from caller block.
|
||||
auto cii = call_inst_itr;
|
||||
for (++cii; cii != call_block_itr->end(); ++cii) {
|
||||
std::unique_ptr<ir::Instruction> cp_inst(cii->Clone(context()));
|
||||
for (ir::Instruction* inst = call_inst_itr->NextNode(); inst;
|
||||
inst = call_inst_itr->NextNode()) {
|
||||
inst->RemoveFromList();
|
||||
std::unique_ptr<ir::Instruction> cp_inst(inst);
|
||||
// If multiple blocks generated, regenerate any same-block
|
||||
// instruction that has not been seen in this last block.
|
||||
if (multiBlocks) {
|
||||
|
Loading…
Reference in New Issue
Block a user