nir: Assert the nir_src union is used safely
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>
Mon, 14 Aug 2023 14:41:23 +0000 (10:41 -0400)
committerAlyssa Rosenzweig <alyssa@rosenzweig.io>
Tue, 10 Oct 2023 08:58:05 +0000 (04:58 -0400)
commit316af8c965142c3879f90ed85b6fd92aefa8b322
tree951e6e67bbacda4d27167ed8a8ba3cf050a6c94d
parentc39896b17b48178fdf89400ce209c22a61f583db
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>
src/compiler/nir/nir.h