================
@@ -141,17 +141,21 @@ std::unique_ptr<Module> llvm::CloneModule(
   for (const Function &I : M) {
     Function *F = cast<Function>(VMap[&I]);
 
-    if (I.isDeclaration()) {
+    auto CopyMD = [&]() {
       // Copy over metadata for declarations since we're not doing it below in
       // CloneFunctionInto().
       SmallVector<std::pair<unsigned, MDNode *>, 1> MDs;
       I.getAllMetadata(MDs);
       for (auto MD : MDs)
         F->addMetadata(MD.first, *MapMetadata(MD.second, VMap));
+    };
+    if (I.isDeclaration()) {
+      CopyMD();
       continue;
     }
 
     if (!ShouldCloneDefinition(&I)) {
+      CopyMD();
----------------
maksimsab wrote:

Doesn't this line create a blowup of unnecessary copies?

https://github.com/llvm/llvm-project/pull/201849
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to