Commit Graph

375 Commits

Author SHA1 Message Date
Alexey Bataev 60859c068a [OPENMP] Add a check for iterator not reached the end of stack, NFC.
Add an extra check for the iterator during checks of the data-sharing
attributes.

llvm-svn: 301549
2017-04-27 15:10:33 +00:00
Alexey Bataev 0e6fc1c2e9 [OPENMP] Improve performance of the hasDSA() function, NFC.
Remove some unneccesary code from the function after the fix for ASAN
buildbots.

llvm-svn: 301547
2017-04-27 14:46:26 +00:00
Haojian Wu 85ddc4cb1a Fix asan failures on OpenMP.
llvm-svn: 301536
2017-04-27 12:22:33 +00:00
Alexey Bataev 4b46539ef3 [OPENMP] Fix handling of OpenMP code during template instantiation.
If some function template is instantiated during handling of OpenMP
code, currently it may cause crash of compiler because of trying of
capturing variables in non-capturing function scopes. Patch fixes this
bug.

llvm-svn: 301416
2017-04-26 15:06:24 +00:00
Alexey Bataev ccaddfb494 [OPENMP] Move handling of threadprivate vars from the stack, NFC.
Threadprivate variables do no need to be handled in the Stack of all
directives, moving it out for better performance and memory.

llvm-svn: 301410
2017-04-26 14:24:21 +00:00
Carlo Bertolli ffafe10fac [OpenMP] Prepare sema to support combined constructs with omp distribute and omp for
https://reviews.llvm.org/D32237

This patch prepares sema with additional fields to support all those composite and combined constructs of OpenMP that include pragma 'distribute' and 'for', such as 'distribute parallel for'. It also extends the regression tests for 'distribute parallel for' and adds a new one.

llvm-svn: 300802
2017-04-20 00:39:39 +00:00
Faisal Vali d143a0c2de [NFC, Scoped Enum] Convert Sema::ExpressionEvaluationContext into a scoped Enum
- also replace direct equality checks against the ConstantEvaluated enumerator  with isConstantEvaluted(), in anticipation of adding finer granularity to the various ConstantEvaluated contexts and reinstating certain restrictions on where lambda expressions can occur in C++17.

- update the clang tablegen backend that uses these Enumerators, and add the relevant scope where needed.

llvm-svn: 299316
2017-04-01 21:30:49 +00:00
Jonas Hahnfeld 64a9e3c530 [OpenMP] Generate better diagnostics for cancel and cancellation point
checkNestingOfRegions uses CancelRegion to determine whether cancel and
cancellation point are valid in the given nesting. This leads to unuseful
diagnostics if CancelRegion is invalid. The given test case has produced:
  region cannot be closely nested inside 'parallel' region

As a solution, introduce checkCancelRegion and call it first to get the
expected error:
  one of 'for', 'parallel', 'sections' or 'taskgroup' is expected

Differential Revision: https://reviews.llvm.org/D30135

llvm-svn: 295808
2017-02-22 06:49:10 +00:00
Carlo Bertolli 8429d81202 [OpenMP] Prepare Sema for initial implementation for pragma 'distribute parallel for'
https://reviews.llvm.org/D29922

This patch adds two fields for use in the implementation of 'distribute parallel for':

The increment expression for the distribute loop. As the chunk assigned to a team is executed by multiple threads within the 'parallel for' region, the increment expression has to correspond to the value returned by the related runtime call (for_static_init).
The upper bound of the innermost loop ('for' in 'distribute parallel for') is not the globalUB expression normally used for pragma 'for' when found in isolation. It is instead the upper bound of the chunk assigned to the team ('distribute' loop). In this way, we prevent teams from executing chunks assigned to other teams.
The use of these two fields can be see in a related explanatory patch:
https://reviews.llvm.org/D29508

llvm-svn: 295497
2017-02-17 21:29:13 +00:00
Arpith Chacko Jacob 7ecc0b7f3d [OpenMP] Support for thread_limit-clause on the 'target teams' directive.
The thread_limit-clause on the combined directive applies to the
'teams' region of this construct. We modify the ThreadLimitClause
class to capture the clause expression within the 'target' region.

