From bced5fac183b953d9ddd2f488c7ac3917eabee1a Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 12 Dec 2023 19:21:33 -0500 Subject: [PATCH 1/2] Common/Crypto/AES: Resolve -Wignored-attributes warnings The alias for __m128i is typically something like: typedef long long __m128i __attribute__((__vector_size__(16), __may_alias__)); and the part that ends up not getting preserved is the __may_alias__ attribute specifier. So, in order to preserve that, we can just use a wrapper struct, so the data type itself isn't being passed through the template. --- Source/Core/Common/Crypto/AES.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Source/Core/Common/Crypto/AES.cpp b/Source/Core/Common/Crypto/AES.cpp index 3fc9a80a56..272341ecca 100644 --- a/Source/Core/Common/Crypto/AES.cpp +++ b/Source/Core/Common/Crypto/AES.cpp @@ -250,7 +250,19 @@ public: } private: - std::array<__m128i, NUM_ROUND_KEYS> round_keys; + // Ensures alignment specifiers are respected. + struct XmmReg + { + __m128i data; + + XmmReg& operator=(const __m128i& m) + { + data = m; + return *this; + } + operator __m128i() const { return data; } + }; + std::array round_keys; }; #endif From dbc792a3ec9bccdb21765dd052ce92c61bdeb6d2 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 12 Dec 2023 19:42:14 -0500 Subject: [PATCH 2/2] Common/Crypto/SHA1: Resolve -Wignored-attributes warnings See commit 417d1310d22b11d5d724625721b5fec09eda099a for an explanation on why we do this. --- Source/Core/Common/Crypto/SHA1.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/Source/Core/Common/Crypto/SHA1.cpp b/Source/Core/Common/Crypto/SHA1.cpp index 57c45b09f3..f87bbd2c6d 100644 --- a/Source/Core/Common/Crypto/SHA1.cpp +++ b/Source/Core/Common/Crypto/SHA1.cpp @@ -166,7 +166,20 @@ public: } private: - using WorkBlock = CyclicArray<__m128i, 4>; + struct XmmReg + { + // Allows aliasing attributes to be respected in the + // face of templates. + __m128i data; + + XmmReg& operator=(const __m128i& d) + { + data = d; + return *this; + } + operator __m128i() const { return data; } + }; + using WorkBlock = CyclicArray; ATTRIBUTE_TARGET("ssse3") static inline __m128i byterev_16B(__m128i x) @@ -244,7 +257,7 @@ private: virtual bool HwAccelerated() const override { return true; } - std::array<__m128i, 2> state{}; + std::array state{}; }; #endif