Commit Graph

847 Commits

Author SHA1 Message Date
Daniel Neilson c8bdc8db73 Change memcpy/memove/memset to have dest and source alignment attributes.
Summary:
  This change is step three in the series of changes to remove alignment argument from
memcpy/memmove/memset in favour of alignment attributes. Steps:

Step 1) Remove alignment parameter and create alignment parameter attributes for
memcpy/memmove/memset. ( rL322965, rC322964, rL322963 )
Step 2) Expand the IRBuilder API to allow creation of memcpy/memmove with differing
source and dest alignments. ( rL323597 )
Step 3) Update Clang to use the new IRBuilder API.
Step 4) Update Polly to use the new IRBuilder API.
Step 5) Update LLVM passes that create memcpy/memmove calls to use the new IRBuilder API,
and those that use use MemIntrinsicInst::[get|set]Alignment() to use getDestAlignment()
and getSourceAlignment() instead.
Step 6) Remove the single-alignment IRBuilder API for memcpy/memmove, and the
MemIntrinsicInst::[get|set]Alignment() methods.

Reference
   http://lists.llvm.org/pipermail/llvm-dev/2015-August/089384.html
   http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20151109/312083.html

Reviewers: rjmccall

Subscribers: jyknight, nemanjai, nhaehnle, javed.absar, sbc100, aheejin, kbarton, fedor.sergeev, cfe-commits

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

llvm-svn: 323617
2018-01-28 17:27:45 +00:00
Alexey Bataev a9b9cc0d79 [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.

llvm-svn: 323232
2018-01-23 18:12:38 +00:00
Daniel Neilson 6e938effaa Change memcpy/memove/memset to have dest and source alignment attributes (Step 1).
Summary:
  Upstream LLVM is changing the the prototypes of the @llvm.memcpy/memmove/memset
intrinsics. This change updates the Clang tests for this change.

  The @llvm.memcpy/memmove/memset intrinsics currently have an explicit argument
which is required to be a constant integer. It represents the alignment of the
dest (and source), and so must be the minimum of the actual alignment of the
two.

 This change removes the alignment argument in favour of placing the alignment
attribute on the source and destination pointers of the memory intrinsic call.

 For example, code which used to read:
   call void @llvm.memcpy.p0i8.p0i8.i32(i8* %dest, i8* %src, i32 100, i32 4, i1 false)
will now read
   call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 4 %dest, i8* align 4 %src, i32 100, i1 false)

 At this time the source and destination alignments must be the same (Step 1).
Step 2 of the change, to be landed shortly, will relax that contraint and allow
the source and destination to have different alignments.

llvm-svn: 322964
2018-01-19 17:12:54 +00:00
Jonas Hahnfeld 5e4df288e2 [OpenMP] Correct generation of offloading entries
Firstly, each offloading entry must have a unique name or the
linker will complain if there are multiple files with target
regions. Secondly, the compiler must not introduce padding so
mark the struct with a PackedAttr.

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

