]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
5 years agoAdd OpenACC target kinds for decomposed kernels regions
Thomas Schwinge [Wed, 23 Jan 2019 14:56:52 +0000 (06:56 -0800)] 
Add OpenACC target kinds for decomposed kernels regions

This patch is in preparation for changes that will cut up OpenACC kernels
regions into individual parts. For the new sub-regions that will be
generated, this adds the following new kinds of OpenACC regions for internal
use:

- GF_OMP_TARGET_KIND_OACC_PARALLEL_KERNELS_PARALLELIZED for parts of kernels
  regions to be executed in gang-redundant mode
- GF_OMP_TARGET_KIND_OACC_PARALLEL_KERNELS_GANG_SINGLE for parts of kernels
  regions to be executed in gang-single mode
- GF_OMP_TARGET_KIND_OACC_DATA_KERNELS for data regions generated around the
  body of a kernels region

    gcc/
    * gimple.h (enum gf_mask): Add new target kinds
    GF_OMP_TARGET_KIND_OACC_PARALLEL_KERNELS_PARALLELIZED,
    GF_OMP_TARGET_KIND_OACC_PARALLEL_KERNELS_GANG_SINGLE, and
    GF_OMP_TARGET_KIND_OACC_DATA_KERNELS.
    (is_gimple_omp_oacc): Handle new target kinds.
    (is_gimple_omp_offloaded): Likewise.
    * gimple-pretty-print.c (dump_gimple_omp_target): Likewise.
    * omp-expand.c (expand_omp_target): Likewise.
    (build_omp_regions_1): Likewise.
    (omp_make_gimple_edges): Likewise.
    * omp-low.c (is_oacc_parallel_or_serial): Likewise.
    (was_originally_oacc_kernels): New function.
    (scan_omp_for): Update check for illegal nesting.
    (check_omp_nesting_restrictions): Handle new target kinds.
    (lower_oacc_reductions): Likewise.
    (lower_omp_target): Likewise.
    * omp-offload.c (execute_oacc_device_lower): Likewise.

(cherry picked from openacc-gcc-9-branch commit
b24a8fc55b6d4fd38a8feff5bca4940e28a005ed)

5 years agoUse "-fopenacc-kernels=parloops" to document "parloops" test cases
Thomas Schwinge [Wed, 30 Jan 2019 09:32:10 +0000 (10:32 +0100)] 
Use "-fopenacc-kernels=parloops" to document "parloops" test cases

gcc/
* flag-types.h (enum openacc_kernels): New type.
gcc/c-family/
* c.opt (fopenacc-kernels): New flag.
gcc/fortran/
* lang.opt (fopenacc-kernels): New flag.
gcc/testsuite/
* c-c++-common/goacc/kernels-1.c: Add
"-fopenacc-kernels=parloops".
* c-c++-common/goacc/kernels-acc-loop-reduction.c: Likewise.
* c-c++-common/goacc/kernels-acc-loop-smaller-equal.c: Likewise.
* c-c++-common/goacc/kernels-alias-2.c: Likewise.
* c-c++-common/goacc/kernels-alias-3.c: Likewise.
* c-c++-common/goacc/kernels-alias-4.c: Likewise.
* c-c++-common/goacc/kernels-alias-5.c: Likewise.
* c-c++-common/goacc/kernels-alias-6.c: Likewise.
* c-c++-common/goacc/kernels-alias-7.c: Likewise.
* c-c++-common/goacc/kernels-alias-8.c: Likewise.
* c-c++-common/goacc/kernels-alias-ipa-pta-2.c: Likewise.
* c-c++-common/goacc/kernels-alias-ipa-pta-3.c: Likewise.
* c-c++-common/goacc/kernels-alias-ipa-pta-4.c: Likewise.
* c-c++-common/goacc/kernels-alias-ipa-pta.c: Likewise.
* c-c++-common/goacc/kernels-alias.c: Likewise.
* c-c++-common/goacc/kernels-counter-var-redundant-load.c:
Likewise.
* c-c++-common/goacc/kernels-counter-vars-function-scope.c:
Likewise.
* c-c++-common/goacc/kernels-double-reduction-n.c: Likewise.
* c-c++-common/goacc/kernels-double-reduction.c: Likewise.
* c-c++-common/goacc/kernels-loop-2-acc-loop.c: Likewise.
* c-c++-common/goacc/kernels-loop-2.c: Likewise.
* c-c++-common/goacc/kernels-loop-3-acc-loop.c: Likewise.
* c-c++-common/goacc/kernels-loop-3.c: Likewise.
* c-c++-common/goacc/kernels-loop-acc-loop.c: Likewise.
* c-c++-common/goacc/kernels-loop-data-2.c: Likewise.
* c-c++-common/goacc/kernels-loop-data-enter-exit-2.c: Likewise.
* c-c++-common/goacc/kernels-loop-data-enter-exit.c: Likewise.
* c-c++-common/goacc/kernels-loop-data-update.c: Likewise.
* c-c++-common/goacc/kernels-loop-data.c: Likewise.
* c-c++-common/goacc/kernels-loop-g.c: Likewise.
* c-c++-common/goacc/kernels-loop-mod-not-zero.c: Likewise.
* c-c++-common/goacc/kernels-loop-n-acc-loop.c: Likewise.
* c-c++-common/goacc/kernels-loop-n.c: Likewise.
* c-c++-common/goacc/kernels-loop-nest.c: Likewise.
* c-c++-common/goacc/kernels-loop.c: Likewise.
* c-c++-common/goacc/kernels-one-counter-var.c: Likewise.
* c-c++-common/goacc/kernels-parallel-loop-data-enter-exit.c:
Likewise.
* c-c++-common/goacc/kernels-reduction.c: Likewise.
* gfortran.dg/goacc/kernels-alias-2.f95: Likewise.
* gfortran.dg/goacc/kernels-alias-3.f95: Likewise.
* gfortran.dg/goacc/kernels-alias-4.f95: Likewise.
* gfortran.dg/goacc/kernels-alias.f95: Likewise.
* gfortran.dg/goacc/kernels-loop-2.f95: Likewise.
* gfortran.dg/goacc/kernels-loop-data-2.f95: Likewise.
* gfortran.dg/goacc/kernels-loop-data-enter-exit-2.f95: Likewise.
* gfortran.dg/goacc/kernels-loop-data-enter-exit.f95: Likewise.
* gfortran.dg/goacc/kernels-loop-data-update.f95: Likewise.
* gfortran.dg/goacc/kernels-loop-data.f95: Likewise.
* gfortran.dg/goacc/kernels-loop-inner.f95: Likewise.
* gfortran.dg/goacc/kernels-loop-n.f95: Likewise.
* gfortran.dg/goacc/kernels-loop.f95: Likewise.
* gfortran.dg/goacc/kernels-loops-adjacent.f95: Likewise.
* gfortran.dg/goacc/kernels-parallel-loop-data-enter-exit.f95:
Likewise.
libgomp/
* testsuite/libgomp.oacc-c-c++-common/kernels-alias-ipa-pta-2.c:
Add "-fopenacc-kernels=parloops".
* testsuite/libgomp.oacc-c-c++-common/kernels-alias-ipa-pta-3.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/kernels-alias-ipa-pta.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/kernels-empty.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/kernels-loop-2.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/kernels-loop-3.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/kernels-loop-and-seq-2.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/kernels-loop-and-seq-3.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/kernels-loop-and-seq-4.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/kernels-loop-and-seq-5.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/kernels-loop-and-seq-6.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/kernels-loop-and-seq.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/kernels-loop-collapse.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/kernels-loop-data-2.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/kernels-loop-data-enter-exit-2.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/kernels-loop-data-enter-exit.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/kernels-loop-data-update.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/kernels-loop-data.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/kernels-loop-g.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/kernels-loop-mod-not-zero.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/kernels-loop-n.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/kernels-loop-nest.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/kernels-loop.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/kernels-parallel-loop-data-enter-exit.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/kernels-reduction-1.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/kernels-reduction.c:
Likewise.
* testsuite/libgomp.oacc-fortran/kernels-loop-2.f95: Likewise.
* testsuite/libgomp.oacc-fortran/kernels-loop-data-2.f95:
Likewise.
* testsuite/libgomp.oacc-fortran/kernels-loop-data-enter-exit-2.f95:
Likewise.
* testsuite/libgomp.oacc-fortran/kernels-loop-data-enter-exit.f95:
Likewise.
* testsuite/libgomp.oacc-fortran/kernels-loop-data-update.f95:
Likewise.
* testsuite/libgomp.oacc-fortran/kernels-loop-data.f95: Likewise.
* testsuite/libgomp.oacc-fortran/kernels-loop.f95: Likewise.
* testsuite/libgomp.oacc-fortran/kernels-parallel-loop-data-enter-exit.f95:
Likewise.
* testsuite/libgomp.oacc-fortran/kernels-reduction-1.f90:
Likewise.

(cherry picked from openacc-gcc-9-branch commit
ff54f28eee8129e9f72d88d0a6d1d15604f652ca)

5 years agoAdd OpenACC 2.6 `acc_get_property' support
Maciej W. Rozycki [Thu, 20 Dec 2018 14:10:17 +0000 (14:10 +0000)] 
Add OpenACC 2.6 `acc_get_property' support

Add generic support for the OpenACC 2.6 `acc_get_property' and
`acc_get_property_string' routines, as well as full handlers for the
host and the NVPTX offload targets and a minimal handler for the HSA
offload target.

Include test cases for both C/C++ and Fortran support, both producing:

OpenACC vendor: GNU
OpenACC name: GOMP
OpenACC driver: 1.0

with the host driver and output like:

OpenACC vendor: Nvidia
OpenACC total memory: 12651462656
OpenACC free memory: 12202737664
OpenACC name: TITAN V
OpenACC driver: 9.1

with the NVPTX driver.

include/
* gomp-constants.h (GOMP_DEVICE_CURRENT): New macro.
(GOMP_DEVICE_PROPERTY_MEMORY, GOMP_DEVICE_PROPERTY_FREE_MEMORY)
(GOMP_DEVICE_PROPERTY_NAME, GOMP_DEVICE_PROPERTY_VENDOR)
(GOMP_DEVICE_PROPERTY_DRIVER): Likewise.
(GOMP_DEVICE_PROPERTY_STRING_MASK): Likewise.

libgomp/
* libgomp.h (gomp_device_descr): Add `get_property_func' member.
* libgomp-plugin.h (gomp_device_property_value): New union.
(gomp_device_property_value): New prototype.
* openacc.h (acc_device_t): Add `acc_device_current' enumeration
constant.
(acc_device_property_t): New enum.
(acc_get_property, acc_get_property_string): New prototypes.
* oacc-init.c (acc_get_device_type): Also assert on
`!acc_device_current' result.
(get_property_any, acc_get_property, acc_get_property_string):
New functions.
* openacc.f90 (openacc_kinds): From `iso_fortran_env' also
import `int64'.  Add `acc_device_current' and
`acc_property_memory', `acc_property_free_memory',
`acc_property_name', `acc_property_vendor' and
`acc_property_driver' constants.  Add `acc_device_property' data
type.
(openacc_internal): Add `acc_get_property' and
`acc_get_property_string' interfaces.  Add `acc_get_property_h',
`acc_get_property_string_h', `acc_get_property_l' and
`acc_get_property_string_l'.
(openacc_c_string): New module.
* oacc-host.c (host_get_property): New function.
(host_dispatch): Wire it.
* target.c (gomp_load_plugin_for_device): Handle `get_property'.
* libgomp.map (OACC_2.6): Add `acc_get_property',
`acc_get_property_h_', `acc_get_property_string' and
`acc_get_property_string_h_' symbols.
* libgomp.texi (OpenACC Runtime Library Routines): Add
`acc_get_property'.
(acc_get_property): New node.

* plugin/plugin-hsa.c (GOMP_OFFLOAD_get_property): New function.
* plugin/plugin-nvptx.c (CUDA_CALLS): Add `cuDeviceGetName',
`cuDeviceTotalMem', `cuDriverGetVersion' and `cuMemGetInfo'
calls.
(GOMP_OFFLOAD_get_property): New function.

* testsuite/libgomp.oacc-c-c++-common/acc-get-property.c: New
test.
* testsuite/libgomp.oacc-fortran/acc-get-property.f: New test.

(cherry picked from openacc-gcc-9-branch commit
4674caa90e82c209db51bf1fb5d7ec42364d47a2)

5 years agoAdd OpenACC 2.6 `no_create' clause support
Maciej W. Rozycki [Thu, 20 Dec 2018 14:10:19 +0000 (14:10 +0000)] 
Add OpenACC 2.6 `no_create' clause support

The clause makes any device code use the local memory address for each
of the variables specified unless the given variable is already present
on the current device.

2018-12-19  Julian Brown  <julian@codesourcery.com>
            Maciej W. Rozycki  <macro@codesourcery.com>

gcc/
* omp-low.c (lower_omp_target): Support GOMP_MAP_NO_ALLOC.
* tree-pretty-print.c (dump_omp_clause): Likewise.

gcc/c-family/
* c-pragma.h (pragma_omp_clause): Add
PRAGMA_OACC_CLAUSE_NO_CREATE.

gcc/c/
* c-parser.c (c_parser_omp_clause_name): Support no_create.
(c_parser_oacc_data_clause): Likewise.
(c_parser_oacc_all_clauses): Likewise.
(OACC_DATA_CLAUSE_MASK, OACC_KERNELS_CLAUSE_MASK)
(OACC_PARALLEL_CLAUSE_MASK, OACC_SERIAL_CLAUSE_MASK): Add
PRAGMA_OACC_CLAUSE_NO_CREATE.
* c-typeck.c (handle_omp_array_sections): Support
GOMP_MAP_NO_ALLOC.

gcc/cp/
* parser.c (cp_parser_omp_clause_name): Support no_create.
(cp_parser_oacc_data_clause): Likewise.
(cp_parser_oacc_all_clauses): Likewise.
(OACC_DATA_CLAUSE_MASK, OACC_KERNELS_CLAUSE_MASK)
(OACC_PARALLEL_CLAUSE_MASK, OACC_SERIAL_CLAUSE_MASK): Add
PRAGMA_OACC_CLAUSE_NO_CREATE.
* semantics.c (handle_omp_array_sections): Support no_create.

gcc/fortran/
* gfortran.h (gfc_omp_map_op): Add OMP_MAP_NO_ALLOC.
* openmp.c (omp_mask2): Add OMP_CLAUSE_NO_CREATE.
(gfc_match_omp_clauses): Support no_create.
(OACC_PARALLEL_CLAUSES, OACC_KERNELS_CLAUSES)
(OACC_SERIAL_CLAUSES, OACC_DATA_CLAUSES): Add
OMP_CLAUSE_NO_CREATE.
* trans-openmp.c (gfc_trans_omp_clauses_1): Support
OMP_MAP_NO_ALLOC.

include/
* gomp-constants.h (gomp_map_kind): Support GOMP_MAP_NO_ALLOC.

libgomp/
* target.c (gomp_map_vars_async): Support GOMP_MAP_NO_ALLOC.

* testsuite/libgomp.oacc-c-c++-common/nocreate-1.c: New test.
* testsuite/libgomp.oacc-c-c++-common/nocreate-2.c: New test.
* testsuite/libgomp.oacc-c-c++-common/nocreate-3.c: New test.
* testsuite/libgomp.oacc-c-c++-common/nocreate-4.c: New test.
* testsuite/libgomp.oacc-fortran/nocreate-1.f90: New test.
* testsuite/libgomp.oacc-fortran/nocreate-2.f90: New test.

(cherry picked from openacc-gcc-9-branch commit
8e74c2ec2b90819c995444370e742864a685209f)

5 years agoAdd OpenACC 2.6 `serial' construct support
Maciej W. Rozycki [Thu, 20 Dec 2018 14:10:18 +0000 (14:10 +0000)] 
Add OpenACC 2.6 `serial' construct support

The `serial' construct is equivalent to a `parallel' construct with
clauses `num_gangs(1) num_workers(1) vector_length(1)' implied.
Naturally these clauses are therefore not supported with the `serial'
construct.  All the remaining clauses accepted with `parallel' are also
accepted with `serial'.

Consequently implementation is straightforward, by handling `serial'
exactly like `parallel', except for hardcoding dimensions rather than
taking them from the relevant clauses, in `expand_omp_target'.

Separate codes are used to denote the `serial' construct throughout the
middle end, even though the mapping of `serial' to an equivalent
`parallel' construct could have been done in the individual language
frontends, saving a lot of mechanical changes and avoiding middle-end
code expansion.  This is so that any reporting such as with warning or
error messages and in diagnostic dumps use `serial' rather than
`parallel', therefore avoiding user confusion.

gcc/
* gimple.h (gf_mask): Add GF_OMP_TARGET_KIND_OACC_SERIAL
enumeration constant.
(is_gimple_omp_oacc): Handle GF_OMP_TARGET_KIND_OACC_SERIAL.
(is_gimple_omp_offloaded): Likewise.
* gimplify.c (omp_region_type): Add ORT_ACC_SERIAL enumeration
constant.  Adjust the value of ORT_NONE accordingly.
(is_gimple_stmt): Handle OACC_SERIAL.
(oacc_default_clause): Handle ORT_ACC_SERIAL.
(gomp_needs_data_present): Likewise.
(gimplify_adjust_omp_clauses): Likewise.
(gimplify_omp_workshare): Handle OACC_SERIAL.
(gimplify_expr): Likewise.
* omp-expand.c (expand_omp_target): Handle
GF_OMP_TARGET_KIND_OACC_SERIAL.
(build_omp_regions_1, omp_make_gimple_edges): Likewise.
* omp-low.c (is_oacc_parallel): Rename function to...
(is_oacc_parallel_or_serial): ... this.  Handle
GF_OMP_TARGET_KIND_OACC_SERIAL.
(build_receiver_ref): Adjust accordingly.
(build_sender_ref): Likewise.
(scan_sharing_clauses): Likewise.
(create_omp_child_function): Likewise.
(scan_omp_for): Likewise.
(scan_omp_target): Likewise.
(lower_oacc_head_mark): Likewise.
(convert_from_firstprivate_int): Likewise.
(lower_omp_target): Likewise.
(check_omp_nesting_restrictions): Handle
GF_OMP_TARGET_KIND_OACC_SERIAL.
(lower_oacc_reductions): Likewise.
(lower_omp_target): Likewise.
* tree-pretty-print.c (dump_generic_node): Handle OACC_SERIAL.
* tree.def (OACC_SERIAL): New tree code.

* doc/generic.texi (OpenACC): Document OACC_SERIAL.

