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