[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / CodeGen / ms-mixed-ptr-sizes.c
bloba853c6083cb8baea1d016ebe58c6bb3f5d430fe2
1 // RUN: %clang_cc1 -triple x86_64-windows-msvc -fms-extensions -emit-llvm -O2 < %s | FileCheck %s --check-prefixes=X64,ALL
2 // RUN: %clang_cc1 -triple i386-pc-win32 -fms-extensions -emit-llvm -O2 < %s | FileCheck %s --check-prefixes=X86,ALL
4 struct Foo {
5 int * __ptr32 p32;
6 int * __ptr64 p64;
7 };
8 void use_foo(struct Foo *f);
9 void test_sign_ext(struct Foo *f, int * __ptr32 __sptr i) {
10 // X64-LABEL: define dso_local void @test_sign_ext({{.*}}ptr addrspace(270) noundef %i)
11 // X86-LABEL: define dso_local void @test_sign_ext(ptr noundef %f, ptr noundef %i)
12 // X64: %{{.+}} = addrspacecast ptr addrspace(270) %i to ptr
13 // X86: %{{.+}} = addrspacecast ptr %i to ptr addrspace(272)
14 f->p64 = i;
15 use_foo(f);
17 void test_zero_ext(struct Foo *f, int * __ptr32 __uptr i) {
18 // X64-LABEL: define dso_local void @test_zero_ext({{.*}}ptr addrspace(271) noundef %i)
19 // X86-LABEL: define dso_local void @test_zero_ext({{.*}}ptr addrspace(271) noundef %i)
20 // X64: %{{.+}} = addrspacecast ptr addrspace(271) %i to ptr
21 // X86: %{{.+}} = addrspacecast ptr addrspace(271) %i to ptr addrspace(272)
22 f->p64 = i;
23 use_foo(f);
25 void test_trunc(struct Foo *f, int * __ptr64 i) {
26 // X64-LABEL: define dso_local void @test_trunc(ptr noundef %f, ptr noundef %i)
27 // X86-LABEL: define dso_local void @test_trunc({{.*}}ptr addrspace(272) noundef %i)
28 // X64: %{{.+}} = addrspacecast ptr %i to ptr addrspace(270)
29 // X86: %{{.+}} = addrspacecast ptr addrspace(272) %i to ptr
30 f->p32 = i;
31 use_foo(f);
33 void test_noop(struct Foo *f, int * __ptr32 i) {
34 // X64-LABEL: define dso_local void @test_noop({{.*}}ptr addrspace(270) noundef %i)
35 // X86-LABEL: define dso_local void @test_noop({{.*}}ptr noundef %i)
36 // X64-NOT: addrspacecast
37 // X86-NOT: addrspacecast
38 f->p32 = i;
39 use_foo(f);
42 void test_other(struct Foo *f, __attribute__((address_space(10))) int *i) {
43 // X64-LABEL: define dso_local void @test_other({{.*}}ptr addrspace(10) noundef %i)
44 // X86-LABEL: define dso_local void @test_other({{.*}}ptr addrspace(10) noundef %i)
45 // X64: %{{.+}} = addrspacecast ptr addrspace(10) %i to ptr addrspace(270)
46 // X86: %{{.+}} = addrspacecast ptr addrspace(10) %i to ptr
47 f->p32 = (int * __ptr32)i;
48 use_foo(f);
51 int test_compare1(int *__ptr32 __uptr i, int *__ptr64 j) {
52 // ALL-LABEL: define dso_local i32 @test_compare1
53 // X64: %{{.+}} = addrspacecast ptr %j to ptr addrspace(271)
54 // X64: %cmp = icmp eq ptr addrspace(271) %{{.+}}, %i
55 // X86: %{{.+}} = addrspacecast ptr addrspace(272) %j to ptr addrspace(271)
56 // X86: %cmp = icmp eq ptr addrspace(271) %{{.+}}, %i
57 return (i == j);
60 int test_compare2(int *__ptr32 __sptr i, int *__ptr64 j) {
61 // ALL-LABEL: define dso_local i32 @test_compare2
62 // X64: %{{.+}} = addrspacecast ptr %j to ptr addrspace(270)
63 // X64: %cmp = icmp eq ptr addrspace(270) %{{.+}}, %i
64 // X86: %{{.+}} = addrspacecast ptr addrspace(272) %j to ptr
65 // X86: %cmp = icmp eq ptr %{{.+}}, %i
66 return (i == j);
69 int test_compare3(int *__ptr32 __uptr i, int *__ptr64 j) {
70 // ALL-LABEL: define dso_local i32 @test_compare3
71 // X64: %{{.+}} = addrspacecast ptr addrspace(271) %i to ptr
72 // X64: %cmp = icmp eq ptr %{{.+}}, %j
73 // X86: %{{.+}} = addrspacecast ptr addrspace(271) %i to ptr addrspace(272)
74 // X86: %cmp = icmp eq ptr addrspace(272) %{{.+}}, %j
75 return (j == i);
78 int test_compare4(int *__ptr32 __sptr i, int *__ptr64 j) {
79 // ALL-LABEL: define dso_local i32 @test_compare4
80 // X64: %{{.+}} = addrspacecast ptr addrspace(270) %i to ptr
81 // X64: %cmp = icmp eq ptr %{{.+}}, %j
82 // X86: %{{.+}} = addrspacecast ptr %i to ptr addrspace(272)
83 // X86: %cmp = icmp eq ptr addrspace(272) %{{.+}}, %j
84 return (j == i);