From: Eric Anholt Date: Thu, 25 Jul 2019 20:37:28 +0000 (-0700) Subject: nir: Fix helgrind complaints about data race in trivial_swizzle init. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3c46778b75b6d40a1384691333d70480c96938f4;p=mesa.git nir: Fix helgrind complaints about data race in trivial_swizzle init. Even if the data race wasn't real (I'm not great at reasoning about this), helgrind is a nice enough tool that keeping noise out of it is probably worthwhile. Besides, typing out the numbers keeps the data in the read-only data section instead of emitting code to initialize it every time. Reviewed-by: Iago Toral Quiroga --- diff --git a/src/compiler/nir/nir_builder.h b/src/compiler/nir/nir_builder.h index 35e4a285714..2fed76106eb 100644 --- a/src/compiler/nir/nir_builder.h +++ b/src/compiler/nir/nir_builder.h @@ -807,9 +807,9 @@ nir_ssa_for_src(nir_builder *build, nir_src src, int num_components) static inline nir_ssa_def * nir_ssa_for_alu_src(nir_builder *build, nir_alu_instr *instr, unsigned srcn) { - static uint8_t trivial_swizzle[NIR_MAX_VEC_COMPONENTS]; - for (int i = 0; i < NIR_MAX_VEC_COMPONENTS; ++i) - trivial_swizzle[i] = i; + static uint8_t trivial_swizzle[] = { 0, 1, 2, 3 }; + STATIC_ASSERT(ARRAY_SIZE(trivial_swizzle) == NIR_MAX_VEC_COMPONENTS); + nir_alu_src *src = &instr->src[srcn]; unsigned num_components = nir_ssa_alu_instr_src_components(instr, srcn);