52 : DstStructTypesSet(DstStructTypesSet) {}
57 void addTypeMapping(
Type *DstTy,
Type *SrcTy);
61 void linkDefinedTypeBodies();
71 return cast<FunctionType>(
get((
Type *)
T));
75 Type *remapType(
Type *SrcTy)
override {
return get(SrcTy); }
77 bool areTypesIsomorphic(
Type *DstTy,
Type *SrcTy);
81 void TypeMapTy::addTypeMapping(
Type *DstTy,
Type *SrcTy) {
82 assert(SpeculativeTypes.empty());
83 assert(SpeculativeDstOpaqueTypes.empty());
87 if (!areTypesIsomorphic(DstTy, SrcTy)) {
90 for (
Type *Ty : SpeculativeTypes)
91 MappedTypes.erase(Ty);
93 SrcDefinitionsToResolve.resize(SrcDefinitionsToResolve.size() -
94 SpeculativeDstOpaqueTypes.size());
95 for (
StructType *Ty : SpeculativeDstOpaqueTypes)
96 DstResolvedOpaqueTypes.erase(Ty);
98 for (
Type *Ty : SpeculativeTypes)
99 if (
auto *STy = dyn_cast<StructType>(Ty))
103 SpeculativeTypes.clear();
104 SpeculativeDstOpaqueTypes.clear();
109 bool TypeMapTy::areTypesIsomorphic(
Type *DstTy,
Type *SrcTy) {
115 Type *&Entry = MappedTypes[SrcTy];
117 return Entry == DstTy;
121 if (DstTy == SrcTy) {
129 if (
StructType *SSTy = dyn_cast<StructType>(SrcTy)) {
131 if (SSTy->isOpaque()) {
133 SpeculativeTypes.push_back(SrcTy);
141 if (cast<StructType>(DstTy)->isOpaque()) {
143 if (!DstResolvedOpaqueTypes.insert(cast<StructType>(DstTy)).second)
145 SrcDefinitionsToResolve.push_back(SSTy);
146 SpeculativeTypes.push_back(SrcTy);
147 SpeculativeDstOpaqueTypes.push_back(cast<StructType>(DstTy));
158 if (isa<IntegerType>(DstTy))
160 if (
PointerType *PT = dyn_cast<PointerType>(DstTy)) {
161 if (PT->getAddressSpace() != cast<PointerType>(SrcTy)->getAddressSpace())
164 }
else if (
FunctionType *FT = dyn_cast<FunctionType>(DstTy)) {
165 if (FT->isVarArg() != cast<FunctionType>(SrcTy)->isVarArg())
167 }
else if (
StructType *DSTy = dyn_cast<StructType>(DstTy)) {
169 if (DSTy->isLiteral() != SSTy->
isLiteral() ||
170 DSTy->isPacked() != SSTy->
isPacked())
172 }
else if (
auto *DSeqTy = dyn_cast<SequentialType>(DstTy)) {
173 if (DSeqTy->getNumElements() !=
174 cast<SequentialType>(SrcTy)->getNumElements())
181 SpeculativeTypes.push_back(SrcTy);
192 void TypeMapTy::linkDefinedTypeBodies() {
194 for (
StructType *SrcSTy : SrcDefinitionsToResolve) {
195 StructType *DstSTy = cast<StructType>(MappedTypes[SrcSTy]);
199 Elements.
resize(SrcSTy->getNumElements());
200 for (
unsigned I = 0,
E = Elements.
size();
I !=
E; ++
I)
201 Elements[
I] =
get(SrcSTy->getElementType(
I));
203 DstSTy->
setBody(Elements, SrcSTy->isPacked());
204 DstStructTypesSet.switchToNonOpaque(DstSTy);
206 SrcDefinitionsToResolve.clear();
207 DstResolvedOpaqueTypes.clear();
221 DstStructTypesSet.addNonOpaque(DTy);
226 return get(Ty, Visited);
231 Type **Entry = &MappedTypes[Ty];
236 bool IsUniqued = !isa<StructType>(Ty) || cast<StructType>(Ty)->isLiteral();
240 for (
auto &Pair : MappedTypes) {
241 assert(!(Pair.first != Ty && Pair.second == Ty) &&
242 "mapping to a source type");
247 if (!IsUniqued && !Visited.
insert(cast<StructType>(Ty)).second) {
262 bool AnyChange =
false;
270 Entry = &MappedTypes[Ty];
272 if (
auto *DTy = dyn_cast<StructType>(*Entry)) {
274 auto *STy = cast<StructType>(Ty);
275 finishType(DTy, STy, ElementTypes);
283 if (!AnyChange && IsUniqued)
292 cast<ArrayType>(Ty)->getNumElements());
295 cast<VectorType>(Ty)->getNumElements());
298 cast<PointerType>(Ty)->getAddressSpace());
302 cast<FunctionType>(Ty)->isVarArg());
304 auto *STy = cast<StructType>(Ty);
311 DstStructTypesSet.addOpaque(STy);
316 DstStructTypesSet.findNonOpaque(ElementTypes, IsPacked)) {
318 return *Entry = OldT;
322 DstStructTypesSet.addNonOpaque(STy);
327 finishType(DTy, STy, ElementTypes);
349 IRLinker &TheIRLinker;
352 GlobalValueMaterializer(IRLinker &TheIRLinker) : TheIRLinker(TheIRLinker) {}
357 IRLinker &TheIRLinker;
360 LocalValueMaterializer(IRLinker &TheIRLinker) : TheIRLinker(TheIRLinker) {}
371 std::unique_ptr<Module> SrcM;
374 std::function<void(GlobalValue &, IRMover::ValueAdder)> AddLazyFor;
377 GlobalValueMaterializer GValMaterializer;
378 LocalValueMaterializer LValMaterializer;
391 std::vector<GlobalValue *> Worklist;
394 if (ValuesToLink.insert(GV).second)
395 Worklist.push_back(GV);
402 bool LinkModuleInlineAsm;
407 bool DoneLinkingBodies =
false;
414 FoundError = std::move(E);
431 void emitWarning(
const Twine &Message) {
457 void computeTypeMapping();
470 Error linkModuleFlagsMetadata();
486 void prepareCompileUnitsForImport();
487 void linkNamedMDNodes();
490 IRLinker(
Module &DstM, MDMapT &SharedMDs,
494 bool LinkModuleInlineAsm,
bool IsPerformingImport)
495 : DstM(DstM), SrcM(std::move(SrcM)), AddLazyFor(std::move(AddLazyFor)),
496 TypeMap(Set), GValMaterializer(*this), LValMaterializer(*this),
497 SharedMDs(SharedMDs), LinkModuleInlineAsm(LinkModuleInlineAsm),
500 AliasMCID(Mapper.registerAlternateMappingContext(AliasValueMap,
501 &LValMaterializer)) {
505 if (IsPerformingImport)
506 prepareCompileUnitsForImport();
529 ConflictGV->setName(Name);
530 assert(ConflictGV->getName() != Name &&
"forceRenaming didn't work");
536 Value *GlobalValueMaterializer::materialize(
Value *SGV) {
537 return TheIRLinker.materialize(SGV,
false);
540 Value *LocalValueMaterializer::materialize(
Value *SGV) {
541 return TheIRLinker.materialize(SGV,
true);
544 Value *IRLinker::materialize(
Value *V,
bool ForAlias) {
562 if (
auto *
F = dyn_cast<Function>(New)) {
563 if (!
F->isDeclaration())
565 }
else if (
auto *V = dyn_cast<GlobalVariable>(New)) {
566 if (V->hasInitializer() || V->hasAppendingLinkage())
569 auto *
A = cast<GlobalAlias>(New);
585 if (ForAlias || shouldLink(New, *SGV))
586 setError(linkGlobalValueBody(*New, *SGV));
627 bool ForDefinition) {
629 if (
auto *SGVar = dyn_cast<GlobalVariable>(SGV)) {
630 NewGV = copyGlobalVariableProto(SGVar);
631 }
else if (
auto *SF = dyn_cast<Function>(SGV)) {
632 NewGV = copyFunctionProto(SF);
635 NewGV = copyGlobalAliasProto(cast<GlobalAlias>(SGV));
652 if (
auto *NewGO = dyn_cast<GlobalObject>(NewGV)) {
655 NewGO->copyMetadata(cast<GlobalObject>(SGV), 0);
661 if (
auto *NewF = dyn_cast<Function>(NewGV)) {
662 NewF->setPersonalityFn(
nullptr);
663 NewF->setPrefixData(
nullptr);
664 NewF->setPrologueData(
nullptr);
674 void IRLinker::computeTypeMapping() {
688 TypeMap.addTypeMapping(DAT->
getElementType(), SAT->getElementType());
703 std::vector<StructType *> Types = SrcM->getIdentifiedStructTypes();
708 if (TypeMap.DstStructTypesSet.hasType(
ST)) {
717 size_t DotPos =
ST->getName().rfind(
'.');
719 ST->getName().back() ==
'.' ||
720 !isdigit(static_cast<unsigned char>(
ST->getName()[DotPos + 1])))
745 if (TypeMap.DstStructTypesSet.hasType(DST))
746 TypeMap.addTypeMapping(DST,
ST);
751 TypeMap.linkDefinedTypeBodies();
756 unsigned NumElements = cast<ArrayType>(C->
getType())->getNumElements();
758 for (
unsigned i = 0;
i != NumElements; ++
i)
774 bool IsNewStructor =
false;
775 bool IsOldStructor =
false;
776 if (Name ==
"llvm.global_ctors" || Name ==
"llvm.global_dtors") {
777 if (cast<StructType>(EltTy)->getNumElements() == 3)
778 IsNewStructor =
true;
780 IsOldStructor =
true;
785 auto &
ST = *cast<StructType>(EltTy);
786 Type *Tys[3] = {
ST.getElementType(0),
ST.getElementType(1), VoidPtrTy};
790 uint64_t DstNumElements = 0;
797 "Linking globals named '" + SrcGV->
getName() +
798 "': can only link appending global with another appending "
803 return stringErr(
"Appending variables with different element types!");
805 return stringErr(
"Appending variables linked with different const'ness!");
809 "Appending variables with different alignment need to be linked!");
813 "Appending variables with different visibility need to be linked!");
817 "Appending variables with different unnamed_addr need to be linked!");
821 "Appending variables with different section name need to be linked!");
834 return !shouldLink(DGV, *Key);
836 SrcElements.
erase(It, SrcElements.
end());
838 uint64_t NewSize = DstNumElements + SrcElements.
size();
852 Mapper.scheduleMapAppendingVariable(*NG,
854 IsOldStructor, SrcElements);
881 bool LazilyAdded =
false;
882 AddLazyFor(SGV, [
this, &LazilyAdded](
GlobalValue &GV) {
893 bool ShouldLink = shouldLink(DGV, *SGV);
899 return cast<Constant>(
I->second);
901 I = AliasValueMap.find(SGV);
902 if (
I != AliasValueMap.end())
903 return cast<Constant>(
I->second);
906 if (!ShouldLink && ForAlias)
912 return linkAppendingVarProto(cast_or_null<GlobalVariable>(DGV),
913 cast<GlobalVariable>(SGV));
916 if (DGV && !ShouldLink) {
922 if (DoneLinkingBodies)
925 NewGV = copyGlobalValueProto(SGV, ShouldLink);
926 if (ShouldLink || !ForAlias)
933 if (
Function *
F = dyn_cast<Function>(NewGV))
935 NewGV = Remangled.getValue();
937 if (ShouldLink || ForAlias) {
939 if (
auto *GO = dyn_cast<GlobalObject>(NewGV)) {
947 if (!ShouldLink && ForAlias)
954 if (DGV && NewGV != DGV) {
995 Mapper.scheduleRemapFunction(Dst);
1000 Mapper.scheduleMapGlobalAliasee(Dst, *Src.
getAliasee(), AliasMCID);
1004 if (
auto *
F = dyn_cast<Function>(&Src))
1005 return linkFunctionBody(cast<Function>(Dst), *
F);
1006 if (
auto *GVar = dyn_cast<GlobalVariable>(&Src)) {
1007 linkGlobalVariable(cast<GlobalVariable>(Dst), *GVar);
1010 linkAliasBody(cast<GlobalAlias>(Dst), cast<GlobalAlias>(Src));
1014 void IRLinker::prepareCompileUnitsForImport() {
1015 NamedMDNode *SrcCompileUnits = SrcM->getNamedMetadata(
"llvm.dbg.cu");
1016 if (!SrcCompileUnits)
1022 auto *CU = cast<DICompileUnit>(SrcCompileUnits->
getOperand(
I));
1023 assert(CU &&
"Expected valid compile unit");
1029 ValueMap.
MD()[CU->getRawEnumTypes()].reset(
nullptr);
1030 ValueMap.
MD()[CU->getRawMacros()].reset(
nullptr);
1031 ValueMap.
MD()[CU->getRawRetainedTypes()].reset(
nullptr);
1038 [](
const GlobalValue *GV) {
return isa<GlobalVariable>(GV); }) &&
1039 "Unexpected importing of a GlobalVariable definition");
1040 ValueMap.
MD()[CU->getRawGlobalVariables()].reset(
nullptr);
1055 bool ReplaceImportedEntities =
false;
1056 for (
auto *
IE : CU->getImportedEntities()) {
1058 assert(Scope &&
"Invalid Scope encoding!");
1059 if (isa<DILocalScope>(Scope))
1062 ReplaceImportedEntities =
true;
1064 if (ReplaceImportedEntities) {
1065 if (!AllImportedModules.
empty())
1069 AllImportedModules.
end())));
1073 ValueMap.
MD()[CU->getRawImportedEntities()].reset(
nullptr);
1079 void IRLinker::linkNamedMDNodes() {
1080 const NamedMDNode *SrcModFlags = SrcM->getModuleFlagsMetadata();
1081 for (
const NamedMDNode &NMD : SrcM->named_metadata()) {
1083 if (&NMD == SrcModFlags)
1087 for (
const MDNode *
Op : NMD.operands())
1093 Error IRLinker::linkModuleFlagsMetadata() {
1095 const NamedMDNode *SrcModFlags = SrcM->getModuleFlagsMetadata();
1120 Flags[
ID] = std::make_pair(Op,
I);
1129 mdconst::extract<ConstantInt>(SrcOp->
getOperand(0));
1133 std::tie(DstOp, DstIndex) = Flags.
lookup(ID);
1134 unsigned SrcBehaviorValue = SrcBehavior->
getZExtValue();
1155 mdconst::extract<ConstantInt>(DstOp->getOperand(0));
1156 unsigned DstBehaviorValue = DstBehavior->
getZExtValue();
1162 SrcOp->
getOperand(2) != DstOp->getOperand(2))
1163 return stringErr(
"linking module flags '" + ID->getString() +
1164 "': IDs have conflicting override values");
1169 Flags[
ID].first = SrcOp;
1174 if (SrcBehaviorValue != DstBehaviorValue)
1175 return stringErr(
"linking module flags '" + ID->getString() +
1176 "': IDs have conflicting behaviors");
1178 auto replaceDstValue = [&](
MDNode *New) {
1179 Metadata *FlagOps[] = {DstOp->getOperand(0),
ID, New};
1186 switch (SrcBehaviorValue) {
1192 if (SrcOp->
getOperand(2) != DstOp->getOperand(2))
1193 return stringErr(
"linking module flags '" + ID->getString() +
1194 "': IDs have conflicting values");
1199 if (SrcOp->
getOperand(2) != DstOp->getOperand(2)) {
1200 emitWarning(
"linking module flags '" + ID->getString() +
1201 "': IDs have conflicting values");
1206 MDNode *DstValue = cast<MDNode>(DstOp->getOperand(2));
1211 MDs.append(SrcValue->op_begin(), SrcValue->op_end());
1218 MDNode *DstValue = cast<MDNode>(DstOp->getOperand(2));
1221 Elts.
insert(SrcValue->op_begin(), SrcValue->op_end());
1231 for (
unsigned I = 0, E = Requirements.
size();
I !=
E; ++
I) {
1232 MDNode *Requirement = Requirements[
I];
1238 return stringErr(
"linking module flags '" + Flag->
getString() +
1239 "': does not have the required value");
1256 const Triple &DstTriple) {
1260 return SrcTriple.
str();
1262 return DstTriple.
str();
1265 Error IRLinker::run() {
1267 if (SrcM->getMaterializer())
1268 if (
Error Err = SrcM->getMaterializer()->materializeMetadata())
1277 emitWarning(
"Linking two modules of different data layouts: '" +
1278 SrcM->getModuleIdentifier() +
"' is '" +
1279 SrcM->getDataLayoutStr() +
"' whereas '" +
1285 if (DstM.
getTargetTriple().empty() && !SrcM->getTargetTriple().empty())
1290 if (!SrcM->getTargetTriple().empty() && !
triplesMatch(SrcTriple, DstTriple))
1291 emitWarning(
"Linking two modules of different target triples: " +
1292 SrcM->getModuleIdentifier() +
"' is '" +
1293 SrcM->getTargetTriple() +
"' whereas '" +
1300 if (LinkModuleInlineAsm && !SrcM->getModuleInlineAsm().empty()) {
1305 SrcM->getModuleInlineAsm());
1309 computeTypeMapping();
1312 while (!Worklist.empty()) {
1314 Worklist.pop_back();
1318 AliasValueMap.find(GV) != AliasValueMap.end())
1322 Mapper.mapValue(*GV);
1324 return std::move(*FoundError);
1329 DoneLinkingBodies =
true;
1338 return linkModuleFlagsMetadata();
1342 : ETypes(E), IsPacked(P) {}
1345 : ETypes(ST->elements()), IsPacked(ST->isPacked()) {}
1355 StructType *IRMover::StructTypeKeyInfo::getEmptyKey() {
1359 StructType *IRMover::StructTypeKeyInfo::getTombstoneKey() {
1363 unsigned IRMover::StructTypeKeyInfo::getHashValue(
const KeyTy &Key) {
1368 unsigned IRMover::StructTypeKeyInfo::getHashValue(
const StructType *
ST) {
1369 return getHashValue(KeyTy(ST));
1374 if (RHS == getEmptyKey() || RHS == getTombstoneKey())
1376 return LHS == KeyTy(RHS);
1381 if (RHS == getEmptyKey() || RHS == getTombstoneKey())
1383 return KeyTy(LHS) == KeyTy(RHS);
1388 NonOpaqueStructTypes.insert(Ty);
1393 NonOpaqueStructTypes.insert(Ty);
1394 bool Removed = OpaqueStructTypes.erase(Ty);
1401 OpaqueStructTypes.insert(Ty);
1408 auto I = NonOpaqueStructTypes.find_as(Key);
1409 return I == NonOpaqueStructTypes.end() ?
nullptr : *
I;
1414 return OpaqueStructTypes.count(Ty);
1415 auto I = NonOpaqueStructTypes.find(Ty);
1416 return I == NonOpaqueStructTypes.end() ?
false : *
I == Ty;
1421 StructTypes.
run(M,
false);
1431 for (
auto *MD : StructTypes.getVisitedMetadata()) {
1432 SharedMDs[MD].reset(const_cast<MDNode *>(MD));
1439 bool LinkModuleInlineAsm,
bool IsPerformingImport) {
1440 IRLinker TheIRLinker(Composite, SharedMDs, IdentifiedStructTypes,
1441 std::move(Src), ValuesToLink, std::move(AddLazyFor),
1442 LinkModuleInlineAsm, IsPerformingImport);
1443 Error E = TheIRLinker.run();
OSType getOS() const
getOS - Get the parsed operating system type of this triple.
void push_back(const T &Elt)
LinkageTypes getLinkage() const
VisibilityTypes getVisibility() const
virtual void copyAttributesFrom(const GlobalValue *Src)
Copy all additional attributes (those not needed to create a GlobalValue) from the GlobalValue Src to...
Constant * getPrologueData() const
Get the prologue data associated with this function.
ValueT lookup(const KeyT &Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
bool isOpaque() const
Return true if this is a type with an identity that has no body specified yet.
A Module instance is used to store all the information related to an LLVM module. ...
auto remove_if(R &&Range, UnaryPredicate P) -> decltype(std::begin(Range))
Provide wrappers to std::remove_if which take ranges instead of having to pass begin/end explicitly...
ValueT lookup(const KeyT &Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
ArrayRef< Type * > ETypes
bool operator!=(const KeyTy &that) const
void addOpaque(StructType *Ty)
Implements a dense probed hash-table based set.
unsigned getNumOperands() const
Return number of MDNode operands.
Any global values not in value map are mapped to null instead of mapping to self. ...
StructType * findNonOpaque(ArrayRef< Type * > ETypes, bool IsPacked)
Type * getValueType() const
void addOperand(MDNode *M)
bool hasAppendingLinkage() const
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.
bool hasAvailableExternallyLinkage() const
void setDataLayout(StringRef Desc)
Set the data layout.
op_iterator op_begin() const
const std::string & str() const
bool hasPrologueData() const
Check whether this function has prologue data.
Context for (re-)mapping values (and metadata).
static void getArrayElements(const Constant *C, SmallVectorImpl< Constant * > &Dest)
void switchToNonOpaque(StructType *Ty)
unsigned getAddressSpace() const
Return the address space of the Pointer type.
Error takeError()
Take ownership of the stored error.
bool isDefault() const
Test if the DataLayout was constructed from an empty string.
void reserve(size_type N)
void setAlignment(unsigned Align)
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
void setOperand(unsigned I, MDNode *New)
iterator end()
Get an iterator to the end of the SetVector.
const Constant * getAliasee() const
op_iterator op_end() const
const std::string & getTargetTriple() const
Get the target triple which is a string describing the target host.
size_type size() const
Determine the number of elements in the SetVector.
StructType * getTypeByName(StringRef Name) const
Return the type with the specified name, or null if there is none by that name.
StringRef getName() const
Return a constant reference to the value's name.
Adds a requirement that another module flag be present and have a specified value after linking is pe...
Appends the two values, which are required to be metadata nodes.
void copyMetadata(const GlobalObject *Src, unsigned Offset)
Copy metadata from Src, adjusting offsets by Offset.
DiagnosticSeverity
Defines the different supported severity of a diagnostic.
struct fuzzer::@269 Flags
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
Class to represent struct types.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
bool isLiteral() const
Return true if this type is uniqued by structural equivalence, false if it is a struct definition...
bool none_of(R &&Range, UnaryPredicate P)
Provide wrappers to std::none_of which take ranges instead of having to pass begin/end explicitly...
Constant * getPersonalityFn() const
Get the personality function associated with this function.
void setModuleInlineAsm(StringRef Asm)
Set the module-scope inline assembly blocks.
void setName(const Twine &Name)
Change the name of the value.
Tagged union holding either a T or a Error.
Interface for custom diagnostic printing.
const std::string & getModuleIdentifier() const
Get the module identifier which is, essentially, the name of the module.
void eraseFromParent() override
eraseFromParent - This method unlinks 'this' from the containing module and deletes it...
LLVM_NODISCARD bool empty() const
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
auto reverse(ContainerTy &&C, typename std::enable_if< has_rbegin< ContainerTy >::value >::type *=nullptr) -> decltype(make_range(C.rbegin(), C.rend()))
llvm::Optional< Function * > remangleIntrinsicFunction(Function *F)
Class to represent function types.
Instruct the remapper to move distinct metadata instead of duplicating it when there are module-level...
bool insert(const value_type &X)
Insert a new element into the SetVector.
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
static bool isEqual(const Function &Caller, const Function &Callee)
bool operator==(const KeyTy &that) const
unsigned getAlignment() const
Class to represent array types.
iterator find(const KeyT &Val)
iterator begin()
Get an iterator to the beginning of the SetVector.
StringRef getSection() const
Get the custom section of this global if it has one.
static FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
TypeID getTypeID() const
Return the type id for the type.
ArchType getArch() const
getArch - Get the parsed architecture type of this triple.
static std::string mergeTriples(const Triple &SrcTriple, const Triple &DstTriple)
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
bool hasType(StructType *Ty)
void takeName(Value *V)
Transfer the name from V to this value.
Type * getElementType() const
Class to represent pointers.
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
SubArchType getSubArch() const
getSubArch - get the parsed subarchitecture type for this triple.
Flag
These should be considered private to the implementation of the MCInstrDesc class.
static bool triplesMatch(const Triple &T0, const Triple &T1)
static Constant * getBitCast(Constant *C, Type *Ty, bool OnlyIfReduced=false)
ExternalWeak linkage description.
Error move(std::unique_ptr< Module > Src, ArrayRef< GlobalValue * > ValuesToLink, std::function< void(GlobalValue &GV, ValueAdder Add)> AddLazyFor, bool LinkModuleInlineAsm, bool IsPerformingImport)
Move in the provide values in ValuesToLink from Src.
This is a class that can be implemented by clients to materialize Values on demand.
This is the base abstract class for diagnostic reporting in the backend.
void stealArgumentListFrom(Function &Src)
Steal arguments from another function.
Emits an error if two values disagree, otherwise the resulting value is that of the operands...
Constant * stripPointerCasts()
KeyTy(ArrayRef< Type * > E, bool P)
The instances of the Type class are immutable: once they are created, they are never changed...
Type * getContainedType(unsigned i) const
This method is used to implement the type iterator (defined at the end of the file).
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
This is an important base class in LLVM.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
This file contains the declarations for the subclasses of Constant, which represent the different fla...
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
bool hasPersonalityFn() const
Check whether this function has a personality function.
Optional< MDMapT > & getMDMap()
void splice(iterator where, iplist_impl &L2)
MDNode * getOperand(unsigned i) const
uint64_t getNumElements() const
Constant * getAggregateElement(unsigned Elt) const
For aggregates (struct/array/vector) return the constant that corresponds to the specified element if...
unsigned getNumContainedTypes() const
Return the number of types in the derived type.
Error materialize()
Make sure this GlobalValue is fully read.
void addNonOpaque(StructType *Ty)
Comdat * getOrInsertComdat(StringRef Name)
Return the Comdat in the module with the specified name.
iterator erase(const_iterator CI)
LLVMContext & getContext() const
All values hold a context through their type.
void setBody(ArrayRef< Type * > Elements, bool isPacked=false)
Specify a body for an opaque identified type.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Triple - Helper class for working with autoconf configuration names.
Base class for scope-like contexts.
const std::string & getModuleInlineAsm() const
Get any module-scope inline assembly blocks.
bool hasExternalWeakLinkage() const
StringRef getString() const
const MDOperand & getOperand(unsigned I) const
A SetVector that performs no allocations if smaller than a certain size.
static ErrorSuccess success()
Create a success value.
bool hasGlobalUnnamedAddr() const
const BasicBlockListType & getBasicBlockList() const
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
This is the shared class of boolean and integer constants.
void setSelectionKind(SelectionKind Val)
16: SIMD 'packed' format, or other vector type
void dropTriviallyDeadConstantArrays()
Destroy ConstantArrays in LLVMContext if they are not used.
void run(const Module &M, bool onlyNamed)
static StructType * get(LLVMContext &Context, ArrayRef< Type * > Elements, bool isPacked=false)
This static method is the primary way to create a literal StructType.
bool hasName() const
Return true if this is a named struct that has a non-empty name.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Type * getType() const
All values are typed, get the type of this value.
CHAIN = SC CHAIN, Imm128 - System call.
NamedMDNode * getOrInsertModuleFlagsMetadata()
Returns the NamedMDNode in the module that represents module-level flags.
void print(DiagnosticPrinter &DP) const override
Print using the given DP a user-friendly message.
void setLinkage(LinkageTypes LT)
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
Uses the specified value, regardless of the behavior or value of the other module.
hash_code hash_combine(const Ts &...args)
Combine values into a single hash_code.
bool isConstant() const
If the value is a global constant, its value is immutable throughout the runtime execution of the pro...
LinkDiagnosticInfo(DiagnosticSeverity Severity, const Twine &Msg)
Emits a warning if two values disagree.
StringRef getName() const
Return the name for this struct type if it has an identity.
hash_code hash_combine_range(InputIteratorT first, InputIteratorT last)
Compute a hash_code for a sequence of values.
This is a class that can be implemented by clients to remap types when cloning constants and instruct...
bool isOSVersionLT(unsigned Major, unsigned Minor=0, unsigned Micro=0) const
isOSVersionLT - Helper function for doing comparisons against version numbers included in the target ...
If this flag is set, the remapper ignores missing function-local entries (Argument, Instruction, BasicBlock) that are not in the value map.
ThreadLocalMode getThreadLocalMode() const
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
void setName(StringRef Name)
Change the name of this type to the specified name, or to a name with a suffix if there is a collisio...
PointerType * getType() const
Global values are always pointers.
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
void emplace_back(ArgTypes &&...Args)
Appends the two values, which are required to be metadata nodes.
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
FunctionType * getFunctionType() const
Returns the FunctionType for me.
void setPrologueData(Constant *PrologueData)
static ArrayType * get(Type *ElementType, uint64_t NumElements)
This static method is the primary way to construct an ArrayType.
void setTargetTriple(StringRef T)
Set the target triple.
bool hasPrefixData() const
Check whether this function has prefix data.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Rename collisions when linking (static functions).
Constant * getPrefixData() const
Get the prefix data associated with this function.
bool hasLocalLinkage() const
void copyAttributesFrom(const GlobalValue *Src) override
copyAttributesFrom - copy all additional attributes (those not needed to create a GlobalVariable) fro...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
std::function< void(GlobalValue &)> ValueAdder
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
static VectorType * get(Type *ElementType, unsigned NumElements)
This static method is the primary way to construct an VectorType.
static StructType * create(LLVMContext &Context, StringRef Name)
This creates an identified struct.
Lightweight error class with error context and mandatory checking.
virtual void eraseFromParent()=0
This method unlinks 'this' from the containing module and deletes it.
static void forceRenaming(GlobalValue *GV, StringRef Name)
The LLVM SymbolTable class autorenames globals that conflict in the symbol table. ...
unsigned getNumOperands() const
VendorType getVendor() const
getVendor - Get the parsed vendor type of this triple.
print Print MemDeps of function
StringRef - Represent a constant reference to a string, i.e.
const std::string & getDataLayoutStr() const
Get the data layout string for the module's target platform.
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, const Twine &N="", Module *M=nullptr)
void setPersonalityFn(Constant *Fn)
bool operator==(uint64_t V1, const APInt &V2)
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
static GCRegistry::Add< ErlangGC > A("erlang","erlang-compatible garbage collector")
TypeFinder - Walk over a module, identifying all of the types that are used by the module...
bool isDeclarationForLinker() const
static IntegerType * getInt8Ty(LLVMContext &C)
GlobalValue * getNamedValue(StringRef Name) const
Return the global value in the module with the specified name, of arbitrary type. ...
static GlobalAlias * create(Type *Ty, unsigned AddressSpace, LinkageTypes Linkage, const Twine &Name, Constant *Aliasee, Module *Parent)
If a parent module is specified, the alias is automatically inserted into the end of the specified mo...
LLVMContext & getContext() const
Get the global data context.
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
void setPrefixData(Constant *PrefixData)