<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - LLVM should emit DW_OP_form_tls_address instead of DW_OP_GNU_push_tls_address"
   href="http://llvm.org/bugs/show_bug.cgi?id=18423">18423</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>LLVM should emit DW_OP_form_tls_address instead of  DW_OP_GNU_push_tls_address
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>DebugInfo
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>aprantl@apple.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>For thread-local storage, LLVM currently uses the custom DWARF expression
DW_OP_GNU_push_tls_address. There is a DW_OP_form_tls_address that has been
part of the DWARF spec since version 3.

<a href="http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20140106/200694.html">http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20140106/200694.html</a>

According to
<a href="http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20140106/200714.html">http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20140106/200714.html</a>
the reason for this is that GDB up to 7.5 does not support
DW_OP_form_tls_address.


Here is a patch we can apply once GDB supports the official DWARF expression:

diff --git a/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
b/lib/CodeGen/AsmPrinter/Dwarf
index 04a2573..bfe1524 100644
--- a/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -1595,7 +1595,9 @@ void
DwarfCompileUnit::createGlobalVariableDIE(DIGlobalVar
        addUInt(Block, dwarf::DW_FORM_udata, DU->getAddrPoolIndex(Expr));
      }
      // 3) followed by a custom OP to make the debugger do a TLS lookup.
-      addUInt(Block, dwarf::DW_FORM_data1, dwarf::DW_OP_GNU_push_tls_address);
+      addUInt(Block, dwarf::DW_FORM_data1,
+              DD->getDwarfVersion() <= 2 ? dwarf::DW_OP_GNU_push_tls_address
+                                         : dwarf::DW_OP_form_tls_address);
    } else {
      DD->addArangeLabel(SymbolCU(this, Sym));
      addOpAddress(Block, Sym);</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>