]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
4 years agoamdgcn: Allow V64DFmode min/max reductions
Andrew Stubbs [Mon, 9 Nov 2020 17:42:34 +0000 (17:42 +0000)] 
amdgcn: Allow V64DFmode min/max reductions

I don't know why these were disabled. There're no direct min/max DPP
instructions for this mode, but the "use moves" strategy works fine.

gcc/ChangeLog:

* config/gcn/gcn.c (gcn_expand_reduc_scalar): Use move instructions
for V64DFmode min/max reductions.

Backport from d9f50366102a8ca3521e4854f7716bd013c8ea0a.

4 years agoopenmp: Fix intermittent hanging of task-detach-6 libgomp tests [PR98738]
Kwok Cheung Yeung [Thu, 21 Jan 2021 13:38:47 +0000 (05:38 -0800)] 
openmp: Fix intermittent hanging of task-detach-6 libgomp tests [PR98738]

This adds support for the task detach clause to taskwait, and fixes a
number of problems related to semaphores that may lead to a hang in
some circumstances.

2021-01-21  Kwok Cheung Yeung  <kcy@codesourcery.com>

libgomp/

PR libgomp/98738
* libgomp.h (enum gomp_task_kind): Add GOMP_TASK_DETACHED.
* task.c (task_fulfilled_p): Check detach field as well.
(GOMP_task): Add thread to debug messages.  Use address of task as
the event handle.
(gomp_barrier_handle_tasks): Fix indentation.  Use address of task
as event handle. Set kind of suspended detach task to
GOMP_TASK_DETACHED and decrement task_running_count.  Move
finish_cancelled block out of else branch.  Skip decrement of
task_running_count if task kind is GOMP_TASK_DETACHED.
(GOMP_taskwait): Finish fulfilled detach tasks.  Update comment.
Queue detach tasks that have not been fulfilled.
(omp_fulfill_event): Use address of task as event handle.  Post
to taskwait_sem and taskgroup_sem if necessary.  Check
task_running_count before calling gomp_team_barrier_wake.
* testsuite/libgomp.c-c++-common/task-detach-5.c (main): Change
data-sharing of detach events on enclosing parallel to private.
* testsuite/libgomp.c-c++-common/task-detach-6.c (main): Likewise.
* testsuite/libgomp.fortran/task-detach-5.f90 (task_detach_5):
Likewise.
* testsuite/libgomp.fortran/task-detach-6.f90 (task_detach_6):
Likewise.

4 years agolibgomp: Fix up GOMP_task on s390x
Jakub Jelinek [Wed, 20 Jan 2021 21:09:22 +0000 (22:09 +0100)] 
libgomp: Fix up GOMP_task on s390x

On Wed, Jan 20, 2021 at 05:04:39PM +0100, Florian Weimer wrote:
> Sorry, this appears to cause OpenMP task state corruption in RPM.  We
> have only seen this on s390x.

Haven't actually verified it, but my suspection is that this is a caller
stack corruption.

We play with fire with the GOMP_task API/ABI extensions, the GOMP_task
function used to be:
void
GOMP_task (void (*fn) (void *), void *data, void (*cpyfn) (void *, void *),
           long arg_size, long arg_align, bool if_clause, unsigned flags);
and later:
void
GOMP_task (void (*fn) (void *), void *data, void (*cpyfn) (void *, void *),
           long arg_size, long arg_align, bool if_clause, unsigned flags,
           void **depend);
and later:
void
GOMP_task (void (*fn) (void *), void *data, void (*cpyfn) (void *, void *),
           long arg_size, long arg_align, bool if_clause, unsigned flags,
           void **depend, int priority);
and now:
void
GOMP_task (void (*fn) (void *), void *data, void (*cpyfn) (void *, void *),
           long arg_size, long arg_align, bool if_clause, unsigned flags,
           void **depend, int priority, void *detach)
and which of those depend, priority and detach argument is present depends
on the bits in flags.
I'm afraid the compiler just decided to spill the detach = NULL store in
  if ((flags & GOMP_TASK_FLAG_DETACH) == 0)
    detach = NULL;
on s390x into the argument stack slot.  Not a problem if the caller passes
all those 10 arguments, but if not, can clobber random stack location.

This hack should fix it up.  Priority doesn't need changing, but I've
changed it anyway just to be safe.  With the patch none of the 3 arguments
are ever modified, so I'd hope gcc doesn't decide to spill something
unrelated there.

2021-01-20  Jakub Jelinek  <jakub@redhat.com>

* task.c (GOMP_task): Rename priority argument to priority_arg,
add priority automatic variable and modify that variable.  Instead of
clearing detach argument when GOMP_TASK_FLAG_DETACH bit is not set,
check flags for that bit.

(cherry picked from commit 0bb27b81a762d3c607bd25409337c749f836c0cd)

4 years agoFix gfortran.dg/gomp/task-detach-1.f90 for non 64bit pointers
Tobias Burnus [Wed, 20 Jan 2021 10:27:26 +0000 (11:27 +0100)] 
Fix gfortran.dg/gomp/task-detach-1.f90 for non 64bit pointers

gcc/testsuite/ChangeLog:

PR fortran/98763
* gfortran.dg/gomp/task-detach-1.f90: Use integer(1) to avoid
missing diagnostic issues with c_intptr_t == default integer kind.

(cherry picked from commit a95538b6c5a9ea480e341da9ca8fbf201417dba5)

4 years agoopenmp: Don't ICE on detach clause with erroneous decl [PR98742]
Jakub Jelinek [Wed, 20 Jan 2021 07:35:20 +0000 (08:35 +0100)] 
openmp: Don't ICE on detach clause with erroneous decl [PR98742]

Similarly to how we handle erroneous operands to e.g. allocate clause,
this change just removes those clauses instead of accessing TYPE_MAIN_VARIANT
of its type, which doesn't work on error_mark_node.  Also, just for good
measure, bails out if TYPE_NAME is NULL.

2021-01-20  Jakub Jelinek  <jakub@redhat.com>

PR c++/98742
* semantics.c (finish_omp_clauses) <case OMP_CLAUSE_DETACH>: If
error_operand_p, remove clause without further checking.  Check
for non-NULL TYPE_NAME.

* c-c++-common/gomp/task-detach-2.c: New test.

(cherry picked from commit 7ab1abf3b82a3bcfff9b7bc596166fef6a0d83ab)

4 years agoopenmp: Don't optimize shared to firstprivate on task with depend clause
Jakub Jelinek [Fri, 18 Dec 2020 20:43:20 +0000 (21:43 +0100)] 
openmp: Don't optimize shared to firstprivate on task with depend clause

The attached testcase is miscompiled, because we optimize shared clauses
to firstprivate when task body can't modify the variable even when the
task has depend clause.  That is wrong, because firstprivate means the
variable will be copied immediately when the task is created, while with
depend clause some other task might change it later before the dependencies
are satisfied and the task should observe the value only after the change.

2020-12-18  Jakub Jelinek  <jakub@redhat.com>

* gimplify.c (struct gimplify_omp_ctx): Add has_depend member.
(gimplify_scan_omp_clauses): Set it to true if OMP_CLAUSE_DEPEND
appears on OMP_TASK.
(gimplify_adjust_omp_clauses_1, gimplify_adjust_omp_clauses): Force
GOVD_WRITTEN on shared variables if task construct has depend clause.

* testsuite/libgomp.c/task-6.c: New test.

(cherry picked from commit 8b60459465252c7d47b58abf83fae2aa84915b03)

4 years agoRTEMS: Fix libgomp build
Sebastian Huber [Mon, 18 Jan 2021 06:23:46 +0000 (07:23 +0100)] 
RTEMS: Fix libgomp build

libgomp/

* config/rtems/sem.h (gomp_sem_getcount): New function.

(cherry picked from commit 0f951b3dd34b355579b4c9a9e287d32ac771bc67)

4 years agolibgomp: Don't access gomp_sem_t as int using atomics unconditionally
Jakub Jelinek [Mon, 18 Jan 2021 06:18:46 +0000 (07:18 +0100)] 
libgomp: Don't access gomp_sem_t as int using atomics unconditionally

This patch introduces gomp_sem_getcount wrapper, which uses sem_getvalue
for POSIX and atomic loads for linux futex and accel.  rtems for now
remains broken.

2021-01-18  Jakub Jelinek  <jakub@redhat.com>

* config/linux/sem.h (gomp_sem_getcount): New function.
* config/posix/sem.h (gomp_sem_getcount): New function.
* config/posix/sem.c (gomp_sem_getcount): New function.
* config/accel/sem.h (gomp_sem_getcount): New function.
* task.c (task_fulfilled_p): Use gomp_sem_getcount.
(omp_fulfill_event): Likewise.

(cherry picked from commit d3b41bde961713ff4af7e18011126434c497edba)

4 years agoopenmp: Add support for the OpenMP 5.0 task detach clause
Kwok Cheung Yeung [Sat, 16 Jan 2021 20:58:13 +0000 (12:58 -0800)] 
openmp: Add support for the OpenMP 5.0 task detach clause

2021-01-16  Kwok Cheung Yeung  <kcy@codesourcery.com>

gcc/
* builtin-types.def
(BT_FN_VOID_OMPFN_PTR_OMPCPYFN_LONG_LONG_BOOL_UINT_PTR_INT): Rename
to...
(BT_FN_VOID_OMPFN_PTR_OMPCPYFN_LONG_LONG_BOOL_UINT_PTR_INT_PTR):
...this.  Add extra argument.
* gimplify.c (omp_default_clause): Ensure that event handle is
firstprivate in a task region.
(gimplify_scan_omp_clauses): Handle OMP_CLAUSE_DETACH.
(gimplify_adjust_omp_clauses): Likewise.
* omp-builtins.def (BUILT_IN_GOMP_TASK): Change function type to
BT_FN_VOID_OMPFN_PTR_OMPCPYFN_LONG_LONG_BOOL_UINT_PTR_INT_PTR.
* omp-expand.c (expand_task_call): Add GOMP_TASK_FLAG_DETACH to flags
if detach clause specified.  Add detach argument when generating
call to GOMP_task.
* omp-low.c (scan_sharing_clauses): Setup data environment for detach
clause.
(finish_taskreg_scan): Move field for variable containing the event
handle to the front of the struct.
* tree-core.h (enum omp_clause_code): Add OMP_CLAUSE_DETACH.  Fix
ordering.
* tree-nested.c (convert_nonlocal_omp_clauses): Handle
OMP_CLAUSE_DETACH clause.
(convert_local_omp_clauses): Handle OMP_CLAUSE_DETACH clause.
* tree-pretty-print.c (dump_omp_clause): Handle OMP_CLAUSE_DETACH.
* tree.c (omp_clause_num_ops): Add entry for OMP_CLAUSE_DETACH.
Fix ordering.
(omp_clause_code_name): Add entry for OMP_CLAUSE_DETACH.  Fix
ordering.
(walk_tree_1): Handle OMP_CLAUSE_DETACH.

gcc/c-family/
* c-pragma.h (pragma_omp_clause): Add PRAGMA_OMP_CLAUSE_DETACH.
Redefine PRAGMA_OACC_CLAUSE_DETACH.

gcc/c/
* c-parser.c (c_parser_omp_clause_detach): New.
(c_parser_omp_all_clauses): Handle PRAGMA_OMP_CLAUSE_DETACH clause.
(OMP_TASK_CLAUSE_MASK): Add mask for PRAGMA_OMP_CLAUSE_DETACH.
* c-typeck.c (c_finish_omp_clauses): Handle PRAGMA_OMP_CLAUSE_DETACH
clause.  Prevent use of detach with mergeable and overriding the
data sharing mode of the event handle.

gcc/cp/
* parser.c (cp_parser_omp_clause_detach): New.
(cp_parser_omp_all_clauses): Handle PRAGMA_OMP_CLAUSE_DETACH.
(OMP_TASK_CLAUSE_MASK): Add mask for PRAGMA_OMP_CLAUSE_DETACH.
* pt.c (tsubst_omp_clauses): Handle OMP_CLAUSE_DETACH clause.
* semantics.c (finish_omp_clauses): Handle OMP_CLAUSE_DETACH clause.
Prevent use of detach with mergeable and overriding the data sharing
mode of the event handle.

