Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/clang/include/clang/Basic/CodeGenOptions.h
Line
Count
Source
1
//===--- CodeGenOptions.h ---------------------------------------*- C++ -*-===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
//
9
//  This file defines the CodeGenOptions interface.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#ifndef LLVM_CLANG_BASIC_CODEGENOPTIONS_H
14
#define LLVM_CLANG_BASIC_CODEGENOPTIONS_H
15
16
#include "clang/Basic/DebugInfoOptions.h"
17
#include "clang/Basic/Sanitizers.h"
18
#include "clang/Basic/XRayInstr.h"
19
#include "llvm/Support/CodeGen.h"
20
#include "llvm/Support/Regex.h"
21
#include "llvm/Target/TargetOptions.h"
22
#include <map>
23
#include <memory>
24
#include <string>
25
#include <vector>
26
27
namespace clang {
28
29
/// Bitfields of CodeGenOptions, split out from CodeGenOptions to ensure
30
/// that this large collection of bitfields is a trivial class type.
31
class CodeGenOptionsBase {
32
public:
33
#define CODEGENOPT(Name, Bits, Default) unsigned Name : Bits;
34
#define ENUM_CODEGENOPT(Name, Type, Bits, Default)
35
#include "clang/Basic/CodeGenOptions.def"
36
37
protected:
38
#define CODEGENOPT(Name, Bits, Default)
39
#define ENUM_CODEGENOPT(Name, Type, Bits, Default) unsigned Name : Bits;
40
#include "clang/Basic/CodeGenOptions.def"
41
};
42
43
/// CodeGenOptions - Track various options which control how the code
44
/// is optimized and passed to the backend.
45
class CodeGenOptions : public CodeGenOptionsBase {
46
public:
47
  enum InliningMethod {
48
    NormalInlining,     // Use the standard function inlining pass.
49
    OnlyHintInlining,   // Inline only (implicitly) hinted functions.
50
    OnlyAlwaysInlining  // Only run the always inlining pass.
51
  };
52
53
  enum VectorLibrary {
54
    NoLibrary,  // Don't use any vector library.
55
    Accelerate, // Use the Accelerate framework.
56
    MASSV,      // IBM MASS vector library.
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
    ProfileCSIRInstr, // IR level PGO context sensitive instrumentation in LLVM.
103
  };
104
105
  enum EmbedBitcodeKind {
106
    Embed_Off,      // No embedded bitcode.
107
    Embed_All,      // Embed both bitcode and commandline in the output.
108
    Embed_Bitcode,  // Embed just the bitcode in the output.
109
    Embed_Marker    // Embed a marker as a placeholder for bitcode.
110
  };
111
112
  enum SignReturnAddressScope {
113
    None,    // No signing for any function
114
    NonLeaf, // Sign the return address of functions that spill LR
115
    All      // Sign the return address of all functions
116
  };
117
118
  enum SignReturnAddressKeyValue { AKey, BKey };
119
120
  enum class FramePointerKind {
121
    None,        // Omit all frame pointers.
122
    NonLeaf,     // Keep non-leaf frame pointers.
123
    All,         // Keep all frame pointers.
124
  };
125
126
  /// The code model to use (-mcmodel).
127
  std::string CodeModel;
128
129
  /// The filename with path we use for coverage data files. The runtime
130
  /// allows further manipulation with the GCOV_PREFIX and GCOV_PREFIX_STRIP
131
  /// environment variables.
132
  std::string CoverageDataFile;
133
134
  /// The filename with path we use for coverage notes files.
135
  std::string CoverageNotesFile;
136
137
  /// Regexes separated by a semi-colon to filter the files to instrument.
138
  std::string ProfileFilterFiles;
139
140
  /// Regexes separated by a semi-colon to filter the files to not instrument.
141
  std::string ProfileExcludeFiles;
142
143
  /// The version string to put into coverage files.
144
  char CoverageVersion[4];
145
146
  /// Enable additional debugging information.
147
  std::string DebugPass;
148
149
  /// The string to embed in debug information as the current working directory.
150
  std::string DebugCompilationDir;
151
152
  /// The string to embed in the debug information for the compile unit, if
153
  /// non-empty.
154
  std::string DwarfDebugFlags;
155
156
  /// The string containing the commandline for the llvm.commandline metadata,
157
  /// if non-empty.
158
  std::string RecordCommandLine;
159
160
  std::map<std::string, std::string> DebugPrefixMap;
161
162
  /// The ABI to use for passing floating point arguments.
163
  std::string FloatABI;
164
165
  /// The floating-point denormal mode to use.
166
  std::string FPDenormalMode;
167
168
  /// The float precision limit to use, if non-empty.
169
  std::string LimitFloatPrecision;
170
171
  struct BitcodeFileToLink {
172
    /// The filename of the bitcode file to link in.
173
    std::string Filename;
174
    /// If true, we set attributes functions in the bitcode library according to
175
    /// our CodeGenOptions, much as we set attrs on functions that we generate
176
    /// ourselves.
177
    bool PropagateAttrs = false;
178
    /// If true, we use LLVM module internalizer.
179
    bool Internalize = false;
180
    /// Bitwise combination of llvm::Linker::Flags, passed to the LLVM linker.
181
    unsigned LinkFlags = 0;
182
  };
183
184
  /// The files specified here are linked in to the module before optimizations.
185
  std::vector<BitcodeFileToLink> LinkBitcodeFiles;
186
187
  /// The user provided name for the "main file", if non-empty. This is useful
188
  /// in situations where the input file name does not match the original input
189
  /// file, for example with -save-temps.
190
  std::string MainFileName;
191
192
  /// The name for the split debug info file used for the DW_AT_[GNU_]dwo_name
193
  /// attribute in the skeleton CU.
194
  std::string SplitDwarfFile;
195
196
  /// Output filename for the split debug info, not used in the skeleton CU.
197
  std::string SplitDwarfOutput;
198
199
  /// The name of the relocation model to use.
200
  llvm::Reloc::Model RelocationModel;
201
202
  /// The thread model to use
203
  std::string ThreadModel;
204
205
  /// If not an empty string, trap intrinsics are lowered to calls to this
206
  /// function instead of to trap instructions.
207
  std::string TrapFuncName;
208
209
  /// A list of dependent libraries.
210
  std::vector<std::string> DependentLibraries;
211
212
  /// A list of linker options to embed in the object file.
213
  std::vector<std::string> LinkerOptions;
214
215
  /// Name of the profile file to use as output for -fprofile-instr-generate,
216
  /// -fprofile-generate, and -fcs-profile-generate.
217
  std::string InstrProfileOutput;
218
219
  /// Name of the profile file to use with -fprofile-sample-use.
220
  std::string SampleProfileFile;
221
222
  /// Name of the profile file to use as input for -fprofile-instr-use
223
  std::string ProfileInstrumentUsePath;
224
225
  /// Name of the profile remapping file to apply to the profile data supplied
226
  /// by -fprofile-sample-use or -fprofile-instr-use.
227
  std::string ProfileRemappingFile;
228
229
  /// Name of the function summary index file to use for ThinLTO function
230
  /// importing.
231
  std::string ThinLTOIndexFile;
232
233
  /// Name of a file that can optionally be written with minimized bitcode
234
  /// to be used as input for the ThinLTO thin link step, which only needs
235
  /// the summary and module symbol table (and not, e.g. any debug metadata).
236
  std::string ThinLinkBitcodeFile;
237
238
  /// Prefix to use for -save-temps output.
239
  std::string SaveTempsFilePrefix;
240
241
  /// Name of file passed with -fcuda-include-gpubinary option to forward to
242
  /// CUDA runtime back-end for incorporating them into host-side object file.
243
  std::string CudaGpuBinaryFileName;
244
245
  /// The name of the file to which the backend should save YAML optimization
246
  /// records.
247
  std::string OptRecordFile;
248
249
  /// The regex that filters the passes that should be saved to the optimization
250
  /// records.
251
  std::string OptRecordPasses;
252
253
  /// The format used for serializing remarks (default: YAML)
254
  std::string OptRecordFormat;
255
256
  /// The name of the partition that symbols are assigned to, specified with
257
  /// -fsymbol-partition (see https://lld.llvm.org/Partitions.html).
258
  std::string SymbolPartition;
259
260
  /// Regular expression to select optimizations for which we should enable
261
  /// optimization remarks. Transformation passes whose name matches this
262
  /// expression (and support this feature), will emit a diagnostic
263
  /// whenever they perform a transformation. This is enabled by the
264
  /// -Rpass=regexp flag.
265
  std::shared_ptr<llvm::Regex> OptimizationRemarkPattern;
266
267
  /// Regular expression to select optimizations for which we should enable
268
  /// missed optimization remarks. Transformation passes whose name matches this
269
  /// expression (and support this feature), will emit a diagnostic
270
  /// whenever they tried but failed to perform a transformation. This is
271
  /// enabled by the -Rpass-missed=regexp flag.
272
  std::shared_ptr<llvm::Regex> OptimizationRemarkMissedPattern;
273
274
  /// Regular expression to select optimizations for which we should enable
275
  /// optimization analyses. Transformation passes whose name matches this
276
  /// expression (and support this feature), will emit a diagnostic
277
  /// whenever they want to explain why they decided to apply or not apply
278
  /// a given transformation. This is enabled by the -Rpass-analysis=regexp
279
  /// flag.
280
  std::shared_ptr<llvm::Regex> OptimizationRemarkAnalysisPattern;
281
282
  /// Set of files defining the rules for the symbol rewriting.
283
  std::vector<std::string> RewriteMapFiles;
284
285
  /// Set of sanitizer checks that are non-fatal (i.e. execution should be
286
  /// continued when possible).
287
  SanitizerSet SanitizeRecover;
288
289
  /// Set of sanitizer checks that trap rather than diagnose.
290
  SanitizerSet SanitizeTrap;
291
292
  /// List of backend command-line options for -fembed-bitcode.
293
  std::vector<uint8_t> CmdArgs;
294
295
  /// A list of all -fno-builtin-* function names (e.g., memset).
296
  std::vector<std::string> NoBuiltinFuncs;
297
298
  std::vector<std::string> Reciprocals;
299
300
  /// The preferred width for auto-vectorization transforms. This is intended to
301
  /// override default transforms based on the width of the architected vector
302
  /// registers.
303
  std::string PreferVectorWidth;
304
305
  /// Set of XRay instrumentation kinds to emit.
306
  XRayInstrSet XRayInstrumentationBundle;
307
308
  std::vector<std::string> DefaultFunctionAttrs;
309
310
  /// List of dynamic shared object files to be loaded as pass plugins.
311
  std::vector<std::string> PassPlugins;
312
313
public:
314
  // Define accessors/mutators for code generation options of enumeration type.
315
#define CODEGENOPT(Name, Bits, Default)
316
#define ENUM_CODEGENOPT(Name, Type, Bits, Default) \
317
3.48M
  Type get##Name() const { return static_cast<Type>(Name); } \
clang::CodeGenOptions::getCompressDebugSections() const
Line
Count
Source
317
21.4k
  Type get##Name() const { return static_cast<Type>(Name); } \
clang::CodeGenOptions::getFramePointer() const
Line
Count
Source
317
464k
  Type get##Name() const { return static_cast<Type>(Name); } \
clang::CodeGenOptions::getEmbedBitcode() const
Line
Count
Source
317
67.0k
  Type get##Name() const { return static_cast<Type>(Name); } \
clang::CodeGenOptions::getObjCDispatchMethod() const
Line
Count
Source
317
1.35k
  Type get##Name() const { return static_cast<Type>(Name); } \
clang::CodeGenOptions::getProfileInstr() const
Line
Count
Source
317
1.25M
  Type get##Name() const { return static_cast<Type>(Name); } \
clang::CodeGenOptions::getProfileUse() const
Line
Count
Source
317
105k
  Type get##Name() const { return static_cast<Type>(Name); } \
clang::CodeGenOptions::getStructReturnConvention() const
Line
Count
Source
317
2.72k
  Type get##Name() const { return static_cast<Type>(Name); } \
clang::CodeGenOptions::getDebugInfo() const
Line
Count
Source
317
668k
  Type get##Name() const { return static_cast<Type>(Name); } \
clang::CodeGenOptions::getDebuggerTuning() const
Line
Count
Source
317
21.6k
  Type get##Name() const { return static_cast<Type>(Name); } \
clang::CodeGenOptions::getInlining() const
Line
Count
Source
317
472k
  Type get##Name() const { return static_cast<Type>(Name); } \
clang::CodeGenOptions::getVecLib() const
Line
Count
Source
317
33.5k
  Type get##Name() const { return static_cast<Type>(Name); } \
clang::CodeGenOptions::getDefaultTLSModel() const
Line
Count
Source
317
474
  Type get##Name() const { return static_cast<Type>(Name); } \
clang::CodeGenOptions::getSignReturnAddress() const
Line
Count
Source
317
370k
  Type get##Name() const { return static_cast<Type>(Name); } \
clang::CodeGenOptions::getSignReturnAddressKey() const
Line
Count
Source
317
78
  Type get##Name() const { return static_cast<Type>(Name); } \
318
890k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
clang::CodeGenOptions::setCompressDebugSections(llvm::DebugCompressionType)
Line
Count
Source
318
56.8k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
clang::CodeGenOptions::setFramePointer(clang::CodeGenOptions::FramePointerKind)
Line
Count
Source
318
79.3k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
clang::CodeGenOptions::setEmbedBitcode(clang::CodeGenOptions::EmbedBitcodeKind)
Line
Count
Source
318
56.8k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
clang::CodeGenOptions::setObjCDispatchMethod(clang::CodeGenOptions::ObjCDispatchMethodKind)
Line
Count
Source
318
57.4k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
clang::CodeGenOptions::setProfileInstr(clang::CodeGenOptions::ProfileInstrKind)
Line
Count
Source
318
56.9k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
clang::CodeGenOptions::setProfileUse(clang::CodeGenOptions::ProfileInstrKind)
Line
Count
Source
318
56.8k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
clang::CodeGenOptions::setStructReturnConvention(clang::CodeGenOptions::StructReturnConventionKind)
Line
Count
Source
318
56.8k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
clang::CodeGenOptions::setDebugInfo(clang::codegenoptions::DebugInfoKind)
Line
Count
Source
318
59.8k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
clang::CodeGenOptions::setDebuggerTuning(llvm::DebuggerKind)
Line
Count
Source
318
79.2k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
clang::CodeGenOptions::setInlining(clang::CodeGenOptions::InliningMethod)
Line
Count
Source
318
102k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
clang::CodeGenOptions::setVecLib(clang::CodeGenOptions::VectorLibrary)
Line
Count
Source
318
56.8k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
clang::CodeGenOptions::setDefaultTLSModel(clang::CodeGenOptions::TLSModel)
Line
Count
Source
318
57.0k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
clang::CodeGenOptions::setSignReturnAddress(clang::CodeGenOptions::SignReturnAddressScope)
Line
Count
Source
318
56.8k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
clang::CodeGenOptions::setSignReturnAddressKey(clang::CodeGenOptions::SignReturnAddressKeyValue)
Line
Count
Source
318
56.8k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
319
#include "clang/Basic/CodeGenOptions.def"
320
321
  CodeGenOptions();
322
323
  /// Is this a libc/libm function that is no longer recognized as a
324
  /// builtin because a -fno-builtin-* option has been specified?
325
  bool isNoBuiltinFunc(const char *Name) const;
326
327
24.8k
  const std::vector<std::string> &getNoBuiltinFuncs() const {
328
24.8k
    return NoBuiltinFuncs;
329
24.8k
  }
330
331
  /// Check if Clang profile instrumenation is on.
332
1.20M
  bool hasProfileClangInstr() const {
333
1.20M
    return getProfileInstr() == ProfileClangInstr;
334
1.20M
  }
335
336
  /// Check if IR level profile instrumentation is on.
337
21.2k
  bool hasProfileIRInstr() const {
338
21.2k
    return getProfileInstr() == ProfileIRInstr;
339
21.2k
  }
340
341
  /// Check if CS IR level profile instrumentation is on.
342
21.3k
  bool hasProfileCSIRInstr() const {
343
21.3k
    return getProfileInstr() == ProfileCSIRInstr;
344
21.3k
  }
345
346
  /// Check if Clang profile use is on.
347
17.6k
  bool hasProfileClangUse() const {
348
17.6k
    return getProfileUse() == ProfileClangInstr;
349
17.6k
  }
350
351
  /// Check if IR level profile use is on.
352
21.2k
  bool hasProfileIRUse() const {
353
21.2k
    return getProfileUse() == ProfileIRInstr ||
354
21.2k
           
getProfileUse() == ProfileCSIRInstr21.2k
;
355
21.2k
  }
356
357
  /// Check if CSIR profile use is on.
358
46
  bool hasProfileCSIRUse() const { return getProfileUse() == ProfileCSIRInstr; }
359
};
360
361
}  // end namespace clang
362
363
#endif