LLVM  13.0.0git
Globals.cpp
Go to the documentation of this file.
1 //===-- Globals.cpp - Implement the GlobalValue & GlobalVariable class ----===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements the GlobalValue & GlobalVariable classes for the IR
10 // library.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "LLVMContextImpl.h"
15 #include "llvm/ADT/SmallPtrSet.h"
16 #include "llvm/ADT/Triple.h"
17 #include "llvm/IR/ConstantRange.h"
18 #include "llvm/IR/Constants.h"
19 #include "llvm/IR/DerivedTypes.h"
20 #include "llvm/IR/GlobalAlias.h"
21 #include "llvm/IR/GlobalValue.h"
22 #include "llvm/IR/GlobalVariable.h"
23 #include "llvm/IR/Module.h"
24 #include "llvm/IR/Operator.h"
25 #include "llvm/Support/Error.h"
27 using namespace llvm;
28 
29 //===----------------------------------------------------------------------===//
30 // GlobalValue Class
31 //===----------------------------------------------------------------------===//
32 
33 // GlobalValue should be a Constant, plus a type, a module, some flags, and an
34 // intrinsic ID. Add an assert to prevent people from accidentally growing
35 // GlobalValue while adding flags.
36 static_assert(sizeof(GlobalValue) ==
37  sizeof(Constant) + 2 * sizeof(void *) + 2 * sizeof(unsigned),
38  "unexpected GlobalValue size growth");
39 
40 // GlobalObject adds a comdat.
41 static_assert(sizeof(GlobalObject) == sizeof(GlobalValue) + sizeof(void *),
42  "unexpected GlobalObject size growth");
43 
45  if (const Function *F = dyn_cast<Function>(this))
46  return F->isMaterializable();
47  return false;
48 }
50  return getParent()->materialize(this);
51 }
52 
53 /// Override destroyConstantImpl to make sure it doesn't get called on
54 /// GlobalValue's because they shouldn't be treated like other constants.
55 void GlobalValue::destroyConstantImpl() {
56  llvm_unreachable("You can't GV->destroyConstantImpl()!");
57 }
58 
59 Value *GlobalValue::handleOperandChangeImpl(Value *From, Value *To) {
60  llvm_unreachable("Unsupported class for handleOperandChange()!");
61 }
62 
63 /// copyAttributesFrom - copy all additional attributes (those not needed to
64 /// create a GlobalValue) from the GlobalValue Src to this one.
70  setDSOLocal(Src->isDSOLocal());
71  setPartition(Src->getPartition());
72 }
73 
75  switch (getValueID()) {
76 #define HANDLE_GLOBAL_VALUE(NAME) \
77  case Value::NAME##Val: \
78  return static_cast<NAME *>(this)->removeFromParent();
79 #include "llvm/IR/Value.def"
80  default:
81  break;
82  }
83  llvm_unreachable("not a global");
84 }
85 
87  switch (getValueID()) {
88 #define HANDLE_GLOBAL_VALUE(NAME) \
89  case Value::NAME##Val: \
90  return static_cast<NAME *>(this)->eraseFromParent();
91 #include "llvm/IR/Value.def"
92  default:
93  break;
94  }
95  llvm_unreachable("not a global");
96 }
97 
100  return true;
101  return getParent() && getParent()->getSemanticInterposition() &&
102  !isDSOLocal();
103 }
104 
106  // See AsmPrinter::getSymbolPreferLocal().
107  return hasDefaultVisibility() &&
109  !isa<GlobalIFunc>(this) && !hasComdat();
110 }
111 
113  PointerType *PtrTy = getType();
114  return PtrTy->getAddressSpace();
115 }
116 
118  assert((!Align || *Align <= MaximumAlignment) &&
119  "Alignment is greater than MaximumAlignment!");
120  unsigned AlignmentData = encode(Align);
121  unsigned OldData = getGlobalValueSubClassData();
122  setGlobalValueSubClassData((OldData & ~AlignmentMask) | AlignmentData);
124  "Alignment representation error!");
125 }
126 
130  setSection(Src->getSection());
131 }
132 
135  StringRef FileName) {
136 
137  // Value names may be prefixed with a binary '1' to indicate
138  // that the backend should not modify the symbols due to any platform
139  // naming convention. Do not include that '1' in the PGO profile name.
140  if (Name[0] == '\1')
141  Name = Name.substr(1);
142 
143  std::string NewName = std::string(Name);
145  // For local symbols, prepend the main file name to distinguish them.
146  // Do not include the full path in the file name since there's no guarantee
147  // that it will stay the same, e.g., if the files are checked out from
148  // version control in different locations.
149  if (FileName.empty())
150  NewName = NewName.insert(0, "<unknown>:");
151  else
152  NewName = NewName.insert(0, FileName.str() + ":");
153  }
154  return NewName;
155 }
156 
157 std::string GlobalValue::getGlobalIdentifier() const {
159  getParent()->getSourceFileName());
160 }
161 
163  if (auto *GA = dyn_cast<GlobalAlias>(this)) {
164  // In general we cannot compute this at the IR level, but we try.
165  if (const GlobalObject *GO = GA->getBaseObject())
166  return GO->getSection();
167  return "";
168  }
169  return cast<GlobalObject>(this)->getSection();
170 }
171 
173  if (auto *GA = dyn_cast<GlobalAlias>(this)) {
174  // In general we cannot compute this at the IR level, but we try.
175  if (const GlobalObject *GO = GA->getBaseObject())
176  return const_cast<GlobalObject *>(GO)->getComdat();
177  return nullptr;
178  }
179  // ifunc and its resolver are separate things so don't use resolver comdat.
180  if (isa<GlobalIFunc>(this))
181  return nullptr;
182  return cast<GlobalObject>(this)->getComdat();
183 }
184 
186  if (!hasPartition())
187  return "";
188  return getContext().pImpl->GlobalValuePartitions[this];
189 }
190 
192  // Do nothing if we're clearing the partition and it is already empty.
193  if (!hasPartition() && S.empty())
194  return;
195 
196  // Get or create a stable partition name string and put it in the table in the
197  // context.
198  if (!S.empty())
199  S = getContext().pImpl->Saver.save(S);
201 
202  // Update the HasPartition field. Setting the partition to the empty string
203  // means this global no longer has a partition.
204  HasPartition = !S.empty();
205 }
206 
207 StringRef GlobalObject::getSectionImpl() const {
208  assert(hasSection());
209  return getContext().pImpl->GlobalObjectSections[this];
210 }
211 
213  // Do nothing if we're clearing the section and it is already empty.
214  if (!hasSection() && S.empty())
215  return;
216 
217  // Get or create a stable section name string and put it in the table in the
218  // context.
219  if (!S.empty())
220  S = getContext().pImpl->Saver.save(S);
222 
223  // Update the HasSectionHashEntryBit. Setting the section to the empty string
224  // means this global no longer has a section.
225  setGlobalObjectFlag(HasSectionHashEntryBit, !S.empty());
226 }
227 
229  // Globals are definitions if they have an initializer.
230  if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(this))
231  return GV->getNumOperands() == 0;
232 
233  // Functions are definitions if they have a body.
234  if (const Function *F = dyn_cast<Function>(this))
235  return F->empty() && !F->isMaterializable();
236 
237  // Aliases and ifuncs are always definitions.
238  assert(isa<GlobalIndirectSymbol>(this));
239  return false;
240 }
241 
243  // Firstly, can only increase the alignment of a global if it
244  // is a strong definition.
246  return false;
247 
248  // It also has to either not have a section defined, or, not have
249  // alignment specified. (If it is assigned a section, the global
250  // could be densely packed with other objects in the section, and
251  // increasing the alignment could cause padding issues.)
252  if (hasSection() && getAlignment() > 0)
253  return false;
254 
255  // On ELF platforms, we're further restricted in that we can't
256  // increase the alignment of any variable which might be emitted
257  // into a shared library, and which is exported. If the main
258  // executable accesses a variable found in a shared-lib, the main
259  // exe actually allocates memory for and exports the symbol ITSELF,
260  // overriding the symbol found in the library. That is, at link
261  // time, the observed alignment of the variable is copied into the
262  // executable binary. (A COPY relocation is also generated, to copy
263  // the initial data from the shadowed variable in the shared-lib
264  // into the location in the main binary, before running code.)
265  //
266  // And thus, even though you might think you are defining the
267  // global, and allocating the memory for the global in your object
268  // file, and thus should be able to set the alignment arbitrarily,
269  // that's not actually true. Doing so can cause an ABI breakage; an
270  // executable might have already been built with the previous
271  // alignment of the variable, and then assuming an increased
272  // alignment will be incorrect.
273 
274  // Conservatively assume ELF if there's no parent pointer.
275  bool isELF =
277  if (isELF && !isDSOLocal())
278  return false;
279 
280  return true;
281 }
282 
284  if (auto *GO = dyn_cast<GlobalObject>(this))
285  return GO;
286  if (auto *GA = dyn_cast<GlobalIndirectSymbol>(this))
287  return GA->getBaseObject();
288  return nullptr;
289 }
290 
292  auto *GO = dyn_cast<GlobalObject>(this);
293  if (!GO)
294  return false;
295 
296  return GO->getMetadata(LLVMContext::MD_absolute_symbol);
297 }
298 
300  auto *GO = dyn_cast<GlobalObject>(this);
301  if (!GO)
302  return None;
303 
304  MDNode *MD = GO->getMetadata(LLVMContext::MD_absolute_symbol);
305  if (!MD)
306  return None;
307 
308  return getConstantRangeFromMetadata(*MD);
309 }
310 
312  if (!hasLinkOnceODRLinkage())
313  return false;
314 
315  // We assume that anyone who sets global unnamed_addr on a non-constant
316  // knows what they're doing.
317  if (hasGlobalUnnamedAddr())
318  return true;
319 
320  // If it is a non constant variable, it needs to be uniqued across shared
321  // objects.
322  if (auto *Var = dyn_cast<GlobalVariable>(this))
323  if (!Var->isConstant())
324  return false;
325 
327 }
328 
329 //===----------------------------------------------------------------------===//
330 // GlobalVariable Implementation
331 //===----------------------------------------------------------------------===//
332 
334  Constant *InitVal, const Twine &Name,
335  ThreadLocalMode TLMode, unsigned AddressSpace,
336  bool isExternallyInitialized)
337  : GlobalObject(Ty, Value::GlobalVariableVal,
338  OperandTraits<GlobalVariable>::op_begin(this),
339  InitVal != nullptr, Link, Name, AddressSpace),
340  isConstantGlobal(constant),
341  isExternallyInitializedConstant(isExternallyInitialized) {
343  "invalid type for global variable");
344  setThreadLocalMode(TLMode);
345  if (InitVal) {
346  assert(InitVal->getType() == Ty &&
347  "Initializer should be the same type as the GlobalVariable!");
348  Op<0>() = InitVal;
349  }
350 }
351 
353  LinkageTypes Link, Constant *InitVal,
354  const Twine &Name, GlobalVariable *Before,
355  ThreadLocalMode TLMode,
357  bool isExternallyInitialized)
358  : GlobalObject(Ty, Value::GlobalVariableVal,
359  OperandTraits<GlobalVariable>::op_begin(this),
360  InitVal != nullptr, Link, Name,
362  ? *AddressSpace
363  : M.getDataLayout().getDefaultGlobalsAddressSpace()),
364  isConstantGlobal(constant),
365  isExternallyInitializedConstant(isExternallyInitialized) {
367  "invalid type for global variable");
368  setThreadLocalMode(TLMode);
369  if (InitVal) {
370  assert(InitVal->getType() == Ty &&
371  "Initializer should be the same type as the GlobalVariable!");
372  Op<0>() = InitVal;
373  }
374 
375  if (Before)
376  Before->getParent()->getGlobalList().insert(Before->getIterator(), this);
377  else
378  M.getGlobalList().push_back(this);
379 }
380 
382  getParent()->getGlobalList().remove(getIterator());
383 }
384 
386  getParent()->getGlobalList().erase(getIterator());
387 }
388 
390  if (!InitVal) {
391  if (hasInitializer()) {
392  // Note, the num operands is used to compute the offset of the operand, so
393  // the order here matters. Clearing the operand then clearing the num
394  // operands ensures we have the correct offset to the operand.
395  Op<0>().set(nullptr);
397  }
398  } else {
399  assert(InitVal->getType() == getValueType() &&
400  "Initializer type must match GlobalVariable type");
401  // Note, the num operands is used to compute the offset of the operand, so
402  // the order here matters. We need to set num operands to 1 first so that
403  // we get the correct offset to the first operand when we set it.
404  if (!hasInitializer())
406  Op<0>().set(InitVal);
407  }
408 }
409 
410 /// Copy all additional attributes (those not needed to create a GlobalVariable)
411 /// from the GlobalVariable Src to this one.
416 }
417 
420  clearMetadata();
421 }
422 
423 //===----------------------------------------------------------------------===//
424 // GlobalIndirectSymbol Implementation
425 //===----------------------------------------------------------------------===//
426 
428  unsigned AddressSpace, LinkageTypes Linkage, const Twine &Name,
429  Constant *Symbol)
430  : GlobalValue(Ty, VTy, &Op<0>(), 1, Linkage, Name, AddressSpace) {
431  Op<0>() = Symbol;
432 }
433 
434 static const GlobalObject *
436  if (auto *GO = dyn_cast<GlobalObject>(C))
437  return GO;
438  if (auto *GA = dyn_cast<GlobalAlias>(C))
439  if (Aliases.insert(GA).second)
440  return findBaseObject(GA->getOperand(0), Aliases);
441  if (auto *CE = dyn_cast<ConstantExpr>(C)) {
442  switch (CE->getOpcode()) {
443  case Instruction::Add: {
444  auto *LHS = findBaseObject(CE->getOperand(0), Aliases);
445  auto *RHS = findBaseObject(CE->getOperand(1), Aliases);
446  if (LHS && RHS)
447  return nullptr;
448  return LHS ? LHS : RHS;
449  }
450  case Instruction::Sub: {
451  if (findBaseObject(CE->getOperand(1), Aliases))
452  return nullptr;
453  return findBaseObject(CE->getOperand(0), Aliases);
454  }
455  case Instruction::IntToPtr:
456  case Instruction::PtrToInt:
457  case Instruction::BitCast:
458  case Instruction::GetElementPtr:
459  return findBaseObject(CE->getOperand(0), Aliases);
460  default:
461  break;
462  }
463  }
464  return nullptr;
465 }
466 
469  return findBaseObject(getOperand(0), Aliases);
470 }
471 
472 //===----------------------------------------------------------------------===//
473 // GlobalAlias Implementation
474 //===----------------------------------------------------------------------===//
475 
476 GlobalAlias::GlobalAlias(Type *Ty, unsigned AddressSpace, LinkageTypes Link,
477  const Twine &Name, Constant *Aliasee,
478  Module *ParentModule)
479  : GlobalIndirectSymbol(Ty, Value::GlobalAliasVal, AddressSpace, Link, Name,
480  Aliasee) {
481  if (ParentModule)
482  ParentModule->getAliasList().push_back(this);
483 }
484 
486  LinkageTypes Link, const Twine &Name,
487  Constant *Aliasee, Module *ParentModule) {
488  return new GlobalAlias(Ty, AddressSpace, Link, Name, Aliasee, ParentModule);
489 }
490 
492  LinkageTypes Linkage, const Twine &Name,
493  Module *Parent) {
494  return create(Ty, AddressSpace, Linkage, Name, nullptr, Parent);
495 }
496 
498  LinkageTypes Linkage, const Twine &Name,
499  GlobalValue *Aliasee) {
500  return create(Ty, AddressSpace, Linkage, Name, Aliasee, Aliasee->getParent());
501 }
502 
504  GlobalValue *Aliasee) {
505  return create(Aliasee->getValueType(), Aliasee->getAddressSpace(), Link, Name,
506  Aliasee);
507 }
508 
510  return create(Aliasee->getLinkage(), Name, Aliasee);
511 }
512 
514  getParent()->getAliasList().remove(getIterator());
515 }
516 
518  getParent()->getAliasList().erase(getIterator());
519 }
520 
522  assert((!Aliasee || Aliasee->getType() == getType()) &&
523  "Alias and aliasee types should match!");
524  setIndirectSymbol(Aliasee);
525 }
526 
527 //===----------------------------------------------------------------------===//
528 // GlobalIFunc Implementation
529 //===----------------------------------------------------------------------===//
530 
531 GlobalIFunc::GlobalIFunc(Type *Ty, unsigned AddressSpace, LinkageTypes Link,
532  const Twine &Name, Constant *Resolver,
533  Module *ParentModule)
534  : GlobalIndirectSymbol(Ty, Value::GlobalIFuncVal, AddressSpace, Link, Name,
535  Resolver) {
536  if (ParentModule)
537  ParentModule->getIFuncList().push_back(this);
538 }
539 
541  LinkageTypes Link, const Twine &Name,
542  Constant *Resolver, Module *ParentModule) {
543  return new GlobalIFunc(Ty, AddressSpace, Link, Name, Resolver, ParentModule);
544 }
545 
547  getParent()->getIFuncList().remove(getIterator());
548 }
549 
551  getParent()->getIFuncList().erase(getIterator());
552 }
llvm::GlobalVariable::setExternallyInitialized
void setExternallyInitialized(bool Val)
Definition: GlobalVariable.h:159
llvm::LLVMContext::pImpl
LLVMContextImpl *const pImpl
Definition: LLVMContext.h:70
llvm::GlobalVariable::eraseFromParent
void eraseFromParent()
eraseFromParent - This method unlinks 'this' from the containing module and deletes it.
Definition: Globals.cpp:385
constant
we should consider alternate ways to model stack dependencies Lots of things could be done in WebAssemblyTargetTransformInfo cpp there are numerous optimization related hooks that can be overridden in WebAssemblyTargetLowering Instead of the OptimizeReturned which should consider preserving the returned attribute through to MachineInstrs and extending the MemIntrinsicResults pass to do this optimization on calls too That would also let the WebAssemblyPeephole pass clean up dead defs for such as it does for stores Consider implementing and or getMachineCombinerPatterns Find a clean way to fix the problem which leads to the Shrink Wrapping pass being run after the WebAssembly PEI pass When setting multiple variables to the same constant
Definition: README.txt:91
llvm::GlobalValue::removeFromParent
void removeFromParent()
This method unlinks 'this' from the containing module, but does not delete it.
Definition: Globals.cpp:74
llvm
Definition: AllocatorList.h:23
llvm::PointerType::isValidElementType
static bool isValidElementType(Type *ElemTy)
Return true if the specified type is valid as a element type.
Definition: Type.cpp:732
M
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
Definition: README.txt:252
llvm::StringRef::empty
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:153
llvm::GlobalValue::getGlobalIdentifier
std::string getGlobalIdentifier() const
Return the modified name for this global value suitable to be used as the key for a global lookup (e....
Definition: Globals.cpp:157
llvm::GlobalVariable::copyAttributesFrom
void copyAttributesFrom(const GlobalVariable *Src)
copyAttributesFrom - copy all additional attributes (those not needed to create a GlobalVariable) fro...
Definition: Globals.cpp:412
llvm::GlobalValue::getLinkage
LinkageTypes getLinkage() const
Definition: GlobalValue.h:461
llvm::GlobalIndirectSymbol::setIndirectSymbol
void setIndirectSymbol(Constant *Symbol)
These methods set and retrieve indirect symbol.
Definition: GlobalIndirectSymbol.h:50
llvm::Function
Definition: Function.h:61
llvm::GlobalObject::getSection
StringRef getSection() const
Get the custom section of this global if it has one.
Definition: GlobalObject.h:112
llvm::User::dropAllReferences
void dropAllReferences()
Drop all references to operands.
Definition: User.h:299
llvm::GlobalVariable::isExternallyInitialized
bool isExternallyInitialized() const
Definition: GlobalVariable.h:156
llvm::GlobalValue::isLocalLinkage
static bool isLocalLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:329
llvm::GlobalValue::materialize
Error materialize()
Make sure this GlobalValue is fully read.
Definition: Globals.cpp:49
ErrorHandling.h
llvm::GlobalIndirectSymbol
Definition: GlobalIndirectSymbol.h:28
llvm::GlobalVariable
Definition: GlobalVariable.h:40
llvm::PointerType::getAddressSpace
unsigned getAddressSpace() const
Return the address space of the Pointer type.
Definition: DerivedTypes.h:689
llvm::GlobalAlias
Definition: GlobalAlias.h:27
llvm::GlobalValue::HasPartition
unsigned HasPartition
True if this symbol has a partition name assigned (see https://lld.llvm.org/Partitions....
Definition: GlobalValue.h:113
Error.h
llvm::GlobalValue::setThreadLocalMode
void setThreadLocalMode(ThreadLocalMode Val)
Definition: GlobalValue.h:248
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:45
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:46
Module.h
llvm::Optional
Definition: APInt.h:33
Operator.h
llvm::codeview::Link
@ Link
Definition: CodeView.h:151
llvm::GlobalValue::setUnnamedAddr
void setUnnamedAddr(UnnamedAddr Val)
Definition: GlobalValue.h:212
llvm::GlobalValue::LinkageTypes
LinkageTypes
An enumeration for the kinds of linkage for global values.
Definition: GlobalValue.h:47
llvm::getConstantRangeFromMetadata
ConstantRange getConstantRangeFromMetadata(const MDNode &RangeMD)
Parse out a conservative ConstantRange from !range metadata.
Definition: ConstantRange.cpp:1681
llvm::detail::DenseSetImpl< ValueT, DenseMap< ValueT, detail::DenseSetEmpty, DenseMapInfo< ValueT >, detail::DenseSetPair< ValueT > >, DenseMapInfo< ValueT > >::insert
std::pair< iterator, bool > insert(const ValueT &V)
Definition: DenseSet.h:206
llvm::Module::getGlobalList
const GlobalListType & getGlobalList() const
Get the Module's list of global variables (constant).
Definition: Module.h:544
llvm::GlobalValue::setDSOLocal
void setDSOLocal(bool Local)
Definition: GlobalValue.h:280
llvm::LLVMContextImpl::GlobalValuePartitions
DenseMap< const GlobalValue *, StringRef > GlobalValuePartitions
Collection of per-GlobalValue partitions used in this context.
Definition: LLVMContextImpl.h:1469
F
#define F(x, y, z)
Definition: MD5.cpp:56
llvm::GlobalVariable::hasInitializer
bool hasInitializer() const
Definitions have initializers, declarations don't.
Definition: GlobalVariable.h:92
llvm::User::setGlobalVariableNumOperands
void setGlobalVariableNumOperands(unsigned NumOps)
Set the number of operands on a GlobalVariable.
Definition: User.h:207
llvm::GlobalValue::getSection
StringRef getSection() const
Definition: Globals.cpp:162
llvm::Resolver
Interface for looking up the initializer for a variable name, used by Init::resolveReferences.
Definition: Record.h:2000
llvm::Triple::isOSBinFormatELF
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
Definition: Triple.h:632
GlobalValue.h
llvm::OperandTraits
Compile-time customization of User operands.
Definition: User.h:42
llvm::GlobalValue::isDeclaration
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
Definition: Globals.cpp:228
Constants.h
llvm::GlobalObject::HasSectionHashEntryBit
@ HasSectionHashEntryBit
Definition: GlobalObject.h:55
llvm::GlobalObject::setSection
void setSection(StringRef S)
Change the section for this global.
Definition: Globals.cpp:212
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::GlobalValue::getThreadLocalMode
ThreadLocalMode getThreadLocalMode() const
Definition: GlobalValue.h:252
llvm::GlobalObject
Definition: GlobalObject.h:28
llvm::GlobalValue::copyAttributesFrom
void copyAttributesFrom(const GlobalValue *Src)
Copy all additional attributes (those not needed to create a GlobalValue) from the GlobalValue Src to...
Definition: Globals.cpp:65
llvm::GlobalIndirectSymbol::GlobalIndirectSymbol
GlobalIndirectSymbol(Type *Ty, ValueTy VTy, unsigned AddressSpace, LinkageTypes Linkage, const Twine &Name, Constant *Symbol)
Definition: Globals.cpp:427
llvm::GlobalValue::hasAtLeastLocalUnnamedAddr
bool hasAtLeastLocalUnnamedAddr() const
Returns true if this value's address is not significant in this module.
Definition: GlobalValue.h:205
llvm::MaybeAlign
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
Definition: Alignment.h:109
llvm::Value::getValueID
unsigned getValueID() const
Return an ID for the concrete type of this object.
Definition: Value.h:529
llvm::Module::getAliasList
const AliasListType & getAliasList() const
Get the Module's list of aliases (constant).
Definition: Module.h:561
LLVMContextImpl.h
findBaseObject
static const GlobalObject * findBaseObject(const Constant *C, DenseSet< const GlobalAlias * > &Aliases)
Definition: Globals.cpp:435
llvm::encode
unsigned encode(MaybeAlign A)
Returns a representation of the alignment that encodes undefined as 0.
Definition: Alignment.h:232
llvm::GlobalIFunc::removeFromParent
void removeFromParent()
This method unlinks 'this' from the containing module, but does not delete it.
Definition: Globals.cpp:546
SmallPtrSet.h
llvm::GlobalValue::hasGlobalUnnamedAddr
bool hasGlobalUnnamedAddr() const
Definition: GlobalValue.h:196
llvm::Align
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
llvm::Comdat
Definition: Comdat.h:31
llvm::Type::isFunctionTy
bool isFunctionTy() const
True if this is an instance of FunctionType.
Definition: Type.h:220
llvm::AddressSpace
AddressSpace
Definition: NVPTXBaseInfo.h:21
llvm::StringRef::str
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
Definition: StringRef.h:245
llvm::None
const NoneType None
Definition: None.h:23
llvm::GlobalIndirectSymbol::getBaseObject
const GlobalObject * getBaseObject() const
Definition: Globals.cpp:467
llvm::GlobalValue::hasDefaultVisibility
bool hasDefaultVisibility() const
Definition: GlobalValue.h:230
llvm::GlobalVariable::dropAllReferences
void dropAllReferences()
Drop all references in preparation to destroy the GlobalVariable.
Definition: Globals.cpp:418
llvm::DenseSet
Implements a dense probed hash-table based set.
Definition: DenseSet.h:268
llvm::GlobalObject::hasSection
bool hasSection() const
Check if this global has a custom object file section.
Definition: GlobalObject.h:104
llvm::GlobalValue
Definition: GlobalValue.h:44
llvm::GlobalValue::canBenefitFromLocalAlias
bool canBenefitFromLocalAlias() const
Definition: Globals.cpp:105
llvm::Constant
This is an important base class in LLVM.
Definition: Constant.h:41
llvm::GlobalObject::canIncreaseAlignment
bool canIncreaseAlignment() const
Returns true if the alignment of the value can be unilaterally increased.
Definition: Globals.cpp:242
llvm::GlobalValue::getVisibility
VisibilityTypes getVisibility() const
Definition: GlobalValue.h:229
llvm::GlobalValue::getParent
Module * getParent()
Get the module that this global value is contained inside of...
Definition: GlobalValue.h:572
llvm::GlobalValue::getDLLStorageClass
DLLStorageClassTypes getDLLStorageClass() const
Definition: GlobalValue.h:256
llvm::GlobalValue::hasComdat
bool hasComdat() const
Definition: GlobalValue.h:222
llvm::LLVMContextImpl::GlobalObjectSections
DenseMap< const GlobalObject *, StringRef > GlobalObjectSections
Collection of per-GlobalObject sections used in this context.
Definition: LLVMContextImpl.h:1466
llvm::GlobalValue::getPartition
StringRef getPartition() const
Definition: Globals.cpp:185
llvm::PointerType
Class to represent pointers.
Definition: DerivedTypes.h:634
llvm::GlobalValue::Linkage
unsigned Linkage
Definition: GlobalValue.h:94
llvm::Value::MaximumAlignment
static const unsigned MaximumAlignment
Definition: Value.h:785
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::GlobalValue::isExternalLinkage
static bool isExternalLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:299
llvm::UniqueStringSaver::save
StringRef save(const char *S)
Definition: StringSaver.h:50
llvm::GlobalObject::getAlignment
unsigned getAlignment() const
FIXME: Remove this function once transition to Align is over.
Definition: GlobalObject.h:71
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:67
llvm::MDNode
Metadata node.
Definition: Metadata.h:897
llvm::Value::clearMetadata
void clearMetadata()
Erase all metadata attached to this Value.
Definition: Metadata.cpp:1285
Triple.h
llvm::Value::ValueTy
ValueTy
Concrete subclass of this.
Definition: Value.h:510
llvm::GlobalValue::isMaterializable
bool isMaterializable() const
If this function's Module is being lazily streamed in functions from disk or some other source,...
Definition: Globals.cpp:44
llvm::GlobalValue::canBeOmittedFromSymbolTable
bool canBeOmittedFromSymbolTable() const
True if GV can be left out of the object symbol table.
Definition: Globals.cpp:311
llvm::GlobalValue::getGlobalValueSubClassData
unsigned getGlobalValueSubClassData() const
Definition: GlobalValue.h:158
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
this
Analysis the ScalarEvolution expression for r is this
Definition: README.txt:8
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:136
llvm::Value::getType
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:256
llvm::GlobalValue::setDLLStorageClass
void setDLLStorageClass(DLLStorageClassTypes C)
Definition: GlobalValue.h:265
llvm::Value::getContext
LLVMContext & getContext() const
All values hold a context through their type.
Definition: Value.cpp:965
llvm::ilist_node_impl::getIterator
self_iterator getIterator()
Definition: ilist_node.h:81
ConstantRange.h
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
llvm::Value::getName
StringRef getName() const
Return a constant reference to the value's name.
Definition: Value.cpp:294
llvm::GlobalIFunc::create
static GlobalIFunc * create(Type *Ty, unsigned AddressSpace, LinkageTypes Linkage, const Twine &Name, Constant *Resolver, Module *Parent)
If a parent module is specified, the ifunc is automatically inserted into the end of the specified mo...
Definition: Globals.cpp:540
llvm::GlobalVariable::GlobalVariable
GlobalVariable(Type *Ty, bool isConstant, LinkageTypes Linkage, Constant *Initializer=nullptr, const Twine &Name="", ThreadLocalMode=NotThreadLocal, unsigned AddressSpace=0, bool isExternallyInitialized=false)
GlobalVariable ctor - If a parent module is specified, the global is automatically inserted into the ...
Definition: Globals.cpp:333
llvm::GlobalValue::eraseFromParent
void eraseFromParent()
This method unlinks 'this' from the containing module and deletes it.
Definition: Globals.cpp:86
llvm::GlobalValue::isStrongDefinitionForLinker
bool isStrongDefinitionForLinker() const
Returns true if this global's definition will be the one chosen by the linker.
Definition: GlobalValue.h:547
llvm::GlobalValue::getUnnamedAddr
UnnamedAddr getUnnamedAddr() const
Definition: GlobalValue.h:209
llvm::Module::getSemanticInterposition
bool getSemanticInterposition() const
Returns whether semantic interposition is to be respected.
Definition: Module.cpp:645
llvm::Module::materialize
llvm::Error materialize(GlobalValue *GV)
Make sure the GlobalValue is fully read.
Definition: Module.cpp:438
llvm::GlobalValue::isInterposable
bool isInterposable() const
Return true if this global's definition can be substituted with an arbitrary definition at link time ...
Definition: Globals.cpp:98
llvm::Module::getIFuncList
const IFuncListType & getIFuncList() const
Get the Module's list of ifuncs (constant).
Definition: Module.h:570
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:80
llvm::GlobalValue::hasLinkOnceODRLinkage
bool hasLinkOnceODRLinkage() const
Definition: GlobalValue.h:436
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
llvm::GlobalValue::ThreadLocalMode
ThreadLocalMode
Definition: GlobalValue.h:178
llvm::GlobalAlias::create
static GlobalAlias * create(Type *Ty, unsigned AddressSpace, LinkageTypes Linkage, const Twine &Name, Constant *Aliasee, Module *Parent)
If a parent module is specified, the alias is automatically inserted into the end of the specified mo...
Definition: Globals.cpp:485
llvm::GlobalValue::isInterposableLinkage
static bool isInterposableLinkage(LinkageTypes Linkage)
Whether the definition of this global may be replaced by something non-equivalent at link time.
Definition: GlobalValue.h:345
llvm::AMDGPU::SendMsg::Op
Op
Definition: SIDefines.h:314
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
GlobalVariable.h
llvm::GlobalValue::getComdat
const Comdat * getComdat() const
Definition: Globals.cpp:172
llvm::GlobalVariable::getAttributes
AttributeSet getAttributes() const
Return the attribute set for this global.
Definition: GlobalVariable.h:223
llvm::GlobalValue::getBaseObject
const GlobalObject * getBaseObject() const
Definition: Globals.cpp:283
llvm::MCID::Add
@ Add
Definition: MCInstrDesc.h:183
GlobalAlias.h
llvm::ARMBuildAttrs::Symbol
@ Symbol
Definition: ARMBuildAttributes.h:79
llvm::GlobalValue::getAddressSpace
unsigned getAddressSpace() const
Definition: Globals.cpp:112
llvm::GlobalValue::setGlobalValueSubClassData
void setGlobalValueSubClassData(unsigned V)
Definition: GlobalValue.h:161
llvm::GlobalValue::isAbsoluteSymbolRef
bool isAbsoluteSymbolRef() const
Returns whether this is a reference to an absolute symbol.
Definition: Globals.cpp:291
llvm::GlobalValue::getAbsoluteSymbolRange
Optional< ConstantRange > getAbsoluteSymbolRange() const
If this is an absolute symbol reference, returns the range of the symbol, otherwise returns None.
Definition: Globals.cpp:299
llvm::LLVMContextImpl::Saver
UniqueStringSaver Saver
Definition: LLVMContextImpl.h:1435
llvm::Module::getTargetTriple
const std::string & getTargetTriple() const
Get the target triple which is a string describing the target host.
Definition: Module.h:257
llvm::GlobalVariable::setAttributes
void setAttributes(AttributeSet A)
Set attribute list for this global.
Definition: GlobalVariable.h:238
llvm::GlobalObject::copyAttributesFrom
void copyAttributesFrom(const GlobalObject *Src)
Definition: Globals.cpp:127
llvm::GlobalValue::setPartition
void setPartition(StringRef Part)
Definition: Globals.cpp:191
llvm::GlobalValue::getType
PointerType * getType() const
Global values are always pointers.
Definition: GlobalValue.h:271
DerivedTypes.h
llvm::GlobalValue::getValueType
Type * getValueType() const
Definition: GlobalValue.h:273
llvm::GlobalValue::hasPartition
bool hasPartition() const
Definition: GlobalValue.h:286
From
BlockVerifier::State From
Definition: BlockVerifier.cpp:55
llvm::GlobalAlias::eraseFromParent
void eraseFromParent()
eraseFromParent - This method unlinks 'this' from the containing module and deletes it.
Definition: Globals.cpp:517
llvm::User::getOperand
Value * getOperand(unsigned i) const
Definition: User.h:169
llvm::GlobalObject::setAlignment
void setAlignment(MaybeAlign Align)
Definition: Globals.cpp:117
llvm::GlobalVariable::removeFromParent
void removeFromParent()
removeFromParent - This method unlinks 'this' from the containing module, but does not delete it.
Definition: Globals.cpp:381
llvm::GlobalValue::isDSOLocal
bool isDSOLocal() const
Definition: GlobalValue.h:282
llvm::GlobalIFunc
Definition: GlobalIFunc.h:32
llvm::GlobalValue::setVisibility
void setVisibility(VisibilityTypes V)
Definition: GlobalValue.h:235
llvm::GlobalValue::Parent
Module * Parent
Definition: GlobalValue.h:166
llvm::Value
LLVM Value Representation.
Definition: Value.h:75
llvm::GlobalIFunc::eraseFromParent
void eraseFromParent()
This method unlinks 'this' from the containing module and deletes it.
Definition: Globals.cpp:550
llvm::GlobalAlias::removeFromParent
void removeFromParent()
removeFromParent - This method unlinks 'this' from the containing module, but does not delete it.
Definition: Globals.cpp:513
llvm::GlobalAlias::setAliasee
void setAliasee(Constant *Aliasee)
These methods retrieve and set alias target.
Definition: Globals.cpp:521
llvm::GlobalVariable::setInitializer
void setInitializer(Constant *InitVal)
setInitializer - Sets the initializer for this global variable, removing any existing initializer if ...
Definition: Globals.cpp:389