LLVM  14.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/SmallPtrSet.h"
17 #include "llvm/ADT/SmallString.h"
18 #include "llvm/ADT/SmallVector.h"
19 #include "llvm/ADT/StringMap.h"
20 #include "llvm/ADT/StringRef.h"
21 #include "llvm/ADT/Twine.h"
22 #include "llvm/IR/Attributes.h"
23 #include "llvm/IR/Comdat.h"
24 #include "llvm/IR/Constants.h"
25 #include "llvm/IR/DataLayout.h"
27 #include "llvm/IR/DerivedTypes.h"
28 #include "llvm/IR/Function.h"
29 #include "llvm/IR/GVMaterializer.h"
30 #include "llvm/IR/GlobalAlias.h"
31 #include "llvm/IR/GlobalIFunc.h"
32 #include "llvm/IR/GlobalValue.h"
33 #include "llvm/IR/GlobalVariable.h"
34 #include "llvm/IR/LLVMContext.h"
35 #include "llvm/IR/Metadata.h"
38 #include "llvm/IR/Type.h"
39 #include "llvm/IR/TypeFinder.h"
40 #include "llvm/IR/Value.h"
42 #include "llvm/Pass.h"
43 #include "llvm/Support/Casting.h"
44 #include "llvm/Support/CodeGen.h"
45 #include "llvm/Support/Error.h"
47 #include "llvm/Support/Path.h"
50 #include <algorithm>
51 #include <cassert>
52 #include <cstdint>
53 #include <memory>
54 #include <utility>
55 #include <vector>
56 
57 using namespace llvm;
58 
59 //===----------------------------------------------------------------------===//
60 // Methods to implement the globals and functions lists.
61 //
62 
63 // Explicit instantiations of SymbolTableListTraits since some of the methods
64 // are not in the public header file.
69 
70 //===----------------------------------------------------------------------===//
71 // Primitive Module methods.
72 //
73 
75  : Context(C), ValSymTab(std::make_unique<ValueSymbolTable>(-1)),
76  Materializer(), ModuleID(std::string(MID)),
77  SourceFileName(std::string(MID)), DL("") {
78  Context.addModule(this);
79 }
80 
82  Context.removeModule(this);
84  GlobalList.clear();
85  FunctionList.clear();
86  AliasList.clear();
87  IFuncList.clear();
88 }
89 
90 std::unique_ptr<RandomNumberGenerator>
92  SmallString<32> Salt(Name);
93 
94  // This RNG is guaranteed to produce the same random stream only
95  // when the Module ID and thus the input filename is the same. This
96  // might be problematic if the input filename extension changes
97  // (e.g. from .c to .bc or .ll).
98  //
99  // We could store this salt in NamedMetadata, but this would make
100  // the parameter non-const. This would unfortunately make this
101  // interface unusable by any Machine passes, since they only have a
102  // const reference to their IR Module. Alternatively we can always
103  // store salt metadata from the Module constructor.
105 
106  return std::unique_ptr<RandomNumberGenerator>(
107  new RandomNumberGenerator(Salt));
108 }
109 
110 /// getNamedValue - Return the first global value in the module with
111 /// the specified name, of arbitrary type. This method returns null
112 /// if a global with the specified name is not found.
114  return cast_or_null<GlobalValue>(getValueSymbolTable().lookup(Name));
115 }
116 
117 unsigned Module::getNumNamedValues() const {
118  return getValueSymbolTable().size();
119 }
120 
121 /// getMDKindID - Return a unique non-zero ID for the specified metadata kind.
122 /// This ID is uniqued across modules in the current LLVMContext.
124  return Context.getMDKindID(Name);
125 }
126 
127 /// getMDKindNames - Populate client supplied SmallVector with the name for
128 /// custom metadata IDs registered in this LLVMContext. ID #0 is not used,
129 /// so it is filled in as an empty string.
131  return Context.getMDKindNames(Result);
132 }
133 
135  return Context.getOperandBundleTags(Result);
136 }
137 
138 //===----------------------------------------------------------------------===//
139 // Methods for easy access to the functions in the module.
140 //
141 
142 // getOrInsertFunction - Look up the specified function in the module symbol
143 // table. If it does not exist, add a prototype for the function and return
144 // it. This is nice because it allows most passes to get away with not handling
145 // the symbol table directly for this common task.
146 //
149  // See if we have a definition for the specified function already.
151  if (!F) {
152  // Nope, add it
155  if (!New->isIntrinsic()) // Intrinsics get attrs set on construction
156  New->setAttributes(AttributeList);
157  FunctionList.push_back(New);
158  return {Ty, New}; // Return the new prototype.
159  }
160 
161  // If the function exists but has the wrong type, return a bitcast to the
162  // right type.
163  auto *PTy = PointerType::get(Ty, F->getAddressSpace());
164  if (F->getType() != PTy)
165  return {Ty, ConstantExpr::getBitCast(F, PTy)};
166 
167  // Otherwise, we just found the existing function or a prototype.
168  return {Ty, F};
169 }
170 
172  return getOrInsertFunction(Name, Ty, AttributeList());
173 }
174 
175 // getFunction - Look up the specified function in the module symbol table.
176 // If it does not exist, return null.
177 //
179  return dyn_cast_or_null<Function>(getNamedValue(Name));
180 }
181 
182 //===----------------------------------------------------------------------===//
183 // Methods for easy access to the global variables in the module.
184 //
185 
186 /// getGlobalVariable - Look up the specified global variable in the module
187 /// symbol table. If it does not exist, return null. The type argument
188 /// should be the underlying type of the global, i.e., it should not have
189 /// the top-level PointerType, which represents the address of the global.
190 /// If AllowLocal is set to true, this function will return types that
191 /// have an local. By default, these types are not returned.
192 ///
194  bool AllowLocal) const {
195  if (GlobalVariable *Result =
196  dyn_cast_or_null<GlobalVariable>(getNamedValue(Name)))
197  if (AllowLocal || !Result->hasLocalLinkage())
198  return Result;
199  return nullptr;
200 }
201 
202 /// getOrInsertGlobal - Look up the specified global in the module symbol table.
203 /// 1. If it does not exist, add a declaration of the global and return it.
204 /// 2. Else, the global exists but has the wrong type: return the function
205 /// with a constantexpr cast to the right type.
206 /// 3. Finally, if the existing global is the correct declaration, return the
207 /// existing global.
209  StringRef Name, Type *Ty,
210  function_ref<GlobalVariable *()> CreateGlobalCallback) {
211  // See if we have a definition for the specified global already.
212  GlobalVariable *GV = dyn_cast_or_null<GlobalVariable>(getNamedValue(Name));
213  if (!GV)
214  GV = CreateGlobalCallback();
215  assert(GV && "The CreateGlobalCallback is expected to create a global");
216 
217  // If the variable exists but has the wrong type, return a bitcast to the
218  // right type.
219  Type *GVTy = GV->getType();
221  if (GVTy != PTy)
222  return ConstantExpr::getBitCast(GV, PTy);
223 
224  // Otherwise, we just found the existing function or a prototype.
225  return GV;
226 }
227 
228 // Overload to construct a global variable using its constructor's defaults.
230  return getOrInsertGlobal(Name, Ty, [&] {
231  return new GlobalVariable(*this, Ty, false, GlobalVariable::ExternalLinkage,
232  nullptr, Name);
233  });
234 }
235 
236 //===----------------------------------------------------------------------===//
237 // Methods for easy access to the global variables in the module.
238 //
239 
240 // getNamedAlias - Look up the specified global in the module symbol table.
241 // If it does not exist, return null.
242 //
244  return dyn_cast_or_null<GlobalAlias>(getNamedValue(Name));
245 }
246 
248  return dyn_cast_or_null<GlobalIFunc>(getNamedValue(Name));
249 }
250 
251 /// getNamedMetadata - Return the first NamedMDNode in the module with the
252 /// specified name. This method returns null if a NamedMDNode with the
253 /// specified name is not found.
255  SmallString<256> NameData;
256  StringRef NameRef = Name.toStringRef(NameData);
257  return NamedMDSymTab.lookup(NameRef);
258 }
259 
260 /// getOrInsertNamedMetadata - Return the first named MDNode in the module
261 /// with the specified name. This method returns a new NamedMDNode if a
262 /// NamedMDNode with the specified name is not found.
264  NamedMDNode *&NMD = NamedMDSymTab[Name];
265  if (!NMD) {
266  NMD = new NamedMDNode(Name);
267  NMD->setParent(this);
268  NamedMDList.push_back(NMD);
269  }
270  return NMD;
271 }
272 
273 /// eraseNamedMetadata - Remove the given NamedMDNode from this module and
274 /// delete it.
276  NamedMDSymTab.erase(NMD->getName());
277  NamedMDList.erase(NMD->getIterator());
278 }
279 
281  if (ConstantInt *Behavior = mdconst::dyn_extract_or_null<ConstantInt>(MD)) {
282  uint64_t Val = Behavior->getLimitedValue();
283  if (Val >= ModFlagBehaviorFirstVal && Val <= ModFlagBehaviorLastVal) {
284  MFB = static_cast<ModFlagBehavior>(Val);
285  return true;
286  }
287  }
288  return false;
289 }
290 
292  MDString *&Key, Metadata *&Val) {
293  if (ModFlag.getNumOperands() < 3)
294  return false;
295  if (!isValidModFlagBehavior(ModFlag.getOperand(0), MFB))
296  return false;
297  MDString *K = dyn_cast_or_null<MDString>(ModFlag.getOperand(1));
298  if (!K)
299  return false;
300  Key = K;
301  Val = ModFlag.getOperand(2);
302  return true;
303 }
304 
305 /// getModuleFlagsMetadata - Returns the module flags in the provided vector.
306 void Module::
308  const NamedMDNode *ModFlags = getModuleFlagsMetadata();
309  if (!ModFlags) return;
310 
311  for (const MDNode *Flag : ModFlags->operands()) {
312  ModFlagBehavior MFB;
313  MDString *Key = nullptr;
314  Metadata *Val = nullptr;
315  if (isValidModuleFlag(*Flag, MFB, Key, Val)) {
316  // Check the operands of the MDNode before accessing the operands.
317  // The verifier will actually catch these failures.
318  Flags.push_back(ModuleFlagEntry(MFB, Key, Val));
319  }
320  }
321 }
322 
323 /// Return the corresponding value if Key appears in module flags, otherwise
324 /// return null.
327  getModuleFlagsMetadata(ModuleFlags);
328  for (const ModuleFlagEntry &MFE : ModuleFlags) {
329  if (Key == MFE.Key->getString())
330  return MFE.Val;
331  }
332  return nullptr;
333 }
334 
335 /// getModuleFlagsMetadata - Returns the NamedMDNode in the module that
336 /// represents module-level flags. This method returns null if there are no
337 /// module-level flags.
339  return getNamedMetadata("llvm.module.flags");
340 }
341 
342 /// getOrInsertModuleFlagsMetadata - Returns the NamedMDNode in the module that
343 /// represents module-level flags. If module-level flags aren't found, it
344 /// creates the named metadata that contains them.
346  return getOrInsertNamedMetadata("llvm.module.flags");
347 }
348 
349 /// addModuleFlag - Add a module-level flag to the module-level flags
350 /// metadata. It will create the module-level flags named metadata if it doesn't
351 /// already exist.
353  Metadata *Val) {
354  Type *Int32Ty = Type::getInt32Ty(Context);
355  Metadata *Ops[3] = {
357  MDString::get(Context, Key), Val};
359 }
361  Constant *Val) {
362  addModuleFlag(Behavior, Key, ConstantAsMetadata::get(Val));
363 }
365  uint32_t Val) {
366  Type *Int32Ty = Type::getInt32Ty(Context);
367  addModuleFlag(Behavior, Key, ConstantInt::get(Int32Ty, Val));
368 }
370  assert(Node->getNumOperands() == 3 &&
371  "Invalid number of operands for module flag!");
372  assert(mdconst::hasa<ConstantInt>(Node->getOperand(0)) &&
373  isa<MDString>(Node->getOperand(1)) &&
374  "Invalid operand types for module flag!");
376 }
377 
379  Metadata *Val) {
381  // Replace the flag if it already exists.
382  for (unsigned I = 0, E = ModFlags->getNumOperands(); I != E; ++I) {
383  MDNode *Flag = ModFlags->getOperand(I);
384  ModFlagBehavior MFB;
385  MDString *K = nullptr;
386  Metadata *V = nullptr;
387  if (isValidModuleFlag(*Flag, MFB, K, V) && K->getString() == Key) {
388  Flag->replaceOperandWith(2, Val);
389  return;
390  }
391  }
392  addModuleFlag(Behavior, Key, Val);
393 }
394 
396  DL.reset(Desc);
397 }
398 
399 void Module::setDataLayout(const DataLayout &Other) { DL = Other; }
400 
401 const DataLayout &Module::getDataLayout() const { return DL; }
402 
404  return cast<DICompileUnit>(CUs->getOperand(Idx));
405 }
407  return cast<DICompileUnit>(CUs->getOperand(Idx));
408 }
409 
410 void Module::debug_compile_units_iterator::SkipNoDebugCUs() {
411  while (CUs && (Idx < CUs->getNumOperands()) &&
412  ((*this)->getEmissionKind() == DICompileUnit::NoDebug))
413  ++Idx;
414 }
415 
417  return concat<GlobalObject>(functions(), globals());
418 }
420 Module::global_objects() const {
421  return concat<const GlobalObject>(functions(), globals());
422 }
423 
425  return concat<GlobalValue>(functions(), globals(), aliases(), ifuncs());
426 }
428 Module::global_values() const {
429  return concat<const GlobalValue>(functions(), globals(), aliases(), ifuncs());
430 }
431 
432 //===----------------------------------------------------------------------===//
433 // Methods to control the materialization of GlobalValues in the Module.
434 //
436  assert(!Materializer &&
437  "Module already has a GVMaterializer. Call materializeAll"
438  " to clear it out before setting another one.");
439  Materializer.reset(GVM);
440 }
441 
443  if (!Materializer)
444  return Error::success();
445 
446  return Materializer->materialize(GV);
447 }
448 
450  if (!Materializer)
451  return Error::success();
452  std::unique_ptr<GVMaterializer> M = std::move(Materializer);
453  return M->materializeModule();
454 }
455 
457  if (!Materializer)
458  return Error::success();
459  return Materializer->materializeMetadata();
460 }
461 
462 //===----------------------------------------------------------------------===//
463 // Other module related stuff.
464 //
465 
466 std::vector<StructType *> Module::getIdentifiedStructTypes() const {
467  // If we have a materializer, it is possible that some unread function
468  // uses a type that is currently not visible to a TypeFinder, so ask
469  // the materializer which types it created.
470  if (Materializer)
471  return Materializer->getIdentifiedStructTypes();
472 
473  std::vector<StructType *> Ret;
474  TypeFinder SrcStructTypes;
475  SrcStructTypes.run(*this, true);
476  Ret.assign(SrcStructTypes.begin(), SrcStructTypes.end());
477  return Ret;
478 }
479 
481  const FunctionType *Proto) {
482  auto Encode = [&BaseName](unsigned Suffix) {
483  return (Twine(BaseName) + "." + Twine(Suffix)).str();
484  };
485 
486  {
487  // fast path - the prototype is already known
488  auto UinItInserted = UniquedIntrinsicNames.insert({{Id, Proto}, 0});
489  if (!UinItInserted.second)
490  return Encode(UinItInserted.first->second);
491  }
492 
493  // Not known yet. A new entry was created with index 0. Check if there already
494  // exists a matching declaration, or select a new entry.
495 
496  // Start looking for names with the current known maximum count (or 0).
497  auto NiidItInserted = CurrentIntrinsicIds.insert({BaseName, 0});
498  unsigned Count = NiidItInserted.first->second;
499 
500  // This might be slow if a whole population of intrinsics already existed, but
501  // we cache the values for later usage.
502  std::string NewName;
503  while (true) {
504  NewName = Encode(Count);
505  GlobalValue *F = getNamedValue(NewName);
506  if (!F) {
507  // Reserve this entry for the new proto
508  UniquedIntrinsicNames[{Id, Proto}] = Count;
509  break;
510  }
511 
512  // A declaration with this name already exists. Remember it.
513  FunctionType *FT = dyn_cast<FunctionType>(F->getValueType());
514  auto UinItInserted = UniquedIntrinsicNames.insert({{Id, FT}, Count});
515  if (FT == Proto) {
516  // It was a declaration for our prototype. This entry was allocated in the
517  // beginning. Update the count to match the existing declaration.
518  UinItInserted.first->second = Count;
519  break;
520  }
521 
522  ++Count;
523  }
524 
525  NiidItInserted.first->second = Count + 1;
526 
527  return NewName;
528 }
529 
530 // dropAllReferences() - This function causes all the subelements to "let go"
531 // of all references that they are maintaining. This allows one to 'delete' a
532 // whole module at a time, even though there may be circular references... first
533 // all references are dropped, and all use counts go to zero. Then everything
534 // is deleted for real. Note that no operations are valid on an object that
535 // has "dropped all references", except operator delete.
536 //
538  for (Function &F : *this)
539  F.dropAllReferences();
540 
541  for (GlobalVariable &GV : globals())
542  GV.dropAllReferences();
543 
544  for (GlobalAlias &GA : aliases())
545  GA.dropAllReferences();
546 
547  for (GlobalIFunc &GIF : ifuncs())
548  GIF.dropAllReferences();
549 }
550 
552  auto *Val =
553  cast_or_null<ConstantAsMetadata>(getModuleFlag("NumRegisterParameters"));
554  if (!Val)
555  return 0;
556  return cast<ConstantInt>(Val->getValue())->getZExtValue();
557 }
558 
559 unsigned Module::getDwarfVersion() const {
560  auto *Val = cast_or_null<ConstantAsMetadata>(getModuleFlag("Dwarf Version"));
561  if (!Val)
562  return 0;
563  return cast<ConstantInt>(Val->getValue())->getZExtValue();
564 }
565 
566 bool Module::isDwarf64() const {
567  auto *Val = cast_or_null<ConstantAsMetadata>(getModuleFlag("DWARF64"));
568  return Val && cast<ConstantInt>(Val->getValue())->isOne();
569 }
570 
571 unsigned Module::getCodeViewFlag() const {
572  auto *Val = cast_or_null<ConstantAsMetadata>(getModuleFlag("CodeView"));
573  if (!Val)
574  return 0;
575  return cast<ConstantInt>(Val->getValue())->getZExtValue();
576 }
577 
578 unsigned Module::getInstructionCount() const {
579  unsigned NumInstrs = 0;
580  for (const Function &F : FunctionList)
581  NumInstrs += F.getInstructionCount();
582  return NumInstrs;
583 }
584 
586  auto &Entry = *ComdatSymTab.insert(std::make_pair(Name, Comdat())).first;
587  Entry.second.Name = &Entry;
588  return &Entry.second;
589 }
590 
592  auto *Val = cast_or_null<ConstantAsMetadata>(getModuleFlag("PIC Level"));
593 
594  if (!Val)
595  return PICLevel::NotPIC;
596 
597  return static_cast<PICLevel::Level>(
598  cast<ConstantInt>(Val->getValue())->getZExtValue());
599 }
600 
602  addModuleFlag(ModFlagBehavior::Max, "PIC Level", PL);
603 }
604 
606  auto *Val = cast_or_null<ConstantAsMetadata>(getModuleFlag("PIE Level"));
607 
608  if (!Val)
609  return PIELevel::Default;
610 
611  return static_cast<PIELevel::Level>(
612  cast<ConstantInt>(Val->getValue())->getZExtValue());
613 }
614 
616  addModuleFlag(ModFlagBehavior::Max, "PIE Level", PL);
617 }
618 
620  auto *Val = cast_or_null<ConstantAsMetadata>(getModuleFlag("Code Model"));
621 
622  if (!Val)
623  return None;
624 
625  return static_cast<CodeModel::Model>(
626  cast<ConstantInt>(Val->getValue())->getZExtValue());
627 }
628 
630  // Linking object files with different code models is undefined behavior
631  // because the compiler would have to generate additional code (to span
632  // longer jumps) if a larger code model is used with a smaller one.
633  // Therefore we will treat attempts to mix code models as an error.
634  addModuleFlag(ModFlagBehavior::Error, "Code Model", CL);
635 }
636 
639  setModuleFlag(ModFlagBehavior::Error, "CSProfileSummary", M);
640  else
641  setModuleFlag(ModFlagBehavior::Error, "ProfileSummary", M);
642 }
643 
645  return (IsCS ? getModuleFlag("CSProfileSummary")
646  : getModuleFlag("ProfileSummary"));
647 }
648 
650  Metadata *MF = getModuleFlag("SemanticInterposition");
651 
652  auto *Val = cast_or_null<ConstantAsMetadata>(MF);
653  if (!Val)
654  return false;
655 
656  return cast<ConstantInt>(Val->getValue())->getZExtValue();
657 }
658 
660  addModuleFlag(ModFlagBehavior::Error, "SemanticInterposition", SI);
661 }
662 
663 void Module::setOwnedMemoryBuffer(std::unique_ptr<MemoryBuffer> MB) {
664  OwnedMemoryBuffer = std::move(MB);
665 }
666 
668  auto *Val = cast_or_null<ConstantAsMetadata>(getModuleFlag("RtLibUseGOT"));
669  return Val && (cast<ConstantInt>(Val->getValue())->getZExtValue() > 0);
670 }
671 
673  addModuleFlag(ModFlagBehavior::Max, "RtLibUseGOT", 1);
674 }
675 
676 bool Module::getUwtable() const {
677  auto *Val = cast_or_null<ConstantAsMetadata>(getModuleFlag("uwtable"));
678  return Val && (cast<ConstantInt>(Val->getValue())->getZExtValue() > 0);
679 }
680 
681 void Module::setUwtable() { addModuleFlag(ModFlagBehavior::Max, "uwtable", 1); }
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 
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  addModuleFlag(ModFlagBehavior::Warning, "SDK Version",
750  ConstantDataArray::get(Context, Entries));
751 }
752 
754  auto *CM = dyn_cast_or_null<ConstantAsMetadata>(getModuleFlag("SDK Version"));
755  if (!CM)
756  return {};
757  auto *Arr = dyn_cast_or_null<ConstantDataArray>(CM->getValue());
758  if (!Arr)
759  return {};
760  auto getVersionComponent = [&](unsigned Index) -> Optional<unsigned> {
761  if (Index >= Arr->getNumElements())
762  return None;
763  return (unsigned)Arr->getElementAsInteger(Index);
764  };
765  auto Major = getVersionComponent(0);
766  if (!Major)
767  return {};
768  VersionTuple Result = VersionTuple(*Major);
769  if (auto Minor = getVersionComponent(1)) {
770  Result = VersionTuple(*Major, *Minor);
771  if (auto Subminor = getVersionComponent(2)) {
772  Result = VersionTuple(*Major, *Minor, *Subminor);
773  }
774  }
775  return Result;
776 }
777 
779  const Module &M, SmallVectorImpl<GlobalValue *> &Vec, bool CompilerUsed) {
780  const char *Name = CompilerUsed ? "llvm.compiler.used" : "llvm.used";
781  GlobalVariable *GV = M.getGlobalVariable(Name);
782  if (!GV || !GV->hasInitializer())
783  return GV;
784 
785  const ConstantArray *Init = cast<ConstantArray>(GV->getInitializer());
786  for (Value *Op : Init->operands()) {
787  GlobalValue *G = cast<GlobalValue>(Op->stripPointerCasts());
788  Vec.push_back(G);
789  }
790  return GV;
791 }
792 
794  if (auto *SummaryMD = getProfileSummary(/*IsCS*/ false)) {
795  std::unique_ptr<ProfileSummary> ProfileSummary(
796  ProfileSummary::getFromMD(SummaryMD));
797  if (ProfileSummary) {
800  return;
801  uint64_t BlockCount = Index.getBlockCount();
802  uint32_t NumCounts = ProfileSummary->getNumCounts();
803  if (!NumCounts)
804  return;
805  double Ratio = (double)BlockCount / NumCounts;
809  }
810  }
811 }
llvm::Module::global_values
iterator_range< global_value_iterator > global_values()
Definition: Module.cpp:424
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:345
GlobalIFunc.h
llvm
This file implements support for optimizing divisions by a constant.
Definition: AllocatorList.h:23
llvm::Module::getModuleFlagsMetadata
NamedMDNode * getModuleFlagsMetadata() const
Returns the NamedMDNode in the module that represents module-level flags.
Definition: Module.cpp:338
Reg
unsigned Reg
Definition: MachineSink.cpp:1566
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:1421
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:578
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:1120
llvm::GVMaterializer
Definition: GVMaterializer.h:28
llvm::Module::isDwarf64
bool isDwarf64() const
Returns the DWARF format by checking module flags.
Definition: Module.cpp:566
llvm::iplist_impl::push_back
void push_back(pointer val)
Definition: ilist.h:313
DebugInfoMetadata.h
llvm::Module::ModFlagBehaviorLastVal
@ ModFlagBehaviorLastVal
Definition: Module.h:153
llvm::DataLayout::getProgramAddressSpace
unsigned getProgramAddressSpace() const
Definition: DataLayout.h:294
llvm::Function
Definition: Function.h:62
llvm::TypeFinder::end
iterator end()
Definition: TypeFinder.h:50
StringRef.h
llvm::ProfileSummary::getFromMD
static ProfileSummary * getFromMD(Metadata *MD)
Construct profile summary from metdata.
Definition: ProfileSummary.cpp:195
Pass.h
llvm::Module::ifuncs
iterator_range< ifunc_iterator > ifuncs()
Definition: Module.h:669
llvm::Module::setMaterializer
void setMaterializer(GVMaterializer *GVM)
Sets the GVMaterializer to GVM.
Definition: Module.cpp:435
llvm::Module::ModFlagBehaviorFirstVal
@ ModFlagBehaviorFirstVal
Definition: Module.h:152
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:729
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:1168
llvm::Module::getCodeViewFlag
unsigned getCodeViewFlag() const
Returns the CodeView Version by checking module flags.
Definition: Module.cpp:571
Path.h
llvm::Module::~Module
~Module()
The module destructor. This will dropAllReferences.
Definition: Module.cpp:81
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:667
VersionTuple.h
llvm::Type::getPointerAddressSpace
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
Definition: DerivedTypes.h:734
llvm::Error::success
static ErrorSuccess success()
Create a success value.
Definition: Error.h:331
llvm::GlobalVariable
Definition: GlobalVariable.h:40
llvm::ConstantExpr::getBitCast
static Constant * getBitCast(Constant *C, Type *Ty, bool OnlyIfReduced=false)
Definition: Constants.cpp:2233
RandomNumberGenerator.h
llvm::GlobalAlias
Definition: GlobalAlias.h:28
Error.h
llvm::Module::getUwtable
bool getUwtable() const
Get/set whether synthesized functions should get the uwtable attribute.
Definition: Module.cpp:676
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:280
llvm::Module::getModuleFlag
Metadata * getModuleFlag(StringRef Key) const
Return the corresponding value if Key appears in module flags, otherwise return null.
Definition: Module.cpp:325
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:619
Module.h
llvm::AttributeList
Definition: Attributes.h:399
llvm::Optional< CodeModel::Model >
llvm::Module::setSDKVersion
void setSDKVersion(const VersionTuple &V)
Attach a build SDK version metadata to this module.
Definition: Module.cpp:739
llvm::ConstantAsMetadata::get
static ConstantAsMetadata * get(Constant *C)
Definition: Metadata.h:419
Offset
uint64_t Offset
Definition: ELFObjHandler.cpp:81
llvm::Module::getOrInsertFunction
FunctionCallee getOrInsertFunction(StringRef Name, FunctionType *T, AttributeList AttributeList)
Look up the specified function in the module symbol table.
Definition: Module.cpp:147
llvm::Module::global_objects
iterator_range< global_object_iterator > global_objects()
Definition: Module.cpp:416
llvm::Module::getProfileSummary
Metadata * getProfileSummary(bool IsCS) const
Returns profile summary metadata.
Definition: Module.cpp:644
llvm::MipsISD::Ret
@ Ret
Definition: MipsISelLowering.h:116
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:130
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:178
llvm::RandomNumberGenerator
A random number generator.
Definition: RandomNumberGenerator.h:32
llvm::Type::getInt32Ty
static IntegerType * getInt32Ty(LLVMContext &C)
Definition: Type.cpp:241
ModuleSummaryIndex.h
llvm::Module::setOverrideStackAlignment
void setOverrideStackAlignment(unsigned Align)
Definition: Module.cpp:735
llvm::TypeFinder::begin
iterator begin()
Definition: TypeFinder.h:49
llvm::MDNode::get
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition: Metadata.h:1233
llvm::Module::setPIELevel
void setPIELevel(PIELevel::Level PL)
Set the PIE level (small or large model)
Definition: Module.cpp:615
F
#define F(x, y, z)
Definition: MD5.cpp:56
llvm::GlobalVariable::hasInitializer
bool hasInitializer() const
Definitions have initializers, declarations don't.
Definition: GlobalVariable.h:92
llvm::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:778
llvm::Module::getSDKVersion
VersionTuple getSDKVersion() const
Get the build SDK version metadata.
Definition: Module.cpp:753
llvm::iplist_impl::erase
iterator erase(iterator where)
Definition: ilist.h:267
llvm::ProfileSummary::isPartialProfile
bool isPartialProfile() const
Definition: ProfileSummary.h:96
llvm::VersionTuple::getMajor
unsigned getMajor() const
Retrieve the major version number.
Definition: VersionTuple.h:70
llvm::MDNode::getNumOperands
unsigned getNumOperands() const
Return number of MDNode operands.
Definition: Metadata.h:1143
Context
LLVMContext & Context
Definition: NVVMIntrRange.cpp:66
llvm::Module::setRtLibUseGOT
void setRtLibUseGOT()
Set that PLT should be avoid for RTLib calls.
Definition: Module.cpp:672
llvm::NamedMDNode::addOperand
void addOperand(MDNode *M)
Definition: Metadata.cpp:1130
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:659
GlobalValue.h
Constants.h
llvm::Module::globals
iterator_range< global_iterator > globals()
Definition: Module.h:611
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:629
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:81
llvm::Module::getValueSymbolTable
const ValueSymbolTable & getValueSymbolTable() const
Get the symbol table of global variable and function identifiers.
Definition: Module.h:591
Twine.h
llvm::StringMap::insert
bool insert(MapEntryTy *KeyValue)
insert - Insert the specified key/value pair into the map.
Definition: StringMap.h:274
llvm::NamedMDNode::getName
StringRef getName() const
Definition: Metadata.cpp:1141
TypeFinder.h
SymbolTableListTraitsImpl.h
llvm::AMDGPU::PALMD::Key
Key
PAL metadata keys.
Definition: AMDGPUMetadata.h:481
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:243
llvm::ConstantArray
ConstantArray - Constant Array Declarations.
Definition: Constants.h:409
llvm::MCID::Flag
Flag
These should be considered private to the implementation of the MCInstrDesc class.
Definition: MCInstrDesc.h:146
llvm::Module::ModuleFlagEntry
Definition: Module.h:165
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:208
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:925
llvm::Module::debug_compile_units_iterator::operator*
DICompileUnit * operator*() const
Definition: Module.cpp:403
llvm::AArch64CC::PL
@ PL
Definition: AArch64BaseInfo.h:260
llvm::VersionTuple
Represents a version number in the form major[.minor[.subminor[.build]]].
Definition: VersionTuple.h:29
SmallPtrSet.h
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:31
llvm::Metadata
Root of the metadata hierarchy.
Definition: Metadata.h:62
llvm::None
const NoneType None
Definition: None.h:23
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
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:247
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:480
llvm::CodeModel::Model
Model
Definition: CodeGen.h:28
llvm::function_ref
An efficient, type-erasing, non-owning reference to a callable.
Definition: STLExtras.h:168
llvm::MDNode::getOperand
const MDOperand & getOperand(unsigned I) const
Definition: Metadata.h:1137
G
const DataFlowGraph & G
Definition: RDFGraph.cpp:202
llvm::Module::aliases
iterator_range< alias_iterator > aliases()
Definition: Module.h:651
llvm::GlobalValue
Definition: GlobalValue.h:44
llvm::GlobalVariable::getInitializer
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
Definition: GlobalVariable.h:136
llvm::Module::setPICLevel
void setPICLevel(PICLevel::Level PL)
Set the PIC level (small or large model)
Definition: Module.cpp:601
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:551
llvm::SymbolTableListTraits
Definition: GlobalAlias.h:26
Index
uint32_t Index
Definition: ELFObjHandler.cpp:84
llvm::StringMap::erase
void erase(iterator I)
Definition: StringMap.h:368
llvm::Module::dropAllReferences
void dropAllReferences()
This function causes all the subinstructions to "let go" of all references that they are maintaining.
Definition: Module.cpp:537
uint64_t
llvm::VersionTuple::getSubminor
Optional< unsigned > getSubminor() const
Retrieve the subminor version number, if provided.
Definition: VersionTuple.h:80
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:59
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:232
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:449
llvm::DICompileUnit
Compile unit.
Definition: DebugInfoMetadata.h:1335
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:633
llvm::Module::getOrInsertComdat
Comdat * getOrInsertComdat(StringRef Name)
Return the Comdat in the module with the specified name.
Definition: Module.cpp:585
llvm::MDString::get
static MDString * get(LLVMContext &Context, StringRef Str)
Definition: Metadata.cpp:473
llvm::Module::setDataLayout
void setDataLayout(StringRef Desc)
Set the data layout.
Definition: Module.cpp:395
llvm::NamedMDNode::getOperand
MDNode * getOperand(unsigned i) const
Definition: Metadata.cpp:1124
llvm::Function::Create
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &N="", Module *M=nullptr)
Definition: Function.h:139
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:73
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:227
llvm::Module::materializeMetadata
llvm::Error materializeMetadata()
Definition: Module.cpp:456
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:67
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:906
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:378
llvm::DICompileUnit::NoDebug
@ NoDebug
Definition: DebugInfoMetadata.h:1341
llvm::Module::setOwnedMemoryBuffer
void setOwnedMemoryBuffer(std::unique_ptr< MemoryBuffer > MB)
Take ownership of the given memory buffer.
Definition: Module.cpp:663
llvm::Module::Module
Module(StringRef ModuleID, LLVMContext &C)
The Module constructor.
Definition: Module.cpp:74
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:32
llvm::TypeFinder
TypeFinder - Walk over a module, identifying all of the types that are used by the module.
Definition: TypeFinder.h:30
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:691
uint32_t
llvm::ilist_node_impl::getIterator
self_iterator getIterator()
Definition: ilist_node.h:81
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:117
llvm::ProfileSummary::PSK_CSInstr
@ PSK_CSInstr
Definition: ProfileSummary.h:47
llvm::Init
Definition: Record.h:271
llvm::Module::getGlobalVariable
GlobalVariable * getGlobalVariable(StringRef Name) const
Look up the specified global variable in the module symbol table.
Definition: Module.h:411
llvm::NamedMDNode::operands
iterator_range< op_iterator > operands()
Definition: Metadata.h:1517
llvm::Module::getOperandBundleTags
void getOperandBundleTags(SmallVectorImpl< StringRef > &Result) const
Populate client supplied SmallVector with the bundle tags registered in this LLVMContext.
Definition: Module.cpp:134
llvm::Module::getSemanticInterposition
bool getSemanticInterposition() const
Returns whether semantic interposition is to be respected.
Definition: Module.cpp:649
llvm::Module::materialize
llvm::Error materialize(GlobalValue *GV)
Make sure the GlobalValue is fully read.
Definition: Module.cpp:442
Attributes.h
llvm::Module::debug_compile_units_iterator::operator->
DICompileUnit * operator->() const
Definition: Module.cpp:406
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:270
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
std
Definition: BitVector.h:838
llvm::Module::getMDKindID
unsigned getMDKindID(StringRef Name) const
Return a unique non-zero ID for the specified metadata kind.
Definition: Module.cpp:123
llvm::AMDGPU::SendMsg::Op
Op
Definition: SIDefines.h:324
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
GlobalVariable.h
llvm::Module::getContext
LLVMContext & getContext() const
Get the global data context.
Definition: Module.h:261
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:263
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:559
llvm::Module::getIdentifiedStructTypes
std::vector< StructType * > getIdentifiedStructTypes() const
Definition: Module.cpp:466
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:277
llvm::Module::getPIELevel
PIELevel::Level getPIELevel() const
Returns the PIE level (small or large model)
Definition: Module.cpp:605
llvm::Module::createRNG
std::unique_ptr< RandomNumberGenerator > createRNG(const StringRef Name) const
Get a RandomNumberGenerator salted for use with this module.
Definition: Module.cpp:91
GlobalAlias.h
llvm::Module::getPICLevel
PICLevel::Level getPICLevel() const
Returns the PIC level (small or large model)
Definition: Module.cpp:591
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:793
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:573
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:352
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:1078
llvm::Module::getNamedMetadata
NamedMDNode * getNamedMetadata(const Twine &Name) const
Return the first NamedMDNode in the module with the specified name.
Definition: Module.cpp:254
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:291
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:260
llvm::GlobalValue::getType
PointerType * getType() const
Global values are always pointers.
Definition: GlobalValue.h:271
llvm::Module::getDataLayout
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
Definition: Module.cpp:401
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:275
LLVMContext.h
llvm::Module::setProfileSummary
void setProfileSummary(Metadata *M, ProfileSummary::Kind Kind)
Attach profile summary metadata to this module.
Definition: Module.cpp:637
llvm::MDString::getString
StringRef getString() const
Definition: Metadata.cpp:483
llvm::AMDGPU::VGPRIndexMode::Id
Id
Definition: SIDefines.h:231
SymbolTableListTraits.h
llvm::MDString
A single uniqued string.
Definition: Metadata.h:611
Value.h
llvm::GlobalIFunc
Definition: GlobalIFunc.h:34
llvm::Module::setUwtable
void setUwtable()
Definition: Module.cpp:681
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
llvm::Module::ModFlagBehavior
ModFlagBehavior
This enumeration defines the supported behaviors of module flags.
Definition: Module.h:117
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:113
SpecialSubKind::string
@ string
Other
Optional< std::vector< StOtherPiece > > Other
Definition: ELFYAML.cpp:1184
llvm::FunctionType
Class to represent function types.
Definition: DerivedTypes.h:103
llvm::Intrinsic::ID
unsigned ID
Definition: TargetTransformInfo.h:37