Coverage Report

Created: 2020-02-25 14:32

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/include/clang/Basic/CodeGenOptions.h
Line
Count
Source (jump to first uncovered line)
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/ADT/FloatingPointMode.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/Basic/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/Basic/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
    MASSV,      // IBM MASS vector library.
58
    SVML        // Intel short vector math library.
59
  };
60
61
62
  enum ObjCDispatchMethodKind {
63
    Legacy = 0,
64
    NonLegacy = 1,
65
    Mixed = 2
66
  };
67
68
  enum TLSModel {
69
    GeneralDynamicTLSModel,
70
    LocalDynamicTLSModel,
71
    InitialExecTLSModel,
72
    LocalExecTLSModel
73
  };
74
75
  /// Clang versions with different platform ABI conformance.
76
  enum class ClangABI {
77
    /// Attempt to be ABI-compatible with code generated by Clang 3.8.x
78
    /// (SVN r257626). This causes <1 x long long> to be passed in an
79
    /// integer register instead of an SSE register on x64_64.
80
    Ver3_8,
81
82
    /// Attempt to be ABI-compatible with code generated by Clang 4.0.x
83
    /// (SVN r291814). This causes move operations to be ignored when
84
    /// determining whether a class type can be passed or returned directly.
85
    Ver4,
86
87
    /// Conform to the underlying platform's C and C++ ABIs as closely
88
    /// as we can.
89
    Latest
90
  };
91
92
  enum StructReturnConventionKind {
93
    SRCK_Default,  // No special option was passed.
94
    SRCK_OnStack,  // Small structs on the stack (-fpcc-struct-return).
95
    SRCK_InRegs    // Small structs in registers (-freg-struct-return).
96
  };
97
98
  enum ProfileInstrKind {
99
    ProfileNone,       // Profile instrumentation is turned off.
100
    ProfileClangInstr, // Clang instrumentation to generate execution counts
101
                       // to use with PGO.
102
    ProfileIRInstr,    // IR level PGO instrumentation in LLVM.
103
    ProfileCSIRInstr, // IR level PGO context sensitive instrumentation in LLVM.
104
  };
105
106
  enum EmbedBitcodeKind {
107
    Embed_Off,      // No embedded bitcode.
108
    Embed_All,      // Embed both bitcode and commandline in the output.
109
    Embed_Bitcode,  // Embed just the bitcode in the output.
110
    Embed_Marker    // Embed a marker as a placeholder for bitcode.
111
  };
112
113
  enum class SignReturnAddressScope {
114
    None,    // No signing for any function
115
    NonLeaf, // Sign the return address of functions that spill LR
116
    All      // Sign the return address of all functions
117
  };
118
119
  enum class SignReturnAddressKeyValue { AKey, BKey };
120
121
  enum class FramePointerKind {
122
    None,        // Omit all frame pointers.
123
    NonLeaf,     // Keep non-leaf frame pointers.
124
    All,         // Keep all frame pointers.
125
  };
126
127
  /// The code model to use (-mcmodel).
128
  std::string CodeModel;
129
130
  /// The filename with path we use for coverage data files. The runtime
131
  /// allows further manipulation with the GCOV_PREFIX and GCOV_PREFIX_STRIP
132
  /// environment variables.
133
  std::string CoverageDataFile;
134
135
  /// The filename with path we use for coverage notes files.
136
  std::string CoverageNotesFile;
137
138
  /// Regexes separated by a semi-colon to filter the files to instrument.
139
  std::string ProfileFilterFiles;
140
141
  /// Regexes separated by a semi-colon to filter the files to not instrument.
142
  std::string ProfileExcludeFiles;
143
144
  /// The version string to put into coverage files.
145
  char CoverageVersion[4];
146
147
  /// Enable additional debugging information.
148
  std::string DebugPass;
149
150
  /// The string to embed in debug information as the current working directory.
151
  std::string DebugCompilationDir;
152
153
  /// The string to embed in the debug information for the compile unit, if
154
  /// non-empty.
155
  std::string DwarfDebugFlags;
156
157
  /// The string containing the commandline for the llvm.commandline metadata,
158
  /// if non-empty.
159
  std::string RecordCommandLine;
160
161
  std::map<std::string, std::string> DebugPrefixMap;
162
163
  /// The ABI to use for passing floating point arguments.
164
  std::string FloatABI;
165
166
  /// The floating-point denormal mode to use.
