summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGStmtOpenMP.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [OPENMP] Fix crash on loop control vars explicitly marked as private.Alexey Bataev2015-04-281-4/+1
| | | | | | It is allowed to mark loop control vars as private in 'private' or 'lastprivate' clause, so no need to assert here. llvm-svn: 235985
* [OPENMP] Simplified iteration over clauses, NFC.Alexey Bataev2015-04-271-66/+21
| | | | llvm-svn: 235838
* [OPENMP] Codegen for 'taskwait' directive.Alexey Bataev2015-04-271-2/+2
| | | | | | | | Emit the following code for 'taskwait' directive within tied task: call i32 @__kmpc_omp_taskwait(<loc>, i32 <thread_id>); Differential Revision: http://reviews.llvm.org/D9245 llvm-svn: 235836
* [OPENMP] Codegen for 'reduction' clause in 'sections' directive.Alexey Bataev2015-04-271-6/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Emit a code for reduction clause. Next code should be emitted for reductions: static kmp_critical_name lock = { 0 }; void reduce_func(void *lhs[<n>], void *rhs[<n>]) { *(Type0*)lhs[0] = ReductionOperation0(*(Type0*)lhs[0], *(Type0*)rhs[0]); ... *(Type<n>-1*)lhs[<n>-1] = ReductionOperation<n>-1(*(Type<n>-1*)lhs[<n>-1], *(Type<n>-1*)rhs[<n>-1]); } ... void *RedList[<n>] = {&<RHSExprs>[0], ..., &<RHSExprs>[<n>-1]}; switch (__kmpc_reduce{_nowait}(<loc>, <gtid>, <n>, sizeof(RedList), RedList, reduce_func, &<lock>)) { case 1: <LHSExprs>[0] = ReductionOperation0(*<LHSExprs>[0], *<RHSExprs>[0]); ... <LHSExprs>[<n>-1] = ReductionOperation<n>-1(*<LHSExprs>[<n>-1], *<RHSExprs>[<n>-1]); __kmpc_end_reduce{_nowait}(<loc>, <gtid>, &<lock>); break; case 2: Atomic(<LHSExprs>[0] = ReductionOperation0(*<LHSExprs>[0], *<RHSExprs>[0])); ... Atomic(<LHSExprs>[<n>-1] = ReductionOperation<n>-1(*<LHSExprs>[<n>-1], *<RHSExprs>[<n>-1])); break; default:; } Reduction variables are a kind of a private variables, they have private copies, but initial values are chosen in accordance with the reduction operation. If sections directive has only single section, then original shared variables are used instead with barrier at the end of the directive. Differential Revision: http://reviews.llvm.org/D9242 llvm-svn: 235835
* [OPENMP] Codegen for 'lastprivate' clause in 'sections' directive.Alexey Bataev2015-04-271-5/+31
| | | | | | | | | | | | | | | | | | | | | | | | | #pragma omp sections lastprivate(<var>) <BODY>; This construct is translated into something like: <last_iter> = alloca i32 <init for lastprivates>; <last_iter> = 0 ; No initializer for simple variables or a default constructor is called for objects. ; For arrays perform element by element initialization by the call of the default constructor. ... OMP_FOR_START(...,<last_iter>, ..); sets <last_iter> to 1 if this is the last iteration. <BODY> ... OMP_FOR_END if (<last_iter> != 0) { <final copy for lastprivate>; Update original variable with the lastprivate value. } call __kmpc_cancel_barrier() ; an implicit barrier to avoid possible data race. If there is only one section, there is no special code generation, original shared variables are used + barrier is emitted at the end of the directive. Differential Revision: http://reviews.llvm.org/D9240 llvm-svn: 235834
* [OPENMP] Codegen for 'private' clause in 'sections' directive.Alexey Bataev2015-04-271-0/+2
| | | | | | | | | | | | | | | | | | If there are 2 or more sections in a 'section' directive the following code is generated: <default init for privates> @__kmpc_for_static_init_4(); <BODY for sections directive> @__kmpc_for_static_fini() If there is only one section, the following code is generated: if (@__kmpc_single()) { <default init for privates> @__kmpc_end_single(); } Differential Revision: http://reviews.llvm.org/D9239 llvm-svn: 235833
* [OPENMP] Codegen for 'private' clause in 'single' directive.Alexey Bataev2015-04-271-0/+1
| | | | | | | | | | | | Emit the following code for 'single' directive with 'private' clause: if (@__kmpc_single()) { <default init for privates> @__kmpc_end_single(); } Differential Revision: http://reviews.llvm.org/D9238 llvm-svn: 235832
* [OPENMP] Codegen for 'firstprivate' clause in 'single' directive.Alexey Bataev2015-04-241-5/+13
| | | | | | | | | | | | | Emit the following code for 'single' directive with 'firtstprivate' clause: if (@__kmpc_single()) { <init for firstprivates> @__kmpc_end_single(); } @__kmpc_cancel_barrier(); // To avoid data race in firstprivate init Differential Revision: http://reviews.llvm.org/D9223 llvm-svn: 235694
* [OPENMP] Do not emit implicit barrier for single directive with ↵Alexey Bataev2015-04-241-2/+3
| | | | | | | | | 'copyprivate' clause(s). Runtime function for 'copyprivate' directive generates implicit barriers, so no need to emit it. Differential Revision: http://reviews.llvm.org/D9215 llvm-svn: 235692
* [OPENMP] Codegen for 'firstprivate' clause in 'sections' directive.Alexey Bataev2015-04-241-1/+25
| | | | | | | | | | | | | | | | | | | | If there are 2 or more sections in a 'section' directive the following code is generated: <init for firstprivates> @__kmpc_cancel_barrier();// To avoid data race in firstprivate init @__kmpc_for_static_init_4(); <BODY for sections directive> @__kmpc_for_static_fini() If there is only one section, the following code is generated: if (@__kmpc_single()) { <init for firstprivates> @__kmpc_end_single(); } @__kmpc_cancel_barrier(); // To avoid data race in firstprivate init Differential Revision: http://reviews.llvm.org/D9214 llvm-svn: 235691
* InstrProf: Stop using RegionCounter outside of CodeGenPGO (NFC)Justin Bogner2015-04-231-10/+7
| | | | | | | | | The RegionCounter type does a lot of legwork, but most of it is only meaningful within the implementation of CodeGenPGO. The uses elsewhere in CodeGen generally just want to increment or read counters, so do that directly. llvm-svn: 235664
* [OPENMP] Codegen for 'atomic capture'.Alexey Bataev2015-04-231-42/+164
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adds codegen for 'atomic capture' constructs with the following forms of expressions/statements: v = x binop= expr; v = x++; v = ++x; v = x--; v = --x; v = x = x binop expr; v = x = expr binop x; {v = x; x = binop= expr;} {v = x; x++;} {v = x; ++x;} {v = x; x--;} {v = x; --x;} {x = x binop expr; v = x;} {x binop= expr; v = x;} {x++; v = x;} {++x; v = x;} {x--; v = x;} {--x; v = x;} {x = x binop expr; v = x;} {x = expr binop x; v = x;} {v = x; x = expr;} If x and expr are integer and binop is associative or x is a LHS in a RHS of the assignment expression, and atomics are allowed for type of x on the target platform atomicrmw instruction is emitted. Otherwise compare-and-swap sequence is emitted. Update of 'v' is not required to be be atomic with respect to the read or write of the 'x'. bb: ... atomic load <x> cont: <expected> = phi [ <x>, label %bb ], [ <new_failed>, %cont ] <desired> = <expected> binop <expr> <res> = cmpxchg atomic &<x>, desired, expected <new_failed> = <res>.field1; br <res>field2, label %exit, label %cont exit: atomic store <old/new x>, <v> ... Differential Revision: http://reviews.llvm.org/D9049 llvm-svn: 235573
* [OPENMP] Codegen for 'if' clause in 'task' directive.Alexey Bataev2015-04-221-74/+19
| | | | | | | | | | | | | If condition evaluates to true, the code executes task by calling @__kmpc_omp_task() runtime function. If condition evaluates to false, the code executes serial version of the code by executing the following code: call void @__kmpc_omp_task_begin_if0(<loc>, <threadid>, <task_t_ptr, returned by @__kmpc_omp_task_alloc()>); proxy_task_entry(<gtid>, <task_t_ptr, returned by @__kmpc_omp_task_alloc()>); call void @__kmpc_omp_task_complete_if0(<loc>, <threadid>, <task_t_ptr, returned by @__kmpc_omp_task_alloc()>); Also it checks if the condition is constant and if it is constant it evaluates its value and then generates either parallel version of the code (if the condition evaluates to true), or the serial version of the code (if the condition evaluates to false). Differential Revision: http://reviews.llvm.org/D9143 llvm-svn: 235507
* [OPENMP] Codegen for 'reduction' clause in 'for' directive.Alexey Bataev2015-04-221-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Emit a code for reduction clause. Next code should be emitted for reductions: static kmp_critical_name lock = { 0 }; void reduce_func(void *lhs[<n>], void *rhs[<n>]) { *(Type0*)lhs[0] = ReductionOperation0(*(Type0*)lhs[0], *(Type0*)rhs[0]); ... *(Type<n>-1*)lhs[<n>-1] = ReductionOperation<n>-1(*(Type<n>-1*)lhs[<n>-1], *(Type<n>-1*)rhs[<n>-1]); } ... void *RedList[<n>] = {&<RHSExprs>[0], ..., &<RHSExprs>[<n>-1]}; switch (__kmpc_reduce{_nowait}(<loc>, <gtid>, <n>, sizeof(RedList), RedList, reduce_func, &<lock>)) { case 1: <LHSExprs>[0] = ReductionOperation0(*<LHSExprs>[0], *<RHSExprs>[0]); ... <LHSExprs>[<n>-1] = ReductionOperation<n>-1(*<LHSExprs>[<n>-1], *<RHSExprs>[<n>-1]); __kmpc_end_reduce{_nowait}(<loc>, <gtid>, &<lock>); break; case 2: Atomic(<LHSExprs>[0] = ReductionOperation0(*<LHSExprs>[0], *<RHSExprs>[0])); ... Atomic(<LHSExprs>[<n>-1] = ReductionOperation<n>-1(*<LHSExprs>[<n>-1], *<RHSExprs>[<n>-1])); break; default:; } Reduction variables are a kind of a private variables, they have private copies, but initial values are chosen in accordance with the reduction operation. Differential Revision: http://reviews.llvm.org/D9139 llvm-svn: 235506
* [OPENMP] Codegen for 'private' clause in 'for' directive.Alexey Bataev2015-04-221-11/+16
| | | | | | | This patch generates helper variables which used as a private copies of the corresponding original variables inside an OpenMP 'for' directive. These generated variables are initialized by default (with the default constructor, if any). In OpenMP region references to original variables are replaced by the references to these private helper variables. Differential Revision: http://reviews.llvm.org/D9106 llvm-svn: 235503
* [OPENMP] Fix use of unsigned counters in loops with zero trip count.Alexey Bataev2015-04-221-51/+90
| | | | | | | | Patch fixes bugs in codegen for loops with unsigned counters and zero trip count. Previously preconditions for all loops were built using logic (Upper - Lower) > 0. But if the loop is a loop with zero trip count, then Upper - Lower is < 0 only for signed integer, for unsigned we're running into an underflow situation. In this patch we're using original Lower<Upper condition to check that loop body can be executed at least once. Also this allows to skip code generation for loops, if it is known that preconditions for the loop are always false. Differential Revision: http://reviews.llvm.org/D9103 llvm-svn: 235500
* [OPENMP] Codegen for 'ordered' directive.Alexey Bataev2015-04-221-19/+40
| | | | | | | | | | | | | | | | | | | Add codegen for 'ordered' directive: __kmpc_ordered(ident_t *, gtid); <associated statement>; __kmpc_end_ordered(ident_t *, gtid); Also for 'for' directives with the dynamic scheduling and an 'ordered' clause added a call to '__kmpc_dispatch_fini_(4|8)[u]()' function after increment expression for loop control variable: while(__kmpc_dispatch_next(&LB, &UB)) { idx = LB; while (idx <= UB) { BODY; ++idx; __kmpc_dispatch_fini_(4|8)[u](); // For ordered loops only. } // inner loop } Differential Revision: http://reviews.llvm.org/D9070 llvm-svn: 235496
* Make helper function static. NFC.Benjamin Kramer2015-04-181-3/+3
| | | | llvm-svn: 235253
* [OPENMP] Codegen for 'copyin' clause in 'parallel' directive.Alexey Bataev2015-04-161-2/+62
| | | | | | | | | | | | | | | Emits the following code for the clause at the beginning of the outlined function for implicit threads: if (<not a master thread>) { ... <thread local copy of var> = <master thread local copy of var>; ... } <sync point>; Checking for a non-master thread is performed by comparing of the address of the thread local variable with the address of the master's variable. Master thread always uses original variables, so you always know the address of the variable in the master thread. Differential Revision: http://reviews.llvm.org/D9026 llvm-svn: 235075
* [OPENMP] Codegen for 'lastprivate' clause in 'for' directive.Alexey Bataev2015-04-161-4/+106
| | | | | | | | | | | | | | | | | | | | | | | | | | | #pragma omp for lastprivate(<var>) for (i = a; i < b; ++b) <BODY>; This construct is translated into something like: <last_iter> = alloca i32 <lastprivate_var> = alloca <type> <last_iter> = 0 ; No initializer for simple variables or a default constructor is called for objects. ; For arrays perform element by element initialization by the call of the default constructor. ... OMP_FOR_START(...,<last_iter>, ..); sets <last_iter> to 1 if this is the last iteration. <BODY> ... OMP_FOR_END if (<last_iter> != 0) { <var> = <lastprivate_var> ; Update original variable with the lastprivate value. } call __kmpc_cancel_barrier() ; an implicit barrier to avoid possible data race. Differential Revision: http://reviews.llvm.org/D8658 llvm-svn: 235074
* [OPENMP] Codegen for 'firstprivate' clause in 'for' directive.Alexey Bataev2015-04-151-57/+79
| | | | | | | | Adds proper codegen for 'firstprivate' clause in for directive. Initially codegen for 'firstprivate' clause was implemented for 'parallel' directive only. Also this patch emits sync point only after initialization of firstprivate variables, not all private variables. This sync point is not required for privates, lastprivates etc., only for initialization of firstprivate variables. Differential Revision: http://reviews.llvm.org/D8660 llvm-svn: 234978
* [OPENMP] Fixed codegen for arrays in 'copyprivate' clause.Alexey Bataev2015-04-141-73/+113
| | | | | | | Fixed a bug with codegen of variables with array types specified in 'copyprivate' clause of 'single' directive. Differential Revision: http://reviews.llvm.org/D8914 llvm-svn: 234856
* [OPENMP] Initial codegen for 'parallel sections' directive.Alexey Bataev2015-04-141-22/+32
| | | | | | | | | | | | | | | Emits code for outlined 'parallel' directive with the implicitly inlined 'sections' directive: ... call __kmpc_fork_call(..., outlined_function, ...); ... define internal void outlined_function(...) { <code for implicit sections directive>; } Differential Revision: http://reviews.llvm.org/D8997 llvm-svn: 234849
* [OPENMP] Initial codegen for 'parallel for' directive.Alexey Bataev2015-04-131-3/+14
| | | | | | | Allows generation of combined 'parallel for' directive that represents 'parallel' region with internal implicit 'for' worksharing region. Differential Revision: http://reviews.llvm.org/D8631 llvm-svn: 234722
* [OPENMP] Codegen for 'reduction' clause in 'parallel' directive.Alexey Bataev2015-04-101-96/+185
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Emit a code for reduction clause. Next code should be emitted for reductions: static kmp_critical_name lock = { 0 }; void reduce_func(void *lhs[<n>], void *rhs[<n>]) { ... *(Type<i> *)lhs[i] = RedOp<i>(*(Type<i> *)lhs[i], *(Type<i> *)rhs[i]); ... } ... void *RedList[<n>] = {&<RHSExprs>[0], ..., &<RHSExprs>[<n> - 1]}; switch (__kmpc_reduce{_nowait}(<loc>, <gtid>, <n>, sizeof(RedList), RedList, reduce_func, &<lock>)) { case 1: ... <LHSExprs>[i] = RedOp<i>(*<LHSExprs>[i], *<RHSExprs>[i]); ... __kmpc_end_reduce{_nowait}(<loc>, <gtid>, &<lock>); break; case 2: ... Atomic(<LHSExprs>[i] = RedOp<i>(*<LHSExprs>[i], *<RHSExprs>[i])); ... break; default: ; } Reduction variables are a kind of a private variables, they have private copies, but initial values are chosen in accordance with the reduction operation. Differential Revision: http://reviews.llvm.org/D8915 llvm-svn: 234583
* [OPENMP] Refactoring of codegen for OpenMP directives.Alexey Bataev2015-04-101-252/+291
| | | | | | | Refactored API of OpenMPRuntime for compatibility with combined directives. Differential Revision: http://reviews.llvm.org/D8859 llvm-svn: 234564
* [OPENMP] Codegen for 'atomic update' construct.Alexey Bataev2015-03-301-3/+132
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adds atomic update codegen for the following forms of expressions: x binop= expr; x++; ++x; x--; --x; x = x binop expr; x = expr binop x; If x and expr are integer and binop is associative or x is a LHS in a RHS of the assignment expression, and atomics are allowed for type of x on the target platform atomicrmw instruction is emitted. Otherwise compare-and-swap sequence is emitted: bb: ... atomic load <x> cont: <expected> = phi [ <x>, label %bb ], [ <new_failed>, %cont ] <desired> = <expected> binop <expr> <res> = cmpxchg atomic &<x>, desired, expected <new_failed> = <res>.field1; br <res>field2, label %exit, label %cont exit: ... Differential Revision: http://reviews.llvm.org/D8536 llvm-svn: 233513
* [OPENMP] Improved codegen for implicit/explicit 'barrier' constructs.Alexey Bataev2015-03-301-9/+12
| | | | | | | Replace boolean IsExplicit parameter of OpenMPRuntime::emitBarrierCall() method by OpenMPDirectiveKind Kind for better compatibility with the runtime library. Also add processing of 'nowait' clause on worksharing directives. Differential Revision: http://reviews.llvm.org/D8659 llvm-svn: 233511
* [OPENMP] Codegen for 'copyprivate' clause ('single' directive).Alexey Bataev2015-03-231-2/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If there is at least one 'copyprivate' clause is associated with the single directive, the following code is generated: ``` i32 did_it = 0; \\ for 'copyprivate' clause if(__kmpc_single(ident_t *, gtid)) { SingleOpGen(); __kmpc_end_single(ident_t *, gtid); did_it = 1; \\ for 'copyprivate' clause } <copyprivate_list>[0] = &var0; ... <copyprivate_list>[n] = &varn; call __kmpc_copyprivate(ident_t *, gtid, <copyprivate_list_size>, <copyprivate_list>, <copy_func>, did_it); ... void<copy_func>(void *LHSArg, void *RHSArg) { Dst = (void * [n])(LHSArg); Src = (void * [n])(RHSArg); Dst[0] = Src[0]; ... Dst[n] = Src[n]; } ``` All list items from all 'copyprivate' clauses are gathered into single <copyprivate list> (<copyprivate_list_size> is a size in bytes of this list) and <copy_func> is used to propagate values of private or threadprivate variables from the 'single' region to other implicit threads from outer 'parallel' region. Differential Revision: http://reviews.llvm.org/D8410 llvm-svn: 232932
* [OPENMP] CodeGen of the 'linear' clause for the 'omp simd' directive.Alexander Musman2015-03-211-0/+53
| | | | | | | | | The linear variable is privatized (similar to 'private') and its value on current iteration is calculated, similar to the loop counter variables. Differential revision: http://reviews.llvm.org/D8375 llvm-svn: 232890
* [OPENMP] Enable codegen of the ‘private’ clause for ‘omp simd’ directiveAlexander Musman2015-03-161-3/+7
| | | | llvm-svn: 232353
* [OPENMP] CodeGen - 'omp for' with dynamic schedule kinds.Alexander Musman2015-03-121-16/+68
| | | | | | Differential Revision: http://reviews.llvm.org/D7138 llvm-svn: 232036
* [OPENMP] Initial codegen for 'omp sections' and 'omp section' directives.Alexey Bataev2015-03-121-21/+132
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [OPENMP] Fix for ExprWithCleanups in 'omp atomic' constructs.Alexey Bataev2015-03-111-0/+6
| | | | | | | This patch allows using of ExprWithCleanups expressions and other complex expressions in 'omp atomic' construct Differential Revision: http://reviews.llvm.org/D8200 llvm-svn: 231905
* [OPENMP] Initial codegen for 'omp task' directive.Alexey Bataev2015-03-101-2/+29
| | | | | | | | | | | | | | | | | The task region is emmitted in several steps: Emit a call to kmp_task_t *__kmpc_omp_task_alloc(ident_t *, kmp_int32 gtid, kmp_int32 flags, size_t sizeof_kmp_task_t, size_t sizeof_shareds, kmp_routine_entry_t *task_entry). Here task_entry is a pointer to the function: kmp_int32 .omp_task_entry.(kmp_int32 gtid, kmp_task_t *tt) { TaskFunction(gtid, tt->part_id, tt->shareds); return 0; } Copy a list of shared variables to field shareds of the resulting structure kmp_task_t returned by the previous call (if any). Copy a pointer to destructions function to field destructions of the resulting structure kmp_task_t. Emit a call to kmp_int32 __kmpc_omp_task(ident_t *, kmp_int32 gtid, kmp_task_t *new_task), where new_task is a resulting structure from previous items. Differential Revision: http://reviews.llvm.org/D7560 llvm-svn: 231762
* [OPENMP] Improved code for generating debug info + generation of all OpenMP ↵Alexey Bataev2015-03-101-23/+20
| | | | | | | | | regions in termination scope Patch adds proper generation of debug info for all OpenMP regions. Also, all OpenMP regions are generated in a termination scope, because standard does not allow to throw exceptions out of structured blocks, associated with the OpenMP regions Differential Revision: http://reviews.llvm.org/D7935 llvm-svn: 231757
* Revert "[OPENMP] Improved code for generating debug info + generation of all ↵Rafael Espindola2015-03-101-20/+23
| | | | | | | | | | | | | OpenMP regions in termination scope Patch adds proper generation of debug info for all OpenMP regions. Also, all OpenMP regions are generated in a termination scope, because standard does not allow to throw exceptions out of structured blocks, associated with the OpenMP regions Differential Revision: http://reviews.llvm.org/D7935" This reverts commit r231752. It was failing to link with cmake: lib64/libclangCodeGen.a(CGOpenMPRuntime.cpp.o):/home/espindola/llvm/llvm/tools/clang/lib/CodeGen/CGOpenMPRuntime.cpp:function clang::CodeGen::InlinedOpenMPRegionRAII::~InlinedOpenMPRegionRAII(): error: undefined reference to 'clang::CodeGen::EHScopeStack::popTerminate()' clang-3.7: error: linker command failed with exit code 1 (use -v to see invocation) llvm-svn: 231754
* [OPENMP] Improved code for generating debug info + generation of all OpenMP ↵Alexey Bataev2015-03-101-23/+20
| | | | | | | | | regions in termination scope Patch adds proper generation of debug info for all OpenMP regions. Also, all OpenMP regions are generated in a termination scope, because standard does not allow to throw exceptions out of structured blocks, associated with the OpenMP regions Differential Revision: http://reviews.llvm.org/D7935 llvm-svn: 231752
* [OPENMP] Codegen for "#pragma omp atomic write"Alexey Bataev2015-02-271-2/+27
| | | | | | | | | | For global reg lvalue - use regular store through global register. For simple lvalue - use simple atomic store. For bitfields, vector element, extended vector elements - the original value of the whole storage (for vector elements) or of some aligned value (for bitfields) is atomically read, the part of this value for the given lvalue is modified and then use atomic compare-and-exchange operation to try to atomically write modified value (if it was not modified). Also, changes in this patch fix the bug for '#pragma omp atomic read' applied to extended vector elements. Differential Revision: http://reviews.llvm.org/D7369 llvm-svn: 230736
* [OPENMP] Fixed codegen for directives without function outlining.Alexey Bataev2015-02-261-34/+5
| | | | | | Fixed crash on codegen for directives like 'omp for', 'omp single' etc. inside of the 'omp parallel', 'omp task' etc. regions. llvm-svn: 230621
* [OPENMP] Rename methods of OpenMPRuntime class. NFC. Alexey Bataev2015-02-251-37/+34
| | | | llvm-svn: 230470
* Revert "Revert r229082 for a bit, it caused PR22577."David Majnemer2015-02-141-2/+5
| | | | | | | This reverts commit r229123. It was a red herring, the bug was present without r229082. llvm-svn: 229205
* Revert r229082 for a bit, it caused PR22577.Nico Weber2015-02-131-5/+2
| | | | llvm-svn: 229123
* MS ABI: Implement /volatile:msDavid Majnemer2015-02-131-2/+5
| | | | | | | | | | | | The /volatile:ms semantics turn volatile loads and stores into atomic acquire and release operations. This distinction is important because volatile memory operations do not form a happens-before relationship with non-atomic memory. This means that a volatile store is not sufficient for implementing a mutex unlock routine. Differential Revision: http://reviews.llvm.org/D7580 llvm-svn: 229082
* [OPENMP] Initial codegen for 'single' directive.Alexey Bataev2015-02-051-2/+7
| | | | | | | | | | | | | | | | This patch emits the following code for the single directive: #pragma omp single <body> <----> if(__kmpc_single(...)) { <body> __kmpc_end_single(...); } Differential Revision: http://reviews.llvm.org/D7045 llvm-svn: 228275
* [OPENMP] Codegen for 'taskyield' directiveAlexey Bataev2015-02-051-2/+3
| | | | | | | | | For 'taskyield' directive emit call to kmp_int32 __kmpc_omp_taskyield(ident_t *, kmp_int32 global_tid, int end_part); runtime function call with end_part arg set to 0 (it is ignored). Differential Revision: http://reviews.llvm.org/D7047 llvm-svn: 228272
* Address review feedback for r228003.Adrian Prantl2015-02-031-2/+2
| | | | | | | - use named constructors - get rid of MarkAsPrologue llvm-svn: 228021
* Merge ArtificialLocation into ApplyDebugLocation and make a clearAdrian Prantl2015-02-031-2/+2
| | | | | | | | | | | | | | | | distinction between the different use-cases. With the previous default behavior we would occasionally emit empty debug locations in situations where they actually were strictly required (= on invoke insns). We now have a choice between defaulting to an empty location or an artificial location. Specifically, this fixes a bug caused by a missing debug location when emitting C++ EH cleanup blocks from within an artificial function, such as an ObjC destroy helper function. rdar://problem/19670595 llvm-svn: 228003
* Support ‘omp for’ with static chunked schedule kind.Alexander Musman2015-01-221-2/+90
| | | | | | Differential Revision: http://reviews.llvm.org/D7006 llvm-svn: 226795
* [OPENMP] CodeGen for "omp atomic read [seq_cst]" directive.Alexey Bataev2015-01-221-2/+119
| | | | | | | | | | | | | "omp atomic read [seq_cst]" accepts expressions "v=x;". In this patch we perform an atomic load of "x" (using builtin atomic loading instructions or a call to "atomic_load()" for simple lvalues and "kmpc_atomic_start();load <x>;kmpc_atomic_end();" for other lvalues), convert the result of loading to type of "v" (using EmitScalarConversion() for simple types and EmitComplexToScalarConversion() for conversions from complex to scalar) and then store the result in "v".) Differential Revision: http://reviews.llvm.org/D6431 llvm-svn: 226788
OpenPOWER on IntegriCloud