xref: /llvm-project/clang/test/OpenMP/align_clause_global_codegen.cpp (revision 0c6f2f629cc0017361310fa4c132090413a874db)
1 // RUN: %clang_cc1 -emit-llvm -o - -fopenmp \
2 // RUN:  -triple i386-unknown-unknown %s \
3 // RUN:  | FileCheck %s --check-prefixes=CHECK,CHECK-32
4 
5 // RUN: %clang_cc1 -emit-llvm -o - -fopenmp \
6 // RUN:  -triple x86_64-unknown-linux-gnu %s \
7 // RUN:  | FileCheck %s --check-prefixes=CHECK,CHECK-64
8 
9 typedef enum omp_allocator_handle_t {
10   omp_null_allocator = 0,
11   omp_default_mem_alloc = 1,
12   omp_large_cap_mem_alloc = 2,
13   omp_const_mem_alloc = 3,
14   omp_high_bw_mem_alloc = 4,
15   omp_low_lat_mem_alloc = 5,
16   omp_cgroup_mem_alloc = 6,
17   omp_pteam_mem_alloc = 7,
18   omp_thread_mem_alloc = 8,
19   KMP_ALLOCATOR_MAX_HANDLE = __UINTPTR_MAX__
20 } omp_allocator_handle_t;
21 
22 //
23 // Should allow larger alignment.
24 //
25 
26 // CHECK: @foo_global1 = global float 0.000000e+00, align 16
27 float foo_global1;
28 #pragma omp allocate(foo_global1) align(16)
29 
30 // CHECK: @foo_global2 = global float 0.000000e+00, align 16
31 float foo_global2;
32 #pragma omp allocate(foo_global2) allocator(omp_default_mem_alloc) align(16)
33 
34 // CHECK: @foo_global3 = global float 0.000000e+00, align 16
35 float foo_global3;
36 #pragma omp allocate(foo_global3) allocator(omp_large_cap_mem_alloc) align(16)
37 
38 // CHECK: @foop_global1 = global ptr null, align 16
39 int *foop_global1;
40 #pragma omp allocate(foop_global1) align(16)
41 
42 //
43 // Should use natural alignment when alignment specified is too small.
44 //
45 
46 // CHECK: @foo_global4 = global float 0.000000e+00, align 4
47 float foo_global4;
48 #pragma omp allocate(foo_global4) align(2)
49 
50 // CHECK: @foo_global5 = global float 0.000000e+00, align 4
51 float foo_global5;
52 #pragma omp allocate(foo_global5) allocator(omp_default_mem_alloc) align(2)
53 
54 // CHECK: @foo_global6 = global float 0.000000e+00, align 4
55 float foo_global6;
56 #pragma omp allocate(foo_global6) allocator(omp_large_cap_mem_alloc) align(2)
57 
58 // CHECK-32: @foop_global2 = global ptr null, align 4
59 // CHECK-64: @foop_global2 = global ptr null, align 8
60 int *foop_global2;
61 #pragma omp allocate(foop_global2) align(2)
62