llvm-svn: 322858
2018-01-18 15:38:03 +00:00
Rafael Espindola e0345b6e1f Update for llvm change.
llvm-svn: 322808
2018-01-18 02:08:38 +00:00
Alexey Bataev 9350fc3987 [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.

llvm-svn: 322587
2018-01-16 19:18:24 +00:00
Alexey Bataev 9f9fb0ba35 [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.

llvm-svn: 322585
2018-01-16 19:02:33 +00:00
Alexey Bataev d60d1baadb [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.

llvm-svn: 322578
2018-01-16 17:55:15 +00:00
Alexey Bataev 8ed89551e2 [OPENMP] Add support for `depend` clauses on `target parallel for`
directives.

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

llvm-svn: 322577
2018-01-16 17:41:04 +00:00
Alexey Bataev 8d16a43416 [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.

llvm-svn: 322575
2018-01-16 17:22:50 +00:00
Alexey Bataev 79df756d1f [OPENMP] Add support for `depend` clause on `target teams distribute`.
Added codegen for `depend` clauses on `#pragma omp target teams
distribute` directives.

llvm-svn: 322571
2018-01-16 16:46:46 +00:00
Alexey Bataev 54d5c7dc44 [OPENMP] Add support for `depend` clauses on `target parallel` directive.
Added codegen for `depend` clauses on `#pragma omp target parallel`
directives.

llvm-svn: 322570
2018-01-16 16:27:49 +00:00
Alexey Bataev 0c869ef21c [OPENMP] Add support for `depend` clauses on `target teams`.
Added codegen for `depend` clause on `#pragma omp target teams`
directives.

llvm-svn: 322569
2018-01-16 15:57:07 +00:00
Alexey Bataev f41c88fd50 [OPENMP] Add support for `depend` clauses on `target simd`.
Added codegen for `depend` clauses on `#pragma omp target simd`
directives.

llvm-svn: 322559
2018-01-16 15:05:16 +00:00
Alexey Bataev 647dd84422 [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.

llvm-svn: 322515
2018-01-15 20:59:40 +00:00
Alexey Bataev 8451efad89 [OPENMP] Add codegen for `depend` clauses on `target` directive.
Added basic support for codegen of `depend` clauses on `target`
directive.

llvm-svn: 322501
2018-01-15 19:06:12 +00:00
Alexey Bataev 475a7440f1 [OPENMP] Replace calls of getAssociatedStmt().
getAssociatedStmt() returns the outermost captured statement for the
OpenMP directive. It may return incorrect region in case of combined
constructs. Reworked the code to reduce the number of calls of
getAssociatedStmt() and used getInnermostCapturedStmt() and
getCapturedStmt() functions instead.
In case of firstprivate variables it may lead to an extra allocas
generation for private copies even if the variable is passed by value
into outlined function and could be used directly as private copy.

llvm-svn: 322393
2018-01-12 19:39:11 +00:00
Rafael Espindola cbca487f49 Make internal/private GVs implicitly dso_local.
While updating clang tests for having clang set dso_local I noticed
that:

- There are *a lot* of tests to update.
- Many of the updates are redundant.

They are redundant because a GV is "obviously dso_local". This patch
starts formalizing that a bit by requiring that internal and private
GVs be dso_local too. Since they all are, we don't have to print
dso_local to the textual representation, making it a bit more compact
and easier to read.

llvm-svn: 322318
2018-01-11 22:15:12 +00:00
Alexey Bataev f3c832a970 [OpenMP] Fix handling of clause on wrong directive, by Joel. E. Denny
Summary:
First, this patch fixes an assert failure when, for example, "omp for"
has num_teams.

Second, this patch prevents duplicate diagnostics when, for example,
"omp for" has uniform.

This patch makes the general assumption (even where it doesn't
necessarily fix an existing bug) that it is worthless to perform sema
for a clause that appears on a directive on which OpenMP does not
permit that clause.  However, due to this assumption, this patch
suppresses some diagnostics that were expected in the test suite.  I
assert that those diagnostics were likely just distracting to the
user.

Reviewers: ABataev

Reviewed By: ABataev

Subscribers: cfe-commits

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

llvm-svn: 322107
2018-01-09 19:21:04 +00:00
Alexey Bataev aee9389b04 [OPENMP] Fix debug info for outlined functions in NVPTX + add more tests.
Fixed name of emitted outlined functions in NVPTX target + extra tests
for the debug info.

llvm-svn: 322022
2018-01-08 20:09:47 +00:00
Alexey Bataev fd9b2affc3 [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.

llvm-svn: 321820
2018-01-04 20:50:08 +00:00
Alexey Bataev b2575930b3 [OPENMP] Fix casting in NVPTX support library.
If the reduction required shuffle in the NVPTX codegen, we may need to
cast the reduced value to the integer type. This casting was implemented
incorrectly and may cause compiler crash. Patch fixes this problem.

llvm-svn: 321818
2018-01-04 20:18:55 +00:00
Alexey Bataev 7cae94e74c [OPENMP] Add debug info for generated functions.
Most of the generated functions for the OpenMP were generated with
disabled debug info. Patch fixes this for better user experience.

llvm-svn: 321816
2018-01-04 19:45:16 +00:00
Carlo Bertolli 52978c3554 [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.

llvm-svn: 321759
2018-01-03 21:12:44 +00:00
Reid Kleckner 06f19a0de0 [WinEH] Allow for multiple terminatepads
Fixes verifier errors with Windows EH and OpenMP, which injects a
terminate scope around parallel blocks.

Fixes PR35778

llvm-svn: 321676
2018-01-02 21:34:16 +00:00
Alexey Bataev a8a9153a37 [OPENMP] Support for -fopenmp-simd option with compilation of simd loops
only.

Added support for -fopenmp-simd option that allows compilation of
simd-based constructs without emission of OpenMP runtime calls.

llvm-svn: 321560
2017-12-29 18:07:07 +00:00
Alexey Bataev e927ca74ee [OPENMP] Initial support for `-fopenmp-simd` option.
Added basic support for `-fopenmp-simd` options.

llvm-svn: 321558
2017-12-29 17:36:15 +00:00
Alexey Bataev fab20e4ea4 [OPENMP] Support for `depend` clauses on `target enter|exit data`.
Added codegen for `depend` clauses on `target enter|exit data` directives.

llvm-svn: 321495
2017-12-27 18:49:38 +00:00
Alexey Bataev d2202caeda [OPENMP] Support for `depend` clauses on `target data update`.
Added codegen for `depend` clauses on `target data update` directives.

llvm-svn: 321493
2017-12-27 17:58:32 +00:00
Jonas Hahnfeld fa059ba59e [OpenMP] Further adjustments of nvptx runtime functions
Pass in default value of 1, similar to previous commit r318836.

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

llvm-svn: 321486
2017-12-27 10:39:56 +00:00
Alexey Bataev ca9e57084c [OPENMP] Fix the tests for 32bits targets, NFC.
llvm-svn: 321427
2017-12-24 14:18:33 +00:00
Alexey Bataev 8e769ee70b [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.

llvm-svn: 321386
2017-12-22 21:01:52 +00:00
Aaron Ballman 8c20828b5c Re-commit r321223, which adds a printing policy to the ASTDumper.
This allows you to dump C++ code that spells bool instead of _Bool, leaves off the elaborated type specifiers when printing struct or class names, and other C-isms.

Fixes the -Wreorder issue and fixes the ast-dump-color.cpp test.

llvm-svn: 321310
2017-12-21 21:42:42 +00:00
Aaron Ballman 9d6501f6cd Reverting r321223 and its follow-up commit because of failing bots due to Misc/ast-dump-color.cpp.
llvm-svn: 321229
2017-12-20 23:17:29 +00:00
Aaron Ballman 207ee3d0a7 Add a printing policy to the ASTDumper.
This allows you to dump C++ code that spells bool instead of _Bool, leaves off the elaborated type specifiers when printing struct or class names, and other C-isms.

llvm-svn: 321223
2017-12-20 22:04:54 +00:00
Alexey Bataev b952e639d9 [OPENMP] Codegen `declare simd` for function declarations.
Previously the attributes were emitted only for function definitions.
Patch adds emission of the attributes for function declarations.

llvm-svn: 320826
2017-12-15 16:28:31 +00:00
Alexey Bataev 0cc6b8ec61 [OPENMP] Add codegen for target data constructs with `nowait` clause.
Added codegen for the `nowait` clause in target data constructs.

llvm-svn: 320717
2017-12-14 17:00:17 +00:00
Alexey Bataev a9f77c6df7 [OPENMP] Add codegen for `nowait` clause in target directives.
Added basic codegen for `nowait` clauses in target-based directives.

llvm-svn: 320613
2017-12-13 21:04:20 +00:00
Alexey Bataev fbe17fb8a5 [OPENMP] Initial codegen for `target teams distribute simd` directive.
Host + generic device codegen for `target teams distribute simd`
directive.

llvm-svn: 320608
2017-12-13 19:45:06 +00:00
Alexey Bataev 3f96fe6d44 [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.

llvm-svn: 320596
2017-12-13 17:31:39 +00:00
Alexey Bataev 3f82cfc329 [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.

llvm-svn: 320590
2017-12-13 15:28:44 +00:00
Gheorghe-Teodor Bercea b4c74c6603 [OpenMP] Add function attribute for triggering data sharing.
Summary:
The backend should only emit data sharing code for the cases where it is needed.
A new function attribute is used by Clang to enable data sharing only for the cases where OpenMP semantics require it and there are variables that need to be shared.

Reviewers: hfinkel, Hahnfeld, ABataev, carlo.bertolli, caomhin

Reviewed By: ABataev

Subscribers: cfe-commits, jholewinski

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

llvm-svn: 320527
2017-12-12 21:38:43 +00:00
Kelvin Li 1ce87c7051 [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

llvm-svn: 320521
2017-12-12 20:08:12 +00:00
Tim Northover 36bb6d5d46 Switch to gnu++14 as the default dialect.
This is C++14 with conforming GNU extensions.

llvm-svn: 320250
2017-12-09 12:09:54 +00:00
Alexey Bataev e83b3e89e6 [OPENMP] Simplify codegen for loop iteration variables in loop preamble.
Initial patch could cause trouble in the optimized code because of the
incorrectly generated lifetime intrinsics.

llvm-svn: 320191
2017-12-08 20:18:58 +00:00
Alexey Bataev dfa430f694 [OPENMP] Initial codegen for `target teams distribute` directive.
Host + default devices codegen for `target teams distribute` directive.

llvm-svn: 320149
2017-12-08 15:03:50 +00:00
Alexey Bataev 8cf35e4683 [OPENMP] Do not capture private variables in the target regions.
Private variables are completely redefined in the outlined regions, so
we don't need to capture them. Patch adds this behavior to the
target-based regions.

llvm-svn: 320078
2017-12-07 19:49:28 +00:00
Jonas Hahnfeld 273d261b8f Fix PR35542: Correct adjusting of private reduction variable
The adjustment is calculated with CreatePtrDiff() which returns
the difference in (base) elements. This is passed to CreateGEP()
so make sure that the GEP base has the correct pointer type:
It needs to be a pointer to the base type, not a pointer to a
constant sized array.

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

llvm-svn: 319931
2017-12-06 19:15:28 +00:00
Alexey Bataev b7304a15cd [OPENMP] Improve error message for mapping union members.
llvm-svn: 319897
2017-12-06 15:04:36 +00:00
Alexey Bataev 999277ad22 [OPENMP] Initial codegen for `teams distribute simd` directive.
Host + default devices codegen for `teams distribute simd` directive.

llvm-svn: 319896
2017-12-06 14:31:09 +00:00