Skip to content

Commit 1e2c20f

Browse files
lixing-starSixWeining
authored andcommitted
[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
1 parent 2f1c942 commit 1e2c20f

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_syscall_linux_loongarch64.inc

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,18 @@
1414
// About local register variables:
1515
// https://gcc.gnu.org/onlinedocs/gcc/Local-Register-Variables.html#Local-Register-Variables
1616
//
17-
// Kernel ABI...
18-
// syscall number is passed in a7
19-
// (http://man7.org/linux/man-pages/man2/syscall.2.html) results are return in
20-
// a0 and a1 (http://man7.org/linux/man-pages/man2/syscall.2.html) arguments
21-
// are passed in: a0-a7 (confirmed by inspecting glibc sources).
17+
// Kernel ABI:
18+
// https://lore.kernel.org/loongarch/[email protected]/T/#m1613bc86c2d7bf5f6da92bd62984302bfd699a2f
19+
// syscall number is placed in a7
20+
// parameters, if present, are placed in a0-a6
21+
// upon return:
22+
// the return value is placed in a0
23+
// t0-t8 should be considered clobbered
24+
// all other registers are preserved
2225
#define SYSCALL(name) __NR_##name
2326

24-
#define INTERNAL_SYSCALL_CLOBBERS "memory"
27+
#define INTERNAL_SYSCALL_CLOBBERS \
28+
"memory", "$t0", "$t1", "$t2", "$t3", "$t4", "$t5", "$t6", "$t7", "$t8"
2529

2630
static uptr __internal_syscall(u64 nr) {
2731
register u64 a7 asm("$a7") = nr;

0 commit comments

Comments
 (0)