| 1 |
// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix=LINUX |
| 2 |
// RUN: %clang_cc1 -triple x86_64-apple-macos -emit-llvm %s -o - | FileCheck %s --check-prefix=LINUX |
| 3 |
// RUN: %clang_cc1 -triple x86_64-windows-pc -emit-llvm %s -o - | FileCheck %s --check-prefix=WINDOWS |
| 4 |
int __attribute__((target("sse4.2"))) foo(int i) { return 0; } |
| 5 |
int __attribute__((target("arch=sandybridge"))) foo(int); |
| 6 |
int __attribute__((target("arch=ivybridge"))) foo(int i) {return 1;} |
| 7 |
int __attribute__((target("default"))) foo(int i) { return 2; } |
| 8 |
|
| 9 |
typedef int (*FuncPtr)(int); |
| 10 |
void func(FuncPtr); |
| 11 |
|
| 12 |
int bar(void) { |
| 13 |
func(foo); |
| 14 |
FuncPtr Free = &foo; |
| 15 |
FuncPtr Free2 = foo; |
| 16 |
|
| 17 |
return 0; |
| 18 |
return Free(1) + Free(2); |
| 19 |
} |
| 20 |
|
| 21 |
// LINUX: @foo.ifunc = weak_odr ifunc i32 (i32), ptr @foo.resolver |
| 22 |
// LINUX: define{{.*}} i32 @foo.sse4.2( |
| 23 |
// LINUX: ret i32 0 |
| 24 |
// LINUX: define{{.*}} i32 @foo.arch_ivybridge( |
| 25 |
// LINUX: ret i32 1 |
| 26 |
// LINUX: define{{.*}} i32 @foo( |
| 27 |
// LINUX: ret i32 2 |
| 28 |
|
| 29 |
// WINDOWS: define dso_local i32 @foo.sse4.2( |
| 30 |
// WINDOWS: ret i32 0 |
| 31 |
// WINDOWS: define dso_local i32 @foo.arch_ivybridge( |
| 32 |
// WINDOWS: ret i32 1 |
| 33 |
// WINDOWS: define dso_local i32 @foo( |
| 34 |
// WINDOWS: ret i32 2 |
| 35 |
|
| 36 |
// LINUX: define{{.*}} i32 @bar() |
| 37 |
// LINUX: call void @func(ptr noundef @foo.ifunc) |
| 38 |
// LINUX: store ptr @foo.ifunc |
| 39 |
// LINUX: store ptr @foo.ifunc |
| 40 |
|
| 41 |
// WINDOWS: define dso_local i32 @bar() |
| 42 |
// WINDOWS: call void @func(ptr noundef @foo.resolver) |
| 43 |
// WINDOWS: store ptr @foo.resolver |
| 44 |
// WINDOWS: store ptr @foo.resolver |
| 45 |
|
| 46 |
// LINUX: declare i32 @foo.arch_sandybridge( |
| 47 |
|
| 48 |
// WINDOWS: declare dso_local i32 @foo.arch_sandybridge( |