blob: 290d6b5c648958ec36b0ed12a028b4a1082b4c03 [file] [log] [blame]
Erich Keane281d20b2018-01-08 21:34:17 +00001// RUN: %clang_cc1 -std=c++11 -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck %s
2void temp();
3void temp(int);
4using FP = void(*)(int);
5void b() {
6 FP f = temp;
7}
8
9int __attribute__((target("sse4.2"))) foo(int) { return 0; }
10int __attribute__((target("arch=sandybridge"))) foo(int);
11int __attribute__((target("arch=ivybridge"))) foo(int) {return 1;}
12int __attribute__((target("default"))) foo(int) { return 2; }
13
14struct S {
15int __attribute__((target("sse4.2"))) foo(int) { return 0; }
16int __attribute__((target("arch=sandybridge"))) foo(int);
17int __attribute__((target("arch=ivybridge"))) foo(int) {return 1;}
18int __attribute__((target("default"))) foo(int) { return 2; }
19};
20
21using FuncPtr = int (*)(int);
22using MemFuncPtr = int (S::*)(int);
23
24void f(FuncPtr, MemFuncPtr);
25
26int 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