gcc/fortran/
* dump-parse-tree.c (show_omp_clauses): Handle detach clause.
* frontend-passes.c (gfc_code_walker): Walk detach expression.
* gfortran.h (struct gfc_omp_clauses): Add detach field.
(gfc_c_intptr_kind): New.
* openmp.c (gfc_free_omp_clauses): Free detach clause.
(gfc_match_omp_detach): New.
(enum omp_mask1): Add OMP_CLAUSE_DETACH.
(enum omp_mask2): Remove OMP_CLAUSE_DETACH.
(gfc_match_omp_clauses): Handle OMP_CLAUSE_DETACH for OpenMP.
(OMP_TASK_CLAUSES): Add OMP_CLAUSE_DETACH.
(resolve_omp_clauses): Prevent use of detach with mergeable and
overriding the data sharing mode of the event handle.
* trans-openmp.c (gfc_trans_omp_clauses): Handle detach clause.
* trans-types.c (gfc_c_intptr_kind): New.
(gfc_init_kinds): Initialize gfc_c_intptr_kind.
* types.def
(BT_FN_VOID_OMPFN_PTR_OMPCPYFN_LONG_LONG_BOOL_UINT_PTR_INT): Rename
to...
(BT_FN_VOID_OMPFN_PTR_OMPCPYFN_LONG_LONG_BOOL_UINT_PTR_INT_PTR):
...this.  Add extra argument.

gcc/testsuite/
* c-c++-common/gomp/task-detach-1.c: New.
* g++.dg/gomp/task-detach-1.C: New.
* gcc.dg/gomp/task-detach-1.c: New.
* gfortran.dg/gomp/task-detach-1.f90: New.

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

libgomp/
* fortran.c (omp_fulfill_event_): New.
* libgomp.h (struct gomp_task): Add detach and completion_sem fields.
(struct gomp_team): Add task_detach_queue and task_detach_count
fields.
* libgomp.map (OMP_5.0.1): Add omp_fulfill_event and omp_fulfill_event_.
* libgomp_g.h (GOMP_task): Add extra argument.
* omp.h.in (enum omp_event_handle_t): New.
(omp_fulfill_event): New.
* omp_lib.f90.in (omp_event_handle_kind): New.
(omp_fulfill_event): New.
* omp_lib.h.in (omp_event_handle_kind): New.
(omp_fulfill_event): Declare.
* priority_queue.c (priority_tree_find): New.
(priority_list_find): New.
(priority_queue_find): New.
* priority_queue.h (priority_queue_predicate): New.
(priority_queue_find): New.
* task.c (gomp_init_task): Initialize detach field.
(task_fulfilled_p): New.
(GOMP_task): Add detach argument.  Ignore detach argument if
GOMP_TASK_FLAG_DETACH not set in flags.  Initialize completion_sem
field. Copy address of completion_sem into detach argument and
into the start of the data record.  Wait for detach event if task
not deferred.
(gomp_barrier_handle_tasks): Queue tasks with unfulfilled events.
Remove completed tasks and requeue dependent tasks.
(omp_fulfill_event): New.
* team.c (gomp_new_team): Initialize task_detach_queue and
task_detach_count fields.
(free_team): Free task_detach_queue field.
* testsuite/libgomp.c-c++-common/task-detach-1.c: New testcase.
* testsuite/libgomp.c-c++-common/task-detach-2.c: New testcase.
* testsuite/libgomp.c-c++-common/task-detach-3.c: New testcase.
* testsuite/libgomp.c-c++-common/task-detach-4.c: New testcase.
* testsuite/libgomp.c-c++-common/task-detach-5.c: New testcase.
* testsuite/libgomp.c-c++-common/task-detach-6.c: New testcase.
* testsuite/libgomp.fortran/task-detach-1.f90: New testcase.
* testsuite/libgomp.fortran/task-detach-2.f90: New testcase.
* testsuite/libgomp.fortran/task-detach-3.f90: New testcase.
* testsuite/libgomp.fortran/task-detach-4.f90: New testcase.
* testsuite/libgomp.fortran/task-detach-5.f90: New testcase.
* testsuite/libgomp.fortran/task-detach-6.f90: New testcase.

(cherry picked from commit a6d22fb21c6f1ad7e8b6b722bfc0e7e11f50cb92)

4 years agoTarget mapping C++ members inside member functions
Chung-Lin Tang [Thu, 21 Jan 2021 15:04:26 +0000 (23:04 +0800)] 
Target mapping C++ members inside member functions

This is a merge of:
https://gcc.gnu.org/pipermail/gcc-patches/2020-December/562467.html

This patch fixes some problems with target mapping when inside
C++ member functions:

1. Allow deref '->' in map clauses.
2. Allow this[X] in map clauses.
3. Create map(this->member) from map(member), when encountering
   member's FIELD_DECL.

This may possibly reverted/updated when a final patch is approved
for mainline.

gcc/cp/ChangeLog:
* parser.c (cp_parser_omp_clause_map): Adjust call to
cp_parser_omp_var_list_no_open to set 'allow_deref' argument to true.
* semantics.c (handle_omp_array_sections_1): Add handling to create
'this->member' from 'member' FIELD_DECL.
(finish_omp_clauses): Likewise. Adjust to allow 'this[]' in OpenMP
map clauses.

gcc/testsuite/ChangeLog:
* g++.dg/gomp/target-3.C: New test.
* g++.dg/gomp/this-2.C: Adjust testcase.

4 years agoCorrect fix offload dwarf info
Andrew Stubbs [Sat, 16 Jan 2021 15:18:07 +0000 (15:18 +0000)] 
Correct fix offload dwarf info

The previous patch wasn't quite right, apparently.  Somehow the behaviour
changed after another clean build?  This tweak fixes it.

This patch should be squashed with fdcb23540a2 to go to mainline.

gcc/ChangeLog:

* dwarf2out.c (gen_subprogram_die): Check offload attributes only.

4 years agoDWARF address space for variables
Andrew Stubbs [Fri, 15 Jan 2021 11:26:46 +0000 (11:26 +0000)] 
DWARF address space for variables

Add DWARF address class attributes for variables that exist outside the
generic address space.  In particular, this is the case for gang-private
variables in OpenACC offload kernels.

gcc/ChangeLog:

* dwarf2out.c (add_location_or_const_value_attribute): Set
DW_AT_address_class, if appropriate.

4 years agoamdgcn: DWARF address spaces
Andrew Stubbs [Wed, 7 Oct 2020 13:15:22 +0000 (14:15 +0100)] 
amdgcn: DWARF address spaces

Map GCN address spaces to the proposed DWARF address spaces defined by AMD.

gcc/ChangeLog:

* config/gcn/gcn.c: Include dwarf2.h.
(gcn_addr_space_debug): New function.
(TARGET_ADDR_SPACE_DEBUG): New hook.

4 years agoamdgcn: Fix DWARF variables with alloca
Andrew Stubbs [Fri, 8 Jan 2021 13:56:52 +0000 (13:56 +0000)] 
amdgcn: Fix DWARF variables with alloca

Require a frame pointer for entry functions that use alloca because it isn't
possible to encode the DWARF frame otherwise.  Adjust the CFA definition
expressions accordingly.

gcc/ChangeLog:

* config/gcn/gcn.c (gcn_expand_prologue): Use the frame pointer for
the DWARF CFA, if it exists.
(gcn_frame_pointer_rqd): Require a frame pointer for entry functions
that use alloca.

4 years agoFix offload dwarf info
Andrew Stubbs [Sun, 6 Dec 2020 19:23:55 +0000 (19:23 +0000)] 
Fix offload dwarf info

Add a notional code range to the notional parent function of offload kernel
functions.  This is enough to prevent GDB discarding them.

gcc/ChangeLog:

* dwarf2out.c (gen_subprogram_die): Add high/low_pc attributes for
parents of offload kernels.

4 years ago[og10] vect: Add target hook to prefer gather/scatter instructions
Julian Brown [Wed, 25 Nov 2020 17:08:01 +0000 (09:08 -0800)] 
[og10] vect: Add target hook to prefer gather/scatter instructions

For AMD GCN, the instructions available for loading/storing vectors are
always scatter/gather operations (i.e. there are separate addresses for
each vector lane), so the current heuristic to avoid gather/scatter
operations with too many elements in get_group_load_store_type is
counterproductive. Avoiding such operations in that function can
subsequently lead to a missed vectorization opportunity whereby later
analyses in the vectorizer try to use a very wide array type which is
not available on this target, and thus it bails out.

The attached patch adds a target hook to override the "single_element_p"
heuristic in the function as a target hook, and activates it for GCN. This
allows much better code to be generated for affected loops.

2021-01-13  Julian Brown  <julian@codesourcery.com>

gcc/
* doc/tm.texi.in (TARGET_VECTORIZE_PREFER_GATHER_SCATTER): Add
documentation hook.
* doc/tm.texi: Regenerate.
* target.def (prefer_gather_scatter): Add target hook under vectorizer.
* tree-vect-stmts.c (get_group_load_store_type): Optionally prefer
gather/scatter instructions to scalar/elementwise fallback.
* config/gcn/gcn.c (TARGET_VECTORIZE_PREFER_GATHER_SCATTER): Define
hook.

4 years ago[og10] openacc: Adjust loop lowering for AMD GCN
Julian Brown [Fri, 6 Nov 2020 23:17:29 +0000 (15:17 -0800)] 
[og10] openacc: Adjust loop lowering for AMD GCN

This patch adjusts OpenACC loop lowering in the AMD GCN target compiler
in such a way that the autovectorizer can vectorize the "vector" dimension
of those loops in more cases.

Rather than generating "SIMT" code that executes a scalar instruction
stream for each lane of a vector in lockstep, for GCN we model the GPU
like a typical CPU, with separate instructions to operate on scalar and
vector data. That means that unlike other offload targets, we rely on
the autovectorizer to handle the innermost OpenACC parallelism level,
which is "vector".

Because of this, the OpenACC builtin functions to return the current
vector lane and the vector width return 0 and 1 respectively, despite
the native vector width being 64 elements wide.

This allows generated code to work with our chosen compilation model,
but the way loops are lowered in omp-offload.c:oacc_xform_loop does not
understand the discrepancy between logical (OpenACC) and physical vector
sizes correctly. That means that if a loop is partitioned over e.g. the
worker AND vector dimensions, we actually lower with unit vector size --
meaning that if we then autovectorize, we end up trying to vectorize
over the "worker" dimension rather than the vector one! Then, because
the number of workers is not fixed at compile time, that means the
autovectorizer has a hard time analysing the loop and thus vectorization
often fails entirely.

We can fix this by deducing the true vector width in oacc_xform_loop,
and using that when we are on a "non-SIMT" offload target. We can then
rearrange how loops are lowered in that function so that the loop form
fed to the autovectorizer is more amenable to vectorization -- namely,
the innermost step is set to process each loop iteration sequentially.

For some benchmarks, allowing vectorization to succeed leads to quite
impressive performance improvements -- I've observed between 2.5x and
40x on one machine/GPU combination.

The low-level builtins available to user code (__builtin_goacc_parlevel_id
and __builtin_goacc_parlevel_size) continue to return 0/1 respectively
for the vector dimension for AMD GCN, even if their containing loop is
vectorized -- that's a quirk that we might possibly want to address at
some later date.

Only non-"chunking" loops are handled at present. "Chunking" loops are
still lowered as before.

2021-01-13  Julian Brown  <julian@codesourcery.com>

gcc/
* omp-offload.c (oacc_thread_numbers): Add VF_BY_VECTORIZER parameter.
Add overloaded wrapper for previous arguments & behaviour.
(oacc_xform_loop): Lower vector loops to iterate a multiple of
omp_max_vf times over contiguous steps on non-SIMT targets.

libgomp/testsuite/
* libgomp.oacc-c-c++-common/loop-gwv-1.c: Adjust for loop lowering
changes.
* libgomp.oacc-c-c++-common/loop-wv-1.c: Likewise.
* libgomp.oacc-c-c++-common/loop-red-gwv-1.c: Likewise.
* libgomp.oacc-c-c++-common/loop-red-wv-1.c: Likewise.
* libgomp.oacc-c-c++-common/routine-gwv-1.c: Likewise.
* libgomp.oacc-c-c++-common/routine-wv-1.c: Likewise.

