1 // RUN: %clang_cc1 -no-opaque-pointers -std=c++11 -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix=LINUX
2 // RUN: %clang_cc1 -no-opaque-pointers -std=c++11 -triple x86_64-windows-pc -emit-llvm %s -o - | FileCheck %s --check-prefix=WINDOWS
5 // LINUX: @_Z10overloadedi.ifunc = weak_odr ifunc i32 (i32), i32 (i32)* ()* @_Z10overloadedi.resolver
6 // LINUX: @_Z10overloadedPKc.ifunc = weak_odr ifunc i32 (i8*), i32 (i8*)* ()* @_Z10overloadedPKc.resolver
7 // struct 'C' ifuncs, note the 'float, U' one doesn't get one.
8 // LINUX: @_ZN1CIssE3fooEv.ifunc = weak_odr ifunc i32 (%struct.C*), i32 (%struct.C*)* ()* @_ZN1CIssE3fooEv.resolver
9 // LINUX: @_ZN1CIisE3fooEv.ifunc = weak_odr ifunc i32 (%struct.C.0*), i32 (%struct.C.0*)* ()* @_ZN1CIisE3fooEv.resolver
10 // LINUX: @_ZN1CIdfE3fooEv.ifunc = weak_odr ifunc i32 (%struct.C.2*), i32 (%struct.C.2*)* ()* @_ZN1CIdfE3fooEv.resolver
12 int __attribute__((target_clones("sse4.2", "default"))) overloaded(int) { return 1; }
13 // LINUX: define {{.*}}i32 @_Z10overloadedi.sse4.2.0(i32{{.+}})
14 // LINUX: define {{.*}}i32 @_Z10overloadedi.default.1(i32{{.+}})
15 // LINUX: define weak_odr i32 (i32)* @_Z10overloadedi.resolver() comdat
16 // LINUX: ret i32 (i32)* @_Z10overloadedi.sse4.2.0
17 // LINUX: ret i32 (i32)* @_Z10overloadedi.default.1
19 // WINDOWS: define dso_local noundef i32 @"?overloaded@@YAHH@Z.sse4.2.0"(i32{{.+}})
20 // WINDOWS: define dso_local noundef i32 @"?overloaded@@YAHH@Z.default.1"(i32{{.+}})
21 // WINDOWS: define weak_odr dso_local i32 @"?overloaded@@YAHH@Z"(i32{{.+}}) comdat
22 // WINDOWS: call i32 @"?overloaded@@YAHH@Z.sse4.2.0"
23 // WINDOWS: call i32 @"?overloaded@@YAHH@Z.default.1"
25 int __attribute__((target_clones("arch=ivybridge", "default"))) overloaded(const char *) { return 2; }
26 // LINUX: define {{.*}}i32 @_Z10overloadedPKc.arch_ivybridge.0(i8*{{.+}})
27 // LINUX: define {{.*}}i32 @_Z10overloadedPKc.default.1(i8*{{.+}})
28 // LINUX: define weak_odr i32 (i8*)* @_Z10overloadedPKc.resolver() comdat
29 // LINUX: ret i32 (i8*)* @_Z10overloadedPKc.arch_ivybridge.0
30 // LINUX: ret i32 (i8*)* @_Z10overloadedPKc.default.1
32 // WINDOWS: define dso_local noundef i32 @"?overloaded@@YAHPEBD@Z.arch_ivybridge.0"(i8*{{.+}})
33 // WINDOWS: define dso_local noundef i32 @"?overloaded@@YAHPEBD@Z.default.1"(i8*{{.+}})
34 // WINDOWS: define weak_odr dso_local i32 @"?overloaded@@YAHPEBD@Z"(i8*{{.+}}) comdat
35 // WINDOWS: call i32 @"?overloaded@@YAHPEBD@Z.arch_ivybridge.0"
36 // WINDOWS: call i32 @"?overloaded@@YAHPEBD@Z.default.1"
38 void use_overloaded() {
40 // LINUX: call noundef i32 @_Z10overloadedi.ifunc
41 // WINDOWS: call noundef i32 @"?overloaded@@YAHH@Z"
43 // LINUX: call noundef i32 @_Z10overloadedPKc.ifunc
44 // WINDOWS: call noundef i32 @"?overloaded@@YAHPEBD@Z"
47 template<typename T
, typename U
>
49 int __attribute__((target_clones("sse4.2", "default"))) foo(){ return 1;}
53 int __attribute__((target_clones("sse4.2", "default"))) foo(){ return 2;}
60 struct C
<double, float> {
61 int __attribute__((target_clones("sse4.2", "default"))) foo(){ return 3;}
64 void uses_specialized() {
67 // LINUX: call noundef i32 @_ZN1CIssE3fooEv.ifunc(%struct.C
68 // WINDOWS: call noundef i32 @"?foo@?$C@FF@@QEAAHXZ"(%struct.C
71 // LINUX: call noundef i32 @_ZN1CIisE3fooEv.ifunc(%struct.C
72 // WINDOWS: call noundef i32 @"?foo@?$C@HF@@QEAAHXZ"(%struct.C
75 // Note this is not an ifunc/mv
76 // LINUX: call noundef i32 @_ZN1CIfsE3fooEv(%struct.C
77 // WINDOWS: call noundef i32 @"?foo@?$C@MF@@QEAAHXZ"(%struct.C
80 // LINUX: call noundef i32 @_ZN1CIdfE3fooEv.ifunc(%struct.C
81 // WINDOWS: call noundef i32 @"?foo@?$C@NM@@QEAAHXZ"(%struct.C
84 // LINUX: define weak_odr i32 (%struct.C*)* @_ZN1CIssE3fooEv.resolver() comdat
85 // LINUX: ret i32 (%struct.C*)* @_ZN1CIssE3fooEv.sse4.2.0
86 // LINUX: ret i32 (%struct.C*)* @_ZN1CIssE3fooEv.default.1
88 // WINDOWS: define {{.*}}i32 @"?foo@?$C@FF@@QEAAHXZ"(%struct.C{{.+}})
89 // WINDOWS: call i32 @"?foo@?$C@FF@@QEAAHXZ.sse4.2.0"
90 // WINDOWS: call i32 @"?foo@?$C@FF@@QEAAHXZ.default.1"
92 // LINUX: define weak_odr i32 (%struct.C{{.+}})* @_ZN1CIisE3fooEv.resolver() comdat
93 // LINUX: ret i32 (%struct.C{{.+}})* @_ZN1CIisE3fooEv.sse4.2.0
94 // LINUX: ret i32 (%struct.C{{.+}})* @_ZN1CIisE3fooEv.default.1
96 // WINDOWS: define {{.*}}i32 @"?foo@?$C@HF@@QEAAHXZ"(%struct.C{{.+}})
97 // WINDOWS: call i32 @"?foo@?$C@HF@@QEAAHXZ.sse4.2.0"
98 // WINDOWS: call i32 @"?foo@?$C@HF@@QEAAHXZ.default.1"
100 // LINUX: define weak_odr i32 (%struct.C{{.+}})* @_ZN1CIdfE3fooEv.resolver() comdat
101 // LINUX: ret i32 (%struct.C{{.+}})* @_ZN1CIdfE3fooEv.sse4.2.0
102 // LINUX: ret i32 (%struct.C{{.+}})* @_ZN1CIdfE3fooEv.default.1
104 // WINDOWS: define {{.*}}i32 @"?foo@?$C@NM@@QEAAHXZ"(%struct.C{{.+}})
105 // WINDOWS: call i32 @"?foo@?$C@NM@@QEAAHXZ.sse4.2.0"
106 // WINDOWS: call i32 @"?foo@?$C@NM@@QEAAHXZ.default.1"
108 // LINUX: define {{.*}}i32 @_ZN1CIssE3fooEv.sse4.2.0(%struct.C{{.+}})
109 // LINUX: define {{.*}}i32 @_ZN1CIssE3fooEv.default.1(%struct.C{{.+}})
110 // LINUX: define {{.*}}i32 @_ZN1CIisE3fooEv.sse4.2.0(%struct.C{{.+}})
111 // LINUX: define {{.*}}i32 @_ZN1CIisE3fooEv.default.1(%struct.C{{.+}})
112 // LINUX: define {{.*}}i32 @_ZN1CIdfE3fooEv.sse4.2.0(%struct.C{{.+}})
113 // LINUX: define {{.*}}i32 @_ZN1CIdfE3fooEv.default.1(%struct.C{{.+}})
115 // WINDOWS: define {{.*}}i32 @"?foo@?$C@FF@@QEAAHXZ.sse4.2.0"(%struct.C{{.+}})
116 // WINDOWS: define {{.*}}i32 @"?foo@?$C@FF@@QEAAHXZ.default.1"(%struct.C{{.+}})
117 // WINDOWS: define {{.*}}i32 @"?foo@?$C@HF@@QEAAHXZ.sse4.2.0"(%struct.C{{.+}})
118 // WINDOWS: define {{.*}}i32 @"?foo@?$C@HF@@QEAAHXZ.default.1"(%struct.C{{.+}})
119 // WINDOWS: define {{.*}}i32 @"?foo@?$C@NM@@QEAAHXZ.sse4.2.0"(%struct.C{{.+}})
120 // WINDOWS: define {{.*}}i32 @"?foo@?$C@NM@@QEAAHXZ.default.1"(%struct.C{{.+}})