[PATCH] D138833: [llvm_stats] Do not import llvm.stats metadata for thinlto

Lei Wang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 28 16:47:41 PST 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rGef0cb372dc80: [llvm_stats] Do not import llvm.stats metadata for thinlto (authored by wlei).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138833/new/

https://reviews.llvm.org/D138833

Files:
  llvm/lib/Linker/IRMover.cpp
  llvm/test/ThinLTO/X86/Inputs/llvm-stats-import.ll
  llvm/test/ThinLTO/X86/llvm-stats-import.ll


Index: llvm/test/ThinLTO/X86/llvm-stats-import.ll
===================================================================
--- /dev/null
+++ llvm/test/ThinLTO/X86/llvm-stats-import.ll
@@ -0,0 +1,28 @@
+; RUN: opt -module-summary %s -o %t1.bc
+; RUN: opt -module-summary %p/Inputs/llvm-stats-import.ll -o %t2.bc
+; RUN: llvm-lto -thinlto-action=thinlink -o %t.index.bc %t1.bc %t2.bc
+
+; RUN: llvm-lto -thinlto-action=import %t1.bc -thinlto-index=%t.index.bc -o - | llvm-dis -o - | FileCheck %s --check-prefix=CHECK-MAIN
+; RUN: llvm-lto -thinlto-action=import %t2.bc -thinlto-index=%t.index.bc -o - | llvm-dis -o - | FileCheck %s --check-prefix=CHECK-FOO
+
+; CHECK-MAIN: !0 = !{!"main", i64 123}
+; CHECK-MAIN-NOT: !{!"foo", i64 456}
+
+; CHECK-FOO: !0 = !{!"foo", i64 456}
+; CHECK-FOO-NOT: !{!"main", i64 123}
+
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define i32 @main() {
+entry:
+  call void (...) @foo()
+  ret i32 0
+}
+
+declare void @foo(...)
+
+attributes #0 = { inaccessiblememonly nounwind willreturn }
+
+!llvm.stats = !{!0}
+!0 = !{!"main", i64 123}
Index: llvm/test/ThinLTO/X86/Inputs/llvm-stats-import.ll
===================================================================
--- /dev/null
+++ llvm/test/ThinLTO/X86/Inputs/llvm-stats-import.ll
@@ -0,0 +1,12 @@
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define void @foo() {
+entry:
+  ret void
+}
+
+attributes #0 = { inaccessiblememonly nounwind willreturn }
+
+!llvm.stats = !{!0}
+!0 = !{!"foo", i64 456}
Index: llvm/lib/Linker/IRMover.cpp
===================================================================
--- llvm/lib/Linker/IRMover.cpp
+++ llvm/lib/Linker/IRMover.cpp
@@ -1244,6 +1244,11 @@
                     DstM.getModuleIdentifier() + "' is not\n");
       continue;
     }
+    // The stats are computed per module and will all be merged in the binary.
+    // Importing the metadata will cause duplication of the stats.
+    if (IsPerformingImport && NMD.getName() == "llvm.stats")
+      continue;
+
     NamedMDNode *DestNMD = DstM.getOrInsertNamedMetadata(NMD.getName());
     // Add Src elements into Dest node.
     for (const MDNode *Op : NMD.operands())


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D138833.478418.patch
Type: text/x-patch
Size: 2334 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221129/b2cfc183/attachment.bin>


More information about the llvm-commits mailing list