Commit Graph

326 Commits

Author SHA1 Message Date
Alexey Bataev a176421da5 [OPENMP 4.1] Sema analysis for array sections in 'reduction' clause.
OpenMP 4.1 allows to use array sections|subscript expressions in 'reduction' clauses. Added sema analysis, updated tests.

llvm-svn: 248880
2015-09-30 09:22:36 +00:00
Alexey Bataev 5f600d6a49 [OPENMP 4.1] Codegen for ‘simd’ clause in ‘ordered’ directive.
Description.
If the simd clause is specified, the ordered regions encountered by any thread will use only a single SIMD lane to execute the ordered regions in the order of the loop iterations.
Restrictions.
An ordered construct with the simd clause is the only OpenMP construct that can appear in the simd region.

An ordered directive with ‘simd’ clause is generated as an outlined function and corresponding function call to prevent this part of code from vectorization later in backend.

llvm-svn: 248772
2015-09-29 03:48:57 +00:00
Alexey Bataev d14d1e6f25 [OPENMP 4.1] Add 'simd' clause for 'ordered' directive.
Parsing and sema analysis for 'simd' clause in 'ordered' directive.
Description
If the simd clause is specified, the ordered regions encountered by any thread will use only a single SIMD lane to execute the ordered
regions in the order of the loop iterations.
Restrictions
An ordered construct with the simd clause is the only OpenMP construct that can appear in the simd region

llvm-svn: 248696
2015-09-28 06:39:35 +00:00
Alexey Bataev 346265e3bc [OPENMP 4.1] Add 'threads' clause for '#pragma omp ordered'.
OpenMP 4.1 extends format of '#pragma omp ordered'. It adds 3 additional clauses: 'threads', 'simd' and 'depend'.
If no clause is specified, the ordered construct behaves as if the threads clause had been specified. If the threads clause is specified, the threads in the team executing the loop region execute ordered regions sequentially in the order of the loop iterations.
The loop region to which an ordered region without any clause or with a threads clause binds must have an ordered clause without the parameter specified on the corresponding loop directive.

llvm-svn: 248569
2015-09-25 10:37:12 +00:00
Alexey Bataev 87933c7ced [OPENMP 4.0] Add 'if' clause for 'cancel' directive.
Add parsing, sema analysis and codegen for 'if' clause in 'cancel' directive.

llvm-svn: 247976
2015-09-18 08:07:34 +00:00
Kelvin Li 4eea8c6b82 Allow static local variables specified on data-sharing attribute clauses.
http://reviews.llvm.org/D11619

llvm-svn: 247715
2015-09-15 18:56:58 +00:00
Alexey Bataev ecb156aba2 [OPENMP] Emit an additional note during analysis of 'if' clause.
Patch adds emission of additional note for 'if' clauses with name modifiers in case if 'if' clause without name modified was specified or 'if' clause with the same name modifier was specified.

llvm-svn: 247706
2015-09-15 17:23:56 +00:00
Alexey Bataev 25e5b44654 [OPENMP] Emit __kmpc_cancel_barrier() and code for 'cancellation point' only if 'cancel' is found.
Patch improves codegen for OpenMP constructs. If the OpenMP region does not have internal 'cancel' construct, a call to 'void __kmpc_barrier()' runtime function is generated for all implicit/explicit barriers. If the region has inner 'cancel' directive, then
```
if (__kmpc_cancel_barrier())
  exit from outer construct;
```
code is generated.
Also, the code for 'canellation point' directive is not generated if parent directive does not have 'cancel' directive.

llvm-svn: 247681
2015-09-15 12:52:43 +00:00
Alexey Bataev c71a4099cf [OPENMP] Preserve alignment of the original variables for the captured references.
Patch makes codegen to preserve alignment of the shared variables captured and used in OpenMP regions.

