[compiler-rt] 303e8cd - [NFC][RISCV][builtins] Remove some hard-coded values from i-cache clear routine
Luís Marques via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 24 06:32:41 PDT 2020
Author: Alexey Baturo
Date: 2020-09-24T14:32:16+01:00
New Revision: 303e8cdacb106c4e1ba07d47ab60d71c03a2552c
URL: https://github.com/llvm/llvm-project/commit/303e8cdacb106c4e1ba07d47ab60d71c03a2552c
DIFF: https://github.com/llvm/llvm-project/commit/303e8cdacb106c4e1ba07d47ab60d71c03a2552c.diff
LOG: [NFC][RISCV][builtins] Remove some hard-coded values from i-cache clear routine
Remove some hard-coded values from i-cache clear routine
Differential Revision: https://reviews.llvm.org/D87578
Added:
Modified:
compiler-rt/lib/builtins/clear_cache.c
Removed:
################################################################################
diff --git a/compiler-rt/lib/builtins/clear_cache.c b/compiler-rt/lib/builtins/clear_cache.c
index 29e31f55d499..e9e291467bd9 100644
--- a/compiler-rt/lib/builtins/clear_cache.c
+++ b/compiler-rt/lib/builtins/clear_cache.c
@@ -46,6 +46,11 @@ uintptr_t GetCurrentProcess(void);
#include <unistd.h>
#endif
+#if defined(__linux__) && defined(__riscv)
+// to get platform-specific syscall definitions
+#include <linux/unistd.h>
+#endif
+
// The compiler generates calls to __clear_cache() when creating
// trampoline functions on the stack for use with nested functions.
// It is expected to invalidate the instruction cache for the
@@ -148,9 +153,10 @@ void __clear_cache(void *start, void *end) {
for (uintptr_t dword = start_dword; dword < end_dword; dword += dword_size)
__asm__ volatile("flush %0" : : "r"(dword));
#elif defined(__riscv) && defined(__linux__)
-#define __NR_riscv_flush_icache (244 + 15)
+ // See: arch/riscv/include/asm/cacheflush.h, arch/riscv/kernel/sys_riscv.c
register void *start_reg __asm("a0") = start;
const register void *end_reg __asm("a1") = end;
+ // "0" means that we clear cache for all threads (SYS_RISCV_FLUSH_ICACHE_ALL)
const register long flags __asm("a2") = 0;
const register long syscall_nr __asm("a7") = __NR_riscv_flush_icache;
__asm __volatile("ecall"
More information about the llvm-commits
mailing list