]> granicus.if.org Git - clang/blob - include/clang/Frontend/CodeGenOptions.h
[PGO] cc1 option name change for profile instrumentation
[clang] / include / clang / Frontend / CodeGenOptions.h
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
17 #include "clang/Basic/Sanitizers.h"
18 #include "clang/Driver/DebugInfoKind.h"
19 #include "llvm/Support/Regex.h"
20 #include <map>
21 #include <memory>
22 #include <string>
23 #include <vector>
24
25 namespace clang {
26
27 /// \brief Bitfields of CodeGenOptions, split out from CodeGenOptions to ensure
28 /// that this large collection of bitfields is a trivial class type.
29 class CodeGenOptionsBase {
30 public:
31 #define CODEGENOPT(Name, Bits, Default) unsigned Name : Bits;
32 #define ENUM_CODEGENOPT(Name, Type, Bits, Default)
33 #include "clang/Frontend/CodeGenOptions.def"
34
35 protected:
36 #define CODEGENOPT(Name, Bits, Default)
37 #define ENUM_CODEGENOPT(Name, Type, Bits, Default) unsigned Name : Bits;
38 #include "clang/Frontend/CodeGenOptions.def"
39 };
40
41 /// CodeGenOptions - Track various options which control how the code
42 /// is optimized and passed to the backend.
43 class CodeGenOptions : public CodeGenOptionsBase {
44 public:
45   enum InliningMethod {
46     NoInlining,         // Perform no inlining whatsoever.
47     NormalInlining,     // Use the standard function inlining pass.
48     OnlyAlwaysInlining  // Only run the always inlining pass.
49   };
50
51   enum VectorLibrary {
52     NoLibrary, // Don't use any vector library.
53     Accelerate // Use the Accelerate framework.
54   };
55
56   enum ObjCDispatchMethodKind {
57     Legacy = 0,
58     NonLegacy = 1,
59     Mixed = 2
60   };
61
62   enum DebuggerKind {
63     DebuggerKindDefault,
64     DebuggerKindGDB,
65     DebuggerKindLLDB,
66     DebuggerKindSCE
67   };
68
69   enum TLSModel {
70     GeneralDynamicTLSModel,
71     LocalDynamicTLSModel,
72     InitialExecTLSModel,
73     LocalExecTLSModel
74   };
75
76   enum FPContractModeKind {
77     FPC_Off,        // Form fused FP ops only where result will not be affected.
78     FPC_On,         // Form fused FP ops according to FP_CONTRACT rules.
79     FPC_Fast        // Aggressively fuse FP ops (E.g. FMA).
80   };
81
82   enum StructReturnConventionKind {
83     SRCK_Default,  // No special option was passed.
84     SRCK_OnStack,  // Small structs on the stack (-fpcc-struct-return).
85     SRCK_InRegs    // Small structs in registers (-freg-struct-return).
86   };
87
88   enum ProfileInstrKind {
89     ProfileNoInstr,    // No instrumentation.
90     ProfileClangInstr  // Clang instrumentation to generate execution counts
91                        // to use with PGO.
92   };
93
94   /// The code model to use (-mcmodel).
95   std::string CodeModel;
96
97   /// The filename with path we use for coverage files. The extension will be
98   /// replaced.
99   std::string CoverageFile;
100
101   /// The version string to put into coverage files.
102   char CoverageVersion[4];
103
104   /// Enable additional debugging information.
105   std::string DebugPass;
106
107   /// The string to embed in debug information as the current working directory.
108   std::string DebugCompilationDir;
109
110   /// The string to embed in the debug information for the compile unit, if
111   /// non-empty.
112   std::string DwarfDebugFlags;
113
114   std::map<std::string, std::string> DebugPrefixMap;
115
116   /// The ABI to use for passing floating point arguments.
117   std::string FloatABI;
118
119   /// The float precision limit to use, if non-empty.
120   std::string LimitFloatPrecision;
121
122   /// The name of the bitcode file to link before optzns.
123   std::vector<std::pair<unsigned, std::string>> LinkBitcodeFiles;
124
125   /// The user provided name for the "main file", if non-empty. This is useful
126   /// in situations where the input file name does not match the original input
127   /// file, for example with -save-temps.
128   std::string MainFileName;
129
130   /// The name for the split debug info file that we'll break out. This is used
131   /// in the backend for setting the name in the skeleton cu.
132   std::string SplitDwarfFile;
133
134   /// The name of the relocation model to use.
135   std::string RelocationModel;
136
137   /// The thread model to use
138   std::string ThreadModel;
139
140   /// If not an empty string, trap intrinsics are lowered to calls to this
141   /// function instead of to trap instructions.
142   std::string TrapFuncName;
143
144   /// A list of command-line options to forward to the LLVM backend.
145   std::vector<std::string> BackendOptions;
146
147   /// A list of dependent libraries.
148   std::vector<std::string> DependentLibraries;
149
150   /// A list of linker options to embed in the object file.
151   std::vector<std::string> LinkerOptions;
152
153   /// Name of the profile file to use as output for -fprofile-instr-generate
154   /// and -fprofile-generate.
155   std::string InstrProfileOutput;
156
157   /// Name of the profile file to use with -fprofile-sample-use.
158   std::string SampleProfileFile;
159
160   /// Name of the profile file to use as input for -fprofile-instr-use
161   std::string InstrProfileInput;
162
163   /// Name of the function summary index file to use for ThinLTO function
164   /// importing.
165   std::string ThinLTOIndexFile;
166
167   /// The EABI version to use
168   std::string EABIVersion;
169
170   /// A list of file names passed with -fcuda-include-gpubinary options to
171   /// forward to CUDA runtime back-end for incorporating them into host-side
172   /// object file.
173   std::vector<std::string> CudaGpuBinaryFileNames;
174
175   /// Regular expression to select optimizations for which we should enable
176   /// optimization remarks. Transformation passes whose name matches this
177   /// expression (and support this feature), will emit a diagnostic
178   /// whenever they perform a transformation. This is enabled by the
179   /// -Rpass=regexp flag.
180   std::shared_ptr<llvm::Regex> OptimizationRemarkPattern;
181
182   /// Regular expression to select optimizations for which we should enable
183   /// missed optimization remarks. Transformation passes whose name matches this
184   /// expression (and support this feature), will emit a diagnostic
185   /// whenever they tried but failed to perform a transformation. This is
186   /// enabled by the -Rpass-missed=regexp flag.
187   std::shared_ptr<llvm::Regex> OptimizationRemarkMissedPattern;
188
189   /// Regular expression to select optimizations for which we should enable
190   /// optimization analyses. Transformation passes whose name matches this
191   /// expression (and support this feature), will emit a diagnostic
192   /// whenever they want to explain why they decided to apply or not apply
193   /// a given transformation. This is enabled by the -Rpass-analysis=regexp
194   /// flag.
195   std::shared_ptr<llvm::Regex> OptimizationRemarkAnalysisPattern;
196
197   /// Set of files definining the rules for the symbol rewriting.
198   std::vector<std::string> RewriteMapFiles;
199
200   /// Set of sanitizer checks that are non-fatal (i.e. execution should be
201   /// continued when possible).
202   SanitizerSet SanitizeRecover;
203
204   /// Set of sanitizer checks that trap rather than diagnose.
205   SanitizerSet SanitizeTrap;
206
207   /// \brief A list of all -fno-builtin-* function names (e.g., memset).
208   std::vector<std::string> NoBuiltinFuncs;
209
210 public:
211   // Define accessors/mutators for code generation options of enumeration type.
212 #define CODEGENOPT(Name, Bits, Default)
213 #define ENUM_CODEGENOPT(Name, Type, Bits, Default) \
214   Type get##Name() const { return static_cast<Type>(Name); } \
215   void set##Name(Type Value) { Name = static_cast<unsigned>(Value); }
216 #include "clang/Frontend/CodeGenOptions.def"
217
218   CodeGenOptions();
219
220   /// \brief Is this a libc/libm function that is no longer recognized as a
221   /// builtin because a -fno-builtin-* option has been specified?
222   bool isNoBuiltinFunc(const char *Name) const;
223
224   const std::vector<std::string> &getNoBuiltinFuncs() const {
225     return NoBuiltinFuncs;
226   }
227
228   /// \brief Check if Clang profile instrumenation is on.
229   bool hasProfileClangInstr() const {
230     return getProfileInstr() == ProfileClangInstr;
231   }
232 };
233
234 }  // end namespace clang
235
236 #endif