Coverage Report

Created: 2018-09-23 03:40

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/clang/include/clang/Frontend/CodeGenOptions.h
Line
Count
Source
1
//===--- CodeGenOptions.h ---------------------------------------*- 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 defines the CodeGenOptions interface.
11
//
12
//===----------------------------------------------------------------------===//
13
14
#ifndef LLVM_CLANG_FRONTEND_CODEGENOPTIONS_H
15
#define LLVM_CLANG_FRONTEND_CODEGENOPTIONS_H
16
17
#include "clang/Basic/DebugInfoOptions.h"
18
#include "clang/Basic/Sanitizers.h"
19
#include "clang/Basic/XRayInstr.h"
20
#include "llvm/Support/CodeGen.h"
21
#include "llvm/Support/Regex.h"
22
#include "llvm/Target/TargetOptions.h"
23
#include <map>
24
#include <memory>
25
#include <string>
26
#include <vector>
27
28
namespace clang {
29
30
/// Bitfields of CodeGenOptions, split out from CodeGenOptions to ensure
31
/// that this large collection of bitfields is a trivial class type.
32
class CodeGenOptionsBase {
33
public:
34
#define CODEGENOPT(Name, Bits, Default) unsigned Name : Bits;
35
#define ENUM_CODEGENOPT(Name, Type, Bits, Default)
36
#include "clang/Frontend/CodeGenOptions.def"
37
38
protected:
39
#define CODEGENOPT(Name, Bits, Default)
40
#define ENUM_CODEGENOPT(Name, Type, Bits, Default) unsigned Name : Bits;
41
#include "clang/Frontend/CodeGenOptions.def"
42
};
43
44
/// CodeGenOptions - Track various options which control how the code
45
/// is optimized and passed to the backend.
46
class CodeGenOptions : public CodeGenOptionsBase {
47
public:
48
  enum InliningMethod {
49
    NormalInlining,     // Use the standard function inlining pass.
50
    OnlyHintInlining,   // Inline only (implicitly) hinted functions.
51
    OnlyAlwaysInlining  // Only run the always inlining pass.
52
  };
53
54
  enum VectorLibrary {
55
    NoLibrary,  // Don't use any vector library.
56
    Accelerate, // Use the Accelerate framework.
57
    SVML        // Intel short vector math library.
58
  };
59
60
61
  enum ObjCDispatchMethodKind {
62
    Legacy = 0,
63
    NonLegacy = 1,
64
    Mixed = 2
65
  };
66
67
  enum TLSModel {
68
    GeneralDynamicTLSModel,
69
    LocalDynamicTLSModel,
70
    InitialExecTLSModel,
71
    LocalExecTLSModel
72
  };
73
74
  /// Clang versions with different platform ABI conformance.
75
  enum class ClangABI {
76
    /// Attempt to be ABI-compatible with code generated by Clang 3.8.x
77
    /// (SVN r257626). This causes <1 x long long> to be passed in an
78
    /// integer register instead of an SSE register on x64_64.
79
    Ver3_8,
80
81
    /// Attempt to be ABI-compatible with code generated by Clang 4.0.x
82
    /// (SVN r291814). This causes move operations to be ignored when
83
    /// determining whether a class type can be passed or returned directly.
84
    Ver4,
85
86
    /// Conform to the underlying platform's C and C++ ABIs as closely
87
    /// as we can.
88
    Latest
89
  };
90
91
  enum StructReturnConventionKind {
92
    SRCK_Default,  // No special option was passed.
93
    SRCK_OnStack,  // Small structs on the stack (-fpcc-struct-return).
94
    SRCK_InRegs    // Small structs in registers (-freg-struct-return).
95
  };
96
97
  enum ProfileInstrKind {
98
    ProfileNone,       // Profile instrumentation is turned off.
99
    ProfileClangInstr, // Clang instrumentation to generate execution counts
100
                       // to use with PGO.
101
    ProfileIRInstr,    // IR level PGO instrumentation in LLVM.
102
  };
103
104
  enum EmbedBitcodeKind {
105
    Embed_Off,      // No embedded bitcode.
106
    Embed_All,      // Embed both bitcode and commandline in the output.
107
    Embed_Bitcode,  // Embed just the bitcode in the output.
108
    Embed_Marker    // Embed a marker as a placeholder for bitcode.
109
  };
110
111
  enum SignReturnAddressScope {
112
    None,    // No signing for any function
113
    NonLeaf, // Sign the return address of functions that spill LR
114
    All      // Sign the return address of all functions
115
  };
116
117
  /// The code model to use (-mcmodel).
118
  std::string CodeModel;
119
120
  /// The filename with path we use for coverage data files. The runtime
121
  /// allows further manipulation with the GCOV_PREFIX and GCOV_PREFIX_STRIP
122
  /// environment variables.
123
  std::string CoverageDataFile;
124
125
  /// The filename with path we use for coverage notes files.
126
  std::string CoverageNotesFile;
127
128
  /// The version string to put into coverage files.
129
  char CoverageVersion[4];
130
131
  /// Enable additional debugging information.
132
  std::string DebugPass;
133
134
  /// The string to embed in debug information as the current working directory.
135
  std::string DebugCompilationDir;
136
137
  /// The string to embed in the debug information for the compile unit, if
138
  /// non-empty.
139
  std::string DwarfDebugFlags;
140
141
  std::map<std::string, std::string> DebugPrefixMap;
142
143
  /// The ABI to use for passing floating point arguments.
144
  std::string FloatABI;
145
146
  /// The floating-point denormal mode to use.
147
  std::string FPDenormalMode;
148
149
  /// The float precision limit to use, if non-empty.
150
  std::string LimitFloatPrecision;
151
152
  struct BitcodeFileToLink {
153
    /// The filename of the bitcode file to link in.
154
    std::string Filename;
155
    /// If true, we set attributes functions in the bitcode library according to
156
    /// our CodeGenOptions, much as we set attrs on functions that we generate
157
    /// ourselves.
158
    bool PropagateAttrs = false;
159
    /// If true, we use LLVM module internalizer.
160
    bool Internalize = false;
161
    /// Bitwise combination of llvm::Linker::Flags, passed to the LLVM linker.
162
    unsigned LinkFlags = 0;
163
  };
164
165
  /// The files specified here are linked in to the module before optimizations.
166
  std::vector<BitcodeFileToLink> LinkBitcodeFiles;
167
168
  /// The user provided name for the "main file", if non-empty. This is useful
169
  /// in situations where the input file name does not match the original input
170
  /// file, for example with -save-temps.
171
  std::string MainFileName;
172
173
  /// The name for the split debug info file that we'll break out. This is used
174
  /// in the backend for setting the name in the skeleton cu.
175
  std::string SplitDwarfFile;
176
177
  /// The name of the relocation model to use.
178
  llvm::Reloc::Model RelocationModel;
179
180
  /// The thread model to use
181
  std::string ThreadModel;
182
183
  /// If not an empty string, trap intrinsics are lowered to calls to this
184
  /// function instead of to trap instructions.
185
  std::string TrapFuncName;
186
187
  /// A list of dependent libraries.
188
  std::vector<std::string> DependentLibraries;
189
190
  /// A list of linker options to embed in the object file.
191
  std::vector<std::string> LinkerOptions;
192
193
  /// Name of the profile file to use as output for -fprofile-instr-generate
194
  /// and -fprofile-generate.
195
  std::string InstrProfileOutput;
196
197
  /// Name of the profile file to use with -fprofile-sample-use.
198
  std::string SampleProfileFile;
199
200
  /// Name of the profile file to use as input for -fprofile-instr-use
201
  std::string ProfileInstrumentUsePath;
202
203
  /// Name of the function summary index file to use for ThinLTO function
204
  /// importing.
205
  std::string ThinLTOIndexFile;
206
207
  /// Name of a file that can optionally be written with minimized bitcode
208
  /// to be used as input for the ThinLTO thin link step, which only needs
209
  /// the summary and module symbol table (and not, e.g. any debug metadata).
210
  std::string ThinLinkBitcodeFile;
211
212
  /// Prefix to use for -save-temps output.
213
  std::string SaveTempsFilePrefix;
214
215
  /// Name of file passed with -fcuda-include-gpubinary option to forward to
216
  /// CUDA runtime back-end for incorporating them into host-side object file.
217
  std::string CudaGpuBinaryFileName;
218
219
  /// The name of the file to which the backend should save YAML optimization
220
  /// records.
221
  std::string OptRecordFile;
222
223
  /// Regular expression to select optimizations for which we should enable
224
  /// optimization remarks. Transformation passes whose name matches this
225
  /// expression (and support this feature), will emit a diagnostic
226
  /// whenever they perform a transformation. This is enabled by the
227
  /// -Rpass=regexp flag.
228
  std::shared_ptr<llvm::Regex> OptimizationRemarkPattern;
229
230
  /// Regular expression to select optimizations for which we should enable
231
  /// missed optimization remarks. Transformation passes whose name matches this
232
  /// expression (and support this feature), will emit a diagnostic
233
  /// whenever they tried but failed to perform a transformation. This is
234
  /// enabled by the -Rpass-missed=regexp flag.
235
  std::shared_ptr<llvm::Regex> OptimizationRemarkMissedPattern;
236
237
  /// Regular expression to select optimizations for which we should enable
238
  /// optimization analyses. Transformation passes whose name matches this
239
  /// expression (and support this feature), will emit a diagnostic
240
  /// whenever they want to explain why they decided to apply or not apply
241
  /// a given transformation. This is enabled by the -Rpass-analysis=regexp
242
  /// flag.
243
  std::shared_ptr<llvm::Regex> OptimizationRemarkAnalysisPattern;
244
245
  /// Set of files defining the rules for the symbol rewriting.
246
  std::vector<std::string> RewriteMapFiles;
247
248
  /// Set of sanitizer checks that are non-fatal (i.e. execution should be
249
  /// continued when possible).
250
  SanitizerSet SanitizeRecover;
251
252
  /// Set of sanitizer checks that trap rather than diagnose.
253
  SanitizerSet SanitizeTrap;
254
255
  /// List of backend command-line options for -fembed-bitcode.
256
  std::vector<uint8_t> CmdArgs;
257
258
  /// A list of all -fno-builtin-* function names (e.g., memset).
259
  std::vector<std::string> NoBuiltinFuncs;
260
261
  std::vector<std::string> Reciprocals;
262
263
  /// The preferred width for auto-vectorization transforms. This is intended to
264
  /// override default transforms based on the width of the architected vector
265
  /// registers.
266
  std::string PreferVectorWidth;
267
268
  /// Set of XRay instrumentation kinds to emit.
269
  XRayInstrSet XRayInstrumentationBundle;
270
271
public:
272
  // Define accessors/mutators for code generation options of enumeration type.
273
#define CODEGENOPT(Name, Bits, Default)
274
#define ENUM_CODEGENOPT(Name, Type, Bits, Default) \
275
2.76M
  Type get##Name() const { return static_cast<Type>(Name); } \
clang::CodeGenOptions::getCompressDebugSections() const
Line
Count
Source
275
20.7k
  Type get##Name() const { return static_cast<Type>(Name); } \
clang::CodeGenOptions::getDebuggerTuning() const
Line
Count
Source
275
20.8k
  Type get##Name() const { return static_cast<Type>(Name); } \
clang::CodeGenOptions::getProfileInstr() const
Line
Count
Source
275
1.18M
  Type get##Name() const { return static_cast<Type>(Name); } \
clang::CodeGenOptions::getProfileUse() const
Line
Count
Source
275
78.7k
  Type get##Name() const { return static_cast<Type>(Name); } \
clang::CodeGenOptions::getVecLib() const
Line
Count
Source
275
33.0k
  Type get##Name() const { return static_cast<Type>(Name); } \
clang::CodeGenOptions::getDebugInfo() const
Line
Count
Source
275
659k
  Type get##Name() const { return static_cast<Type>(Name); } \
clang::CodeGenOptions::getEmbedBitcode() const
Line
Count
Source
275
62.1k
  Type get##Name() const { return static_cast<Type>(Name); } \
clang::CodeGenOptions::getSignReturnAddress() const
Line
Count
Source
275
359k
  Type get##Name() const { return static_cast<Type>(Name); } \
clang::CodeGenOptions::getObjCDispatchMethod() const
Line
Count
Source
275
1.23k
  Type get##Name() const { return static_cast<Type>(Name); } \
clang::CodeGenOptions::getDefaultTLSModel() const
Line
Count
Source
275
281
  Type get##Name() const { return static_cast<Type>(Name); } \
clang::CodeGenOptions::getInlining() const
Line
Count
Source
275
333k
  Type get##Name() const { return static_cast<Type>(Name); } \
clang::CodeGenOptions::getStructReturnConvention() const
Line
Count
Source
275
3.06k
  Type get##Name() const { return static_cast<Type>(Name); } \
276
667k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
clang::CodeGenOptions::setCompressDebugSections(llvm::DebugCompressionType)
Line
Count
Source
276
50.1k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
clang::CodeGenOptions::setEmbedBitcode(clang::CodeGenOptions::EmbedBitcodeKind)
Line
Count
Source
276
50.1k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
clang::CodeGenOptions::setObjCDispatchMethod(clang::CodeGenOptions::ObjCDispatchMethodKind)
Line
Count
Source
276
50.7k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
clang::CodeGenOptions::setProfileInstr(clang::CodeGenOptions::ProfileInstrKind)
Line
Count
Source
276
50.2k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
clang::CodeGenOptions::setProfileUse(clang::CodeGenOptions::ProfileInstrKind)
Line
Count
Source
276
50.1k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
clang::CodeGenOptions::setStructReturnConvention(clang::CodeGenOptions::StructReturnConventionKind)
Line
Count
Source
276
50.1k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
clang::CodeGenOptions::setDebugInfo(clang::codegenoptions::DebugInfoKind)
Line
Count
Source
276
53.1k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
clang::CodeGenOptions::setDebuggerTuning(llvm::DebuggerKind)
Line
Count
Source
276
70.2k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
clang::CodeGenOptions::setInlining(clang::CodeGenOptions::InliningMethod)
Line
Count
Source
276
91.4k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
clang::CodeGenOptions::setVecLib(clang::CodeGenOptions::VectorLibrary)
Line
Count
Source
276
50.1k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
clang::CodeGenOptions::setDefaultTLSModel(clang::CodeGenOptions::TLSModel)
Line
Count
Source
276
50.4k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
clang::CodeGenOptions::setSignReturnAddress(clang::CodeGenOptions::SignReturnAddressScope)
Line
Count
Source
276
50.1k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
277
#include "clang/Frontend/CodeGenOptions.def"
278
279
  CodeGenOptions();
280
281
  /// Is this a libc/libm function that is no longer recognized as a
282
  /// builtin because a -fno-builtin-* option has been specified?
283
  bool isNoBuiltinFunc(const char *Name) const;
284
285
24.0k
  const std::vector<std::string> &getNoBuiltinFuncs() const {
286
24.0k
    return NoBuiltinFuncs;
287
24.0k
  }
288
289
  /// Check if Clang profile instrumenation is on.
290
1.16M
  bool hasProfileClangInstr() const {
291
1.16M
    return getProfileInstr() == ProfileClangInstr;
292
1.16M
  }
293
294
  /// Check if IR level profile instrumentation is on.
295
20.6k
  bool hasProfileIRInstr() const {
296
20.6k
    return getProfileInstr() == ProfileIRInstr;
297
20.6k
  }
298
299
  /// Check if Clang profile use is on.
300
16.8k
  bool hasProfileClangUse() const {
301
16.8k
    return getProfileUse() == ProfileClangInstr;
302
16.8k
  }
303
304
  /// Check if IR level profile use is on.
305
20.6k
  bool hasProfileIRUse() const {
306
20.6k
    return getProfileUse() == ProfileIRInstr;
307
20.6k
  }
308
309
};
310
311
}  // end namespace clang
312
313
#endif