1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 18:37:34 +00:00

AK: Work around Apple Clang __builtin_subc codegen issue

Apple Clang 14.0.3 (Xcode 14.3) miscompiles this builtin on AArch64,
causing the borrow flag to be set incorrectly. I have added a detailed
writeup on Qemu's issue tracker, where the same issue led to a hang when
emulating x86:

https://gitlab.com/qemu-project/qemu/-/issues/1659#note_1408275831

I don't know of any specific issue caused by this on Lagom, but better
safe than sorry.
This commit is contained in:
Daniel Bertalan 2023-06-23 09:18:29 +00:00 committed by Andreas Kling
parent 7dadc9ff33
commit 9d4dfc1061
2 changed files with 8 additions and 1 deletions

View file

@ -117,6 +117,13 @@
# define AK_HAS_CONDITIONALLY_TRIVIAL
#endif
// Apple Clang 14.0.3 (shipped in Xcode 14.3) has a bug that causes __builtin_subc{,l,ll}
// to incorrectly return whether a borrow occurred on AArch64. See our writeup for the Qemu
// issue also caused by it: https://gitlab.com/qemu-project/qemu/-/issues/1659#note_1408275831
#if ARCH(AARCH64) && defined(__apple_build_version__) && __clang_major__ == 14
# define AK_BUILTIN_SUBC_BROKEN
#endif
#ifdef ALWAYS_INLINE
# undef ALWAYS_INLINE
#endif