agx: fix UB in cursor comparison

padding here is implementation-defined, do the cleaner thing. fixes invalid IR
generated with gcc but not clang.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reported-by: Janne Grunau <janne-fdr@jannau.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29179>
This commit is contained in:
Alyssa Rosenzweig
2024-05-07 16:58:04 -04:00
committed by Marge Bot
parent bcffc84306
commit efa9f242a8
2 changed files with 13 additions and 1 deletions
+1 -1
View File
@@ -1082,7 +1082,7 @@ agx_emit_export(agx_builder *b, unsigned base, nir_src src)
agx_export(&b_, chan, base + (c * stride));
}
if (memcmp(&b->cursor, &after_cursor, sizeof(agx_cursor)) == 0) {
if (agx_cursors_equal(b->cursor, after_cursor)) {
b->cursor = agx_after_block_logical(b->cursor.block);
}
+12
View File
@@ -801,6 +801,18 @@ typedef struct {
};
} agx_cursor;
static inline bool
agx_cursors_equal(agx_cursor a, agx_cursor b)
{
if (a.option != b.option)
return false;
if (a.option == agx_cursor_after_block)
return a.block == b.block;
else
return a.instr == b.instr;
}
static inline agx_cursor
agx_after_block(agx_block *block)
{