1 // RUN: %clang_cc1 -std=c++11 -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix=LINUX
2 // RUN: %clang_cc1 -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), ptr @_Z10overloadedi.resolver
6 // LINUX: @_Z10overloadedPKc.ifunc = weak_odr ifunc i32 (ptr), ptr @_Z10overloadedPKc.resolver
7 // struct 'C' ifuncs, note the 'float, U' one doesn't get one.
8 // LINUX: @_ZN1CIssE3fooEv.ifunc = weak_odr ifunc i32 (ptr), ptr @_ZN1CIssE3fooEv.resolver
9 // LINUX: @_ZN1CIisE3fooEv.ifunc = weak_odr ifunc i32 (ptr), ptr @_ZN1CIisE3fooEv.resolver
10 // LINUX: @_ZN1CIdfE3fooEv.ifunc = weak_odr ifunc i32 (ptr), ptr @_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 ptr @_Z10overloadedi.resolver() comdat
16 // LINUX: ret ptr @_Z10overloadedi.sse4.2.0
17 // LINUX: ret ptr @_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(ptr{{.+}})
27 // LINUX: define {{.*}}i32 @_Z10overloadedPKc.default.1(ptr{{.+}})
28 // LINUX: define weak_odr ptr @_Z10overloadedPKc.resolver() comdat
29 // LINUX: ret ptr @_Z10overloadedPKc.arch_ivybridge.0
30 // LINUX: ret ptr @_Z10overloadedPKc.default.1
32 // WINDOWS: define dso_local noundef i32 @"?overloaded@@YAHPEBD@Z.arch_ivybridge.0"(ptr{{.+}})
33 // WINDOWS: define dso_local noundef i32 @"?overloaded@@YAHPEBD@Z.default.1"(ptr{{.+}})
34 // WINDOWS: define weak_odr dso_local i32 @"?overloaded@@YAHPEBD@Z"(ptr{{.+}}) 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(ptr
68 // WINDOWS: call noundef i32 @"?foo@?$C@FF@@QEAAHXZ"(ptr
71 // LINUX: call noundef i32 @_ZN1CIisE3fooEv.ifunc(ptr
72 // WINDOWS: call noundef i32 @"?foo@?$C@HF@@QEAAHXZ"(ptr
75 // Note this is not an ifunc/mv
76 // LINUX: call noundef i32 @_ZN1CIfsE3fooEv(ptr
77 // WINDOWS: call noundef i32 @"?foo@?$C@MF@@QEAAHXZ"(ptr
80 // LINUX: call noundef i32 @_ZN1CIdfE3fooEv.ifunc(ptr
81 // WINDOWS: call noundef i32 @"?foo@?$C@NM@@QEAAHXZ"(ptr
84 // LINUX: define weak_odr ptr @_ZN1CIssE3fooEv.resolver() comdat
85 // LINUX: ret ptr @_ZN1CIssE3fooEv.sse4.2.0
86 // LINUX: ret ptr @_ZN1CIssE3fooEv.default.1
88 // WINDOWS: define {{.*}}i32 @"?foo@?$C@FF@@QEAAHXZ"(ptr
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 ptr @_ZN1CIisE3fooEv.resolver() comdat
93 // LINUX: ret ptr @_ZN1CIisE3fooEv.sse4.2.0
94 // LINUX: ret ptr @_ZN1CIisE3fooEv.default.1
96 // WINDOWS: define {{.*}}i32 @"?foo@?$C@HF@@QEAAHXZ"(ptr
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 ptr @_ZN1CIdfE3fooEv.resolver() comdat
101 // LINUX: ret ptr @_ZN1CIdfE3fooEv.sse4.2.0
102 // LINUX: ret ptr @_ZN1CIdfE3fooEv.default.1
104 // WINDOWS: define {{.*}}i32 @"?foo@?$C@NM@@QEAAHXZ"(ptr
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(ptr
109 // LINUX: define {{.*}}i32 @_ZN1CIssE3fooEv.default.1(ptr
110 // LINUX: define {{.*}}i32 @_ZN1CIisE3fooEv.sse4.2.0(ptr
111 // LINUX: define {{.*}}i32 @_ZN1CIisE3fooEv.default.1(ptr
112 // LINUX: define {{.*}}i32 @_ZN1CIdfE3fooEv.sse4.2.0(ptr
113 // LINUX: define {{.*}}i32 @_ZN1CIdfE3fooEv.default.1(ptr
115 // WINDOWS: define {{.*}}i32 @"?foo@?$C@FF@@QEAAHXZ.sse4.2.0"(ptr
116 // WINDOWS: define {{.*}}i32 @"?foo@?$C@FF@@QEAAHXZ.default.1"(ptr
117 // WINDOWS: define {{.*}}i32 @"?foo@?$C@HF@@QEAAHXZ.sse4.2.0"(ptr
118 // WINDOWS: define {{.*}}i32 @"?foo@?$C@HF@@QEAAHXZ.default.1"(ptr
119 // WINDOWS: define {{.*}}i32 @"?foo@?$C@NM@@QEAAHXZ.sse4.2.0"(ptr
120 // WINDOWS: define {{.*}}i32 @"?foo@?$C@NM@@QEAAHXZ.default.1"(ptr