llvm-svn: 247401
2015-09-11 10:29:41 +00:00
Alexey Bataev ed5fb67ad1 [OPENMP] Fix printing of array section with single index.
llvm-svn: 247389
2015-09-11 04:54:28 +00:00
David Blaikie fc473554a6 [opaque pointer type] update test cases for explicit pointee types on global aliases
llvm-svn: 247380
2015-09-11 03:22:18 +00:00
Alexey Bataev 6a43c00ebd [OPENMP] Generate threadprivates as TLS variables by default.
If target supports TLS all threadprivates are generated as TLS. If target does not support TLS, use runtime calls for proper codegen of threadprivate variables.

llvm-svn: 247273
2015-09-10 12:06:58 +00:00
Alexey Bataev 5852e42949 [OPENMP] Fix test incompatibility with Windows.
llvm-svn: 247270
2015-09-10 11:31:04 +00:00
Alexey Bataev e19facb9bc [OPENMP] Fix test incompatibility with Windows codegen.
llvm-svn: 247268
2015-09-10 11:09:46 +00:00
Alexey Bataev 1d7f0faf93 [OPENMP] Propagate alignment from original variables to the private copies.
Currently private copies of captured variables have default alignment. Patch makes private variables to have same alignment as original variables.

llvm-svn: 247260
2015-09-10 09:48:30 +00:00
Alexey Bataev 22b46291f4 [OPENMP] Fix test incompatibility with 32-bit platforms
llvm-svn: 247255
2015-09-10 09:06:59 +00:00
Alexey Bataev 2377fe95c6 [OPENMP] Outlined function for parallel and other regions with list of captured variables.
Currently all variables used in OpenMP regions are captured into a record and passed to outlined functions in this record. It may result in some poor performance because of too complex analysis later in optimization passes. Patch makes to emit outlined functions for parallel-based regions with a list of captured variables. It reduces code for 2*n GEPs, stores and loads at least.
Codegen for task-based regions remains unchanged because runtime requires that all captured variables are passed in captured record.

llvm-svn: 247251
2015-09-10 08:12:02 +00:00
John McCall 7f416cc426 Compute and preserve alignment more faithfully in IR-generation.
Introduce an Address type to bundle a pointer value with an
alignment.  Introduce APIs on CGBuilderTy to work with Address
values.  Change core APIs on CGF/CGM to traffic in Address where
appropriate.  Require alignments to be non-zero.  Update a ton
of code to compute and propagate alignment information.

As part of this, I've promoted CGBuiltin's EmitPointerWithAlignment
helper function to CGF and made use of it in a number of places in
the expression emitter.

The end result is that we should now be significantly more correct
when performing operations on objects that are locally known to
be under-aligned.  Since alignment is not reliably tracked in the
type system, there are inherent limits to this, but at least we
are no longer confused by standard operations like derived-to-base
conversions and array-to-pointer decay.  I've also fixed a large
number of bugs where we were applying the complete-object alignment
to a pointer instead of the non-virtual alignment, although most of
these were hidden by the very conservative approach we took with
member alignment.

Also, because IRGen now reliably asserts on zero alignments, we
should no longer be subject to an absurd but frustrating recurring
bug where an incomplete type would report a zero alignment and then
we'd naively do a alignmentAtOffset on it and emit code using an
alignment equal to the largest power-of-two factor of the offset.

We should also now be emitting much more aggressive alignment
attributes in the presence of over-alignment.  In particular,
field access now uses alignmentAtOffset instead of min.

Several times in this patch, I had to change the existing
code-generation pattern in order to more effectively use
the Address APIs.  For the most part, this seems to be a strict
improvement, like doing pointer arithmetic with GEPs instead of
ptrtoint.  That said, I've tried very hard to not change semantics,
but it is likely that I've failed in a few places, for which I
apologize.

ABIArgInfo now always carries the assumed alignment of indirect and
indirect byval arguments.  In order to cut down on what was already
a dauntingly large patch, I changed the code to never set align
attributes in the IR on non-byval indirect arguments.  That is,
we still generate code which assumes that indirect arguments have
the given alignment, but we don't express this information to the
backend except where it's semantically required (i.e. on byvals).
This is likely a minor regression for those targets that did provide
this information, but it'll be trivial to add it back in a later
patch.

