[llvm-branch-commits] [clang] [lld] [llvm] Reland "Compute GUIDs once and store in metadata" (#184065) (PR #201849)
Maksim Sabianin via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Jun 18 06:28:53 PDT 2026
================
@@ -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
More information about the llvm-branch-commits
mailing list