[C++20][Modules][Serialization] Add an additional test case for #120277. (#126349)
[llvm-project.git] / llvm / test / CodeGen / AArch64 / aarch64-mixed-ptr-sizes.ll
blobb7c8df7310adca0d6840159c704a045be221a5af
1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s | FileCheck %s
3 ; RUN: llc --fast-isel < %s | FileCheck %s
4 ; RUN: llc --global-isel --global-isel-abort=2 < %s | FileCheck %s
6 ; Source to regenerate:
7 ; struct Foo {
8 ;   int * __ptr32 p32;
9 ;   int * __ptr64 p64;
10 ;   __attribute__((address_space(9))) int *p_other;
11 ; };
12 ; extern "C" void use_foo(Foo *f);
13 ; extern "C" int use_int(int i);
14 ; extern "C" void test_sign_ext(Foo *f, int * __ptr32 __sptr i) {
15 ;   f->p64 = i;
16 ;   use_foo(f);
17 ; }
18 ; extern "C" void test_sign_ext_store_load(int * __ptr32 __sptr i) {
19 ;   *i = use_int(*i);
20 ; }
21 ; extern "C" void test_zero_ext(Foo *f, int * __ptr32 __uptr i) {
22 ;   f->p64 = i;
23 ;   use_foo(f);
24 ; }
25 ; extern "C" void test_zero_ext_store_load(int * __ptr32 __uptr i) {
26 ;   *i = use_int(*i);
27 ; }
28 ; extern "C" void test_trunc(Foo *f, int * __ptr64 i) {
29 ;   f->p32 = i;
30 ;   use_foo(f);
31 ; }
32 ; extern "C" void test_noop1(Foo *f, int * __ptr32 i) {
33 ;   f->p32 = i;
34 ;   use_foo(f);
35 ; }
36 ; extern "C" void test_noop2(Foo *f, int * __ptr64 i) {
37 ;   f->p64 = i;
38 ;   use_foo(f);
39 ; }
40 ; extern "C" void test_null_arg(Foo *f, int * __ptr32 i) {
41 ;   test_noop1(f, 0);
42 ; }
43 ; extern "C" void test_unrecognized(Foo *f, __attribute__((address_space(14))) int *i) {
44 ;   f->p32 = (int * __ptr32)i;
45 ;   use_foo(f);
46 ; }
48 ; $ clang --target=aarch64-windows-msvc -fms-extensions -O2 -S -emit-llvm t.cpp
50 target datalayout = "e-m:w-p:64:64-i32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-n32:64-S128-Fn32"
51 target triple = "aarch64-unknown-windows-msvc"
53 ; Function Attrs: mustprogress uwtable
54 define dso_local void @test_sign_ext(ptr noundef %f, ptr addrspace(270) noundef %i) local_unnamed_addr #0 {
55 ; CHECK-LABEL: test_sign_ext:
56 ; CHECK:       // %bb.0: // %entry
57 ; CHECK-NEXT:    // kill: def $w1 killed $w1 def $x1
58 ; CHECK-NEXT:    sxtw x8, w1
59 ; CHECK-NEXT:    str  x8, [x0, #8]
60 ; CHECK-NEXT:    b    use_foo
61 entry:
62   %0 = addrspacecast ptr addrspace(270) %i to ptr
63   %p64 = getelementptr inbounds nuw i8, ptr %f, i64 8
64   store ptr %0, ptr %p64, align 8
65   tail call void @use_foo(ptr noundef %f)
66   ret void
69 declare dso_local void @use_foo(ptr noundef) local_unnamed_addr #1
71 ; Function Attrs: mustprogress uwtable
72 define dso_local void @test_sign_ext_store_load(ptr addrspace(270) nocapture noundef %i) local_unnamed_addr #0 {
73 ; CHECK-LABEL: test_sign_ext_store_load:
74 ; CHECK:       // %bb.0: // %entry
75 ; CHECK:       sxtw    x19, w0
76 ; CHECK-NEXT:  ldr     w0, [x19]
77 ; CHECK-NEXT:  bl      use_int
78 ; CHECK-NEXT:  str     w0, [x19]
79 entry:
80   %0 = load i32, ptr addrspace(270) %i, align 4
81   %call = tail call i32 @use_int(i32 noundef %0)
82   store i32 %call, ptr addrspace(270) %i, align 4
83   ret void
86 declare dso_local i32 @use_int(i32 noundef) local_unnamed_addr #1
88 ; Function Attrs: mustprogress uwtable
89 define dso_local void @test_zero_ext(ptr noundef %f, ptr addrspace(271) noundef %i) local_unnamed_addr #0 {
90 ; CHECK-LABEL: test_zero_ext:
91 ; CHECK:       // %bb.0: // %entry
92 ; CHECK-NEXT:  mov     w8, w1
93 ; CHECK-NEXT:  str     x8, [x0, #8]
94 ; CHECK-NEXT:  b       use_foo
95 entry:
96   %0 = addrspacecast ptr addrspace(271) %i to ptr
97   %p64 = getelementptr inbounds nuw i8, ptr %f, i64 8
98   store ptr %0, ptr %p64, align 8
99   tail call void @use_foo(ptr noundef %f)
100   ret void
103 ; Function Attrs: mustprogress uwtable
104 define dso_local void @test_zero_ext_store_load(ptr addrspace(271) nocapture noundef %i) local_unnamed_addr #0 {
105 ; CHECK-LABEL: test_zero_ext_store_load:
106 ; CHECK:       // %bb.0: // %entry
107 ; CHECK:       mov     w19, w0
108 ; CHECK-NEXT:  ldr     w0, [x19]
109 ; CHECK-NEXT:  bl      use_int
110 ; CHECK-NEXT:  str     w0, [x19]
111 entry:
112   %0 = load i32, ptr addrspace(271) %i, align 4
113   %call = tail call i32 @use_int(i32 noundef %0)
114   store i32 %call, ptr addrspace(271) %i, align 4
115   ret void
118 ; Function Attrs: mustprogress uwtable
119 define dso_local void @test_trunc(ptr noundef %f, ptr noundef %i) local_unnamed_addr #0 {
120 ; CHECK-LABEL: test_trunc:
121 ; CHECK:       // %bb.0: // %entry
122 ; CHECK-NEXT:    str     w1, [x0]
123 ; CHECK-NEXT:    b      use_foo
124 entry:
125   %0 = addrspacecast ptr %i to ptr addrspace(270)
126   store ptr addrspace(270) %0, ptr %f, align 8
127   tail call void @use_foo(ptr noundef nonnull %f)
128   ret void
131 ; Function Attrs: mustprogress uwtable
132 define dso_local void @test_noop1(ptr noundef %f, ptr addrspace(270) noundef %i) local_unnamed_addr #0 {
133 ; CHECK-LABEL: test_noop1:
134 ; CHECK:       // %bb.0: // %entry
135 ; CHECK-NEXT:    str  w1, [x0]
136 ; CHECK-NEXT:    b    use_foo
137 entry:
138   store ptr addrspace(270) %i, ptr %f, align 8
139   tail call void @use_foo(ptr noundef nonnull %f)
140   ret void
143 ; Function Attrs: mustprogress uwtable
144 define dso_local void @test_noop2(ptr noundef %f, ptr noundef %i) local_unnamed_addr #0 {
145 ; CHECK-LABEL: test_noop2:
146 ; CHECK:       // %bb.0: // %entry
147 ; CHECK-NEXT:    str  x1, [x0, #8]
148 ; CHECK-NEXT:    b    use_foo
149 entry:
150   %p64 = getelementptr inbounds nuw i8, ptr %f, i64 8
151   store ptr %i, ptr %p64, align 8
152   tail call void @use_foo(ptr noundef %f)
153   ret void
156 ; Function Attrs: mustprogress uwtable
157 define dso_local void @test_null_arg(ptr noundef %f, ptr addrspace(270) nocapture noundef readnone %i) local_unnamed_addr #0 {
158 ; CHECK-LABEL: test_null_arg:
159 ; CHECK:       // %bb.0: // %entry
160 ; CHECK-NEXT:    str  wzr, [x0]
161 ; CHECK-NEXT:    b    use_foo
162 entry:
163   store ptr addrspace(270) null, ptr %f, align 8
164   tail call void @use_foo(ptr noundef nonnull %f)
165   ret void
168 ; Function Attrs: mustprogress uwtable
169 define dso_local void @test_unrecognized(ptr noundef %f, ptr addrspace(14) noundef %i) local_unnamed_addr #0 {
170 ; CHECK-LABEL: test_unrecognized:
171 ; CHECK:       // %bb.0: // %entry
172 ; CHECK-NEXT:    str   w1, [x0]
173 ; CHECK-NEXT:    b    use_foo
174 entry:
175   %0 = addrspacecast ptr addrspace(14) %i to ptr addrspace(270)
176   store ptr addrspace(270) %0, ptr %f, align 8
177   tail call void @use_foo(ptr noundef nonnull %f)
178   ret void
181 attributes #0 = { mustprogress uwtable "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" "target-features"="+fp-armv8,+neon,+v8a,-fmv" }
182 attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" "target-features"="+fp-armv8,+neon,+v8a,-fmv" }