4 years agoamdgcn: Remove dead code for fixed v0 register
Julian Brown [Wed, 25 Nov 2020 00:42:55 +0000 (16:42 -0800)] 
amdgcn: Remove dead code for fixed v0 register

This patch removes code to fix the v0 register in
gcn_conditional_register_usage that was missed out of the previous patch
removing the need for that:

  https://gcc.gnu.org/pipermail/gcc-patches/2019-November/534284.html

Backport from mainline:

2021-01-13  Julian Brown  <julian@codesourcery.com>

gcc/
* config/gcn/gcn.c (gcn_conditional_register_usage): Remove dead code
to fix v0 register.

(cherry picked from commit 7993fe1877a689463d8c71a0873e5cc8db080273)

4 years agoamdgcn: Fix exec register live-on-entry to BB in md-reorg
Julian Brown [Fri, 6 Nov 2020 22:53:29 +0000 (14:53 -0800)] 
amdgcn: Fix exec register live-on-entry to BB in md-reorg

This patch fixes a corner case in the AMD GCN md-reorg pass when the
EXEC register is live on entry to a BB, and could be clobbered by code
inserted by the pass before a use in (e.g.) a different BB.

Backport from mainline:

2021-01-13  Julian Brown  <julian@codesourcery.com>

gcc/
* config/gcn/gcn.c (gcn_md_reorg): Fix case where EXEC reg is live
on entry to a BB.

(cherry picked from commit 3df6fac0080468d1521775e82a5e060f0b1c78ca)

4 years agoamdgcn: Improve FP division accuracy
Julian Brown [Mon, 30 Nov 2020 19:10:04 +0000 (11:10 -0800)] 
amdgcn: Improve FP division accuracy

GCN has a reciprocal-approximation instruction but no
hardware divide. This patch adjusts the open-coded reciprocal
approximation/Newton-Raphson refinement steps to use fused multiply-add
instructions as is necessary to obtain a properly-rounded result, and
adds further refinement steps to correctly round the full division result.

The patterns in question are still guarded by a flag_reciprocal_math
condition, and do not yet support denormals.

Backport from mainline:

2021-01-13  Julian Brown  <julian@codesourcery.com>

gcc/
* config/gcn/gcn-valu.md (recip<mode>2<exec>, recip<mode>2): Use unspec
for reciprocal-approximation instructions.
(div<mode>3): Use fused multiply-accumulate operations for reciprocal
refinement and division result.
* config/gcn/gcn.md (UNSPEC_RCP): New unspec constant.

gcc/testsuite/
* gcc.target/gcn/fpdiv.c: New test.

(cherry picked from commit c8812bac8ee39f73ea881e4f6260acf5590b4190)

4 years agoamdgcn: Fix subdf3 pattern
Julian Brown [Mon, 30 Nov 2020 20:01:37 +0000 (12:01 -0800)] 
amdgcn: Fix subdf3 pattern

This patch fixes a typo in the subdf3 pattern that meant it had a
non-standard name and thus the compiler would emit a libcall rather than
the proper hardware instruction for DFmode subtraction.

Backport from mainline:

2021-01-13  Julian Brown  <julian@codesourcery.com>

gcc/
* config/gcn/gcn-valu.md (subdf): Rename to...
(subdf3): This.

(cherry picked from commit abb3993e49c04bd40e42f196f55785cc3fd81682)

4 years agonvptx: Cache stacks block for OpenMP kernel launch
Julian Brown [Wed, 21 Oct 2020 17:00:19 +0000 (10:00 -0700)] 
nvptx: Cache stacks block for OpenMP kernel launch

2021-01-05  Julian Brown  <julian@codesourcery.com>

libgomp/
* plugin/plugin-nvptx.c (SOFTSTACK_CACHE_LIMIT): New define.
(struct ptx_device): Add omp_stacks struct.
(nvptx_open_device): Initialise cached-stacks housekeeping info.
(nvptx_close_device): Free cached stacks block and mutex.
(nvptx_stacks_free): New function.
(nvptx_alloc): Add SUPPRESS_ERRORS parameter.
(GOMP_OFFLOAD_alloc): Add strategies for freeing soft-stacks block.
(nvptx_stacks_alloc): Rename to...
(nvptx_stacks_acquire): This.  Cache stacks block between runs if same
size or smaller is required.
(nvptx_stacks_free): Remove.
(GOMP_OFFLOAD_run): Call nvptx_stacks_acquire and lock stacks block
during kernel execution.

(cherry picked from commit 6b577a17b26347e78c8b9167f24fc5c9d9724270)

4 years agoFortran: Delay vtab generation until after parsing [PR92587]
Tobias Burnus [Tue, 5 Jan 2021 11:29:09 +0000 (12:29 +0100)] 
Fortran: Delay vtab generation until after parsing [PR92587]

Forward port of GCC 10 commit 6f3f06e431c181d3e51d31f49a2bf0be2944ae93
which is a backport of mainline commit ba9fa684053917a07bfa8f4742da0e196e72b9a2

gcc/fortran/ChangeLog:

PR fortran/92587
* match.c (gfc_match_assignment): Move gfc_find_vtab call from here ...
* resolve.c (gfc_resolve_code): ... to here.

gcc/testsuite/ChangeLog:

PR fortran/92587
* gfortran.dg/finalize_37.f90: New test.

(cherry picked from commit ba9fa684053917a07bfa8f4742da0e196e72b9a2)

4 years agoopenmp: Fix g++.dg/gomp/declare-target-3.C testcase when offloading is disabled
Kwok Cheung Yeung [Fri, 18 Dec 2020 20:05:20 +0000 (12:05 -0800)] 
openmp: Fix g++.dg/gomp/declare-target-3.C testcase when offloading is disabled

This is a backport from mainline of commit
bfb37fa4dd49ee775ae90355464265a2f60c1067.

2020-12-18  Kwok Cheung Yeung  <kcy@codesourcery.com>

gcc/testsuite/
* g++.dg/gomp/declare-target-3.C: Only check .offload_var_table
entries if offloading is enabled.

4 years agoOpenMP: Add implicit declare target for nested procedures
Tobias Burnus [Wed, 30 Sep 2020 12:59:27 +0000 (14:59 +0200)] 
OpenMP: Add implicit declare target for nested procedures

This is a backport from mainline of commit
8b0a63e47cd83f4e8534d0d201739bdd10f321a2.

gcc/ChangeLog:

* omp-offload.c (omp_discover_implicit_declare_target): Also
handled nested functions.

libgomp/ChangeLog:

* testsuite/libgomp.fortran/declare-target-3.f90: New test.

4 years agoopenmp: Implicitly add 'declare target' directives for dynamic initializers in C++
Kwok Cheung Yeung [Fri, 18 Dec 2020 16:26:34 +0000 (08:26 -0800)] 
openmp: Implicitly add 'declare target' directives for dynamic initializers in C++

This is a backport from mainline (commit
3af02d32cce2ff1ff11d078cf8094305f57ca179).

2020-12-18  Kwok Cheung Yeung  <kcy@codesourcery.com>

gcc/
* langhooks-def.h (lhd_get_decl_init): New.
(lhd_finish_decl_inits): New.
(LANG_HOOKS_GET_DECL_INIT): New.
(LANG_HOOKS_OMP_FINISH_DECL_INITS): New.
(LANG_HOOKS_DECLS): Add LANG_HOOKS_GET_DECL_INIT and
LANG_HOOKS_OMP_FINISH_DECL_INITS.
* langhooks.c (lhd_omp_get_decl_init): New.
(lhd_omp_finish_decl_inits): New.
* langhooks.h (struct lang_hooks_for_decls): Add omp_get_decl_init
and omp_finish_decl_inits.
* omp-offload.c (omp_discover_declare_target_var_r): Use
get_decl_init langhook in place of DECL_INITIAL.  Call
omp_finish_decl_inits langhook at end of function.

gcc/cp/
* cp-lang.c (cxx_get_decl_init): New.
(cxx_omp_finish_decl_inits): New.
(LANG_HOOKS_GET_DECL_INIT): New.
(LANG_HOOKS_OMP_FINISH_DECL_INITS): New.
* cp-tree.h (dynamic_initializers): New.
* decl.c (dynamic_initializers): New.
* decl2.c (c_parse_final_cleanups): Add initializer entries
from vars to dynamic_initializers.

gcc/testsuite/
* g++.dg/gomp/declare-target-3.C: New.

4 years agoopenmp: Implement OpenMP 5.0 base-pointer attachement and clause ordering
Chung-Lin Tang [Tue, 10 Nov 2020 11:36:58 +0000 (03:36 -0800)] 
openmp: Implement OpenMP 5.0 base-pointer attachement and clause ordering

This patch implements some parts of the target variable mapping changes
specified in OpenMP 5.0, including base-pointer attachment/detachment
behavior for array section list-items in map clauses, and ordering of
map clauses according to map kind.

2020-11-10  Chung-Lin Tang  <cltang@codesourcery.com>

gcc/c-family/ChangeLog:

* c-common.h (c_omp_adjust_map_clauses): New declaration.
* c-omp.c (struct map_clause): Helper type for c_omp_adjust_map_clauses.
(c_omp_adjust_map_clauses): New function.

gcc/c/ChangeLog:

* c-parser.c (c_parser_omp_target_data): Add use of
new c_omp_adjust_map_clauses function. Add GOMP_MAP_ATTACH_DETACH as
handled map clause kind.
(c_parser_omp_target_enter_data): Likewise.
(c_parser_omp_target_exit_data): Likewise.
(c_parser_omp_target): Likewise.
* c-typeck.c (handle_omp_array_sections): Adjust COMPONENT_REF case to
use GOMP_MAP_ATTACH_DETACH map kind for C_ORT_OMP region type.
(c_finish_omp_clauses): Adjust bitmap checks to allow struct decl and
same struct field access to co-exist on OpenMP construct.

gcc/cp/ChangeLog:

* parser.c (cp_parser_omp_target_data): Add use of
new c_omp_adjust_map_clauses function. Add GOMP_MAP_ATTACH_DETACH as
handled map clause kind.
(cp_parser_omp_target_enter_data): Likewise.
(cp_parser_omp_target_exit_data): Likewise.
(cp_parser_omp_target): Likewise.
* semantics.c (handle_omp_array_sections): Adjust COMPONENT_REF case to
use GOMP_MAP_ATTACH_DETACH map kind for C_ORT_OMP region type. Fix
interaction between reference case and attach/detach.
(finish_omp_clauses): Adjust bitmap checks to allow struct decl and
same struct field access to co-exist on OpenMP construct.

gcc/ChangeLog:

* gimplify.c (is_or_contains_p): New static helper function.
(omp_target_reorder_clauses): New function.
(gimplify_scan_omp_clauses): Add use of omp_target_reorder_clauses to
reorder clause list according to OpenMP 5.0 rules. Add handling of
GOMP_MAP_ATTACH_DETACH for OpenMP cases.
* omp-low.c (is_omp_target): New static helper function.
(scan_sharing_clauses): Add scan phase handling of GOMP_MAP_ATTACH/DETACH
for OpenMP cases.
(lower_omp_target): Add lowering handling of GOMP_MAP_ATTACH/DETACH for
OpenMP cases.

gcc/testsuite/ChangeLog:

* c-c++-common/gomp/clauses-2.c: Remove dg-error cases now valid.
* gfortran.dg/gomp/map-2.f90: Likewise.
* c-c++-common/gomp/map-5.c: New testcase.

libgomp/ChangeLog:

* libgomp.h (enum gomp_map_vars_kind): Adjust enum values to be bit-flag
usable.
* oacc-mem.c (acc_map_data): Adjust gomp_map_vars argument flags to
'GOMP_MAP_VARS_OPENACC | GOMP_MAP_VARS_ENTER_DATA'.
(goacc_enter_datum): Likewise for call to gomp_map_vars_async.
(goacc_enter_data_internal): Likewise.
* target.c (gomp_map_vars_internal):
Change checks of GOMP_MAP_VARS_ENTER_DATA to use bit-and (&). Adjust use
of gomp_attach_pointer for OpenMP cases.
(gomp_exit_data): Add handling of GOMP_MAP_DETACH.
(GOMP_target_enter_exit_data): Add handling of GOMP_MAP_ATTACH.
* testsuite/libgomp.c-c++-common/ptr-attach-1.c: New testcase.

