2021-11-29 06:28:02 -08:00
|
|
|
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -verify %s
|
|
|
|
|
|
|
|
// expected-error@+1 {{'target_clones' multiversioning requires a default target}}
|
|
|
|
void __attribute__((target_clones("sse4.2", "arch=sandybridge")))
|
|
|
|
no_default(void);
|
|
|
|
|
|
|
|
// expected-error@+2 {{'target_clones' and 'target' attributes are not compatible}}
|
|
|
|
// expected-note@+1 {{conflicting attribute is here}}
|
|
|
|
void __attribute__((target("sse4.2"), target_clones("arch=sandybridge")))
|
|
|
|
ignored_attr(void);
|
|
|
|
// expected-error@+2 {{'target' and 'target_clones' attributes are not compatible}}
|
|
|
|
// expected-note@+1 {{conflicting attribute is here}}
|
|
|
|
void __attribute__((target_clones("arch=sandybridge,default"), target("sse4.2")))
|
|
|
|
ignored_attr2(void);
|
|
|
|
|
|
|
|
int redecl(void);
|
|
|
|
int __attribute__((target_clones("sse4.2", "default"))) redecl(void) { return 1; }
|
|
|
|
|
|
|
|
int __attribute__((target_clones("sse4.2", "default"))) redecl2(void);
|
|
|
|
int __attribute__((target_clones("sse4.2", "default"))) redecl2(void) { return 1; }
|
|
|
|
|
|
|
|
int __attribute__((target_clones("sse4.2", "default"))) redecl3(void);
|
|
|
|
int redecl3(void);
|
|
|
|
|
|
|
|
int __attribute__((target_clones("sse4.2", "arch=atom", "default"))) redecl4(void);
|
|
|
|
// expected-error@+3 {{'target_clones' attribute does not match previous declaration}}
|
|
|
|
// expected-note@-2 {{previous declaration is here}}
|
|
|
|
int __attribute__((target_clones("sse4.2", "arch=sandybridge", "default")))
|
|
|
|
redecl4(void) { return 1; }
|
|
|
|
|
|
|
|
int __attribute__((target("sse4.2"))) redef2(void) { return 1; }
|
|
|
|
// expected-error@+2 {{multiversioning attributes cannot be combined}}
|
|
|
|
// expected-note@-2 {{previous declaration is here}}
|
|
|
|
int __attribute__((target_clones("sse4.2", "default"))) redef2(void) { return 1; }
|
|
|
|
|
|
|
|
int __attribute__((target_clones("sse4.2,default"))) redef3(void) { return 1; }
|
|
|
|
// expected-error@+2 {{redefinition of 'redef3'}}
|
|
|
|
// expected-note@-2 {{previous definition is here}}
|
|
|
|
int __attribute__((target_clones("sse4.2,default"))) redef3(void) { return 1; }
|
|
|
|
|
|
|
|
int __attribute__((target_clones("sse4.2,default"))) redef4(void) { return 1; }
|
|
|
|
// expected-error@+2 {{redefinition of 'redef4'}}
|
|
|
|
// expected-note@-2 {{previous definition is here}}
|
|
|
|
int __attribute__((target_clones("sse4.2,default"))) redef4(void) { return 1; }
|
|
|
|
|
|
|
|
// Duplicates are allowed, however they alter name mangling.
|
|
|
|
// expected-warning@+2 {{mixing 'target_clones' specifier mechanisms is permitted for GCC compatibility}}
|
|
|
|
// expected-warning@+1 2 {{version list contains duplicate entries}}
|
|
|
|
int __attribute__((target_clones("arch=atom,arch=atom", "arch=atom,default")))
|
|
|
|
dupes(void) { return 1; }
|
|
|
|
|
|
|
|
// expected-warning@+1 {{unsupported '' in the 'target_clones' attribute string;}}
|
|
|
|
void __attribute__((target_clones("")))
|
|
|
|
empty_target_1(void);
|
|
|
|
// expected-warning@+1 {{unsupported '' in the 'target_clones' attribute string;}}
|
|
|
|
void __attribute__((target_clones(",default")))
|
|
|
|
empty_target_2(void);
|
|
|
|
// expected-warning@+1 {{unsupported '' in the 'target_clones' attribute string;}}
|
|
|
|
void __attribute__((target_clones("default,")))
|
|
|
|
empty_target_3(void);
|
|
|
|
// expected-warning@+1 {{unsupported '' in the 'target_clones' attribute string;}}
|
|
|
|
void __attribute__((target_clones("default, ,avx2")))
|
|
|
|
empty_target_4(void);
|
|
|
|
|
|
|
|
// expected-warning@+1 {{unsupported '' in the 'target_clones' attribute string;}}
|
|
|
|
void __attribute__((target_clones("default,avx2", "")))
|
|
|
|
empty_target_5(void);
|
|
|
|
|
|
|
|
// expected-warning@+1 {{version list contains duplicate entries}}
|
|
|
|
void __attribute__((target_clones("default", "default")))
|
|
|
|
dupe_default(void);
|
|
|
|
|
|
|
|
// expected-warning@+1 {{version list contains duplicate entries}}
|
|
|
|
void __attribute__((target_clones("avx2,avx2,default")))
|
|
|
|
dupe_normal(void);
|
|
|
|
|
|
|
|
// expected-error@+2 {{attribute 'target_clones' cannot appear more than once on a declaration}}
|
|
|
|
// expected-note@+1 {{conflicting attribute is here}}
|
|
|
|
void __attribute__((target_clones("avx2,default"), target_clones("arch=atom,default")))
|
|
|
|
dupe_normal2(void);
|
|
|
|
|
|
|
|
int mv_after_use(void);
|
2022-02-03 16:39:21 -05:00
|
|
|
int useage(void) {
|
2021-11-29 06:28:02 -08:00
|
|
|
return mv_after_use();
|
|
|
|
}
|
|
|
|
// expected-error@+1 {{function declaration cannot become a multiversioned function after first usage}}
|
|
|
|
int __attribute__((target_clones("sse4.2", "default"))) mv_after_use(void) { return 1; }
|
|
|
|
|
2022-01-28 15:08:33 -08:00
|
|
|
void bad_overload1(void) __attribute__((target_clones("mmx", "sse4.2", "default")));
|
|
|
|
void bad_overload1(int p) {}
|
|
|
|
|
|
|
|
void bad_overload2(int p) {}
|
2022-02-09 15:02:13 -08:00
|
|
|
// expected-error@+2 {{conflicting types for 'bad_overload2'}}
|
|
|
|
// expected-note@-2 {{previous definition is here}}
|
2022-01-28 15:08:33 -08:00
|
|
|
void bad_overload2(void) __attribute__((target_clones("mmx", "sse4.2", "default")));
|
|
|
|
|
|
|
|
void bad_overload3(void) __attribute__((target_clones("mmx", "sse4.2", "default")));
|
2022-02-09 15:02:13 -08:00
|
|
|
// expected-error@+2 {{conflicting types for 'bad_overload3'}}
|
|
|
|
// expected-note@-2 {{previous declaration is here}}
|
2022-01-28 15:08:33 -08:00
|
|
|
void bad_overload3(int) __attribute__((target_clones("mmx", "sse4.2", "default")));
|
|
|
|
|
|
|
|
void good_overload1(void) __attribute__((target_clones("mmx", "sse4.2", "default")));
|
|
|
|
void __attribute__((__overloadable__)) good_overload1(int p) {}
|
|
|
|
|
|
|
|
// expected-error@+1 {{attribute 'target_clones' multiversioning cannot be combined with attribute 'overloadable'}}
|
|
|
|
void __attribute__((__overloadable__)) good_overload2(void) __attribute__((target_clones("mmx", "sse4.2", "default")));
|
|
|
|
void good_overload2(int p) {}
|
|
|
|
|
|
|
|
// expected-error@+1 {{attribute 'target_clones' multiversioning cannot be combined with attribute 'overloadable'}}
|
|
|
|
void __attribute__((__overloadable__)) good_overload3(void) __attribute__((target_clones("mmx", "sse4.2", "default")));
|
|
|
|
// expected-error@+1 {{attribute 'target_clones' multiversioning cannot be combined with attribute 'overloadable'}}
|
|
|
|
void __attribute__((__overloadable__)) good_overload3(int) __attribute__((target_clones("mmx", "sse4.2", "default")));
|
|
|
|
|
|
|
|
void good_overload4(void) __attribute__((target_clones("mmx", "sse4.2", "default")));
|
|
|
|
// expected-error@+1 {{attribute 'target_clones' multiversioning cannot be combined with attribute 'overloadable'}}
|
|
|
|
void __attribute__((__overloadable__)) good_overload4(int) __attribute__((target_clones("mmx", "sse4.2", "default")));
|
|
|
|
|
|
|
|
// expected-error@+1 {{attribute 'target_clones' multiversioning cannot be combined with attribute 'overloadable'}}
|
|
|
|
void __attribute__((__overloadable__)) good_overload5(void) __attribute__((target_clones("mmx", "sse4.2", "default")));
|
|
|
|
void good_overload5(int) __attribute__((target_clones("mmx", "sse4.2", "default")));
|
[X86] Support arch=x86-64{,-v2,-v3,-v4} for target_clones attribute
GCC 12 (https://gcc.gnu.org/PR101696) allows `arch=x86-64`
`arch=x86-64-v2` `arch=x86-64-v3` `arch=x86-64-v4` in the
target_clones function attribute. This patch ports the feature.
* Set KeyFeature to `x86-64{,-v2,-v3,-v4}` in `Processors[]`, to be used
by X86TargetInfo::multiVersionSortPriority
* builtins: change `__cpu_features2` to an array like libgcc. Define
`FEATURE_X86_64_{BASELINE,V2,V3,V4}` and depended ISA feature bits.
* CGBuiltin.cpp: update EmitX86CpuSupports to handle `arch=x86-64*`.
Close https://github.com/llvm/llvm-project/issues/55830
Reviewed By: pengfei
Differential Revision: https://reviews.llvm.org/D158329
2023-08-23 22:08:55 -07:00
|
|
|
|
|
|
|
void good_isa_level(int) __attribute__((target_clones("default", "arch=x86-64", "arch=x86-64-v2", "arch=x86-64-v3", "arch=x86-64-v4")));
|
|
|
|
// expected-warning@+1 {{unsupported CPU 'x86-64-v5' in the 'target_clones' attribute string; 'target_clones' attribute ignored}}
|
|
|
|
void bad_isa_level(int) __attribute__((target_clones("default", "arch=x86-64-v5")));
|
2025-01-14 11:27:51 +01:00
|
|
|
|
|
|
|
// expected-warning@+1 {{unsupported 'sha' in the 'target_clones' attribute string; 'target_clones' attribute ignored}}
|
|
|
|
void bad_feature(void) __attribute__((target_clones("default", "sse4.2", "sha")));
|