-
Notifications
You must be signed in to change notification settings - Fork 1.3k
platform: fix unaligned 64-bit accesses on AArch32 #699
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Hello. Thank you for the patch. We try to keep different concepts separate, so it would be better to split |
34d3d27 to
3009e0a
Compare
|
Thanks for the feedback, here's an updated version. I figured it would be best to avoid people mistakenly choosing the wrong guard for ARMV8* defines in the future by forcing them to choose _32, _64, or _ANY. Let me know what you think? |
02c8def to
c8b6083
Compare
|
Sorry for the late response. |
Ensures that Aarch32 Arm builds with an Armv8 compiler do not set BROTLI_64_BITS. This scenario is possible with ChromeOS builds, as they may use a toolchain with the target armv7-cros-gnueabi, but with -march=armv8. This will set __ARM_ARCH to 8 (defining BROTLI_TARGET_ARMV8), but will also set __ARM_32BIT_STATE and not __ARM_64BIT_STATE. Without this, illegal 64-bit non-word-aligned reads (LDRD) may be emitted. Also fix unaligned 64-bit reads on AArch32 - STRD was still possible to emit.
c8b6083 to
fe4316c
Compare
|
Added the guard, and an alternative solution if that guard fails. |
|
LGTM. |
|
How's code generation for |
|
Okay, here's a comparison of the code generation that I'm seeing with the versions of gcc/clang available in ChromeOS. This is using the gcc compiler: and the clang compiler: This produces the following assembly: You can play around with the code I was using at https://godbolt.org/g/pE7Q9V So I suggest we go with attribute(aligned) when available, and then memcpy in the rare case it's not? Let me know if you agree, and then I'll push a new version. Thanks! |
|
Thanks for checking the output! Looks like -march=armv8-a is necessary to elide the memcpy call. Your suggestion of attr+memcpy fallback sounds good to me. |
|
Thanks again! |
|
Sorry, landed too soon. Yes, lets proceed with attribute(aligned) + memcpy fallback. |
Ensures that Aarch32 Arm builds with an Armv8 compiler do not set BROTLI_64_BITS. This scenario is possible with ChromeOS builds, as they may use a toolchain with the target armv7-cros-gnueabi, but with -march=armv8. This will set __ARM_ARCH to 8 (defining BROTLI_TARGET_ARMV8), but will also set __ARM_32BIT_STATE and not __ARM_64BIT_STATE. Without this, illegal 64-bit non-word-aligned reads (LDRD) may be emitted. Also fix unaligned 64-bit reads on AArch32 - STRD was still possible to emit.
…" (google#701) This reverts commit 6d027d1.
Ensures that Aarch32 Arm builds with an Armv8 compiler do not set
BROTLI_64_BITS.
This scenario is possible with ChromeOS builds, as they may use a
toolchain with the target armv7-cros-gnueabi, but with -march=armv8.
This will set __ARM_ARCH to 8 (defining BROTLI_TARGET_ARMV8), but will
also set __ARM_32BIT_STATE and not __ARM_64BIT_STATE. Without this,
illegal 64-bit non-word-aligned reads (LDRD) may be emitted.
Also fix unaligned 64-bit reads on AArch32 - STRD was still possible to
emit.