brintos

brintos / llvm-project-archived public Read only

0
0
Text · 9.7 KiB · dfc3d61 Raw
188 lines · c
1// RUN: %clang_cc1 -triple x86_64-linux-gnu -Wno-strict-prototypes -fsyntax-only -verify %s2 3void __attribute__((target("sse4.2"))) no_default(void);4void __attribute__((target("arch=sandybridge")))  no_default(void);5 6void use1(void){7  // expected-error@+1 {{no matching function for call to 'no_default'}}8  no_default();9}10 11void __attribute__((target("sse4.2"))) has_def(void);12void __attribute__((target("default")))  has_def(void);13 14void use2(void){15  // expected-error@+2 {{reference to overloaded function could not be resolved; did you mean to call it?}}16  // expected-note@-4 {{possible target for call}}17  +has_def;18}19 20int __attribute__((target("sse4.2"))) no_proto();21// expected-error@-1 {{multiversioned function must have a prototype}}22// expected-note@+1 {{function multiversioning caused by this declaration}}23int __attribute__((target("arch=sandybridge"))) no_proto();24 25// The following should all be legal, since they are just redeclarations.26int __attribute__((target("sse4.2"))) redecl1(void);27int __attribute__((target("sse4.2"))) redecl1(void) { return 1; }28int __attribute__((target("arch=sandybridge")))  redecl1(void) { return 2; }29 30int __attribute__((target("sse4.2"))) redecl2(void) { return 1; }31int __attribute__((target("sse4.2"))) redecl2(void);32int __attribute__((target("arch=sandybridge")))  redecl2(void) { return 2; }33 34int __attribute__((target("sse4.2"))) redecl3(void) { return 0; }35int __attribute__((target("arch=ivybridge"))) redecl3(void) { return 1; }36int __attribute__((target("arch=sandybridge")))  redecl3(void);37int __attribute__((target("arch=sandybridge")))  redecl3(void) { return 2; }38 39int __attribute__((target("sse4.2"))) redecl4(void) { return 1; }40int __attribute__((target("arch=sandybridge")))  redecl4(void) { return 2; }41int __attribute__((target("arch=sandybridge")))  redecl4(void);42 43int __attribute__((target("sse4.2"))) redef(void) { return 1; }44int __attribute__((target("arch=ivybridge"))) redef(void) { return 1; }45int __attribute__((target("arch=sandybridge")))  redef(void) { return 2; }46// expected-error@+2 {{redefinition of 'redef'}}47// expected-note@-2 {{previous definition is here}}48int __attribute__((target("arch=sandybridge")))  redef(void) { return 2; }49 50int __attribute__((target("default"))) redef2(void) { return 1;}51// expected-error@+2 {{redefinition of 'redef2'}}52// expected-note@-2 {{previous definition is here}}53int __attribute__((target("default"))) redef2(void) { return 1;}54 55int redef3(void) { return 1; }56// expected-warning@+4 {{attribute declaration must precede definition}}57// expected-note@-2 {{previous definition is here}}58// expected-error@+2 {{redefinition of 'redef3'}}59// expected-note@-4 {{previous definition is here}}60int __attribute__((target("default"))) redef3(void) { return 1; }61// allow this, since we don't complain about more than one redefinition62int __attribute__((target("sse4.2"))) redef3(void) { return 1; }63 64int __attribute__((target("sse4.2"))) mv_after_use(void) { return 1; }65int use3(void) {66  return mv_after_use();67}68 69// expected-error@+2 {{function declaration cannot become a multiversioned function after first usage}}70// expected-note@-6 {{previous declaration is here}}71int __attribute__((target("arch=sandybridge")))  mv_after_use(void) { return 2; }72 73int __attribute__((target("sse4.2,arch=sandybridge"))) mangle(void) { return 1; }74//expected-error@+2 {{multiversioned function redeclarations require identical target attributes}}75//expected-note@-2 {{previous declaration is here}}76int __attribute__((target("arch=sandybridge,sse4.2")))  mangle(void) { return 2; }77 78// allow this, since we want to treat the 1st one as fwd-decl of the sandybridge version.79int prev_no_target(void);80int __attribute__((target("arch=sandybridge")))  prev_no_target(void) { return 2; }81int __attribute__((target("arch=ivybridge")))  prev_no_target(void) { return 2; }82 83int __attribute__((target("arch=sandybridge")))  prev_no_target2(void);84int prev_no_target2(void);85// expected-error@-1 {{function declaration is missing 'target' attribute in a multiversioned function}}86// expected-note@+1 {{function multiversioning caused by this declaration}}87int __attribute__((target("arch=ivybridge")))  prev_no_target2(void);88 89void __attribute__((target("sse4.2"))) addtl_attrs(void);90//expected-error@+2 {{attribute 'target' multiversioning cannot be combined with attribute 'no_caller_saved_registers'}}91void __attribute__((no_caller_saved_registers,target("arch=sandybridge")))92addtl_attrs(void);93 94//expected-error@+1 {{attribute 'target' multiversioning cannot be combined with attribute 'no_caller_saved_registers'}}95void __attribute__((target("default"), no_caller_saved_registers)) addtl_attrs2(void);96 97//expected-error@+2 {{attribute 'target' multiversioning cannot be combined with attribute 'no_caller_saved_registers'}}98//expected-note@+2 {{function multiversioning caused by this declaration}}99void __attribute__((no_caller_saved_registers,target("sse4.2"))) addtl_attrs3(void);100void __attribute__((target("arch=sandybridge")))  addtl_attrs3(void);101 102void __attribute__((target("sse4.2"))) addtl_attrs4(void);103void __attribute__((target("arch=sandybridge")))  addtl_attrs4(void);104//expected-error@+1 {{attribute 'target' multiversioning cannot be combined}}105void __attribute__((no_caller_saved_registers,target("arch=ivybridge")))  addtl_attrs4(void);106 107int __attribute__((target("sse4.2"))) diff_cc(void);108// expected-error@+1 {{multiversioned function declaration has a different calling convention}}109__vectorcall int __attribute__((target("arch=sandybridge")))  diff_cc(void);110 111int __attribute__((target("sse4.2"))) diff_ret(void);112// expected-error@+1 {{multiversioned function declaration has a different return type}}113short __attribute__((target("arch=sandybridge")))  diff_ret(void);114 115void __attribute__((target("sse4.2"), nothrow, used, nonnull(1))) addtl_attrs5(int*);116void __attribute__((target("arch=sandybridge"))) addtl_attrs5(int*);117 118void __attribute__((target("sse4.2"))) addtl_attrs6(int*);119void __attribute__((target("arch=sandybridge"), nothrow, used, nonnull)) addtl_attrs6(int*);120 121int __attribute__((target("sse4.2"))) bad_overload1(void);122int __attribute__((target("arch=sandybridge"))) bad_overload1(void);123// expected-error@+1 {{function declaration is missing 'target' attribute in a multiversioned function}}124int bad_overload1(int);125 126int bad_overload2(int);127// expected-error@+2 {{conflicting types for 'bad_overload2'}}128// expected-note@-2 {{previous declaration is here}}129int __attribute__((target("sse4.2"))) bad_overload2(void);130// expected-error@+2 {{conflicting types for 'bad_overload2'}}131// expected-note@-5 {{previous declaration is here}}132int __attribute__((target("arch=sandybridge"))) bad_overload2(void);133 134// expected-error@+2 {{attribute 'target' multiversioning cannot be combined with attribute 'overloadable'}}135// expected-note@+2 {{function multiversioning caused by this declaration}}136int __attribute__((__overloadable__)) __attribute__((target("sse4.2"))) bad_overload3(void);137int __attribute__((target("arch=sandybridge"))) bad_overload3(void);138 139int __attribute__((target("sse4.2"))) bad_overload4(void);140// expected-error@+1 {{attribute 'target' multiversioning cannot be combined with attribute 'overloadable'}}141int __attribute__((__overloadable__)) __attribute__((target("arch=sandybridge"))) bad_overload4(void);142 143int __attribute__((target("sse4.2"))) bad_overload5(void);144int __attribute__((target("arch=sandybridge"))) bad_overload5(int);145 146int __attribute__((target("sse4.2"))) good_overload1(void);147int __attribute__((target("arch=sandybridge"))) good_overload1(void);148int __attribute__((__overloadable__)) good_overload1(int);149 150int __attribute__((__overloadable__)) good_overload2(int);151int __attribute__((target("sse4.2"))) good_overload2(void);152int __attribute__((target("arch=sandybridge"))) good_overload2(void);153 154// expected-error@+2 {{attribute 'target' multiversioning cannot be combined with attribute 'overloadable'}}155// expected-note@+2 {{function multiversioning caused by this declaration}}156int __attribute__((__overloadable__)) __attribute__((target("sse4.2"))) good_overload3(void);157int __attribute__((__overloadable__)) __attribute__((target("arch=sandybridge"))) good_overload3(void);158int good_overload3(int);159 160int good_overload4(int);161// expected-error@+2 {{attribute 'target' multiversioning cannot be combined with attribute 'overloadable'}}162// expected-note@+2 {{function multiversioning caused by this declaration}}163int __attribute__((__overloadable__)) __attribute__((target("sse4.2"))) good_overload4(void);164int __attribute__((__overloadable__)) __attribute__((target("arch=sandybridge"))) good_overload4(void);165 166int __attribute__((__overloadable__)) __attribute__((target("sse4.2"))) good_overload5(void);167int __attribute__((__overloadable__)) __attribute__((target("arch=sandybridge"))) good_overload5(int);168 169int __attribute__((target("sse4.2"))) good_overload6(void);170int __attribute__((__overloadable__)) __attribute__((target("arch=sandybridge"))) good_overload6(int);171 172int __attribute__((__overloadable__)) __attribute__((target("sse4.2"))) good_overload7(void);173int __attribute__((target("arch=sandybridge"))) good_overload7(int);174 175// expected-error@+2 {{function multiversioning doesn't support feature 'sha'}}176// expected-note@+2 {{function multiversioning caused by this declaration}}177int __attribute__((target("sha"))) no_priority1(void);178int __attribute__((target("default"))) no_priority1(void);179 180int __attribute__((target("default"))) no_priority2(void);181// expected-error@+1 {{function multiversioning doesn't support feature 'sha'}}182int __attribute__((target("sha"))) no_priority2(void);183 184int __attribute__((target("default"))) no_priority3(void);185int __attribute__((target("avx2"))) no_priority3(void);186// expected-error@+1 {{function multiversioning doesn't support feature 'sha'}}187int __attribute__((target("sha"))) no_priority3(void);188