Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGenCXX / attr-target-mv-func-ptrs.cpp
blob690f44ceb58be84e26d5f4ec62d6fd61156b6e35
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-windows-pc -emit-llvm %s -o - | FileCheck %s --check-prefix=WINDOWS
3 void temp();
4 void temp(int);
5 using FP = void(*)(int);
6 void b() {
7 FP f = temp;
10 int __attribute__((target("sse4.2"))) foo(int) { return 0; }
11 int __attribute__((target("arch=sandybridge"))) foo(int);
12 int __attribute__((target("arch=ivybridge"))) foo(int) {return 1;}
13 int __attribute__((target("default"))) foo(int) { return 2; }
15 struct S {
16 int __attribute__((target("sse4.2"))) foo(int) { return 0; }
17 int __attribute__((target("arch=sandybridge"))) foo(int);
18 int __attribute__((target("arch=ivybridge"))) foo(int) {return 1;}
19 int __attribute__((target("default"))) foo(int) { return 2; }
22 using FuncPtr = int (*)(int);
23 using MemFuncPtr = int (S::*)(int);
25 void f(FuncPtr, MemFuncPtr);
27 int bar() {
28 FuncPtr Free = &foo;
29 MemFuncPtr Member = &S::foo;
30 S s;
31 f(foo, &S::foo);
32 return Free(1) + (s.*Member)(2);
35 // LINUX: @_Z3fooi.ifunc
36 // LINUX: @_ZN1S3fooEi.ifunc
38 // LINUX: define{{.*}} i32 @_Z3barv()
39 // Store to Free of ifunc
40 // LINUX: store ptr @_Z3fooi.ifunc
41 // Store to Member of ifunc
42 // LINUX: store { i64, i64 } { i64 ptrtoint (ptr @_ZN1S3fooEi.ifunc to i64), i64 0 }, ptr [[MEMBER:%[a-z]+]]
44 // Call to 'f' with the ifunc
45 // LINUX: call void @_Z1fPFiiEM1SFiiE(ptr noundef @_Z3fooi.ifunc
47 // WINDOWS: define dso_local noundef i32 @"?bar@@YAHXZ"()
48 // Store to Free
49 // WINDOWS: store ptr @"?foo@@YAHH@Z.resolver", ptr
50 // Store to Member
51 // WINDOWS: store ptr @"?foo@S@@QEAAHH@Z.resolver", ptr
53 // Call to 'f'
54 // WINDOWS: call void @"?f@@YAXP6AHH@ZP8S@@EAAHH@Z@Z"(ptr noundef @"?foo@@YAHH@Z.resolver", ptr @"?foo@S@@QEAAHH@Z.resolver")