Reviewers: ABataev
Differential Revision: https://reviews.llvm.org/D29087

llvm-svn: 293049
2017-01-25 11:44:35 +00:00
Arpith Chacko Jacob bc126344e1 [OpenMP] Support for num_teams-clause on the 'target teams' directive.
The num_teams-clause on the combined directive applies to the
'teams' region of this construct. We modify the NumTeamsClause
class to capture the clause expression within the 'target' region.

Reviewers: ABataev
Differential Revision: https://reviews.llvm.org/D29085

llvm-svn: 293048
2017-01-25 11:28:18 +00:00
Arpith Chacko Jacob 99a1e0eba5 [OpenMP] Codegen support for 'target teams' on the host.
This patch adds support for codegen of 'target teams' on the host.
This combined directive has two captured statements, one for the
'teams' region, and the other for the 'parallel'.

This target teams region is offloaded using the __tgt_target_teams()
call. The patch sets the number of teams as an argument to
this call.

Reviewers: ABataev
Differential Revision: https://reviews.llvm.org/D29084

llvm-svn: 293005
2017-01-25 02:18:43 +00:00
Arpith Chacko Jacob 86f9e46365 Reverting commit because an NVPTX patch sneaked in. Break up into two
patches.

llvm-svn: 293003
2017-01-25 01:45:59 +00:00
Arpith Chacko Jacob 4dbf368e14 [OpenMP] Codegen support for 'target teams' on the host.
This patch adds support for codegen of 'target teams' on the host.
This combined directive has two captured statements, one for the
'teams' region, and the other for the 'parallel'.

This target teams region is offloaded using the __tgt_target_teams()
call. The patch sets the number of teams as an argument to
this call.

Reviewers: ABataev
Differential Revision: https://reviews.llvm.org/D29084

llvm-svn: 293001
2017-01-25 01:38:33 +00:00
Arpith Chacko Jacob 33c849a007 [OpenMP] Support for the num_threads-clause on 'target parallel'.
The num_threads-clause on the combined directive applies to the
'parallel' region of this construct. We modify the NumThreadsClause
class to capture the clause expression within the 'target' region.

The offload runtime call for 'target parallel' is changed to
__tgt_target_teams() with 1 team and the number of threads set by
this clause or a default if none.

Reviewers: ABataev
Differential Revision: https://reviews.llvm.org/D29082

llvm-svn: 292997
2017-01-25 00:57:16 +00:00
Arpith Chacko Jacob 1f46b70b5d [OpenMP] DSAChecker bug fix for combined directives.
The DSAChecker code in SemaOpenMP looks at the captured statement
associated with an OpenMP directive.  A combined directive such as
'target parallel' has nested capture statements, which have to be
fully traversed before executing the DSAChecker.  This is a patch
to perform the traversal for such combined directives.

Reviewers: ABataev
Differential Revision: https://reviews.llvm.org/D29026

llvm-svn: 292794
2017-01-23 15:38:49 +00:00
Arpith Chacko Jacob fe4890a68b [OpenMP] Support for the if-clause on the combined directive 'target parallel'.
The if-clause on the combined directive potentially applies to both the
'target' and the 'parallel' regions.  Codegen'ing the if-clause on the
combined directive requires additional support because the expression in
the clause must be captured by the 'target' capture statement but not
the 'parallel' capture statement.  Note that this situation arises for
other clauses such as num_threads.

The OMPIfClause class inherits OMPClauseWithPreInit to support capturing
of expressions in the clause.  A member CaptureRegion is added to
OMPClauseWithPreInit to indicate which captured statement (in this case
'target' but not 'parallel') captures these expressions.

To ensure correct codegen of captured expressions in the presence of
combined 'target' directives, OMPParallelScope was added to 'parallel'
codegen.

Reviewers: ABataev
Differential Revision: https://reviews.llvm.org/D28781

llvm-svn: 292437
2017-01-18 20:40:48 +00:00
Arpith Chacko Jacob 19b911cb75 [OpenMP] Codegen support for 'target parallel' on the host.
This patch adds support for codegen of 'target parallel' on the host.
It is also the first combined directive that requires two or more
captured statements.  Support for this functionality is included in
the patch.

