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);
397 if (
auto *AL = dyn_cast<DIArgList>(MD)) {
399 for (
auto *VAM :
AL->getArgs()) {
407 }
else if (
Value *LV = mapValue(VAM->getValue())) {
425 return getVM()[
V] =
const_cast<Value *
>(
V);
428 auto *MappedMD = mapMetadata(MD);
430 return getVM()[
V] =
const_cast<Value *
>(
V);
441 return mapBlockAddress(*BA);
443 if (
const auto *E = dyn_cast<DSOLocalEquivalent>(
C)) {
444 auto *Val = mapValue(E->getGlobalValue());
449 auto *
Func = cast<Function>(Val->stripPointerCastsAndAliases());
450 Type *NewTy = E->getType();
457 if (
const auto *
NC = dyn_cast<NoCFIValue>(
C)) {
458 auto *Val = mapValue(
NC->getGlobalValue());
463 auto mapValueOrNull = [
this](
Value *
V) {
464 auto Mapped = mapValue(V);
466 "Unexpected null mapping for constant operand without "
467 "NullMapMissingGlobalValues flag");
473 unsigned OpNo = 0, NumOperands =
C->getNumOperands();
474 Value *Mapped =
nullptr;
475 for (; OpNo != NumOperands; ++OpNo) {
477 Mapped = mapValueOrNull(
Op);
485 Type *NewTy =
C->getType();
491 if (OpNo == NumOperands && NewTy ==
C->getType())
492 return getVM()[
V] =
C;
498 for (
unsigned j = 0;
j != OpNo; ++
j)
499 Ops.
push_back(cast<Constant>(
C->getOperand(j)));
502 if (OpNo != NumOperands) {
506 for (++OpNo; OpNo != NumOperands; ++OpNo) {
507 Mapped = mapValueOrNull(
C->getOperand(OpNo));
513 Type *NewSrcTy =
nullptr;
515 if (
auto *GEPO = dyn_cast<GEPOperator>(
C))
516 NewSrcTy = TypeMapper->
remapType(GEPO->getSourceElementType());
519 return getVM()[
V] =
CE->getWithOperands(Ops, NewTy,
false, NewSrcTy);
520 if (isa<ConstantArray>(
C))
522 if (isa<ConstantStruct>(
C))
524 if (isa<ConstantVector>(
C))
527 if (isa<PoisonValue>(
C))
529 if (isa<UndefValue>(
C))
531 if (isa<ConstantAggregateZero>(
C))
533 if (isa<ConstantTargetNone>(
C))
535 assert(isa<ConstantPointerNull>(
C));
539void Mapper::remapDbgRecord(
DbgRecord &DR) {
546 DLR->setLabel(cast<DILabel>(mapMetadata(DLR->getLabel())));
552 auto *MappedVar = mapMetadata(
V.getVariable());
553 V.setVariable(cast<DILocalVariable>(MappedVar));
557 if (
V.isDbgAssign()) {
558 auto *NewAddr = mapValue(
V.getAddress());
559 if (!IgnoreMissingLocals && !NewAddr)
562 V.setAddress(NewAddr);
563 V.setAssignId(cast<DIAssignID>(mapMetadata(
V.getAssignID())));
569 for (
Value *Val : Vals)
582 for (
unsigned int I = 0;
I < Vals.size(); ++
I)
584 V.replaceVariableLocationOp(
I, NewVals[
I]);
596 DelayedBBs.
push_back(DelayedBasicBlock(BA));
597 BB = DelayedBBs.
back().TempBB.get();
606 getVM().MD()[
Key].reset(Val);
611 return mapToMetadata(MD,
const_cast<Metadata *
>(MD));
614std::optional<Metadata *> MDNodeMapper::tryToMapOperand(
const Metadata *
Op) {
618 if (std::optional<Metadata *> MappedOp =
M.mapSimpleMetadata(
Op)) {
620 if (
auto *CMD = dyn_cast<ConstantAsMetadata>(
Op))
621 assert((!*MappedOp ||
M.getVM().count(CMD->getValue()) ||
622 M.getVM().getMappedMD(
Op)) &&
623 "Expected Value to be memoized");
625 assert((isa<MDString>(
Op) ||
M.getVM().getMappedMD(
Op)) &&
626 "Expected result to be memoized");
633 return mapDistinctNode(
N);
638 assert(
N.isDistinct() &&
"Expected a distinct node");
639 assert(!
M.getVM().getMappedMD(&
N) &&
"Expected an unmapped node");
643 NewM =
M.mapToSelf(&
N);
647 <<
"To " << *NewM <<
"\n\n");
648 M.mapToMetadata(&
N, NewM);
650 DistinctWorklist.push_back(cast<MDNode>(NewM));
652 return DistinctWorklist.back();
662std::optional<Metadata *> MDNodeMapper::getMappedOp(
const Metadata *
Op)
const {
666 if (std::optional<Metadata *> MappedOp =
M.getVM().getMappedMD(
Op))
669 if (isa<MDString>(
Op))
672 if (
auto *CMD = dyn_cast<ConstantAsMetadata>(
Op))
679 auto Where =
Info.find(&
Op);
680 assert(Where !=
Info.end() &&
"Expected a valid reference");
682 auto &OpD = Where->second;
687 if (!OpD.Placeholder)
688 OpD.Placeholder =
Op.clone();
690 return *OpD.Placeholder;
693template <
class OperandMapper>
694void MDNodeMapper::remapOperands(
MDNode &
N, OperandMapper mapOperand) {
695 assert(!
N.isUniqued() &&
"Expected distinct or temporary nodes");
696 for (
unsigned I = 0, E =
N.getNumOperands();
I != E; ++
I) {
700 LLVM_DEBUG(
dbgs() <<
"Replacing Op " << Old <<
" with " << New <<
" in "
704 N.replaceOperandWith(
I, New);
711struct POTWorklistEntry {
717 bool HasChanged =
false;
719 POTWorklistEntry(
MDNode &
N) :
N(&
N),
Op(
N.op_begin()) {}
724bool MDNodeMapper::createPOT(UniquedGraph &
G,
const MDNode &FirstN) {
725 assert(
G.Info.empty() &&
"Expected a fresh traversal");
729 bool AnyChanges =
false;
732 (void)
G.Info[&FirstN];
735 auto &WE = Worklist.
back();
736 if (
MDNode *
N = visitOperands(
G, WE.Op, WE.N->op_end(), WE.HasChanged)) {
743 assert(WE.N->isUniqued() &&
"Expected only uniqued nodes");
744 assert(WE.Op == WE.N->op_end() &&
"Expected to visit all operands");
745 auto &
D =
G.Info[WE.N];
746 AnyChanges |=
D.HasChanged = WE.HasChanged;
748 G.POT.push_back(WE.N);
760 if (std::optional<Metadata *> MappedOp = tryToMapOperand(
Op)) {
762 HasChanged |=
Op != *MappedOp;
769 "Only uniqued operands cannot be mapped immediately");
770 if (
G.Info.insert(std::make_pair(&OpN,
Data())).second)
776void MDNodeMapper::UniquedGraph::propagateChanges() {
786 auto Where = Info.find(Op);
787 return Where != Info.end() && Where->second.HasChanged;
791 AnyChanges =
D.HasChanged =
true;
793 }
while (AnyChanges);
796void MDNodeMapper::mapNodesInPOT(UniquedGraph &
G) {
799 for (
auto *
N :
G.POT) {
808 bool HadPlaceholder(
D.Placeholder);
811 TempMDNode ClonedN =
D.Placeholder ? std::move(
D.Placeholder) :
N->clone();
813 if (std::optional<Metadata *> MappedOp =
getMappedOp(Old))
816 assert(
G.Info[Old].ID >
D.ID &&
"Expected a forward reference");
817 return &
G.getFwdReference(*cast<MDNode>(Old));
821 if (
N && NewN &&
N != NewN) {
823 <<
"To " << *NewN <<
"\n\n");
826 M.mapToMetadata(
N, NewN);
835 for (
auto *
N : CyclicNodes)
836 if (!
N->isResolved())
841 assert(DistinctWorklist.empty() &&
"MDNodeMapper::map is not recursive");
843 "MDNodeMapper::map assumes module-level changes");
846 assert(
N.isResolved() &&
"Unexpected unresolved node");
849 N.isUniqued() ? mapTopLevelUniquedNode(
N) : mapDistinctNode(
N);
850 while (!DistinctWorklist.empty())
852 if (std::optional<Metadata *> MappedOp = tryToMapOperand(Old))
854 return mapTopLevelUniquedNode(*cast<MDNode>(Old));
859Metadata *MDNodeMapper::mapTopLevelUniquedNode(
const MDNode &FirstN) {
864 if (!createPOT(
G, FirstN)) {
868 return &
const_cast<MDNode &
>(FirstN);
872 G.propagateChanges();
881std::optional<Metadata *> Mapper::mapSimpleMetadata(
const Metadata *MD) {
883 if (std::optional<Metadata *> NewMD = getVM().getMappedMD(MD))
886 if (isa<MDString>(MD))
894 if (
auto *CMD = dyn_cast<ConstantAsMetadata>(MD)) {
902 assert(isa<MDNode>(MD) &&
"Expected a metadata node");
908 assert(MD &&
"Expected valid metadata");
909 assert(!isa<LocalAsMetadata>(MD) &&
"Unexpected local metadata");
911 if (std::optional<Metadata *> NewMD = mapSimpleMetadata(MD))
914 return MDNodeMapper(*this).map(*cast<MDNode>(MD));
917void Mapper::flush() {
919 while (!Worklist.
empty()) {
921 CurrentMCID = E.MCID;
923 case WorklistEntry::MapGlobalInit:
924 E.Data.GVInit.GV->setInitializer(mapConstant(E.Data.GVInit.Init));
925 remapGlobalObjectMetadata(*E.Data.GVInit.GV);
927 case WorklistEntry::MapAppendingVar: {
928 unsigned PrefixSize = AppendingInits.
size() - E.AppendingGVNumNewMembers;
934 AppendingInits.
resize(PrefixSize);
935 mapAppendingVariable(*E.Data.AppendingGV.GV,
936 E.Data.AppendingGV.InitPrefix,
937 E.AppendingGVIsOldCtorDtor,
ArrayRef(NewInits));
940 case WorklistEntry::MapAliasOrIFunc: {
943 if (
auto *GA = dyn_cast<GlobalAlias>(GV))
945 else if (
auto *GI = dyn_cast<GlobalIFunc>(GV))
951 case WorklistEntry::RemapFunction:
952 remapFunction(*E.Data.RemapF);
960 while (!DelayedBBs.
empty()) {
962 BasicBlock *BB = cast_or_null<BasicBlock>(mapValue(DBB.OldBB));
963 DBB.TempBB->replaceAllUsesWith(BB ? BB : DBB.OldBB);
969 for (
Use &
Op :
I->operands()) {
976 "Referenced value not in value map!");
980 if (
PHINode *PN = dyn_cast<PHINode>(
I)) {
981 for (
unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) {
982 Value *
V = mapValue(PN->getIncomingBlock(i));
985 PN->setIncomingBlock(i, cast<BasicBlock>(V));
988 "Referenced block not in value map!");
994 I->getAllMetadata(MDs);
995 for (
const auto &
MI : MDs) {
997 MDNode *
New = cast_or_null<MDNode>(mapMetadata(Old));
999 I->setMetadata(
MI.first, New);
1006 if (
auto *CB = dyn_cast<CallBase>(
I)) {
1009 Tys.reserve(FTy->getNumParams());
1010 for (
Type *Ty : FTy->params())
1013 TypeMapper->
remapType(
I->getType()), Tys, FTy->isVarArg()));
1017 for (
unsigned i = 0; i <
Attrs.getNumAttrSets(); ++i) {
1018 for (
int AttrIdx = Attribute::FirstTypeAttr;
1019 AttrIdx <= Attribute::LastTypeAttr; AttrIdx++) {
1022 Attrs.getAttributeAtIndex(i, TypedAttr).getValueAsType()) {
1023 Attrs =
Attrs.replaceAttributeTypeAtIndex(
C, i, TypedAttr,
1029 CB->setAttributes(Attrs);
1032 if (
auto *AI = dyn_cast<AllocaInst>(
I))
1033 AI->setAllocatedType(TypeMapper->
remapType(AI->getAllocatedType()));
1034 if (
auto *
GEP = dyn_cast<GetElementPtrInst>(
I)) {
1035 GEP->setSourceElementType(
1037 GEP->setResultElementType(
1040 I->mutateType(TypeMapper->
remapType(
I->getType()));
1043void Mapper::remapGlobalObjectMetadata(
GlobalObject &GO) {
1047 for (
const auto &
I : MDs)
1048 GO.
addMetadata(
I.first, *cast<MDNode>(mapMetadata(
I.second)));
1051void Mapper::remapFunction(
Function &
F) {
1053 for (
Use &
Op :
F.operands())
1058 remapGlobalObjectMetadata(
F);
1068 remapInstruction(&
I);
1080 unsigned NumElements =
1081 cast<ArrayType>(InitPrefix->
getType())->getNumElements();
1082 for (
unsigned I = 0;
I != NumElements; ++
I)
1088 if (IsOldCtorDtor) {
1092 auto &
ST = *cast<StructType>(NewMembers.
front()->getType());
1093 Type *
Tys[3] = {
ST.getElementType(0),
ST.getElementType(1), VoidPtrTy};
1097 for (
auto *V : NewMembers) {
1099 if (IsOldCtorDtor) {
1100 auto *S = cast<ConstantStruct>(V);
1101 auto *E1 = cast<Constant>(mapValue(S->getOperand(0)));
1102 auto *E2 = cast<Constant>(mapValue(S->getOperand(1)));
1106 NewV = cast_or_null<Constant>(mapValue(V));
1117 assert(AlreadyScheduled.
insert(&GV).second &&
"Should not reschedule");
1118 assert(MCID < MCs.
size() &&
"Invalid mapping context");
1121 WE.Kind = WorklistEntry::MapGlobalInit;
1123 WE.Data.GVInit.GV = &GV;
1124 WE.Data.GVInit.Init = &
Init;
1133 assert(AlreadyScheduled.
insert(&GV).second &&
"Should not reschedule");
1134 assert(MCID < MCs.
size() &&
"Invalid mapping context");
1137 WE.Kind = WorklistEntry::MapAppendingVar;
1139 WE.Data.AppendingGV.GV = &GV;
1140 WE.Data.AppendingGV.InitPrefix = InitPrefix;
1141 WE.AppendingGVIsOldCtorDtor = IsOldCtorDtor;
1142 WE.AppendingGVNumNewMembers = NewMembers.
size();
1149 assert(AlreadyScheduled.
insert(&GV).second &&
"Should not reschedule");
1150 assert((isa<GlobalAlias>(GV) || isa<GlobalIFunc>(GV)) &&
1151 "Should be alias or ifunc");
1152 assert(MCID < MCs.
size() &&
"Invalid mapping context");
1155 WE.Kind = WorklistEntry::MapAliasOrIFunc;
1157 WE.Data.AliasOrIFunc.GV = &GV;
1158 WE.Data.AliasOrIFunc.Target = &
Target;
1162void Mapper::scheduleRemapFunction(
Function &
F,
unsigned MCID) {
1163 assert(AlreadyScheduled.
insert(&
F).second &&
"Should not reschedule");
1164 assert(MCID < MCs.
size() &&
"Invalid mapping context");
1167 WE.Kind = WorklistEntry::RemapFunction;
1169 WE.Data.RemapF = &
F;
1174 assert(!hasWorkToDo() &&
"Expected to have flushed the worklist");
1175 this->Flags = this->Flags |
Flags;
1179 return reinterpret_cast<Mapper *
>(pImpl);
1184class FlushingMapper {
1188 explicit FlushingMapper(
void *pImpl) :
M(*
getAsMapper(pImpl)) {
1189 assert(!
M.hasWorkToDo() &&
"Expected to be flushed");
1192 ~FlushingMapper() {
M.flush(); }
1194 Mapper *operator->()
const {
return &
M; }
1202 : pImpl(new Mapper(VM, Flags, TypeMapper, Materializer)) {}
1209 return getAsMapper(pImpl)->registerAlternateMappingContext(VM, Materializer);
1213 FlushingMapper(pImpl)->addFlags(Flags);
1217 return FlushingMapper(pImpl)->mapValue(&V);
1221 return cast_or_null<Constant>(
mapValue(
C));
1225 return FlushingMapper(pImpl)->mapMetadata(&MD);
1233 FlushingMapper(pImpl)->remapInstruction(&
I);
1237 FlushingMapper(pImpl)->remapDbgRecord(DR);
1248 FlushingMapper(pImpl)->remapFunction(
F);
1252 FlushingMapper(pImpl)->remapGlobalObjectMetadata(GO);
1267 GV, InitPrefix, IsOldCtorDtor, NewMembers, MCID);
1272 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.
ID ArrayRef< Type * > Tys
@ 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.