aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJessica Clarke <jrtc27@jrtc27.com>2023-07-22 23:01:21 +0100
committerJessica Clarke <jrtc27@jrtc27.com>2023-07-22 23:01:21 +0100
commit2b0f5df7b4e01d5b9b380fd72a19df021b9a3b98 (patch)
treed42f9f3cf57dbcaf157d916726e8ce483c026593
parentb396817c61cd07cfa31b5f74998b8448bfdeb07f (diff)
downloadllvm-2b0f5df7b4e01d5b9b380fd72a19df021b9a3b98.zip
llvm-2b0f5df7b4e01d5b9b380fd72a19df021b9a3b98.tar.gz
llvm-2b0f5df7b4e01d5b9b380fd72a19df021b9a3b98.tar.bz2
[builtins][Mips] Un-break FreeBSD build of __clear_cache
Commit 674a17e9bbe8 ("MIPS/compiler_rt: use synci to flush icache on r6") completely removed the OS-specific guards under the guise of "For pre-r6, we can use cacheflush libc function, which is same on Linux and FreeBSD." However, the code in question had guards for Linux and OpenBSD, not Linux and FreeBSD, and FreeBSD does not have a cacheflush libc function as claimed, so this was neither the statement they intended to make nor was it sufficient justification for making the code completely unconditional. Whilst the upcoming FreeBSD 14 release has dropped support for MIPS, FreeBSD 13 has support for it. Fix this by only calling cacheflush on the OSes where it was previously called, and not on other OSes where it either definitely isn't available (FreeBSD) or is unknown (any other OS than the three mentioned in this commit).
-rw-r--r--compiler-rt/lib/builtins/clear_cache.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler-rt/lib/builtins/clear_cache.c b/compiler-rt/lib/builtins/clear_cache.c
index 8993761..54cbda0 100644
--- a/compiler-rt/lib/builtins/clear_cache.c
+++ b/compiler-rt/lib/builtins/clear_cache.c
@@ -110,10 +110,14 @@ void __clear_cache(void *start, void *end) {
"jr.hb $at\n"
"move $at, $0\n"
".set at");
-#else
+#elif defined(__linux__) || defined(__OpenBSD__)
// Pre-R6 may not be globalized. And some implementations may give strange
// synci_step. So, let's use libc call for it.
cacheflush(start, end_int - start_int, BCACHE);
+#else
+ (void)start_int;
+ (void)end_int;
+ compilerrt_abort();
#endif
}
#elif defined(__aarch64__) && !defined(__APPLE__)