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
4 // Test ensures that this properly differentiates between types in different
6 int __attribute__((target("sse4.2"))) foo(int) { return 0; }
7 int __attribute__((target("arch=sandybridge"))) foo(int);
8 int __attribute__((target("arch=ivybridge"))) foo(int) {return 1;}
9 int __attribute__((target("default"))) foo(int) { return 2; }
12 int __attribute__((target("sse4.2"))) foo(int) { return 0; }
13 int __attribute__((target("arch=sandybridge"))) foo(int);
14 int __attribute__((target("arch=ivybridge"))) foo(int) {return 1;}
15 int __attribute__((target("default"))) foo(int) { return 2; }
19 return foo(1) + ns::foo(2);
24 // ITANIUM: @_Z3fooi.ifunc = weak_odr ifunc i32 (i32), ptr @_Z3fooi.resolver
25 // ITANIUM: @_ZN2ns3fooEi.ifunc = weak_odr ifunc i32 (i32), ptr @_ZN2ns3fooEi.resolver
27 // ITANIUM: define{{.*}} i32 @_Z3fooi.sse4.2(i32 noundef %0)
29 // ITANIUM: define{{.*}} i32 @_Z3fooi.arch_ivybridge(i32 noundef %0)
31 // ITANIUM: define{{.*}} i32 @_Z3fooi(i32 noundef %0)
34 // WINDOWS: define dso_local noundef i32 @"?foo@@YAHH@Z.sse4.2"(i32 noundef %0)
36 // WINDOWS: define dso_local noundef i32 @"?foo@@YAHH@Z.arch_ivybridge"(i32 noundef %0)
38 // WINDOWS: define dso_local noundef i32 @"?foo@@YAHH@Z"(i32 noundef %0)
41 // ITANIUM: define{{.*}} i32 @_ZN2ns3fooEi.sse4.2(i32 noundef %0)
43 // ITANIUM: define{{.*}} i32 @_ZN2ns3fooEi.arch_ivybridge(i32 noundef %0)
45 // ITANIUM: define{{.*}} i32 @_ZN2ns3fooEi(i32 noundef %0)
48 // WINDOWS: define dso_local noundef i32 @"?foo@ns@@YAHH@Z.sse4.2"(i32 noundef %0)
50 // WINDOWS: define dso_local noundef i32 @"?foo@ns@@YAHH@Z.arch_ivybridge"(i32 noundef %0)
52 // WINDOWS: define dso_local noundef i32 @"?foo@ns@@YAHH@Z"(i32 noundef %0)
55 // ITANIUM: define{{.*}} i32 @_Z3barv()
56 // ITANIUM: call noundef i32 @_Z3fooi.ifunc(i32 noundef 1)
57 // ITANIUM: call noundef i32 @_ZN2ns3fooEi.ifunc(i32 noundef 2)
59 // WINDOWS: define dso_local noundef i32 @"?bar@@YAHXZ"()
60 // WINDOWS: call noundef i32 @"?foo@@YAHH@Z.resolver"(i32 noundef 1)
61 // WINDOWS: call noundef i32 @"?foo@ns@@YAHH@Z.resolver"(i32 noundef 2)
63 // ITANIUM: define weak_odr ptr @_Z3fooi.resolver()
65 // ITANIUM: ret ptr @_Z3fooi.arch_sandybridge
66 // ITANIUM: ret ptr @_Z3fooi.arch_ivybridge
67 // ITANIUM: ret ptr @_Z3fooi.sse4.2
68 // ITANIUM: ret ptr @_Z3fooi
70 // WINDOWS: define weak_odr dso_local i32 @"?foo@@YAHH@Z.resolver"(i32 %0) comdat
71 // WINDOWS: call i32 @"?foo@@YAHH@Z.arch_sandybridge"(i32 %0)
72 // WINDOWS: call i32 @"?foo@@YAHH@Z.arch_ivybridge"(i32 %0)
73 // WINDOWS: call i32 @"?foo@@YAHH@Z.sse4.2"(i32 %0)
74 // WINDOWS: call i32 @"?foo@@YAHH@Z"(i32 %0)
76 // ITANIUM: define weak_odr ptr @_ZN2ns3fooEi.resolver()
78 // ITANIUM: ret ptr @_ZN2ns3fooEi.arch_sandybridge
79 // ITANIUM: ret ptr @_ZN2ns3fooEi.arch_ivybridge
80 // ITANIUM: ret ptr @_ZN2ns3fooEi.sse4.2
81 // ITANIUM: ret ptr @_ZN2ns3fooEi
83 // WINDOWS: define weak_odr dso_local i32 @"?foo@ns@@YAHH@Z.resolver"(i32 %0) comdat
84 // WINDOWS: call i32 @"?foo@ns@@YAHH@Z.arch_sandybridge"(i32 %0)
85 // WINDOWS: call i32 @"?foo@ns@@YAHH@Z.arch_ivybridge"(i32 %0)
86 // WINDOWS: call i32 @"?foo@ns@@YAHH@Z.sse4.2"(i32 %0)
87 // WINDOWS: call i32 @"?foo@ns@@YAHH@Z"(i32 %0)
89 // ITANIUM: declare noundef i32 @_Z3fooi.arch_sandybridge(i32 noundef)
90 // ITANIUM: declare noundef i32 @_ZN2ns3fooEi.arch_sandybridge(i32 noundef)
92 // WINDOWS: declare dso_local noundef i32 @"?foo@@YAHH@Z.arch_sandybridge"(i32 noundef)
93 // WINDOWS: declare dso_local noundef i32 @"?foo@ns@@YAHH@Z.arch_sandybridge"(i32 noundef)