Mesa (master): nir: Strengthen "no jumps" assertions in instruction insertion API.
Kenneth Graunke
kwg at kemper.freedesktop.org
Thu Aug 27 20:40:52 UTC 2015
Module: Mesa
Branch: master
Commit: c44d50775209266b5c8bad0ab7a7c4ccd7db14a4
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c44d50775209266b5c8bad0ab7a7c4ccd7db14a4
Author: Kenneth Graunke <kenneth at whitecape.org>
Date: Mon Aug 24 17:30:08 2015 -0700
nir: Strengthen "no jumps" assertions in instruction insertion API.
Jumps must be the last instruction in a block, so inserting another
instruction after a jump is illegal.
Previously, we only checked this when the new instruction being inserted
was a jump. This is a red herring - inserting *any* kind of instruction
after a jump is illegal.
Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
Reviewed-by: Jason Ekstrand <jason.ekstrand at intel.com>
Acked-by: Connor Abbott <cwabbott0 at gmail.com>
---
src/glsl/nir/nir.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c
index 77cc4f0..ff758f4 100644
--- a/src/glsl/nir/nir.c
+++ b/src/glsl/nir/nir.c
@@ -675,9 +675,10 @@ nir_instr_insert_before(nir_instr *instr, nir_instr *before)
void
nir_instr_insert_after(nir_instr *instr, nir_instr *after)
{
+ assert(instr->type != nir_instr_type_jump);
+
if (after->type == nir_instr_type_jump) {
assert(instr == nir_block_last_instr(instr->block));
- assert(instr->type != nir_instr_type_jump);
}
after->block = instr->block;
@@ -705,10 +706,9 @@ nir_instr_insert_before_block(nir_block *block, nir_instr *before)
void
nir_instr_insert_after_block(nir_block *block, nir_instr *after)
{
- if (after->type == nir_instr_type_jump) {
- assert(exec_list_is_empty(&block->instr_list) ||
- nir_block_last_instr(block)->type != nir_instr_type_jump);
- }
+ nir_instr *last = nir_block_last_instr(block);
+ assert(last == NULL || last->type != nir_instr_type_jump);
+ (void) last;
after->block = block;
add_defs_uses(after);
More information about the mesa-commit
mailing list