Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inline TLS field access for linux/osx x64/arm64 #87082

Merged
merged 88 commits into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
9387a59
wip
kunalspathak Jun 1, 2023
4b27a2d
add __tls_get_addr() code in jitinterface
kunalspathak Jun 2, 2023
909b8e6
working model
kunalspathak Jun 2, 2023
773eb84
linux rely on __tls_get_addr() value
kunalspathak Jun 2, 2023
05aaa68
Add fields for both max/threadSTaticBlocks, have separate for GC/non-gc
kunalspathak Jun 2, 2023
03d9c2c
code cleanup
kunalspathak Jun 2, 2023
a98c2cf
code cleanup
kunalspathak Jun 2, 2023
04b3cbc
add comments
kunalspathak Jun 2, 2023
46d8fc3
jit format
kunalspathak Jun 2, 2023
f44d745
update guid
kunalspathak Jun 3, 2023
67d33a9
Merge remote-tracking branch 'origin/main' into tls_linux
kunalspathak Jun 3, 2023
7fb2f16
Merge remote-tracking branch 'origin/main' into tls_linux
kunalspathak Jun 5, 2023
fcbebaa
review feedback
kunalspathak Jun 6, 2023
7364faa
fix the offset
kunalspathak Jun 6, 2023
f257987
arm64: wip
kunalspathak Jun 7, 2023
f85614b
linux arm64 model
kunalspathak Jun 7, 2023
5bdf881
arm64: offsetOfThreadStaticBlock adjustment
kunalspathak Jun 8, 2023
b6d2ef0
Add mrs and tpid0 register
kunalspathak Jun 8, 2023
75ec05a
arm64: use the new mrs/tpidr0
kunalspathak Jun 9, 2023
fd200b5
fix arm64 build and offset calculation:
kunalspathak Jun 9, 2023
4523864
arm64: working
kunalspathak Jun 9, 2023
4bef20a
arm64: move to struct model
kunalspathak Jun 9, 2023
1f437f6
arm64: fixed the struct model
kunalspathak Jun 9, 2023
b5394d7
x64: move to struct model
kunalspathak Jun 9, 2023
dce8d91
code refactoring
kunalspathak Jun 10, 2023
e96530a
#define for field access
kunalspathak Jun 10, 2023
c4db025
change mrs -> mrs_tpid0
kunalspathak Jun 10, 2023
ddc931f
fix a bug
kunalspathak Jun 10, 2023
a716411
Merge remote-tracking branch 'origin/main' into tls_linux
kunalspathak Jun 10, 2023
1e14591
remove unwanted method
kunalspathak Jun 10, 2023
1632086
another fix
kunalspathak Jun 10, 2023
529c7f7
Add entries in CorInfoType.cs
kunalspathak Jun 10, 2023
90e091d
Update the #ifdef
kunalspathak Jun 10, 2023
694c9cc
fix the windows scenario:
kunalspathak Jun 12, 2023
e6044a8
review feedback
kunalspathak Jun 12, 2023
ae76829
fix the data-type
kunalspathak Jun 12, 2023
76db418
add osx-arm64 support
kunalspathak Jun 14, 2023
63ae9e8
fix osx-arm64 issues
kunalspathak Jun 16, 2023
e376109
fix build error
kunalspathak Jun 12, 2023
e74fcd2
Merge remote-tracking branch 'origin/main' into tls_linux
kunalspathak Jun 16, 2023
0d255d2
fix build error after merge
kunalspathak Jun 16, 2023
ac982cb
add osx/x64 support
kunalspathak Jun 16, 2023
130bc14
fix errors
kunalspathak Jun 16, 2023
eeb1a7a
Merge remote-tracking branch 'origin/main' into tls_linux
kunalspathak Jun 16, 2023
d3cdf77
fix the macos/x64
kunalspathak Jun 19, 2023
ec40932
disable for alpine linux
kunalspathak Jun 21, 2023
368e8c5
Disable for R2R
kunalspathak Jun 21, 2023
c35938c
review feedback
kunalspathak Jun 22, 2023
8a222d2
fix r2r check
kunalspathak Jun 22, 2023
5235d37
move windows to struct model
kunalspathak Jun 22, 2023
a273623
review feedback
kunalspathak Jun 22, 2023
6ef9e8d
fix the register clobbering in release bits
kunalspathak Jun 23, 2023
6d31ec6
Move the linux/x64 logic to .S file
kunalspathak Jun 26, 2023
ce44ced
Merge remote-tracking branch 'origin/main' into tls_linux
kunalspathak Jun 26, 2023
9292e2a
Use TargetOS::IsMacOS
kunalspathak Jun 26, 2023
de5ada2
disable optimization for single file
kunalspathak Jun 27, 2023
3fcec56
working for linux/x64
kunalspathak Jun 27, 2023
c39cf0e
fix some errors for osx/x64
kunalspathak Jun 27, 2023
9906f4e
fix for osx x64/arm64
kunalspathak Jun 27, 2023
cf3b8c0
fix for arm64 linux/osx
kunalspathak Jun 27, 2023
ed0c6a7
try disable for musl/arm64
kunalspathak Jun 27, 2023
5801bbf
Merge remote-tracking branch 'origin/main' into tls_linux
kunalspathak Jun 27, 2023
7dca821
rename variable
kunalspathak Jun 27, 2023
99dec18
Rename variable to tlsIndexObject
kunalspathak Jun 28, 2023
bdca9fe
Make offset variables as uint32_t
kunalspathak Jun 28, 2023
f1e5459
change the type of indexObj/ftnAddr to void*
kunalspathak Jun 28, 2023
cb409f5
replace ifdef(msc_ver) with ifdef(windows)
kunalspathak Jun 28, 2023
e3b7dc6
Revert to JIT_TO_EE_TRANSITION_LEAF
kunalspathak Jun 28, 2023
ab284c7
Move code to asmHelpers.S and rename method
kunalspathak Jun 28, 2023
bcc0a55
rename the methods per the platform
kunalspathak Jun 28, 2023
f475b6d
fix osx builds
kunalspathak Jun 28, 2023
4e0c211
fix build break
kunalspathak Jun 28, 2023
47e087d
fix some errors around osx
kunalspathak Jun 29, 2023
04420db
rename some more methods
kunalspathak Jun 29, 2023
94f4d43
review feedback
kunalspathak Jun 29, 2023
71d27eb
review feedback
kunalspathak Jun 29, 2023
09ec151
delete the comment
kunalspathak Jun 29, 2023
e28401c
make methods static
kunalspathak Jun 29, 2023
b89a55f
remove macos/x64 check
kunalspathak Jun 30, 2023
c6ae3e4
fix the check for linux/x64
kunalspathak Jun 30, 2023
d237f0b
detect early for single-file linux/x64
kunalspathak Jun 30, 2023
71b99dd
move the assert
kunalspathak Jun 30, 2023
de5b3b7
review feedback
kunalspathak Jul 3, 2023
c7864df
misc fixup
kunalspathak Jul 3, 2023
2429d75
use fgMorphArgs()
kunalspathak Jul 3, 2023
8fa1e6f
Merge remote-tracking branch 'origin/main' into tls_linux
kunalspathak Jul 3, 2023
d645f2e
remove commented code
kunalspathak Jul 5, 2023
d42fdce
Merge remote-tracking branch 'origin/main' into tls_linux
kunalspathak Jul 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -7123,7 +7123,7 @@ class Compiler
optMethodFlags |= OMF_HAS_GUARDEDDEVIRT;
}

