[libc-commits] [libc] b0272d8 - [libc] Fix set_thread_ptr call in rv32 start up code

Mikhail R. Gadelha via libc-commits libc-commits at lists.llvm.org
Wed Aug 30 07:31:15 PDT 2023


Author: Mikhail R. Gadelha
Date: 2023-08-30T11:30:56-03:00
New Revision: b0272d8ec34992b8a47683a2cff7387919343e21

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

LOG: [libc] Fix set_thread_ptr call in rv32 start up code

This patch changes the instruction in set_thread_ptr from ld to mv,
as rv32 doesn't have the ld instruction, and mv is supported by both
rv32 and rv64.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D159110

Added: 
    

Modified: 
    libc/startup/linux/riscv64/start.cpp

Removed: 
    


################################################################################
diff  --git a/libc/startup/linux/riscv64/start.cpp b/libc/startup/linux/riscv64/start.cpp
index 9835bc4e03e8b0..d68cc9219ecce7 100644
--- a/libc/startup/linux/riscv64/start.cpp
+++ b/libc/startup/linux/riscv64/start.cpp
@@ -80,7 +80,7 @@ void cleanup_tls(uintptr_t addr, uintptr_t size) {
 }
 
 static void set_thread_ptr(uintptr_t val) {
-  LIBC_INLINE_ASM("ld tp, %0\n\t" : : "m"(val));
+  LIBC_INLINE_ASM("mv tp, %0\n\t" : : "r"(val));
 }
 
 using InitCallback = void(int, char **, char **);


        


More information about the libc-commits mailing list