2
1
Fork 0
mirror of https://github.com/yuzu-emu/yuzu.git synced 2024-07-04 23:31:19 +01:00

kernel: mark TLS accessors as noinline for non-MSVC LTO

This commit is contained in:
Liam 2023-10-12 09:16:22 -04:00
parent 45a76637f5
commit 2212c9653d
2 changed files with 12 additions and 8 deletions

View file

@ -39,8 +39,12 @@
#define Crash() exit(1) #define Crash() exit(1)
#endif #endif
#define LTO_NOINLINE __attribute__((noinline))
#else // _MSC_VER #else // _MSC_VER
#define LTO_NOINLINE
// Locale Cross-Compatibility // Locale Cross-Compatibility
#define locale_t _locale_t #define locale_t _locale_t

View file

@ -373,7 +373,7 @@ struct KernelCore::Impl {
static inline thread_local u8 host_thread_id = UINT8_MAX; static inline thread_local u8 host_thread_id = UINT8_MAX;
/// Sets the host thread ID for the caller. /// Sets the host thread ID for the caller.
u32 SetHostThreadId(std::size_t core_id) { LTO_NOINLINE u32 SetHostThreadId(std::size_t core_id) {
// This should only be called during core init. // This should only be called during core init.
ASSERT(host_thread_id == UINT8_MAX); ASSERT(host_thread_id == UINT8_MAX);
@ -384,13 +384,13 @@ struct KernelCore::Impl {
} }
/// Gets the host thread ID for the caller /// Gets the host thread ID for the caller
u32 GetHostThreadId() const { LTO_NOINLINE u32 GetHostThreadId() const {
return host_thread_id; return host_thread_id;
} }
// Gets the dummy KThread for the caller, allocating a new one if this is the first time // Gets the dummy KThread for the caller, allocating a new one if this is the first time
KThread* GetHostDummyThread(KThread* existing_thread) { LTO_NOINLINE KThread* GetHostDummyThread(KThread* existing_thread) {
const auto initialize{[](KThread* thread) { const auto initialize{[](KThread* thread) LTO_NOINLINE {
ASSERT(KThread::InitializeDummyThread(thread, nullptr).IsSuccess()); ASSERT(KThread::InitializeDummyThread(thread, nullptr).IsSuccess());
return thread; return thread;
}}; }};
@ -424,11 +424,11 @@ struct KernelCore::Impl {
static inline thread_local bool is_phantom_mode_for_singlecore{false}; static inline thread_local bool is_phantom_mode_for_singlecore{false};
bool IsPhantomModeForSingleCore() const { LTO_NOINLINE bool IsPhantomModeForSingleCore() const {
return is_phantom_mode_for_singlecore; return is_phantom_mode_for_singlecore;
} }
void SetIsPhantomModeForSingleCore(bool value) { LTO_NOINLINE void SetIsPhantomModeForSingleCore(bool value) {
ASSERT(!is_multicore); ASSERT(!is_multicore);
is_phantom_mode_for_singlecore = value; is_phantom_mode_for_singlecore = value;
} }
@ -439,14 +439,14 @@ struct KernelCore::Impl {
static inline thread_local KThread* current_thread{nullptr}; static inline thread_local KThread* current_thread{nullptr};
KThread* GetCurrentEmuThread() { LTO_NOINLINE KThread* GetCurrentEmuThread() {
if (!current_thread) { if (!current_thread) {
current_thread = GetHostDummyThread(nullptr); current_thread = GetHostDummyThread(nullptr);
} }
return current_thread; return current_thread;
} }
void SetCurrentEmuThread(KThread* thread) { LTO_NOINLINE void SetCurrentEmuThread(KThread* thread) {
current_thread = thread; current_thread = thread;
} }