LLVM  15.0.0git
Module.cpp
Go to the documentation of this file.
1 //===- Module.cpp - Implement the Module 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 Module class for the IR library.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "llvm/IR/Module.h"
15 #include "llvm/ADT/Optional.h"
16 #include "llvm/ADT/SmallString.h"
17 #include "llvm/ADT/SmallVector.h"
18 #include "llvm/ADT/StringMap.h"
19 #include "llvm/ADT/StringRef.h"
20 #include "llvm/ADT/Twine.h"
21 #include "llvm/IR/Attributes.h"
22 #include "llvm/IR/Comdat.h"
23 #include "llvm/IR/Constants.h"
24 #include "llvm/IR/DataLayout.h"
26 #include "llvm/IR/DerivedTypes.h"
27 #include "llvm/IR/Function.h"
28 #include "llvm/IR/GVMaterializer.h"
29 #include "llvm/IR/GlobalAlias.h"
30 #include "llvm/IR/GlobalIFunc.h"
31 #include "llvm/IR/GlobalValue.h"
32 #include "llvm/IR/GlobalVariable.h"
33 #include "llvm/IR/LLVMContext.h"
34 #include "llvm/IR/Metadata.h"
37 #include "llvm/IR/Type.h"
38 #include "llvm/IR/TypeFinder.h"
39 #include "llvm/IR/Value.h"
41 #include "llvm/Support/Casting.h"
42 #include "llvm/Support/CodeGen.h"
43 #include "llvm/Support/Error.h"
45 #include "llvm/Support/Path.h"
48 #include <algorithm>
49 #include <cassert>
50 #include <cstdint>
51 #include <memory>
52 #include <utility>
53 #include <vector>
54 
55 using namespace llvm;
56 
57 //===----------------------------------------------------------------------===//
58 // Methods to implement the globals and functions lists.
59 //
60 
61 // Explicit instantiations of SymbolTableListTraits since some of the methods
62 // are not in the public header file.
67 
68 //===----------------------------------------------------------------------===//
69 // Primitive Module methods.
70 //
71 
73  : Context(C), ValSymTab(std::make_unique<ValueSymbolTable>(-1)),
74  ModuleID(std::string(MID)), SourceFileName(std::string(MID)), DL("") {
75  Context.addModule(this);
76 }
77 
79  Context.removeModule(this);
81  GlobalList.clear();
82  FunctionList.clear();
83  AliasList.clear();
84  IFuncList.clear();
85 }
86 
87 std::unique_ptr<RandomNumberGenerator>
89  SmallString<32> Salt(Name);
90 
91  // This RNG is guaranteed to produce the same random stream only
92  // when the Module ID and thus the input filename is the same. This
93  // might be problematic if the input filename extension changes
94  // (e.g. from .c to .bc or .ll).
95  //
96  // We could store this salt in NamedMetadata, but this would make
97  // the parameter non-const. This would unfortunately make this
98  // interface unusable by any Machine passes, since they only have a
99  // const reference to their IR Module. Alternatively we can always
100  // store salt metadata from the Module constructor.
102 
103  return std::unique_ptr<RandomNumberGenerator>(
104  new RandomNumberGenerator(Salt));
105 }
106 
107 /// getNamedValue - Return the first global value in the module with
108 /// the specified name, of arbitrary type. This method returns null
109 /// if a global with the specified name is not found.
111  return cast_or_null<GlobalValue>(getValueSymbolTable().lookup(Name));
112 }
113 
114 unsigned Module::getNumNamedValues() const {
115  return getValueSymbolTable().size();
116 }
117 
118 /// getMDKindID - Return a unique non-zero ID for the specified metadata kind.
119 /// This ID is uniqued across modules in the current LLVMContext.
121  return Context.getMDKindID(Name);
122 }
123 
124 /// getMDKindNames - Populate client supplied SmallVector with the name for
125 /// custom metadata IDs registered in this LLVMContext. ID #0 is not used,
126 /// so it is filled in as an empty string.
128  return Context.getMDKindNames(Result);
129 }
130 
132  return Context.getOperandBundleTags(Result);
133 }
134 
135 //===----------------------------------------------------------------------===//
136 // Methods for easy access to the functions in the module.
137 //
138 
139 // getOrInsertFunction - Look up the specified function in the module symbol
140 // table. If it does not exist, add a prototype for the function and return
141 // it. This is nice because it allows most passes to get away with not handling
142 // the symbol table directly for this common task.
143 //
146  // See if we have a definition for the specified function already.
148  if (!F) {
149  // Nope, add it
152  if (!New->isIntrinsic()) // Intrinsics get attrs set on construction
153  New->setAttributes(AttributeList);
154  FunctionList.push_back(New);
155  return {Ty, New}; // Return the new prototype.
156  }
157 
158  // If the function exists but has the wrong type, return a bitcast to the
159  // right type.
160  auto *PTy = PointerType::get(Ty, F->getAddressSpace());
161  if (F->getType() != PTy)
162  return {Ty, ConstantExpr::getBitCast(F, PTy)};
163 
164  // Otherwise, we just found the existing function or a prototype.
165  return {Ty, F};
166 }
167 
169  return getOrInsertFunction(Name, Ty, AttributeList());
170 }
171 
172 // getFunction - Look up the specified function in the module symbol table.
173 // If it does not exist, return null.
174 //
176  return dyn_cast_or_null<Function>(getNamedValue(Name));
177 }
178 
179 //===----------------------------------------------------------------------===//
180 // Methods for easy access to the global variables in the module.
181 //
182 
183 /// getGlobalVariable - Look up the specified global variable in the module
184 /// symbol table. If it does not exist, return null. The type argument
185 /// should be the underlying type of the global, i.e., it should not have
186 /// the top-level PointerType, which represents the address of the global.
187 /// If AllowLocal is set to true, this function will return types that
188 /// have an local. By default, these types are not returned.
189 ///
191  bool AllowLocal) const {
192  if (GlobalVariable *Result =
193  dyn_cast_or_null<GlobalVariable>(getNamedValue(Name)))
194  if (AllowLocal || !Result->hasLocalLinkage())
195  return Result;
196  return nullptr;
197 }
198 
199 /// getOrInsertGlobal - Look up the specified global in the module symbol table.
200 /// 1. If it does not exist, add a declaration of the global and return it.
201 /// 2. Else, the global exists but has the wrong type: return the function
202 /// with a constantexpr cast to the right type.
203 /// 3. Finally, if the existing global is the correct declaration, return the
204 /// existing global.
206  StringRef Name, Type *Ty,
207  function_ref<GlobalVariable *()> CreateGlobalCallback) {
208  // See if we have a definition for the specified global already.
209  GlobalVariable *GV = dyn_cast_or_null<GlobalVariable>(getNamedValue(Name));
210  if (!GV)
211  GV = CreateGlobalCallback();
212  assert(GV && "The CreateGlobalCallback is expected to create a global");
213 
214  // If the variable exists but has the wrong type, return a bitcast to the
215  // right type.
216  Type *GVTy = GV->getType();
218  if (GVTy != PTy)
219  return ConstantExpr::getBitCast(GV, PTy);
220 
221  // Otherwise, we just found the existing function or a prototype.
222  return GV;
223 }
224 
225 // Overload to construct a global variable using its constructor's defaults.
227  return getOrInsertGlobal(Name, Ty, [&] {
228  return new GlobalVariable(*this, Ty, false, GlobalVariable::ExternalLinkage,
229  nullptr, Name);
230  });
231 }
232 
233 //===----------------------------------------------------------------------===//
234 // Methods for easy access to the global variables in the module.
235 //
236 
237 // getNamedAlias - Look up the specified global in the module symbol table.
238 // If it does not exist, return null.
239 //
241  return dyn_cast_or_null<GlobalAlias>(getNamedValue(Name));
242 }
243 
245  return dyn_cast_or_null<GlobalIFunc>(getNamedValue(Name));
246 }
247 
248 /// getNamedMetadata - Return the first NamedMDNode in the module with the
249 /// specified name. This method returns null if a NamedMDNode with the
250 /// specified name is not found.
252  SmallString<256> NameData;
253  StringRef NameRef = Name.toStringRef(NameData);
254  return NamedMDSymTab.lookup(NameRef);
255 }
256 
257 /// getOrInsertNamedMetadata - Return the first named MDNode in the module
258 /// with the specified name. This method returns a new NamedMDNode if a
259 /// NamedMDNode with the specified name is not found.
261  NamedMDNode *&NMD = NamedMDSymTab[Name];
262  if (!NMD) {
263  NMD = new NamedMDNode(Name);
264  NMD->setParent(this);
265  NamedMDList.push_back(NMD);
266  }
267  return NMD;
268 }
269 
270 /// eraseNamedMetadata - Remove the given NamedMDNode from this module and
271 /// delete it.
273  NamedMDSymTab.erase(NMD->getName());
274  NamedMDList.erase(NMD->getIterator());
275 }
276 
278  if (ConstantInt *Behavior = mdconst::dyn_extract_or_null<ConstantInt>(MD)) {
279  uint64_t Val = Behavior->getLimitedValue();
280  if (Val >= ModFlagBehaviorFirstVal && Val <= ModFlagBehaviorLastVal) {
281  MFB = static_cast<ModFlagBehavior>(Val);
282  return true;
283  }
284  }
285  return false;
286 }
287 
289  MDString *&Key, Metadata *&Val) {
290  if (ModFlag.getNumOperands() < 3)
291  return false;
292  if (!isValidModFlagBehavior(ModFlag.getOperand(0), MFB))
293  return false;
294  MDString *K = dyn_cast_or_null<MDString>(ModFlag.getOperand(1));
295  if (!K)
296  return false;
297  Key = K;
298  Val = ModFlag.getOperand(2);
299  return true;
300 }
301 
302 /// getModuleFlagsMetadata - Returns the module flags in the provided vector.
303 void Module::
305  const NamedMDNode *ModFlags = getModuleFlagsMetadata();
306  if (!ModFlags) return;
307 
308  for (const MDNode *Flag : ModFlags->operands()) {
309  ModFlagBehavior MFB;
310  MDString *Key = nullptr;
311  Metadata *Val = nullptr;
312  if (isValidModuleFlag(*Flag, MFB, Key, Val)) {
313  // Check the operands of the MDNode before accessing the operands.
314  // The verifier will actually catch these failures.
315  Flags.push_back(ModuleFlagEntry(MFB, Key, Val));
316  }
317  }
318 }
319 
320 /// Return the corresponding value if Key appears in module flags, otherwise
321 /// return null.
324  getModuleFlagsMetadata(ModuleFlags);
325  for (const ModuleFlagEntry &MFE : ModuleFlags) {
326  if (Key == MFE.Key->getString())
327  return MFE.Val;
328  }
329  return nullptr;
330 }
331 
332 /// getModuleFlagsMetadata - Returns the NamedMDNode in the module that
333 /// represents module-level flags. This method returns null if there are no
334 /// module-level flags.
336  return getNamedMetadata("llvm.module.flags");
337 }
338 
339 /// getOrInsertModuleFlagsMetadata - Returns the NamedMDNode in the module that
340 /// represents module-level flags. If module-level flags aren't found, it
341 /// creates the named metadata that contains them.
343  return getOrInsertNamedMetadata("llvm.module.flags");
344 }
345 
346 /// addModuleFlag - Add a module-level flag to the module-level flags
347 /// metadata. It will create the module-level flags named metadata if it doesn't
348 /// already exist.
350  Metadata *Val) {
351  Type *Int32Ty = Type::getInt32Ty(Context);
352  Metadata *Ops[3] = {
354  MDString::get(Context, Key), Val};
356 }
358  Constant *Val) {
359  addModuleFlag(Behavior, Key, ConstantAsMetadata::get(Val));
360 }
362  uint32_t Val) {
363  Type *Int32Ty = Type::getInt32Ty(Context);
364  addModuleFlag(Behavior, Key, ConstantInt::get(Int32Ty, Val));
365 }
367  assert(Node->getNumOperands() == 3 &&
368  "Invalid number of operands for module flag!");
369  assert(mdconst::hasa<ConstantInt>(Node->getOperand(0)) &&
370  isa<MDString>(Node->getOperand(1)) &&
371  "Invalid operand types for module flag!");
373 }
374 
376  Metadata *Val) {
378  // Replace the flag if it already exists.
379  for (unsigned I = 0, E = ModFlags->getNumOperands(); I != E; ++I) {
380  MDNode *Flag = ModFlags->getOperand(I);
381  ModFlagBehavior MFB;
382  MDString *K = nullptr;
383  Metadata *V = nullptr;
384  if (isValidModuleFlag(*Flag, MFB, K, V) && K->getString() == Key) {
385  Flag->replaceOperandWith(2, Val);
386  return;
387  }
388  }
389  addModuleFlag(Behavior, Key, Val);
390 }
391 
393  DL.reset(Desc);
394 }
395 
396 void Module::setDataLayout(const DataLayout &Other) { DL = Other; }
397 
398 const DataLayout &Module::getDataLayout() const { return DL; }
399 
401  return cast<DICompileUnit>(CUs->getOperand(Idx));
402 }
404  return cast<DICompileUnit>(CUs->getOperand(Idx));
405 }
406 
407 void Module::debug_compile_units_iterator::SkipNoDebugCUs() {
408  while (CUs && (Idx < CUs->getNumOperands()) &&
409  ((*this)->getEmissionKind() == DICompileUnit::NoDebug))
410  ++Idx;
411 }
412 
414  return concat<GlobalObject>(functions(), globals());
415 }
417 Module::global_objects() const {
418  return concat<const GlobalObject>(functions(), globals());
419 }
420 
422  return concat<GlobalValue>(functions(), globals(), aliases(), ifuncs());
423 }
425 Module::global_values() const {
426  return concat<const GlobalValue>(functions(), globals(), aliases(), ifuncs());
427 }
428 
429 //===----------------------------------------------------------------------===//
430 // Methods to control the materialization of GlobalValues in the Module.
431 //
433  assert(!Materializer &&
434  "Module already has a GVMaterializer. Call materializeAll"
435  " to clear it out before setting another one.");
436  Materializer.reset(GVM);
437 }
438 
440  if (!Materializer)
441  return Error::success();
442 
443  return Materializer->materialize(GV);
444 }
445 
447  if (!Materializer)
448  return Error::success();
449  std::unique_ptr<GVMaterializer> M = std::move(Materializer);
450  return M->materializeModule();
451 }
452 
454  if (!Materializer)
455  return Error::success();
456  return Materializer->materializeMetadata();
457 }
458 
459 //===----------------------------------------------------------------------===//
460 // Other module related stuff.
461 //
462 
463 std::vector<StructType *> Module::getIdentifiedStructTypes() const {
464  // If we have a materializer, it is possible that some unread function
465  // uses a type that is currently not visible to a TypeFinder, so ask
466  // the materializer which types it created.
467  if (Materializer)
468  return Materializer->getIdentifiedStructTypes();
469 
470  std::vector<StructType *> Ret;
471  TypeFinder SrcStructTypes;
472  SrcStructTypes.run(*this, true);
473  Ret.assign(SrcStructTypes.begin(), SrcStructTypes.end());
474  return Ret;
475 }
476 
478  const FunctionType *Proto) {
479  auto Encode = [&BaseName](unsigned Suffix) {
480  return (Twine(BaseName) + "." + Twine(Suffix)).str();
481  };
482 
483  {
484  // fast path - the prototype is already known
485  auto UinItInserted = UniquedIntrinsicNames.insert({{Id, Proto}, 0});
486  if (!UinItInserted.second)
487  return Encode(UinItInserted.first->second);
488  }
489 
490  // Not known yet. A new entry was created with index 0. Check if there already
491  // exists a matching declaration, or select a new entry.
492 
493  // Start looking for names with the current known maximum count (or 0).
494  auto NiidItInserted = CurrentIntrinsicIds.insert({BaseName, 0});
495  unsigned Count = NiidItInserted.first->second;
496 
497  // This might be slow if a whole population of intrinsics already existed, but
498  // we cache the values for later usage.
499  std::string NewName;
500  while (true) {
501  NewName = Encode(Count);
502  GlobalValue *F = getNamedValue(NewName);
503  if (!F) {
504  // Reserve this entry for the new proto
505  UniquedIntrinsicNames[{Id, Proto}] = Count;
506  break;
507  }
508 
509  // A declaration with this name already exists. Remember it.
510  FunctionType *FT = dyn_cast<FunctionType>(F->getValueType());
511  auto UinItInserted = UniquedIntrinsicNames.insert({{Id, FT}, Count});
512  if (FT == Proto) {
513  // It was a declaration for our prototype. This entry was allocated in the
514  // beginning. Update the count to match the existing declaration.
515  UinItInserted.first->second = Count;
516  break;
517  }
518 
519  ++Count;
520  }
521 
522  NiidItInserted.first->second = Count + 1;
523 
524  return NewName;
525 }
526 
527 // dropAllReferences() - This function causes all the subelements to "let go"
528 // of all references that they are maintaining. This allows one to 'delete' a
529 // whole module at a time, even though there may be circular references... first
530 // all references are dropped, and all use counts go to zero. Then everything
531 // is deleted for real. Note that no operations are valid on an object that
532 // has "dropped all references", except operator delete.
533 //
535  for (Function &F : *this)
536  F.dropAllReferences();
537 
538  for (GlobalVariable &GV : globals())
539  GV.dropAllReferences();
540 
541  for (GlobalAlias &GA : aliases())
542  GA.dropAllReferences();
543 
544  for (GlobalIFunc &GIF : ifuncs())
545  GIF.dropAllReferences();
546 }
547 
549  auto *Val =
550  cast_or_null<ConstantAsMetadata>(getModuleFlag("NumRegisterParameters"));
551  if (!Val)
552  return 0;
553  return cast<ConstantInt>(Val->getValue())->getZExtValue();
554 }
555 
556 unsigned Module::getDwarfVersion() const {
557  auto *Val = cast_or_null<ConstantAsMetadata>(getModuleFlag("Dwarf Version"));
558  if (!Val)
559  return 0;
560  return cast<ConstantInt>(Val->getValue())->getZExtValue();
561 }
562 
563 bool Module::isDwarf64() const {
564  auto *Val = cast_or_null<ConstantAsMetadata>(getModuleFlag("DWARF64"));
565  return Val && cast<ConstantInt>(Val->getValue())->isOne();
566 }
567 
568 unsigned Module::getCodeViewFlag() const {
569  auto *Val = cast_or_null<ConstantAsMetadata>(getModuleFlag("CodeView"));
570  if (!Val)
571  return 0;
572  return cast<ConstantInt>(Val->getValue())->getZExtValue();
573 }
574 
575 unsigned Module::getInstructionCount() const {
576  unsigned NumInstrs = 0;
577  for (const Function &F : FunctionList)
578  NumInstrs += F.getInstructionCount();
579  return NumInstrs;
580 }
581 
583  auto &Entry = *ComdatSymTab.insert(std::make_pair(Name, Comdat())).first;
584  Entry.second.Name = &Entry;
585  return &Entry.second;
586 }
587 
589  auto *Val = cast_or_null<ConstantAsMetadata>(getModuleFlag("PIC Level"));
590 
591  if (!Val)
592  return PICLevel::NotPIC;
593 
594  return static_cast<PICLevel::Level>(
595  cast<ConstantInt>(Val->getValue())->getZExtValue());
596 }
597 
599  addModuleFlag(ModFlagBehavior::Max, "PIC Level", PL);
600 }
601 
603  auto *Val = cast_or_null<ConstantAsMetadata>(getModuleFlag("PIE Level"));
604 
605  if (!Val)
606  return PIELevel::Default;
607 
608  return static_cast<PIELevel::Level>(
609  cast<ConstantInt>(Val->getValue())->getZExtValue());
610 }
611 
613  addModuleFlag(ModFlagBehavior::Max, "PIE Level", PL);
614 }
615 
617  auto *Val = cast_or_null<ConstantAsMetadata>(getModuleFlag("Code Model"));
618 
619  if (!Val)
620  return None;
621 
622  return static_cast<CodeModel::Model>(
623  cast<ConstantInt>(Val->getValue())->getZExtValue());
624 }
625 
627  // Linking object files with different code models is undefined behavior
628  // because the compiler would have to generate additional code (to span
629  // longer jumps) if a larger code model is used with a smaller one.
630  // Therefore we will treat attempts to mix code models as an error.
631  addModuleFlag(ModFlagBehavior::Error, "Code Model", CL);
632 }
633 
636  setModuleFlag(ModFlagBehavior::Error, "CSProfileSummary", M);
637  else
638  setModuleFlag(ModFlagBehavior::Error, "ProfileSummary", M);
639 }
640 
642  return (IsCS ? getModuleFlag("CSProfileSummary")
643  : getModuleFlag("ProfileSummary"));
644 }
645 
647  Metadata *MF = getModuleFlag("SemanticInterposition");
648 
649  auto *Val = cast_or_null<ConstantAsMetadata>(MF);
650  if (!Val)
651  return false;
652 
653  return cast<ConstantInt>(Val->getValue())->getZExtValue();
654 }
655 
657  addModuleFlag(ModFlagBehavior::Error, "SemanticInterposition", SI);
658 }
659 
660 void Module::setOwnedMemoryBuffer(std::unique_ptr<MemoryBuffer> MB) {
661  OwnedMemoryBuffer = std::move(MB);
662 }
663 
665  auto *Val = cast_or_null<ConstantAsMetadata>(getModuleFlag("RtLibUseGOT"));
666  return Val && (cast<ConstantInt>(Val->getValue())->getZExtValue() > 0);
667 }
668 
670  addModuleFlag(ModFlagBehavior::Max, "RtLibUseGOT", 1);
671 }
672 
674  if (auto *Val = cast_or_null<ConstantAsMetadata>(getModuleFlag("uwtable")))
675  return UWTableKind(cast<ConstantInt>(Val->getValue())->getZExtValue());
676  return UWTableKind::None;
677 }
678 
680  addModuleFlag(ModFlagBehavior::Max, "uwtable", uint32_t(Kind));
681 }
682 
684  auto *Val = cast_or_null<ConstantAsMetadata>(getModuleFlag("frame-pointer"));
685  return static_cast<FramePointerKind>(
686  Val ? cast<ConstantInt>(Val->getValue())->getZExtValue() : 0);
687 }
688 
690  addModuleFlag(ModFlagBehavior::Max, "frame-pointer", static_cast<int>(Kind));
691 }
692 
694  Metadata *MD = getModuleFlag("stack-protector-guard");
695  if (auto *MDS = dyn_cast_or_null<MDString>(MD))
696  return MDS->getString();
697  return {};
698 }
699 
702  addModuleFlag(ModFlagBehavior::Error, "stack-protector-guard", ID);
703 }
704 
706  Metadata *MD = getModuleFlag("stack-protector-guard-reg");
707  if (auto *MDS = dyn_cast_or_null<MDString>(MD))
708  return MDS->getString();
709  return {};
710 }
711 
714  addModuleFlag(ModFlagBehavior::Error, "stack-protector-guard-reg", ID);
715 }
716 
718  Metadata *MD = getModuleFlag("stack-protector-guard-offset");
719  if (auto *CI = mdconst::dyn_extract_or_null<ConstantInt>(MD))
720  return CI->getSExtValue();
721  return INT_MAX;
722 }
723 
725  addModuleFlag(ModFlagBehavior::Error, "stack-protector-guard-offset", Offset);
726 }
727 
729  Metadata *MD = getModuleFlag("override-stack-alignment");
730  if (auto *CI = mdconst::dyn_extract_or_null<ConstantInt>(MD))
731  return CI->getZExtValue();
732  return 0;
733 }
734 
736  addModuleFlag(ModFlagBehavior::Error, "override-stack-alignment", Align);
737 }
738 
739 static void addSDKVersionMD(const VersionTuple &V, Module &M, StringRef Name) {
740  SmallVector<unsigned, 3> Entries;
741  Entries.push_back(V.getMajor());
742  if (auto Minor = V.getMinor()) {
743  Entries.push_back(*Minor);
744  if (auto Subminor = V.getSubminor())
745  Entries.push_back(*Subminor);
746  // Ignore the 'build' component as it can't be represented in the object
747  // file.
748  }
749  M.addModuleFlag(Module::ModFlagBehavior::Warning, Name,
750  ConstantDataArray::get(M.getContext(), Entries));
751 }
752 
754  addSDKVersionMD(V, *this, "SDK Version");
755 }
756 
758  auto *CM = dyn_cast_or_null<ConstantAsMetadata>(MD);
759  if (!CM)
760  return {};
761  auto *Arr = dyn_cast_or_null<ConstantDataArray>(CM->getValue());
762  if (!Arr)
763  return {};
764  auto getVersionComponent = [&](unsigned Index) -> Optional<unsigned> {
765  if (Index >= Arr->getNumElements())
766  return None;
767  return (unsigned)Arr->getElementAsInteger(Index);
768  };
769  auto Major = getVersionComponent(0);
770  if (!Major)
771  return {};
772  VersionTuple Result = VersionTuple(*Major);
773  if (auto Minor = getVersionComponent(1)) {
774  Result = VersionTuple(*Major, *Minor);
775  if (auto Subminor = getVersionComponent(2)) {
776  Result = VersionTuple(*Major, *Minor, *Subminor);
777  }
778  }
779  return Result;
780 }
781 
783  return getSDKVersionMD(getModuleFlag("SDK Version"));
784 }
785 
787  const Module &M, SmallVectorImpl<GlobalValue *> &Vec, bool CompilerUsed) {
788  const char *Name = CompilerUsed ? "llvm.compiler.used" : "llvm.used";
789  GlobalVariable *GV = M.getGlobalVariable(Name);
790  if (!GV || !GV->hasInitializer())
791  return GV;
792 
793  const ConstantArray *Init = cast<ConstantArray>(GV->getInitializer());
794  for (Value *Op : Init->operands()) {
795  GlobalValue *G = cast<GlobalValue>(Op->stripPointerCasts());
796  Vec.push_back(G);
797  }
798  return GV;
799 }
800 
802  if (auto *SummaryMD = getProfileSummary(/*IsCS*/ false)) {
803  std::unique_ptr<ProfileSummary> ProfileSummary(
804  ProfileSummary::getFromMD(SummaryMD));
805  if (ProfileSummary) {
808  return;
809  uint64_t BlockCount = Index.getBlockCount();
810  uint32_t NumCounts = ProfileSummary->getNumCounts();
811  if (!NumCounts)
812  return;
813  double Ratio = (double)BlockCount / NumCounts;
817  }
818  }
819 }
820 
822  if (const auto *MD = getModuleFlag("darwin.target_variant.triple"))
823  return cast<MDString>(MD)->getString();
824  return "";
825 }
826 
828  addModuleFlag(ModFlagBehavior::Override, "darwin.target_variant.triple",
830 }
831 
833  return getSDKVersionMD(getModuleFlag("darwin.target_variant.SDK Version"));
834 }
835 
837  addSDKVersionMD(Version, *this, "darwin.target_variant.SDK Version");
838 }
llvm::Module::global_values
iterator_range< global_value_iterator > global_values()
Definition: Module.cpp:421
MemoryBuffer.h
Int32Ty
IntegerType * Int32Ty
Definition: NVVMIntrRange.cpp:67
llvm::Module::getOrInsertModuleFlagsMetadata
NamedMDNode * getOrInsertModuleFlagsMetadata()
Returns the NamedMDNode in the module that represents module-level flags.
Definition: Module.cpp:342
GlobalIFunc.h
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
llvm::Module::getModuleFlagsMetadata
NamedMDNode * getModuleFlagsMetadata() const
Returns the NamedMDNode in the module that represents module-level flags.
Definition: Module.cpp:335
llvm::Module::setFramePointer
void setFramePointer(FramePointerKind Kind)
Definition: Module.cpp:689
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
Comdat.h
llvm::NamedMDNode
A tuple of MDNodes.
Definition: Metadata.h:1488
llvm::lltok::Error
@ Error
Definition: LLToken.h:21
Optional.h
llvm::DataLayout
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:113
llvm::Module::getInstructionCount
unsigned getInstructionCount() const
Returns the number of non-debug IR instructions in the module.
Definition: Module.cpp:575
llvm::Module::getStackProtectorGuard
StringRef getStackProtectorGuard() const
Get/set what kind of stack protector guard to use.
Definition: Module.cpp:693
llvm::ProfileSummary::Kind
Kind
Definition: ProfileSummary.h:47
Metadata.h
llvm::NamedMDNode::getNumOperands
unsigned getNumOperands() const
Definition: Metadata.cpp:1150
llvm::GVMaterializer
Definition: GVMaterializer.h:28
llvm::Module::isDwarf64
bool isDwarf64() const
Returns the DWARF format by checking module flags.
Definition: Module.cpp:563
llvm::iplist_impl::push_back
void push_back(pointer val)
Definition: ilist.h:314
DebugInfoMetadata.h
llvm::Module::ModFlagBehaviorLastVal
@ ModFlagBehaviorLastVal
Definition: Module.h:154
T
llvm::DataLayout::getProgramAddressSpace
unsigned getProgramAddressSpace() const
Definition: DataLayout.h:295
llvm::Function
Definition: Function.h:60
llvm::TypeFinder::end
iterator end()
Definition: TypeFinder.h:52
StringRef.h
llvm::ProfileSummary::getFromMD
static ProfileSummary * getFromMD(Metadata *MD)
Construct profile summary from metdata.
Definition: ProfileSummary.cpp:194
llvm::Module::ifuncs
iterator_range< ifunc_iterator > ifuncs()
Definition: Module.h:672
llvm::Module::setMaterializer
void setMaterializer(GVMaterializer *GVM)
Sets the GVMaterializer to GVM.
Definition: Module.cpp:432
llvm::Module::ModFlagBehaviorFirstVal
@ ModFlagBehaviorFirstVal
Definition: Module.h:153
llvm::PointerType::get
static PointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space.
Definition: Type.cpp:727
double
into xmm2 addss xmm2 xmm1 xmm3 addss xmm3 movaps xmm0 unpcklps xmm0 ret seems silly when it could just be one addps Expand libm rounding functions main should enable SSE DAZ mode and other fast SSE modes Think about doing i64 math in SSE regs on x86 This testcase should have no SSE instructions in and only one load from a constant double
Definition: README-SSE.txt:85
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1185
llvm::UWTableKind::None
@ None
No unwind table requested.
llvm::Module::getCodeViewFlag
unsigned getCodeViewFlag() const
Returns the CodeView Version by checking module flags.
Definition: Module.cpp:568
Path.h
llvm::Module::~Module
~Module()
The module destructor. This will dropAllReferences.
Definition: Module.cpp:78
llvm::Module::getStackProtectorGuardReg
StringRef getStackProtectorGuardReg() const
Get/set which register to use as the stack protector guard register.
Definition: Module.cpp:705
llvm::Module::getRtLibUseGOT
bool getRtLibUseGOT() const
Returns true if PLT should be avoided for RTLib calls.
Definition: Module.cpp:664
VersionTuple.h
llvm::Type::getPointerAddressSpace
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
Definition: DerivedTypes.h:729
llvm::X86Disassembler::Reg
Reg
All possible values of the reg field in the ModR/M byte.
Definition: X86DisassemblerDecoder.h:462
llvm::Error::success
static ErrorSuccess success()
Create a success value.
Definition: Error.h:329
llvm::GlobalVariable
Definition: GlobalVariable.h:39
llvm::ConstantExpr::getBitCast
static Constant * getBitCast(Constant *C, Type *Ty, bool OnlyIfReduced=false)
Definition: Constants.cpp:2266
RandomNumberGenerator.h
llvm::GlobalAlias
Definition: GlobalAlias.h:28
Error.h
llvm::Module::isValidModFlagBehavior
static bool isValidModFlagBehavior(Metadata *MD, ModFlagBehavior &MFB)
Checks if Metadata represents a valid ModFlagBehavior, and stores the converted result in MFB.
Definition: Module.cpp:277
llvm::Module::getModuleFlag
Metadata * getModuleFlag(StringRef Key) const
Return the corresponding value if Key appears in module flags, otherwise return null.
Definition: Module.cpp:322
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
llvm::Module::getCodeModel
Optional< CodeModel::Model > getCodeModel() const
Returns the code model (tiny, small, kernel, medium or large model)
Definition: Module.cpp:616
Module.h
llvm::AttributeList
Definition: Attributes.h:425
llvm::Optional< CodeModel::Model >
llvm::Module::setSDKVersion
void setSDKVersion(const VersionTuple &V)
Attach a build SDK version metadata to this module.
Definition: Module.cpp:753
llvm::ConstantAsMetadata::get
static ConstantAsMetadata * get(Constant *C)
Definition: Metadata.h:420
llvm::Module::getOrInsertFunction
FunctionCallee getOrInsertFunction(StringRef Name, FunctionType *T, AttributeList AttributeList)
Look up the specified function in the module symbol table.
Definition: Module.cpp:144
llvm::Module::global_objects
iterator_range< global_object_iterator > global_objects()
Definition: Module.cpp:413
llvm::Module::getProfileSummary
Metadata * getProfileSummary(bool IsCS) const
Returns profile summary metadata.
Definition: Module.cpp:641
llvm::MipsISD::Ret
@ Ret
Definition: MipsISelLowering.h:119
llvm::Module::getMDKindNames
void getMDKindNames(SmallVectorImpl< StringRef > &Result) const
Populate client supplied SmallVector with the name for custom metadata IDs registered in this LLVMCon...
Definition: Module.cpp:127
llvm::Module::setStackProtectorGuard
void setStackProtectorGuard(StringRef Kind)
Definition: Module.cpp:700
llvm::Module::getFunction
Function * getFunction(StringRef Name) const
Look up the specified function in the module symbol table.
Definition: Module.cpp:175
llvm::RandomNumberGenerator
A random number generator.
Definition: RandomNumberGenerator.h:32
llvm::Type::getInt32Ty
static IntegerType * getInt32Ty(LLVMContext &C)
Definition: Type.cpp:239
ModuleSummaryIndex.h
llvm::Module::setOverrideStackAlignment
void setOverrideStackAlignment(unsigned Align)
Definition: Module.cpp:735
llvm::TypeFinder::begin
iterator begin()
Definition: TypeFinder.h:51
llvm::MDNode::get
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition: Metadata.h:1300
llvm::Module::setPIELevel
void setPIELevel(PIELevel::Level PL)
Set the PIE level (small or large model)
Definition: Module.cpp:612
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::collectUsedGlobalVariables
GlobalVariable * collectUsedGlobalVariables(const Module &M, SmallVectorImpl< GlobalValue * > &Vec, bool CompilerUsed)
Given "llvm.used" or "llvm.compiler.used" as a global name, collect the initializer elements of that ...
Definition: Module.cpp:786
llvm::Module::getSDKVersion
VersionTuple getSDKVersion() const
Get the build SDK version metadata.
Definition: Module.cpp:782
llvm::iplist_impl::erase
iterator erase(iterator where)
Definition: ilist.h:268
llvm::ProfileSummary::isPartialProfile
bool isPartialProfile() const
Definition: ProfileSummary.h:96
llvm::VersionTuple::getMajor
unsigned getMajor() const
Retrieve the major version number.
Definition: VersionTuple.h:72
llvm::MDNode::getNumOperands
unsigned getNumOperands() const
Return number of MDNode operands.
Definition: Metadata.h:1210
Context
LLVMContext & Context
Definition: NVVMIntrRange.cpp:66
addSDKVersionMD
static void addSDKVersionMD(const VersionTuple &V, Module &M, StringRef Name)
Definition: Module.cpp:739
llvm::Module::setRtLibUseGOT
void setRtLibUseGOT()
Set that PLT should be avoid for RTLib calls.
Definition: Module.cpp:669
llvm::NamedMDNode::addOperand
void addOperand(MDNode *M)
Definition: Metadata.cpp:1160
llvm::ConstantInt
This is the shared class of boolean and integer constants.
Definition: Constants.h:79
llvm::Module::setSemanticInterposition
void setSemanticInterposition(bool)
Set whether semantic interposition is to be respected.
Definition: Module.cpp:656
llvm::UWTableKind
UWTableKind
Definition: CodeGen.h:100
GlobalValue.h
Constants.h
llvm::Module::globals
iterator_range< global_iterator > globals()
Definition: Module.h:614
SmallString.h
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::ProfileSummary::getNumCounts
uint32_t getNumCounts() const
Definition: ProfileSummary.h:91
llvm::Module::setCodeModel
void setCodeModel(CodeModel::Model CL)
Set the code model (tiny, small, kernel, medium or large)
Definition: Module.cpp:626
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::ProfileSummary::getMD
Metadata * getMD(LLVMContext &Context, bool AddPartialField=true, bool AddPartialProfileRatioField=true)
Return summary information as metadata.
Definition: ProfileSummary.cpp:80
llvm::Module::getValueSymbolTable
const ValueSymbolTable & getValueSymbolTable() const
Get the symbol table of global variable and function identifiers.
Definition: Module.h:594
Twine.h
llvm::StringMap::insert
bool insert(MapEntryTy *KeyValue)
insert - Insert the specified key/value pair into the map.
Definition: StringMap.h:276
llvm::NamedMDNode::getName
StringRef getName() const
Definition: Metadata.cpp:1171
llvm::Module::getDarwinTargetVariantTriple
StringRef getDarwinTargetVariantTriple() const
Get the target variant triple which is a string describing a variant of the target host platform.
Definition: Module.cpp:821
TypeFinder.h
SymbolTableListTraitsImpl.h
getSDKVersionMD
static VersionTuple getSDKVersionMD(Metadata *MD)
Definition: Module.cpp:757
llvm::AMDGPU::PALMD::Key
Key
PAL metadata keys.
Definition: AMDGPUMetadata.h:486
GVMaterializer.h
llvm::Module::getNamedAlias
GlobalAlias * getNamedAlias(StringRef Name) const
Return the global alias in the module with the specified name, of arbitrary type.
Definition: Module.cpp:240
llvm::Module::setDarwinTargetVariantSDKVersion
void setDarwinTargetVariantSDKVersion(VersionTuple Version)
Set the target variant version build SDK version metadata.
Definition: Module.cpp:836
llvm::dwarf::Index
Index
Definition: Dwarf.h:472
llvm::ConstantArray
ConstantArray - Constant Array Declarations.
Definition: Constants.h:410
llvm::MCID::Flag
Flag
These should be considered private to the implementation of the MCInstrDesc class.
Definition: MCInstrDesc.h:147
llvm::Module::ModuleFlagEntry
Definition: Module.h:166
llvm::Module::getOrInsertGlobal
Constant * getOrInsertGlobal(StringRef Name, Type *Ty, function_ref< GlobalVariable *()> CreateGlobalCallback)
Look up the specified global in the module symbol table.
Definition: Module.cpp:205
llvm::ValueSymbolTable::size
unsigned size() const
The number of name/type pairs is returned.
Definition: ValueSymbolTable.h:86
llvm::ConstantInt::get
static Constant * get(Type *Ty, uint64_t V, bool IsSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
Definition: Constants.cpp:928
llvm::Module::debug_compile_units_iterator::operator*
DICompileUnit * operator*() const
Definition: Module.cpp:400
llvm::AArch64CC::PL
@ PL
Definition: AArch64BaseInfo.h:260
llvm::VersionTuple
Represents a version number in the form major[.minor[.subminor[.build]]].
Definition: VersionTuple.h:31
llvm::IndexedInstrProf::Version
const uint64_t Version
Definition: InstrProf.h:1027
StringMap.h
llvm::ProfileSummary::PSK_Sample
@ PSK_Sample
Definition: ProfileSummary.h:47
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::Metadata
Root of the metadata hierarchy.
Definition: Metadata.h:62
llvm::None
const NoneType None
Definition: None.h:24
llvm::lltok::Kind
Kind
Definition: LLToken.h:18
llvm::Module::getFramePointer
FramePointerKind getFramePointer() const
Get/set whether synthesized functions should get the "frame-pointer" attribute.
Definition: Module.cpp:683
llvm::CallingConv::ID
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition: CallingConv.h:24
Type.h
llvm::Module::getNamedIFunc
GlobalIFunc * getNamedIFunc(StringRef Name) const
Return the global ifunc in the module with the specified name, of arbitrary type.
Definition: Module.cpp:244
llvm::SmallString< 32 >
ValueSymbolTable.h
llvm::ProfileSummary::getKind
Kind getKind() const
Definition: ProfileSummary.h:82
llvm::Module::getUniqueIntrinsicName
std::string getUniqueIntrinsicName(StringRef BaseName, Intrinsic::ID Id, const FunctionType *Proto)
Return a unique name for an intrinsic whose mangling is based on an unnamed type.
Definition: Module.cpp:477
llvm::CodeModel::Model
Model
Definition: CodeGen.h:28
llvm::Module::getUwtable
UWTableKind getUwtable() const
Get/set whether synthesized functions should get the uwtable attribute.
Definition: Module.cpp:673
llvm::function_ref
An efficient, type-erasing, non-owning reference to a callable.
Definition: STLFunctionalExtras.h:36
llvm::MDNode::getOperand
const MDOperand & getOperand(unsigned I) const
Definition: Metadata.h:1204
G
const DataFlowGraph & G
Definition: RDFGraph.cpp:200
llvm::Module::aliases
iterator_range< alias_iterator > aliases()
Definition: Module.h:654
llvm::GlobalValue
Definition: GlobalValue.h:44
llvm::GlobalVariable::getInitializer
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
Definition: GlobalVariable.h:135
llvm::Module::setPICLevel
void setPICLevel(PICLevel::Level PL)
Set the PIC level (small or large model)
Definition: Module.cpp:598
llvm::Constant
This is an important base class in LLVM.
Definition: Constant.h:41
llvm::Module::getNumberRegisterParameters
unsigned getNumberRegisterParameters() const
Returns the Number of Register ParametersDwarf Version by checking module flags.
Definition: Module.cpp:548
llvm::SymbolTableListTraits
Definition: GlobalAlias.h:26
llvm::StringMap::erase
void erase(iterator I)
Definition: StringMap.h:370
llvm::Module::dropAllReferences
void dropAllReferences()
This function causes all the subinstructions to "let go" of all references that they are maintaining.
Definition: Module.cpp:534
uint64_t
llvm::VersionTuple::getSubminor
Optional< unsigned > getSubminor() const
Retrieve the subminor version number, if provided.
Definition: VersionTuple.h:82
move
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Definition: README.txt:546
llvm::LLVMContext
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:68
I
#define I(x, y, z)
Definition: MD5.cpp:58
llvm::StringMap::lookup
ValueTy lookup(StringRef Key) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
Definition: StringMap.h:234
llvm::PICLevel::NotPIC
@ NotPIC
Definition: CodeGen.h:33
llvm::Module::materializeAll
llvm::Error materializeAll()
Make sure all GlobalValues in this Module are fully read and clear the Materializer.
Definition: Module.cpp:446
llvm::DICompileUnit
Compile unit.
Definition: DebugInfoMetadata.h:1322
llvm::PointerType
Class to represent pointers.
Definition: DerivedTypes.h:632
llvm::ProfileSummary
Definition: ProfileSummary.h:45
llvm::Module::functions
iterator_range< iterator > functions()
Definition: Module.h:636
llvm::Module::getOrInsertComdat
Comdat * getOrInsertComdat(StringRef Name)
Return the Comdat in the module with the specified name.
Definition: Module.cpp:582
llvm::MDString::get
static MDString * get(LLVMContext &Context, StringRef Str)
Definition: Metadata.cpp:497
llvm::Module::setDataLayout
void setDataLayout(StringRef Desc)
Set the data layout.
Definition: Module.cpp:392
llvm::NamedMDNode::getOperand
MDNode * getOperand(unsigned i) const
Definition: Metadata.cpp:1154
llvm::Function::Create
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &N="", Module *M=nullptr)
Definition: Function.h:137
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::VersionTuple::getMinor
Optional< unsigned > getMinor() const
Retrieve the minor version number, if provided.
Definition: VersionTuple.h:75
SI
StandardInstrumentations SI(Debug, VerifyEach)
llvm::FramePointerKind
FramePointerKind
Definition: CodeGen.h:70
llvm::Module::getModuleIdentifier
const std::string & getModuleIdentifier() const
Get the module identifier which is, essentially, the name of the module.
Definition: Module.h:228
llvm::Module::materializeMetadata
llvm::Error materializeMetadata()
Definition: Module.cpp:453
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
llvm::Module::getOverrideStackAlignment
unsigned getOverrideStackAlignment() const
Get/set the stack alignment overridden from the default.
Definition: Module.cpp:728
llvm::MDNode
Metadata node.
Definition: Metadata.h:937
llvm::Module::setModuleFlag
void setModuleFlag(ModFlagBehavior Behavior, StringRef Key, Metadata *Val)
Like addModuleFlag but replaces the old module flag if it already exists.
Definition: Module.cpp:375
llvm::DICompileUnit::NoDebug
@ NoDebug
Definition: DebugInfoMetadata.h:1328
llvm::Module::setOwnedMemoryBuffer
void setOwnedMemoryBuffer(std::unique_ptr< MemoryBuffer > MB)
Take ownership of the given memory buffer.
Definition: Module.cpp:660
llvm::Module::Module
Module(StringRef ModuleID, LLVMContext &C)
The Module constructor.
Definition: Module.cpp:72
DataLayout.h
llvm::PIELevel::Default
@ Default
Definition: CodeGen.h:37
llvm::Module::setStackProtectorGuardReg
void setStackProtectorGuardReg(StringRef Reg)
Definition: Module.cpp:712
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm::TypeFinder::run
void run(const Module &M, bool onlyNamed)
Definition: TypeFinder.cpp:34
llvm::TypeFinder
TypeFinder - Walk over a module, identifying all of the types that are used by the module.
Definition: TypeFinder.h:31
llvm::ConstantDataArray::get
static Constant * get(LLVMContext &Context, ArrayRef< ElementTy > Elts)
get() constructor - Return a constant with array type with an element count and element type matching...
Definition: Constants.h:692
uint32_t
llvm::ilist_node_impl::getIterator
self_iterator getIterator()
Definition: ilist_node.h:82
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition: AArch64SLSHardening.cpp:76
llvm::PICLevel::Level
Level
Definition: CodeGen.h:33
llvm::Module::getNumNamedValues
unsigned getNumNamedValues() const
Return the number of global values in the module.
Definition: Module.cpp:114
llvm::ProfileSummary::PSK_CSInstr
@ PSK_CSInstr
Definition: ProfileSummary.h:47
llvm::Init
Definition: Record.h:281
llvm::Module::getGlobalVariable
GlobalVariable * getGlobalVariable(StringRef Name) const
Look up the specified global variable in the module symbol table.
Definition: Module.h:414
llvm::NamedMDNode::operands
iterator_range< op_iterator > operands()
Definition: Metadata.h:1584
llvm::Module::getOperandBundleTags
void getOperandBundleTags(SmallVectorImpl< StringRef > &Result) const
Populate client supplied SmallVector with the bundle tags registered in this LLVMContext.
Definition: Module.cpp:131
llvm::Module::getSemanticInterposition
bool getSemanticInterposition() const
Returns whether semantic interposition is to be respected.
Definition: Module.cpp:646
llvm::Module::materialize
llvm::Error materialize(GlobalValue *GV)
Make sure the GlobalValue is fully read.
Definition: Module.cpp:439
llvm::Module::setUwtable
void setUwtable(UWTableKind Kind)
Definition: Module.cpp:679
Attributes.h
llvm::Module::debug_compile_units_iterator::operator->
DICompileUnit * operator->() const
Definition: Module.cpp:403
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:83
llvm::LLVMContext::getMDKindNames
void getMDKindNames(SmallVectorImpl< StringRef > &Result) const
getMDKindNames - Populate client supplied SmallVector with the name for custom metadata IDs registere...
Definition: LLVMContext.cpp:285
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:50
std
Definition: BitVector.h:851
llvm::Module::getMDKindID
unsigned getMDKindID(StringRef Name) const
Return a unique non-zero ID for the specified metadata kind.
Definition: Module.cpp:120
llvm::AMDGPU::SendMsg::Op
Op
Definition: SIDefines.h:345
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:155
GlobalVariable.h
llvm::Module::getContext
LLVMContext & getContext() const
Get the global data context.
Definition: Module.h:262
Casting.h
Function.h
llvm::Module::getOrInsertNamedMetadata
NamedMDNode * getOrInsertNamedMetadata(StringRef Name)
Return the named MDNode in the module with the specified name.
Definition: Module.cpp:260
llvm::ProfileSummary::setPartialProfileRatio
void setPartialProfileRatio(double R)
Definition: ProfileSummary.h:98
llvm::Module::getDwarfVersion
unsigned getDwarfVersion() const
Returns the Dwarf Version by checking module flags.
Definition: Module.cpp:556
llvm::Module::getIdentifiedStructTypes
std::vector< StructType * > getIdentifiedStructTypes() const
Definition: Module.cpp:463
llvm::LLVMContext::getOperandBundleTags
void getOperandBundleTags(SmallVectorImpl< StringRef > &Result) const
getOperandBundleTags - Populate client supplied SmallVector with the bundle tags registered in this L...
Definition: LLVMContext.cpp:292
llvm::Module::getPIELevel
PIELevel::Level getPIELevel() const
Returns the PIE level (small or large model)
Definition: Module.cpp:602
llvm::Module::createRNG
std::unique_ptr< RandomNumberGenerator > createRNG(const StringRef Name) const
Get a RandomNumberGenerator salted for use with this module.
Definition: Module.cpp:88
GlobalAlias.h
llvm::Module::getPICLevel
PICLevel::Level getPICLevel() const
Returns the PIC level (small or large model)
Definition: Module.cpp:588
llvm::GlobalValue::ExternalLinkage
@ ExternalLinkage
Externally visible function.
Definition: GlobalValue.h:48
CodeGen.h
llvm::Module::setPartialSampleProfileRatio
void setPartialSampleProfileRatio(const ModuleSummaryIndex &Index)
Set the partial sample profile ratio in the profile summary module flag, if applicable.
Definition: Module.cpp:801
llvm::PIELevel::Level
Level
Definition: CodeGen.h:37
llvm::sys::path::filename
StringRef filename(StringRef path, Style style=Style::native)
Get filename.
Definition: Path.cpp:577
SmallVector.h
llvm::ValueSymbolTable
This class provides a symbol table of name/value pairs.
Definition: ValueSymbolTable.h:37
llvm::Module::addModuleFlag
void addModuleFlag(ModFlagBehavior Behavior, StringRef Key, Metadata *Val)
Add a module-level flag to the module-level flags metadata.
Definition: Module.cpp:349
lookup
static bool lookup(const GsymReader &GR, DataExtractor &Data, uint64_t &Offset, uint64_t BaseAddr, uint64_t Addr, SourceLocations &SrcLocs, llvm::Error &Err)
A Lookup helper functions.
Definition: InlineInfo.cpp:108
llvm::ModuleSummaryIndex
Class to hold module path string table and global value map, and encapsulate methods for operating on...
Definition: ModuleSummaryIndex.h:1087
llvm::Module::getNamedMetadata
NamedMDNode * getNamedMetadata(const Twine &Name) const
Return the first NamedMDNode in the module with the specified name.
Definition: Module.cpp:251
llvm::Module::getStackProtectorGuardOffset
int getStackProtectorGuardOffset() const
Get/set what offset from the stack protector to use.
Definition: Module.cpp:717
llvm::Module::isValidModuleFlag
static bool isValidModuleFlag(const MDNode &ModFlag, ModFlagBehavior &MFB, MDString *&Key, Metadata *&Val)
Check if the given module flag metadata represents a valid module flag, and store the flag behavior,...
Definition: Module.cpp:288
llvm::DataLayout::reset
void reset(StringRef LayoutDescription)
Parse a data layout string (with fallback to default values).
Definition: DataLayout.cpp:180
llvm::iterator_range
A range adaptor for a pair of iterators.
Definition: iterator_range.h:30
llvm::FunctionCallee
A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...
Definition: DerivedTypes.h:165
llvm::SmallVectorImpl< StringRef >
llvm::LLVMContext::getMDKindID
unsigned getMDKindID(StringRef Name) const
getMDKindID - Return a unique non-zero ID for the specified metadata kind.
Definition: LLVMContext.cpp:275
llvm::GlobalValue::getType
PointerType * getType() const
Global values are always pointers.
Definition: GlobalValue.h:276
llvm::Module::getDataLayout
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
Definition: Module.cpp:398
DerivedTypes.h
llvm::Module::setStackProtectorGuardOffset
void setStackProtectorGuardOffset(int Offset)
Definition: Module.cpp:724
llvm::Module::eraseNamedMetadata
void eraseNamedMetadata(NamedMDNode *NMD)
Remove the given NamedMDNode from this module and delete it.
Definition: Module.cpp:272
LLVMContext.h
llvm::Module::setProfileSummary
void setProfileSummary(Metadata *M, ProfileSummary::Kind Kind)
Attach profile summary metadata to this module.
Definition: Module.cpp:634
llvm::MDString::getString
StringRef getString() const
Definition: Metadata.cpp:507
llvm::AMDGPU::VGPRIndexMode::Id
Id
Definition: SIDefines.h:238
SymbolTableListTraits.h
llvm::MDString
A single uniqued string.
Definition: Metadata.h:612
Value.h
llvm::GlobalIFunc
Definition: GlobalIFunc.h:34
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
llvm::Module::setDarwinTargetVariantTriple
void setDarwinTargetVariantTriple(StringRef T)
Set the target variant triple which is a string describing a variant of the target host platform.
Definition: Module.cpp:827
llvm::Module::ModFlagBehavior
ModFlagBehavior
This enumeration defines the supported behaviors of module flags.
Definition: Module.h:115
llvm::Module::getDarwinTargetVariantSDKVersion
VersionTuple getDarwinTargetVariantSDKVersion() const
Get the target variant version build SDK version metadata.
Definition: Module.cpp:832
llvm::Module::getNamedValue
GlobalValue * getNamedValue(StringRef Name) const
Return the global value in the module with the specified name, of arbitrary type.
Definition: Module.cpp:110
SpecialSubKind::string
@ string
Other
Optional< std::vector< StOtherPiece > > Other
Definition: ELFYAML.cpp:1236
llvm::FunctionType
Class to represent function types.
Definition: DerivedTypes.h:103
llvm::Intrinsic::ID
unsigned ID
Definition: TargetTransformInfo.h:38