A combined directive such as 'target parallel' has two captured
statements, one for the 'target' and the other for the 'parallel'
region.  Two captured statements are required because each has
different implicit parameters (see SemaOpenMP.cpp).  For example,
the 'parallel' has 'global_tid' and 'bound_tid' while the 'target'
does not.  The patch adds support for handling multiple captured
statements based on the combined directive.

When codegen'ing the 'target parallel' directive, the 'target'
outlined function is created using the outer captured statement
and the 'parallel' outlined function is created using the inner
captured statement.

Reviewers: ABataev
Differential Revision: https://reviews.llvm.org/D28753

llvm-svn: 292419
2017-01-18 18:18:53 +00:00
Arpith Chacko Jacob 42793e000a Revert r292374 to debug Windows buildbot failure.
llvm-svn: 292400
2017-01-18 15:36:05 +00:00
Arpith Chacko Jacob 68019578a3 [OpenMP] Codegen support for 'target parallel' on the host.
This patch adds support for codegen of 'target parallel' on the host.
It is also the first combined directive that requires two or more
captured statements.  Support for this functionality is included in
the patch.

A combined directive such as 'target parallel' has two captured
statements, one for the 'target' and the other for the 'parallel'
region.  Two captured statements are required because each has
different implicit parameters (see SemaOpenMP.cpp).  For example,
the 'parallel' has 'global_tid' and 'bound_tid' while the 'target'
does not.  The patch adds support for handling multiple captured
statements based on the combined directive.

When codegen'ing the 'target parallel' directive, the 'target'
outlined function is created using the outer captured statement
and the 'parallel' outlined function is created using the inner
captured statement.

Reviewers: ABataev
Differential Revision: https://reviews.llvm.org/D28753

llvm-svn: 292374
2017-01-18 15:14:52 +00:00
Richard Smith 3beb7c6b5f Remove redundant passing around of a "ContainsAutoType" flag.
This flag serves no purpose other than to prevent us walking through a type to
check whether it contains an 'auto' specifier; this duplication of information
is error-prone, does not appear to provide any performance benefit, and will
become less practical once we support C++1z deduced class template types and
eventually constrained types from the Concepts TS.

No functionality change intended.

llvm-svn: 291737
2017-01-12 02:27:38 +00:00
Kelvin Li da68118729 [OpenMP] Sema and parsing for 'target teams distribute simd’ pragma
This patch is to implement sema and parsing for 'target teams distribute simd’ pragma.
    
Differential Revision: https://reviews.llvm.org/D28252

llvm-svn: 291579
2017-01-10 18:08:18 +00:00
Kelvin Li 4101032e5f [OpenMP] Support the 'is_device_ptr' clause with 'target parallel for' pragma
This patch is to add support of the 'is_device_ptr' clause with the 'target parallel for' pragma.

Differential Revision: https://reviews.llvm.org/D28255

llvm-svn: 291540
2017-01-10 05:15:35 +00:00
Kelvin Li c4bfc6fa8f [OpenMP] Support the 'is_device_ptr' clause with 'target parallel for simd' pragma
This patch is to add support of the 'is_device_ptr' clause with the 'target parallel for simd' pragma.

Differential Revision: https://reviews.llvm.org/D28402

llvm-svn: 291537
2017-01-10 04:26:44 +00:00
Kelvin Li 1851df563d [OpenMP] Sema and parsing for 'target teams distribute parallel for simd’ pragma
This patch is to implement sema and parsing for 'target teams distribute parallel for simd’ pragma.

Differential Revision: https://reviews.llvm.org/D28202

llvm-svn: 290862
2017-01-03 05:23:48 +00:00
Kelvin Li 80e8f56284 [OpenMP] Sema and parsing for 'target teams distribute parallel for’ pragma
This patch is to implement sema and parsing for 'target teams distribute parallel for’ pragma.

Differential Revision: https://reviews.llvm.org/D28160

llvm-svn: 290725
2016-12-29 22:16:30 +00:00
Kelvin Li 83c451e998 [OpenMP] Sema and parsing for 'target teams distribute' pragma
This patch is to implement sema and parsing for 'target teams distribute' pragma.

