[libc-commits] [libc] [libc] inline thread self (PR #101739)
via libc-commits
libc-commits at lists.llvm.org
Fri Aug 2 12:17:10 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: Schrodinger ZHU Yifan (SchrodingerZhu)
<details>
<summary>Changes</summary>
The codegen for non-inlined version is quite ugly. See https://godbolt.org/z/rb5qYj3vY
---
Full diff: https://github.com/llvm/llvm-project/pull/101739.diff
2 Files Affected:
- (modified) libc/src/__support/threads/thread.cpp (-3)
- (modified) libc/src/__support/threads/thread.h (+1-1)
``````````diff
diff --git a/libc/src/__support/threads/thread.cpp b/libc/src/__support/threads/thread.cpp
index 886281e0d50f7..dad4f75f092ed 100644
--- a/libc/src/__support/threads/thread.cpp
+++ b/libc/src/__support/threads/thread.cpp
@@ -17,9 +17,6 @@
#include "src/__support/macros/attributes.h"
namespace LIBC_NAMESPACE_DECL {
-
-LIBC_THREAD_LOCAL Thread self;
-
namespace {
using AtExitCallback = void(void *);
diff --git a/libc/src/__support/threads/thread.h b/libc/src/__support/threads/thread.h
index 68640cef32964..f2b1f6bbb253d 100644
--- a/libc/src/__support/threads/thread.h
+++ b/libc/src/__support/threads/thread.h
@@ -231,7 +231,7 @@ struct Thread {
int get_name(cpp::StringStream &name) const;
};
-extern LIBC_THREAD_LOCAL Thread self;
+LIBC_INLINE_VAR LIBC_THREAD_LOCAL Thread self;
// Platforms should implement this function.
[[noreturn]] void thread_exit(ThreadReturnValue retval, ThreadStyle style);
``````````
</details>
https://github.com/llvm/llvm-project/pull/101739
More information about the libc-commits
mailing list