[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 3 21:29:51 PDT 2024


huangjd wrote:

It also possibly reveals another bug (not related, won't cause immediate trouble). If there is a template with function pointer parameter, and there's an instantiation of the template but the function used is not defined, then the optimizer could do away the metadata info for the template parameter, so we will ended up non-identical metadata type nodes with the same name in different modules.

```
template <void (*Func)()>
struct S {
  void Impl() {
    Func();
  }
};

void func1();
```


```!18 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S<&func1>", file: !11, line: 2, size: 8, flags: DIFlagTypePassByValue, elements: !19, templateParams: !20, identifier: "_ZTS1SIXadL_Z5func1vEEE")
!19 = !{}
!20 = !{!21}
!21 = !DITemplateValueParameter(name: "Func", type: !22, value: ptr @_Z5func1v)```

If `func1` is not defined in the current module, then the value in `!21` could be optimized away and becomes `undef`, not sure if this is the correct behavior 








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


More information about the llvm-commits mailing list