bool doesMethodHasTlsFieldAccess()
bool methodHasTlsFieldAccess()
{
return (optMethodFlags & OMF_HAS_TLS_FIELD) != 0;
}
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/jit/emit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10205,6 +10205,8 @@ void emitter::emitRecordCallSite(ULONG instrOffset, /* IN */

if (callSig == nullptr)
{
// For certain calls whose target is non-containable (e.g. tls access targets), `methodHandle`
// will be nullptr, because the target is present in a register.
if ((methodHandle != nullptr) && (Compiler::eeGetHelperNum(methodHandle) == CORINFO_HELP_UNDEF))
kunalspathak marked this conversation as resolved.
Show resolved Hide resolved
{
emitComp->eeGetMethodSig(methodHandle, &sigInfo);
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/jit/emitarm64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3740,11 +3740,13 @@ void emitter::emitIns_R(instruction ins, emitAttr attr, regNumber reg)
id->idReg1(reg);
fmt = IF_SR_1A;
break;

case INS_mrs_tpid0:
kunalspathak marked this conversation as resolved.
Show resolved Hide resolved
id = emitNewInstrSmall(attr);
id->idReg1(reg);
fmt = IF_SR_1A;
break;
kunalspathak marked this conversation as resolved.
Show resolved Hide resolved

default:
unreached();
}
Expand Down
3 changes: 2 additions & 1 deletion src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17488,7 +17488,8 @@ bool GenTree::isContained() const
// return true if node is contained and an indir
bool GenTree::isContainedIndir() const
{
return OperIsIndir() && isContained();
bool answer = isContained();
return OperIsIndir() && answer;
kunalspathak marked this conversation as resolved.
Show resolved Hide resolved
}

bool GenTree::isIndirAddrMode()
Expand Down
27 changes: 14 additions & 13 deletions src/coreclr/jit/helperexpansion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ PhaseStatus Compiler::fgExpandThreadLocalAccess()
{
PhaseStatus result = PhaseStatus::MODIFIED_NOTHING;

if (!doesMethodHasTlsFieldAccess())
if (!methodHasTlsFieldAccess())
{
// TP: nothing to expand in the current method
JITDUMP("Nothing to expand.\n")
Expand Down Expand Up @@ -486,7 +486,7 @@ bool Compiler::fgExpandThreadLocalAccessForCall(BasicBlock** pBlock, Statement*
// On Arm, Thread execution blocks are accessed using co-processor registers and instructions such
// as MRC and MCR are used to access them. We do not support them and so should never optimize the
// field access using TLS.
assert(!"Unsupported scenario of optimizing TLS access on Linux Arm32/x86");
noway_assert(!"Unsupported scenario of optimizing TLS access on Linux Arm32/x86");
#endif
}
else
Expand All @@ -495,7 +495,7 @@ bool Compiler::fgExpandThreadLocalAccessForCall(BasicBlock** pBlock, Statement*
// On Arm, Thread execution blocks are accessed using co-processor registers and instructions such
// as MRC and MCR are used to access them. We do not support them and so should never optimize the
// field access using TLS.
assert(!"Unsupported scenario of optimizing TLS access on Windows Arm32");
noway_assert(!"Unsupported scenario of optimizing TLS access on Windows Arm32");
#endif
}

Expand All @@ -512,14 +512,15 @@ bool Compiler::fgExpandThreadLocalAccessForCall(BasicBlock** pBlock, Statement*
info.compCompHnd->getThreadLocalStaticBlocksInfo(&threadStaticBlocksInfo, isGCThreadStatic);

JITDUMP("getThreadLocalStaticBlocksInfo (%s)\n:", isGCThreadStatic ? "GC" : "Non-GC");
JITDUMP("offsetOfThreadLocalStoragePointer= %u\n", threadStaticBlocksInfo.offsetOfThreadLocalStoragePointer);
JITDUMP("tlsIndex= %u\n", (ssize_t)threadStaticBlocksInfo.tlsIndex.addr);
JITDUMP("tlsGetAddrFtnPtr= %u\n", threadStaticBlocksInfo.tlsGetAddrFtnPtr);
JITDUMP("tlsIndexObject= %u\n", (size_t)threadStaticBlocksInfo.tlsIndexObject);
JITDUMP("threadVarsSection= %u\n", (size_t)threadStaticBlocksInfo.threadVarsSection);
JITDUMP("offsetOfMaxThreadStaticBlocks= %u\n", threadStaticBlocksInfo.offsetOfMaxThreadStaticBlocks);
JITDUMP("offsetOfThreadStaticBlocks= %u\n", threadStaticBlocksInfo.offsetOfThreadStaticBlocks);
JITDUMP("offsetOfGCDataPointer= %u\n", threadStaticBlocksInfo.offsetOfGCDataPointer);
JITDUMP("tlsIndex= %p\n", dspOffset(dspPtr(threadStaticBlocksInfo.tlsIndex.addr)));
JITDUMP("tlsGetAddrFtnPtr= %p\n", dspOffset(dspPtr(threadStaticBlocksInfo.tlsGetAddrFtnPtr)));
JITDUMP("tlsIndexObject= %p\n", dspOffset(dspPtr(threadStaticBlocksInfo.tlsIndexObject)));
JITDUMP("threadVarsSection= %p\n", dspOffset(dspPtr(threadStaticBlocksInfo.threadVarsSection)));
kunalspathak marked this conversation as resolved.
Show resolved Hide resolved
JITDUMP("offsetOfThreadLocalStoragePointer= %u\n",
dspOffset(threadStaticBlocksInfo.offsetOfThreadLocalStoragePointer));
JITDUMP("offsetOfMaxThreadStaticBlocks= %u\n", dspOffset(threadStaticBlocksInfo.offsetOfMaxThreadStaticBlocks));
JITDUMP("offsetOfThreadStaticBlocks= %u\n", dspOffset(threadStaticBlocksInfo.offsetOfThreadStaticBlocks));
JITDUMP("offsetOfGCDataPointer= %u\n", dspOffset(threadStaticBlocksInfo.offsetOfGCDataPointer));

assert((eeGetHelperNum(call->gtCallMethHnd) == CORINFO_HELP_GETSHARED_NONGCTHREADSTATIC_BASE_NOCTOR_OPTIMIZED) ||
(eeGetHelperNum(call->gtCallMethHnd) == CORINFO_HELP_GETSHARED_GCTHREADSTATIC_BASE_NOCTOR_OPTIMIZED));
Expand Down Expand Up @@ -617,7 +618,7 @@ bool Compiler::fgExpandThreadLocalAccessForCall(BasicBlock** pBlock, Statement*

// This is a call which takes an argument.
// Populate and set the ABI appropriately.
assert(threadVarsSectionVal != 0);
assert(opts.altJit || threadVarsSectionVal != 0);
GenTree* tlsArg = gtNewIconNode(threadVarsSectionVal, TYP_I_IMPL);
tlsRefCall->gtArgs.InsertAfterThisOrFirst(this, NewCallArg::Primitive(tlsArg));

Expand All @@ -643,7 +644,7 @@ bool Compiler::fgExpandThreadLocalAccessForCall(BasicBlock** pBlock, Statement*

// This is an indirect call which takes an argument.
// Populate and set the ABI appropriately.
assert(threadStaticBlocksInfo.tlsIndexObject != 0);
assert(opts.altJit || threadStaticBlocksInfo.tlsIndexObject != 0);
GenTree* tlsArg = gtNewIconNode((size_t)threadStaticBlocksInfo.tlsIndexObject, TYP_I_IMPL);
kunalspathak marked this conversation as resolved.
Show resolved Hide resolved
tlsRefCall->gtArgs.InsertAfterThisOrFirst(this, NewCallArg::Primitive(tlsArg));

Expand Down
4 changes: 4 additions & 0 deletions src/coreclr/jit/lsraarmarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,10 @@ int LinearScan::BuildCall(GenTreeCall* call)

if (call->gtCallType == CT_INDIRECT)
kunalspathak marked this conversation as resolved.
Show resolved Hide resolved
{
// For TLS accesses, we need to find the address of the thread local by doing
// an indirect call to the relevant address corresponding to that variable.
// As an (early) argument, it takes the address of tlv_get_address
// symbol (osx) or the offset of the varible in TCB (linux).
kunalspathak marked this conversation as resolved.
Show resolved Hide resolved
for (CallArg& arg : call->gtArgs.EarlyArgs())
{
CallArgABIInformation& abiInfo = arg.AbiInfo;
Expand Down
8 changes: 4 additions & 4 deletions src/coreclr/tools/superpmi/superpmi-shared/agnostic.h
Original file line number Diff line number Diff line change
Expand Up @@ -533,10 +533,10 @@ struct Agnostic_GetThreadLocalStaticBlocksInfo
DWORDLONG tlsGetAddrFtnPtr;
DWORDLONG tlsIndexObject;
DWORDLONG threadVarsSection;
kunalspathak marked this conversation as resolved.
Show resolved Hide resolved
UINT offsetOfThreadLocalStoragePointer;
UINT offsetOfMaxThreadStaticBlocks;
UINT offsetOfThreadStaticBlocks;
UINT offsetOfGCDataPointer;
DWORD offsetOfThreadLocalStoragePointer;
DWORD offsetOfMaxThreadStaticBlocks;
DWORD offsetOfThreadStaticBlocks;
DWORD offsetOfGCDataPointer;
};

struct Agnostic_GetThreadLocalFieldInfo
Expand Down
33 changes: 15 additions & 18 deletions src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3573,13 +3573,12 @@ void MethodContext::recGetThreadLocalStaticBlocksInfo(CORINFO_THREAD_STATIC_BLOC
Agnostic_GetThreadLocalStaticBlocksInfo value;
ZeroMemory(&value, sizeof(value));

value.tlsIndex.handle = CastHandle(pInfo->tlsIndex.addr);
value.tlsIndex.accessType = pInfo->tlsIndex.accessType;
value.tlsGetAddrFtnPtr = CastHandle(pInfo->tlsGetAddrFtnPtr);
value.tlsIndexObject = CastHandle(pInfo->tlsIndexObject);
value.threadVarsSection = CastHandle(pInfo->threadVarsSection);
value.offsetOfMaxThreadStaticBlocks = pInfo->offsetOfMaxThreadStaticBlocks;
value.tlsIndex = SpmiRecordsHelper::StoreAgnostic_CORINFO_CONST_LOOKUP(&pInfo->tlsIndex);
value.tlsGetAddrFtnPtr = CastPointer(pInfo->tlsGetAddrFtnPtr);
value.tlsIndexObject = CastPointer(pInfo->tlsIndexObject);
value.threadVarsSection = CastPointer(pInfo->threadVarsSection);
value.offsetOfThreadLocalStoragePointer = pInfo->offsetOfThreadLocalStoragePointer;
value.offsetOfMaxThreadStaticBlocks = pInfo->offsetOfMaxThreadStaticBlocks;
value.offsetOfThreadStaticBlocks = pInfo->offsetOfThreadStaticBlocks;
value.offsetOfGCDataPointer = pInfo->offsetOfGCDataPointer;

Expand All @@ -3591,15 +3590,14 @@ void MethodContext::recGetThreadLocalStaticBlocksInfo(CORINFO_THREAD_STATIC_BLOC

void MethodContext::dmpGetThreadLocalStaticBlocksInfo(DWORD key, const Agnostic_GetThreadLocalStaticBlocksInfo& value)
{
printf("GetThreadLocalStaticBlocksInfo key %u, value tlsIndex-%016" PRIX64
printf("GetThreadLocalStaticBlocksInfo key %u, tlsIndex-%s, "
", tlsGetAddrFtnPtr-%016" PRIX64 ", tlsIndexObject - %016" PRIX64
", threadVarsSection - %016" PRIX64
", offsetOfThreadLocalStoragePointer-%u, offsetOfMaxThreadStaticBlocks-%u"
", offsetOfThreadStaticBlocks-%u, offsetOfGCDataPointer-%u"
", value tlsGetAddrFtnPtr-%016" PRIX64 ", tlsIndexObject-%016" PRIX64
", threadVarsSection-%016" PRIX64 ,
key, value.tlsIndex.handle, value.offsetOfThreadLocalStoragePointer,
value.offsetOfMaxThreadStaticBlocks, value.offsetOfThreadStaticBlocks,
value.offsetOfGCDataPointer, value.tlsGetAddrFtnPtr, value.tlsIndexObject,
value.threadVarsSection);
", offsetOfThreadStaticBlocks-%u, offsetOfGCDataPointer-%u",
key, SpmiDumpHelper::DumpAgnostic_CORINFO_CONST_LOOKUP(value.tlsIndex).c_str(), value.tlsGetAddrFtnPtr,
value.tlsIndexObject, value.threadVarsSection, value.offsetOfThreadLocalStoragePointer,
value.offsetOfMaxThreadStaticBlocks, value.offsetOfThreadStaticBlocks, value.offsetOfGCDataPointer);
}

void MethodContext::repGetThreadLocalStaticBlocksInfo(CORINFO_THREAD_STATIC_BLOCKS_INFO* pInfo, bool isGCType)
Expand All @@ -3609,14 +3607,13 @@ void MethodContext::repGetThreadLocalStaticBlocksInfo(CORINFO_THREAD_STATIC_BLOC

DEBUG_REP(dmpGetThreadLocalStaticBlocksInfo(key, value));

pInfo->tlsIndex.accessType = (InfoAccessType)value.tlsIndex.accessType;
pInfo->tlsIndex.addr = (void*)value.tlsIndex.handle;
pInfo->tlsIndex = SpmiRecordsHelper::RestoreCORINFO_CONST_LOOKUP(value.tlsIndex);
pInfo->tlsGetAddrFtnPtr = (void*)value.tlsGetAddrFtnPtr;
pInfo->tlsIndexObject = (void*)value.tlsIndexObject;
pInfo->threadVarsSection = (void*)value.threadVarsSection;
pInfo->offsetOfMaxThreadStaticBlocks = (DWORD)value.offsetOfMaxThreadStaticBlocks;
pInfo->offsetOfThreadLocalStoragePointer = value.offsetOfThreadLocalStoragePointer;
pInfo->offsetOfThreadStaticBlocks = (DWORD)value.offsetOfThreadStaticBlocks;
pInfo->offsetOfMaxThreadStaticBlocks = value.offsetOfMaxThreadStaticBlocks;
pInfo->offsetOfThreadStaticBlocks = value.offsetOfThreadStaticBlocks;
pInfo->offsetOfGCDataPointer = value.offsetOfGCDataPointer;
}

Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/vm/jithelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1865,7 +1865,7 @@ HCIMPL1(void*, JIT_GetSharedNonGCThreadStaticBaseOptimized, UINT32 staticBlockIn
if (t_NonGCThreadStaticBlocksSize > 0)
{
memcpy(newThreadStaticBlocks, t_ThreadStatics.NonGCThreadStaticBlocks, t_NonGCThreadStaticBlocksSize * sizeof(PTR_BYTE));
delete t_ThreadStatics.NonGCThreadStaticBlocks;
delete[] t_ThreadStatics.NonGCThreadStaticBlocks;
}

t_NonGCThreadStaticBlocksSize = newThreadStaticBlocksSize;
Expand Down Expand Up @@ -1959,7 +1959,7 @@ HCIMPL1(void*, JIT_GetSharedGCThreadStaticBaseOptimized, UINT32 staticBlockIndex
if (t_GCThreadStaticBlocksSize > 0)
{
memcpy(newThreadStaticBlocks, t_ThreadStatics.GCThreadStaticBlocks, t_GCThreadStaticBlocksSize * sizeof(PTR_BYTE));
delete t_ThreadStatics.GCThreadStaticBlocks;
delete[] t_ThreadStatics.GCThreadStaticBlocks;
}

t_GCThreadStaticBlocksSize = newThreadStaticBlocksSize;
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/vm/jitinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1392,7 +1392,7 @@ static void* GetThreadStaticDescriptor(uint8_t* p)
{
// The optimization is disabled if coreclr is not compiled in .so format.
_ASSERTE(false && "Unexpected code sequence");
return 0;
return nullptr;
}

// At this point, `p` contains the instruction pointer and is pointing to the above opcodes.
Expand Down Expand Up @@ -1593,7 +1593,7 @@ void CEEInfo::getFieldInfo (CORINFO_RESOLVED_TOKEN * pResolvedToken,
// For linux/x64, check if compiled coreclr as .so file and not single file.
// For single file, the `tls_index` might not be accurate.
// Do not perform this optimization in such case.
optimizeThreadStaticAccess = GetTlsIndexObjectAddress() != 0;
optimizeThreadStaticAccess = GetTlsIndexObjectAddress() != nullptr;
#endif // TARGET_UNIX && TARGET_AMD64

if (optimizeThreadStaticAccess)
Expand Down