4 years agoopenmp: Retire nest-var ICV for OpenMP 5.1
Kwok Cheung Yeung [Wed, 18 Nov 2020 19:24:36 +0000 (11:24 -0800)] 
openmp: Retire nest-var ICV for OpenMP 5.1

This removes the nest-var ICV, expressing nesting in terms of the
max-active-levels-var ICV instead.  The max-active-levels-var ICV
is now per data environment rather than per device.

This is a backport from mainline (commit
6fae7eda968db658c280ad6f94fe6906a15af0c9).

2020-11-18  Kwok Cheung Yeung  <kcy@codesourcery.com>

libgomp/
* env.c (gomp_global_icv): Remove nest_var field.  Add
max_active_levels_var field.
(gomp_max_active_levels_var): Remove.
(parse_boolean): Return true on success.
(handle_omp_display_env): Express OMP_NESTED in terms of
max_active_levels_var.  Change format specifier for
max_active_levels_var.
(initialize_env): Set max_active_levels_var from
OMP_MAX_ACTIVE_LEVELS, OMP_NESTED, OMP_NUM_THREADS and
OMP_PROC_BIND.
* icv.c (omp_set_nested): Express in terms of
max_active_levels_var.
(omp_get_nested): Likewise.
(omp_set_max_active_levels): Use max_active_levels_var field instead
of gomp_max_active_levels_var.
(omp_get_max_active_levels): Likewise.
* libgomp.h (struct gomp_task_icv): Remove nest_var field.  Add
max_active_levels_var field.
(gomp_supported_active_levels): Set to UCHAR_MAX.
(gomp_max_active_levels_var): Delete.
* libgomp.texi (omp_get_nested): Update documentation.
(omp_set_nested): Likewise.
(OMP_MAX_ACTIVE_LEVELS): Likewise.
(OMP_NESTED): Likewise.
(OMP_NUM_THREADS): Likewise.
(OMP_PROC_BIND): Likewise.
* parallel.c (gomp_resolve_num_threads): Replace reference
to nest_var with max_active_levels_var.  Use max_active_levels_var
field instead of gomp_max_active_levels_var.

4 years agoopenmp: Mark deprecated symbols in OpenMP 5.0
Kwok Cheung Yeung [Thu, 5 Nov 2020 18:11:23 +0000 (10:11 -0800)] 
openmp: Mark deprecated symbols in OpenMP 5.0

This is a backport from mainline (commit
10508db867934264bbc2578f1f454c19fa558fd3).

2020-11-05  Ulrich Drepper  <drepper@redhat.com>
    Kwok Cheung Yeung  <kcy@codesourcery.com>

libgomp/
* Makefile.am (%.mod): Add -cpp and -fopenmp to compile flags.
* Makefile.in: Regenerate.
* fortran.c: Wrap uses of omp_set_nested and omp_get_nested with
pragmas to ignore -Wdeprecated-declarations warnings.
* icv.c: Likewise.
* omp.h.in (__GOMP_DEPRECATED_5_0): Define.
Mark omp_lock_hint_* enum values, omp_lock_hint_t, omp_set_nested,
and omp_get_nested with __GOMP_DEPRECATED_5_0.
* omp_lib.f90.in: Mark omp_get_nested and omp_set_nested as
deprecated.
* testsuite/libgomp.c++/affinity-1.C: Add -Wno-deprecated-declarations
to test options.
* testsuite/libgomp.c/affinity-1.c: Likewise.
* testsuite/libgomp.c/affinity-2.c: Likewise.
* testsuite/libgomp.c/appendix-a/a.15.1.c: Likewise.
* testsuite/libgomp.c/lib-1.c: Likewise.
* testsuite/libgomp.c/nested-1.c: Likewise.
* testsuite/libgomp.c/nested-2.c: Likewise.
* testsuite/libgomp.c/nested-3.c: Likewise.
* testsuite/libgomp.c/pr32362-1.c: Likewise.
* testsuite/libgomp.c/pr32362-2.c: Likewise.
* testsuite/libgomp.c/pr32362-3.c: Likewise.
* testsuite/libgomp.c/pr35549.c: Likewise.
* testsuite/libgomp.c/pr42942.c: Likewise.
* testsuite/libgomp.c/pr61200.c: Likewise.
* testsuite/libgomp.c/sort-1.c: Likewise.
* testsuite/libgomp.c/target-5.c: Likewise.
* testsuite/libgomp.c/target-6.c: Likewise.
* testsuite/libgomp.c/teams-1.c: Likewise.
* testsuite/libgomp.c/thread-limit-1.c: Likewise.
* testsuite/libgomp.c/thread-limit-2.c: Likewise.
* testsuite/libgomp.c/thread-limit-4.c: Likewise.
* testsuite/libgomp.fortran/affinity1.f90: Likewise.
* testsuite/libgomp.fortran/lib1.f90: Likewise.
* testsuite/libgomp.fortran/lib2.f: Likewise.
* testsuite/libgomp.fortran/nested1.f90: Likewise.
* testsuite/libgomp.fortran/teams1.f90: Likewise.

4 years agoopenmp: Add test for OMP_TARGET_OFFLOAD=mandatory for cases where it must not fail
Jakub Jelinek [Thu, 22 Oct 2020 07:33:17 +0000 (09:33 +0200)] 
openmp: Add test for OMP_TARGET_OFFLOAD=mandatory for cases where it must not fail

This is a backport from mainline (commit
17c5b7e1dc47bab6e6cedbf4b2d88cef3283533e).

2020-10-22  Jakub Jelinek  <jakub@redhat.com>

* testsuite/libgomp.c/target-41.c: New test.

4 years agoopenmp: Change omp_get_initial_device () to match OpenMP 5.1 requirements
Jakub Jelinek [Thu, 22 Oct 2020 07:31:01 +0000 (09:31 +0200)] 
openmp: Change omp_get_initial_device () to match OpenMP 5.1 requirements

> Therefore, I think until omp_get_initial_device () value is changed, we

The following so far untested patch implements that change.

OpenMP 4.5 said for omp_get_initial_device:
The value of the device number is implementation defined. If it is between 0 and one less than
omp_get_num_devices() then it is valid for use with all device constructs and routines; if it is
outside that range, then it is only valid for use with the device memory routines and not in the
device clause.
and OpenMP 5.0 similarly, but OpenMP 5.1 says:
The value of the device number is the value returned by the omp_get_num_devices routine.

As the new value is compatible with what has been required earlier, I think
we can change it already now.

This is a backport from mainline (commit
74c9882b80bda50b37c9555498de7123c6bdb9e4).

2020-10-22  Jakub Jelinek  <jakub@redhat.com>

* icv.c (omp_get_initial_device): Remove including corresponding
ialias.
* icv-device.c (omp_get_initial_device): New function.  Return
gomp_get_num_devices ().  Add ialias.
* target.c (resolve_device): Don't fail with
OMP_TARGET_OFFLOAD=mandatory if device_id is equal to
gomp_get_num_devices ().
(omp_target_alloc, omp_target_free, omp_target_is_present,
omp_target_memcpy, omp_target_memcpy_rect, omp_target_associate_ptr,
omp_target_disassociate_ptr, omp_pause_resource): Use
gomp_get_num_devices () instead of GOMP_DEVICE_HOST_FALLBACK on the
first use in the functions, in uses dominated by the
gomp_get_num_devices call use num_devices_openmp instead.
* libgomp.texi (omp_get_initial_device): Document.
* config/gcn/icv-device.c (omp_get_initial_device): New function.
Add ialias.
* config/nvptx/icv-device.c (omp_get_initial_device): Likewise.
* testsuite/libgomp.c/target-40.c: New test.

4 years agoopenmp: Implement support for OMP_TARGET_OFFLOAD environment variable
Kwok Cheung Yeung [Tue, 20 Oct 2020 11:15:59 +0000 (04:15 -0700)] 
openmp: Implement support for OMP_TARGET_OFFLOAD environment variable

This implements support for the OMP_TARGET_OFFLOAD environment variable
introduced in the OpenMP 5.0 standard, which controls how offloading
is handled.  It may be set to MANDATORY (abort if offloading cannot be
performed), DISABLED (no offloading to devices) or DEFAULT (offload to
device if possible, fall back to host if not).

This is a backport from mainline (commits
1bfc07d150790fae93184a79a7cce897655cb37b,
35f258f4bbba7fa044f90b4f14d1bc942db58089 and
121a8812c45b3155ccbd268b000ad00a778e81e8).

2020-10-20  Kwok Cheung Yeung  <kcy@codesourcery.com>
    Jakub Jelinek  <jakub@redhat.com>

libgomp/
* env.c (gomp_target_offload_var): New.
(parse_target_offload): New.
(handle_omp_display_env): Print value of OMP_TARGET_OFFLOAD.
(initialize_env): Parse OMP_TARGET_OFFLOAD.
* libgomp.h (gomp_target_offload_t): New.
(gomp_target_offload_var): New.
* libgomp.texi (OMP_TARGET_OFFLOAD): New section.
* target.c (resolve_device): Generate error if device not found and
offloading is mandatory.
(gomp_target_fallback): Generate error if offloading is mandatory.
(GOMP_target): Add argument in call to gomp_target_fallback.
(GOMP_target_ext): Likewise.
(gomp_target_data_fallback): Generate error if offloading is mandatory.
(GOMP_target_data): Add argument in call to gomp_target_data_fallback.
(GOMP_target_data_ext): Likewise.
(gomp_target_task_fn): Add argument in call to gomp_target_fallback.
(gomp_target_init): Return early if offloading is disabled.
Inside of the function, use automatic
variables corresponding to num_devices, num_devices_openmp and devices
global variables and update the globals only at the end of the
function.

4 years agoopenmp: Add support for the omp_get_supported_active_levels runtime library routine
Kwok Cheung Yeung [Wed, 7 Oct 2020 16:34:32 +0000 (09:34 -0700)] 
openmp: Add support for the omp_get_supported_active_levels runtime library routine

This patch implements the omp_get_supported_active_levels runtime routine
from the OpenMP 5.0 specification, which returns the maximum number of
active nested parallel regions supported by this implementation.  The
current maximum (set using the omp_set_max_active_levels routine or the
OMP_MAX_ACTIVE_LEVELS environment variable) cannot exceed this number.

This is a backport from mainline (commits
8949b985dbaf07d433bd57d2883e1e5414f20e75 and
445567b22a3c535be0b1861b393e9a0b050f2b1e).

2020-10-13  Kwok Cheung Yeung  <kcy@codesourcery.com>

libgomp/
* env.c (gomp_max_active_levels_var): Initialize to
gomp_supported_active_levels.
(initialize_env): Limit gomp_max_active_levels_var to be at most
equal to gomp_supported_active_levels.
* fortran.c (omp_get_supported_active_levels): Add ialias_redirect.
(omp_get_supported_active_levels_): New.
* icv.c (omp_set_max_active_levels): Limit gomp_max_active_levels_var
to at most equal to gomp_supported_active_levels.
(omp_get_supported_active_levels): New.
* libgomp.h (gomp_supported_active_levels): New.
* libgomp.map (OMP_5.0.1): Add omp_get_supported_active_levels and
omp_get_supported_active_levels_.
* libgomp.texi (omp_get_max_active_levels): Modify description.
(omp_get_supported_active_levels): New.
(omp_set_max_active_levels): Update.  Add reference to
omp_get_supported_active_levels.
* omp.h.in (omp_get_supported_active_levels): New.
* omp_lib.f90.in (omp_get_supported_active_levels): New.
* omp_lib.h.in (omp_get_supported_active_levels): New.
* testsuite/libgomp.c/lib-2.c (main): Check omp_get_max_active_levels
against omp_get_supported_active_levels.
* testsuite/libgomp.fortran/lib4.f90 (lib4): Likewise.

