
GCC's attribute 'target', in addition to being an optimization hint, also allows function multiversioning. We currently have the former implemented, this is the latter's implementation. This works by enabling functions with the same name/signature to coexist, so that they can all be emitted. Multiversion state is stored in the FunctionDecl itself, and SemaDecl manages the definitions. Note that it ends up having to permit redefinition of functions so that they can all be emitted. Additionally, all versions of the function must be emitted, so this also manages that. Note that this includes some additional rules that GCC does not, since defining something as a MultiVersion function after a usage has been made illegal. The only 'history rewriting' that happens is if a function is emitted before it has been converted to a multiversion'ed function, at which point its name needs to be changed. Function templates and virtual functions are NOT yet supported (not supported in GCC either). Additionally, constructors/destructors are disallowed, but the former is planned. llvm-svn: 322028
11 lines
565 B
C
11 lines
565 B
C
// RUN: %clang_cc1 -triple x86_64-windows-pc -fsyntax-only -verify %s
|
|
// RUN: %clang_cc1 -triple arm-none-eabi -fsyntax-only -verify %s
|
|
|
|
int __attribute__((target("sse4.2"))) redecl1(void) { return 1; }
|
|
//expected-error@+2 {{function multiversioning is not supported on the current target}}
|
|
//expected-note@-2 {{previous declaration is here}}
|
|
int __attribute__((target("avx"))) redecl1(void) { return 2; }
|
|
|
|
//expected-error@+1 {{function multiversioning is not supported on the current target}}
|
|
int __attribute__((target("default"))) with_def(void) { return 1;}
|