Commit Graph

488 Commits

Author SHA1 Message Date
Fangrui Song 202f222f94 [OPENMP] Fix -Wunused-lambda-capture. NFC
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@330284 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-18 19:32:01 +00:00
Alexey Bataev b62c028144 [OPENMP] Code cleanup and code improvements.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@330270 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-18 15:57:46 +00:00
Alexey Bataev fb5b5046b3 [OPENMP] Replace push_back by emplace_back, NFC.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@330042 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-13 17:48:43 +00:00
Alexey Bataev 07aa03bc10 [OPENMP] Code cleanup, NFC.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329843 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-11 19:21:00 +00:00
Alexey Bataev 6d12dfba81 [OPENMP] Additional attributes for the pointer parameters.
Added attributes for better optimization of the OpenMP code.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329751 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-10 20:10:53 +00:00
Alexey Bataev 1fc609130a [OPENMP] Codegen for declare target with link clause.
If the link clause is used on the declare target directive, the object
should be linked on target or target data directives, not during the
codegen. Patch adds support for this clause.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328544 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-26 16:40:55 +00:00
Alexey Bataev 53912bffa0 [OPENMP, NVPTX] Globalization of the private redeclarations.
If the generic codegen is enabled and private copy of the original
variable escapes the declaration context, this private copy should be
globalized just like it was the original variable.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@327985 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-20 14:45:59 +00:00
Alexey Bataev ecef9fa6ef [OPENMP] Codegen for `omp declare target` construct.
Added initial codegen for device side of declarations inside `omp
declare target` construct + codegen for implicit `declare target`
functions, which are used in the target regions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@327636 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-15 15:47:20 +00:00
Reid Kleckner 49c32abef3 Re-land "[Sema] Make getCurFunction() return null outside function parsing"
This relands r326965.

There was a null dereference in typo correction that was triggered in
Sema/diagnose_if.c. We are not always in a function scope when doing
typo correction. The fix is to add a null check.

LLVM's optimizer made it hard to find this bug. I wrote it up in a
not-very-well-editted blog post here:
http://qinsb.blogspot.com/2018/03/ub-will-delete-your-null-checks.html

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@327334 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-12 21:43:02 +00:00
Reid Kleckner 61d936f6b2 Revert "[Sema] Make getCurFunction() return null outside function parsing"
This reverts r326965. It seems to have caused repeating test failures in
clang/test/Sema/diagnose_if.c on some buildbots.

I cannot reproduce the problem, and it's not immediately obvious what
the problem is, so let's revert to green.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@326974 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-08 01:12:22 +00:00
Reid Kleckner ad50a4ee05 [Sema] Make getCurFunction() return null outside function parsing
Summary:
Before this patch, Sema pre-allocated a FunctionScopeInfo and kept it in
the first, always present element of the FunctionScopes stack. This
meant that Sema::getCurFunction would return a pointer to this
pre-allocated object when parsing code outside a function body. This is
pretty much always a bug, so this patch moves the pre-allocated object
into a separate unique_ptr. This should make bugs like PR36536 a lot
more obvious.

As you can see from this patch, there were a number of places that
unconditionally assumed they were always called inside a function.
However, there are also many places that null checked the result of
getCurFunction(), so I think this is a reasonable direction.

Reviewers: rsmith

Subscribers: cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@326965 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-08 00:14:34 +00:00
Alexey Bataev b4e3f41c8b [OPENMP] Treat local variables in CUDA mode as thread local.
In CUDA mode all local variables are actually thread
local|threadprivate, not private, and, thus, they cannot be shared
between threads|lanes.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@326590 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-02 17:17:12 +00:00
George Burgess IV f6b7996bf6 Remove redundant casts. NFC
So I wrote a clang-tidy check to lint out redundant `isa`, `cast`, and
`dyn_cast`s for fun. This is a portion of what it found for clang; I
plan to do similar cleanups in LLVM and other subprojects when I find
time.

Because of the volume of changes, I explicitly avoided making any change
that wasn't highly local and obviously correct to me (e.g. we still have
a number of foo(cast<Bar>(baz)) that I didn't touch, since overloading
is a thing and the cast<Bar> did actually change the type -- just up the
class hierarchy).

I also tried to leave the types we were cast<>ing to somewhere nearby,
in cases where it wasn't locally obvious what we were dealing with
before.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@326416 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-01 05:43:23 +00:00
Alexey Bataev e273bc1916 [OPENMP] Emit warning for non-trivial types in map clauses.
If the mapped type is non-trivial, the warning message is emitted for
better user experience.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@326251 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-27 21:31:11 +00:00
Alexey Bataev c55b070633 [OPENMP] Allow multiple mappings for member expressions for pointers.
If several member expressions are mapped and they reference the same
address as a base, but access different members, this must be allowed.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@326212 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-27 17:42:00 +00:00
Alexey Bataev 16003bcdb4 [OPENMP] Do not emit messages for templates in declare target
constructs.

