blob: a6e6e9b385650fe23e135564c960b36b2f3a3373 [file] [log] [blame]
Alexey Bataevf8365372017-11-17 17:57:25 +00001// Test host codegen.
2// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s
3// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s
4// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
5// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s
6// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
7// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
8
9// Test target simd codegen - host bc file has to be created first.
10// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm-bc %s -o %t-ppc-host.bc
11// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s -check-prefix=TCHECK
12// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t %s
13// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s -check-prefix=TCHECK
14// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm-bc %s -o %t-x86-host.bc
15// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s -check-prefix=TCHECK
16// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -o %t %s
17// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -fopenmp-is-device -fopenmp-host-ir-file-path %t-x86-host.bc -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s -check-prefix=TCHECK
18
19// Check that no target code is emmitted if no omptests flag was provided.
20// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK-NTARGET
21
22// expected-no-diagnostics
23#ifndef HEADER
24#define HEADER
25
26// CHECK-DAG: [[SA:%.+]] = type { [4 x i32] }
27// CHECK-DAG: [[SB:%.+]] = type { [8 x i32] }
28// CHECK-DAG: [[SC:%.+]] = type { [16 x i32] }
29// CHECK-DAG: [[SD:%.+]] = type { [32 x i32] }
30// CHECK-DAG: [[SE:%.+]] = type { [64 x i32] }
31// CHECK-DAG: [[ST1:%.+]] = type { [228 x i32] }
32// CHECK-DAG: [[ST2:%.+]] = type { [1128 x i32] }
33// CHECK-DAG: [[ENTTY:%.+]] = type { i8*, i8*, i[[SZ:32|64]], i32, i32 }
34// CHECK-DAG: [[DEVTY:%.+]] = type { i8*, i8*, [[ENTTY]]*, [[ENTTY]]* }
35// CHECK-DAG: [[DSCTY:%.+]] = type { i32, [[DEVTY]]*, [[ENTTY]]*, [[ENTTY]]* }
36
37// TCHECK: [[ENTTY:%.+]] = type { i8*, i8*, i[[SZ:32|64]], i32, i32 }
38
39// CHECK-DAG: $[[REGFN:\.omp_offloading\..+]] = comdat
40
41// CHECK-DAG: [[A1:@.+]] = internal global [[SA]]
42// CHECK-DAG: [[A2:@.+]] = global [[SA]]
43// CHECK-DAG: [[B1:@.+]] = global [[SB]]
44// CHECK-DAG: [[B2:@.+]] = global [[SB]]
45// CHECK-DAG: [[C1:@.+]] = internal global [[SC]]
46// CHECK-DAG: [[D1:@.+]] = global [[SD]]
47// CHECK-DAG: [[E1:@.+]] = global [[SE]]
48// CHECK-DAG: [[T1:@.+]] = global [[ST1]]
49// CHECK-DAG: [[T2:@.+]] = global [[ST2]]
50
51// CHECK-NTARGET-DAG: [[SA:%.+]] = type { [4 x i32] }
52// CHECK-NTARGET-DAG: [[SB:%.+]] = type { [8 x i32] }
53// CHECK-NTARGET-DAG: [[SC:%.+]] = type { [16 x i32] }
54// CHECK-NTARGET-DAG: [[SD:%.+]] = type { [32 x i32] }
55// CHECK-NTARGET-DAG: [[SE:%.+]] = type { [64 x i32] }
56// CHECK-NTARGET-DAG: [[ST1:%.+]] = type { [228 x i32] }
57// CHECK-NTARGET-DAG: [[ST2:%.+]] = type { [1128 x i32] }
58// CHECK-NTARGET-NOT: type { i8*, i8*, %
59// CHECK-NTARGET-NOT: type { i32, %
60
61// We have 7 target regions
62
63// CHECK-DAG: {{@.+}} = private constant i8 0
64// TCHECK-NOT: {{@.+}} = private constant i8 0
65// CHECK-DAG: {{@.+}} = private unnamed_addr constant [1 x i[[SZ]]] [i[[SZ]] 4]
George Rokos63bc9d62017-11-21 18:25:12 +000066// CHECK-DAG: {{@.+}} = private unnamed_addr constant [1 x i64] [i64 288]
Alexey Bataevf8365372017-11-17 17:57:25 +000067// CHECK-DAG: {{@.+}} = private constant i8 0
68// CHECK-DAG: {{@.+}} = private unnamed_addr constant [1 x i[[SZ]]] [i[[SZ]] 4]
George Rokos63bc9d62017-11-21 18:25:12 +000069// CHECK-DAG: {{@.+}} = private unnamed_addr constant [1 x i64] [i64 288]
Alexey Bataevf8365372017-11-17 17:57:25 +000070// CHECK-DAG: {{@.+}} = private constant i8 0
71// CHECK-DAG: {{@.+}} = private unnamed_addr constant [1 x i[[SZ]]] [i[[SZ]] 4]
George Rokos63bc9d62017-11-21 18:25:12 +000072// CHECK-DAG: {{@.+}} = private unnamed_addr constant [1 x i64] [i64 288]
Alexey Bataevf8365372017-11-17 17:57:25 +000073// CHECK-DAG: {{@.+}} = private constant i8 0
74// CHECK-DAG: {{@.+}} = private unnamed_addr constant [1 x i[[SZ]]] [i[[SZ]] 4]
George Rokos63bc9d62017-11-21 18:25:12 +000075// CHECK-DAG: {{@.+}} = private unnamed_addr constant [1 x i64] [i64 288]
Alexey Bataevf8365372017-11-17 17:57:25 +000076// CHECK-DAG: {{@.+}} = private constant i8 0
77// CHECK-DAG: {{@.+}} = private unnamed_addr constant [1 x i[[SZ]]] [i[[SZ]] 4]
George Rokos63bc9d62017-11-21 18:25:12 +000078// CHECK-DAG: {{@.+}} = private unnamed_addr constant [1 x i64] [i64 288]
Alexey Bataevf8365372017-11-17 17:57:25 +000079// CHECK-DAG: {{@.+}} = private constant i8 0
80// CHECK-DAG: {{@.+}} = private unnamed_addr constant [1 x i[[SZ]]] [i[[SZ]] 4]
George Rokos63bc9d62017-11-21 18:25:12 +000081// CHECK-DAG: {{@.+}} = private unnamed_addr constant [1 x i64] [i64 288]
Alexey Bataevf8365372017-11-17 17:57:25 +000082// CHECK-DAG: {{@.+}} = private constant i8 0
83// CHECK-DAG: {{@.+}} = private unnamed_addr constant [1 x i[[SZ]]] [i[[SZ]] 4]
George Rokos63bc9d62017-11-21 18:25:12 +000084// CHECK-DAG: {{@.+}} = private unnamed_addr constant [1 x i64] [i64 288]
Alexey Bataevf8365372017-11-17 17:57:25 +000085// CHECK-DAG: {{@.+}} = private constant i8 0
86// CHECK-DAG: {{@.+}} = private unnamed_addr constant [1 x i[[SZ]]] [i[[SZ]] 4]
George Rokos63bc9d62017-11-21 18:25:12 +000087// CHECK-DAG: {{@.+}} = private unnamed_addr constant [1 x i64] [i64 288]
Alexey Bataevf8365372017-11-17 17:57:25 +000088// CHECK-DAG: {{@.+}} = private constant i8 0
89// CHECK-DAG: {{@.+}} = private unnamed_addr constant [1 x i[[SZ]]] [i[[SZ]] 4]
George Rokos63bc9d62017-11-21 18:25:12 +000090// CHECK-DAG: {{@.+}} = private unnamed_addr constant [1 x i64] [i64 288]
Alexey Bataevf8365372017-11-17 17:57:25 +000091// CHECK-DAG: {{@.+}} = private constant i8 0
92// CHECK-DAG: {{@.+}} = private unnamed_addr constant [1 x i[[SZ]]] [i[[SZ]] 4]
George Rokos63bc9d62017-11-21 18:25:12 +000093// CHECK-DAG: {{@.+}} = private unnamed_addr constant [1 x i64] [i64 288]
Alexey Bataevf8365372017-11-17 17:57:25 +000094// CHECK-DAG: {{@.+}} = private constant i8 0
95// CHECK-DAG: {{@.+}} = private unnamed_addr constant [1 x i[[SZ]]] [i[[SZ]] 4]
George Rokos63bc9d62017-11-21 18:25:12 +000096// CHECK-DAG: {{@.+}} = private unnamed_addr constant [1 x i64] [i64 288]
Alexey Bataevf8365372017-11-17 17:57:25 +000097// CHECK-DAG: {{@.+}} = private constant i8 0
98// CHECK-DAG: {{@.+}} = private unnamed_addr constant [1 x i[[SZ]]] [i[[SZ]] 4]
George Rokos63bc9d62017-11-21 18:25:12 +000099// CHECK-DAG: {{@.+}} = private unnamed_addr constant [1 x i64] [i64 288]
Alexey Bataevf8365372017-11-17 17:57:25 +0000100
101// CHECK-NTARGET-NOT: private constant i8 0
102// CHECK-NTARGET-NOT: private unnamed_addr constant [1 x i
103
104// CHECK-DAG: [[NAMEPTR1:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME1:__omp_offloading_[0-9a-f]+_[0-9a-f]+__Z.+_l[0-9]+]]\00"
105// CHECK-DAG: [[ENTRY1:@.+]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR1]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
106// CHECK-DAG: [[NAMEPTR2:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME2:.+]]\00"
107// CHECK-DAG: [[ENTRY2:@.+]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR2]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
108// CHECK-DAG: [[NAMEPTR3:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME3:.+]]\00"
109// CHECK-DAG: [[ENTRY3:@.+]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR3]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
110// CHECK-DAG: [[NAMEPTR4:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME4:.+]]\00"
111// CHECK-DAG: [[ENTRY4:@.+]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR4]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
112// CHECK-DAG: [[NAMEPTR5:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME5:.+]]\00"
113// CHECK-DAG: [[ENTRY5:@.+]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR5]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
114// CHECK-DAG: [[NAMEPTR6:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME6:.+]]\00"
115// CHECK-DAG: [[ENTRY6:@.+]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR6]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
116// CHECK-DAG: [[NAMEPTR7:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME7:.+]]\00"
117// CHECK-DAG: [[ENTRY7:@.+]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR7]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
118// CHECK-DAG: [[NAMEPTR8:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME8:.+]]\00"
119// CHECK-DAG: [[ENTRY8:@.+]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR8]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
120// CHECK-DAG: [[NAMEPTR9:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME9:.+]]\00"
121// CHECK-DAG: [[ENTRY9:@.+]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR9]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
122// CHECK-DAG: [[NAMEPTR10:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME10:.+]]\00"
123// CHECK-DAG: [[ENTRY10:@.+]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR10]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
124// CHECK-DAG: [[NAMEPTR11:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME11:.+]]\00"
125// CHECK-DAG: [[ENTRY11:@.+]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR11]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
126// CHECK-DAG: [[NAMEPTR12:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME12:.+]]\00"
127// CHECK-DAG: [[ENTRY12:@.+]] = constant [[ENTTY]] { i8* @{{.*}}, i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR12]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
128
129// TCHECK-DAG: [[NAMEPTR1:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME1:__omp_offloading_[0-9a-f]+_[0-9a-f]+__Z.+_l[0-9]+]]\00"
130// TCHECK-DAG: [[ENTRY1:@.+]] = constant [[ENTTY]] { i8* bitcast (void (i[[SZ]])* @{{.*}} to i8*), i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR1]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
131// TCHECK-DAG: [[NAMEPTR2:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME2:.+]]\00"
132// TCHECK-DAG: [[ENTRY2:@.+]] = constant [[ENTTY]] { i8* bitcast (void (i[[SZ]])* @{{.*}} to i8*), i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR2]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
133// TCHECK-DAG: [[NAMEPTR3:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME3:.+]]\00"
134// TCHECK-DAG: [[ENTRY3:@.+]] = constant [[ENTTY]] { i8* bitcast (void (i[[SZ]])* @{{.*}} to i8*), i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR3]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
135// TCHECK-DAG: [[NAMEPTR4:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME4:.+]]\00"
136// TCHECK-DAG: [[ENTRY4:@.+]] = constant [[ENTTY]] { i8* bitcast (void (i[[SZ]])* @{{.*}} to i8*), i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR4]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
137// TCHECK-DAG: [[NAMEPTR5:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME5:.+]]\00"
138// TCHECK-DAG: [[ENTRY5:@.+]] = constant [[ENTTY]] { i8* bitcast (void (i[[SZ]])* @{{.*}} to i8*), i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR5]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
139// TCHECK-DAG: [[NAMEPTR6:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME6:.+]]\00"
140// TCHECK-DAG: [[ENTRY6:@.+]] = constant [[ENTTY]] { i8* bitcast (void (i[[SZ]])* @{{.*}} to i8*), i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR6]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
141// TCHECK-DAG: [[NAMEPTR7:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME7:.+]]\00"
142// TCHECK-DAG: [[ENTRY7:@.+]] = constant [[ENTTY]] { i8* bitcast (void (i[[SZ]])* @{{.*}} to i8*), i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR7]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
143// TCHECK-DAG: [[NAMEPTR8:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME8:.+]]\00"
144// TCHECK-DAG: [[ENTRY8:@.+]] = constant [[ENTTY]] { i8* bitcast (void (i[[SZ]])* @{{.*}} to i8*), i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR8]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
145// TCHECK-DAG: [[NAMEPTR9:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME9:.+]]\00"
146// TCHECK-DAG: [[ENTRY9:@.+]] = constant [[ENTTY]] { i8* bitcast (void (i[[SZ]])* @{{.*}} to i8*), i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR9]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
147// TCHECK-DAG: [[NAMEPTR10:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME10:.+]]\00"
148// TCHECK-DAG: [[ENTRY10:@.+]] = constant [[ENTTY]] { i8* bitcast (void (i[[SZ]])* @{{.*}} to i8*), i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR10]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
149// TCHECK-DAG: [[NAMEPTR11:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME11:.+]]\00"
150// TCHECK-DAG: [[ENTRY11:@.+]] = constant [[ENTTY]] { i8* bitcast (void (i[[SZ]])* @{{.*}} to i8*), i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR11]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
151// TCHECK-DAG: [[NAMEPTR12:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME12:.+]]\00"
152// TCHECK-DAG: [[ENTRY12:@.+]] = constant [[ENTTY]] { i8* bitcast (void (i[[SZ]])* @{{.*}} to i8*), i8* getelementptr inbounds ([{{.*}} x i8], [{{.*}} x i8]* [[NAMEPTR12]], i32 0, i32 0), i[[SZ]] 0, i32 0, i32 0 }, section ".omp_offloading.entries", align 1
153
154// CHECK: [[ENTBEGIN:@.+]] = external constant [[ENTTY]]
155// CHECK: [[ENTEND:@.+]] = external constant [[ENTTY]]
156// CHECK: [[DEVBEGIN:@.+]] = external constant i8
157// CHECK: [[DEVEND:@.+]] = external constant i8
158// CHECK: [[IMAGES:@.+]] = internal unnamed_addr constant [1 x [[DEVTY]]] [{{.+}} { i8* [[DEVBEGIN]], i8* [[DEVEND]], [[ENTTY]]* [[ENTBEGIN]], [[ENTTY]]* [[ENTEND]] }], comdat($[[REGFN]])
159// CHECK: [[DESC:@.+]] = internal constant [[DSCTY]] { i32 1, [[DEVTY]]* getelementptr inbounds ([1 x [[DEVTY]]], [1 x [[DEVTY]]]* [[IMAGES]], i32 0, i32 0), [[ENTTY]]* [[ENTBEGIN]], [[ENTTY]]* [[ENTEND]] }, comdat($[[REGFN]])
160
161// We have 4 initializers, one for the 500 priority, another one for 501, or more for the default priority, and the last one for the offloading registration function.
162// CHECK: @llvm.global_ctors = appending global [4 x { i32, void ()*, i8* }] [
163// CHECK-SAME: { i32, void ()*, i8* } { i32 500, void ()* [[P500:@[^,]+]], i8* null },
164// CHECK-SAME: { i32, void ()*, i8* } { i32 501, void ()* [[P501:@[^,]+]], i8* null },
165// CHECK-SAME: { i32, void ()*, i8* } { i32 65535, void ()* [[PMAX:@[^,]+]], i8* null },
166// CHECK-SAME: { i32, void ()*, i8* } { i32 0, void ()* bitcast (void (i8*)* @[[REGFN]] to void ()*), i8* bitcast (void (i8*)* @[[REGFN]] to i8*) }]
167
168// CHECK-NTARGET: @llvm.global_ctors = appending global [3 x { i32, void ()*, i8* }] [
169
170extern int *R;
171
172struct SA {
173 int arr[4];
174 void foo() {
175 int a = *R;
176 a += 1;
177 *R = a;
178 }
179 SA() {
180 int a = *R;
181 a += 2;
182 *R = a;
183 }
184 ~SA() {
185 int a = *R;
186 a += 3;
187 *R = a;
188 }
189};
190
191struct SB {
192 int arr[8];
193 void foo() {
194 int a = *R;
195 #pragma omp target simd
196 for (int i = 0; i < 10; ++i)
197 a += 4;
198 *R = a;
199 }
200 SB() {
201 int a = *R;
202 a += 5;
203 *R = a;
204 }
205 ~SB() {
206 int a = *R;
207 a += 6;
208 *R = a;
209 }
210};
211
212struct SC {
213 int arr[16];
214 void foo() {
215 int a = *R;
216 a += 7;
217 *R = a;
218 }
219 SC() {
220 int a = *R;
221 #pragma omp target simd
222 for (int i = 0; i < 10; ++i)
223 a += 8;
224 *R = a;
225 }
226 ~SC() {
227 int a = *R;
228 a += 9;
229 *R = a;
230 }
231};
232
233struct SD {
234 int arr[32];
235 void foo() {
236 int a = *R;
237 a += 10;
238 *R = a;
239 }
240 SD() {
241 int a = *R;
242 a += 11;
243 *R = a;
244 }
245 ~SD() {
246 int a = *R;
247 #pragma omp target simd
248 for (int i = 0; i < 10; ++i)
249 a += 12;
250 *R = a;
251 }
252};
253
254struct SE {
255 int arr[64];
256 void foo() {
257 int a = *R;
258 #pragma omp target simd if(target: 0)
259 for (int i = 0; i < 10; ++i)
260 a += 13;
261 *R = a;
262 }
263 SE() {
264 int a = *R;
265 #pragma omp target simd
266 for (int i = 0; i < 10; ++i)
267 a += 14;
268 *R = a;
269 }
270 ~SE() {
271 int a = *R;
272 #pragma omp target simd
273 for (int i = 0; i < 10; ++i)
274 a += 15;
275 *R = a;
276 }
277};
278
279template <int x>
280struct ST {
281 int arr[128 + x];
282 void foo() {
283 int a = *R;
284 #pragma omp target simd
285 for (int i = 0; i < 10; ++i)
286 a += 16 + x;
287 *R = a;
288 }
289 ST() {
290 int a = *R;
291 #pragma omp target simd
292 for (int i = 0; i < 10; ++i)
293 a += 17 + x;
294 *R = a;
295 }
296 ~ST() {
297 int a = *R;
298 #pragma omp target simd
299 for (int i = 0; i < 10; ++i)
300 a += 18 + x;
301 *R = a;
302 }
303};
304
305// We have to make sure we us all the target regions:
306//CHECK-DAG: define internal void @[[NAME1]](
307//CHECK-DAG: call void @[[NAME1]](
308//CHECK-DAG: define internal void @[[NAME2]](
309//CHECK-DAG: call void @[[NAME2]](
310//CHECK-DAG: define internal void @[[NAME3]](
311//CHECK-DAG: call void @[[NAME3]](
312//CHECK-DAG: define internal void @[[NAME4]](
313//CHECK-DAG: call void @[[NAME4]](
314//CHECK-DAG: define internal void @[[NAME5]](
315//CHECK-DAG: call void @[[NAME5]](
316//CHECK-DAG: define internal void @[[NAME6]](
317//CHECK-DAG: call void @[[NAME6]](
318//CHECK-DAG: define internal void @[[NAME7]](
319//CHECK-DAG: call void @[[NAME7]](
320//CHECK-DAG: define internal void @[[NAME8]](
321//CHECK-DAG: call void @[[NAME8]](
322//CHECK-DAG: define internal void @[[NAME9]](
323//CHECK-DAG: call void @[[NAME9]](
324//CHECK-DAG: define internal void @[[NAME10]](
325//CHECK-DAG: call void @[[NAME10]](
326//CHECK-DAG: define internal void @[[NAME11]](
327//CHECK-DAG: call void @[[NAME11]](
328//CHECK-DAG: define internal void @[[NAME12]](
329//CHECK-DAG: call void @[[NAME12]](
330
331//TCHECK-DAG: define void @[[NAME1]](
332//TCHECK-DAG: define void @[[NAME2]](
333//TCHECK-DAG: define void @[[NAME3]](
334//TCHECK-DAG: define void @[[NAME4]](
335//TCHECK-DAG: define void @[[NAME5]](
336//TCHECK-DAG: define void @[[NAME6]](
337//TCHECK-DAG: define void @[[NAME7]](
338//TCHECK-DAG: define void @[[NAME8]](
339//TCHECK-DAG: define void @[[NAME9]](
340//TCHECK-DAG: define void @[[NAME10]](
341//TCHECK-DAG: define void @[[NAME11]](
342//TCHECK-DAG: define void @[[NAME12]](
343
344// CHECK-NTARGET-NOT: __tgt_target
345// CHECK-NTARGET-NOT: __tgt_register_lib
346// CHECK-NTARGET-NOT: __tgt_unregister_lib
347
348// TCHECK-NOT: __tgt_target
349// TCHECK-NOT: __tgt_register_lib
350// TCHECK-NOT: __tgt_unregister_lib
351
352// We have 2 initializers with priority 500
353//CHECK: define internal void [[P500]](
354//CHECK: call void @{{.+}}()
355//CHECK: call void @{{.+}}()
356//CHECK-NOT: call void @{{.+}}()
357//CHECK: ret void
358
359// We have 1 initializers with priority 501
360//CHECK: define internal void [[P501]](
361//CHECK: call void @{{.+}}()
362//CHECK-NOT: call void @{{.+}}()
363//CHECK: ret void
364
365// We have 6 initializers with default priority
366//CHECK: define internal void [[PMAX]](
367//CHECK: call void @{{.+}}()
368//CHECK: call void @{{.+}}()
369//CHECK: call void @{{.+}}()
370//CHECK: call void @{{.+}}()
371//CHECK: call void @{{.+}}()
372//CHECK: call void @{{.+}}()
373//CHECK-NOT: call void @{{.+}}()
374//CHECK: ret void
375
376// Check registration and unregistration
377
378//CHECK: define internal void @[[UNREGFN:.+]](i8*)
379//CHECK-SAME: comdat($[[REGFN]]) {
380//CHECK: call i32 @__tgt_unregister_lib([[DSCTY]]* [[DESC]])
381//CHECK: ret void
382//CHECK: declare i32 @__tgt_unregister_lib([[DSCTY]]*)
383
384//CHECK: define linkonce hidden void @[[REGFN]](i8*)
385//CHECK-SAME: comdat {
386//CHECK: call i32 @__tgt_register_lib([[DSCTY]]* [[DESC]])
387//CHECK: call i32 @__cxa_atexit(void (i8*)* @[[UNREGFN]], i8* bitcast ([[DSCTY]]* [[DESC]] to i8*),
388//CHECK: ret void
389//CHECK: declare i32 @__tgt_register_lib([[DSCTY]]*)
390
391static __attribute__((init_priority(500))) SA a1;
392SA a2;
393SB __attribute__((init_priority(500))) b1;
394SB __attribute__((init_priority(501))) b2;
395static SC c1;
396SD d1;
397SE e1;
398ST<100> t1;
399ST<1000> t2;
400
401
402int bar(int a){
403 int r = a;
404
405 a1.foo();
406 a2.foo();
407 b1.foo();
408 b2.foo();
409 c1.foo();
410 d1.foo();
411 e1.foo();
412 t1.foo();
413 t2.foo();
414
415 #pragma omp target simd
416 for (int i = 0; i < 10; ++i)
417 ++r;
418
419 return r + *R;
420}
421
422// Check metadata is properly generated:
423// CHECK: !omp_offload.info = !{!{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}}
424// CHECK-DAG: = !{i32 0, i32 [[DEVID:-?[0-9]+]], i32 [[FILEID:-?[0-9]+]], !"_ZN2SB3fooEv", i32 195, i32 {{[0-9]+}}}
425// CHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_ZN2SDD1Ev", i32 247, i32 {{[0-9]+}}}
426// CHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_ZN2SEC1Ev", i32 265, i32 {{[0-9]+}}}
427// CHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_ZN2SED1Ev", i32 272, i32 {{[0-9]+}}}
428// CHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_ZN2STILi1000EE3fooEv", i32 284, i32 {{[0-9]+}}}
429// CHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_ZN2STILi100EEC1Ev", i32 291, i32 {{[0-9]+}}}
430// CHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_Z3bari", i32 415, i32 {{[0-9]+}}}
431// CHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_ZN2STILi100EED1Ev", i32 298, i32 {{[0-9]+}}}
432// CHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_ZN2STILi1000EEC1Ev", i32 291, i32 {{[0-9]+}}}
433// CHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_ZN2STILi1000EED1Ev", i32 298, i32 {{[0-9]+}}}
434// CHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_ZN2STILi100EE3fooEv", i32 284, i32 {{[0-9]+}}}
435// CHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_ZN2SCC1Ev", i32 221, i32 {{[0-9]+}}}
436
437// TCHECK: !omp_offload.info = !{!{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}, !{{[0-9]+}}}
438// TCHECK-DAG: = !{i32 0, i32 [[DEVID:-?[0-9]+]], i32 [[FILEID:-?[0-9]+]], !"_ZN2SB3fooEv", i32 195, i32 {{[0-9]+}}}
439// TCHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_ZN2SDD1Ev", i32 247, i32 {{[0-9]+}}}
440// TCHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_ZN2SEC1Ev", i32 265, i32 {{[0-9]+}}}
441// TCHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_ZN2SED1Ev", i32 272, i32 {{[0-9]+}}}
442// TCHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_ZN2STILi1000EE3fooEv", i32 284, i32 {{[0-9]+}}}
443// TCHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_ZN2STILi100EEC1Ev", i32 291, i32 {{[0-9]+}}}
444// TCHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_Z3bari", i32 415, i32 {{[0-9]+}}}
445// TCHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_ZN2STILi100EED1Ev", i32 298, i32 {{[0-9]+}}}
446// TCHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_ZN2STILi1000EEC1Ev", i32 291, i32 {{[0-9]+}}}
447// TCHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_ZN2STILi1000EED1Ev", i32 298, i32 {{[0-9]+}}}
448// TCHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_ZN2STILi100EE3fooEv", i32 284, i32 {{[0-9]+}}}
449// TCHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_ZN2SCC1Ev", i32 221, i32 {{[0-9]+}}}
450
451#endif