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())));
569 for (
Value *Val :
V.location_ops())
571 for (
Value *Val : Vals)
579 if (!IgnoreMissingLocals &&
585 for (
unsigned int I = 0;
I < Vals.size(); ++
I)
587 V.replaceVariableLocationOp(
I, NewVals[
I]);
599 DelayedBBs.
push_back(DelayedBasicBlock(BA));
600 BB = DelayedBBs.
back().TempBB.get();
609 getVM().MD()[
Key].reset(Val);
614 return mapToMetadata(MD,
const_cast<Metadata *
>(MD));
617std::optional<Metadata *> MDNodeMapper::tryToMapOperand(
const Metadata *
Op) {
621 if (std::optional<Metadata *> MappedOp =
M.mapSimpleMetadata(
Op)) {
623 if (
auto *CMD = dyn_cast<ConstantAsMetadata>(
Op))
624 assert((!*MappedOp ||
M.getVM().count(CMD->getValue()) ||
625 M.getVM().getMappedMD(
Op)) &&
626 "Expected Value to be memoized");
628 assert((isa<MDString>(
Op) ||
M.getVM().getMappedMD(
Op)) &&
629 "Expected result to be memoized");
636 return mapDistinctNode(
N);
641 assert(
N.isDistinct() &&
"Expected a distinct node");
642 assert(!
M.getVM().getMappedMD(&
N) &&
"Expected an unmapped node");
646 NewM =
M.mapToSelf(&
N);
650 <<
"To " << *NewM <<
"\n\n");
651 M.mapToMetadata(&
N, NewM);
653 DistinctWorklist.push_back(cast<MDNode>(NewM));
655 return DistinctWorklist.back();
665std::optional<Metadata *> MDNodeMapper::getMappedOp(
const Metadata *
Op)
const {
669 if (std::optional<Metadata *> MappedOp =
M.getVM().getMappedMD(
Op))
672 if (isa<MDString>(
Op))
675 if (
auto *CMD = dyn_cast<ConstantAsMetadata>(
Op))
682 auto Where =
Info.find(&
Op);
683 assert(Where !=
Info.end() &&
"Expected a valid reference");
685 auto &OpD = Where->second;
690 if (!OpD.Placeholder)
691 OpD.Placeholder =
Op.clone();
693 return *OpD.Placeholder;
696template <
class OperandMapper>
697void MDNodeMapper::remapOperands(
MDNode &
N, OperandMapper mapOperand) {
698 assert(!
N.isUniqued() &&
"Expected distinct or temporary nodes");
699 for (
unsigned I = 0, E =
N.getNumOperands();
I != E; ++
I) {
703 LLVM_DEBUG(
dbgs() <<
"Replacing Op " << Old <<
" with " << New <<
" in "
707 N.replaceOperandWith(
I, New);
714struct POTWorklistEntry {
720 bool HasChanged =
false;
722 POTWorklistEntry(
MDNode &
N) :
N(&
N),
Op(
N.op_begin()) {}
727bool MDNodeMapper::createPOT(UniquedGraph &
G,
const MDNode &FirstN) {
728 assert(
G.Info.empty() &&
"Expected a fresh traversal");
732 bool AnyChanges =
false;
735 (void)
G.Info[&FirstN];
738 auto &WE = Worklist.
back();
739 if (
MDNode *
N = visitOperands(
G, WE.Op, WE.N->op_end(), WE.HasChanged)) {
746 assert(WE.N->isUniqued() &&
"Expected only uniqued nodes");
747 assert(WE.Op == WE.N->op_end() &&
"Expected to visit all operands");
748 auto &
D =
G.Info[WE.N];
749 AnyChanges |=
D.HasChanged = WE.HasChanged;
751 G.POT.push_back(WE.N);
763 if (std::optional<Metadata *> MappedOp = tryToMapOperand(
Op)) {
765 HasChanged |=
Op != *MappedOp;
772 "Only uniqued operands cannot be mapped immediately");
773 if (
G.Info.insert(std::make_pair(&OpN,
Data())).second)
779void MDNodeMapper::UniquedGraph::propagateChanges() {
789 auto Where = Info.find(Op);
790 return Where != Info.end() && Where->second.HasChanged;
794 AnyChanges =
D.HasChanged =
true;
796 }
while (AnyChanges);
799void MDNodeMapper::mapNodesInPOT(UniquedGraph &
G) {
802 for (
auto *
N :
G.POT) {
811 bool HadPlaceholder(
D.Placeholder);
814 TempMDNode ClonedN =
D.Placeholder ? std::move(
D.Placeholder) :
N->clone();
816 if (std::optional<Metadata *> MappedOp =
getMappedOp(Old))
819 assert(
G.Info[Old].ID >
D.ID &&
"Expected a forward reference");
820 return &
G.getFwdReference(*cast<MDNode>(Old));
824 if (
N && NewN &&
N != NewN) {
826 <<
"To " << *NewN <<
"\n\n");
829 M.mapToMetadata(
N, NewN);
838 for (
auto *
N : CyclicNodes)
839 if (!
N->isResolved())
844 assert(DistinctWorklist.empty() &&
"MDNodeMapper::map is not recursive");
846 "MDNodeMapper::map assumes module-level changes");
849 assert(
N.isResolved() &&
"Unexpected unresolved node");
852 N.isUniqued() ? mapTopLevelUniquedNode(
N) : mapDistinctNode(
N);
853 while (!DistinctWorklist.empty())
855 if (std::optional<Metadata *> MappedOp = tryToMapOperand(Old))
857 return mapTopLevelUniquedNode(*cast<MDNode>(Old));
862Metadata *MDNodeMapper::mapTopLevelUniquedNode(
const MDNode &FirstN) {
867 if (!createPOT(
G, FirstN)) {
871 return &
const_cast<MDNode &
>(FirstN);
875 G.propagateChanges();
884std::optional<Metadata *> Mapper::mapSimpleMetadata(
const Metadata *MD) {
886 if (std::optional<Metadata *> NewMD = getVM().getMappedMD(MD))
889 if (isa<MDString>(MD))
897 if (
auto *CMD = dyn_cast<ConstantAsMetadata>(MD)) {
905 assert(isa<MDNode>(MD) &&
"Expected a metadata node");
911 assert(MD &&
"Expected valid metadata");
912 assert(!isa<LocalAsMetadata>(MD) &&
"Unexpected local metadata");
914 if (std::optional<Metadata *> NewMD = mapSimpleMetadata(MD))
917 return MDNodeMapper(*this).map(*cast<MDNode>(MD));
920void Mapper::flush() {
922 while (!Worklist.
empty()) {
924 CurrentMCID = E.MCID;
926 case WorklistEntry::MapGlobalInit:
927 E.Data.GVInit.GV->setInitializer(mapConstant(E.Data.GVInit.Init));
928 remapGlobalObjectMetadata(*E.Data.GVInit.GV);
930 case WorklistEntry::MapAppendingVar: {
931 unsigned PrefixSize = AppendingInits.
size() - E.AppendingGVNumNewMembers;
937 AppendingInits.
resize(PrefixSize);
938 mapAppendingVariable(*E.Data.AppendingGV.GV,
939 E.Data.AppendingGV.InitPrefix,
940 E.AppendingGVIsOldCtorDtor,
ArrayRef(NewInits));
943 case WorklistEntry::MapAliasOrIFunc: {
946 if (
auto *GA = dyn_cast<GlobalAlias>(GV))
948 else if (
auto *GI = dyn_cast<GlobalIFunc>(GV))
954 case WorklistEntry::RemapFunction:
955 remapFunction(*E.Data.RemapF);
963 while (!DelayedBBs.
empty()) {
965 BasicBlock *BB = cast_or_null<BasicBlock>(mapValue(DBB.OldBB));
966 DBB.TempBB->replaceAllUsesWith(BB ? BB : DBB.OldBB);
972 for (
Use &
Op :
I->operands()) {
979 "Referenced value not in value map!");
983 if (
PHINode *PN = dyn_cast<PHINode>(
I)) {
984 for (
unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) {
985 Value *
V = mapValue(PN->getIncomingBlock(i));
988 PN->setIncomingBlock(i, cast<BasicBlock>(V));
991 "Referenced block not in value map!");
997 I->getAllMetadata(MDs);
998 for (
const auto &
MI : MDs) {
1000 MDNode *
New = cast_or_null<MDNode>(mapMetadata(Old));
1002 I->setMetadata(
MI.first, New);
1009 if (
auto *CB = dyn_cast<CallBase>(
I)) {
1012 Tys.
reserve(FTy->getNumParams());
1013 for (
Type *Ty : FTy->params())
1016 TypeMapper->
remapType(
I->getType()), Tys, FTy->isVarArg()));
1020 for (
unsigned i = 0; i <
Attrs.getNumAttrSets(); ++i) {
1021 for (
int AttrIdx = Attribute::FirstTypeAttr;
1022 AttrIdx <= Attribute::LastTypeAttr; AttrIdx++) {
1025 Attrs.getAttributeAtIndex(i, TypedAttr).getValueAsType()) {
1026 Attrs =
Attrs.replaceAttributeTypeAtIndex(
C, i, TypedAttr,
1032 CB->setAttributes(Attrs);
1035 if (
auto *AI = dyn_cast<AllocaInst>(
I))
1036 AI->setAllocatedType(TypeMapper->
remapType(AI->getAllocatedType()));
1037 if (
auto *
GEP = dyn_cast<GetElementPtrInst>(
I)) {
1038 GEP->setSourceElementType(
1040 GEP->setResultElementType(
1043 I->mutateType(TypeMapper->
remapType(
I->getType()));
1046void Mapper::remapGlobalObjectMetadata(
GlobalObject &GO) {
1050 for (
const auto &
I : MDs)
1051 GO.
addMetadata(
I.first, *cast<MDNode>(mapMetadata(
I.second)));
1054void Mapper::remapFunction(
Function &
F) {
1056 for (
Use &
Op :
F.operands())
1061 remapGlobalObjectMetadata(
F);
1071 remapInstruction(&
I);
1083 unsigned NumElements =
1084 cast<ArrayType>(InitPrefix->
getType())->getNumElements();
1085 for (
unsigned I = 0;
I != NumElements; ++
I)
1091 if (IsOldCtorDtor) {
1095 auto &
ST = *cast<StructType>(NewMembers.
front()->getType());
1096 Type *Tys[3] = {
ST.getElementType(0),
ST.getElementType(1), VoidPtrTy};
1100 for (
auto *V : NewMembers) {
1102 if (IsOldCtorDtor) {
1103 auto *S = cast<ConstantStruct>(V);
1104 auto *E1 = cast<Constant>(mapValue(S->getOperand(0)));
1105 auto *E2 = cast<Constant>(mapValue(S->getOperand(1)));
1109 NewV = cast_or_null<Constant>(mapValue(V));
1120 assert(AlreadyScheduled.
insert(&GV).second &&
"Should not reschedule");
1121 assert(MCID < MCs.
size() &&
"Invalid mapping context");
1124 WE.Kind = WorklistEntry::MapGlobalInit;
1126 WE.Data.GVInit.GV = &GV;
1127 WE.Data.GVInit.Init = &
Init;
1136 assert(AlreadyScheduled.
insert(&GV).second &&
"Should not reschedule");
1137 assert(MCID < MCs.
size() &&
"Invalid mapping context");
1140 WE.Kind = WorklistEntry::MapAppendingVar;
1142 WE.Data.AppendingGV.GV = &GV;
1143 WE.Data.AppendingGV.InitPrefix = InitPrefix;
1144 WE.AppendingGVIsOldCtorDtor = IsOldCtorDtor;
1145 WE.AppendingGVNumNewMembers = NewMembers.
size();
1152 assert(AlreadyScheduled.
insert(&GV).second &&
"Should not reschedule");
1153 assert((isa<GlobalAlias>(GV) || isa<GlobalIFunc>(GV)) &&
1154 "Should be alias or ifunc");
1155 assert(MCID < MCs.
size() &&
"Invalid mapping context");
1158 WE.Kind = WorklistEntry::MapAliasOrIFunc;
1160 WE.Data.AliasOrIFunc.GV = &GV;
1161 WE.Data.AliasOrIFunc.Target = &
Target;
1165void Mapper::scheduleRemapFunction(
Function &
F,
unsigned MCID) {
1166 assert(AlreadyScheduled.
insert(&
F).second &&
"Should not reschedule");
1167 assert(MCID < MCs.
size() &&
"Invalid mapping context");
1170 WE.Kind = WorklistEntry::RemapFunction;
1172 WE.Data.RemapF = &
F;
1177 assert(!hasWorkToDo() &&
"Expected to have flushed the worklist");
1178 this->Flags = this->Flags |
Flags;
1182 return reinterpret_cast<Mapper *
>(pImpl);
1187class FlushingMapper {
1191 explicit FlushingMapper(
void *pImpl) :
M(*
getAsMapper(pImpl)) {
1192 assert(!
M.hasWorkToDo() &&
"Expected to be flushed");
1195 ~FlushingMapper() {
M.flush(); }
1197 Mapper *operator->()
const {
return &
M; }
1205 : pImpl(new Mapper(VM, Flags, TypeMapper, Materializer)) {}
1212 return getAsMapper(pImpl)->registerAlternateMappingContext(VM, Materializer);
1216 FlushingMapper(pImpl)->addFlags(Flags);
1220 return FlushingMapper(pImpl)->mapValue(&V);
1224 return cast_or_null<Constant>(
mapValue(
C));
1228 return FlushingMapper(pImpl)->mapMetadata(&MD);
1236 FlushingMapper(pImpl)->remapInstruction(&
I);
1240 FlushingMapper(pImpl)->remapDbgRecord(DR);
1251 FlushingMapper(pImpl)->remapFunction(
F);
1255 FlushingMapper(pImpl)->remapGlobalObjectMetadata(GO);
1270 GV, InitPrefix, IsOldCtorDtor, NewMembers, MCID);
1275 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...
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.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
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
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.