The compiler may emit some extra warnings for functions, that are
implicit specialization of the templates, declared in the target region.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@325391 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-16 21:23:23 +00:00
Alexey Bataev 983fc54414 [OPENMP] Fix PR35873: Fix data-sharing attributes for const variables.
Compiler erroneously returned wrong data-sharing attributes for the
constant variables if they have explictly specified attributes.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@325373 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-16 19:16:54 +00:00
Alexey Bataev 1ed95d8460 [OPENMP] Fix PR38398: compiler crash on standalone pragma ordered with depend sink|source clause.
Patch fixes compiler crash on standalone #pragmas ordered with
depend(sink|source) clauses.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@325302 91177308-0d34-0410-b5e6-96231b3b80d8
2018-02-15 22:42:57 +00:00
Alexey Bataev 960241680b [OPENMP] Remove more empty SourceLocations() from the code.
Removed more empty SourceLocations() from the OpenMP code and replaced
with the correct locations for better debug info emission.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@323232 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-23 18:12:38 +00:00
Alexey Bataev 275b0a025a [OPENMP] Add support for `depend` clauses on `target teams distribute
parallel for simd` directives.

Added codegen for `depend` clauses on `#pragma omp target teams
distribute parallel for simd` directives.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@322587 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-16 19:18:24 +00:00
Alexey Bataev 47898b2812 [OPENMP] Add support for `depend` on `target teams distribute parallel
for` directives.

Added codegen for `depend` clauses on `#pragma omp target teams
distribute parallel for` directives.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@322585 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-16 19:02:33 +00:00
Alexey Bataev 89f8888263 [OPENMP] Add support for `depend` clauses on `target parallel for simd`
directives.

Added codegen for `depend` clauses on `#pragma omp target parallel for
simd` directives.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@322578 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-16 17:55:15 +00:00
Alexey Bataev 850e39c243 [OPENMP] Add support for `depend` clauses on `target parallel for`
directives.

Added codegen for `depend` clause on `#pragma omp target parallel for`
directives.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@322577 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-16 17:41:04 +00:00
Alexey Bataev 985afbc074 [OPENMP] Add support for `depend` clauses on `target teams distribute
simd` directives.

Added codegen for `depend` clauses on `#pragma omp target teams
distribute simd` directives.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@322575 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-16 17:22:50 +00:00
Alexey Bataev 1064d9b118 [OPENMP] Add support for `depend` clause on `target teams distribute`.
Added codegen for `depend` clauses on `#pragma omp target teams
distribute` directives.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@322571 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-16 16:46:46 +00:00
Alexey Bataev 5be47da982 [OPENMP] Add support for `depend` clauses on `target parallel` directive.
Added codegen for `depend` clauses on `#pragma omp target parallel`
directives.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@322570 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-16 16:27:49 +00:00
Alexey Bataev a483fc2091 [OPENMP] Add support for `depend` clauses on `target teams`.
Added codegen for `depend` clause on `#pragma omp target teams`
directives.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@322569 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-16 15:57:07 +00:00
Alexey Bataev 8809092f3f [OPENMP] Add support for `depend` clauses on `target simd`.
Added codegen for `depend` clauses on `#pragma omp target simd`
directives.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@322559 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-16 15:05:16 +00:00
Alexey Bataev 902664b25a [OPENMP] Initial codegen for `target teams distribute parallel for
simd`.

Added host codegen + codegen for devices with default codegen for
`#pragma omp target teams distribute parallel for simd` directive.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@322515 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-15 20:59:40 +00:00
Alexey Bataev c024ae818a [OPENMP] Add codegen for `depend` clauses on `target` directive.
Added basic support for codegen of `depend` clauses on `target`
directive.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@322501 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-15 19:06:12 +00:00
Alexey Bataev 925ec79113 [OPENMP] Fix capturing of expressions in clauses.
Patch fixes incorrect capturing of the expressions in clauses with
expressions that must be captured for the combined constructs. Incorrect
capturing may lead to compiler crash during codegen phase.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321820 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-04 20:50:08 +00:00
Carlo Bertolli b15c783295 [OpenMP] Initial implementation of code generation for pragma 'target teams distribute parallel for' on host
https://reviews.llvm.org/D41709

