1 // RUN: %clang_cc1 -std=c++11 -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefixes=ITANIUM,LINUX
2 // RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-macos -emit-llvm %s -o - | FileCheck %s --check-prefixes=ITANIUM,DARWIN
3 // RUN: %clang_cc1 -std=c++11 -triple x86_64-windows-pc -emit-llvm %s -o - | FileCheck %s --check-prefix=WINDOWS
8 // ITANIUM: @_Z10overloadedi.ifunc = weak_odr alias i32 (i32), ptr @_Z10overloadedi
9 // ITANIUM: @_Z10overloadedPKc.ifunc = weak_odr alias i32 (ptr), ptr @_Z10overloadedPKc
10 // ITANIUM: @_ZN1CIssE3fooEv.ifunc = weak_odr alias i32 (ptr), ptr @_ZN1CIssE3fooEv
11 // ITANIUM: @_ZN1CIisE3fooEv.ifunc = weak_odr alias i32 (ptr), ptr @_ZN1CIisE3fooEv
12 // ITANIUM: @_ZN1CIdfE3fooEv.ifunc = weak_odr alias i32 (ptr), ptr @_ZN1CIdfE3fooEv
15 // ITANIUM: @_Z10overloadedi = weak_odr ifunc i32 (i32), ptr @_Z10overloadedi.resolver
16 // ITANIUM: @_Z10overloadedPKc = weak_odr ifunc i32 (ptr), ptr @_Z10overloadedPKc.resolver
17 // struct 'C' ifuncs, note the 'float, U' one doesn't get one.
18 // ITANIUM: @_ZN1CIssE3fooEv = weak_odr ifunc i32 (ptr), ptr @_ZN1CIssE3fooEv.resolver
19 // ITANIUM: @_ZN1CIisE3fooEv = weak_odr ifunc i32 (ptr), ptr @_ZN1CIisE3fooEv.resolver
20 // ITANIUM: @_ZN1CIdfE3fooEv = weak_odr ifunc i32 (ptr), ptr @_ZN1CIdfE3fooEv.resolver
22 int __attribute__((target_clones("sse4.2", "default"))) overloaded(int) { return 1; }
23 // ITANIUM: define {{.*}}i32 @_Z10overloadedi.sse4.2.0(i32{{.+}})
24 // ITANIUM: define {{.*}}i32 @_Z10overloadedi.default.1(i32{{.+}})
25 // ITANIUM: define weak_odr ptr @_Z10overloadedi.resolver()
27 // ITANIUM: ret ptr @_Z10overloadedi.sse4.2.0
28 // ITANIUM: ret ptr @_Z10overloadedi.default.1
30 // WINDOWS: define dso_local noundef i32 @"?overloaded@@YAHH@Z.sse4.2.0"(i32{{.+}})
31 // WINDOWS: define dso_local noundef i32 @"?overloaded@@YAHH@Z.default.1"(i32{{.+}})
32 // WINDOWS: define weak_odr dso_local i32 @"?overloaded@@YAHH@Z"(i32{{.+}}) comdat
33 // WINDOWS: call i32 @"?overloaded@@YAHH@Z.sse4.2.0"
34 // WINDOWS: call i32 @"?overloaded@@YAHH@Z.default.1"
36 int __attribute__((target_clones("arch=ivybridge", "default"))) overloaded(const char *) { return 2; }
37 // ITANIUM: define {{.*}}i32 @_Z10overloadedPKc.arch_ivybridge.0(ptr{{.+}})
38 // ITANIUM: define {{.*}}i32 @_Z10overloadedPKc.default.1(ptr{{.+}})
39 // ITANIUM: define weak_odr ptr @_Z10overloadedPKc.resolver()
41 // ITANIUM: ret ptr @_Z10overloadedPKc.arch_ivybridge.0
42 // ITANIUM: ret ptr @_Z10overloadedPKc.default.1
44 // WINDOWS: define dso_local noundef i32 @"?overloaded@@YAHPEBD@Z.arch_ivybridge.0"(ptr{{.+}})
45 // WINDOWS: define dso_local noundef i32 @"?overloaded@@YAHPEBD@Z.default.1"(ptr{{.+}})
46 // WINDOWS: define weak_odr dso_local i32 @"?overloaded@@YAHPEBD@Z"(ptr{{.+}}) comdat
47 // WINDOWS: call i32 @"?overloaded@@YAHPEBD@Z.arch_ivybridge.0"
48 // WINDOWS: call i32 @"?overloaded@@YAHPEBD@Z.default.1"
50 void use_overloaded() {
52 // ITANIUM: call noundef i32 @_Z10overloadedi
53 // WINDOWS: call noundef i32 @"?overloaded@@YAHH@Z"
55 // ITANIUM: call noundef i32 @_Z10overloadedPKc
56 // WINDOWS: call noundef i32 @"?overloaded@@YAHPEBD@Z"
59 template<typename T
, typename U
>
61 int __attribute__((target_clones("sse4.2", "default"))) foo(){ return 1;}
65 int __attribute__((target_clones("sse4.2", "default"))) foo(){ return 2;}
72 struct C
<double, float> {
73 int __attribute__((target_clones("sse4.2", "default"))) foo(){ return 3;}
76 void uses_specialized() {
79 // ITANIUM: call noundef i32 @_ZN1CIssE3fooEv(ptr
80 // WINDOWS: call noundef i32 @"?foo@?$C@FF@@QEAAHXZ"(ptr
83 // ITANIUM: call noundef i32 @_ZN1CIisE3fooEv(ptr
84 // WINDOWS: call noundef i32 @"?foo@?$C@HF@@QEAAHXZ"(ptr
87 // Note this is not an ifunc/mv
88 // ITANIUM: call noundef i32 @_ZN1CIfsE3fooEv(ptr
89 // WINDOWS: call noundef i32 @"?foo@?$C@MF@@QEAAHXZ"(ptr
92 // ITANIUM: call noundef i32 @_ZN1CIdfE3fooEv(ptr
93 // WINDOWS: call noundef i32 @"?foo@?$C@NM@@QEAAHXZ"(ptr
96 // ITANIUM: define weak_odr ptr @_ZN1CIssE3fooEv.resolver()
98 // ITANIUM: ret ptr @_ZN1CIssE3fooEv.sse4.2.0
99 // ITANIUM: ret ptr @_ZN1CIssE3fooEv.default.1
101 // WINDOWS: define {{.*}}i32 @"?foo@?$C@FF@@QEAAHXZ"(ptr
102 // WINDOWS: call i32 @"?foo@?$C@FF@@QEAAHXZ.sse4.2.0"
103 // WINDOWS: call i32 @"?foo@?$C@FF@@QEAAHXZ.default.1"
105 // ITANIUM: define weak_odr ptr @_ZN1CIisE3fooEv.resolver()
106 // LINUX-SAME: comdat
107 // ITANIUM: ret ptr @_ZN1CIisE3fooEv.sse4.2.0
108 // ITANIUM: ret ptr @_ZN1CIisE3fooEv.default.1
110 // WINDOWS: define {{.*}}i32 @"?foo@?$C@HF@@QEAAHXZ"(ptr
111 // WINDOWS: call i32 @"?foo@?$C@HF@@QEAAHXZ.sse4.2.0"
112 // WINDOWS: call i32 @"?foo@?$C@HF@@QEAAHXZ.default.1"
114 // ITANIUM: define weak_odr ptr @_ZN1CIdfE3fooEv.resolver()
115 // LINUX-SAME: comdat
116 // ITANIUM: ret ptr @_ZN1CIdfE3fooEv.sse4.2.0
117 // ITANIUM: ret ptr @_ZN1CIdfE3fooEv.default.1
119 // WINDOWS: define {{.*}}i32 @"?foo@?$C@NM@@QEAAHXZ"(ptr
120 // WINDOWS: call i32 @"?foo@?$C@NM@@QEAAHXZ.sse4.2.0"
121 // WINDOWS: call i32 @"?foo@?$C@NM@@QEAAHXZ.default.1"
123 // ITANIUM: define {{.*}}i32 @_ZN1CIssE3fooEv.sse4.2.0(ptr
124 // ITANIUM: define {{.*}}i32 @_ZN1CIssE3fooEv.default.1(ptr
125 // ITANIUM: define {{.*}}i32 @_ZN1CIisE3fooEv.sse4.2.0(ptr
126 // ITANIUM: define {{.*}}i32 @_ZN1CIisE3fooEv.default.1(ptr
127 // ITANIUM: define {{.*}}i32 @_ZN1CIdfE3fooEv.sse4.2.0(ptr
128 // ITANIUM: define {{.*}}i32 @_ZN1CIdfE3fooEv.default.1(ptr
130 // WINDOWS: define {{.*}}i32 @"?foo@?$C@FF@@QEAAHXZ.sse4.2.0"(ptr
131 // WINDOWS: define {{.*}}i32 @"?foo@?$C@FF@@QEAAHXZ.default.1"(ptr
132 // WINDOWS: define {{.*}}i32 @"?foo@?$C@HF@@QEAAHXZ.sse4.2.0"(ptr
133 // WINDOWS: define {{.*}}i32 @"?foo@?$C@HF@@QEAAHXZ.default.1"(ptr
134 // WINDOWS: define {{.*}}i32 @"?foo@?$C@NM@@QEAAHXZ.sse4.2.0"(ptr
135 // WINDOWS: define {{.*}}i32 @"?foo@?$C@NM@@QEAAHXZ.default.1"(ptr