[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / CodeGen / SystemZ / zos-mixed-ptr-sizes-malloc.c
blob1b05e8aa5052aff00f6f7c4b92a527144a86e49e
1 // RUN: %clang_cc1 -triple s390x-ibm-zos -O2 -emit-llvm %s -o - | FileCheck %s --check-prefix=X64
2 #include <stddef.h>
3 void *__malloc31(size_t);
5 int test_1() {
6 // X64-LABEL: define {{.*}} i32 @test_1()
7 // X64: ret i32 135
8 int *__ptr32 a;
9 int *b;
10 int i;
11 int sum1, sum2, sum3;
13 a = (int *__ptr32)__malloc31(sizeof(int) * 10);
15 b = a;
16 sum1 = 0;
17 for (i = 0; i < 10; ++i) {
18 a[i] = i;
19 sum1 += i;
22 sum2 = 0;
23 for (i = 0; i < 10; ++i) {
24 sum2 += a[i];
26 sum3 = 0;
27 for (i = 0; i < 10; ++i) {
28 sum3 += b[i];
31 return (sum1 + sum2 + sum3);
34 int test_2() {
35 // X64-LABEL: define {{.*}} i32 @test_2()
36 // X64: ret i32 4
37 int *a = (int *)__malloc31(sizeof(int));
38 int *__ptr32 b;
40 *a = 99;
41 b = a;
42 *b = 44;
44 // Test should return 4
45 return (*b - 40);
48 int test_3() {
49 // X64-LABEL: define {{.*}} i32 @test_3()
50 // X64: ret i32 4
51 int *a = (int *)__malloc31(sizeof(int));
52 int *__ptr32 b;
54 *a = 99;
55 b = a;
57 // Test should return 4
58 return (*b - 95);
61 int test_4() {
62 // X64-LABEL: define {{.*}} i32 @test_4()
63 // X64: ret i32 1
64 int *a = (int *)__malloc31(sizeof(int));
65 float *d = (float *)__malloc31(sizeof(float));
67 int *__ptr32 b;
68 int *c;
70 float *__ptr32 e;
71 float *f;
73 *a = 0;
74 *d = 0.0;
76 b = a;
77 c = a;
78 e = d;
79 f = d;
81 // Test should return 1
82 return (b == c && e == f);