mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-26 06:20:09 +01:00
nir: Assert the nir_src union is used safely
It is undefined behaviour in C to read a different member of a union than was written. Nothing in-tree should be using this behaviour with the nir_src union: nir_if should never be read as nir_instr and vice versa. Assert this. Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Reviewed-by: Rhys Perry <pendingchaos02@gmail.com> Acked-by: Faith Ekstrand <faith.ekstrand@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24671>
This commit is contained in:
parent
c39896b17b
commit
316af8c965
1 changed files with 2 additions and 0 deletions
|
|
@ -1018,12 +1018,14 @@ nir_src_is_if(const nir_src *src)
|
|||
static inline nir_instr *
|
||||
nir_src_parent_instr(const nir_src *src)
|
||||
{
|
||||
assert(!nir_src_is_if(src));
|
||||
return src->renamed_parent_instr;
|
||||
}
|
||||
|
||||
static inline struct nir_if *
|
||||
nir_src_parent_if(const nir_src *src)
|
||||
{
|
||||
assert(nir_src_is_if(src));
|
||||
return src->parent_if;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue