Coverage Report

Created: 2018-07-12 09:57

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
Line
Count
Source (jump to first uncovered line)
1
//==- llvm/CodeGen/TargetLoweringObjectFileImpl.h - Object Info --*- C++ -*-==//
2
//
3
//                     The LLVM Compiler Infrastructure
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
//
10
// This file implements classes used to handle lowerings specific to common
11
// object file formats.
12
//
13
//===----------------------------------------------------------------------===//
14
15
#ifndef LLVM_CODEGEN_TARGETLOWERINGOBJECTFILEIMPL_H
16
#define LLVM_CODEGEN_TARGETLOWERINGOBJECTFILEIMPL_H
17
18
#include "llvm/IR/Module.h"
19
#include "llvm/MC/MCExpr.h"
20
#include "llvm/Target/TargetLoweringObjectFile.h"
21
22
namespace llvm {
23
24
class GlobalValue;
25
class MachineModuleInfo;
26
class Mangler;
27
class MCContext;
28
class MCSection;
29
class MCSymbol;
30
class TargetMachine;
31
32
class TargetLoweringObjectFileELF : public TargetLoweringObjectFile {
33
  bool UseInitArray = false;
34
  mutable unsigned NextUniqueID = 1;  // ID 0 is reserved for execute-only sections
35
36
protected:
37
  MCSymbolRefExpr::VariantKind PLTRelativeVariantKind =
38
      MCSymbolRefExpr::VK_None;
39
40
public:
41
23.5k
  TargetLoweringObjectFileELF() = default;
42
23.2k
  ~TargetLoweringObjectFileELF() override = default;
43
44
  /// Emit Obj-C garbage collection and linker options.
45
  void emitModuleMetadata(MCStreamer &Streamer, Module &M) const override;
46
47
  void emitPersonalityValue(MCStreamer &Streamer, const DataLayout &TM,
48
                            const MCSymbol *Sym) const override;
49
50
  /// Given a constant with the SectionKind, return a section that it should be
51
  /// placed in.
52
  MCSection *getSectionForConstant(const DataLayout &DL, SectionKind Kind,
53
                                   const Constant *C,
54
                                   unsigned &Align) const override;
55
56
  MCSection *getExplicitSectionGlobal(const GlobalObject *GO, SectionKind Kind,
57
                                      const TargetMachine &TM) const override;
58
59
  MCSection *SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind,
60
                                    const TargetMachine &TM) const override;
61
62
  MCSection *getSectionForJumpTable(const Function &F,
63
                                    const TargetMachine &TM) const override;
64
65
  bool shouldPutJumpTableInFunctionSection(bool UsesLabelDifference,
66
                                           const Function &F) const override;
67
68
  /// Return an MCExpr to use for a reference to the specified type info global
69
  /// variable from exception handling information.
70
  const MCExpr *getTTypeGlobalReference(const GlobalValue *GV,
71
                                        unsigned Encoding,
72
                                        const TargetMachine &TM,
73
                                        MachineModuleInfo *MMI,
74
                                        MCStreamer &Streamer) const override;
75
76
  // The symbol that gets passed to .cfi_personality.
77
  MCSymbol *getCFIPersonalitySymbol(const GlobalValue *GV,
78
                                    const TargetMachine &TM,
79
                                    MachineModuleInfo *MMI) const override;
80
81
  void InitializeELF(bool UseInitArray_);
82
  MCSection *getStaticCtorSection(unsigned Priority,
83
                                  const MCSymbol *KeySym) const override;
84
  MCSection *getStaticDtorSection(unsigned Priority,
85
                                  const MCSymbol *KeySym) const override;
86
87
  const MCExpr *lowerRelativeReference(const GlobalValue *LHS,
88
                                       const GlobalValue *RHS,
89
                                       const TargetMachine &TM) const override;
90
};
91
92
class TargetLoweringObjectFileMachO : public TargetLoweringObjectFile {
93
public:
94
  TargetLoweringObjectFileMachO();
95
7.17k
  ~TargetLoweringObjectFileMachO() override = default;
96
97
  void Initialize(MCContext &Ctx, const TargetMachine &TM) override;
98
99
  /// Emit the module flags that specify the garbage collection information.
100
  void emitModuleMetadata(MCStreamer &Streamer, Module &M) const override;
101
102
  MCSection *SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind,
103
                                    const TargetMachine &TM) const override;
104
105
  MCSection *getExplicitSectionGlobal(const GlobalObject *GO, SectionKind Kind,
106
                                      const TargetMachine &TM) const override;
