File: irbuilder_nested_openmp_parallel_empty.c

package info (click to toggle)
llvm-toolchain-15 1%3A15.0.6-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,554,644 kB
  • sloc: cpp: 5,922,452; ansic: 1,012,136; asm: 674,362; python: 191,568; objc: 73,855; f90: 42,327; lisp: 31,913; pascal: 11,973; javascript: 10,144; sh: 9,421; perl: 7,447; ml: 5,527; awk: 3,523; makefile: 2,520; xml: 885; cs: 573; fortran: 567
file content (124 lines) | stat: -rw-r--r-- 6,342 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
// RUN: %clang_cc1 -no-opaque-pointers -verify -fopenmp -fopenmp-enable-irbuilder -x c++ -emit-llvm %s -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -o - | FileCheck %s --check-prefixes=ALL,IRBUILDER
//  %clang_cc1 -no-opaque-pointers -fopenmp -fopenmp-enable-irbuilder -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o /tmp/t1 %s
//  %clang_cc1 -no-opaque-pointers -fopenmp -fopenmp-enable-irbuilder -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -debug-info-kind=limited -std=c++11 -include-pch /tmp/t1 -verify %s -emit-llvm -o - | FileCheck --check-prefixes=ALL-DEBUG,IRBUILDER-DEBUG %s

// expected-no-diagnostics

// TODO: Teach the update script to check new functions too.

#ifndef HEADER
#define HEADER

// ALL-LABEL: @_Z17nested_parallel_0v(
// ALL-NEXT:  entry:
// ALL-NEXT:    [[OMP_GLOBAL_THREAD_NUM:%.*]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* @[[GLOB1:[0-9]+]])
// ALL-NEXT:    br label [[OMP_PARALLEL:%.*]]
// ALL:       omp_parallel:
// ALL-NEXT:    call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* @[[GLOB1]], i32 0, void (i32*, i32*, ...)* bitcast (void (i32*, i32*)* @_Z17nested_parallel_0v..omp_par.1 to void (i32*, i32*, ...)*))
// ALL-NEXT:    br label [[OMP_PAR_OUTLINED_EXIT12:%.*]]
// ALL:       omp.par.outlined.exit12:
// ALL-NEXT:    br label [[OMP_PAR_EXIT_SPLIT:%.*]]
// ALL:       omp.par.exit.split:
// ALL-NEXT:    ret void
//
void nested_parallel_0(void) {
#pragma omp parallel
  {
#pragma omp parallel
    {
    }
  }
}

// ALL-LABEL: @_Z17nested_parallel_1Pfid(
// ALL-NEXT:  entry:
// ALL-NEXT:    [[STRUCTARG14:%.*]] = alloca { i32*, double*, float** }, align 8
// ALL-NEXT:    [[R_ADDR:%.*]] = alloca float*, align 8
// ALL-NEXT:    [[A_ADDR:%.*]] = alloca i32, align 4
// ALL-NEXT:    [[B_ADDR:%.*]] = alloca double, align 8
// ALL-NEXT:    store float* [[R:%.*]], float** [[R_ADDR]], align 8
// ALL-NEXT:    store i32 [[A:%.*]], i32* [[A_ADDR]], align 4
// ALL-NEXT:    store double [[B:%.*]], double* [[B_ADDR]], align 8
// ALL-NEXT:    [[OMP_GLOBAL_THREAD_NUM:%.*]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* @[[GLOB1]])
// ALL-NEXT:    br label [[OMP_PARALLEL:%.*]]
// ALL:       omp_parallel:
// ALL-NEXT:    [[GEP_A_ADDR15:%.*]] = getelementptr { i32*, double*, float** }, { i32*, double*, float** }* [[STRUCTARG14]], i32 0, i32 0
// ALL-NEXT:    store i32* [[A_ADDR]], i32** [[GEP_A_ADDR15]], align 8
// ALL-NEXT:    [[GEP_B_ADDR16:%.*]] = getelementptr { i32*, double*, float** }, { i32*, double*, float** }* [[STRUCTARG14]], i32 0, i32 1
// ALL-NEXT:    store double* [[B_ADDR]], double** [[GEP_B_ADDR16]], align 8
// ALL-NEXT:    [[GEP_R_ADDR17:%.*]] = getelementptr { i32*, double*, float** }, { i32*, double*, float** }* [[STRUCTARG14]], i32 0, i32 2
// ALL-NEXT:    store float** [[R_ADDR]], float*** [[GEP_R_ADDR17]], align 8
// ALL-NEXT:    call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* @[[GLOB1]], i32 1, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, { i32*, double*, float** }*)* @_Z17nested_parallel_1Pfid..omp_par.2 to void (i32*, i32*, ...)*), { i32*, double*, float** }* [[STRUCTARG14]])
// ALL-NEXT:    br label [[OMP_PAR_OUTLINED_EXIT13:%.*]]
// ALL:       omp.par.outlined.exit13:
// ALL-NEXT:    br label [[OMP_PAR_EXIT_SPLIT:%.*]]
// ALL:       omp.par.exit.split:
// ALL-NEXT:    ret void
//
void nested_parallel_1(float *r, int a, double b) {
#pragma omp parallel
  {
#pragma omp parallel
    {
      *r = a + b;
    }
  }
}

