Home | History | Annotate | Download | only in OpenMP
      1 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck %s
      2 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-apple-darwin10 -emit-pch -o %t %s
      3 // RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin10 -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
      4 // RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++11 -DLAMBDA -triple x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck -check-prefix=LAMBDA %s
      5 // RUN: %clang_cc1 -verify -fopenmp -x c++ -fblocks -DBLOCKS -triple x86_64-apple-darwin10 -emit-llvm %s -o - | FileCheck -check-prefix=BLOCKS %s
      6 // expected-no-diagnostics
      7 // REQUIRES: x86-registered-target
      8 #ifndef HEADER
      9 #define HEADER
     10 
     11 template <class T>
     12 struct S {
     13   T f;
     14   S(T a) : f(a) {}
     15   S() : f() {}
     16   S<T> &operator=(const S<T> &);
     17   operator T() { return T(); }
     18   ~S() {}
     19 };
     20 
     21 volatile int g = 1212;
     22 
     23 // CHECK: [[S_FLOAT_TY:%.+]] = type { float }
     24 // CHECK [[CAP_MAIN_TY:%.+]] = type { i{{[0-9]+}}*, [2 x i{{[0-9]+}}]*, [2 x [[S_FLOAT_TY]]]*, [[S_FLOAT_TY]]*, i{{[0-9]+}}* }
     25 // CHECK: [[S_INT_TY:%.+]] = type { i32 }
     26 // CHECK-DAG: [[SINGLE_BARRIER_LOC:@.+]] = private unnamed_addr constant %{{.+}} { i32 0, i32 322, i32 0, i32 0, i8*
     27 // CHECK-DAG: [[SECTIONS_BARRIER_LOC:@.+]] = private unnamed_addr constant %{{.+}} { i32 0, i32 194, i32 0, i32 0, i8*
     28 // CHECK-DAG: [[X:@.+]] = global double 0.0
     29 template <typename T>
     30 T tmain() {
     31   S<T> test;
     32   T t_var = T();
     33   T vec[] = {1, 2};
     34   S<T> s_arr[] = {1, 2};
     35   S<T> var(3);
     36 #pragma omp parallel
     37 #pragma omp sections lastprivate(t_var, vec, s_arr, var)
     38   {
     39     vec[0] = t_var;
     40 #pragma omp section
     41     s_arr[0] = var;
     42   }
     43   return T();
     44 }
     45 
     46 namespace A {
     47 double x;
     48 }
     49 namespace B {
     50 using A::x;
     51 }
     52 
     53 int main() {
     54   static int sivar;
     55 #ifdef LAMBDA
     56   // LAMBDA: [[G:@.+]] = global i{{[0-9]+}} 1212,
     57   // LAMBDA-LABEL: @main
     58   // LAMBDA: call void [[OUTER_LAMBDA:@.+]](
     59   [&]() {
     60   // LAMBDA: define{{.*}} internal{{.*}} void [[OUTER_LAMBDA]](
     61   // LAMBDA: call void {{.+}} @__kmpc_fork_call({{.+}}, i32 1, {{.+}}* [[OMP_REGION:@.+]] to {{.+}})
     62 #pragma omp parallel
     63 #pragma omp sections lastprivate(g, sivar)
     64   {
     65     // LAMBDA: define{{.*}} internal{{.*}} void [[OMP_REGION]](i32* noalias [[GTID:%.+]], i32* noalias %{{.+}}, i32* dereferenceable(4) [[SIVAR_REF:%.+]])
     66     // LAMBDA: alloca i{{[0-9]+}},
     67     // LAMBDA: alloca i{{[0-9]+}},
     68     // LAMBDA: alloca i{{[0-9]+}},
     69     // LAMBDA: alloca i{{[0-9]+}},
     70     // LAMBDA: alloca i{{[0-9]+}},
     71     // LAMBDA: [[G_PRIVATE_ADDR:%.+]] = alloca i{{[0-9]+}},
     72     // LAMBDA: [[SIVAR1_PRIVATE_ADDR:%.+]] = alloca i{{[0-9]+}},
     73 
     74     // LAMBDA: store i{{[0-9]+}}* [[SIVAR_REF]], i{{[0-9]+}}** %{{.+}},
     75     // LAMBDA: [[SIVAR_REF_ADDR:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** %{{.+}},
     76 
     77     // LAMBDA: [[GTID_ADDR:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** %{{.+}}, align 8
     78     // LAMBDA: [[GTID_ADDR_REF:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[GTID_ADDR]], align 4
     79 
     80     // LAMBDA: call {{.+}} @__kmpc_for_static_init_4(%{{.+}}* @{{.+}}, i32 [[GTID_ADDR_REF]], i32 34, i32* [[IS_LAST_ADDR:%.+]], i32* %{{.+}}, i32* %{{.+}}, i32* %{{.+}}, i32 1, i32 1)
     81     // LAMBDA: store i{{[0-9]+}} 1, i{{[0-9]+}}* [[G_PRIVATE_ADDR]],
     82     // LAMBDA: store i{{[0-9]+}} 13, i{{[0-9]+}}* [[SIVAR1_PRIVATE_ADDR]],
     83     // LAMBDA: [[G_PRIVATE_ADDR_REF:%.+]] = getelementptr inbounds %{{.+}}, %{{.+}}* [[ARG:%.+]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
     84     // LAMBDA: store i{{[0-9]+}}* [[G_PRIVATE_ADDR]], i{{[0-9]+}}** [[G_PRIVATE_ADDR_REF]]
     85     // LAMBDA: [[SIVAR_PRIVATE_ADDR_REF:%.+]] = getelementptr inbounds %{{.+}}, %{{.+}}* [[ARG:%.+]], i{{[0-9]+}} 0, i{{[0-9]+}} 1
     86     // LAMBDA: store i{{[0-9]+}}* [[SIVAR1_PRIVATE_ADDR]], i{{[0-9]+}}** [[SIVAR_PRIVATE_ADDR_REF]]
     87     // LAMBDA: call void [[INNER_LAMBDA:@.+]](%{{.+}}* [[ARG]])
     88     // LAMBDA: call void @__kmpc_for_static_fini(%{{.+}}* @{{.+}}, i32 [[GTID_ADDR_REF]])
     89     {
     90       g = 1;
     91       sivar = 13;
     92     }
     93     // Check for final copying of private values back to original vars.
     94     // LAMBDA: [[IS_LAST_VAL:%.+]] = load i32, i32* [[IS_LAST_ADDR]],
     95     // LAMBDA: [[IS_LAST_ITER:%.+]] = icmp ne i32 [[IS_LAST_VAL]], 0
     96     // LAMBDA: br i1 [[IS_LAST_ITER:%.+]], label %[[LAST_THEN:.+]], label %[[LAST_DONE:.+]]
     97     // LAMBDA: [[LAST_THEN]]
     98     // Actual copying.
     99 
    100     // original g=private_g;
    101     // LAMBDA: [[G_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[G_PRIVATE_ADDR]],
    102     // LAMBDA: store volatile i{{[0-9]+}} [[G_VAL]], i{{[0-9]+}}* [[G]],
    103 
    104     // original sivar = private sivar;
    105     // LAMBDA: [[SIVAR1_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[SIVAR1_PRIVATE_ADDR]],
    106     // LAMBDA: store i{{[0-9]+}} [[SIVAR1_VAL]], i{{[0-9]+}}* [[SIVAR_REF_ADDR]],
    107     // LAMBDA: br label %[[LAST_DONE]]
    108     // LAMBDA: [[LAST_DONE]]
    109     // LAMBDA: call void @__kmpc_barrier(%{{.+}}* @{{.+}}, i{{[0-9]+}} [[GTID_ADDR_REF]])
    110 #pragma omp section
    111     [&]() {
    112       // LAMBDA: define {{.+}} void [[INNER_LAMBDA]](%{{.+}}* [[ARG_PTR:%.+]])
    113       // LAMBDA: store %{{.+}}* [[ARG_PTR]], %{{.+}}** [[ARG_PTR_REF:%.+]],
    114       g = 2;
    115       sivar = 23;
    116       // LAMBDA: [[ARG_PTR:%.+]] = load %{{.+}}*, %{{.+}}** [[ARG_PTR_REF]]
    117       // LAMBDA: [[G_PTR_REF:%.+]] = getelementptr inbounds %{{.+}}, %{{.+}}* [[ARG_PTR]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
    118       // LAMBDA: [[G_REF:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[G_PTR_REF]]
    119       // LAMBDA: store i{{[0-9]+}} 2, i{{[0-9]+}}* [[G_REF]]
    120       // LAMBDA: [[SIVAR_PTR_REF:%.+]] = getelementptr inbounds %{{.+}}, %{{.+}}* [[ARG_PTR]], i{{[0-9]+}} 0, i{{[0-9]+}} 1
    121       // LAMBDA: [[SIVAR_REF:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[SIVAR_PTR_REF]]
    122       // LAMBDA: store i{{[0-9]+}} 23, i{{[0-9]+}}* [[SIVAR_REF]]
    123     }();
    124   }
    125   }();
    126   return 0;
    127 #elif defined(BLOCKS)
    128   // BLOCKS: [[G:@.+]] = global i{{[0-9]+}} 1212,
    129   // BLOCKS-LABEL: @main
    130   // BLOCKS: call void {{%.+}}(i8
    131   ^{
    132   // BLOCKS: define{{.*}} internal{{.*}} void {{.+}}(i8*
    133   // BLOCKS: call void {{.+}} @__kmpc_fork_call({{.+}}, i32 1, {{.+}}* [[OMP_REGION:@.+]] to {{.+}})
    134 #pragma omp parallel
    135 #pragma omp sections lastprivate(g, sivar)
    136   {
    137     // BLOCKS: define{{.*}} internal{{.*}} void [[OMP_REGION]](i32* noalias [[GTID:%.+]], i32* noalias %{{.+}}, i32* dereferenceable(4) [[SIVAR:%.+]])
    138     // BLOCKS: alloca i{{[0-9]+}},
    139     // BLOCKS: alloca i{{[0-9]+}},
    140     // BLOCKS: alloca i{{[0-9]+}},
    141     // BLOCKS: alloca i{{[0-9]+}},
    142     // BLOCKS: alloca i{{[0-9]+}},
    143     // BLOCKS: [[G_PRIVATE_ADDR:%.+]] = alloca i{{[0-9]+}},
    144     // BLOCKS: [[SIVAR1_PRIVATE_ADDR:%.+]] = alloca i{{[0-9]+}},
    145 
    146     // BLOCKS: store i{{[0-9]+}}* [[SIVAR]], i{{[0-9]+}}** [[SIVAR_ADDR:%.+]],
    147     // BLOCKS: [[SIVAR_REF_ADDR:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[SIVAR_ADDR]],
    148 
    149     // BLOCKS: [[GTID_ADDR:%.+]] = load i32*, i32** [[GTID:%.+]], align 8
    150     // BLOCKS: [[GTID_ADDR_REF:%.+]] = load i32, i32* [[GTID_ADDR]], align 4
    151     // BLOCKS: call {{.+}} @__kmpc_for_static_init_4(%{{.+}}* @{{.+}}, i32 [[GTID_ADDR_REF]], i32 34, i32* [[IS_LAST_ADDR:%.+]], i32* %{{.+}}, i32* %{{.+}}, i32* %{{.+}}, i32 1, i32 1)
    152     // BLOCKS: store i{{[0-9]+}} 1, i{{[0-9]+}}* [[G_PRIVATE_ADDR]],
    153     // BLOCKS: store i{{[0-9]+}} 17, i{{[0-9]+}}* [[SIVAR1_PRIVATE_ADDR]],
    154     // BLOCKS-NOT: [[G]]{{[[^:word:]]}}
    155     // BLOCKS: i{{[0-9]+}}* [[G_PRIVATE_ADDR]]
    156     // BLOCKS-NOT: [[G]]{{[[^:word:]]}}
    157     // BLOCKS-NOT: [[SIVAR]]{{[[^:word:]]}}
    158     // BLOCKS: i{{[0-9]+}}* [[SIVAR1_PRIVATE_ADDR]]
    159     // BLOCKS-NOT: [[SIVAR]]{{[[^:word:]]}}
    160     // BLOCKS: call void {{%.+}}(i8
    161     // BLOCKS: call void @__kmpc_for_static_fini(%{{.+}}* @{{.+}}, i32 [[GTID_ADDR_REF]])
    162     {
    163       g = 1;
    164       sivar = 17;
    165     }
    166     // Check for final copying of private values back to original vars.
    167     // BLOCKS: [[IS_LAST_VAL:%.+]] = load i32, i32* [[IS_LAST_ADDR]],
    168     // BLOCKS: [[IS_LAST_ITER:%.+]] = icmp ne i32 [[IS_LAST_VAL]], 0
    169     // BLOCKS: br i1 [[IS_LAST_ITER:%.+]], label %[[LAST_THEN:.+]], label %[[LAST_DONE:.+]]
    170     // BLOCKS: [[LAST_THEN]]
    171     // Actual copying.
    172 
    173     // original g=private_g;
    174     // BLOCKS: [[G_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[G_PRIVATE_ADDR]],
    175     // BLOCKS: store volatile i{{[0-9]+}} [[G_VAL]], i{{[0-9]+}}* [[G]],
    176 
    177     // original sivar = private sivar;
    178     // BLOCKS: [[SIVAR1_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[SIVAR1_PRIVATE_ADDR]],
    179     // BLOCKS: store i{{[0-9]+}} [[SIVAR1_VAL]], i{{[0-9]+}}* [[SIVAR_REF_ADDR]],
    180     // BLOCKS: br label %[[LAST_DONE]]
    181     // BLOCKS: [[LAST_DONE]]
    182     // BLOCKS: call void @__kmpc_barrier(%{{.+}}* @{{.+}}, i{{[0-9]+}} [[GTID_ADDR_REF]])
    183 #pragma omp section
    184     ^{
    185       // BLOCKS: define {{.+}} void {{@.+}}(i8*
    186       g = 2;
    187       sivar = 29;
    188       // BLOCKS-NOT: [[G]]{{[[^:word:]]}}
    189       // BLOCKS: store i{{[0-9]+}} 2, i{{[0-9]+}}*
    190       // BLOCKS-NOT: [[G]]{{[[^:word:]]}}
    191       // BLOCKS-NOT: [[SIVAR]]{{[[^:word:]]}}
    192       // BLOCKS: store i{{[0-9]+}} 29, i{{[0-9]+}}*
    193       // BLOCKS-NOT: [[SIVAR]]{{[[^:word:]]}}
    194       // BLOCKS: ret
    195     }();
    196   }
    197   }();
    198   return 0;
    199 #else
    200   S<float> test;
    201   int t_var = 0;
    202   int vec[] = {1, 2};
    203   S<float> s_arr[] = {1, 2};
    204   S<float> var(3);
    205 #pragma omp parallel
    206 #pragma omp sections lastprivate(t_var, vec, s_arr, var, sivar)
    207   {
    208     {
    209     vec[0] = t_var;
    210     s_arr[0] = var;
    211     sivar = 31;
    212     }
    213   }
    214 #pragma omp parallel
    215 #pragma omp sections lastprivate(A::x, B::x)
    216   {
    217     A::x++;
    218 #pragma omp section
    219     ;
    220   }
    221   return tmain<int>();
    222 #endif
    223 }
    224 
    225 // CHECK: define i{{[0-9]+}} @main()
    226 // CHECK: [[TEST:%.+]] = alloca [[S_FLOAT_TY]],
    227 // CHECK: call {{.*}} [[S_FLOAT_TY_DEF_CONSTR:@.+]]([[S_FLOAT_TY]]* [[TEST]])
    228 
    229 // CHECK: call void (%{{.+}}*, i{{[0-9]+}}, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)*, ...) @__kmpc_fork_call(%{{.+}}* @{{.+}}, i{{[0-9]+}} 5, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)* bitcast (void (i{{[0-9]+}}*, i{{[0-9]+}}*, i32*, [2 x i32]*, [2 x [[S_FLOAT_TY]]]*, [[S_FLOAT_TY]]*, i{{[0-9]+}}*)* [[MAIN_MICROTASK:@.+]] to void
    230 
    231 // CHECK: call void (%{{.+}}*, i{{[0-9]+}}, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)*, ...) @__kmpc_fork_call(%{{.+}}* @{{.+}}, i{{[0-9]+}} 0, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)* bitcast (void (i{{[0-9]+}}*, i{{[0-9]+}}*)* [[MAIN_MICROTASK1:@.+]] to void
    232 // CHECK: = call {{.+}} [[TMAIN_INT:@.+]]()
    233 // CHECK: call void [[S_FLOAT_TY_DESTR:@.+]]([[S_FLOAT_TY]]*
    234 // CHECK: ret
    235 
    236 // CHECK: define internal void [[MAIN_MICROTASK]](i{{[0-9]+}}* noalias [[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}},
    237 // CHECK-NOT: alloca i{{[0-9]+}},
    238 // CHECK-NOT: alloca [2 x i{{[0-9]+}}],
    239 // CHECK-NOT: alloca [2 x [[S_FLOAT_TY]]],
    240 // CHECK-NOT: alloca [[S_FLOAT_TY]],
    241 // CHECK: store i{{[0-9]+}}* [[GTID_ADDR]], i{{[0-9]+}}** [[GTID_ADDR_REF:%.+]]
    242 
    243 // CHECK: [[GTID_REF:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[GTID_ADDR_REF]]
    244 // CHECK: [[GTID:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[GTID_REF]]
    245 // CHECK: call i32 @__kmpc_single(
    246 
    247 // CHECK-DAG: getelementptr inbounds [2 x i32], [2 x i32]* %{{.+}}, i{{[0-9]+}} 0, i{{[0-9]+}} 0
    248 // CHECK-DAG: getelementptr inbounds [2 x [[S_FLOAT_TY]]], [2 x [[S_FLOAT_TY]]]* %{{.+}}, i{{[0-9]+}} 0, i{{[0-9]+}} 0
    249 
    250 // <Skip loop body>
    251 
    252 // CHECK-NOT: call void [[S_FLOAT_TY_DESTR]]([[S_FLOAT_TY]]* [[VAR_PRIV]])
    253 // CHECK-NOT: call void [[S_FLOAT_TY_DESTR]]([[S_FLOAT_TY]]*
    254 
    255 // CHECK: call void @__kmpc_end_single(
    256 
    257 // CHECK: call void @__kmpc_barrier(%{{.+}}* [[SINGLE_BARRIER_LOC]], i{{[0-9]+}} [[GTID]])
    258 // CHECK: ret void
    259 
    260 //
    261 // CHECK: define internal void [[MAIN_MICROTASK1]](i{{[0-9]+}}* noalias [[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}})
    262 // CHECK: [[X_PRIV:%.+]] = alloca double,
    263 // CHECK-NOT: alloca double
    264 
    265 // Check for default initialization.
    266 // CHECK-NOT: [[X_PRIV]]
    267 
    268 // CHECK: [[GTID_REF:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[GTID_ADDR_REF]]
    269 // CHECK: [[GTID:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[GTID_REF]]
    270 // CHECK: call void @__kmpc_for_static_init_4(%{{.+}}* @{{.+}}, i32 [[GTID]], i32 34, i32* [[IS_LAST_ADDR:%.+]], i32* %{{.+}}, i32* %{{.+}}, i32* %{{.+}}, i32 1, i32 1)
    271 // <Skip loop body>
    272 // CHECK: call void @__kmpc_for_static_fini(%{{.+}}* @{{.+}}, i32 [[GTID]])
    273 
    274 // Check for final copying of private values back to original vars.
    275 // CHECK: [[IS_LAST_VAL:%.+]] = load i32, i32* [[IS_LAST_ADDR]],
    276 // CHECK: [[IS_LAST_ITER:%.+]] = icmp ne i32 [[IS_LAST_VAL]], 0
    277 // CHECK: br i1 [[IS_LAST_ITER:%.+]], label %[[LAST_THEN:.+]], label %[[LAST_DONE:.+]]
    278 // CHECK: [[LAST_THEN]]
    279 // Actual copying.
    280 
    281 // original x=private_x;
    282 // CHECK: [[X_VAL:%.+]] = load double, double* [[X_PRIV]],
    283 // CHECK: store double [[X_VAL]], double* [[X]],
    284 // CHECK-NEXT: br label %[[LAST_DONE]]
    285 // CHECK: [[LAST_DONE]]
    286 
    287 // CHECK: call void @__kmpc_barrier(%{{.+}}* [[SECTIONS_BARRIER_LOC]], i{{[0-9]+}} [[GTID]])
    288 // CHECK: ret void
    289 
    290 // CHECK: define {{.*}} i{{[0-9]+}} [[TMAIN_INT]]()
    291 // CHECK: [[TEST:%.+]] = alloca [[S_INT_TY]],
    292 // CHECK: call {{.*}} [[S_INT_TY_DEF_CONSTR:@.+]]([[S_INT_TY]]* [[TEST]])
    293 // CHECK: call void (%{{.+}}*, i{{[0-9]+}}, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)*, ...) @__kmpc_fork_call(%{{.+}}* @{{.+}}, i{{[0-9]+}} 4, void (i{{[0-9]+}}*, i{{[0-9]+}}*, ...)* bitcast (void (i{{[0-9]+}}*, i{{[0-9]+}}*, i32*, [2 x i32]*, [2 x [[S_INT_TY]]]*, [[S_INT_TY]]*)* [[TMAIN_MICROTASK:@.+]] to void
    294 // CHECK: call void [[S_INT_TY_DESTR:@.+]]([[S_INT_TY]]*
    295 // CHECK: ret
    296 //
    297 // CHECK: define internal void [[TMAIN_MICROTASK]](i{{[0-9]+}}* noalias [[GTID_ADDR:%.+]], i{{[0-9]+}}* noalias %{{.+}},
    298 // CHECK: alloca i{{[0-9]+}},
    299 // CHECK: alloca i{{[0-9]+}},
    300 // CHECK: alloca i{{[0-9]+}},
    301 // CHECK: alloca i{{[0-9]+}},
    302 // CHECK: alloca i{{[0-9]+}},
    303 // CHECK: [[T_VAR_PRIV:%.+]] = alloca i{{[0-9]+}},
    304 // CHECK: [[VEC_PRIV:%.+]] = alloca [2 x i{{[0-9]+}}],
    305 // CHECK: [[S_ARR_PRIV:%.+]] = alloca [2 x [[S_INT_TY]]],
    306 // CHECK: [[VAR_PRIV:%.+]] = alloca [[S_INT_TY]],
    307 // CHECK: store i{{[0-9]+}}* [[GTID_ADDR]], i{{[0-9]+}}** [[GTID_ADDR_REF:%.+]]
    308 
    309 // CHECK: [[T_VAR_REF:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** %
    310 // CHECK: [[VEC_REF:%.+]] = load [2 x i{{[0-9]+}}]*, [2 x i{{[0-9]+}}]** %
    311 // CHECK: [[S_ARR_REF:%.+]] = load [2 x [[S_INT_TY]]]*, [2 x [[S_INT_TY]]]** %
    312 // CHECK: [[VAR_REF:%.+]] = load [[S_INT_TY]]*, [[S_INT_TY]]** %
    313 
    314 // Check for default initialization.
    315 // CHECK-NOT: [[T_VAR_PRIV]]
    316 // CHECK-NOT: [[VEC_PRIV]]
    317 // CHECK: [[S_ARR_PRIV_ITEM:%.+]] = phi [[S_INT_TY]]*
    318 // CHECK: call {{.*}} [[S_INT_TY_DEF_CONSTR]]([[S_INT_TY]]* [[S_ARR_PRIV_ITEM]])
    319 // CHECK: call {{.*}} [[S_INT_TY_DEF_CONSTR]]([[S_INT_TY]]* [[VAR_PRIV]])
    320 // CHECK: call {{.+}} @__kmpc_for_static_init_4(%{{.+}}* @{{.+}}, i32 %{{.+}}, i32 34, i32* [[IS_LAST_ADDR:%.+]], i32* %{{.+}}, i32* %{{.+}}, i32* %{{.+}}, i32 1, i32 1)
    321 // <Skip loop body>
    322 // CHECK: call void @__kmpc_for_static_fini(%{{.+}}* @{{.+}}, i32 %{{.+}})
    323 
    324 // Check for final copying of private values back to original vars.
    325 // CHECK: [[IS_LAST_VAL:%.+]] = load i32, i32* [[IS_LAST_ADDR]],
    326 // CHECK: [[IS_LAST_ITER:%.+]] = icmp ne i32 [[IS_LAST_VAL]], 0
    327 // CHECK: br i1 [[IS_LAST_ITER:%.+]], label %[[LAST_THEN:.+]], label %[[LAST_DONE:.+]]
    328 // CHECK: [[LAST_THEN]]
    329 // Actual copying.
    330 
    331 // original t_var=private_t_var;
    332 // CHECK: [[T_VAR_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[T_VAR_PRIV]],
    333 // CHECK: store i{{[0-9]+}} [[T_VAR_VAL]], i{{[0-9]+}}* [[T_VAR_REF]],
    334 
    335 // original vec[]=private_vec[];
    336 // CHECK: [[VEC_DEST:%.+]] = bitcast [2 x i{{[0-9]+}}]* [[VEC_REF]] to i8*
    337 // CHECK: [[VEC_SRC:%.+]] = bitcast [2 x i{{[0-9]+}}]* [[VEC_PRIV]] to i8*
    338 // CHECK: call void @llvm.memcpy.{{.+}}(i8* [[VEC_DEST]], i8* [[VEC_SRC]],
    339 
    340 // original s_arr[]=private_s_arr[];
    341 // CHECK: [[S_ARR_BEGIN:%.+]] = getelementptr inbounds [2 x [[S_INT_TY]]], [2 x [[S_INT_TY]]]* [[S_ARR_REF]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
    342 // CHECK: [[S_ARR_PRIV_BEGIN:%.+]] = bitcast [2 x [[S_INT_TY]]]* [[S_ARR_PRIV]] to [[S_INT_TY]]*
    343 // CHECK: [[S_ARR_END:%.+]] = getelementptr [[S_INT_TY]], [[S_INT_TY]]* [[S_ARR_BEGIN]], i{{[0-9]+}} 2
    344 
    345 // CHK: [[SIVAR_REF:%.+]] = getelementptr [[S_INT_TY]], [[S_INT_TY]]* [[S_ARR_BEGIN]], i{{[0-9]+}} 4
    346 // CHK: store i{{[0-9]+}}* [[SIVAR]], i{{[0-9]+}} [[SIVAR_REF]]
    347 
    348 // CHECK: [[IS_EMPTY:%.+]] = icmp eq [[S_INT_TY]]* [[S_ARR_BEGIN]], [[S_ARR_END]]
    349 // CHECK: br i1 [[IS_EMPTY]], label %[[S_ARR_BODY_DONE:.+]], label %[[S_ARR_BODY:.+]]
    350 // CHECK: [[S_ARR_BODY]]
    351 // CHECK: call {{.*}} [[S_INT_TY_COPY_ASSIGN:@.+]]([[S_INT_TY]]* {{.+}}, [[S_INT_TY]]* {{.+}})
    352 // CHECK: br i1 {{.+}}, label %[[S_ARR_BODY_DONE]], label %[[S_ARR_BODY]]
    353 // CHECK: [[S_ARR_BODY_DONE]]
    354 
    355 // original var=private_var;
    356 // CHECK: call {{.*}} [[S_INT_TY_COPY_ASSIGN:@.+]]([[S_INT_TY]]* [[VAR_REF]], [[S_INT_TY]]* {{.*}} [[VAR_PRIV]])
    357 // CHECK: br label %[[LAST_DONE]]
    358 // CHECK: [[LAST_DONE]]
    359 // CHECK-DAG: call void [[S_INT_TY_DESTR]]([[S_INT_TY]]* [[VAR_PRIV]])
    360 // CHECK-DAG: call void [[S_INT_TY_DESTR]]([[S_INT_TY]]*
    361 // CHECK: [[GTID_REF:%.+]] = load i{{[0-9]+}}*, i{{[0-9]+}}** [[GTID_ADDR_REF]]
    362 // CHECK: [[GTID:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[GTID_REF]]
    363 // CHECK: call void @__kmpc_barrier(%{{.+}}* [[SECTIONS_BARRIER_LOC]], i{{[0-9]+}} [[GTID]])
    364 // CHECK: ret void
    365 #endif
    366 
    367