| 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-apple-macos -emit-llvm %s -o - | FileCheck %s --check-prefix=LINUX |
| 3 |
// RUN: %clang_cc1 -std=c++11 -triple x86_64-windows-pc -emit-llvm %s -o - | FileCheck %s --check-prefix=WINDOWS |
| 4 |
void temp(); |
| 5 |
void temp(int); |
| 6 |
using FP = void(*)(int); |
| 7 |
void b() { |
| 8 |
FP f = temp; |
| 9 |
} |
| 10 |
|
| 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; } |
| 15 |
|
| 16 |
struct S { |
| 17 |
int __attribute__((target("sse4.2"))) foo(int) { return 0; } |
| 18 |
int __attribute__((target("arch=sandybridge"))) foo(int); |
| 19 |
int __attribute__((target("arch=ivybridge"))) foo(int) {return 1;} |
| 20 |
int __attribute__((target("default"))) foo(int) { return 2; } |
| 21 |
}; |
| 22 |
|
| 23 |
using FuncPtr = int (*)(int); |
| 24 |
using MemFuncPtr = int (S::*)(int); |
| 25 |
|
| 26 |
void f(FuncPtr, MemFuncPtr); |
| 27 |
|
| 28 |
int bar() { |
| 29 |
FuncPtr Free = &foo; |
| 30 |
MemFuncPtr Member = &S::foo; |
| 31 |
S s; |
| 32 |
f(foo, &S::foo); |
| 33 |
return Free(1) + (s.*Member)(2); |
| 34 |
} |
| 35 |
|
| 36 |
// LINUX: @_Z3fooi.ifunc |
| 37 |
// LINUX: @_ZN1S3fooEi.ifunc |
| 38 |
|
| 39 |
// LINUX: define{{.*}} i32 @_Z3barv() |
| 40 |
// Store to Free of ifunc |
| 41 |
// LINUX: store ptr @_Z3fooi.ifunc |
| 42 |
// Store to Member of ifunc |
| 43 |
// LINUX: store { i64, i64 } { i64 ptrtoint (ptr @_ZN1S3fooEi.ifunc to i64), i64 0 }, ptr [[MEMBER:%[a-z]+]] |
| 44 |
|
| 45 |
// Call to 'f' with the ifunc |
| 46 |
// LINUX: call void @_Z1fPFiiEM1SFiiE(ptr noundef @_Z3fooi.ifunc |
| 47 |
|
| 48 |
// WINDOWS: define dso_local noundef i32 @"?bar@@YAHXZ"() |
| 49 |
// Store to Free |
| 50 |
// WINDOWS: store ptr @"?foo@@[email protected]", ptr |
| 51 |
// Store to Member |
| 52 |
// WINDOWS: store ptr @"?foo@S@@[email protected]", ptr |
| 53 |
|
| 54 |
// Call to 'f' |
| 55 |
// WINDOWS: call void @"?f@@YAXP6AHH@ZP8S@@EAAHH@Z@Z"(ptr noundef @"?foo@@[email protected]", ptr @"?foo@S@@[email protected]") |