167
  llvm::DenormalMode FPDenormalMode;
168
169
  /// The floating-point subnormal mode to use, for float.
170
  llvm::DenormalMode FP32DenormalMode;
171
172
  /// The float precision limit to use, if non-empty.
173
  std::string LimitFloatPrecision;
174
175
  struct BitcodeFileToLink {
176
    /// The filename of the bitcode file to link in.
177
    std::string Filename;
178
    /// If true, we set attributes functions in the bitcode library according to
179
    /// our CodeGenOptions, much as we set attrs on functions that we generate
180
    /// ourselves.
181
    bool PropagateAttrs = false;
182
    /// If true, we use LLVM module internalizer.
183
    bool Internalize = false;
184
    /// Bitwise combination of llvm::Linker::Flags, passed to the LLVM linker.
185
    unsigned LinkFlags = 0;
186
  };
187
188
  /// The files specified here are linked in to the module before optimizations.
189
  std::vector<BitcodeFileToLink> LinkBitcodeFiles;
190
191
  /// The user provided name for the "main file", if non-empty. This is useful
192
  /// in situations where the input file name does not match the original input
193
  /// file, for example with -save-temps.
194
  std::string MainFileName;
195
196
  /// The name for the split debug info file used for the DW_AT_[GNU_]dwo_name
197
  /// attribute in the skeleton CU.
198
  std::string SplitDwarfFile;
199
200
  /// Output filename for the split debug info, not used in the skeleton CU.
201
  std::string SplitDwarfOutput;
202
203
  /// The name of the relocation model to use.
204
  llvm::Reloc::Model RelocationModel;
205
206
  /// The thread model to use
207
  std::string ThreadModel;
208
209
  /// If not an empty string, trap intrinsics are lowered to calls to this
210
  /// function instead of to trap instructions.
211
  std::string TrapFuncName;
212
213
  /// A list of dependent libraries.
214
  std::vector<std::string> DependentLibraries;
215
216
  /// A list of linker options to embed in the object file.
217
  std::vector<std::string> LinkerOptions;
218
219
  /// Name of the profile file to use as output for -fprofile-instr-generate,
220
  /// -fprofile-generate, and -fcs-profile-generate.
221
  std::string InstrProfileOutput;
222
223
  /// Name of the profile file to use with -fprofile-sample-use.
224
  std::string SampleProfileFile;
225
226
  /// Name of the profile file to use as input for -fprofile-instr-use
227
  std::string ProfileInstrumentUsePath;
228
229
  /// Name of the profile remapping file to apply to the profile data supplied
230
  /// by -fprofile-sample-use or -fprofile-instr-use.
231
  std::string ProfileRemappingFile;
232
233
  /// Name of the function summary index file to use for ThinLTO function
234
  /// importing.
235
  std::string ThinLTOIndexFile;
236
237
  /// Name of a file that can optionally be written with minimized bitcode
238
  /// to be used as input for the ThinLTO thin link step, which only needs
239
  /// the summary and module symbol table (and not, e.g. any debug metadata).
240
  std::string ThinLinkBitcodeFile;
241
242
  /// Prefix to use for -save-temps output.
243
  std::string SaveTempsFilePrefix;
244
245
  /// Name of file passed with -fcuda-include-gpubinary option to forward to
246
  /// CUDA runtime back-end for incorporating them into host-side object file.
247
  std::string CudaGpuBinaryFileName;
248
249
  /// The name of the file to which the backend should save YAML optimization
250
  /// records.
251
  std::string OptRecordFile;
252
253
  /// The regex that filters the passes that should be saved to the optimization
254
  /// records.
255
  std::string OptRecordPasses;
256
257
  /// The format used for serializing remarks (default: YAML)
258
  std::string OptRecordFormat;
259
260
  /// The name of the partition that symbols are assigned to, specified with
261
  /// -fsymbol-partition (see https://lld.llvm.org/Partitions.html).
262
  std::string SymbolPartition;
263
264
  /// Regular expression to select optimizations for which we should enable
265
  /// optimization remarks. Transformation passes whose name matches this
266
  /// expression (and support this feature), will emit a diagnostic
267
  /// whenever they perform a transformation. This is enabled by the
268
  /// -Rpass=regexp flag.
269
  std::shared_ptr<llvm::Regex> OptimizationRemarkPattern;
270
271
  /// Regular expression to select optimizations for which we should enable
