From 0d82b49d0a2a17a5274bac47286505843d1a0f94 Mon Sep 17 00:00:00 2001 From: Bruce Forstall Date: Mon, 27 Mar 2017 17:05:45 -0700 Subject: [PATCH] Implement TLS field handles for RyuJIT/x86 (dotnet/coreclr#10510) Implement TLS field handles for RyuJIT/x86 This isn't used by .NET Core, but helps us run desktop testing. Commit migrated from https://github.com/dotnet/coreclr/commit/5061b6c0c261ca475187375725f4a324c7f8b20c --- src/coreclr/src/jit/codegenxarch.cpp | 20 ++++++++++++++++---- src/coreclr/src/jit/gentree.cpp | 4 +--- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/coreclr/src/jit/codegenxarch.cpp b/src/coreclr/src/jit/codegenxarch.cpp index 2549095..5d26612 100644 --- a/src/coreclr/src/jit/codegenxarch.cpp +++ b/src/coreclr/src/jit/codegenxarch.cpp @@ -1314,7 +1314,7 @@ void CodeGen::genCodeForTreeNode(GenTreePtr treeNode) case GT_CNS_INT: #ifdef _TARGET_X86_ - NYI_IF(treeNode->IsIconHandle(GTF_ICON_TLS_HDL), "TLS constants"); + assert(!treeNode->IsIconHandle(GTF_ICON_TLS_HDL)); #endif // _TARGET_X86_ __fallthrough; @@ -1625,6 +1625,7 @@ void CodeGen::genCodeForTreeNode(GenTreePtr treeNode) break; case GT_IND: + { #ifdef FEATURE_SIMD // Handling of Vector3 type values loaded through indirection. if (treeNode->TypeGet() == TYP_SIMD12) @@ -1634,10 +1635,21 @@ void CodeGen::genCodeForTreeNode(GenTreePtr treeNode) } #endif // FEATURE_SIMD - genConsumeAddress(treeNode->AsIndir()->Addr()); - emit->emitInsMov(ins_Load(treeNode->TypeGet()), emitTypeSize(treeNode), treeNode); + GenTree* addr = treeNode->AsIndir()->Addr(); + if (addr->IsCnsIntOrI() && addr->IsIconHandle(GTF_ICON_TLS_HDL)) + { + noway_assert(EA_ATTR(genTypeSize(treeNode->gtType)) == EA_PTRSIZE); + emit->emitIns_R_C(ins_Load(TYP_I_IMPL), EA_PTRSIZE, treeNode->gtRegNum, FLD_GLOBAL_FS, + (int)addr->gtIntCon.gtIconVal); + } + else + { + genConsumeAddress(addr); + emit->emitInsMov(ins_Load(treeNode->TypeGet()), emitTypeSize(treeNode), treeNode); + } genProduceReg(treeNode); - break; + } + break; case GT_MULHI: #ifdef _TARGET_X86_ diff --git a/src/coreclr/src/jit/gentree.cpp b/src/coreclr/src/jit/gentree.cpp index 01845f1..4e42f4f 100644 --- a/src/coreclr/src/jit/gentree.cpp +++ b/src/coreclr/src/jit/gentree.cpp @@ -16076,9 +16076,7 @@ bool GenTreeIntConCommon::FitsInAddrBase(Compiler* comp) #endif #endif //! LEGACY_BACKEND - // TODO-x86 - TLS field handles are excluded for now as they are accessed relative to FS segment. - // Handling of TLS field handles is a NYI and this needs to be relooked after implementing it. - return IsCnsIntOrI() && !IsIconHandle(GTF_ICON_TLS_HDL); + return IsCnsIntOrI(); } // Returns true if this icon value is encoded as addr needs recording a relocation with VM -- 2.7.4