4 years agoMerge remote-tracking branch 'origin/releases/gcc-10' into devel/omp/gcc-10
Tobias Burnus [Mon, 28 Sep 2020 17:58:57 +0000 (19:58 +0200)] 
Merge remote-tracking branch 'origin/releases/gcc-10' into devel/omp/gcc-10

Merged up to a6c47f4ce26639bfbc72821ae629b9af7744a9d7 (2020-09-28)

4 years agoOpenMP: Handle cpp_implicit_alias in declare-target discovery (PR96390)
Tobias Burnus [Mon, 28 Sep 2020 17:57:50 +0000 (19:57 +0200)] 
OpenMP: Handle cpp_implicit_alias in declare-target discovery (PR96390)

Backport mainline version; updates commit
ef509d1985aa53a8c0875c25ad4050ea807be10e for later review-comment
changes.

gcc/ChangeLog:

PR middle-end/96390
* omp-offload.c (omp_discover_declare_target_tgt_fn_r): Handle
alias nodes.

libgomp/ChangeLog:

PR middle-end/96390
* testsuite/libgomp.c++/pr96390.C: New test.
* testsuite/libgomp.c-c++-common/pr96390.c: New test.

(cherry picked from commit 2a10a2c0689db280ee3a94164504b7196b8370f4)

4 years agogomp/pr94874.c: Update scan-tree-dump
Tobias Burnus [Mon, 28 Sep 2020 17:57:20 +0000 (19:57 +0200)] 
gomp/pr94874.c: Update scan-tree-dump

g++ on OG10 adds an additional temporary compared to mainline.

* c-c++-common/gomp/pr94874.c: Update scan-tree-dump.

4 years agotestsuite: [aarch64] Fix aarch64/advsimd-intrinsics/v{trn,uzp,zip}_half.c
Christophe Lyon [Fri, 25 Sep 2020 10:40:18 +0000 (10:40 +0000)] 
testsuite: [aarch64] Fix aarch64/advsimd-intrinsics/v{trn,uzp,zip}_half.c

Since r11-3402 (g:65c9878641cbe0ed898aa7047b7b994e9d4a5bb1), the
vtrn_half, vuzp_half and vzip_half started failing with

vtrn_half.c:76:17: error: redeclaration of 'vector_float64x2' with no linkage
vtrn_half.c:77:17: error: redeclaration of 'vector2_float64x2' with no linkage
vtrn_half.c:80:17: error: redeclaration of 'vector_res_float64x2' with no linkage

This is because r11-3402 now always declares float64x2 variables for
aarch64, leading to a duplicate declaration in these testcases.

The fix is simply to remove these now useless declarations.

These tests are skipped on arm*, so there is no impact on that target.

2020-09-25  Christophe Lyon  <christophe.lyon@linaro.org>

gcc/testsuite/
PR target/71233
* gcc.target/aarch64/advsimd-intrinsics/vtrn_half.c: Remove
declarations of vector, vector2, vector_res for float64x2 type.
* gcc.target/aarch64/advsimd-intrinsics/vuzp_half.c: Likewise.
* gcc.target/aarch64/advsimd-intrinsics/vzip_half.c: Likewise.

(cherry picked from commit 8c775bf447e190024fa08c55e38db94dd013a393)

4 years agoAArch64: Implement missing p128<->f64 reinterpret intrinsics
Kyrylo Tkachov [Wed, 23 Sep 2020 16:37:58 +0000 (17:37 +0100)] 
AArch64: Implement missing p128<->f64 reinterpret intrinsics

This patch implements the missing reinterprets to and from poly128_t and
float64x2_t.
I've plugged in the appropriate testing in the advsimd-intrinsics.exp
too.

Bootstrapped and tested on aarch64-none-linux-gnu.
Tested advsimd-intrinsics.exp on arm-none-eabi too to make sure arm
testing isn't affected.

gcc/
PR target/71233
* config/aarch64/arm_neon.h (vreinterpretq_f64_p128,
vreinterpretq_p128_f64): Define.

gcc/testsuite/
PR target/71233
* gcc.target/aarch64/advsimd-intrinsics/arm-neon-ref.h
(clean_results): Add float64x2_t cleanup.
(DECL_VARIABLE_128BITS_VARIANTS): Add float64x2_t variable.
* gcc.target/aarch64/advsimd-intrinsics/vreinterpret_p128.c: Add
testing of vreinterpretq_f64_p128, vreinterpretq_p128_f64.

(cherry picked from commit 65c9878641cbe0ed898aa7047b7b994e9d4a5bb1)

4 years agoAArch64: Implement missing vrndns_f32 intrinsic
Kyrylo Tkachov [Wed, 23 Sep 2020 11:02:29 +0000 (12:02 +0100)] 
AArch64: Implement missing vrndns_f32 intrinsic

This patch implements the missing vrndns_f32 intrinsic. This operates on a scalar float32_t value.
It can be mapped down to a __builtin_aarch64_frintnsf builtin.

This patch does that.

Bootstrapped and tested on aarch64-none-linux-gnu.

gcc/
PR target/71233
* config/aarch64/aarch64-simd-builtins.def (frintn): Use BUILTIN_VHSDF_HSDF
for modes.  Remove explicit hf instantiation.
* config/aarch64/arm_neon.h (vrndns_f32): Define.

gcc/testsuite/
PR target/71233
* gcc.target/aarch64/simd/vrndns_f32_1.c: New test.

(cherry picked from commit 02b5377b3766804059b7824330d33d0e1cef2e5b)

4 years agoAArch64: Implement missing _p64 intrinsics for vector permutes
Kyrylo Tkachov [Wed, 23 Sep 2020 10:07:50 +0000 (11:07 +0100)] 
AArch64: Implement missing _p64 intrinsics for vector permutes

This patch implements some missing vector permute intrinsics operating on poly64x2_t types.
They are implemented identically to their uint64x2_t brethren.

Bootstrapped and tested on aarch64-none-linux-gnu.

gcc/
PR target/71233
* config/aarch64/arm_neon.h (vtrn1q_p64, vtrn2q_p64, vuzp1q_p64,
vuzp2q_p64, vzip1q_p64, vzip2q_p64): Define.

gcc/testsuite/
PR target/71233
* gcc.target/aarch64/simd/trn_zip_p64_1.c: New test.

(cherry picked from commit e8e818399d70c5a5a3d30a54d305c6e2b92e2c66)

4 years agoAArch64: Implement vldrq_p128 intrinsic
Kyrylo Tkachov [Wed, 23 Sep 2020 09:32:42 +0000 (10:32 +0100)] 
AArch64: Implement vldrq_p128 intrinsic

This patch implements the missing vldrq_p128 intrinsic that just loads from the appropriate pointer.

Bootstrapped and tested on aarch64-none-linux-gnu.

gcc/
PR target/71233
* config/aarch64/arm_neon.h (vldrq_p128): Define.

gcc/testsuite/
PR target/71233
* gcc.target/aarch64/simd/vldrq_p128_1.c: New test.

(cherry picked from commit f2868e4bcff2c7b882d01231f039459c00e59d7b)

4 years agoAArch64: Implement vstrq_p128 intrinsic
Kyrylo Tkachov [Wed, 23 Sep 2020 09:29:17 +0000 (10:29 +0100)] 
AArch64: Implement vstrq_p128 intrinsic

This patch implements the missing vstrq_p128 intrinsic.
It just performs a store of the poly128_t argument to a memory location.

Bootstrapped and tested on aarch64-none-linux-gnu.

gcc/
PR target/71233
* config/aarch64/arm_neon.h (vstrq_p128): Define.

gcc/testsuite/
PR target/71233
* gcc.target/aarch64/simd/vstrq_p128_1.c: New test.

(cherry picked from commit d23ea1e865301cd45f14ccbdb0bca49251fde9e1)

4 years agoAArch64: Implement missing vcls intrinsics on unsigned types
Kyrylo Tkachov [Tue, 22 Sep 2020 11:03:49 +0000 (12:03 +0100)] 
AArch64: Implement missing vcls intrinsics on unsigned types

This patch implements some missing intrinsics that perform a CLS on unsigned SIMD types.

Bootstrapped and tested on aarch64-none-linux-gnu.

gcc/
PR target/71233
* config/aarch64/arm_neon.h (vcls_u8, vcls_u16, vcls_u32,
vclsq_u8, vclsq_u16, vclsq_u32): Define.

gcc/testsuite/
PR target/71233
* gcc.target/aarch64/simd/vcls_unsigned_1.c: New test.

(cherry picked from commit 30957092db46d8798e632feefb5df634488dbb33)

4 years agoAArch64: Implement missing vceq*_p* intrinsics
Kyrylo Tkachov [Tue, 22 Sep 2020 11:00:38 +0000 (12:00 +0100)] 
AArch64: Implement missing vceq*_p* intrinsics

This patch implements some missing vceq* intrinsics on poly types.
The behaviour is to produce the appropriate CMEQ instruction as for the unsigned types.

Bootstrapped and tested on aarch64-none-linux-gnu.

gcc/
PR target/71233
* config/aarch64/arm_neon.h (vceqq_p64, vceqz_p64, vceqzq_p64): Define.

gcc/testsuite/

PR target/71233
* gcc.target/aarch64/simd/vceq_poly_1.c: New test.

(cherry picked from commit d4703be185b422f637deebd3bb9222a41c8023d6)

4 years agoAArch64: Implement poly-type vadd intrinsics
Kyrylo Tkachov [Tue, 22 Sep 2020 10:58:36 +0000 (11:58 +0100)] 
AArch64: Implement poly-type vadd intrinsics

This implements the vadd[p]_p* intrinsics.
In terms of functionality they are aliases of veor operations on the relevant unsigned types.

Bootstrapped and tested on aarch64-none-linux-gnu.

gcc/
PR target/71233
* config/aarch64/arm_neon.h (vadd_p8, vadd_p16, vadd_p64, vaddq_p8,
vaddq_p16, vaddq_p64, vaddq_p128): Define.

gcc/testsuite/
PR target/71233
* gcc.target/aarch64/simd/vadd_poly_1.c: New test.

(cherry picked from commit fa9ad35dae03dcb20c4ccb50ba1b351a8ab77970)

4 years agoRevert "Fortran : ICE in build_field PR95614"
Mark Eggleston [Mon, 28 Sep 2020 11:07:07 +0000 (12:07 +0100)] 
Revert "Fortran  :  ICE in build_field PR95614"

This reverts commit 4a67941a956003dcce8866604ba25f5a0bfd16cf.

4 years agoFix bogus alignment warning on address clause
Eric Botcazou [Mon, 28 Sep 2020 07:00:46 +0000 (09:00 +0200)] 
Fix bogus alignment warning on address clause

The compiler gives a bogus alignment warning on an address clause and
a discriminated record type with variable size.

gcc/ada/ChangeLog:
* gcc-interface/decl.c (maybe_saturate_size): Add ALIGN parameter
and round down the result to ALIGN.
(gnat_to_gnu_entity): Adjust calls to maybe_saturate_size.

gcc/testsuite/ChangeLog:
* gnat.dg/addr16.adb: New test.
* gnat.dg/addr16_pkg.ads: New helper.

4 years agoDaily bump.
GCC Administrator [Mon, 28 Sep 2020 00:16:55 +0000 (00:16 +0000)] 
Daily bump.

4 years agooptabs: Don't reuse target for multi-word expansions if it overlaps operand(s) [PR97073]
Jakub Jelinek [Sun, 27 Sep 2020 21:18:26 +0000 (23:18 +0200)] 
optabs: Don't reuse target for multi-word expansions if it overlaps operand(s) [PR97073]

The following testcase is miscompiled on i686-linux, because
we try to expand a double-word bitwise logic operation with op0
being a (mem:DI u) and target (mem:DI u+4), i.e. partial overlap, and
thus end up with:
movl 4(%esp), %eax
andl u, %eax
movl %eax, u+4
! movl u+4, %eax optimized out
andl 8(%esp), %eax
movl %eax, u+8
rather than with the desired:
movl 4(%esp), %edx
movl 8(%esp), %eax
andl u, %edx
andl u+4, %eax
movl %eax, u+8
movl %edx, u+4
because the store of the first word to target overwrites the second word of
the operand.
expand_binop for this (and several similar places) already check for target
== op0 or target == op1, this patch just adds reg_overlap_mentioned_p calls
next to it.
Pedantically, at least for some of these it might be sufficient to force
a different target if there is overlap but target is not rtx_equal_p to
the operand (e.g. in this bitwise logical case, but e.g. not in the shift
cases where there is reordering), though that would go against the
preexisting target == op? checks and the rationale that REG_EQUAL notes in
that case isn't correct.

