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
3 // Test ensures that this properly differentiates between types in different
5 int __attribute__((target("sse4.2"))) foo(int) { return 0; }
6 int __attribute__((target("arch=sandybridge"))) foo(int);
7 int __attribute__((target("arch=ivybridge"))) foo(int) {return 1;}
8 int __attribute__((target("default"))) foo(int) { return 2; }
11 int __attribute__((target("sse4.2"))) foo(int) { return 0; }
12 int __attribute__((target("arch=sandybridge"))) foo(int);
13 int __attribute__((target("arch=ivybridge"))) foo(int) {return 1;}
14 int __attribute__((target("default"))) foo(int) { return 2; }
18 return foo(1) + ns::foo(2);
21 // LINUX: @_Z3fooi.ifunc = weak_odr ifunc i32 (i32), i32 (i32)* ()* @_Z3fooi.resolver
22 // LINUX: @_ZN2ns3fooEi.ifunc = weak_odr ifunc i32 (i32), i32 (i32)* ()* @_ZN2ns3fooEi.resolver
24 // LINUX: define{{.*}} i32 @_Z3fooi.sse4.2(i32 noundef %0)
26 // LINUX: define{{.*}} i32 @_Z3fooi.arch_ivybridge(i32 noundef %0)
28 // LINUX: define{{.*}} i32 @_Z3fooi(i32 noundef %0)
31 // WINDOWS: define dso_local noundef i32 @"?foo@@YAHH@Z.sse4.2"(i32 noundef %0)
33 // WINDOWS: define dso_local noundef i32 @"?foo@@YAHH@Z.arch_ivybridge"(i32 noundef %0)
35 // WINDOWS: define dso_local noundef i32 @"?foo@@YAHH@Z"(i32 noundef %0)
38 // LINUX: define{{.*}} i32 @_ZN2ns3fooEi.sse4.2(i32 noundef %0)
40 // LINUX: define{{.*}} i32 @_ZN2ns3fooEi.arch_ivybridge(i32 noundef %0)
42 // LINUX: define{{.*}} i32 @_ZN2ns3fooEi(i32 noundef %0)
45 // WINDOWS: define dso_local noundef i32 @"?foo@ns@@YAHH@Z.sse4.2"(i32 noundef %0)
47 // WINDOWS: define dso_local noundef i32 @"?foo@ns@@YAHH@Z.arch_ivybridge"(i32 noundef %0)
49 // WINDOWS: define dso_local noundef i32 @"?foo@ns@@YAHH@Z"(i32 noundef %0)
52 // LINUX: define{{.*}} i32 @_Z3barv()
53 // LINUX: call noundef i32 @_Z3fooi.ifunc(i32 noundef 1)
54 // LINUX: call noundef i32 @_ZN2ns3fooEi.ifunc(i32 noundef 2)
56 // WINDOWS: define dso_local noundef i32 @"?bar@@YAHXZ"()
57 // WINDOWS: call noundef i32 @"?foo@@YAHH@Z.resolver"(i32 noundef 1)
58 // WINDOWS: call noundef i32 @"?foo@ns@@YAHH@Z.resolver"(i32 noundef 2)
60 // LINUX: define weak_odr i32 (i32)* @_Z3fooi.resolver() comdat
61 // LINUX: ret i32 (i32)* @_Z3fooi.arch_sandybridge
62 // LINUX: ret i32 (i32)* @_Z3fooi.arch_ivybridge
63 // LINUX: ret i32 (i32)* @_Z3fooi.sse4.2
64 // LINUX: ret i32 (i32)* @_Z3fooi
66 // WINDOWS: define weak_odr dso_local i32 @"?foo@@YAHH@Z.resolver"(i32 %0) comdat
67 // WINDOWS: call i32 @"?foo@@YAHH@Z.arch_sandybridge"(i32 %0)
68 // WINDOWS: call i32 @"?foo@@YAHH@Z.arch_ivybridge"(i32 %0)
69 // WINDOWS: call i32 @"?foo@@YAHH@Z.sse4.2"(i32 %0)
70 // WINDOWS: call i32 @"?foo@@YAHH@Z"(i32 %0)
72 // LINUX: define weak_odr i32 (i32)* @_ZN2ns3fooEi.resolver() comdat
73 // LINUX: ret i32 (i32)* @_ZN2ns3fooEi.arch_sandybridge
74 // LINUX: ret i32 (i32)* @_ZN2ns3fooEi.arch_ivybridge
75 // LINUX: ret i32 (i32)* @_ZN2ns3fooEi.sse4.2
76 // LINUX: ret i32 (i32)* @_ZN2ns3fooEi
78 // WINDOWS: define weak_odr dso_local i32 @"?foo@ns@@YAHH@Z.resolver"(i32 %0) comdat
79 // WINDOWS: call i32 @"?foo@ns@@YAHH@Z.arch_sandybridge"(i32 %0)
80 // WINDOWS: call i32 @"?foo@ns@@YAHH@Z.arch_ivybridge"(i32 %0)
81 // WINDOWS: call i32 @"?foo@ns@@YAHH@Z.sse4.2"(i32 %0)
82 // WINDOWS: call i32 @"?foo@ns@@YAHH@Z"(i32 %0)
84 // LINUX: declare noundef i32 @_Z3fooi.arch_sandybridge(i32 noundef)
85 // LINUX: declare noundef i32 @_ZN2ns3fooEi.arch_sandybridge(i32 noundef)
87 // WINDOWS: declare dso_local noundef i32 @"?foo@@YAHH@Z.arch_sandybridge"(i32 noundef)
88 // WINDOWS: declare dso_local noundef i32 @"?foo@ns@@YAHH@Z.arch_sandybridge"(i32 noundef)