lp_test_arit regression with clang
$ builddir/src/gallium/drivers/llvmpipe/lp_test_arit
round.v1(-0.5): ref = -0, out = -1, precision = -inf bits, FAIL
round.v1(0.5): ref = 0, out = 1, precision = -inf bits, FAIL
round.v4(-0.5): ref = -0, out = -1, precision = -inf bits, FAIL
round.v4(0.5): ref = 0, out = 1, precision = -inf bits, FAIL
1b8a43a0bafd8c1d50b6fc840fadce8dfd7250de is the first bad commit
commit 1b8a43a0bafd8c1d50b6fc840fadce8dfd7250de
Author: Jason Ekstrand <jason.ekstrand@collabora.com>
Date: Mon Mar 28 18:29:44 2022 -0500
util: Remove util_cpu_detect
util_cpu_detect is an anti-pattern: it relies on callers high up in the call
chain initializing a local implementation detail. As a real example, I added:
...a Mali compiler unit test
...that called bi_imm_f16() to construct an FP16 immediate
...that calls _mesa_float_to_half internally
...that calls util_get_cpu_caps internally, but only on x86_64!
...that relies on util_cpu_detect having been called before.
As a consequence, this unit test:
...crashes on x86_64 with USE_X86_64_ASM set
...passes on every other architecture
...works on my local arm64 workstation and on my test board
...failed CI which runs on x86_64
...needed to have a random util_cpu_detect() call sprinkled in.
This is a bad design decision. It pollutes the tree with magic, it causes
mysterious CI failures especially for non-x86_64 developers, and it is not
justified by a micro-optimization.
Instead, let's call util_cpu_detect directly from util_get_cpu_caps, avoiding
the footgun where it fails to be called. This cleans up Mesa's design,
simplifies the tree, and avoids a class of a (possibly platform-specific)
failures. To mitigate the added overhead, wrap it all in a (fast) atomic
load check and declare the whole thing as ATTRIBUTE_CONST so the
compiler will CSE calls to util_cpu_detect.
Co-authored-by: Alyssa Rosenzweig <alyssa@collabora.com>
Reviewed-by: Marek Olšák <maraeo@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15580>
src/amd/common/ac_gpu_info.c | 2 -
src/amd/compiler/tests/main.cpp | 4 --
src/broadcom/vulkan/v3dv_device.c | 3 --
src/compiler/glsl_types.cpp | 6 ---
src/compiler/isaspec/decode.c | 2 -
src/gallium/auxiliary/draw/draw_context.c | 4 --
src/gallium/auxiliary/gallivm/lp_bld_init.c | 2 -
src/gallium/auxiliary/pipe-loader/pipe_loader.c | 2 -
src/gallium/auxiliary/rtasm/rtasm_cpu.c | 1 -
src/gallium/auxiliary/rtasm/rtasm_x86sse.c | 1 -
src/gallium/auxiliary/util/u_threaded_context.c | 2 -
src/gallium/drivers/lima/standalone/lima_disasm.c | 4 --
src/gallium/drivers/llvmpipe/lp_screen.c | 6 +--
src/gallium/drivers/llvmpipe/lp_test_main.c | 2 -
src/gallium/drivers/radeonsi/si_get.c | 2 -
src/gallium/drivers/vc4/vc4_screen.c | 3 --
src/gallium/drivers/zink/zink_screen.c | 1 -
src/gallium/tests/unit/translate_test.c | 2 -
src/gallium/tests/unit/u_half_test.c | 1 -
src/mesa/main/tests/mesa_formats.cpp | 6 ---
src/mesa/state_tracker/st_context.c | 4 --
src/util/tests/format/u_format_test.c | 2 -
src/util/u_cpu_detect.c | 3 ++
src/util/u_cpu_detect.h | 47 ++++++++++++++++++-----
src/util/u_queue.c | 3 --
25 files changed, 42 insertions(+), 73 deletions(-)
bisect found first bad commit
Edited by Vinson Lee