24 void ValueMapTypeRemapper::anchor() {}
25 void ValueMaterializer::anchor() {}
43 if (isa<GlobalValue>(V) || isa<MDString>(V))
44 return VM[V] =
const_cast<Value*
>(V);
46 if (
const InlineAsm *IA = dyn_cast<InlineAsm>(V)) {
50 NewTy = cast<FunctionType>(TypeMapper->
remapType(NewTy));
52 if (NewTy != IA->getFunctionType())
53 V =
InlineAsm::get(NewTy, IA->getAsmString(), IA->getConstraintString(),
54 IA->hasSideEffects(), IA->isAlignStack());
57 return VM[V] =
const_cast<Value*
>(V);
61 if (
const MDNode *MD = dyn_cast<MDNode>(V)) {
65 return VM[V] =
const_cast<Value*
>(V);
72 for (
unsigned i = 0, e = MD->getNumOperands(); i != e; ++i) {
74 if (OP == 0)
continue;
75 Value *Mapped_OP =
MapValue(OP, VM, Flags, TypeMapper, Materializer);
78 if (Mapped_OP == OP ||
84 Elts.
reserve(MD->getNumOperands());
85 for (i = 0; i != e; ++i) {
86 Value *Op = MD->getOperand(i);
90 Value *Mapped_Op =
MapValue(Op, VM, Flags, TypeMapper, Materializer);
93 if (Mapped_Op == 0 && (Flags & RF_IgnoreMissingEntries))
105 VM[V] =
const_cast<Value*
>(V);
109 return const_cast<Value*
>(V);
120 cast<Function>(
MapValue(BA->getFunction(), VM,
Flags, TypeMapper, Materializer));
122 Flags, TypeMapper, Materializer));
130 for (; OpNo != NumOperands; ++OpNo) {
132 Mapped =
MapValue(Op, VM, Flags, TypeMapper, Materializer);
133 if (Mapped != C)
break;
143 if (OpNo == NumOperands && NewTy == C->
getType())
150 for (
unsigned j = 0; j != OpNo; ++j)
154 if (OpNo != NumOperands) {
158 for (++OpNo; OpNo != NumOperands; ++OpNo)
160 Flags, TypeMapper, Materializer));
164 return VM[V] = CE->getWithOperands(Ops, NewTy);
165 if (isa<ConstantArray>(C))
167 if (isa<ConstantStruct>(C))
169 if (isa<ConstantVector>(C))
172 if (isa<UndefValue>(C))
174 if (isa<ConstantAggregateZero>(C))
176 assert(isa<ConstantPointerNull>(C));
188 Value *V =
MapValue(*op, VMap, Flags, TypeMapper, Materializer);
194 "Referenced value not in value map!");
198 if (
PHINode *PN = dyn_cast<PHINode>(I)) {
199 for (
unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) {
203 PN->setIncomingBlock(i, cast<BasicBlock>(V));
206 "Referenced block not in value map!");
216 MDNode *New =
MapValue(Old, VMap, Flags, TypeMapper, Materializer);
void push_back(const T &Elt)
static void deleteTemporary(MDNode *N)
static MDNode * getTemporary(LLVMContext &Context, ArrayRef< Value * > Vals)
enable_if_c<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
unsigned getNumOperands() const
static ConstantAggregateZero * get(Type *Ty)
MDNode - a tuple of other values.
void RemapInstruction(Instruction *I, ValueToValueMapTy &VM, RemapFlags Flags=RF_None, ValueMapTypeRemapper *TypeMapper=0, ValueMaterializer *Materializer=0)
Value * MapValue(const Value *V, ValueToValueMapTy &VM, RemapFlags Flags=RF_None, ValueMapTypeRemapper *TypeMapper=0, ValueMaterializer *Materializer=0)
static MDNode * get(LLVMContext &Context, ArrayRef< Value * > Vals)
static Constant * get(ArrayRef< Constant * > V)
iterator find(const KeyT &Val)
void replaceAllUsesWith(Value *V)
void getAllMetadata(SmallVectorImpl< std::pair< unsigned, MDNode * > > &MDs) const
* if(!EatIfPresent(lltok::kw_thread_local)) return false
static ConstantPointerNull * get(PointerType *T)
get() - Static factory methods - Return objects of the specified value
LLVM Basic Block Representation.
static BlockAddress * get(Function *F, BasicBlock *BB)
get - Return a BlockAddress for the specified function and basic block.
LLVM Constant Representation.
static Constant * get(ArrayType *T, ArrayRef< Constant * > V)
Value * getOperand(unsigned i) const
static Constant * get(StructType *T, ArrayRef< Constant * > V)
virtual Value * materializeValueFor(Value *V)=0
static UndefValue * get(Type *T)
RemapFlags
RemapFlags - These are flags that the value mapping APIs allow.
LLVMContext & getContext() const
All values hold a context through their type.
void setMetadata(unsigned KindID, MDNode *Node)
static InlineAsm * get(FunctionType *Ty, StringRef AsmString, StringRef Constraints, bool hasSideEffects, bool isAlignStack=false, AsmDialect asmDialect=AD_ATT)
void mutateType(Type *Ty)
LLVM Value Representation.
virtual Type * remapType(Type *SrcTy)=0