File: attr-target-clones.c

package info (click to toggle)
llvm-toolchain-14 1%3A14.0.6-16
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,496,368 kB
  • sloc: cpp: 5,593,980; ansic: 986,873; asm: 585,869; python: 184,223; objc: 72,530; lisp: 31,119; f90: 27,793; javascript: 9,780; pascal: 9,762; sh: 9,482; perl: 7,468; ml: 5,432; awk: 3,523; makefile: 2,547; xml: 953; cs: 573; fortran: 567
file content (88 lines) | stat: -rw-r--r-- 4,115 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// 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);
int useage() {
  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; }