[llvm] [ThinLTO] Do not duplicate import a function that is actually defined in the current module #110064 (PR #111933)
Teresa Johnson via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 10 20:28:19 PDT 2024
================
@@ -0,0 +1,92 @@
+; 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: llvm-lto2 run %t1.bc %t2.bc -o %t3.o -save-temps \
----------------
teresajohnson wrote:
As written this will invoke in-process, not distributed, ThinLTO. Which if it reproduces the original failure without your fix is good enough and probably easiest (and you can remove your clang invocation below completely instead of changing it to opt like I suggest there). For distributed thinlto you need to add -thinlto-distributed-indexes. I'm not sure how the test worked without that but maybe the index.bc file used by the clang invocation below was hanging around from a prior invocation when you were using lld?
https://github.com/llvm/llvm-project/pull/111933
More information about the llvm-commits
mailing list