[llvm] 2384a6a - Remove IRLinker::linkNamedMDNodes() assert

Hans Wennborg via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 8 06:57:33 PDT 2025


Author: Hans Wennborg
Date: 2025-09-08T15:57:16+02:00
New Revision: 2384a6a29c18a5a3e3bf30811b528b8db433a4aa

URL: https://github.com/llvm/llvm-project/commit/2384a6a29c18a5a3e3bf30811b528b8db433a4aa
DIFF: https://github.com/llvm/llvm-project/commit/2384a6a29c18a5a3e3bf30811b528b8db433a4aa.diff

LOG: Remove IRLinker::linkNamedMDNodes() assert

It was added in #157045, but will fail if there are duplicated nodes in
DstM already, as illustrated by the test. See comments on the PR.

Added: 
    

Modified: 
    llvm/lib/Linker/IRMover.cpp
    llvm/test/ThinLTO/X86/Inputs/import-metadata.ll
    llvm/test/ThinLTO/X86/import-metadata.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Linker/IRMover.cpp b/llvm/lib/Linker/IRMover.cpp
index 489e03d5fdd60..1bff6cd25156d 100644
--- a/llvm/lib/Linker/IRMover.cpp
+++ b/llvm/lib/Linker/IRMover.cpp
@@ -1152,7 +1152,6 @@ void IRLinker::linkNamedMDNodes() {
       if (Inserted.insert(MD).second)
         DestNMD->addOperand(MD);
     }
-    assert(Inserted.size() == DestNMD->getNumOperands());
   }
 }
 

diff  --git a/llvm/test/ThinLTO/X86/Inputs/import-metadata.ll b/llvm/test/ThinLTO/X86/Inputs/import-metadata.ll
index bab5dacfcb797..fc69d278f5f41 100644
--- a/llvm/test/ThinLTO/X86/Inputs/import-metadata.ll
+++ b/llvm/test/ThinLTO/X86/Inputs/import-metadata.ll
@@ -15,9 +15,13 @@ entry:
 !llvm.module.flags = !{!2, !3}
 !llvm.md = !{!5}
 
+; IRLinker shouldn't assert about duplicated operands.
+!llvm.ident = !{!6, !6}
+
 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, enums: !4)
 !1 = !DIFile(filename: "foo.cpp", directory: "tmp")
 !2 = !{i32 2, !"Dwarf Version", i32 4}
 !3 = !{i32 2, !"Debug Info Version", i32 3}
 !4 = !{}
 !5 = !{!4}
+!6 = !{!"foo"}

diff  --git a/llvm/test/ThinLTO/X86/import-metadata.ll b/llvm/test/ThinLTO/X86/import-metadata.ll
index 7175fb6bb2715..cfd6c4b6eb002 100644
--- a/llvm/test/ThinLTO/X86/import-metadata.ll
+++ b/llvm/test/ThinLTO/X86/import-metadata.ll
@@ -33,9 +33,13 @@ define i32 @main() {
 !llvm.module.flags = !{!2, !3}
 !llvm.md = !{!5}
 
+; IRLinker shouldn't assert about duplicated operands.
+!llvm.ident = !{!6, !6}
+
 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, enums: !4)
 !1 = !DIFile(filename: "main.cpp", directory: "tmp")
 !2 = !{i32 2, !"Dwarf Version", i32 4}
 !3 = !{i32 2, !"Debug Info Version", i32 3}
 !4 = !{}
 !5 = !{!4}
+!6 = !{!"foo"}


        


More information about the llvm-commits mailing list