[clang-tools-extra] [llvm] [clang] [Clang] Fix linker error for function multiversioning (PR #71706)

via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 1 09:31:56 PST 2023


elizabethandrews wrote:

> > I requested some minor changes.
> > Can we document the `.ifunc` symbols as a deprecated feature? With this change, they will never be referenced except by code compiled by older compiler versions. Maybe plan to deprecate them a year from now?
> 
> How/where do I document this?
> 
> > It looks like there is a related issue in which multiple ifunc symbols are emitted for the `cpu_dispatch` attribute. See https://godbolt.org/z/71vr8ceza. The relevant symbols emitted are listed below. Note that both `_Z12cpu_specificv` and `_Z12cpu_specificv.ifunc` are "i" symbols with the same address. The caller in this case calls the `.ifunc` symbol (just as for `target_clones` prior to this change). It would be nice if we can fix this issue at the same time and likewise deprecate the `.ifunc` symbol for `cpu_dispatch`/`cpu_specific`.
> > ```
> > 00000000000024c0 i _Z12cpu_specificv
> > 0000000000002480 T _Z12cpu_specificv.A
> > 0000000000002490 T _Z12cpu_specificv.M
> > 00000000000024c0 i _Z12cpu_specificv.ifunc
> > 00000000000024c0 W _Z12cpu_specificv.resolver
> > ```
> > 
> > 
> >     
> >       
> >     
> > 
> >       
> >     
> > 
> >     
> >   
> > I think the only time a symbol with a `.ifunc` suffix is actually needed is when the `target` attribute is used in an overloading context (since in that situation, the `target(default)` definition gets the non-suffixed name.
> 
> The symbols correspond to the ifunc and it's alias. Mangling rules seem to vary between different MV attributes. For example - for `target` attribute, the default versions do not include a `.default` suffix. I do not know what the mangling requirements for `cpu_dispatch` are off the top of my head. I do not think we should change it to match `target_clones` attribute without confirming this is the correct behavior for this attribute.

@tahonermann as discussed offline, I documented the deprecation in attribute documentation. I wasn't 100% certain of what to say, so please feel free to wordsmith! As also discussed, I will make changes to `cpu_dispatch` in a follow-up PR.

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


More information about the cfe-commits mailing list