mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-03 05:00:09 +01:00
aco: Skip code paths to emit copies when there are no copies.
Found while running with libstdc++ debug mode. Fixes the following: Error: attempt to advance a dereferenceable (start-of-sequence) iterator -1 steps, which falls outside its valid range. Cc: mesa-stable Signed-off-by: Timur Kristóf <timur.kristof@gmail.com> Reviewed-by: Rhys Perry <pendingchaos02@gmail.com> Reviewed-by: Tony Wasserka <tony.wasserka@gmx.de> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12682>
This commit is contained in:
parent
728ed892df
commit
bb956464cb
1 changed files with 23 additions and 12 deletions
|
|
@ -445,6 +445,9 @@ emit_parallelcopies(cssa_ctx& ctx)
|
|||
continue;
|
||||
|
||||
std::map<uint32_t, ltg_node> ltg;
|
||||
bool has_vgpr_copy = false;
|
||||
bool has_sgpr_copy = false;
|
||||
|
||||
/* first, try to coalesce all parallelcopies */
|
||||
for (const copy& cp : ctx.parallelcopies[i]) {
|
||||
if (try_coalesce_copy(ctx, cp, i)) {
|
||||
|
|
@ -459,6 +462,10 @@ emit_parallelcopies(cssa_ctx& ctx)
|
|||
uint32_t write_idx = ctx.merge_node_table[cp.def.tempId()].index;
|
||||
assert(write_idx != -1u);
|
||||
ltg[write_idx] = {cp, read_idx};
|
||||
|
||||
bool is_vgpr = cp.def.regClass().type() == RegType::vgpr;
|
||||
has_vgpr_copy |= is_vgpr;
|
||||
has_sgpr_copy |= !is_vgpr;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -475,19 +482,23 @@ emit_parallelcopies(cssa_ctx& ctx)
|
|||
Builder bld(ctx.program);
|
||||
Block& block = ctx.program->blocks[i];
|
||||
|
||||
/* emit VGPR copies */
|
||||
auto IsLogicalEnd = [](const aco_ptr<Instruction>& inst) -> bool
|
||||
{ return inst->opcode == aco_opcode::p_logical_end; };
|
||||
auto it = std::find_if(block.instructions.rbegin(), block.instructions.rend(), IsLogicalEnd);
|
||||
bld.reset(&block.instructions, std::prev(it.base()));
|
||||
emit_copies_block(bld, ltg, RegType::vgpr);
|
||||
if (has_vgpr_copy) {
|
||||
/* emit VGPR copies */
|
||||
auto IsLogicalEnd = [](const aco_ptr<Instruction>& inst) -> bool
|
||||
{ return inst->opcode == aco_opcode::p_logical_end; };
|
||||
auto it = std::find_if(block.instructions.rbegin(), block.instructions.rend(), IsLogicalEnd);
|
||||
bld.reset(&block.instructions, std::prev(it.base()));
|
||||
emit_copies_block(bld, ltg, RegType::vgpr);
|
||||
}
|
||||
|
||||
/* emit SGPR copies */
|
||||
aco_ptr<Instruction> branch = std::move(block.instructions.back());
|
||||
block.instructions.pop_back();
|
||||
bld.reset(&block.instructions);
|
||||
emit_copies_block(bld, ltg, RegType::sgpr);
|
||||
bld.insert(std::move(branch));
|
||||
if (has_sgpr_copy) {
|
||||
/* emit SGPR copies */
|
||||
aco_ptr<Instruction> branch = std::move(block.instructions.back());
|
||||
block.instructions.pop_back();
|
||||
bld.reset(&block.instructions);
|
||||
emit_copies_block(bld, ltg, RegType::sgpr);
|
||||
bld.insert(std::move(branch));
|
||||
}
|
||||
}
|
||||
|
||||
/* finally, rename coalesced phi operands */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue