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