54 :
Context(C), Materializer(), ModuleID(MID), SourceFileName(MID), DL(
"") {
57 Context.addModule(
this);
61 Context.removeModule(
this);
160 va_start(Args, RetTy);
163 std::vector<Type*> ArgTys;
164 while (
Type *ArgTy = va_arg(Args,
Type*))
165 ArgTys.push_back(ArgTy);
178 va_start(Args, RetTy);
181 std::vector<Type*> ArgTys;
182 while (
Type *ArgTy = va_arg(Args,
Type*))
183 ArgTys.push_back(ArgTy);
214 if (AllowLocal || !Result->hasLocalLinkage())
279 NMD->setParent(
this);
293 if (
ConstantInt *Behavior = mdconst::dyn_extract_or_null<ConstantInt>(MD)) {
294 uint64_t Val = Behavior->getLimitedValue();
307 if (!ModFlags)
return;
311 if (
Flag->getNumOperands() >= 3 &&
313 dyn_cast_or_null<MDString>(
Flag->getOperand(1))) {
329 if (Key == MFE.Key->getString())
371 "Invalid number of operands for module flag!");
374 "Invalid operand types for module flag!");
387 return cast<DICompileUnit>(CUs->
getOperand(Idx));
390 return cast<DICompileUnit>(CUs->getOperand(Idx));
393 void Module::debug_compile_units_iterator::SkipNoDebugCUs() {
394 while (CUs && (Idx < CUs->getNumOperands()) &&
404 "Module already has a GVMaterializer. Call materializeAll"
405 " to clear it out before setting another one.");
406 Materializer.reset(GVM);
413 return Materializer->materialize(GV);
419 std::unique_ptr<GVMaterializer> M = std::move(Materializer);
420 return M->materializeModule();
426 return Materializer->materializeMetadata();
438 return Materializer->getIdentifiedStructTypes();
440 std::vector<StructType *>
Ret;
442 SrcStructTypes.
run(*
this,
true);
443 Ret.assign(SrcStructTypes.
begin(), SrcStructTypes.
end());
459 GV.dropAllReferences();
462 GA.dropAllReferences();
465 GIF.dropAllReferences();
469 auto *Val = cast_or_null<ConstantAsMetadata>(
getModuleFlag(
"Dwarf Version"));
472 return cast<ConstantInt>(Val->getValue())->getZExtValue();
476 auto *Val = cast_or_null<ConstantAsMetadata>(
getModuleFlag(
"CodeView"));
479 return cast<ConstantInt>(Val->getValue())->getZExtValue();
483 auto &Entry = *ComdatSymTab.
insert(std::make_pair(Name,
Comdat())).first;
484 Entry.second.Name = &Entry;
485 return &Entry.second;
489 auto *Val = cast_or_null<ConstantAsMetadata>(
getModuleFlag(
"PIC Level"));
495 cast<ConstantInt>(Val->getValue())->getZExtValue());
503 auto *Val = cast_or_null<ConstantAsMetadata>(
getModuleFlag(
"PIE Level"));
509 cast<ConstantInt>(Val->getValue())->getZExtValue());
525 OwnedMemoryBuffer = std::move(MB);
530 const char *
Name = CompilerUsed ?
"llvm.compiler.used" :
"llvm.used";
537 GlobalValue *
G = cast<GlobalValue>(
Op->stripPointerCastsNoFollowAliases());
Pass interface - Implemented by all 'passes'.
StringRef getName() const
void push_back(const T &Elt)
A parsed version of the target data layout string in and methods for querying it. ...
This class provides a symbol table of name/value pairs.
const ValueSymbolTable & getValueSymbolTable() const
Get the symbol table of global variable and function identifiers.
GlobalIFunc * getNamedIFunc(StringRef Name) const
Return the global ifunc in the module with the specified name, of arbitrary type. ...
llvm::Error materializeAll()
Make sure all GlobalValues in this Module are fully read and clear the Materializer.
void reset(StringRef LayoutDescription)
Parse a data layout string (with fallback to default values).
DICompileUnit * operator*() const
iterator erase(iterator where)
RandomNumberGenerator * createRNG(const Pass *P) const
Get a RandomNumberGenerator salted for use with this module.
GlobalVariable * collectUsedGlobalVariables(const Module &M, SmallPtrSetImpl< GlobalValue * > &Set, bool CompilerUsed)
Given "llvm.used" or "llvm.compiler.used" as a global name, collect the initializer elements of that ...
A Module instance is used to store all the information related to an LLVM module. ...
static MDString * get(LLVMContext &Context, StringRef Str)
unsigned getNumOperands() const
Return number of MDNode operands.
MachineInstrBuilder MachineInstrBuilder &DefMI const MCInstrDesc & Desc
void setMaterializer(GVMaterializer *GVM)
Sets the GVMaterializer to GVM.
void addOperand(MDNode *M)
bool isIntrinsic() const
isIntrinsic - Returns true if the function's name starts with "llvm.".
static PointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space...
NamedMDNode * getOrInsertNamedMetadata(StringRef Name)
Return the named MDNode in the module with the specified name.
Externally visible function.
void setDataLayout(StringRef Desc)
Set the data layout.
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
std::vector< StructType * > getIdentifiedStructTypes() const
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
PIELevel::Level getPIELevel() const
Returns the PIE level (small or large model)
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
void getMDKindNames(SmallVectorImpl< StringRef > &Result) const
Populate client supplied SmallVector with the name for custom metadata IDs registered in this LLVMCon...
struct fuzzer::@269 Flags
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
void eraseNamedMetadata(NamedMDNode *NMD)
Remove the given NamedMDNode from this module and delete it.
Metadata * getProfileSummary()
Returns profile summary metadata.
static const uint16_t * lookup(unsigned opcode, unsigned domain, ArrayRef< uint16_t[3]> Table)
const std::string & getModuleIdentifier() const
Get the module identifier which is, essentially, the name of the module.
unsigned getCodeViewFlag() const
Returns the CodeView Version by checking module flags.
DICompileUnit * operator->() const
Class to represent function types.
static FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
void dropAllReferences()
This function causes all the subinstructions to "let go" of all references that they are maintaining...
iterator_range< op_iterator > operands()
Class to represent pointers.
Flag
These should be considered private to the implementation of the MCInstrDesc class.
Function * getFunction(StringRef Name) const
Look up the specified function in the module symbol table.
void getMDKindNames(SmallVectorImpl< StringRef > &Result) const
getMDKindNames - Populate client supplied SmallVector with the name for custom metadata IDs registere...
static Constant * getBitCast(Constant *C, Type *Ty, bool OnlyIfReduced=false)
StringRef filename(StringRef path)
Get filename.
Module(StringRef ModuleID, LLVMContext &C)
The Module constructor.
Constant * getOrInsertFunction(StringRef Name, FunctionType *T, AttributeSet AttributeList)
Look up the specified function in the module symbol table.
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important class for using LLVM in a threaded context.
void getOperandBundleTags(SmallVectorImpl< StringRef > &Result) const
Populate client supplied SmallVector with the bundle tags registered in this LLVMContext.
Constant * getOrInsertGlobal(StringRef Name, Type *Ty)
Look up the specified global in the module symbol table.
NamedMDNode * getModuleFlagsMetadata() const
Returns the NamedMDNode in the module that represents module-level flags.
This is an important base class in LLVM.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
ModFlagBehavior
This enumeration defines the supported behaviors of module flags.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
void addModuleFlag(ModFlagBehavior Behavior, StringRef Key, Metadata *Val)
Add a module-level flag to the module-level flags metadata.
MDNode * getOperand(unsigned i) const
unsigned getMDKindID(StringRef Name) const
getMDKindID - Return a unique non-zero ID for the specified metadata kind.
self_iterator getIterator()
Comdat * getOrInsertComdat(StringRef Name)
Return the Comdat in the module with the specified name.
unsigned getDwarfVersion() const
Returns the Dwarf Version by checking module flags.
Metadata * getModuleFlag(StringRef Key) const
Return the corresponding value if Key appears in module flags, otherwise return null.
void getOperandBundleTags(SmallVectorImpl< StringRef > &Result) const
getOperandBundleTags - Populate client supplied SmallVector with the bundle tags registered in this L...
const MDOperand & getOperand(unsigned I) const
static ErrorSuccess success()
Create a success value.
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the generic address space (address sp...
This is the shared class of boolean and integer constants.
PICLevel::Level getPICLevel() const
Returns the PIC level (small or large model)
void run(const Module &M, bool onlyNamed)
StringRef toStringRef(SmallVectorImpl< char > &Out) const
This returns the twine as a single StringRef if it can be represented as such.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Module.h This file contains the declarations for the Module class.
static bool isValidModFlagBehavior(Metadata *MD, ModFlagBehavior &MFB)
Checks if Metadata represents a valid ModFlagBehavior, and stores the converted result in MFB...
NamedMDNode * getOrInsertModuleFlagsMetadata()
Returns the NamedMDNode in the module that represents module-level flags.
void dropAllReferences()
dropAllReferences() - This method causes all the subinstructions to "let go" of all references that t...
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.
bool insert(MapEntryTy *KeyValue)
insert - Insert the specified key/value pair into the map.
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
StringMap - This is an unconventional map that is specialized for handling keys that are "strings"...
ConstantArray - Constant Array Declarations.
bool hasInitializer() const
Definitions have initializers, declarations don't.
void push_back(pointer val)
GlobalAlias * getNamedAlias(StringRef Name) const
Return the global alias in the module with the specified name, of arbitrary type. ...
void setAttributes(AttributeSet Attrs)
Set the attribute list for this Function.
A random number generator.
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
void setProfileSummary(Metadata *M)
Attach profile summary metadata to this module.
PointerType * getType() const
Global values are always pointers.
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
NamedMDNode * getNamedMetadata(const Twine &Name) const
Return the first NamedMDNode in the module with the specified name.
static IntegerType * getInt32Ty(LLVMContext &C)
llvm::Error materialize(GlobalValue *GV)
Make sure the GlobalValue is fully read.
~Module()
The module destructor. This will dropAllReferences.
void setPIELevel(PIELevel::Level PL)
Set the PIE level (small or large model)
iterator_range< ifunc_iterator > ifuncs()
void setOwnedMemoryBuffer(std::unique_ptr< MemoryBuffer > MB)
Take ownership of the given memory buffer.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
Lightweight error class with error context and mandatory checking.
void setPICLevel(PICLevel::Level PL)
Set the PIC level (small or large model)
iterator_range< global_iterator > globals()
StringRef - Represent a constant reference to a string, i.e.
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, const Twine &N="", Module *M=nullptr)
unsigned getMDKindID(StringRef Name) const
Return a unique non-zero ID for the specified metadata kind.
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
TypeFinder - Walk over a module, identifying all of the types that are used by the module...
llvm::Error materializeMetadata()
GlobalValue * getNamedValue(StringRef Name) const
Return the global value in the module with the specified name, of arbitrary type. ...
Value * lookup(StringRef Name) const
This method finds the value with the given Name in the the symbol table.
GlobalVariable * getGlobalVariable(StringRef Name) const
Look up the specified global variable in the module symbol table.
iterator_range< alias_iterator > aliases()