aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/IPO/MergeFunctions.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Transforms/IPO/MergeFunctions.cpp')
-rw-r--r--llvm/lib/Transforms/IPO/MergeFunctions.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/IPO/MergeFunctions.cpp b/llvm/lib/Transforms/IPO/MergeFunctions.cpp
index 05a3b16..b50a700 100644
--- a/llvm/lib/Transforms/IPO/MergeFunctions.cpp
+++ b/llvm/lib/Transforms/IPO/MergeFunctions.cpp
@@ -712,11 +712,13 @@ static bool canCreateThunkFor(Function *F) {
return true;
}
-/// Copy metadata from one function to another.
-static void copyMetadataIfPresent(Function *From, Function *To, StringRef Key) {
- if (MDNode *MD = From->getMetadata(Key)) {
- To->setMetadata(Key, MD);
- }
+/// Copy all metadata of a specific kind from one function to another.
+static void copyMetadataIfPresent(Function *From, Function *To,
+ StringRef Kind) {
+ SmallVector<MDNode *, 4> MDs;
+ From->getMetadata(Kind, MDs);
+ for (MDNode *MD : MDs)
+ To->addMetadata(Kind, *MD);
}
// Replace G with a simple tail call to bitcast(F). Also (unless