| 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 |
| 5 |
// namespaces. |
| 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; } |
| 10 |
|
| 11 |
namespace ns { |
| 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; } |
| 16 |
} |
| 17 |
|
| 18 |
int bar() { |
| 19 |
return foo(1) + ns::foo(2); |
| 20 |
} |
| 21 |
|
| 22 |
// DARWIN-NOT: comdat |
| 23 |
|
| 24 |
// ITANIUM: @_Z3fooi.ifunc = weak_odr ifunc i32 (i32), ptr @_Z3fooi.resolver |
| 25 |
// ITANIUM: @_ZN2ns3fooEi.ifunc = weak_odr ifunc i32 (i32), ptr @_ZN2ns3fooEi.resolver |
| 26 |
|
| 27 |
// ITANIUM: define{{.*}} i32 @_Z3fooi.sse4.2(i32 noundef %0) |
| 28 |
// ITANIUM: ret i32 0 |
| 29 |
// ITANIUM: define{{.*}} i32 @_Z3fooi.arch_ivybridge(i32 noundef %0) |
| 30 |
// ITANIUM: ret i32 1 |
| 31 |
// ITANIUM: define{{.*}} i32 @_Z3fooi(i32 noundef %0) |
| 32 |
// ITANIUM: ret i32 2 |
| 33 |
|
| 34 |
// WINDOWS: define dso_local noundef i32 @"?foo@@[email protected]"(i32 noundef %0) |
| 35 |
// WINDOWS: ret i32 0 |
| 36 |
// WINDOWS: define dso_local noundef i32 @"?foo@@[email protected]_ivybridge"(i32 noundef %0) |
| 37 |
// WINDOWS: ret i32 1 |
| 38 |
// WINDOWS: define dso_local noundef i32 @"?foo@@YAHH@Z"(i32 noundef %0) |
| 39 |
// WINDOWS: ret i32 2 |
| 40 |
|
| 41 |
// ITANIUM: define{{.*}} i32 @_ZN2ns3fooEi.sse4.2(i32 noundef %0) |
| 42 |
// ITANIUM: ret i32 0 |
| 43 |
// ITANIUM: define{{.*}} i32 @_ZN2ns3fooEi.arch_ivybridge(i32 noundef %0) |
| 44 |
// ITANIUM: ret i32 1 |
| 45 |
// ITANIUM: define{{.*}} i32 @_ZN2ns3fooEi(i32 noundef %0) |
| 46 |
// ITANIUM: ret i32 2 |
| 47 |
|
| 48 |
// WINDOWS: define dso_local noundef i32 @"?foo@ns@@[email protected]"(i32 noundef %0) |
| 49 |
// WINDOWS: ret i32 0 |
| 50 |
// WINDOWS: define dso_local noundef i32 @"?foo@ns@@[email protected]_ivybridge"(i32 noundef %0) |
| 51 |
// WINDOWS: ret i32 1 |
| 52 |
// WINDOWS: define dso_local noundef i32 @"?foo@ns@@YAHH@Z"(i32 noundef %0) |
| 53 |
// WINDOWS: ret i32 2 |
| 54 |
|
| 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) |
| 58 |
|
| 59 |
// WINDOWS: define dso_local noundef i32 @"?bar@@YAHXZ"() |
| 60 |
// WINDOWS: call noundef i32 @"?foo@@[email protected]"(i32 noundef 1) |
| 61 |
// WINDOWS: call noundef i32 @"?foo@ns@@[email protected]"(i32 noundef 2) |
| 62 |
|
| 63 |
// ITANIUM: define weak_odr ptr @_Z3fooi.resolver() #[[ATTR_RESOLVER:[0-9]+]] |
| 64 |
// LINUX-SAME: comdat |
| 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 |
| 69 |
|
| 70 |
// WINDOWS: define weak_odr dso_local i32 @"?foo@@[email protected]"(i32 %0) #[[ATTR_RESOLVER:[0-9]+]] comdat |
| 71 |
// WINDOWS: call i32 @"?foo@@[email protected]_sandybridge"(i32 %0) |
| 72 |
// WINDOWS: call i32 @"?foo@@[email protected]_ivybridge"(i32 %0) |
| 73 |
// WINDOWS: call i32 @"?foo@@[email protected]"(i32 %0) |
| 74 |
// WINDOWS: call i32 @"?foo@@YAHH@Z"(i32 %0) |
| 75 |
|
| 76 |
// ITANIUM: define weak_odr ptr @_ZN2ns3fooEi.resolver() #[[ATTR_RESOLVER]] |
| 77 |
// LINUX-SAME: comdat |
| 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 |
| 82 |
|
| 83 |
// WINDOWS: define weak_odr dso_local i32 @"?foo@ns@@[email protected]"(i32 %0) #[[ATTR_RESOLVER]] comdat |
| 84 |
// WINDOWS: call i32 @"?foo@ns@@[email protected]_sandybridge"(i32 %0) |
| 85 |
// WINDOWS: call i32 @"?foo@ns@@[email protected]_ivybridge"(i32 %0) |
| 86 |
// WINDOWS: call i32 @"?foo@ns@@[email protected]"(i32 %0) |
| 87 |
// WINDOWS: call i32 @"?foo@ns@@YAHH@Z"(i32 %0) |
| 88 |
|
| 89 |
// ITANIUM: declare noundef i32 @_Z3fooi.arch_sandybridge(i32 noundef) |
| 90 |
// ITANIUM: declare noundef i32 @_ZN2ns3fooEi.arch_sandybridge(i32 noundef) |
| 91 |
|
| 92 |
// WINDOWS: declare dso_local noundef i32 @"?foo@@[email protected]_sandybridge"(i32 noundef) |
| 93 |
// WINDOWS: declare dso_local noundef i32 @"?foo@ns@@[email protected]_sandybridge"(i32 noundef) |