I partially punted on applying this work to CGBuiltin.  Please
do not add more uses of the CreateDefaultAligned{Load,Store}
APIs; they will be going away eventually.

llvm-svn: 246985
2015-09-08 08:05:57 +00:00
Alexey Bataev 5a1954780f [OPENMP] Fix false diagnostic on instantiation-dependent exprs for atomic constructs.
Some of instantiation-dependent expressions could cause false diagnostic to be emitted about unsupported atomic constructs. Relaxed rules for detection of incorrect expressions.

llvm-svn: 246853
2015-09-04 12:55:50 +00:00
Alexey Bataev caacd53dde [OPENMP] Fix for http://llvm.org/PR24674: assertion failed and and abort trap
Fix processing of shared variables with reference types in OpenMP constructs. Previously, if the variable was not marked in one of the private clauses, the reference to this variable was emitted incorrectly and caused an assertion later.

llvm-svn: 246846
2015-09-04 11:26:21 +00:00
Alexey Bataev b500101e1c [OPENMP] Fix for http://llvm.org/PR24687: ICE on compilation of R package TPmsm.
Fixed capturing of VLAs in 'private' clause of the OpenMP directives.

llvm-svn: 246757
2015-09-03 10:21:46 +00:00
Alexey Bataev 7371aa365c [OPENMP 4.1] Codegen for extended format of 'if' clause.
Fixed codegen for extended format of 'if' clauses with special 'directive-name-modifier' + ast-print tests for extended format of 'if' clause.

llvm-svn: 246748
2015-09-03 08:45:56 +00:00
Alexey Bataev 6b8046addf [OPENMP 4.1] Parsing/sema analysis for extended format of 'if' clause.
OpenMP 4.1 added special 'directive-name-modifier' to the 'if' clause.
Format of 'if' clause is as follows:
```
if([ directive-name-modifier :] scalar-logical-expression)
```

The restriction rules are also changed.
1. If any 'if' clause on the directive includes a 'directive-name-modifier' then all 'if' clauses on the directive must include a 'directive-name-modifier'.
2. At most one 'if' clause without a 'directive-name-modifier' can appear on the directive.
3. At most one 'if' clause with some particular 'directive-name-modifier' can appear on the directive.

'directive-name-modifier' is important for combined directives and allows to separate conditions in 'if' clause for simple sub-directives in combined directive. This 'directive-name-modifier' identifies the sub-directive to which this 'if' clause must be applied.

llvm-svn: 246747
2015-09-03 07:23:48 +00:00
Hans Wennborg 2151d12ec0 Fix CHECK directives that weren't checking.
llvm-svn: 246492
2015-08-31 21:48:52 +00:00
Alexey Bataev d6fdc8b685 [OPENMP 4.0] Codegen for array sections.
Added codegen for array section in 'depend' clause of 'task' directive. It emits to pointers, one for the begin of array section and another for the end of array section. Size of the section is calculated as (end + 1 - start) * sizeof(basic_element_type).

llvm-svn: 246422
2015-08-31 07:32:19 +00:00
Daniel Jasper ad5b7962c9 Revert "[OPENMP 4.0] Codegen for array sections."
The test is currently failing on bots:
http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_check/12747/

llvm-svn: 246288
2015-08-28 08:42:22 +00:00
Alexey Bataev 117fb35cf7 [OPENMP 4.0] Codegen for array sections.
Added codegen for array section in 'depend' clause of 'task' directive. It emits to pointers, one for the begin of array section and another for the end of array section. Size of the section is calculated as (end + 1 - start) * sizeof(basic_element_type).