This patch includes code generation and testing for offloading when target device is host.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321759 91177308-0d34-0410-b5e6-96231b3b80d8
2018-01-03 21:12:44 +00:00
Alexey Bataev 403ecae674 [OPENMP] Support for `depend` clauses on `target enter|exit data`.
Added codegen for `depend` clauses on `target enter|exit data` directives.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321495 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-27 18:49:38 +00:00
Alexey Bataev a847afa6b9 [OPENMP] Support for `depend` clauses on `target data update`.
Added codegen for `depend` clauses on `target data update` directives.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321493 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-27 17:58:32 +00:00
Alexey Bataev e0f33c8c40 [OPENMP] Captured arguments of the capturable clauses by value.
If the clause is applied to the combined construct and has captured
expression, try to capture this expression by value rather than by
reference.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321386 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-22 21:01:52 +00:00
Richard Smith 96881be75c [c++20] P0515R3: Parsing support and basic AST construction for operator <=>.
Adding the new enumerator forced a bunch more changes into this patch than I
would have liked. The -Wtautological-compare warning was extended to properly
check the new comparison operator, clang-format needed updating because it uses
precedence levels as weights for determining where to break lines (and several
operators increased their precedence levels with this change), thread-safety
analysis needed changes to build its own IL properly for the new operator.

All "real" semantic checking for this operator has been deferred to a future
patch. For now, we use the relational comparison rules and arbitrarily give
the builtin form of the operator a return type of 'void'.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320707 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-14 15:16:18 +00:00
Alexey Bataev e3e5f4e1c6 [OPENMP] Initial codegen for `target teams distribute simd` directive.
Host + generic device codegen for `target teams distribute simd`
directive.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320608 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-13 19:45:06 +00:00
Alexey Bataev 3d430af98c [OPENMP] Support `reduction` clause on target-based directives.
OpenMP 5.0 added support for `reduction` clause in target-based
directives. Patch adds this support to clang.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320596 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-13 17:31:39 +00:00
Alexey Bataev a60bd62877 [OPENMP] Fix handling of clauses in clause parsing mode.
The compiler may generate incorrect code if we try to capture the
variable in clause parsing mode.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320590 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-13 15:28:44 +00:00
Kelvin Li c607ed2198 [OpenMP] Diagnose function name on the link clause
This patch is to add diagnose when a function name is
specified on the link clause. According to the  OpenMP
spec, only the list items that exclude the function 
name are allowed on the link clause.

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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320521 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-12 20:08:12 +00:00
Alexey Bataev 984e4561c9 [OPENMP] Initial codegen for `target teams distribute` directive.
Host + default devices codegen for `target teams distribute` directive.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320149 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-08 15:03:50 +00:00
Alexey Bataev f41523819e [OPENMP] Initial codegen for `teams distribute simd` directive.
Host + default devices codegen for `teams distribute simd` directive.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@319896 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-06 14:31:09 +00:00
Alexey Bataev b3d5240383 [OPENMP] Fix implicit mapping analysis.
Fixed processing of implicitly mapped objects in target-based executable
directives.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@319814 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-05 19:20:09 +00:00
Alexey Bataev 11fc3579c4 [OPENMP] Remove non-required parameters for distribute simd outlined
region, NFC.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@319800 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-05 17:41:34 +00:00
Alexey Bataev 6dee2d7289 [OPENMP] Fix assert fail after target implicit map checks.
If the error is generated during analysis of implicitly or explicitly
mapped variables, it may cause compiler crash because of incorrect
analysis.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@319774 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-05 15:22:49 +00:00
Carlo Bertolli 5440a99158 [OpenMP] Initial implementation of code generation for pragma 'teams distribute parallel for simd' on host
https://reviews.llvm.org/D40795

This includes regression tests for all associated clauses.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@319696 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-04 20:57:19 +00:00
Alexey Bataev 1d00b51338 [OPENMP] Codegen for `distribute simd` directive.
Initial codegen support for `distribute simd` directive.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@319661 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-04 15:38:33 +00:00
Alexey Bataev e05cbf9fd8 [OPENMP] Do not allow variables to be first|last-privates in
distribute directives.

OpenMP standard does not allow to mark the variables as firstprivate and lastprivate at the same time in distribute-based directives. Patch fixes this problem.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@319560 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-01 17:40:15 +00:00
Richard Smith 8b60629816 [c++2a] P0515R3: Support for overloaded operator<=>.
No CodeGen support for MSABI yet, we don't know how to mangle this there.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@319513 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-01 02:13:10 +00:00
Kelvin Li af90f306af [OpenMP] Diagnose undeclared variables on declare target clause
Clang asserts on undeclared variables on the to or link clause in the declare
target directive. The patch is to properly diagnose the error.

// foo1 and foo2 are not declared
#pragma omp declare target to(foo1)
#pragma omp declare target link(foo2)

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



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@319458 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-30 18:52:06 +00:00