clang  8.0.0svn
CodeGenOptions.h
Go to the documentation of this file.
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 
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.
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.
47 public:
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 
55  NoLibrary, // Don't use any vector library.
56  Accelerate, // Use the Accelerate framework.
57  SVML // Intel short vector math library.
58  };
59 
60 
62  Legacy = 0,
63  NonLegacy = 1,
64  Mixed = 2
65  };
66 
67  enum TLSModel {
71  LocalExecTLSModel
72  };
73 
74  enum DwarfFissionKind { NoFission, SplitFileFission, SingleFileFission };
75 
76  /// Clang versions with different platform ABI conformance.
77  enum class ClangABI {
78  /// Attempt to be ABI-compatible with code generated by Clang 3.8.x
79  /// (SVN r257626). This causes <1 x long long> to be passed in an
80  /// integer register instead of an SSE register on x64_64.
81  Ver3_8,
82 
83  /// Attempt to be ABI-compatible with code generated by Clang 4.0.x
84  /// (SVN r291814). This causes move operations to be ignored when
85  /// determining whether a class type can be passed or returned directly.
86  Ver4,
87 
88  /// Conform to the underlying platform's C and C++ ABIs as closely
89  /// as we can.
90  Latest
91  };
92 
94  SRCK_Default, // No special option was passed.
95  SRCK_OnStack, // Small structs on the stack (-fpcc-struct-return).
96  SRCK_InRegs // Small structs in registers (-freg-struct-return).
97  };
98 
100  ProfileNone, // Profile instrumentation is turned off.
101  ProfileClangInstr, // Clang instrumentation to generate execution counts
102  // to use with PGO.
103  ProfileIRInstr, // IR level PGO instrumentation in LLVM.
104  };
105 
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 
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 SignReturnAddressKeyValue { AKey, BKey };
120 
121  /// The code model to use (-mcmodel).
122  std::string CodeModel;
123 
124  /// The filename with path we use for coverage data files. The runtime
125  /// allows further manipulation with the GCOV_PREFIX and GCOV_PREFIX_STRIP
126  /// environment variables.
127  std::string CoverageDataFile;
128 
129  /// The filename with path we use for coverage notes files.
130  std::string CoverageNotesFile;
131 
132  /// The version string to put into coverage files.
133  char CoverageVersion[4];
134 
135  /// Enable additional debugging information.
136  std::string DebugPass;
137 
138  /// The string to embed in debug information as the current working directory.
139  std::string DebugCompilationDir;
140 
141  /// The string to embed in the debug information for the compile unit, if
142  /// non-empty.
143  std::string DwarfDebugFlags;
144 
145  std::map<std::string, std::string> DebugPrefixMap;
146 
147  /// The ABI to use for passing floating point arguments.
148  std::string FloatABI;
149 
150  /// The floating-point denormal mode to use.
151  std::string FPDenormalMode;
152 
153  /// The float precision limit to use, if non-empty.
154  std::string LimitFloatPrecision;
155 
157  /// The filename of the bitcode file to link in.
158  std::string Filename;
159  /// If true, we set attributes functions in the bitcode library according to
160  /// our CodeGenOptions, much as we set attrs on functions that we generate
161  /// ourselves.
162  bool PropagateAttrs = false;
163  /// If true, we use LLVM module internalizer.
164  bool Internalize = false;
165  /// Bitwise combination of llvm::Linker::Flags, passed to the LLVM linker.
166  unsigned LinkFlags = 0;
167  };
168 
169  /// The files specified here are linked in to the module before optimizations.
170  std::vector<BitcodeFileToLink> LinkBitcodeFiles;
171 
172  /// The user provided name for the "main file", if non-empty. This is useful
173  /// in situations where the input file name does not match the original input
174  /// file, for example with -save-temps.
175  std::string MainFileName;
176 
177  /// The name for the split debug info file that we'll break out. This is used
178  /// in the backend for setting the name in the skeleton cu.
179  std::string SplitDwarfFile;
180 
181  /// The name of the relocation model to use.
182  llvm::Reloc::Model RelocationModel;
183 
184  /// The thread model to use
185  std::string ThreadModel;
186 
187  /// If not an empty string, trap intrinsics are lowered to calls to this
188  /// function instead of to trap instructions.
189  std::string TrapFuncName;
190 
191  /// A list of dependent libraries.
192  std::vector<std::string> DependentLibraries;
193 
194  /// A list of linker options to embed in the object file.
195  std::vector<std::string> LinkerOptions;
196 
197  /// Name of the profile file to use as output for -fprofile-instr-generate
198  /// and -fprofile-generate.
199  std::string InstrProfileOutput;
200 
201  /// Name of the profile file to use with -fprofile-sample-use.
202  std::string SampleProfileFile;
203 
204  /// Name of the profile file to use as input for -fprofile-instr-use
206 
207  /// Name of the profile remapping file to apply to the profile data supplied
208  /// by -fprofile-sample-use or -fprofile-instr-use.
209  std::string ProfileRemappingFile;
210 
211  /// Name of the function summary index file to use for ThinLTO function
212  /// importing.
213  std::string ThinLTOIndexFile;
214 
215  /// Name of a file that can optionally be written with minimized bitcode
216  /// to be used as input for the ThinLTO thin link step, which only needs
217  /// the summary and module symbol table (and not, e.g. any debug metadata).
218  std::string ThinLinkBitcodeFile;
219 
220  /// Prefix to use for -save-temps output.
221  std::string SaveTempsFilePrefix;
222 
223  /// Name of file passed with -fcuda-include-gpubinary option to forward to
224  /// CUDA runtime back-end for incorporating them into host-side object file.
226 
227  /// The name of the file to which the backend should save YAML optimization
228  /// records.
229  std::string OptRecordFile;
230 
231  /// Regular expression to select optimizations for which we should enable
232  /// optimization remarks. Transformation passes whose name matches this
233  /// expression (and support this feature), will emit a diagnostic
234  /// whenever they perform a transformation. This is enabled by the
235  /// -Rpass=regexp flag.
236  std::shared_ptr<llvm::Regex> OptimizationRemarkPattern;
237 
238  /// Regular expression to select optimizations for which we should enable
239  /// missed optimization remarks. Transformation passes whose name matches this
240  /// expression (and support this feature), will emit a diagnostic
241  /// whenever they tried but failed to perform a transformation. This is
242  /// enabled by the -Rpass-missed=regexp flag.
243  std::shared_ptr<llvm::Regex> OptimizationRemarkMissedPattern;
244 
245  /// Regular expression to select optimizations for which we should enable
246  /// optimization analyses. Transformation passes whose name matches this
247  /// expression (and support this feature), will emit a diagnostic
248  /// whenever they want to explain why they decided to apply or not apply
249  /// a given transformation. This is enabled by the -Rpass-analysis=regexp
250  /// flag.
251  std::shared_ptr<llvm::Regex> OptimizationRemarkAnalysisPattern;
252 
253  /// Set of files defining the rules for the symbol rewriting.
254  std::vector<std::string> RewriteMapFiles;
255 
256  /// Set of sanitizer checks that are non-fatal (i.e. execution should be
257  /// continued when possible).
259 
260  /// Set of sanitizer checks that trap rather than diagnose.
262 
263  /// List of backend command-line options for -fembed-bitcode.
264  std::vector<uint8_t> CmdArgs;
265 
266  /// A list of all -fno-builtin-* function names (e.g., memset).
267  std::vector<std::string> NoBuiltinFuncs;
268 
269  std::vector<std::string> Reciprocals;
270 
271  /// The preferred width for auto-vectorization transforms. This is intended to
272  /// override default transforms based on the width of the architected vector
273  /// registers.
274  std::string PreferVectorWidth;
275 
276  /// Set of XRay instrumentation kinds to emit.
278 
279 public:
280  // Define accessors/mutators for code generation options of enumeration type.
281 #define CODEGENOPT(Name, Bits, Default)
282 #define ENUM_CODEGENOPT(Name, Type, Bits, Default) \
283  Type get##Name() const { return static_cast<Type>(Name); } \
284  void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
285 #include "clang/Frontend/CodeGenOptions.def"
286 
287  CodeGenOptions();
288 
289  /// Is this a libc/libm function that is no longer recognized as a
290  /// builtin because a -fno-builtin-* option has been specified?
291  bool isNoBuiltinFunc(const char *Name) const;
292 
293  const std::vector<std::string> &getNoBuiltinFuncs() const {
294  return NoBuiltinFuncs;
295  }
296 
297  /// Check if Clang profile instrumenation is on.
298  bool hasProfileClangInstr() const {
299  return getProfileInstr() == ProfileClangInstr;
300  }
301 
302  /// Check if IR level profile instrumentation is on.
303  bool hasProfileIRInstr() const {
304  return getProfileInstr() == ProfileIRInstr;
305  }
306 
307  /// Check if Clang profile use is on.
308  bool hasProfileClangUse() const {
309  return getProfileUse() == ProfileClangInstr;
310  }
311 
312  /// Check if IR level profile use is on.
313  bool hasProfileIRUse() const {
314  return getProfileUse() == ProfileIRInstr;
315  }
316 
317 };
318 
319 } // end namespace clang
320 
321 #endif
std::string CoverageNotesFile
The filename with path we use for coverage notes files.
std::string ProfileInstrumentUsePath
Name of the profile file to use as input for -fprofile-instr-use.
std::string DwarfDebugFlags
The string to embed in the debug information for the compile unit, if non-empty.
std::string SaveTempsFilePrefix
Prefix to use for -save-temps output.
std::shared_ptr< llvm::Regex > OptimizationRemarkMissedPattern
Regular expression to select optimizations for which we should enable missed optimization remarks...
std::string FPDenormalMode
The floating-point denormal mode to use.
std::string SampleProfileFile
Name of the profile file to use with -fprofile-sample-use.
std::vector< std::string > Reciprocals
std::vector< std::string > RewriteMapFiles
Set of files defining the rules for the symbol rewriting.
Bitfields of CodeGenOptions, split out from CodeGenOptions to ensure that this large collection of bi...
std::string SplitDwarfFile
The name for the split debug info file that we&#39;ll break out.
std::string DebugPass
Enable additional debugging information.
SanitizerSet SanitizeRecover
Set of sanitizer checks that are non-fatal (i.e.
Defines the clang::SanitizerKind enum.
std::map< std::string, std::string > DebugPrefixMap
std::vector< uint8_t > CmdArgs
List of backend command-line options for -fembed-bitcode.
std::string CodeModel
The code model to use (-mcmodel).
ClangABI
Clang versions with different platform ABI conformance.
std::string FloatABI
The ABI to use for passing floating point arguments.
bool hasProfileClangUse() const
Check if Clang profile use is on.
std::string ThreadModel
The thread model to use.
std::vector< std::string > DependentLibraries
A list of dependent libraries.
std::string ProfileRemappingFile
Name of the profile remapping file to apply to the profile data supplied by -fprofile-sample-use or -...
std::vector< std::string > NoBuiltinFuncs
A list of all -fno-builtin-* function names (e.g., memset).
std::string LimitFloatPrecision
The float precision limit to use, if non-empty.
std::shared_ptr< llvm::Regex > OptimizationRemarkPattern
Regular expression to select optimizations for which we should enable optimization remarks...
Defines the clang::XRayInstrKind enum.
SanitizerSet SanitizeTrap
Set of sanitizer checks that trap rather than diagnose.
std::shared_ptr< llvm::Regex > OptimizationRemarkAnalysisPattern
Regular expression to select optimizations for which we should enable optimization analyses...
XRayInstrSet XRayInstrumentationBundle
Set of XRay instrumentation kinds to emit.
std::vector< BitcodeFileToLink > LinkBitcodeFiles
The files specified here are linked in to the module before optimizations.
std::string ThinLTOIndexFile
Name of the function summary index file to use for ThinLTO function importing.
std::string CudaGpuBinaryFileName
Name of file passed with -fcuda-include-gpubinary option to forward to CUDA runtime back-end for inco...
Dataflow Directional Tag Classes.
std::string PreferVectorWidth
The preferred width for auto-vectorization transforms.
llvm::Reloc::Model RelocationModel
The name of the relocation model to use.
bool hasProfileIRUse() const
Check if IR level profile use is on.
std::string DebugCompilationDir
The string to embed in debug information as the current working directory.
bool hasProfileClangInstr() const
Check if Clang profile instrumenation is on.
std::string CoverageDataFile
The filename with path we use for coverage data files.
std::vector< std::string > LinkerOptions
A list of linker options to embed in the object file.
CodeGenOptions - Track various options which control how the code is optimized and passed to the back...
std::string MainFileName
The user provided name for the "main file", if non-empty.
bool hasProfileIRInstr() const
Check if IR level profile instrumentation is on.
const std::vector< std::string > & getNoBuiltinFuncs() const
std::string InstrProfileOutput
Name of the profile file to use as output for -fprofile-instr-generate and -fprofile-generate.
std::string TrapFuncName
If not an empty string, trap intrinsics are lowered to calls to this function instead of to trap inst...
std::string OptRecordFile
The name of the file to which the backend should save YAML optimization records.
std::string ThinLinkBitcodeFile
Name of a file that can optionally be written with minimized bitcode to be used as input for the Thin...