llvm.org GIT mirror llvm / e2e5c51
Merging r292624: ------------------------------------------------------------------------ r292624 | petarj | 2017-01-20 09:53:30 -0800 (Fri, 20 Jan 2017) | 9 lines [mips] Fix debug information for __thread variable This patch fixes debug information for __thread variable on Mips using .dtprelword and .dtpreldword directives. Patch by Aleksandar Beserminji. Differential Revision: http://reviews.llvm.org/D28770 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_40@293664 91177308-0d34-0410-b5e6-96231b3b80d8 Hans Wennborg 2 years ago
8 changed file(s) with 65 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
479479 /// Get the value for DW_AT_APPLE_isa. Zero if no isa encoding specified.
480480 virtual unsigned getISAEncoding() { return 0; }
481481
482 /// Emit the directive and value for debug thread local expression
483 ///
484 /// \p Value - The value to emit.
485 /// \p Size - The size of the integer (in bytes) to emit.
486 virtual void EmitDebugValue(const MCExpr *Value, unsigned Size) const;
487
482488 //===------------------------------------------------------------------===//
483489 // Dwarf Lowering Routines
484490 //===------------------------------------------------------------------===//
566566 OutStreamer->AddBlankLine();
567567 }
568568
569 /// Emit the directive and value for debug thread local expression
570 ///
571 /// \p Value - The value to emit.
572 /// \p Size - The size of the integer (in bytes) to emit.
573 void AsmPrinter::EmitDebugValue(const MCExpr *Value,
574 unsigned Size) const {
575 OutStreamer->EmitValue(Value, Size);
576 }
577
569578 /// EmitFunctionHeader - This method emits the header for the current
570579 /// function.
571580 void AsmPrinter::EmitFunctionHeader() {
483483 /// EmitValue - Emit expression value.
484484 ///
485485 void DIEExpr::EmitValue(const AsmPrinter *AP, dwarf::Form Form) const {
486 AP->OutStreamer->EmitValue(Expr, SizeOf(AP, Form));
486 AP->EmitDebugValue(Expr, SizeOf(AP, Form));
487487 }
488488
489489 /// SizeOf - Determine size of expression value in bytes.
10361036 // TODO: implement
10371037 }
10381038
1039 // Emit .dtprelword or .dtpreldword directive
1040 // and value for debug thread local expression.
1041 void MipsAsmPrinter::EmitDebugValue(const MCExpr *Value,
1042 unsigned Size) const {
1043 switch (Size) {
1044 case 4:
1045 OutStreamer->EmitDTPRel32Value(Value);
1046 break;
1047 case 8:
1048 OutStreamer->EmitDTPRel64Value(Value);
1049 break;
1050 default:
1051 llvm_unreachable("Unexpected size of expression value.");
1052 }
1053 }
1054
10391055 // Align all targets of indirect branches on bundle size. Used only if target
10401056 // is NaCl.
10411057 void MipsAsmPrinter::NaClAlignIndirectJumpTargets(MachineFunction &MF) {
139139 void EmitStartOfAsmFile(Module &M) override;
140140 void EmitEndOfAsmFile(Module &M) override;
141141 void PrintDebugValueComment(const MachineInstr *MI, raw_ostream &OS);
142 void EmitDebugValue(const MCExpr *Value, unsigned Size) const override;
142143 };
143144 }
144145
147147 // Otherwise, we work the same as ELF.
148148 return TargetLoweringObjectFileELF::getSectionForConstant(DL, Kind, C, Align);
149149 }
150
151 const MCExpr *
152 MipsTargetObjectFile::getDebugThreadLocalSymbol(const MCSymbol *Sym) const {
153 const MCExpr *Expr =
154 MCSymbolRefExpr::create(Sym, MCSymbolRefExpr::VK_None, getContext());
155 return MCBinaryExpr::createAdd(
156 Expr, MCConstantExpr::create(0x8000, getContext()), getContext());
157 }
4141 MCSection *getSectionForConstant(const DataLayout &DL, SectionKind Kind,
4242 const Constant *C,
4343 unsigned &Align) const override;
44 /// Describe a TLS variable address within debug info.
45 const MCExpr *getDebugThreadLocalSymbol(const MCSymbol *Sym) const override;
4446 };
4547 } // end namespace llvm
4648
0 ; RUN: llc -O0 -march=mips -mcpu=mips32r2 -filetype=asm < %s | FileCheck %s -check-prefix=CHECK-WORD
1 ; RUN: llc -O0 -march=mips64 -mcpu=mips64r2 -filetype=asm < %s | FileCheck %s -check-prefix=CHECK-DWORD
2
3 @x = thread_local global i32 5, align 4, !dbg !0
4
5 ; CHECK-WORD: .dtprelword x+32768
6 ; CHECK-DWORD: .dtpreldword x+32768
7
8 !llvm.dbg.cu = !{!2}
9 !llvm.module.flags = !{!7, !8}
10 !llvm.ident = !{!9}
11
12 !0 = !DIGlobalVariableExpression(var: !1)
13 !1 = distinct !DIGlobalVariable(name: "x", scope: !2, file: !3, line: 1, type: !6, isLocal: false, isDefinition: true)
14 !2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 4.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5)
15 !3 = !DIFile(filename: "tls.c", directory: "/tmp")
16 !4 = !{}
17 !5 = !{!0}
18 !6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
19 !7 = !{i32 2, !"Dwarf Version", i32 4}
20 !8 = !{i32 2, !"Debug Info Version", i32 3}
21 !9 = !{!"clang version 4.0.0"}