gcc/c-family/
* c-pragma.h (pragma_kind): Add PRAGMA_OACC_SERIAL enumeration
constant.
* c-pragma.c (oacc_pragmas): Add "serial" entry.

gcc/c/
* c-parser.c (OACC_SERIAL_CLAUSE_MASK): New macro.
(OACC_SERIAL_CLAUSE_DEVICE_TYPE_MASK): Likewise.
(c_parser_oacc_kernels_parallel): Rename function to...
(c_parser_oacc_compute): ... this.  Handle PRAGMA_OACC_SERIAL.
(c_parser_omp_construct): Update accordingly.

gcc/cp/
* constexpr.c (potential_constant_expression_1): Handle
OACC_SERIAL.
* parser.c (OACC_SERIAL_CLAUSE_MASK): New macro.
(OACC_SERIAL_CLAUSE_DEVICE_TYPE_MASK): Likewise.
(cp_parser_oacc_kernels_parallel): Rename function to...
(cp_parser_oacc_compute): ... this.  Handle PRAGMA_OACC_SERIAL.
(cp_parser_omp_construct): Update accordingly.
(cp_parser_pragma): Handle PRAGMA_OACC_SERIAL.  Fix alphabetic
order.
* pt.c (tsubst_expr): Handle OACC_SERIAL.

gcc/fortran/
* gfortran.h (gfc_statement): Add ST_OACC_SERIAL_LOOP,
ST_OACC_END_SERIAL_LOOP, ST_OACC_SERIAL and ST_OACC_END_SERIAL
enumeration constants.
(gfc_exec_op): Add EXEC_OACC_SERIAL_LOOP and EXEC_OACC_SERIAL
enumeration constants.
* match.h (gfc_match_oacc_serial): New prototype.
(gfc_match_oacc_serial_loop): Likewise.
* dump-parse-tree.c (show_omp_node, show_code_node): Handle
EXEC_OACC_SERIAL_LOOP and EXEC_OACC_SERIAL.
* match.c (match_exit_cycle): Handle EXEC_OACC_SERIAL_LOOP.
* openmp.c (OACC_SERIAL_CLAUSES): New macro.
(OACC_SERIAL_CLAUSE_DEVICE_TYPE_MASK): Likewise.
(gfc_match_oacc_serial_loop): New function.
(gfc_match_oacc_serial): Likewise.
(oacc_is_loop): Handle EXEC_OACC_SERIAL_LOOP.
(resolve_omp_clauses): Handle EXEC_OACC_SERIAL.
(oacc_is_serial): New function.
(oacc_code_to_statement): Handle EXEC_OACC_SERIAL and
EXEC_OACC_SERIAL_LOOP.
(gfc_resolve_oacc_directive): Likewise.
* parse.c (decode_oacc_directive) <'s'>: Add case for "serial"
and "serial loop".
(next_statement): Handle ST_OACC_SERIAL_LOOP and ST_OACC_SERIAL.
(gfc_ascii_statement): Likewise.  Handle ST_OACC_END_SERIAL_LOOP
and ST_OACC_END_SERIAL.
(parse_oacc_structured_block): Handle ST_OACC_SERIAL.
(parse_oacc_loop): Handle ST_OACC_SERIAL_LOOP and
ST_OACC_END_SERIAL_LOOP.
(parse_executable): Handle ST_OACC_SERIAL_LOOP and
ST_OACC_SERIAL.
(is_oacc): Handle EXEC_OACC_SERIAL_LOOP and EXEC_OACC_SERIAL.
* resolve.c (gfc_resolve_blocks, gfc_resolve_code): Likewise.
* st.c (gfc_free_statement): Likewise.
* trans-openmp.c (gfc_trans_oacc_construct): Handle
EXEC_OACC_SERIAL.
(gfc_trans_oacc_combined_directive): Handle
EXEC_OACC_SERIAL_LOOP.
(gfc_trans_oacc_directive): Handle EXEC_OACC_SERIAL_LOOP and
EXEC_OACC_SERIAL.
* trans.c (trans_code): Likewise.

gcc/testsuite/
* c-c++-common/goacc/serial-dims.c: New test.

libgomp/
* testsuite/libgomp.oacc-c-c++-common/serial-dims.c: New test.

(cherry picked from openacc-gcc-9-branch commit
46e6f6b64f5e9e9996e7a66e3885747d85dab8b2)

5 years agoUse functional parameters for data mappings in OpenACC child functions
Cesar Philippidis [Thu, 21 Dec 2017 21:40:34 +0000 (13:40 -0800)] 
Use functional parameters for data mappings in OpenACC child functions

* Makefile.def: Make libgomp depend on libffi.
* configure.ac: Likewise.
* Makefile.in: Regenerate.
* configure: Regenerate.

gcc/fortran/
* types.def: (BF_FN_VOID_INT_INT_OMPFN_SIZE_PTR_PTR_PTR_VAR):
Define.

gcc/
* builtin-types.def (BF_FN_VOID_INT_INT_OMPFN_SIZE_PTR_PTR_PTR_VAR):
Define.
* config/nvptx/nvptx.c (nvptx_expand_cmp_swap): Handle PARM_DECLs.
* omp-builtins.def (BUILD_IN_GOACC_PARALLEL): Call
GOACC_parallel_keyed_v2.
* omp-expand.c (expand_omp_target): Update call to
BUILT_IN_GOACC_PARALLEL.
* omp-low.c (struct omp_context): Add parm_map member.
(lookup_parm): New function.
(build_receiver_ref): Lookup parm_map decls.
(install_parm_decl): New function.
(install_var_field): Install parm_map decl for OpenACC parallel region
data clauses.
(delete_omp_context): Clean parm_map.
(scan_sharing_clauses): Install subarray variable mapping into parm_map.
(create_omp_child_function): Defer creation of child function for
OpenACC parallel regions.
(scan_omp_target): Likewise.
(append_decl_arg): New function.
(lower_omp_target): Create an child offloaded function using one
parameter per data mapping for OpenACC parallel regions.
* tree-ssa-structalias.c (find_func_aliases_for_builtin_call):
Ignore OpenACC parallel regions.
(find_func_clobbers): Likewise.
(ipa_pta_execute): Likewise.

libgomp/
* Makefile.am: Add libffi build dependency.
* configure.ac: Likewise.
* Makefile.in: Regenerate.
* config.h.in: Regenerate.
* configure: Regenerate.
* libgomp-plugin.h: Define GOMP_OFFLOAD_openacc_exec_params and
GOMP_OFFLOAD_openacc_async_exec_params.
* libgomp.h (acc_dispatch_t): Use them here.
* libgomp.map (GOACC_parallel_keyed_v2): Declare.
* libgomp_g.h (GOACC_parallel_keyed_v2): Likewise.
* oacc-host.c (host_openacc_exec_params): New function.
(host_openacc_async_exec_params): Likewise.
* oacc-parallel.c (goacc_call_host_fn): Likewise.
(GOACC_parallel_keyed_internal): Likewise.
(GOACC_parallel_keyed): Wrapper for GOACC_parallel_keyed_internal.
(GOACC_parallel_keyed_v2): Likewise.
* plugin/plugin-nvptx.c (nvptx_exec): Replace CUDeviceptr dp parameter
with void **kargs.
(openacc_exec_internal): New function.
(GOMP_OFFLOAD_openacc_exec_params): New function.
(GOMP_OFFLOAD_openacc_exec): Update to call openacc_exec_internal.
(openacc_async_exec_internal): New function.
(GOMP_OFFLOAD_openacc_async_exec_params): New function.
(GOMP_OFFLOAD_openacc_async_exec): Update call to
openacc_async_exec_internal.
* target.c (gomp_load_plugin_for_device): Handle
openacc_exec_params and openacc_async_exec_params.
* testsuite/Makefile.in: Regenerate.
* testsuite/libgomp.oacc-c-c++-common/combined-directives-1.c:
Xfail on offloaded targets.

* Makefile.def: Bootstrap module libffi. Add libffi dependency
to all-target-libgomp.
* Makefile.in: Regenerate.
* configure.ac: Add libffi to bootstrap_target_libs when libgomp
is bootstrapped.
* configure: Regenerate.

gcc/
* omp-low.c (install_parm_decl): Don't extract identifiers from
artifical decls.

gcc/testsuite/
* c-c++-common/goacc/large_array.c: New test.

(cherry picked from openacc-gcc-7-branch commit
b4dd21b9a1f9f499c613b55225cad689b7928a7f, commit
9ba1d875dcb9412cccdd49138a3525e7adab3e76, commit
762cf3c7890fab15a69494a6480455cd99621d7d, and commit
6585af7290fd79f6cb834a39c2bbf7e1934808b1)

(cherry picked from openacc-gcc-9-branch commit
721ed7ea405710ef0beab3629567dd39cdd22ca3)

5 years agoAdd OpenACC 2.6 if and if_present clauses on host_data construct: GOACC_FLAG_HOST_DAT...
Gergö Barany [Fri, 21 Dec 2018 09:12:44 +0000 (01:12 -0800)] 
Add OpenACC 2.6 if and if_present clauses on host_data construct: GOACC_FLAG_HOST_DATA_IF_PRESENT

    gcc/c/
    * c-parser.c (OACC_HOST_DATA_CLAUSE_MASK): Add PRAGMA_OACC_CLAUSE_IF
    and PRAGMA_OACC_CLAUSE_IF_PRESENT.
    gcc/cp/
    * parser.c (OACC_HOST_DATA_CLAUSE_MASK): Likewise.

    gcc/fortran/
    * openmp.c (OACC_HOST_DATA_CLAUSES): Add OMP_CLAUSE_IF and
    OMP_CLAUSE_IF_PRESENT.

    gcc/
    * omp-expand.c (expand_omp_target): Handle if_present flag on
    OpenACC host_data construct.

    gcc/testsuite/
    * c-c++-common/goacc/host_data-1.c: Add tests of if and if_present
    clauses on host_data.
    * gfortran.dg/goacc/host_data-tree.f95: Likewise.

    include/
    * gomp-constants.h (GOACC_FLAG_HOST_DATA_IF_PRESENT): New constant.

    libgomp/
    * libgomp.h (enum gomp_map_vars_kind): Add
    GOMP_MAP_VARS_OPENACC_IF_PRESENT.
    * oacc-parallel.c (GOACC_data_start): Handle
    GOACC_FLAG_HOST_DATA_IF_PRESENT flag.
    * target.c (gomp_map_vars_async): Handle
    GOMP_MAP_VARS_OPENACC_IF_PRESENT mapping kind.
    * testsuite/libgomp.oacc-c-c++-common/host_data-6.c: New test.

Reviewed-by: Thomas Schwinge <thomas@codesourcery.com>
(cherry picked from openacc-gcc-9-branch commit
b52c8d006581b2a657ac3d81ab2527bb398b6615)

5 years agoReport errors on missing OpenACC reduction clauses in nested reductions
Gergö Barany [Thu, 20 Dec 2018 14:07:34 +0000 (15:07 +0100)] 
Report errors on missing OpenACC reduction clauses in nested reductions

..., as suggested by OpenACC 2.6, 2.9.11. "reduction clause".

In gcc/testsuite/c-c++-common/goacc/reduction-6.c, we remove the erroneous
reductions on variable b; adding a reduction clause to make it compile cleanly
would make it a duplicate of the test for variable c.

gcc/
* omp-low.c (struct omp_context): New fields
local_reduction_clauses, outer_reduction_clauses.
(new_omp_context): Initialize these.
(scan_sharing_clauses): Record reduction clauses on OpenACC
constructs.
(scan_omp_for): Check reduction clauses for incorrect nesting.
gcc/testsuite/
* c-c++-common/goacc/nested-reductions-fail.c: New test.
* c-c++-common/goacc/nested-reductions.c: New test.
* c-c++-common/goacc/reduction-6.c: Adjust.
libgomp/
* testsuite/libgomp.oacc-c-c++-common/par-loop-comb-reduction-1.c:
Add missing reduction clauses.
* testsuite/libgomp.oacc-c-c++-common/par-loop-comb-reduction-2.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/par-loop-comb-reduction-3.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/par-loop-comb-reduction-4.c:
Likewise.

(cherry picked from openacc-gcc-9-branch commit
ffa02cac81b32e526c1b901bc9dc8a0123fcb912)

5 years agoDisable libstdc++ dependency for libffi
Maciej W. Rozycki [Thu, 20 Dec 2018 14:10:16 +0000 (14:10 +0000)] 
Disable libstdc++ dependency for libffi

