PR16493: DebugInfo with TLS on PPC crashing due to invalid relocation
authorDavid Blaikie <dblaikie@gmail.com>
Mon, 1 Jul 2013 21:45:25 +0000 (21:45 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Mon, 1 Jul 2013 21:45:25 +0000 (21:45 +0000)
Restrict the current TLS support to X86 ELF for now. Test that we don't
produce it on PPC & we can flesh that test case out with the right thing
once someone implements it.

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

include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
lib/CodeGen/TargetLoweringObjectFileImpl.cpp
lib/Target/X86/X86TargetObjectFile.cpp
lib/Target/X86/X86TargetObjectFile.h
test/DebugInfo/PowerPC/lit.local.cfg [new file with mode: 0644]
test/DebugInfo/PowerPC/tls.ll [new file with mode: 0644]
test/DebugInfo/X86/tls.ll

index 5e11ecf7759b48d5e2994545d37083669a6ea749..5b22c9c685ae600bd1ece1a6491106254de12580 100644 (file)
@@ -72,9 +72,6 @@ public:
   getStaticCtorSection(unsigned Priority = 65535) const;
   virtual const MCSection *
   getStaticDtorSection(unsigned Priority = 65535) const;
-
-  /// \brief Describe a TLS variable address within debug info.
-  virtual const MCSymbolRefExpr *getDebugThreadLocalSymbol(const MCSymbol *Sym) const;
 };
 
 
index 69d55913caf00916a41a507b71c8e75c638cffd7..7e7359a8feed9ee1eb5f508aa500158cfc0d78d8 100644 (file)
@@ -401,10 +401,6 @@ TargetLoweringObjectFileELF::InitializeELF(bool UseInitArray_) {
                                SectionKind::getDataRel());
 }
 
-const MCSymbolRefExpr *TargetLoweringObjectFileELF::getDebugThreadLocalSymbol(const MCSymbol *Sym) const {
-  return MCSymbolRefExpr::Create(Sym, MCSymbolRefExpr::VK_DTPOFF, getContext());
-}
-
 //===----------------------------------------------------------------------===//
 //                                 MachO
 //===----------------------------------------------------------------------===//
index 871dacd6a1c1ee86839d864ed1666f0cc87a5508..a00e8d4f4dd44d0b29e6342ab135caa51f6f2904 100644 (file)
@@ -47,3 +47,9 @@ X86LinuxTargetObjectFile::Initialize(MCContext &Ctx, const TargetMachine &TM) {
   TargetLoweringObjectFileELF::Initialize(Ctx, TM);
   InitializeELF(TM.Options.UseInitArray);
 }
+
+const MCSymbolRefExpr *
+X86LinuxTargetObjectFile::getDebugThreadLocalSymbol(
+    const MCSymbol *Sym) const {
+  return MCSymbolRefExpr::Create(Sym, MCSymbolRefExpr::VK_DTPOFF, getContext());
+}
index 9d26d389d4de065e5c98823a21d523d6ea9548a7..7baedd2ddfddf9871b7fd337b121b03a41ee4aef 100644 (file)
@@ -36,6 +36,9 @@ namespace llvm {
   /// and x86-64.
   class X86LinuxTargetObjectFile : public TargetLoweringObjectFileELF {
     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;
   };
 
 } // end namespace llvm
diff --git a/test/DebugInfo/PowerPC/lit.local.cfg b/test/DebugInfo/PowerPC/lit.local.cfg
new file mode 100644 (file)
index 0000000..112a1c3
--- /dev/null
@@ -0,0 +1,5 @@
+config.suffixes = ['.ll', '.s']
+
+targets = set(config.root.targets_to_build.split())
+if not 'PowerPC' in targets:
+    config.unsupported = True
diff --git a/test/DebugInfo/PowerPC/tls.ll b/test/DebugInfo/PowerPC/tls.ll
new file mode 100644 (file)
index 0000000..3e53896
--- /dev/null
@@ -0,0 +1,22 @@
+; RUN: llc -mtriple=powerpc-unknown-unknown -O0 -filetype=asm < %s | FileCheck %s
+
+; FIXME: add relocation and DWARF expression support to llvm-dwarfdump & use
+; that here instead of raw assembly printing
+
+; CHECK: debug_info
+; CHECK-NOT: tls@DTPOFF
+
+@tls = thread_local global i32 7, align 4
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!7}
+
+!0 = metadata !{i32 786449, metadata !1, i32 4, metadata !"clang version 3.4 ", i1 false, metadata !"", i32 0, metadata !2, metadata !2, metadata !2, metadata !3, metadata !2, metadata !""} ; [ DW_TAG_compile_unit ] [/tmp/tls.cpp] [DW_LANG_C_plus_plus]
+!1 = metadata !{metadata !"tls.cpp", metadata !"/tmp"}
+!2 = metadata !{i32 0}
+!3 = metadata !{metadata !4}
+!4 = metadata !{i32 786484, i32 0, null, metadata !"tls", metadata !"tls", metadata !"", metadata !5, i32 1, metadata !6, i32 0, i32 1, i32* @tls, null} ; [ DW_TAG_variable ] [tls] [line 1] [def]
+!5 = metadata !{i32 786473, metadata !1}          ; [ DW_TAG_file_type ] [/tmp/tls.cpp]
+!6 = metadata !{i32 786468, null, null, metadata !"int", i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed]
+!7 = metadata !{i32 2, metadata !"Dwarf Version", i32 3}
+
index 2ed673af845b547992dfb96fcb1f5721efac0567..e2a9af962ccbac8da8504ac5def9931c9677b5e7 100644 (file)
@@ -1,5 +1,5 @@
-; RUN: llc -mtriple=x86_64-unknown-unknown -O0 -filetype=asm < %s | FileCheck %s
-; RUN: llc -mtriple=i386-unknown-unknown -O0 -filetype=asm < %s | FileCheck --check-prefix=CHECK-32 %s
+; RUN: llc -mtriple=x86_64-linux -O0 -filetype=asm < %s | FileCheck %s
+; RUN: llc -mtriple=i386-linux -O0 -filetype=asm < %s | FileCheck --check-prefix=CHECK-32 %s
 
 ; FIXME: add relocation and DWARF expression support to llvm-dwarfdump & use
 ; that here instead of raw assembly printing