2020-09-27  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/97073
* optabs.c (expand_binop, expand_absneg_bit, expand_unop,
expand_copysign_bit): Check reg_overlap_mentioned_p between target
and operand(s) and if it returns true, force a pseudo as target.

* gcc.c-torture/execute/pr97073.c: New test.

(cherry picked from commit a4b31d5807f2bc67c8999b3d53369cf2a5c6e1ec)

4 years agoFortran : ICE in build_field PR95614
Mark Eggleston [Thu, 11 Jun 2020 13:33:51 +0000 (14:33 +0100)] 
Fortran  :  ICE in build_field PR95614

Local identifiers can not be the same as a module name.  Original
patch by Steve Kargl resulted in name clashes between common block
names and local identifiers.  A local identifier can be the same as
a global identier if that identifier represents a common.  The patch
was modified to allow global identifiers that represent a common
block.

2020-09-27  Steven G. Kargl  <kargl@gcc.gnu.org>
    Mark Eggleston  <markeggleston@gcc.gnu.org>

gcc/fortran/

PR fortran/95614
* decl.c (gfc_get_common): Use gfc_match_common_name instead
of match_common_name.
* decl.c (gfc_bind_idents): Use gfc_match_common_name instead
of match_common_name.
* match.c : Rename match_common_name to gfc_match_common_name.
* match.c (gfc_match_common): Use gfc_match_common_name instead
of match_common_name.
* match.h : Rename match_common_name to gfc_match_common_name.
* resolve.c (resolve_common_vars): Check each symbol in a
common block has a global symbol.  If there is a global symbol
issue an error if the symbol type is known as is not a common
block name.

2020-09-27  Mark Eggleston  <markeggleston@gcc.gnu.org>

gcc/testsuite/

PR fortran/95614
* gfortran.dg/pr95614_1.f90: New test.
* gfortran.dg/pr95614_2.f90: New test.

(cherry picked from commit e5a76af3a2f3324efc60b4b2778ffb29d5c377bc)

4 years agoDaily bump.
GCC Administrator [Sun, 27 Sep 2020 00:16:59 +0000 (00:16 +0000)] 
Daily bump.

4 years agoDaily bump.
GCC Administrator [Sat, 26 Sep 2020 00:17:01 +0000 (00:17 +0000)] 
Daily bump.

4 years agoAdd test for PR95464.c.
Vladimir N. Makarov [Thu, 4 Jun 2020 17:32:24 +0000 (13:32 -0400)] 
Add test for PR95464.c.

2020-06-04  Vladimir Makarov  <vmakarov@redhat.com>

PR middle-end/95464
* gcc.target/i386/pr95464.c: New.

(cherry picked from commit e7ef9a40cd0c688cd331bc26224d1fbe360c1fe6)

4 years agoAdd processing STRICT_LOW_PART for matched reloads.
Vladimir N. Makarov [Thu, 4 Jun 2020 16:04:48 +0000 (12:04 -0400)] 
Add processing STRICT_LOW_PART for matched reloads.

2020-06-04  Vladimir Makarov  <vmakarov@redhat.com>

PR middle-end/95464
* lra.c (lra_emit_move): Add processing STRICT_LOW_PART.
* lra-constraints.c (match_reload): Use STRICT_LOW_PART in output
reload if the original insn has it too.

(cherry picked from commit 5261cf8ce824bfc75eb6f12ad5e3716c085b6f9a)

4 years agoarm: Require MVE memory operand for destination of vst1q intrinsic
Joe Ramsay [Wed, 19 Aug 2020 12:34:06 +0000 (12:34 +0000)] 
arm: Require MVE memory operand for destination of vst1q intrinsic

Previously, the machine description patterns for vst1q accepted a generic memory
operand for the destination, which could lead to an unrecognised builtin when
expanding vst1q* intrinsics. This change fixes the pattern to only accept MVE
memory operands.

gcc/ChangeLog:

PR target/96683
* config/arm/mve.md (mve_vst1q_f<mode>): Require MVE memory operand for
destination.
(mve_vst1q_<supf><mode>): Likewise.

gcc/testsuite/ChangeLog:

PR target/96683
* gcc.target/arm/mve/intrinsics/vst1q_f16.c: New test.
* gcc.target/arm/mve/intrinsics/vst1q_s16.c: New test.
* gcc.target/arm/mve/intrinsics/vst1q_s8.c: New test.
* gcc.target/arm/mve/intrinsics/vst1q_u16.c: New test.
* gcc.target/arm/mve/intrinsics/vst1q_u8.c: New test.

(cherry picked from commit 91d206adfe39ce063f6a5731b92a03c05e82e94a)

4 years agoDaily bump.
GCC Administrator [Fri, 25 Sep 2020 00:17:04 +0000 (00:17 +0000)] 
Daily bump.

4 years agortl_data: Add sp_is_clobbered_by_asm
H.J. Lu [Mon, 14 Sep 2020 15:52:27 +0000 (08:52 -0700)] 
rtl_data: Add sp_is_clobbered_by_asm

Add sp_is_clobbered_by_asm to rtl_data to inform backends that the stack
pointer is clobbered by asm statement.

gcc/

PR target/97032
* cfgexpand.c (asm_clobber_reg_kind): Set sp_is_clobbered_by_asm
to true if the stack pointer is clobbered by asm statement.
* emit-rtl.h (rtl_data): Add sp_is_clobbered_by_asm.
* config/i386/i386.c (ix86_get_drap_rtx): Set need_drap to true
if the stack pointer is clobbered by asm statement.

gcc/testsuite/

PR target/97032
* gcc.target/i386/pr97032.c: New test.

(cherry picked from commit 453a20c65722719b9e2d84339f215e7ec87692dc)

4 years ago[RS6000] Power10 libffi fixes
Alan Modra [Fri, 18 Sep 2020 13:51:05 +0000 (23:21 +0930)] 
[RS6000] Power10 libffi fixes

Power10 pc-relative code doesn't use or preserve r2 as a TOC pointer.
That means calling between pc-relative and TOC using code can't be
done without intervening linker stubs, and a call from TOC code to
pc-relative code must have a nop after the bl in order to restore r2.

Now the PowerPC libffi assembly code doesn't use r2 except for the
implicit use when making calls back to C, ffi_closure_helper_LINUX64
and ffi_prep_args64.  So changing the assembly to interoperate with
pc-relative code without stubs is easily done.

PR target/97166
* src/powerpc/linux64.S (ffi_call_LINUX64): Don't emit global
entry when __PCREL__.  Call using @notoc.  Add nops.
* src/powerpc/linux64_closure.S (ffi_closure_LINUX64): Likewise.
(ffi_go_closure_linux64): Likewise.

(cherry picked from commit 08cd8d5929eac84b27788d8483fd75ab7ad13129)
(cherry picked from commit fff56af6421a1a3e357bcaad99f2ea084d72a7a8)

4 years ago[RS6000] Built-in __PCREL__ define
Alan Modra [Wed, 23 Sep 2020 10:45:39 +0000 (20:15 +0930)] 
[RS6000] Built-in __PCREL__ define

Useful in assembly to know details of power10 function calls.

PR target/97166
* config/rs6000/rs6000-c.c (rs6000_target_modify_macros):
Conditionally define __PCREL__.

(cherry picked from commit 677b9150f54a0483d3de1182ac40717b7c4431a5)

4 years agoaarch64: Do not alter value on a force_reg returned rtx expanding __jcvt
Andrea Corallo [Thu, 17 Sep 2020 16:17:52 +0000 (17:17 +0100)] 
aarch64: Do not alter value on a force_reg returned rtx expanding __jcvt

2020-09-17  Andrea Corallo  <andrea.corallo@arm.com>

* config/aarch64/aarch64-builtins.c
(aarch64_general_expand_builtin): Use expand machinery not to
alter the value of an rtx returned by force_reg.

(cherry picked from commit 2c62952f8160bdc8d4111edb34a4bc75096c1e05)

4 years agoaarch64: Add support for Neoverse V1 CPU
Alex Coplan [Thu, 24 Sep 2020 09:17:48 +0000 (10:17 +0100)] 
aarch64: Add support for Neoverse V1 CPU

This patch backports the AArch64 support for Arm's Neoverse V1 CPU to
GCC 10.

gcc/ChangeLog:

* config/aarch64/aarch64-cores.def: Add Neoverse V1.
* config/aarch64/aarch64-tune.md: Regenerate.
* doc/invoke.texi: Document support for Neoverse V1.

4 years agoDaily bump.
GCC Administrator [Thu, 24 Sep 2020 00:17:04 +0000 (00:17 +0000)] 
Daily bump.

4 years agoDaily bump.
GCC Administrator [Wed, 23 Sep 2020 00:17:02 +0000 (00:17 +0000)] 
Daily bump.

4 years agolibstdc++: Fix out-of-bounds string_view access in filesystem::path [PR 97167]
Jonathan Wakely [Tue, 22 Sep 2020 19:02:58 +0000 (20:02 +0100)] 
libstdc++: Fix out-of-bounds string_view access in filesystem::path [PR 97167]

libstdc++-v3/ChangeLog:

PR libstdc++/97167
* src/c++17/fs_path.cc (path::_Parser::root_path()): Check
for empty string before inspecting the first character.
* testsuite/27_io/filesystem/path/append/source.cc: Append
empty string_view to path.

(cherry picked from commit 49ff88bd0d8a36a9e903f01ce05685cfe07dee5d)

4 years agobpf: use xBPF signed div, mod insns when available
David Faust [Tue, 22 Sep 2020 18:31:35 +0000 (20:31 +0200)] 
bpf: use xBPF signed div, mod insns when available

The 'mod' and 'div' operators in eBPF are unsigned, with no signed
counterpart. xBPF adds two new ALU operations, sdiv and smod, for
signed division and modulus, respectively. Update bpf.md with
'define_insn' blocks for signed div and mod to use them when targetting
xBPF, and add new tests to ensure they are used appropriately.

2020-09-17  David Faust  <david.faust@oracle.com>

gcc/
* config/bpf/bpf.md: Add defines for signed div and mod operators.

gcc/testsuite/
* gcc.target/bpf/diag-sdiv.c: New test.
* gcc.target/bpf/diag-smod.c: New test.
* gcc.target/bpf/xbpf-sdiv-1.c: New test.
* gcc.target/bpf/xbpf-smod-1.c: New test.

(cherry picked from commit 7c8ba5da80d5d95a8521010d6731d0d83036145d)

4 years agoamdgcn: CFI configuration
Andrew Stubbs [Fri, 17 Jul 2020 14:42:26 +0000 (15:42 +0100)] 
amdgcn: CFI configuration

The necessary adjustments to support CFI in ROCGDB (ROCm 3.8+).

The -fomit-frame-pointer option now has different defaults because it has now
become useful.  Otherwise the only change in output is in the debug info.

gcc/

* common/config/gcn/gcn-common.c
(gcn_option_optimization_table): Change OPT_fomit_frame_pointer to -O3.
* config/gcn/gcn.c (move_callee_saved_registers): Emit CFI notes for
prologue register saves.
(gcn_expand_prologue): Prefer the frame pointer when emitting CFI.
(gcn_frame_pointer_rqd): New function.
(gcn_debug_unwind_info): Use UI_DWARF2.
(gcn_dwarf_register_number): Map DWARF_LINK_REGISTER to DWARF PC.
(gcn_dwarf_register_span): DWARF_LINK_REGISTER doesn't span.
(TARGET_FRAME_POINTER_REQUIRED): Define new hook.
* config/gcn/gcn.h (DWARF_FRAME_RETURN_COLUMN): New define.
(DWARF_LINK_REGISTER): New define.
(FIRST_PSEUDO_REGISTER): Increment.
(FIXED_REGISTERS): Add entry for DWARF_LINK_REGISTER.
(CALL_USED_REGISTERS): Likewise.
(REGISTER_NAMES): Likewise.

