diff options
Diffstat (limited to 'llvm/lib/Transforms/Utils/ValueMapper.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/ValueMapper.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/llvm/lib/Transforms/Utils/ValueMapper.cpp b/llvm/lib/Transforms/Utils/ValueMapper.cpp index 472c2cab26d..ffd3a274cde 100644 --- a/llvm/lib/Transforms/Utils/ValueMapper.cpp +++ b/llvm/lib/Transforms/Utils/ValueMapper.cpp @@ -79,6 +79,7 @@ public: ~Mapper(); Value *mapValue(const Value *V); + void remapInstruction(Instruction *I); /// Map metadata. /// @@ -735,15 +736,16 @@ MDNode *llvm::MapMetadata(const MDNode *MD, ValueToValueMapTy &VM, Flags, TypeMapper, Materializer)); } -/// RemapInstruction - Convert the instruction operands from referencing the -/// current values into those specified by VMap. -/// -void llvm::RemapInstruction(Instruction *I, ValueToValueMapTy &VMap, +void llvm::RemapInstruction(Instruction *I, ValueToValueMapTy &VM, RemapFlags Flags, ValueMapTypeRemapper *TypeMapper, - ValueMaterializer *Materializer){ + ValueMaterializer *Materializer) { + Mapper(VM, Flags, TypeMapper, Materializer).remapInstruction(I); +} + +void Mapper::remapInstruction(Instruction *I) { // Remap operands. for (User::op_iterator op = I->op_begin(), E = I->op_end(); op != E; ++op) { - Value *V = MapValue(*op, VMap, Flags, TypeMapper, Materializer); + Value *V = mapValue(*op); // If we aren't ignoring missing entries, assert that something happened. if (V) *op = V; @@ -755,7 +757,8 @@ void llvm::RemapInstruction(Instruction *I, ValueToValueMapTy &VMap, // Remap phi nodes' incoming blocks. if (PHINode *PN = dyn_cast<PHINode>(I)) { for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) { - Value *V = MapValue(PN->getIncomingBlock(i), VMap, Flags); + // FIXME: Use Mapper::mapValue (but note the missing Materializer flag). + Value *V = MapValue(PN->getIncomingBlock(i), VM, Flags); // If we aren't ignoring missing entries, assert that something happened. if (V) PN->setIncomingBlock(i, cast<BasicBlock>(V)); @@ -770,7 +773,7 @@ void llvm::RemapInstruction(Instruction *I, ValueToValueMapTy &VMap, I->getAllMetadata(MDs); for (const auto &MI : MDs) { MDNode *Old = MI.second; - MDNode *New = MapMetadata(Old, VMap, Flags, TypeMapper, Materializer); + MDNode *New = cast_or_null<MDNode>(mapMetadata(Old)); if (New != Old) I->setMetadata(MI.first, New); } |