Differential Revision: https://reviews.llvm.org/D28015

llvm-svn: 290508
2016-12-25 04:52:54 +00:00
Alexey Bataev a7206b9e09 [OPENMP] Fix for PR31416: Clang crashes on OMPCapturedExpr during source
based coverage compilation

Added source location info to captured expression declaration + fixed
source location info for loop based directives.

llvm-svn: 290181
2016-12-20 16:51:02 +00:00
Kelvin Li bf594a5600 [OpenMP] Sema and parsing for 'target teams' pragma
This patch is to implement sema and parsing for 'target teams' pragma.

Differential Revision: https://reviews.llvm.org/D27818

llvm-svn: 290038
2016-12-17 05:48:59 +00:00
Kelvin Li 193ee2db47 [OpenMP] support the 'is_device_ptr' clause with 'target parallel' pragma
This patch is to add support of the 'is_device_ptr' clause in the 'target parallel' pragma.
    
Differential Revision: https://reviews.llvm.org/D27821

llvm-svn: 289989
2016-12-16 20:50:46 +00:00
Kelvin Li 8437625e35 Fix assert message. NFC.
llvm-svn: 289657
2016-12-14 15:39:58 +00:00
Samuel Antao 4c8035bca4 Fix format and a few typos in comments.
llvm-svn: 289450
2016-12-12 18:00:20 +00:00
Kelvin Li 7ade93f5e2 [OpenMP] Sema and parsing for 'teams distribute parallel for' pragma
This patch is to implement sema and parsing for 'teams distribute parallel for' pragma.
    
Differential Revision: https://reviews.llvm.org/D27345

llvm-svn: 289179
2016-12-09 03:24:30 +00:00
Kelvin Li 579e41ced2 [OpenMP] Sema and parsing for 'teams distribute parallel for simd' pragma
This patch is to implement sema and parsing for 'teams distribute parallel for simd' pragma.

Differential Revision: https://reviews.llvm.org/D27084

llvm-svn: 288294
2016-11-30 23:51:03 +00:00
Alexey Bataev 7fcacd8e0e [OPENMP] Fix for PR31137: Wrong DSA for members in struct.
If member expression is used in the task region and the base expression
is a DeclRefExp and the variable used in this ref expression is private,
it should be marked as implicitly firstprivate inside this region. Patch
fixes this issue.

llvm-svn: 288039
2016-11-28 15:55:15 +00:00
Kelvin Li 2bfddcec19 Remove comments (NFC)
Differential Revision: https://reviews.llvm.org/D27006

llvm-svn: 287852
2016-11-24 03:18:07 +00:00
Kelvin Li 4e325f77a9 Re-apply patch r279045.
llvm-svn: 285066
2016-10-25 12:50:55 +00:00
David Sheinkman d03c85c02e [OpenMP] Check if the template specialization is mappable instead of specialized template Differential Revision: https://reviews.llvm.org/D25252
llvm-svn: 283460
2016-10-06 15:47:36 +00:00
David Sheinkman 92589990ba [OpenMP] fix segfault when a variable referenced in reduction clause is a reference parameter\nDifferential Revision: http://reviews.llvm.org/D24524
llvm-svn: 283223
2016-10-04 14:41:36 +00:00
Diana Picus 8b44bbc077 Revert "[OpenMP] Sema and parsing for 'teams distribute simd’ pragma"
This reverts commit r279003 as it breaks some of our buildbots (e.g.
clang-cmake-aarch64-quick, clang-x86_64-linux-selfhost-modules).

The error is in OpenMP/teams_distribute_simd_ast_print.cpp:
clang: /home/buildslave/buildslave/clang-cmake-aarch64-quick/llvm/include/llvm/ADT/DenseMap.h:527:
bool llvm::DenseMapBase<DerivedT, KeyT, ValueT, KeyInfoT, BucketT>::LookupBucketFor(const LookupKeyT&, const BucketT*&) const
[with LookupKeyT = clang::Stmt*; DerivedT = llvm::DenseMap<clang::Stmt*, long unsigned int>;
      KeyT = clang::Stmt*; ValueT = long unsigned int;
      KeyInfoT = llvm::DenseMapInfo<clang::Stmt*>;
      BucketT = llvm::detail::DenseMapPair<clang::Stmt*, long unsigned int>]:
