[llvm] [ThinLTO] Do not duplicate import a function that is actually defined in the current module (PR #110064)

William Junda Huang via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 10 19:22:39 PDT 2024


================
@@ -0,0 +1,87 @@
+; https://github.com/llvm/llvm-project/pull/110064
+; This test case checks if thinLTO correctly links metadata values in a specific
+; situation. Assume we are linking module B into module A, where an extern
+; function used in A is defined in B, but the function body has a
+; DITemplateValueParameter referring to another function back in A. The
+; compiler must check this other function is actually coming from A, thus
+; already materialized and does not require remapping. The IR here is modified
+; from the following source code.
+;
+; // A.h
+; template <void (*Func)()>
+; struct S {
+;   void Impl() {
+;     Func();
+;   }
+; };
+;
+; void func1();
+;
+; // A.cpp
+; #include "A.h"
+; __attribute__((weak)) void func1() {}
+; extern void thinlto1();
+; void bar() {
+;   S<func1> s; // Force instantiation of S<func1> in this compilation unit.
+;   s.Impl();
+;   thinlto1();
+; }
+;
+; // B.cpp
+; #include "A.h"
+; void thinlto1() {
+;   S<func1> s;
+; }
+;
+; RUN: opt -module-summary -o %t1.bc %s
+; RUN: opt -module-summary -o %t2.bc %S/Inputs/ditemplatevalueparameter-remap.ll
+; RUN: ld.lld --plugin-opt=thinlto-index-only -shared %t1.bc %t2.bc
----------------
huangjd wrote:

I fixed the test case and this is the new pr https://github.com/llvm/llvm-project/pull/111933 
Is there a way to "dry run" a patch on all llvm build bots before actually submitting something? 

https://github.com/llvm/llvm-project/pull/110064


More information about the llvm-commits mailing list