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
3 // RUN: %clang_cc1 -triple aarch64-windows-msvc -fms-extensions -emit-llvm -O2 < %s | FileCheck %s --check-prefixes=AARCH64,ALL
9 void use_foo(struct Foo
*f
);
10 void test_sign_ext(struct Foo
*f
, int * __ptr32 __sptr i
) {
11 // X64-LABEL: define dso_local void @test_sign_ext({{.*}}ptr addrspace(270) noundef %i)
12 // X86-LABEL: define dso_local void @test_sign_ext(ptr noundef initializes((8, 16)) %f, ptr noundef %i)
13 // AARCH64-LABEL: define dso_local void @test_sign_ext({{.*}}ptr addrspace(270) noundef %i) local_unnamed_addr #0
14 // X64: %{{.+}} = addrspacecast ptr addrspace(270) %i to ptr
15 // X86: %{{.+}} = addrspacecast ptr %i to ptr addrspace(272)
16 // AARCH64: %{{.+}} = addrspacecast ptr addrspace(270) %i to ptr
20 void test_zero_ext(struct Foo
*f
, int * __ptr32 __uptr i
) {
21 // X64-LABEL: define dso_local void @test_zero_ext(ptr noundef initializes((8, 16)) %f, ptr addrspace(271) noundef %i)
22 // X86-LABEL: define dso_local void @test_zero_ext({{.*}}ptr addrspace(271) noundef %i)
23 // AARCH64-LABEL: define dso_local void @test_zero_ext(ptr noundef initializes((8, 16)) %f, ptr addrspace(271) noundef %i) local_unnamed_addr #0
24 // X64: %{{.+}} = addrspacecast ptr addrspace(271) %i to ptr
25 // X86: %{{.+}} = addrspacecast ptr addrspace(271) %i to ptr addrspace(272)
26 // AARCH64: %{{.+}} = addrspacecast ptr addrspace(271) %i to ptr
30 void test_trunc(struct Foo
*f
, int * __ptr64 i
) {
31 // X64-LABEL: define dso_local void @test_trunc(ptr noundef initializes((0, 4)) %f, ptr noundef %i)
32 // X86-LABEL: define dso_local void @test_trunc({{.*}}ptr addrspace(272) noundef %i)
33 // AARCH64-LABEL: define dso_local void @test_trunc(ptr noundef initializes((0, 4)) %f, ptr noundef %i) local_unnamed_addr #0
34 // X64: %{{.+}} = addrspacecast ptr %i to ptr addrspace(270)
35 // X86: %{{.+}} = addrspacecast ptr addrspace(272) %i to ptr
36 // AARCH64: %{{.+}} = addrspacecast ptr %i to ptr addrspace(270)
40 void test_noop(struct Foo
*f
, int * __ptr32 i
) {
41 // X64-LABEL: define dso_local void @test_noop({{.*}}ptr addrspace(270) noundef %i)
42 // X86-LABEL: define dso_local void @test_noop({{.*}}ptr noundef %i)
43 // AARCH64-LABEL: define dso_local void @test_noop({{.*}}ptr addrspace(270) noundef %i) local_unnamed_addr #0
44 // X64-NOT: addrspacecast
45 // X86-NOT: addrspacecast
46 // AARCH64-NOT: addrspacecast
51 void test_other(struct Foo
*f
, __attribute__((address_space(10))) int *i
) {
52 // X64-LABEL: define dso_local void @test_other({{.*}}ptr addrspace(10) noundef %i)
53 // X86-LABEL: define dso_local void @test_other({{.*}}ptr addrspace(10) noundef %i)
54 // AARCH64-LABEL: define dso_local void @test_other({{.*}}ptr addrspace(10) noundef %i) local_unnamed_addr #0
55 // X64: %{{.+}} = addrspacecast ptr addrspace(10) %i to ptr addrspace(270)
56 // X86: %{{.+}} = addrspacecast ptr addrspace(10) %i to ptr
57 // AARCH64: %{{.+}} = addrspacecast ptr addrspace(10) %i to ptr addrspace(270)
58 f
->p32
= (int * __ptr32
)i
;
62 int test_compare1(int *__ptr32 __uptr i
, int *__ptr64 j
) {
63 // ALL-LABEL: define dso_local range(i32 0, 2) i32 @test_compare1
64 // X64: %{{.+}} = addrspacecast ptr %j to ptr addrspace(271)
65 // X64: %cmp = icmp eq ptr addrspace(271) %i, %{{.+}}
66 // X86: %{{.+}} = addrspacecast ptr addrspace(272) %j to ptr addrspace(271)
67 // X86: %cmp = icmp eq ptr addrspace(271) %i, %{{.+}}
68 // AARCH64: %{{.+}} = addrspacecast ptr %j to ptr addrspace(271)
69 // AARCH64: %cmp = icmp eq ptr addrspace(271) %i, %{{.+}}
73 int test_compare2(int *__ptr32 __sptr i
, int *__ptr64 j
) {
74 // ALL-LABEL: define dso_local range(i32 0, 2) i32 @test_compare2
75 // X64: %{{.+}} = addrspacecast ptr %j to ptr addrspace(270)
76 // X64: %cmp = icmp eq ptr addrspace(270) %i, %{{.+}}
77 // X86: %{{.+}} = addrspacecast ptr addrspace(272) %j to ptr
78 // X86: %cmp = icmp eq ptr %i, %{{.+}}
79 // AARCH64: %{{.+}} = addrspacecast ptr %j to ptr addrspace(270)
80 // AARCH64: %cmp = icmp eq ptr addrspace(270) %i, %{{.+}}
84 int test_compare3(int *__ptr32 __uptr i
, int *__ptr64 j
) {
85 // ALL-LABEL: define dso_local range(i32 0, 2) i32 @test_compare3
86 // X64: %{{.+}} = addrspacecast ptr addrspace(271) %i to ptr
87 // X64: %cmp = icmp eq ptr %j, %{{.+}}
88 // X86: %{{.+}} = addrspacecast ptr addrspace(271) %i to ptr addrspace(272)
89 // X86: %cmp = icmp eq ptr addrspace(272) %j, %{{.+}}
90 // AARCH64: %{{.+}} = addrspacecast ptr addrspace(271) %i to ptr
91 // AARCH64: %cmp = icmp eq ptr %j, %{{.+}}
95 int test_compare4(int *__ptr32 __sptr i
, int *__ptr64 j
) {
96 // ALL-LABEL: define dso_local range(i32 0, 2) i32 @test_compare4
97 // X64: %{{.+}} = addrspacecast ptr addrspace(270) %i to ptr
98 // X64: %cmp = icmp eq ptr %j, %{{.+}}
99 // X86: %{{.+}} = addrspacecast ptr %i to ptr addrspace(272)
100 // X86: %cmp = icmp eq ptr addrspace(272) %j, %{{.+}}
101 // AARCH64: %{{.+}} = addrspacecast ptr addrspace(270) %i to ptr
102 // AARCH64: %cmp = icmp eq ptr %j, %{{.+}}