[compiler-rt] 1e2c20f - [compiler-rt] Mark $t* as clobbered for Linux/LoongArch syscalls
Weining Lu via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 11 05:24:43 PST 2022
Author: XingLi
Date: 2022-11-11T21:24:07+08:00
New Revision: 1e2c20fc1381f88c9a697d5c25ff4393c31b69a3
URL: https://github.com/llvm/llvm-project/commit/1e2c20fc1381f88c9a697d5c25ff4393c31b69a3
DIFF: https://github.com/llvm/llvm-project/commit/1e2c20fc1381f88c9a697d5c25ff4393c31b69a3.diff
LOG: [compiler-rt] Mark $t* as clobbered for Linux/LoongArch syscalls
Linux/LoongArch doesn't preserve temporary registers across syscalls,
so we have to explicitly mark them as clobbered to avoid trashing local variables.
Reviewed By: xry111, xen0n, tangyouling, SixWeining
Differential Revision: https://reviews.llvm.org/D137396
Added:
Modified:
compiler-rt/lib/sanitizer_common/sanitizer_syscall_linux_loongarch64.inc
Removed:
################################################################################
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_syscall_linux_loongarch64.inc b/compiler-rt/lib/sanitizer_common/sanitizer_syscall_linux_loongarch64.inc
index a0f847f75bec4..80f5e6be8ad14 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_syscall_linux_loongarch64.inc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_syscall_linux_loongarch64.inc
@@ -14,14 +14,18 @@
// About local register variables:
// https://gcc.gnu.org/onlinedocs/gcc/Local-Register-Variables.html#Local-Register-Variables
//
-// Kernel ABI...
-// syscall number is passed in a7
-// (http://man7.org/linux/man-pages/man2/syscall.2.html) results are return in
-// a0 and a1 (http://man7.org/linux/man-pages/man2/syscall.2.html) arguments
-// are passed in: a0-a7 (confirmed by inspecting glibc sources).
+// Kernel ABI:
+// https://lore.kernel.org/loongarch/1f353678-3398-e30b-1c87-6edb278f74db@xen0n.name/T/#m1613bc86c2d7bf5f6da92bd62984302bfd699a2f
+// syscall number is placed in a7
+// parameters, if present, are placed in a0-a6
+// upon return:
+// the return value is placed in a0
+// t0-t8 should be considered clobbered
+// all other registers are preserved
#define SYSCALL(name) __NR_##name
-#define INTERNAL_SYSCALL_CLOBBERS "memory"
+#define INTERNAL_SYSCALL_CLOBBERS \
+ "memory", "$t0", "$t1", "$t2", "$t3", "$t4", "$t5", "$t6", "$t7", "$t8"
static uptr __internal_syscall(u64 nr) {
register u64 a7 asm("$a7") = nr;
More information about the llvm-commits
mailing list