[cfe-dev] __attribute__ ((target("XXX"))) semantic in clang and gcc

David Blaikie via cfe-dev cfe-dev at lists.llvm.org
Tue Dec 8 09:38:58 PST 2015


Not exactly different, just limited - as the GCC wiki page mentions, GCC
supported (& continues to support) the target attribute
<https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-g_t_0040code_007btarget_007d-function-attribute-3220>
without the multiversioning feature. That's all that Clang has implemented
- you specify you want a certain function compiled for a certain
architecture/feature/etc, and then it's up to you how you dispatch to that
function to ensure that you only call it when running in the right
environment.

Implementing actual multiversioning (with the overloads, ifunc
relocations/stub generation, etc) is not implemented currently and while I
don't know of anyone who has plans to, it's certainly something that could
be done (ie: the project isn't philosophically opposed to the feature or
anything).

- Dave

On Tue, Dec 8, 2015 at 4:55 AM, Dmitry Polukhin via cfe-dev <
cfe-dev at lists.llvm.org> wrote:

> Hi All,
>
> Clang documentation claims that __attribute__ ((target("XXX"))) is
> supported in clang, see
> http://clang.llvm.org/docs/AttributeReference.html#target-gnu-target But
> the semantic of the attribute is significantly different in Clang and GCC
> (see GCC documentation https://gcc.gnu.org/wiki/FunctionMultiVersioning).
> In short Clang allows to specify target CPU for a single function but GCC
> allows to specify set of functions optimized for different CPUs and
> generates dynamic dispatching code. Is it intentional difference in the
> semantic of the attribute or it is just missing feature that needs to be
> implemented?
>
> --
> Best regards,
> Dmitry Polukhin
> Software Engineer
> Intel Compiler Team
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20151208/dcf206de/attachment.html>


More information about the cfe-dev mailing list