Revert "[llvm] Improve llvm.objectsize computation by computing GEP, alloca and mallo...
[llvm-project.git] / clang / test / CodeGen / ifunc-win.c
blobdeda51757e43be1c6623158b9646d080b3cd9386
1 // RUN: %clang_cc1 -triple aarch64-pc-windows-msvc -emit-llvm -o - %s | FileCheck %s
2 // RUN: %clang_cc1 -triple aarch64-pc-windows-msvc -O2 -emit-llvm -o - %s | FileCheck %s
3 // RUN: %clang_cc1 -triple aarch64-pc-windows-msvc -fsanitize=thread -O2 -emit-llvm -o - %s | FileCheck %s --check-prefix=SAN
4 // RUN: %clang_cc1 -triple aarch64-pc-windows-msvc -fsanitize=address -O2 -emit-llvm -o - %s | FileCheck %s --check-prefix=SAN
6 // REQUIRES: aarch64-registered-target
8 int foo(int) __attribute__ ((ifunc("foo_ifunc")));
10 static int f1(int i) {
11 return i + 1;
14 static int f2(int i) {
15 return i + 2;
18 typedef int (*foo_t)(int);
20 volatile int global;
22 static foo_t foo_ifunc(void) {
23 return global ? f1 : f2;
26 int bar(void) {
27 return foo(1);
30 extern void goo(void);
32 void bar2(void) {
33 goo();
36 extern void goo(void) __attribute__ ((ifunc("goo_ifunc")));
38 void* goo_ifunc(void) {
39 return 0;
42 /// The ifunc is emitted after its resolver.
43 void *hoo_ifunc(void) { return 0; }
44 extern void hoo(int) __attribute__ ((ifunc("hoo_ifunc")));
46 /// ifunc on Windows is lowered to global pointers and an indirect call.
47 // CHECK: @global = dso_local global i32 0, align 4
48 // CHECK: {{.*}} = internal{{.*}}global{{.*}}poison, align 8
49 /// Register the constructor for initialisation.
50 // CHECK: @llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 10, ptr @{{.*}}, ptr null }]
52 // CHECK-LABEL: @bar()
53 // CHECK %0 = load ptr, ptr @0, align 8
54 // CHECK %call = call i32 %0(i32 noundef 1)
56 // CHECK-LABEL: @bar2()
57 // CHECK %0 = load ptr, ptr getelementptr inbounds ([3 x ptr], ptr @0, i32 0, i32 1), align 8
58 // CHECK call void %0()
60 // CHECK: define internal void @{{.*}}()
62 // SAN: define {{(dso_local )?}}noalias {{(noundef )?}}ptr @goo_ifunc() {{(local_unnamed_addr )?}}
64 // SAN: define {{(dso_local )?}}noalias {{(noundef )?}}ptr @hoo_ifunc() {{(local_unnamed_addr )?}}
66 // SAN: define internal {{(fastcc )?}}{{(noundef )?}}nonnull ptr @foo_ifunc() {{(unnamed_addr )?}}