1 // RUN: %clang_cc1 -std=c++11 -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck %s 2 void temp(); 3 void temp(int); 4 using FP = void(*)(int); 5 void b() { 6 FP f = temp; 7 } 8 9 int __attribute__((target("sse4.2"))) foo(int) { return 0; } 10 int __attribute__((target("arch=sandybridge"))) foo(int); 11 int __attribute__((target("arch=ivybridge"))) foo(int) {return 1;} 12 int __attribute__((target("default"))) foo(int) { return 2; } 13 14 struct S { 15 int __attribute__((target("sse4.2"))) foo(int) { return 0; } 16 int __attribute__((target("arch=sandybridge"))) foo(int); 17 int __attribute__((target("arch=ivybridge"))) foo(int) {return 1;} 18 int __attribute__((target("default"))) foo(int) { return 2; } 19 }; 20 21 using FuncPtr = int (*)(int); 22 using MemFuncPtr = int (S::*)(int); 23 24 void f(FuncPtr, MemFuncPtr); 25 26 int bar() { 27 FuncPtr Free = &foo; 28 MemFuncPtr Member = &S::foo; 29 S s; 30 f(foo, &S::foo); 31 return Free(1) + (s.*Member)(2); 32 } 33 34 35 // CHECK: @_Z3fooi.ifunc 36 // CHECK: @_ZN1S3fooEi.ifunc 37 38 // CHECK: define i32 @_Z3barv() 39 // Store to Free of ifunc 40 // CHECK: store i32 (i32)* @_Z3fooi.ifunc 41 // Store to Member of ifunc 42 // CHECK: store { i64, i64 } { i64 ptrtoint (i32 (%struct.S*, i32)* @_ZN1S3fooEi.ifunc to i64), i64 0 }, { i64, i64 }* [[MEMBER:%[a-z]+]] 43 44 // Call to 'f' with the ifunc 45 // CHECK: call void @_Z1fPFiiEM1SFiiE(i32 (i32)* @_Z3fooi.ifunc 46