48#define DEBUG_TYPE "value-mapper"
51void ValueMapTypeRemapper::anchor() {}
52void ValueMaterializer::anchor() {}
58struct DelayedBasicBlock {
60 std::unique_ptr<BasicBlock> TempBB;
63 : OldBB(Old.getBasicBlock()),
64 TempBB(
BasicBlock::Create(Old.getContext())) {}
78 struct AppendingGVTy {
82 struct AliasOrIFuncTy {
89 unsigned AppendingGVIsOldCtorDtor : 1;
90 unsigned AppendingGVNumNewMembers;
93 AppendingGVTy AppendingGV;
94 AliasOrIFuncTy AliasOrIFunc;
99struct MappingContext {
106 : VM(&VM), Materializer(Materializer) {}
110 friend class MDNodeMapper;
118 unsigned CurrentMCID = 0;
130 MCs(1, MappingContext(VM, Materializer)), IdentityMD(IdentityMD) {}
133 ~Mapper() {
assert(!hasWorkToDo() &&
"Expected to be flushed"); }
135 bool hasWorkToDo()
const {
return !Worklist.
empty(); }
140 MCs.
push_back(MappingContext(VM, Materializer));
141 return MCs.
size() - 1;
154 return cast_or_null<Constant>(mapValue(
C));
171 void scheduleRemapFunction(
Function &
F,
unsigned MCID);
186 std::optional<Metadata *> mapSimpleMetadata(
const Metadata *MD);
197 bool HasChanged =
false;
198 unsigned ID = std::numeric_limits<unsigned>::max();
199 TempMDNode Placeholder;
203 struct UniquedGraph {
211 void propagateChanges();
225 MDNodeMapper(Mapper &M) :
M(
M) {}
278 std::optional<Metadata *> tryToMapOperand(
const Metadata *
Op);
306 bool createPOT(UniquedGraph &
G,
const MDNode &FirstN);
327 void mapNodesInPOT(UniquedGraph &
G);
335 template <
class OperandMapper>
345 if (
I != getVM().
end()) {
346 assert(
I->second &&
"Unexpected null mapping");
351 if (
auto *Materializer = getMaterializer()) {
352 if (
Value *NewV = Materializer->materialize(
const_cast<Value *
>(V))) {
360 if (isa<GlobalValue>(V)) {
363 return getVM()[
V] =
const_cast<Value *
>(
V);
366 if (
const InlineAsm *IA = dyn_cast<InlineAsm>(V)) {
370 NewTy = cast<FunctionType>(TypeMapper->
remapType(NewTy));
372 if (NewTy !=
IA->getFunctionType())
374 IA->hasSideEffects(),
IA->isAlignStack(),
375 IA->getDialect(),
IA->canThrow());
378 return getVM()[
V] =
const_cast<Value *
>(
V);
381 if (
const auto *MDV = dyn_cast<MetadataAsValue>(V)) {
382 const Metadata *MD = MDV->getMetadata();
384 if (
auto *
LAM = dyn_cast<LocalAsMetadata>(MD)) {
386 if (
Value *LV = mapValue(
LAM->getValue())) {
387 if (V ==
LAM->getValue())
388 return const_cast<Value *
>(V);
399 if (
auto *AL = dyn_cast<DIArgList>(MD)) {
401 for (
auto *VAM :
AL->getArgs()) {
409 }
else if (
Value *LV = mapValue(VAM->getValue())) {
427 return getVM()[
V] =
const_cast<Value *
>(
V);
430 auto *MappedMD = mapMetadata(MD);
432 return getVM()[
V] =
const_cast<Value *
>(
V);
443 return mapBlockAddress(*BA);
445 if (
const auto *E = dyn_cast<DSOLocalEquivalent>(
C)) {
446 auto *Val = mapValue(E->getGlobalValue());
451 auto *
Func = cast<Function>(Val->stripPointerCastsAndAliases());
452 Type *NewTy = E->getType();
459 if (
const auto *
NC = dyn_cast<NoCFIValue>(
C)) {
460 auto *Val = mapValue(
NC->getGlobalValue());
465 auto mapValueOrNull = [
this](
Value *
V) {
466 auto Mapped = mapValue(V);
468 "Unexpected null mapping for constant operand without "
469 "NullMapMissingGlobalValues flag");
475 unsigned OpNo = 0, NumOperands =
C->getNumOperands();
476 Value *Mapped =
nullptr;
477 for (; OpNo != NumOperands; ++OpNo) {
479 Mapped = mapValueOrNull(
Op);
487 Type *NewTy =
C->getType();
493 if (OpNo == NumOperands && NewTy ==
C->getType())
494 return getVM()[
V] =
C;
500 for (
unsigned j = 0;
j != OpNo; ++
j)
501 Ops.
push_back(cast<Constant>(
C->getOperand(j)));
504 if (OpNo != NumOperands) {
508 for (++OpNo; OpNo != NumOperands; ++OpNo) {
509 Mapped = mapValueOrNull(
C->getOperand(OpNo));
515 Type *NewSrcTy =
nullptr;
517 if (
auto *GEPO = dyn_cast<GEPOperator>(
C))
518 NewSrcTy = TypeMapper->
remapType(GEPO->getSourceElementType());
521 return getVM()[
V] =
CE->getWithOperands(Ops, NewTy,
false, NewSrcTy);
522 if (isa<ConstantArray>(
C))
524 if (isa<ConstantStruct>(
C))
526 if (isa<ConstantVector>(
C))
529 if (isa<PoisonValue>(
C))
531 if (isa<UndefValue>(
C))
533 if (isa<ConstantAggregateZero>(
C))
535 if (isa<ConstantTargetNone>(
C))
537 assert(isa<ConstantPointerNull>(
C));
541void Mapper::remapDbgRecord(
DbgRecord &DR) {
548 DLR->setLabel(cast<DILabel>(mapMetadata(DLR->getLabel())));
554 auto *MappedVar = mapMetadata(
V.getVariable());
555 V.setVariable(cast<DILocalVariable>(MappedVar));
559 if (
V.isDbgAssign()) {
560 auto *NewAddr = mapValue(
V.getAddress());
561 if (!IgnoreMissingLocals && !NewAddr)
564 V.setAddress(NewAddr);
565 V.setAssignId(cast<DIAssignID>(mapMetadata(
V.getAssignID())));
571 for (
Value *Val : Vals)
584 for (
unsigned int I = 0;
I < Vals.size(); ++
I)
586 V.replaceVariableLocationOp(
I, NewVals[
I]);
598 DelayedBBs.
push_back(DelayedBasicBlock(BA));
599 BB = DelayedBBs.
back().TempBB.get();
608 getVM().MD()[
Key].reset(Val);
613 return mapToMetadata(MD,
const_cast<Metadata *
>(MD));
616std::optional<Metadata *> MDNodeMapper::tryToMapOperand(
const Metadata *
Op) {
620 if (std::optional<Metadata *> MappedOp =
M.mapSimpleMetadata(
Op)) {
622 if (
auto *CMD = dyn_cast<ConstantAsMetadata>(
Op))
623 assert((!*MappedOp ||
M.getVM().count(CMD->getValue()) ||
624 M.getVM().getMappedMD(
Op)) &&
625 "Expected Value to be memoized");
627 assert((isa<MDString>(
Op) ||
M.getVM().getMappedMD(
Op)) &&
628 "Expected result to be memoized");
635 return mapDistinctNode(
N);
640 assert(
N.isDistinct() &&
"Expected a distinct node");
641 assert(!
M.getVM().getMappedMD(&
N) &&
"Expected an unmapped node");
645 NewM =
M.mapToSelf(&
N);
649 <<
"To " << *NewM <<
"\n\n");
650 M.mapToMetadata(&
N, NewM);
652 DistinctWorklist.push_back(cast<MDNode>(NewM));
654 return DistinctWorklist.back();
664std::optional<Metadata *> MDNodeMapper::getMappedOp(
const Metadata *
Op)
const {
668 if (std::optional<Metadata *> MappedOp =
M.getVM().getMappedMD(
Op))
671 if (isa<MDString>(
Op))
674 if (
auto *CMD = dyn_cast<ConstantAsMetadata>(
Op))
681 auto Where =
Info.find(&
Op);
682 assert(Where !=
Info.end() &&
"Expected a valid reference");
684 auto &OpD = Where->second;
689 if (!OpD.Placeholder)
690 OpD.Placeholder =
Op.clone();
692 return *OpD.Placeholder;
695template <
class OperandMapper>
696void MDNodeMapper::remapOperands(
MDNode &
N, OperandMapper mapOperand) {
697 assert(!
N.isUniqued() &&
"Expected distinct or temporary nodes");
698 for (
unsigned I = 0, E =
N.getNumOperands();
I != E; ++
I) {
702 LLVM_DEBUG(
dbgs() <<
"Replacing Op " << Old <<
" with " << New <<
" in "
706 N.replaceOperandWith(
I, New);
713struct POTWorklistEntry {
719 bool HasChanged =
false;
721 POTWorklistEntry(
MDNode &
N) :
N(&
N),
Op(
N.op_begin()) {}
726bool MDNodeMapper::createPOT(UniquedGraph &
G,
const MDNode &FirstN) {
727 assert(
G.Info.empty() &&
"Expected a fresh traversal");
731 bool AnyChanges =
false;
734 (void)
G.Info[&FirstN];
737 auto &WE = Worklist.
back();
738 if (
MDNode *
N = visitOperands(
G, WE.Op, WE.N->op_end(), WE.HasChanged)) {
745 assert(WE.N->isUniqued() &&
"Expected only uniqued nodes");
746 assert(WE.Op == WE.N->op_end() &&
"Expected to visit all operands");
747 auto &
D =
G.Info[WE.N];
748 AnyChanges |=
D.HasChanged = WE.HasChanged;
750 G.POT.push_back(WE.N);
762 if (std::optional<Metadata *> MappedOp = tryToMapOperand(
Op)) {
764 HasChanged |=
Op != *MappedOp;
771 "Only uniqued operands cannot be mapped immediately");
772 if (
G.Info.insert(std::make_pair(&OpN,
Data())).second)
778void MDNodeMapper::UniquedGraph::propagateChanges() {
788 auto Where = Info.find(Op);
789 return Where != Info.end() && Where->second.HasChanged;
793 AnyChanges =
D.HasChanged =
true;
795 }
while (AnyChanges);
798void MDNodeMapper::mapNodesInPOT(UniquedGraph &
G) {
801 for (
auto *
N :
G.POT) {
810 bool HadPlaceholder(
D.Placeholder);
813 TempMDNode ClonedN =
D.Placeholder ? std::move(
D.Placeholder) :
N->clone();
815 if (std::optional<Metadata *> MappedOp =
getMappedOp(Old))
818 assert(
G.Info[Old].ID >
D.ID &&
"Expected a forward reference");
819 return &
G.getFwdReference(*cast<MDNode>(Old));
823 if (
N && NewN &&
N != NewN) {
825 <<
"To " << *NewN <<
"\n\n");
828 M.mapToMetadata(
N, NewN);
837 for (
auto *
N : CyclicNodes)
838 if (!
N->isResolved())
843 assert(DistinctWorklist.empty() &&
"MDNodeMapper::map is not recursive");
845 "MDNodeMapper::map assumes module-level changes");
848 assert(
N.isResolved() &&
"Unexpected unresolved node");
851 N.isUniqued() ? mapTopLevelUniquedNode(
N) : mapDistinctNode(
N);
852 while (!DistinctWorklist.empty())
854 if (std::optional<Metadata *> MappedOp = tryToMapOperand(Old))
856 return mapTopLevelUniquedNode(*cast<MDNode>(Old));
861Metadata *MDNodeMapper::mapTopLevelUniquedNode(
const MDNode &FirstN) {
866 if (!createPOT(
G, FirstN)) {
870 return &
const_cast<MDNode &
>(FirstN);
874 G.propagateChanges();
883std::optional<Metadata *> Mapper::mapSimpleMetadata(
const Metadata *MD) {
885 if (std::optional<Metadata *> NewMD = getVM().getMappedMD(MD))
888 if (isa<MDString>(MD))
896 if (
auto *CMD = dyn_cast<ConstantAsMetadata>(MD)) {
908 if (IdentityMD && IdentityMD->
contains(MD))
911 assert(isa<MDNode>(MD) &&
"Expected a metadata node");
917 assert(MD &&
"Expected valid metadata");
918 assert(!isa<LocalAsMetadata>(MD) &&
"Unexpected local metadata");
920 if (std::optional<Metadata *> NewMD = mapSimpleMetadata(MD))
923 return MDNodeMapper(*this).map(*cast<MDNode>(MD));
926void Mapper::flush() {
928 while (!Worklist.
empty()) {
930 CurrentMCID = E.MCID;
932 case WorklistEntry::MapGlobalInit:
933 E.Data.GVInit.GV->setInitializer(mapConstant(E.Data.GVInit.Init));
934 remapGlobalObjectMetadata(*E.Data.GVInit.GV);
936 case WorklistEntry::MapAppendingVar: {
937 unsigned PrefixSize = AppendingInits.
size() - E.AppendingGVNumNewMembers;
943 AppendingInits.
resize(PrefixSize);
944 mapAppendingVariable(*E.Data.AppendingGV.GV,
945 E.Data.AppendingGV.InitPrefix,
946 E.AppendingGVIsOldCtorDtor,
ArrayRef(NewInits));
949 case WorklistEntry::MapAliasOrIFunc: {
952 if (
auto *GA = dyn_cast<GlobalAlias>(GV))
954 else if (
auto *GI = dyn_cast<GlobalIFunc>(GV))
960 case WorklistEntry::RemapFunction:
961 remapFunction(*E.Data.RemapF);
969 while (!DelayedBBs.
empty()) {
971 BasicBlock *BB = cast_or_null<BasicBlock>(mapValue(DBB.OldBB));
972 DBB.TempBB->replaceAllUsesWith(BB ? BB : DBB.OldBB);
978 for (
Use &
Op :
I->operands()) {
985 "Referenced value not in value map!");
989 if (
PHINode *PN = dyn_cast<PHINode>(
I)) {
990 for (
unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) {
991 Value *
V = mapValue(PN->getIncomingBlock(i));
994 PN->setIncomingBlock(i, cast<BasicBlock>(V));
997 "Referenced block not in value map!");
1003 I->getAllMetadata(MDs);
1004 for (
const auto &
MI : MDs) {
1006 MDNode *
New = cast_or_null<MDNode>(mapMetadata(Old));
1008 I->setMetadata(
MI.first, New);
1015 if (
auto *CB = dyn_cast<CallBase>(
I)) {
1018 Tys.reserve(FTy->getNumParams());
1019 for (
Type *Ty : FTy->params())
1022 TypeMapper->
remapType(
I->getType()), Tys, FTy->isVarArg()));
1026 for (
unsigned i = 0; i <
Attrs.getNumAttrSets(); ++i) {
1027 for (
int AttrIdx = Attribute::FirstTypeAttr;
1028 AttrIdx <= Attribute::LastTypeAttr; AttrIdx++) {
1031 Attrs.getAttributeAtIndex(i, TypedAttr).getValueAsType()) {
1032 Attrs =
Attrs.replaceAttributeTypeAtIndex(
C, i, TypedAttr,
1038 CB->setAttributes(Attrs);
1041 if (
auto *AI = dyn_cast<AllocaInst>(
I))
1042 AI->setAllocatedType(TypeMapper->
remapType(AI->getAllocatedType()));
1043 if (
auto *
GEP = dyn_cast<GetElementPtrInst>(
I)) {
1044 GEP->setSourceElementType(
1046 GEP->setResultElementType(
1049 I->mutateType(TypeMapper->
remapType(
I->getType()));
1052void Mapper::remapGlobalObjectMetadata(
GlobalObject &GO) {
1056 for (
const auto &
I : MDs)
1057 GO.
addMetadata(
I.first, *cast<MDNode>(mapMetadata(
I.second)));
1060void Mapper::remapFunction(
Function &
F) {
1062 for (
Use &
Op :
F.operands())
1067 remapGlobalObjectMetadata(
F);
1077 remapInstruction(&
I);
1089 unsigned NumElements =
1090 cast<ArrayType>(InitPrefix->
getType())->getNumElements();
1091 for (
unsigned I = 0;
I != NumElements; ++
I)
1097 if (IsOldCtorDtor) {
1101 auto &
ST = *cast<StructType>(NewMembers.
front()->getType());
1102 Type *
Tys[3] = {
ST.getElementType(0),
ST.getElementType(1), VoidPtrTy};
1106 for (
auto *V : NewMembers) {
1108 if (IsOldCtorDtor) {
1109 auto *S = cast<ConstantStruct>(V);
1110 auto *E1 = cast<Constant>(mapValue(S->getOperand(0)));
1111 auto *E2 = cast<Constant>(mapValue(S->getOperand(1)));
1115 NewV = cast_or_null<Constant>(mapValue(V));
1126 assert(AlreadyScheduled.
insert(&GV).second &&
"Should not reschedule");
1127 assert(MCID < MCs.
size() &&
"Invalid mapping context");
1130 WE.Kind = WorklistEntry::MapGlobalInit;
1132 WE.Data.GVInit.GV = &GV;
1133 WE.Data.GVInit.Init = &
Init;
1142 assert(AlreadyScheduled.
insert(&GV).second &&
"Should not reschedule");
1143 assert(MCID < MCs.
size() &&
"Invalid mapping context");
1146 WE.Kind = WorklistEntry::MapAppendingVar;
1148 WE.Data.AppendingGV.GV = &GV;
1149 WE.Data.AppendingGV.InitPrefix = InitPrefix;
1150 WE.AppendingGVIsOldCtorDtor = IsOldCtorDtor;
1151 WE.AppendingGVNumNewMembers = NewMembers.
size();
1158 assert(AlreadyScheduled.
insert(&GV).second &&
"Should not reschedule");
1159 assert((isa<GlobalAlias>(GV) || isa<GlobalIFunc>(GV)) &&
1160 "Should be alias or ifunc");
1161 assert(MCID < MCs.
size() &&
"Invalid mapping context");
1164 WE.Kind = WorklistEntry::MapAliasOrIFunc;
1166 WE.Data.AliasOrIFunc.GV = &GV;
1167 WE.Data.AliasOrIFunc.Target = &
Target;
1171void Mapper::scheduleRemapFunction(
Function &
F,
unsigned MCID) {
1172 assert(AlreadyScheduled.
insert(&
F).second &&
"Should not reschedule");
1173 assert(MCID < MCs.
size() &&
"Invalid mapping context");
1176 WE.Kind = WorklistEntry::RemapFunction;
1178 WE.Data.RemapF = &
F;
1183 assert(!hasWorkToDo() &&
"Expected to have flushed the worklist");
1184 this->Flags = this->Flags |
Flags;
1188 return reinterpret_cast<Mapper *
>(pImpl);
1193class FlushingMapper {
1197 explicit FlushingMapper(
void *pImpl) :
M(*
getAsMapper(pImpl)) {
1198 assert(!
M.hasWorkToDo() &&
"Expected to be flushed");
1201 ~FlushingMapper() {
M.flush(); }
1203 Mapper *operator->()
const {
return &
M; }
1212 : pImpl(new Mapper(VM, Flags, TypeMapper, Materializer, IdentityMD)) {}
1219 return getAsMapper(pImpl)->registerAlternateMappingContext(VM, Materializer);
1223 FlushingMapper(pImpl)->addFlags(Flags);
1227 return FlushingMapper(pImpl)->mapValue(&V);
1231 return cast_or_null<Constant>(
mapValue(
C));
1235 return FlushingMapper(pImpl)->mapMetadata(&MD);
1243 FlushingMapper(pImpl)->remapInstruction(&
I);
1247 FlushingMapper(pImpl)->remapDbgRecord(DR);
1258 FlushingMapper(pImpl)->remapFunction(
F);
1262 FlushingMapper(pImpl)->remapGlobalObjectMetadata(GO);
1277 GV, InitPrefix, IsOldCtorDtor, NewMembers, MCID);
1282 getAsMapper(pImpl)->scheduleMapAliasOrIFunc(GA, Aliasee, MCID);
static unsigned getMappedOp(unsigned PseudoOp)
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Analysis containing CSE Info
This file contains the declarations for the subclasses of Constant, which represent the different fla...
This file defines the DenseMap class.
This file defines the DenseSet and SmallDenseSet classes.
This file contains the declaration of the GlobalIFunc class, which represents a single indirect funct...
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
while(!ToSimplify.empty())
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallVector class.
static void remapOperands(VPBlockBase *Entry, VPBlockBase *NewEntry, DenseMap< VPValue *, VPValue * > &Old2NewVPValues)
static Mapper * getAsMapper(void *pImpl)
static ConstantAsMetadata * wrapConstantAsMetadata(const ConstantAsMetadata &CMD, Value *MappedV)
This class represents an incoming formal argument to a Function.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
const T & front() const
front - Get the first element.
size_t size() const
size - Get the array size.
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results,...
LLVM Basic Block Representation.
The address of a basic block.
Function * getFunction() const
BasicBlock * getBasicBlock() const
static BlockAddress * get(Function *F, BasicBlock *BB)
Return a BlockAddress for the specified function and basic block.
static ConstantAggregateZero * get(Type *Ty)
static Constant * get(ArrayType *T, ArrayRef< Constant * > V)
A constant value that is initialized with an expression using other constant values.
static Constant * getBitCast(Constant *C, Type *Ty, bool OnlyIfReduced=false)
static ConstantPointerNull * get(PointerType *T)
Static factory methods - Return objects of the specified value.
static Constant * get(StructType *T, ArrayRef< Constant * > V)
static Constant * get(ArrayRef< Constant * > V)
This is an important base class in LLVM.
static Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
Constant * getAggregateElement(unsigned Elt) const
For aggregates (struct/array/vector) return the constant that corresponds to the specified element if...
static DIArgList * get(LLVMContext &Context, ArrayRef< ValueAsMetadata * > Args)
static DSOLocalEquivalent * get(GlobalValue *GV)
Return a DSOLocalEquivalent for the specified global value.
This class represents an Operation in the Expression.
Records a position in IR for a source label (DILabel).
Base class for non-instruction debug metadata records that have positions within IR.
DebugLoc getDebugLoc() const
void setDebugLoc(DebugLoc Loc)
Record of a variable value-assignment, aka a non instruction representation of the dbg....
Implements a dense probed hash-table based set.
static FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
void getAllMetadata(SmallVectorImpl< std::pair< unsigned, MDNode * > > &MDs) const
Appends all metadata attached to this value to MDs, sorting by KindID.
void addMetadata(unsigned KindID, MDNode &MD)
Add a metadata attachment.
void clearMetadata()
Erase all metadata attached to this Value.
Type * getValueType() const
void setInitializer(Constant *InitVal)
setInitializer - Sets the initializer for this global variable, removing any existing initializer if ...
static InlineAsm * get(FunctionType *Ty, StringRef AsmString, StringRef Constraints, bool hasSideEffects, bool isAlignStack=false, AsmDialect asmDialect=AD_ATT, bool canThrow=false)
InlineAsm::get - Return the specified uniqued inline asm string.
This is an important class for using LLVM in a threaded context.
static std::enable_if_t< std::is_base_of< MDNode, T >::value, T * > replaceWithDistinct(std::unique_ptr< T, TempMDNodeDeleter > N)
Replace a temporary node with a distinct one.
static std::enable_if_t< std::is_base_of< MDNode, T >::value, T * > replaceWithUniqued(std::unique_ptr< T, TempMDNodeDeleter > N)
Replace a temporary node with a uniqued one.
Tracking metadata reference owned by Metadata.
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
A Module instance is used to store all the information related to an LLVM module.
static NoCFIValue * get(GlobalValue *GV)
Return a NoCFIValue for the specified function.
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the default address space (address sp...
static PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
Interface for looking up the initializer for a variable name, used by Init::resolveReferences.
bool contains(ConstPtrType Ptr) const
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
void reserve(size_type N)
void append(ItTy in_start, ItTy in_end)
Add the specified range to the end of the SmallVector.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
static StructType * get(LLVMContext &Context, ArrayRef< Type * > Elements, bool isPacked=false)
This static method is the primary way to create a literal StructType.
Target - Wrapper for Target specific information.
Tracking metadata reference.
The instances of the Type class are immutable: once they are created, they are never changed.
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
A Use represents the edge between a Value definition and its users.
This is a class that can be implemented by clients to remap types when cloning constants and instruct...
virtual Type * remapType(Type *SrcTy)=0
The client should implement this method if they want to remap types while mapping values.
void remapDbgRecord(Module *M, DbgRecord &V)
void remapDbgRecordRange(Module *M, iterator_range< DbgRecordIterator > Range)
MDNode * mapMDNode(const MDNode &N)
Metadata * mapMetadata(const Metadata &MD)
void remapInstruction(Instruction &I)
void scheduleMapGlobalInitializer(GlobalVariable &GV, Constant &Init, unsigned MappingContextID=0)
void scheduleRemapFunction(Function &F, unsigned MappingContextID=0)
void scheduleMapGlobalIFunc(GlobalIFunc &GI, Constant &Resolver, unsigned MappingContextID=0)
unsigned registerAlternateMappingContext(ValueToValueMapTy &VM, ValueMaterializer *Materializer=nullptr)
Register an alternate mapping context.
void remapFunction(Function &F)
Constant * mapConstant(const Constant &C)
ValueMapper(ValueToValueMapTy &VM, RemapFlags Flags=RF_None, ValueMapTypeRemapper *TypeMapper=nullptr, ValueMaterializer *Materializer=nullptr, const MetadataSetTy *IdentityMD=nullptr)
void scheduleMapAppendingVariable(GlobalVariable &GV, Constant *InitPrefix, bool IsOldCtorDtor, ArrayRef< Constant * > NewMembers, unsigned MappingContextID=0)
void scheduleMapGlobalAlias(GlobalAlias &GA, Constant &Aliasee, unsigned MappingContextID=0)
void remapGlobalObjectMetadata(GlobalObject &GO)
Value * mapValue(const Value &V)
void addFlags(RemapFlags Flags)
Add to the current RemapFlags.
This is a class that can be implemented by clients to materialize Values on demand.
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
LLVMContext & getContext() const
All values hold a context through their type.
std::pair< iterator, bool > insert(const ValueT &V)
A range adaptor for a pair of iterators.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char Attrs[]
Key for Kernel::Metadata::mAttrs.
@ C
The default llvm calling convention, compatible with C.
ID ArrayRef< Type * > Tys
@ CE
Windows NT (Windows on ARM)
NodeAddr< FuncNode * > Func
const_iterator end(StringRef path LLVM_LIFETIME_BOUND)
Get end iterator over path.
This is an optimization pass for GlobalISel generic memory operations.
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
void RemapFunction(Function &F, ValueToValueMapTy &VM, RemapFlags Flags=RF_None, ValueMapTypeRemapper *TypeMapper=nullptr, ValueMaterializer *Materializer=nullptr, const MetadataSetTy *IdentityMD=nullptr)
Remap the operands, metadata, arguments, and instructions of a function.
RemapFlags
These are flags that the value mapping APIs allow.
@ RF_IgnoreMissingLocals
If this flag is set, the remapper ignores missing function-local entries (Argument,...
@ RF_NullMapMissingGlobalValues
Any global values not in value map are mapped to null instead of mapping to self.
@ RF_NoModuleLevelChanges
If this flag is set, the remapper knows that only local values within a function (such as an instruct...
@ RF_ReuseAndMutateDistinctMDs
Instruct the remapper to reuse and mutate distinct metadata (remapping them in place) instead of clon...
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool none_of(R &&Range, UnaryPredicate P)
Provide wrappers to std::none_of which take ranges instead of having to pass begin/end explicitly.
DWARFExpression::Operation Op
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.