summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Linker
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2016-04-08 19:26:32 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2016-04-08 19:26:32 +0000
commitbb2c3e199e9e95ff7b07efb084b94960b76e6556 (patch)
tree7e6d08809e93196a4fd04919e4b32ec6fb828db2 /llvm/lib/Linker
parent41725a1e7a1666374a5f63b837d7c22fe503ba22 (diff)
downloadbcm5719-llvm-bb2c3e199e9e95ff7b07efb084b94960b76e6556.tar.gz
bcm5719-llvm-bb2c3e199e9e95ff7b07efb084b94960b76e6556.zip
ValueMapper: Extract llvm::RemapFunction from IRMover.cpp, NFC
Strip out the remapping parts of IRLinker::linkFunctionBody and put them in ValueMapper.cpp under the name Mapper::remapFunction (with a top-level entry-point llvm::RemapFunction). This is a nice cleanup on its own since it puts the remapping code together and shares a single Mapper context for the entire IRLinker::linkFunctionBody Call. Besides that, this will make it easier to break the co-recursion between IRMover.cpp and ValueMapper.cpp in follow ups. llvm-svn: 265835
Diffstat (limited to 'llvm/lib/Linker')
-rw-r--r--llvm/lib/Linker/IRMover.cpp33
1 files changed, 8 insertions, 25 deletions
diff --git a/llvm/lib/Linker/IRMover.cpp b/llvm/lib/Linker/IRMover.cpp
index 3c27b82739f..eaa95e67045 100644
--- a/llvm/lib/Linker/IRMover.cpp
+++ b/llvm/lib/Linker/IRMover.cpp
@@ -963,43 +963,26 @@ bool IRLinker::linkFunctionBody(Function &Dst, Function &Src) {
if (std::error_code EC = Src.materialize())
return emitError(EC.message());
- // Link in the prefix data.
+ // Link in the operands without remapping.
if (Src.hasPrefixData())
- Dst.setPrefixData(MapValue(Src.getPrefixData(), ValueMap, ValueMapperFlags,
- &TypeMap, &GValMaterializer));
-
- // Link in the prologue data.
+ Dst.setPrefixData(Src.getPrefixData());
if (Src.hasPrologueData())
- Dst.setPrologueData(MapValue(Src.getPrologueData(), ValueMap,
- ValueMapperFlags, &TypeMap,
- &GValMaterializer));
-
- // Link in the personality function.
+ Dst.setPrologueData(Src.getPrologueData());
if (Src.hasPersonalityFn())
- Dst.setPersonalityFn(MapValue(Src.getPersonalityFn(), ValueMap,
- ValueMapperFlags, &TypeMap,
- &GValMaterializer));
+ Dst.setPersonalityFn(Src.getPersonalityFn());
- // Copy over the metadata attachments.
+ // Copy over the metadata attachments without remapping.
SmallVector<std::pair<unsigned, MDNode *>, 8> MDs;
Src.getAllMetadata(MDs);
for (const auto &I : MDs)
- Dst.setMetadata(I.first, MapMetadata(I.second, ValueMap, ValueMapperFlags,
- &TypeMap, &GValMaterializer));
+ Dst.setMetadata(I.first, I.second);
// Steal arguments and splice the body of Src into Dst.
Dst.stealArgumentListFrom(Src);
Dst.getBasicBlockList().splice(Dst.end(), Src.getBasicBlockList());
- // At this point, everything has been moved over, but the types and non-local
- // operands will be wrong. Loop through everything and patch it up.
- for (Argument &A : Dst.args())
- A.mutateType(TypeMap.get(A.getType()));
- for (BasicBlock &BB : Dst)
- for (Instruction &I : BB)
- RemapInstruction(&I, ValueMap, ValueMapperFlags, &TypeMap,
- &GValMaterializer);
-
+ // Everything has been moved over. Remap it.
+ RemapFunction(Dst, ValueMap, ValueMapperFlags, &TypeMap, &GValMaterializer);
return false;
}
OpenPOWER on IntegriCloud