LLVM 22.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"
17#include "llvm/ADT/StringMap.h"
18#include "llvm/ADT/StringRef.h"
19#include "llvm/ADT/Twine.h"
20#include "llvm/IR/Attributes.h"
21#include "llvm/IR/Comdat.h"
22#include "llvm/IR/Constants.h"
23#include "llvm/IR/DataLayout.h"
26#include "llvm/IR/Function.h"
28#include "llvm/IR/GlobalAlias.h"
29#include "llvm/IR/GlobalIFunc.h"
30#include "llvm/IR/GlobalValue.h"
32#include "llvm/IR/LLVMContext.h"
33#include "llvm/IR/Metadata.h"
36#include "llvm/IR/Type.h"
37#include "llvm/IR/TypeFinder.h"
38#include "llvm/IR/Value.h"
43#include "llvm/Support/Error.h"
45#include "llvm/Support/Path.h"
49#include <cassert>
50#include <cstdint>
51#include <memory>
52#include <optional>
53#include <utility>
54#include <vector>
55
56using namespace llvm;
57
58//===----------------------------------------------------------------------===//
59// Methods to implement the globals and functions lists.
60//
61
62// Explicit instantiations of SymbolTableListTraits since some of the methods
63// are not in the public header file.
68
69//===----------------------------------------------------------------------===//
70// Primitive Module methods.
71//
72
74 : Context(C), ValSymTab(std::make_unique<ValueSymbolTable>(-1)),
75 ModuleID(std::string(MID)), SourceFileName(std::string(MID)) {
76 Context.addModule(this);
77}
78
80 assert(&Context == &Other.Context && "Module must be in the same Context");
81
82 dropAllReferences();
83
84 ModuleID = std::move(Other.ModuleID);
85 SourceFileName = std::move(Other.SourceFileName);
86
87 GlobalList.clear();
88 GlobalList.splice(GlobalList.begin(), Other.GlobalList);
89
90 FunctionList.clear();
91 FunctionList.splice(FunctionList.begin(), Other.FunctionList);
92
93 AliasList.clear();
94 AliasList.splice(AliasList.begin(), Other.AliasList);
95
96 IFuncList.clear();
97 IFuncList.splice(IFuncList.begin(), Other.IFuncList);
98
99 NamedMDList.clear();
100 NamedMDList.splice(NamedMDList.begin(), Other.NamedMDList);
101 GlobalScopeAsm = std::move(Other.GlobalScopeAsm);
102 OwnedMemoryBuffer = std::move(Other.OwnedMemoryBuffer);
103 Materializer = std::move(Other.Materializer);
104 TargetTriple = std::move(Other.TargetTriple);
105 DL = std::move(Other.DL);
106 CurrentIntrinsicIds = std::move(Other.CurrentIntrinsicIds);
107 UniquedIntrinsicNames = std::move(Other.UniquedIntrinsicNames);
108 ModuleFlags = std::move(Other.ModuleFlags);
109 Context.addModule(this);
110 return *this;
111}
112
114 Context.removeModule(this);
115 dropAllReferences();
116 GlobalList.clear();
117 FunctionList.clear();
118 AliasList.clear();
119 IFuncList.clear();
120}
121
123 if (auto *DeclareIntrinsicFn =
124 Intrinsic::getDeclarationIfExists(this, Intrinsic::dbg_declare)) {
125 assert((!isMaterialized() || DeclareIntrinsicFn->hasZeroLiveUses()) &&
126 "Debug declare intrinsic should have had uses removed.");
127 DeclareIntrinsicFn->eraseFromParent();
128 }
129 if (auto *ValueIntrinsicFn =
130 Intrinsic::getDeclarationIfExists(this, Intrinsic::dbg_value)) {
131 assert((!isMaterialized() || ValueIntrinsicFn->hasZeroLiveUses()) &&
132 "Debug value intrinsic should have had uses removed.");
133 ValueIntrinsicFn->eraseFromParent();
134 }
135 if (auto *AssignIntrinsicFn =
136 Intrinsic::getDeclarationIfExists(this, Intrinsic::dbg_assign)) {
137 assert((!isMaterialized() || AssignIntrinsicFn->hasZeroLiveUses()) &&
138 "Debug assign intrinsic should have had uses removed.");
139 AssignIntrinsicFn->eraseFromParent();
140 }
141 if (auto *LabelntrinsicFn =
142 Intrinsic::getDeclarationIfExists(this, Intrinsic::dbg_label)) {
143 assert((!isMaterialized() || LabelntrinsicFn->hasZeroLiveUses()) &&
144 "Debug label intrinsic should have had uses removed.");
145 LabelntrinsicFn->eraseFromParent();
146 }
147}
148
149std::unique_ptr<RandomNumberGenerator>
150Module::createRNG(const StringRef Name) const {
151 SmallString<32> Salt(Name);
152
153 // This RNG is guaranteed to produce the same random stream only
154 // when the Module ID and thus the input filename is the same. This
155 // might be problematic if the input filename extension changes
156 // (e.g. from .c to .bc or .ll).
157 //
158 // We could store this salt in NamedMetadata, but this would make
159 // the parameter non-const. This would unfortunately make this
160 // interface unusable by any Machine passes, since they only have a
161 // const reference to their IR Module. Alternatively we can always
162 // store salt metadata from the Module constructor.
163 Salt += sys::path::filename(getModuleIdentifier());
164
165 return std::unique_ptr<RandomNumberGenerator>(
166 new RandomNumberGenerator(Salt));
167}
168
169/// getNamedValue - Return the first global value in the module with
170/// the specified name, of arbitrary type. This method returns null
171/// if a global with the specified name is not found.
173 return cast_or_null<GlobalValue>(getValueSymbolTable().lookup(Name));
174}
175
176unsigned Module::getNumNamedValues() const {
177 return getValueSymbolTable().size();
178}
179
180/// getMDKindID - Return a unique non-zero ID for the specified metadata kind.
181/// This ID is uniqued across modules in the current LLVMContext.
182unsigned Module::getMDKindID(StringRef Name) const {
183 return Context.getMDKindID(Name);
184}
185
186/// getMDKindNames - Populate client supplied SmallVector with the name for
187/// custom metadata IDs registered in this LLVMContext. ID #0 is not used,
188/// so it is filled in as an empty string.
190 return Context.getMDKindNames(Result);
191}
192
194 return Context.getOperandBundleTags(Result);
195}
196
197//===----------------------------------------------------------------------===//
198// Methods for easy access to the functions in the module.
199//
200
201// getOrInsertFunction - Look up the specified function in the module symbol
202// table. If it does not exist, add a prototype for the function and return
203// it. This is nice because it allows most passes to get away with not handling
204// the symbol table directly for this common task.
205//
207 AttributeList AttributeList) {
208 // See if we have a definition for the specified function already.
209 GlobalValue *F = getNamedValue(Name);
210 if (!F) {
211 // Nope, add it
213 DL.getProgramAddressSpace(), Name, this);
214 if (!New->isIntrinsic()) // Intrinsics get attrs set on construction
215 New->setAttributes(AttributeList);
216 return {Ty, New}; // Return the new prototype.
217 }
218
219 // Otherwise, we just found the existing function or a prototype.
220 return {Ty, F};
221}
222
224 return getOrInsertFunction(Name, Ty, AttributeList());
225}
226
227// getFunction - Look up the specified function in the module symbol table.
228// If it does not exist, return null.
229//
231 return dyn_cast_or_null<Function>(getNamedValue(Name));
232}
233
234//===----------------------------------------------------------------------===//
235// Methods for easy access to the global variables in the module.
236//
237
238/// getGlobalVariable - Look up the specified global variable in the module
239/// symbol table. If it does not exist, return null. The type argument
240/// should be the underlying type of the global, i.e., it should not have
241/// the top-level PointerType, which represents the address of the global.
242/// If AllowLocal is set to true, this function will return types that
243/// have an local. By default, these types are not returned.
244///
246 bool AllowLocal) const {
247 if (GlobalVariable *Result =
248 dyn_cast_or_null<GlobalVariable>(getNamedValue(Name)))
249 if (AllowLocal || !Result->hasLocalLinkage())
250 return Result;
251 return nullptr;
252}
253
254/// getOrInsertGlobal - Look up the specified global in the module symbol table.
255/// If it does not exist, add a declaration of the global and return it.
256/// Otherwise, return the existing global.
258 StringRef Name, Type *Ty,
259 function_ref<GlobalVariable *()> CreateGlobalCallback) {
260 // See if we have a definition for the specified global already.
261 GlobalVariable *GV = dyn_cast_or_null<GlobalVariable>(getNamedValue(Name));
262 if (!GV)
263 GV = CreateGlobalCallback();
264 assert(GV && "The CreateGlobalCallback is expected to create a global");
265
266 // Otherwise, we just found the existing function or a prototype.
267 return GV;
268}
269
270// Overload to construct a global variable using its constructor's defaults.
272 return getOrInsertGlobal(Name, Ty, [&] {
273 return new GlobalVariable(*this, Ty, false, GlobalVariable::ExternalLinkage,
274 nullptr, Name);
275 });
276}
277
278//===----------------------------------------------------------------------===//
279// Methods for easy access to the global variables in the module.
280//
281
282// getNamedAlias - Look up the specified global in the module symbol table.
283// If it does not exist, return null.
284//
286 return dyn_cast_or_null<GlobalAlias>(getNamedValue(Name));
287}
288
290 return dyn_cast_or_null<GlobalIFunc>(getNamedValue(Name));
291}
292
293/// getNamedMetadata - Return the first NamedMDNode in the module with the
294/// specified name. This method returns null if a NamedMDNode with the
295/// specified name is not found.
297 return NamedMDSymTab.lookup(Name);
298}
299
300/// getOrInsertNamedMetadata - Return the first named MDNode in the module
301/// with the specified name. This method returns a new NamedMDNode if a
302/// NamedMDNode with the specified name is not found.
304 NamedMDNode *&NMD = NamedMDSymTab[Name];
305 if (!NMD) {
306 NMD = new NamedMDNode(Name);
307 NMD->setParent(this);
308 insertNamedMDNode(NMD);
309 if (Name == "llvm.module.flags")
310 ModuleFlags = NMD;
311 }
312 return NMD;
313}
314
315/// eraseNamedMetadata - Remove the given NamedMDNode from this module and
316/// delete it.
318 NamedMDSymTab.erase(NMD->getName());
319 if (NMD == ModuleFlags)
320 ModuleFlags = nullptr;
321 eraseNamedMDNode(NMD);
322}
323
324bool Module::isValidModFlagBehavior(Metadata *MD, ModFlagBehavior &MFB) {
326 uint64_t Val = Behavior->getLimitedValue();
327 if (Val >= ModFlagBehaviorFirstVal && Val <= ModFlagBehaviorLastVal) {
328 MFB = static_cast<ModFlagBehavior>(Val);
329 return true;
330 }
331 }
332 return false;
333}
334
335/// getModuleFlagsMetadata - Returns the module flags in the provided vector.
336void Module::
337getModuleFlagsMetadata(SmallVectorImpl<ModuleFlagEntry> &Flags) const {
338 const NamedMDNode *ModFlags = getModuleFlagsMetadata();
339 if (!ModFlags) return;
340
341 for (const MDNode *Flag : ModFlags->operands()) {
342 // The verifier will catch errors, so no need to check them here.
343 auto *MFBConstant = mdconst::extract<ConstantInt>(Flag->getOperand(0));
344 auto MFB = static_cast<ModFlagBehavior>(MFBConstant->getLimitedValue());
345 MDString *Key = cast<MDString>(Flag->getOperand(1));
346 Metadata *Val = Flag->getOperand(2);
347 Flags.push_back(ModuleFlagEntry(MFB, Key, Val));
348 }
349}
350
351/// Return the corresponding value if Key appears in module flags, otherwise
352/// return null.
354 const NamedMDNode *ModFlags = getModuleFlagsMetadata();
355 if (!ModFlags)
356 return nullptr;
357 for (const MDNode *Flag : ModFlags->operands()) {
358 if (Key == cast<MDString>(Flag->getOperand(1))->getString())
359 return Flag->getOperand(2);
360 }
361 return nullptr;
362}
363
364/// getOrInsertModuleFlagsMetadata - Returns the NamedMDNode in the module that
365/// represents module-level flags. If module-level flags aren't found, it
366/// creates the named metadata that contains them.
368 if (ModuleFlags)
369 return ModuleFlags;
370 return getOrInsertNamedMetadata("llvm.module.flags");
371}
372
373/// addModuleFlag - Add a module-level flag to the module-level flags
374/// metadata. It will create the module-level flags named metadata if it doesn't
375/// already exist.
376void Module::addModuleFlag(ModFlagBehavior Behavior, StringRef Key,
377 Metadata *Val) {
378 Type *Int32Ty = Type::getInt32Ty(Context);
379 Metadata *Ops[3] = {
380 ConstantAsMetadata::get(ConstantInt::get(Int32Ty, Behavior)),
381 MDString::get(Context, Key), Val};
382 getOrInsertModuleFlagsMetadata()->addOperand(MDNode::get(Context, Ops));
383}
384void Module::addModuleFlag(ModFlagBehavior Behavior, StringRef Key,
385 Constant *Val) {
386 addModuleFlag(Behavior, Key, ConstantAsMetadata::get(Val));
387}
388void Module::addModuleFlag(ModFlagBehavior Behavior, StringRef Key,
389 uint32_t Val) {
390 Type *Int32Ty = Type::getInt32Ty(Context);
391 addModuleFlag(Behavior, Key, ConstantInt::get(Int32Ty, Val));
392}
394 assert(Node->getNumOperands() == 3 &&
395 "Invalid number of operands for module flag!");
396 assert(mdconst::hasa<ConstantInt>(Node->getOperand(0)) &&
397 isa<MDString>(Node->getOperand(1)) &&
398 "Invalid operand types for module flag!");
399 getOrInsertModuleFlagsMetadata()->addOperand(Node);
400}
401
402void Module::setModuleFlag(ModFlagBehavior Behavior, StringRef Key,
403 Metadata *Val) {
404 NamedMDNode *ModFlags = getOrInsertModuleFlagsMetadata();
405 // Replace the flag if it already exists.
406 for (unsigned i = 0; i < ModFlags->getNumOperands(); ++i) {
407 MDNode *Flag = ModFlags->getOperand(i);
408 if (cast<MDString>(Flag->getOperand(1))->getString() == Key) {
409 Type *Int32Ty = Type::getInt32Ty(Context);
410 Metadata *Ops[3] = {
411 ConstantAsMetadata::get(ConstantInt::get(Int32Ty, Behavior)),
412 MDString::get(Context, Key), Val};
413 ModFlags->setOperand(i, MDNode::get(Context, Ops));
414 return;
415 }
416 }
417 addModuleFlag(Behavior, Key, Val);
418}
419void Module::setModuleFlag(ModFlagBehavior Behavior, StringRef Key,
420 Constant *Val) {
421 setModuleFlag(Behavior, Key, ConstantAsMetadata::get(Val));
422}
423void Module::setModuleFlag(ModFlagBehavior Behavior, StringRef Key,
424 uint32_t Val) {
425 Type *Int32Ty = Type::getInt32Ty(Context);
426 setModuleFlag(Behavior, Key, ConstantInt::get(Int32Ty, Val));
427}
428
430
432
434 return cast<DICompileUnit>(CUs->getOperand(Idx));
435}
437 return cast<DICompileUnit>(CUs->getOperand(Idx));
438}
439
440void Module::debug_compile_units_iterator::SkipNoDebugCUs() {
441 while (CUs && (Idx < CUs->getNumOperands()) &&
442 ((*this)->getEmissionKind() == DICompileUnit::NoDebug))
443 ++Idx;
444}
445
448}
452}
453
455 return concat<GlobalValue>(functions(), globals(), aliases(), ifuncs());
456}
458Module::global_values() const {
459 return concat<const GlobalValue>(functions(), globals(), aliases(), ifuncs());
460}
461
462//===----------------------------------------------------------------------===//
463// Methods to control the materialization of GlobalValues in the Module.
464//
466 assert(!Materializer &&
467 "Module already has a GVMaterializer. Call materializeAll"
468 " to clear it out before setting another one.");
469 Materializer.reset(GVM);
470}
471
473 if (!Materializer)
474 return Error::success();
475
476 return Materializer->materialize(GV);
477}
478
480 if (!Materializer)
481 return Error::success();
482 std::unique_ptr<GVMaterializer> M = std::move(Materializer);
483 return M->materializeModule();
484}
485
487 llvm::TimeTraceScope timeScope("Materialize metadata");
488 if (!Materializer)
489 return Error::success();
490 return Materializer->materializeMetadata();
491}
492
493//===----------------------------------------------------------------------===//
494// Other module related stuff.
495//
496
497std::vector<StructType *> Module::getIdentifiedStructTypes() const {
498 // If we have a materializer, it is possible that some unread function
499 // uses a type that is currently not visible to a TypeFinder, so ask
500 // the materializer which types it created.
501 if (Materializer)
502 return Materializer->getIdentifiedStructTypes();
503
504 std::vector<StructType *> Ret;
505 TypeFinder SrcStructTypes;
506 SrcStructTypes.run(*this, true);
507 Ret.assign(SrcStructTypes.begin(), SrcStructTypes.end());
508 return Ret;
509}
510
512 const FunctionType *Proto) {
513 auto Encode = [&BaseName](unsigned Suffix) {
514 return (Twine(BaseName) + "." + Twine(Suffix)).str();
515 };
516
517 {
518 // fast path - the prototype is already known
519 auto UinItInserted = UniquedIntrinsicNames.insert({{Id, Proto}, 0});
520 if (!UinItInserted.second)
521 return Encode(UinItInserted.first->second);
522 }
523
524 // Not known yet. A new entry was created with index 0. Check if there already
525 // exists a matching declaration, or select a new entry.
526
527 // Start looking for names with the current known maximum count (or 0).
528 auto NiidItInserted = CurrentIntrinsicIds.insert({BaseName, 0});
529 unsigned Count = NiidItInserted.first->second;
530
531 // This might be slow if a whole population of intrinsics already existed, but
532 // we cache the values for later usage.
533 std::string NewName;
534 while (true) {
535 NewName = Encode(Count);
536 GlobalValue *F = getNamedValue(NewName);
537 if (!F) {
538 // Reserve this entry for the new proto
539 UniquedIntrinsicNames[{Id, Proto}] = Count;
540 break;
541 }
542
543 // A declaration with this name already exists. Remember it.
544 FunctionType *FT = dyn_cast<FunctionType>(F->getValueType());
545 auto UinItInserted = UniquedIntrinsicNames.insert({{Id, FT}, Count});
546 if (FT == Proto) {
547 // It was a declaration for our prototype. This entry was allocated in the
548 // beginning. Update the count to match the existing declaration.
549 UinItInserted.first->second = Count;
550 break;
551 }
552
553 ++Count;
554 }
555
556 NiidItInserted.first->second = Count + 1;
557
558 return NewName;
559}
560
561// dropAllReferences() - This function causes all the subelements to "let go"
562// of all references that they are maintaining. This allows one to 'delete' a
563// whole module at a time, even though there may be circular references... first
564// all references are dropped, and all use counts go to zero. Then everything
565// is deleted for real. Note that no operations are valid on an object that
566// has "dropped all references", except operator delete.
567//
569 for (Function &F : *this)
570 F.dropAllReferences();
571
572 for (GlobalVariable &GV : globals())
574
575 for (GlobalAlias &GA : aliases())
576 GA.dropAllReferences();
577
578 for (GlobalIFunc &GIF : ifuncs())
579 GIF.dropAllReferences();
580}
581
583 auto *Val =
584 cast_or_null<ConstantAsMetadata>(getModuleFlag("NumRegisterParameters"));
585 if (!Val)
586 return 0;
587 return cast<ConstantInt>(Val->getValue())->getZExtValue();
588}
589
590unsigned Module::getDwarfVersion() const {
591 auto *Val = cast_or_null<ConstantAsMetadata>(getModuleFlag("Dwarf Version"));
592 if (!Val)
593 return 0;
594 return cast<ConstantInt>(Val->getValue())->getZExtValue();
595}
596
597bool Module::isDwarf64() const {
598 auto *Val = cast_or_null<ConstantAsMetadata>(getModuleFlag("DWARF64"));
599 return Val && cast<ConstantInt>(Val->getValue())->isOne();
600}
601
602unsigned Module::getCodeViewFlag() const {
603 auto *Val = cast_or_null<ConstantAsMetadata>(getModuleFlag("CodeView"));
604 if (!Val)
605 return 0;
606 return cast<ConstantInt>(Val->getValue())->getZExtValue();
607}
608
609unsigned Module::getInstructionCount() const {
610 unsigned NumInstrs = 0;
611 for (const Function &F : FunctionList)
612 NumInstrs += F.getInstructionCount();
613 return NumInstrs;
614}
615
617 auto &Entry = *ComdatSymTab.insert(std::make_pair(Name, Comdat())).first;
618 Entry.second.Name = &Entry;
619 return &Entry.second;
620}
621
623 auto *Val = cast_or_null<ConstantAsMetadata>(getModuleFlag("PIC Level"));
624
625 if (!Val)
626 return PICLevel::NotPIC;
627
628 return static_cast<PICLevel::Level>(
629 cast<ConstantInt>(Val->getValue())->getZExtValue());
630}
631
633 // The merge result of a non-PIC object and a PIC object can only be reliably
634 // used as a non-PIC object, so use the Min merge behavior.
635 addModuleFlag(ModFlagBehavior::Min, "PIC Level", PL);
636}
637
639 auto *Val = cast_or_null<ConstantAsMetadata>(getModuleFlag("PIE Level"));
640
641 if (!Val)
642 return PIELevel::Default;
643
644 return static_cast<PIELevel::Level>(
645 cast<ConstantInt>(Val->getValue())->getZExtValue());
646}
647
649 addModuleFlag(ModFlagBehavior::Max, "PIE Level", PL);
650}
651
652std::optional<CodeModel::Model> Module::getCodeModel() const {
653 auto *Val = cast_or_null<ConstantAsMetadata>(getModuleFlag("Code Model"));
654
655 if (!Val)
656 return std::nullopt;
657
658 return static_cast<CodeModel::Model>(
659 cast<ConstantInt>(Val->getValue())->getZExtValue());
660}
661
663 // Linking object files with different code models is undefined behavior
664 // because the compiler would have to generate additional code (to span
665 // longer jumps) if a larger code model is used with a smaller one.
666 // Therefore we will treat attempts to mix code models as an error.
667 addModuleFlag(ModFlagBehavior::Error, "Code Model", CL);
668}
669
670std::optional<uint64_t> Module::getLargeDataThreshold() const {
671 auto *Val =
672 cast_or_null<ConstantAsMetadata>(getModuleFlag("Large Data Threshold"));
673
674 if (!Val)
675 return std::nullopt;
676
677 return cast<ConstantInt>(Val->getValue())->getZExtValue();
678}
679
681 // Since the large data threshold goes along with the code model, the merge
682 // behavior is the same.
683 addModuleFlag(ModFlagBehavior::Error, "Large Data Threshold",
684 ConstantInt::get(Type::getInt64Ty(Context), Threshold));
685}
686
688 if (Kind == ProfileSummary::PSK_CSInstr)
689 setModuleFlag(ModFlagBehavior::Error, "CSProfileSummary", M);
690 else
691 setModuleFlag(ModFlagBehavior::Error, "ProfileSummary", M);
692}
693
694Metadata *Module::getProfileSummary(bool IsCS) const {
695 return (IsCS ? getModuleFlag("CSProfileSummary")
696 : getModuleFlag("ProfileSummary"));
697}
698
700 Metadata *MF = getModuleFlag("SemanticInterposition");
701
702 auto *Val = cast_or_null<ConstantAsMetadata>(MF);
703 if (!Val)
704 return false;
705
706 return cast<ConstantInt>(Val->getValue())->getZExtValue();
707}
708
710 addModuleFlag(ModFlagBehavior::Error, "SemanticInterposition", SI);
711}
712
713void Module::setOwnedMemoryBuffer(std::unique_ptr<MemoryBuffer> MB) {
714 OwnedMemoryBuffer = std::move(MB);
715}
716
717bool Module::getRtLibUseGOT() const {
718 auto *Val = cast_or_null<ConstantAsMetadata>(getModuleFlag("RtLibUseGOT"));
719 return Val && (cast<ConstantInt>(Val->getValue())->getZExtValue() > 0);
720}
721
723 addModuleFlag(ModFlagBehavior::Max, "RtLibUseGOT", 1);
724}
725
728 getModuleFlag("direct-access-external-data"));
729 if (Val)
730 return cast<ConstantInt>(Val->getValue())->getZExtValue() > 0;
731 return getPICLevel() == PICLevel::NotPIC;
732}
733
735 addModuleFlag(ModFlagBehavior::Max, "direct-access-external-data", Value);
736}
737
739 if (auto *Val = cast_or_null<ConstantAsMetadata>(getModuleFlag("uwtable")))
740 return UWTableKind(cast<ConstantInt>(Val->getValue())->getZExtValue());
741 return UWTableKind::None;
742}
743
745 addModuleFlag(ModFlagBehavior::Max, "uwtable", uint32_t(Kind));
746}
747
749 auto *Val = cast_or_null<ConstantAsMetadata>(getModuleFlag("frame-pointer"));
750 return static_cast<FramePointerKind>(
751 Val ? cast<ConstantInt>(Val->getValue())->getZExtValue() : 0);
752}
753
755 addModuleFlag(ModFlagBehavior::Max, "frame-pointer", static_cast<int>(Kind));
756}
757
759 Metadata *MD = getModuleFlag("stack-protector-guard");
760 if (auto *MDS = dyn_cast_or_null<MDString>(MD))
761 return MDS->getString();
762 return {};
763}
764
767 addModuleFlag(ModFlagBehavior::Error, "stack-protector-guard", ID);
768}
769
771 Metadata *MD = getModuleFlag("stack-protector-guard-reg");
772 if (auto *MDS = dyn_cast_or_null<MDString>(MD))
773 return MDS->getString();
774 return {};
775}
776
779 addModuleFlag(ModFlagBehavior::Error, "stack-protector-guard-reg", ID);
780}
781
783 Metadata *MD = getModuleFlag("stack-protector-guard-symbol");
784 if (auto *MDS = dyn_cast_or_null<MDString>(MD))
785 return MDS->getString();
786 return {};
787}
788
790 MDString *ID = MDString::get(getContext(), Symbol);
791 addModuleFlag(ModFlagBehavior::Error, "stack-protector-guard-symbol", ID);
792}
793
795 Metadata *MD = getModuleFlag("stack-protector-guard-offset");
797 return CI->getSExtValue();
798 return INT_MAX;
799}
800
802 addModuleFlag(ModFlagBehavior::Error, "stack-protector-guard-offset", Offset);
803}
804
805unsigned Module::getOverrideStackAlignment() const {
806 Metadata *MD = getModuleFlag("override-stack-alignment");
808 return CI->getZExtValue();
809 return 0;
810}
811
812unsigned Module::getMaxTLSAlignment() const {
813 Metadata *MD = getModuleFlag("MaxTLSAlign");
815 return CI->getZExtValue();
816 return 0;
817}
818
820 addModuleFlag(ModFlagBehavior::Error, "override-stack-alignment", Align);
821}
822
823static void addSDKVersionMD(const VersionTuple &V, Module &M, StringRef Name) {
825 Entries.push_back(V.getMajor());
826 if (auto Minor = V.getMinor()) {
827 Entries.push_back(*Minor);
828 if (auto Subminor = V.getSubminor())
829 Entries.push_back(*Subminor);
830 // Ignore the 'build' component as it can't be represented in the object
831 // file.
832 }
833 M.addModuleFlag(Module::ModFlagBehavior::Warning, Name,
834 ConstantDataArray::get(M.getContext(), Entries));
835}
836
837void Module::setSDKVersion(const VersionTuple &V) {
838 addSDKVersionMD(V, *this, "SDK Version");
839}
840
843 if (!CM)
844 return {};
845 auto *Arr = dyn_cast_or_null<ConstantDataArray>(CM->getValue());
846 if (!Arr)
847 return {};
848 auto getVersionComponent = [&](unsigned Index) -> std::optional<unsigned> {
849 if (Index >= Arr->getNumElements())
850 return std::nullopt;
851 return (unsigned)Arr->getElementAsInteger(Index);
852 };
853 auto Major = getVersionComponent(0);
854 if (!Major)
855 return {};
857 if (auto Minor = getVersionComponent(1)) {
858 Result = VersionTuple(*Major, *Minor);
859 if (auto Subminor = getVersionComponent(2)) {
860 Result = VersionTuple(*Major, *Minor, *Subminor);
861 }
862 }
863 return Result;
864}
865
867 return getSDKVersionMD(getModuleFlag("SDK Version"));
868}
869
871 const Module &M, SmallVectorImpl<GlobalValue *> &Vec, bool CompilerUsed) {
872 const char *Name = CompilerUsed ? "llvm.compiler.used" : "llvm.used";
873 GlobalVariable *GV = M.getGlobalVariable(Name);
874 if (!GV || !GV->hasInitializer())
875 return GV;
876
878 for (Value *Op : Init->operands()) {
879 GlobalValue *G = cast<GlobalValue>(Op->stripPointerCasts());
880 Vec.push_back(G);
881 }
882 return GV;
883}
884
886 if (auto *SummaryMD = getProfileSummary(/*IsCS*/ false)) {
887 std::unique_ptr<ProfileSummary> ProfileSummary(
888 ProfileSummary::getFromMD(SummaryMD));
889 if (ProfileSummary) {
892 return;
893 uint64_t BlockCount = Index.getBlockCount();
894 uint32_t NumCounts = ProfileSummary->getNumCounts();
895 if (!NumCounts)
896 return;
897 double Ratio = (double)BlockCount / NumCounts;
899 setProfileSummary(ProfileSummary->getMD(getContext()),
901 }
902 }
903}
904
906 if (const auto *MD = getModuleFlag("darwin.target_variant.triple"))
907 return cast<MDString>(MD)->getString();
908 return "";
909}
910
912 addModuleFlag(ModFlagBehavior::Warning, "darwin.target_variant.triple",
914}
915
917 return getSDKVersionMD(getModuleFlag("darwin.target_variant.SDK Version"));
918}
919
921 addSDKVersionMD(Version, *this, "darwin.target_variant.SDK Version");
922}
923
925 StringRef TargetABI;
926 if (auto *TargetABIMD =
927 dyn_cast_or_null<MDString>(getModuleFlag("target-abi")))
928 TargetABI = TargetABIMD->getString();
929 return TargetABI;
930}
931
933 Metadata *MD = getModuleFlag("winx64-eh-unwindv2");
935 return static_cast<WinX64EHUnwindV2Mode>(CI->getZExtValue());
937}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the StringMap class.
Lower uses of LDS variables from non kernel functions
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
This file contains the simple types necessary to represent the attributes associated with functions a...
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
#define LLVM_EXPORT_TEMPLATE
Definition Compiler.h:215
This file contains the declarations for the subclasses of Constant, which represent the different fla...
dxil globals
dxil translate DXIL Translate Metadata
This file contains the declaration of the GlobalIFunc class, which represents a single indirect funct...
Module.h This file contains the declarations for the Module class.
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.
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
#define F(x, y, z)
Definition MD5.cpp:55
#define G(x, y, z)
Definition MD5.cpp:56
Machine Check Debug Module
Register Reg
static Constant * getOrInsertGlobal(Module &M, StringRef Name, Type *Ty)
This file contains the declarations for metadata subclasses.
#define T
ModuleSummaryIndex.h This file contains the declarations the classes that hold the module index and s...
StandardInstrumentations SI(Mod->getContext(), Debug, VerifyEach)
static VersionTuple getSDKVersionMD(Metadata *MD)
Definition Module.cpp:841
static void addSDKVersionMD(const VersionTuple &V, Module &M, StringRef Name)
Definition Module.cpp:823
This file defines the SmallString class.
This file defines the SmallVector class.
Defines the llvm::VersionTuple class, which represents a version in the form major[....
ConstantArray - Constant Array Declarations.
Definition Constants.h:433
static ConstantAsMetadata * get(Constant *C)
Definition Metadata.h:536
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:715
This is the shared class of boolean and integer constants.
Definition Constants.h:87
This is an important base class in LLVM.
Definition Constant.h:43
A parsed version of the target data layout string in and methods for querying it.
Definition DataLayout.h:63
static ErrorSuccess success()
Create a success value.
Definition Error.h:336
A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &N="", Module *M=nullptr)
Definition Function.h:166
@ ExternalLinkage
Externally visible function.
Definition GlobalValue.h:53
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
bool hasInitializer() const
Definitions have initializers, declarations don't.
This is an important class for using LLVM in a threaded context.
Definition LLVMContext.h:68
Metadata node.
Definition Metadata.h:1078
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition Metadata.h:1569
A single uniqued string.
Definition Metadata.h:721
static LLVM_ABI MDString * get(LLVMContext &Context, StringRef Str)
Definition Metadata.cpp:608
Class to hold module path string table and global value map, and encapsulate methods for operating on...
LLVM_ABI DICompileUnit * operator*() const
Definition Module.cpp:433
LLVM_ABI DICompileUnit * operator->() const
Definition Module.cpp:436
void setStackProtectorGuardSymbol(StringRef Symbol)
Definition Module.cpp:789
void setSemanticInterposition(bool)
Set whether semantic interposition is to be respected.
Definition Module.cpp:709
NamedMDNode * getNamedMetadata(StringRef Name) const
Return the first NamedMDNode in the module with the specified name.
Definition Module.cpp:296
@ Warning
Emits a warning if two values disagree.
Definition Module.h:124
llvm::Error materializeAll()
Make sure all GlobalValues in this Module are fully read and clear the Materializer.
Definition Module.cpp:479
WinX64EHUnwindV2Mode getWinX64EHUnwindV2Mode() const
Get how unwind v2 (epilog) information should be generated for x64 Windows.
Definition Module.cpp:932
void setOverrideStackAlignment(unsigned Align)
Definition Module.cpp:819
void setDirectAccessExternalData(bool Value)
Definition Module.cpp:734
unsigned getMaxTLSAlignment() const
Definition Module.cpp:812
StringRef getTargetABIFromMD()
Returns target-abi from MDString, null if target-abi is absent.
Definition Module.cpp:924
void setOwnedMemoryBuffer(std::unique_ptr< MemoryBuffer > MB)
Take ownership of the given memory buffer.
Definition Module.cpp:713
void setMaterializer(GVMaterializer *GVM)
Sets the GVMaterializer to GVM.
Definition Module.cpp:465
llvm::Error materialize(GlobalValue *GV)
Make sure the GlobalValue is fully read.
Definition Module.cpp:472
Function * getFunction(StringRef Name) const
Look up the specified function in the module symbol table.
Definition Module.cpp:230
void setCodeModel(CodeModel::Model CL)
Set the code model (tiny, small, kernel, medium or large)
Definition Module.cpp:662
StringRef getStackProtectorGuardSymbol() const
Get/set a symbol to use as the stack protector guard.
Definition Module.cpp:782
bool getSemanticInterposition() const
Returns whether semantic interposition is to be respected.
Definition Module.cpp:699
void getMDKindNames(SmallVectorImpl< StringRef > &Result) const
Populate client supplied SmallVector with the name for custom metadata IDs registered in this LLVMCon...
Definition Module.cpp:189
Module(StringRef ModuleID, LLVMContext &C)
The Module constructor.
Definition Module.cpp:73
void removeDebugIntrinsicDeclarations()
Used when printing this module in the new debug info format; removes all declarations of debug intrin...
Definition Module.cpp:122
void setRtLibUseGOT()
Set that PLT should be avoid for RTLib calls.
Definition Module.cpp:722
llvm::Error materializeMetadata()
Definition Module.cpp:486
NamedMDNode * getOrInsertModuleFlagsMetadata()
Returns the NamedMDNode in the module that represents module-level flags.
Definition Module.cpp:367
void eraseNamedMetadata(NamedMDNode *NMD)
Remove the given NamedMDNode from this module and delete it.
Definition Module.cpp:317
unsigned getNumNamedValues() const
Return the number of global values in the module.
Definition Module.cpp:176
unsigned getMDKindID(StringRef Name) const
Return a unique non-zero ID for the specified metadata kind.
Definition Module.cpp:182
void setFramePointer(FramePointerKind Kind)
Definition Module.cpp:754
std::optional< uint64_t > getLargeDataThreshold() const
Returns the large data threshold.
Definition Module.cpp:670
StringRef getStackProtectorGuard() const
Get/set what kind of stack protector guard to use.
Definition Module.cpp:758
bool getRtLibUseGOT() const
Returns true if PLT should be avoided for RTLib calls.
Definition Module.cpp:717
void setModuleFlag(ModFlagBehavior Behavior, StringRef Key, Metadata *Val)
Like addModuleFlag but replaces the old module flag if it already exists.
Definition Module.cpp:402
UWTableKind getUwtable() const
Get/set whether synthesized functions should get the uwtable attribute.
Definition Module.cpp:738
void dropAllReferences()
This function causes all the subinstructions to "let go" of all references that they are maintaining.
Definition Module.cpp:568
void setStackProtectorGuard(StringRef Kind)
Definition Module.cpp:765
void setProfileSummary(Metadata *M, ProfileSummary::Kind Kind)
Attach profile summary metadata to this module.
Definition Module.cpp:687
void setUwtable(UWTableKind Kind)
Definition Module.cpp:744
unsigned getCodeViewFlag() const
Returns the CodeView Version by checking module flags.
Definition Module.cpp:602
void setPartialSampleProfileRatio(const ModuleSummaryIndex &Index)
Set the partial sample profile ratio in the profile summary module flag, if applicable.
Definition Module.cpp:885
Module & operator=(Module &&Other)
Move assignment.
Definition Module.cpp:79
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:511
~Module()
The module destructor. This will dropAllReferences.
Definition Module.cpp:113
FramePointerKind getFramePointer() const
Get/set whether synthesized functions should get the "frame-pointer" attribute.
Definition Module.cpp:748
unsigned getOverrideStackAlignment() const
Get/set the stack alignment overridden from the default.
Definition Module.cpp:805
void addModuleFlag(ModFlagBehavior Behavior, StringRef Key, Metadata *Val)
Add a module-level flag to the module-level flags metadata.
Definition Module.cpp:376
void setStackProtectorGuardReg(StringRef Reg)
Definition Module.cpp:777
PICLevel::Level getPICLevel() const
Returns the PIC level (small or large model)
Definition Module.cpp:622
std::unique_ptr< RandomNumberGenerator > createRNG(const StringRef Name) const
Get a RandomNumberGenerator salted for use with this module.
Definition Module.cpp:150
std::vector< StructType * > getIdentifiedStructTypes() const
Definition Module.cpp:497
void setDarwinTargetVariantTriple(StringRef T)
Set the target variant triple which is a string describing a variant of the target host platform.
Definition Module.cpp:911
void setPICLevel(PICLevel::Level PL)
Set the PIC level (small or large model)
Definition Module.cpp:632
unsigned getNumberRegisterParameters() const
Returns the Number of Register ParametersDwarf Version by checking module flags.
Definition Module.cpp:582
GlobalIFunc * getNamedIFunc(StringRef Name) const
Return the global ifunc in the module with the specified name, of arbitrary type.
Definition Module.cpp:289
StringRef getStackProtectorGuardReg() const
Get/set which register to use as the stack protector guard register.
Definition Module.cpp:770
unsigned getDwarfVersion() const
Returns the Dwarf Version by checking module flags.
Definition Module.cpp:590
void setDataLayout(StringRef Desc)
Set the data layout.
Definition Module.cpp:429
GlobalVariable * getGlobalVariable(StringRef Name) const
Look up the specified global variable in the module symbol table.
Definition Module.h:430
void setLargeDataThreshold(uint64_t Threshold)
Set the large data threshold.
Definition Module.cpp:680
bool isDwarf64() const
Returns the DWARF format by checking module flags.
Definition Module.cpp:597
static bool isValidModFlagBehavior(Metadata *MD, ModFlagBehavior &MFB)
Checks if Metadata represents a valid ModFlagBehavior, and stores the converted result in MFB.
Definition Module.cpp:324
void setStackProtectorGuardOffset(int Offset)
Definition Module.cpp:801
iterator_range< global_object_iterator > global_objects()
Definition Module.cpp:446
GlobalValue * getNamedValue(StringRef Name) const
Return the global value in the module with the specified name, of arbitrary type.
Definition Module.cpp:172
unsigned getInstructionCount() const
Returns the number of non-debug IR instructions in the module.
Definition Module.cpp:609
NamedMDNode * getOrInsertNamedMetadata(StringRef Name)
Return the named MDNode in the module with the specified name.
Definition Module.cpp:303
void getOperandBundleTags(SmallVectorImpl< StringRef > &Result) const
Populate client supplied SmallVector with the bundle tags registered in this LLVMContext.
Definition Module.cpp:193
Comdat * getOrInsertComdat(StringRef Name)
Return the Comdat in the module with the specified name.
Definition Module.cpp:616
FunctionCallee getOrInsertFunction(StringRef Name, FunctionType *T, AttributeList AttributeList)
Look up the specified function in the module symbol table.
Definition Module.cpp:206
std::optional< CodeModel::Model > getCodeModel() const
Returns the code model (tiny, small, kernel, medium or large model)
Definition Module.cpp:652
VersionTuple getDarwinTargetVariantSDKVersion() const
Get the target variant version build SDK version metadata.
Definition Module.cpp:916
void setPIELevel(PIELevel::Level PL)
Set the PIE level (small or large model)
Definition Module.cpp:648
GlobalVariable * getOrInsertGlobal(StringRef Name, Type *Ty, function_ref< GlobalVariable *()> CreateGlobalCallback)
Look up the specified global in the module symbol table.
Definition Module.cpp:257
VersionTuple getSDKVersion() const
Get the build SDK version metadata.
Definition Module.cpp:866
GlobalAlias * getNamedAlias(StringRef Name) const
Return the global alias in the module with the specified name, of arbitrary type.
Definition Module.cpp:285
void setDarwinTargetVariantSDKVersion(VersionTuple Version)
Set the target variant version build SDK version metadata.
Definition Module.cpp:920
PIELevel::Level getPIELevel() const
Returns the PIE level (small or large model)
Definition Module.cpp:638
StringRef getDarwinTargetVariantTriple() const
Get the target variant triple which is a string describing a variant of the target host platform.
Definition Module.cpp:905
void setSDKVersion(const VersionTuple &V)
Attach a build SDK version metadata to this module.
Definition Module.cpp:837
iterator_range< global_value_iterator > global_values()
Definition Module.cpp:454
int getStackProtectorGuardOffset() const
Get/set what offset from the stack protector to use.
Definition Module.cpp:794
bool getDirectAccessExternalData() const
Get/set whether referencing global variables can use direct access relocations on ELF targets.
Definition Module.cpp:726
Metadata * getProfileSummary(bool IsCS) const
Returns profile summary metadata.
Definition Module.cpp:694
Metadata * getModuleFlag(StringRef Key) const
Return the corresponding value if Key appears in module flags, otherwise return null.
Definition Module.cpp:353
A tuple of MDNodes.
Definition Metadata.h:1757
LLVM_ABI void setOperand(unsigned I, MDNode *New)
LLVM_ABI StringRef getName() const
LLVM_ABI MDNode * getOperand(unsigned i) const
LLVM_ABI unsigned getNumOperands() const
iterator_range< op_iterator > operands()
Definition Metadata.h:1853
void setPartialProfileRatio(double R)
LLVM_ABI Metadata * getMD(LLVMContext &Context, bool AddPartialField=true, bool AddPartialProfileRatioField=true)
Return summary information as metadata.
uint32_t getNumCounts() const
bool isPartialProfile() const
static LLVM_ABI ProfileSummary * getFromMD(Metadata *MD)
Construct profile summary from metdata.
A random number generator.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Definition SmallString.h:26
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
The TimeTraceScope is a helper class to call the begin and end functions of the time trace profiler.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition Twine.h:82
TypeFinder - Walk over a module, identifying all of the types that are used by the module.
Definition TypeFinder.h:31
iterator end()
Definition TypeFinder.h:52
void run(const Module &M, bool onlyNamed)
iterator begin()
Definition TypeFinder.h:51
static LLVM_ABI IntegerType * getInt64Ty(LLVMContext &C)
Definition Type.cpp:298
static LLVM_ABI IntegerType * getInt32Ty(LLVMContext &C)
Definition Type.cpp:297
void dropAllReferences()
Drop all references to operands.
Definition User.h:349
This class provides a symbol table of name/value pairs.
Represents a version number in the form major[.minor[.subminor[.build]]].
An efficient, type-erasing, non-owning reference to a callable.
A range adaptor for a pair of iterators.
This file contains the declaration of the Comdat class, which represents a single COMDAT in LLVM.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition CallingConv.h:24
LLVM_ABI Function * getDeclarationIfExists(const Module *M, ID id)
Look up the Function declaration of the intrinsic id in the Module M and return it if it exists.
Flag
These should be considered private to the implementation of the MCInstrDesc class.
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > dyn_extract_or_null(Y &&MD)
Extract a Value from Metadata, if any, allowing null.
Definition Metadata.h:708
std::enable_if_t< detail::IsValidPointer< X, Y >::value, bool > hasa(Y &&MD)
Check whether Metadata has a Value.
Definition Metadata.h:650
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > extract(Y &&MD)
Extract a Value from Metadata.
Definition Metadata.h:667
Context & getContext() const
Definition BasicBlock.h:99
LLVM_ABI StringRef filename(StringRef path LLVM_LIFETIME_BOUND, Style style=Style::native)
Get filename.
Definition Path.cpp:577
This is an optimization pass for GlobalISel generic memory operations.
@ Offset
Definition DWP.cpp:477
FramePointerKind
Definition CodeGen.h:118
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
FunctionAddr VTableAddr uintptr_t uintptr_t Int32Ty
Definition InstrProf.h:296
auto cast_or_null(const Y &Val)
Definition Casting.h:714
Op::Description Desc
detail::concat_range< ValueT, RangeTs... > concat(RangeTs &&...Ranges)
Returns a concatenated range across two or more ranges.
Definition STLExtras.h:1150
auto dyn_cast_or_null(const Y &Val)
Definition Casting.h:753
UWTableKind
Definition CodeGen.h:148
@ None
No unwind table requested.
Definition CodeGen.h:149
FunctionAddr VTableAddr Count
Definition InstrProf.h:139
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
Definition Casting.h:547
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
@ Other
Any other memory.
Definition ModRef.h:68
DWARFExpression::Operation Op
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:559
WinX64EHUnwindV2Mode
Definition CodeGen.h:161
LLVM_ABI 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:870
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:867
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition Alignment.h:39