// ALL-LABEL: @_Z17nested_parallel_2Pfid(
// ALL-NEXT:  entry:
// ALL-NEXT:    [[STRUCTARG:%.*]] = alloca { i32*, double*, float** }, align 8
// ALL-NEXT:    [[R_ADDR:%.*]] = alloca float*, align 8
// ALL-NEXT:    [[A_ADDR:%.*]] = alloca i32, align 4
// ALL-NEXT:    [[B_ADDR:%.*]] = alloca double, align 8
// ALL-NEXT:    store float* [[R:%.*]], float** [[R_ADDR]], align 8
// ALL-NEXT:    store i32 [[A:%.*]], i32* [[A_ADDR]], align 4
// ALL-NEXT:    store double [[B:%.*]], double* [[B_ADDR]], align 8
// ALL-NEXT:    [[OMP_GLOBAL_THREAD_NUM:%.*]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* @[[GLOB1]])
// ALL-NEXT:    br label [[OMP_PARALLEL:%.*]]
// ALL:       omp_parallel:
// ALL-NEXT:    [[GEP_A_ADDR:%.*]] = getelementptr { i32*, double*, float** }, { i32*, double*, float** }* [[STRUCTARG]], i32 0, i32 0
// ALL-NEXT:    store i32* [[A_ADDR]], i32** [[GEP_A_ADDR]], align 8
// ALL-NEXT:    [[GEP_B_ADDR:%.*]] = getelementptr { i32*, double*, float** }, { i32*, double*, float** }* [[STRUCTARG]], i32 0, i32 1
// ALL-NEXT:    store double* [[B_ADDR]], double** [[GEP_B_ADDR]], align 8
// ALL-NEXT:    [[GEP_R_ADDR:%.*]] = getelementptr { i32*, double*, float** }, { i32*, double*, float** }* [[STRUCTARG]], i32 0, i32 2
// ALL-NEXT:    store float** [[R_ADDR]], float*** [[GEP_R_ADDR]], align 8
// ALL-NEXT:    call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* @[[GLOB1]], i32 1, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, { i32*, double*, float** }*)* @_Z17nested_parallel_2Pfid..omp_par.5 to void (i32*, i32*, ...)*), { i32*, double*, float** }* [[STRUCTARG]])
// ALL-NEXT:    br label [[OMP_PAR_OUTLINED_EXIT55:%.*]]
// ALL:       omp.par.outlined.exit55:
// ALL-NEXT:    br label [[OMP_PAR_EXIT_SPLIT:%.*]]
// ALL:       omp.par.exit.split:
// ALL-NEXT:    [[TMP0:%.*]] = load i32, i32* [[A_ADDR]], align 4
// ALL-NEXT:    [[CONV56:%.*]] = sitofp i32 [[TMP0]] to double
// ALL-NEXT:    [[TMP1:%.*]] = load double, double* [[B_ADDR]], align 8
// ALL-NEXT:    [[ADD57:%.*]] = fadd double [[CONV56]], [[TMP1]]
// ALL-NEXT:    [[CONV58:%.*]] = fptrunc double [[ADD57]] to float
// ALL-NEXT:    [[TMP2:%.*]] = load float*, float** [[R_ADDR]], align 8
// ALL-NEXT:    store float [[CONV58]], float* [[TMP2]], align 4
// ALL-NEXT:    ret void
//
void nested_parallel_2(float *r, int a, double b) {
#pragma omp parallel
  {
    *r = a + b;
#pragma omp parallel
    {
      *r = a + b;
#pragma omp parallel
      {
        *r = a + b;
      }
      *r = a + b;
#pragma omp parallel
      {
        *r = a + b;
      }
      *r = a + b;
    }
    *r = a + b;
  }
  *r = a + b;
}

#endif