4 years agolibstdc++: Use correct argument type for __use_alloc, again [PR 96803]
Jonathan Wakely [Tue, 22 Sep 2020 07:42:18 +0000 (08:42 +0100)] 
libstdc++: Use correct argument type for __use_alloc, again [PR 96803]

While backporting 5494edae83ad33c769bd1ebc98f0c492453a6417 I noticed
that it's still not correct. I made the allocator-extended constructor
use the right type for the uses-allocator construction detection, but I
used an rvalue when it should be a const lvalue.

This should fix it properly this time.

libstdc++-v3/ChangeLog:

PR libstdc++/96803
* include/std/tuple
(_Tuple_impl(allocator_arg_t, Alloc, const _Tuple_impl<U...>&)):
Use correct value category in __use_alloc call.
* testsuite/20_util/tuple/cons/96803.cc: Check with constructors
that require correct value category to be used.

(cherry picked from commit 7825399092d572ce8ea82c4aa8dfeb65076b0e52)

4 years agolibstdc++: Use correct argument type for __use_alloc [PR 96803]
Jonathan Wakely [Wed, 26 Aug 2020 18:32:30 +0000 (19:32 +0100)] 
libstdc++: Use correct argument type for __use_alloc [PR 96803]

The _Tuple_impl constructor for allocator-extended construction from a
different tuple type uses the _Tuple_impl's own _Head type in the
__use_alloc test. That is incorrect, because the argument tuple could
have a different type. Using the wrong type might select the
leading-allocator convention when it should use the trailing-allocator
convention, or vice versa.

libstdc++-v3/ChangeLog:

PR libstdc++/96803
* include/std/tuple
(_Tuple_impl(allocator_arg_t, Alloc, const _Tuple_impl<U...>&)):
Replace parameter pack with a type parameter and a pack and pass
the first type to __use_alloc.
* testsuite/20_util/tuple/cons/96803.cc: New test.

(cherry picked from commit 5494edae83ad33c769bd1ebc98f0c492453a6417)

4 years agoDaily bump.
GCC Administrator [Tue, 22 Sep 2020 00:17:04 +0000 (00:17 +0000)] 
Daily bump.

4 years agolibstdc++: Fix build for targets without lstat [PR 94681]
Jonathan Wakely [Mon, 10 Aug 2020 17:58:14 +0000 (18:58 +0100)] 
libstdc++: Fix build for targets without lstat [PR 94681]

libstdc++-v3/ChangeLog:

PR libstdc++/94681
* src/c++17/fs_ops.cc (read_symlink): Use posix::lstat instead
of calling ::lstat directly.
* src/filesystem/ops.cc (read_symlink): Likewise.

(cherry picked from commit 5b065f0563262a0d6cd1fea8426913bfdd841301)

4 years agolibstdc++: Make C++17 ignore --disable-libstdcxx-filesystem-ts [PR 94681]
Jonathan Wakely [Mon, 10 Aug 2020 12:21:59 +0000 (13:21 +0100)] 
libstdc++: Make C++17 ignore --disable-libstdcxx-filesystem-ts [PR 94681]

The configure switch should only affect the optional Filesystem TS, not
the std::filesystem features of C++17.

libstdc++-v3/ChangeLog:

PR libstdc++/94681
* acinclude.m4 (GLIBCXX_CHECK_FILESYSTEM_DEPS): Do not depend on
$enable_libstdcxx_filesystem_ts.
* configure: Regenerate.

(cherry picked from commit 90f7636bf8df50940e0f749af60a6b374a8f09b4)

4 years agolibstdc++: Fix noexcept-specifier for std::bind_front [PR 97101]
Jonathan Wakely [Sun, 20 Sep 2020 23:17:02 +0000 (00:17 +0100)] 
libstdc++: Fix noexcept-specifier for std::bind_front [PR 97101]

libstdc++-v3/ChangeLog:

PR libstdc++/97101
* include/std/functional (bind_front): Fix order of parameters
in is_nothrow_constructible_v specialization.
* testsuite/20_util/function_objects/bind_front/97101.cc: New test.

(cherry picked from commit 3c755b428e188228d0bad90625c995fd25a02322)

4 years agolibgo: don't put golang.org packages in zstdpkglist.go
Ian Lance Taylor [Mon, 21 Sep 2020 19:45:43 +0000 (12:45 -0700)] 
libgo: don't put golang.org packages in zstdpkglist.go

This ensures that internal/goroot.IsStandardPackage does not treat
golang.org packages as being in the standard library.

For golang/go#41368
Fixes golang/go#41499

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

4 years agolibstdc++: handle small max_blocks_per_chunk in pool resources [PR 94160]
Jonathan Wakely [Thu, 10 Sep 2020 14:39:15 +0000 (15:39 +0100)] 
libstdc++: handle small max_blocks_per_chunk in pool resources [PR 94160]

When a pool resource is constructed with max_blocks_per_chunk=1 it ends
up creating a pool with blocks_per_chunk=0 which means it never
allocates anything. Instead it returns null pointers, which should be
impossible.

To avoid this problem, round the max_blocks_per_chunk value to a
multiple of four, so it's never smaller than four.

libstdc++-v3/ChangeLog:

PR libstdc++/94160
* src/c++17/memory_resource.cc (munge_options): Round
max_blocks_per_chunk to a multiple of four.
(__pool_resource::_M_alloc_pools()): Simplify slightly.
* testsuite/20_util/unsynchronized_pool_resource/allocate.cc:
Check that valid pointers are returned when small values are
used for max_blocks_per_chunk.

(cherry picked from commit 30b41cfbb2dade63e52465234a725d1d02fe70aa)

4 years agodwarf: Multi-register CFI address support
Andrew Stubbs [Mon, 27 Jul 2020 09:55:22 +0000 (10:55 +0100)] 
dwarf: Multi-register CFI address support

Add support for architectures such as AMD GCN, in which the pointer size is
larger than the register size.  This allows the CFI information to include
multi-register locations for the stack pointer, frame pointer, and return
address.

Note that this uses a newly proposed DWARF operator DW_OP_LLVM_piece_end,
which is currently only recognized by the ROCGDB debugger from AMD.  The exact
name and encoding for this operator is subject to change if and when the DWARF
standard accepts it.

gcc/ChangeLog:

* dwarf2cfi.c (dw_stack_pointer_regnum): Change type to struct cfa_reg.
(dw_frame_pointer_regnum): Likewise.
(new_cfi_row): Use set_by_dwreg.
(get_cfa_from_loc_descr): Use set_by_dwreg.  Support register spans
with DW_OP_piece and DW_OP_LLVM_piece_end.  Support DW_OP_lit*,
DW_OP_const*, DW_OP_minus, and DW_OP_plus.
(lookup_cfa_1): Use set_by_dwreg.
(def_cfa_0): Update for cfa_reg and support register spans.
(reg_save): Change sreg parameter to struct cfa_reg.  Support register
spans.
(dwf_cfa_reg): New function.
(dwarf2out_flush_queued_reg_saves): Use dwf_cfa_reg instead of
dwf_regno.
(dwarf2out_frame_debug_def_cfa): Likewise.
(dwarf2out_frame_debug_adjust_cfa): Likewise.
(dwarf2out_frame_debug_cfa_offset): Likewise.  Update reg_save usage.
(dwarf2out_frame_debug_cfa_register): Likewise.
(dwarf2out_frame_debug_expr): Likewise.
(create_pseudo_cfg): Use set_by_dwreg.
(initial_return_save): Use set_by_dwreg and dwf_cfa_reg,
(create_cie_data): Use dwf_cfa_reg.
(execute_dwarf2_frame): Use dwf_cfa_reg.
(dump_cfi_row): Use set_by_dwreg.
* dwarf2out.c (build_span_loc): New function.
(build_cfa_loc): Support register spans.
(build_cfa_aligned_loc): Update cfa_reg usage.
(convert_cfa_to_fb_loc_list): Use set_by_dwreg.
* dwarf2out.h (struct cfa_reg): New type.
(struct dw_cfa_location): Use struct cfa_reg.
(build_span_loc): New prototype.
* gengtype.c (main): Accept poly_uint16_pod type.

include/ChangeLog:

* dwarf2.def (DW_OP_LLVM_piece_end): New extension operator.

4 years agoDaily bump.
GCC Administrator [Mon, 21 Sep 2020 00:17:01 +0000 (00:17 +0000)] 
Daily bump.

4 years agoFix linkage with -nodefaultlibs option.
John David Anglin [Sun, 20 Sep 2020 19:39:42 +0000 (19:39 +0000)] 
Fix linkage with -nodefaultlibs option.

2020-09-20  John David Anglin  < danglin@gcc.gnu.org>

gcc/ChangeLog
* config/pa/pa-hpux11.h (LINK_GCC_C_SEQUENCE_SPEC): Delete.
* config/pa/pa64-hpux.h (LINK_GCC_C_SEQUENCE_SPEC): Likewise.
(ENDFILE_SPEC): Link with libgcc_stub.a and mill.a.
* config/pa/pa32-linux.h (ENDFILE_SPEC): Link with libgcc.a.

4 years agoDaily bump.
GCC Administrator [Sun, 20 Sep 2020 00:16:56 +0000 (00:16 +0000)] 
Daily bump.

4 years agonvptx: fix malformed patch
Andrew Stubbs [Sat, 19 Sep 2020 18:16:28 +0000 (19:16 +0100)] 
nvptx: fix malformed patch

An edit got botched. Fixed now.

libgomp/

* config/nvptx/bar.c (gomp_team_barrier_wake): Remove rogue asm.

4 years agoDaily bump.
GCC Administrator [Sat, 19 Sep 2020 00:17:02 +0000 (00:17 +0000)] 
Daily bump.

4 years agoFortran: Avoid double-free with parse error (PR96041, PR93423)
Tobias Burnus [Thu, 17 Sep 2020 12:01:09 +0000 (14:01 +0200)] 
Fortran: Avoid double-free with parse error (PR96041, PR93423)

gcc/fortran/

PR fortran/96041
PR fortran/93423
* decl.c (gfc_match_submod_proc): Avoid later double-free
in the error case.

(cherry picked from commit c12facd22881517127ebbe213d7ecc7fc1fcea4e)

4 years agoPR fortran/93423 - ICE on invalid with argument list for module procedure
Harald Anlauf [Thu, 2 Jul 2020 18:48:16 +0000 (20:48 +0200)] 
PR fortran/93423 - ICE on invalid with argument list for module procedure

When recovering from an error, a NULL pointer dereference could occur.
Check for that situation and punt.

gcc/fortran/
PR fortran/93423
* resolve.c (resolve_symbol): Avoid NULL pointer dereference.

(cherry picked from commit b88744905a46be44ffa3c57d46080f601ae832b8)

4 years agoamdgcn: Remove omp_gcn pass
Andrew Stubbs [Thu, 17 Sep 2020 11:48:21 +0000 (12:48 +0100)] 
amdgcn: Remove omp_gcn pass

This pass only had an optimization for obtaining team/thread numbers in it,
and that turns out to be invalid in the presence of nested parallel regions,
so we can simply delete the whole thing.

Of course, it would be nice to apply the optimization where it is valid, but
that will take more effort than I have to spend right now.

gcc/ChangeLog:

* config/gcn/gcn-tree.c (execute_omp_gcn): Delete.
(make_pass_omp_gcn): Delete.
* config/gcn/t-gcn-hsa (PASSES_EXTRA): Delete.
* config/gcn/gcn-passes.def: Removed.

(cherry picked from commit 220724c311473b8b0f2418350c2b64e796e92bda)

4 years agolibgomp: disable barriers in nested teams
Andrew Stubbs [Thu, 17 Sep 2020 11:53:39 +0000 (12:53 +0100)] 
libgomp: disable barriers in nested teams

Both GCN and NVPTX allow nested parallel regions, but the barrier
implementation did not allow the nested teams to run independently of each
other (due to hardware limitations).  This patch fixes that, under the
assumption that each thread will create a new subteam of one thread, by
simply not using barriers when there's no other thread to synchronise.

libgomp/ChangeLog:

