blob: 05830a34c175a642cea811ee5f56a656349a2a15 [file] [log] [blame]
Alexey Bataevdfa430f2017-12-08 15:03:50 +00001// Test host codegen.
Fangrui Songdbc96b52020-02-03 10:09:39 -08002// 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
Alexey Bataevdfa430f2017-12-08 15:03:50 +00003// 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
Fangrui Songdbc96b52020-02-03 10:09:39 -08004// 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
Alexey Bataevdfa430f2017-12-08 15:03:50 +00006// 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
Fangrui Songdbc96b52020-02-03 10:09:39 -08007// 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
Alexey Bataevdfa430f2017-12-08 15:03:50 +00008
Fangrui Songdbc96b52020-02-03 10:09:39 -08009// 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
Alexey Bataeva8a9153a2017-12-29 18:07:07 +000010// 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
Fangrui Songdbc96b52020-02-03 10:09:39 -080011// 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
Alexey Bataeva8a9153a2017-12-29 18:07:07 +000013// 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
Fangrui Songdbc96b52020-02-03 10:09:39 -080014// 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
Alexey Bataeva8a9153a2017-12-29 18:07:07 +000015// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
16
Alexey Bataevdfa430f2017-12-08 15:03:50 +000017// Test target teams distribute 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
Fangrui Songdbc96b52020-02-03 10:09:39 -080019// 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
Alexey Bataevdfa430f2017-12-08 15:03:50 +000020// 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
Fangrui Songdbc96b52020-02-03 10:09:39 -080021// 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
Alexey Bataevdfa430f2017-12-08 15:03:50 +000022// 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
Fangrui Songdbc96b52020-02-03 10:09:39 -080023// 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
Alexey Bataevdfa430f2017-12-08 15:03:50 +000024// 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
Fangrui Songdbc96b52020-02-03 10:09:39 -080025// 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
Alexey Bataevdfa430f2017-12-08 15:03:50 +000026
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
Fangrui Songdbc96b52020-02-03 10:09:39 -080028// 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
Alexey Bataeva8a9153a2017-12-29 18:07:07 +000029// 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
Fangrui Songdbc96b52020-02-03 10:09:39 -080030// 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
Alexey Bataeva8a9153a2017-12-29 18:07:07 +000031// 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
Fangrui Songdbc96b52020-02-03 10:09:39 -080032// 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
Alexey Bataeva8a9153a2017-12-29 18:07:07 +000033// 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
Fangrui Songdbc96b52020-02-03 10:09:39 -080034// 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
Alexey Bataeva8a9153a2017-12-29 18:07:07 +000035// SIMD-ONLY1-NOT: {{__kmpc|__tgt}}
36
Alexander Kornienko2a8c18d2018-04-06 15:14:32 +000037// Check that no target code is emitted if no omptests flag was provided.
Fangrui Songdbc96b52020-02-03 10:09:39 -080038// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK-NTARGET
Alexey Bataevdfa430f2017-12-08 15:03:50 +000039
Fangrui Songdbc96b52020-02-03 10:09:39 -080040// 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
Alexey Bataeva8a9153a2017-12-29 18:07:07 +000041// SIMD-ONLY2-NOT: {{__kmpc|__tgt}}
42
Saiyedul Islama1bdf8f2020-08-27 18:50:34 +000043// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s
44// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s
45// RUN: %clang_cc1 -fopenmp -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
46// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s
47// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
48// RUN: %clang_cc1 -fopenmp -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
49
50// RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
51// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s
52// RUN: %clang_cc1 -fopenmp-simd -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
53// RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
54// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s
55// RUN: %clang_cc1 -fopenmp-simd -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
56// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
57
58// Test target teams distribute codegen - host bc file has to be created first.
59// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm-bc %s -o %t-ppc-host.bc
60// RUN: %clang_cc1 -verify -fopenmp -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
61// RUN: %clang_cc1 -fopenmp -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
62// RUN: %clang_cc1 -fopenmp -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
63// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm-bc %s -o %t-x86-host.bc
64// RUN: %clang_cc1 -verify -fopenmp -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
65// RUN: %clang_cc1 -fopenmp -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
66// RUN: %clang_cc1 -fopenmp -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
67
68// RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm-bc %s -o %t-ppc-host.bc
69// RUN: %clang_cc1 -verify -fopenmp-simd -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
70// RUN: %clang_cc1 -fopenmp-simd -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
71// RUN: %clang_cc1 -fopenmp-simd -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
72// RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm-bc %s -o %t-x86-host.bc
73// RUN: %clang_cc1 -verify -fopenmp-simd -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
74// RUN: %clang_cc1 -fopenmp-simd -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
75// RUN: %clang_cc1 -fopenmp-simd -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
76// SIMD-ONLY1-NOT: {{__kmpc|__tgt}}
77
78// Check that no target code is emitted if no omptests flag was provided.
79// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK-NTARGET
80
81// RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY2 %s
82// SIMD-ONLY2-NOT: {{__kmpc|__tgt}}
83
Alexey Bataevdfa430f2017-12-08 15:03:50 +000084// expected-no-diagnostics
85#ifndef HEADER
86#define HEADER
87
88// CHECK-DAG: [[SA:%.+]] = type { [4 x i32] }
89// CHECK-DAG: [[SB:%.+]] = type { [8 x i32] }
90// CHECK-DAG: [[SC:%.+]] = type { [16 x i32] }
91// CHECK-DAG: [[SD:%.+]] = type { [32 x i32] }
92// CHECK-DAG: [[SE:%.+]] = type { [64 x i32] }
93// CHECK-DAG: [[ST1:%.+]] = type { [228 x i32] }
94// CHECK-DAG: [[ST2:%.+]] = type { [1128 x i32] }
95// CHECK-DAG: [[ENTTY:%.+]] = type { i8*, i8*, i[[SZ:32|64]], i32, i32 }
Alexey Bataevdfa430f2017-12-08 15:03:50 +000096
97// TCHECK: [[ENTTY:%.+]] = type { i8*, i8*, i[[SZ:32|64]], i32, i32 }
98
Alexey Bataevdfa430f2017-12-08 15:03:50 +000099// CHECK-DAG: [[A1:@.+]] = internal global [[SA]]
Fangrui Songfd739802020-12-31 00:27:11 -0800100// CHECK-DAG: [[A2:@.+]] ={{.*}} global [[SA]]
101// CHECK-DAG: [[B1:@.+]] ={{.*}} global [[SB]]
102// CHECK-DAG: [[B2:@.+]] ={{.*}} global [[SB]]
Alexey Bataevdfa430f2017-12-08 15:03:50 +0000103// CHECK-DAG: [[C1:@.+]] = internal global [[SC]]
Fangrui Songfd739802020-12-31 00:27:11 -0800104// CHECK-DAG: [[D1:@.+]] ={{.*}} global [[SD]]
105// CHECK-DAG: [[E1:@.+]] ={{.*}} global [[SE]]
106// CHECK-DAG: [[T1:@.+]] ={{.*}} global [[ST1]]
107// CHECK-DAG: [[T2:@.+]] ={{.*}} global [[ST2]]
Alexey Bataevdfa430f2017-12-08 15:03:50 +0000108
109// CHECK-NTARGET-DAG: [[SA:%.+]] = type { [4 x i32] }
110// CHECK-NTARGET-DAG: [[SB:%.+]] = type { [8 x i32] }
111// CHECK-NTARGET-DAG: [[SC:%.+]] = type { [16 x i32] }
112// CHECK-NTARGET-DAG: [[SD:%.+]] = type { [32 x i32] }
113// CHECK-NTARGET-DAG: [[SE:%.+]] = type { [64 x i32] }
114// CHECK-NTARGET-DAG: [[ST1:%.+]] = type { [228 x i32] }
115// CHECK-NTARGET-DAG: [[ST2:%.+]] = type { [1128 x i32] }
116// CHECK-NTARGET-NOT: type { i8*, i8*, %
117// CHECK-NTARGET-NOT: type { i32, %
118
119// We have 7 target regions
120
Fangrui Songfd739802020-12-31 00:27:11 -0800121// CHECK-DAG: {{@.+}} = weak{{.*}} constant i8 0
122// TCHECK-NOT: {{@.+}} = weak{{.*}} constant i8 0
Alexey Bataeva90fc662019-06-25 16:00:43 +0000123// CHECK-DAG: {{@.+}} = private unnamed_addr constant [1 x i64] [i64 4]
Alexey Bataevb3638132018-07-19 16:34:13 +0000124// CHECK-DAG: {{@.+}} = private unnamed_addr constant [1 x i64] [i64 800]
Fangrui Songfd739802020-12-31 00:27:11 -0800125// CHECK-DAG: {{@.+}} = weak{{.*}} constant i8 0
Alexey Bataeva90fc662019-06-25 16:00:43 +0000126// CHECK-DAG: {{@.+}} = private unnamed_addr constant [1 x i64] [i64 4]
Alexey Bataevb3638132018-07-19 16:34:13 +0000127// CHECK-DAG: {{@.+}} = private unnamed_addr constant [1 x i64] [i64 800]
Fangrui Songfd739802020-12-31 00:27:11 -0800128// CHECK-DAG: {{@.+}} = weak{{.*}} constant i8 0
Alexey Bataeva90fc662019-06-25 16:00:43 +0000129// CHECK-DAG: {{@.+}} = private unnamed_addr constant [1 x i64] [i64 4]
Alexey Bataevb3638132018-07-19 16:34:13 +0000130// CHECK-DAG: {{@.+}} = private unnamed_addr constant [1 x i64] [i64 800]
Fangrui Songfd739802020-12-31 00:27:11 -0800131// CHECK-DAG: {{@.+}} = weak{{.*}} constant i8 0
Alexey Bataeva90fc662019-06-25 16:00:43 +0000132// CHECK-DAG: {{@.+}} = private unnamed_addr constant [1 x i64] [i64 4]
Alexey Bataevb3638132018-07-19 16:34:13 +0000133// CHECK-DAG: {{@.+}} = private unnamed_addr constant [1 x i64] [i64 800]
Fangrui Songfd739802020-12-31 00:27:11 -0800134// CHECK-DAG: {{@.+}} = weak{{.*}} constant i8 0
Alexey Bataeva90fc662019-06-25 16:00:43 +0000135// CHECK-DAG: {{@.+}} = private unnamed_addr constant [1 x i64] [i64 4]
Alexey Bataevb3638132018-07-19 16:34:13 +0000136// CHECK-DAG: {{@.+}} = private unnamed_addr constant [1 x i64] [i64 800]
Fangrui Songfd739802020-12-31 00:27:11 -0800137// CHECK-DAG: {{@.+}} = weak{{.*}} constant i8 0
Alexey Bataeva90fc662019-06-25 16:00:43 +0000138// CHECK-DAG: {{@.+}} = private unnamed_addr constant [1 x i64] [i64 4]
Alexey Bataevb3638132018-07-19 16:34:13 +0000139// CHECK-DAG: {{@.+}} = private unnamed_addr constant [1 x i64] [i64 800]
Fangrui Songfd739802020-12-31 00:27:11 -0800140// CHECK-DAG: {{@.+}} = weak{{.*}} constant i8 0
Alexey Bataeva90fc662019-06-25 16:00:43 +0000141// CHECK-DAG: {{@.+}} = private unnamed_addr constant [1 x i64] [i64 4]
Alexey Bataevb3638132018-07-19 16:34:13 +0000142// CHECK-DAG: {{@.+}} = private unnamed_addr constant [1 x i64] [i64 800]
Fangrui Songfd739802020-12-31 00:27:11 -0800143// CHECK-DAG: {{@.+}} = weak{{.*}} constant i8 0
Alexey Bataeva90fc662019-06-25 16:00:43 +0000144// CHECK-DAG: {{@.+}} = private unnamed_addr constant [1 x i64] [i64 4]
Alexey Bataevb3638132018-07-19 16:34:13 +0000145// CHECK-DAG: {{@.+}} = private unnamed_addr constant [1 x i64] [i64 800]
Fangrui Songfd739802020-12-31 00:27:11 -0800146// CHECK-DAG: {{@.+}} = weak{{.*}} constant i8 0
Alexey Bataeva90fc662019-06-25 16:00:43 +0000147// CHECK-DAG: {{@.+}} = private unnamed_addr constant [1 x i64] [i64 4]
Alexey Bataevb3638132018-07-19 16:34:13 +0000148// CHECK-DAG: {{@.+}} = private unnamed_addr constant [1 x i64] [i64 800]
Fangrui Songfd739802020-12-31 00:27:11 -0800149// CHECK-DAG: {{@.+}} = weak{{.*}} constant i8 0
Alexey Bataeva90fc662019-06-25 16:00:43 +0000150// CHECK-DAG: {{@.+}} = private unnamed_addr constant [1 x i64] [i64 4]
Alexey Bataevb3638132018-07-19 16:34:13 +0000151// CHECK-DAG: {{@.+}} = private unnamed_addr constant [1 x i64] [i64 800]
Fangrui Songfd739802020-12-31 00:27:11 -0800152// CHECK-DAG: {{@.+}} = weak{{.*}} constant i8 0
Alexey Bataeva90fc662019-06-25 16:00:43 +0000153// CHECK-DAG: {{@.+}} = private unnamed_addr constant [1 x i64] [i64 4]
Alexey Bataevb3638132018-07-19 16:34:13 +0000154// CHECK-DAG: {{@.+}} = private unnamed_addr constant [1 x i64] [i64 800]
Fangrui Songfd739802020-12-31 00:27:11 -0800155// CHECK-DAG: {{@.+}} = weak{{.*}} constant i8 0
Alexey Bataeva90fc662019-06-25 16:00:43 +0000156// CHECK-DAG: {{@.+}} = private unnamed_addr constant [1 x i64] [i64 4]
Alexey Bataevb3638132018-07-19 16:34:13 +0000157// CHECK-DAG: {{@.+}} = private unnamed_addr constant [1 x i64] [i64 800]
Alexey Bataevdfa430f2017-12-08 15:03:50 +0000158
Alexey Bataev9a700172018-05-08 14:16:57 +0000159// CHECK-NTARGET-NOT: weak constant i8 0
Alexey Bataevdfa430f2017-12-08 15:03:50 +0000160// CHECK-NTARGET-NOT: private unnamed_addr constant [1 x i
161
162// CHECK-DAG: [[NAMEPTR1:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME1:__omp_offloading_[0-9a-f]+_[0-9a-f]+__Z.+_l[0-9]+]]\00"
Fangrui Songfd739802020-12-31 00:27:11 -0800163// CHECK-DAG: [[ENTRY1:@.+]] = weak{{.*}} 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
Alexey Bataevdfa430f2017-12-08 15:03:50 +0000164// CHECK-DAG: [[NAMEPTR2:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME2:.+]]\00"
Fangrui Songfd739802020-12-31 00:27:11 -0800165// CHECK-DAG: [[ENTRY2:@.+]] = weak{{.*}} 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
Alexey Bataevdfa430f2017-12-08 15:03:50 +0000166// CHECK-DAG: [[NAMEPTR3:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME3:.+]]\00"
Fangrui Songfd739802020-12-31 00:27:11 -0800167// CHECK-DAG: [[ENTRY3:@.+]] = weak{{.*}} 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
Alexey Bataevdfa430f2017-12-08 15:03:50 +0000168// CHECK-DAG: [[NAMEPTR4:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME4:.+]]\00"
Fangrui Songfd739802020-12-31 00:27:11 -0800169// CHECK-DAG: [[ENTRY4:@.+]] = weak{{.*}} 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
Alexey Bataevdfa430f2017-12-08 15:03:50 +0000170// CHECK-DAG: [[NAMEPTR5:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME5:.+]]\00"
Fangrui Songfd739802020-12-31 00:27:11 -0800171// CHECK-DAG: [[ENTRY5:@.+]] = weak{{.*}} 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
Alexey Bataevdfa430f2017-12-08 15:03:50 +0000172// CHECK-DAG: [[NAMEPTR6:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME6:.+]]\00"
Fangrui Songfd739802020-12-31 00:27:11 -0800173// CHECK-DAG: [[ENTRY6:@.+]] = weak{{.*}} 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
Alexey Bataevdfa430f2017-12-08 15:03:50 +0000174// CHECK-DAG: [[NAMEPTR7:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME7:.+]]\00"
Fangrui Songfd739802020-12-31 00:27:11 -0800175// CHECK-DAG: [[ENTRY7:@.+]] = weak{{.*}} 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
Alexey Bataevdfa430f2017-12-08 15:03:50 +0000176// CHECK-DAG: [[NAMEPTR8:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME8:.+]]\00"
Fangrui Songfd739802020-12-31 00:27:11 -0800177// CHECK-DAG: [[ENTRY8:@.+]] = weak{{.*}} 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
Alexey Bataevdfa430f2017-12-08 15:03:50 +0000178// CHECK-DAG: [[NAMEPTR9:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME9:.+]]\00"
Fangrui Songfd739802020-12-31 00:27:11 -0800179// CHECK-DAG: [[ENTRY9:@.+]] = weak{{.*}} 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
Alexey Bataevdfa430f2017-12-08 15:03:50 +0000180// CHECK-DAG: [[NAMEPTR10:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME10:.+]]\00"
Fangrui Songfd739802020-12-31 00:27:11 -0800181// CHECK-DAG: [[ENTRY10:@.+]] = weak{{.*}} 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
Alexey Bataevdfa430f2017-12-08 15:03:50 +0000182// CHECK-DAG: [[NAMEPTR11:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME11:.+]]\00"
Fangrui Songfd739802020-12-31 00:27:11 -0800183// CHECK-DAG: [[ENTRY11:@.+]] = weak{{.*}} 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
Alexey Bataevdfa430f2017-12-08 15:03:50 +0000184// CHECK-DAG: [[NAMEPTR12:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME12:.+]]\00"
Fangrui Songfd739802020-12-31 00:27:11 -0800185// CHECK-DAG: [[ENTRY12:@.+]] = weak{{.*}} 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
Alexey Bataevdfa430f2017-12-08 15:03:50 +0000186
187// TCHECK-DAG: [[NAMEPTR1:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME1:__omp_offloading_[0-9a-f]+_[0-9a-f]+__Z.+_l[0-9]+]]\00"
Fangrui Songfd739802020-12-31 00:27:11 -0800188// TCHECK-DAG: [[ENTRY1:@.+]] = weak{{.*}} 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
Alexey Bataevdfa430f2017-12-08 15:03:50 +0000189// TCHECK-DAG: [[NAMEPTR2:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME2:.+]]\00"
Fangrui Songfd739802020-12-31 00:27:11 -0800190// TCHECK-DAG: [[ENTRY2:@.+]] = weak{{.*}} 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
Alexey Bataevdfa430f2017-12-08 15:03:50 +0000191// TCHECK-DAG: [[NAMEPTR3:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME3:.+]]\00"
Fangrui Songfd739802020-12-31 00:27:11 -0800192// TCHECK-DAG: [[ENTRY3:@.+]] = weak{{.*}} 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
Alexey Bataevdfa430f2017-12-08 15:03:50 +0000193// TCHECK-DAG: [[NAMEPTR4:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME4:.+]]\00"
Fangrui Songfd739802020-12-31 00:27:11 -0800194// TCHECK-DAG: [[ENTRY4:@.+]] = weak{{.*}} 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
Alexey Bataevdfa430f2017-12-08 15:03:50 +0000195// TCHECK-DAG: [[NAMEPTR5:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME5:.+]]\00"
Fangrui Songfd739802020-12-31 00:27:11 -0800196// TCHECK-DAG: [[ENTRY5:@.+]] = weak{{.*}} 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
Alexey Bataevdfa430f2017-12-08 15:03:50 +0000197// TCHECK-DAG: [[NAMEPTR6:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME6:.+]]\00"
Fangrui Songfd739802020-12-31 00:27:11 -0800198// TCHECK-DAG: [[ENTRY6:@.+]] = weak{{.*}} 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
Alexey Bataevdfa430f2017-12-08 15:03:50 +0000199// TCHECK-DAG: [[NAMEPTR7:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME7:.+]]\00"
Fangrui Songfd739802020-12-31 00:27:11 -0800200// TCHECK-DAG: [[ENTRY7:@.+]] = weak{{.*}} 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
Alexey Bataevdfa430f2017-12-08 15:03:50 +0000201// TCHECK-DAG: [[NAMEPTR8:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME8:.+]]\00"
Fangrui Songfd739802020-12-31 00:27:11 -0800202// TCHECK-DAG: [[ENTRY8:@.+]] = weak{{.*}} 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
Alexey Bataevdfa430f2017-12-08 15:03:50 +0000203// TCHECK-DAG: [[NAMEPTR9:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME9:.+]]\00"
Fangrui Songfd739802020-12-31 00:27:11 -0800204// TCHECK-DAG: [[ENTRY9:@.+]] = weak{{.*}} 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
Alexey Bataevdfa430f2017-12-08 15:03:50 +0000205// TCHECK-DAG: [[NAMEPTR10:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME10:.+]]\00"
Fangrui Songfd739802020-12-31 00:27:11 -0800206// TCHECK-DAG: [[ENTRY10:@.+]] = weak{{.*}} 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
Alexey Bataevdfa430f2017-12-08 15:03:50 +0000207// TCHECK-DAG: [[NAMEPTR11:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME11:.+]]\00"
Fangrui Songfd739802020-12-31 00:27:11 -0800208// TCHECK-DAG: [[ENTRY11:@.+]] = weak{{.*}} 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
Alexey Bataevdfa430f2017-12-08 15:03:50 +0000209// TCHECK-DAG: [[NAMEPTR12:@.+]] = internal unnamed_addr constant [{{.*}} x i8] c"[[NAME12:.+]]\00"
Fangrui Songfd739802020-12-31 00:27:11 -0800210// TCHECK-DAG: [[ENTRY12:@.+]] = weak{{.*}} 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
Alexey Bataevdfa430f2017-12-08 15:03:50 +0000211
Alexey Bataevdfa430f2017-12-08 15:03:50 +0000212// 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.
Sergey Dmitriev5836c352019-10-15 18:42:47 +0000213// CHECK: @llvm.global_ctors = appending global [4 x { i32, void ()*, i8* }] [
Alexey Bataevdfa430f2017-12-08 15:03:50 +0000214// CHECK-SAME: { i32, void ()*, i8* } { i32 500, void ()* [[P500:@[^,]+]], i8* null },
215// CHECK-SAME: { i32, void ()*, i8* } { i32 501, void ()* [[P501:@[^,]+]], i8* null },
216// CHECK-SAME: { i32, void ()*, i8* } { i32 65535, void ()* [[PMAX:@[^,]+]], i8* null },
Alexey Bataevdfa430f2017-12-08 15:03:50 +0000217
218// CHECK-NTARGET: @llvm.global_ctors = appending global [3 x { i32, void ()*, i8* }] [
219
220extern int *R;
221
222struct SA {
223 int arr[4];
224 void foo() {
225 int a = *R;
226 a += 1;
227 *R = a;
228 }
229 SA() {
230 int a = *R;
231 a += 2;
232 *R = a;
233 }
234 ~SA() {
235 int a = *R;
236 a += 3;
237 *R = a;
238 }
239};
240
241struct SB {
242 int arr[8];
243 void foo() {
244 int a = *R;
245 #pragma omp target teams distribute
246 for (int i = 0; i < 10; ++i)
247 a += 4;
248 *R = a;
249 }
250 SB() {
251 int a = *R;
252 a += 5;
253 *R = a;
254 }
255 ~SB() {
256 int a = *R;
257 a += 6;
258 *R = a;
259 }
260};
261
262struct SC {
263 int arr[16];
264 void foo() {
265 int a = *R;
266 a += 7;
267 *R = a;
268 }
269 SC() {
270 int a = *R;
271 #pragma omp target teams distribute
272 for (int i = 0; i < 10; ++i)
273 a += 8;
274 *R = a;
275 }
276 ~SC() {
277 int a = *R;
278 a += 9;
279 *R = a;
280 }
281};
282
283struct SD {
284 int arr[32];
285 void foo() {
286 int a = *R;
287 a += 10;
288 *R = a;
289 }
290 SD() {
291 int a = *R;
292 a += 11;
293 *R = a;
294 }
295 ~SD() {
296 int a = *R;
297 #pragma omp target teams distribute
298 for (int i = 0; i < 10; ++i)
299 a += 12;
300 *R = a;
301 }
302};
303
304struct SE {
305 int arr[64];
306 void foo() {
307 int a = *R;
308 #pragma omp target teams distribute if(target: 0)
309 for (int i = 0; i < 10; ++i)
310 a += 13;
311 *R = a;
312 }
313 SE() {
314 int a = *R;
315 #pragma omp target teams distribute
316 for (int i = 0; i < 10; ++i)
317 a += 14;
318 *R = a;
319 }
320 ~SE() {
321 int a = *R;
322 #pragma omp target teams distribute
323 for (int i = 0; i < 10; ++i)
324 a += 15;
325 *R = a;
326 }
327};
328
329template <int x>
330struct ST {
331 int arr[128 + x];
332 void foo() {
333 int a = *R;
334 #pragma omp target teams distribute
335 for (int i = 0; i < 10; ++i)
336 a += 16 + x;
337 *R = a;
338 }
339 ST() {
340 int a = *R;
341 #pragma omp target teams distribute
342 for (int i = 0; i < 10; ++i)
343 a += 17 + x;
344 *R = a;
345 }
346 ~ST() {
347 int a = *R;
348 #pragma omp target teams distribute
349 for (int i = 0; i < 10; ++i)
350 a += 18 + x;
351 *R = a;
352 }
353};
354
355// We have to make sure we us all the target regions:
356//CHECK-DAG: define internal void @[[NAME1]](
357//CHECK-DAG: call void @[[NAME1]](
358//CHECK-DAG: define internal void @[[NAME2]](
359//CHECK-DAG: call void @[[NAME2]](
360//CHECK-DAG: define internal void @[[NAME3]](
361//CHECK-DAG: call void @[[NAME3]](
362//CHECK-DAG: define internal void @[[NAME4]](
363//CHECK-DAG: call void @[[NAME4]](
364//CHECK-DAG: define internal void @[[NAME5]](
365//CHECK-DAG: call void @[[NAME5]](
366//CHECK-DAG: define internal void @[[NAME6]](
367//CHECK-DAG: call void @[[NAME6]](
368//CHECK-DAG: define internal void @[[NAME7]](
369//CHECK-DAG: call void @[[NAME7]](
370//CHECK-DAG: define internal void @[[NAME8]](
371//CHECK-DAG: call void @[[NAME8]](
372//CHECK-DAG: define internal void @[[NAME9]](
373//CHECK-DAG: call void @[[NAME9]](
374//CHECK-DAG: define internal void @[[NAME10]](
375//CHECK-DAG: call void @[[NAME10]](
376//CHECK-DAG: define internal void @[[NAME11]](
377//CHECK-DAG: call void @[[NAME11]](
378//CHECK-DAG: define internal void @[[NAME12]](
379//CHECK-DAG: call void @[[NAME12]](
380
Fangrui Songfd739802020-12-31 00:27:11 -0800381//TCHECK-DAG: define weak{{.*}} void @[[NAME1]](
382//TCHECK-DAG: define weak{{.*}} void @[[NAME2]](
383//TCHECK-DAG: define weak{{.*}} void @[[NAME3]](
384//TCHECK-DAG: define weak{{.*}} void @[[NAME4]](
385//TCHECK-DAG: define weak{{.*}} void @[[NAME5]](
386//TCHECK-DAG: define weak{{.*}} void @[[NAME6]](
387//TCHECK-DAG: define weak{{.*}} void @[[NAME7]](
388//TCHECK-DAG: define weak{{.*}} void @[[NAME8]](
389//TCHECK-DAG: define weak{{.*}} void @[[NAME9]](
390//TCHECK-DAG: define weak{{.*}} void @[[NAME10]](
391//TCHECK-DAG: define weak{{.*}} void @[[NAME11]](
392//TCHECK-DAG: define weak{{.*}} void @[[NAME12]](
Alexey Bataevdfa430f2017-12-08 15:03:50 +0000393
394// CHECK-NTARGET-NOT: __tgt_target
Alexey Bataevdfa430f2017-12-08 15:03:50 +0000395
396// TCHECK-NOT: __tgt_target
Alexey Bataevdfa430f2017-12-08 15:03:50 +0000397
398// We have 2 initializers with priority 500
399//CHECK: define internal void [[P500]](
400//CHECK: call void @{{.+}}()
401//CHECK: call void @{{.+}}()
402//CHECK-NOT: call void @{{.+}}()
403//CHECK: ret void
404
405// We have 1 initializers with priority 501
406//CHECK: define internal void [[P501]](
407//CHECK: call void @{{.+}}()
408//CHECK-NOT: call void @{{.+}}()
409//CHECK: ret void
410
411// We have 6 initializers with default priority
412//CHECK: define internal void [[PMAX]](
413//CHECK: call void @{{.+}}()
414//CHECK: call void @{{.+}}()
415//CHECK: call void @{{.+}}()
416//CHECK: call void @{{.+}}()
417//CHECK: call void @{{.+}}()
418//CHECK: call void @{{.+}}()
419//CHECK-NOT: call void @{{.+}}()
420//CHECK: ret void
421
Alexey Bataevdfa430f2017-12-08 15:03:50 +0000422static __attribute__((init_priority(500))) SA a1;
423SA a2;
424SB __attribute__((init_priority(500))) b1;
425SB __attribute__((init_priority(501))) b2;
426static SC c1;
427SD d1;
428SE e1;
429ST<100> t1;
430ST<1000> t2;
431
432
433int bar(int a){
434 int r = a;
435
436 a1.foo();
437 a2.foo();
438 b1.foo();
439 b2.foo();
440 c1.foo();
441 d1.foo();
442 e1.foo();
443 t1.foo();
444 t2.foo();
445
446 #pragma omp target teams distribute
447 for (int i = 0; i < 10; ++i)
448 ++r;
449
450 return r + *R;
451}
452
453// Check metadata is properly generated:
454// 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]+}}}
Saiyedul Islama1bdf8f2020-08-27 18:50:34 +0000455// CHECK-DAG: = !{i32 0, i32 [[DEVID:-?[0-9]+]], i32 [[FILEID:-?[0-9]+]], !"_ZN2SB3fooEv", i32 245, i32 {{[0-9]+}}}
456// CHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_ZN2SDD1Ev", i32 297, i32 {{[0-9]+}}}
457// CHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_ZN2SEC1Ev", i32 315, i32 {{[0-9]+}}}
458// CHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_ZN2SED1Ev", i32 322, i32 {{[0-9]+}}}
459// CHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_ZN2STILi1000EE3fooEv", i32 334, i32 {{[0-9]+}}}
460// CHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_ZN2STILi100EEC1Ev", i32 341, i32 {{[0-9]+}}}
461// CHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_Z3bari", i32 446, i32 {{[0-9]+}}}
462// CHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_ZN2STILi100EED1Ev", i32 348, i32 {{[0-9]+}}}
463// CHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_ZN2STILi1000EEC1Ev", i32 341, i32 {{[0-9]+}}}
464// CHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_ZN2STILi1000EED1Ev", i32 348, i32 {{[0-9]+}}}
465// CHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_ZN2STILi100EE3fooEv", i32 334, i32 {{[0-9]+}}}
466// CHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_ZN2SCC1Ev", i32 271, i32 {{[0-9]+}}}
Alexey Bataevdfa430f2017-12-08 15:03:50 +0000467
468// 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]+}}}
Saiyedul Islama1bdf8f2020-08-27 18:50:34 +0000469// TCHECK-DAG: = !{i32 0, i32 [[DEVID:-?[0-9]+]], i32 [[FILEID:-?[0-9]+]], !"_ZN2SB3fooEv", i32 245, i32 {{[0-9]+}}}
470// TCHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_ZN2SDD1Ev", i32 297, i32 {{[0-9]+}}}
471// TCHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_ZN2SEC1Ev", i32 315, i32 {{[0-9]+}}}
472// TCHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_ZN2SED1Ev", i32 322, i32 {{[0-9]+}}}
473// TCHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_ZN2STILi1000EE3fooEv", i32 334, i32 {{[0-9]+}}}
474// TCHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_ZN2STILi100EEC1Ev", i32 341, i32 {{[0-9]+}}}
475// TCHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_Z3bari", i32 446, i32 {{[0-9]+}}}
476// TCHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_ZN2STILi100EED1Ev", i32 348, i32 {{[0-9]+}}}
477// TCHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_ZN2STILi1000EEC1Ev", i32 341, i32 {{[0-9]+}}}
478// TCHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_ZN2STILi1000EED1Ev", i32 348, i32 {{[0-9]+}}}
479// TCHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_ZN2STILi100EE3fooEv", i32 334, i32 {{[0-9]+}}}
480// TCHECK-DAG: = !{i32 0, i32 [[DEVID]], i32 [[FILEID]], !"_ZN2SCC1Ev", i32 271, i32 {{[0-9]+}}}
Alexey Bataevdfa430f2017-12-08 15:03:50 +0000481
482#endif