[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / CodeGen / address-space-ptr32.c
blobead9550e4a64f96608b2f9994f6efae3764b8ba8
1 // RUN: %clang_cc1 -triple x86_64-windows-msvc -fms-extensions -emit-llvm < %s | FileCheck %s
3 _Static_assert(sizeof(void *) == 8, "sizeof(void *) has unexpected value. Expected 8.");
5 int foo(void) {
6 // CHECK: define dso_local i32 @foo
7 // CHECK: %a = alloca ptr addrspace(270), align 4
8 // CHECK: ret i32 4
9 int (*__ptr32 a)(int);
10 return sizeof(a);
13 int bar(void) {
14 // CHECK: define dso_local i32 @bar
15 // CHECK: %p = alloca ptr addrspace(270), align 4
16 // CHECK: ret i32 4
17 int *__ptr32 p;
18 return sizeof(p);
22 int baz(void) {
23 // CHECK: define dso_local i32 @baz
24 // CHECK: %p = alloca ptr addrspace(270), align 4
25 // CHECK: ret i32 4
26 typedef int *__ptr32 IP32_PTR;
28 IP32_PTR p;
29 return sizeof(p);
32 int fugu(void) {
33 // CHECK: define dso_local i32 @fugu
34 // CHECK: %p = alloca ptr addrspace(270), align 4
35 // CHECK: ret i32 4
36 typedef int *int_star;
38 int_star __ptr32 p;
39 return sizeof(p);
42 typedef __SIZE_TYPE__ size_t;
43 size_t strlen(const char *);
45 size_t test_calling_strlen_with_32_bit_pointer ( char *__ptr32 s ) {
46 // CHECK-LABEL: define dso_local i64 @test_calling_strlen_with_32_bit_pointer(ptr addrspace(270) noundef %s)
47 // CHECK-NEXT: entry:
48 // CHECK-NEXT: %s.addr = alloca ptr addrspace(270), align 4
49 // CHECK-NEXT: store ptr addrspace(270) %s, ptr %s.addr, align 4
50 // CHECK-NEXT: %0 = load ptr addrspace(270), ptr %s.addr, align 4
51 // CHECK-NEXT: %1 = addrspacecast ptr addrspace(270) %0 to ptr
52 // CHECK-NEXT: %call = call i64 @strlen(ptr noundef %1)
53 // CHECK-NEXT: ret i64 %call
54 return strlen ( s );
57 // CHECK-LABEL: declare dso_local i64 @strlen(ptr noundef)
59 size_t test_calling_strlen_with_64_bit_pointer ( char *s ) {
60 // CHECK-LABEL: define dso_local i64 @test_calling_strlen_with_64_bit_pointer(ptr noundef %s)
61 // CHECK-NEXT: entry:
62 // CHECK-NEXT: %s.addr = alloca ptr, align 8
63 // CHECK-NEXT: store ptr %s, ptr %s.addr, align 8
64 // CHECK-NEXT: %0 = load ptr, ptr %s.addr, align 8
65 // CHECK-NEXT: %call = call i64 @strlen(ptr noundef %0)
66 // CHECK-NEXT: ret i64 %call
67 return strlen ( s );