[DebugInfo] Allow getDebugThreadLocalSymbol to return MCExpr
authorUlrich Weigand <ulrich.weigand@de.ibm.com>
Tue, 2 Jul 2013 18:47:09 +0000 (18:47 +0000)
committerUlrich Weigand <ulrich.weigand@de.ibm.com>
Tue, 2 Jul 2013 18:47:09 +0000 (18:47 +0000)
This allows getDebugThreadLocalSymbol to return a generic MCExpr
instead of just a MCSymbolRefExpr.

This is in preparation for supporting debug info for TLS variables
on PowerPC, where we need to describe the variable location using
a more complex expression than just MCSymbolRefExpr.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185460 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Target/TargetLoweringObjectFile.h
lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
lib/Target/TargetLoweringObjectFile.cpp
lib/Target/X86/X86TargetObjectFile.cpp
lib/Target/X86/X86TargetObjectFile.h

index a17feeb0a719ea4bb5dcf2eaaf7c22e4023a3118..7f15b742580d2612c09b05df185a5a4a6bde7288 100644 (file)
@@ -140,7 +140,7 @@ public:
 
   /// \brief Create a symbol reference to describe the given TLS variable when
   /// emitting the address in debug info.
-  virtual const MCSymbolRefExpr *getDebugThreadLocalSymbol(const MCSymbol *Sym) const;
+  virtual const MCExpr *getDebugThreadLocalSymbol(const MCSymbol *Sym) const;
 
 protected:
   virtual const MCSection *
index 398718dc17571660f6dd35272ac918758e57382a..e8462323704bcc5005aecdca2f6c64c29a458770 100644 (file)
@@ -1358,7 +1358,7 @@ void CompileUnit::createGlobalVariableDIE(const MDNode *N) {
       unsigned PointerSize = Asm->getDataLayout().getPointerSize();
       assert((PointerSize == 4 || PointerSize == 8) &&
              "Add support for other sizes if necessary");
-      const MCSymbolRefExpr *Ref =
+      const MCExpr *Expr =
           Asm->getObjFileLowering().getDebugThreadLocalSymbol(Sym);
       // Based on GCC's support for TLS:
       if (!DD->useSplitDwarf()) {
@@ -1366,10 +1366,10 @@ void CompileUnit::createGlobalVariableDIE(const MDNode *N) {
         addUInt(Block, 0, dwarf::DW_FORM_data1,
                 PointerSize == 4 ? dwarf::DW_OP_const4u : dwarf::DW_OP_const8u);
         // 2) containing the (relocated) address of the TLS variable
-        addExpr(Block, 0, dwarf::DW_FORM_udata, Ref);
+        addExpr(Block, 0, dwarf::DW_FORM_udata, Expr);
       } else {
         addUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_GNU_const_index);
-        addUInt(Block, 0, dwarf::DW_FORM_udata, DU->getAddrPoolIndex(Ref));
+        addUInt(Block, 0, dwarf::DW_FORM_udata, DU->getAddrPoolIndex(Expr));
       }
       // 3) followed by a custom OP to tell the debugger about TLS (presumably)
       addUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_lo_user);
index fc50aa5192a7606892f4c9a2e30c3cfdb4e6ff3a..cd810b624f56613dc90f9c4ad28ea39521440844 100644 (file)
@@ -318,7 +318,7 @@ getTTypeReference(const MCSymbolRefExpr *Sym, unsigned Encoding,
   }
 }
 
-const MCSymbolRefExpr *TargetLoweringObjectFile::getDebugThreadLocalSymbol(const MCSymbol *Sym) const {
+const MCExpr *TargetLoweringObjectFile::getDebugThreadLocalSymbol(const MCSymbol *Sym) const {
   // FIXME: It's not clear what, if any, default this should have - perhaps a
   // null return could mean 'no location' & we should just do that here.
   return MCSymbolRefExpr::Create(Sym, *Ctx);
index a00e8d4f4dd44d0b29e6342ab135caa51f6f2904..a19c5a601e8829cc99d062880c6390b68e6758d3 100644 (file)
@@ -48,7 +48,7 @@ X86LinuxTargetObjectFile::Initialize(MCContext &Ctx, const TargetMachine &TM) {
   InitializeELF(TM.Options.UseInitArray);
 }
 
-const MCSymbolRefExpr *
+const MCExpr *
 X86LinuxTargetObjectFile::getDebugThreadLocalSymbol(
     const MCSymbol *Sym) const {
   return MCSymbolRefExpr::Create(Sym, MCSymbolRefExpr::VK_DTPOFF, getContext());
index 7baedd2ddfddf9871b7fd337b121b03a41ee4aef..79c861d2e12e18f5cf0c1fe7f18e038714096e33 100644 (file)
@@ -38,7 +38,7 @@ namespace llvm {
     virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
 
     /// \brief Describe a TLS variable address within debug info.
-    virtual const MCSymbolRefExpr *getDebugThreadLocalSymbol(const MCSymbol *Sym) const;
+    virtual const MCExpr *getDebugThreadLocalSymbol(const MCSymbol *Sym) const;
   };
 
 } // end namespace llvm