Meta: Globally disable -Wpsabi

This warning is triggered when one accepts or returns vectors from a
function (that is not marked with [[gnu::target(...)]]) which would have
been otherwise passed in register if the current translation unit had
been compiled with more permissive flags wrt instruction selection (i.
e. if one adds -mavx2 to cmdline). This will never be a problem for us
since we (a) never use different instruction selection options across
ABI boundaries; (b) most of the affected functions are actually
TU-local.

Moreover, even if we somehow properly annotated all of the SIMD helpers,
calling them across ABI (or target) boundaries would still be very
dangerous because of inconsistent and bogus handling of
[[gnu::target(...)]] across compilers. See
https://github.com/llvm/llvm-project/issues/64706 and
https://www.reddit.com/r/cpp/comments/17qowl2/comment/k8j2odi .
This commit is contained in:
Dan Klishch 2024-07-04 23:50:08 -04:00 committed by Nico Weber
parent 84d66ac538
commit 56b7f9e404
6 changed files with 13 additions and 22 deletions

View file

@ -10,13 +10,6 @@
#include <AK/Concepts.h>
#include <AK/SIMD.h>
// Functions returning vectors or accepting vector arguments have different calling conventions
// depending on whether the target architecture supports SSE or not. GCC generates warning "psabi"
// when compiling for non-SSE architectures. We disable this warning because these functions
// are static and should never be visible from outside the translation unit that includes this header.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpsabi"
namespace AK::SIMD {
// SIMD Vector Expansion
@ -327,5 +320,3 @@ ALWAYS_INLINE static T elementwise_byte_reverse(T a)
}
}
#pragma GCC diagnostic pop

View file

@ -11,13 +11,6 @@
#include <AK/SIMDExtras.h>
#include <math.h>
// Functions returning vectors or accepting vector arguments have different calling conventions
// depending on whether the target architecture supports SSE or not. GCC generates warning "psabi"
// when compiling for non-SSE architectures. We disable this warning because these functions
// are static and should never be visible from outside the translation unit that includes this header.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpsabi"
namespace AK::SIMD {
// Functions ending in "_int_range" only accept arguments within range [INT_MIN, INT_MAX].
@ -90,5 +83,3 @@ ALWAYS_INLINE static f32x4 sqrt(f32x4 v)
}
}
#pragma GCC diagnostic pop

View file

@ -13,6 +13,19 @@ add_compile_options(-Wno-invalid-offsetof)
add_compile_options(-Wno-unknown-warning-option)
add_compile_options(-Wno-unused-command-line-argument)
# This warning is triggered when one accepts or returns vectors from a function (that is not marked
# with [[gnu::target(...)]]) which would have been otherwise passed in register if the current
# translation unit had been compiled with more permissive flags wrt instruction selection (i. e. if
# one adds -mavx2 to cmdline). This will never be a problem for us since we (a) never use
# different instruction selection options across ABI boundaries; (b) most of the affected functions
# are actually TU-local.
#
# Moreover, even if we somehow properly annotated all of the SIMD helpers, calling them across ABI
# (or target) boundaries would still be very dangerous because of inconsistent and bogus handling of
# [[gnu::target(...)]] across compilers. See https://github.com/llvm/llvm-project/issues/64706 and
# https://www.reddit.com/r/cpp/comments/17qowl2/comment/k8j2odi .
add_compile_options(-Wno-psabi)
add_compile_options(-fno-exceptions)
add_compile_options(-ffp-contract=off)

View file

@ -15,7 +15,6 @@
# include <AK/SIMD.h>
# include <AK/SIMDExtras.h>
# include <cpuid.h>
# pragma GCC diagnostic ignored "-Wpsabi"
#endif
namespace Crypto::Hash {

View file

@ -13,7 +13,6 @@
# include <AK/SIMD.h>
# include <AK/SIMDExtras.h>
# include <cpuid.h>
# pragma GCC diagnostic ignored "-Wpsabi"
#endif
namespace Crypto::Hash {

View file

@ -15,8 +15,6 @@
#include <LibGfx/Bitmap.h>
#include <LibGfx/ImageFormats/PNGWriter.h>
#pragma GCC diagnostic ignored "-Wpsabi"
namespace Gfx {
class PNGChunk {