LLVM  16.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/Triple.h"
16 #include "llvm/IR/ConstantRange.h"
17 #include "llvm/IR/Constants.h"
18 #include "llvm/IR/DerivedTypes.h"
19 #include "llvm/IR/GlobalAlias.h"
20 #include "llvm/IR/GlobalValue.h"
21 #include "llvm/IR/GlobalVariable.h"
22 #include "llvm/IR/Module.h"
23 #include "llvm/Support/Error.h"
25 using namespace llvm;
26 
27 //===----------------------------------------------------------------------===//
28 // GlobalValue Class
29 //===----------------------------------------------------------------------===//
30 
31 // GlobalValue should be a Constant, plus a type, a module, some flags, and an
32 // intrinsic ID. Add an assert to prevent people from accidentally growing
33 // GlobalValue while adding flags.
34 static_assert(sizeof(GlobalValue) ==
35  sizeof(Constant) + 2 * sizeof(void *) + 2 * sizeof(unsigned),
36  "unexpected GlobalValue size growth");
37 
38 // GlobalObject adds a comdat.
39 static_assert(sizeof(GlobalObject) == sizeof(GlobalValue) + sizeof(void *),
40  "unexpected GlobalObject size growth");
41 
43  if (const Function *F = dyn_cast<Function>(this))
44  return F->isMaterializable();
45  return false;
46 }
48  return getParent()->materialize(this);
49 }
50 
51 /// Override destroyConstantImpl to make sure it doesn't get called on
52 /// GlobalValue's because they shouldn't be treated like other constants.
53 void GlobalValue::destroyConstantImpl() {
54  llvm_unreachable("You can't GV->destroyConstantImpl()!");
55 }
56 
57 Value *GlobalValue::handleOperandChangeImpl(Value *From, Value *To) {
58  llvm_unreachable("Unsupported class for handleOperandChange()!");
59 }
60 
61 /// copyAttributesFrom - copy all additional attributes (those not needed to
62 /// create a GlobalValue) from the GlobalValue Src to this one.
64  setVisibility(Src->getVisibility());
65  setUnnamedAddr(Src->getUnnamedAddr());
66  setThreadLocalMode(Src->getThreadLocalMode());
67  setDLLStorageClass(Src->getDLLStorageClass());
68  setDSOLocal(Src->isDSOLocal());
69  setPartition(Src->getPartition());
70  if (Src->hasSanitizerMetadata())
71  setSanitizerMetadata(Src->getSanitizerMetadata());
72  else
74 }
75 
77  switch (getValueID()) {
78 #define HANDLE_GLOBAL_VALUE(NAME) \
79  case Value::NAME##Val: \
80  return static_cast<NAME *>(this)->removeFromParent();
81 #include "llvm/IR/Value.def"
82  default:
83  break;
84  }
85  llvm_unreachable("not a global");
86 }
87 
89  switch (getValueID()) {
90 #define HANDLE_GLOBAL_VALUE(NAME) \
91  case Value::NAME##Val: \
92  return static_cast<NAME *>(this)->eraseFromParent();
93 #include "llvm/IR/Value.def"
94  default:
95  break;
96  }
97  llvm_unreachable("not a global");
98 }
99 
101 
104  return true;
105  return getParent() && getParent()->getSemanticInterposition() &&
106  !isDSOLocal();
107 }
108 
110  // See AsmPrinter::getSymbolPreferLocal(). For a deduplicate comdat kind,
111  // references to a discarded local symbol from outside the group are not
112  // allowed, so avoid the local alias.
113  auto isDeduplicateComdat = [](const Comdat *C) {
114  return C && C->getSelectionKind() != Comdat::NoDeduplicate;
115  };
116  return hasDefaultVisibility() &&
118  !isa<GlobalIFunc>(this) && !isDeduplicateComdat(getComdat());
119 }
120 
122  PointerType *PtrTy = getType();
123  return PtrTy->getAddressSpace();
124 }
125 
127  assert((!Align || *Align <= MaximumAlignment) &&
128  "Alignment is greater than MaximumAlignment!");
129  unsigned AlignmentData = encode(Align);
130  unsigned OldData = getGlobalValueSubClassData();
131  setGlobalValueSubClassData((OldData & ~AlignmentMask) | AlignmentData);
133  "Alignment representation error!");
134 }
135 
138  setAlignment(Src->getAlign());
139  setSection(Src->getSection());
140 }
141 
144  StringRef FileName) {
145 
146  // Value names may be prefixed with a binary '1' to indicate
147  // that the backend should not modify the symbols due to any platform
148  // naming convention. Do not include that '1' in the PGO profile name.
149  if (Name[0] == '\1')
150  Name = Name.substr(1);
151 
152  std::string NewName = std::string(Name);
154  // For local symbols, prepend the main file name to distinguish them.
155  // Do not include the full path in the file name since there's no guarantee
156  // that it will stay the same, e.g., if the files are checked out from
157  // version control in different locations.
158  if (FileName.empty())
159  NewName = NewName.insert(0, "<unknown>:");
160  else
161  NewName = NewName.insert(0, FileName.str() + ":");
162  }
163  return NewName;
164 }
165 
166 std::string GlobalValue::getGlobalIdentifier() const {
168  getParent()->getSourceFileName());
169 }
170 
172  if (auto *GA = dyn_cast<GlobalAlias>(this)) {
173  // In general we cannot compute this at the IR level, but we try.
174  if (const GlobalObject *GO = GA->getAliaseeObject())
175  return GO->getSection();
176  return "";
177  }
178  return cast<GlobalObject>(this)->getSection();
179 }
180 
182  if (auto *GA = dyn_cast<GlobalAlias>(this)) {
183  // In general we cannot compute this at the IR level, but we try.
184  if (const GlobalObject *GO = GA->getAliaseeObject())
185  return const_cast<GlobalObject *>(GO)->getComdat();
186  return nullptr;
187  }
188  // ifunc and its resolver are separate things so don't use resolver comdat.
189  if (isa<GlobalIFunc>(this))
190  return nullptr;
191  return cast<GlobalObject>(this)->getComdat();
192 }
193 
195  if (ObjComdat)
196  ObjComdat->removeUser(this);
197  ObjComdat = C;
198  if (C)
199  C->addUser(this);
200 }
201 
203  if (!hasPartition())
204  return "";
205  return getContext().pImpl->GlobalValuePartitions[this];
206 }
207 
209  // Do nothing if we're clearing the partition and it is already empty.
210  if (!hasPartition() && S.empty())
211  return;
212 
213  // Get or create a stable partition name string and put it in the table in the
214  // context.
215  if (!S.empty())
216  S = getContext().pImpl->Saver.save(S);
218 
219  // Update the HasPartition field. Setting the partition to the empty string
220  // means this global no longer has a partition.
221  HasPartition = !S.empty();
222 }
223 
227  assert(getContext().pImpl->GlobalValueSanitizerMetadata.count(this));
229 }
230 
233  HasSanitizerMetadata = true;
234 }
235 
239  MetadataMap.erase(this);
240  HasSanitizerMetadata = false;
241 }
242 
243 StringRef GlobalObject::getSectionImpl() const {
244  assert(hasSection());
245  return getContext().pImpl->GlobalObjectSections[this];
246 }
247 
249  // Do nothing if we're clearing the section and it is already empty.
250  if (!hasSection() && S.empty())
251  return;
252 
253  // Get or create a stable section name string and put it in the table in the
254  // context.
255  if (!S.empty())
256  S = getContext().pImpl->Saver.save(S);
258 
259  // Update the HasSectionHashEntryBit. Setting the section to the empty string
260  // means this global no longer has a section.
261  setGlobalObjectFlag(HasSectionHashEntryBit, !S.empty());
262 }
263 
264 bool GlobalValue::isNobuiltinFnDef() const {
265  const Function *F = dyn_cast<Function>(this);
266  if (!F || F->empty())
267  return false;
268  return F->hasFnAttribute(Attribute::NoBuiltin);
269 }
270 
272  // Globals are definitions if they have an initializer.
273  if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(this))
274  return GV->getNumOperands() == 0;
275 
276  // Functions are definitions if they have a body.
277  if (const Function *F = dyn_cast<Function>(this))
278  return F->empty() && !F->isMaterializable();
279 
280  // Aliases and ifuncs are always definitions.
281  assert(isa<GlobalAlias>(this) || isa<GlobalIFunc>(this));
282  return false;
283 }
284 
286  // Firstly, can only increase the alignment of a global if it
287  // is a strong definition.
289  return false;
290 
291  // It also has to either not have a section defined, or, not have
292  // alignment specified. (If it is assigned a section, the global
293  // could be densely packed with other objects in the section, and
294  // increasing the alignment could cause padding issues.)
295  if (hasSection() && getAlign())
296  return false;
297 
298  // On ELF platforms, we're further restricted in that we can't
299  // increase the alignment of any variable which might be emitted
300  // into a shared library, and which is exported. If the main
301  // executable accesses a variable found in a shared-lib, the main
302  // exe actually allocates memory for and exports the symbol ITSELF,
303  // overriding the symbol found in the library. That is, at link
304  // time, the observed alignment of the variable is copied into the
305  // executable binary. (A COPY relocation is also generated, to copy
306  // the initial data from the shadowed variable in the shared-lib
307  // into the location in the main binary, before running code.)
308  //
309  // And thus, even though you might think you are defining the
310  // global, and allocating the memory for the global in your object
311  // file, and thus should be able to set the alignment arbitrarily,
312  // that's not actually true. Doing so can cause an ABI breakage; an
313  // executable might have already been built with the previous
314  // alignment of the variable, and then assuming an increased
315  // alignment will be incorrect.
316 
317  // Conservatively assume ELF if there's no parent pointer.
318  bool isELF =
320  if (isELF && !isDSOLocal())
321  return false;
322 
323  return true;
324 }
325 
326 template <typename Operation>
327 static const GlobalObject *
329  const Operation &Op) {
330  if (auto *GO = dyn_cast<GlobalObject>(C)) {
331  Op(*GO);
332  return GO;
333  }
334  if (auto *GA = dyn_cast<GlobalAlias>(C)) {
335  Op(*GA);
336  if (Aliases.insert(GA).second)
337  return findBaseObject(GA->getOperand(0), Aliases, Op);
338  }
339  if (auto *CE = dyn_cast<ConstantExpr>(C)) {
340  switch (CE->getOpcode()) {
341  case Instruction::Add: {
342  auto *LHS = findBaseObject(CE->getOperand(0), Aliases, Op);
343  auto *RHS = findBaseObject(CE->getOperand(1), Aliases, Op);
344  if (LHS && RHS)
345  return nullptr;
346  return LHS ? LHS : RHS;
347  }
348  case Instruction::Sub: {
349  if (findBaseObject(CE->getOperand(1), Aliases, Op))
350  return nullptr;
351  return findBaseObject(CE->getOperand(0), Aliases, Op);
352  }
353  case Instruction::IntToPtr:
354  case Instruction::PtrToInt:
355  case Instruction::BitCast:
356  case Instruction::GetElementPtr:
357  return findBaseObject(CE->getOperand(0), Aliases, Op);
358  default:
359  break;
360  }
361  }
362  return nullptr;
363 }
364 
367  return findBaseObject(this, Aliases, [](const GlobalValue &) {});
368 }
369 
371  auto *GO = dyn_cast<GlobalObject>(this);
372  if (!GO)
373  return false;
374 
375  return GO->getMetadata(LLVMContext::MD_absolute_symbol);
376 }
377 
379  auto *GO = dyn_cast<GlobalObject>(this);
380  if (!GO)
381  return None;
382 
383  MDNode *MD = GO->getMetadata(LLVMContext::MD_absolute_symbol);
384  if (!MD)
385  return None;
386 
387  return getConstantRangeFromMetadata(*MD);
388 }
389 
391  if (!hasLinkOnceODRLinkage())
392  return false;
393 
394  // We assume that anyone who sets global unnamed_addr on a non-constant
395  // knows what they're doing.
396  if (hasGlobalUnnamedAddr())
397  return true;
398 
399  // If it is a non constant variable, it needs to be uniqued across shared
400  // objects.
401  if (auto *Var = dyn_cast<GlobalVariable>(this))
402  if (!Var->isConstant())
403  return false;
404 
406 }
407 
408 //===----------------------------------------------------------------------===//
409 // GlobalVariable Implementation
410 //===----------------------------------------------------------------------===//
411 
413  Constant *InitVal, const Twine &Name,
414  ThreadLocalMode TLMode, unsigned AddressSpace,
415  bool isExternallyInitialized)
416  : GlobalObject(Ty, Value::GlobalVariableVal,
417  OperandTraits<GlobalVariable>::op_begin(this),
418  InitVal != nullptr, Link, Name, AddressSpace),
419  isConstantGlobal(constant),
420  isExternallyInitializedConstant(isExternallyInitialized) {
422  "invalid type for global variable");
423  setThreadLocalMode(TLMode);
424  if (InitVal) {
425  assert(InitVal->getType() == Ty &&
426  "Initializer should be the same type as the GlobalVariable!");
427  Op<0>() = InitVal;
428  }
429 }
430 
432  LinkageTypes Link, Constant *InitVal,
433  const Twine &Name, GlobalVariable *Before,
434  ThreadLocalMode TLMode,
436  bool isExternallyInitialized)
437  : GlobalObject(Ty, Value::GlobalVariableVal,
438  OperandTraits<GlobalVariable>::op_begin(this),
439  InitVal != nullptr, Link, Name,
441  ? *AddressSpace
442  : M.getDataLayout().getDefaultGlobalsAddressSpace()),
443  isConstantGlobal(constant),
444  isExternallyInitializedConstant(isExternallyInitialized) {
446  "invalid type for global variable");
447  setThreadLocalMode(TLMode);
448  if (InitVal) {
449  assert(InitVal->getType() == Ty &&
450  "Initializer should be the same type as the GlobalVariable!");
451  Op<0>() = InitVal;
452  }
453 
454  if (Before)
455  Before->getParent()->getGlobalList().insert(Before->getIterator(), this);
456  else
457  M.getGlobalList().push_back(this);
458 }
459 
461  getParent()->getGlobalList().remove(getIterator());
462 }
463 
465  getParent()->getGlobalList().erase(getIterator());
466 }
467 
469  if (!InitVal) {
470  if (hasInitializer()) {
471  // Note, the num operands is used to compute the offset of the operand, so
472  // the order here matters. Clearing the operand then clearing the num
473  // operands ensures we have the correct offset to the operand.
474  Op<0>().set(nullptr);
476  }
477  } else {
478  assert(InitVal->getType() == getValueType() &&
479  "Initializer type must match GlobalVariable type");
480  // Note, the num operands is used to compute the offset of the operand, so
481  // the order here matters. We need to set num operands to 1 first so that
482  // we get the correct offset to the first operand when we set it.
483  if (!hasInitializer())
485  Op<0>().set(InitVal);
486  }
487 }
488 
489 /// Copy all additional attributes (those not needed to create a GlobalVariable)
490 /// from the GlobalVariable Src to this one.
493  setExternallyInitialized(Src->isExternallyInitialized());
494  setAttributes(Src->getAttributes());
495 }
496 
499  clearMetadata();
500 }
501 
502 //===----------------------------------------------------------------------===//
503 // GlobalAlias Implementation
504 //===----------------------------------------------------------------------===//
505 
506 GlobalAlias::GlobalAlias(Type *Ty, unsigned AddressSpace, LinkageTypes Link,
507  const Twine &Name, Constant *Aliasee,
508  Module *ParentModule)
509  : GlobalValue(Ty, Value::GlobalAliasVal, &Op<0>(), 1, Link, Name,
510  AddressSpace) {
511  setAliasee(Aliasee);
512  if (ParentModule)
513  ParentModule->getAliasList().push_back(this);
514 }
515 
517  LinkageTypes Link, const Twine &Name,
518  Constant *Aliasee, Module *ParentModule) {
519  return new GlobalAlias(Ty, AddressSpace, Link, Name, Aliasee, ParentModule);
520 }
521 
523  LinkageTypes Linkage, const Twine &Name,
524  Module *Parent) {
525  return create(Ty, AddressSpace, Linkage, Name, nullptr, Parent);
526 }
527 
529  LinkageTypes Linkage, const Twine &Name,
530  GlobalValue *Aliasee) {
531  return create(Ty, AddressSpace, Linkage, Name, Aliasee, Aliasee->getParent());
532 }
533 
535  GlobalValue *Aliasee) {
536  return create(Aliasee->getValueType(), Aliasee->getAddressSpace(), Link, Name,
537  Aliasee);
538 }
539 
541  return create(Aliasee->getLinkage(), Name, Aliasee);
542 }
543 
545  getParent()->getAliasList().remove(getIterator());
546 }
547 
549  getParent()->getAliasList().erase(getIterator());
550 }
551 
553  assert((!Aliasee || Aliasee->getType() == getType()) &&
554  "Alias and aliasee types should match!");
555  Op<0>().set(Aliasee);
556 }
557 
560  return findBaseObject(getOperand(0), Aliases, [](const GlobalValue &) {});
561 }
562 
563 //===----------------------------------------------------------------------===//
564 // GlobalIFunc Implementation
565 //===----------------------------------------------------------------------===//
566 
567 GlobalIFunc::GlobalIFunc(Type *Ty, unsigned AddressSpace, LinkageTypes Link,
568  const Twine &Name, Constant *Resolver,
569  Module *ParentModule)
570  : GlobalObject(Ty, Value::GlobalIFuncVal, &Op<0>(), 1, Link, Name,
571  AddressSpace) {
572  setResolver(Resolver);
573  if (ParentModule)
574  ParentModule->getIFuncList().push_back(this);
575 }
576 
578  LinkageTypes Link, const Twine &Name,
579  Constant *Resolver, Module *ParentModule) {
580  return new GlobalIFunc(Ty, AddressSpace, Link, Name, Resolver, ParentModule);
581 }
582 
584  getParent()->getIFuncList().remove(getIterator());
585 }
586 
588  getParent()->getIFuncList().erase(getIterator());
589 }
590 
593  return dyn_cast<Function>(
594  findBaseObject(getResolver(), Aliases, [](const GlobalValue &) {}));
595 }
596 
598  function_ref<void(const GlobalValue &)> Op) const {
600  findBaseObject(getResolver(), Aliases, Op);
601 }
llvm::GlobalVariable::setExternallyInitialized
void setExternallyInitialized(bool Val)
Definition: GlobalVariable.h:158
llvm::GlobalValue::hasSanitizerMetadata
bool hasSanitizerMetadata() const
Definition: GlobalValue.h:345
llvm::LLVMContext::pImpl
LLVMContextImpl *const pImpl
Definition: LLVMContext.h:69
llvm::GlobalVariable::eraseFromParent
void eraseFromParent()
eraseFromParent - This method unlinks 'this' from the containing module and deletes it.
Definition: Globals.cpp:464
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::GlobalObject::setComdat
void setComdat(Comdat *C)
Definition: Globals.cpp:194
llvm::GlobalValue::removeFromParent
void removeFromParent()
This method unlinks 'this' from the containing module, but does not delete it.
Definition: Globals.cpp:76
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::PointerType::isValidElementType
static bool isValidElementType(Type *ElemTy)
Return true if the specified type is valid as a element type.
Definition: Type.cpp:778
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::GlobalObject::~GlobalObject
~GlobalObject()
Definition: Globals.cpp:100
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:166
llvm::Value::MaximumAlignment
static constexpr uint64_t MaximumAlignment
Definition: Value.h:793
llvm::GlobalVariable::copyAttributesFrom
void copyAttributesFrom(const GlobalVariable *Src)
copyAttributesFrom - copy all additional attributes (those not needed to create a GlobalVariable) fro...
Definition: Globals.cpp:491
llvm::GlobalValue::getLinkage
LinkageTypes getLinkage() const
Definition: GlobalValue.h:533
llvm::Function
Definition: Function.h:60
llvm::Comdat::NoDeduplicate
@ NoDeduplicate
No deduplication is performed.
Definition: Comdat.h:39
llvm::GlobalObject::getAlign
MaybeAlign getAlign() const
Returns the alignment of the given variable or function.
Definition: GlobalObject.h:79
llvm::User::dropAllReferences
void dropAllReferences()
Drop all references to operands.
Definition: User.h:299
llvm::GlobalValue::isLocalLinkage
static bool isLocalLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:398
llvm::GlobalValue::materialize
Error materialize()
Make sure this GlobalValue is fully read.
Definition: Globals.cpp:47
ErrorHandling.h
llvm::GlobalIFunc::applyAlongResolverPath
void applyAlongResolverPath(function_ref< void(const GlobalValue &)> Op) const
Definition: Globals.cpp:597
llvm::GlobalVariable
Definition: GlobalVariable.h:39
llvm::PointerType::getAddressSpace
unsigned getAddressSpace() const
Return the address space of the Pointer type.
Definition: DerivedTypes.h:682
llvm::GlobalAlias
Definition: GlobalAlias.h:28
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:261
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
llvm::DenseMapBase< DenseMap< KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::erase
bool erase(const KeyT &Val)
Definition: DenseMap.h:302
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
Module.h
llvm::Optional
Definition: APInt.h:33
llvm::GlobalValue::setSanitizerMetadata
void setSanitizerMetadata(SanitizerMetadata Meta)
Definition: Globals.cpp:231
llvm::codeview::Link
@ Link
Definition: CodeView.h:154
llvm::GlobalValue::setUnnamedAddr
void setUnnamedAddr(UnnamedAddr Val)
Definition: GlobalValue.h:225
RHS
Value * RHS
Definition: X86PartialReduction.cpp:76
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:1800
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:550
llvm::GlobalValue::setDSOLocal
void setDSOLocal(bool Local)
Definition: GlobalValue.h:293
llvm::LLVMContextImpl::GlobalValuePartitions
DenseMap< const GlobalValue *, StringRef > GlobalValuePartitions
Collection of per-GlobalValue partitions used in this context.
Definition: LLVMContextImpl.h:1506
F
#define F(x, y, z)
Definition: MD5.cpp:55
llvm::GlobalVariable::hasInitializer
bool hasInitializer() const
Definitions have initializers, declarations don't.
Definition: GlobalVariable.h:91
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:171
llvm::Resolver
Interface for looking up the initializer for a variable name, used by Init::resolveReferences.
Definition: Record.h:2095
LHS
Value * LHS
Definition: X86PartialReduction.cpp:75
llvm::Triple::isOSBinFormatELF
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
Definition: Triple.h:663
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:271
Constants.h
llvm::LLVMContextImpl::GlobalValueSanitizerMetadata
DenseMap< const GlobalValue *, GlobalValue::SanitizerMetadata > GlobalValueSanitizerMetadata
Definition: LLVMContextImpl.h:1509
llvm::GlobalObject::setSection
void setSection(StringRef S)
Change the section for this global.
Definition: Globals.cpp:248
Operation
PowerPC Reduce CR logical Operation
Definition: PPCReduceCRLogicals.cpp:734
llvm::GlobalValue::getSanitizerMetadata
const SanitizerMetadata & getSanitizerMetadata() const
Definition: Globals.cpp:225
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::GlobalObject
Definition: GlobalObject.h:27
llvm::GlobalValue::HasSanitizerMetadata
unsigned HasSanitizerMetadata
True if this symbol has sanitizer metadata available.
Definition: GlobalValue.h:118
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:63
llvm::GlobalValue::hasAtLeastLocalUnnamedAddr
bool hasAtLeastLocalUnnamedAddr() const
Returns true if this value's address is not significant in this module.
Definition: GlobalValue.h:218
llvm::MaybeAlign
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
Definition: Alignment.h:117
llvm::Value::getValueID
unsigned getValueID() const
Return an ID for the concrete type of this object.
Definition: Value.h:532
llvm::Module::getAliasList
const AliasListType & getAliasList() const
Get the Module's list of aliases (constant).
Definition: Module.h:567
LLVMContextImpl.h
findBaseObject
static const GlobalObject * findBaseObject(const Constant *C, DenseSet< const GlobalAlias * > &Aliases, const Operation &Op)
Definition: Globals.cpp:328
llvm::encode
unsigned encode(MaybeAlign A)
Returns a representation of the alignment that encodes undefined as 0.
Definition: Alignment.h:218
llvm::GlobalIFunc::removeFromParent
void removeFromParent()
This method unlinks 'this' from the containing module, but does not delete it.
Definition: Globals.cpp:583
llvm::GlobalValue::SanitizerMetadata
Definition: GlobalValue.h:307
llvm::GlobalValue::hasGlobalUnnamedAddr
bool hasGlobalUnnamedAddr() const
Definition: GlobalValue.h:209
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:33
llvm::Type::isFunctionTy
bool isFunctionTy() const
True if this is an instance of FunctionType.
Definition: Type.h:214
llvm::AddressSpace
AddressSpace
Definition: NVPTXBaseInfo.h:21
llvm::None
const NoneType None
Definition: None.h:24
llvm::GlobalValue::hasDefaultVisibility
bool hasDefaultVisibility() const
Definition: GlobalValue.h:243
llvm::GlobalVariable::dropAllReferences
void dropAllReferences()
Drop all references in preparation to destroy the GlobalVariable.
Definition: Globals.cpp:497
llvm::GlobalObject::HasSectionHashEntryBit
@ HasSectionHashEntryBit
Definition: GlobalObject.h:54
llvm::function_ref
An efficient, type-erasing, non-owning reference to a callable.
Definition: STLFunctionalExtras.h:36
llvm::StringRef::empty
constexpr bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:134
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:103
llvm::GlobalValue
Definition: GlobalValue.h:44
llvm::GlobalValue::canBenefitFromLocalAlias
bool canBenefitFromLocalAlias() const
Definition: Globals.cpp:109
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:285
llvm::GlobalValue::getParent
Module * getParent()
Get the module that this global value is contained inside of...
Definition: GlobalValue.h:644
llvm::DenseMap
Definition: DenseMap.h:714
llvm::LLVMContextImpl::GlobalObjectSections
DenseMap< const GlobalObject *, StringRef > GlobalObjectSections
Collection of per-GlobalObject sections used in this context.
Definition: LLVMContextImpl.h:1503
llvm::GlobalValue::getPartition
StringRef getPartition() const
Definition: Globals.cpp:202
llvm::PointerType
Class to represent pointers.
Definition: DerivedTypes.h:632
llvm::GlobalIFunc::getResolver
const Constant * getResolver() const
Definition: GlobalIFunc.h:70
llvm::GlobalValue::Linkage
unsigned Linkage
Definition: GlobalValue.h:94
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::GlobalValue::isExternalLinkage
static bool isExternalLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:365
llvm::UniqueStringSaver::save
StringRef save(const char *S)
Definition: StringSaver.h:50
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
llvm::MDNode
Metadata node.
Definition: Metadata.h:944
llvm::Value::clearMetadata
void clearMetadata()
Erase all metadata attached to this Value.
Definition: Metadata.cpp:1383
Triple.h
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:42
llvm::GlobalValue::canBeOmittedFromSymbolTable
bool canBeOmittedFromSymbolTable() const
True if GV can be left out of the object symbol table.
Definition: Globals.cpp:390
llvm::GlobalValue::getGlobalValueSubClassData
unsigned getGlobalValueSubClassData() const
Definition: GlobalValue.h:171
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
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:143
llvm::Value::getType
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:255
llvm::GlobalValue::setDLLStorageClass
void setDLLStorageClass(DLLStorageClassTypes C)
Definition: GlobalValue.h:278
llvm::Value::getContext
LLVMContext & getContext() const
All values hold a context through their type.
Definition: Value.cpp:994
llvm::ilist_node_impl::getIterator
self_iterator getIterator()
Definition: ilist_node.h:82
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::GlobalValue::getAliaseeObject
const GlobalObject * getAliaseeObject() const
Definition: Globals.cpp:365
llvm::Value::getName
StringRef getName() const
Return a constant reference to the value's name.
Definition: Value.cpp:308
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:577
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:412
llvm::GlobalValue::eraseFromParent
void eraseFromParent()
This method unlinks 'this' from the containing module and deletes it.
Definition: Globals.cpp:88
llvm::GlobalObject::getAlignment
uint64_t getAlignment() const
FIXME: Remove this function once transition to Align is over.
Definition: GlobalObject.h:70
llvm::GlobalValue::isStrongDefinitionForLinker
bool isStrongDefinitionForLinker() const
Returns true if this global's definition will be the one chosen by the linker.
Definition: GlobalValue.h:619
llvm::Module::getSemanticInterposition
bool getSemanticInterposition() const
Returns whether semantic interposition is to be respected.
Definition: Module.cpp:648
llvm::Module::materialize
llvm::Error materialize(GlobalValue *GV)
Make sure the GlobalValue is fully read.
Definition: Module.cpp:439
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:102
llvm::Module::getIFuncList
const IFuncListType & getIFuncList() const
Get the Module's list of ifuncs (constant).
Definition: Module.h:576
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
llvm::GlobalValue::hasLinkOnceODRLinkage
bool hasLinkOnceODRLinkage() const
Definition: GlobalValue.h:508
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:50
llvm::GlobalValue::ThreadLocalMode
ThreadLocalMode
Definition: GlobalValue.h:191
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:516
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:414
llvm::AMDGPU::SendMsg::Op
Op
Definition: SIDefines.h:348
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:155
GlobalVariable.h
llvm::GlobalValue::getComdat
const Comdat * getComdat() const
Definition: Globals.cpp:181
SanitizerMetadata
GlobalValue::SanitizerMetadata SanitizerMetadata
Definition: Globals.cpp:224
llvm::MCID::Add
@ Add
Definition: MCInstrDesc.h:185
GlobalAlias.h
llvm::GlobalValue::getAddressSpace
unsigned getAddressSpace() const
Definition: Globals.cpp:121
llvm::GlobalValue::setGlobalValueSubClassData
void setGlobalValueSubClassData(unsigned V)
Definition: GlobalValue.h:174
llvm::GlobalValue::isAbsoluteSymbolRef
bool isAbsoluteSymbolRef() const
Returns whether this is a reference to an absolute symbol.
Definition: Globals.cpp:370
llvm::GlobalValue::removeSanitizerMetadata
void removeSanitizerMetadata()
Definition: Globals.cpp:236
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:378
llvm::GlobalAlias::getAliaseeObject
const GlobalObject * getAliaseeObject() const
Definition: Globals.cpp:558
llvm::LLVMContextImpl::Saver
UniqueStringSaver Saver
Definition: LLVMContextImpl.h:1473
llvm::Module::getTargetTriple
const std::string & getTargetTriple() const
Get the target triple which is a string describing the target host.
Definition: Module.h:258
llvm::GlobalVariable::setAttributes
void setAttributes(AttributeSet A)
Set attribute list for this global.
Definition: GlobalVariable.h:237
llvm::GlobalObject::copyAttributesFrom
void copyAttributesFrom(const GlobalObject *Src)
Definition: Globals.cpp:136
llvm::GlobalValue::setPartition
void setPartition(StringRef Part)
Definition: Globals.cpp:208
llvm::GlobalValue::getType
PointerType * getType() const
Global values are always pointers.
Definition: GlobalValue.h:284
DerivedTypes.h
llvm::GlobalValue::getValueType
Type * getValueType() const
Definition: GlobalValue.h:286
llvm::StringRef::str
std::string str() const
str - Get the contents as an std::string.
Definition: StringRef.h:221
llvm::GlobalValue::hasPartition
bool hasPartition() const
Definition: GlobalValue.h:299
llvm::User::Op
Use & Op()
Definition: User.h:133
llvm::GlobalObject::ObjComdat
Comdat * ObjComdat
Definition: GlobalObject.h:51
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:548
llvm::User::getOperand
Value * getOperand(unsigned i) const
Definition: User.h:169
llvm::GlobalObject::setAlignment
void setAlignment(MaybeAlign Align)
Definition: Globals.cpp:126
llvm::GlobalVariable::removeFromParent
void removeFromParent()
removeFromParent - This method unlinks 'this' from the containing module, but does not delete it.
Definition: Globals.cpp:460
llvm::GlobalIFunc::getResolverFunction
const Function * getResolverFunction() const
Definition: Globals.cpp:591
llvm::GlobalValue::isDSOLocal
bool isDSOLocal() const
Definition: GlobalValue.h:295
llvm::GlobalIFunc
Definition: GlobalIFunc.h:34
llvm::GlobalValue::setVisibility
void setVisibility(VisibilityTypes V)
Definition: GlobalValue.h:248
llvm::GlobalValue::Parent
Module * Parent
Definition: GlobalValue.h:179
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
llvm::GlobalIFunc::eraseFromParent
void eraseFromParent()
This method unlinks 'this' from the containing module and deletes it.
Definition: Globals.cpp:587
llvm::GlobalAlias::removeFromParent
void removeFromParent()
removeFromParent - This method unlinks 'this' from the containing module, but does not delete it.
Definition: Globals.cpp:544
llvm::GlobalAlias::setAliasee
void setAliasee(Constant *Aliasee)
These methods retrieve and set alias target.
Definition: Globals.cpp:552
llvm::GlobalVariable::setInitializer
void setInitializer(Constant *InitVal)
setInitializer - Sets the initializer for this global variable, removing any existing initializer if ...
Definition: Globals.cpp:468