[compiler-rt] 1f8ea41 - [sanitizer] Fix the internal_clone implementation on loongarch
Weining Lu via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 9 19:58:50 PST 2022
Author: Youling Tang
Date: 2022-12-10T11:50:39+08:00
New Revision: 1f8ea4149cbe4f841a77d4f9762c47cf600b7cbe
URL: https://github.com/llvm/llvm-project/commit/1f8ea4149cbe4f841a77d4f9762c47cf600b7cbe
DIFF: https://github.com/llvm/llvm-project/commit/1f8ea4149cbe4f841a77d4f9762c47cf600b7cbe.diff
LOG: [sanitizer] Fix the internal_clone implementation on loongarch
Fix syscall clone argument passing order, also `call fn(arg)` should
return, change `jr $a5`(jirl $zero, $a5, 0) to `jirl $ra, $a5, 0`.
Reviewed By: SixWeining
Differential Revision: https://reviews.llvm.org/D139619
Added:
Modified:
compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
index 2c9f19a02a31c..24c6acaa9e5a4 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
@@ -1514,8 +1514,8 @@ uptr internal_clone(int (*fn)(void *), void *child_stack, int flags, void *arg,
register int __flags __asm__("$a0") = flags;
register void *__stack __asm__("$a1") = child_stack;
register int *__ptid __asm__("$a2") = parent_tidptr;
- register void *__tls __asm__("$a3") = newtls;
- register int *__ctid __asm__("$a4") = child_tidptr;
+ register int *__ctid __asm__("$a3") = child_tidptr;
+ register void *__tls __asm__("$a4") = newtls;
register int (*__fn)(void *) __asm__("$a5") = fn;
register void *__arg __asm__("$a6") = arg;
register int nr_clone __asm__("$a7") = __NR_clone;
@@ -1529,15 +1529,16 @@ uptr internal_clone(int (*fn)(void *), void *child_stack, int flags, void *arg,
// In the child, now. Call "fn(arg)".
"move $a0, $a6\n"
- "jr $a5\n"
+ "jirl $ra, $a5, 0\n"
// Call _exit($a0).
"addi.d $a7, $zero, %9\n"
"syscall 0\n"
+
"1:\n"
: "=r"(res)
- : "0"(__flags), "r"(__stack), "r"(__ptid), "r"(__tls), "r"(__ctid),
+ : "0"(__flags), "r"(__stack), "r"(__ptid), "r"(__ctid), "r"(__tls),
"r"(__fn), "r"(__arg), "r"(nr_clone), "i"(__NR_exit)
: "memory", "$t0", "$t1", "$t2", "$t3", "$t4", "$t5", "$t6", "$t7", "$t8");
return res;
More information about the llvm-commits
mailing list