From 052d949dcb646bf40f6ef50df330d67f49832aaf Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Thu, 18 Jan 2024 15:59:44 -0800 Subject: [PATCH 1/2] Always expand TLS for NativeAOT --- src/coreclr/jit/helperexpansion.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/coreclr/jit/helperexpansion.cpp b/src/coreclr/jit/helperexpansion.cpp index b3e5bddd9e804d..92b68e8ba463a4 100644 --- a/src/coreclr/jit/helperexpansion.cpp +++ b/src/coreclr/jit/helperexpansion.cpp @@ -444,7 +444,13 @@ PhaseStatus Compiler::fgExpandThreadLocalAccess() // Always expand for NativeAOT because the TLS access will not be generated by NativeAOT const bool isNativeAOT = IsTargetAbi(CORINFO_NATIVEAOT_ABI); - if (!isNativeAOT && opts.OptimizationDisabled()) + if (isNativeAOT) + { + return fgExpandHelper<&Compiler::fgExpandThreadLocalAccessForCallNativeAOT>( + false /* expand rarely run blocks for NativeAOT */); + } + + if (opts.OptimizationDisabled()) { JITDUMP("Optimizations aren't allowed - bail out.\n") return result; @@ -459,9 +465,7 @@ PhaseStatus Compiler::fgExpandThreadLocalAccess() return result; } - return isNativeAOT ? fgExpandHelper<&Compiler::fgExpandThreadLocalAccessForCallNativeAOT>( - false /* expand rarely run blocks for NativeAOT */) - : fgExpandHelper<&Compiler::fgExpandThreadLocalAccessForCall>(true); + return fgExpandHelper<&Compiler::fgExpandThreadLocalAccessForCall>(true); } //------------------------------------------------------------------------------ From 405678e35ae4fa33fe39ca1e104c8ac8c8fd34a3 Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Thu, 18 Jan 2024 17:03:00 -0800 Subject: [PATCH 2/2] Update src/coreclr/jit/helperexpansion.cpp --- src/coreclr/jit/helperexpansion.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/jit/helperexpansion.cpp b/src/coreclr/jit/helperexpansion.cpp index 92b68e8ba463a4..9b9fb009a6f50f 100644 --- a/src/coreclr/jit/helperexpansion.cpp +++ b/src/coreclr/jit/helperexpansion.cpp @@ -442,7 +442,7 @@ PhaseStatus Compiler::fgExpandThreadLocalAccess() return result; } - // Always expand for NativeAOT because the TLS access will not be generated by NativeAOT + // Always expand for NativeAOT because the slow TLS access helper will not be generated by NativeAOT const bool isNativeAOT = IsTargetAbi(CORINFO_NATIVEAOT_ABI); if (isNativeAOT) {