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;
149 void remapDPValue(
DPValue &DPV);
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>
334 void remapOperands(
MDNode &
N, OperandMapper mapOperand);
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::remapDPValue(
DPValue &V) {
542 auto *MappedVar = mapMetadata(
V.getVariable());
543 auto *MappedDILoc = mapMetadata(
V.getDebugLoc());
544 V.setVariable(cast<DILocalVariable>(MappedVar));
545 V.setDebugLoc(
DebugLoc(cast<DILocation>(MappedDILoc)));
549 for (
Value *Val :
V.location_ops())
551 for (
Value *Val : Vals)
561 if (!IgnoreMissingLocals &&
567 for (
unsigned int I = 0;
I < Vals.size(); ++
I)
569 V.replaceVariableLocationOp(
I, NewVals[
I]);
581 DelayedBBs.
push_back(DelayedBasicBlock(BA));
582 BB = DelayedBBs.
back().TempBB.get();
591 getVM().MD()[
Key].reset(Val);
596 return mapToMetadata(MD,
const_cast<Metadata *
>(MD));
599std::optional<Metadata *> MDNodeMapper::tryToMapOperand(
const Metadata *
Op) {
603 if (std::optional<Metadata *> MappedOp =
M.mapSimpleMetadata(
Op)) {
605 if (
auto *CMD = dyn_cast<ConstantAsMetadata>(
Op))
606 assert((!*MappedOp ||
M.getVM().count(CMD->getValue()) ||
607 M.getVM().getMappedMD(
Op)) &&
608 "Expected Value to be memoized");
610 assert((isa<MDString>(
Op) ||
M.getVM().getMappedMD(
Op)) &&
611 "Expected result to be memoized");
618 return mapDistinctNode(
N);
623 assert(
N.isDistinct() &&
"Expected a distinct node");
624 assert(!
M.getVM().getMappedMD(&
N) &&
"Expected an unmapped node");
628 NewM =
M.mapToSelf(&
N);
632 <<
"To " << *NewM <<
"\n\n");
633 M.mapToMetadata(&
N, NewM);
635 DistinctWorklist.push_back(cast<MDNode>(NewM));
637 return DistinctWorklist.back();
647std::optional<Metadata *> MDNodeMapper::getMappedOp(
const Metadata *
Op)
const {
651 if (std::optional<Metadata *> MappedOp =
M.getVM().getMappedMD(
Op))
654 if (isa<MDString>(
Op))
657 if (
auto *CMD = dyn_cast<ConstantAsMetadata>(
Op))
664 auto Where =
Info.find(&
Op);
665 assert(Where !=
Info.end() &&
"Expected a valid reference");
667 auto &OpD = Where->second;
672 if (!OpD.Placeholder)
673 OpD.Placeholder =
Op.clone();
675 return *OpD.Placeholder;
678template <
class OperandMapper>
679void MDNodeMapper::remapOperands(
MDNode &
N, OperandMapper mapOperand) {
680 assert(!
N.isUniqued() &&
"Expected distinct or temporary nodes");
681 for (
unsigned I = 0,
E =
N.getNumOperands();
I !=
E; ++
I) {
685 LLVM_DEBUG(
dbgs() <<
"Replacing Op " << Old <<
" with " << New <<
" in "
689 N.replaceOperandWith(
I, New);
696struct POTWorklistEntry {
702 bool HasChanged =
false;
704 POTWorklistEntry(
MDNode &
N) :
N(&
N),
Op(
N.op_begin()) {}
709bool MDNodeMapper::createPOT(UniquedGraph &
G,
const MDNode &FirstN) {
710 assert(
G.Info.empty() &&
"Expected a fresh traversal");
714 bool AnyChanges =
false;
717 (void)
G.Info[&FirstN];
718 while (!Worklist.
empty()) {
720 auto &WE = Worklist.
back();
721 if (
MDNode *
N = visitOperands(
G, WE.Op, WE.N->op_end(), WE.HasChanged)) {
728 assert(WE.N->isUniqued() &&
"Expected only uniqued nodes");
729 assert(WE.Op == WE.N->op_end() &&
"Expected to visit all operands");
730 auto &
D =
G.Info[WE.N];
731 AnyChanges |=
D.HasChanged = WE.HasChanged;
733 G.POT.push_back(WE.N);
745 if (std::optional<Metadata *> MappedOp = tryToMapOperand(
Op)) {
747 HasChanged |=
Op != *MappedOp;
754 "Only uniqued operands cannot be mapped immediately");
755 if (
G.Info.insert(std::make_pair(&OpN,
Data())).second)
761void MDNodeMapper::UniquedGraph::propagateChanges() {
771 auto Where = Info.find(Op);
772 return Where != Info.end() && Where->second.HasChanged;
776 AnyChanges =
D.HasChanged =
true;
778 }
while (AnyChanges);
781void MDNodeMapper::mapNodesInPOT(UniquedGraph &
G) {
784 for (
auto *
N :
G.POT) {
793 bool HadPlaceholder(
D.Placeholder);
796 TempMDNode ClonedN =
D.Placeholder ? std::move(
D.Placeholder) :
N->clone();
797 remapOperands(*ClonedN, [
this, &
D, &
G](
Metadata *Old) {
798 if (std::optional<Metadata *> MappedOp =
getMappedOp(Old))
801 assert(
G.Info[Old].ID >
D.ID &&
"Expected a forward reference");
802 return &
G.getFwdReference(*cast<MDNode>(Old));
806 if (
N && NewN &&
N != NewN) {
808 <<
"To " << *NewN <<
"\n\n");
811 M.mapToMetadata(
N, NewN);
820 for (
auto *
N : CyclicNodes)
821 if (!
N->isResolved())
826 assert(DistinctWorklist.empty() &&
"MDNodeMapper::map is not recursive");
828 "MDNodeMapper::map assumes module-level changes");
831 assert(
N.isResolved() &&
"Unexpected unresolved node");
834 N.isUniqued() ? mapTopLevelUniquedNode(
N) : mapDistinctNode(
N);
835 while (!DistinctWorklist.empty())
836 remapOperands(*DistinctWorklist.pop_back_val(), [
this](
Metadata *Old) {
837 if (std::optional<Metadata *> MappedOp = tryToMapOperand(Old))
839 return mapTopLevelUniquedNode(*cast<MDNode>(Old));
844Metadata *MDNodeMapper::mapTopLevelUniquedNode(
const MDNode &FirstN) {
849 if (!createPOT(
G, FirstN)) {
853 return &
const_cast<MDNode &
>(FirstN);
857 G.propagateChanges();
866std::optional<Metadata *> Mapper::mapSimpleMetadata(
const Metadata *MD) {
868 if (std::optional<Metadata *> NewMD = getVM().getMappedMD(MD))
871 if (isa<MDString>(MD))
879 if (
auto *CMD = dyn_cast<ConstantAsMetadata>(MD)) {
887 assert(isa<MDNode>(MD) &&
"Expected a metadata node");
893 assert(MD &&
"Expected valid metadata");
894 assert(!isa<LocalAsMetadata>(MD) &&
"Unexpected local metadata");
896 if (std::optional<Metadata *> NewMD = mapSimpleMetadata(MD))
899 return MDNodeMapper(*this).map(*cast<MDNode>(MD));
902void Mapper::flush() {
904 while (!Worklist.
empty()) {
906 CurrentMCID =
E.MCID;
908 case WorklistEntry::MapGlobalInit:
909 E.Data.GVInit.GV->setInitializer(mapConstant(
E.Data.GVInit.Init));
910 remapGlobalObjectMetadata(*
E.Data.GVInit.GV);
912 case WorklistEntry::MapAppendingVar: {
913 unsigned PrefixSize = AppendingInits.
size() -
E.AppendingGVNumNewMembers;
919 AppendingInits.
resize(PrefixSize);
920 mapAppendingVariable(*
E.Data.AppendingGV.GV,
921 E.Data.AppendingGV.InitPrefix,
922 E.AppendingGVIsOldCtorDtor,
ArrayRef(NewInits));
925 case WorklistEntry::MapAliasOrIFunc: {
928 if (
auto *GA = dyn_cast<GlobalAlias>(GV))
930 else if (
auto *GI = dyn_cast<GlobalIFunc>(GV))
936 case WorklistEntry::RemapFunction:
937 remapFunction(*
E.Data.RemapF);
945 while (!DelayedBBs.
empty()) {
947 BasicBlock *BB = cast_or_null<BasicBlock>(mapValue(DBB.OldBB));
948 DBB.TempBB->replaceAllUsesWith(BB ? BB : DBB.OldBB);
954 for (
Use &
Op :
I->operands()) {
961 "Referenced value not in value map!");
965 if (
PHINode *PN = dyn_cast<PHINode>(
I)) {
966 for (
unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) {
967 Value *
V = mapValue(PN->getIncomingBlock(i));
970 PN->setIncomingBlock(i, cast<BasicBlock>(V));
973 "Referenced block not in value map!");
979 I->getAllMetadata(MDs);
980 for (
const auto &
MI : MDs) {
982 MDNode *
New = cast_or_null<MDNode>(mapMetadata(Old));
984 I->setMetadata(
MI.first, New);
991 if (
auto *CB = dyn_cast<CallBase>(
I)) {
994 Tys.
reserve(FTy->getNumParams());
995 for (
Type *Ty : FTy->params())
998 TypeMapper->
remapType(
I->getType()), Tys, FTy->isVarArg()));
1002 for (
unsigned i = 0; i <
Attrs.getNumAttrSets(); ++i) {
1003 for (
int AttrIdx = Attribute::FirstTypeAttr;
1004 AttrIdx <= Attribute::LastTypeAttr; AttrIdx++) {
1007 Attrs.getAttributeAtIndex(i, TypedAttr).getValueAsType()) {
1008 Attrs =
Attrs.replaceAttributeTypeAtIndex(
C, i, TypedAttr,
1014 CB->setAttributes(Attrs);
1017 if (
auto *AI = dyn_cast<AllocaInst>(
I))
1018 AI->setAllocatedType(TypeMapper->
remapType(AI->getAllocatedType()));
1019 if (
auto *
GEP = dyn_cast<GetElementPtrInst>(
I)) {
1020 GEP->setSourceElementType(
1022 GEP->setResultElementType(
1025 I->mutateType(TypeMapper->
remapType(
I->getType()));
1028void Mapper::remapGlobalObjectMetadata(
GlobalObject &GO) {
1032 for (
const auto &
I : MDs)
1033 GO.
addMetadata(
I.first, *cast<MDNode>(mapMetadata(
I.second)));
1036void Mapper::remapFunction(
Function &
F) {
1038 for (
Use &
Op :
F.operands())
1043 remapGlobalObjectMetadata(
F);
1053 remapInstruction(&
I);
1061 unsigned NumElements =
1062 cast<ArrayType>(InitPrefix->
getType())->getNumElements();
1063 for (
unsigned I = 0;
I != NumElements; ++
I)
1069 if (IsOldCtorDtor) {
1073 auto &
ST = *cast<StructType>(NewMembers.
front()->getType());
1074 Type *Tys[3] = {
ST.getElementType(0),
ST.getElementType(1), VoidPtrTy};
1078 for (
auto *V : NewMembers) {
1080 if (IsOldCtorDtor) {
1081 auto *S = cast<ConstantStruct>(V);
1082 auto *E1 = cast<Constant>(mapValue(S->getOperand(0)));
1083 auto *E2 = cast<Constant>(mapValue(S->getOperand(1)));
1087 NewV = cast_or_null<Constant>(mapValue(V));
1098 assert(AlreadyScheduled.
insert(&GV).second &&
"Should not reschedule");
1099 assert(MCID < MCs.
size() &&
"Invalid mapping context");
1102 WE.Kind = WorklistEntry::MapGlobalInit;
1104 WE.Data.GVInit.GV = &GV;
1105 WE.Data.GVInit.Init = &
Init;
1114 assert(AlreadyScheduled.
insert(&GV).second &&
"Should not reschedule");
1115 assert(MCID < MCs.
size() &&
"Invalid mapping context");
1118 WE.Kind = WorklistEntry::MapAppendingVar;
1120 WE.Data.AppendingGV.GV = &GV;
1121 WE.Data.AppendingGV.InitPrefix = InitPrefix;
1122 WE.AppendingGVIsOldCtorDtor = IsOldCtorDtor;
1123 WE.AppendingGVNumNewMembers = NewMembers.
size();
1130 assert(AlreadyScheduled.
insert(&GV).second &&
"Should not reschedule");
1131 assert((isa<GlobalAlias>(GV) || isa<GlobalIFunc>(GV)) &&
1132 "Should be alias or ifunc");
1133 assert(MCID < MCs.
size() &&
"Invalid mapping context");
1136 WE.Kind = WorklistEntry::MapAliasOrIFunc;
1138 WE.Data.AliasOrIFunc.GV = &GV;
1139 WE.Data.AliasOrIFunc.Target = &
Target;
1143void Mapper::scheduleRemapFunction(
Function &
F,
unsigned MCID) {
1144 assert(AlreadyScheduled.
insert(&
F).second &&
"Should not reschedule");
1145 assert(MCID < MCs.
size() &&
"Invalid mapping context");
1148 WE.Kind = WorklistEntry::RemapFunction;
1150 WE.Data.RemapF = &
F;
1155 assert(!hasWorkToDo() &&
"Expected to have flushed the worklist");
1156 this->Flags = this->Flags |
Flags;
1160 return reinterpret_cast<Mapper *
>(pImpl);
1165class FlushingMapper {
1169 explicit FlushingMapper(
void *pImpl) :
M(*
getAsMapper(pImpl)) {
1170 assert(!
M.hasWorkToDo() &&
"Expected to be flushed");
1173 ~FlushingMapper() {
M.flush(); }
1175 Mapper *operator->()
const {
return &
M; }
1183 : pImpl(new Mapper(VM, Flags, TypeMapper, Materializer)) {}
1190 return getAsMapper(pImpl)->registerAlternateMappingContext(VM, Materializer);
1194 FlushingMapper(pImpl)->addFlags(Flags);
1198 return FlushingMapper(pImpl)->mapValue(&V);
1202 return cast_or_null<Constant>(
mapValue(
C));
1206 return FlushingMapper(pImpl)->mapMetadata(&MD);
1214 FlushingMapper(pImpl)->remapInstruction(&
I);
1218 FlushingMapper(pImpl)->remapDPValue(V);
1229 FlushingMapper(pImpl)->remapFunction(
F);
1233 FlushingMapper(pImpl)->remapGlobalObjectMetadata(GO);
1248 GV, InitPrefix, IsOldCtorDtor, NewMembers, MCID);
1253 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...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallVector class.
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)
Record of a variable value-assignment, aka a non instruction representation of the dbg....
static DSOLocalEquivalent * get(GlobalValue *GV)
Return a DSOLocalEquivalent for the specified global value.
This class represents an Operation in the Expression.
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.
MDNode * mapMDNode(const MDNode &N)
Metadata * mapMetadata(const Metadata &MD)
void remapInstruction(Instruction &I)
void remapDPValue(Module *M, DPValue &V)
void scheduleMapGlobalInitializer(GlobalVariable &GV, Constant &Init, unsigned MappingContextID=0)
void remapDPValueRange(Module *M, iterator_range< DPValueIterator > Range)
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.