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