Linker: Copy over function metadata attachments

Update `lib/Linker` to handle `Function` metadata attachments.  The
attachments stick with the function body.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235786 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Duncan P. N. Exon Smith
2015-04-24 22:07:31 +00:00
parent ae3211466a
commit 8efc190690
3 changed files with 46 additions and 0 deletions

View File

@@ -1205,6 +1205,13 @@ bool ModuleLinker::linkFunctionBody(Function &Dst, Function &Src) {
++DI;
}
// Copy over the metadata attachments.
SmallVector<std::pair<unsigned, MDNode *>, 8> MDs;
Src.getAllMetadata(MDs);
for (const auto &I : MDs)
Dst.setMetadata(I.first, MapMetadata(I.second, ValueMap, RF_None, &TypeMap,
&ValMaterializer));
// Splice the body of the source function into the dest function.
Dst.getBasicBlockList().splice(Dst.end(), Src.getBasicBlockList());