1 // RUN: %clang_cc1 -triple x86_64-windows-msvc -fms-extensions -emit-llvm -O2 < %s | FileCheck %s --check-prefix=X64
2 // RUN: %clang_cc1 -triple i386-pc-win32 -fms-extensions -emit-llvm -O2 < %s | FileCheck %s --check-prefix=X86
3
4 struct Foo {
5 int * __ptr32 p32;
6 int * __ptr64 p64;
7 };
8 void use_foo(struct Foo *f);
test_sign_ext(struct Foo * f,int * __ptr32 __sptr i)9 void test_sign_ext(struct Foo *f, int * __ptr32 __sptr i) {
10 // X64-LABEL: define dso_local void @test_sign_ext({{.*}}i32 addrspace(270)* %i)
11 // X86-LABEL: define dso_local void @test_sign_ext(%struct.Foo* %f, i32* %i)
12 // X64: %{{.+}} = addrspacecast i32 addrspace(270)* %i to i32*
13 // X86: %{{.+}} = addrspacecast i32* %i to i32 addrspace(272)*
14 f->p64 = i;
15 use_foo(f);
16 }
test_zero_ext(struct Foo * f,int * __ptr32 __uptr i)17 void test_zero_ext(struct Foo *f, int * __ptr32 __uptr i) {
18 // X64-LABEL: define dso_local void @test_zero_ext({{.*}}i32 addrspace(271)* %i)
19 // X86-LABEL: define dso_local void @test_zero_ext({{.*}}i32 addrspace(271)* %i)
20 // X64: %{{.+}} = addrspacecast i32 addrspace(271)* %i to i32*
21 // X86: %{{.+}} = addrspacecast i32 addrspace(271)* %i to i32 addrspace(272)*
22 f->p64 = i;
23 use_foo(f);
24 }
test_trunc(struct Foo * f,int * __ptr64 i)25 void test_trunc(struct Foo *f, int * __ptr64 i) {
26 // X64-LABEL: define dso_local void @test_trunc(%struct.Foo* %f, i32* %i)
27 // X86-LABEL: define dso_local void @test_trunc({{.*}}i32 addrspace(272)* %i)
28 // X64: %{{.+}} = addrspacecast i32* %i to i32 addrspace(270)*
29 // X86: %{{.+}} = addrspacecast i32 addrspace(272)* %i to i32*
30 f->p32 = i;
31 use_foo(f);
32 }
test_noop(struct Foo * f,int * __ptr32 i)33 void test_noop(struct Foo *f, int * __ptr32 i) {
34 // X64-LABEL: define dso_local void @test_noop({{.*}}i32 addrspace(270)* %i)
35 // X86-LABEL: define dso_local void @test_noop({{.*}}i32* %i)
36 // X64-NOT: addrspacecast
37 // X86-NOT: addrspacecast
38 f->p32 = i;
39 use_foo(f);
40 }
41
test_other(struct Foo * f,int * i)42 void test_other(struct Foo *f, __attribute__((address_space(10))) int *i) {
43 // X64-LABEL: define dso_local void @test_other({{.*}}i32 addrspace(10)* %i)
44 // X86-LABEL: define dso_local void @test_other({{.*}}i32 addrspace(10)* %i)
45 // X64: %{{.+}} = addrspacecast i32 addrspace(10)* %i to i32 addrspace(270)*
46 // X86: %{{.+}} = addrspacecast i32 addrspace(10)* %i to i32*
47 f->p32 = (int * __ptr32)i;
48 use_foo(f);
49 }
50