#include "llvm/Transforms/Utils/ValueMapper.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/IR/Argument.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Constant.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GlobalAlias.h"
#include "llvm/IR/GlobalIFunc.h"
#include "llvm/IR/GlobalObject.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/InlineAsm.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Metadata.h"
#include "llvm/IR/Operator.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/Value.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Debug.h"
#include <cassert>
#include <limits>
#include <memory>
#include <utility>
usingnamespacellvm;
#define DEBUG_TYPE …
void ValueMapTypeRemapper::anchor() { … }
void ValueMaterializer::anchor() { … }
namespace {
struct DelayedBasicBlock { … };
struct WorklistEntry { … };
struct MappingContext { … };
class Mapper { … };
class MDNodeMapper { … };
}
Value *Mapper::mapValue(const Value *V) { … }
void Mapper::remapDbgRecord(DbgRecord &DR) { … }
Value *Mapper::mapBlockAddress(const BlockAddress &BA) { … }
Metadata *Mapper::mapToMetadata(const Metadata *Key, Metadata *Val) { … }
Metadata *Mapper::mapToSelf(const Metadata *MD) { … }
std::optional<Metadata *> MDNodeMapper::tryToMapOperand(const Metadata *Op) { … }
MDNode *MDNodeMapper::mapDistinctNode(const MDNode &N) { … }
static ConstantAsMetadata *wrapConstantAsMetadata(const ConstantAsMetadata &CMD,
Value *MappedV) { … }
std::optional<Metadata *> MDNodeMapper::getMappedOp(const Metadata *Op) const { … }
Metadata &MDNodeMapper::UniquedGraph::getFwdReference(MDNode &Op) { … }
template <class OperandMapper>
void MDNodeMapper::remapOperands(MDNode &N, OperandMapper mapOperand) { … }
namespace {
struct POTWorklistEntry { … };
}
bool MDNodeMapper::createPOT(UniquedGraph &G, const MDNode &FirstN) { … }
MDNode *MDNodeMapper::visitOperands(UniquedGraph &G, MDNode::op_iterator &I,
MDNode::op_iterator E, bool &HasChanged) { … }
void MDNodeMapper::UniquedGraph::propagateChanges() { … }
void MDNodeMapper::mapNodesInPOT(UniquedGraph &G) { … }
Metadata *MDNodeMapper::map(const MDNode &N) { … }
Metadata *MDNodeMapper::mapTopLevelUniquedNode(const MDNode &FirstN) { … }
std::optional<Metadata *> Mapper::mapSimpleMetadata(const Metadata *MD) { … }
Metadata *Mapper::mapMetadata(const Metadata *MD) { … }
void Mapper::flush() { … }
void Mapper::remapInstruction(Instruction *I) { … }
void Mapper::remapGlobalObjectMetadata(GlobalObject &GO) { … }
void Mapper::remapFunction(Function &F) { … }
void Mapper::mapAppendingVariable(GlobalVariable &GV, Constant *InitPrefix,
bool IsOldCtorDtor,
ArrayRef<Constant *> NewMembers) { … }
void Mapper::scheduleMapGlobalInitializer(GlobalVariable &GV, Constant &Init,
unsigned MCID) { … }
void Mapper::scheduleMapAppendingVariable(GlobalVariable &GV,
Constant *InitPrefix,
bool IsOldCtorDtor,
ArrayRef<Constant *> NewMembers,
unsigned MCID) { … }
void Mapper::scheduleMapAliasOrIFunc(GlobalValue &GV, Constant &Target,
unsigned MCID) { … }
void Mapper::scheduleRemapFunction(Function &F, unsigned MCID) { … }
void Mapper::addFlags(RemapFlags Flags) { … }
static Mapper *getAsMapper(void *pImpl) { … }
namespace {
class FlushingMapper { … };
}
ValueMapper::ValueMapper(ValueToValueMapTy &VM, RemapFlags Flags,
ValueMapTypeRemapper *TypeMapper,
ValueMaterializer *Materializer)
: … { … }
ValueMapper::~ValueMapper() { … }
unsigned
ValueMapper::registerAlternateMappingContext(ValueToValueMapTy &VM,
ValueMaterializer *Materializer) { … }
void ValueMapper::addFlags(RemapFlags Flags) { … }
Value *ValueMapper::mapValue(const Value &V) { … }
Constant *ValueMapper::mapConstant(const Constant &C) { … }
Metadata *ValueMapper::mapMetadata(const Metadata &MD) { … }
MDNode *ValueMapper::mapMDNode(const MDNode &N) { … }
void ValueMapper::remapInstruction(Instruction &I) { … }
void ValueMapper::remapDbgRecord(Module *M, DbgRecord &DR) { … }
void ValueMapper::remapDbgRecordRange(
Module *M, iterator_range<DbgRecord::self_iterator> Range) { … }
void ValueMapper::remapFunction(Function &F) { … }
void ValueMapper::remapGlobalObjectMetadata(GlobalObject &GO) { … }
void ValueMapper::scheduleMapGlobalInitializer(GlobalVariable &GV,
Constant &Init,
unsigned MCID) { … }
void ValueMapper::scheduleMapAppendingVariable(GlobalVariable &GV,
Constant *InitPrefix,
bool IsOldCtorDtor,
ArrayRef<Constant *> NewMembers,
unsigned MCID) { … }
void ValueMapper::scheduleMapGlobalAlias(GlobalAlias &GA, Constant &Aliasee,
unsigned MCID) { … }
void ValueMapper::scheduleMapGlobalIFunc(GlobalIFunc &GI, Constant &Resolver,
unsigned MCID) { … }
void ValueMapper::scheduleRemapFunction(Function &F, unsigned MCID) { … }