summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornormalcoder <normalcoder@gmail.com>2021-12-19 00:12:08 +0300
committerBen Gamari <ben@smart-cactus.org>2022-08-15 17:11:26 -0400
commitc2043b0a2132d1f8b6a22f3daacaaf6fb194db17 (patch)
treed43b4386a02ddf5410e195bfe5a3168cbea8d793
parent05eef6e223d3a1ee9d6216ef9e536e70d29c75ae (diff)
downloadhaskell-c2043b0a2132d1f8b6a22f3daacaaf6fb194db17.tar.gz
ncg/aarch64: Don't use x18 register on AArch64/Darwin
Apple's ABI documentation [1] says: "The platforms reserve register x18. Don’t use this register." While this wasn't problematic in previous Darwin releases, macOS 13 appears to start zeroing this register periodically. See #21964. [1] https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms (cherry picked from commit 67575f2004340564d6e52af055ed6fb43d3f9711)
-rw-r--r--compiler/CodeGen.Platform.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/compiler/CodeGen.Platform.h b/compiler/CodeGen.Platform.h
index 346dd0af03..a216d266dd 100644
--- a/compiler/CodeGen.Platform.h
+++ b/compiler/CodeGen.Platform.h
@@ -926,6 +926,14 @@ freeReg 29 = False
-- ip0 -- used for spill offset computations
freeReg 16 = False
+#if defined(darwin_HOST_OS) || defined(ios_HOST_OS)
+-- x18 is reserved by the platform on Darwin/iOS, and can not be used
+-- More about ARM64 ABI that Apple platforms support:
+-- https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms
+-- https://github.com/Siguza/ios-resources/blob/master/bits/arm64.md
+freeReg 18 = False
+#endif
+
# if defined(REG_Base)
freeReg REG_Base = False
# endif