Assertion `!KeyInfoT::isEqual(Val, EmptyKey) && !KeyInfoT::isEqual(Val, TombstoneKey) &&
"Empty/Tombstone value shouldn't be inserted into map!"' failed.

llvm-svn: 279045
2016-08-18 09:25:07 +00:00
Kelvin Li 0e3bde8216 [OpenMP] Sema and parsing for 'teams distribute simd’ pragma
This patch is to implement sema and parsing for 'teams distribute simd’ pragma.

This patch is originated by Carlo Bertolli.

Differential Revision: https://reviews.llvm.org/D23528

llvm-svn: 279003
2016-08-17 23:13:03 +00:00
David Majnemer 9d16822224 [SemaOpenMP] Some miscellaneous cleanups
Clean up some typos, follow the coding style a little more rigorously.

No functionality change is intended.

llvm-svn: 277840
2016-08-05 17:44:54 +00:00
Kelvin Li 0253287633 [OpenMP] Sema and parsing for 'teams distribute' pragma
This patch is to implement sema and parsing for 'teams distribute' pragma.

Differential Revision: https://reviews.llvm.org/D23189

llvm-svn: 277818
2016-08-05 14:37:37 +00:00
Samuel Antao 6890b09634 [OpenMP] Code generation for the is_device_ptr clause
Summary: This patch adds support for the is_device_ptr clause. It expands SEMA to use the mappable expression logic that can only be tested with code generation in place and check conflicts with other data sharing related clauses using the mappable expressions infrastructure.

Reviewers: hfinkel, carlo.bertolli, arpith-jacob, kkwli0, ABataev

Subscribers: caomhin, cfe-commits

Differential Revision: https://reviews.llvm.org/D22788

llvm-svn: 276978
2016-07-28 14:25:09 +00:00
Samuel Antao cc10b85789 [OpenMP] Codegen for use_device_ptr clause.
Summary: This patch adds support for the use_device_ptr clause. It includes changes in SEMA that could not be tested without codegen, namely, the use of the first private logic and mappable expressions support.

Reviewers: hfinkel, carlo.bertolli, arpith-jacob, kkwli0, ABataev

Subscribers: caomhin, cfe-commits

Differential Revision: https://reviews.llvm.org/D22691

llvm-svn: 276977
2016-07-28 14:23:26 +00:00
Kelvin Li 2b51f7284b [OpenMP] diagnose orphaned teams construct
The OpenMP spec mandates that 'a teams construct must be contained within a 
target construct'. Currently, this scenario is not diagnosed. This patch is 
to add check for orphaned teams construct and issue an error message.

Differential Revision: https://reviews.llvm.org/D22785

llvm-svn: 276726
2016-07-26 04:32:50 +00:00
Kelvin Li 986330c190 [OpenMP] Sema and parsing for 'target simd' pragma
This patch is to implement sema and parsing for 'target simd' pragma.

Differential Revision: https://reviews.llvm.org/D22479

llvm-svn: 276203
2016-07-20 22:57:10 +00:00
Kelvin Li 4f161cf1c2 [OpenMP] Ignore parens in atomic capture
Clang misdiagnoses atomic captures cases that contains parens.
i.e.

  int v, int *p;
#pragma omp atomic capture
{ v = (*p); (*p)++; }

Patch by David S.

Differential Revision: https://reviews.llvm.org/D22487

llvm-svn: 276167
2016-07-20 19:41:17 +00:00
Alexey Bataev e397812dcb [OPENMP] Removed loop statement as its body executes at most once, NFC.
Removed not required loop statement, addressing comments from Richard
Smith.

llvm-svn: 275947
2016-07-19 05:06:39 +00:00
Samuel Antao dab51bbd48 [OpenMP] Remove dead code in conditional of mappable expressions SEMA.
llvm-svn: 275930
2016-07-18 23:22:11 +00:00