pan/cs: only flush block instrs if there is a pending if block

It is only needed for pending `if` block as it's the only block
we don't end normally and where instructions are only flushed when
we are certain that no `else` branch is gonna be added.

It also collide with scenarios where we want to add a preamble
before inserting a block.

Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Lars-Ivar Hesselberg Simonsen <lars-ivar.simonsen@arm.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31174>
This commit is contained in:
Louis-Francis Ratté-Boulianne 2024-10-08 02:56:11 -04:00 committed by Marge Bot
parent f98e01f0d2
commit e9e0153248

View file

@ -576,6 +576,7 @@ cs_flush_pending_if(struct cs_builder *b)
cs_set_label(b, &b->blocks.pending_if.end_label);
b->blocks.stack = b->blocks.pending_if.block.next;
cs_flush_block_instrs(b);
}
static inline void *
@ -584,7 +585,6 @@ cs_alloc_ins(struct cs_builder *b)
/* If an instruction is emitted after an if_end(), it flushes the pending if,
* causing further cs_else_start() instructions to be invalid. */
cs_flush_pending_if(b);
cs_flush_block_instrs(b);
return cs_alloc_ins_block(b, 1);
}
@ -599,7 +599,6 @@ cs_finish(struct cs_builder *b)
return;
cs_flush_pending_if(b);
cs_flush_block_instrs(b);
cs_wrap_chunk(b);
/* This prevents adding instructions after that point. */