Skip to content

Commit

Permalink
Meta: Globally disable -Wpsabi
Browse files Browse the repository at this point in the history
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
llvm/llvm-project#64706 and
https://www.reddit.com/r/cpp/comments/17qowl2/comment/k8j2odi .
  • Loading branch information
DanShaders authored and nico committed Jul 12, 2024
1 parent 84d66ac commit 56b7f9e
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 22 deletions.
9 changes: 0 additions & 9 deletions AK/SIMDExtras.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -327,5 +320,3 @@ ALWAYS_INLINE static T elementwise_byte_reverse(T a)
}

}

#pragma GCC diagnostic pop
9 changes: 0 additions & 9 deletions AK/SIMDMath.h
Original file line number Diff line number Diff line change
Expand Up @@ -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].
Expand Down Expand Up @@ -90,5 +83,3 @@ ALWAYS_INLINE static f32x4 sqrt(f32x4 v)
}

}

#pragma GCC diagnostic pop
13 changes: 13 additions & 0 deletions Meta/CMake/common_compile_options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion Userland/Libraries/LibCrypto/Hash/SHA1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
# include <AK/SIMD.h>
# include <AK/SIMDExtras.h>
# include <cpuid.h>
# pragma GCC diagnostic ignored "-Wpsabi"
#endif

namespace Crypto::Hash {
Expand Down
1 change: 0 additions & 1 deletion Userland/Libraries/LibCrypto/Hash/SHA2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# include <AK/SIMD.h>
# include <AK/SIMDExtras.h>
# include <cpuid.h>
# pragma GCC diagnostic ignored "-Wpsabi"
#endif

namespace Crypto::Hash {
Expand Down
2 changes: 0 additions & 2 deletions Userland/Libraries/LibGfx/ImageFormats/PNGWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
#include <LibGfx/Bitmap.h>
#include <LibGfx/ImageFormats/PNGWriter.h>

#pragma GCC diagnostic ignored "-Wpsabi"

namespace Gfx {

class PNGChunk {
Expand Down

0 comments on commit 56b7f9e

Please sign in to comment.