[llvm-branch-commits] [compiler-rt] 6a5ccb2 - [compiler-rt] Implement __clear_cache() on OpenBSD/riscv64

Tom Stellard via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Sep 17 20:54:49 PDT 2021


Author: Jeremie Courreges-Anglas
Date: 2021-09-17T20:54:32-07:00
New Revision: 6a5ccb2ec43887dba71b5ba6a9a035b18e619ad6

URL: https://github.com/llvm/llvm-project/commit/6a5ccb2ec43887dba71b5ba6a9a035b18e619ad6
DIFF: https://github.com/llvm/llvm-project/commit/6a5ccb2ec43887dba71b5ba6a9a035b18e619ad6.diff

LOG: [compiler-rt] Implement __clear_cache() on OpenBSD/riscv64

(cherry picked from commit 3db959060546eef76b90733ccde80c75576a97ad)

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 3c12b74e8fa62..da0715914b416 100644
--- a/compiler-rt/lib/builtins/clear_cache.c
+++ b/compiler-rt/lib/builtins/clear_cache.c
@@ -35,7 +35,7 @@ uintptr_t GetCurrentProcess(void);
 #include <machine/sysarch.h>
 #endif
 
-#if defined(__OpenBSD__) && (defined(__arm__) || defined(__mips__))
+#if defined(__OpenBSD__) && (defined(__arm__) || defined(__mips__) || defined(__riscv))
 // clang-format off
 #include <sys/types.h>
 #include <machine/sysarch.h>
@@ -166,6 +166,13 @@ void __clear_cache(void *start, void *end) {
                    : "=r"(start_reg)
                    : "r"(start_reg), "r"(end_reg), "r"(flags), "r"(syscall_nr));
   assert(start_reg == 0 && "Cache flush syscall failed.");
+#elif defined(__riscv) && defined(__OpenBSD__)
+  struct riscv_sync_icache_args arg;
+
+  arg.addr = (uintptr_t)start;
+  arg.len = (uintptr_t)end - (uintptr_t)start;
+
+  sysarch(RISCV_SYNC_ICACHE, &arg);
 #else
 #if __APPLE__
   // On Darwin, sys_icache_invalidate() provides this functionality


        


More information about the llvm-branch-commits mailing list