107
108
  MCSection *getSectionForConstant(const DataLayout &DL, SectionKind Kind,
109
                                   const Constant *C,
110
                                   unsigned &Align) const override;
111
112
  /// The mach-o version of this method defaults to returning a stub reference.
113
  const MCExpr *getTTypeGlobalReference(const GlobalValue *GV,
114
                                        unsigned Encoding,
115
                                        const TargetMachine &TM,
116
                                        MachineModuleInfo *MMI,
117
                                        MCStreamer &Streamer) const override;
118
119
  // The symbol that gets passed to .cfi_personality.
120
  MCSymbol *getCFIPersonalitySymbol(const GlobalValue *GV,
121
                                    const TargetMachine &TM,
122
                                    MachineModuleInfo *MMI) const override;
123
124
  /// Get MachO PC relative GOT entry relocation
125
  const MCExpr *getIndirectSymViaGOTPCRel(const MCSymbol *Sym,
126
                                          const MCValue &MV, int64_t Offset,
127
                                          MachineModuleInfo *MMI,
128
                                          MCStreamer &Streamer) const override;
129
130
  void getNameWithPrefix(SmallVectorImpl<char> &OutName, const GlobalValue *GV,
131
                         const TargetMachine &TM) const override;
132
};
133
134
class TargetLoweringObjectFileCOFF : public TargetLoweringObjectFile {
135
  mutable unsigned NextUniqueID = 0;
136
137
public:
138
1.47k
  ~TargetLoweringObjectFileCOFF() override = default;
139
140
  void Initialize(MCContext &Ctx, const TargetMachine &TM) override;
141
  MCSection *getExplicitSectionGlobal(const GlobalObject *GO, SectionKind Kind,
142
                                      const TargetMachine &TM) const override;
143
144
  MCSection *SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind,
145
                                    const TargetMachine &TM) const override;
146
147
  void getNameWithPrefix(SmallVectorImpl<char> &OutName, const GlobalValue *GV,
148
                         const TargetMachine &TM) const override;
149
150
  MCSection *getSectionForJumpTable(const Function &F,
151
                                    const TargetMachine &TM) const override;
152
153
  /// Emit Obj-C garbage collection and linker options.
154
  void emitModuleMetadata(MCStreamer &Streamer, Module &M) const override;
155
156
  MCSection *getStaticCtorSection(unsigned Priority,
157
                                  const MCSymbol *KeySym) const override;
158
  MCSection *getStaticDtorSection(unsigned Priority,
159
                                  const MCSymbol *KeySym) const override;
160
161
  void emitLinkerFlagsForGlobal(raw_ostream &OS,
162
                                const GlobalValue *GV) const override;
163
164
  void emitLinkerFlagsForUsed(raw_ostream &OS,
165
                              const GlobalValue *GV) const override;
166
167
  const MCExpr *lowerRelativeReference(const GlobalValue *LHS,
168
                                       const GlobalValue *RHS,
169
                                       const TargetMachine &TM) const override;
170
171
  /// Given a mergeable constant with the specified size and relocation
172
  /// information, return a section that it should be placed in.
173
  MCSection *getSectionForConstant(const DataLayout &DL, SectionKind Kind,
174
                                   const Constant *C,
175
                                   unsigned &Align) const override;
176
};
177
178
class TargetLoweringObjectFileWasm : public TargetLoweringObjectFile {
179
  mutable unsigned NextUniqueID = 0;
180
181
public:
182
  TargetLoweringObjectFileWasm() = default;
183
0
  ~TargetLoweringObjectFileWasm() override = default;
184
185
  MCSection *getExplicitSectionGlobal(const GlobalObject *GO, SectionKind Kind,
186
                                      const TargetMachine &TM) const override;
187
188
  MCSection *SelectSectionForGlobal(const GlobalObject *GO, SectionKind Kind,
189
                                    const TargetMachine &TM) const override;
190
191
  bool shouldPutJumpTableInFunctionSection(bool UsesLabelDifference,
192
                                           const Function &F) const override;
193
194
  void InitializeWasm();
195
  MCSection *getStaticCtorSection(unsigned Priority,
196
                                  const MCSymbol *KeySym) const override;
197
  MCSection *getStaticDtorSection(unsigned Priority,
198
                                  const MCSymbol *KeySym) const override;
199
200
  const MCExpr *lowerRelativeReference(const GlobalValue *LHS,
201
                                       const GlobalValue *RHS,
202
                                       const TargetMachine &TM) const override;
203
};
204
205
} // end namespace llvm
206
207
#endif // LLVM_CODEGEN_TARGETLOWERINGOBJECTFILEIMPL_H