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;
128 MCs(1, MappingContext(VM, Materializer)) {}
131 ~Mapper() {
assert(!hasWorkToDo() &&
"Expected to be flushed"); }
133 bool hasWorkToDo()
const {
return !Worklist.
empty(); }
138 MCs.
push_back(MappingContext(VM, Materializer));
139 return MCs.
size() - 1;
152 return cast_or_null<Constant>(mapValue(
C));
169 void scheduleRemapFunction(
Function &
F,
unsigned MCID);
184 std::optional<Metadata *> mapSimpleMetadata(
const Metadata *MD);
195 bool HasChanged =
false;
196 unsigned ID = std::numeric_limits<unsigned>::max();
197 TempMDNode Placeholder;
201 struct UniquedGraph {
209 void propagateChanges();
223 MDNodeMapper(Mapper &M) :
M(
M) {}
276 std::optional<Metadata *> tryToMapOperand(
const Metadata *
Op);
304 bool createPOT(UniquedGraph &
G,
const MDNode &FirstN);
325 void mapNodesInPOT(UniquedGraph &
G);
333 template <
class OperandMapper>
343 if (
I != getVM().
end()) {
344 assert(
I->second &&
"Unexpected null mapping");
349 if (
auto *Materializer = getMaterializer()) {
350 if (
Value *NewV = Materializer->materialize(
const_cast<Value *
>(V))) {
358 if (isa<GlobalValue>(V)) {
361 return getVM()[
V] =
const_cast<Value *
>(
V);
364 if (
const InlineAsm *IA = dyn_cast<InlineAsm>(V)) {
368 NewTy = cast<FunctionType>(TypeMapper->
remapType(NewTy));
370 if (NewTy !=
IA->getFunctionType())
372 IA->hasSideEffects(),
IA->isAlignStack(),
373 IA->getDialect(),
IA->canThrow());
376 return getVM()[
V] =
const_cast<Value *
>(
V);
379 if (
const auto *MDV = dyn_cast<MetadataAsValue>(V)) {
380 const Metadata *MD = MDV->getMetadata();
382 if (
auto *
LAM = dyn_cast<LocalAsMetadata>(MD)) {
384 if (
Value *LV = mapValue(
LAM->getValue())) {
385 if (V ==
LAM->getValue())
386 return const_cast<Value *
>(V);
398 if (
auto *AL = dyn_cast<DIArgList>(MD)) {
400 for (
auto *VAM :
AL->getArgs()) {
408 }
else if (
Value *LV = mapValue(VAM->getValue())) {
426 return getVM()[
V] =
const_cast<Value *
>(
V);
429 auto *MappedMD = mapMetadata(MD);
431 return getVM()[
V] =
const_cast<Value *
>(
V);
442 return mapBlockAddress(*BA);
444 if (
const auto *E = dyn_cast<DSOLocalEquivalent>(
C)) {
445 auto *Val = mapValue(E->getGlobalValue());
450 auto *
Func = cast<Function>(Val->stripPointerCastsAndAliases());
451 Type *NewTy = E->getType();
458 if (
const auto *
NC = dyn_cast<NoCFIValue>(
C)) {
459 auto *Val = mapValue(
NC->getGlobalValue());
464 auto mapValueOrNull = [
this](
Value *
V) {
465 auto Mapped = mapValue(V);
467 "Unexpected null mapping for constant operand without "
468 "NullMapMissingGlobalValues flag");
474 unsigned OpNo = 0, NumOperands =
C->getNumOperands();
475 Value *Mapped =
nullptr;
476 for (; OpNo != NumOperands; ++OpNo) {
478 Mapped = mapValueOrNull(
Op);
486 Type *NewTy =
C->getType();
492 if (OpNo == NumOperands && NewTy ==
C->getType())
493 return getVM()[
V] =
C;
499 for (
unsigned j = 0;
j != OpNo; ++
j)
500 Ops.
push_back(cast<Constant>(
C->getOperand(j)));
503 if (OpNo != NumOperands) {
507 for (++OpNo; OpNo != NumOperands; ++OpNo) {
508 Mapped = mapValueOrNull(
C->getOperand(OpNo));
514 Type *NewSrcTy =
nullptr;
516 if (
auto *GEPO = dyn_cast<GEPOperator>(
C))
517 NewSrcTy = TypeMapper->
remapType(GEPO->getSourceElementType());
520 return getVM()[
V] =
CE->getWithOperands(Ops, NewTy,
false, NewSrcTy);
521 if (isa<ConstantArray>(
C))
523 if (isa<ConstantStruct>(
C))
525 if (isa<ConstantVector>(
C))
528 if (isa<PoisonValue>(
C))
530 if (isa<UndefValue>(
C))
532 if (isa<ConstantAggregateZero>(
C))
534 if (isa<ConstantTargetNone>(
C))
536 assert(isa<ConstantPointerNull>(
C));
540void Mapper::remapDbgRecord(
DbgRecord &DR) {
547 DLR->setLabel(cast<DILabel>(mapMetadata(DLR->getLabel())));
553 auto *MappedVar = mapMetadata(
V.getVariable());
554 V.setVariable(cast<DILocalVariable>(MappedVar));
558 if (
V.isDbgAssign()) {
559 auto *NewAddr = mapValue(
V.getAddress());
560 if (!IgnoreMissingLocals && !NewAddr)
563 V.setAddress(NewAddr);
564 V.setAssignId(cast<DIAssignID>(mapMetadata(
V.getAssignID())));
570 for (
Value *Val : Vals)
583 for (
unsigned int I = 0;
I < Vals.size(); ++
I)
585 V.replaceVariableLocationOp(
I, NewVals[
I]);
597 DelayedBBs.
push_back(DelayedBasicBlock(BA));
598 BB = DelayedBBs.
back().TempBB.get();
607 getVM().MD()[
Key].reset(Val);
612 return mapToMetadata(MD,
const_cast<Metadata *
>(MD));
615std::optional<Metadata *> MDNodeMapper::tryToMapOperand(
const Metadata *
Op) {
619 if (std::optional<Metadata *> MappedOp =
M.mapSimpleMetadata(
Op)) {
621 if (
auto *CMD = dyn_cast<ConstantAsMetadata>(
Op))
622 assert((!*MappedOp ||
M.getVM().count(CMD->getValue()) ||
623 M.getVM().getMappedMD(
Op)) &&
624 "Expected Value to be memoized");
626 assert((isa<MDString>(
Op) ||
M.getVM().getMappedMD(
Op)) &&
627 "Expected result to be memoized");
634 return mapDistinctNode(
N);
639 assert(
N.isDistinct() &&
"Expected a distinct node");
640 assert(!
M.getVM().getMappedMD(&
N) &&
"Expected an unmapped node");
644 NewM =
M.mapToSelf(&
N);
648 <<
"To " << *NewM <<
"\n\n");
649 M.mapToMetadata(&
N, NewM);
651 DistinctWorklist.push_back(cast<MDNode>(NewM));
653 return DistinctWorklist.back();
663std::optional<Metadata *> MDNodeMapper::getMappedOp(
const Metadata *
Op)
const {
667 if (std::optional<Metadata *> MappedOp =
M.getVM().getMappedMD(
Op))
670 if (isa<MDString>(
Op))
673 if (
auto *CMD = dyn_cast<ConstantAsMetadata>(
Op))
680 auto Where =
Info.find(&
Op);
681 assert(Where !=
Info.end() &&
"Expected a valid reference");
683 auto &OpD = Where->second;
688 if (!OpD.Placeholder)
689 OpD.Placeholder =
Op.clone();
691 return *OpD.Placeholder;
694template <
class OperandMapper>
695void MDNodeMapper::remapOperands(
MDNode &
N, OperandMapper mapOperand) {
696 assert(!
N.isUniqued() &&
"Expected distinct or temporary nodes");
697 for (
unsigned I = 0, E =
N.getNumOperands();
I != E; ++
I) {
701 LLVM_DEBUG(
dbgs() <<
"Replacing Op " << Old <<
" with " << New <<
" in "
705 N.replaceOperandWith(
I, New);
712struct POTWorklistEntry {
718 bool HasChanged =
false;
720 POTWorklistEntry(
MDNode &
N) :
N(&
N),
Op(
N.op_begin()) {}
725bool MDNodeMapper::createPOT(UniquedGraph &
G,
const MDNode &FirstN) {
726 assert(
G.Info.empty() &&
"Expected a fresh traversal");
730 bool AnyChanges =
false;
733 (void)
G.Info[&FirstN];
736 auto &WE = Worklist.
back();
737 if (
MDNode *
N = visitOperands(
G, WE.Op, WE.N->op_end(), WE.HasChanged)) {
744 assert(WE.N->isUniqued() &&
"Expected only uniqued nodes");
745 assert(WE.Op == WE.N->op_end() &&
"Expected to visit all operands");
746 auto &
D =
G.Info[WE.N];
747 AnyChanges |=
D.HasChanged = WE.HasChanged;
749 G.POT.push_back(WE.N);
761 if (std::optional<Metadata *> MappedOp = tryToMapOperand(
Op)) {
763 HasChanged |=
Op != *MappedOp;
770 "Only uniqued operands cannot be mapped immediately");
771 if (
G.Info.insert(std::make_pair(&OpN,
Data())).second)
777void MDNodeMapper::UniquedGraph::propagateChanges() {
787 auto Where = Info.find(Op);
788 return Where != Info.end() && Where->second.HasChanged;
792 AnyChanges =
D.HasChanged =
true;
794 }
while (AnyChanges);
797void MDNodeMapper::mapNodesInPOT(UniquedGraph &
G) {
800 for (
auto *
N :
G.POT) {
809 bool HadPlaceholder(
D.Placeholder);
812 TempMDNode ClonedN =
D.Placeholder ? std::move(
D.Placeholder) :
N->clone();
814 if (std::optional<Metadata *> MappedOp =
getMappedOp(Old))
817 assert(
G.Info[Old].ID >
D.ID &&
"Expected a forward reference");
818 return &
G.getFwdReference(*cast<MDNode>(Old));
822 if (
N && NewN &&
N != NewN) {
824 <<
"To " << *NewN <<
"\n\n");
827 M.mapToMetadata(
N, NewN);
836 for (
auto *
N : CyclicNodes)
837 if (!
N->isResolved())
842 assert(DistinctWorklist.empty() &&
"MDNodeMapper::map is not recursive");
844 "MDNodeMapper::map assumes module-level changes");
847 assert(
N.isResolved() &&
"Unexpected unresolved node");
850 N.isUniqued() ? mapTopLevelUniquedNode(
N) : mapDistinctNode(
N);
851 while (!DistinctWorklist.empty())
853 if (std::optional<Metadata *> MappedOp = tryToMapOperand(Old))
855 return mapTopLevelUniquedNode(*cast<MDNode>(Old));
860Metadata *MDNodeMapper::mapTopLevelUniquedNode(
const MDNode &FirstN) {
865 if (!createPOT(
G, FirstN)) {
869 return &
const_cast<MDNode &
>(FirstN);
873 G.propagateChanges();
882std::optional<Metadata *> Mapper::mapSimpleMetadata(
const Metadata *MD) {
884 if (std::optional<Metadata *> NewMD = getVM().getMappedMD(MD))
887 if (isa<MDString>(MD))
895 if (
auto *CMD = dyn_cast<ConstantAsMetadata>(MD)) {
903 assert(isa<MDNode>(MD) &&
"Expected a metadata node");
909 assert(MD &&
"Expected valid metadata");
910 assert(!isa<LocalAsMetadata>(MD) &&
"Unexpected local metadata");
912 if (std::optional<Metadata *> NewMD = mapSimpleMetadata(MD))
915 return MDNodeMapper(*this).map(*cast<MDNode>(MD));
918void Mapper::flush() {
920 while (!Worklist.
empty()) {
922 CurrentMCID = E.MCID;
924 case WorklistEntry::MapGlobalInit:
925 E.Data.GVInit.GV->setInitializer(mapConstant(E.Data.GVInit.Init));
926 remapGlobalObjectMetadata(*E.Data.GVInit.GV);
928 case WorklistEntry::MapAppendingVar: {
929 unsigned PrefixSize = AppendingInits.
size() - E.AppendingGVNumNewMembers;
935 AppendingInits.
resize(PrefixSize);
936 mapAppendingVariable(*E.Data.AppendingGV.GV,
937 E.Data.AppendingGV.InitPrefix,
938 E.AppendingGVIsOldCtorDtor,
ArrayRef(NewInits));
941 case WorklistEntry::MapAliasOrIFunc: {
944 if (
auto *GA = dyn_cast<GlobalAlias>(GV))
946 else if (
auto *GI = dyn_cast<GlobalIFunc>(GV))
952 case WorklistEntry::RemapFunction:
953 remapFunction(*E.Data.RemapF);
961 while (!DelayedBBs.
empty()) {
963 BasicBlock *BB = cast_or_null<BasicBlock>(mapValue(DBB.OldBB));
964 DBB.TempBB->replaceAllUsesWith(BB ? BB : DBB.OldBB);
970 for (
Use &
Op :
I->operands()) {
977 "Referenced value not in value map!");
981 if (
PHINode *PN = dyn_cast<PHINode>(
I)) {
982 for (
unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) {
983 Value *
V = mapValue(PN->getIncomingBlock(i));
986 PN->setIncomingBlock(i, cast<BasicBlock>(V));
989 "Referenced block not in value map!");
995 I->getAllMetadata(MDs);
996 for (
const auto &
MI : MDs) {
998 MDNode *
New = cast_or_null<MDNode>(mapMetadata(Old));
1000 I->setMetadata(
MI.first, New);
1007 if (
auto *CB = dyn_cast<CallBase>(
I)) {
1010 Tys.
reserve(FTy->getNumParams());
1011 for (
Type *Ty : FTy->params())
1014 TypeMapper->
remapType(
I->getType()), Tys, FTy->isVarArg()));
1018 for (
unsigned i = 0; i <
Attrs.getNumAttrSets(); ++i) {
1019 for (
int AttrIdx = Attribute::FirstTypeAttr;
1020 AttrIdx <= Attribute::LastTypeAttr; AttrIdx++) {
1023 Attrs.getAttributeAtIndex(i, TypedAttr).getValueAsType()) {
1024 Attrs =
Attrs.replaceAttributeTypeAtIndex(
C, i, TypedAttr,
1030 CB->setAttributes(Attrs);
1033 if (
auto *AI = dyn_cast<AllocaInst>(
I))
1034 AI->setAllocatedType(TypeMapper->
remapType(AI->getAllocatedType()));
1035 if (
auto *
GEP = dyn_cast<GetElementPtrInst>(
I)) {
1036 GEP->setSourceElementType(
1038 GEP->setResultElementType(
1041 I->mutateType(TypeMapper->
remapType(
I->getType()));
1044void Mapper::remapGlobalObjectMetadata(
GlobalObject &GO) {
1048 for (
const auto &
I : MDs)
1049 GO.
addMetadata(
I.first, *cast<MDNode>(mapMetadata(
I.second)));
1052void Mapper::remapFunction(
Function &
F) {
1054 for (
Use &
Op :
F.operands())
1059 remapGlobalObjectMetadata(
F);
1069 remapInstruction(&
I);
1081 unsigned NumElements =
1082 cast<ArrayType>(InitPrefix->
getType())->getNumElements();
1083 for (
unsigned I = 0;
I != NumElements; ++
I)
1089 if (IsOldCtorDtor) {
1093 auto &
ST = *cast<StructType>(NewMembers.
front()->getType());
1094 Type *Tys[3] = {
ST.getElementType(0),
ST.getElementType(1), VoidPtrTy};
1098 for (
auto *V : NewMembers) {
1100 if (IsOldCtorDtor) {
1101 auto *S = cast<ConstantStruct>(V);
1102 auto *E1 = cast<Constant>(mapValue(S->getOperand(0)));
1103 auto *E2 = cast<Constant>(mapValue(S->getOperand(1)));
1107 NewV = cast_or_null<Constant>(mapValue(V));
1118 assert(AlreadyScheduled.
insert(&GV).second &&
"Should not reschedule");
1119 assert(MCID < MCs.
size() &&
"Invalid mapping context");
1122 WE.Kind = WorklistEntry::MapGlobalInit;
1124 WE.Data.GVInit.GV = &GV;
1125 WE.Data.GVInit.Init = &
Init;
1134 assert(AlreadyScheduled.
insert(&GV).second &&
"Should not reschedule");
1135 assert(MCID < MCs.
size() &&
"Invalid mapping context");
1138 WE.Kind = WorklistEntry::MapAppendingVar;
1140 WE.Data.AppendingGV.GV = &GV;
1141 WE.Data.AppendingGV.InitPrefix = InitPrefix;
1142 WE.AppendingGVIsOldCtorDtor = IsOldCtorDtor;
1143 WE.AppendingGVNumNewMembers = NewMembers.
size();
1150 assert(AlreadyScheduled.
insert(&GV).second &&
"Should not reschedule");
1151 assert((isa<GlobalAlias>(GV) || isa<GlobalIFunc>(GV)) &&
1152 "Should be alias or ifunc");
1153 assert(MCID < MCs.
size() &&
"Invalid mapping context");
1156 WE.Kind = WorklistEntry::MapAliasOrIFunc;
1158 WE.Data.AliasOrIFunc.GV = &GV;
1159 WE.Data.AliasOrIFunc.Target = &
Target;
1163void Mapper::scheduleRemapFunction(
Function &
F,
unsigned MCID) {
1164 assert(AlreadyScheduled.
insert(&
F).second &&
"Should not reschedule");
1165 assert(MCID < MCs.
size() &&
"Invalid mapping context");
1168 WE.Kind = WorklistEntry::RemapFunction;
1170 WE.Data.RemapF = &
F;
1175 assert(!hasWorkToDo() &&
"Expected to have flushed the worklist");
1176 this->Flags = this->Flags |
Flags;
1180 return reinterpret_cast<Mapper *
>(pImpl);
1185class FlushingMapper {
1189 explicit FlushingMapper(
void *pImpl) :
M(*
getAsMapper(pImpl)) {
1190 assert(!
M.hasWorkToDo() &&
"Expected to be flushed");
1193 ~FlushingMapper() {
M.flush(); }
1195 Mapper *operator->()
const {
return &
M; }
1203 : pImpl(new Mapper(VM, Flags, TypeMapper, Materializer)) {}
1210 return getAsMapper(pImpl)->registerAlternateMappingContext(VM, Materializer);
1214 FlushingMapper(pImpl)->addFlags(Flags);
1218 return FlushingMapper(pImpl)->mapValue(&V);
1222 return cast_or_null<Constant>(
mapValue(
C));
1226 return FlushingMapper(pImpl)->mapMetadata(&MD);
1234 FlushingMapper(pImpl)->remapInstruction(&
I);
1238 FlushingMapper(pImpl)->remapDbgRecord(DR);
1249 FlushingMapper(pImpl)->remapFunction(
F);
1253 FlushingMapper(pImpl)->remapGlobalObjectMetadata(GO);
1268 GV, InitPrefix, IsOldCtorDtor, NewMembers, MCID);
1273 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.
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.
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)
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.
@ CE
Windows NT (Windows on ARM)
NodeAddr< FuncNode * > Func
const_iterator end(StringRef path)
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.
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.
void RemapFunction(Function &F, ValueToValueMapTy &VM, RemapFlags Flags=RF_None, ValueMapTypeRemapper *TypeMapper=nullptr, ValueMaterializer *Materializer=nullptr)
Remap the operands, metadata, arguments, and instructions of a function.