LLVM: lib/Target/TargetMachine.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
28using namespace llvm;
29
31 "no-kernel-info-end-lto",
32 cl::desc("remove the kernel-info pass at the end of the full LTO pipeline"),
34
35
36
37
38
46
48
55
58 return false;
59
60
61
62
65
67
68
69 if (!GO)
70 return true;
71
73
75 return Name.consume_front(Prefix) && (Name.empty() || Name[0] == '.');
76 };
77
78
79 if (!GV) {
80
81
82 if (GO->hasSection()) {
83 StringRef Name = GO->getSection();
84 return IsPrefix(Name, ".ltext");
85 }
87 }
88
89 if (GV->isThreadLocal())
90 return false;
91
92
93
94 if (auto CM = GV->getCodeModel()) {
96 return false;
98 return true;
99 }
100
101
102
103
104
105 if (GV->hasSection()) {
106 StringRef Name = GV->getSection();
107 return IsPrefix(Name, ".lbss") || IsPrefix(Name, ".ldata") ||
108 IsPrefix(Name, ".lrodata");
109 }
110
111
114 if (!GV->getValueType()->isSized())
115 return true;
116
117
118 if (GV->isDeclaration() && (GV->getName() == "__ehdr_start" ||
119 GV->getName().starts_with("__start_") ||
120 GV->getName().starts_with("__stop_")))
121 return true;
122
123
124
125
126
127
128
129
130
131 if (!GV->isDeclarationForLinker() &&
133 .isReadOnlyWithRel())
134 return false;
136 uint64_t Size = DL.getTypeAllocSize(GV->getValueType());
138 }
139
140 return false;
141}
142
146
147
148
149
150
151
152
153
154
156#define RESET_OPTION(X, Y) \
157 do { \
158 Options.X = F.getFnAttribute(Y).getValueAsBool(); \
159 } while (0)
160
161 RESET_OPTION(NoInfsFPMath, "no-infs-fp-math");
162 RESET_OPTION(NoNaNsFPMath, "no-nans-fp-math");
163 RESET_OPTION(NoSignedZerosFPMath, "no-signed-zeros-fp-math");
164}
165
166
167
169
183
184
188 llvm_unreachable("getSelectedTLSModel for non-TLS variable");
189 break;
198 }
200}
201
205
206
207
208
209
210
211
212
213
214 if (!GV)
215 return false;
216
217
219 return true;
220
221 if (TT.isOSBinFormatCOFF()) {
222
224 return false;
225
226
227
228
229
230
233 return false;
234
235
236
237
239 return false;
240
241
242 return true;
243 }
244
245 if (TT.isOSBinFormatGOFF())
246 return true;
247
248 if (TT.isOSBinFormatMachO()) {
250 return true;
252 }
253
254 assert(TT.isOSBinFormatELF() || TT.isOSBinFormatWasm() ||
255 TT.isOSBinFormatXCOFF());
256 return false;
257}
258
261
265 bool IsSharedLibrary = RM == Reloc::PIC_ && !IsPIE;
267
269 if (IsSharedLibrary) {
270 if (IsLocal)
272 else
274 } else {
275 if (IsLocal)
277 else
279 }
280
281
283 if (SelectedModel > Model)
284 return SelectedModel;
285
286 return Model;
287}
288
293
296 bool MayAlwaysUsePrivate) const {
298
299
301 return;
302 }
305}
306
309
311 return TargetSymbol;
312
316}
317
324
327 return {INT_MAX, INT_MAX};
328 std::pair<int, int> Ret;
329 if (.consumeInteger(10, Ret.first) && Version.consume_front("."))
330 Version.consumeInteger(10, Ret.second);
331 return Ret;
332}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
Module.h This file contains the declarations for the Module class.
static TLSModel::Model getSelectedTLSModel(const GlobalValue *GV)
Get the IR-specified TLS model for Var.
Definition TargetMachine.cpp:185
#define RESET_OPTION(X, Y)
This pass exposes codegen information to IR-level passes.
A parsed version of the target data layout string in and methods for querying it.
Tagged union holding either a T or a Error.
bool hasPrivateLinkage() const
bool hasExternalWeakLinkage() const
ThreadLocalMode getThreadLocalMode() const
bool hasDLLImportStorageClass() const
bool isDeclarationForLinker() const
Module * getParent()
Get the module that this global value is contained inside of...
LLVM_ABI const GlobalObject * getAliaseeObject() const
bool isStrongDefinitionForLinker() const
Returns true if this global's definition will be the one chosen by the linker.
Context object for machine code objects.
LLVM_ABI MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
MCContext & getContext() const
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
LLVM_ABI void getNameWithPrefix(raw_ostream &OS, const GlobalValue *GV, bool CannotUsePrivateLabel) const
Print the appropriate prefix and the specified global variable's name.
PIELevel::Level getPIELevel() const
Returns the PIE level (small or large model)
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
StringRef - Represent a constant reference to a string, i.e.
Analysis pass providing the TargetTransformInfo.
virtual void getNameWithPrefix(SmallVectorImpl< char > &OutName, const GlobalValue *GV, const TargetMachine &TM) const
Mangler & getMangler() const
static SectionKind getKindForGlobal(const GlobalObject *GO, const TargetMachine &TM)
Classify the specified global variable into a set of target independent categories embodied in Sectio...
virtual MCSymbol * getTargetSymbol(const GlobalValue *GV, const TargetMachine &TM) const
Targets that have a special convention for their symbols could use this hook to return a specialized ...
Triple TargetTriple
Triple string, CPU name, and target feature strings the TargetMachine instance is created with.
std::unique_ptr< const MCAsmInfo > AsmInfo
Contains target specific asm information.
TLSModel::Model getTLSModel(const GlobalValue *GV) const
Returns the TLS model which should be used for the given global variable.
Definition TargetMachine.cpp:262
bool isPositionIndependent() const
Definition TargetMachine.cpp:143
uint64_t getMaxCodeSize() const
Returns the maximum code size possible under the code model.
Definition TargetMachine.cpp:170
const Triple & getTargetTriple() const
bool useTLSDESC() const
Returns true if this target uses TLS Descriptors.
Definition TargetMachine.cpp:260
uint64_t LargeDataThreshold
bool useEmulatedTLS() const
Returns true if this target uses emulated TLS.
Definition TargetMachine.cpp:259
std::unique_ptr< const MCInstrInfo > MII
virtual TargetLoweringObjectFile * getObjFileLowering() const
Reloc::Model getRelocationModel() const
Returns the code generation relocation model.
Definition TargetMachine.cpp:168
virtual TargetTransformInfo getTargetTransformInfo(const Function &F) const
Return a TargetTransformInfo for a given function.
Definition TargetMachine.cpp:290
const DataLayout DL
DataLayout for the target: keep ABI type size and alignment.
bool shouldAssumeDSOLocal(const GlobalValue *GV) const
Definition TargetMachine.cpp:202
virtual Expected< std::unique_ptr< MCStreamer > > createMCStreamer(raw_pwrite_stream &Out, raw_pwrite_stream *DwoOut, CodeGenFileType FileType, MCContext &Ctx)
Definition TargetMachine.cpp:50
static std::pair< int, int > parseBinutilsVersion(StringRef Version)
Definition TargetMachine.cpp:325
std::unique_ptr< const MCSubtargetInfo > STI
TargetIRAnalysis getTargetIRAnalysis() const
Get a TargetIRAnalysis appropriate for the target.
Definition TargetMachine.cpp:318
unsigned RequireStructuredCFG
MCSymbol * getSymbol(const GlobalValue *GV) const
Definition TargetMachine.cpp:307
const Target & TheTarget
The Target that this machine was created for.
CodeModel::Model getCodeModel() const
Returns the code model.
bool isLargeGlobalValue(const GlobalValue *GV) const
Definition TargetMachine.cpp:56
void resetTargetOptions(const Function &F) const
Reset the target options based on the function's attributes.
Definition TargetMachine.cpp:155
TargetMachine(const Target &T, StringRef DataLayoutString, const Triple &TargetTriple, StringRef CPU, StringRef FS, const TargetOptions &Options)
Definition TargetMachine.cpp:39
void getNameWithPrefix(SmallVectorImpl< char > &Name, const GlobalValue *GV, Mangler &Mang, bool MayAlwaysUsePrivate=false) const
Definition TargetMachine.cpp:294
std::unique_ptr< const MCRegisterInfo > MRI
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
Target - Wrapper for Target specific information.
Triple - Helper class for working with autoconf configuration names.
An abstract base class for streams implementations that also support a pwrite operation.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
initializer< Ty > init(const Ty &Val)
This is an optimization pass for GlobalISel generic memory operations.
constexpr uint64_t maxUIntN(uint64_t N)
Gets the maximum value for a N-bit unsigned integer.
decltype(auto) dyn_cast(const From &Val)
dyn_cast - Return the argument parameter cast to the specified type.
FunctionAddr VTableAddr uintptr_t uintptr_t Version
CodeGenFileType
These enums are meant to be passed into addPassesToEmitFile to indicate what type of file to emit,...
bool isa(const From &Val)
isa - Return true if the parameter to the template is an instance of one of the template type argu...
LLVM_ABI llvm:🆑:opt< bool > NoKernelInfoEndLTO
Implement std::hash so that hash_code can be used in STL containers.