* config/gcn/bar.c (gomp_barrier_wait_end): Skip the barrier if the
total number of threads is one.
(gomp_team_barrier_wake): Likewise.
(gomp_team_barrier_wait_end): Likewise.
(gomp_team_barrier_wait_cancel_end): Likewise.
* config/nvptx/bar.c (gomp_barrier_wait_end): Likewise.
(gomp_team_barrier_wake): Likewise.
(gomp_team_barrier_wait_end): Likewise.
(gomp_team_barrier_wait_cancel_end): Likewise.
* testsuite/libgomp.c-c++-common/nested-parallel-unbalanced.c: New test.

4 years agolibgomp.c-c++-common/pr96390.c: XFAIL on nvptx.
Tobias Burnus [Fri, 18 Sep 2020 11:18:40 +0000 (04:18 -0700)] 
libgomp.c-c++-common/pr96390.c: XFAIL on nvptx.

libgomp/

* testsuite/libgomp.c-c++-common/pr96390.c: XFAIL on nvptx.
* testsuite/libgomp.c++/pr96390.C: Likewise.

4 years agoDaily bump.
GCC Administrator [Fri, 18 Sep 2020 00:16:57 +0000 (00:16 +0000)] 
Daily bump.

4 years agoOpenMP: Fix declare-target discovery with aliasing
Tobias Burnus [Thu, 17 Sep 2020 22:14:30 +0000 (15:14 -0700)] 
OpenMP: Fix declare-target discovery with aliasing

        PR middle-end/96390
        * omp-offload.c (omp_discover_declare_target_tgt_fn_r): Fix
        offloadable setting with target_alias.

4 years agoMerge remote-tracking branch 'origin/releases/gcc-10' into devel/omp/gcc-10
Tobias Burnus [Thu, 17 Sep 2020 16:55:32 +0000 (18:55 +0200)] 
Merge remote-tracking branch 'origin/releases/gcc-10' into devel/omp/gcc-10

Merge up to d01c3def63caf59d1d156aec8d52a1540e5ffe27 (2020-09-17)

4 years agoOpenMP: Handle cpp_implicit_alias in declare-target discovery (PR96390)
Tobias Burnus [Thu, 17 Sep 2020 16:45:00 +0000 (18:45 +0200)] 
OpenMP: Handle cpp_implicit_alias in declare-target discovery (PR96390)

Submitted to mainline at
https://gcc.gnu.org/pipermail/gcc-patches/2020-September/554142.html

gcc/ChangeLog:

PR middle-end/96390
* omp-offload.c (omp_discover_declare_target_tgt_fn_r): Handle
alias nodes.

libgomp/ChangeLog:

PR middle-end/96390
* testsuite/libgomp.c++/pr96390.C: New test.
* testsuite/libgomp.c-c++-common/pr96390.c: New test.

4 years agoopenmp: Also implicitly mark as declare target to functions mentioned in target regions
Jakub Jelinek [Thu, 17 Sep 2020 16:43:33 +0000 (18:43 +0200)] 
openmp: Also implicitly mark as declare target to functions mentioned in target regions

OpenMP 5.0 also specifies that functions referenced from target regions
(except for target regions with device(ancestor:)) are also implicitly declare target to.

This patch implements that.

2020-05-14  Jakub Jelinek  <jakub@redhat.com>

* function.h (struct function): Add has_omp_target bit.
* omp-offload.c (omp_discover_declare_target_fn_r): New function,
old renamed to ...
(omp_discover_declare_target_tgt_fn_r): ... this.
(omp_discover_declare_target_var_r): Call
omp_discover_declare_target_tgt_fn_r instead of
omp_discover_declare_target_fn_r.
(omp_discover_implicit_declare_target): Also queue functions with
has_omp_target bit set, for those walk with
omp_discover_declare_target_fn_r, for declare target to functions
walk with omp_discover_declare_target_tgt_fn_r.
gcc/c/
* c-parser.c (c_parser_omp_target): Set cfun->has_omp_target.
gcc/cp/
* cp-gimplify.c (cp_genericize_r): Set cfun->has_omp_target.
gcc/fortran/
* trans-openmp.c: Include function.h.
(gfc_trans_omp_target): Set cfun->has_omp_target.
libgomp/
* testsuite/libgomp.c-c++-common/target-40.c: New test.

(cherry picked from commit 49ddde69fc8e1e4c48d4b0027ea37ac862da0f1f)

4 years agoopenmp: Implement discovery of implicit declare target to clauses
Jakub Jelinek [Thu, 17 Sep 2020 16:36:28 +0000 (18:36 +0200)] 
openmp: Implement discovery of implicit declare target to clauses

This attempts to implement what the OpenMP 5.0 spec in declare target section
says as ammended by the 5.1 changes so far (related to device_type(host)), except
that it doesn't have the device(ancestor: ...) handling yet because we do not
support it yet, and I've left so far out the except lambda note, because I need
that clarified.

2020-05-12  Jakub Jelinek  <jakub@redhat.com>

* omp-offload.h (omp_discover_implicit_declare_target): Declare.
* omp-offload.c: Include context.h.
(omp_declare_target_fn_p, omp_declare_target_var_p,
omp_discover_declare_target_fn_r, omp_discover_declare_target_var_r,
omp_discover_implicit_declare_target): New functions.
* cgraphunit.c (analyze_functions): Call
omp_discover_implicit_declare_target.

* testsuite/libgomp.c/target-39.c: New test.

(cherry picked from commit dc703151d4f4560e647649506d5b4ceb0ee11e90)

4 years agopreprocessor: Fix ICE with too long line in fmtwarn [PR96935]
Marek Polacek [Wed, 16 Sep 2020 13:27:29 +0000 (09:27 -0400)] 
preprocessor: Fix ICE with too long line in fmtwarn [PR96935]

Here we ICE in char_span::subspan because the offset it gets is -1.
It's -1 because get_substring_ranges_for_loc gets a location whose
column was 0.  That only happens in testcases like the attached where
we're dealing with extremely long lines (at least 4065 chars it seems).
This does happen in practice, though, so it's not just a theoretical
problem (e.g. when building the SU2 suite).

Fixed by checking that the column get_substring_ranges_for_loc gets is
sane, akin to other checks in that function.

gcc/ChangeLog:

PR preprocessor/96935
* input.c (get_substring_ranges_for_loc): Return if start.column
is less than 1.

gcc/testsuite/ChangeLog:

PR preprocessor/96935
* gcc.dg/format/pr96935.c: New test.

(cherry picked from commit 31dd5cd6344bfbbe122fb512993b128e11236d35)

4 years agoFix warning messages in libgomp.oacc-fortran/privatized-ref-1.f95 testcase
Kwok Cheung Yeung [Thu, 17 Sep 2020 10:16:04 +0000 (03:16 -0700)] 
Fix warning messages in libgomp.oacc-fortran/privatized-ref-1.f95 testcase

2020-09-17  Kwok Cheung Yeung  <kcy@codesourcery.com>

libgomp/
* testsuite/libgomp.oacc-fortran/privatized-ref-1.f95 (workers, vectors):
Reduce number of workers to 16.

4 years agoIf -mavx implies -mxsave, then -mno-xsave should imply -mno-avx.
liuhongt [Wed, 16 Sep 2020 05:56:30 +0000 (13:56 +0800)] 
If -mavx implies -mxsave, then -mno-xsave should imply -mno-avx.

Current status is -mno-avx implies -mno-xsave which should be wrong.

gcc/ChangeLog

* common/config/i386/i386-common.c
(OPTION_MASK_ISA_AVX_UNSET): Remove OPTION_MASK_ISA_XSAVE_UNSET.
(OPTION_MASK_ISA_XSAVE_UNSET): Add OPTION_MASK_ISA_AVX_UNSET.

gcc/testsuite/ChangeLog

* gcc.target/i386/xsave-avx-1.c: New test.

4 years agoDaily bump.
GCC Administrator [Thu, 17 Sep 2020 00:17:05 +0000 (00:17 +0000)] 
Daily bump.

4 years agoXFAIL libgomp.oacc-fortran/privatized-ref-2.f90 on nvptx
Kwok Cheung Yeung [Wed, 16 Sep 2020 17:19:35 +0000 (10:19 -0700)] 
XFAIL libgomp.oacc-fortran/privatized-ref-2.f90 on nvptx

The testcase uses alloca, which is not currently supported on nvptx
(see PR65181).

2020-09-16  Kwok Cheung Yeung  <kcy@codesourcery.com>

libgomp/
* testsuite/libgomp.oacc-fortran/privatized-ref-2.f90: XFAIL on nvptx.

4 years agoFortran: OpenMP - fix simd with (last)private (PR97061)
Tobias Burnus [Wed, 16 Sep 2020 14:25:55 +0000 (16:25 +0200)] 
Fortran: OpenMP - fix simd with (last)private (PR97061)

gcc/fortran/ChangeLog:

PR fortran/97061
* trans-openmp.c (gfc_trans_omp_do): Handle simd with (last)private.

gcc/testsuite/ChangeLog:

PR fortran/97061
* gfortran.dg/gomp/openmp-simd-6.f90: New test.

(cherry picked from commit 91347c3bbf788ede4af89f46206991c47fa8aceb)

4 years agoMerge remote-tracking branch 'origin/releases/gcc-10' into devel/omp/gcc-10
Tobias Burnus [Wed, 16 Sep 2020 14:19:53 +0000 (16:19 +0200)] 
Merge remote-tracking branch 'origin/releases/gcc-10' into devel/omp/gcc-10

Merge up to 7e97e7470e74b0d9a68000938a359a7049774d77 (2020-09-16)

4 years ago[OpenMP] Fix mapping of artificial variables (PR94874)
Tobias Burnus [Wed, 16 Sep 2020 14:19:35 +0000 (16:19 +0200)] 
[OpenMP] Fix mapping of artificial variables (PR94874)

gcc/c-family/ChangeLog:

* c-common.h (c_omp_predetermined_mapping): Declare.
* c-omp.c (c_omp_predetermined_mapping): New.

gcc/c/ChangeLog:

* c-objc-common.h (LANG_HOOKS_OMP_PREDETERMINED_MAPPING): Redefine.

gcc/cp/ChangeLog:

* cp-gimplify.c (cxx_omp_predetermined_mapping): New.
* cp-objcp-common.h (LANG_HOOKS_OMP_PREDETERMINED_MAPPING): Redfine.
* cp-tree.h (cxx_omp_predetermined_mapping): Declare.

gcc/fortran/ChangeLog:

* f95-lang.c (LANG_HOOKS_OMP_PREDETERMINED_MAPPING): Redefine.
* trans-openmp.c (gfc_omp_predetermined_mapping): New.
* trans.h (gfc_omp_predetermined_mapping): Declare.

gcc/ChangeLog:

* gimplify.c (omp_notice_variable): Use new hook.
* langhooks-def.h (lhd_omp_predetermined_mapping): Declare.
(LANG_HOOKS_OMP_PREDETERMINED_MAPPING): Define
(LANG_HOOKS_DECLS): Add it.
* langhooks.c (lhd_omp_predetermined_sharing): Remove bogus unused attr.
(lhd_omp_predetermined_mapping): New.
* langhooks.h (struct lang_hooks_for_decls): Add new hook.

gcc/testsuite/ChangeLog
2020-06-03  Thomas Schwinge  <thomas@codesourcery.com>
    Tobias Burnus  <tobias@codesourcery.com>

PR middle-end/94874
* c-c++-common/gomp/pr94874.c: New.

(cherry picked from commit 93535a2b40367e6f68433295b37dc52c0e9c2c55)

4 years agoOpenMP/Fortran: Permit impure ELEMENTAL in omp directives
Tobias Burnus [Wed, 16 Sep 2020 14:13:15 +0000 (16:13 +0200)] 
OpenMP/Fortran: Permit impure ELEMENTAL in omp directives

OpenMP since 4.5 permits IMPURE ELEMENTAL in directives and
the code already only checked for PURE. – Followup for
-fopenmp-simd.

gcc/fortran/ChangeLog:

* parse.c (decode_omp_directive): Remove "or ELEMENTAL"
from "in PURE" error message also for -fopenmp-simd.

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/pr79154-simd.f90: New test.

(cherry picked from commit 244ed2adaa3d349d381ca6ce090c2fa69b6e8d8b)