[libc-commits] [PATCH] D159110: [libc] Fix set_thread_ptr call in rv32 start up code
Mikhail Ramalho via Phabricator via libc-commits
libc-commits at lists.llvm.org
Tue Aug 29 08:25:37 PDT 2023
mikhail.ramalho created this revision.
mikhail.ramalho added reviewers: michaelrj, sivachandra.
Herald added subscribers: libc-commits, asb, luke, sunshaoce, frasercrmck, luismarques, apazos, sameer.abuasal, s.egerton, Jim, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, niosHD, sabuasal, simoncook, johnrusso, rbar.
Herald added projects: libc-project, All.
mikhail.ramalho requested review of this revision.
Herald added a subscriber: wangpc.
This patch changes the instruction in set_thread_ptr from ld (load
doubleword) to lw (load word), as rv32 doesn't have the ld instruction.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D159110
Files:
libc/startup/linux/riscv/start.cpp
Index: libc/startup/linux/riscv/start.cpp
===================================================================
--- libc/startup/linux/riscv/start.cpp
+++ libc/startup/linux/riscv/start.cpp
@@ -80,7 +80,11 @@
}
static void set_thread_ptr(uintptr_t val) {
+#ifdef LIBC_TARGET_ARCH_IS_RISCV32
+ LIBC_INLINE_ASM("lw tp, %0\n\t" : : "m"(val));
+#else // LIBC_TARGET_ARCH_IS_RISCV64
LIBC_INLINE_ASM("ld tp, %0\n\t" : : "m"(val));
+#endif
}
using InitCallback = void(int, char **, char **);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D159110.554362.patch
Type: text/x-patch
Size: 495 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230829/3d64c18c/attachment.bin>
More information about the libc-commits
mailing list