llvm-svn: 246278
2015-08-28 06:09:05 +00:00
Ahmed Bougacha 68bf64e302 [X86] Use AVX features instead of ABI to init. SimdDefaultAlign.
The ABI string only exists to communicate with TargetCodeGenInfo.
Concretely, since we only used "avx*" ABI strings on x86_64 (as AVX
doesn't affect the i386 ABIs), this meant that, when initializing
SimdDefaultAlign, we would ignore AVX/AVX512 on i386, for no good
reason.

Instead, directly check the features. A similar change for
MaxVectorAlign will follow.

Differential Revision: http://reviews.llvm.org/D12390

llvm-svn: 246228
2015-08-27 22:24:56 +00:00
Alexey Bataev 627cbd31d1 Fix possible crash on null base or type for array elements.
llvm-svn: 245939
2015-08-25 15:15:12 +00:00
Alexey Bataev 1a3320e463 [OPENMP 4.0] Initial support for array sections.
Adds parsing/sema analysis/serialization/deserialization for array sections in OpenMP constructs (introduced in OpenMP 4.0).
Currently it is allowed to use array sections only in OpenMP clauses that accepts list of expressions.
Differential Revision: http://reviews.llvm.org/D10732

llvm-svn: 245937
2015-08-25 14:24:04 +00:00
Alexey Bataev 45bfad51d8 [OPENMP 4.1] Add codegen for 'simdlen' clause.
Add emission of metadata for simd loops in presence of 'simdlen' clause.
If 'simdlen' clause is provided without 'safelen' clause, the vectorizer width for the loop is set to value of 'simdlen' clause + all read/write ops in loop are marked with '!llvm.mem.parallel_loop_access' metadata.
If 'simdlen' clause is provided along with 'safelen' clause, the vectorizer width for the loop is set to value of 'simdlen' clause + all read/write ops in loop are not marked with '!llvm.mem.parallel_loop_access' metadata.
If 'safelen' clause is provided without 'simdlen' clause, the vectorizer width for the loop is set to value of 'safelen' clause + all read/write ops in loop are not marked with '!llvm.mem.parallel_loop_access' metadata.

llvm-svn: 245697
2015-08-21 12:19:04 +00:00
Alexey Bataev d386a6ccb9 [OPENMP 4.1] Add ast-print tests for 'val', 'uval' and 'ref' modifiers.
llvm-svn: 245693
2015-08-21 11:32:42 +00:00
Alexey Bataev 66b15b505f [OPENMP 4.1] Initial support for 'simdlen' clause.
Add parsing/sema analysis for 'simdlen' clause in simd directives. Also add check that if both 'safelen' and 'simdlen' clauses are specified, the value of 'simdlen' parameter is less than the value of 'safelen' parameter.

llvm-svn: 245692
2015-08-21 11:14:16 +00:00
Alexey Bataev 84cfb1dcde [OPENMP 4.1] Improved codegen for 'uval' qualifier of 'linear' clause.
According to standard the 'uval' modifier declares the address of the original list item to have an invariant value for all iterations of the associated loop(s). Patch improves codegen for this qualifier by removing usage of the original reference variable and replacing by referenced l-value.

llvm-svn: 245674
2015-08-21 06:41:23 +00:00
Alexey Bataev 1185e193a4 [OPENMP 4.1] Allow to use 'uval' and 'ref' modifiers for reference types only.
Standard allows to use 'uval' and 'ref' modifiers in 'linear' clause for variables with reference types only. Added check for it and modified test.

llvm-svn: 245556
2015-08-20 12:15:57 +00:00
Alexey Bataev 182227bd5b [OPENMP 4.1] Initial support for modifiers in 'linear' clause.
OpenMP 4.1 adds 3 optional modifiers to 'linear' clause.
Format of 'linear' clause has changed to:
```
linear(linear-list[ : linear-step])
```
where linear-list is one of the following
```
list
modifier(list)
```
where modifier is one of the following:
```
 ref (C++)
 val (C/C++)
 uval (C++)
```
Patch adds parsing and sema analysis for these modifiers.

llvm-svn: 245550
2015-08-20 10:54:39 +00:00
Alexey Bataev c7e8435bef [OPENMP] Link libomp.lib on Windows
Adds libomp.lib for -fopenmp=libomp and libiomp5md.lib for -fopenmp=libiomp5 on Windows
Differential Revision: http://reviews.llvm.org/D11932

llvm-svn: 245414
2015-08-19 04:49:01 +00:00
Alexey Bataev bd9fec1eaa [OPENMP 4.1] Allow variables with reference types in private clauses.
OpenMP 4.1 allows to use variables with reference types in all private clauses (private, firstprivate, lastprivate, linear etc.). Patch allows to use such variables and fixes codegen for linear variables with reference types.

llvm-svn: 245268
2015-08-18 06:47:21 +00:00
Alexey Bataev b08f89ffc1 [OPENMP] Fix for http://llvm.org/PR24371: Assert failure compiling blender 2.75.
blender uses statements expression in condition of the loop under control of the '#pragma omp parallel for'. This condition is used several times in different expressions required for codegen of the loop directive. If there are some variables defined in statement expression, it fires an assert during codegen because of redefinition of the same variables.
We have to rebuild several expression to be sure that all variables are unique.

llvm-svn: 245041
2015-08-14 12:25:37 +00:00
Alexey Bataev 4652e4baaf [OPENMP] Fix for http://llvm.org/PR24430: clang hangs on invalid input with openmp directive
Add parsing of openmp directives inside structs/unions in C mode.

llvm-svn: 244719
2015-08-12 07:10:54 +00:00
Michael Wong e710d5459e This patch commits OpenMP 4 target device clauses
This is committed on behalf of Kelvin Li
http://reviews.llvm.org/D11469?id=31227

llvm-svn: 244325
2015-08-07 16:16:36 +00:00
Alexey Bataev a889917493 [OPENMP 4.1] Allow references in init expression for loop-based constructs.
OpenMP 4.1 allows to use variables with reference types in private clauses and, therefore, in init expressions of the cannonical loop forms.

llvm-svn: 244209
2015-08-06 12:30:57 +00:00
Alexey Bataev 54acd40591 [OPENMP 4.1] Support for 'linear' clause in loop directives.
OpenMP 4.1 allows 'linear' clause in loop directives. Patch adds support for it.

llvm-svn: 243969
2015-08-04 11:18:19 +00:00
Alexey Bataev 48977c3364 [OPENMP] Fix compiler crash during data-sharing attributes analysis.
If a global variable is marked as private in OpenMP construct and then is used in of the private clauses of the same construct, it might cause compiler crash because of incorrect capturing.

llvm-svn: 243964
2015-08-04 08:10:48 +00:00
Alexey Bataev 10e775f4a8 [OPENMP 4.1] Initial support for extended 'ordered' clause.
OpenMP 4.1 introduces optional argument '(n)' for 'ordered' clause, where 'n' is a number of loops that immediately follow the directive.
'n' must be constant positive integer expressions and it must be less or equal than the number of the loops in the resulting loop nest.
Patch adds parsing and semantic analysis for this optional argument.

llvm-svn: 243635
2015-07-30 11:36:16 +00:00
Samuel Antao bc47f8fc21 [OpenMP] Fix copyin codegen test regression in order used in compare
instruction. 

llvm-svn: 243289
2015-07-27 17:49:18 +00:00
Samuel Antao d31d4c17e6 [OpenMP] Fix copyin clause codegen regression caused by r243277.
llvm-svn: 243285
2015-07-27 17:30:41 +00:00
Samuel Antao 2e2d680fee [OpenMP] Add TLS requirement for the copyin clause codegen test. This is an
attempt to fix regressions triggered by r243277.

llvm-svn: 243280
2015-07-27 16:59:45 +00:00
Samuel Antao 9c75cfe976 [OpenMP] Add capture for threadprivate variables used in copyin clause
if TLS is enabled in OpenMP code generation. 

llvm-svn: 243277
2015-07-27 16:38:06 +00:00
Michael Wong 65f367fcbb Commit for http://reviews.llvm.org/D10765
for OpenMP 4 target data directive parsing and sema.
This commit is on behalf of Kelvin Li.

llvm-svn: 242785
2015-07-21 13:44:28 +00:00