272
  /// missed optimization remarks. Transformation passes whose name matches this
273
  /// expression (and support this feature), will emit a diagnostic
274
  /// whenever they tried but failed to perform a transformation. This is
275
  /// enabled by the -Rpass-missed=regexp flag.
276
  std::shared_ptr<llvm::Regex> OptimizationRemarkMissedPattern;
277
278
  /// Regular expression to select optimizations for which we should enable
279
  /// optimization analyses. Transformation passes whose name matches this
280
  /// expression (and support this feature), will emit a diagnostic
281
  /// whenever they want to explain why they decided to apply or not apply
282
  /// a given transformation. This is enabled by the -Rpass-analysis=regexp
283
  /// flag.
284
  std::shared_ptr<llvm::Regex> OptimizationRemarkAnalysisPattern;
285
286
  /// Set of files defining the rules for the symbol rewriting.
287
  std::vector<std::string> RewriteMapFiles;
288
289
  /// Set of sanitizer checks that are non-fatal (i.e. execution should be
290
  /// continued when possible).
291
  SanitizerSet SanitizeRecover;
292
293
  /// Set of sanitizer checks that trap rather than diagnose.
294
  SanitizerSet SanitizeTrap;
295
296
  /// List of backend command-line options for -fembed-bitcode.
297
  std::vector<uint8_t> CmdArgs;
298
299
  /// A list of all -fno-builtin-* function names (e.g., memset).
300
  std::vector<std::string> NoBuiltinFuncs;
301
302
  std::vector<std::string> Reciprocals;
303
304
  /// The preferred width for auto-vectorization transforms. This is intended to
305
  /// override default transforms based on the width of the architected vector
306
  /// registers.
307
  std::string PreferVectorWidth;
308
309
  /// Set of XRay instrumentation kinds to emit.
310
  XRayInstrSet XRayInstrumentationBundle;
311
312
  std::vector<std::string> DefaultFunctionAttrs;
313
314
  /// List of dynamic shared object files to be loaded as pass plugins.
315
  std::vector<std::string> PassPlugins;
316
317
public:
318
  // Define accessors/mutators for code generation options of enumeration type.
319
#define CODEGENOPT(Name, Bits, Default)
320
#define ENUM_CODEGENOPT(Name, Type, Bits, Default) \
321
2.69M
  Type get##Name() const { return static_cast<Type>(Name); } \
clang::CodeGenOptions::getEmbedBitcode() const
Line
Count
Source
321
59.0k
  Type get##Name() const { return static_cast<Type>(Name); } \
clang::CodeGenOptions::getProfileUse() const
Line
Count
Source
321
98.8k
  Type get##Name() const { return static_cast<Type>(Name); } \
clang::CodeGenOptions::getDebugInfo() const
Line
Count
Source
321
1.45M
  Type get##Name() const { return static_cast<Type>(Name); } \
clang::CodeGenOptions::getCompressDebugSections() const
Line
Count
Source
321
14.2k
  Type get##Name() const { return static_cast<Type>(Name); } \
clang::CodeGenOptions::getFramePointer() const
Line
Count
Source
321
269k
  Type get##Name() const { return static_cast<Type>(Name); } \
clang::CodeGenOptions::getObjCDispatchMethod() const
Line
Count
Source
321
12.0k
  Type get##Name() const { return static_cast<Type>(Name); } \
clang::CodeGenOptions::getProfileInstr() const
Line
Count
Source
321
576k
  Type get##Name() const { return static_cast<Type>(Name); } \
clang::CodeGenOptions::getStructReturnConvention() const
Line
Count
Source
321
2.45k
  Type get##Name() const { return static_cast<Type>(Name); } \
clang::CodeGenOptions::getDebuggerTuning() const
Line
Count
Source
321
107k
  Type get##Name() const { return static_cast<Type>(Name); } \
clang::CodeGenOptions::getInlining() const
Line
Count
Source
321
38.5k
  Type get##Name() const { return static_cast<Type>(Name); } \
clang::CodeGenOptions::getVecLib() const
Line
Count
Source
321
17.7k
  Type get##Name() const { return static_cast<Type>(Name); } \
clang::CodeGenOptions::getDefaultTLSModel() const
Line
Count
Source
321
477
  Type get##Name() const { return static_cast<Type>(Name); } \
clang::CodeGenOptions::getSignReturnAddress() const
Line
Count
Source
321
25.7k
  Type get##Name() const { return static_cast<Type>(Name); } \
