Debian Codegraph @

clang/test/CodeGenCXX/attr-target-clones.cpp

raw
1 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 6
2 // RUN: %clang_cc1 -std=c++11 -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefixes=ITANIUM,LINUX
3 // RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-macos -emit-llvm %s -o - | FileCheck %s --check-prefixes=ITANIUM,DARWIN
4 // RUN: %clang_cc1 -std=c++11 -triple x86_64-windows-pc -emit-llvm %s -o - | FileCheck %s --check-prefix=WINDOWS
5
6
7 // Aliases for ifuncs
8
9 // Overloaded ifuncs
10 // struct 'C' ifuncs, note the 'float, U' one doesn't get one.
11
12 //
13 int __attribute__((target_clones("sse4.2", "default"))) overloaded(int) { return 1; }
14
15
16 //
17 int __attribute__((target_clones("arch=ivybridge", "default"))) overloaded(const char *) { return 2; }
18
19
20 // LINUX-LABEL: define dso_local void @_Z14use_overloadedv(
21 // LINUX-SAME: ) #[[ATTR1:[0-9]+]] {
22 // LINUX-NEXT: [[ENTRY:.*:]]
23 // LINUX-NEXT: [[CALL:%.*]] = call noundef i32 @_Z10overloadedi(i32 noundef 1)
24 // LINUX-NEXT: [[CALL1:%.*]] = call noundef i32 @_Z10overloadedPKc(ptr noundef null)
25 // LINUX-NEXT: ret void
26 //
27 // DARWIN-LABEL: define void @_Z14use_overloadedv(
28 // DARWIN-SAME: ) #[[ATTR1:[0-9]+]] {
29 // DARWIN-NEXT: [[ENTRY:.*:]]
30 // DARWIN-NEXT: [[CALL:%.*]] = call noundef i32 @_Z10overloadedi(i32 noundef 1)
31 // DARWIN-NEXT: [[CALL1:%.*]] = call noundef i32 @_Z10overloadedPKc(ptr noundef null)
32 // DARWIN-NEXT: ret void
33 //
34 void use_overloaded() {
35 overloaded(1);
36 overloaded(nullptr);
37 }
38
39 template<typename T, typename U>
40 struct C {
41 int __attribute__((target_clones("sse4.2", "default"))) foo(){ return 1;}
42 };
43 template<typename U>
44 struct C<int, U> {
45 int __attribute__((target_clones("sse4.2", "default"))) foo(){ return 2;}
46 };
47 template<typename U>
48 struct C<float, U> {
49 int foo(){ return 2;}
50 };
51 template<>
52 //
53 struct C<double, float> {
54 int __attribute__((target_clones("sse4.2", "default"))) foo(){ return 3;}
55 };
56
57 // LINUX-LABEL: define dso_local void @_Z16uses_specializedv(
58 // LINUX-SAME: ) #[[ATTR1]] {
59 // LINUX-NEXT: [[ENTRY:.*:]]
60 // LINUX-NEXT: [[C:%.*]] = alloca [[STRUCT_C:%.*]], align 1
61 // LINUX-NEXT: [[C2:%.*]] = alloca [[STRUCT_C_0:%.*]], align 1
62 // LINUX-NEXT: [[C3:%.*]] = alloca [[STRUCT_C_1:%.*]], align 1
63 // LINUX-NEXT: [[C4:%.*]] = alloca [[STRUCT_C_2:%.*]], align 1
64 // LINUX-NEXT: [[CALL:%.*]] = call noundef i32 @_ZN1CIssE3fooEv(ptr noundef nonnull align 1 dereferenceable(1) [[C]])
65 // LINUX-NEXT: [[CALL1:%.*]] = call noundef i32 @_ZN1CIisE3fooEv(ptr noundef nonnull align 1 dereferenceable(1) [[C2]])
66 // LINUX-NEXT: [[CALL2:%.*]] = call noundef i32 @_ZN1CIfsE3fooEv(ptr noundef nonnull align 1 dereferenceable(1) [[C3]])
67 // LINUX-NEXT: [[CALL3:%.*]] = call noundef i32 @_ZN1CIdfE3fooEv(ptr noundef nonnull align 1 dereferenceable(1) [[C4]])
68 // LINUX-NEXT: ret void
69 //
70 // DARWIN-LABEL: define void @_Z16uses_specializedv(
71 // DARWIN-SAME: ) #[[ATTR1]] {
72 // DARWIN-NEXT: [[ENTRY:.*:]]
73 // DARWIN-NEXT: [[C:%.*]] = alloca [[STRUCT_C:%.*]], align 1
74 // DARWIN-NEXT: [[C2:%.*]] = alloca [[STRUCT_C_0:%.*]], align 1
75 // DARWIN-NEXT: [[C3:%.*]] = alloca [[STRUCT_C_1:%.*]], align 1
76 // DARWIN-NEXT: [[C4:%.*]] = alloca [[STRUCT_C_2:%.*]], align 1
77 // DARWIN-NEXT: [[CALL:%.*]] = call noundef i32 @_ZN1CIssE3fooEv(ptr noundef nonnull align 1 dereferenceable(1) [[C]])
78 // DARWIN-NEXT: [[CALL1:%.*]] = call noundef i32 @_ZN1CIisE3fooEv(ptr noundef nonnull align 1 dereferenceable(1) [[C2]])
79 // DARWIN-NEXT: [[CALL2:%.*]] = call noundef i32 @_ZN1CIfsE3fooEv(ptr noundef nonnull align 1 dereferenceable(1) [[C3]])
80 // DARWIN-NEXT: [[CALL3:%.*]] = call noundef i32 @_ZN1CIdfE3fooEv(ptr noundef nonnull align 1 dereferenceable(1) [[C4]])
81 // DARWIN-NEXT: ret void
82 //
83 void uses_specialized() {
84 C<short, short> c;
85 c.foo();
86 C<int, short> c2;
87 c2.foo();
88 C<float, short> c3;
89 c3.foo();
90 // Note this is not an ifunc/mv
91 C<double, float> c4;
92 c4.foo();
93 }
94
95
96
97
98
99
100
101
102 //// NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
103 // ITANIUM: {{.*}}
104 // WINDOWS: {{.*}}