Disable AC_PROG_CXX and consequently a libstdc++ dependency for libffi,
introduced with upstream libffi commit 7d698125b1f0 ("Use the proper C++
compiler to run C++ tests").  This is only needed for the libffi test
suite, which we don't have to support in the GCC tree, as libffi is
maintained as a separate project.  The dependency causes a build failure
with the `powerpc64le-linux-gnu' target due to a circular dependency:

make[1]: Circular configure-target-libffi <- maybe-all-target-libstdc++-v3 dependency dropped.
make[1]: *** [configure-target-libffi] Error 1
make: *** [all] Error 2

due to a libgomp dependency for libstdc++ and then a libffi dependency
for libgomp, introduced with commit 998eb38b265d ("Use functional
parameters for data mappings in OpenACC child functions").

/
* Makefile.def (lang_env_dependencies): Disable `cxx' dependency
for `libffi'.
* Makefile.in: Regenerate.

libffi/
* configure.ac: Disable AC_PROG_CXX.
* configure: Regenerate.
* Makefile.in: Regenerate.
* include/Makefile.in: Regenerate.
* man/Makefile.in: Regenerate.
* testsuite/Makefile.in: Regenerate.

(cherry picked from openacc-gcc-9-branch commit
f5c850bac631c669b11de0c9ad3e2ba90f86dac9)

5 years agoAllow optional arguments to be used in the use_device OpenACC clause
Kwok Cheung Yeung [Thu, 31 Jan 2019 16:00:16 +0000 (08:00 -0800)] 
Allow optional arguments to be used in the use_device OpenACC clause

Optional arguments should be treated as references rather than pointers
in the lowering.  However, for non-present arguments, this would result
in a null dereference, so conditionals need to be added to detect and
handle this.

gcc/
* omp-low.c (lower_omp_target): For use_device clauses, generate
conditional statements to treat Fortran optional arguments like
references if non-null, or propogate null arguments into offloaded
code otherwise.

Reviewed-by: Julian Brown <julian@codesourcery.com>
(cherry picked from openacc-gcc-9-branch commit
4fba24cfbbd3738216a3551483744f82888741f3)

5 years agoEnsure that optional-arguments check is specific to Fortran
Kwok Cheung Yeung [Thu, 31 Jan 2019 15:54:58 +0000 (07:54 -0800)] 
Ensure that optional-arguments check is specific to Fortran

gcc/
* omp-general.c (omp_is_optional_argument): Add comment.  Add extra
check for Fortran language.

Reviewed-by: Julian Brown <julian@codesourcery.com>
(cherry picked from openacc-gcc-9-branch commit
abe09848284672b86613258711044b5019fadeb6)

5 years agoAdd tests for Fortran optional arguments in OpenACC 2.6
Kwok Cheung Yeung [Wed, 30 Jan 2019 20:07:56 +0000 (12:07 -0800)] 
Add tests for Fortran optional arguments in OpenACC 2.6

libgomp/
* testsuite/libgomp.oacc-fortran/optional-cache.f95
* testsuite/libgomp.oacc-fortran/optional-data-copyin-by-value.f90
* testsuite/libgomp.oacc-fortran/optional-data-copyin.f90
* testsuite/libgomp.oacc-fortran/optional-data-copyout.f90
* testsuite/libgomp.oacc-fortran/optional-data-enter-exit.f90
* testsuite/libgomp.oacc-fortran/optional-declare.f90
* testsuite/libgomp.oacc-fortran/optional-firstprivate.f90
* testsuite/libgomp.oacc-fortran/optional-host_data.f90
* testsuite/libgomp.oacc-fortran/optional-nested-calls.f90
* testsuite/libgomp.oacc-fortran/optional-private.f90
* testsuite/libgomp.oacc-fortran/optional-reduction.f90
* testsuite/libgomp.oacc-fortran/optional-update-device.f90
* testsuite/libgomp.oacc-fortran/optional-update-host.f90

Reviewed-by: Julian Brown <julian@codesourcery.com>
Reviewed-by: Thomas Schwinge <thomas@codesourcery.com>
(cherry picked from openacc-gcc-9-branch commit
b23eb4c2405aeaf877b441d76e998034752a9c7f)

5 years agoAdd support for allocatable arrays as optional arguments
Kwok Cheung Yeung [Wed, 30 Jan 2019 19:36:27 +0000 (11:36 -0800)] 
Add support for allocatable arrays as optional arguments

This patch allows allocatable arrays to be used as Fortran optional
arguments.  When an optional argument is detected, the Fortran
front-end now generates extra code to test if the argument is null.
If so, it sets the size of the array contents to zero, and the
pointers to data to null.  This prevents libgomp from trying to
copy non-existant data, and preserves the null pointer used by
PRESENT to detect non-present arguments.

gcc/fortran/
* trans-openmp.c (gfc_build_conditional_assign): New.
(gfc_build_conditional_assign_expr): New.
(gfc_omp_finish_clause): Add conditionals to set the clause
declaration to null and size to zero if the declaration is a
non-present optional argument.
(gfc_trans_omp_clauses_1): Likewise.

Reviewed-by: Chung-Lin Tang <cltang@codesourcery.com>
(cherry picked from openacc-gcc-9-branch commit
b82fdae5301f3c9a03b64d7e125ef7ccacc59364)

5 years agoCalculate correct size for optional arguments used in the firstprivate clause
Kwok Cheung Yeung [Wed, 30 Jan 2019 19:22:08 +0000 (11:22 -0800)] 
Calculate correct size for optional arguments used in the firstprivate clause

The lowering for firstprivate uses the pointer size rather than the size
of the referenced object when passed an optional argument.  This patch
detects optional arguments as a special case and treats them as reference
types.

gcc/
* omp-general.c (omp_is_optional_argument): New.
* omp-general.h (omp_is_optional_argument): New.
* omp-low.c (lower_omp_target): Use size of referenced object when
optional argument used as argument to firstprivate.

(cherry picked from openacc-gcc-9-branch commit
57093894d563543f5fe5e2b76f974340375c5421)

5 years agoAllow NULL for update directives in OpenACC 2.6
Kwok Cheung Yeung [Wed, 30 Jan 2019 18:43:47 +0000 (10:43 -0800)] 
Allow NULL for update directives in OpenACC 2.6

A non-present passed-by-reference Fortran optional argument is represented
by a null pointer.  When passed to an update directive, it should be ignored
as variable mappings are not created for null pointers.  This should be
safe as it is not possible to change a non-present argument into a present
one (or vice-versa) in Fortran.

libgomp/
* oacc-mem.c (update_dev_host): Return early if the host address
is NULL.
        * testsuite/libgomp.oacc-c-c++-common/lib-43.c: Remove.
        * testsuite/libgomp.oacc-c-c++-common/lib-47.c: Likewise.

Reviewed-by: Julian Brown <julian@codesourcery.com>
Reviewed-by: Thomas Schwinge <thomas@codesourcery.com>
(cherry picked from openacc-gcc-9-branch commit
b930a8a1ee826ca52081c7c0e88554b3091afb62)

5 years agoAdd support for gang local storage allocation in shared memory
Julian Brown [Thu, 21 Mar 2019 22:09:24 +0000 (15:09 -0700)] 
Add support for gang local storage allocation in shared memory

2018-12-11  Julian Brown  <julian@codesourcery.com>
         Chung-Lin Tang  <cltang@codesourcery.com>

     gcc/
     * config/nvptx/nvptx.c (tree-hash-traits.h): Include.
     (gangprivate_shared_size): New global variable.
     (gangprivate_shared_align): Likewise.
     (gangprivate_shared_sym): Likewise.
     (gangprivate_shared_hmap): Likewise.
     (nvptx_option_override): Initialize gangprivate_shared_sym,
     gangprivate_shared_align.
     (nvptx_file_end): Output gangprivate_shared_sym.
     (nvptx_goacc_expand_accel_var): New function.
     (nvptx_set_current_function): New function.
     (TARGET_SET_CURRENT_FUNCTION): Define hook.
     (TARGET_GOACC_EXPAND_ACCEL): Likewise.
     * doc/tm.texi (TARGET_GOACC_EXPAND_ACCEL_VAR): Document new hook.
     * doc/tm.texi.in (TARGET_GOACC_EXPAND_ACCEL_VAR): Likewise.
     * expr.c (expand_expr_real_1): Remap decls marked with the
     "oacc gangprivate" attribute.
     * omp-low.c (omp_context): Add oacc_partitioning_level and
     oacc_addressable_var_decls fields.
     (new_omp_context): Initialize oacc_addressable_var_decls in new
     omp_context.
     (delete_omp_context): Delete oacc_addressable_var_decls in old
     omp_context.
     (lower_oacc_head_tail): Record partitioning-level count in omp context.
     (oacc_record_private_var_clauses, oacc_record_vars_in_bind)
     (mark_oacc_gangprivate): New functions.
     (lower_omp_for): Call oacc_record_private_var_clauses with "for"
     clauses.  Call mark_oacc_gangprivate for gang-partitioned loops.
     (lower_omp_target): Call oacc_record_private_var_clauses with "target"
     clauses.
     Call mark_oacc_gangprivate for offloaded target regions.
     (lower_omp_1): Call vars_in_bind for GIMPLE_BIND within OMP regions.
     * target.def (expand_accel_var): New hook.

     libgomp/
     * testsuite/libgomp.oacc-c-c++-common/gang-private-1.c: New test.
     * testsuite/libgomp.oacc-c-c++-common/loop-gwv-2.c: New test.
     * testsuite/libgomp.oacc-c/pr85465.c: New test.
     * testsuite/libgomp.oacc-fortran/gangprivate-attrib-1.f90: New test.kk

(cherry picked from openacc-gcc-9-branch commit
605f776041c41d77bd541cc0732cd26a2939c581)

5 years agoNew tests from pr72741 only
Julian Brown [Mon, 18 Mar 2019 22:32:57 +0000 (15:32 -0700)] 
New tests from pr72741 only

Diagnostics updated relative to last posted version.

2018-10-02  Cesar Philippidis  <cesar@codesourcery.com>

gcc/testsuite/
* gfortran.dg/goacc/pr72741.f90: Update test for current diagnostics.
* gfortran.dg/goacc/pr72741-2.f: New test.
* gfortran.dg/goacc/pr72741-intrinsic-1.f: New test.
* gfortran.dg/goacc/pr72741-intrinsic-2.f: New test.

(cherry picked from openacc-gcc-9-branch commit
e5ca8c276ca621b2541da1d49d8f585c7a33a57b)

5 years agoTweak target selector for libgomp.oacc-c-c++-common/lib-93.c.
Julian Brown [Tue, 19 Mar 2019 13:53:56 +0000 (06:53 -0700)] 
Tweak target selector for libgomp.oacc-c-c++-common/lib-93.c.

libgomp/
* testsuite/libgomp.oacc-c-c++-common/lib-93.c: Adjust target selector.

(cherry picked from openacc-gcc-9-branch commit
553ec292e4ae9dfb428a5dcc1a251d2055eae1be)

5 years agoFix hang when running oacc exec with CUDA 9.0 nvprof
Julian Brown [Wed, 27 Feb 2019 00:00:54 +0000 (16:00 -0800)] 
Fix hang when running oacc exec with CUDA 9.0 nvprof

2018-09-20  Tom de Vries  <tdevries@suse.de>
    Cesar Philippidis  <cesar@codesourcery.com>

libgomp/
* oacc-init.c (acc_init_state_lock, acc_init_state, acc_init_thread):
New variable.
(acc_init_1): Set acc_init_thread to pthread_self ().  Set
acc_init_state to initializing at the start, and to initialized at the
end.
(self_initializing_p): New function.
(acc_get_device_type): Return acc_device_none if called by thread that
is currently executing acc_init_1.

(cherry picked from openacc-gcc-9-branch commit
84af3c5a2fbb5023057e2ca319b0c22f5f7d4795)

5 years agoEnable firstprivate OpenACC reductions
Julian Brown [Tue, 26 Feb 2019 23:59:03 +0000 (15:59 -0800)] 
Enable firstprivate OpenACC reductions

2018-09-05  Cesar Philippidis  <cesar@codesourcery.com>
    Chung-Lin Tang  <cltang@codesourcery.com>

gcc/
* gimplify.c (omp_add_variable): Enable firstprivate reduction
variables.

gcc/testsuite/
* c-c++-common/goacc/reduction-8.c: New test.

libgomp/
* testsuite/libgomp.oacc-c-c++-common/privatize-reduction-1.c: New
test.
* testsuite/libgomp.oacc-c-c++-common/privatize-reduction-2.c: New
test.

(cherry picked from openacc-gcc-9-branch commit
1add5113c32e7b8ea8536aee877f901a4a6eb5fc)

5 years agoDon't mark OpenACC auto loops as independent inside acc parallel regions
Julian Brown [Tue, 26 Feb 2019 23:55:23 +0000 (15:55 -0800)] 
Don't mark OpenACC auto loops as independent inside acc parallel regions

2018-09-20  Cesar Philippidis  <cesar@codesourcery.com>

gcc/
* omp-low.c (lower_oacc_head_mark): Don't mark OpenACC auto
loops as independent inside acc parallel regions.

gcc/testsuite/
* c-c++-common/goacc/loop-auto-1.c: Adjust test case to conform to
the new behavior of the auto clause in OpenACC 2.5.
* c-c++-common/goacc/loop-auto-2.c: Likewise.
* gcc.dg/goacc/loop-processing-1.c: Likewise.
* c-c++-common/goacc/loop-auto-3.c: New test.
* gfortran.dg/goacc/loop-auto-1.f90: New test.

libgomp/
* testsuite/libgomp.oacc-c-c++-common/loop-auto-1.c: Adjust test case
to conform to the new behavior of the auto clause in OpenACC 2.5.

(cherry picked from openacc-gcc-9-branch commit
6acf40a4364ccab3b71c3b58bf9ba5f16d19dc27)

5 years agoFortran "declare create"/allocate support for OpenACC
Julian Brown [Tue, 26 Feb 2019 23:48:00 +0000 (15:48 -0800)] 
Fortran "declare create"/allocate support for OpenACC

2018-10-04  Cesar Philippidis  <cesar@codesourcery.com>
            Julian Brown  <julian@codesourcery.com>

gcc/
* omp-low.c (scan_sharing_clauses): Update handling of OpenACC declare
create, declare copyin and declare deviceptr to have local lifetimes.
(convert_to_firstprivate_int): Handle pointer types.
(convert_from_firstprivate_int): Likewise.  Create local storage for
the values being pointed to.  Add new orig_type argument.
(lower_omp_target): Handle GOMP_MAP_DECLARE_{ALLOCATE,DEALLOCATE}.
Add orig_type argument to convert_from_firstprivate_int call.
Allow pointer types with GOMP_MAP_FIRSTPRIVATE_INT.  Don't privatize
firstprivate VLAs.
* tree-pretty-print.c (dump_omp_clause): Handle
GOMP_MAP_DECLARE_{ALLOCATE,DEALLOCATE}.

gcc/fortran/
* gfortran.h (enum gfc_omp_map_op): Add OMP_MAP_DECLARE_ALLOCATE,
OMP_MAP_DECLARE_DEALLOCATE.
(gfc_omp_clauses): Add update_allocatable.
* trans-array.c (gfc_array_allocate): Call
gfc_trans_oacc_declare_allocate for decls that have oacc_declare_create
attribute set.
* trans-decl.c (add_attributes_to_decl): Enable lowering of OpenACC
declare create, declare copyin and declare deviceptr clauses.
(find_module_oacc_declare_clauses): Relax oacc_declare_create to
OMP_MAP_ALLOC, and oacc_declare_copyin to OMP_MAP_TO, in order to
match OpenACC 2.5 semantics.
(finish_oacc_declare): Reset module_oacc_clauses before scanning each
namespace.
* trans-openmp.c (gfc_trans_omp_clauses): Use GOMP_MAP_ALWAYS_POINTER
(for update directive) or GOMP_MAP_FIRSTPRIVATE_POINTER (otherwise) for
allocatable scalar decls.  Handle OMP_MAP_DECLARE_{ALLOCATE,DEALLOCATE}
clauses.
(gfc_trans_oacc_executable_directive): Use GOMP_MAP_ALWAYS_POINTER
for allocatable scalar data clauses inside acc update directives.
(gfc_trans_oacc_declare_allocate): New function.
* trans-stmt.c (gfc_trans_allocate): Call
gfc_trans_oacc_declare_allocate for decls with oacc_declare_create
attribute set.
(gfc_trans_deallocate): Likewise.
* trans.h (gfc_trans_oacc_declare_allocate): Declare.

gcc/testsuite/
* gfortran.dg/goacc/declare-allocatable-1.f90: New test.

include/
* gomp-constants.h (enum gomp_map_kind): Define
GOMP_MAP_DECLARE_{ALLOCATE,DEALLOCATE} and GOMP_MAP_FLAG_SPECIAL_4.

libgomp/
* oacc-mem.c (gomp_acc_declare_allocate): New function.
* oacc-parallel.c (GOACC_enter_exit_data): Handle
GOMP_MAP_DECLARE_{ALLOCATE,DEALLOCATE}.
* testsuite/libgomp.oacc-fortran/allocatable-array.f90: New test.
* testsuite/libgomp.oacc-fortran/allocatable-scalar.f90: New test.
* testsuite/libgomp.oacc-fortran/declare-allocatable-1.f90: New test.
* testsuite/libgomp.oacc-fortran/declare-allocatable-2.f90: New test.
* testsuite/libgomp.oacc-fortran/declare-allocatable-3.f90: New test.
* testsuite/libgomp.oacc-fortran/declare-allocatable-4.f90: New test.

(cherry picked from openacc-gcc-9-branch commit
965361e8890836b8e79da7d68fbf288f4c03dfc2)

5 years agoEnable GOMP_MAP_FIRSTPRIVATE_INT for OpenACC
Julian Brown [Tue, 26 Feb 2019 23:10:21 +0000 (15:10 -0800)] 
Enable GOMP_MAP_FIRSTPRIVATE_INT for OpenACC

2018-12-22  Cesar Philippidis  <cesar@codesourcery.com>
            Julian Brown  <julian@codesourcery.com>

gcc/
* omp-low.c (maybe_lookup_field_in_outer_ctx): New function.
(convert_to_firstprivate_int): New function.
(convert_from_firstprivate_int): New function.
(lower_omp_target): Enable GOMP_MAP_FIRSTPRIVATE_INT in OpenACC.

libgomp/
* oacc-parallel.c (GOACC_parallel_keyed): Handle
GOMP_MAP_FIRSTPRIVATE_INT host addresses.
* plugin/plugin-nvptx.c (nvptx_exec): Handle
GOMP_MAP_FIRSTPRIVATE_INT host addresses.
* testsuite/libgomp.oacc-c++/firstprivate-int.C: New test.
* testsuite/libgomp.oacc-c-c++-common/firstprivate-int.c: New
test.
* testsuite/libgomp.oacc-fortran/firstprivate-int.f90: New test.

(cherry picked from openacc-gcc-9-branch commit
97d46d0cd32293f1506528ed213bc52dbb0e80f4)

5 years agoFix implicit mapping for array slices on lexically-enclosing data constructs (PR70828)
Julian Brown [Tue, 26 Feb 2019 22:22:41 +0000 (14:22 -0800)] 
Fix implicit mapping for array slices on lexically-enclosing data constructs (PR70828)

2018-08-28  Julian Brown  <julian@codesourcery.com>
            Cesar Philippidis  <cesar@codesourcery.com>

gcc/
* gimplify.c (oacc_array_mapping_info): New struct.
(gimplify_omp_ctx): Add decl_data_clause hash map.
(new_omp_context): Zero-initialise above.
(delete_omp_context): Delete above if allocated.
(gimplify_scan_omp_clauses): Scan for array mappings on data constructs,
and record in above map.
(gomp_oacc_needs_data_present): New function.
(gimplify_adjust_omp_clauses_1): Handle data mappings (e.g. array
slices) declared in lexically-enclosing data constructs.
* omp-low.c (lower_omp_target): Allow decl for bias not to be present
in OpenACC context.

gcc/testsuite/
* c-c++-common/goacc/acc-data-chain.c: New test.
* gfortran.dg/goacc/pr70828.f90: New test.
* gfortran.dg/goacc/pr70828-2.f90: New test.

libgomp/
* testsuite/libgomp.oacc-c-c++-common/pr70828.c: New test.
* testsuite/libgomp.oacc-fortran/implicit_copy.f90: New test.
* testsuite/libgomp.oacc-fortran/pr70828.f90: New test.
* testsuite/libgomp.oacc-fortran/pr70828-2.f90: New test.
* testsuite/libgomp.oacc-fortran/pr70828-3.f90: New test.
* testsuite/libgomp.oacc-fortran/pr70828-4.f90: New test.
* testsuite/libgomp.oacc-fortran/pr70828-5.f90: New test.
* testsuite/libgomp.oacc-fortran/pr70828-6.f90: New test.

(cherry picked from openacc-gcc-9-branch commit
846842be6a21b3e0818441dd2454ea1f05c8ab86)

5 years agoDefault compute dimensions (compile time)
Julian Brown [Tue, 26 Feb 2019 22:12:06 +0000 (14:12 -0800)] 
Default compute dimensions (compile time)

Typo fix relative to last posted version.

2018-10-05  Nathan Sidwell  <nathan@acm.org>
    Tom de Vries  <tdevries@suse.de>
    Thomas Schwinge  <thomas@codesourcery.com>
    Julian Brown  <julian@codesourcery.com>

gcc/
* doc/invoke.texi (fopenacc-dim): Update.
* omp-offload.c (oacc_parse_default_dims): Update.
(oacc_validate_dims): Emit warnings about strange partitioning choices.

gcc/testsuite/
* c-c++-common/goacc/acc-icf.c: Update.
* c-c++-common/goacc/parallel-dims-1.c: Likewise.
* c-c++-common/goacc/parallel-reduction.c: Likewise.
* c-c++-common/goacc/pr70688.c: Likewise.
* c-c++-common/goacc/routine-1.c: Likewise.
* c-c++-common/goacc/uninit-dim-clause.c: Likewise.
* gfortran.dg/goacc/parallel-tree.f95: Likewise.
* gfortran.dg/goacc/routine-4.f90: Likewise.
* gfortran.dg/goacc/routine-level-of-parallelism-1.f90: Likewise.
* gfortran.dg/goacc/uninit-dim-clause.f95: Likewise.

libgomp/
* testsuite/libgomp.oacc-c-c++-common/loop-g-1.c: Add -w.
* testsuite/libgomp.oacc-c-c++-common/loop-g-2.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/loop-red-g-1.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/loop-red-w-1.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/loop-red-w-2.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/loop-warn-1.c: New.
* testsuite/libgomp.oacc-c-c++-common/firstprivate-1.c: Update.
* testsuite/libgomp.oacc-c-c++-common/loop-auto-1.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/loop-w-1.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/mode-transitions.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/parallel-dims.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/private-variables.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/reduction-7.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/routine-g-1.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/routine-w-1.c: Likewise.
* testsuite/libgomp.oacc-fortran/par-reduction-2-1.f: Likewise.
* testsuite/libgomp.oacc-fortran/par-reduction-2-2.f: Likewise.
* testsuite/libgomp.oacc-fortran/pr84028.f90: Likewise.
* testsuite/libgomp.oacc-fortran/private-variables.f90: Likewise.
* testsuite/libgomp.oacc-fortran/routine-7.f90: Likewise.
* testsuite/libgomp.oacc-c-c++-common/loop-default-compile.c: New.

(cherry picked from openacc-gcc-9-branch commit
0dd9e6ac878a47ebf021b700e56d4a8d31938bd1)

5 years agoGenerate sequential loop for OpenACC loop directive inside kernels
Julian Brown [Tue, 26 Feb 2019 21:39:03 +0000 (13:39 -0800)] 
Generate sequential loop for OpenACC loop directive inside kernels

2019-09-20  Chung-Lin Tang <cltang@codesourcery.com>
    Cesar Philippidis  <cesar@codesourcery.com>

gcc/
* omp-expand.c (struct omp_region): Add inside_kernels_p field.
(expand_omp_for_generic): Adjust to generate a 'sequential' loop
when GOMP builtin arguments are BUILT_IN_NONE.
(expand_omp_for): Use expand_omp_for_generic to generate a
non-parallelized loop for OMP_FORs inside OpenACC kernels regions.
(expand_omp): Mark inside_kernels_p field true for regions
nested inside OpenACC kernels constructs.
gcc/testsuite/
* c-c++-common/goacc/kernels-loop-acc-loop.c: New test.
* c-c++-common/goacc/kernels-loop-2-acc-loop.c: New test.
* c-c++-common/goacc/kernels-loop-3-acc-loop.c: New test.
* c-c++-common/goacc/kernels-loop-n-acc-loop.c: New test.
* c-c++-common/goacc/kernels-acc-loop-reduction.c: New test.
* c-c++-common/goacc/kernels-acc-loop-smaller-equal.c: New test.

(cherry picked from openacc-gcc-9-branch commit
691d1aa4a69aac5230ada0f116efee445a2ea4fe)

5 years agoReinstate kernels-restrict behaviour
Julian Brown [Wed, 6 Mar 2019 22:44:56 +0000 (14:44 -0800)] 
Reinstate kernels-restrict behaviour

This patch contains a small fix for upstream churn relative to the last version
posted.

2018-09-20  Cesar Philippidis  <cesar@codesourcery.com>
    Julian Brown  <julian@codesourcery.com>

* omp-low.c (install_var_field): New base_pointer_restrict
argument.
(scan_sharing_clauses): Update call to install_var_field.
(omp_target_base_pointers_restrict_p): New function.
(scan_omp_target): Update call to install_var_field.

(cherry picked from openacc-gcc-9-branch commit
99a4260fe264624136eda666363464eba48bdc3e)

5 years agoAdjustments and additions to testcases
Julian Brown [Tue, 26 Feb 2019 21:18:36 +0000 (13:18 -0800)] 
Adjustments and additions to testcases

Some additions of redundant "present" clauses dropped.

2018-10-22  Cesar Philippidis  <cesar@codesourcery.com>

gcc/testsuite/
* g++.dg/goacc/loop-1.c: New test.
* g++.dg/goacc/loop-2.c: New test.
* g++.dg/goacc/loop-3.c: New test.

2018-10-22  James Norris  <jnorris@codesourcery.com>
    Cesar Philippidis  <cesar@codesourcery.com>
    Tom de Vries  <tom@codesourcery.com>

libgomp/
* testsuite/libgomp.oacc-c-c++-common/data-2.c: Update parallel
regions to denote variables copyied in via acc enter data as
present.
* testsuite/libgomp.oacc-fortran/data-3.f90: Likewise.
* testsuite/libgomp.oacc-fortran/data-4.f90: Likewise.
* testsuite/libgomp.oacc-c-c++-common/subr.h: Reimplement.
* testsuite/libgomp.oacc-c-c++-common/subr.ptx: Regenerated PTX.
* testsuite/libgomp.oacc-c-c++-common/timer.h: Removed.
* testsuite/libgomp.oacc-c-c++-common/lib-69.c: Change async checks.
* testsuite/libgomp.oacc-c-c++-common/lib-70.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/lib-71.c: Rework kernel i/f.
* testsuite/libgomp.oacc-c-c++-common/lib-72.c: Rework kernel i/f and
change async checks.
* testsuite/libgomp.oacc-c-c++-common/lib-73.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/lib-74.c: Rework kernel i/f and
timing checks.
* testsuite/libgomp.oacc-c-c++-common/lib-75.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/lib-76.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/lib-77.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/lib-78.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/lib-79.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/lib-80.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/lib-81.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/lib-82.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/lib-93.c: New test.

(cherry picked from openacc-gcc-9-branch commit
18e5e71a03b69316246a417f5d957cbaa64245a5)

5 years agoVarious OpenACC reduction enhancements - test cases
Julian Brown [Tue, 12 Feb 2019 23:14:22 +0000 (15:14 -0800)] 
Various OpenACC reduction enhancements - test cases

2018-12-13  Cesar Philippidis  <cesar@codesourcery.com>
            Nathan Sidwell  <nathan@acm.org>
            Julian Brown  <julian@codesourcery.com>

        gcc/testsuite/
        * c-c++-common/goacc/orphan-reductions-1.c: New test.
        * c-c++-common/goacc/reduction-7.c: New test.
        * c-c++-common/goacc/routine-4.c: Update.
        * g++.dg/goacc/reductions-1.C: New test.
        * gcc.dg/goacc/loop-processing-1.c: Update.
        * gfortran.dg/goacc/orphan-reductions-1.f90: New test.

        libgomp/
        * libgomp.oacc-c-c++-common/par-reduction-3.c: New test.
        * libgomp.oacc-c-c++-common/reduction-cplx-flt-2.c: New test.
        * libgomp.oacc-fortran/reduction-9.f90: New test.

(cherry picked from openacc-gcc-9-branch commit
e3cdb913b543ebd719dc8fe33f92f504c141d9f6)

5 years agoVarious OpenACC reduction enhancements - ME and nvptx changes
Julian Brown [Tue, 12 Feb 2019 23:06:55 +0000 (15:06 -0800)] 
Various OpenACC reduction enhancements - ME and nvptx changes

Parts of the first posting got lost in the second posting, above.
This version hopefully contains everything.

2018-10-30  Cesar Philippidis  <cesar@codesourcery.com>

gcc/
* config/nvptx/nvptx.c (nvptx_propagate_unified): New.
(nvptx_split_blocks): Call it for cond_uni insn.
(nvptx_expand_cond_uni): New.
(enum nvptx_builtins): Add NVPTX_BUILTIN_COND_UNI.
(nvptx_init_builtins): Initialize it.
(nvptx_expand_builtin):
(nvptx_generate_vector_shuffle): Change integral SHIFT operand to
tree BITS operand.
(nvptx_vector_reduction): New.
(nvptx_adjust_reduction_type): New.
(nvptx_goacc_reduction_setup): Use it to adjust the type of ref_to_res.
(nvptx_goacc_reduction_init): Don't update LHS if it doesn't exist.
(nvptx_goacc_reduction_fini): Call nvptx_vector_reduction for vector.
Use it to adjust the type of ref_to_res.
(nvptx_goacc_reduction_teardown):
* config/nvptx/nvptx.md (cond_uni): New pattern.

(cherry picked from openacc-gcc-9-branch commit
6f456aa7d21e587debff82f3cbf89750528018d1)

5 years agoVarious OpenACC reduction enhancements - FE changes
Julian Brown [Tue, 12 Feb 2019 22:56:12 +0000 (14:56 -0800)] 
Various OpenACC reduction enhancements - FE changes

This version differs somewhat from the last version posted upstream
(and addresses some of Jakub's review comments).

2018-12-13  Cesar Philippidis  <cesar@codesourcery.com>
            Nathan Sidwell  <nathan@acm.org>
            Julian Brown  <julian@codesourcery.com>

        gcc/c/
        * c-parser.c (c_parser_omp_variable_list): New c_omp_region_type
        argument.  Use it to specialize handling of OMP_CLAUSE_REDUCTION for
        OpenACC.
(c_parser_oacc_data_clause): Add region-type argument.
(c_parser_oacc_data_clause_deviceptr): Likewise.
        (c_parser_omp_clause_reduction): Change is_omp boolean parameter to
        c_omp_region_type.  Update call to c_parser_omp_variable_list.
        (c_parser_oacc_all_clauses): Update calls to
        c_parser_omp_clause_reduction.
        (c_parser_omp_all_clauses): Likewise.
(c_parser_oacc_cache): Update call to c_parser_omp_var_list_parens.
        * c-typeck.c (c_finish_omp_clauses): Emit an error on orphan OpenACC
        gang reductions.  Suppress user-defined reduction error for OpenACC.

        gcc/cp/
        * parser.c (cp_parser_omp_var_list_no_open):  New c_omp_region_type
        argument.  Use it to specialize handling of OMP_CLAUSE_REDUCTION for
        OpenACC.
(cp_parser_omp_var_list): Add c_omp_region_type argument. Update call
to cp_parser_omp_var_list_parens.
(cp_parser_oacc_data_clause): Update call to cp_parser_omp_var_list.
        (cp_parser_omp_clause_reduction): Change is_omp boolean parameter to
        c_omp_region_type.  Update call to cp_parser_omp_var_list_no_open.
        (cp_parser_oacc_all_clauses): Update call to
        cp_parser_omp_clause_reduction.
        (cp_parser_omp_all_clauses): Likewise.
        * semantics.c (finish_omp_reduction_clause): Add c_omp_region_type
argument.  Suppress user-defined reduction error for OpenACC.
(finish_omp_clauses): Emit an error on orphan OpenACC gang reductions.

        gcc/fortran/
        * openmp.c (resolve_oacc_loop_blocks): Emit an error on orphan OpenACC
        gang reductions.
        * trans-openmp.c (gfc_omp_clause_copy_ctor): Permit reductions.

(cherry picked from openacc-gcc-9-branch commit
533beb2ec19f8486e4b1b645a153746f96b41f04)

5 years agoAdd OpenACC Fortran support for deviceptr and variable in common blocks
Julian Brown [Tue, 12 Feb 2019 22:32:34 +0000 (14:32 -0800)] 
Add OpenACC Fortran support for deviceptr and variable in common blocks

2018-06-29  Cesar Philippidis  <cesar@codesourcery.com>
    James Norris  <jnorris@codesourcery.com>

gcc/fortran/
* openmp.c (gfc_match_omp_map_clause): Re-write handling of the
deviceptr clause.  Add new common_blocks argument.  Propagate it to
gfc_match_omp_variable_list.
(gfc_match_omp_clauses): Update calls to gfc_match_omp_map_clauses.
(resolve_positive_int_expr): Promote the warning to an error.
(check_array_not_assumed): Remove pointer check.
(resolve_oacc_nested_loops): Error on do concurrent loops.
* trans-openmp.c (gfc_omp_finish_clause): Don't create pointer data
mappings for deviceptr clauses.
(gfc_trans_omp_clauses): Likewise.

gcc/
* gimplify.c (enum gimplify_omp_var_data): Add GOVD_DEVICETPR.
(oacc_default_clause): Privatize fortran common blocks.
(omp_notice_variable): Add GOVD_DEVICEPTR attribute when appropriate.
Defer the expansion of DECL_VALUE_EXPR for common block decls.
(gimplify_scan_omp_clauses): Add GOVD_DEVICEPTR attribute when
appropriate.
(gimplify_adjust_omp_clauses_1): Set GOMP_MAP_FORCE_DEVICEPTR for
implicit deviceptr mappings.

gcc/testsuite/
* c-c++-common/goacc/deviceptr-4.c: Update.
* gfortran.dg/goacc/common-block-1.f90: New test.
* gfortran.dg/goacc/common-block-2.f90: New test.
* gfortran.dg/goacc/loop-2.f95: Update.
* gfortran.dg/goacc/loop-3-2.f95: Update.
* gfortran.dg/goacc/loop-3.f95: Update.
* gfortran.dg/goacc/loop-5.f95: Update.
* gfortran.dg/goacc/pr72715.f90: New test.
* gfortran.dg/goacc/sie.f95: Update.
* gfortran.dg/goacc/tile-1.f90: Update.
* gfortran.dg/gomp/pr77516.f90: Update.

libgomp/
* oacc-parallel.c (GOACC_parallel_keyed): Handle Fortran deviceptr
clause.
(GOACC_data_start): Likewise.
* testsuite/libgomp.oacc-fortran/common-block-1.f90: New test.
* testsuite/libgomp.oacc-fortran/common-block-2.f90: New test.
* testsuite/libgomp.oacc-fortran/common-block-3.f90: New test.
* testsuite/libgomp.oacc-fortran/deviceptr-1.f90: New test.

(cherry picked from openacc-gcc-9-branch commit
ac6c90812344f4f4cfe4d2f5901c1a9d038a4000)

5 years agoTweak error return value for acc_set_cuda_stream.
Julian Brown [Tue, 12 Feb 2019 14:36:03 +0000 (06:36 -0800)] 
Tweak error return value for acc_set_cuda_stream.

The return value of acc_set_cuda_stream is unspecified in OpenACC 2.6.
The testsuite changes might be unnecessary with the current async code.

libgomp/
* oacc-cuda.c (acc_set_cuda_stream): Return 0 on error/invalid
arguments.
* testsuite/libgomp.oacc-c-c++-common/lib-84.c: Handle unnumbered
async stream being an alias for a numbered async stream.
* testsuite/libgomp.oacc-c-c++-common/lib-85.c: Likewise.

(cherry picked from openacc-gcc-9-branch commit
6b0f72aad2030b3efa651652d75ad3d3cc9a76f6)

5 years agoUse oacc_verify_routine_clauses for C/C++
Julian Brown [Thu, 7 Feb 2019 13:19:53 +0000 (05:19 -0800)] 
Use oacc_verify_routine_clauses for C/C++

2018-10-02  Thomas Schwinge  <thomas@codesourcery.com>
    Cesar Philippidis  <cesar@codesourcery.com>

gcc/
* omp-general.c (oacc_build_routine_dims): Move some of its
processing into...
(oacc_verify_routine_clauses): ... this new function.
* omp-general.h (oacc_verify_routine_clauses): New prototype.

gcc/c/
* c-parser.c (c_parser_oacc_routine): Normalize order of clauses.
(c_finish_oacc_routine): Call oacc_verify_routine_clauses.

gcc/cp/
* parser.c (cp_parser_oacc_routine)
(cp_parser_late_parsing_oacc_routine): Normalize order of clauses.
(cp_finalize_oacc_routine): Call oacc_verify_routine_clauses.

gcc/testsuite/
* c-c++-common/goacc/routine-level-of-parallelism-1.c: New test.

(cherry picked from openacc-gcc-9-branch commit
1cf459e23c2048b5800cd06e96a6041c17fabbc7)

5 years agoAdd support for OpenACC routine nohost clause
Julian Brown [Thu, 7 Feb 2019 01:46:25 +0000 (17:46 -0800)] 
Add support for OpenACC routine nohost clause

2018-10-02  Thomas Schwinge  <thomas@codesourcery.com>
    Cesar Philippidis  <cesar@codesourcery.com>

gcc/
* tree-core.h (omp_clause_code): Add OMP_CLAUSE_NOHOST.
* tree.c (omp_clause_num_ops, omp_clause_code_name, walk_tree_1):
Update for these.
* tree-pretty-print.c (dump_omp_clause): Handle OMP_CLAUSE_NOHOST.
* gimplify.c (gimplify_scan_omp_clauses)
(gimplify_adjust_omp_clauses): Handle OMP_CLAUSE_NOHOST.
* tree-nested.c (convert_nonlocal_omp_clauses)
(convert_local_omp_clauses): Likewise.
* omp-low.c (scan_sharing_clauses): Likewise.
* omp-offload.c (maybe_discard_oacc_function): New function.
(execute_oacc_device_lower) [!ACCEL_COMPILER]: Handle OpenACC
nohost clauses.

gcc/c-family/
* c-attribs.c (c_common_attribute_table): Set min_len to -1 for
"omp declare target".
* c-pragma.h (pragma_omp_clause): Add PRAGMA_OACC_CLAUSE_NOHST.

gcc/c/
* c-parser.c (c_parser_omp_clause_name): Handle "nohost".
(c_parser_oacc_all_clauses): Handle PRAGMA_OACC_CLAUSE_NOHOST.
(c_parser_oacc_routine, c_finish_oacc_routine): Update.
* c-typeck.c (c_finish_omp_clauses): Handle OMP_CLAUSE_NOHOST.

gcc/cp/
* parser.c (cp_parser_omp_clause_name): Handle "nohost".
(cp_parser_oacc_all_clauses): Handle PRAGMA_OACC_CLAUSE_NOHOST,
(cp_parser_oacc_routine, cp_finalize_oacc_routine): Update.
* pt.c (tsubst_omp_clauses): Handle OMP_CLAUSE_NOHOST.
* semantics.c (finish_omp_clauses): Handle OMP_CLAUSE_NOHOST.

gcc/fortran/
* gfortran.h (gfc_omp_clauses): Add nohost members.
* openmp.c (omp_mask2): Add OMP_CLAUSE_NOHOST.
(gfc_match_omp_clauses): Handle OMP_CLAUSE_NOHOST.
(gfc_match_oacc_routine): Set oacc_function_nohost when appropriate.
* gfortran.h (symbol_attribute): Add oacc_function_nohost member.
* trans-openmp.c (gfc_add_omp_offload_attributes): Use it to decide
whether to generate an OMP_CLAUSE_NOHOST clause.
(gfc_trans_omp_clauses_1): Unreachable code to generate an
OMP_CLAUSE_NOHOST clause.

gcc/testsuite/
* c-c++-common/goacc/classify-routine.c: Adjust test.
* c-c++-common/goacc/routine-1.c: Likewise.
* c-c++-common/goacc/routine-2.c: Likewise.
* c-c++-common/goacc/routine-nohost-1.c: New test.
* g++.dg/goacc/routine-2.C: Adjust test.
* gfortran.dg/goacc/pr72741.f90: New test.

libgomp/
* testsuite/libgomp.oacc-c-c++-common/routine-3.c: New test.
* testsuite/libgomp.oacc-c-c++-common/routine-nohost-1.c: New test.
* testsuite/libgomp.oacc-c-c++-common/routine-bind-nohost-1.c:
Update test.
* testsuite/libgomp.oacc-fortran/routine-6.f90: Likewise.

(cherry picked from openacc-gcc-9-branch commit
a6ec4f19ff50a91a7b0a8c3663e49c071b506016)

5 years agoInteraction of dynamic/multidimensional arrays with attach/detach.
Julian Brown [Tue, 5 Feb 2019 21:43:21 +0000 (13:43 -0800)] 
Interaction of dynamic/multidimensional arrays with attach/detach.

gcc/
* omp-low.c (scan_sharing_clauses): Disallow dynamic (multidimensional)
arrays within structs.

gcc/testsuite/
* c-c++-common/goacc/deep-copy-multidim.c: Add test.

(cherry picked from openacc-gcc-9-branch commit
857f3bc94d843467db9857b82512a1a5a470b1ef)

5 years ago[8/8] Multi-dimensional dynamic array support for OpenACC data clauses, libgomp tests...
Julian Brown [Tue, 5 Feb 2019 20:51:36 +0000 (12:51 -0800)] 
[8/8] Multi-dimensional dynamic array support for OpenACC data clauses, libgomp testsuite additions

2018-10-16  Chung-Lin Tang  <cltang@codesourcery.com>

libgomp/
* testsuite/libgomp.oacc-c-c++-common/da-1.c: New test.
* testsuite/libgomp.oacc-c-c++-common/da-2.c: New test.
* testsuite/libgomp.oacc-c-c++-common/da-3.c: New test.
* testsuite/libgomp.oacc-c-c++-common/da-4.c: New test.
* testsuite/libgomp.oacc-c-c++-common/da-utils.h: New test.

(cherry picked from openacc-gcc-9-branch commit
26413f817be2e0e0ec02333930c3d01acea4f1c7)

5 years ago[7/8] Multi-dimensional dynamic array support for OpenACC data clauses, libgomp support
Julian Brown [Thu, 14 Mar 2019 21:25:15 +0000 (14:25 -0700)] 
[7/8] Multi-dimensional dynamic array support for OpenACC data clauses, libgomp support

2018-10-16  Chung-Lin Tang  <cltang@codesourcery.com>

libgomp/
* target.c (struct da_dim): New struct declaration.
(struct da_descr_type): Likewise.
(struct da_info): Likewise.
(gomp_dynamic_array_count_rows): New function.
(gomp_dynamic_array_compute_info): Likewise.
(gomp_dynamic_array_fill_rows_1): Likewise.
(gomp_dynamic_array_fill_rows): Likewise.
(gomp_dynamic_array_create_ptrblock): Likewise.
(gomp_map_vars): Add code to handle dynamic array map kinds.

(cherry picked from openacc-gcc-9-branch commit
e2266a0a7f99e40ca91bdc70174426a249b3dd7a)

5 years ago[6/8] Multi-dimensional dynamic array support for OpenACC data clauses, tree pretty...
Julian Brown [Tue, 5 Feb 2019 15:38:41 +0000 (07:38 -0800)] 
[6/8] Multi-dimensional dynamic array support for OpenACC data clauses, tree pretty-printing additions

2018-10-16  Chung-Lin Tang  <cltang@codesourcery.com>

gcc/
* tree-pretty-print.c (dump_omp_clauses): Add cases for printing
GOMP_MAP_DYNAMIC_ARRAY map kinds.

(cherry picked from openacc-gcc-9-branch commit
1851ac580e2727cd8d2a3a8793e19fc02e8716b4)

5 years ago[5/8] Multi-dimensional dynamic array support for OpenACC data clauses, omp-low:...
Julian Brown [Tue, 5 Feb 2019 15:37:12 +0000 (07:37 -0800)] 
[5/8] Multi-dimensional dynamic array support for OpenACC data clauses, omp-low: bias scanning/adjustment during omp-lowering

2018-10-16  Chung-Lin Tang  <cltang@codesourcery.com>

gcc/
* omp-low.c (dynamic_array_lookup): New function.
(dynamic_array_reference_start): Likewise.
(scan_for_op): Likewise.
(scan_for_reference): Likewise.
(da_create_bias): Likewise.
(da_dimension_peel): Likewise.
(lower_omp_1): Add case to look for start of dynamic array reference,
and handle bias adjustments for the code sequence.

(cherry picked from openacc-gcc-9-branch commit
b84089be096efbaf5bd7825074df215e22eb9d14)

5 years ago[4/8] Multi-dimensional dynamic array support for OpenACC data clauses, omp-low:...
Julian Brown [Tue, 5 Feb 2019 15:35:18 +0000 (07:35 -0800)] 
[4/8] Multi-dimensional dynamic array support for OpenACC data clauses, omp-low: dynamic array descriptor creation

2018-10-16  Chung-Lin Tang  <cltang@codesourcery.com>

gcc/
* omp-low.c (struct omp_context):
Add 'hash_map<tree_operand_hash, tree> *dynamic_arrays' field, also
added include of "tree-hash-traits.h".
(append_field_to_record_type): New function.
(create_dynamic_array_descr_type): Likewise.
(create_dynamic_array_descr_init_code): Likewise.
(new_omp_context): Add initialize of dynamic_arrays field.
(delete_omp_context): Add delete of dynamic_arrays field.
(scan_sharing_clauses): For dynamic array map kinds, check for
supported dimension structure, and install dynamic array variable into
current omp_context.
(lower_omp_target): Add handling for dynamic array map kinds.

(cherry picked from openacc-gcc-9-branch commit
428bb933e9720f9f3dcfadbfe7bb499b45c5e6b2)

5 years ago[3/8] Multi-dimensional dynamic array support for OpenACC data clauses, gimplify...
Julian Brown [Tue, 5 Feb 2019 15:33:25 +0000 (07:33 -0800)] 
[3/8] Multi-dimensional dynamic array support for OpenACC data clauses, gimplify patch

2018-10-16  Chung-Lin Tang  <cltang@codesourcery.com>

gcc/
* gimplify.c (gimplify_scan_omp_clauses): For dynamic array map kinds,
make sure bias in each dimension are put into firstprivate variables.

(cherry picked from openacc-gcc-9-branch commit
a9cde8c122c4dc48bd8aad71e0c543e07b08a4ca)

5 years ago[2/8] Multi-dimensional dynamic array support for OpenACC data clauses, C/C++ front...
Julian Brown [Tue, 5 Feb 2019 15:32:29 +0000 (07:32 -0800)] 
[2/8] Multi-dimensional dynamic array support for OpenACC data clauses, C/C++ front-end parts

2018-10-16  Chung-Lin Tang  <cltang@codesourcery.com>

gcc/c/
* c-typeck.c (handle_omp_array_sections_1): Add 'bool &non_contiguous'
parameter, adjust recursive call site, add cases for allowing
pointer based multi-dimensional arrays for OpenACC.
(handle_omp_array_sections): Adjust handle_omp_array_sections_1 call,
handle non-contiguous case to create dynamic array map.

gcc/cp/
* semantics.c (handle_omp_array_sections_1): Add 'bool &non_contiguous'
parameter, adjust recursive call site, add cases for allowing
pointer based multi-dimensional arrays for OpenACC.
(handle_omp_array_sections): Adjust handle_omp_array_sections_1 call,
handle non-contiguous case to create dynamic array map.

(cherry picked from openacc-gcc-9-branch commit
245dc26efd584c444902fd5453b79a6efebd0e57)

5 years ago[1/8] Multi-dimensional dynamic array support for OpenACC data clauses, gomp-constant...
Julian Brown [Tue, 5 Feb 2019 14:25:31 +0000 (06:25 -0800)] 
[1/8] Multi-dimensional dynamic array support for OpenACC data clauses, gomp-constants.h additions

2018-10-16  Chung-Lin Tang  <cltang@codesourcery.com>

include/
* gomp-constants.h (GOMP_MAP_FLAG_SPECIAL_3): Define.
(enum gomp_map_kind): Add GOMP_MAP_DYNAMIC_ARRAY,
GOMP_MAP_DYNAMIC_ARRAY_TO, GOMP_MAP_DYNAMIC_ARRAY_FROM,
GOMP_MAP_DYNAMIC_ARRAY_TOFROM, GOMP_MAP_DYNAMIC_ARRAY_FORCE_TO,
GOMP_MAP_DYNAMIC_ARRAY_FORCE_FROM, GOMP_MAP_DYNAMIC_ARRAY_FORCE_TOFROM,
GOMP_MAP_DYNAMIC_ARRAY_ALLOC, GOMP_MAP_DYNAMIC_ARRAY_FORCE_ALLOC,
GOMP_MAP_DYNAMIC_ARRAY_FORCE_PRESENT.
(GOMP_MAP_DYNAMIC_ARRAY_P): Define.

(cherry picked from openacc-gcc-9-branch commit
378239a91cd9d2253991edd85c777b377d312c0e)

5 years ago[og8] Attach/detach array slices on dereferenced struct members
Julian Brown [Thu, 31 Jan 2019 16:39:15 +0000 (08:39 -0800)] 
[og8] Attach/detach array slices on dereferenced struct members

A couple of fixes folded in relative to og8 version.

2019-01-31  Julian Brown  <julian@codesourcery.com>

gcc/c/
* c-typeck.c (handle_omp_array_sections_1): Handle chained dereferences.
(c_finish_omp_clauses): Likewise.

gcc/cp/
* semantics.c (handle_omp_array_sections_1): Handle array section on
dereferenced struct member.
(finish_omp_clauses): Don't error on multiple dereferenced struct
elements with the same base.

gcc/
* gimplify.c (gimplify_scan_omp_clauses): Handle array sections on
dereferenced struct members.

gcc/testsuite/
* c-c++-common/goacc/deep-copy-arrayofstruct.c: New test.

libgomp/
* testsuite/libgomp.oacc-c++/deep-copy-12.C: New test.
* testsuite/libgomp.oacc-c++/deep-copy-13.C: New test.
* testsuite/libgomp.oacc-c-c++-common/deep-copy-9.c: New test.
* testsuite/libgomp.oacc-c-c++-common/deep-copy-10.c: New test.
* testsuite/libgomp.oacc-c-c++-common/deep-copy-11.c: New test.
* testsuite/libgomp.oacc-c-c++-common/deep-copy-14.c: New test.

(cherry picked from openacc-gcc-9-branch commit
ad36f2e3a8ad481c6bbd6376a1ab25fce1da4d8d)

5 years agoOpenACC reference count consistency checking
Julian Brown [Fri, 30 Nov 2018 10:40:49 +0000 (02:40 -0800)] 
OpenACC reference count consistency checking

2018-11-28  Julian Brown  <julian@codesourcery.com>

libgomp/
* libgomp.h (RC_CHECKING): New macro, disabled by default, guarding all
hunks in this patch.
(target_mem_desc): Add forward declaration.
(async_tgt_use): New struct.
(target_mem_desc): Add refcount_chk, mark fields.
(acc_dispatch_t): Add tgt_uses, au_lock fields.
(dump_tgt, gomp_rc_check): Add prototypes.
* oacc-async (goacc_async_unmap_tgt): Add refcount self-check code.
(goacc_async_copyout_unmap_vars): Likewise.
(goacc_remove_var_async): Likewise.
* oacc-parallel.c (GOACC_parallel_keyed_internal): Add refcount
self-check code.
(GOACC_data_start, GOACC_data_end, GOACC_enter_exit_data): Likewise.
* target.c (stdio.h): Include.
(dump_tgt, rc_check_clear, rc_check_count, rc_check_verify)
(gomp_rc_check): New functions to consistency-check reference counts.
(gomp_target_init): Initialise self-check-related device fields.

(cherry picked from openacc-gcc-9-branch commit
ee87cb3436ca56c7ebe96768f7d13e3d959fbbd5)

5 years agoOpenACC 2.6 manual deep copy support (attach/detach)
Julian Brown [Fri, 4 Jan 2019 01:58:51 +0000 (17:58 -0800)] 
OpenACC 2.6 manual deep copy support (attach/detach)

2018-12-14  Julian Brown  <julian@codesourcery.com>

gcc/c-family/
* c-pragma.h (pragma_omp_clause): Add PRAGMA_OACC_CLAUSE_ATTACH and
PRAGMA_OACC_CLAUSE_DETACH.
* c-common.h (c_omp_map_clause_name): Add prototype.
* c-omp.c (c_omp_map_clause_name): New function.

gcc/c/
* c-parser.c (c_parser_omp_clause_name): Add parsing of attach and
detach clauses.
(c_parser_omp_variable_list): Add ALLOW_DEREF optional parameter.
Allow deref (->) in variable lists if true.
(c_parser_omp_var_list_parens): Add ALLOW_DEREF optional parameter.
Pass to c_parser_omp_variable_list.
(c_parser_oacc_data_clause): Support attach and detach clauses.  Update
call to c_parser_omp_variable_list.
(c_parser_oacc_all_clauses): Support attach and detach clauses.
(OACC_DATA_CLAUSE_MASK, OACC_ENTER_DATA_CLAUSE_MASK)
(OACC_KERNELS_CLAUSE_MASK, OACC_PARALLEL_CLAUSE_MASK): Add
PRAGMA_OACC_CLAUSE_ATTACH.
(OACC_EXIT_DATA_CLAUSE_MASK): Add PRAGMA_OACC_CLAUSE_DETACH.
* c-typeck.c (handle_omp_array_sections_1): Reject subarrays for attach
and detach.  Support deref.
(c_oacc_check_attachments): New function.
(c_finish_omp_clauses): Check attach/detach arguments for being
pointers using above.  Support deref.

gcc/cp/
* parser.c (cp_parser_omp_clause_name): Support attach and detach
clauses.
(cp_parser_omp_var_list_no_open): Add ALLOW_DEREF optional parameter.
Parse deref if true.
(cp_parser_omp_var_list): Add ALLOW_DEREF optional parameter.  Pass to
cp_parser_omp_var_list_no_open.
(cp_parser_oacc_data_clause): Support attach and detach clauses.
Update call to cp_parser_omp_var_list_no_open.
(cp_parser_oacc_all_clauses): Support attach and detach.
(OACC_DATA_CLAUSE_MASK, OACC_ENTER_DATA_CLAUSE_MASK)
(OACC_KERNELS_CLAUSE_MASK, OACC_PARALLEL_CLAUSE_MASK): Add
PRAGMA_OACC_CLAUSE_ATTACH.
(OACC_EXIT_DATA_CLAUSE_MASK): Add PRAGMA_OACC_CLAUSE_DETACH.
* semantics.c (handle_omp_array_sections_1): Reject subarrays for
attach and detach.
(cp_oacc_check_attachments): New function.
(finish_omp_clauses): Use above function.  Allow structure fields and
class members to appear in OpenACC data clauses.  Support deref.

gcc/fortran/
* gfortran.h (gfc_omp_map_op): Add OMP_MAP_ATTACH, OMP_MAP_DETACH.
* openmp.c (gfc_match_omp_variable_list): Add allow_derived parameter.
Parse derived-type member accesses if true.
(omp_mask2): Add OMP_CLAUSE_ATTACH and OMP_CLAUSE_DETACH.
(gfc_match_omp_map_clause): Add allow_derived parameter.  Pass to
gfc_match_omp_variable_list.
(gfc_match_omp_clauses): Support attach and detach.  Support derived
types for appropriate OpenACC directives.
(OACC_PARALLEL_CLAUSES, OACC_KERNELS_CLAUSES, OACC_DATA_CLAUSES)
(OACC_ENTER_DATA_CLAUSES): Add OMP_CLAUSE_ATTACH.
(OACC_EXIT_DATA_CLAUSES): Add OMP_CLAUSE_DETACH.
(check_symbol_not_pointer): Don't disallow pointer objects of derived
type.
(resolve_oacc_data_clauses): Don't disallow allocatable derived types.
(resolve_omp_clauses): Perform duplicate checking only for non-derived
type component accesses (plain variables and arrays or array sections).
Support component refs.
* trans-openmp.c (gfc_omp_privatize_by_reference): Support component
refs.
(gfc_trans_omp_clauses): Support component refs, attach and detach
clauses.

gcc/
* gimplify.c (gimplify_omp_var_data): Add GOVD_MAP_HAS_ATTACHMENTS.
(insert_struct_component_mapping): Support derived-type member mappings
for arrays with descriptors which use GOMP_MAP_TO_PSET.
(gimplify_scan_omp_clauses): Rewrite GOMP_MAP_ALWAYS_POINTER to
GOMP_MAP_ATTACH for OpenACC struct/derived-type component pointers.
Handle pointer mappings that use GOMP_MAP_TO_PSET.  Handle attach/detach
clauses.
(gimplify_adjust_omp_clauses_1): Skip adjustments for explicit
attach/detach clauses.
(gimplify_omp_target_update): Handle finalize for detach.
* omp-low.c (lower_omp_target): Support GOMP_MAP_ATTACH,
GOMP_MAP_DETACH, GOMP_MAP_FORCE_DETACH.
* tree-pretty-print.c (dump_omp_clause): Likewise.

include/
* gomp-constants.h (GOMP_MAP_DEEP_COPY): Define.
(gomp_map_kind): Add GOMP_MAP_ATTACH, GOMP_MAP_DETACH,
GOMP_MAP_FORCE_DETACH.

gcc/testsuite/
* c-c++-common/goacc/mdc-1.c: New test.
* c-c++-common/goacc/mdc-2.c: New test.
* gcc.dg/goacc/mdc.C: New test.
* gfortran.dg/goacc/data-clauses.f95: New test.
* gfortran.dg/goacc/derived-types.f90: New test.
* gfortran.dg/goacc/enter-exit-data.f95: New test.

libgomp/
* libgomp.h (struct target_var_desc): Add do_detach flag.
(VREFCOUNT_LINK_KEY): New macro.
(struct splay_tree_key_s): Put link_key and new attach_count field into
a new union.  Substitute dynamic_refcount field for virtual_refcount.
(struct acc_dispatch_t): Remove data_environ field.
(enum gomp_map_vars_kind): Add GOMP_MAP_VARS_OPENACC_ENTER_DATA.
(gomp_acc_insert_pointer): Remove prototype.
(gomp_acc_remove_pointer): Update prototype.
(struct gomp_coalesce_buf): Add forward declaration.
(gomp_map_val, gomp_attach_pointer, gomp_detach_pointer): Add
prototypes.
* libgomp.map (OACC_2.6): New section. Add acc_attach, acc_attach_async,
acc_detach, acc_detach_async, acc_detach_finalize,
acc_detach_finalize_async.
* oacc-async.c (goacc_remove_var_async): New function.
* oacc-host.c (host_dispatch): Don't initialise removed data_environ
field.
* oacc-init.c (acc_shutdown_1): Use gomp_remove_var instead of
gomp_unmap_vars to remove mappings by splay tree key instead of target
memory descriptor.
* oacc-int.h (splay_tree_key_s): Add forward declaration.
(goacc_remove_var_async): Add prototype.
* oacc-mem.c (lookup_dev_1): New function.
(lookup_dev): Reimplement using above.
(acc_free, acc_hostptr): Update calls to lookup_dev.
(acc_map_data): Likewise.  Don't add to data_environ list.
(acc_unmap_data): Remove call to gomp_unmap_vars.  Fix semantics to
remove mapping, but not mapped data.
(present_create_copy): Use virtual_refcount instead of
dynamic_refcount.  Don't manipulate data_environ.  Fix target pointer
return value.
(delete_copyout): Update for virtual_refcount semantics.  Use
goacc_remove_var_async for asynchronous delete/copyouts.
(gomp_acc_insert_pointer): Remove function.
(gomp_acc_remove_pointer): Reimplement.
(acc_attach_async, acc_attach, goacc_detach_internal, acc_detach)
(acc_detach_async, acc_detach_finalize, acc_detach_finalize_async): New
functions.
* oacc-parallel.c (find_pointer): Support attach/detach.  Make a little
more strict.
(GOACC_parallel_keyed): Use gomp_map_val to calculate device addresses.
(GOACC_enter_exit_data): Support attach/detach and GOMP_MAP_STRUCT.
Don't call gomp_acc_insert_pointer.
* openacc.h (acc_attach, acc_attach_async, acc_detach)
(acc_detach_async, acc_detach_finalize, acc_detach_finalize_async): Add
prototypes.
* target.c (gomp_map_vars_existing): Initialise do_detach field of
tgt_var_desc.
(gomp_attach_pointer, gomp_detach_pointer): New functions.
(gomp_map_val): Make global.
(gomp_map_vars_async): Handle GOMP_MAP_VARS_OPENACC_ENTER_DATA.  Update
for virtual_refcount semantics.  Support attach and detach.
(gomp_remove_var): Free attach count array if present.
(gomp_unmap_vars_async): Support detach and update for virtual_refcount
semantics.  Disambiguate link_key/attach_count using virtual_refcount
with magic value as a tag.
(gomp_load_image_to_device): Zero-initialise virtual_refcount fields.
(gomp_free_memmap): Remove function.
(gomp_exit_data): Check virtual_refcount for tag value before using
link_key.
(omp_target_associate_ptr): Zero-initialise virtual_refcount and
link_key splay tree key fields.
(gomp_target_init): Don't initialise removed data_environ field.
* testsuite/libgomp.oacc-c-c++-common/context-2.c: Use correct API to
deallocate acc_copyin'd data.
* testsuite/libgomp.oacc-c-c++-common/context-4.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/deep-copy-1.c: New test.
* testsuite/libgomp.oacc-c-c++-common/deep-copy-2.c: New test.
* testsuite/libgomp.oacc-c-c++-common/deep-copy-3.c: New test.
* testsuite/libgomp.oacc-c-c++-common/deep-copy-4.c: New test.
* testsuite/libgomp.oacc-c-c++-common/deep-copy-5.c: New test.
* testsuite/libgomp.oacc-c-c++-common/deep-copy-6.c: New test.
* testsuite/libgomp.oacc-c-c++-common/deep-copy-7.c: New test.
* testsuite/libgomp.oacc-c-c++-common/deep-copy-8.c: New test.
* testsuite/libgomp.oacc-fortran/deep-copy-1.c: New test.
* testsuite/libgomp.oacc-fortran/deep-copy-2.c: New test.
* testsuite/libgomp.oacc-fortran/deep-copy-3.c: New test.
* testsuite/libgomp.oacc-fortran/deep-copy-4.c: New test.
* testsuite/libgomp.oacc-fortran/deep-copy-5.c: New test.
* testsuite/libgomp.oacc-fortran/deep-copy-6.c: New test.
* testsuite/libgomp.oacc-fortran/deep-copy-7.c: New test.
* testsuite/libgomp.oacc-fortran/deep-copy-8.c: New test.
* testsuite/libgomp.oacc-fortran/data-2.f90: Update test.
* testsuite/libgomp.oacc-fortran/derived-type-1.f90: New test.
* testsuite/libgomp.oacc-fortran/update-2.f90: New test.

(cherry picked from openacc-gcc-9-branch commit
1242d5e6581365913f4dc3968206893970be4d07)

5 years agoFactor out duplicate code in gimplify_scan_omp_clauses
Julian Brown [Mon, 5 Nov 2018 23:51:46 +0000 (15:51 -0800)] 
Factor out duplicate code in gimplify_scan_omp_clauses

2018-11-10  Julian Brown  <julian@codesourcery.com>

gcc/
* gimplify.c (insert_struct_comp_map, check_base_and_compare_lt): New.
(gimplify_scan_omp_clauses): Outline duplicated code into calls to
above two functions.

(cherry picked from openacc-gcc-9-branch commit
e7f6d3b9a0b10f6b86e83bb19cb54ebd8ca61545)

5 years agoHost-to-device transfer coalescing & magic offset value self-documentation
Julian Brown [Mon, 5 Nov 2018 23:11:12 +0000 (15:11 -0800)] 
Host-to-device transfer coalescing & magic offset value self-documentation

2018-11-10  Julian Brown  <julian@codesourcery.com>

libgomp/
* libgomp.h (OFFSET_INLINED, OFFSET_POINTER, OFFSET_STRUCT): Define.
* target.c (FIELD_TGT_EMPTY): Define.
(gomp_map_val): Use OFFSET_* macros instead of magic constants.  Write
as switch instead of list of ifs.
(gomp_map_vars_internal): Use OFFSET_* and FIELD_TGT_EMPTY macros.

(cherry picked from openacc-gcc-9-branch commit
dc9711235460a559ab9bafca5f9b4bae155ac798)

5 years agoAsync rework (v6)
Julian Brown [Tue, 26 Feb 2019 16:41:05 +0000 (08:41 -0800)] 
Async rework (v6)

2019-02-26  Chung-Lin Tang  <cltang@codesourcery.com>

include/
* gomp-constants.h (GOMP_ASYNC_DEFAULT): Define.
(GOMP_PLUGIN_IF_VERSION): New version symbol for plugin interface.
Update surrounding comments.

libgomp/
* target.c (goacc_device_copy_async): New function.
(gomp_copy_host2dev): Remove 'static', add goacc_asyncqueue parameter,
add goacc_device_copy_async case.
(gomp_copy_dev2host): Likewise.
(gomp_map_vars_existing): Add goacc_asyncqueue parameter, adjust code.
(gomp_map_pointer): Likewise.
(gomp_map_fields_existing): Likewise.
(gomp_map_vars_internal): New always_inline function, renamed from
gomp_map_vars.
(gomp_map_vars): Implement by calling gomp_map_vars_internal.
(gomp_map_vars_async): Implement by calling gomp_map_vars_internal,
passing goacc_asyncqueue argument.
(gomp_unmap_tgt): Remove statis, add attribute_hidden.
(gomp_unmap_vars_internal): New always_inline function, renamed from
gomp_unmap_vars.
(gomp_unmap_vars): Implement by calling gomp_unmap_vars_internal.
(gomp_unmap_vars_async): Implement by calling gomp_unmap_vars_internal,
passing goacc_asyncqueue argument.
(gomp_fini_device): New function.
(gomp_exit_data): Adjust gomp_copy_dev2host call.
(gomp_load_plugin_for_device): Remove old interface, adjust to load
new async interface.
(gomp_target_fini): Adjust code to call gomp_fini_device.

* oacc-async.c (get_goacc_thread): New function.
(get_goacc_thread_device): New function.
(lookup_goacc_asyncqueue): New function.
(validate_async_val): New function.
(lookup_goacc_asyncqueue): New function.
(get_goacc_asyncqueue): New function.
(acc_async_test): Adjust code to use new async design.
(acc_async_test_all): Likewise.
(acc_wait): Likewise.
(acc_wait_async): Likewise.
(acc_wait_all): Likewise.
(acc_wait_all_async): Likewise.
(acc_get_default_async): New API function.
(acc_set_default_async): Likewise.
(goacc_async_unmap_tgt): New function.
(goacc_async_copyout_unmap_vars): Likewise.
(goacc_async_free): Likewise.
(goacc_init_asyncqueues): Likewise.
(goacc_fini_asyncqueues): Likewise.

* oacc-cuda.c (acc_get_cuda_stream): Adjust code to use new async
design.
(acc_set_cuda_stream): Likewise.

* oacc-host.c (host_version): Update to return GOMP_PLUGIN_IF_VERSION.
(host_openacc_exec): Adjust parameters, remove 'async'.
(host_openacc_register_async_cleanup): Remove.
(host_openacc_async_exec): New function.
(host_openacc_async_test): Adjust parameters.
(host_openacc_async_test_all): Remove.
(host_openacc_async_wait): Remove.
(host_openacc_async_wait_async): Remove.
(host_openacc_async_wait_all): Remove.
(host_openacc_async_wait_all_async): Remove.
(host_openacc_async_set_async): Remove.
(host_openacc_async_synchronize): New function.
(host_openacc_async_serialize): New function.
(host_openacc_async_host2dev): New function.
(host_openacc_async_dev2host): New function.
(host_openacc_async_queue_callback): New function.
(host_openacc_async_construct): New function.
(host_openacc_async_destruct): New function.
(struct gomp_device_descr host_dispatch): Remove initialization of old
interface, add intialization of new async sub-struct.

* oacc-init.c (acc_shutdown_1): Adjust to use gomp_fini_device.
(goacc_attach_host_thread_to_device): Remove old async code usage, add
initialization of per-thread default_async.

* oacc-int.h (goacc_init_asyncqueues): New declaration.
(goacc_fini_asyncqueues): Likewise.
(goacc_async_free): Likewise.
(get_goacc_asyncqueue): Likewise.
(lookup_goacc_asyncqueue): Likewise.

* oacc-mem.c (memcpy_tofrom_device): Adjust code to use new async
design.
(present_create_copy): Likewise.
(delete_copyout): Likewise.
(update_dev_host): Likewise.
(gomp_acc_insert_pointer): Add async parameter, adjust code to use new
async design.
(gomp_acc_remove_pointer): Adjust code to use new async design.

* oacc-parallel.c (GOACC_parallel_keyed): Likewise.
(GOACC_enter_exit_data): Likewise.
(goacc_wait): Likewise.
(GOACC_update): Likewise.

* oacc-plugin.c (GOMP_PLUGIN_async_unmap_vars): Change to assert fail
when called, warn as obsolete in comment.

* libgomp-plugin.h (struct goacc_asyncqueue): Declare.
(struct goacc_asyncqueue_list): Likewise.
(goacc_aq): Likewise.
(goacc_aq_list): Likewise.
(GOMP_OFFLOAD_openacc_register_async_cleanup): Remove.
(GOMP_OFFLOAD_openacc_async_test): Remove.
(GOMP_OFFLOAD_openacc_async_test_all): Remove.
(GOMP_OFFLOAD_openacc_async_wait): Remove.
(GOMP_OFFLOAD_openacc_async_wait_async): Remove.
(GOMP_OFFLOAD_openacc_async_wait_all): Remove.
(GOMP_OFFLOAD_openacc_async_wait_all_async): Remove.
(GOMP_OFFLOAD_openacc_async_set_async): Remove.
(GOMP_OFFLOAD_openacc_exec): Adjust declaration.
(GOMP_OFFLOAD_openacc_cuda_get_stream): Likewise.
(GOMP_OFFLOAD_openacc_cuda_set_stream): Likewise.
(GOMP_OFFLOAD_openacc_async_exec): Declare.
(GOMP_OFFLOAD_openacc_async_construct): Declare.
(GOMP_OFFLOAD_openacc_async_destruct): Declare.
(GOMP_OFFLOAD_openacc_async_test): Declare.
(GOMP_OFFLOAD_openacc_async_synchronize): Declare.
(GOMP_OFFLOAD_openacc_async_serialize): Declare.
(GOMP_OFFLOAD_openacc_async_queue_callback): Declare.
(GOMP_OFFLOAD_openacc_async_host2dev): Declare.
(GOMP_OFFLOAD_openacc_async_dev2host): Declare.

* openacc.h (acc_async_t): Add acc_async_default enum.
(acc_set_default_async): Declare API function.
(acc_get_default_async): Likewise.

* libgomp.h (struct acc_dispatch_t): Define 'async' sub-struct.
Delete register_async_cleanup_func, async_test_func,
async_test_all_func, async_wait_func, async_wait_async_func,
async_wait_all_func, async_wait_all_async_func, async_set_async_func
hook fields.
(gomp_acc_insert_pointer): Adjust declaration.
(gomp_copy_host2dev): New declaration.
(gomp_copy_dev2host): Likewise.
(gomp_map_vars_async): Likewise.
(gomp_unmap_tgt): Likewise.
(gomp_unmap_vars_async): Likewise.
(gomp_fini_device): Likewise.

* libgomp.map (OACC_2.5): Add acc_get_default_async,
acc_get_default_async_h_, acc_set_default_async, and
acc_set_default_async_h_.

* openacc.f90 (acc_async_default): Declare.
(acc_set_default_async): Likewise.
(acc_get_default_async): Likewise.

* openacc_lib.h (acc_async_default): Declare.
 (acc_set_default_async): Likewise.
(acc_get_default_async): Likewise.

* plugin/plugin-hsa.c (GOMP_OFFLOAD_version): Update to return
GOMP_PLUGIN_IF_VERSION.

* plugin/plugin-nvptx.c (struct cuda_map): Remove.
(struct ptx_stream): Remove.
(struct nvptx_thread): Remove current_stream field.
(cuda_map_create): Remove.
(cuda_map_destroy): Remove.
(map_init): Remove.
(map_fini): Remove.
(map_pop): Remove.
(map_push): Remove.
(struct goacc_asyncqueue): Define.
(struct nvptx_callback): Define.
(struct ptx_free_block): Define.
(struct ptx_device): Remove null_stream, active_streams, async_streams,
stream_lock, and next fields.
(enum ptx_event_type): Remove.
(struct ptx_event): Remove.
(ptx_event_lock): Remove.
(ptx_events): Remove.
(init_streams_for_device): Remove.
(fini_streams_for_device): Remove.
(select_stream_for_async): Remove.
(nvptx_init): Remove ptx_events and ptx_event_lock references.
(nvptx_attach_host_thread_to_device): Remove CUDA_ERROR_NOT_PERMITTED
case.
(nvptx_open_device): Add free_blocks initialization, remove
init_streams_for_device call.
(nvptx_close_device): Remove fini_streams_for_device call, add
free_blocks destruct code.
(event_gc): Remove.
(event_add): Remove.
(nvptx_exec): Adjust parameters and code.
(nvptx_free): Likewise.
(nvptx_host2dev): Remove.
(nvptx_dev2host): Remove.
(nvptx_set_async): Remove.
(nvptx_async_test): Remove.
(nvptx_async_test_all): Remove.
(nvptx_wait): Remove.
(nvptx_wait_async): Remove.
(nvptx_wait_all): Remove.
(nvptx_wait_all_async): Remove.
(nvptx_get_cuda_stream): Remove.
(nvptx_set_cuda_stream): Remove.
(GOMP_OFFLOAD_alloc): Adjust code.
(GOMP_OFFLOAD_free): Likewise.
(GOMP_OFFLOAD_openacc_register_async_cleanup): Remove.
(GOMP_OFFLOAD_openacc_exec): Adjust parameters and code.
(GOMP_OFFLOAD_openacc_async_test_all): Remove.
(GOMP_OFFLOAD_openacc_async_wait): Remove.
(GOMP_OFFLOAD_openacc_async_wait_async): Remove.
(GOMP_OFFLOAD_openacc_async_wait_all): Remove.
(GOMP_OFFLOAD_openacc_async_wait_all_async): Remove.
(GOMP_OFFLOAD_openacc_async_set_async): Remove.
(cuda_free_argmem): New function.
(GOMP_OFFLOAD_openacc_async_exec): New plugin hook function.
(GOMP_OFFLOAD_openacc_create_thread_data): Adjust code.
(GOMP_OFFLOAD_openacc_cuda_get_stream): Adjust code.
(GOMP_OFFLOAD_openacc_cuda_set_stream): Adjust code.
(GOMP_OFFLOAD_openacc_async_construct): New plugin hook function.
(GOMP_OFFLOAD_openacc_async_destruct): New plugin hook function.
(GOMP_OFFLOAD_openacc_async_test): Remove and re-implement.
(GOMP_OFFLOAD_openacc_async_synchronize): New plugin hook function.
(GOMP_OFFLOAD_openacc_async_serialize): New plugin hook function.
(GOMP_OFFLOAD_openacc_async_queue_callback): New plugin hook function.
(cuda_callback_wrapper): New function.
(cuda_memcpy_sanity_check): New function.
(GOMP_OFFLOAD_host2dev): Remove and re-implement.
(GOMP_OFFLOAD_dev2host): Remove and re-implement.
(GOMP_OFFLOAD_openacc_async_host2dev): New plugin hook function.
(GOMP_OFFLOAD_openacc_async_dev2host): New plugin hook function.

* testsuite/libgomp.oacc-c-c++-common/asyncwait-2.c: New testcase.
* testsuite/libgomp.oacc-c-c++-common/lib-81.c: Adjust testcase.
* testsuite/libgomp.oacc-fortran/lib-12.f90: Likewise.

liboffloadmic/
* plugin/libgomp-plugin-intelmic.cpp (GOMP_OFFLOAD_version):
Update to return GOMP_PLUGIN_IF_VERSION.

(cherry picked from openacc-gcc-9-branch commit
b7d99d5bc7b4391eecbd0b7521c149dbb516b2c4)

5 years ago[PATCH] Forward -foffload=[...] from the driver (compile-time) to libgomp (run-time)
Julian Brown [Thu, 28 Feb 2019 16:53:54 +0000 (08:53 -0800)] 
[PATCH] Forward -foffload=[...] from the driver (compile-time) to libgomp (run-time)

gcc/
PR libgomp/81886
* doc/invoke.texi (-ffixed-@var{reg}): Document conflict with
Fortran options.
* gcc.c (add_omp_infile_spec_func, spec_lang_mask_accept): New.
(driver_self_specs): Add spec to use %:add-omp-infile().
(static_spec_functions): Add add-omp-infile.
(struct switchstr): Add lang_mask field.  Expand comment.
(struct infile): Add lang_mask field.
(add_infile, save_switch, do_spec): Add lang_mask argument.
(driver_unknown_option_callback, driver_wrong_lang_callback)
(driver_handle_option, process_command, do_self_spec)
(driver::do_spec_on_infiles, driver::maybe_run_linker): All
callers changed.
(give_switch): Check languages of switch against
spec_lang_mask_accept.
(driver::maybe_putenv_OFFLOAD_TARGETS): Don't free
offload_targets.
* gcc.h (do_spec): Update prototype.
gcc/fortran/
PR libgomp/81886
* gfortranspec.c (lang_specific_pre_link): Update call to do_spec.
libgomp/
PR libgomp/81886
* plugin/configfrag.ac (tgt_name): Do not set.
(offload_targets): Separate with colons not commas.
* config.h.in, configure: Regenerate.
* libgomp.h (gomp_offload_target_available_p): New prototype.
* libgomp.map (GOACC_2.0.GOMP_4_BRANCH): Add
GOMP_set_offload_targets.
* libgomp_g.h (GOMP_set_offload_targets): New prototype.
* oacc-init.c (resolve_device): Use
gomp_offload_target_available_p.
* target.c (resolve_device): Use host fallback when offload data
not available.
(gomp_offload_target_available_p, offload_target_to_plugin_name)
(gomp_offload_targets, gomp_offload_targets_init)
(GOMP_set_offload_targets, gomp_plugin_prefix)
(gomp_plugin_suffix): New.
(gomp_load_plugin_for_device): Add gomp_debug call.
(gomp_target_init): Use gomp_offload_targets instead of
OFFLOAD_TARGETS.  Handle and rewrie colon-separated string.
* openacc.h (enum acc_device_t): Add _acc_device_intel_mic,
_acc_device_hsa.
* oacc-init.c (get_openacc_name): Handle these.
(resolve_device): Debugging output.
* target.c (resolve_device, gomp_init_device)
(gomp_offload_target_available_p): Likewise.
* testsuite/lib/libgomp.exp: Expect offload targets to be
colon-separated.  Adjust matching of offload targets.
(libgomp_init)
(check_effective_target_openacc_nvidia_accel_configured)
(check_effective_target_openacc_host_selected): Adjust checks of
offload target names.
* testsuite/libgomp.oacc-c++/c++.exp: Adjust set of offload targets.
Use -foffload instead of setenv ACC_DEVICE_TYPE.  Provide offload
target in "-DACC_DEVICE_TYPE_host", and "-DACC_DEVICE_TYPE_nvidia".
* testsuite/libgomp.oacc-c/c.exp: Likewise.
* testsuite/libgomp.oacc-fortran/fortran.exp: Likewise.
* testsuite/libgomp.oacc-c-c++-common/parallel-dims.c: Adapt.
* testsuite/libgomp.oacc-c/offload-targets-1.c: New file.
* testsuite/libgomp.oacc-c/offload-targets-2.c: Likewise.
* testsuite/libgomp.oacc-c/offload-targets-3.c: Likewise.
* testsuite/libgomp.oacc-c/offload-targets-4.c: Likewise.
* testsuite/libgomp.oacc-c/offload-targets-5.c: Likewise.
* testsuite/libgomp.oacc-c/offload-targets-6.c: Likewise.
* testsuite/libgomp.oacc-c-c++-common/acc-on-device-2.c: Adjust.
* testsuite/libgomp.oacc-c-c++-common/acc_on_device-1.c: Likewise.
* testsuite/libgomp.oacc-fortran/acc_on_device-1-1.f90: Likewise.
* testsuite/libgomp.oacc-fortran/acc_on_device-1-2.f: Likewise.
* testsuite/libgomp.oacc-fortran/acc_on_device-1-3.f: Likewise.

(cherry picked from gomp-4_0-branch r227045, r227154, r227175, r248030, and
openacc-gcc-7-branch commit 917e247055a37f912129ed545719182de0046adb)

(cherry picked from openacc-gcc-9-branch commit
789c1d022a871eb06ab08bbb63dcb89006361d93)

6 years agore PR middle-end/89765 (Multiple problems with vec-insert implementation on PowerPC)
Richard Biener [Thu, 25 Apr 2019 17:58:56 +0000 (17:58 +0000)] 
re PR middle-end/89765 (Multiple problems with vec-insert implementation on PowerPC)

PR middle-end/89765
* gimplify.c (gimplify_expr): Avoid turning a lvalue
VIEW_CONVERT_EXPR into one operating on an rvalue.

From-SVN: r270579

6 years agox86: Update message for target_clones and unsupported ISAs
H.J. Lu [Thu, 25 Apr 2019 17:00:28 +0000 (10:00 -0700)] 
x86: Update message for target_clones and unsupported ISAs

Before AVX512F, processors with the newer ISAs also support the older
ISAs, i.e., AVX2 processors also support AVX and SSE4, SSE4 processors
also support SSSE3, ...   After AVX512F, an AVX512XX processor may not
support AVX512YY.  It means AVX512XX features, except for AVX512F, can't
be used to decide priority in target_clones.

This patch updates error message for ISAs with P_ZERO priority.  It also
merges _feature_list into _isa_names_table and marks ISAs, which have
unknown priority, with P_ZERO so that we only need to update one place
to add a new ISA feature.

gcc/

2019-04-25  H.J. Lu  <hongjiu.lu@intel.com>

PR target/89929
* config/i386/i386.c (feature_priority): Moved to file scope.
(processor_features): Likewise.
(processor_model): Likewise.
(_arch_names_table): Likewise.
(arch_names_table): Likewise.
(_feature_list): Removed.
(feature_list): Likewise.
(_isa_names_table): Moved to file scope.  Add priority.
(isa_names_table): Likewise.
(get_builtin_code_for_version): Replace feature_list with
isa_names_table.  Update error message for P_ZERO priority.

gcc/testsuite/

2019-04-25  Martin Liska  <mliska@suse.cz>
    H.J. Lu  <hongjiu.lu@intel.com>

PR target/89929
* g++.target/i386/mv28.C: New test.
* gcc.target/i386/mvc14.c: Likewise.
* g++.target/i386/pr57362.C: Updated.

From-SVN: r270578

6 years agolibphobos: Fix segfault in runtime caused by unexpected GC of TLS data.
Iain Buclaw [Thu, 25 Apr 2019 15:31:35 +0000 (15:31 +0000)] 
libphobos: Fix segfault in runtime caused by unexpected GC of TLS data.

libphobos/ChangeLog:

2019-04-25  Iain Buclaw  <ibuclaw@gdcproject.org>

PR d/90250
* libdruntime/gcc/sections/elf_shared.d (initTLSRanges): Populate
_tlsRanges in every startup thread.
* testsuite/libphobos.thread/thread.exp: Load libphobos-dg.exp.
* testsuite/libphobos.thread/tlsgc_sections.d: New test.

From-SVN: r270576

6 years agotree-pass.h (make_pass_phi_only_cprop): Remove.
Richard Biener [Thu, 25 Apr 2019 14:55:42 +0000 (14:55 +0000)] 
tree-pass.h (make_pass_phi_only_cprop): Remove.

2019-04-25  Richard Biener  <rguenther@suse.de>

* tree-pass.h (make_pass_phi_only_cprop): Remove.
* timevar.def (TV_TREE_PHI_CPROP): Likewise.

From-SVN: r270575

6 years agore PR tree-optimization/90037 (-Wnull-dereference false positive after r269302)
Jeff Law [Thu, 25 Apr 2019 14:32:16 +0000 (08:32 -0600)] 
re PR tree-optimization/90037 (-Wnull-dereference false positive after r269302)

PR tree-optimization/90037
* Makefile.in (OBJS): Remove tree-ssa-phionlycprop.c
* passes.def: Replace all instance of phi-only cprop with the
lattice propagator.  Move propagation pass from after erroneous
path isolation to before erroneous path isolation.
* tree-ssa-phionlycprop.c: Remove.

* gcc.dg/tree-ssa/20030710-1.c: Update dump file to scan.
* gcc.dg/isolate-2.c: Likewise.
* gcc.dg/isolate-4.c: Likewise.
* gcc.dg/pr19431.c: Accept either ordering of PHI args.
* gcc.dg/pr90037.c: New test.

From-SVN: r270574

6 years agoFix typo in m4/druntime/cpu.m4
Rainer Orth [Thu, 25 Apr 2019 12:39:33 +0000 (12:39 +0000)] 
Fix typo in m4/druntime/cpu.m4

* m4/druntime/cpu.m4 (DRUNTIME_CPU_SOURCES): Quote brackets.
* configure: Regenerate.

From-SVN: r270573

6 years agore PR c++/44648 (missing -Wunused warning on a const variable in if statement)
Jakub Jelinek [Thu, 25 Apr 2019 12:18:07 +0000 (14:18 +0200)] 
re PR c++/44648 (missing -Wunused warning on a const variable in if statement)

PR c++/44648
* g++.dg/warn/Wunused-var-35.C: Remove xfail.

From-SVN: r270572

6 years agoD: Do not add target_libs if phobos is disabled
Johannes Pfau [Thu, 25 Apr 2019 11:22:27 +0000 (11:22 +0000)] 
D: Do not add target_libs if phobos is disabled

From-SVN: r270571

6 years agore PR tree-optimization/90213 (UBSAN: signed integer overflow: -5621332293356458048...
Richard Biener [Thu, 25 Apr 2019 11:17:49 +0000 (11:17 +0000)] 
re PR tree-optimization/90213 (UBSAN: signed integer overflow: -5621332293356458048 * 8 cannot be represented in type 'long int')

2019-04-24  Richard Biener  <rguenther@suse.de>

PR middle-end/90213
* gimple-fold.c (fold_const_aggregate_ref_1): Do multiplication
by size and BITS_PER_UNIT on poly-wide-ints.

From-SVN: r270570

6 years agore PR middle-end/90194 (ICE in expand_debug_expr, at cfgexpand.c:5244)
Richard Biener [Thu, 25 Apr 2019 11:15:35 +0000 (11:15 +0000)] 
re PR middle-end/90194 (ICE in expand_debug_expr, at cfgexpand.c:5244)

2019-04-25  Richard Biener  <rguenther@suse.de>

PR middle-end/90194
* match.pd: Add pattern to simplify view-conversion of an
empty constructor.

* g++.dg/torture/pr90194.C: New testcase.

From-SVN: r270569

6 years agoD: Implement GCC emutls in druntime
Johannes Pfau [Thu, 25 Apr 2019 11:11:39 +0000 (11:11 +0000)] 
D: Implement GCC emutls in druntime

* libdruntime/Makefile.am: Add emutls and gthread files.
* libdruntime/Makefile.in: Regenerate.
* libdruntime/gcc/emutls.d: New file. Implement GC-compatible emutls.
* libdruntime/gcc/gthread.d: New file.
* libdruntime/gcc/sections/elf_shared.d: Integrate emutls support.
* testsuite/libphobos.allocations/tls_gc_integration.d: New test for
TLS.

From-SVN: r270568

6 years agolibphobos: Add missing PWD_COMMAND to Makefile.
Iain Buclaw [Thu, 25 Apr 2019 06:26:57 +0000 (06:26 +0000)] 
libphobos: Add missing PWD_COMMAND to Makefile.

2019-04-25  Iain Buclaw  <ibuclaw@gdcproject.org>

* testsuite/Makefile.am: Set PWD_COMMAND.
* testsuite/Makefile.in: Regenerate.

From-SVN: r270566

6 years agocompiler: fix glitch when inlining method with empty param/receiver
Ian Lance Taylor [Thu, 25 Apr 2019 01:13:22 +0000 (01:13 +0000)] 
compiler: fix glitch when inlining method with empty param/receiver

    Fix a problem with Function_declaration::import_function relating to
    how no-name or "sink" parameters are handled. In Gogo::start_function
    (for the non-inline case) when parameter bindings are being added,
    parameters with empty/sink names are renamed to synthesized "r.%d" /
    "p.%d" names so as to avoid collisions. This same handling needs to be
    present when creating the bindings for an inline function that's being
    instantiated after being read from export data.

    Fixes golang/go#31637.

    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/173538

From-SVN: r270564

6 years agoDaily bump.
GCC Administrator [Thu, 25 Apr 2019 00:16:17 +0000 (00:16 +0000)] 
Daily bump.

From-SVN: r270563

6 years agolibphobos: Fix linker warning and SEGV in core.thread tests.
Iain Buclaw [Wed, 24 Apr 2019 22:46:59 +0000 (22:46 +0000)] 
libphobos: Fix linker warning and SEGV in core.thread tests.

The monolithic core/threadasm.S source has been removed, and split into
multiple parts, one for each intended target CPU/OS.

Added .type and .size directives for all asm implementations of
fiber_switchContent and callWithStackShell where they were missing.

libphobos/ChangeLog:

2019-04-25  Iain Buclaw  <ibuclaw@gdcproject.org>

PR d/90086
* m4/druntime/cpu.m4 (DRUNTIME_CPU_SOURCES): New macro.
* configure.ac: Use it.
* configure: Regenerate.
* libdruntime/Makefile.am: Add new config sources to
DRUNTIME_SOURCES_CONFIGURED.
* libdruntime/Makefile.in: Regenerate.
* libdruntime/config/aarch64/switchcontext.S: New file.
* libdruntime/config/arm/switchcontext.S: New file.
* libdruntime/config/common/threadasm.S: New file.
* libdruntime/config/mingw/switchcontext.S: New file.
* libdruntime/config/mips/switchcontext.S: New file.
* libdruntime/config/powerpc/switchcontext.S: New file.
* libdruntime/config/powerpc64/callwithstack.S: New file.
* libdruntime/config/x86/switchcontext.S: New file.
* libdruntime/core/threadasm.S: Remove.

From-SVN: r270560

6 years agoUpdate C++17 library status tables
Jonathan Wakely [Wed, 24 Apr 2019 22:16:45 +0000 (23:16 +0100)] 
Update C++17 library status tables

* doc/xml/manual/status_cxx2017.xml: Document P0024R2 status.
* doc/html/*: Regenerate.

From-SVN: r270559

6 years agoMake filesystem::path comparison operators hidden friends (LWG 3065)
Jonathan Wakely [Wed, 24 Apr 2019 21:35:26 +0000 (22:35 +0100)] 
Make filesystem::path comparison operators hidden friends (LWG 3065)

This change revealed two testsuite bugs where some string comparisons
only compiled by converting the strings to filesystem::path objects.

* include/bits/fs_path.h (operator<, operator<=, operator>)
(operator>=, operator==, operator!=): Make hidden friends, as per
LWG 3065.
* testsuite/27_io/filesystem/path/native/string-char8_t.cc: Fix
string type in test.
* testsuite/27_io/filesystem/path/native/string.cc: Likewise.

From-SVN: r270558

6 years agore PR c++/90236 (bogus error with auto non-type template argument)
Marek Polacek [Wed, 24 Apr 2019 21:28:04 +0000 (21:28 +0000)] 
re PR c++/90236 (bogus error with auto non-type template argument)

PR c++/90236
* g++.dg/cpp1z/nontype-auto16.C: New test.

From-SVN: r270557

6 years agoPR c++/90227 - error with template parameter packs.
Jason Merrill [Wed, 24 Apr 2019 20:37:30 +0000 (16:37 -0400)] 
PR c++/90227 - error with template parameter packs.

If require_all_args, we aren't waiting for more args to be deduced later.

* pt.c (coerce_template_parms): Do add empty pack when
require_all_args.

From-SVN: r270556

6 years agolibphobos: Fix FAIL phobos.exp/core.time on CentOS 5.11, Linux 2.6.18
Iain Buclaw [Wed, 24 Apr 2019 18:57:36 +0000 (18:57 +0000)] 
libphobos: Fix FAIL phobos.exp/core.time on CentOS 5.11, Linux 2.6.18

Merges upstream druntime e03164b5.

Reviewed-on: https://github.com/dlang/druntime/pull/2581

libphobos/ChangeLog:

2019-04-24  Iain Buclaw  <ibuclaw@gdcproject.org>

PR d/89432
* testsuite/lib/libphobos.exp (check_effective_target_linux_pre_2639):
New proc.
* testsuite/libphobos.druntime/druntime.exp: Add compiler flag
-fversion=Linux_Pre_2639 if target is linux_pre_2639.
* testsuite/libphobos.druntime_shared/druntime_shared.exp: Likewise.

From-SVN: r270554

6 years agoaix71.h (SUBTARGET_OVERRIDE_OPTIONS): Disable OPTION_MASK_VSX and OPTION_MASK_ALTIVEC...
Clement Chigot [Wed, 24 Apr 2019 18:03:47 +0000 (18:03 +0000)] 
aix71.h (SUBTARGET_OVERRIDE_OPTIONS): Disable OPTION_MASK_VSX and OPTION_MASK_ALTIVEC from rs6000_isa_flags for Go on...

2019-04-24  Clement Chigot  <clement.chigot@atos.net>

        * config/rs6000/aix71.h (SUBTARGET_OVERRIDE_OPTIONS): Disable
        OPTION_MASK_VSX and OPTION_MASK_ALTIVEC from rs6000_isa_flags
        for Go on 32 bit AIX.
        * config/rs6000/aix72.h: Likewise.

From-SVN: r270553

6 years agoUse __and_v<...> instead of __and_<...>::value
Jonathan Wakely [Wed, 24 Apr 2019 16:25:21 +0000 (17:25 +0100)] 
Use __and_v<...> instead of __and_<...>::value

* include/std/any (any::any(ValueType&&)): Use __and_v.
* include/std/numeric (midpoint(T, T, T), midpoint(T*, T*, T*)):
Likewise.

From-SVN: r270552

6 years agoFinish implementing "Treating Unnecessary decay" (P0777R1)
Jonathan Wakely [Wed, 24 Apr 2019 16:25:17 +0000 (17:25 +0100)] 
Finish implementing "Treating Unnecessary decay" (P0777R1)

* include/std/tuple (apply): Use remove_reference_t instead of decay_t
as per P0777R1.
* include/std/type_traits (__result_of_memfun): Use remove_reference
instead of __remove_cvref_t and remove redundant is_same check.
(__inv_unwrap): Use __remove_cvref_t instead of decay_t.

From-SVN: r270551

6 years agore PR target/90193 (asm goto with TLS "m" input operand generates incorrect assembler...
Jakub Jelinek [Wed, 24 Apr 2019 15:49:36 +0000 (17:49 +0200)] 
re PR target/90193 (asm goto with TLS "m" input operand generates incorrect assembler in O1 and O2)

PR target/90193
* rtl.c (classify_insn): Return JUMP_INSN for asm goto.
* emit-rtl.c (try_split): Copy over REG_LABEL_TARGET.

* gcc.target/i386/pr90193.c: New test.

From-SVN: r270550

6 years agoFix basic_string_view typedefs and enforce preconditions
Jonathan Wakely [Wed, 24 Apr 2019 15:17:53 +0000 (16:17 +0100)] 
Fix basic_string_view typedefs and enforce preconditions

The basic_string_view::pointer and basic_string_view::reference typedefs
are supposed to refer to the non-const value type.

In previous standards having traits_type::char_type different to
value_type was simply undefined, but in the C++2a draft it's ill-formed,
as changed by P1148R0. For std::basic_string and iostreams we might
want to only enforce this conditionally for __cplusplus > 201703L but
for std::basic_string_view we don't have backwards compatibility
concerns. Also add assertions to verify the _CharT argument is a
"char-like" type (non-array, trivial, standard layout type).

Also remove the non-standard basic_string_view::_M_check and
basic_string_view::_M_limit member functions, replacing them with
non-member functions that will still exist even if basic_string_view is
specialized by the program.

* include/experimental/string_view (basic_string_view::pointer)
(basic_string_view::reference): Fix to refer to non-const value_type.
* include/bits/basic_string.h (basic_string): Use __sv_check and
__sv_limit instead of basic_string_view::_M_check and
basic_string_view::_M_limit.
* include/std/string_view (__sv_check, __sv_limit): New
helper functions to replace basic_string_view::_M_check and
basic_string_view::_M_limit.
(basic_string_view): Add static assertions to enforce ill-formed
requirement for traits_type::char_type from P1148R0, and to enforce
required properties of char-like types.
(basic_string_view::pointer, basic_string_view::reference): Fix to
refer to non-const value_type.
(basic_string_view::operator[], basic_string_view::at)
(basic_string_view::front, basic_string_view::back)
(basic_string_view::data): Use const_reference and const_pointer
typedefs for return types.
(basic_string_view::_M_check, basic_string_view::_M_limit): Remove.
(hash<wstring_view>): Fix argument_type typedef.
* testsuite/21_strings/basic_string_view/modifiers/remove_prefix/
char/1.cc: Fix expected return type of basic_string_view::data().
* testsuite/21_strings/basic_string_view/modifiers/remove_prefix/
wchar_t/1.cc: Likewise.
* testsuite/21_strings/basic_string_view/modifiers/remove_suffix/
char/1.cc: Likewise.
* testsuite/21_strings/basic_string_view/modifiers/remove_suffix/
wchar_t/1.cc: Likewise.
* testsuite/21_strings/basic_string_view/requirements/traits_neg.cc:
New test.
* testsuite/21_strings/basic_string_view/requirements/typedefs.cc:
Check reference and pointer typedefs.
* testsuite/experimental/string_view/requirements/typedefs.cc:
Likewise.
* testsuite/experimental/string_view/modifiers/remove_prefix/char/1.cc:
Fix expected return type of basic_string_view::data().
* testsuite/experimental/string_view/modifiers/remove_prefix/wchar_t/
1.cc: Likewise.
* testsuite/experimental/string_view/modifiers/remove_suffix/char/1.cc:
Likewise.
* testsuite/experimental/string_view/modifiers/remove_suffix/wchar_t/
1.cc: Likewise.

From-SVN: r270548

6 years agoPR libstdc++/90220 Fix std::any_cast for array types
Jonathan Wakely [Wed, 24 Apr 2019 15:17:43 +0000 (16:17 +0100)] 
PR libstdc++/90220 Fix std::any_cast for array types

Although the std::any constructors use decay_t to determine the type of
the contained value, std::any_cast should use the un-decayed type (and
so always fail for function and array types that decay to pointers).

Using remove_cv_t is correct, because the condition for std::any_cast
to return non-null is operand.type() == typeid(T) and typeid ignores
top-level cv-qualifiers.

PR libstdc++/90220
* include/std/any (__any_caster): Use remove_cv_t instead of decay_t.
Avoid a runtime check for types that can never be stored in std::any.
* testsuite/20_util/any/misc/any_cast.cc: Test std::any_cast with
array types.

From-SVN: r270547

6 years agolibphobos: Skip curl tests if libcurl is not installed on the target.
Iain Buclaw [Wed, 24 Apr 2019 14:17:34 +0000 (14:17 +0000)] 
libphobos: Skip curl tests if libcurl is not installed on the target.

libphobos/ChangeLog:

2019-04-24  Iain Buclaw  <ibuclaw@gdcproject.org>

PR d/88654
* testsuite/lib/libphobos.exp (libphobos-dg-test): Check
libphobos_skipped_test_p before running test.
(libphobos-dg-prune): New proc.
(libphobos_init): Set libphobos_skip_tests.
(libphobos_skipped_test_p): New proc.
(check_effective_target_libcurl_available): New proc.
* testsuite/libphobos.phobos/phobos.exp: Skip curl tests if library
not found.
* testsuite/libphobos.phobos_shared/phobos_shared.exp: Likewise.

From-SVN: r270545

6 years agoS/390: Fix PR89952 incorrect CFI
Andreas Krebbel [Wed, 24 Apr 2019 13:40:38 +0000 (13:40 +0000)] 
S/390: Fix PR89952 incorrect CFI

This patch fixes a cases where inconsistent CFI is generated.

After restoring the hard frame pointer (r11) from an FPR we have to
set the CFA register.  In order to be able to set it back to the stack
pointer (r15) we have to make sure that r15 has been restored already.

The patch also adds a scheduler dependency to prevent the instruction
scheduler from swapping the r11 and r15 restore again.

gcc/ChangeLog:

2019-04-24  Andreas Krebbel  <krebbel@linux.ibm.com>

PR target/89952
* config/s390/s390.c (s390_restore_gprs_from_fprs): Restore GPRs
     from FPRs in reverse order.  Generate REG_CFA_DEF_CFA note also
     for restored hard frame pointer.
(s390_sched_dependencies_evaluation): Implement new target hook.
(TARGET_SCHED_DEPENDENCIES_EVALUATION_HOOK): New macro definition.

gcc/testsuite/ChangeLog:

2019-04-24  Andreas Krebbel  <krebbel@linux.ibm.com>

PR target/89952
* gcc.target/s390/pr89952.c: New test.

From-SVN: r270544

6 years agore PR target/89093 (C++ exception handling clobbers d8 VFP register)
Ian Lance Taylor [Wed, 24 Apr 2019 12:45:45 +0000 (12:45 +0000)] 
re PR target/89093 (C++ exception handling clobbers d8 VFP register)

PR target/89093
    runtime: mark unwind functions general-regs-only on ARM

    For https://gcc.gnu.org/PR89093.

    Change-Id: Ic426b43d633c77104bda01d4e7835bc9ab4695ef
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/173657
Reviewed-by: Ian Lance Taylor <iant@golang.org>
From-SVN: r270542

6 years agolibphobos: Fix assert in core.sys.posix.sys.stat for aarch64/ilp32.
Iain Buclaw [Wed, 24 Apr 2019 11:04:22 +0000 (11:04 +0000)] 
libphobos: Fix assert in core.sys.posix.sys.stat for aarch64/ilp32.

Merges upstream druntime 51365217.

Reviewed-on: https://github.com/dlang/druntime/pull/2579

From-SVN: r270541

6 years ago[ARC][COMMITTED] Fix typos.
Claudiu Zissulescu [Wed, 24 Apr 2019 10:15:47 +0000 (12:15 +0200)] 
[ARC][COMMITTED] Fix typos.

gcc/
xxxx-xx-xx  Claudiu Zissulescu  <claziss@synopsys.com>

* config/arc/arc-options.def: Fix typos and spelling mistakes.
* config/arc/arc.c (arc_init): Cleanup warning message.
(arc_override_options): Likewise.

From-SVN: r270540

6 years agocall.c (null_ptr_cst_p): Order checks according to expensiveness.
Richard Biener [Wed, 24 Apr 2019 10:08:07 +0000 (10:08 +0000)] 
call.c (null_ptr_cst_p): Order checks according to expensiveness.

2019-04-24  Richard Biener  <rguenther@suse.de>

cp/
* call.c (null_ptr_cst_p): Order checks according to expensiveness.
(conversion_null_warnings): Likewise.
* typeck.c (same_type_ignoring_top_level_qualifiers_p): Return
early if type1 == type2.

From-SVN: r270539

6 years agoPR libstdc++/90220 Fix std::any_cast for function pointers
Jonathan Wakely [Wed, 24 Apr 2019 09:46:07 +0000 (10:46 +0100)] 
PR libstdc++/90220 Fix std::any_cast for function pointers

PR libstdc++/90220 (partial)
* include/std/any (any_cast<T>(any*), any_cast<T>(const any*)): Do
not attempt ill-formed static_cast to pointers to non-object types.
* testsuite/20_util/any/misc/any_cast.cc: Test std::any_cast with
function types.

From-SVN: r270538

6 years agore PR target/90187 (ICE in extract_insn, at recog.c:2304 x86_64)
Jakub Jelinek [Wed, 24 Apr 2019 09:27:14 +0000 (11:27 +0200)] 
re PR target/90187 (ICE in extract_insn, at recog.c:2304 x86_64)

PR target/90187
* config/i386/i386.c (ix86_expand_sse_fp_minmax): Force if_true into
a register if both if_true and if_false are MEMs.

* g++.target/i386/pr90187.C: New test.

From-SVN: r270537

6 years agod/dmd: Merge upstream dmd 423758078
Iain Buclaw [Wed, 24 Apr 2019 09:15:59 +0000 (09:15 +0000)] 
d/dmd: Merge upstream dmd 423758078

Fixes another failing test to pass on BigEndian.

Initial patch by Robin Dapp.

Reviewed-on: https://github.com/dlang/dmd/pull/9684

gcc/testsuite/ChangeLog:

2019-04-24  Iain Buclaw  <ibuclaw@gdcproject.org>

* gdc.test/README.gcc: New file.

From-SVN: r270536

6 years agore PR target/89093 (C++ exception handling clobbers d8 VFP register)
Ramana Radhakrishnan [Wed, 24 Apr 2019 08:16:07 +0000 (08:16 +0000)] 
re PR target/89093 (C++ exception handling clobbers d8 VFP register)

PR target/89093
* raise-gcc.c (TARGET_ATTRIBUTE): Define.
(continue_unwind, personality_body, PERSONALITY_FUNCTION): Add
TARGET_ATTRIBUTE.

Co-Authored-By: Bernd Edlinger <bernd.edlinger@hotmail.de>
Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r270535

6 years agore PR tree-optimization/90208 (error: EH landing pad label)
Jakub Jelinek [Wed, 24 Apr 2019 08:14:50 +0000 (10:14 +0200)] 
re PR tree-optimization/90208 (error: EH landing pad label)

PR tree-optimization/90208
* tree-cfg.c (remove_bb): Move forced labels from removed bbs
after labels of new_bb, not before them.

* gcc.dg/tsan/pr90208-1.c: New test.
* gcc.dg/tsan/pr90208-2.c: New test.

From-SVN: r270534

6 years agore PR tree-optimization/90211 (ICE: tree check: expected ssa_name, have real_cst...
Jakub Jelinek [Wed, 24 Apr 2019 08:13:29 +0000 (10:13 +0200)] 
re PR tree-optimization/90211 (ICE: tree check: expected ssa_name, have real_cst in first_readonly_imm_use, at ssa-iterators.h:351)

PR tree-optimization/90211
* tree-parloops.c (try_create_reduction_list): Ignore phi arguments
which are not SSA_NAMEs.

* gcc.dg/autopar/pr90211.c: New test.

From-SVN: r270533

6 years agolibphobos: Fix link build errors when compiling with unsupported options
Iain Buclaw [Wed, 24 Apr 2019 02:04:04 +0000 (02:04 +0000)] 
libphobos: Fix link build errors when compiling with unsupported options

The first compilation test to get baseline warnings was getting more
messages due to a missing object.d file, compared to later configure
tests where libphobos is in the include paths.

Because there must always be an object module during compilation, let
the tests themselves be an empty object module instead.

libphobos/ChangeLog:

2019-04-24  Iain Buclaw  <ibuclaw@gdcproject.org>

PR d/88431
* configure: Regenerate.
* m4/libtool.m4 (lt_simple_compile_test_code): Update to not have
dependencies on libphobos.
(lt_simple_link_test_code): Likewise.
(GDCFLAGS): Don't override for D compiler tests.

From-SVN: r270531

6 years agoDaily bump.
GCC Administrator [Wed, 24 Apr 2019 00:16:17 +0000 (00:16 +0000)] 
Daily bump.

From-SVN: r270530

6 years agoAvoid -Wcatch-value warning in testsuite
Jonathan Wakely [Tue, 23 Apr 2019 23:17:52 +0000 (00:17 +0100)] 
Avoid -Wcatch-value warning in testsuite

* testsuite/20_util/variant/run.cc: Catch exception by reference to
prevent -Wcatch-value warning.

From-SVN: r270527

6 years agoFix whitespace in ChangeLog
Jonathan Wakely [Tue, 23 Apr 2019 23:01:35 +0000 (00:01 +0100)] 
Fix whitespace in ChangeLog

From-SVN: r270526

6 years agoImplement LWG 2904 for std::variant assignment
Jonathan Wakely [Tue, 23 Apr 2019 23:01:12 +0000 (00:01 +0100)] 
Implement LWG 2904 for std::variant assignment

* include/std/variant (__variant_construct): Use template parameter
type instead of equivalent decltype-specifier.
(_Move_ctor_base<false, Types...>::_Move_ctor_base(_Move_ctor_base&&)):
Replace forward with move.
(_Move_ctor_base<false, Types...>::_M_destructive_move)
(_Move_ctor_base<false, Types...>::_M_destructive_copy)
(_Move_ctor_base<true, Types...>::_M_destructive_move)
(_Move_ctor_base<true, Types...>::_M_destructive_copy): Only set the
index after construction succeeds.
(_Copy_assign_base<false, Types...>::operator=): Remove redundant
if-constexpr checks that are always true. Use __remove_cvref_t instead
of remove_reference so that is_nothrow_move_constructible check
doesn't use a const rvalue parameter. In the potentially-throwing case
construct a temporary and move assign it, as per LWG 2904.
(_Move_assign_base<false, Types...>::operator=): Remove redundant
if-constexpr checks that are always true. Use emplace as per LWG 2904.
(variant::operator=(T&&)): Only use emplace conditionally, otherwise
construct a temporary and move assign from it, as per LWG 2904.
* testsuite/20_util/variant/exception_safety.cc: Check that
assignment operators have strong exception safety guarantee.

From-SVN: r270525

6 years agolibphobos: Add AArch64 Linux as a supported target.
Iain Buclaw [Tue, 23 Apr 2019 22:53:35 +0000 (22:53 +0000)] 
libphobos: Add AArch64 Linux as a supported target.

libphobos/ChangeLog:

2019-04-24  Iain Buclaw  <ibuclaw@gdcproject.org>

* configure.tgt: Add aarch64*-*-linux* as a supported target.

From-SVN: r270524

6 years agolibphobos: Add D support for S/390 Linux
Iain Buclaw [Tue, 23 Apr 2019 22:53:25 +0000 (22:53 +0000)] 
libphobos: Add D support for S/390 Linux

gcc/d/ChangeLog:

2019-04-23  Iain Buclaw  <ibuclaw@gdcproject.org>
    Robin Dapp  <rdapp@linux.ibm.com>

* typeinfo.cc (create_typeinfo): Write typeinfo flags as uint.

gcc/testsuite/ChangeLog:

2019-04-23  Iain Buclaw  <ibuclaw@gdcproject.org>
    Robin Dapp  <rdapp@linux.ibm.com>

* gdc.dg/link.d: Test if target d_runtime.
* gdc.dg/runnable.d: Fix tests to work on BigEndian.
* gdc.dg/simd.d: Likewise.

libphobos/ChangeLog:

2019-04-23  Iain Buclaw  <ibuclaw@gdcproject.org>
    Robin Dapp  <rdapp@linux.ibm.com>

* configure.tgt: Add s390*-linux* as a supported target.
* libdruntime/gcc/sections/elf_shared.d: import gcc.builtins.
(__tls_get_addr_internal): Declare.
(TLS_DTV_OFFSET): Define as zero on SystemZ.
(getTLSRange): Support getting TLS on SystemZ.
* testsuite/libphobos.typeinfo/struct-align.d: New test.

Co-Authored-By: Robin Dapp <rdapp@linux.ibm.com>
From-SVN: r270523

6 years agolibphobos: Add D support for RISC-V Linux
Iain Buclaw [Tue, 23 Apr 2019 22:53:12 +0000 (22:53 +0000)] 
libphobos: Add D support for RISC-V Linux

2019-04-23  Iain Buclaw  <ibuclaw@gdcproject.org>

* configure.tgt: Add riscv*-*-linux* as supported target.
* libdruntime/gcc/sections/elf_shared.d (getDependencies): Adjust
dlpi_addr on RISCV32 and RISCV64.
* src/std/math.d: Add IEEE FPU control support for RISCV.

From-SVN: r270522

6 years agoDocument PSTL linker flags
Thomas Rodgers [Tue, 23 Apr 2019 21:03:24 +0000 (21:03 +0000)] 
Document PSTL linker flags

* doc/xml/manual/using.xml: Add PSTL linker flags to table
        3.1.

From-SVN: r270521

6 years agoUpdate .po files.
Joseph Myers [Tue, 23 Apr 2019 21:03:01 +0000 (22:03 +0100)] 
Update .po files.

* be.po, da.po, de.po, el.po, fi.po, fr.po, hr.po, id.po, ja.po,
nl.po, ru.po, sr.po, sv.po, tr.po, uk.po, vi.po, zh_CN.po,
zh_TW.po: Update.

From-SVN: r270520

6 years agod: Add support for compiling without libphobos library.
Iain Buclaw [Tue, 23 Apr 2019 20:08:46 +0000 (20:08 +0000)] 
d: Add support for compiling without libphobos library.

Merges upstream dmd 3b3dca8be

Reviewed-on: https://github.com/dlang/dmd/pull/9678

gcc/d/ChangeLog:

2019-04-23  Iain Buclaw  <ibuclaw@gdcproject.org>

* d-builtins.cc (d_init_versions): Add D_BetterC, D_ModuleInfo,
D_Exceptions, D_TypeInfo as predefined version conditions.
* d-codegen.cc (build_bounds_condition): Generate trap if D asserts
are turned off.
* d-frontend.cc (getTypeInfoType): Add error when -fno-rtti is set.
* d-lang.cc (d_init_options): Initialize new front-end options.
(d_handle_option): Handle -fdruntime, -fexceptions, and -frtti.
(d_post_options): Turn off D runtime features if -fno-druntime is set.
* d-spec.cc (lang_specific_driver): Handle -fdruntime.
* d-tree.h (have_typeinfo_p): Add prototype.
(build_typeinfo): Update prototype.
* decl.cc (DeclVisitor::visit(StructDeclaration)): Create typeinfo
only if TypeInfo exists.
(DeclVisitor::visit(ClassDeclaration)): Likewise.
(DeclVisitor::visit(InterfaceDeclaration)): Likewise.
(DeclVisitor::visit(EnumDeclaration)): Likewise.
* expr.cc: Update all calls to build_typeinfo.
* gdc.texi (Runtime Options): Document -fdruntime and -frtti.
* lang.opt: Add -fdruntime and -frtti.
* modules.cc (build_module_tree): Create module info only if
ModuleInfo exists.
* toir.cc (IRVisitor::visit(ThrowStatement)): Update test for
-fno-exceptions.
* typeinfo.cc (create_tinfo_types): Build internal typeinfo classes
only if Object exists.
(have_typeinfo_p): New function.
(class TypeInfoVisitor): Update all calls to build_typeinfo.
(build_typeinfo): Add error when -fno-rtti is set.

gcc/testsuite/ChangeLog:

2019-04-23  Iain Buclaw  <ibuclaw@gdcproject.org>

* gdc.test/fail_compilation/fail2456.d: New test.
* gdc.test/fail_compilation/test18312.d: New test.
* gdc.test/gdc-test.exp (gdc-convert-args): Handle -betterC.

From-SVN: r270518