diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2016-04-08 19:09:34 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2016-04-08 19:09:34 +0000 |
commit | a574e7a7a4fe727d315685ab4e67d02cf6e76471 (patch) | |
tree | 0141972324ee3fc704cc6525cafd51b24f555e9f /llvm/lib/Transforms/Utils/ValueMapper.cpp | |
parent | fe6583a0a66ca64125df0b6a59855bb08d9c6591 (diff) | |
download | llvm-a574e7a7a4fe727d315685ab4e67d02cf6e76471.zip llvm-a574e7a7a4fe727d315685ab4e67d02cf6e76471.tar.gz llvm-a574e7a7a4fe727d315685ab4e67d02cf6e76471.tar.bz2 |
ValueMapper: Roll RemapInstruction into Mapper, NFC
Add Mapper::remapInstruction, move the guts of llvm::RemapInstruction
into it, and use the same Mapper for most of the calls to MapValue and
MapMetadata. There should be no functionality change here.
I left off the call to MapValue that wasn't passing in a Materializer
argument (for basic blocks of PHINodes). It shouldn't change
functionality either, but I'm suspicious enough to commit separately.
llvm-svn: 265832
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 472c2ca..ffd3a27 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); } |