clang::CodeGenOptions::getSignReturnAddressKey() const
Line
Count
Source
321
18.1k
  Type get##Name() const { return static_cast<Type>(Name); } \
322
1.11M
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
clang::CodeGenOptions::setCompressDebugSections(llvm::DebugCompressionType)
Line
Count
Source
322
71.4k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
clang::CodeGenOptions::setFramePointer(clang::CodeGenOptions::FramePointerKind)
Line
Count
Source
322
101k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
clang::CodeGenOptions::setEmbedBitcode(clang::CodeGenOptions::EmbedBitcodeKind)
Line
Count
Source
322
71.4k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
clang::CodeGenOptions::setObjCDispatchMethod(clang::CodeGenOptions::ObjCDispatchMethodKind)
Line
Count
Source
322
71.4k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
clang::CodeGenOptions::setProfileInstr(clang::CodeGenOptions::ProfileInstrKind)
Line
Count
Source
322
71.5k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
clang::CodeGenOptions::setProfileUse(clang::CodeGenOptions::ProfileInstrKind)
Line
Count
Source
322
71.5k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
clang::CodeGenOptions::setStructReturnConvention(clang::CodeGenOptions::StructReturnConventionKind)
Line
Count
Source
322
71.4k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
clang::CodeGenOptions::setDebugInfo(clang::codegenoptions::DebugInfoKind)
Line
Count
Source
322
89.5k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
clang::CodeGenOptions::setDebuggerTuning(llvm::DebuggerKind)
Line
Count
Source
322
90.5k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
clang::CodeGenOptions::setInlining(clang::CodeGenOptions::InliningMethod)
Line
Count
Source
322
116k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
clang::CodeGenOptions::setVecLib(clang::CodeGenOptions::VectorLibrary)
Line
Count
Source
322
71.4k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
clang::CodeGenOptions::setDefaultTLSModel(clang::CodeGenOptions::TLSModel)
Line
Count
Source
322
71.4k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
clang::CodeGenOptions::setSignReturnAddress(clang::CodeGenOptions::SignReturnAddressScope)
Line
Count
Source
322
71.4k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
clang::CodeGenOptions::setSignReturnAddressKey(clang::CodeGenOptions::SignReturnAddressKeyValue)
Line
Count
Source
322
71.4k
  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
323
#include "clang/Basic/CodeGenOptions.def"
324
325
  CodeGenOptions();
326
327
  /// Is this a libc/libm function that is no longer recognized as a
328
  /// builtin because a -fno-builtin-* option has been specified?
329
  bool isNoBuiltinFunc(const char *Name) const;
330
331
0
  const std::vector<std::string> &getNoBuiltinFuncs() const {
332
0
    return NoBuiltinFuncs;
333
0
  }
334
335
  /// Check if Clang profile instrumenation is on.
336
548k
  bool hasProfileClangInstr() const {
337
548k
    return getProfileInstr() == ProfileClangInstr;
338
548k
  }
339
340
  /// Check if IR level profile instrumentation is on.
341
14.0k
  bool hasProfileIRInstr() const {
342
14.0k
    return getProfileInstr() == ProfileIRInstr;
343
14.0k
  }
344
345
  /// Check if CS IR level profile instrumentation is on.
346
14.0k
  bool hasProfileCSIRInstr() const {
347
14.0k
    return getProfileInstr() == ProfileCSIRInstr;
348
14.0k
  }
349
350
  /// Check if Clang profile use is on.
351
25.7k
  bool hasProfileClangUse() const {
352
25.7k
    return getProfileUse() == ProfileClangInstr;
353
25.7k
  }
354
355
  /// Check if IR level profile use is on.
356
14.0k
  bool hasProfileIRUse() const {
357
14.0k
    return getProfileUse() == ProfileIRInstr ||
358
14.0k
           
getProfileUse() == ProfileCSIRInstr14.0k
;
359
14.0k
  }
360
361
  /// Check if CSIR profile use is on.
362
74
  bool hasProfileCSIRUse() const { return getProfileUse() == ProfileCSIRInstr; }
363
364
  /// Check if type and variable info should be emitted.
365
1.36M
  bool hasReducedDebugInfo() const {
366
1.36M
    return getDebugInfo() >= codegenoptions::DebugInfoConstructor;
367
1.36M
  }
368
};
369
370
}  // end namespace clang
371
372
#endif