[OPENMP] Initial codegen for 'omp sections' and 'omp section' directives.
authorAlexey Bataev <a.bataev@hotmail.com>
Thu, 12 Mar 2015 08:53:29 +0000 (08:53 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Thu, 12 Mar 2015 08:53:29 +0000 (08:53 +0000)
commit2df54a07bfb843e5fbd83573aefc3422081c5126
tree8e435cb71bc474c5cde694d7fe7a1e764cf3d6ba
parentae586d27ffb1afc05b77cf7434433d582181ac64
[OPENMP] Initial codegen for 'omp sections' and 'omp section' directives.
If only one section is found in the sections region, it is emitted just like single region.
Otherwise it is emitted as a static non-chunked loop.

#pragma omp sections
{
#pragma omp section
  {1}
  ...
  #pragma omp section
  {n}
}
is translated to something like

i32 <iter_var>
i32 <last_iter> = 0
i32 <lower_bound> = 0
i32 <upper_bound> = n-1
i32 <stride> = 1
call void @__kmpc_for_static_init_4(<loc>, i32 <gtid>, i32 34/*static non-chunked*/, i32* <last_iter>, i32* <lower_bound>, i32* <upper_bound>, i32* <stride>, i32 1/*increment always 1*/, i32 1/*chunk always 1*/)
<upper_bound> = min(<upper_bound>, n-1)
<iter_var> = <lb>
check:
br <iter_var> <= <upper_bound>, label cont, label exit
continue:
switch (IV) {
  case 0:
  {1};
  break;
  ...
  case <NumSection> - 1:
  {n};
  break;
  }
  ++<iter_var>
  br label check
  exit:
  call void @__kmpc_for_static_fini(<loc>, i32 <gtid>)
Differential Revision: http://reviews.llvm.org/D8244

llvm-svn: 232021
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/test/OpenMP/sections_codegen.cpp [new file with mode: 0644]