Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / OpenMP / metadirective_device_kind_codegen.cpp
blobbfbfec8b27e1e88f23c648feaf5cee2d9ea5fb18
1 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-linux -emit-llvm %s -fexceptions -fcxx-exceptions -o - -fsanitize-address-use-after-scope | FileCheck %s
2 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple aarch64-unknown-linux -emit-llvm %s -fexceptions -fcxx-exceptions -o - -fsanitize-address-use-after-scope | FileCheck %s
3 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple ppc64le-unknown-linux -emit-llvm %s -fexceptions -fcxx-exceptions -o - -fsanitize-address-use-after-scope | FileCheck %s
5 // expected-no-diagnostics
6 #ifndef HEADER
7 #define HEADER
9 void bar();
11 void foo() {
12 #pragma omp metadirective when(device = {kind(any)} \
13 : parallel)
14 bar();
15 #pragma omp metadirective when(device = {kind(host, cpu)} \
16 : parallel for num_threads(4))
17 for (int i = 0; i < 100; i++)
19 #pragma omp metadirective when(device = {kind(host)} \
20 : parallel for)
21 for (int i = 0; i < 100; i++)
23 #pragma omp metadirective when(device = {kind(nohost, gpu)} \
24 :) when(device = {kind(cpu)} \
25 : parallel)
26 bar();
27 #pragma omp metadirective when(device = {kind(any, cpu)} \
28 : parallel)
29 bar();
30 #pragma omp metadirective when(device = {kind(any, host)} \
31 : parallel)
32 bar();
33 #pragma omp metadirective when(device = {kind(gpu)} \
34 : target parallel for) default(parallel for)
35 for (int i = 0; i < 100; i++)
39 // CHECK-LABEL: define {{.+}} void @_Z3foov()
40 // CHECK: @__kmpc_fork_call(ptr {{.+}}, i32 0, ptr [[OUTLINED_1:@.+]])
41 // CHECK-NEXT: @__kmpc_push_num_threads
42 // CHECK: @__kmpc_fork_call(ptr {{.+}}, i32 0, ptr [[OUTLINED_2:@.+]])
43 // CHECK: @__kmpc_fork_call(ptr {{.+}}, i32 0, ptr [[OUTLINED_3:@.+]])
44 // CHECK: @__kmpc_fork_call(ptr {{.+}}, i32 0, ptr [[OUTLINED_4:@.+]])
45 // CHECK: @__kmpc_fork_call(ptr {{.+}}, i32 0, ptr [[OUTLINED_5:@.+]])
46 // CHECK: @__kmpc_fork_call(ptr {{.+}}, i32 0, ptr [[OUTLINED_6:@.+]])
47 // CHECK: @__kmpc_fork_call(ptr {{.+}}, i32 0, ptr [[OUTLINED_7:@.+]])
48 // CHECK: ret void
50 // CHECK: define internal void [[OUTLINED_1]](
51 // CHECK: void @_Z3barv()
52 // CHECK: ret void
54 // CHECK: define internal void [[OUTLINED_2]](
55 // CHECK: call void @__kmpc_for_static_init
56 // CHECK: call void @__kmpc_for_static_fini
57 // CHECK: ret void
59 // CHECK: define internal void [[OUTLINED_3]](
60 // CHECK: call void @__kmpc_for_static_init
61 // CHECK: call void @__kmpc_for_static_fini
62 // CHECK: ret void
64 // CHECK: define internal void [[OUTLINED_4]](
65 // CHECK: void @_Z3barv()
66 // CHECK: ret void
68 // CHECK: define internal void [[OUTLINED_5]](
69 // CHECK: void @_Z3barv()
70 // CHECK: ret void
72 // CHECK: define internal void [[OUTLINED_6]](
73 // CHECK: void @_Z3barv()
74 // CHECK: ret void
76 // CHECK: define internal void [[OUTLINED_7]](
77 // CHECK: call void @__kmpc_for_static_init
78 // CHECK: call void @__kmpc_for_static_fini
79 // CHECK: ret void
81 #endif