[lld] [lldb] [llvm] [AArch64] Support TLS variables in debug info (PR #146572)
Peter Smith via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 9 10:08:33 PDT 2026
================
@@ -274,9 +274,17 @@ void DwarfCompileUnit::addLocationAttribute(
if (!Global && (!Expr || !Expr->isConstant()))
continue;
- if (Global && Global->isThreadLocal() &&
- !Asm->getObjFileLowering().supportDebugThreadLocalLocation())
- continue;
+ if (Global && Global->isThreadLocal()) {
+ // Do not emit TLS location for preemptible TLS variables
+ // (e.g. TLS in shared libraries). The TLS offset cannot be
+ // represented safely in DWARF. In that case let Debugger use
+ // Runtime TLS lookup via DTV (Dynmic thread vector).
+ if (Asm->TM.getTargetTriple().isAArch64() && !Global->isDSOLocal())
----------------
smithp35 wrote:
This isn't specific to AArch64, quoting from Dwarf 5
> DW_OP_form_tls_address The DW_OP_form_tls_address operation pops a value from the stack, which must have an integral type identifier, translates this value into an address in the thread-local storage for a thread, and pushes the address onto the stack together with the generic type identifier. The meaning of the value on the top of the stack prior to this operation is defined by the run-time environment. If the run-time environment supports multiple thread-local storage blocks for a single thread, then the block corresponding to the executable or shared library containing this DWARF expression is used.
I think the important bit is the last sentence. When executing code in a shared-library the dwarf expression would look up in the block for the shared library.
https://github.com/llvm/llvm-project/pull/146572
More information about the llvm-commits
mailing list