48#define DEBUG_TYPE "value-mapper"
51void ValueMapTypeRemapper::anchor() {}
52void ValueMaterializer::anchor() {}
58struct DelayedBasicBlock {
60 std::unique_ptr<BasicBlock> TempBB;
62 DelayedBasicBlock(
const BlockAddress &Old)
63 : OldBB(Old.getBasicBlock()),
78 struct AppendingGVTy {
80 GlobalVariable *OldGV;
82 struct AliasOrIFuncTy {
89 unsigned AppendingGVIsOldCtorDtor : 1;
90 unsigned AppendingGVNumNewMembers;
93 AppendingGVTy AppendingGV;
94 AliasOrIFuncTy AliasOrIFunc;
99struct MappingContext {
101 ValueMaterializer *Materializer =
nullptr;
105 ValueMaterializer *Materializer =
nullptr)
106 : VM(&VM), Materializer(Materializer) {}
110 friend class MDNodeMapper;
113 DenseSet<GlobalValue *> AlreadyScheduled;
117 ValueMapTypeRemapper *TypeMapper;
118 unsigned CurrentMCID = 0;
127 ValueMapTypeRemapper *TypeMapper, ValueMaterializer *Materializer,
130 MCs(1, MappingContext(VM, Materializer)), IdentityMD(IdentityMD) {}
133 ~Mapper() {
assert(!hasWorkToDo() &&
"Expected to be flushed"); }
135 bool hasWorkToDo()
const {
return !Worklist.
empty(); }
139 ValueMaterializer *Materializer =
nullptr) {
140 MCs.
push_back(MappingContext(VM, Materializer));
141 return MCs.
size() - 1;
146 void remapGlobalObjectMetadata(GlobalObject &GO);
149 void remapInstruction(Instruction *
I);
150 void remapFunction(Function &
F);
151 void remapDbgRecord(DbgRecord &DVR);
153 Constant *mapConstant(
const Constant *
C) {
163 void scheduleMapGlobalInitializer(GlobalVariable &GV, Constant &Init,
165 void scheduleMapAppendingVariable(GlobalVariable &GV, GlobalVariable *OldGV,
169 void scheduleMapAliasOrIFunc(GlobalValue &GV, Constant &Target,
171 void scheduleRemapFunction(Function &
F,
unsigned MCID);
176 void mapAppendingVariable(GlobalVariable &GV, GlobalVariable *OldGV,
181 ValueMaterializer *getMaterializer() {
return MCs[CurrentMCID].Materializer; }
183 Value *mapBlockAddress(
const BlockAddress &BA);
186 std::optional<Metadata *> mapSimpleMetadata(
const Metadata *MD);
197 bool HasChanged =
false;
198 unsigned ID = std::numeric_limits<unsigned>::max();
199 TempMDNode Placeholder;
203 struct UniquedGraph {
204 SmallDenseMap<const Metadata *, Data, 32>
Info;
211 void propagateChanges();
221 SmallDenseMap<const Metadata *, Data, 32> InfoStorage;
225 MDNodeMapper(Mapper &M) :
M(
M) {}
267 Metadata *mapTopLevelUniquedNode(
const MDNode &FirstN);
278 std::optional<Metadata *> tryToMapOperand(
const Metadata *
Op);
287 MDNode *mapDistinctNode(
const MDNode &
N);
306 bool createPOT(UniquedGraph &
G,
const MDNode &FirstN);
327 void mapNodesInPOT(UniquedGraph &
G);
335 template <
class OperandMapper>
345 if (
I != getVM().
end()) {
346 assert(
I->second &&
"Unexpected null mapping");
351 if (
auto *Materializer = getMaterializer()) {
352 if (
Value *NewV = Materializer->materialize(
const_cast<Value *
>(V))) {
363 return getVM()[
V] =
const_cast<Value *
>(
V);
372 if (NewTy !=
IA->getFunctionType())
374 IA->hasSideEffects(),
IA->isAlignStack(),
375 IA->getDialect(),
IA->canThrow());
378 return getVM()[
V] =
const_cast<Value *
>(
V);
382 const Metadata *MD = MDV->getMetadata();
386 if (
Value *LV = mapValue(
LAM->getValue())) {
387 if (V ==
LAM->getValue())
388 return const_cast<Value *
>(
V);
401 for (
auto *VAM :
AL->getArgs()) {
409 }
else if (
Value *LV = mapValue(VAM->getValue())) {
427 return getVM()[
V] =
const_cast<Value *
>(
V);
430 auto *MappedMD = mapMetadata(MD);
432 return getVM()[
V] =
const_cast<Value *
>(
V);
443 return mapBlockAddress(*BA);
446 auto *Val = mapValue(
E->getGlobalValue());
452 Type *NewTy =
E->getType();
460 auto *Val = mapValue(
NC->getGlobalValue());
465 auto mapValueOrNull = [
this](
Value *
V) {
466 auto Mapped = mapValue(V);
468 "Unexpected null mapping for constant operand without "
469 "NullMapMissingGlobalValues flag");
475 unsigned OpNo = 0, NumOperands =
C->getNumOperands();
476 Value *Mapped =
nullptr;
477 for (; OpNo != NumOperands; ++OpNo) {
479 Mapped = mapValueOrNull(
Op);
487 Type *NewTy =
C->getType();
493 if (OpNo == NumOperands && NewTy ==
C->getType())
494 return getVM()[
V] =
C;
500 for (
unsigned j = 0;
j != OpNo; ++
j)
504 if (OpNo != NumOperands) {
508 for (++OpNo; OpNo != NumOperands; ++OpNo) {
509 Mapped = mapValueOrNull(
C->getOperand(OpNo));
515 Type *NewSrcTy =
nullptr;
518 NewSrcTy = TypeMapper->
remapType(GEPO->getSourceElementType());
521 return getVM()[
V] =
CE->getWithOperands(
Ops, NewTy,
false, NewSrcTy);
545void Mapper::remapDbgRecord(
DbgRecord &DR) {
558 auto *MappedVar = mapMetadata(
V.getVariable());
563 if (
V.isDbgAssign()) {
564 auto *NewAddr = mapValue(
V.getAddress());
565 if (!IgnoreMissingLocals && !NewAddr)
568 V.setAddress(NewAddr);
575 for (
Value *Val : Vals)
588 for (
unsigned int I = 0;
I < Vals.size(); ++
I)
590 V.replaceVariableLocationOp(
I, NewVals[
I]);
602 DelayedBBs.
push_back(DelayedBasicBlock(BA));
603 BB = DelayedBBs.
back().TempBB.get();
612 getVM().MD()[
Key].reset(Val);
617 return mapToMetadata(MD,
const_cast<Metadata *
>(MD));
620std::optional<Metadata *> MDNodeMapper::tryToMapOperand(
const Metadata *
Op) {
624 if (std::optional<Metadata *> MappedOp =
M.mapSimpleMetadata(
Op)) {
627 assert((!*MappedOp ||
M.getVM().count(CMD->getValue()) ||
628 M.getVM().getMappedMD(
Op)) &&
629 "Expected Value to be memoized");
632 "Expected result to be memoized");
639 return mapDistinctNode(
N);
644 assert(
N.isDistinct() &&
"Expected a distinct node");
645 assert(!
M.getVM().getMappedMD(&
N) &&
"Expected an unmapped node");
649 NewM =
M.mapToSelf(&
N);
653 <<
"To " << *NewM <<
"\n\n");
654 M.mapToMetadata(&
N, NewM);
658 return DistinctWorklist.back();
668std::optional<Metadata *> MDNodeMapper::getMappedOp(
const Metadata *
Op)
const {
672 if (std::optional<Metadata *> MappedOp =
M.getVM().getMappedMD(
Op))
685 auto Where =
Info.find(&
Op);
686 assert(Where !=
Info.end() &&
"Expected a valid reference");
688 auto &OpD = Where->second;
693 if (!OpD.Placeholder)
694 OpD.Placeholder =
Op.clone();
696 return *OpD.Placeholder;
699template <
class OperandMapper>
700void MDNodeMapper::remapOperands(
MDNode &
N, OperandMapper mapOperand) {
701 assert(!
N.isUniqued() &&
"Expected distinct or temporary nodes");
702 for (
unsigned I = 0,
E =
N.getNumOperands();
I !=
E; ++
I) {
706 LLVM_DEBUG(
dbgs() <<
"Replacing Op " << Old <<
" with " << New <<
" in "
710 N.replaceOperandWith(
I, New);
717struct POTWorklistEntry {
723 bool HasChanged =
false;
725 POTWorklistEntry(MDNode &
N) :
N(&
N),
Op(
N.op_begin()) {}
730bool MDNodeMapper::createPOT(UniquedGraph &
G,
const MDNode &FirstN) {
731 assert(
G.Info.empty() &&
"Expected a fresh traversal");
735 bool AnyChanges =
false;
738 (void)
G.Info[&FirstN];
739 while (!Worklist.
empty()) {
741 auto &WE = Worklist.
back();
742 if (
MDNode *
N = visitOperands(
G, WE.Op, WE.N->op_end(), WE.HasChanged)) {
749 assert(WE.N->isUniqued() &&
"Expected only uniqued nodes");
750 assert(WE.Op == WE.N->op_end() &&
"Expected to visit all operands");
751 auto &
D =
G.Info[WE.N];
752 AnyChanges |=
D.HasChanged = WE.HasChanged;
754 G.POT.push_back(WE.N);
766 if (std::optional<Metadata *> MappedOp = tryToMapOperand(
Op)) {
768 HasChanged |=
Op != *MappedOp;
775 "Only uniqued operands cannot be mapped immediately");
776 if (
G.Info.try_emplace(&OpN).second)
782void MDNodeMapper::UniquedGraph::propagateChanges() {
792 auto Where = Info.find(Op);
793 return Where != Info.end() && Where->second.HasChanged;
797 AnyChanges =
D.HasChanged =
true;
799 }
while (AnyChanges);
802void MDNodeMapper::mapNodesInPOT(UniquedGraph &
G) {
805 for (
auto *
N :
G.POT) {
814 bool HadPlaceholder(
D.Placeholder);
817 TempMDNode ClonedN =
D.Placeholder ? std::move(
D.Placeholder) :
N->clone();
819 if (std::optional<Metadata *> MappedOp =
getMappedOp(Old))
822 assert(
G.Info[Old].ID >
D.ID &&
"Expected a forward reference");
827 if (
N && NewN &&
N != NewN) {
829 <<
"To " << *NewN <<
"\n\n");
832 M.mapToMetadata(
N, NewN);
841 for (
auto *
N : CyclicNodes)
842 if (!
N->isResolved())
847 assert(DistinctWorklist.empty() &&
"MDNodeMapper::map is not recursive");
849 "MDNodeMapper::map assumes module-level changes");
852 assert(
N.isResolved() &&
"Unexpected unresolved node");
855 N.isUniqued() ? mapTopLevelUniquedNode(
N) : mapDistinctNode(
N);
856 while (!DistinctWorklist.empty())
858 if (std::optional<Metadata *> MappedOp = tryToMapOperand(Old))
860 return mapTopLevelUniquedNode(*cast<MDNode>(Old));
865Metadata *MDNodeMapper::mapTopLevelUniquedNode(
const MDNode &FirstN) {
870 if (!createPOT(
G, FirstN)) {
874 return &
const_cast<MDNode &
>(FirstN);
878 G.propagateChanges();
887std::optional<Metadata *> Mapper::mapSimpleMetadata(
const Metadata *MD) {
889 if (std::optional<Metadata *> NewMD = getVM().getMappedMD(MD))
911 if (IdentityMD && (*IdentityMD)(MD))
920 assert(MD &&
"Expected valid metadata");
923 if (std::optional<Metadata *> NewMD = mapSimpleMetadata(MD))
929void Mapper::flush() {
931 while (!Worklist.
empty()) {
933 CurrentMCID =
E.MCID;
935 case WorklistEntry::MapGlobalInit:
936 E.Data.GVInit.GV->setInitializer(mapConstant(
E.Data.GVInit.Init));
937 remapGlobalObjectMetadata(*
E.Data.GVInit.GV);
939 case WorklistEntry::MapAppendingVar: {
940 unsigned PrefixSize = AppendingInits.
size() -
E.AppendingGVNumNewMembers;
946 AppendingInits.
resize(PrefixSize);
947 mapAppendingVariable(*
E.Data.AppendingGV.GV,
948 E.Data.AppendingGV.OldGV,
949 E.AppendingGVIsOldCtorDtor,
ArrayRef(NewInits));
952 case WorklistEntry::MapAliasOrIFunc: {
963 case WorklistEntry::RemapFunction:
964 remapFunction(*
E.Data.RemapF);
972 while (!DelayedBBs.
empty()) {
975 DBB.TempBB->replaceAllUsesWith(BB ? BB : DBB.OldBB);
981 for (
Use &
Op :
I->operands()) {
988 "Referenced value not in value map!");
994 if (CB->getMetadata(LLVMContext::MD_callee_type) && !CB->isIndirectCall())
995 CB->setMetadata(LLVMContext::MD_callee_type,
nullptr);
1000 for (
unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) {
1001 Value *
V = mapValue(PN->getIncomingBlock(i));
1007 "Referenced block not in value map!");
1013 I->getAllMetadata(MDs);
1014 for (
const auto &
MI : MDs) {
1018 I->setMetadata(
MI.first, New);
1032 Tys.
reserve(FTy->getNumParams());
1033 for (
Type *Ty : FTy->params())
1036 TypeMapper->
remapType(
I->getType()), Tys, FTy->isVarArg()));
1039 AttributeList
Attrs = CB->getAttributes();
1040 for (
unsigned i = 0; i <
Attrs.getNumAttrSets(); ++i) {
1041 for (
int AttrIdx = Attribute::FirstTypeAttr;
1042 AttrIdx <= Attribute::LastTypeAttr; AttrIdx++) {
1045 Attrs.getAttributeAtIndex(i, TypedAttr).getValueAsType()) {
1046 Attrs =
Attrs.replaceAttributeTypeAtIndex(
C, i, TypedAttr,
1052 CB->setAttributes(Attrs);
1056 AI->setAllocatedType(TypeMapper->
remapType(AI->getAllocatedType()));
1058 GEP->setSourceElementType(
1060 GEP->setResultElementType(
1063 I->mutateType(TypeMapper->
remapType(
I->getType()));
1066void Mapper::remapGlobalObjectMetadata(
GlobalObject &GO) {
1070 for (
const auto &
I : MDs)
1074void Mapper::remapFunction(
Function &
F) {
1076 for (
Use &
Op :
F.operands())
1081 remapGlobalObjectMetadata(
F);
1091 remapInstruction(&
I);
1106 unsigned NumElements =
1108 for (
unsigned I = 0;
I != NumElements; ++
I)
1117 if (IsOldCtorDtor) {
1122 Type *Tys[3] = {
ST.getElementType(0),
ST.getElementType(1), VoidPtrTy};
1126 for (
auto *V : NewMembers) {
1128 if (IsOldCtorDtor) {
1146 assert(AlreadyScheduled.
insert(&GV).second &&
"Should not reschedule");
1150 WE.Kind = WorklistEntry::MapGlobalInit;
1152 WE.Data.GVInit.GV = &GV;
1153 WE.Data.GVInit.Init = &
Init;
1162 assert(AlreadyScheduled.
insert(&GV).second &&
"Should not reschedule");
1166 WE.Kind = WorklistEntry::MapAppendingVar;
1168 WE.Data.AppendingGV.GV = &GV;
1169 WE.Data.AppendingGV.OldGV = OldGV;
1170 WE.AppendingGVIsOldCtorDtor = IsOldCtorDtor;
1171 WE.AppendingGVNumNewMembers = NewMembers.
size();
1178 assert(AlreadyScheduled.
insert(&GV).second &&
"Should not reschedule");
1180 "Should be alias or ifunc");
1184 WE.Kind = WorklistEntry::MapAliasOrIFunc;
1186 WE.Data.AliasOrIFunc.GV = &GV;
1187 WE.Data.AliasOrIFunc.Target = &
Target;
1191void Mapper::scheduleRemapFunction(
Function &
F,
unsigned MCID) {
1192 assert(AlreadyScheduled.
insert(&
F).second &&
"Should not reschedule");
1196 WE.Kind = WorklistEntry::RemapFunction;
1198 WE.Data.RemapF = &
F;
1203 assert(!hasWorkToDo() &&
"Expected to have flushed the worklist");
1208 return reinterpret_cast<Mapper *
>(pImpl);
1213class FlushingMapper {
1217 explicit FlushingMapper(
void *pImpl) :
M(*
getAsMapper(pImpl)) {
1218 assert(!
M.hasWorkToDo() &&
"Expected to be flushed");
1221 ~FlushingMapper() {
M.flush(); }
1223 Mapper *operator->()
const {
return &
M; }
1232 : pImpl(new Mapper(VM, Flags, TypeMapper, Materializer, IdentityMD)) {}
1239 return getAsMapper(pImpl)->registerAlternateMappingContext(VM, Materializer);
1243 FlushingMapper(pImpl)->addFlags(Flags);
1247 return FlushingMapper(pImpl)->mapValue(&V);
1255 return FlushingMapper(pImpl)->mapMetadata(&MD);
1263 FlushingMapper(pImpl)->remapInstruction(&
I);
1267 FlushingMapper(pImpl)->remapDbgRecord(DR);
1278 FlushingMapper(pImpl)->remapFunction(
F);
1282 FlushingMapper(pImpl)->remapGlobalObjectMetadata(GO);
1297 GV, OldGV, IsOldCtorDtor, NewMembers,
MCID);
1319 auto AtomGroup =
DL->getAtomGroup();
1323 auto R = VM.
AtomMap.find({
DL->getInlinedAt(), AtomGroup});
1326 AtomGroup = R->second;
1330 I->getContext(),
DL.getLine(),
DL.getCol(),
DL.getScope(),
1331 DL.getInlinedAt(),
DL.isImplicitCode(), AtomGroup,
DL->getAtomRank());
1332 I->setDebugLoc(New);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static unsigned getMappedOp(unsigned PseudoOp)
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
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...
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
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 LLVM_ABI BlockAddress * get(Function *F, BasicBlock *BB)
Return a BlockAddress for the specified function and basic block.
static LLVM_ABI ConstantAggregateZero * get(Type *Ty)
static LLVM_ABI Constant * get(ArrayType *T, ArrayRef< Constant * > V)
A constant value that is initialized with an expression using other constant values.
static LLVM_ABI Constant * getBitCast(Constant *C, Type *Ty, bool OnlyIfReduced=false)
static LLVM_ABI ConstantPointerNull * get(PointerType *T)
Static factory methods - Return objects of the specified value.
static LLVM_ABI ConstantPtrAuth * get(Constant *Ptr, ConstantInt *Key, ConstantInt *Disc, Constant *AddrDisc, Constant *DeactivationSymbol)
Return a pointer signed with the specified parameters.
static LLVM_ABI Constant * get(StructType *T, ArrayRef< Constant * > V)
static LLVM_ABI Constant * get(ArrayRef< Constant * > V)
This is an important base class in LLVM.
static LLVM_ABI Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
LLVM_ABI Constant * getAggregateElement(unsigned Elt) const
For aggregates (struct/array/vector) return the constant that corresponds to the specified element if...
LLVM_ABI void destroyConstant()
Called if some element of this constant is no longer valid.
static LLVM_ABI DIArgList * get(LLVMContext &Context, ArrayRef< ValueAsMetadata * > Args)
static LLVM_ABI DSOLocalEquivalent * get(GlobalValue *GV)
Return a DSOLocalEquivalent for the specified global value.
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....
Class to represent function types.
static LLVM_ABI FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
LLVM_ABI void getAllMetadata(SmallVectorImpl< std::pair< unsigned, MDNode * > > &MDs) const
Appends all metadata attached to this value to MDs, sorting by KindID.
LLVM_ABI void addMetadata(unsigned KindID, MDNode &MD)
Add a metadata attachment.
LLVM_ABI void clearMetadata()
Erase all metadata attached to this Value.
LLVM_ABI bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
Type * getValueType() const
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
LLVM_ABI void setInitializer(Constant *InitVal)
setInitializer - Sets the initializer for this global variable, removing any existing initializer if ...
static LLVM_ABI 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 MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
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.
const MDOperand * op_iterator
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.
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
A Module instance is used to store all the information related to an LLVM module.
static LLVM_ABI NoCFIValue * get(GlobalValue *GV)
Return a NoCFIValue for the specified function.
Class to represent pointers.
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the default address space (address sp...
static LLVM_ABI 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 LLVM_ABI StructType * get(LLVMContext &Context, ArrayRef< Type * > Elements, bool isPacked=false)
This static method is the primary way to create a literal StructType.
Target - Wrapper for Target specific information.
Tracking metadata reference.
The instances of the Type class are immutable: once they are created, they are never changed.
static LLVM_ABI 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.
ValueMapIteratorImpl< MapT, const Value *, false > iterator
DMAtomT AtomMap
Map {(InlinedAt, old atom number) -> new atom number}.
LLVM_ABI void remapDbgRecord(Module *M, DbgRecord &V)
LLVM_ABI void remapDbgRecordRange(Module *M, iterator_range< DbgRecordIterator > Range)
LLVM_ABI MDNode * mapMDNode(const MDNode &N)
LLVM_ABI Metadata * mapMetadata(const Metadata &MD)
LLVM_ABI void remapInstruction(Instruction &I)
LLVM_ABI void scheduleMapGlobalInitializer(GlobalVariable &GV, Constant &Init, unsigned MappingContextID=0)
LLVM_ABI void scheduleRemapFunction(Function &F, unsigned MappingContextID=0)
LLVM_ABI ValueMapper(ValueToValueMapTy &VM, RemapFlags Flags=RF_None, ValueMapTypeRemapper *TypeMapper=nullptr, ValueMaterializer *Materializer=nullptr, const MetadataPredicate *IdentityMD=nullptr)
LLVM_ABI void scheduleMapGlobalIFunc(GlobalIFunc &GI, Constant &Resolver, unsigned MappingContextID=0)
LLVM_ABI unsigned registerAlternateMappingContext(ValueToValueMapTy &VM, ValueMaterializer *Materializer=nullptr)
Register an alternate mapping context.
LLVM_ABI void remapFunction(Function &F)
LLVM_ABI Constant * mapConstant(const Constant &C)
LLVM_ABI void scheduleMapGlobalAlias(GlobalAlias &GA, Constant &Aliasee, unsigned MappingContextID=0)
LLVM_ABI void remapGlobalObjectMetadata(GlobalObject &GO)
LLVM_ABI Value * mapValue(const Value &V)
LLVM_ABI void scheduleMapAppendingVariable(GlobalVariable &GV, GlobalVariable *OldGV, bool IsOldCtorDtor, ArrayRef< Constant * > NewMembers, unsigned MappingContextID=0)
LLVM_ABI 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.
bool hasUseList() const
Check if this Value has a use-list.
LLVM_ABI 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.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ C
The default llvm calling convention, compatible with C.
@ BasicBlock
Various leaf nodes.
@ CE
Windows NT (Windows on ARM)
NodeAddr< FuncNode * > Func
Context & getContext() const
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.
FunctionAddr VTableAddr Value
std::function< bool(const Metadata *)> MetadataPredicate
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
auto cast_or_null(const Y &Val)
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_DoNotRemapAtoms
Do not remap source location atoms.
@ RF_ReuseAndMutateDistinctMDs
Instruct the remapper to reuse and mutate distinct metadata (remapping them in place) instead of clon...
LLVM_ABI 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.
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
FunctionAddr VTableAddr uintptr_t uintptr_t Data
DWARFExpression::Operation Op
ArrayRef(const T &OneElt) -> ArrayRef< T >
ValueMap< const Value *, WeakTrackingVH > ValueToValueMapTy
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
void RemapFunction(Function &F, ValueToValueMapTy &VM, RemapFlags Flags=RF_None, ValueMapTypeRemapper *TypeMapper=nullptr, ValueMaterializer *Materializer=nullptr, const MetadataPredicate *IdentityMD=nullptr)
Remap the operands, metadata, arguments, and instructions of a function.
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
LLVM_ABI void RemapSourceAtom(Instruction *I, ValueToValueMapTy &VM)
Remap source location atom.