Re: [Ada,FYI] revamp ada.numerics.aux

2020-10-23 Thread Iain Sandoe
Rainer Orth  wrote:

> Hi Alexandre,
> 
>> On Oct 19, 2020, Andreas Schwab  wrote:
>> 
>>> -nostdinc a-nallfl.ads -o a-nallfl.o
>>> a-nallfl.ads:48:13: warning: intrinsic binding type mismatch on return value
>>> a-nallfl.ads:48:13: warning: intrinsic binding type mismatch on argument 1
>>> a-nallfl.ads:48:13: warning: profile of "Sin" doesn't match the builtin
>>> it binds
>> 
>> Thanks for the report.  Ada's Standard.Long_Long_Float is mapped to C
>> double rather than long double on this target.
>> 
>> Here's a workaround, for aarch64-* and ppc*-linux-gnu, where I've
>> observed the mismatch so far.
> 
> your patch similarly broke sparc*-sun-solaris* bootstrap.  The attached
> snippet on top of this workaround fixes that.

Also powerpc-darwin.

FAOD - these functions only related to the C “double” [64bit] type, right?
(i.e. this is not related to the use of of long double [on powerpc darwin, the
 default for that is the same as AIX - ibm128]). 

thanks
Iain

[PATCH] Darwin, Ada, PowerPC : Fix bootstrap after recent change.

---
 gcc/ada/Makefile.rtl | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/ada/Makefile.rtl b/gcc/ada/Makefile.rtl
index 7a0c05b423d..9fd9f6af25f 100644
--- a/gcc/ada/Makefile.rtl
+++ b/gcc/ada/Makefile.rtl
@@ -2778,6 +2778,7 @@ ifeq ($(strip $(filter-out darwin%,$(target_os))),)
 
   ifeq ($(strip $(filter-out powerpc%,$(target_cpu))),)
 LIBGNAT_TARGET_PAIRS += \
+  a-nallfl.ads

Re: [Ada] Improve precision of Ada.Directories.Modification_Time

2020-10-23 Thread Iain Sandoe
Hans-Peter Nilsson  wrote:

> On Wed, 21 Oct 2020, Iain Sandoe wrote:
> 
>> Arnaud Charlet  wrote:
>> 
 This patch breaks bootstrap on Darwin platforms.
 
 Pierre-Marie de Rodat  wrote:
 
> The modification file time precision now defined by OS.
> 
> Tested on x86_64-pc-linux-gnu, committed on trunk
> 
> gcc/ada/
> 
>   * adaint.c (__gnat_file_time): New routine.
>   (__gnat_copy_attribs): Copy timestamps in nanoseconds.
>   * libgnat/a-direct.adb (C_Modification_Time): Bind to
>   __gnat_file_time.
>   (Modification_Time): Call to C_Modification_Time.
 
 #if defined(st_mtime)
 
 is a necessary test - but the fields in the stat structure on Darwin
 platforms are
 named st_{a,c,m}timespec rather than the Linux st_{a,c,m}tim.
>>> 
>>> What about instead putting above extern long long __gnat_file_time the
>>> following:
>>> 
>>> #if __APPLE__
>>> #define st_mtim st_mtimespec
>>> #define st_atim st_atimespec
>>> #endif
>>> 
>>> To avoid having the two (nested) #if __APPLE__ and keep the code easier
>>> to follow?
>> 
>> works for me (the test patch was drafted quickly to allow bootstrap to
>> continue)
>> - I can amend the patch and (re-)test more widely.
>> 
>> Iain
> 
> For future reference, TRT for this kind of problem is to
> autoconf for the right struct field name, using AC_CHECK_MEMBER
> or AC_CHECK_MEMBERS (then use e.g. #if HAVE_STAT_ST_MTIM / #if
> HAVE_STAT_ST_MTIMESPEC, definitely not #if __APPLE__).

I’m not diasgreeing with your technical comment; now I am in a difficult 
position.
I don’t have resources at the moment to make the changes you suggest, and
Darwin is bootstrap-broken (at least for Ada).

so .. the attached is a workaround - now I’ve resolved the second bootstrap 
issue
on powerpc-darwin, I was able to test it more widely.

I have *not* applied the patch, pending a “proper” solution at some unspecified
time in the future .. 

Iain


==

Darwin has timeval entries for file access and modification
times but they are named differently from those on Linux (and
presumably everywhere else, since no other platform has
reported an issue).
---
 gcc/ada/adaint.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c
index b7406a03c31..560f3529442 100644
--- a/gcc/ada/adaint.c
+++ b/gcc/ada/adaint.c
@@ -237,6 +237,11 @@ UINT __gnat_current_ccs_encoding;
 
 #include "adaint.h"
 
+#if defined (__APPLE__) && defined (st_mtime)
+#define st_atim st_atimespec
+#define st_mtim st_mtimespec
+#endif
+
 /* Define symbols O_BINARY and O_TEXT as harmless zeroes if they are not
defined in the current system. On DOS-like systems these flags control
whether the file is opened/created in text-translation mode (CR/LF in
-- 
2.24.1





Re: [PATCH][Arm] Auto-vectorization for MVE: vsub

2020-10-23 Thread Dennis Zhang via Gcc-patches
Hi Kyrylo,

> 
> From: Kyrylo Tkachov 
> Sent: Thursday, October 22, 2020 9:40 AM
> To: Dennis Zhang; gcc-patches@gcc.gnu.org
> Cc: nd; Richard Earnshaw; Ramana Radhakrishnan
> Subject: RE: [PATCH][Arm] Auto-vectorization for MVE: vsub
>
> Hi Dennis,
>
> > -Original Message-
> > From: Dennis Zhang 
> > Sent: 06 October 2020 17:47
> > To: gcc-patches@gcc.gnu.org
> > Cc: Kyrylo Tkachov ; nd ;
> > Richard Earnshaw ; Ramana Radhakrishnan
> > 
> > Subject: Re: [PATCH][Arm] Auto-vectorization for MVE: vsub
> >
> > Hi all,
> >
> > On 8/17/20 6:41 PM, Dennis Zhang wrote:
> > >
> > > Hi all,
> > >
> > > This patch enables MVE vsub instructions for auto-vectorization.
> > > It adds RTL templates for MVE vsub instructions using 'minus' instead of
> > > unspec expression to make the instructions recognizable for vectorization.
> > > MVE target is added in sub3 optab. The sub3 optab is
> > > modified to use a mode iterator that selects available modes for various
> > > targets correspondingly.
> > > MVE vector modes are enabled in arm_preferred_simd_mode in arm.c to
> > > support vectorization.
> > >
> > > This patch also fixes 'vreinterpretq_*.c' MVE intrinsic tests. The tests
> > > generate wrong instruction numbers because of unexpected icf
> > optimization.
> > > This bug is exposed by the MVE vector modes enabled in this patch,
> > > therefore it is corrected in this patch to avoid test failures.
> > >
> > > MVE instructions are documented here:
> > > https://developer.arm.com/architectures/instruction-sets/simd-
> > isas/helium/helium-intrinsics
> > >
> > > The patch is regtested for arm-none-eabi and bootstrapped for
> > > arm-none-linux-gnueabihf.
> > >
> > > Is it OK for trunk please?
> > >
> > > Thanks
> > > Dennis
> > >
> > > gcc/ChangeLog:
> > >
> > > 2020-08-10  Dennis Zhang  
> > >
> > > * config/arm/arm.c (arm_preferred_simd_mode): Enable MVE vector
> > modes.
> > > * config/arm/arm.h (TARGET_NEON_IWMMXT): New macro.
> > > (TARGET_NEON_IWMMXT_MVE, TARGET_NEON_IWMMXT_MVE_FP):
> > Likewise.
> > > (TARGET_NEON_MVE_HFP): Likewise.
> > > * config/arm/iterators.md (VSEL): New mode iterator to select modes
> > > for corresponding targets.
> > > * config/arm/mve.md (mve_vsubq): New entry for vsub instruction
> > > using expression 'minus'.
> > > (mve_vsubq_f): Use minus instead of VSUBQ_F unspec.
> > > * config/arm/neon.md (sub3): Removed here. Integrated in the
> > > sub3 in vec-common.md
> > > * config/arm/vec-common.md (sub3): Enable MVE target. Use
> > VSEL
> > > to select available modes. Exclude TARGET_NEON_FP16INST from
> > > TARGET_NEON statement. Intergrate TARGET_NEON_FP16INST which is
> > > originally in neon.md.
> > >
> > > gcc/testsuite/ChangeLog:
> > >
> > > 2020-08-10  Dennis Zhang  
> > >
> > > * gcc.target/arm/mve/intrinsics/vreinterpretq_f16.c: Use additional
> > > option -fno-ipa-icf and change the instruction count from 8 to 16.
> > > * gcc.target/arm/mve/intrinsics/vreinterpretq_f32.c: Likewise.
> > > * gcc.target/arm/mve/intrinsics/vreinterpretq_s16.c: Likewise.
> > > * gcc.target/arm/mve/intrinsics/vreinterpretq_s32.c: Likewise.
> > > * gcc.target/arm/mve/intrinsics/vreinterpretq_s64.c: Likewise.
> > > * gcc.target/arm/mve/intrinsics/vreinterpretq_s8.c: Likewise.
> > > * gcc.target/arm/mve/intrinsics/vreinterpretq_u16.c: Likewise.
> > > * gcc.target/arm/mve/intrinsics/vreinterpretq_u32.c: Likewise.
> > > * gcc.target/arm/mve/intrinsics/vreinterpretq_u64.c: Likewise.
> > > * gcc.target/arm/mve/intrinsics/vreinterpretq_u8.c: Likewise.
> > > * gcc.target/arm/mve/mve.exp: Include tests in subdir 'vect'.
> > > * gcc.target/arm/mve/vect/vect_sub_0.c: New test.
> > > * gcc.target/arm/mve/vect/vect_sub_1.c: New test.
> > >
> >
> > This patch is updated based on Richard Sandiford's patch adding new
> > vector mode macros:
> > https://gcc.gnu.org/pipermail/gcc-patches/2020-September/553425.html
> > The old version of this patch is at
> > https://gcc.gnu.org/pipermail/gcc-patches/2020-August/552104.html
> > And a less related part in the old version is separated into another
> > patch: https://gcc.gnu.org/pipermail/gcc-patches/2020-
> > September/554100.html
> >
> > This patch enables MVE vsub instructions for auto-vectorization.
> > It adds insns for MVE vsub instructions using 'minus' instead of unspec
> > expression to make the instructions recognizable for auto-vectorization.
> > The sub3 in mve.md is modified to use new mode macros which
> > make
> > the expander available when certain modes are supported. Then various
> > targets can share this expander for vectorization. The redundant
> > sub3 insns in neon.md are then removed.
> >
> > Regression tested on arm-none-eabi and bootstraped on
> > arm-none-linux-gnueabihf.
> >
> > Is it OK for trunk please?
>
> Ok.
> Thanks,
> Kyrill
>

Thanks for your approval. The patch has been committed as 
98161c248c88f873bbffba23664c540f551d89d5

Bests
Dennis

> >
> > gcc/ChangeLog:
> >
> > 2020-10-02  Dennis Zh

Re: [Ada] Build support units for 128-bit integer types on 64-bit platforms

2020-10-23 Thread Andreas Schwab
ut %86_64 
> dragonfly%,$(target_cpu) $(target_os))),)
>s-tpopsp.adb$(ATOMICS_TARGET_PAIRS) \
>$(X86_64_TARGET_PAIRS) \
> +  $(GNATRTL_128BIT_PAIRS) \
>system.ads  
>GNATLIB_SHARED = gnatlib-shared-dual
>  
> -  EXTRA_GNATRTL_NONTASKING_OBJS=g-sse.o g-ssvety.o
> +  EXTRA_GNATRTL_NONTASKING_OBJS += g-sse.o g-ssvety.o
> +  EXTRA_GNATRTL_NONTASKING_OBJS += $(GNATRTL_128BIT_OBJS)
>  
>EH_MECHANISM=-gcc
>THREADSLIB= -lpthread
> @@ -1919,6 +1960,18 @@ ifeq ($(strip $(filter-out s390% linux%,$(target_cpu) 
> $(target_os))),)
>s-tpopsp.adbsystem.ads  
> +  ifeq ($(strip $(filter-out s390x,$(target_cpu))),)
> +ifneq ($(strip $(MULTISUBDIR)),/32)
> +  LIBGNAT_TARGET_PAIRS += $(GNATRTL_128BIT_PAIRS)
> +  EXTRA_GNATRTL_NONTASKING_OBJS += $(GNATRTL_128BIT_OBJS)
> +endif
> +  else
> +ifeq ($(strip $(MULTISUBDIR)),/64)
> +  LIBGNAT_TARGET_PAIRS += $(GNATRTL_128BIT_PAIRS)
> +  EXTRA_GNATRTL_NONTASKING_OBJS += $(GNATRTL_128BIT_OBJS)
> +endif
> +  endif
> +
>TOOLS_TARGET_PAIRS = indepsw.adb  
>EXTRA_GNATRTL_TASKING_OBJS=s-linux.o
> @@ -2208,7 +2261,7 @@ endif
>  
>  # PowerPC and e500v2 Linux
>  ifeq ($(strip $(filter-out powerpc% linux%,$(target_cpu) $(target_os))),)
> -  LIBGNAT_TARGET_PAIRS_COMMON = \
> +  LIBGNAT_TARGET_PAIRS = \
>a-exetim.adba-exetim.adsa-intnam.ads @@ -2220,21 +2273,30 @@ ifeq ($(strip $(filter-out powerpc% 
> linux%,$(target_cpu) $(target_os))),)
>s-linux.adss-osinte.adbs-tpopsp.adb +  s-mudido.adb +  s-osinte.ads +  s-osprim.adb +  s-taprop.adb +  s-tasinf.ads +  s-tasinf.adb +  s-taspri.ads$(TRASYM_DWARF_UNIX_PAIRS) \
>s-tsmona.adb$(ATOMICS_TARGET_PAIRS) \
>$(ATOMICS_BUILTINS_TARGET_PAIRS) \
>system.ads  
> -  LIBGNAT_TARGET_PAIRS = \
> -$(LIBGNAT_TARGET_PAIRS_COMMON) \
> -s-mudido.adb -s-osinte.ads -s-osprim.adb -s-taprop.adb -s-tasinf.ads -s-tasinf.adb -s-taspri.ads +  ifeq ($(strip $(filter-out powerpc64,$(target_cpu))),)
> +ifneq ($(strip $(MULTISUBDIR)),/32)
> +  LIBGNAT_TARGET_PAIRS += $(GNATRTL_128BIT_PAIRS)
> +  EXTRA_GNATRTL_NONTASKING_OBJS += $(GNATRTL_128BIT_OBJS)
> +endif
> +  else
> +ifeq ($(strip $(MULTISUBDIR)),/64)
> +  LIBGNAT_TARGET_PAIRS += $(GNATRTL_128BIT_PAIRS)
> +  EXTRA_GNATRTL_NONTASKING_OBJS += $(GNATRTL_128BIT_OBJS)
> +endif
> +  endif
>  
>TOOLS_TARGET_PAIRS = indepsw.adb  
> @@ -2301,10 +2363,12 @@ ifeq ($(strip $(filter-out aarch64% 
> linux%,$(target_cpu) $(target_os))),)
>s-taspri.ads$(ATOMICS_TARGET_PAIRS) \
>$(ATOMICS_BUILTINS_TARGET_PAIRS) \
> +  $(GNATRTL_128BIT_PAIRS) \
>system.ads  
>TOOLS_TARGET_PAIRS = indepsw.adb  
> +  EXTRA_GNATRTL_NONTASKING_OBJS = $(GNATRTL_128BIT_OBJS)
>EXTRA_GNATRTL_TASKING_OBJS=s-linux.o a-exetim.o
>EH_MECHANISM=-gcc
>THREADSLIB=-lpthread -lrt
> @@ -2313,7 +2377,7 @@ ifeq ($(strip $(filter-out aarch64% 
> linux%,$(target_cpu) $(target_os))),)
>LIBRARY_VERSION := $(LIB_VERSION)
>  endif
>  
> -# Sparc Linux
> +# SPARC Linux
>  ifeq ($(strip $(filter-out sparc% linux%,$(target_cpu) $(target_os))),)
>LIBGNAT_TARGET_PAIRS = \
>a-intnam.ads @@ -2330,6 +2394,18 @@ ifeq ($(strip $(filter-out sparc% linux%,$(target_cpu) 
> $(target_os))),)
>s-tpopsp.adbsystem.ads  
> +  ifeq ($(strip $(filter-out sparc64 sparcv9,$(target_cpu))),)
> +ifneq ($(strip $(MULTISUBDIR)),/32)
> +  LIBGNAT_TARGET_PAIRS += $(GNATRTL_128BIT_PAIRS)
> +  EXTRA_GNATRTL_NONTASKING_OBJS += $(GNATRTL_128BIT_OBJS)
> +endif
> +  else
> +ifeq ($(strip $(MULTISUBDIR)),/64)
> +  LIBGNAT_TARGET_PAIRS += $(GNATRTL_128BIT_PAIRS)
> +  EXTRA_GNATRTL_NONTASKING_OBJS += $(GNATRTL_128BIT_OBJS)
> +endif
> +  endif
> +
>TOOLS_TARGET_PAIRS = indepsw.adb  
>EXTRA_GNATRTL_TASKING_OBJS=s-linux.o
> @@ -2447,11 +2523,13 @@ ifeq ($(strip $(filter-out %ia64 linux%,$(target_cpu) 
> $(target_os))),)
>s-tsmona.adb$(ATOMICS_TARGET_PAIRS) \
>$(ATOMICS_BUILTINS_TARGET_PAIRS) \
> +  $(GNATRTL_128BIT_PAIRS) \
>system.ads  
>TOOLS_TARGET_PAIRS = indepsw.adb  
>EXTRA_GNATRTL_NONTASKING_OBJS += $(TRASYM_DWARF_UNIX_OBJS)
> +  EXTRA_GNATRTL_NONTASKING_OBJS += $(GNATRTL_128BIT_OBJ
>EXTRA_GNATRTL_TASKING_OBJS=s-linux.o a-exetim.o
>EH_MECHANISM=-gcc
>THREADSLIB=-lpthread -lrt

/usr/local/gcc/gcc-20201023/gcc/ada/Makefile.rtl:2834: *** unterminated 
variable reference.  Stop.

Andreas.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."


Re: [PATCH] xfail and improve some failing libgomp tests

2020-10-23 Thread Tom de Vries
On 10/22/20 3:19 PM, Jakub Jelinek wrote:
> On Tue, Oct 06, 2020 at 05:45:31PM +0200, Tom de Vries wrote:
>> I've updated the patch accordingly.
>>
>> FWIW, I now run into an ICE which looks like PR96680:
> 
> With the patch I've posted today to fix up declare variant LTO handling,
> Tobias reported the patch still doesn't work, and there are two
> reasons for that.
> One is that when the base function is marked implicitly as declare target,
> we don't mark also implicitly the variants.  I'll need to ask on omp-lang
> about details for that, but generally the compiler should do it some way.
> The other one is that the way base_delay is written, it will always
> call the usleep function, which is undesirable for nvptx.  While the
> compiler will replace all direct calls to base_delay to nvptx_delay,
> the base_delay definition which calls usleep stays.
> 
> The following should work instead (I've tested it without offloading and
> Tobias with offloading):
> 

I've tested this patch in combination with:
- "[PATCH] lto: LTO cgraph support for late declare variant resolution"
  https://gcc.gnu.org/pipermail/gcc-patches/2020-October/556793.html
- "[omp, simt] Handle alternative IV"
  https://gcc.gnu.org/pipermail/gcc-patches/2020-October/555352.html
on top of commit c26d7df1031 "OpenMP: Fortran - support omp flush's
memorder clauses".

The only FAILs I see are for PR97532 (
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97532 ), 10 in total.

So, LGTM.

Thanks,
- Tom

> 2020-10-22  Jakub Jelinek  
>   Tom de Vries  
> 
>   PR testsuite/81690
>   * testsuite/libgomp.c/usleep.h: New file.
>   * testsuite/libgomp.c/target-32.c: Include usleep.h.
>   (main): Use tgt_usleep instead of usleep.
>   * testsuite/libgomp.c/thread-limit-2.c: Include usleep.h.
>   (main): Use tgt_usleep instead of usleep.
> 
> --- gcc/libgomp/testsuite/libgomp.c/usleep.h.jj   2020-10-22 
> 14:45:14.034196695 +0200
> +++ gcc/libgomp/testsuite/libgomp.c/usleep.h  2020-10-22 14:48:05.186719495 
> +0200
> @@ -0,0 +1,24 @@
> +#include 
> +
> +int
> +nvptx_usleep (useconds_t d)
> +{
> +  /* This function serves as a replacement for usleep in
> + this test case.  It does not even attempt to be functionally
> + equivalent  - we just want some sort of delay. */
> +  int i;
> +  int N = d * 2000;
> +  for (i = 0; i < N; i++)
> +asm volatile ("" : : : "memory");
> +  return 0;
> +}
> +
> +#pragma omp declare variant (nvptx_usleep) 
> match(construct={target},device={arch(nvptx)})
> +#pragma omp declare variant (usleep) match(user={condition(1)})
> +int
> +tgt_usleep (useconds_t d)
> +{
> +  return 0;
> +}
> +
> +#pragma omp declare target to (nvptx_usleep, tgt_usleep)
> --- gcc/libgomp/testsuite/libgomp.c/target-32.c.jj2020-01-12 
> 11:54:39.037373820 +0100
> +++ gcc/libgomp/testsuite/libgomp.c/target-32.c   2020-10-22 
> 14:46:23.211195456 +0200
> @@ -1,5 +1,6 @@
>  #include 
>  #include 
> +#include "usleep.h"
>  
>  int main ()
>  {
> @@ -18,28 +19,28 @@ int main ()
>  
>  #pragma omp target nowait map(alloc: b) depend(in: d[2]) depend(out: 
> d[3])
>  {
> -  usleep (1000);
> +  tgt_usleep (1000);
>#pragma omp atomic update
>b |= 4;
>  }
>  
>  #pragma omp target nowait map(alloc: b) depend(in: d[2]) depend(out: 
> d[4])
>  {
> -  usleep (5000);
> +  tgt_usleep (5000);
>#pragma omp atomic update
>b |= 1;
>  }
>  
>  #pragma omp target nowait map(alloc: c) depend(in: d[3], d[4]) 
> depend(out: d[5])
>  {
> -  usleep (5000);
> +  tgt_usleep (5000);
>#pragma omp atomic update
>c |= 8;
>  }
>  
>  #pragma omp target nowait map(alloc: c) depend(in: d[3], d[4]) 
> depend(out: d[6])
>  {
> -  usleep (1000);
> +  tgt_usleep (1000);
>#pragma omp atomic update
>c |= 2;
>  }
> --- gcc/libgomp/testsuite/libgomp.c/thread-limit-2.c.jj   2020-01-12 
> 11:54:39.037373820 +0100
> +++ gcc/libgomp/testsuite/libgomp.c/thread-limit-2.c  2020-10-22 
> 14:57:31.957516284 +0200
> @@ -4,6 +4,7 @@
>  #include 
>  #include 
>  #include 
> +#include "usleep.h"
>  
>  int
>  main ()
> @@ -48,7 +49,7 @@ main ()
> v = ++cnt;
> if (v > 6)
>   abort ();
> -   usleep (1);
> +   tgt_usleep (1);
> #pragma omp atomic
> --cnt;
>   }
> 
> 
>   Jakub
> 


[Ada] Update header of front-end files

2020-10-23 Thread Pierre-Marie de Rodat
Some Ada front-end files had a runtime license exception header, which
is not needed since these files are pure compiler (tool) files, and not
runtime files.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

* alloc.ads, aspects.adb, aspects.ads, atree.adb, atree.ads,
casing.adb, casing.ads, csets.adb, csets.ads, debug.adb, debug.ads,
einfo.adb, einfo.ads, elists.adb, elists.ads, fname.adb, fname.ads,
gnatvsn.adb, gnatvsn.ads, hostparm.ads, indepsw-aix.adb,
indepsw-darwin.adb, indepsw-gnu.adb, indepsw.adb, indepsw.ads,
krunch.adb, krunch.ads, lib-list.adb, lib-sort.adb, lib.adb, lib.ads,
namet-sp.adb, namet-sp.ads, namet.adb, namet.ads, nlists.adb,
nlists.ads, opt.adb, opt.ads, output.adb, output.ads, rident.ads,
scans.adb, scans.ads, scil_ll.adb, scil_ll.ads, sem_aux.ads,
sem_aux.adb, sfn_scan.adb, sinfo.adb, sinfo.ads, sinput.adb,
sinput.ads, snames.adb-tmpl, snames.ads-tmpl, stand.ads,
stringt.adb, stringt.ads, table.adb, table.ads, types.adb,
types.ads, uintp.adb, uintp.ads, uname.adb, uname.ads,
urealp.adb, urealp.ads, vast.adb, vast.ads, widechar.adb,
widechar.ads: Update header.

patch.diff.gz
Description: application/gzip


[Ada] Sync code for external properties with SPARK RM

2020-10-23 Thread Pierre-Marie de Rodat
Originally the allowed combinations of external properties (i.e.
Async_Readers, Async_Writers, Effective_Writes and Effective_Reads) were
described in the SPARK RM as a sequence of conditions. Then they have
been rewritten as a table and now the correspondence between description
in the SPARK RM and implementation in GNAT is not obvious.

This patch makes the implementation to mirror the description;
otherwise, semantics is unaffected.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

* sem_prag.adb (Check_External_Properties): Rewrite to match the
SPARK RM description.diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb
--- a/gcc/ada/sem_prag.adb
+++ b/gcc/ada/sem_prag.adb
@@ -29600,44 +29600,38 @@ package body Sem_Prag is
   ER   : Boolean;
   EW   : Boolean)
is
-   begin
-  --  All properties enabled
-
-  if AR and AW and ER and EW then
- null;
-
-  --  Async_Readers + Effective_Writes
-  --  Async_Readers + Async_Writers + Effective_Writes
-
-  elsif AR and EW and not ER then
- null;
-
-  --  Async_Writers + Effective_Reads
-  --  Async_Readers + Async_Writers + Effective_Reads
-
-  elsif AW and ER and not EW then
- null;
-
-  --  Async_Readers + Async_Writers
-
-  elsif AR and AW and not ER and not EW then
- null;
+  type Properties is array (Positive range 1 .. 4) of Boolean;
+  type Combinations is array (Positive range <>) of Properties;
+  --  Arrays of Async_Readers, Async_Writers, Effective_Writes and
+  --  Effective_Reads properties and their combinations, respectively.
+
+  Specified : constant Properties := (AR, AW, EW, ER);
+  --  External properties, as given by the Item pragma
+
+  Allowed : constant Combinations :=
+(1 => (True,  False, True,  False),
+ 2 => (False, True,  False, True),
+ 3 => (True,  False, False, False),
+ 4 => (False, True,  False, False),
+ 5 => (True,  True,  True,  False),
+ 6 => (True,  True,  False, True),
+ 7 => (True,  True,  False, False),
+ 8 => (True,  True,  True,  True));
+  --  Allowed combinations, as listed in the SPARK RM 7.1.2(6) table
 
-  --  Async_Readers
-
-  elsif AR and not AW and not ER and not EW then
- null;
-
-  --  Async_Writers
+   begin
+  --  Check if the specified properties match any of the allowed
+  --  combination; if not, then emit an error.
 
-  elsif AW and not AR and not ER and not EW then
- null;
+  for J in Allowed'Range loop
+ if Specified = Allowed (J) then
+return;
+ end if;
+  end loop;
 
-  else
- SPARK_Msg_N
-   ("illegal combination of external properties (SPARK RM 7.1.2(6))",
-Item);
-  end if;
+  SPARK_Msg_N
+("illegal combination of external properties (SPARK RM 7.1.2(6))",
+ Item);
end Check_External_Properties;
 





[Ada] Fix default value for re-analysis of external property pragmas

2020-10-23 Thread Pierre-Marie de Rodat
Routine Analyze_External_Property_In_Decl_Part, which deals with pragmas
Async_Readers, Async_Writers, Effective_Reads, Effective_Writes,
returned early when the pragma has been already analyzed. When this
happened, its output parameter Expr_Val was set to False no matter what
the pragma argument was.

This was incorrect, especially since typically those pragmas are used
with no arguments, which implicitly means the argument is True. Now when
returning early the output parameter is set to the (implicit) argument
given by the pragma.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

* sem_prag.adb (Analyze_External_Property_In_Decl_Part): Set the
output parameter Expr_Val to the (implicit) pragma argument even
when returning early.diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb
--- a/gcc/ada/sem_prag.adb
+++ b/gcc/ada/sem_prag.adb
@@ -2101,12 +2101,11 @@ package body Sem_Prag is
   Expr : Node_Id;
 
begin
-  Expr_Val := False;
-
-  --  Do not analyze the pragma multiple times
+  --  Do not analyze the pragma multiple times, but set the output
+  --  parameter to the argument specified by the pragma.
 
   if Is_Analyzed_Pragma (N) then
- return;
+ goto Leave;
   end if;
 
   Error_Msg_Name_1 := Pragma_Name (N);
@@ -2147,6 +2146,10 @@ package body Sem_Prag is
  end if;
   end if;
 
+  Set_Is_Analyzed_Pragma (N);
+
+  <>
+
   --  Ensure that the Boolean expression (if present) is static. A missing
   --  argument defaults the value to True (SPARK RM 7.1.2(5)).
 
@@ -2160,7 +2163,6 @@ package body Sem_Prag is
  end if;
   end if;
 
-  Set_Is_Analyzed_Pragma (N);
end Analyze_External_Property_In_Decl_Part;
 
-




[Ada] Always enable the support for 128-bit integer types on 64-bit platforms

2020-10-23 Thread Pierre-Marie de Rodat
This lifts the condition of the presence of s-arit128.ads in order to
enable the support for 128-bit integer types on 64-bit platforms, the
rationale being that this mirrors the support for 64-bit integer types
on 32-bit platforms, which is always enabled.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

* gnat1drv.adb (Adjust_Global_Switches): Rewrite again code enabling
or disabling the support for 128-bit integer types.diff --git a/gcc/ada/gnat1drv.adb b/gcc/ada/gnat1drv.adb
--- a/gcc/ada/gnat1drv.adb
+++ b/gcc/ada/gnat1drv.adb
@@ -800,30 +800,21 @@ procedure Gnat1drv is
   end if;
 
   --  Enable or disable the support for 128-bit types. It is automatically
-  --  enabled if the back end supports them, unless not in GNAT mode and
-  --  either the runtime does not contain the required support units or the
-  --  switch -gnatd.H is specified.
+  --  enabled if the back end supports them, unless -gnatd.H is specified.
 
   Enable_128bit_Types := Ttypes.Standard_Long_Long_Long_Integer_Size = 128;
 
-  if Enable_128bit_Types and then not GNAT_Mode then
- Name_Len := 13;
- Name_Buffer (1 .. Name_Len) := "s-arit128.ads";
-
- if Find_File (Name_Find, Osint.Source, Full_Name => True) = No_File
-   or else Debug_Flag_Dot_HH
- then
-Enable_128bit_Types := False;
-
-Ttypes.Standard_Long_Long_Long_Integer_Size :=
-  Ttypes.Standard_Long_Long_Integer_Size;
-Ttypes.Standard_Long_Long_Long_Integer_Width :=
-  Ttypes.Standard_Long_Long_Integer_Width;
-Ttypes.System_Max_Integer_Size :=
-  Ttypes.Standard_Long_Long_Integer_Size;
-Ttypes.System_Max_Binary_Modulus_Power :=
-  Ttypes.Standard_Long_Long_Integer_Size;
- end if;
+  if Enable_128bit_Types and then Debug_Flag_Dot_HH then
+ Enable_128bit_Types := False;
+
+ Ttypes.Standard_Long_Long_Long_Integer_Size :=
+   Ttypes.Standard_Long_Long_Integer_Size;
+ Ttypes.Standard_Long_Long_Long_Integer_Width :=
+   Ttypes.Standard_Long_Long_Integer_Width;
+ Ttypes.System_Max_Integer_Size :=
+   Ttypes.Standard_Long_Long_Integer_Size;
+ Ttypes.System_Max_Binary_Modulus_Power :=
+   Ttypes.Standard_Long_Long_Integer_Size;
   end if;
 
   --  Finally capture adjusted value of Suppress_Options as the initial




[Ada] Prevent copying uninitialized array with address clause

2020-10-23 Thread Pierre-Marie de Rodat
An object of a nominal unconstrained array type may be given a subtype
by initialization with an aggregate with specified bounds and box
initialization. The freezing of the object copies the aggregate into
the object, which propagates uninitialized values if the component type
has no default specified. This patch introduces a predicate to recognize
and optimize away such useless copies, when the object includes an
address clause.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

* freeze.adb (Is_Uninitialized_Aggregate): Recognize an array
aggregate with box initialization, scalar components, and no
component default values.
(Freeze_Entity, Check_Address_Clause): Call it, and simplify
freeze code for entity by removing useless assignment.diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb
--- a/gcc/ada/freeze.adb
+++ b/gcc/ada/freeze.adb
@@ -182,6 +182,12 @@ package body Freeze is
--  the designated type. Otherwise freezing the access type does not freeze
--  the designated type.
 
+   function Is_Uninitialized_Aggregate (N : Node_Id) return Boolean;
+   --  Determine whether an array aggregate used in an object declaration
+   --  is uninitialized, when the aggregate is declared with a box and
+   --  the component type has no default value. Such an aggregate can be
+   --  optimized away and prevent the copying of uninitialized data.
+
procedure Process_Default_Expressions
  (E : Entity_Id;
   After : in out Node_Id);
@@ -718,7 +724,14 @@ package body Freeze is
  --  expansion elsewhere. This exception is necessary to avoid copying
  --  limited objects.
 
- if Present (Init) and then not Is_Limited_View (Typ) then
+ if Present (Init)
+   and then not Is_Limited_View (Typ)
+ then
+if Is_Uninitialized_Aggregate (Init) then
+   Init := Empty;
+   Set_No_Initialization (Decl);
+   return;
+end if;
 
 --  Capture initialization value at point of declaration, and make
 --  explicit assignment legal, because object may be a constant.
@@ -9131,6 +9144,40 @@ package body Freeze is
   end if;
end Freeze_Subprogram;
 
+   
+   -- Is_Uninitialized_Aggregate --
+   
+
+   function Is_Uninitialized_Aggregate (N : Node_Id) return Boolean is
+  Aggr : constant Node_Id := Original_Node (N);
+  Typ  : constant Entity_Id := Etype (Aggr);
+
+  Comp  : Node_Id;
+  Comp_Type : Entity_Id;
+   begin
+  if Nkind (Aggr) /= N_Aggregate
+or else No (Typ)
+or else Ekind (Typ) /= E_Array_Type
+or else Present (Expressions (Aggr))
+or else No (Component_Associations (Aggr))
+  then
+ return False;
+  else
+ Comp_Type := Component_Type (Typ);
+ Comp := First (Component_Associations (Aggr));
+
+ if not Box_Present (Comp)
+   or else Present (Next (Comp))
+ then
+return False;
+ end if;
+
+ return Is_Scalar_Type (Comp_Type)
+   and then No (Default_Aspect_Component_Value (Typ))
+   and then No (Default_Aspect_Value (Comp_Type));
+  end if;
+   end Is_Uninitialized_Aggregate;
+
--
-- Is_Fully_Defined --
--




[Ada] Iterative patch for accessibility cleanup

2020-10-23 Thread Pierre-Marie de Rodat
This patch fixes a "comes from source" calculation needed for
determining the innermost master scope depth.

Also, this patch fixes issues calculating accessibility for function
calls which initialize objects in their entirety.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

* sem_util.adb (Accessibility_Call_Helper): In the selected
component case, test if a prefix is a function call and whether
the subprogram call is not being used in its entirety and use
the Innermost_Master_Scope_Depth in that case.
(Innermost_Master_Scope_Depth): Test against the node_par
instead of its identifier to avoid misattributing unnamed blocks
as not being from source.
(Function_Call_Level): Add calculation for whether a subprogram
call is initializing an object in its entirety.
(Subprogram_Call_Level): Renamed to Function_Call_Level.diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -295,8 +295,8 @@ package body Sem_Util is
   --  enclosing dynamic scope (effectively the accessibility
   --  level of the innermost enclosing master).
 
-  function Subprogram_Call_Level (Call_Ent : Entity_Id) return Node_Id;
-  --  Centeralized processing of subprogram calls which may appear in
+  function Function_Call_Level (Call_Ent : Entity_Id) return Node_Id;
+  --  Centralized processing of subprogram calls which may appear in
   --  prefix notation.
 
   --
@@ -314,7 +314,7 @@ package body Sem_Util is
  --  that Defining_Entity can be applied to, and return the
  --  depth of that entity's nearest enclosing dynamic scope.
 
- --  The rules which define what a master are are defined in
+ --  The rules that define what a master are defined in
  --  RM 7.6.1 (3), and include statements and conditions for loops
  --  among other things. These cases are detected properly ???
 
@@ -327,7 +327,7 @@ package body Sem_Util is
 
--  Ignore transient scopes made during expansion
 
-   if Comes_From_Source (Encl_Scop) then
+   if Comes_From_Source (Node_Par) then
   return Scope_Depth (Encl_Scop);
end if;
 
@@ -366,15 +366,16 @@ package body Sem_Util is
  return Result;
   end Make_Level_Literal;
 
-  ---
-  -- Subprogram_Call_Level --
-  ---
+  -
+  -- Function_Call_Level --
+  -
 
-  function Subprogram_Call_Level (Call_Ent : Entity_Id) return Node_Id is
+  function Function_Call_Level (Call_Ent : Entity_Id) return Node_Id is
+ Par : Node_Id;
   begin
  --  Results of functions are objects, so we either get the
  --  accessibility of the function or, in case of a call which is
- --  indirect, the level of the access to subprogram type.
+ --  indirect, the level of the access-to-subprogram type.
 
  --  This code looks wrong ???
 
@@ -393,17 +394,62 @@ package body Sem_Util is
  if Is_Named_Access_Type (Etype (Call_Ent)) then
 return Make_Level_Literal (Type_Access_Level (Etype (Call_Ent)));
 
- --  Otherwise, the level is that of the innermost master of the call,
- --  according to RM 3.10.2 (10.6/2).
-
- --  Note: Expr is used here instead of Call_Ent since expansion may
- --  have taken place, and we need to ensure we can climb the parent
- --  chain.
+ --  Otherwise, the level is dictated by RM 3.10.2 (10.7/3)
 
  else
-return Make_Level_Literal (Innermost_Master_Scope_Depth (Expr));
+--  Find any relevant enclosing parent nodes that designate an
+--  object being initialized.
+
+--  Note: The above is only relevant if the result is used "in its
+--  entirety" as RM 3.10.2 (10.2/3) states. However, this is
+--  accounted for in the case statement in the main body of
+--  Accessibility_Level_Helper for N_Selected_Component.
+
+--  How are we sure, for example, that we are not coming up from,
+--  say, the left hand part of an assignment. More verification
+--  needed ???
+
+Par := Parent (Expr);
+while Present (Par) loop
+   exit when Nkind (Par) in N_Assignment_Statement
+  | N_Object_Declaration
+  | N_Function_Call;
+   Par := Parent (Par);
+end loop;
+
+--  If no object is being initialized then the level is that of the
+--  innermost master of the call, according to RM 3.10.2 (10.6/3).
+
+if No (Par) or else Nkind (Par) = N_Function_Call then
+   re

[Ada] Spurious errors on tagged types with renamed subprograms

2020-10-23 Thread Pierre-Marie de Rodat
When a tagged type erroneusly defines primitives by means of renaming
subprograms that require overriding, the compiler properly reports the
error; however, it also reports bogus errors indicating that the
renaming declaration must be overridden.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

* sem_ch3.adb (Check_Abstract_Overriding): Subprogram renamings
cannot be overridden.
(Derive_Subprogram): Enable setting attribute
Requires_Overriding on functions with controlling access results
of record extensions with a null extension part require
overriding (AI95-00391/06).diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb
--- a/gcc/ada/sem_ch3.adb
+++ b/gcc/ada/sem_ch3.adb
@@ -10876,6 +10876,13 @@ package body Sem_Ch3 is
   then
  null;
 
+  --  Subprogram renamings cannot be overridden
+
+  elsif Comes_From_Source (Subp)
+ and then Present (Alias (Subp))
+  then
+ null;
+
   else
  Error_Msg_NE
("type must be declared abstract or & overridden",
@@ -15726,7 +15733,9 @@ package body Sem_Ch3 is
  null;
 
   --  Ada 2005 (AI-228): Calculate the "require overriding" and "abstract"
-  --  properties of the subprogram, as defined in RM-3.9.3(4/2-6/2).
+  --  properties of the subprogram, as defined in RM-3.9.3(4/2-6/2). Note
+  --  that functions with controlling access results of record extensions
+  --  with a null extension part require overriding (AI95-00391/06).
 
   --  Ada 202x (AI12-0042): Similarly, set those properties for
   --  implementing the rule of RM 7.3.2(6.1/4).
@@ -15744,8 +15753,7 @@ package body Sem_Ch3 is
  and then Ekind (Etype (New_Subp)) =
E_Anonymous_Access_Type
  and then Designated_Type (Etype (New_Subp)) =
-Derived_Type
- and then not Is_Null_Extension (Derived_Type))
+Derived_Type)
or else (Comes_From_Source (Alias (New_Subp))
  and then Is_EVF_Procedure (Alias (New_Subp)))
 




[Ada] Crash on expression function and access type

2020-10-23 Thread Pierre-Marie de Rodat
This patch fixes a compiler abort on an expression function that is a
completion, when the expression includes function calls and dereferences
and the result is an access type.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

* freeze.adb (Freeze_Type_Refs): Add guard on freezing of the
designated type of an access type appearing in the expression,
when expression includes an explicit dereference whose prefix
includes a function call.diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb
--- a/gcc/ada/freeze.adb
+++ b/gcc/ada/freeze.adb
@@ -8008,19 +8008,19 @@ package body Freeze is
  if Nkind (Node) in N_Has_Etype
and then Present (Etype (Node))
and then Is_Access_Type (Etype (Node))
-   and then Nkind (Parent (Node)) = N_Function_Call
-   and then Node = Controlling_Argument (Parent (Node))
  then
-Check_And_Freeze_Type (Designated_Type (Etype (Node)));
+if Nkind (Parent (Node)) = N_Function_Call
+  and then Node = Controlling_Argument (Parent (Node))
+then
+   Check_And_Freeze_Type (Designated_Type (Etype (Node)));
 
- --  An explicit dereference freezes the designated type as well,
- --  even though that type is not attached to an entity in the
- --  expression.
+--  An explicit dereference freezes the designated type as well,
+--  even though that type is not attached to an entity in the
+--  expression.
 
- elsif Nkind (Node) in N_Has_Etype
-   and then Nkind (Parent (Node)) = N_Explicit_Dereference
- then
-Check_And_Freeze_Type (Designated_Type (Etype (Node)));
+elsif Nkind (Parent (Node)) = N_Explicit_Dereference then
+   Check_And_Freeze_Type (Designated_Type (Etype (Node)));
+end if;
 
  --  An iterator specification freezes the iterator type, even though
  --  that type is not attached to an entity in the construct.




[Ada] CUDA: fix CUDA_Execute not working with aggregates

2020-10-23 Thread Pierre-Marie de Rodat
When expanding pragma CUDA_Execute, the compiler declares temporary
variables to capture the value of the pragma's arguments. These
declarations's type is inferred from the pragma's arguments type,
because said arguments could be integers of CUDA.Vector_Types.Dim3s.

Inferring the type of these declarations failed when the CUDA_Execute
pragma was given an aggregate which should be treated as a Dim3. This is
because the aggregate does not have a type.

Fixing this is as simple as checking for the aggregate case and using a
Dim3 when needed.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

* exp_prag.adb (Etype_Or_Dim3): New function.
(Expand_Pragma_Cuda_Execute): Use Etype_Or_Dim3 for temporary
decls.diff --git a/gcc/ada/exp_prag.adb b/gcc/ada/exp_prag.adb
--- a/gcc/ada/exp_prag.adb
+++ b/gcc/ada/exp_prag.adb
@@ -752,6 +752,11 @@ package body Exp_Prag is
   --  type of which is Integer, the value of which is Init_Val if present
   --  and 0 otherwise.
 
+  function Etype_Or_Dim3 (N : Node_Id) return Node_Id;
+  --  If N is an aggregate whose type is unknown, return a new occurrence
+  --  of the public Dim3 type. Otherwise, return a new occurrence of N's
+  --  type.
+
   function Get_Nth_Arg_Type
  (Subprogram : Entity_Id;
   N  : Positive) return Entity_Id;
@@ -988,6 +993,20 @@ package body Exp_Prag is
 Default_Val => Make_Null (Loc));
   end Build_Stream_Declaration;
 
+  
+  -- Etype_Or_Dim3  --
+  
+
+  function Etype_Or_Dim3 (N : Node_Id) return Node_Id is
+  begin
+ if Nkind (N) = N_Aggregate and then Is_Composite_Type (Etype (N))
+ then
+return New_Occurrence_Of (RTE (RE_Dim3), Sloc (N));
+ end if;
+
+ return New_Occurrence_Of (Etype (N), Loc);
+  end Etype_Or_Dim3;
+
   --
   -- Get_Nth_Arg_Type --
   --
@@ -1054,13 +1073,11 @@ package body Exp_Prag is
   --  referenced multiple times but could have side effects.
   Temp_Grid_Decl : constant Node_Id := Make_Object_Declaration (Loc,
 Defining_Identifier => Temp_Grid,
-Object_Definition   =>
-  New_Occurrence_Of (Etype (Grid_Dimensions), Loc),
+Object_Definition   => Etype_Or_Dim3 (Grid_Dimensions),
 Expression  => Grid_Dimensions);
   Temp_Block_Decl : constant Node_Id := Make_Object_Declaration (Loc,
 Defining_Identifier => Temp_Block,
-Object_Definition   =>
-  New_Occurrence_Of (Etype (Block_Dimensions), Loc),
+Object_Definition   => Etype_Or_Dim3 (Block_Dimensions),
 Expression  => Block_Dimensions);
 
   --  List holding the entities of the copies of Procedure_Call's




[Ada] CUDA: Use internal types instead of public ones

2020-10-23 Thread Pierre-Marie de Rodat
The previous version of the CUDA bindings had a C_Pass_By_Copy
convention on its definition of the Dim3 type. The new version doesn't.
This change causes ABI issues in generated binaries.

In order to avoid needing changes in the compiler every time the
public bindings are updated, a new Dim3 type is introduced in the
internal bindings.

This new Dim3 type isn't directly referenced in the compiler: it is
instead inferred from the internal definition of the Cuda Launch_Kernel
function. This provides greater flexibility and will hopefully also help
avoid updates in the compiler when the internal bindings change.

Having two Dim3 definitions (one public and one internal) means that the
compiler now needs to convert one to the other. This conversion is
performed in Build_Dim3_Declaration.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

* exp_prag.adb (Get_Launch_Kernel_Arg_Type): Renamed to
Get_Nth_Arg_Type and made more generic.
(Build_Dim3_Declaration): Now builds a CUDA.Internal.Dim3
instead of a CUDA.Vector_Types.Dim3.
(Build_Shared_Memory_Declaration): Now infers needed type from
Launch_Kernel instead of using a hard-coded type.
(Expand_Pragma_CUDA_Execute): Build additional temporaries to
store Grids and Blocks.
* rtsfind.ads: Move Launch_Kernel from public to internal
package.diff --git a/gcc/ada/exp_prag.adb b/gcc/ada/exp_prag.adb
--- a/gcc/ada/exp_prag.adb
+++ b/gcc/ada/exp_prag.adb
@@ -682,12 +682,16 @@ package body Exp_Prag is
  Init_Val : Node_Id) return Node_Id;
   --  Build an object declaration of the form
   --
-  --Decl_Id : CUDA.Vectory_Types.Dim3 := Val;
+  --Decl_Id : CUDA.Internal.Dim3 := Val;
   --
   --  Val depends on the nature of Init_Val, as follows:
   --
-  --* If Init_Val is already of type CUDA.Vector_Types.Dim3, then
-  --  Init_Val is used.
+  --* If Init_Val is of type CUDA.Vector_Types.Dim3, then Val has the
+  --  following form:
+  --
+  --(Interfaces.C.Unsigned (Val.X),
+  -- Interfaces.C.Unsigned (Val.Y),
+  -- Interfaces.C.Unsigned (Val.Z))
   --
   --* If Init_Val is a single Integer, Val has the following form:
   --
@@ -729,8 +733,8 @@ package body Exp_Prag is
 (Decl_Id  : Entity_Id;
  Init_Val : Node_Id) return Node_Id;
   --  Builds a declaration the Defining_Identifier of which is Decl_Id, the
-  --  type of which is CUDA.Driver_Types.Stream_T and the value of which is
-  --  Init_Val if present or null if not.
+  --  type of which is inferred from CUDA.Internal.Launch_Kernel and the
+  --  value of which is Init_Val if present or null if not.
 
   function Build_Simple_Declaration_With_Default
  (Decl_Id : Entity_Id;
@@ -748,9 +752,10 @@ package body Exp_Prag is
   --  type of which is Integer, the value of which is Init_Val if present
   --  and 0 otherwise.
 
-  function Get_Launch_Kernel_Arg_Type (N : Positive) return Entity_Id;
-  --  Returns the type of the Nth argument of the Launch_Kernel CUDA
-  --  runtime function.
+  function Get_Nth_Arg_Type
+ (Subprogram : Entity_Id;
+  N  : Positive) return Entity_Id;
+  --  Returns the type of the Nth argument of Subprogram.
 
   function To_Addresses (Elmts : Elist_Id) return List_Id;
   --  Returns a new list containing each element of Elmts wrapped in an
@@ -792,57 +797,81 @@ package body Exp_Prag is
 (Decl_Id  : Entity_Id;
  Init_Val : Node_Id) return Node_Id
   is
- Grid_Dim_X : Node_Id;
- Grid_Dim_Y : Node_Id;
- Grid_Dim_Z : Node_Id;
- Init_Value : Node_Id;
+ --  Expressions for each component of the returned Dim3
+ Dim_X: Node_Id;
+ Dim_Y: Node_Id;
+ Dim_Z: Node_Id;
+
+ --  Type of CUDA.Internal.Dim3 - inferred from
+ --  RE_Push_Call_Configuration to avoid needing changes in GNAT when
+ --  the CUDA bindings change (this happens frequently).
+ Internal_Dim3 : constant Entity_Id :=
+   Get_Nth_Arg_Type (RTE (RE_Push_Call_Configuration), 1);
+
+ --  Entities for each component of external and internal Dim3
+ First_Component  : Entity_Id := First_Entity (RTE (RE_Dim3));
+ Second_Component : Entity_Id := Next_Entity (First_Component);
+ Third_Component  : Entity_Id := Next_Entity (Second_Component);
   begin
+
+ --  Sem_prag.adb ensured that Init_Val is either a Dim3, an
+ --  aggregate of three Any_Integers or Any_Integer.
+
+ --  If Init_Val is a Dim3, use each of its components.
+
  if Etype (Init_Val) = RTE (RE_Dim3) then
-Init_Value := Init_Val;
+Dim_X := Make_Selected_Component (Loc,
+  Prefix=> New_Occurrence_Of (Entity (Init_Val)

[Ada] Better error for illegal call to abstract operation in instantiations

2020-10-23 Thread Pierre-Marie de Rodat
In cases involving instantiations and formal packages, a call to an
abstract nondispatching subprogram within an instantiation, where
the operation comes in via the actual for a formal package, was
not being flagged with an informative message on the instantiation.
(A program could potentially compile but end up with an undefined
reference at link time, or a general error might be flagged on
the instantiation without anything more specific.) This is corrected
by checking during analysis for such a call in the case where the call
is not overloaded with multiple interpretations, and issuing an error
at that point.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

* sem_ch4.adb (Analyze_Call): In the case where the call is not
overloaded, check for a call to an abstract nondispatching
operation and flag an error.diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb
--- a/gcc/ada/sem_ch4.adb
+++ b/gcc/ada/sem_ch4.adb
@@ -1254,6 +1254,25 @@ package body Sem_Ch4 is
 
  Analyze_One_Call (N, Nam_Ent, True, Success);
 
+ --  If the nonoverloaded interpretation is a call to an abstract
+ --  nondispatching operation, then flag an error and return.
+
+ --  Should this be incorporated in Remove_Abstract_Operations (which
+ --  currently only deals with cases where the name is overloaded)? ???
+
+ if Is_Overloadable (Nam_Ent)
+   and then Is_Abstract_Subprogram (Nam_Ent)
+   and then not Is_Dispatching_Operation (Nam_Ent)
+ then
+Set_Etype (N, Any_Type);
+
+Error_Msg_Sloc := Sloc (Nam_Ent);
+Error_Msg_NE
+  ("cannot call abstract operation& declared#", N, Nam_Ent);
+
+return;
+ end if;
+
  --  If this is an indirect call, the return type of the access_to
  --  subprogram may be an incomplete type. At the point of the call,
  --  use the full type if available, and at the same time update the




[Ada] Fix scope of index parameter inside a delta aggregate

2020-10-23 Thread Pierre-Marie de Rodat
When resolving iterated_component_association that occurs within
delta_aggregate, we create an implicit loop which should act as a scope
for the index parameter entity. However, the name of this entity was
entered before pushing the scope of the implicit loop, so the index
parameter was visible outside of the delta_aggregate.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

* sem_aggr.adb (Resolve_Delta_Array_Aggregate): Push scope of
the implicit loop before entering name of the index parameter,
not after; enter name no matter if the identifier has been
decorated before.diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb
--- a/gcc/ada/sem_aggr.adb
+++ b/gcc/ada/sem_aggr.adb
@@ -3052,15 +3052,15 @@ package body Sem_Aggr is
 begin
Set_Etype  (Ent, Standard_Void_Type);
Set_Parent (Ent, Assoc);
+   Push_Scope (Ent);
 
if No (Scope (Id)) then
-  Enter_Name (Id);
   Set_Etype (Id, Index_Type);
   Set_Ekind (Id, E_Variable);
   Set_Scope (Id, Ent);
end if;
+   Enter_Name (Id);
 
-   Push_Scope (Ent);
Analyze_And_Resolve
  (New_Copy_Tree (Expression (Assoc)), Component_Type (Typ));
End_Scope;




[Ada] Fix crash in SPARK on array delta_aggregate with subtype_indication

2020-10-23 Thread Pierre-Marie de Rodat
Expansion of array delta_aggregate in GNATprove mode needs handled
ranges and expressions (including type identifiers), but not
subtype_indications (e.g. "A with delta Integer range 1 .. 10 => 0").

Also, call Apply_Scalar_Range_Check didn't seem necessary for ranges and
likewise it makes no difference for subtype_indication, so remove it.

This patch only affects GNATprove; compilation is unaffected.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

* exp_spark.adb (Expand_SPARK_Delta_Or_Update): Handle
subtype_indication; do not apply range checks for ranges; add
comment saying that others_choices is not allowed.diff --git a/gcc/ada/exp_spark.adb b/gcc/ada/exp_spark.adb
--- a/gcc/ada/exp_spark.adb
+++ b/gcc/ada/exp_spark.adb
@@ -248,17 +248,22 @@ package body Exp_SPARK is
Index_Typ := First_Index (Typ);
 
while Present (Index) loop
-  --  The index denotes a range of elements
+  --  If the index denotes a range of elements or a constrained
+  --  subtype indication, then their low and high bounds
+  --  already have range checks applied.
 
-  if Nkind (Index) = N_Range then
- Apply_Scalar_Range_Check
-   (Low_Bound  (Index), Base_Type (Etype (Index_Typ)));
- Apply_Scalar_Range_Check
-   (High_Bound (Index), Base_Type (Etype (Index_Typ)));
+  if Nkind (Index) in N_Range | N_Subtype_Indication then
+ null;
 
-  --  Otherwise the index denotes a single element
+  --  Otherwise the index denotes a single expression where
+  --  range checks need to be applied or a subtype name
+  --  (without range constraints) where applying checks is
+  --  harmless.
+  --
+  --  In delta_aggregate and Update attribute on array the
+  --  others_choice is not allowed.
 
-  else
+  else pragma Assert (Nkind (Index) in N_Subexpr);
  Apply_Scalar_Range_Check (Index, Etype (Index_Typ));
   end if;
 




[Ada] Error when closing c_stream

2020-10-23 Thread Pierre-Marie de Rodat
When using .C_Streams.Open with a null Name, the File will be
incorrectly set as a temporary file, causing a wrong attempt to delete
it when closing it.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

* libgnat/s-fileio.adb (Open): Fix setting of Tempfile.diff --git a/gcc/ada/libgnat/s-fileio.adb b/gcc/ada/libgnat/s-fileio.adb
--- a/gcc/ada/libgnat/s-fileio.adb
+++ b/gcc/ada/libgnat/s-fileio.adb
@@ -800,9 +800,9 @@ package body System.File_IO is
 
   Text_Encoding : Content_Encoding;
 
-  Tempfile : constant Boolean := Name = "";
+  Tempfile : constant Boolean := Name = "" and Stream = NULL_Stream;
   --  Indicates temporary file case, which is indicated by an empty file
-  --  name.
+  --  name and no specified Stream.
 
   Namelen : constant Integer := max_path_len;
   --  Length required for file name, not including final ASCII.NUL.




[Ada] Missing detection of unused with_clause

2020-10-23 Thread Pierre-Marie de Rodat
In some cases involving a package spec using object.method notation
in e.g. subprogram aspects, an old change in Complete_Object_Operation
would disable the proper detection of an unused "with" clause.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

* sem_ch4.adb (Complete_Object_Operation): Only mark entities
referenced if we are compiling the extended main unit.
* sem_attr.adb (Analyze_Attribute [Attribute_Tag]): Record a
reference on the type and its scope.diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb
--- a/gcc/ada/sem_attr.adb
+++ b/gcc/ada/sem_attr.adb
@@ -6288,6 +6288,15 @@ package body Sem_Attr is
 
  if Comes_From_Source (N) then
 Check_Not_Incomplete_Type;
+
+--  'Tag requires visibility on the corresponding package holding
+--  the tag, so record a reference here, to avoid spurious unused
+--  with_clause reported when compiling the main unit.
+
+if In_Extended_Main_Source_Unit (Current_Scope) then
+   Set_Referenced (P_Type, True);
+   Set_Referenced (Scope (P_Type), True);
+end if;
  end if;
 
  --  Set appropriate type


diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb
--- a/gcc/ada/sem_ch4.adb
+++ b/gcc/ada/sem_ch4.adb
@@ -9010,16 +9010,20 @@ package body Sem_Ch4 is
 Rewrite (First_Actual, Obj);
  end if;
 
- --  The operation is obtained from the dispatch table and not by
- --  visibility, and may be declared in a unit that is not explicitly
- --  referenced in the source, but is nevertheless required in the
- --  context of the current unit. Indicate that operation and its scope
- --  are referenced, to prevent spurious and misleading warnings. If
- --  the operation is overloaded, all primitives are in the same scope
- --  and we can use any of them.
-
- Set_Referenced (Entity (Subprog), True);
- Set_Referenced (Scope (Entity (Subprog)), True);
+ if In_Extended_Main_Source_Unit (Current_Scope) then
+--  The operation is obtained from the dispatch table and not by
+--  visibility, and may be declared in a unit that is not
+--  explicitly referenced in the source, but is nevertheless
+--  required in the context of the current unit. Indicate that
+--  operation and its scope are referenced, to prevent spurious and
+--  misleading warnings. If the operation is overloaded, all
+--  primitives are in the same scope and we can use any of them.
+--  Don't do that outside the main unit since otherwise this will
+--  e.g. prevent the detection of some unused with clauses.
+
+Set_Referenced (Entity (Subprog), True);
+Set_Referenced (Scope (Entity (Subprog)), True);
+ end if;
 
  Rewrite (Node_To_Replace, Call_Node);
 




[Ada] Decorate iterated_component_association in SPARK expansion

2020-10-23 Thread Pierre-Marie de Rodat
When compiling iterated_component_association, the analysis, resolution
and range checking is done when expanding aggregate into assignments.
This is now mirrored in the custom expansion for GNATprove, so that the
backend sees a fully decorated (but unexpanded) AST.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

* exp_spark.adb (Expand_SPARK_N_Aggregate,
Expand_SPARK_Delta_Or_Update): Expand
Iterated_Component_Association occurring within delta
aggregates.
(Expand_SPARK): Apply SPARK-specific expansion to ordinary
aggregates.diff --git a/gcc/ada/exp_spark.adb b/gcc/ada/exp_spark.adb
--- a/gcc/ada/exp_spark.adb
+++ b/gcc/ada/exp_spark.adb
@@ -36,6 +36,7 @@ with Nlists;   use Nlists;
 with Nmake;use Nmake;
 with Rtsfind;  use Rtsfind;
 with Sem;  use Sem;
+with Sem_Ch8;  use Sem_Ch8;
 with Sem_Prag; use Sem_Prag;
 with Sem_Res;  use Sem_Res;
 with Sem_Util; use Sem_Util;
@@ -51,6 +52,9 @@ package body Exp_SPARK is
-- Local Subprograms --
---
 
+   procedure Expand_SPARK_N_Aggregate (N : Node_Id);
+   --  Perform aggregate-specific expansion
+
procedure Expand_SPARK_N_Attribute_Reference (N : Node_Id);
--  Perform attribute-reference-specific expansion
 
@@ -101,6 +105,9 @@ package body Exp_SPARK is
  =>
 Qualify_Entity_Names (N);
 
+ when N_Aggregate =>
+Expand_SPARK_N_Aggregate (N);
+
  --  Replace occurrences of System'To_Address by calls to
  --  System.Storage_Elements.To_Address.
 
@@ -215,11 +222,29 @@ package body Exp_SPARK is
Expr  := Expression (Assoc);
Comp_Type := Component_Type (Typ);
 
+   --  Analyze expression of the iterated_component_association
+   --  with its index parameter in scope.
+
+   if Nkind (Assoc) = N_Iterated_Component_Association then
+  Push_Scope (Scope (Defining_Identifier (Assoc)));
+  Analyze_And_Resolve (Expression (Assoc), Comp_Type);
+   end if;
+
if Is_Scalar_Type (Comp_Type) then
   Apply_Scalar_Range_Check (Expr, Comp_Type);
end if;
 
-   Index := First (Choices (Assoc));
+   --  Restore scope of the iterated_component_association
+
+   if Nkind (Assoc) = N_Iterated_Component_Association then
+  End_Scope;
+   end if;
+
+   Index :=
+ First
+   (if Nkind (Assoc) = N_Iterated_Component_Association
+then Discrete_Choices (Assoc)
+else Choices (Assoc));
Index_Typ := First_Index (Typ);
 
while Present (Index) loop
@@ -340,6 +365,74 @@ package body Exp_SPARK is
   end if;
end Expand_SPARK_N_Freeze_Type;
 
+   --
+   -- Expand_SPARK_N_Aggregate --
+   --
+
+   procedure Expand_SPARK_N_Aggregate (N : Node_Id) is
+  Assoc : Node_Id := First (Component_Associations (N));
+   begin
+  --  For compilation, frontend analyses a copy of the
+  --  iterated_component_association's expression for legality checking;
+  --  (then the expression is copied again when expanding association into
+  --  assignments for the individual choices). For SPARK we analyze the
+  --  original expression and apply range checks, if required.
+
+  while Present (Assoc) loop
+ if Nkind (Assoc) = N_Iterated_Component_Association then
+declare
+   Typ : constant Entity_Id := Etype (N);
+
+   Comp_Type : constant Entity_Id := Component_Type (Typ);
+   Expr  : constant Node_Id := Expression (Assoc);
+   Index_Typ : constant Entity_Id := First_Index (Typ);
+
+   Index : Node_Id;
+
+begin
+   --  Analyze expression with index parameter in scope
+
+   Push_Scope (Scope (Defining_Identifier (Assoc)));
+   Enter_Name (Defining_Identifier (Assoc));
+   Analyze_And_Resolve (Expression (Assoc), Comp_Type);
+
+   if Is_Scalar_Type (Comp_Type) then
+  Apply_Scalar_Range_Check (Expr, Comp_Type);
+   end if;
+
+   End_Scope;
+
+   --  Analyze discrete choices
+
+   Index := First (Discrete_Choices (Assoc));
+
+   while Present (Index) loop
+
+  --  The index denotes a range of elements where range checks
+  --  have been already applied.
+
+  if Nkind (Index) in N_Others_Choice
+| N_Range
+| N_Subtype_Indication
+  then
+ null;
+
+  --  Otherwise the index denotes a single element (or a
+  --  subtype name which d

[Ada] Do not use Long_Long_Long_Integer'Image with pragma Discard_Names

2020-10-23 Thread Pierre-Marie de Rodat
When the Image attribute is applied to an enumeration type subject to
pragma Discard_Names, the underlying numeric value is printed instead
of the string of the literal and this is done by invoking the Image
routine of Long_Long_Long_Integer, which is overkill in the context.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

* exp_imgv.adb (Expand_Image_Attribute): For an enumeration type
subject to pragma Discard_Names, convert 'Pos to Long_Long_Integer
before applying 'Img to the result.diff --git a/gcc/ada/exp_imgv.adb b/gcc/ada/exp_imgv.adb
--- a/gcc/ada/exp_imgv.adb
+++ b/gcc/ada/exp_imgv.adb
@@ -619,15 +619,18 @@ package body Exp_Imgv is
or else No (Lit_Strings (Rtyp))
  then
 --  When pragma Discard_Names applies to the first subtype, build
---  (Pref'Pos (Expr))'Img.
+--  (Long_Long_Integer (Pref'Pos (Expr)))'Img. The conversion is
+--  there to avoid applying 'Img directly in Universal_Integer,
+--  which can be a very large type. See also the handling of 'Val.
 
 Rewrite (N,
   Make_Attribute_Reference (Loc,
 Prefix =>
-   Make_Attribute_Reference (Loc,
- Prefix => Pref,
- Attribute_Name => Name_Pos,
- Expressions=> New_List (Expr)),
+  Convert_To (Standard_Long_Long_Integer,
+Make_Attribute_Reference (Loc,
+Prefix => Pref,
+Attribute_Name => Name_Pos,
+Expressions=> New_List (Expr))),
 Attribute_Name =>
   Name_Img));
 Analyze_And_Resolve (N, Standard_String);




[Ada] Ignore container types for aggregates if not in Ada_2020

2020-10-23 Thread Pierre-Marie de Rodat
To prevent ambiguities in the use of predefined containers in legacy
code, the resolution of aggregates must ignore the presence of the
Aggregate aspect when the compilation version is earlier than Ada_2020.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

* sem_aggr.adb (Resolve_Aggregate): Do not call
Resolve_Container_Aggregate if compilation version is earlier
than Ada_2020.diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb
--- a/gcc/ada/sem_aggr.adb
+++ b/gcc/ada/sem_aggr.adb
@@ -901,6 +901,7 @@ package body Sem_Aggr is
 
   elsif Present (Find_Aspect (Typ, Aspect_Aggregate))
 and then Ekind (Typ) /= E_Record_Type
+and then Ada_Version >= Ada_2020
   then
  Resolve_Container_Aggregate (N, Typ);
 




[Ada] Fix logic in C_Select under mingw

2020-10-23 Thread Pierre-Marie de Rodat
GNAT started generated a new legitimate warning on g-socthi__mingw.adb:
g-socthi.adb:395:19: warning: condition is always True

After further investigation, it appears that Original_WFS was
unconditionally dereferencing Writefds without first checking against null.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

* libgnat/g-socthi__mingw.adb (C_Select): Fix logic in code and
make it explicit that we are checking against null values before
dereferencing them.diff --git a/gcc/ada/libgnat/g-socthi__mingw.adb b/gcc/ada/libgnat/g-socthi__mingw.adb
--- a/gcc/ada/libgnat/g-socthi__mingw.adb
+++ b/gcc/ada/libgnat/g-socthi__mingw.adb
@@ -375,13 +375,10 @@ package body GNAT.Sockets.Thin is
   Exceptfds : access Fd_Set;
   Timeout   : Timeval_Access) return C.int
is
-  pragma Warnings (Off, Exceptfds);
-
-  Original_WFS : aliased constant Fd_Set := Writefds.all;
-
-  Res  : C.int;
-  S: aliased C.int;
-  Last : aliased C.int;
+  Original_WFS : aliased Fd_Set;
+  Res  : C.int;
+  S: aliased C.int;
+  Last : aliased C.int;
 
begin
   --  Asynchronous connection failures are notified in the exception fd
@@ -392,7 +389,8 @@ package body GNAT.Sockets.Thin is
   --  present in the initial write fd set, then move the socket from the
   --  exception fd set to the write fd set.
 
-  if Writefds /= No_Fd_Set_Access then
+  if Writefds /= null then
+ Original_WFS := Writefds.all;
 
  --  Add any socket present in write fd set into exception fd set
 
@@ -411,7 +409,7 @@ package body GNAT.Sockets.Thin is
 
   Res := Standard_Select (Nfds, Readfds, Writefds, Exceptfds, Timeout);
 
-  if Exceptfds /= No_Fd_Set_Access then
+  if Exceptfds /= null then
  declare
 EFSC: aliased Fd_Set := Exceptfds.all;
 Flag: constant C.int := SOSC.MSG_PEEK + SOSC.MSG_OOB;
@@ -448,8 +446,8 @@ package body GNAT.Sockets.Thin is
   --  exception fd set back to write fd set. Otherwise, ignore
   --  this event since the user is not watching for it.
 
-  if Writefds /= No_Fd_Set_Access
-and then (Is_Socket_In_Set (Original_WFS'Access, S) /= 0)
+  if Writefds /= null
+and then Is_Socket_In_Set (Original_WFS'Access, S) /= 0
   then
  Insert_Socket_In_Set (Writefds, S);
   end if;
@@ -457,6 +455,7 @@ package body GNAT.Sockets.Thin is
 end loop;
  end;
   end if;
+
   return Res;
end C_Select;
 




[Ada] Sockets.Poll implementation

2020-10-23 Thread Pierre-Marie de Rodat
Implement wait on set of sockets to become ready to perform I/O
operations.  Current implementation of the similar functionality with
type Selector_Type and Check_Selector routine in GNAT.Sockets package is
limited by 1024 sockets. New implementation limited only by process
limit on number of open files. On OS where poll system call is not
available, the wait is implemented on top of select system call without
limit on size of sockets set.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

* Makefile.rtl (GNATRTL_SOCKETS_OBJS): New object
g-socpol$(objext) New source files noted: g-socpol.adb,
g-socpol.ads, g-socpol__dummy.adb, g-socpol__dummy.ads,
g-sopowa.adb, g-sopowa__posix.adb, g-sopowa__mingw.adb,
g-spogwa.adb, g-spogwa.ads.
* impunit.adb (Non_Imp_File_Names_95): New base filename
g-socpol in "GNAT Library Units" section for GNAT.Sockets.Poll
unit.
* libgnat/g-socket.ads, libgnat/g-socket.adb:
(Raise_Socket_Error): Moved from body to private part of
specification to use in GNAT.Sockets.Poll.
* libgnat/g-socpol.ads, libgnat/g-socpol.adb: Main unit of the
implementation.
* libgnat/g-socpol__dummy.ads, libgnat/g-socpol__dummy.adb:
Empty unit for the systems without sockets support.
* libgnat/g-spogwa.ads, libgnat/g-spogwa.adb: Generic unit
implementing sockets poll on top of select system call.
* libgnat/g-sopowa.adb (Wait): Separate implementation for
operation systems with poll system call support.
* libgnat/g-sopowa__posix.adb (Wait): Separate implementation
for POSIX select system call.
* libgnat/g-sopowa__mingw.adb (Wait): Separate implementation
for Windows select system call.
* gsocket.h (_WIN32_WINNT): Increase to 0x0600 for winsock2.h to
allow WSAPoll related definitions.
* s-oscons-tmplt.c: Fix comment next to #endif for
#if defined (__linux__) || defined (__ANDROID__) line.  Include
 for all except VxWorks and Windows.
(SIZEOF_nfds_t): New definition.
(SIZEOF_fd_type): New definition.
(SIZEOF_pollfd_events): New definition.
(POLLIN, POLLPRI, POLLOUT, POLLERR, POLLHUP, POLLNVAL): New
definitions for VxWorks to be able to emulate poll on top of
select in it.  Define POLLPRI as zero on Windows as it is not
supported there.
(Poll_Linkname): New definition, because the poll system call
has different name in Windows and POSIX.

patch.diff.gz
Description: application/gzip


[Ada] Further Ada 2020 work on accessibility checking

2020-10-23 Thread Pierre-Marie de Rodat
This patch implements AI12-0035, AI12-0335, AI12-0345, AI12-0372, and
partially Ada2012-A235 and fixes many holes in accessibility checking.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

* checks.adb (Apply_Accessibility_Check): Skip checks against
the extra accessibility of a function result when in Ada 2005
mode or earlier.
* exp_ch3.adb (Build_Initialization_Call): Modify accessibility
level calls to use Accessibility_Level.
(Expand_N_Object_Declaration): Modify accessibility level calls
to use Accessibility_Level.
* exp_ch4.adb (Expand_Allocator_Expression): Add static check
for anonymous access discriminants. Remove unneeded propagation
of accessibility actual.
(Expand_N_In): Modify accessibility level calls to use
Accessibility_Level.
(Expand_N_Type_Conversion): Modify accessibility level calls to
use Accessibility_Level.
* exp_ch5.adb (Expand_N_Assignment_Statement): Modify
accessibility level calls to use Accessibility_Level.
* exp_ch6.adb (Expand_Call_Helper): Rewrite accessibility
calculation for the extra accessibility of result actual in
function calls, and modify accessibility level calls to use
Accessibility_Level.
(Check_Against_Result_Level): Removed.
* exp_ch9.adb (Expand_N_Requeue_Statement): Add dynamic
accessibility check for requeues
* sem_attr.adb (Resolve_Attribute): Modify accessibility level
calls to use Accessibility_Level.
* sem_ch13.adb (Associate_Storage_Pool): Modify accessibility
level calls to use Accessibility_Level.
* sem_ch4.adb (Analyze_Call): Add static check for explicitly
aliased formals in function calls within return statements.
* sem_ch6.adb (Check_Return_Construct_Accessibility): Rewrite
routine to account for non-aggregate return objects.
(Generate_Minimum_Accessibility): Created.
(Analyze_Call): Modify accessibility level calls to use
Accessibility_Level.
(Analyze_Subprogram_Body_Helper): Add generation of minimum
accessibility for the extra accessibility of the function
result.
* sem_ch9.adb (Analyze_Requeue): Modify accessibility level
calls to use Accessibility_Level.
* sem_res.adb: (Check_Aliased_Parameters): Modify accessibility
level calls to use Accessibility_Level.
(Valid_Conversion): Modify accessibility level calls to use
Accessibility_Level.
* sem_util.adb, sem_util.ads (Accessibility_Level_Helper):
Renamed to Accessibility_Level, add detection for functions in
prefix notation, and add cases where to return zero when
specified. Modified to take new, more descriptive, parameters.
(Accessibility_Level): Created.
(Function_Call_Level): Removed.
(Function_Call_Or_Allocator_Level): Created to centralize the
calculation accessibility levels for function calls and
allocators.
(Static_Accessibility_Level): Removed.
(Dynamic_Accessibility_Level): Removed.
(Get_Dynamic_Accessibility): Renamed from Get_Accessibility.
(In_Return_Value): Created to determine if a given expression
contributes to the current function's return value.
(Is_Master): Created.
(Is_Explicitly_Aliased): Created

patch.diff.gz
Description: application/gzip


[Ada] Clean up in writing of ALI files

2020-10-23 Thread Pierre-Marie de Rodat
We had code that was trying to read an existing ALI files to extract
information in -gnatc mode, mainly for ASIS use. Remove this code which
is no longer needed and might even cause hard to understand effects.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

* lib-writ.ads, lib-writ.adb (Write_ALI): No longer read
existing ALI files in -gnatc mode.diff --git a/gcc/ada/lib-writ.adb b/gcc/ada/lib-writ.adb
--- a/gcc/ada/lib-writ.adb
+++ b/gcc/ada/lib-writ.adb
@@ -268,17 +268,6 @@ package body Lib.Writ is
   --  Collect with lines for entries in the context clause of the given
   --  compilation unit, Cunit.
 
-  procedure Update_Tables_From_ALI_File;
-  --  Given an up to date ALI file (see Up_To_Date_ALI_file_Exists
-  --  function), update tables from the ALI information, including
-  --  specifically the Compilation_Switches table.
-
-  function Up_To_Date_ALI_File_Exists return Boolean;
-  --  If there exists an ALI file that is up to date, then this function
-  --  initializes the tables in the ALI spec to contain information on
-  --  this file (using Scan_ALI) and returns True. If no file exists,
-  --  or the file is not up to date, then False is returned.
-
   procedure Write_Unit_Information (Unit_Num : Unit_Number_Type);
   --  Write out the library information for one unit for which code is
   --  generated (includes unit line and with lines).
@@ -397,76 +386,6 @@ package body Lib.Writ is
  end loop;
   end Collect_Withs;
 
-  
-  -- Up_To_Date_ALI_File_Exists --
-  
-
-  function Up_To_Date_ALI_File_Exists return Boolean is
- Name : File_Name_Type;
- Text : Text_Buffer_Ptr;
- Id   : Sdep_Id;
- Sind : Source_File_Index;
-
-  begin
- Opt.Check_Object_Consistency := True;
- Read_Library_Info (Name, Text);
-
- --  Return if we could not find an ALI file
-
- if Text = null then
-return False;
- end if;
-
- --  Return if ALI file has bad format
-
- Initialize_ALI;
-
- if Scan_ALI (Name, Text, False, Err => True) = No_ALI_Id then
-return False;
- end if;
-
- --  If we have an OK ALI file, check if it is up to date
- --  Note that we assume that the ALI read has all the entries
- --  we have in our table, plus some additional ones (that can
- --  come from expansion).
-
- Id := First_Sdep_Entry;
- for J in 1 .. Num_Sdep loop
-Sind := Source_Index (Sdep_Table (J));
-
-while Sdep.Table (Id).Sfile /= File_Name (Sind) loop
-   if Id = Sdep.Last then
-  return False;
-   else
-  Id := Id + 1;
-   end if;
-end loop;
-
-if Sdep.Table (Id).Stamp /= Time_Stamp (Sind) then
-   return False;
-end if;
- end loop;
-
- return True;
-  end Up_To_Date_ALI_File_Exists;
-
-  -
-  -- Update_Tables_From_ALI_File --
-  -
-
-  procedure Update_Tables_From_ALI_File is
-  begin
- --  Build Compilation_Switches table
-
- Compilation_Switches.Init;
-
- for J in First_Arg_Entry .. Args.Last loop
-Compilation_Switches.Increment_Last;
-Compilation_Switches.Table (Compilation_Switches.Last) :=
-  Args.Table (J);
- end loop;
-  end Update_Tables_From_ALI_File;
-
   
   -- Write_Unit_Information --
   
@@ -1095,8 +1014,7 @@ package body Lib.Writ is
  return;
   end if;
 
-  --  Build sorted source dependency table. We do this right away, because
-  --  it is referenced by Up_To_Date_ALI_File_Exists.
+  --  Build sorted source dependency table.
 
   for Unum in Units.First .. Last_Unit loop
  if Cunit_Entity (Unum) = Empty
@@ -1130,20 +1048,8 @@ package body Lib.Writ is
 
   Lib.Sort (Sdep_Table (1 .. Num_Sdep));
 
-  --  If we are not generating code, and there is an up to date ALI file
-  --  file accessible, read it, and acquire the compilation arguments from
-  --  this file. In GNATprove mode, always generate the ALI file, which
-  --  contains a special section for formal verification.
-
-  if Operating_Mode /= Generate_Code and then not GNATprove_Mode then
- if Up_To_Date_ALI_File_Exists then
-Update_Tables_From_ALI_File;
-return;
- end if;
-  end if;
-
-  --  Otherwise acquire compilation arguments and prepare to write out a
-  --  new ali file.
+  --  Acquire compilation arguments and prepare to write out a new ali
+  --  file.
 
   Create_Output_Library_Info;
 


diff --git a/gc

[Ada] Reject illegal syntax in pragma Contract_Cases

2020-10-23 Thread Pierre-Marie de Rodat
In pragma Contract_Cases argument only "CASE_GUARD => CONSEQUENCE"
clauses are allowed. Once we know that the pragma argument is an
N_Aggregate, we checked if it has component associations; now we also
check that it has no expressions.

Same for the argument of the Subprogram_Variant contract, whose
implementation was heavily inspired by the Contract_Cases contract.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

* contracts.adb (Analyze_Entry_Or_Subprogram_Contract,
Analyze_Subprogram_Body_Stub_Contract): Fix missing references
to Subprogram_Variant where similar references to Contract_Cases
are present.
* sem_prag.adb (Analyze_Contract_Case, Analyze_Variant): Check
that aggregate parameter has no expressions.
(Analyze_Pragma): Replace Contract_Cases with Subprogram_Variant
in a copy-pasted comment.diff --git a/gcc/ada/contracts.adb b/gcc/ada/contracts.adb
--- a/gcc/ada/contracts.adb
+++ b/gcc/ada/contracts.adb
@@ -668,7 +668,7 @@ package body Contracts is
 end;
  end if;
 
- --  Analyze contract-cases and test-cases
+ --  Analyze contract-cases, subprogram-variant and test-cases
 
  Prag := Contract_Test_Cases (Items);
  while Present (Prag) loop
@@ -1432,6 +1432,7 @@ package body Contracts is
   --Global
   --Postcondition
   --Precondition
+  --Subprogram_Variant
   --Test_Case
 
   else


diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb
--- a/gcc/ada/sem_prag.adb
+++ b/gcc/ada/sem_prag.adb
@@ -549,7 +549,11 @@ package body Sem_Prag is
 
   pragma Assert (Nkind (CCases) = N_Aggregate);
 
-  if Present (Component_Associations (CCases)) then
+  --  Only CASE_GUARD => CONSEQUENCE clauses are allowed
+
+  if Present (Component_Associations (CCases))
+and then No (Expressions (CCases))
+  then
 
  --  Ensure that the formal parameters are visible when analyzing all
  --  clauses. This falls out of the general rule of aspects pertaining
@@ -23900,7 +23904,7 @@ package body Sem_Prag is
 Ensure_Aggregate_Form (Get_Argument (N, Spec_Id));
 
 --  Chain the pragma on the contract for further processing by
---  Analyze_Contract_Cases_In_Decl_Part.
+--  Analyze_Subprogram_Variant_In_Decl_Part.
 
 Add_Contract_Item (N, Defining_Entity (Subp_Decl));
 
@@ -29048,7 +29052,11 @@ package body Sem_Prag is
 
   pragma Assert (Nkind (Variants) = N_Aggregate);
 
-  if Present (Component_Associations (Variants)) then
+  --  Only "change_direction => discrete_expression" clauses are allowed
+
+  if Present (Component_Associations (Variants))
+and then No (Expressions (Variants))
+  then
 
  --  Ensure that the formal parameters are visible when analyzing all
  --  clauses. This falls out of the general rule of aspects pertaining




[Ada] Implement new legality rules introduced in C.6(12) by AI12-0363

2020-10-23 Thread Pierre-Marie de Rodat
This removes the now obsolete legality rules specified by AI12-0128
and replaces them with the new legality rules specified by AI12-0363
pertaining to nonatomic subcomponents of full access types and objects.

This also introduces the new aspect Full_Access_Only in Ada 2020 mode
and revamps the implementation of GNAT's aspect Volatile_Full_Access
to make it closely resemble Full_Access_Only while preserving the
original semantics of the aspect.  They share a single implementation
and the only difference are the legality rules for Full_Access_Only.

Internally this renames various predicates tagged with Atomic_Or_VFA
to use the Full_Access tag instead, as "full access" is now defined
in the Ada 2020 RM.  This also makes a couple of cleanups in the
handling of representation items on entities.

There should be no code generation changes for existing programs.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

* doc/gnat_rm/implementation_defined_pragmas.rst (VFA): Remove uage
restrictions in conjunction with Atomic and Aliased.
* gnat_rm.texi: Regenerate.
* aspects.ads (Aspect_Id): Add Aspect_Full_Access_Only.
(Is_Representation_Aspect): Likewise.
(Aspect_Names): Likewise.
(Aspect_Delay): Likewise.
* einfo.ads (Is_Atomic_Or_VFA): Rename into...
(Is_Full_Access): ...this.
(Is_Volatile_Full_Access): Document new usage for Full_Access_Only.
* einfo.adb (Is_Atomic_Or_VFA): Rename into...
(Is_Full_Access): ...this.
* freeze.ads (Is_Atomic_VFA_Aggregate): Rename into...
(Is_Full_Access_Aggregate): ...this.
* freeze.adb (Is_Atomic_VFA_Aggregate): Rename into...
(Is_Full_Access_Aggregate): ...this.  Adjust to above renaming.
(Freeze_Array_Type): Likewise.
(Freeze_Entity): Likewise.
* exp_aggr.adb (Aggr_Assignment_OK_For_Backend): Likewise.
(Expand_Record_Aggregate): Likewise.
* exp_ch4.adb (Expand_N_Op_Eq): Likewise.
* exp_ch5.adb (Expand_Assign_Array): Likewise.
* exp_ch8.adb (Evaluation_Required): Likewise.
* layout.adb (Layout_Type): Likewise.
(Set_Composite_Alignment): Likewise.
* sem_aux.ads (Has_Rep_Item): Delete.
* sem_aux.adb (Has_Rep_Item): Likewise.
* sem_attr.adb (Resolve_Attribute) : Implement
new legality rules in C.6(12).
* sem_ch12.adb (Instantiate_Object): Likewise.
* sem_res.adb (Resolve_Actuals): Likewise.
* sem_ch13.adb (Inherit_Delayed_Rep_Aspects): Deal with aspect
Full_Access_Only.
(Check_False_Aspect_For_Derived_Type): Likewise.
(Make_Pragma_From_Boolean_Aspect): Test for the presence of Expr.
Deal with aspect Full_Access_Only.
(Analyze_Aspects_At_Freeze_Point): Likewise.
(Analyze_One_Aspect): Do not set Delay_Required to true even for
Always_Delay boolean aspects if they have no expression.  Force
Delay_Required to true for aspect Full_Access_Only in all cases.
Reject aspect Full_Access_Only if not in Ada 2020 mode.
(Check_Aspect_At_End_Of_Declarations): Deal with empty expression.
(Check_Aspect_At_Freeze_Point): Likewise.
(Rep_Item_Entity): Delete.
(Inherit_Aspects_At_Freeze_Point): Align handling for Bit_Order
with that for Scalar_Storage_Order.
* sem_prag.adb (Check_Atomic_VFA): Delete.
(Check_VFA_Conflicts): Likewise.
(Check_Full_Access_Only): New procedure.
(Process_Atomic_Independent_Shared_Volatile): Call to implement
the new legality checks in C.6(8/2) and mark the entity last.
(Analyze_Pragma) : Remove obsolete check.
* sem_util.ads (Is_Atomic_Or_VFA_Object): Rename into...
(Is_Full_Access_Object): ...this.
(Is_Subcomponent_Of_Atomic_Object): Rename into...
(Is_Subcomponent_Of_Full_Access_Object): ...this.
* sem_util.adb (Inherit_Rep_Item_Chain): Use Present_In_Rep_Item.
(Is_Atomic_Or_VFA_Object): Rename into...
(Is_Full_Access_Object): ...this.
(Is_Subcomponent_Of_Atomic_Object): Rename into...
(Is_Subcomponent_Of_Full_Access_Object): ...this and adjust.
* snames.ads-tmpl (Name_Full_Access_Only): New name of aspect.
* gcc-interface/decl.c (gnat_to_gnu_entity): Adjust for renaming.
(promote_object_alignment): Likewise.
(gnat_to_gnu_field): Likewise.  Rename local variable and use
specific qualifier in error message for Volatile_Full_Access.
* gcc-interface/trans.c (lvalue_required_p): Likewise.

patch.diff.gz
Description: application/gzip


Kryptowaluta: dobry sposob na zarabianie pieniedzy -- ZVS/46514810014

2020-10-23 Thread [iTrade] Józefa Kaminski via Gcc-patches
   


Zarob dzis fortune, inwestuje!.pdf
Description: Binary data


Re: [Ada,FYI] revamp ada.numerics.aux

2020-10-23 Thread Alexandre Oliva
On Oct 22, 2020, Eric Botcazou  wrote:

>> So I'm going ahead and checking this in, approved by Eric Botcazou.
>> (Rainer's followup patch is coming up separately but momentarily)
>> 
>> 
>> aarch64-* and ppc*-linux-gnu long long float/long double mismatch

> Does this fix https://gcc.gnu.org/PR97504 for PowerPC64?

Yeah.

> Note that S/390 is affected as well according to Stefan.

Thanks for drawing my attention to it.  I also noticed sparc*-linux-gnu
and powerpc*-darwin had missed the earlier fixes for sparc and ppc.
Here's the patch I'm checking in.


more wraplf for aux long long float: s390, sparc and powerpc

From: Alexandre Oliva 

The wraplf version of Ada.Numerics.Aux_Long_Long_Float is needed on
s390* as well.  Also add it to sparc*-linux-gnu and powerpc-darwin,
that were missed when adding it for sparc and ppc targets.


for  gcc/ada/ChangeLog

PR ada/97504
* Makefile.rtl (LIBGNAT_TARGET_PAIRS): Select wraplf version
of Aux_Long_Long_Float for s390 and remaining sparc and
powerpc targets.
---
 gcc/ada/Makefile.rtl |3 +++
 1 file changed, 3 insertions(+)

diff --git a/gcc/ada/Makefile.rtl b/gcc/ada/Makefile.rtl
index e2a4f4e..a1cf23a 100644
--- a/gcc/ada/Makefile.rtl
+++ b/gcc/ada/Makefile.rtl
@@ -1909,6 +1909,7 @@ endif
 ifeq ($(strip $(filter-out s390% linux%,$(target_cpu) $(target_os))),)
   LIBGNAT_TARGET_PAIRS = \
   a-intnam.adshttps://FSFLA.org/blogs/lxo/
Free Software Activist
GNU Toolchain Engineer


[PATCH] Add debug_bb_details and debug_bb_n_details

2020-10-23 Thread Xiong Hu Luo via Gcc-patches
Sometimes debug_bb_slim&debug_bb_n_slim is not enough, how about adding
this debug_bb_details&debug_bb_n_details? Or any other similar call
existed?

gcc/ChangeLog:

2020-10-23  Xionghu Luo  

* print-rtl.c (debug_bb_details): New function.
* (debug_bb_n_details): New function.
---
 gcc/print-rtl.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/gcc/print-rtl.c b/gcc/print-rtl.c
index 25265efc71b..f45873b8863 100644
--- a/gcc/print-rtl.c
+++ b/gcc/print-rtl.c
@@ -2150,6 +2150,21 @@ debug_bb_n_slim (int n)
   debug_bb_slim (bb);
 }
 
+extern void debug_bb_details (basic_block);
+DEBUG_FUNCTION void
+debug_bb_details (basic_block bb)
+{
+  dump_bb (stderr, bb, 0, TDF_DETAILS | TDF_BLOCKS);
+}
+
+extern void debug_bb_n_details (int);
+DEBUG_FUNCTION void
+debug_bb_n_details (int n)
+{
+  basic_block bb = BASIC_BLOCK_FOR_FN (cfun, n);
+  debug_bb_details (bb);
+}
+
 #endif
 
 #if __GNUC__ >= 10
-- 
2.27.0.90.geebb51ba8c



Re: [patch] OpenMP: Fortran - support omp flush's memorder clauses

2020-10-23 Thread Bernhard Reutner-Fischer via Gcc-patches
On 22 October 2020 17:02:36 CEST, Jakub Jelinek via Gcc-patches 
 wrote:
>On Thu, Oct 22, 2020 at 04:52:10PM +0200, Tobias Burnus wrote:
>> +  else
>> +{
>> +  enum memmodel mo = MEMMODEL_LAST;
>> +  switch (code->ext.omp_clauses->memorder)
>> +{
>> +case OMP_MEMORDER_ACQ_REL: mo = MEMMODEL_ACQ_REL; break;
>> +case OMP_MEMORDER_RELEASE: mo = MEMMODEL_RELEASE; break;
>> +case OMP_MEMORDER_ACQUIRE: mo = MEMMODEL_ACQUIRE; break;
>> +case OMP_MEMORDER_LAST: gcc_unreachable (); break;
>
>I'd probably use
>   default: gcc_unreachable (); break;
>here instead.
>Otherwise LGTM, thanks.

I have one trivial remark though. In

+{
+  if (gfc_match ("acq_rel") == MATCH_YES)
+   mo = OMP_MEMORDER_ACQ_REL;
+  else if (gfc_match ("release") == MATCH_YES)
+   mo = OMP_MEMORDER_RELEASE;
+  else if (gfc_match ("acquire") == MATCH_YES)
+   mo = OMP_MEMORDER_ACQUIRE;
+  else
+   {
+ gfc_error ("Expected AQC_REL, RELEASE, or ACQUIRE at %C");

I suggest s/AQC/ACQ/
LGTM too, otherwise ;)


Re: [Ada] Improve precision of Ada.Directories.Modification_Time

2020-10-23 Thread Arnaud Charlet
> > For future reference, TRT for this kind of problem is to
> > autoconf for the right struct field name, using AC_CHECK_MEMBER
> > or AC_CHECK_MEMBERS (then use e.g. #if HAVE_STAT_ST_MTIM / #if
> > HAVE_STAT_ST_MTIMESPEC, definitely not #if __APPLE__).
> 
> I'm not diasgreeing with your technical comment; now I am in a difficult 
> position.
> I don't have resources at the moment to make the changes you suggest, and
> Darwin is bootstrap-broken (at least for Ada).
> 
> so .. the attached is a workaround - now I've resolved the second bootstrap 
> issue
> on powerpc-darwin, I was able to test it more widely.
> 
> I have *not* applied the patch, pending a 'proper' solution at some 
> unspecified
> time in the future .. 

Your patch is OK, the "proper" solution is unlikely to appear anytime soon,
so let's not have best be the enemy of good (enough).

Arno

> Darwin has timeval entries for file access and modification
> times but they are named differently from those on Linux (and
> presumably everywhere else, since no other platform has
> reported an issue).
> ---
>  gcc/ada/adaint.c | 5 +
>  1 file changed, 5 insertions(+)
> 
> diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c
> index b7406a03c31..560f3529442 100644
> --- a/gcc/ada/adaint.c
> +++ b/gcc/ada/adaint.c
> @@ -237,6 +237,11 @@ UINT __gnat_current_ccs_encoding;
>  
>  #include "adaint.h"
>  
> +#if defined (__APPLE__) && defined (st_mtime)
> +#define st_atim st_atimespec
> +#define st_mtim st_mtimespec
> +#endif
> +
>  /* Define symbols O_BINARY and O_TEXT as harmless zeroes if they are not
> defined in the current system. On DOS-like systems these flags control
> whether the file is opened/created in text-translation mode (CR/LF in


Re: New modref/ipa_modref optimization passes

2020-10-23 Thread Bernhard Reutner-Fischer via Gcc-patches
On 16 October 2020 11:20:23 CEST, Richard Biener  wrote:

>IMHO the cleanest way would be to swap the CAF token field and
>the dim[] field (which is an ABI change for -fcoarray)

I think coarrays are new anyway so I suppose an ABI break is fine?



Re: [PATCH] Add debug_bb_details and debug_bb_n_details

2020-10-23 Thread Segher Boessenkool
On Fri, Oct 23, 2020 at 04:34:02AM -0500, Xiong Hu Luo wrote:
> Sometimes debug_bb_slim&debug_bb_n_slim is not enough, how about adding
> this debug_bb_details&debug_bb_n_details? Or any other similar call
> existed?

> +  dump_bb (stderr, bb, 0, TDF_DETAILS | TDF_BLOCKS);

You can just call this dump_bb directly?  And as a bonus you can dump it
to the dump file instead of to stderr ;-)


Segher


Re: New modref/ipa_modref optimization passes

2020-10-23 Thread Andre Vehreschild



On Fri, 23 Oct 2020 11:54:08 +0200
Bernhard Reutner-Fischer via Fortran  wrote:

> On 16 October 2020 11:20:23 CEST, Richard Biener  wrote:
>
> >IMHO the cleanest way would be to swap the CAF token field and
> >the dim[] field (which is an ABI change for -fcoarray)
>
> I think coarrays are new anyway so I suppose an ABI break is fine?

Coarrays are in the standard since Fortran 2008. So what I'd rather not call
them new being there for more than 10 years...

The descriptor is used in the opencoarrays library, too. And has to be kept in
sync. So when the ABI break is reasonable it's fine.

--
Andre Vehreschild * Email: vehre ad gmx dot de


Re: [Ada] Improve precision of Ada.Directories.Modification_Time

2020-10-23 Thread Hans-Peter Nilsson



On Fri, 23 Oct 2020, Arnaud Charlet wrote:

> > > For future reference, TRT for this kind of problem is to
> > > autoconf for the right struct field name, using AC_CHECK_MEMBER
> > > or AC_CHECK_MEMBERS (then use e.g. #if HAVE_STAT_ST_MTIM / #if
> > > HAVE_STAT_ST_MTIMESPEC, definitely not #if __APPLE__).
> >
> > I'm not diasgreeing with your technical comment; now I am in a difficult 
> > position.
> > I don't have resources at the moment to make the changes you suggest, and
> > Darwin is bootstrap-broken (at least for Ada).
> >
> > so .. the attached is a workaround - now I've resolved the second bootstrap 
> > issue
> > on powerpc-darwin, I was able to test it more widely.
> >
> > I have *not* applied the patch, pending a 'proper' solution at some 
> > unspecified
> > time in the future ..
>
> Your patch is OK, the "proper" solution is unlikely to appear anytime soon,
> so let's not have best be the enemy of good (enough).
>
> Arno

Absolutely, hence my "for future reference"; not a suggestion
to put resources to *this* instance.

brgds, H-P


>
> > Darwin has timeval entries for file access and modification
> > times but they are named differently from those on Linux (and
> > presumably everywhere else, since no other platform has
> > reported an issue).
> > ---
> >  gcc/ada/adaint.c | 5 +
> >  1 file changed, 5 insertions(+)
> >
> > diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c
> > index b7406a03c31..560f3529442 100644
> > --- a/gcc/ada/adaint.c
> > +++ b/gcc/ada/adaint.c
> > @@ -237,6 +237,11 @@ UINT __gnat_current_ccs_encoding;
> >
> >  #include "adaint.h"
> >
> > +#if defined (__APPLE__) && defined (st_mtime)
> > +#define st_atim st_atimespec
> > +#define st_mtim st_mtimespec
> > +#endif
> > +
> >  /* Define symbols O_BINARY and O_TEXT as harmless zeroes if they are not
> > defined in the current system. On DOS-like systems these flags control
> > whether the file is opened/created in text-translation mode (CR/LF in
>


Re: [PATCH] Add debug_bb_details and debug_bb_n_details

2020-10-23 Thread Richard Biener
On Fri, 23 Oct 2020, Xiong Hu Luo wrote:

> Sometimes debug_bb_slim&debug_bb_n_slim is not enough, how about adding
> this debug_bb_details&debug_bb_n_details? Or any other similar call
> existed?

There's already debug_bb and debug_bb_n in cfg.c which works on both
RTL and GIMPLE.  How about instead adding overloads that accept
a flags argument so you can do

debug_bb_n (5, TDF_DETAILS)

?  The debug_bb_slim variant would then just a forwarder.

> gcc/ChangeLog:
> 
> 2020-10-23  Xionghu Luo  
> 
>   * print-rtl.c (debug_bb_details): New function.
>   * (debug_bb_n_details): New function.
> ---
>  gcc/print-rtl.c | 15 +++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/gcc/print-rtl.c b/gcc/print-rtl.c
> index 25265efc71b..f45873b8863 100644
> --- a/gcc/print-rtl.c
> +++ b/gcc/print-rtl.c
> @@ -2150,6 +2150,21 @@ debug_bb_n_slim (int n)
>debug_bb_slim (bb);
>  }
>  
> +extern void debug_bb_details (basic_block);
> +DEBUG_FUNCTION void
> +debug_bb_details (basic_block bb)
> +{
> +  dump_bb (stderr, bb, 0, TDF_DETAILS | TDF_BLOCKS);
> +}
> +
> +extern void debug_bb_n_details (int);
> +DEBUG_FUNCTION void
> +debug_bb_n_details (int n)
> +{
> +  basic_block bb = BASIC_BLOCK_FOR_FN (cfun, n);
> +  debug_bb_details (bb);
> +}
> +
>  #endif
>  
>  #if __GNUC__ >= 10
> 

-- 
Richard Biener 
SUSE Software Solutions Germany GmbH, Maxfeldstrasse 5, 90409 Nuernberg,
Germany; GF: Felix Imend


[PATCH, OpenMP 5.0] Implement structure element mapping changes in 5.0

2020-10-23 Thread Chung-Lin Tang

Hi Jakub,
this patch set implements more of OpenMP 5.0 mapping, specifically this part in 
2.19.7.1 map Clause:

"If a list item in a map clause is a structure element then all other structure 
elements of the
 containing structure variable form a structure sibling list. The map clause 
and the structure sibling
 list are associated with the same construct. If a corresponding list item of 
the structure sibling list
 item is present in the device data environment when the construct is 
encountered then:

 * If the 1 structure sibling list item does not appear in a map clause on the 
construct then:
   – If the construct is a target, target data, or target enter data construct 
then the
 structure sibling list item is treated as if it is a list item in a map 
clause on the construct with a
 map-type of alloc.
   – If the construct is target exit data construct, then the structure sibling 
list item is treated
 as if it is a list item in a map clause on the construct with a map-type of 
release."

While really wordy, I believe this simply means that maps of structure element 
fields have their reference
counts increased/decreased in a uniform fashion, i.e. the are alloc/release'd 
together, instead of
having parts of the structure possibly deallocated while others still exist on 
the device.

In general, upon encountering a construct, we can't statically determine and 
insert alloc/release maps
for each element of a structure variable, since we don't really know which 
region of the structure is
currently mapped or not, hence this probably can't be properly implemented in 
the compiler.

Instead this patch tries to do the equivalent in the runtime: I've modified the 
handling of the
(GOMP_MAP_STRUCT, , , ...) sequence to:

  (1) Create just a single splay_tree_key to represent the entire structure's 
mapped-region
  (all element target_var_desc's now reference this same key instead of 
creating their own), and

  (2) Associated an increment/decrement of the splay_tree_key refcount only 
with the leading GOMP_MAP_STRUCT,
  not with each individual struct element, e.g. those element 
tgt_var_desc's mainly are now only used to
  execute the host<->device copying logic.

This implies that, GOMP_MAP_STRUCT is needed also in "exit data" directives 
too, so a small patch in
gcc/gimplify.c has been made to NOT remove this map for OpenMP target exit 
data. OpenACC has not been touched.

(There are some parts of the libgomp changes with are related to 
differentiating OpenMP/OpenACC cases,
which also exists in the last 5.0-mapping patch, also included here for 
self-completeness)

This patch contains three libgomp testcases, the first one of which was also 
included in the last 5.0-mapping
patch set as an XFAIL, but now passes with this patch.

Tobias' had an earlier issue with Fortran arrays (I forgot which kind it was 
called) where sub-struct fields
clashed with each other, causing a libgomp runtime mapping fail. That problem 
should be fixed with this
patch, since the capturing of all tgt_var_desc's key references into a single 
splay_tree_key inherently avoids
the multiple overlapping key behavior. I have lightly tested Tobias' testcase 
he gave me earlier on this,
and this part of the issue appears to be solved, however it still needs the 
first 5.0-mapping patch combined
with this patch to completely work, since the Fortran array struct needs 
pointer-attachment/detachment of the
data to really work before and after the target region.

This patch has been tested on x86_64-linux with nvptx offloading with no 
regressions, also currently testing
for powerpc64le-linux, seeking approval for trunk.

(BTW Jakub, thanks for your review of the other first patch set, I will be 
working on that revision next).

Thanks,
Chung-Lin

2020-10-23  Chung-Lin Tang  

gcc/
* gimplify.c (gimplify_adjust_omp_clauses): Do not remove
GOMP_MAP_STRUCT clauses for OpenMP target exit data constructs.

libgomp/
* libgomp.h (struct target_var_desc): New 'bool is_struct' field,
update comments for 'length' field.
(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_existing): Add 'bool inc_ref' parameter,
conditionalize refcount increase on inc_ref. Initialize is_struct
field for tgt_var.
(gomp_map_fields_existing): Add 'bool fld_inc_ref' parameter, adjust
calls to gomp_map_vars_existing.
(gomp_map_vars_internal): Change checks of GOMP_MAP_VARS_ENTER_DATA
to use bit-and (&). Adjust OpenMP handling of GOMP_MAP_STRUCT.
(gomp_var_unref): New function, factored from code in
gomp_unmap_vars_intern

[PATCH] middle-end/97521 - always use single-bit bools in mask vector types

2020-10-23 Thread Richard Biener
This makes us always use a single-bit boolean type component type
for integer mode mask VECTOR_BOOLEAN_TYPE_P to match the RTL and target
representation.  This aovids the need for magic translation and
the inconsistencies from the translation requirement now that
we expose temporaries of those types on the GIMPLE level.

Bootstrapped and tested on x86_64-unknown-linux-gnu, i386.exp
results are unchanged when run in SDE with -march=cascadelake.

OK?

Thanks,
Richard.

2020-10-23  Richard Biener  

PR middle-end/97521
* expr.c (const_scalar_mask_from_tree): Remove.
(expand_expr_real_1): Always VIEW_CONVERT integer mode
vector constants to an integer type.
* tree.c (build_truth_vector_type_for_mode): Use a single-bit
boolean component type for non-vector-mode mask_mode.

* gcc.target/i386/pr97521.c: New testcase.
---
 gcc/expr.c  | 39 +++--
 gcc/testsuite/gcc.target/i386/pr97521.c | 27 +
 gcc/tree.c  | 11 +--
 3 files changed, 40 insertions(+), 37 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/i386/pr97521.c

diff --git a/gcc/expr.c b/gcc/expr.c
index 9d951e82522..ae16f077758 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -96,7 +96,6 @@ static void emit_single_push_insn (machine_mode, rtx, tree);
 static void do_tablejump (rtx, machine_mode, rtx, rtx, rtx,
  profile_probability);
 static rtx const_vector_from_tree (tree);
-static rtx const_scalar_mask_from_tree (scalar_int_mode, tree);
 static tree tree_expr_size (const_tree);
 static HOST_WIDE_INT int_expr_size (tree);
 static void convert_mode_scalar (rtx, rtx, int);
@@ -10356,16 +10355,10 @@ expand_expr_real_1 (tree exp, rtx target, 
machine_mode tmode,
scalar_int_mode int_mode;
if (is_int_mode (mode, &int_mode))
  {
-   if (VECTOR_BOOLEAN_TYPE_P (TREE_TYPE (exp)))
- return const_scalar_mask_from_tree (int_mode, exp);
-   else
- {
-   tree type_for_mode
- = lang_hooks.types.type_for_mode (int_mode, 1);
-   if (type_for_mode)
- tmp = fold_unary_loc (loc, VIEW_CONVERT_EXPR,
-   type_for_mode, exp);
- }
+   tree type_for_mode = lang_hooks.types.type_for_mode (int_mode, 1);
+   if (type_for_mode)
+ tmp = fold_unary_loc (loc, VIEW_CONVERT_EXPR,
+   type_for_mode, exp);
  }
if (!tmp)
  {
@@ -12739,30 +12732,6 @@ const_vector_mask_from_tree (tree exp)
   return builder.build ();
 }
 
-/* EXP is a VECTOR_CST in which each element is either all-zeros or all-ones.
-   Return a constant scalar rtx of mode MODE in which bit X is set if element
-   X of EXP is nonzero.  */
-static rtx
-const_scalar_mask_from_tree (scalar_int_mode mode, tree exp)
-{
-  wide_int res = wi::zero (GET_MODE_PRECISION (mode));
-  tree elt;
-
-  /* The result has a fixed number of bits so the input must too.  */
-  unsigned int nunits = VECTOR_CST_NELTS (exp).to_constant ();
-  for (unsigned int i = 0; i < nunits; ++i)
-{
-  elt = VECTOR_CST_ELT (exp, i);
-  gcc_assert (TREE_CODE (elt) == INTEGER_CST);
-  if (integer_all_onesp (elt))
-   res = wi::set_bit (res, i);
-  else
-   gcc_assert (integer_zerop (elt));
-}
-
-  return immed_wide_int_const (res, mode);
-}
-
 /* Return a CONST_VECTOR rtx for a VECTOR_CST tree.  */
 static rtx
 const_vector_from_tree (tree exp)
diff --git a/gcc/testsuite/gcc.target/i386/pr97521.c 
b/gcc/testsuite/gcc.target/i386/pr97521.c
new file mode 100644
index 000..804ffd61e13
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr97521.c
@@ -0,0 +1,27 @@
+/* { dg-do run } */
+/* { dg-options "-O -mno-sse2" } */
+
+typedef unsigned char __attribute__ ((__vector_size__ (8))) V;
+typedef unsigned long long __attribute__ ((__vector_size__ (16))) W;
+
+V c;
+W d, e;
+
+V
+foo (W f)
+{
+  W g = (W) { 0, 209 } <7 <= (0 < f);
+  W h = e + g + d;
+  V j = (V) (h[0]) + (V) c;
+  return j;
+}
+
+int
+main (void)
+{
+  V x = foo ((W) { 3 });
+  for (unsigned i = 0; i < sizeof (x); i++)
+if (x[i] != 0xff)
+  __builtin_abort ();
+  return 0;
+}
diff --git a/gcc/tree.c b/gcc/tree.c
index 555ba97e68b..e24e84f39c7 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -10926,8 +10926,15 @@ build_truth_vector_type_for_mode (poly_uint64 nunits, 
machine_mode mask_mode)
 {
   gcc_assert (mask_mode != BLKmode);
 
-  poly_uint64 vsize = GET_MODE_BITSIZE (mask_mode);
-  unsigned HOST_WIDE_INT esize = vector_element_size (vsize, nunits);
+  unsigned HOST_WIDE_INT esize;
+  if (VECTOR_MODE_P (mask_mode))
+{
+  poly_uint64 vsize = GET_MODE_BITSIZE (mask_mode);
+  esize = vector_element_size (vsize, nunits);
+}
+  else
+esize = 1;
+
   tree bool_type = build_nonstandard_boolean_type (esize);
 
   return make_vect

Re: [PATCH] t/trodgers/c2a_synchronization

2020-10-23 Thread Jonathan Wakely via Gcc-patches

On 05/10/20 15:54 -0700, Thomas Rodgers wrote:

From: Thomas Rodgers 

This *should* be the correct patch this time.


There are still some review comments not addressed. I'll keep all my
comments on this version in a single reply, so they aren't lost among
multiple replies.

I think the significant issues like the handling of spurious wakeups
and the missing "no effects" case in _M_try_acquire() are resolved,
thanks.


diff --git a/libstdc++-v3/include/bits/atomic_timed_wait.h 
b/libstdc++-v3/include/bits/atomic_timed_wait.h
new file mode 100644
index 000..cd5b6aabc44
--- /dev/null
+++ b/libstdc++-v3/include/bits/atomic_timed_wait.h


[...]


+struct __timed_waiters : __waiters
+{
+  template
+   __atomic_wait_status
+   _M_do_wait_until(__platform_wait_t __version,
+const chrono::time_point<_Clock, _Duration>& __atime)
+   {
+#ifdef _GLIBCXX_HAVE_LINUX_FUTEX
+ return __platform_wait_until(&_M_ver, __version, __atime);


Qualify to prevent ADL in associated namespaces of the _Clock and
_Duration types.


+  template
+bool
+__atomic_wait_until(const _Tp* __addr, _Tp __old, _Pred __pred,
+   const chrono::time_point<_Clock, _Duration>&
+   __atime) noexcept
+{
+  using namespace __detail;
+
+  if (std::__atomic_spin(__pred))
+   return true;
+
+  auto& __w = __timed_waiters::_S_timed_for((void*)__addr);
+  auto __version = __w._M_enter_wait();
+  do
+   {
+ __atomic_wait_status __res;
+ if constexpr (__platform_wait_uses_type<_Tp>)
+   {
+ __res = __platform_wait_until((__platform_wait_t*)(void*) __addr,


Qualify to prevent ADL.



diff --git a/libstdc++-v3/include/bits/atomic_wait.h 
b/libstdc++-v3/include/bits/atomic_wait.h
new file mode 100644
index 000..30f682e828a
--- /dev/null
+++ b/libstdc++-v3/include/bits/atomic_wait.h




+  template
+void
+__atomic_wait(const _Tp* __addr, _Tp __old, _Pred __pred) noexcept
+{
+  using namespace __detail;
+  if (__atomic_spin(__pred))


Qualify to prevent ADL.


diff --git a/libstdc++-v3/include/bits/semaphore_base.h 
b/libstdc++-v3/include/bits/semaphore_base.h
new file mode 100644
index 000..a32a6b12a1b
--- /dev/null
+++ b/libstdc++-v3/include/bits/semaphore_base.h
@@ -0,0 +1,298 @@
+// -*- C++ -*- header.
+
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+// .
+
+/** @file bits/semaphore_base.h
+ *  This is an internal header file, included by other library headers.
+ *  Do not attempt to use it directly. @headername{semaphore}
+ */
+
+#ifndef _GLIBCXX_SEMAPHORE_BASE_H
+#define _GLIBCXX_SEMAPHORE_BASE_H 1
+
+#pragma GCC system_header
+
+#include 
+#include 
+#include 
+
+#include 
+
+#if __has_include()
+#define _GLIBCXX_HAVE_POSIX_SEMAPHORE 1
+#include 
+#endif
+
+#include 
+#include 
+
+#include 


This shouldn't be here.


+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+#ifdef _GLIBCXX_HAVE_POSIX_SEMAPHORE
+  struct __platform_semaphore
+  {
+using __clock_t = chrono::system_clock;
+static constexpr ptrdiff_t _S_max = SEM_VALUE_MAX;
+
+explicit __platform_semaphore(ptrdiff_t __count) noexcept
+{
+  sem_init(&_M_semaphore, 0, __count);
+}
+
+__platform_semaphore(const __platform_semaphore&) = delete;
+__platform_semaphore& operator=(const __platform_semaphore&) = delete;
+
+~__platform_semaphore()
+{ sem_destroy(&_M_semaphore); }
+
+_GLIBCXX_ALWAYS_INLINE void
+_M_acquire() noexcept
+{
+  for (;;)
+   {
+ auto __err = sem_wait(&_M_semaphore);
+ if (__err && (errno == EINTR))
+   continue;
+ else if (__err)
+   std::terminate();
+ else
+   break;
+   }
+}
+
+_GLIBCXX_ALWAYS_INLINE void
+_M_release(std::ptrdiff_t __update) noexcept
+{
+  for(; __update != 0; --__update)
+   {
+   

Re: [PATCH] arc: Use separate predicated patterns for mpyd(u)

2020-10-23 Thread Claudiu Zissulescu Ianculescu via Gcc-patches
Gentle PING.

On Wed, Oct 7, 2020 at 12:39 PM Claudiu Zissulescu  wrote:
>
> From: Claudiu Zissulescu 
>
> The compiler can match mpyd.eq r0,r1,r0 as a predicated instruction,
> which is incorrect. The mpyd(u) instruction takes as input two 32-bit
> registers, returning into a double 64-bit even-odd register pair.  For
> the predicated case, the ARC instruction decoder expects the
> destination register to be the same as the first input register. In
> the big-endian case the result is swaped in the destination register
> pair, however, the instruction encoding remains the same.  Refurbish
> the mpyd(u) patterns to take into account the above observation.
>
> Permission to apply this patch to master, gcc10 and gcc9 branches.
>
> Cheers,
> Claudiu
>
> -xx-xx  Claudiu Zissulescu  
>
> * testsuite/gcc.target/arc/pmpyd.c: New test.
> * testsuite/gcc.target/arc/tmac-1.c: Update.
> * config/arc/arc.md (mpyd_arcv2hs): New template
> pattern.
> (*pmpyd_arcv2hs): Likewise.
> (*pmpyd_imm_arcv2hs): Likewise.
> (mpyd_arcv2hs): Moved into above template.
> (mpyd_imm_arcv2hs): Moved into above template.
> (mpydu_arcv2hs): Likewise.
> (mpydu_imm_arcv2hs): Likewise.
> (su_optab): New optab prefix for sign/zero-extending operations.
>
> Signed-off-by: Claudiu Zissulescu 
> ---
>  gcc/config/arc/arc.md | 101 +-
>  gcc/testsuite/gcc.target/arc/pmpyd.c  |  15 
>  gcc/testsuite/gcc.target/arc/tmac-1.c |   2 +-
>  3 files changed, 67 insertions(+), 51 deletions(-)
>  create mode 100644 gcc/testsuite/gcc.target/arc/pmpyd.c
>
> diff --git a/gcc/config/arc/arc.md b/gcc/config/arc/arc.md
> index 1720e8cd2f6f..d4d9f59a3eac 100644
> --- a/gcc/config/arc/arc.md
> +++ b/gcc/config/arc/arc.md
> @@ -894,6 +894,8 @@ archs4x, archs4xd"
>
>  (define_code_iterator SEZ [sign_extend zero_extend])
>  (define_code_attr SEZ_prefix [(sign_extend "sex") (zero_extend "ext")])
> +; Optab prefix for sign/zero-extending operations
> +(define_code_attr su_optab [(sign_extend "") (zero_extend "u")])
>
>  (define_insn "*xt_cmp0_noout"
>[(set (match_operand 0 "cc_set_register" "")
> @@ -6436,66 +6438,65 @@ archs4x, archs4xd"
> (set_attr "predicable" "no")
> (set_attr "cond" "nocond")])
>
> -(define_insn "mpyd_arcv2hs"
> -  [(set (match_operand:DI 0 "even_register_operand"
> "=Rcr, r")
> -   (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand"  "  
> 0, c"))
> -(sign_extend:DI (match_operand:SI 2 "register_operand"  "  
> c, c"
> +(define_insn "mpyd_arcv2hs"
> +  [(set (match_operand:DI 0 "even_register_operand"   "=r")
> +   (mult:DI (SEZ:DI (match_operand:SI 1 "register_operand" "r"))
> +(SEZ:DI (match_operand:SI 2 "register_operand" "r"
> (set (reg:DI ARCV2_ACC)
> (mult:DI
> - (sign_extend:DI (match_dup 1))
> - (sign_extend:DI (match_dup 2]
> + (SEZ:DI (match_dup 1))
> + (SEZ:DI (match_dup 2]
>"TARGET_PLUS_MACD"
> -  "mpyd%? %0,%1,%2"
> -  [(set_attr "length" "4,4")
> -  (set_attr "iscompact" "false")
> -  (set_attr "type" "multi")
> -  (set_attr "predicable" "yes,no")
> -  (set_attr "cond" "canuse,nocond")])
> -
> -(define_insn "mpyd_imm_arcv2hs"
> -  [(set (match_operand:DI 0 "even_register_operand"
> "=Rcr, r,r,Rcr,  r")
> -   (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand"  "  
> 0, c,0,  0,  c"))
> -(match_operand 2   "immediate_operand"  "  
> L, L,I,Cal,Cal")))
> +  "mpyd%?\\t%0,%1,%2"
> +  [(set_attr "length" "4")
> +   (set_attr "iscompact" "false")
> +   (set_attr "type" "multi")
> +   (set_attr "predicable" "no")])
> +
> +(define_insn "*pmpyd_arcv2hs"
> +  [(set (match_operand:DI 0 "even_register_operand" "=r")
> +   (mult:DI
> +(SEZ:DI (match_operand:SI 1 "even_register_operand" "%0"))
> +(SEZ:DI (match_operand:SI 2 "register_operand"  "r"
> (set (reg:DI ARCV2_ACC)
> -   (mult:DI (sign_extend:DI (match_dup 1))
> -(match_dup 2)))]
> +   (mult:DI
> + (SEZ:DI (match_dup 1))
> + (SEZ:DI (match_dup 2]
>"TARGET_PLUS_MACD"
> -  "mpyd%? %0,%1,%2"
> -  [(set_attr "length" "4,4,4,8,8")
> -  (set_attr "iscompact" "false")
> -  (set_attr "type" "multi")
> -  (set_attr "predicable" "yes,no,no,yes,no")
> -  (set_attr "cond" "canuse,nocond,nocond,canuse_limm,nocond")])
> -
> -(define_insn "mpydu_arcv2hs"
> -  [(set (match_operand:DI 0 "even_register_operand"
> "=Rcr, r")
> -   (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand"  "  
> 0, c"))
> -(zero_extend:DI (match_operand:SI 2 "register_operand" "   
> c, c"
> +  "mpyd%?\\t%0,%1,%2"
> +  [(set_attr "length" "4")
> +   (set_attr "iscompact" "false")
> +   (set_attr "type" "multi")
> +   (set_attr "predicable

Re: [PATCH] arc: Improve/add instruction patterns to better use MAC instructions.

2020-10-23 Thread Claudiu Zissulescu Ianculescu via Gcc-patches
Gentle PING.

On Fri, Oct 9, 2020 at 5:24 PM Claudiu Zissulescu  wrote:
>
> From: Claudiu Zissulescu 
>
> ARC MYP7+ instructions add MAC instructions for vector and scalar data
> types. This patch adds a madd pattern for 16it datum that is using the
> 32bit MAC instruction, and dot_prod patterns for v4hi vector
> types. The 64bit moves are also upgraded by using vadd2 instuction.
>
> gcc/
> -xx-xx  Claudiu Zissulescu  
>
> * config/arc/arc.c (arc_split_move): Recognize vadd2 instructions.
> * config/arc/arc.md (movdi_insn): Update pattern to use vadd2
> instructions.
> (movdf_insn): Likewise.
> (maddhisi4): New pattern.
> (umaddhisi4): Likewise.
> * config/arc/simdext.md (mov_int): Update pattern to use
> vadd2.
> (sdot_prodv4hi): New pattern.
> (udot_prodv4hi): Likewise.
> (arc_vec_mac_hi_v4hi): Update/renamed to
> arc_vec_mac_v2hiv2si.
> (arc_vec_mac_v2hiv2si_zero): New pattern.
>
> Signed-off-by: Claudiu Zissulescu 
> ---
>  gcc/config/arc/arc.c  |  8 
>  gcc/config/arc/arc.md | 71 ---
>  gcc/config/arc/constraints.md |  5 ++
>  gcc/config/arc/simdext.md | 90 +++
>  4 files changed, 147 insertions(+), 27 deletions(-)
>
> diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c
> index ec55cfde87a9..d5b521e75e67 100644
> --- a/gcc/config/arc/arc.c
> +++ b/gcc/config/arc/arc.c
> @@ -10202,6 +10202,14 @@ arc_split_move (rtx *operands)
>return;
>  }
>
> +  if (TARGET_PLUS_QMACW
> +  && even_register_operand (operands[0], mode)
> +  && even_register_operand (operands[1], mode))
> +{
> +  emit_move_insn (operands[0], operands[1]);
> +  return;
> +}
> +
>if (TARGET_PLUS_QMACW
>&& GET_CODE (operands[1]) == CONST_VECTOR)
>  {
> diff --git a/gcc/config/arc/arc.md b/gcc/config/arc/arc.md
> index f9fc11e51a85..1720e8cd2f6f 100644
> --- a/gcc/config/arc/arc.md
> +++ b/gcc/config/arc/arc.md
> @@ -1345,8 +1345,8 @@ archs4x, archs4xd"
>")
>
>  (define_insn_and_split "*movdi_insn"
> -  [(set (match_operand:DI 0 "move_dest_operand"  "=w, w,r,   m")
> -   (match_operand:DI 1 "move_double_src_operand" "c,Hi,m,cCm3"))]
> +  [(set (match_operand:DI 0 "move_dest_operand"  "=r, r,r,   m")
> +   (match_operand:DI 1 "move_double_src_operand" "r,Hi,m,rCm3"))]
>"register_operand (operands[0], DImode)
> || register_operand (operands[1], DImode)
> || (satisfies_constraint_Cm3 (operands[1])
> @@ -1358,6 +1358,13 @@ archs4x, archs4xd"
>  default:
>return \"#\";
>
> +case 0:
> +if (TARGET_PLUS_QMACW
> +   && even_register_operand (operands[0], DImode)
> +   && even_register_operand (operands[1], DImode))
> +  return \"vadd2\\t%0,%1,0\";
> +return \"#\";
> +
>  case 2:
>  if (TARGET_LL64
>  && memory_operand (operands[1], DImode)
> @@ -1374,7 +1381,7 @@ archs4x, archs4xd"
>  return \"#\";
>  }
>  }"
> -  "reload_completed"
> +  "&& reload_completed"
>[(const_int 0)]
>{
> arc_split_move (operands);
> @@ -1420,15 +1427,24 @@ archs4x, archs4xd"
>"if (prepare_move_operands (operands, DFmode)) DONE;")
>
>  (define_insn_and_split "*movdf_insn"
> -  [(set (match_operand:DF 0 "move_dest_operand"  "=D,r,c,c,r,m")
> -   (match_operand:DF 1 "move_double_src_operand" "r,D,c,E,m,c"))]
> -  "register_operand (operands[0], DFmode) || register_operand (operands[1], 
> DFmode)"
> +  [(set (match_operand:DF 0 "move_dest_operand"  "=D,r,r,r,r,m")
> +   (match_operand:DF 1 "move_double_src_operand" "r,D,r,E,m,r"))]
> +  "register_operand (operands[0], DFmode)
> +   || register_operand (operands[1], DFmode)"
>"*
>  {
>   switch (which_alternative)
> {
>  default:
>return \"#\";
> +
> +case 2:
> +if (TARGET_PLUS_QMACW
> +   && even_register_operand (operands[0], DFmode)
> +   && even_register_operand (operands[1], DFmode))
> +  return \"vadd2\\t%0,%1,0\";
> +return \"#\";
> +
>  case 4:
>  if (TARGET_LL64
> && ((even_register_operand (operands[0], DFmode)
> @@ -6177,6 +6193,49 @@ archs4x, archs4xd"
>[(set_attr "length" "0")])
>
>  ;; MAC and DMPY instructions
> +
> +; Use MAC instruction to emulate 16bit mac.
> +(define_expand "maddhisi4"
> +  [(match_operand:SI 0 "register_operand" "")
> +   (match_operand:HI 1 "register_operand" "")
> +   (match_operand:HI 2 "extend_operand"   "")
> +   (match_operand:SI 3 "register_operand" "")]
> +  "TARGET_PLUS_DMPY"
> +  "{
> +   rtx acc_reg = gen_rtx_REG (DImode, ACC_REG_FIRST);
> +   rtx tmp1 = gen_reg_rtx (SImode);
> +   rtx tmp2 = gen_reg_rtx (SImode);
> +   rtx accl = gen_lowpart (SImode, acc_reg);
> +
> +   emit_move_insn (accl, operands[3]);
> +   emit_insn (gen_rtx_SET (tmp1, gen_rtx_SIGN_EXTEND (SImode, operands[1])));
> +   emit_insn (gen_rtx_SET (tmp2, gen_rtx_SIGN_EXTEND (SImode, operand

Re: Materialize clones on demand

2020-10-23 Thread Martin Jambor
Hi,

On Thu, Oct 22 2020, Jan Hubicka wrote:
> Hi,
> this patch removes the pass to materialize all clones and instead this
> is now done on demand.  The motivation is to reduce lifetime of function
> bodies in ltrans that should noticeably reduce memory use for highly
> parallel compilations of large programs (like Martin does) or with
> partitioning reduced/disabled. For cc1 with one partition the memory use
> seems to go down from 4gb to cca 1.5gb (seeing from top, so this is not
> particularly accurate).
>

Nice.

> This should also make get_body to do the right thing at WPA time (still
> not good idea for production patch).  I did not test this path.
>
> Martin (Jambor), Jakub, there is one FIXME in ipa-param-manipulation.
> We seem to ICE when we redirect to a call before callee is materialized
> (this should be possible to trigger on mainline with recursive
> callgraphs too, but it definitly triggers on several testcases in c
> testsuite if the get_untransformed_body is disabled). It would be nice
> to fix this, but I am not quite sure how the debug info adjustments here
> works.

Well, the debug mappings are all based on PARM_DECLs.  Unfortunately, I
cannot think of any quick fix now, though we might want to sit down and
try to revise the mechanism also because of debug info issues described
in PR 95343 and PR 93385.  I'll keep this in mind and in my notes.

I have one question regarding the patch itself:

> Bootstrapped/regtested x86_64-linux and also lto-bootstrapped with
> release checking.  I plan to commit it after bit more testing.
>
> Honza
>
> gcc/ChangeLog:
>
> 2020-10-22  Jan Hubicka  
>
>   * cgraph.c (cgraph_node::get_untransformed_body): Perform lazy
>   clone materialization.
>   * cgraph.h (cgraph_node::materialize_clone): Declare.
>   (symbol_table::materialize_all_clones): Remove.
>   * cgraphclones.c (cgraph_materialize_clone): Turn to ...
>   (cgraph_node::materialize_clone): .. this one; move here
>   dumping from symbol_table::materialize_all_clones.
>   (symbol_table::materialize_all_clones): Remove.
>   * cgraphunit.c (mark_functions_to_output): Clear stmt references.
>   (cgraph_node::expand): Initialize bitmaps early;
>   do not call execute_all_ipa_transforms if there are no transforms.
>   * ipa-inline-transform.c (save_inline_function_body): Fix formating.
>   (inline_transform): Materialize all clones before function is modified.
>   * ipa-param-manipulation.c (ipa_param_adjustments::modify_call):
>   Materialize clone if needed.
>   * ipa.c (class pass_materialize_all_clones): Remove.
>   (make_pass_materialize_all_clones): Remove.
>   * passes.c (execute_all_ipa_transforms): Materialize all clones.
>   * passes.def: Remove pass_materialize_all_clones.
>   * tree-pass.h (make_pass_materialize_all_clones): Remove.
>

[...]

> diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
> index 05713c28cf0..1e2262789dd 100644
> --- a/gcc/cgraphunit.c
> +++ b/gcc/cgraphunit.c
> @@ -2298,7 +2299,8 @@ cgraph_node::expand (void)
>bitmap_obstack_initialize (®_obstack); /* FIXME, only at RTL 
> generation*/
>  
>update_ssa (TODO_update_ssa_only_virtuals);
> -  execute_all_ipa_transforms (false);
> +  if (ipa_transforms_to_apply.exists ())
> +execute_all_ipa_transforms (false);
>  

Can some function not have ipa_inline among the transforms_to_apply?

Martin


Re: Materialize clones on demand

2020-10-23 Thread Jan Hubicka
> > Bootstrapped/regtested x86_64-linux and also lto-bootstrapped with
> > release checking.  I plan to commit it after bit more testing.
> >
> > Honza
> >
> > gcc/ChangeLog:
> >
> > 2020-10-22  Jan Hubicka  
> >
> > * cgraph.c (cgraph_node::get_untransformed_body): Perform lazy
> > clone materialization.
> > * cgraph.h (cgraph_node::materialize_clone): Declare.
> > (symbol_table::materialize_all_clones): Remove.
> > * cgraphclones.c (cgraph_materialize_clone): Turn to ...
> > (cgraph_node::materialize_clone): .. this one; move here
> > dumping from symbol_table::materialize_all_clones.
> > (symbol_table::materialize_all_clones): Remove.
> > * cgraphunit.c (mark_functions_to_output): Clear stmt references.
> > (cgraph_node::expand): Initialize bitmaps early;
> > do not call execute_all_ipa_transforms if there are no transforms.
> > * ipa-inline-transform.c (save_inline_function_body): Fix formating.
> > (inline_transform): Materialize all clones before function is modified.
> > * ipa-param-manipulation.c (ipa_param_adjustments::modify_call):
> > Materialize clone if needed.
> > * ipa.c (class pass_materialize_all_clones): Remove.
> > (make_pass_materialize_all_clones): Remove.
> > * passes.c (execute_all_ipa_transforms): Materialize all clones.
> > * passes.def: Remove pass_materialize_all_clones.
> > * tree-pass.h (make_pass_materialize_all_clones): Remove.
> >
> 
> [...]
> 
> > diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
> > index 05713c28cf0..1e2262789dd 100644
> > --- a/gcc/cgraphunit.c
> > +++ b/gcc/cgraphunit.c
> > @@ -2298,7 +2299,8 @@ cgraph_node::expand (void)
> >bitmap_obstack_initialize (®_obstack); /* FIXME, only at RTL 
> > generation*/
> >  
> >update_ssa (TODO_update_ssa_only_virtuals);
> > -  execute_all_ipa_transforms (false);
> > +  if (ipa_transforms_to_apply.exists ())
> > +execute_all_ipa_transforms (false);
> >  
> 
> Can some function not have ipa_inline among the transforms_to_apply?

This is for the case of repeated execution.  If you do get_body earlier
transforms are already applied.

Honza
> 
> Martin


[PATCH] testsuite: Add noexcept(false) to throwing destructor

2020-10-23 Thread Jonathan Wakely via Gcc-patches
I think this test is intended to check this property of the C++
standard:

"If a destructor directly invoked by stack unwinding exits via an
exception, std::terminate is invoked." [except.throw]

Since C++11 any exception escaping a destructor will call
std::terminate, so the test would terminate even if the unwinding
behaviour was wrong.

Give the destructor a potentially-throwing exception specification,
so that we know that terminate was called for the right reason.

gcc/testsuite/ChangeLog:

* g++.dg/compat/eh/filter2_y.C: Add noexcept(false) to
destructor.


Tested powerpc64le-linux. OK for trunk?

commit a1ef6bb4c681062c477f6a7a0859badf1bec4b09
Author: Jonathan Wakely 
Date:   Fri Oct 23 11:57:53 2020

testsuite: Add noexcept(false) to throwing destructor

I think this test is intended to check this property of the C++
standard:

"If a destructor directly invoked by stack unwinding exits via an
exception, std::terminate is invoked." [except.throw]

Since C++11 any exception escaping a destructor will call
std::terminate, so the test would terminate even if the unwinding
behaviour was wrong.

Give the destructor a potentially-throwing exception specification,
so that we know that terminate was called for the right reason.

gcc/testsuite/ChangeLog:

* g++.dg/compat/eh/filter2_y.C: Add noexcept(false) to
destructor.

diff --git a/gcc/testsuite/g++.dg/compat/eh/filter2_y.C 
b/gcc/testsuite/g++.dg/compat/eh/filter2_y.C
index 87c6fea1012..67a4ffedd86 100644
--- a/gcc/testsuite/g++.dg/compat/eh/filter2_y.C
+++ b/gcc/testsuite/g++.dg/compat/eh/filter2_y.C
@@ -9,6 +9,12 @@ struct a
   a () { }
 
   ~a ()
+#if __cplusplus >= 201103L
+// Give this destructor a potentially-throwing exception specification so
+// that we verify std::terminate gets called due to an exception during
+// unwinding, not just because the destructor is noexcept.
+noexcept(false)
+#endif
 {
   try
{


[PATCH] Optimize macro: make it more predictable

2020-10-23 Thread Martin Liška

Hey.

This is a follow-up of the discussion that happened in thread about 
no_stack_protector
attribute: https://gcc.gnu.org/pipermail/gcc-patches/2020-May/545916.html

The current optimize attribute works in the following way:
- 1) we take current global_options as base
- 2) maybe_default_options is called for the currently selected optimization 
level, which
 means all rules in default_options_table are executed
- 3) attribute values are applied (via decode_options)

So the step 2) is problematic: in case of -O2 -fno-omit-frame-pointer and 
__attribute__((optimize("-fno-stack-protector")))
ends basically with -O2 -fno-stack-protector because -fno-omit-frame-pointer is 
default:
/* -O1 and -Og optimizations.  */
{ OPT_LEVELS_1_PLUS, OPT_fomit_frame_pointer, NULL, 1 },

My patch handled and the current optimize attribute really behaves that same as 
appending attribute value
to the command line. So far so good. We should also reflect that in 
documentation entry which is quite
vague right now:

"""
The optimize attribute is used to specify that a function is to be compiled 
with different optimization options than specified on the command line.
"""

and we may want to handle -Ox in the attribute in a special way. I guess many 
macro/pragma users expect that

-O2 -ftree-vectorize and __attribute__((optimize(1))) will end with -O1 and not
with -ftree-vectorize -O1 ?

I'm also planning to take a look at the target macro/attribute, I expect 
similar problems:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97469

Thoughts?
Thanks,
Martin

gcc/c-family/ChangeLog:

* c-common.c (parse_optimize_options): Decoded attribute options
with the ones that were already set on the command line.

gcc/ChangeLog:

* toplev.c (toplev::main): Save decoded Optimization options.
* toplev.h (save_opt_decoded_options): New.

gcc/testsuite/ChangeLog:

* gcc.target/i386/avx512er-vrsqrt28ps-3.c: Disable -ffast-math.
* gcc.target/i386/avx512er-vrsqrt28ps-5.c: Likewise.
---
 gcc/c-family/c-common.c   | 15 ++-
 .../gcc.target/i386/avx512er-vrsqrt28ps-3.c   |  2 +-
 .../gcc.target/i386/avx512er-vrsqrt28ps-5.c   |  2 +-
 gcc/toplev.c  |  8 
 gcc/toplev.h  |  1 +
 5 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index e16ca3894bc..d4342e93d0a 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -5727,10 +5727,23 @@ parse_optimize_options (tree args, bool attr_p)
   j++;
 }
   decoded_options_count = j;
+
+  /* Merge the decoded options with save_decoded_options.  */
+  unsigned save_opt_count = save_opt_decoded_options.length ();
+  unsigned merged_decoded_options_count = save_opt_count + 
decoded_options_count;
+  cl_decoded_option *merged_decoded_options
+= XNEWVEC (cl_decoded_option, merged_decoded_options_count);
+
+  for (unsigned i = 0; i < save_opt_count; ++i)
+merged_decoded_options[i] = save_opt_decoded_options[i];
+  for (unsigned i = 0; i < decoded_options_count; ++i)
+merged_decoded_options[save_opt_count + i] = decoded_options[i];
+
   /* And apply them.  */
   decode_options (&global_options, &global_options_set,
- decoded_options, decoded_options_count,
+ merged_decoded_options, merged_decoded_options_count,
  input_location, global_dc, NULL);
+  free (decoded_options);
 
   targetm.override_options_after_change();
 
diff --git a/gcc/testsuite/gcc.target/i386/avx512er-vrsqrt28ps-3.c b/gcc/testsuite/gcc.target/i386/avx512er-vrsqrt28ps-3.c

index 1ba8172d6e3..40aefb50844 100644
--- a/gcc/testsuite/gcc.target/i386/avx512er-vrsqrt28ps-3.c
+++ b/gcc/testsuite/gcc.target/i386/avx512er-vrsqrt28ps-3.c
@@ -8,7 +8,7 @@
 #define MAX 1000
 #define EPS 0.1
 
-__attribute__ ((noinline, optimize (1)))

+__attribute__ ((noinline, optimize (1, "-fno-fast-math")))
 void static
 compute_rsqrt_ref (float *a, float *r)
 {
diff --git a/gcc/testsuite/gcc.target/i386/avx512er-vrsqrt28ps-5.c 
b/gcc/testsuite/gcc.target/i386/avx512er-vrsqrt28ps-5.c
index e067a81e562..498f4d50aa5 100644
--- a/gcc/testsuite/gcc.target/i386/avx512er-vrsqrt28ps-5.c
+++ b/gcc/testsuite/gcc.target/i386/avx512er-vrsqrt28ps-5.c
@@ -8,7 +8,7 @@
 #define MAX 1000
 #define EPS 0.1
 
-__attribute__ ((noinline, optimize (1)))

+__attribute__ ((noinline, optimize (1, "-fno-fast-math")))
 void static
 compute_sqrt_ref (float *a, float *r)
 {
diff --git a/gcc/toplev.c b/gcc/toplev.c
index 8c1e1e1f44f..27e4a1bc485 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -123,6 +123,9 @@ static bool no_backend;
 struct cl_decoded_option *save_decoded_options;
 unsigned int save_decoded_options_count;
 
+/* Vector of saved Optimization decoded command line options.  */

+auto_vec save_opt_decoded_options;
+
 /* Used to enable -fvar-tracking, -fweb and -frename-

Re: [PATCH, OpenMP 5.0] Implement structure element mapping changes in 5.0

2020-10-23 Thread Jakub Jelinek via Gcc-patches
On Fri, Oct 23, 2020 at 06:24:20PM +0800, Chung-Lin Tang wrote:
> this patch set implements more of OpenMP 5.0 mapping, specifically this part 
> in 2.19.7.1 map Clause:
> 
> "If a list item in a map clause is a structure element then all other 
> structure elements of the
>  containing structure variable form a structure sibling list. The map clause 
> and the structure sibling
>  list are associated with the same construct. If a corresponding list item of 
> the structure sibling list
>  item is present in the device data environment when the construct is 
> encountered then:
> 
>  * If the 1 structure sibling list item does not appear in a map clause on 
> the construct then:
>– If the construct is a target, target data, or target enter data 
> construct then the
>  structure sibling list item is treated as if it is a list item in a map 
> clause on the construct with a
>  map-type of alloc.
>– If the construct is target exit data construct, then the structure 
> sibling list item is treated
>  as if it is a list item in a map clause on the construct with a map-type 
> of release."
> 
> While really wordy, I believe this simply means that maps of structure 
> element fields have their reference
> counts increased/decreased in a uniform fashion, i.e. the are alloc/release'd 
> together, instead of
> having parts of the structure possibly deallocated while others still exist 
> on the device.

I think part of the reason for the above wording being so long is the
declare mapper stuff which caused the mapping of the whole struct to be
implicitly treated as mapping of all the elements individually (which we
don't want to actually implement that way unless we have to (e.g. due to
references in there, different declare mappers etc.)).

> In general, upon encountering a construct, we can't statically determine and 
> insert alloc/release maps
> for each element of a structure variable, since we don't really know which 
> region of the structure is
> currently mapped or not, hence this probably can't be properly implemented in 
> the compiler.
> 
> Instead this patch tries to do the equivalent in the runtime: I've modified 
> the handling of the
> (GOMP_MAP_STRUCT, , , ...) sequence to:
> 
>   (1) Create just a single splay_tree_key to represent the entire structure's 
> mapped-region
>   (all element target_var_desc's now reference this same key instead of 
> creating their own), and

I'm not sure that is what we want.  If we create just a single
splay_tree_key spanning the whole structure mapped region, then we can't
diagnose various mapping errors.  E.g. if I have:
void bar (struct S *);
struct S { int a, b, c, d, e; };
void foo (struct S s)
{
  #pragma omp target data map(tofrom: s.b, s.d)
  #pragma omp target map (s.b, s.c)
  bar (&s);
}
then target data maps the &s.b to &s.d + 1 region of the struct, but s.c
wasn't mapped and so the target region's mapping should fail, even when it
is in the middle of the mapped region.

The structure mapping wording was written in a way to give implementations a
choice, either map the whole struct (space inefficient), or the region from
the first to last element in the struct the needs mapping (what GCC
implements, also space inefficient, but less so), or only map the fields
individually and somehow remap all uses of the struct in the region (I think
that is only theoretically possible if one can analyze the whole target
region and rewrite anything that could refer to it in there).

So, I'd think instead of having just one splay_tree_key, we need multiple
(we could merge adjacent ones though if we want) but we need some way to tie
them together (e.g. represent them as one master entry (perhaps the first one) 
and
slaves entries and use the refcount of the master entry for all of them.

There are other OpenMP 5.0 changes which are very tightly related to that
though, namely that OpenMP 4.5 disallowed mapping the same variable multiple
times in the same region and therefore had the simple rule that each mapping
bumps the refcount by one.  As OpenMP 5.0 dropped that, we have instead:
"If the corresponding list item’s reference count was not already incremented 
because of the
effect of a map clause on the construct then:
a) The corresponding list item’s reference count is incremented by one;"

So, additionally we need to ensure that we don't bump again refcounts we've
bumped already in the same GOMP_* call and similarly at the end of region
when unmapping.  Additionally there is the complication that for enter data
and exit data we call actually gomp_map_vars multiple times, so we'll need
to track it somehow even across those calls.

Though, the refcount is only on the target_mem_desc struct not on the
target_var_desc.  But we need to bump the refcount for each separate
target_var_desc in there unless it is one of these slave entries, otherwise
e.g.
#pragma omp target data map (x, y, z)
{
#pragma omp target enter data map (to: x)
#pragma omp target en

PING^2 [PATCH] Use the section flag 'o' for __patchable_function_entries

2020-10-23 Thread H.J. Lu via Gcc-patches
On Fri, Oct 2, 2020 at 6:00 AM H.J. Lu  wrote:
>
> On Thu, Feb 6, 2020 at 6:57 PM H.J. Lu  wrote:
> >
> > This commit in GNU binutils 2.35:
> >
> > https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=b7d072167715829eed0622616f6ae0182900de3e
> >
> > added the section flag 'o' to .section directive:
> >
> > .section __patchable_function_entries,"awo",@progbits,foo
> >
> > which specifies the symbol name which the section references.  Assembler
> > creates a unique __patchable_function_entries section with the section,
> > where foo is defined, as its linked-to section.  Linker keeps a section
> > if its linked-to section is kept during garbage collection.
> >
> > This patch checks assembler support for the section flag 'o' and uses
> > it to implement __patchable_function_entries section.  Since Solaris may
> > use GNU assembler with Solairs ld.  Even if GNU assembler supports the
> > section flag 'o', it doesn't mean that Solairs ld supports it.  This
> > feature is disabled for Solairs targets.
> >
> > gcc/
> >
> > PR middle-end/93195
> > PR middle-end/93197
> > * configure.ac (HAVE_GAS_SECTION_LINK_ORDER): New.  Define if
> > the assembler supports the section flag 'o' for specifying
> > section with link-order.
> > * dwarf2out.c (output_comdat_type_unit): Pass 0 as flags2
> > to targetm.asm_out.named_section.
> > * config/sol2.c (solaris_elf_asm_comdat_section): Likewise.
> > * output.h (SECTION2_LINK_ORDER): New.
> > (switch_to_section): Add an unsigned int argument.
> > (default_no_named_section): Likewise.
> > (default_elf_asm_named_section): Likewise.
> > * target.def (asm_out.named_section): Likewise.
> > * targhooks.c (default_print_patchable_function_entry): Pass
> > current_function_decl to get_section and SECTION2_LINK_ORDER
> > to switch_to_section.
> > * varasm.c (default_no_named_section): Add an unsigned int
> > argument.
> > (default_elf_asm_named_section): Add an unsigned int argument,
> > flags2.  Use 'o' flag for SECTION2_LINK_ORDER if assembler
> > supports it.
> > (switch_to_section): Add an unsigned int argument and pass it
> > to targetm.asm_out.named_section.
> > (handle_vtv_comdat_section): Pass 0 to
> > targetm.asm_out.named_section.
> > * config.in: Regenerated.
> > * configure: Likewise.
> > * doc/tm.texi: Likewise.
> >
> > gcc/testsuite/
> >
> > PR middle-end/93195
> > * g++.dg/pr93195a.C: New test.
> > * g++.dg/pr93195b.C: Likewise.
> > * lib/target-supports.exp
> > (check_effective_target_o_flag_in_section): New proc.
>
> PING
>
> https://gcc.gnu.org/pipermail/gcc-patches/2020-February/539963.html

PING.


-- 
H.J.


Re: PING^3 [PATCH] x86: Add cmpmemsi for -minline-all-stringops

2020-10-23 Thread H.J. Lu via Gcc-patches
On Sun, Oct 18, 2020 at 8:16 AM Jan Hubicka  wrote:
>
> > On Fri, Oct 2, 2020 at 6:21 AM H.J. Lu  wrote:
> > >
> > > On Wed, Sep 16, 2020 at 10:07 PM H.J. Lu  wrote:
> > > >
> > > > On Wed, Aug 19, 2020 at 6:09 AM H.J. Lu  wrote:
> > > > >
> > > > > On Tue, May 19, 2020 at 5:14 AM H.J. Lu  wrote:
> > > > > >
> > > > > > On Tue, May 19, 2020 at 1:48 AM Uros Bizjak  
> > > > > > wrote:
> > > > > > >
> > > > > > > On Sun, May 17, 2020 at 7:06 PM H.J. Lu  
> > > > > > > wrote:
> > > > > > > >
> > > > > > > > Duplicate the cmpstrn pattern for cmpmem.  The only difference 
> > > > > > > > is that
> > > > > > > > the length argument of cmpmem is guaranteed to be less than or 
> > > > > > > > equal to
> > > > > > > > lengths of 2 memory areas.  Since "repz cmpsb" can be much 
> > > > > > > > slower than
> > > > > > > > memcmp function implemented with vector instruction, see
> > > > > > > >
> > > > > > > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43052
> > > > > > > >
> > > > > > > > expand cmpmem to "repz cmpsb" only with -mgeneral-regs-only.
> > > > > > >
> > > > > > > If there is no benefit compared to the library implementation, 
> > > > > > > then
> > > > > > > enable these patterns only when -minline-all-stringops is used.
> > > > > >
> > > > > > Fixed.
> > > > > >
> > > > > > > Eventually these should be reimplemented with SSE4 string 
> > > > > > > instructions.
> > > > > > >
> > > > > > > Honza is the author of the block handling x86 system, I'll leave 
> > > > > > > the
> > > > > > > review to him.
> > > > > >
> > > > > > We used to expand memcmp to "repz cmpsb" via cmpstrnsi.  It was 
> > > > > > changed
> > > > > > by
> > > > > >
> > > > > > commit 9b0f6f5e511ca512e4faeabc81d2fd3abad9b02f
> > > > > > Author: Nick Clifton 
> > > > > > Date:   Fri Aug 12 16:26:11 2011 +
> > > > > >
> > > > > > builtins.c (expand_builtin_memcmp): Do not use cmpstrnsi 
> > > > > > pattern.
> > > > > >
> > > > > > * builtins.c (expand_builtin_memcmp): Do not use 
> > > > > > cmpstrnsi
> > > > > > pattern.
> > > > > > * doc/md.texi (cmpstrn): Note that the comparison stops 
> > > > > > if both
> > > > > > fetched bytes are zero.
> > > > > > (cmpstr): Likewise.
> > > > > > (cmpmem): Note that the comparison does not stop if 
> > > > > > both of the
> > > > > > fetched bytes are zero.
> > > > > >
> > > > > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95151
> > > > > >
> > > > > > is a regression.
> > > > > >
> > > > > > Honza, can you take a look at this?
> > > > > >
> > > > >
> > > > > PING:
> > > > >
> > > > > https://gcc.gnu.org/pipermail/gcc-patches/2020-May/546921.html
> > > > >
> > > >
> > > > PING.
> > > >
> > >
> > > PING.
> > >
> >
> > I'd like to check it in next Tuesday if there are no comments.
>
> I still plan to intorduce the two-level optimize_for_size predicates.
> Will try to do that by tuesday.

Any updates on this?  My patch is still needed to generate cmpmemsi
with -minline-all-stringops.  If there are comments, I will check it in next
Monday.

--
H.J.


Rename DECL_IS_BUILTIN to DECL_IS_UNDECLARED_BUILTIN

2020-10-23 Thread Nathan Sidwell

Patch affects C++, C, GO, common-core

In cleaning up C++'s handling of hidden decls, I renamed its 
DECL_BUILTIN_P, which checks for loc == BUILTINS_LOCATION to 
DECL_UNDECLARED_BUILTIN_P, because the location gets updated, if user 
source declares the builtin, and the predicate no longer holds.  The 
original name was confusing me.  (The builtin may still retain builtin 
properties in the redeclaration, and other predicates can still detect 
that.)


I discovered that tree.h had its own variant 'DECL_IS_BUILTIN', which 
behaves in (almost) the same manner.  And therefore has the same 
mutating behaviour.


This patch deletes the C++ one, and renames tree.h's to 
DECL_IS_UNDECLARED_BUILTIN, to emphasize its non-constantness.  I guess 
_IS_ wins over _P :)


The indirection via SOURCE_LOCUS was introduced by Richard in 2012:
2012-09-26  Richard Guenther  

* tree.h (DECL_IS_BUILTIN): Compare LOCATION_LOCUS.

From-SVN: r191759

I couldn't find the email on gcc-patches, but I don't see why this is 
necessary -- no undeclared builtin has an adhoc location, they're all 
BUILTINS_LOCATION, or UNKNOWN_LOCATION.


That some builtins have UNKNOWN_LOCATION is why the test is <= rather 
than ==.  This seems wrong, and we should be using BUILTINS_LOCATION 
everywhere.  But that's a different bug.


bootstrapped on x86-64-linux and test results look the same across all 
the languages I can build. ok?


gcc/
* tree.h (DECL_IS_BUILTIN): Rename to ...
(DECL_IS_UNDECLARED_BUILTIN): ... here.  No need to use
SOURCE_LOCUS.
* calls.c (maybe_warn_alloc_args_overflow): Adjust for rename.
* cfgexpand.c (pass_expand::execute): Likewise.
* dwarf2out.c (base_type_die, is_naming_typedef_decl): Likewise.
* godump.c (go_decl, go_type_decl): Likewise.
* print-tree.c (print_decl_identifier): Likewise.
* tree-pretty-print.c (dump_generic_node): Likewise.
* tree-ssa-ccp.c (pass_post_ipa_warn::execute): Likewise.
* xcoffout.c (xcoff_assign_fundamental_type_number): Likewise.
gcc/c-family/
* c-ada-spec.c (collect_ada_nodes): Rename
DECL_IS_BUILTIN->DECL_IS_UNDECLARED_BUILTIN.
(collect_ada_node): Likewise.
(dump_forward_type): Likewise.
* c-common.c (set_underlying_type): Rename
DECL_IS_BUILTIN->DECL_IS_UNDECLARED_BUILTIN.
(user_facing_original_type): Likewise.
(c_common_finalize_early_debug): Likewise.
gcc/c/
* c-decl.c (diagnose_mismatched_decls): Rename
DECL_IS_BUILTIN->DECL_IS_UNDECLARED_BUILTIN.
(warn_if_shadowing, implicitly_declare, names_builtin_p)
(collect_source_refs): Likewise.
* c-typeck.c (inform_declaration, inform_for_arg)
(convert_for_assignment): Likewise.
gcc/cp/
* cp-tree.h (DECL_UNDECLARED_BUILTIN_P): Delete.
* cp-objcp-common.c (names_bultin_p): Rename
DECL_IS_BUILTIN->DECL_IS_UNDECLARED_BUILTIN.
* decl.c (decls_match): Likewise.  Replace
DECL_UNDECLARED_BUILTIN_P with DECL_IS_UNDECLARED_BUILTIN.
(duplicate_decls): Likewise.
* decl2.c (collect_source_refs): Likewise.
* name-lookup.c (anticipated_builtin_p, print_binding_level)
(do_nonmember_using_decl): Likewise.
* pt.c (builtin_pack_fn_p): Likewise.
* typeck.c (error_args_num): Likewise.
gcc/lto/
* lto-symtab.c (lto_symtab_merge_decls_1): Rename
DECL_IS_BUILTIN->DECL_IS_UNDECLARED_BUILTIN.
gcc/go/
* go-gcc.cc (Gcc_backend::call_expression): Rename
DECL_IS_BUILTIN->DECL_IS_UNDECLARED_BUILTIN.
libcc1/
* libcc1plugin.cc (address_rewriter): Rename
DECL_IS_BUILTIN->DECL_IS_UNDECLARED_BUILTIN.
* libcp1plugin.cc (supplement_binding): Likewise.

nathan
--
Nathan Sidwell
diff --git i/gcc/c-family/c-ada-spec.c w/gcc/c-family/c-ada-spec.c
index c75b173eec3..266a7fe0fa4 100644
--- i/gcc/c-family/c-ada-spec.c
+++ w/gcc/c-family/c-ada-spec.c
@@ -713,7 +713,7 @@ collect_ada_nodes (tree t, const char *source_file)
  in the context of bindings) and namespaces (we do not handle them properly
  yet).  */
   for (n = t; n; n = TREE_CHAIN (n))
-if (!DECL_IS_BUILTIN (n)
+if (!DECL_IS_UNDECLARED_BUILTIN (n)
 	&& TREE_CODE (n) != NAMESPACE_DECL
 	&& LOCATION_FILE (decl_sloc (n, false)) == source_file)
   to_dump_count++;
@@ -723,7 +723,7 @@ collect_ada_nodes (tree t, const char *source_file)
 
   /* Store the relevant nodes.  */
   for (n = t; n; n = TREE_CHAIN (n))
-if (!DECL_IS_BUILTIN (n)
+if (!DECL_IS_UNDECLARED_BUILTIN (n)
 	&& TREE_CODE (n) != NAMESPACE_DECL
 	&& LOCATION_FILE (decl_sloc (n, false)) == source_file)
   to_dump[i++] = n;
@@ -2321,7 +2321,7 @@ dump_ada_node (pretty_printer *buffer, tree node, tree type, int spc,
   return 0;
 
 case TYPE_DECL:
-  if (DECL_IS_BUILTIN (node))
+  if (DECL_IS_UNDECLARED_BUILTIN (node

PING^4 [PATCH] x86: Inline strncmp only with -minline-all-stringops

2020-10-23 Thread H.J. Lu via Gcc-patches
On Fri, Oct 2, 2020 at 6:23 AM Jan Hubicka  wrote:
>
> > > > diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
> > > > index fb677e17817..f3fbed81c4a 100644
> > > > --- a/gcc/config/i386/i386.md
> > > > +++ b/gcc/config/i386/i386.md
> > > > @@ -18007,7 +18007,13 @@ (define_expand "cmpstrnsi"
> > > >  {
> > > >rtx addr1, addr2, countreg, align, out;
> > > >
> > > > -  if (optimize_insn_for_size_p () && !TARGET_INLINE_ALL_STRINGOPS)
> > > > +  /* Expand strncmp only with -minline-all-stringops since
> > > > + "repz cmpsb" can be much slower than strncmp functions
> > > > + implemented with vector instructions, see
> > > > +
> > > > + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43052
> > > > +   */
> > > > +  if (!TARGET_INLINE_ALL_STRINGOPS)
> > > >  FAIL;
>
> I think this is hitting the more general problem that we want to have
> two levels of optimization for size (at least internally). One for parts
> of program guessed to be cold and do not perform such extreme changes
> (i.e. translate stringops, division etc.) and other when we really want
> top optimize for size.
>
> I will try to push out patches for two-state optimize_size next week.
>

As of r11-4314, GCC still inlines strncmp without -minline-all-stringops.
If  there are no comments,  I will check in my patch:

https://gcc.gnu.org/pipermail/gcc-patches/2020-August/552237.html

next Monday.

-- 
H.J.


Re: [PATCH] testsuite: Add noexcept(false) to throwing destructor

2020-10-23 Thread Nathan Sidwell

On 10/23/20 7:46 AM, Jonathan Wakely wrote:

I think this test is intended to check this property of the C++
standard:

"If a destructor directly invoked by stack unwinding exits via an
exception, std::terminate is invoked." [except.throw]

Since C++11 any exception escaping a destructor will call
std::terminate, so the test would terminate even if the unwinding
behaviour was wrong.

Give the destructor a potentially-throwing exception specification,
so that we know that terminate was called for the right reason.

gcc/testsuite/ChangeLog:

* g++.dg/compat/eh/filter2_y.C: Add noexcept(false) to
destructor.


Tested powerpc64le-linux. OK for trunk?


ok


--
Nathan Sidwell


[RS6000] Power10 ICE running gcc.target/powerpc/ppc-ne0-1.c

2020-10-23 Thread Alan Modra via Gcc-patches
rs6000_emit_int_cmove generates isel so the condition below needs
fixing for power10.  Bootstrapped and regression tested
powerpc64le-linux power10 and power8.  OK?

* config/rs6000/rs6000.md (cstore4): Don't call
rs6000_emit_int_cmove for power10 when -mno-isel.

diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md
index 2bf5df41a9b..cd41b759f71 100644
--- a/gcc/config/rs6000/rs6000.md
+++ b/gcc/config/rs6000/rs6000.md
@@ -11538,7 +11538,7 @@
   ""
 {
   /* Everything is best done with setbc[r] if available.  */
-  if (TARGET_POWER10)
+  if (TARGET_POWER10 && TARGET_ISEL)
 rs6000_emit_int_cmove (operands[0], operands[1], const1_rtx, const0_rtx);
 
   /* Expanding EQ and NE directly to some machine instructions does not help

-- 
Alan Modra
Australia Development Lab, IBM


[PATCH]AArch64 Fix overflow in memcopy expansion on aarch64.

2020-10-23 Thread Tamar Christina via Gcc-patches
Hi All,

Currently the inline memcpy expansion code for AArch64 is using a signed int
to hold the number of elements to copy.  When you giver give it a value larger
than INT_MAX it will overflow.

The overflow causes the maximum number of instructions we want to expand to
check to fail since this assumes an unsigned number.

This patch changes the maximum isns arithmetic to be unsigned.  The type can
stay 32-bits since the number of instructions we are allowed to expand to
are at most 8 which is far below what you could fit in an unsigned int.

note that the calculation *must* remained signed as the memcopy issues
overlapping unaligned copies.  This means the pointer must be moved back and
so you need signed arithmetic.

Bootstrapped Regtested on aarch64-none-linux-gnu and no issues.

Ok for master and backport to GCC 9 and 10?

Thanks,
Tamar

gcc/ChangeLog:

PR target/97535
* config/aarch64/aarch64.c (aarch64_expand_cpymem): Use unsigned
arithmetic in check.

gcc/testsuite/ChangeLog:

PR target/97535
* gcc.target/aarch64/pr97535.c: New test.

-- 
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index a8cc545c37044345c3f1d3bf09151c8a9578a032..09a2d77da57efe8fa21097ca7b166113becd6069 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -21299,6 +21299,8 @@ aarch64_copy_one_block_and_progress_pointers (rtx *src, rtx *dst,
 bool
 aarch64_expand_cpymem (rtx *operands)
 {
+  /* These need to be signed as we need to perform arithmetic on n as
+ signed operations.  */
   int n, mode_bits;
   rtx dst = operands[0];
   rtx src = operands[1];
@@ -21309,21 +21311,26 @@ aarch64_expand_cpymem (rtx *operands)
   /* When optimizing for size, give a better estimate of the length of a
  memcpy call, but use the default otherwise.  Moves larger than 8 bytes
  will always require an even number of instructions to do now.  And each
- operation requires both a load+store, so devide the max number by 2.  */
-  int max_num_moves = (speed_p ? 16 : AARCH64_CALL_RATIO) / 2;
+ operation requires both a load+store, so divide the max number by 2.  */
+  unsigned int max_num_moves = (speed_p ? 16 : AARCH64_CALL_RATIO) / 2;
 
   /* We can't do anything smart if the amount to copy is not constant.  */
   if (!CONST_INT_P (operands[2]))
 return false;
 
-  n = INTVAL (operands[2]);
+  /* This may get truncated but that's fine as it would be above our maximum
+ memset inline limit.  */
+  unsigned tmp = INTVAL (operands[2]);
 
   /* Try to keep the number of instructions low.  For all cases we will do at
  most two moves for the residual amount, since we'll always overlap the
  remainder.  */
-  if (((n / 16) + (n % 16 ? 2 : 0)) > max_num_moves)
+  if (((tmp / 16) + (tmp % 16 ? 2 : 0)) > max_num_moves)
 return false;
 
+  /* At this point tmp is known to have to fit inside an int.  */
+  n = tmp;
+
   base = copy_to_mode_reg (Pmode, XEXP (dst, 0));
   dst = adjust_automodify_address (dst, VOIDmode, base, 0);
 
diff --git a/gcc/testsuite/gcc.target/aarch64/pr97535.c b/gcc/testsuite/gcc.target/aarch64/pr97535.c
new file mode 100644
index ..6f83b3f571413577180682c18400d913bb13124d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/pr97535.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#include 
+
+#define SIZE 2181038080
+
+extern char raw_buffer[SIZE];
+
+void setRaw(const void *raw)
+{
+memcpy(raw_buffer, raw, SIZE);
+}
+
+/* At any optimization level this should be a function call
+   and not inlined.  */
+/* { dg-final { scan-assembler "bl\tmemcpy" } } */



[PATCH][pushed] gcov: fix reading of zero sections.

2020-10-23 Thread Martin Liška

I noticed that during coverage build of binutils.

gcc/ChangeLog:

* gcov.c (read_count_file): Never call gcov_sync with a negative
value.

Patch survives gcov.exp tests and I'm going to install it.

Martin

---
 gcc/gcov.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/gcc/gcov.c b/gcc/gcov.c
index b302e2197dd..36938bd0fce 100644
--- a/gcc/gcov.c
+++ b/gcc/gcov.c
@@ -1940,6 +1940,7 @@ read_count_file (void)
   while ((tag = gcov_read_unsigned ()))
 {
   unsigned length = gcov_read_unsigned ();
+  int read_length = (int)length;
   unsigned long base = gcov_position ();
 
   if (tag == GCOV_TAG_OBJECT_SUMMARY)

@@ -1972,7 +1973,6 @@ read_count_file (void)
}
   else if (tag == GCOV_TAG_FOR_COUNTER (GCOV_COUNTER_ARCS) && fn)
{
- int read_length = (int)length;
  length = abs (read_length);
  if (length != GCOV_TAG_COUNTER_LENGTH (fn->counts.size ()))
goto mismatch;
@@ -1980,10 +1980,10 @@ read_count_file (void)
  if (read_length > 0)
for (ix = 0; ix != fn->counts.size (); ix++)
  fn->counts[ix] += gcov_read_counter ();
- else
-   length = 0;
}
-  gcov_sync (base, length);
+  if (read_length < 0)
+   read_length = 0;
+  gcov_sync (base, read_length);
   if ((error = gcov_is_error ()))
{
  fnotice (stderr,
--
2.28.0



move sincos after pre (was: Re: [Ada,FYI] revamp ada.numerics.aux)

2020-10-23 Thread Alexandre Oliva
On Oct 22, 2020, Alexandre Oliva  wrote:

> On Oct 18, 2020, Alexandre Oliva  wrote:
>> The option is provided by default, but there is an alternate version
>> that doesn't, that is used for vxworks targets.

> vxworks float EFs not precise enough -> use long float

> From: Alexandre Oliva 

> Some acats-4 tests that check the precision of Float elementary
> functions fail with vxworks 7.2's implementations of single-precision
> math functions.

> This patch arranges for us to bypass the single-precision functions,
> and use the Aux_Long_Float implementation, based on the double-typed
> calls from the C library, for Float and Short_Float.


On platforms in which Aux_[Real_Type] involves non-NOP conversions
(e.g., between single- and double-precision, or between short float
and float), the conversions before the calls are CSEd too late for
sincos to combine calls.

This patch moves sincos after PRE, where the conversions are unified
at -O2.

I'm regstrapping this on x86_64-linux-gnu and powerpc64-linux-gnu, and
also testing it on affected platforms.  Another way to go, that would
take a little more effort, would be to extend sincos to take equivalent
conversions as the same operand, but I doubt I'll be able to undertake
that any time soon, so...  Is this one ok to install?


for  gcc/ChangeLog

* passes.def: Move sincos after pre.

for  gcc/testsuite/ChangeLog

* gnat.dg/sin_cos.ads: New.
* gnat.dg/sin_cos.adb: New.
* gcc.dg/sin_cos.c: New.
---
 gcc/passes.def|2 +-
 gcc/testsuite/gcc.dg/sin_cos.c|   41 +
 gcc/testsuite/gnat.dg/sin_cos.adb |   14 +
 gcc/testsuite/gnat.dg/sin_cos.ads |4 
 4 files changed, 60 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.dg/sin_cos.c
 create mode 100644 gcc/testsuite/gnat.dg/sin_cos.adb
 create mode 100644 gcc/testsuite/gnat.dg/sin_cos.ads

diff --git a/gcc/passes.def b/gcc/passes.def
index cf15d8e..2743506 100644
--- a/gcc/passes.def
+++ b/gcc/passes.def
@@ -242,12 +242,12 @@ along with GCC; see the file COPYING3.  If not see
   NEXT_PASS (pass_ccp, true /* nonzero_p */);
   /* After CCP we rewrite no longer addressed locals into SSA
 form if possible.  */
-  NEXT_PASS (pass_cse_sincos);
   NEXT_PASS (pass_optimize_bswap);
   NEXT_PASS (pass_laddress);
   NEXT_PASS (pass_lim);
   NEXT_PASS (pass_walloca, false);
   NEXT_PASS (pass_pre);
+  NEXT_PASS (pass_cse_sincos);
   NEXT_PASS (pass_sink_code);
   NEXT_PASS (pass_sancov);
   NEXT_PASS (pass_asan);
diff --git a/gcc/testsuite/gcc.dg/sin_cos.c b/gcc/testsuite/gcc.dg/sin_cos.c
new file mode 100644
index ..a4a7727
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/sin_cos.c
@@ -0,0 +1,41 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+/* This maps to essentially the same gimple that is generated for
+   gnat.dg/sin_cos.adb, on platforms that use the wraplf variant of
+   Ada.Numerics.Aux_Float.  The value of EPSILON is not relevant to
+   the test, but the test must be there to keep the conversions in
+   different BBs long enough to trigger the problem that prevented the
+   sincos optimization, because the arguments passed to sin and cos
+   didn't get unified into a single SSA_NAME in time for sincos.  */
+
+#include 
+
+#define EPSILON 3.4526697709225118160247802734375e-4
+
+static float my_sinf(float x) {
+  return (float) sin ((double) x);
+}
+
+static float wrap_sinf(float x) {
+  if (fabs (x) < EPSILON)
+return 0;
+  return my_sinf (x);
+}
+
+static float my_cosf(float x) {
+  return (float) cos ((double) x);
+}
+
+static float wrap_cosf(float x) {
+  if (fabs (x) < EPSILON)
+return 1;
+  return my_cosf (x);
+}
+
+float my_sin_cos(float x, float *s, float *c) {
+  *s = wrap_sinf (x);
+  *c = wrap_cosf (x);
+}
+
+/* { dg-final { scan-assembler "sincos\|cexp" { target *-linux-gnu* 
*-w64-mingw* powerpc*-*-* } } } */
diff --git a/gcc/testsuite/gnat.dg/sin_cos.adb 
b/gcc/testsuite/gnat.dg/sin_cos.adb
new file mode 100644
index ..e72f521
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/sin_cos.adb
@@ -0,0 +1,14 @@
+--  { dg-do compile }
+--  { dg-options "-O2 -gnatn" }
+
+with Ada.Numerics.Elementary_Functions;
+use Ada.Numerics.Elementary_Functions;
+package body Sin_Cos is
+   procedure Sin_Cos (Angle : T; SinA, CosA : out T) is
+   begin
+  SinA := Sin (Angle);
+  CosA := Cos (Angle);
+   end;
+end Sin_Cos;
+
+--  { dg-final { scan-assembler "sincos\|cexp" { target *-linux-gnu* 
*-w64-mingw* powerpc*-*-* } } }
diff --git a/gcc/testsuite/gnat.dg/sin_cos.ads 
b/gcc/testsuite/gnat.dg/sin_cos.ads
new file mode 100644
index ..a0eff3d
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/sin_cos.ads
@@ -0,0 +1,4 @@
+package Sin_Cos is
+   subtype T is Float;
+   procedure Sin_Cos (Angle : T; SinA, CosA : out T);
+end Sin_Cos;


-- 
Alexandre Oliva, happy hacker
https://FSFLA.org/blogs/lxo/
Free Software Activist
GNU

Re: [patch] Add an if-exists-then-else spec function

2020-10-23 Thread Olivier Hainque



> On 22 Oct 2020, at 22:52, Joseph Myers  wrote:
> 
> This is OK.

Great, thanks Joseph!



[PATCH] libcpp: Update cpp_wcwidth() to Unicode 13.0.0

2020-10-23 Thread Lewis Hyatt via Gcc-patches
Hello-

The attached patch updates cpp_wcwidth() (for computation of display
widths needed to calculate column numbers in diagnostics) from Unicode 12
to Unicode 13. The patch was purely mechanical, following the directions
in contrib/unicode/README without any unexpected hiccups. A couple
questions please:

-Is it OK for master?

-Unicode 13 actually came out just immediately before GCC 10 was
 released. Would it make sense to put this on GCC 10 branch as well?

Thanks!

-Lewis
generated_cpp_wcwidth.h was regenerated using Unicode 13.0.0 data files. No
material changes to the parsing scripts (either GCC- or glibc-sourced) were
necessary; glibc's utf8_gen.py was tweaked slightly by glibc and matched here.

contrib/ChangeLog:

* unicode/EastAsianWidth.txt: Update to Unicode 13.0.0.
* unicode/PropList.txt: Likewise.
* unicode/README: Likewise.
* unicode/UnicodeData.txt: Likewise.
* unicode/from_glibc/unicode_utils.py: Update to latest glibc version.
* unicode/from_glibc/utf8_gen.py: Likewise.

libcpp/ChangeLog:

* generated_cpp_wcwidth.h: Regenerated from Unicode 13.0.0 data.

diff --git a/contrib/unicode/EastAsianWidth.txt 
b/contrib/unicode/EastAsianWidth.txt
index 94d55d6654a..b43aec92738 100644
--- a/contrib/unicode/EastAsianWidth.txt
+++ b/contrib/unicode/EastAsianWidth.txt
@@ -1,6 +1,6 @@
-# EastAsianWidth-12.1.0.txt
-# Date: 2019-03-31, 22:01:58 GMT [KW, LI]
-# © 2019 Unicode®, Inc.
+# EastAsianWidth-13.0.0.txt
+# Date: 2029-01-21, 18:14:00 GMT [KW, LI]
+# © 2020 Unicode®, Inc.
 # Unicode and the Unicode Logo are registered trademarks of Unicode, Inc. in 
the U.S. and other countries.
 # For terms of use, see http://www.unicode.org/terms_of_use.html
 #
@@ -9,7 +9,7 @@
 #
 # East_Asian_Width Property
 #
-# This file is an informative contributory data file in the
+# This file is a normative contributory data file in the
 # Unicode Character Database.
 #
 # The format is two fields separated by a semicolon.
@@ -332,7 +332,7 @@
 085E;N   # Po MANDAIC PUNCTUATION
 0860..086A;N # Lo[11] SYRIAC LETTER MALAYALAM NGA..SYRIAC LETTER 
MALAYALAM SSA
 08A0..08B4;N # Lo[21] ARABIC LETTER BEH WITH SMALL V BELOW..ARABIC 
LETTER KAF WITH DOT BELOW
-08B6..08BD;N # Lo [8] ARABIC LETTER BEH WITH SMALL MEEM ABOVE..ARABIC 
LETTER AFRICAN NOON
+08B6..08C7;N # Lo[18] ARABIC LETTER BEH WITH SMALL MEEM ABOVE..ARABIC 
LETTER LAM WITH SMALL ARABIC LETTER TAH ABOVE
 08D3..08E1;N # Mn[15] ARABIC SMALL LOW WAW..ARABIC SMALL HIGH SIGN 
SAFHA
 08E2;N   # Cf ARABIC DISPUTED END OF AYAH
 08E3..08FF;N # Mn[29] ARABIC TURNED DAMMA BELOW..ARABIC MARK SIDEWAYS 
NOON GHUNNA
@@ -450,7 +450,7 @@
 0B47..0B48;N # Mc [2] ORIYA VOWEL SIGN E..ORIYA VOWEL SIGN AI
 0B4B..0B4C;N # Mc [2] ORIYA VOWEL SIGN O..ORIYA VOWEL SIGN AU
 0B4D;N   # Mn ORIYA SIGN VIRAMA
-0B56;N   # Mn ORIYA AI LENGTH MARK
+0B55..0B56;N # Mn [2] ORIYA SIGN OVERLINE..ORIYA AI LENGTH MARK
 0B57;N   # Mc ORIYA AU LENGTH MARK
 0B5C..0B5D;N # Lo [2] ORIYA LETTER RRA..ORIYA LETTER RHA
 0B5F..0B61;N # Lo [3] ORIYA LETTER YYA..ORIYA LETTER VOCALIC LL
@@ -529,7 +529,7 @@
 0CF1..0CF2;N # Lo [2] KANNADA SIGN JIHVAMULIYA..KANNADA SIGN 
UPADHMANIYA
 0D00..0D01;N # Mn [2] MALAYALAM SIGN COMBINING ANUSVARA 
ABOVE..MALAYALAM SIGN CANDRABINDU
 0D02..0D03;N # Mc [2] MALAYALAM SIGN ANUSVARA..MALAYALAM SIGN VISARGA
-0D05..0D0C;N # Lo [8] MALAYALAM LETTER A..MALAYALAM LETTER VOCALIC L
+0D04..0D0C;N # Lo [9] MALAYALAM LETTER VEDIC ANUSVARA..MALAYALAM 
LETTER VOCALIC L
 0D0E..0D10;N # Lo [3] MALAYALAM LETTER E..MALAYALAM LETTER AI
 0D12..0D3A;N # Lo[41] MALAYALAM LETTER O..MALAYALAM LETTER TTTA
 0D3B..0D3C;N # Mn [2] MALAYALAM SIGN VERTICAL BAR VIRAMA..MALAYALAM 
SIGN CIRCULAR VIRAMA
@@ -550,6 +550,7 @@
 0D70..0D78;N # No [9] MALAYALAM NUMBER TEN..MALAYALAM FRACTION THREE 
SIXTEENTHS
 0D79;N   # So MALAYALAM DATE MARK
 0D7A..0D7F;N # Lo [6] MALAYALAM LETTER CHILLU NN..MALAYALAM LETTER 
CHILLU K
+0D81;N   # Mn SINHALA SIGN CANDRABINDU
 0D82..0D83;N # Mc [2] SINHALA SIGN ANUSVARAYA..SINHALA SIGN VISARGAYA
 0D85..0D96;N # Lo[18] SINHALA LETTER AYANNA..SINHALA LETTER AUYANNA
 0D9A..0DB1;N # Lo[24] SINHALA LETTER ALPAPRAANA KAYANNA..SINHALA 
LETTER DANTAJA NAYANNA
@@ -795,6 +796,7 @@
 1AA8..1AAD;N # Po [6] TAI THAM SIGN KAAN..TAI THAM SIGN CAANG
 1AB0..1ABD;N # Mn[14] COMBINING DOUBLED CIRCUMFLEX ACCENT..COMBINING 
PARENTHESES BELOW
 1ABE;N   # Me COMBINING PARENTHESES OVERLAY
+1ABF..1AC0;N # Mn [2] COMBINING LATIN SMALL LETTER W BELOW..COMBINING 
LATIN SMALL LETTER TURNED W BELOW
 1B00..1B03;N # Mn [4] BALINESE SIGN ULU RICEM..BALINESE SIGN SURANG
 1B04;N   # Mc BALINESE SIGN BISAH
 1B05.

Re: move sincos after pre (was: Re: [Ada, FYI] revamp ada.numerics.aux)

2020-10-23 Thread Richard Biener via Gcc-patches
On October 23, 2020 4:23:35 PM GMT+02:00, Alexandre Oliva  
wrote:
>On Oct 22, 2020, Alexandre Oliva  wrote:
>
>> On Oct 18, 2020, Alexandre Oliva  wrote:
>>> The option is provided by default, but there is an alternate version
>>> that doesn't, that is used for vxworks targets.
>
>> vxworks float EFs not precise enough -> use long float
>
>> From: Alexandre Oliva 
>
>> Some acats-4 tests that check the precision of Float elementary
>> functions fail with vxworks 7.2's implementations of single-precision
>> math functions.
>
>> This patch arranges for us to bypass the single-precision functions,
>> and use the Aux_Long_Float implementation, based on the double-typed
>> calls from the C library, for Float and Short_Float.
>
>
>On platforms in which Aux_[Real_Type] involves non-NOP conversions
>(e.g., between single- and double-precision, or between short float
>and float), the conversions before the calls are CSEd too late for
>sincos to combine calls.
>
>This patch moves sincos after PRE, where the conversions are unified
>at -O2.
>
>I'm regstrapping this on x86_64-linux-gnu and powerpc64-linux-gnu, and
>also testing it on affected platforms.  Another way to go, that would
>take a little more effort, would be to extend sincos to take equivalent
>conversions as the same operand, but I doubt I'll be able to undertake
>that any time soon, so...  Is this one ok to install?

Can you move it one pass further after sink please? Also I don't remember 
exactly but does pass_sincos only handle sin/cos unifying? 

Thanks, 
Richard. 

>
>for  gcc/ChangeLog
>
>   * passes.def: Move sincos after pre.
>
>for  gcc/testsuite/ChangeLog
>
>   * gnat.dg/sin_cos.ads: New.
>   * gnat.dg/sin_cos.adb: New.
>   * gcc.dg/sin_cos.c: New.
>---
> gcc/passes.def|2 +-
>gcc/testsuite/gcc.dg/sin_cos.c|   41
>+
> gcc/testsuite/gnat.dg/sin_cos.adb |   14 +
> gcc/testsuite/gnat.dg/sin_cos.ads |4 
> 4 files changed, 60 insertions(+), 1 deletion(-)
> create mode 100644 gcc/testsuite/gcc.dg/sin_cos.c
> create mode 100644 gcc/testsuite/gnat.dg/sin_cos.adb
> create mode 100644 gcc/testsuite/gnat.dg/sin_cos.ads
>
>diff --git a/gcc/passes.def b/gcc/passes.def
>index cf15d8e..2743506 100644
>--- a/gcc/passes.def
>+++ b/gcc/passes.def
>@@ -242,12 +242,12 @@ along with GCC; see the file COPYING3.  If not
>see
>   NEXT_PASS (pass_ccp, true /* nonzero_p */);
>   /* After CCP we rewrite no longer addressed locals into SSA
>form if possible.  */
>-  NEXT_PASS (pass_cse_sincos);
>   NEXT_PASS (pass_optimize_bswap);
>   NEXT_PASS (pass_laddress);
>   NEXT_PASS (pass_lim);
>   NEXT_PASS (pass_walloca, false);
>   NEXT_PASS (pass_pre);
>+  NEXT_PASS (pass_cse_sincos);
>   NEXT_PASS (pass_sink_code);
>   NEXT_PASS (pass_sancov);
>   NEXT_PASS (pass_asan);
>diff --git a/gcc/testsuite/gcc.dg/sin_cos.c
>b/gcc/testsuite/gcc.dg/sin_cos.c
>new file mode 100644
>index ..a4a7727
>--- /dev/null
>+++ b/gcc/testsuite/gcc.dg/sin_cos.c
>@@ -0,0 +1,41 @@
>+/* { dg-do compile } */
>+/* { dg-options "-O2" } */
>+
>+/* This maps to essentially the same gimple that is generated for
>+   gnat.dg/sin_cos.adb, on platforms that use the wraplf variant of
>+   Ada.Numerics.Aux_Float.  The value of EPSILON is not relevant to
>+   the test, but the test must be there to keep the conversions in
>+   different BBs long enough to trigger the problem that prevented the
>+   sincos optimization, because the arguments passed to sin and cos
>+   didn't get unified into a single SSA_NAME in time for sincos.  */
>+
>+#include 
>+
>+#define EPSILON 3.4526697709225118160247802734375e-4
>+
>+static float my_sinf(float x) {
>+  return (float) sin ((double) x);
>+}
>+
>+static float wrap_sinf(float x) {
>+  if (fabs (x) < EPSILON)
>+return 0;
>+  return my_sinf (x);
>+}
>+
>+static float my_cosf(float x) {
>+  return (float) cos ((double) x);
>+}
>+
>+static float wrap_cosf(float x) {
>+  if (fabs (x) < EPSILON)
>+return 1;
>+  return my_cosf (x);
>+}
>+
>+float my_sin_cos(float x, float *s, float *c) {
>+  *s = wrap_sinf (x);
>+  *c = wrap_cosf (x);
>+}
>+
>+/* { dg-final { scan-assembler "sincos\|cexp" { target *-linux-gnu*
>*-w64-mingw* powerpc*-*-* } } } */
>diff --git a/gcc/testsuite/gnat.dg/sin_cos.adb
>b/gcc/testsuite/gnat.dg/sin_cos.adb
>new file mode 100644
>index ..e72f521
>--- /dev/null
>+++ b/gcc/testsuite/gnat.dg/sin_cos.adb
>@@ -0,0 +1,14 @@
>+--  { dg-do compile }
>+--  { dg-options "-O2 -gnatn" }
>+
>+with Ada.Numerics.Elementary_Functions;
>+use Ada.Numerics.Elementary_Functions;
>+package body Sin_Cos is
>+   procedure Sin_Cos (Angle : T; SinA, CosA : out T) is
>+   begin
>+  SinA := Sin (Angle);
>+  CosA := Cos (Angle);
>+   end;
>+end Sin_Cos;
>+
>+--  { dg-final { scan-assembler "sincos\|cexp" { target *-linux-gnu*
>*-w64-mingw* powerpc*-*-* } } }
>diff --git a/gcc/testsuite/gnat.dg/sin_cos.ad

Re: [PATCH] rs6000: Fix extraneous characters in the documentation

2020-10-23 Thread Segher Boessenkool
On Wed, Aug 19, 2020 at 04:03:31PM -0300, Tulio Magno Quites Machado Filho via 
Gcc-patches wrote:
> Replace them with a whitespace in order to avoid artifacts in the HTML
> document.

Pushed to trunk now.  Thanks!


Segher


[patch] vxworks: Fix overzealous gthread support inhibition for vxworks

2020-10-23 Thread Olivier Hainque
The tests for macros possibly defined in gthr.h needs to
be performed after the corresponding #include. This was tested
together with the previous updates to gthr-vxworks-thread.c
and gthr-vxworks-cond.c and was meant to be squashed with them.

Olivier

2010-10-23  Olivier Hainque  

libgcc/
* config/gthr-vxworks-thread.c: #include gthr.h before
testing the guard defined there.
* config/gthr-vxworks-cond.c: Likewise.

--- a/libgcc/config/gthr-vxworks-cond.c
+++ b/libgcc/config/gthr-vxworks-cond.c
@@ -26,9 +26,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If 
not, see
This file implements the GTHREAD_HAS_COND part of the interface
exposed by gthr-vxworks.h.  */
 
+#include "gthr.h"
+
 #if __GTHREAD_HAS_COND
 
-#include "gthr.h"
 #include 
 
 /* --- Condition Variables  */
diff --git a/libgcc/config/gthr-vxworks-thread.c 
b/libgcc/config/gthr-vxworks-thread.c
index a723005e03bc..c87168c22711 100644
--- a/libgcc/config/gthr-vxworks-thread.c
+++ b/libgcc/config/gthr-vxworks-thread.c
@@ -27,9 +27,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If 
not, see
exposed by gthr-vxworks.h, using APIs exposed by regular (!AE/653)
VxWorks kernels.  */
 
+#include "gthr.h"
+
 #if __GTHREAD_CXX0X
 
-#include "gthr.h"
 #include 
 #include 
 
-- 
2.17.1



Grow your Clients

2020-10-23 Thread Wendy Williams
Hi,



Are you keen on obtaining the Decision Makers contacts of the companies who 
want to migrate their CAD software or hoping to get another CAD software?



This is an extraordinary chance to build your deals. It would be ideal if you 
let me know whether you are intrigued and I will furnish you with more 
information.



Anticipate your response.


Regards,
Wendy Williams
Demand Generation Head


If you wish not to receive marketing emails please response "Remove"



[PATCH] analyzer: remove dead code

2020-10-23 Thread Martin Liška

Hey.

I've noticed that when building GCC with Clang.
David what do you think about it?

Thanks,
Martin

gcc/analyzer/ChangeLog:

* constraint-manager.cc (constraint_manager::merge): Remove
unused code.
* constraint-manager.h: Likewise.
* program-state.cc (sm_state_map::sm_state_map): Likewise.
(program_state::program_state): Likewise.
(test_sm_state_map): Likewise.
* program-state.h: Likewise.
* region-model-reachability.cc (reachable_regions::reachable_regions): 
Likewise.
* region-model-reachability.h: Likewise.
* region-model.cc (region_model::handle_unrecognized_call): Likewise.
(region_model::get_reachable_svalues): Likewise.
(region_model::can_merge_with_p): Likewise.
---
 gcc/analyzer/constraint-manager.cc| 11 ---
 gcc/analyzer/constraint-manager.h |  3 +--
 gcc/analyzer/program-state.cc | 22 +++---
 gcc/analyzer/program-state.h  |  3 +--
 gcc/analyzer/region-model-reachability.cc |  5 ++---
 gcc/analyzer/region-model-reachability.h  |  3 +--
 gcc/analyzer/region-model.cc  |  7 +++
 7 files changed, 23 insertions(+), 31 deletions(-)

diff --git a/gcc/analyzer/constraint-manager.cc 
b/gcc/analyzer/constraint-manager.cc
index 603b22811c1..f9fffe45c66 100644
--- a/gcc/analyzer/constraint-manager.cc
+++ b/gcc/analyzer/constraint-manager.cc
@@ -1808,9 +1808,8 @@ class merger_fact_visitor : public fact_visitor
 {
 public:
   merger_fact_visitor (const constraint_manager *cm_b,
-  constraint_manager *out,
-  const model_merger &merger)
-  : m_cm_b (cm_b), m_out (out), m_merger (merger)
+  constraint_manager *out)
+  : m_cm_b (cm_b), m_out (out)
   {}
 
   void on_fact (const svalue *lhs, enum tree_code code, const svalue *rhs)

@@ -1844,7 +1843,6 @@ public:
 private:
   const constraint_manager *m_cm_b;
   constraint_manager *m_out;
-  const model_merger &m_merger;
 };
 
 /* Use MERGER to merge CM_A and CM_B into *OUT.

@@ -1856,14 +1854,13 @@ private:
 void
 constraint_manager::merge (const constraint_manager &cm_a,
   const constraint_manager &cm_b,
-  constraint_manager *out,
-  const model_merger &merger)
+  constraint_manager *out)
 {
   /* Merge the equivalence classes and constraints.
  The easiest way to do this seems to be to enumerate all of the facts
  in cm_a, see which are also true in cm_b,
  and add those to *OUT.  */
-  merger_fact_visitor v (&cm_b, out, merger);
+  merger_fact_visitor v (&cm_b, out);
   cm_a.for_each_fact (&v);
 }
 
diff --git a/gcc/analyzer/constraint-manager.h b/gcc/analyzer/constraint-manager.h

index 98960ffad84..1142b1f06e6 100644
--- a/gcc/analyzer/constraint-manager.h
+++ b/gcc/analyzer/constraint-manager.h
@@ -274,8 +274,7 @@ public:
 
   static void merge (const constraint_manager &cm_a,

 const constraint_manager &cm_b,
-constraint_manager *out,
-const model_merger &merger);
+constraint_manager *out);
 
   void for_each_fact (fact_visitor *) const;
 
diff --git a/gcc/analyzer/program-state.cc b/gcc/analyzer/program-state.cc

index 5bb8907e340..77c2de435d6 100644
--- a/gcc/analyzer/program-state.cc
+++ b/gcc/analyzer/program-state.cc
@@ -135,8 +135,8 @@ extrinsic_state::get_model_manager () const
 
 /* sm_state_map's ctor.  */
 
-sm_state_map::sm_state_map (const state_machine &sm, int sm_idx)

-: m_sm (sm), m_sm_idx (sm_idx), m_map (), m_global_state (sm.get_start_state 
())
+sm_state_map::sm_state_map (const state_machine &sm)
+: m_sm (sm), m_map (), m_global_state (sm.get_start_state ())
 {
 }
 
@@ -577,7 +577,7 @@ program_state::program_state (const extrinsic_state &ext_state)

   const int num_states = ext_state.get_num_checkers ();
   for (int i = 0; i < num_states; i++)
 {
-  sm_state_map *sm = new sm_state_map (ext_state.get_sm (i), i);
+  sm_state_map *sm = new sm_state_map (ext_state.get_sm (i));
   m_checker_states.quick_push (sm);
 }
 }
@@ -1154,7 +1154,7 @@ test_sm_state_map ()
 const svalue *y_sval = model.get_rvalue (y, NULL);
 const svalue *z_sval = model.get_rvalue (z, NULL);
 
-sm_state_map map (*sm, 0);

+sm_state_map map (*sm);
 ASSERT_TRUE (map.is_empty_p ());
 ASSERT_EQ (map.get_state (x_sval, ext_state), start);
 
@@ -1183,7 +1183,7 @@ test_sm_state_map ()

 const svalue *y_sval = model.get_rvalue (y, NULL);
 const svalue *z_sval = model.get_rvalue (z, NULL);
 
-sm_state_map map (*sm, 0);

+sm_state_map map (*sm);
 ASSERT_TRUE (map.is_empty_p ());
 ASSERT_EQ (map.get_state (x_sval, ext_state), start);
 ASSERT_EQ (map.get_state (y_sval, ext_state), start);
@@ -1206,9 +1206,9 @@ test_sm_state_map ()
 const svalue *y_sval = model.get_rvalue (y, NULL);

Re: [RS6000] Power10 ICE running gcc.target/powerpc/ppc-ne0-1.c

2020-10-23 Thread Segher Boessenkool
On Sat, Oct 24, 2020 at 12:32:40AM +1030, Alan Modra wrote:
> rs6000_emit_int_cmove generates isel so the condition below needs
> fixing for power10.  Bootstrapped and regression tested
> powerpc64le-linux power10 and power8.  OK?
> 
>   * config/rs6000/rs6000.md (cstore4): Don't call
>   rs6000_emit_int_cmove for power10 when -mno-isel.

This is okay for trunk.  Thanks!

If we need more of this, we probably want a TARGET_SETBC, and if this
option becomes non-orthogonal (when many things use the insns directly),
we'll need to just disable -mno-isel (for later cpus).  But all is fine
for now it seems :-)


Segher


[patch] vxworks: Link with the configured net lib on vxworks7

2020-10-23 Thread Olivier Hainque

The net library is configurable on vxworks7. Pick the library
to include in link closures in accordance with the availability
of a revealing header file, using the recently introduced 
if-exist-then-else spec builtin function.

Tested on a mix of gcc-9 and gcc-10 based builds for Vxworks7r2,
and sanity checked that a powerpc-vxworks build passes for languages=c,c++
with mainline sources.

Committing to mainline.

Olivier

2021-10-23  Douglas Rupp  

gcc/
* config/vxworks.h (VXWORKS_NET_LIBS_RTP): Use -lrtnet if
rtnetStackLib.h is available, fallback to -lnet otherwise.

--- a/gcc/config/vxworks.h
+++ b/gcc/config/vxworks.h
@@ -90,7 +90,7 @@ along with GCC; see the file COPYING3.  If not see
 #define VXWORKS_SYSCALL_LIBS_RTP
 
 #if TARGET_VXWORKS7
-#define VXWORKS_NET_LIBS_RTP "-lnet"
+#define VXWORKS_NET_LIBS_RTP "-l%:if-exists-then-else(%:getenv(VSB_DIR 
/usr/h/public/rtnetStackLib.h) rtnet net)"
 #else
 #define VXWORKS_NET_LIBS_RTP "-lnet -ldsi"
 #endif
-- 
2.17.1



Re: [Ada] Build support units for 128-bit integer types on 64-bit platforms

2020-10-23 Thread Eric Botcazou
> /usr/local/gcc/gcc-20201023/gcc/ada/Makefile.rtl:2834: *** unterminated
> variable reference.  Stop.

Sorry about that, tentatively fixed by the attached patch, installed.

-- 
Eric Botcazoudiff --git a/gcc/ada/Makefile.rtl b/gcc/ada/Makefile.rtl
index 7a0c05b423d..f91085dd404 100644
--- a/gcc/ada/Makefile.rtl
+++ b/gcc/ada/Makefile.rtl
@@ -2533,7 +2533,7 @@ ifeq ($(strip $(filter-out %ia64 linux%,$(target_cpu) $(target_os))),)
   TOOLS_TARGET_PAIRS = indepsw.adb

Re: [RS6000] altivec style lvx/stvx addresses vs power10

2020-10-23 Thread Segher Boessenkool
Hi!

On Fri, Oct 23, 2020 at 05:15:08PM +1030, Alan Modra wrote:
> The problem starts with fwprop creating
> (insn 9 4 0 2 (set (mem:V8HI (and:DI (plus:DI (reg/v/f:DI 121 [ vpp ])
> (const_int 12 [0xc]))
> (const_int -16 [0xfff0])) [0 MEM  int> [(void *)_4 & -16B]+0 S16 A128])
> (reg/v:V8HI 120 [ vp1 ])) "pixel.c":6:10 1237 {vsx_movv8hi_64bit}
> which is finally thrown out as invalid by lra.  lra of course does that
> by reloading the entire address.

While it could/should just reload that 12 into a reg :-(  Could you
investigate doing that?  Is there any reason we should not?

> Now at the time the AND stripping was added (git commit 850e8d3d56d),
> rs6000_legitimate_address looked a lot simpler.  This patch allows
> through just those addresses that were legitimate in those simpler
> days.  (legitimate_small_data_p, legitimate_constant_pool_address_p,
> legitimate_lo_sum_address_p, and legitimate_offset_address_p did get
> to look at the inside of an AND address, but I'm fairly certain
> small_data, constant_pool and lo_sum addresses would never be wrapped
> in an AND, and offset_address_p of that time excluded altivec modes.)
> 
> Regstrapped powerpc64le-linux power8 and power10, with tests on
> powerpc64-linux -m64/-m32 still running.  OK assuming they pass?

I would be much happier if this was performance tested.  But, it is okay
for trunk.  Thanks!


Segher


Re: [Ada] Build support units for 128-bit integer types on 64-bit platforms

2020-10-23 Thread Andreas Schwab
On Okt 23 2020, Eric Botcazou wrote:

> diff --git a/gcc/ada/Makefile.rtl b/gcc/ada/Makefile.rtl
> index 7a0c05b423d..f91085dd404 100644
> --- a/gcc/ada/Makefile.rtl
> +++ b/gcc/ada/Makefile.rtl
> @@ -2533,7 +2533,7 @@ ifeq ($(strip $(filter-out %ia64 linux%,$(target_cpu) 
> $(target_os))),)
>TOOLS_TARGET_PAIRS = indepsw.adb  
>EXTRA_GNATRTL_NONTASKING_OBJS += $(TRASYM_DWARF_UNIX_OBJS)
> -  EXTRA_GNATRTL_NONTASKING_OBJS += $(GNATRTL_128BIT_OBJ
> +  EXTRA_GNATRTL_NONTASKING_OBJS += $(GNATRTL_128BIT_OBJ)

That variable doesn't exist.

Andreas.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."


Re: [PATCH] arm: Implement vceqq_p64, vceqz_p64 and vceqzq_p64 intrinsics

2020-10-23 Thread Christophe Lyon via Gcc-patches
ping?

On Fri, 16 Oct 2020 at 10:41, Christophe Lyon
 wrote:
>
> On Thu, 15 Oct 2020 at 20:10, Andrea Corallo  wrote:
> >
> > Hi Christophe,
> >
> > I've spotted two very minors.
> >
> > Christophe Lyon via Gcc-patches  writes:
> >
> > [...]
> >
> > > +/* For vceqq_p64, we rely on vceq_p64 for each of the two elements.  */
> > > +__extension__ extern __inline uint64x2_t
> > > +__attribute__  ((__always_inline__, __gnu_inline__, __artificial__))
> > > +vceqq_p64 (poly64x2_t __a, poly64x2_t __b)
> > > +{
> > > +  poly64_t __high_a = vget_high_p64 (__a);
> > > +  poly64_t __high_b = vget_high_p64 (__b);
> > > +  uint64x1_t __high = vceq_p64(__high_a, __high_b);
> > ^^^
> >space
>
> Thanks for catching this, I'll fix it before committing if the rest is 
> approved.
>
> Christophe
>
> > > +
> > > +  poly64_t __low_a = vget_low_p64 (__a);
> > > +  poly64_t __low_b = vget_low_p64 (__b);
> > > +  uint64x1_t __low = vceq_p64(__low_a, __low_b);
> >
> > Same
> >
> > > +  return vcombine_u64 (__low, __high);
> > > +}
> > > +
> > > +__extension__ extern __inline uint64x2_t
> > > +__attribute__  ((__always_inline__, __gnu_inline__, __artificial__))
> > > +vceqzq_p64 (poly64x2_t __a)
> > > +{
> > > +  poly64x2_t __b = vreinterpretq_p64_u32 (vdupq_n_u32 (0));
> > > +  return vceqq_p64 (__a, __b);
> > > +}
> >
> > Thanks
> >
> >   Andrea


Re: [Ada] Build support units for 128-bit integer types on 64-bit platforms

2020-10-23 Thread Eric Botcazou
> That variable doesn't exist.

Bummer.  Attached patch installed.

-- 
Eric Botcazoudiff --git a/gcc/ada/Makefile.rtl b/gcc/ada/Makefile.rtl
index 39b458781a8..7b5b3344af7 100644
--- a/gcc/ada/Makefile.rtl
+++ b/gcc/ada/Makefile.rtl
@@ -2543,7 +2543,7 @@ ifeq ($(strip $(filter-out %ia64 linux%,$(target_cpu) $(target_os))),)
   TOOLS_TARGET_PAIRS = indepsw.adb

Re: [PATCH, OpenMP 5.0] Implement structure element mapping changes in 5.0

2020-10-23 Thread Chung-Lin Tang

Hi Jakub, thanks for the prompt review.

On 2020/10/23 8:13 PM, Jakub Jelinek wrote:

In general, upon encountering a construct, we can't statically determine and 
insert alloc/release maps
for each element of a structure variable, since we don't really know which 
region of the structure is
currently mapped or not, hence this probably can't be properly implemented in 
the compiler.

Instead this patch tries to do the equivalent in the runtime: I've modified the 
handling of the
(GOMP_MAP_STRUCT, , , ...) sequence to:

   (1) Create just a single splay_tree_key to represent the entire structure's 
mapped-region
   (all element target_var_desc's now reference this same key instead of 
creating their own), and

I'm not sure that is what we want.  If we create just a single
splay_tree_key spanning the whole structure mapped region, then we can't
diagnose various mapping errors.  E.g. if I have:
void bar (struct S *);
struct S { int a, b, c, d, e; };
void foo (struct S s)
{
   #pragma omp target data map(tofrom: s.b, s.d)
   #pragma omp target map (s.b, s.c)
   bar (&s);
}
then target data maps the &s.b to &s.d + 1 region of the struct, but s.c
wasn't mapped and so the target region's mapping should fail, even when it
is in the middle of the mapped region.


Are you really sure this is what we want? I don't quite see anything harmful
about implicitly mapping "middle fields" like s.c, in fact the corresponding
memory is actually "mapped" anyways.


The structure mapping wording was written in a way to give implementations a
choice, either map the whole struct (space inefficient), or the region from
the first to last element in the struct the needs mapping (what GCC
implements, also space inefficient, but less so), or only map the fields
individually and somehow remap all uses of the struct in the region (I think
that is only theoretically possible if one can analyze the whole target
region and rewrite anything that could refer to it in there).


That seems to imply that rejecting "middle fields" are not really required
behavior.


So, I'd think instead of having just one splay_tree_key, we need multiple
(we could merge adjacent ones though if we want) but we need some way to tie
them together (e.g. represent them as one master entry (perhaps the first one) 
and
slaves entries and use the refcount of the master entry for all of them.


I did think of that route before, but it's just too complex and unwieldly 
compared
to an elegant solution like using one single splay_tree_key. I can try to think
more about a "composite-key" like design, but please reconsider the current 
patch.
It's already very close to the 5.0 spec, with what you mention not really "that"
large an issue.

Thanks,
Chung-Lin


Re: [RS6000] Adjust testcases for power10 instructions

2020-10-23 Thread Segher Boessenkool
On Fri, Oct 23, 2020 at 04:45:29PM +1030, Alan Modra wrote:
> Revised patch, removing changes to
> gcc.target/powerpc/fold-vec-st-double.c,
> gcc.target/powerpc/fold-vec-st-longlong.c,
> gcc.target/powerpc/fold-vec-st-pixel.c.  Fixing fails on those three
> tests will be the subject of another patch.

Okido.

> Most of these changes are fairly obvious.  Duplicated setbcr in
> +/* { dg-final { scan-assembler-times {\maddic\M|\msetbcr\M} 4 } } */
> +/* { dg-final { scan-assembler-times {\msubfe\M|\msetbcr\M} 1 } } */
> is due to addic;subfe being replaced in one function with setbcr.

But that won't really work.  If there is more than one addic replaced by
setbcr, that second scan fails (because it matches at least two times
then).

>   * gcc.dg/pr56727-2.c,
...
>   * gcc.target/powerpc/ppc-eq0-1.c,
>   * gcc.target/powerpc/ppc-ne0-1.c,
>   * gcc.target/powerpc/pr86731-fwrapv-longlong.c: Match power10 insns.

This should all be behind only one "*" (so delete it on all but the
first line here).

> --- a/gcc/testsuite/gcc.dg/vect/costmodel/ppc/costmodel-bb-slp-9a-pr63175.c
> +++ b/gcc/testsuite/gcc.dg/vect/costmodel/ppc/costmodel-bb-slp-9a-pr63175.c
> @@ -25,6 +25,6 @@ main1 (void)
> with no word loads (lw, lwu, lwz, lwzu, or their indexed forms)
> or word stores (stw, stwu, stwx, stwux, or their indexed forms).  */
>  
> -/* { dg-final { scan-assembler "\t(lvx|lxv|lvsr|stxv)" } } */
> +/* { dg-final { scan-assembler "\t(lvx|lxv|lvsr|stxv|plxv|pstxv)" } } */

/* { dg-final { scan-assembler "\t(lvx|p?lxv|lvsr|p?stxv)" } } */
might be more readable/maintainable/extensible?


> --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-load-builtin_vec_xl-char.c
> +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-load-builtin_vec_xl-char.c
> @@ -36,4 +36,4 @@ BUILD_VAR_TEST( test10, vector unsigned char, signed long 
> long, vector unsigned
>  BUILD_VAR_TEST( test11, vector unsigned char, signed int, vector unsigned 
> char);
>  BUILD_CST_TEST( test12, vector unsigned char, 8, vector unsigned char);
>  
> -/* { dg-final { scan-assembler-times 
> {\mlxvw4x\M|\mlxvd2x\M|\mlxvx\M|\mlvx\M} 12 } } */
> +/* { dg-final { scan-assembler-times 
> {\mlxvw4x\M|\mlxvd2x\M|\mlxvx\M|\mlvx\M|\mplxv\M} 12 } } */

Here, it did not allow lxv before.  Should it?

(in many files)

Have you verified the p10 code generation actually makes sense?

> --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-splat-longlong.c
> +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-splat-longlong.c
> @@ -25,7 +25,7 @@ vector signed long long test_sll () { const vector signed 
> long long y = {34, 45}
>  vector unsigned long long test_ull () { const vector unsigned long long y = 
> {56, 67}; return vec_splat (y, 0b00010); }
>  
>  /* Assorted load instructions for the initialization with known constants. */
> -/* { dg-final { scan-assembler-times {\mlvx\M|\mlxvd2x\M|\mlxv\M} 3 } } */
> +/* { dg-final { scan-assembler-times 
> {\mlvx\M|\mlxvd2x\M|\mlxv\M|\mplxv\M|\mplxv\M} 3 } } */

You have plxv twice here.

> --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-store-builtin_vec_xst-char.c
> +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-store-builtin_vec_xst-char.c
> @@ -36,4 +36,4 @@ BUILD_VAR_TEST( test10,  vector unsigned char, signed long 
> long, vector unsigned
>  BUILD_VAR_TEST( test11,  vector unsigned char, signed int, vector unsigned 
> char );
>  BUILD_CST_TEST( test12,  vector unsigned char, 12, vector unsigned char );
>  
> -/* { dg-final { scan-assembler-times 
> {\mstxvw4x\M|\mstxvd2x\M|\mstxvx\M|\mstvx\M} 12 } } */
> +/* { dg-final { scan-assembler-times 
> {\mstxvw4x\M|\mstxvd2x\M|\mstxvx\M|\mstvx\M|\mpstxv\M} 12 } } */

Similarly, should it have plain stxv as well?

> --- a/gcc/testsuite/gcc.target/powerpc/lvsl-lvsr.c
> +++ b/gcc/testsuite/gcc.target/powerpc/lvsl-lvsr.c
> @@ -1,12 +1,10 @@
> -/* Test expected code generation for lvsl and lvsr on little endian.
> -   Note that lvsl and lvsr are each produced once, but the filename
> -   causes them to appear twice in the file.  */
> +/* Test expected code generation for lvsl and lvsr on little endian.  */
>  
>  /* { dg-do compile { target { powerpc64le-*-* } } } */
>  /* { dg-options "-O0 -Wno-deprecated" } */
> -/* { dg-final { scan-assembler-times "lvsl" 2 } } */
> -/* { dg-final { scan-assembler-times "lvsr" 2 } } */
> -/* { dg-final { scan-assembler-times {\mlxvd2x\M|\mlxv\M} 2 } } */
> +/* { dg-final { scan-assembler-times {\slvsl\s} 1 } } */
> +/* { dg-final { scan-assembler-times {\slvsr\s} 1 } } */

This could use a comment (we normally use \m \M).

Better is to just rename the file, of course :-)

> +/* { dg-final { scan-assembler-times {\mlxvd2x\M|\mlxv\M|\mplxv\M} 2 } } */

\mp?lxv\M

> --- a/gcc/testsuite/gcc.target/powerpc/ppc-eq0-1.c
> +++ b/gcc/testsuite/gcc.target/powerpc/ppc-eq0-1.c
> @@ -7,4 +7,4 @@ int foo(int x)
>return x == 0;
>  }
>  
> -/* { dg-final { scan-assembler "cntlzw|isel" } } */
> +/* { dg-final { scan-assembler {\mcntlzw\M|\misel\M|\msetbc\M} 

[committed] handle invalid input even earlier (PR 97463)

2020-10-23 Thread Martin Sebor via Gcc-patches

To avoid yet another ICE caused by dereferencing a null tree due to
invalid input, the attached change moves the handling even earlier
in the affected function.  Tested on x86_64-linux and pushed as
obvious (at least until the next ICE shows up that necessitates to
move the test earlier still).

Martin
commit 7991e963239160624b22a12caaacce95d3667e49
Author: Martin Sebor 
Date:   Fri Oct 23 12:30:20 2020 -0600

PR c/97463 - ICE in warn_parm_ptrarray_mismatch on an incompatible function redeclaration

gcc/c-family/ChangeLog:

PR c/97463
* c-warn.c (warn_parm_ptrarray_mismatch): Move null test earlier.

gcc/testsuite/ChangeLog:

PR c/97463
* gcc.dg/pr97463.c: New test.

diff --git a/gcc/c-family/c-warn.c b/gcc/c-family/c-warn.c
index ebd011d1a42..a1b945053e8 100644
--- a/gcc/c-family/c-warn.c
+++ b/gcc/c-family/c-warn.c
@@ -3177,14 +3177,14 @@ warn_parm_ptrarray_mismatch (location_t origloc, tree curparms, tree newparms)
 	{
 	  curtyp = TREE_TYPE (curtyp);
 	  newtyp = TREE_TYPE (newtyp);
+
+	  if (!newtyp)
+	/* Bail on error.  */
+	return;
 	}
   while (TREE_CODE (curtyp) == POINTER_TYPE
 	 && TREE_CODE (newtyp) == POINTER_TYPE);
 
-  if (!newtyp)
-	/* Bail on error.  */
-	return;
-
   if (TREE_CODE (curtyp) != ARRAY_TYPE
 	  || TREE_CODE (newtyp) != ARRAY_TYPE)
 	{
diff --git a/gcc/testsuite/gcc.dg/pr97463.c b/gcc/testsuite/gcc.dg/pr97463.c
new file mode 100644
index 000..f93b07ccb80
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr97463.c
@@ -0,0 +1,7 @@
+/* PR c/97463 - ICE in warn_parm_ptrarray_mismatch on an incompatible
+   function redeclaration
+   { dg-do compile }
+   { dg-options "-Wall" } */
+
+void f (void**);
+void f (int n) { }  // { dg-error "conflicting types" }


[committed] handle [static] VLAs (PR 97552)

2020-10-23 Thread Martin Sebor via Gcc-patches

The attached tweak enables the -Wvla-parameter warning to also recognize
the [static] notation for VLAs, the same way it does ordinary arrays.
Tested on x86_64-linux and pushed as obvious.

Martin
commit 757ba6653c2699761c2243e0194749a6695112d8
Author: Martin Sebor 
Date:   Fri Oct 23 12:37:38 2020 -0600

PR middle-end/97552 - missing waning passing null to a VLA argument declared [static]

gcc/ChangeLog:

PR middle-end/97552
* attribs.c (init_attr_rdwr_indices): Handle static VLA parameters.

gcc/c/ChangeLog:

PR middle-end/97552
* c-decl.c (get_parm_array_spec): Handle static VLA parameters.

gcc/testsuite/ChangeLog:

PR middle-end/97552
* gcc.dg/Wvla-parameter-2.c: Adjust text of expected warning.
* gcc.dg/Wnonnull-5.c: New test.

diff --git a/gcc/attribs.c b/gcc/attribs.c
index 3bdb2ffda81..a6f6b70e39e 100644
--- a/gcc/attribs.c
+++ b/gcc/attribs.c
@@ -2109,6 +2109,7 @@ init_attr_rdwr_indices (rdwr_map *rwm, tree attrs)
 		 is followed by a comma and a dollar sign its bound is
 		 on the list.  Otherwise it's a VLA with an unspecified
 		 bound.  */
+		  acc.static_p = p[-2] == 's';
 		  acc.minsize = HOST_WIDE_INT_M1U;
 		}
 
diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
index 81b9adb6a33..1673b958555 100644
--- a/gcc/c/c-decl.c
+++ b/gcc/c/c-decl.c
@@ -5784,6 +5784,9 @@ get_parm_array_spec (const struct c_parm *parm, tree attrs)
 	  continue;
 	}
 
+  if (pd->u.array.static_p)
+	spec += 's';
+
   if (TREE_CODE (nelts) == INTEGER_CST)
 	{
 	  /* Skip all constant bounds except the most significant one.
@@ -5796,9 +5799,8 @@ get_parm_array_spec (const struct c_parm *parm, tree attrs)
 	return attrs;
 
 	  char buf[40];
-	  const char *code = pd->u.array.static_p ? "s" : "";
 	  unsigned HOST_WIDE_INT n = tree_to_uhwi (nelts);
-	  sprintf (buf, "%s%llu", code, (unsigned long long)n);
+	  sprintf (buf, "%llu", (unsigned long long)n);
 	  spec += buf;
 	  break;
 	}
diff --git a/gcc/testsuite/gcc.dg/Wnonnull-5.c b/gcc/testsuite/gcc.dg/Wnonnull-5.c
new file mode 100644
index 000..ef6ed54c3f3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/Wnonnull-5.c
@@ -0,0 +1,53 @@
+/* PR middle-end/97552 - missing waning passing null to a VLA argument
+   declared [static]
+   { dg-do compile }
+   { dg-options "-Wall" } */
+
+#define A(...) __attribute__ ((__VA_ARGS__))
+
+void fptr_array (int(*)[0]);
+
+void fstatic_array (int[static 0]);
+void A (nonnull) fnonnull_static_array (int [static 0]);
+
+void fvla (int n, int [n]);
+void A (nonnull) fnonnull_vla (int n, int [n]);
+
+void fstatic_vla (int n, int [static n]);
+void A (nonnull) fnonnull_static_vla (int n, int [static n]);
+
+
+void test_null (void)
+{
+  fptr_array (0);
+  fptr_array (&(int[0]){ });
+
+  fstatic_array (0);// { dg-warning "\\\[-Wnonnull" }
+  fnonnull_static_array (0);// { dg-warning "\\\[-Wnonnull" }
+
+  fvla (0, 0);
+  fnonnull_vla (0, 0);  // { dg-warning "\\\[-Wnonnull" }
+
+  fstatic_vla (0, 0);   // { dg-warning "\\\[-Wnonnull" }
+  fnonnull_static_vla (0, 0);   // { dg-warning "\\\[-Wnonnull" }
+}
+
+
+#pragma GCC optimize ("1")
+
+void test_null_optimized (void)
+{
+  int (*pa)[0] = 0;
+  fptr_array (pa);
+
+  int *p = 0;
+
+  fstatic_array (p);// { dg-warning "\\\[-Wnonnull" }
+  fnonnull_static_array (p);// { dg-warning "\\\[-Wnonnull" }
+
+  fvla (0, p);
+  fnonnull_vla (0, p);  // { dg-warning "\\\[-Wnonnull" }
+
+  fstatic_vla (0, p);   // { dg-warning "\\\[-Wnonnull" }
+  fnonnull_static_vla (0, p);   // { dg-warning "\\\[-Wnonnull" }
+}
diff --git a/gcc/testsuite/gcc.dg/Wvla-parameter-2.c b/gcc/testsuite/gcc.dg/Wvla-parameter-2.c
index ba9324143b4..01728e7ebb7 100644
--- a/gcc/testsuite/gcc.dg/Wvla-parameter-2.c
+++ b/gcc/testsuite/gcc.dg/Wvla-parameter-2.c
@@ -67,9 +67,9 @@ void a2pampan (int (*(*(*[2])[n1])[n2]));
 int f2ia1_1 (int n, int [n][n]);// { sg-message "previously declared as 'int\\\[n]\\\[n]' with bound argument 1" }
 int f2ia1_1 (int n, int[static n][n]);
 int f2ia1_1 (int n, int a[static n][n]) { return sizeof *a; }
-int f2ia1_1 (int n, int[static n + 1][n]);  // { dg-warning "argument 2 of type 'int\\\[n \\\+ 1]\\\[n]' declared with mismatched bound 'n \\\+ 1'" }
+int f2ia1_1 (int n, int[static n + 1][n]);  // { dg-warning "argument 2 of type 'int\\\[static  *n \\\+ 1]\\\[n]' declared with mismatched bound 'n \\\+ 1'" }
 
-int f2ias1_1 (int n, int [static n][n]);// { dg-message "previously declared as 'int\\\[n]\\\[n]' with bound argument 1" }
+int f2ias1_1 (int n, int [static n][n]);// { dg-message "previously declared as 'int\\\[static +n]\\\[n]' with bound argument 1" }
 int f2ias1_1 (int n, int[n][n]);
 int f2ias1_1 (int n, int a[++n][n]) // { dg-warning "argument 2 of type 'int\\\[\\\

[PATCH] c++: Implement -Wvexing-parse [PR25814]

2020-10-23 Thread Marek Polacek via Gcc-patches
This patch implements the -Wvexing-parse warning to warn about the
sneaky most vexing parse rule in C++: the cases when a declaration
looks like a variable definition, but the C++ language requires it
to be interpreted as a function declaration.  This warning is on by
default (like clang++).  From the docs:

  void f(double a) {
int i();// extern int i (void);
int n(int(a));  // extern int n (int);
  }

  Another example:

  struct S { S(int); };
  void f(double a) {
S x(int(a));   // extern struct S x (int);
S y(int());// extern struct S y (int (*) (void));
S z(); // extern struct S z (void);
  }

You can find more on this in [dcl.ambig.res].

I spent a fair amount of time on fix-it hints so that GCC can recommend
various ways to resolve such an ambiguity.  Sometimes that's tricky.
E.g., suggesting default-initialization when the class doesn't have
a default constructor would not be optimal.  Suggesting {}-init is also
not trivial because it can use an initializer-list constructor if no
default constructor is available (which ()-init wouldn't do).  And of
course, pre-C++11, we shouldn't be recommending {}-init at all.

I also uncovered a bug in cp_parser_declarator, where we were setting
*parenthesized_p to true despite the comment saying the exact opposite.

Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?

gcc/c-family/ChangeLog:

PR c++/25814
* c.opt (Wvexing-parse): New option.

gcc/cp/ChangeLog:

PR c++/25814
* parser.c (cp_parser_init_declarator): Maybe set warn_ambig_parse.
Pass it to cp_parser_declarator.
(cp_parser_declarator): Add a tree parameter with a default
value.  Set *parenthesized_p to false rather than to true.  Pass
warn_ambig_parse to cp_parser_direct_declarator.
(warn_about_ambiguous_parse): New function.
(cp_parser_direct_declarator): Add a tree parameter with a default
value.  Have cp_parser_parameter_declaration_clause set a flag
if it encountered a vexing parse.  Call warn_about_ambiguous_parse
if desirable.
(cp_parser_parameter_declaration_clause): New bool * parameter
with a default value.  Set it.  Pass it to
cp_parser_parameter_declaration_list.
(cp_parser_parameter_declaration_list): New bool * parameter.
Set it.
(cp_parser_cache_defarg): Adjust the call to
cp_parser_parameter_declaration_list.

gcc/ChangeLog:

PR c++/25814
* doc/invoke.texi: Document -Wvexing-parse.

gcc/testsuite/ChangeLog:

PR c++/25814
* g++.dg/cpp2a/fn-template16.C: Add a dg-warning.
* g++.dg/cpp2a/fn-template7.C: Likewise.
* g++.dg/lookup/pr80891-5.C: Likewise.
* g++.dg/lto/pr79050_0.C: Add extern.
* g++.dg/lto/pr84805_0.C: Likewise.
* g++.dg/parse/pr58898.C: Add a dg-warning.
* g++.dg/template/scope5.C: Likewise.
* g++.old-deja/g++.brendan/recurse.C: Likewise.
* g++.old-deja/g++.jason/template4.C: Likewise.
* g++.old-deja/g++.law/arm4.C: Likewise.
* g++.old-deja/g++.mike/for2.C: Likewise.
* g++.old-deja/g++.other/local4.C: Likewise.
* g++.old-deja/g++.pt/crash3.C: Likewise.
* g++.dg/warn/Wvexing-parse.C: New test.
* g++.dg/warn/Wvexing-parse2.C: New test.
* g++.dg/warn/Wvexing-parse3.C: New test.
* g++.dg/warn/Wvexing-parse4.C: New test.
* g++.dg/warn/Wvexing-parse5.C: New test.
* g++.dg/warn/Wvexing-parse6.C: New test.

libstdc++-v3/ChangeLog:

PR c++/25814
* testsuite/20_util/reference_wrapper/lwg2993.cc: Add a dg-warning.
* testsuite/25_algorithms/generate_n/87982_neg.cc: Likewise.
---
 gcc/c-family/c.opt|   4 +
 gcc/cp/parser.c   | 176 +++---
 gcc/doc/invoke.texi   |  34 +++-
 gcc/testsuite/g++.dg/cpp2a/fn-template16.C|   2 +-
 gcc/testsuite/g++.dg/cpp2a/fn-template7.C |   2 +-
 gcc/testsuite/g++.dg/lookup/pr80891-5.C   |   2 +-
 gcc/testsuite/g++.dg/lto/pr79050_0.C  |   2 +-
 gcc/testsuite/g++.dg/lto/pr84805_0.C  |   2 +-
 gcc/testsuite/g++.dg/parse/pr58898.C  |   4 +-
 gcc/testsuite/g++.dg/template/scope5.C|   2 +-
 gcc/testsuite/g++.dg/warn/Wvexing-parse.C | 110 +++
 gcc/testsuite/g++.dg/warn/Wvexing-parse2.C|  24 +++
 gcc/testsuite/g++.dg/warn/Wvexing-parse3.C| 129 +
 gcc/testsuite/g++.dg/warn/Wvexing-parse4.C|  74 
 gcc/testsuite/g++.dg/warn/Wvexing-parse5.C|  14 ++
 gcc/testsuite/g++.dg/warn/Wvexing-parse6.C|  24 +++
 .../g++.old-deja/g++.brendan/recurse.C|   2 +-
 .../g++.old-deja/g++.jason/template4.C|   2 +-
 gcc/testsuite/g++.old-deja/g++.law/arm4.C |   2 +-
 gcc/testsuite/g++.old-deja/g++.mike/for2.C|   2 +-
 gcc/testsuite/g++.old-deja/g++.other/local4.C |   2 +-
 gcc/testsu

Re: Materialize clones on demand

2020-10-23 Thread Jan Hubicka
> Hi,
> 
> On Thu, Oct 22 2020, Jan Hubicka wrote:
> > Hi,
> > this patch removes the pass to materialize all clones and instead this
> > is now done on demand.  The motivation is to reduce lifetime of function
> > bodies in ltrans that should noticeably reduce memory use for highly
> > parallel compilations of large programs (like Martin does) or with
> > partitioning reduced/disabled. For cc1 with one partition the memory use
> > seems to go down from 4gb to cca 1.5gb (seeing from top, so this is not
> > particularly accurate).
> >
> 
> Nice.

Sadly this is only true w/o debug info.  I collected memory usage stats
at the end of the ltrans stage and it is as folloes

 - after streaming in global stream: 126M GGC and 41M heap
 - after streaming symbol table: 373M GGC and 92M heap
 - after stremaing in summaries: 394M GGC and 92M heap 
   (only large summary seems to be ipa-cp transformation summary)
 - then compilation starts and memory goes slowly up to 3527M at the end
   of compilation

The following accounts for more than 1% GGC:

Time variable   usr   sys  wall 
  GGC
 ipa inlining heuristics:   6.99 (  0%)   4.62 (  1%)  11.17 (  1%) 
  241M (  1%)
 ipa lto gimple in  :  50.04 (  3%)  29.72 (  7%)  80.22 (  4%) 
 3129M ( 14%)
 ipa lto decl in:   0.79 (  0%)   0.36 (  0%)   1.15 (  0%) 
  135M (  1%)
 ipa lto cgraph I/O :   0.95 (  0%)   0.20 (  0%)   1.15 (  0%) 
  269M (  1%)
 cfg cleanup:  25.83 (  2%)   2.52 (  1%)  28.15 (  1%) 
  154M (  1%)
 df reg dead/unused notes   :  24.08 (  2%)   2.09 (  1%)  26.77 (  1%) 
  180M (  1%)
 alias analysis :  16.94 (  1%)   1.05 (  0%)  17.71 (  1%) 
  383M (  2%)
 integration:  45.76 (  3%)  44.30 ( 11%)  88.99 (  5%) 
 2328M ( 10%)
 tree VRP   :  41.38 (  3%)  15.67 (  4%)  57.71 (  3%) 
  560M (  2%)
 tree SSA rewrite   :   6.71 (  0%)   2.17 (  1%)   8.96 (  0%) 
  194M (  1%)
 tree SSA incremental   :  26.99 (  2%)   8.23 (  2%)  34.42 (  2%) 
  144M (  1%)
 tree operand scan  :  65.34 (  4%)  61.50 ( 15%) 127.02 (  7%) 
  886M (  4%)
 dominator optimization :  41.53 (  3%)  13.56 (  3%)  55.78 (  3%) 
  407M (  2%)
 tree split crit edges  :   1.08 (  0%)   0.65 (  0%)   1.63 (  0%) 
  127M (  1%)
 tree PRE   :  34.30 (  2%)  14.52 (  4%)  49.08 (  3%) 
  337M (  1%)
 tree code sinking  :   2.92 (  0%)   0.58 (  0%)   3.51 (  0%) 
  122M (  1%)
 tree iv optimization   :   6.71 (  0%)   1.19 (  0%)   8.46 (  0%) 
  133M (  1%)
 expand :  45.56 (  3%)   8.24 (  2%)  55.02 (  3%) 
 1980M (  9%)
 forward prop   :  11.89 (  1%)   1.39 (  0%)  12.59 (  1%) 
  130M (  1%)
 dead store elim2   :  10.03 (  1%)   0.70 (  0%)  11.23 (  1%) 
  138M (  1%)
 loop init  :  11.96 (  1%)   4.95 (  1%)  17.11 (  1%) 
  378M (  2%)
 CPROP  :  22.63 (  2%)   2.78 (  1%)  25.19 (  1%) 
  359M (  2%)
 combiner   :  41.39 (  3%)   2.57 (  1%)  43.30 (  2%) 
  558M (  2%)
 reload CSE regs:  22.38 (  2%)   1.25 (  0%)  23.06 (  1%) 
  186M (  1%)
 final  :  32.33 (  2%)   4.28 (  1%)  36.75 (  2%) 
 1105M (  5%)
 symout :  49.04 (  3%)   2.23 (  1%)  52.33 (  3%) 
 2517M ( 11%)
 var-tracking emit  :  33.26 (  2%)   1.02 (  0%)  34.35 (  2%) 
  582M (  3%)
 rest of compilation:  38.05 (  3%)  15.61 (  4%)  52.42 (  3%) 
  114M (  1%)
 TOTAL  :1486.02408.79   1899.96
22512M

We seem to leak some hashtables:
dwarf2out.c:28850 (dwarf2out_init)  31M: 23.8%   47M
   19 :  0.0%   ggc
cselib.c:3137 (cselib_init) 34M: 25.9%   34M
 1514k: 17.3%  heap
tree-scalar-evolution.c:2984 (scev_initialize)  37M: 27.6%   50M
  228k:  2.6%   ggc

and hashmaps:
ipa-reference.c:1133 (ipa_reference_read_optimiz  2047k:  3.0% 3071k
9 :  0.0%  heap
tree-ssa.c:60 (redirect_edge_var_map_add) 4125k:  6.1% 4126k
 8190 :  0.1%  heap
alias.c:1200 (record_alias_subset)4510k:  6.6% 4510k
 4546 :  0.0%   ggc
ipa-prop.h:986 (ipcp_transformation_t)8191k: 12.0%   11M
   16 :  0.0%   ggc
dwarf2out.c:5957 (dwarf2out_register_external_di47M: 72.2%   71M
   12 :  0.0%   ggc

and hashsets:
ipa-devirt.c:3093 (possible_polymorphic_call_tar15k:  0.9%   23k
8 :  0.0%  heap
ipa-devirt.c:1599 (add_type_duplicate) 412k: 22.2%  412k
 4065 :

Move thunks out of cgraph_node

2020-10-23 Thread Jan Hubicka
Hi,
this patch moves thunk_info out of cgraph_node into a symbol summary.
I also moved it to separate hearder file since cgraph.h became really too
fat.  I plan to contiue with similar breakup in order to cleanup interfaces
and reduce WPA memory footprint (symbol table now consumes more memory than
trees)

Bootstrapped/regtested x86_64-linux, plan to commit it shortly.

gcc/ChangeLog:

2020-10-23  Jan Hubicka  

* Makefile.in: Add symtab-thunks.o
(GTFILES): Add symtab-thunks.h and symtab-thunks.cc; remove cgraphunit.c
* cgraph.c: Include symtab-thunks.h.
(cgraph_node::create_thunk): Update
(symbol_table::create_edge): Update
(cgraph_node::dump): Update
(cgraph_node::call_for_symbol_thunks_and_aliases): Update
(set_nothrow_flag_1): Update
(set_malloc_flag_1): Update
(set_const_flag_1): Update
(collect_callers_of_node_1): Update
(clone_of_p): Update
(cgraph_node::verify_node): Update
(cgraph_node::function_symbol): Update
(cgraph_c_finalize): Call thunk_info::release.
(cgraph_node::has_thunk_p): Update
(cgraph_node::former_thunk_p): Move here from cgraph.h; reimplement.
* cgraph.h (struct cgraph_thunk_info): Rename to symtab-thunks.h.
(cgraph_node): Remove thunk field; add thunk bitfield.
(cgraph_node::expand_thunk): Move to symtab-thunks.h
(symtab_thunks_cc_finalize): Declare.
(cgraph_node::has_gimple_body_p): Update.
(cgraph_node::former_thunk_p): Update.
* cgraphclones.c: Include symtab-thunks.h.
(duplicate_thunk_for_node): Update.
(cgraph_edge::redirect_callee_duplicating_thunks): Update.
(cgraph_node::expand_all_artificial_thunks): Update.
(cgraph_node::create_edge_including_clones): Update.
* cgraphunit.c: Include symtab-thunks.h.
(vtable_entry_type): Move to symtab-thunks.c.
(cgraph_node::analyze): Update.
(analyze_functions): Update.
(mark_functions_to_output): Update.
(thunk_adjust): Move to symtab-thunks.c
(cgraph_node::expand_thunk): Move to symtab-thunks.c
(cgraph_node::assemble_thunks_and_aliases): Update.
(output_in_order): Update.
(cgraphunit_c_finalize): Do not clear vtable_entry_type.
(cgraph_node::create_wrapper): Update.
* gengtype.c (open_base_files): Add symtab-thunks.h
* ipa-comdats.c (propagate_comdat_group): UPdate.
(ipa_comdats): Update.
* ipa-cp.c (determine_versionability): UPdate.
(gather_caller_stats): Update.
(count_callers): Update
(set_single_call_flag): Update
(initialize_node_lattices): Update
(call_passes_through_thunk_p): Update
(call_passes_through_thunk): Update
(propagate_constants_across_call): Update
(find_more_scalar_values_for_callers_subset): Update
(has_undead_caller_from_outside_scc_p): Update
* ipa-fnsummary.c (evaluate_properties_for_edge): Update.
(compute_fn_summary): Update.
(inline_analyze_function): Update.
* ipa-icf.c: Include symtab-thunks.h.
(sem_function::equals_wpa): Update.
(redirect_all_callers): Update.
(sem_function::init): Update.
(sem_function::parse): Update.
* ipa-inline-transform.c: Include symtab-thunks.h.
(inline_call): Update.
(save_inline_function_body): Update.
(preserve_function_body_p): Update.
* ipa-inline.c (inline_small_functions): Update.
* ipa-polymorphic-call.c: Include alloc-pool.h, symbol-summary.h,
symtab-thunks.h
(ipa_polymorphic_call_context::ipa_polymorphic_call_context): Update.
* ipa-pure-const.c: Include symtab-thunks.h.
(analyze_function): Update.
* ipa-sra.c (check_for_caller_issues): Update.
* ipa-utils.c (ipa_reverse_postorder): Update.
(ipa_merge_profiles): Update.
* ipa-visibility.c (non_local_p): Update.
(cgraph_node::local_p): Update.
(function_and_variable_visibility): Update.
* ipa.c (symbol_table::remove_unreachable_nodes): Update.
* lto-cgraph.c: Include alloc-pool.h, symbol-summary.h and
symtab-thunks.h
(lto_output_edge): Update.
(lto_output_node): Update.
(compute_ltrans_boundary): Update.
(output_symtab): Update.
(verify_node_partition): Update.
(input_overwrite_node): Update.
(input_node): Update.
* lto-streamer-in.c (fixup_call_stmt_edges): Update.
* symtab-thunks.cc: New file.
* symtab-thunks.h: New file.
* toplev.c (toplev::finalize): Call symtab_thunks_cc_finalize.
* trans-mem.c (ipa_tm_mayenterirr_function): Update.
(ipa_tm_execute): Update.
* tree-inline.c (expand_call_inline): Update.
* tree-nested.c (create_nesting_tree): Update.
(convert_all_function_

Re: [RS6000] VSX_MM_SUFFIX

2020-10-23 Thread Segher Boessenkool
On Fri, Oct 23, 2020 at 09:41:30AM +1030, Alan Modra wrote:
> On Thu, Oct 22, 2020 at 11:03:14AM -0500, Segher Boessenkool wrote:
> > On Thu, Oct 22, 2020 at 08:58:10AM -0700, Carl Love wrote:
> > > OK, looks like VSX_MM_SUFFIX doesn't exist anymore.  Don't know what
> > > happed to it.  Thanks.
> > 
> > It never existed on trunk.  Please always regstrap patches on trunk
> > before committing.  It feels unnecessary at times, but now you know
> > why :-)
> 
> Regression testing wouldn't have caught the problem, unless Carl had
> done so on power10.

"regstrap" is "bootstrap + regression check".  It won't bootstrap (won't
cross build even afaics?)


Segher


[PATCH] rs6000, Power 10 testsuite fixes

2020-10-23 Thread Carl Love via Gcc-patches
GCC maintainers:

The following patch fixes a few issues with the tests.  The DEBUG is
defined in each of the files thus the #ifdef DEBUG should just be #if
DEBUG.  The other issue is a some of the line lengths for the error
prints exceed 80 characters.  The patch fixes the prints.

The patch was compiled and tested on:

  powerpc64le-unknown-linux-gnu (Power 9 LE)

with no regressions.  Additionally, the test cases were manually
compiled with -mcpu=power10 and run on mambo.  The expected results
were changed for the cases where the print statements were changed to
verify the prints still work correctly.

Please let me know if this patch is acceptable for mainline.  Thanks.

Carl Love
 

---

gcc/ChangeLog

2020-10-22  Carl Love  

* config/testsuite/gcc.targetpc/vec-blend-runnable.c: Change
#ifdef DEBUG to #if DEBUG.
Fix printf line so it is less then 80 characters long.
* config/testsuite/gcc.targetpc/vec-insert-word-runnable.c: Change
#ifdef DEBUG to #if DEBUG.
* config/testsuite/gcc.targetpc/vec-permute-ext-runnable.c: Change
#ifdef DEBUG to #if DEBUG.
* config/testsuite/gcc.targetpc/vec-replace-word-runnable.c: Change
#ifdef DEBUG to #if DEBUG.
Fix printf lines so they are less then 80 characters long.
* config/testsuite/gcc.targetpc/vec-shift-double-runnable.c: Change
#ifdef DEBUG to #if DEBUG.
---
 .../gcc.target/powerpc/vec-blend-runnable.c|  5 +++--
 .../gcc.target/powerpc/vec-insert-word-runnable.c  |  2 +-
 .../gcc.target/powerpc/vec-permute-ext-runnable.c  |  2 +-
 .../gcc.target/powerpc/vec-replace-word-runnable.c | 14 +-
 .../gcc.target/powerpc/vec-shift-double-runnable.c |  2 +-
 5 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/gcc/testsuite/gcc.target/powerpc/vec-blend-runnable.c 
b/gcc/testsuite/gcc.target/powerpc/vec-blend-runnable.c
index 0c3d47234ed..d7baf16955b 100644
--- a/gcc/testsuite/gcc.target/powerpc/vec-blend-runnable.c
+++ b/gcc/testsuite/gcc.target/powerpc/vec-blend-runnable.c
@@ -5,7 +5,7 @@
 
 #define DEBUG 0
 
-#ifdef DEBUG
+#if DEBUG
 #include 
 #endif
 
@@ -144,7 +144,8 @@ main (int argc, char *argv [])
 
   if (!vec_all_eq (vresult_ushort,  expected_vresult_ushort)) {
 #if DEBUG
-printf("ERROR, vec_blendv (vsrc_a_ushort, vsrc_b_ushort, 
vsrc_c_ushort)\n");
+printf("ERROR, vec_blendv (vsrc_a_ushort, vsrc_b_ushort, "
+  "vsrc_c_ushort)\n");
 for(i = 0; i < 8; i++)
   printf(" vresult_ushort[%d] = %d, expected_vresult_ushort[%d] = %d\n",
 i, vresult_ushort[i], i, expected_vresult_ushort[i]);
diff --git a/gcc/testsuite/gcc.target/powerpc/vec-insert-word-runnable.c 
b/gcc/testsuite/gcc.target/powerpc/vec-insert-word-runnable.c
index 8c2721aedfc..e0224cc3d38 100644
--- a/gcc/testsuite/gcc.target/powerpc/vec-insert-word-runnable.c
+++ b/gcc/testsuite/gcc.target/powerpc/vec-insert-word-runnable.c
@@ -5,7 +5,7 @@
 
 #define DEBUG 0
 
-#ifdef DEBUG
+#if DEBUG
 #include 
 #endif
 
diff --git a/gcc/testsuite/gcc.target/powerpc/vec-permute-ext-runnable.c 
b/gcc/testsuite/gcc.target/powerpc/vec-permute-ext-runnable.c
index c2dcd48b4c5..90fb7979ca2 100644
--- a/gcc/testsuite/gcc.target/powerpc/vec-permute-ext-runnable.c
+++ b/gcc/testsuite/gcc.target/powerpc/vec-permute-ext-runnable.c
@@ -5,7 +5,7 @@
 
 #define DEBUG 0
 
-#ifdef DEBUG
+#if DEBUG
 #include 
 #endif
 
diff --git a/gcc/testsuite/gcc.target/powerpc/vec-replace-word-runnable.c 
b/gcc/testsuite/gcc.target/powerpc/vec-replace-word-runnable.c
index 94af2106482..c75a87d028a 100644
--- a/gcc/testsuite/gcc.target/powerpc/vec-replace-word-runnable.c
+++ b/gcc/testsuite/gcc.target/powerpc/vec-replace-word-runnable.c
@@ -6,7 +6,7 @@
 
 #define DEBUG 0
 
-#ifdef DEBUG
+#if DEBUG
 #include 
 #endif
 
@@ -212,7 +212,8 @@ main (int argc, char *argv [])
 
   if (!vec_all_eq (vresult_float,  expected_vresult_float)) {
 #if DEBUG
-printf("ERROR, vec_replace_unaligned (src_vb_float, src_va_float, 
index)\n");
+printf("ERROR, vec_replace_unaligned (src_vb_float, src_va_float, "
+  "index)\n");
 for(i = 0; i < 4; i++)
   printf(" vresult_float[%d] = %f, expected_vresult_float[%d] = %f\n",
 i, vresult_float[i], i, expected_vresult_float[i]);
@@ -233,7 +234,8 @@ main (int argc, char *argv [])
 
   if (!vec_all_eq (vresult_ullint,  expected_vresult_ullint)) {
 #if DEBUG
-printf("ERROR, vec_replace_unaligned (src_vb_ullint, src_va_ullint, 
index)\n");
+printf("ERROR, vec_replace_unaligned (src_vb_ullint, src_va_ullint, "
+  "index)\n");
 for(i = 0; i < 2; i++)
   printf(" vresult_ullint[%d] = %d, expected_vresult_ullint[%d] = %d\n",
 i, vresult_ullint[i], i, expected_vresult_ullint[i]);
@@ -252,7 +254,8 @@ main (int argc, char *argv [])
 
   if (!vec_all_eq (vresult_llint,  expected_vresult_llint)) {
 #if DEBUG
-printf("ERRO

[r11-4328 Regression] FAIL: g++.dg/warn/Wsizeof-array-div2.C -std=gnu++98 (test for warnings, line 11) on Linux/x86_64

2020-10-23 Thread sunil.k.pandey via Gcc-patches
On Linux/x86_64,

83f83ddfe0fe41c9b553850d4ababd5089df8332 is the first bad commit
commit 83f83ddfe0fe41c9b553850d4ababd5089df8332
Author: Marek Polacek 
Date:   Fri Sep 11 16:19:08 2020 -0400

c, c++: Implement -Wsizeof-array-div [PR91741]

caused

FAIL: c-c++-common/Wsizeof-array-div1.c  -std=gnu++14  (test for warnings, line 
16)
FAIL: c-c++-common/Wsizeof-array-div1.c  -std=gnu++14  (test for warnings, line 
17)
FAIL: c-c++-common/Wsizeof-array-div1.c  -std=gnu++14  (test for warnings, line 
21)
FAIL: c-c++-common/Wsizeof-array-div1.c  -std=gnu++17  (test for warnings, line 
16)
FAIL: c-c++-common/Wsizeof-array-div1.c  -std=gnu++17  (test for warnings, line 
17)
FAIL: c-c++-common/Wsizeof-array-div1.c  -std=gnu++17  (test for warnings, line 
21)
FAIL: c-c++-common/Wsizeof-array-div1.c  -std=gnu++2a  (test for warnings, line 
16)
FAIL: c-c++-common/Wsizeof-array-div1.c  -std=gnu++2a  (test for warnings, line 
17)
FAIL: c-c++-common/Wsizeof-array-div1.c  -std=gnu++2a  (test for warnings, line 
21)
FAIL: c-c++-common/Wsizeof-array-div1.c  -std=gnu++98  (test for warnings, line 
16)
FAIL: c-c++-common/Wsizeof-array-div1.c  -std=gnu++98  (test for warnings, line 
17)
FAIL: c-c++-common/Wsizeof-array-div1.c  -std=gnu++98  (test for warnings, line 
21)
FAIL: c-c++-common/Wsizeof-array-div1.c  -Wc++-compat   (test for warnings, 
line 16)
FAIL: c-c++-common/Wsizeof-array-div1.c  -Wc++-compat   (test for warnings, 
line 17)
FAIL: c-c++-common/Wsizeof-array-div1.c  -Wc++-compat   (test for warnings, 
line 21)
FAIL: g++.dg/warn/Wsizeof-array-div2.C  -std=gnu++14  (test for warnings, line 
11)
FAIL: g++.dg/warn/Wsizeof-array-div2.C  -std=gnu++17  (test for warnings, line 
11)
FAIL: g++.dg/warn/Wsizeof-array-div2.C  -std=gnu++2a  (test for warnings, line 
11)
FAIL: g++.dg/warn/Wsizeof-array-div2.C  -std=gnu++98  (test for warnings, line 
11)

with GCC configured with

Configured with: ../../gcc/configure 
--prefix=/local/skpandey/gccwork/toolwork/gcc-bisect-master/master/r11-4328/usr 
--enable-clocale=gnu --with-system-zlib --with-demangler-in-ld 
--with-fpmath=sse --enable-languages=c,c++,fortran --enable-cet --without-isl 
--enable-libmpx x86_64-linux --disable-bootstrap

To reproduce:

$ cd {build_dir}/gcc && make check 
RUNTESTFLAGS="dg.exp=c-c++-common/Wsizeof-array-div1.c 
--target_board='unix{-m32}'"
$ cd {build_dir}/gcc && make check 
RUNTESTFLAGS="dg.exp=c-c++-common/Wsizeof-array-div1.c 
--target_board='unix{-m32\ -march=cascadelake}'"
$ cd {build_dir}/gcc && make check 
RUNTESTFLAGS="dg.exp=g++.dg/warn/Wsizeof-array-div2.C 
--target_board='unix{-m32}'"
$ cd {build_dir}/gcc && make check 
RUNTESTFLAGS="dg.exp=g++.dg/warn/Wsizeof-array-div2.C 
--target_board='unix{-m32\ -march=cascadelake}'"

(Please do not reply to this email, for question about this report, contact me 
at skpgkp2 at gmail dot com)


Re: [PATCH 2/8] [RS6000] rs6000_rtx_costs for AND

2020-10-23 Thread Hans-Peter Nilsson
On Thu, 22 Oct 2020, Alan Modra via Gcc-patches wrote:

Hi!

> On Wed, Oct 21, 2020 at 03:29:11PM -0500, Segher Boessenkool wrote:
> > Anyway:
> >
> > +  || (outer_code == AND
> > +  && rs6000_is_valid_2insn_and (x, mode)))
> > {
> >   *total = COSTS_N_INSNS (1);
> >   return true;
> >
> > It should return COSTS_N_INSNS (2) for that?
>
> No, it should not!
>
>   /* (reg) is costed at zero by rtlanal.c:rtx_cost.  That sets a
>baseline for rtx costs:  If a constant is valid in an insn,
>it is free.  */

>From where is this quote?  My "git grep" fails to find it for me
(on master).  It seems like a port-specific commment so I'd
have expected to find it somewhere in config/rs6000.

brgds, H-P


Re: [r11-4328 Regression] FAIL: g++.dg/warn/Wsizeof-array-div2.C -std=gnu++98 (test for warnings, line 11) on Linux/x86_64

2020-10-23 Thread Marek Polacek via Gcc-patches
On Fri, Oct 23, 2020 at 04:14:20PM -0700, sunil.k.pandey via Gcc-patches wrote:
> On Linux/x86_64,
> 
> 83f83ddfe0fe41c9b553850d4ababd5089df8332 is the first bad commit
> commit 83f83ddfe0fe41c9b553850d4ababd5089df8332
> Author: Marek Polacek 
> Date:   Fri Sep 11 16:19:08 2020 -0400
> 
> c, c++: Implement -Wsizeof-array-div [PR91741]
> 
> caused
> 
> FAIL: c-c++-common/Wsizeof-array-div1.c  -std=gnu++14  (test for warnings, 
> line 16)
> FAIL: c-c++-common/Wsizeof-array-div1.c  -std=gnu++14  (test for warnings, 
> line 17)
> FAIL: c-c++-common/Wsizeof-array-div1.c  -std=gnu++14  (test for warnings, 
> line 21)
> FAIL: c-c++-common/Wsizeof-array-div1.c  -std=gnu++17  (test for warnings, 
> line 16)
> FAIL: c-c++-common/Wsizeof-array-div1.c  -std=gnu++17  (test for warnings, 
> line 17)
> FAIL: c-c++-common/Wsizeof-array-div1.c  -std=gnu++17  (test for warnings, 
> line 21)
> FAIL: c-c++-common/Wsizeof-array-div1.c  -std=gnu++2a  (test for warnings, 
> line 16)
> FAIL: c-c++-common/Wsizeof-array-div1.c  -std=gnu++2a  (test for warnings, 
> line 17)
> FAIL: c-c++-common/Wsizeof-array-div1.c  -std=gnu++2a  (test for warnings, 
> line 21)
> FAIL: c-c++-common/Wsizeof-array-div1.c  -std=gnu++98  (test for warnings, 
> line 16)
> FAIL: c-c++-common/Wsizeof-array-div1.c  -std=gnu++98  (test for warnings, 
> line 17)
> FAIL: c-c++-common/Wsizeof-array-div1.c  -std=gnu++98  (test for warnings, 
> line 21)
> FAIL: c-c++-common/Wsizeof-array-div1.c  -Wc++-compat   (test for warnings, 
> line 16)
> FAIL: c-c++-common/Wsizeof-array-div1.c  -Wc++-compat   (test for warnings, 
> line 17)
> FAIL: c-c++-common/Wsizeof-array-div1.c  -Wc++-compat   (test for warnings, 
> line 21)
> FAIL: g++.dg/warn/Wsizeof-array-div2.C  -std=gnu++14  (test for warnings, 
> line 11)
> FAIL: g++.dg/warn/Wsizeof-array-div2.C  -std=gnu++17  (test for warnings, 
> line 11)
> FAIL: g++.dg/warn/Wsizeof-array-div2.C  -std=gnu++2a  (test for warnings, 
> line 11)
> FAIL: g++.dg/warn/Wsizeof-array-div2.C  -std=gnu++98  (test for warnings, 
> line 11)

Fixed thus:

>From d835608f05471e749533c756ccdd9e166b819b68 Mon Sep 17 00:00:00 2001
From: Marek Polacek 
Date: Fri, 23 Oct 2020 19:26:43 -0400
Subject: [PATCH] testsuite: Fix -Wsizeof-array-div tests.

gcc/testsuite/ChangeLog:

* c-c++-common/Wsizeof-array-div1.c: Expect certain warnings on
lp64 targets only.
* g++.dg/warn/Wsizeof-array-div2.C: Only run on lp64 targets.
---
 gcc/testsuite/c-c++-common/Wsizeof-array-div1.c | 6 +++---
 gcc/testsuite/g++.dg/warn/Wsizeof-array-div2.C  | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/gcc/testsuite/c-c++-common/Wsizeof-array-div1.c 
b/gcc/testsuite/c-c++-common/Wsizeof-array-div1.c
index 84d9a730cba..6e01d6c87d1 100644
--- a/gcc/testsuite/c-c++-common/Wsizeof-array-div1.c
+++ b/gcc/testsuite/c-c++-common/Wsizeof-array-div1.c
@@ -13,12 +13,12 @@ fn (int ap[])
   int r = 0;
 
   r += sizeof (arr) / sizeof (*arr);
-  r += sizeof (arr) / sizeof (p); /* { dg-warning "expression does not 
compute" } */
-  r += sizeof (arr) / sizeof p; /* { dg-warning "expression does not compute" 
} */
+  r += sizeof (arr) / sizeof (p); /* { dg-warning "expression does not 
compute" "" { target { lp64 } } } */
+  r += sizeof (arr) / sizeof p; /* { dg-warning "expression does not compute" 
"" { target { lp64 } } } */
   r += sizeof (arr) / (sizeof p);
   r += sizeof (arr) / (sizeof (p));
   r += sizeof (arr2) / sizeof p;
-  r += sizeof (arr2) / sizeof (int); /* { dg-warning "expression does not 
compute" } */
+  r += sizeof (arr2) / sizeof (int); /* { dg-warning "expression does not 
compute" "" { target { lp64 } } } */
   r += sizeof (arr2) / sizeof (int *);
   r += sizeof (arr2) / sizeof (short *);
   r += sizeof (arr) / sizeof (int);
diff --git a/gcc/testsuite/g++.dg/warn/Wsizeof-array-div2.C 
b/gcc/testsuite/g++.dg/warn/Wsizeof-array-div2.C
index 7962c23522c..66fe72ab6c9 100644
--- a/gcc/testsuite/g++.dg/warn/Wsizeof-array-div2.C
+++ b/gcc/testsuite/g++.dg/warn/Wsizeof-array-div2.C
@@ -1,5 +1,5 @@
 // PR c++/91741
-// { dg-do compile }
+// { dg-do compile { target { lp64 } } }
 // { dg-options "-Wall" }
 // From .
 

base-commit: 67f3791f7d133214b112bd831ff2876822c665d0
-- 
2.26.2



[PATCH] g++, libstdc++: implement __is_nothrow_{constructible, assignable}

2020-10-23 Thread Ville Voutilainen via Gcc-patches
Finishing testing on Linux-PPC64. Ok for trunk if tests pass?

2020-10-24  Ville Voutilainen  

gcc/c-family/ChangeLog:

Implement __is_nothrow_{constructible,assignable}
* c-common.c (__is_nothrow_assignable): New.
(__is_nothrow_constructible): Likewise.
* c-common.h (RID_IS_NOTHROW_ASSIGNABLE): New.
(RID_IS_NOTHROW_CONSTRUCTIBLE): Likewise.

gcc/cp/ChangeLog:

Implement __is_nothrow_{constructible,assignable}
   * cp-tree.h (CPTK_IS_NOTHROW_ASSIGNABLE): New.
(CPTK_IS_NOTHROW_CONSTRUCTIBLE): Likewise.
(is_nothrow_xible): Likewise.
* method.c (__is_nothrow_xible): New.
* parser.c (cp_parser_primary_expression): Handle the new RID_*.
(cp_parser_trait_expr): Likewise.
* semantics.c (trait_expr_value): Handle the new RID_*.
(finish_trait_expr): Likewise.

libstdc++-v3/ChangeLog:

Implement __is_nothrow_{constructible,assignable}
   * include/std/type_traits (__is_nt_constructible_impl): Remove.
(__is_nothrow_constructible_impl): Adjust.
(is_nothrow_default_constructible): Likewise.
(__is_nt_assignable_impl): Remove.
(__is_nothrow_assignable_impl): Adjust.
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index e16ca3894bc..098a36e4d67 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -527,6 +527,8 @@ const struct c_common_resword c_common_reswords[] =
   { "while",		RID_WHILE,	0 },
   { "__is_assignable", RID_IS_ASSIGNABLE, D_CXXONLY },
   { "__is_constructible", RID_IS_CONSTRUCTIBLE, D_CXXONLY },
+  { "__is_nothrow_assignable", RID_IS_NOTHROW_ASSIGNABLE, D_CXXONLY },
+  { "__is_nothrow_constructible", RID_IS_NOTHROW_CONSTRUCTIBLE, D_CXXONLY },
 
   /* C++ transactional memory.  */
   { "synchronized",	RID_SYNCHRONIZED, D_CXX_OBJC | D_TRANSMEM },
diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h
index 3d96092a297..24a4a8e7fe3 100644
--- a/gcc/c-family/c-common.h
+++ b/gcc/c-family/c-common.h
@@ -176,6 +176,7 @@ enum rid
   RID_IS_TRIVIALLY_COPYABLE,
   RID_IS_UNION,RID_UNDERLYING_TYPE,
   RID_IS_ASSIGNABLE,   RID_IS_CONSTRUCTIBLE,
+  RID_IS_NOTHROW_ASSIGNABLE,   RID_IS_NOTHROW_CONSTRUCTIBLE,
 
   /* C++11 */
   RID_CONSTEXPR, RID_DECLTYPE, RID_NOEXCEPT, RID_NULLPTR, RID_STATIC_ASSERT,
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 5c06ac3789e..1ce20989e13 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -1323,7 +1323,9 @@ enum cp_trait_kind
   CPTK_IS_UNION,
   CPTK_UNDERLYING_TYPE,
   CPTK_IS_ASSIGNABLE,
-  CPTK_IS_CONSTRUCTIBLE
+  CPTK_IS_CONSTRUCTIBLE,
+  CPTK_IS_NOTHROW_ASSIGNABLE,
+  CPTK_IS_NOTHROW_CONSTRUCTIBLE
 };
 
 /* The types that we are processing.  */
@@ -6752,6 +6754,7 @@ extern void use_thunk(tree, bool);
 extern bool trivial_fn_p			(tree);
 extern tree forward_parm			(tree);
 extern bool is_trivially_xible			(enum tree_code, tree, tree);
+extern bool is_nothrow_xible			(enum tree_code, tree, tree);
 extern bool is_xible(enum tree_code, tree, tree);
 extern tree get_defaulted_eh_spec		(tree, tsubst_flags_t = tf_warning_or_error);
 extern bool maybe_explain_implicit_delete	(tree);
diff --git a/gcc/cp/method.c b/gcc/cp/method.c
index 6e4c5f7e83b..2ffc86cbd81 100644
--- a/gcc/cp/method.c
+++ b/gcc/cp/method.c
@@ -1933,6 +1933,21 @@ is_trivially_xible (enum tree_code code, tree to, tree from)
   return !nt;
 }
 
+/* Returns true iff TO is nothrow assignable (if CODE is MODIFY_EXPR) or
+   constructible (otherwise) from FROM, which is a single type for
+   assignment or a list of types for construction.  */
+
+bool
+is_nothrow_xible (enum tree_code code, tree to, tree from)
+{
+  tree expr;
+  expr = is_xible_helper (code, to, from, /*trivial*/false);
+
+  if (expr == NULL_TREE || expr == error_mark_node)
+return false;
+  return expr_noexcept_p (expr, tf_none);
+}
+
 /* Returns true iff TO is assignable (if CODE is MODIFY_EXPR) or
constructible (otherwise) from FROM, which is a single type for
assignment or a list of types for construction.  */
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 7ec7d42773c..cce3d0a679e 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -5637,6 +5637,8 @@ cp_parser_primary_expression (cp_parser *parser,
 	case RID_IS_UNION:
 	case RID_IS_ASSIGNABLE:
 	case RID_IS_CONSTRUCTIBLE:
+	case RID_IS_NOTHROW_ASSIGNABLE:
+	case RID_IS_NOTHROW_CONSTRUCTIBLE:
 	  return cp_parser_trait_expr (parser, token->keyword);
 
 	// C++ concepts
@@ -10501,6 +10503,14 @@ cp_parser_trait_expr (cp_parser* parser, enum rid keyword)
   kind = CPTK_IS_CONSTRUCTIBLE;
   variadic = true;
   break;
+case RID_IS_NOTHROW_ASSIGNABLE:
+  kind = CPTK_IS_NOTHROW_ASSIGNABLE;
+  binary = true;
+  break;
+case RID_IS_NOTHROW_CONSTRUCTIBLE:
+  kind = CPTK_IS_NOTHROW_CONSTRUCTIBLE;
+  variadic = true;
+  break;
 default:
   gcc_unreachable ();
 }
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 1e42cd799c2..ac488478f36 100644
--- a/gcc/cp/semantics.c

Re: [PATCH] g++, libstdc++: implement __is_nothrow_{constructible, assignable}

2020-10-23 Thread Ville Voutilainen via Gcc-patches
On Sat, 24 Oct 2020 at 02:32, Ville Voutilainen
 wrote:
> * method.c (__is_nothrow_xible): New.

..and this is is_nothrow_xible, without leading underscores.


libgo patch committed: Merge upstream net/http/cgi changes

2020-10-23 Thread Ian Lance Taylor via Gcc-patches
This libgo patch by Nikhil Benesch updates the net/http/cgi package to
incorporate upstream modifications to the cgi package's set of rules
about which environment variables should be inherited by child
processes by default on each platform.  In particular this permits
tests to pass on NetBSD by preserving the value of the LD_LIBRARY_PATH
environment variable.

This is a partial backport of the following upstream CLs:

https://golang.org/cl/263802
https://golang.org/cl/263577
https://golang.org/cl/254740

Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.  Committed
to mainline.

Ian
e4b34e8508b6eab7b129a9ada549d2649b3152e9
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index 384ca6e8864..3ad6c9633f1 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-fa66bd11bbe58943e273cfa74356771c996f5b24
+28f3df468666787f83f94220312383a7c267a8ce
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
diff --git a/libgo/go/net/http/cgi/host.go b/libgo/go/net/http/cgi/host.go
index 863f40638ab..eff67caf4e6 100644
--- a/libgo/go/net/http/cgi/host.go
+++ b/libgo/go/net/http/cgi/host.go
@@ -37,15 +37,15 @@ var trailingPort = regexp.MustCompile(`:([0-9]+)$`)
 
 var osDefaultInheritEnv = func() []string {
switch runtime.GOOS {
-   case "darwin":
+   case "darwin", "ios":
return []string{"DYLD_LIBRARY_PATH"}
-   case "linux", "freebsd", "openbsd":
+   case "linux", "freebsd", "netbsd", "openbsd":
return []string{"LD_LIBRARY_PATH"}
case "hpux":
return []string{"LD_LIBRARY_PATH", "SHLIB_PATH"}
case "irix":
return []string{"LD_LIBRARY_PATH", "LD_LIBRARYN32_PATH", 
"LD_LIBRARY64_PATH"}
-   case "solaris":
+   case "illumos", "solaris":
return []string{"LD_LIBRARY_PATH", "LD_LIBRARY_PATH_32", 
"LD_LIBRARY_PATH_64"}
case "windows":
return []string{"SystemRoot", "COMSPEC", "PATHEXT", "WINDIR"}


Re: [PATCH] g++, libstdc++: implement __is_nothrow_{constructible, assignable}

2020-10-23 Thread Marek Polacek via Gcc-patches
On Sat, Oct 24, 2020 at 02:32:37AM +0300, Ville Voutilainen via Gcc-patches 
wrote:
> Finishing testing on Linux-PPC64. Ok for trunk if tests pass?
> 
> 2020-10-24  Ville Voutilainen  
> 
> gcc/c-family/ChangeLog:
> 
> Implement __is_nothrow_{constructible,assignable}
> * c-common.c (__is_nothrow_assignable): New.
> (__is_nothrow_constructible): Likewise.
> * c-common.h (RID_IS_NOTHROW_ASSIGNABLE): New.
> (RID_IS_NOTHROW_CONSTRUCTIBLE): Likewise.
> 
> gcc/cp/ChangeLog:
> 
> Implement __is_nothrow_{constructible,assignable}
>* cp-tree.h (CPTK_IS_NOTHROW_ASSIGNABLE): New.
> (CPTK_IS_NOTHROW_CONSTRUCTIBLE): Likewise.
> (is_nothrow_xible): Likewise.
> * method.c (__is_nothrow_xible): New.
> * parser.c (cp_parser_primary_expression): Handle the new RID_*.
> (cp_parser_trait_expr): Likewise.
> * semantics.c (trait_expr_value): Handle the new RID_*.
> (finish_trait_expr): Likewise.
> 
> libstdc++-v3/ChangeLog:
> 
> Implement __is_nothrow_{constructible,assignable}
>* include/std/type_traits (__is_nt_constructible_impl): Remove.
> (__is_nothrow_constructible_impl): Adjust.
> (is_nothrow_default_constructible): Likewise.
> (__is_nt_assignable_impl): Remove.
> (__is_nothrow_assignable_impl): Adjust.

> diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
> index e16ca3894bc..098a36e4d67 100644
> --- a/gcc/c-family/c-common.c
> +++ b/gcc/c-family/c-common.c
> @@ -527,6 +527,8 @@ const struct c_common_resword c_common_reswords[] =
>{ "while", RID_WHILE,  0 },
>{ "__is_assignable", RID_IS_ASSIGNABLE, D_CXXONLY },
>{ "__is_constructible", RID_IS_CONSTRUCTIBLE, D_CXXONLY },
> +  { "__is_nothrow_assignable", RID_IS_NOTHROW_ASSIGNABLE, D_CXXONLY },
> +  { "__is_nothrow_constructible", RID_IS_NOTHROW_CONSTRUCTIBLE, D_CXXONLY },
>  
>/* C++ transactional memory.  */
>{ "synchronized",  RID_SYNCHRONIZED, D_CXX_OBJC | D_TRANSMEM },
> diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h
> index 3d96092a297..24a4a8e7fe3 100644
> --- a/gcc/c-family/c-common.h
> +++ b/gcc/c-family/c-common.h
> @@ -176,6 +176,7 @@ enum rid
>RID_IS_TRIVIALLY_COPYABLE,
>RID_IS_UNION,RID_UNDERLYING_TYPE,
>RID_IS_ASSIGNABLE,   RID_IS_CONSTRUCTIBLE,
> +  RID_IS_NOTHROW_ASSIGNABLE,   RID_IS_NOTHROW_CONSTRUCTIBLE,
>  
>/* C++11 */
>RID_CONSTEXPR, RID_DECLTYPE, RID_NOEXCEPT, RID_NULLPTR, RID_STATIC_ASSERT,
> diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
> index 5c06ac3789e..1ce20989e13 100644
> --- a/gcc/cp/cp-tree.h
> +++ b/gcc/cp/cp-tree.h
> @@ -1323,7 +1323,9 @@ enum cp_trait_kind
>CPTK_IS_UNION,
>CPTK_UNDERLYING_TYPE,
>CPTK_IS_ASSIGNABLE,
> -  CPTK_IS_CONSTRUCTIBLE
> +  CPTK_IS_CONSTRUCTIBLE,
> +  CPTK_IS_NOTHROW_ASSIGNABLE,
> +  CPTK_IS_NOTHROW_CONSTRUCTIBLE
>  };
>  
>  /* The types that we are processing.  */
> @@ -6752,6 +6754,7 @@ extern void use_thunk   (tree, 
> bool);
>  extern bool trivial_fn_p (tree);
>  extern tree forward_parm (tree);
>  extern bool is_trivially_xible   (enum tree_code, tree, 
> tree);
> +extern bool is_nothrow_xible (enum tree_code, tree, tree);
>  extern bool is_xible (enum tree_code, tree, tree);
>  extern tree get_defaulted_eh_spec(tree, tsubst_flags_t = 
> tf_warning_or_error);
>  extern bool maybe_explain_implicit_delete(tree);
> diff --git a/gcc/cp/method.c b/gcc/cp/method.c
> index 6e4c5f7e83b..2ffc86cbd81 100644
> --- a/gcc/cp/method.c
> +++ b/gcc/cp/method.c
> @@ -1933,6 +1933,21 @@ is_trivially_xible (enum tree_code code, tree to, tree 
> from)
>return !nt;
>  }
>  
> +/* Returns true iff TO is nothrow assignable (if CODE is MODIFY_EXPR) or
> +   constructible (otherwise) from FROM, which is a single type for
> +   assignment or a list of types for construction.  */
> +
> +bool
> +is_nothrow_xible (enum tree_code code, tree to, tree from)
> +{
> +  tree expr;
> +  expr = is_xible_helper (code, to, from, /*trivial*/false);

  tree expr = is_xible_helper (code, to, from, /*trivial*/false);

would be nicer, otherwise the front-end changes look fine, thanks.

Marek



Re: [PATCH] g++, libstdc++: implement __is_nothrow_{constructible, assignable}

2020-10-23 Thread Ville Voutilainen via Gcc-patches
On Sat, 24 Oct 2020 at 03:00, Marek Polacek  wrote:
> > +  tree expr;
> > +  expr = is_xible_helper (code, to, from, /*trivial*/false);
>
>   tree expr = is_xible_helper (code, to, from, /*trivial*/false);
>
> would be nicer, otherwise the front-end changes look fine, thanks.

Ha, we have the same thing in is_trivially_xible, so I'll drive-by
change that one as well.


Re: [PATCH v2] c++: Fix verify_ctor_sanity ICE [PR96241]

2020-10-23 Thread Marek Polacek via Gcc-patches
On Thu, Oct 22, 2020 at 05:37:06PM -0400, Jason Merrill via Gcc-patches wrote:
> On 10/15/20 6:18 PM, Marek Polacek wrote:
> > The code added in r10-6437 caused us to create a CONSTRUCTOR when we're
> > {}-initializing an aggregate.  Then we pass this new CONSTRUCTOR down to
> > cxx_eval_constant_expression which, if the CONSTRUCTOR isn't TREE_CONSTANT
> > or reduced_constant_expression_p, calls cxx_eval_bare_aggregate.  In
> > this case the CONSTRUCTOR wasn't reduced_constant_expression_p because
> > for r_c_e_p a CONST_DECL isn't good enough so it returns false.  So we
> > go to cxx_eval_bare_aggregate where we crash, because ctx->ctor wasn't
> > set up properly.  So my fix is to do so.  Since we're value-initializing,
> > I'm not setting CONSTRUCTOR_NO_CLEARING.
> > 
> > Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk/10?
> > 
> > gcc/cp/ChangeLog:
> > 
> > PR c++/96241
> > * constexpr.c (cxx_eval_array_reference): Set up ctx->ctor if we
> > are initializing an aggregate.
> > 
> > gcc/testsuite/ChangeLog:
> > 
> > PR c++/96241
> > * g++.dg/cpp1y/constexpr-96241.C: New test.
> > ---
> >   gcc/cp/constexpr.c   |  4 ++
> >   gcc/testsuite/g++.dg/cpp1y/constexpr-96241.C | 47 
> >   2 files changed, 51 insertions(+)
> >   create mode 100644 gcc/testsuite/g++.dg/cpp1y/constexpr-96241.C
> > 
> > diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
> > index a118f8a810b..5193047670c 100644
> > --- a/gcc/cp/constexpr.c
> > +++ b/gcc/cp/constexpr.c
> > @@ -3657,10 +3657,14 @@ cxx_eval_array_reference (const constexpr_ctx *ctx, 
> > tree t,
> >initializer, it's initialized from {}.  But use build_value_init
> >directly for non-aggregates to avoid creating a garbage CONSTRUCTOR. 
> >  */
> > tree val;
> > +  constexpr_ctx new_ctx;
> > if (CP_AGGREGATE_TYPE_P (elem_type))
> >   {
> > tree empty_ctor = build_constructor (init_list_type_node, NULL);
> > val = digest_init (elem_type, empty_ctor, tf_warning_or_error);
> > +  new_ctx = *ctx;
> > +  new_ctx.ctor = build_constructor (elem_type, NULL);
> > +  ctx = &new_ctx;
> 
> In the case that 'val' is reduced_constant_expression_p, this results in a
> garbage constructor.  Let's try to free the new CONSTRUCTOR if it isn't
> returned from cxx_eval_constant_expression.

Good point indeed.  Here's a patch with that fixed.  A new test is included;
it's something that crashed when I freed the wrong CONSTRUCTOR, but our
testsuite didn't catch it.

Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?

-- >8 --
The code added in r10-6437 caused us to create a CONSTRUCTOR when we're
{}-initializing an aggregate.  Then we pass this new CONSTRUCTOR down to
cxx_eval_constant_expression which, if the CONSTRUCTOR isn't TREE_CONSTANT
or reduced_constant_expression_p, calls cxx_eval_bare_aggregate.  In
this case the CONSTRUCTOR wasn't reduced_constant_expression_p because
for r_c_e_p a CONST_DECL isn't good enough so it returns false.  So we
go to cxx_eval_bare_aggregate where we crash, because ctx->ctor wasn't
set up properly.  So my fix is to do so.  Since we're value-initializing,
I'm not setting CONSTRUCTOR_NO_CLEARING.  To avoid keeping a garbage
constructor around, I call free_constructor in case the evaluation did
not use it.

gcc/cp/ChangeLog:

PR c++/96241
* constexpr.c (cxx_eval_array_reference): Set up ctx->ctor if we
are initializing an aggregate.  Call free_constructor on the new
CONSTRUCTOR if it isn't returned from cxx_eval_constant_expression.

gcc/testsuite/ChangeLog:

PR c++/96241
* g++.dg/cpp0x/constexpr-96241.C: New test.
* g++.dg/cpp1y/constexpr-96241.C: New test.
---
 gcc/cp/constexpr.c   | 11 -
 gcc/testsuite/g++.dg/cpp0x/constexpr-96241.C | 18 
 gcc/testsuite/g++.dg/cpp1y/constexpr-96241.C | 47 
 3 files changed, 74 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/cpp0x/constexpr-96241.C
 create mode 100644 gcc/testsuite/g++.dg/cpp1y/constexpr-96241.C

diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index 4707d29f3bc..7ebdd308dcd 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -3657,15 +3657,22 @@ cxx_eval_array_reference (const constexpr_ctx *ctx, 
tree t,
  initializer, it's initialized from {}.  But use build_value_init
  directly for non-aggregates to avoid creating a garbage CONSTRUCTOR.  */
   tree val;
+  constexpr_ctx new_ctx;
   if (CP_AGGREGATE_TYPE_P (elem_type))
 {
   tree empty_ctor = build_constructor (init_list_type_node, NULL);
   val = digest_init (elem_type, empty_ctor, tf_warning_or_error);
+  new_ctx = *ctx;
+  new_ctx.ctor = build_constructor (elem_type, NULL);
+  ctx = &new_ctx;
 }
   else
 val = build_value_init (elem_type, tf_warning_or_error);
-  return cxx_eval_constant_expression (ctx, val, lval, non_constant_p

Re: [PATCH] g++, libstdc++: implement __is_nothrow_{constructible, assignable}

2020-10-23 Thread Marek Polacek via Gcc-patches
On Sat, Oct 24, 2020 at 03:03:51AM +0300, Ville Voutilainen via Gcc-patches 
wrote:
> On Sat, 24 Oct 2020 at 03:00, Marek Polacek  wrote:
> > > +  tree expr;
> > > +  expr = is_xible_helper (code, to, from, /*trivial*/false);
> >
> >   tree expr = is_xible_helper (code, to, from, /*trivial*/false);
> >
> > would be nicer, otherwise the front-end changes look fine, thanks.
> 
> Ha, we have the same thing in is_trivially_xible, so I'll drive-by
> change that one as well.

Please.  Thanks!

Marek



Re: [PATCH] g++, libstdc++: implement __is_nothrow_{constructible, assignable}

2020-10-23 Thread Ville Voutilainen via Gcc-patches
On Sat, 24 Oct 2020 at 03:07, Marek Polacek  wrote:
> > Ha, we have the same thing in is_trivially_xible, so I'll drive-by
> > change that one as well.
>
> Please.  Thanks!

The tree is also on a separated line in is_trivially_xible and
is_nothrow_xible, but not
in is_xible. What do we think about line-whitespace changes mixed with
'real' changes?


[PATCH] [tree-optimization] Fix for PR97223

2020-10-23 Thread Eugene Rozenfeld via Gcc-patches
This patch adds a pattern for folding 
x < (short) ((unsigned short)x + const)
to
 x <= SHORT_MAX - const
(and similarly for other integral types) if const is not 0.
as described in PR97223.

For example, without this patch the x86_64-pc-linux code generated for this 
function

bool f(char x)
{
return x < (char)(x + 12);
}

is

leaeax,[rdi+0xc]
cmpal,dil
setg   al
ret  

With the patch the code is 

cmpdil,0x73
setle  al
ret

Tested on x86_64-pc-linux.

Eugene



0001-Add-a-tree-optimization-described-in-PR97223.patch
Description: 0001-Add-a-tree-optimization-described-in-PR97223.patch


Re: [RS6000] Adjust testcases for power10 instructions

2020-10-23 Thread Alan Modra via Gcc-patches
On Fri, Oct 23, 2020 at 01:22:31PM -0500, Segher Boessenkool wrote:
> On Fri, Oct 23, 2020 at 04:45:29PM +1030, Alan Modra wrote:
> > Revised patch, removing changes to
> > gcc.target/powerpc/fold-vec-st-double.c,
> > gcc.target/powerpc/fold-vec-st-longlong.c,
> > gcc.target/powerpc/fold-vec-st-pixel.c.  Fixing fails on those three
> > tests will be the subject of another patch.
> 
> Okido.
> 
> > Most of these changes are fairly obvious.  Duplicated setbcr in
> > +/* { dg-final { scan-assembler-times {\maddic\M|\msetbcr\M} 4 } } */
> > +/* { dg-final { scan-assembler-times {\msubfe\M|\msetbcr\M} 1 } } */
> > is due to addic;subfe being replaced in one function with setbcr.
> 
> But that won't really work.  If there is more than one addic replaced by
> setbcr, that second scan fails (because it matches at least two times
> then).

Sure it works.  I did test the patch!  If future code gen changes, the
test will need updating at that point.  scan-assembler tests require
maintenance..

> > * gcc.dg/pr56727-2.c,
> ...
> > * gcc.target/powerpc/ppc-eq0-1.c,
> > * gcc.target/powerpc/ppc-ne0-1.c,
> > * gcc.target/powerpc/pr86731-fwrapv-longlong.c: Match power10 insns.
> 
> This should all be behind only one "*" (so delete it on all but the
> first line here).

Huh, ok.

> > --- a/gcc/testsuite/gcc.dg/vect/costmodel/ppc/costmodel-bb-slp-9a-pr63175.c
> > +++ b/gcc/testsuite/gcc.dg/vect/costmodel/ppc/costmodel-bb-slp-9a-pr63175.c
> > @@ -25,6 +25,6 @@ main1 (void)
> > with no word loads (lw, lwu, lwz, lwzu, or their indexed forms)
> > or word stores (stw, stwu, stwx, stwux, or their indexed forms).  */
> >  
> > -/* { dg-final { scan-assembler "\t(lvx|lxv|lvsr|stxv)" } } */
> > +/* { dg-final { scan-assembler "\t(lvx|lxv|lvsr|stxv|plxv|pstxv)" } } */
> 
> /* { dg-final { scan-assembler "\t(lvx|p?lxv|lvsr|p?stxv)" } } */
> might be more readable/maintainable/extensible?

OK.

> > --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-load-builtin_vec_xl-char.c
> > +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-load-builtin_vec_xl-char.c
> > @@ -36,4 +36,4 @@ BUILD_VAR_TEST( test10, vector unsigned char, signed long 
> > long, vector unsigned
> >  BUILD_VAR_TEST( test11, vector unsigned char, signed int, vector unsigned 
> > char);
> >  BUILD_CST_TEST( test12, vector unsigned char, 8, vector unsigned char);
> >  
> > -/* { dg-final { scan-assembler-times 
> > {\mlxvw4x\M|\mlxvd2x\M|\mlxvx\M|\mlvx\M} 12 } } */
> > +/* { dg-final { scan-assembler-times 
> > {\mlxvw4x\M|\mlxvd2x\M|\mlxvx\M|\mlvx\M|\mplxv\M} 12 } } */
> 
> Here, it did not allow lxv before.  Should it?
> 
> (in many files)

We don't generate lxv due to the insn only supporting DQ offsets.  For
example, on power9 test3_cst from this test is
li 9,2
lxvx 34,3,9
blr
On power10
plxv 34,2(3)
blr

> Have you verified the p10 code generation actually makes sense?

Yes, I did.

> > --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-splat-longlong.c
> > +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-splat-longlong.c
> > @@ -25,7 +25,7 @@ vector signed long long test_sll () { const vector signed 
> > long long y = {34, 45}
> >  vector unsigned long long test_ull () { const vector unsigned long long y 
> > = {56, 67}; return vec_splat (y, 0b00010); }
> >  
> >  /* Assorted load instructions for the initialization with known constants. 
> > */
> > -/* { dg-final { scan-assembler-times {\mlvx\M|\mlxvd2x\M|\mlxv\M} 3 } } */
> > +/* { dg-final { scan-assembler-times 
> > {\mlvx\M|\mlxvd2x\M|\mlxv\M|\mplxv\M|\mplxv\M} 3 } } */
> 
> You have plxv twice here.

Oops.

> > --- a/gcc/testsuite/gcc.target/powerpc/fold-vec-store-builtin_vec_xst-char.c
> > +++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-store-builtin_vec_xst-char.c
> > @@ -36,4 +36,4 @@ BUILD_VAR_TEST( test10,  vector unsigned char, signed 
> > long long, vector unsigned
> >  BUILD_VAR_TEST( test11,  vector unsigned char, signed int, vector unsigned 
> > char );
> >  BUILD_CST_TEST( test12,  vector unsigned char, 12, vector unsigned char );
> >  
> > -/* { dg-final { scan-assembler-times 
> > {\mstxvw4x\M|\mstxvd2x\M|\mstxvx\M|\mstvx\M} 12 } } */
> > +/* { dg-final { scan-assembler-times 
> > {\mstxvw4x\M|\mstxvd2x\M|\mstxvx\M|\mstvx\M|\mpstxv\M} 12 } } */
> 
> Similarly, should it have plain stxv as well?

No.  Same reason as to why lxv isn't generated.

> > --- a/gcc/testsuite/gcc.target/powerpc/lvsl-lvsr.c
> > +++ b/gcc/testsuite/gcc.target/powerpc/lvsl-lvsr.c
> > @@ -1,12 +1,10 @@
> > -/* Test expected code generation for lvsl and lvsr on little endian.
> > -   Note that lvsl and lvsr are each produced once, but the filename
> > -   causes them to appear twice in the file.  */
> > +/* Test expected code generation for lvsl and lvsr on little endian.  */
> >  
> >  /* { dg-do compile { target { powerpc64le-*-* } } } */
> >  /* { dg-options "-O0 -Wno-deprecated" } */
> > -/* { dg-final { scan-assembler-times "lvsl" 2 } } */
> > -/* { dg-final { scan-assembl

Re: [PATCH 2/8] [RS6000] rs6000_rtx_costs for AND

2020-10-23 Thread Alan Modra via Gcc-patches
On Fri, Oct 23, 2020 at 07:18:44PM -0400, Hans-Peter Nilsson wrote:
> On Thu, 22 Oct 2020, Alan Modra via Gcc-patches wrote:
> >   /* (reg) is costed at zero by rtlanal.c:rtx_cost.  That sets a
> >  baseline for rtx costs:  If a constant is valid in an insn,
> >  it is free.  */
> 
> >From where is this quote?  My "git grep" fails to find it for me
> (on master).  It seems like a port-specific commment so I'd
> have expected to find it somewhere in config/rs6000.

It's in a patch in the rs6000_rtx_costs series that hasn't yet been
committed.
https://gcc.gnu.org/pipermail/gcc-patches/2020-October/555757.html

-- 
Alan Modra
Australia Development Lab, IBM


Re: [PATCH] c++: Implement -Wvexing-parse [PR25814]

2020-10-23 Thread Jason Merrill via Gcc-patches

On 10/23/20 3:01 PM, Marek Polacek wrote:

This patch implements the -Wvexing-parse warning to warn about the
sneaky most vexing parse rule in C++: the cases when a declaration
looks like a variable definition, but the C++ language requires it
to be interpreted as a function declaration.  This warning is on by
default (like clang++).  From the docs:

   void f(double a) {
 int i();// extern int i (void);
 int n(int(a));  // extern int n (int);
   }

   Another example:

   struct S { S(int); };
   void f(double a) {
 S x(int(a));   // extern struct S x (int);
 S y(int());// extern struct S y (int (*) (void));
 S z(); // extern struct S z (void);
   }

You can find more on this in [dcl.ambig.res].

I spent a fair amount of time on fix-it hints so that GCC can recommend
various ways to resolve such an ambiguity.  Sometimes that's tricky.
E.g., suggesting default-initialization when the class doesn't have
a default constructor would not be optimal.  Suggesting {}-init is also
not trivial because it can use an initializer-list constructor if no
default constructor is available (which ()-init wouldn't do).  And of
course, pre-C++11, we shouldn't be recommending {}-init at all.


What do you think of, instead of passing the type down into the 
declarator parse, adding the paren locations to cp_declarator::function 
and giving the diagnostic from cp_parser_init_declarator instead?



I also uncovered a bug in cp_parser_declarator, where we were setting
*parenthesized_p to true despite the comment saying the exact opposite.

Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?

gcc/c-family/ChangeLog:

PR c++/25814
* c.opt (Wvexing-parse): New option.

gcc/cp/ChangeLog:

PR c++/25814
* parser.c (cp_parser_init_declarator): Maybe set warn_ambig_parse.
Pass it to cp_parser_declarator.
(cp_parser_declarator): Add a tree parameter with a default
value.  Set *parenthesized_p to false rather than to true.  Pass
warn_ambig_parse to cp_parser_direct_declarator.
(warn_about_ambiguous_parse): New function.
(cp_parser_direct_declarator): Add a tree parameter with a default
value.  Have cp_parser_parameter_declaration_clause set a flag
if it encountered a vexing parse.  Call warn_about_ambiguous_parse
if desirable.
(cp_parser_parameter_declaration_clause): New bool * parameter
with a default value.  Set it.  Pass it to
cp_parser_parameter_declaration_list.
(cp_parser_parameter_declaration_list): New bool * parameter.
Set it.
(cp_parser_cache_defarg): Adjust the call to
cp_parser_parameter_declaration_list.

gcc/ChangeLog:

PR c++/25814
* doc/invoke.texi: Document -Wvexing-parse.

gcc/testsuite/ChangeLog:

PR c++/25814
* g++.dg/cpp2a/fn-template16.C: Add a dg-warning.
* g++.dg/cpp2a/fn-template7.C: Likewise.
* g++.dg/lookup/pr80891-5.C: Likewise.
* g++.dg/lto/pr79050_0.C: Add extern.
* g++.dg/lto/pr84805_0.C: Likewise.
* g++.dg/parse/pr58898.C: Add a dg-warning.
* g++.dg/template/scope5.C: Likewise.
* g++.old-deja/g++.brendan/recurse.C: Likewise.
* g++.old-deja/g++.jason/template4.C: Likewise.
* g++.old-deja/g++.law/arm4.C: Likewise.
* g++.old-deja/g++.mike/for2.C: Likewise.
* g++.old-deja/g++.other/local4.C: Likewise.
* g++.old-deja/g++.pt/crash3.C: Likewise.
* g++.dg/warn/Wvexing-parse.C: New test.
* g++.dg/warn/Wvexing-parse2.C: New test.
* g++.dg/warn/Wvexing-parse3.C: New test.
* g++.dg/warn/Wvexing-parse4.C: New test.
* g++.dg/warn/Wvexing-parse5.C: New test.
* g++.dg/warn/Wvexing-parse6.C: New test.

libstdc++-v3/ChangeLog:

PR c++/25814
* testsuite/20_util/reference_wrapper/lwg2993.cc: Add a dg-warning.
* testsuite/25_algorithms/generate_n/87982_neg.cc: Likewise.
---
  gcc/c-family/c.opt|   4 +
  gcc/cp/parser.c   | 176 +++---
  gcc/doc/invoke.texi   |  34 +++-
  gcc/testsuite/g++.dg/cpp2a/fn-template16.C|   2 +-
  gcc/testsuite/g++.dg/cpp2a/fn-template7.C |   2 +-
  gcc/testsuite/g++.dg/lookup/pr80891-5.C   |   2 +-
  gcc/testsuite/g++.dg/lto/pr79050_0.C  |   2 +-
  gcc/testsuite/g++.dg/lto/pr84805_0.C  |   2 +-
  gcc/testsuite/g++.dg/parse/pr58898.C  |   4 +-
  gcc/testsuite/g++.dg/template/scope5.C|   2 +-
  gcc/testsuite/g++.dg/warn/Wvexing-parse.C | 110 +++
  gcc/testsuite/g++.dg/warn/Wvexing-parse2.C|  24 +++
  gcc/testsuite/g++.dg/warn/Wvexing-parse3.C| 129 +
  gcc/testsuite/g++.dg/warn/Wvexing-parse4.C|  74 
  gcc/testsuite/g++.dg/warn/Wvexing-parse5.C|  14 ++
  gcc/testsuite/g++.dg/warn/Wvexing-parse6.C|  24 +++
  .../g++.ol

Re: [PATCH v2] c++: Fix verify_ctor_sanity ICE [PR96241]

2020-10-23 Thread Jason Merrill via Gcc-patches

On 10/23/20 8:06 PM, Marek Polacek wrote:

On Thu, Oct 22, 2020 at 05:37:06PM -0400, Jason Merrill via Gcc-patches wrote:

On 10/15/20 6:18 PM, Marek Polacek wrote:

The code added in r10-6437 caused us to create a CONSTRUCTOR when we're
{}-initializing an aggregate.  Then we pass this new CONSTRUCTOR down to
cxx_eval_constant_expression which, if the CONSTRUCTOR isn't TREE_CONSTANT
or reduced_constant_expression_p, calls cxx_eval_bare_aggregate.  In
this case the CONSTRUCTOR wasn't reduced_constant_expression_p because
for r_c_e_p a CONST_DECL isn't good enough so it returns false.  So we
go to cxx_eval_bare_aggregate where we crash, because ctx->ctor wasn't
set up properly.  So my fix is to do so.  Since we're value-initializing,
I'm not setting CONSTRUCTOR_NO_CLEARING.

Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk/10?

gcc/cp/ChangeLog:

PR c++/96241
* constexpr.c (cxx_eval_array_reference): Set up ctx->ctor if we
are initializing an aggregate.

gcc/testsuite/ChangeLog:

PR c++/96241
* g++.dg/cpp1y/constexpr-96241.C: New test.
---
   gcc/cp/constexpr.c   |  4 ++
   gcc/testsuite/g++.dg/cpp1y/constexpr-96241.C | 47 
   2 files changed, 51 insertions(+)
   create mode 100644 gcc/testsuite/g++.dg/cpp1y/constexpr-96241.C

diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index a118f8a810b..5193047670c 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -3657,10 +3657,14 @@ cxx_eval_array_reference (const constexpr_ctx *ctx, 
tree t,
initializer, it's initialized from {}.  But use build_value_init
directly for non-aggregates to avoid creating a garbage CONSTRUCTOR.  */
 tree val;
+  constexpr_ctx new_ctx;
 if (CP_AGGREGATE_TYPE_P (elem_type))
   {
 tree empty_ctor = build_constructor (init_list_type_node, NULL);
 val = digest_init (elem_type, empty_ctor, tf_warning_or_error);
+  new_ctx = *ctx;
+  new_ctx.ctor = build_constructor (elem_type, NULL);
+  ctx = &new_ctx;


In the case that 'val' is reduced_constant_expression_p, this results in a
garbage constructor.  Let's try to free the new CONSTRUCTOR if it isn't
returned from cxx_eval_constant_expression.


Good point indeed.  Here's a patch with that fixed.  A new test is included;
it's something that crashed when I freed the wrong CONSTRUCTOR, but our
testsuite didn't catch it.

Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?


OK.


-- >8 --
The code added in r10-6437 caused us to create a CONSTRUCTOR when we're
{}-initializing an aggregate.  Then we pass this new CONSTRUCTOR down to
cxx_eval_constant_expression which, if the CONSTRUCTOR isn't TREE_CONSTANT
or reduced_constant_expression_p, calls cxx_eval_bare_aggregate.  In
this case the CONSTRUCTOR wasn't reduced_constant_expression_p because
for r_c_e_p a CONST_DECL isn't good enough so it returns false.  So we
go to cxx_eval_bare_aggregate where we crash, because ctx->ctor wasn't
set up properly.  So my fix is to do so.  Since we're value-initializing,
I'm not setting CONSTRUCTOR_NO_CLEARING.  To avoid keeping a garbage
constructor around, I call free_constructor in case the evaluation did
not use it.

gcc/cp/ChangeLog:

PR c++/96241
* constexpr.c (cxx_eval_array_reference): Set up ctx->ctor if we
are initializing an aggregate.  Call free_constructor on the new
CONSTRUCTOR if it isn't returned from cxx_eval_constant_expression.

gcc/testsuite/ChangeLog:

PR c++/96241
* g++.dg/cpp0x/constexpr-96241.C: New test.
* g++.dg/cpp1y/constexpr-96241.C: New test.
---
  gcc/cp/constexpr.c   | 11 -
  gcc/testsuite/g++.dg/cpp0x/constexpr-96241.C | 18 
  gcc/testsuite/g++.dg/cpp1y/constexpr-96241.C | 47 
  3 files changed, 74 insertions(+), 2 deletions(-)
  create mode 100644 gcc/testsuite/g++.dg/cpp0x/constexpr-96241.C
  create mode 100644 gcc/testsuite/g++.dg/cpp1y/constexpr-96241.C

diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index 4707d29f3bc..7ebdd308dcd 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -3657,15 +3657,22 @@ cxx_eval_array_reference (const constexpr_ctx *ctx, 
tree t,
   initializer, it's initialized from {}.  But use build_value_init
   directly for non-aggregates to avoid creating a garbage CONSTRUCTOR.  */
tree val;
+  constexpr_ctx new_ctx;
if (CP_AGGREGATE_TYPE_P (elem_type))
  {
tree empty_ctor = build_constructor (init_list_type_node, NULL);
val = digest_init (elem_type, empty_ctor, tf_warning_or_error);
+  new_ctx = *ctx;
+  new_ctx.ctor = build_constructor (elem_type, NULL);
+  ctx = &new_ctx;
  }
else
  val = build_value_init (elem_type, tf_warning_or_error);
-  return cxx_eval_constant_expression (ctx, val, lval, non_constant_p,
-  overflow_p);
+  t = cxx_eval_constant_expression (ct

Re: [PATCH] g++, libstdc++: implement __is_nothrow_{constructible, assignable}

2020-10-23 Thread Jason Merrill via Gcc-patches

On 10/23/20 8:03 PM, Ville Voutilainen wrote:

On Sat, 24 Oct 2020 at 03:00, Marek Polacek  wrote:

+  tree expr;
+  expr = is_xible_helper (code, to, from, /*trivial*/false);


   tree expr = is_xible_helper (code, to, from, /*trivial*/false);

would be nicer, otherwise the front-end changes look fine, thanks.


Ha, we have the same thing in is_trivially_xible, so I'll drive-by
change that one as well.


OK with that change.

Jason




[PATCH] rs6000, Add bcd builtings listed in appendix B of the ABI

2020-10-23 Thread Carl Love via Gcc-patches


Gcc maintainers:

The following patch adds support for the built-ins listed in Table B.1,
"Binary-Coded Decimal Built-In Functions" of the "64-Bit ELF V2 ABI
Specification", July 30, 2019.

The built-ins adds support the V16QI type for addition, subtraction and
comparison as sepcified in the Table B.1.  Note, the V1TI type was
previously supported for add, subtract and comparison.  The builtins
for test for valid value, multiply by 10, divide by 10 and conversion
to DFP value are also added for the V16QI type as specified in Table
B.1.

The patch includes adding the #include  to the existing bcd-
2.c and bcd-3.c tests so they will pass the regression tests as the
builtins names are now listed in altivec.h rather then just using
internal names.

The patch was compiled and tested on:

  powerpc64le-unknown-linux-gnu (Power 9 LE)

with no regressions. 

Please let me know if this patch is acceptable for mainline.  Thanks.

Carl Love
--

gcc/ChangeLog

2020-10-22  Carl Love  

* config/rs6000/altivec.h (__builtin_bcdadd, __builtin_bcdadd_lt,
__builtin_bcdadd_eq, __builtin_bcdadd_gt, __builtin_bcdadd_ofl,
__builtin_bcdadd_ov, __builtin_bcdsub, __builtin_bcdsub_lt,
__builtin_bcdsub_eq, __builtin_bcdsub_gt, __builtin_bcdsub_ofl,
__builtin_bcdsub_ov, __builtin_bcdinvalid, __builtin_bcdmul10,
__builtin_bcddiv10, __builtin_bcd2dfp, __builtin_bcdcmpeq,
__builtin_bcdcmpgt, __builtin_bcdcmplt, __builtin_bcdcmpge,
__builtin_bcdcmple): Add defines.
* config/rs6000/altivec.md: Add UNSPEC_BCDSHIFT.
(BCD_TEST): Add le, ge to code iterator.
Add VBCD mode iterator.
(bcd_test, *bcd_test2,
bcd_, bcd_): Add mode to name.
Change iterator from V1TI to VBCD.
(*bcdinvalid_, bcdshift_v16qi): New define_insn.
(bcdinvalid_, bcdmul10_v16qi, bcddiv10_v16qi): New define.
config/rs6000/dfp.md (dfp_denbcd_v16qi_inst): New define_insn.
(dfp_denbcd_v16qi): New define_expand.
* confit/rs6000/rs6000-builtin.def (BU_P8V_MISC_1): New define.
(BCDADD): Replaced with BCDADD_V1TI and BCDADD_V16QI.
(BCDADD_LT): Replaced with BCDADD_LT_V1TI and BCDADD_LT_V16QI.
(BCDADD_EQ): Replaced with BCDADD_EQ_V1TI and BCDADD_EQ_V16QI.
(BCDADD_GT): Replaced with BCDADD_GT_V1TI and BCDADD_GT_V16QI.
(BCDADD_OV): Replaced with BCDADD_OV_V1TI and BCDADD_OV_V16QI.
(BCDSUB_V1TI, BCDSUB_V16QI, BCDSUB_LT_V1TI, BCDSUB_LT_V16QI,
BCDSUB_LE_V1TI, BCDSUB_LE_V16QI, BCDSUB_EQ_V1TI, BCDSUB_EQ_V16QI,
BCDSUB_GT_V1TI, BCDSUB_GT_V16QI, BCDSUB_GE_V1TI, BCDSUB_GE_V16QI,
BCDSUB_OV_V1TI, BCDSUB_OV_V16QI, BCDINVALID_V1TI, BCDINVALID_V16QI,
BCDMUL10_V16QI, BCDDIV10_V16QI, DENBCD_V16QI): New builtin definitions.
(BCDADD, BCDADD_LT, BCDADD_EQ, BCDADD_GT, BCDADD_OV, BCDSUB, BCDSUB_LT,
BCDSUB_LE, BCDSUB_EQ, BCDSUB_GT, BCDSUB_GE, BCDSUB_OV, BCDINVALID,
BCDMUL10, BCDDIV10, DENBCD): New overload definitions.
config/rs6000/rs6000-call.c (P8V_BUILTIN_VEC_BCDADD, 
P8V_BUILTIN_VEC_BCDADD_LT,
P8V_BUILTIN_VEC_BCDADD_EQ, P8V_BUILTIN_VEC_BCDADD_GT, 
P8V_BUILTIN_VEC_BCDADD_OV,
P8V_BUILTIN_VEC_BCDINVALID, P9V_BUILTIN_VEC_BCDMUL10, 
P8V_BUILTIN_VEC_DENBCD.
P8V_BUILTIN_VEC_BCDSUB, P8V_BUILTIN_VEC_BCDSUB_LT, 
P8V_BUILTIN_VEC_BCDSUB_LE,
P8V_BUILTIN_VEC_BCDSUB_EQ, P8V_BUILTIN_VEC_BCDSUB_GT, 
P8V_BUILTIN_VEC_BCDSUB_GE,
P8V_BUILTIN_VEC_BCDSUB_OV): New overloaded specifications.
(CODE_FOR_bcdadd): Replaced with CODE_FOR_bcdadd_v16qi and 
CODE_FOR_bcdadd_v1ti.
(CODE_FOR_bcdadd_lt): Replaced with CODE_FOR_bcdadd_lt_v16qi and 
CODE_FOR_bcdadd_lt_v1ti.
(CODE_FOR_bcdadd_eq): Replaced with CODE_FOR_bcdadd_eq_v16qi and 
CODE_FOR_bcdadd_eq_v1ti.
(CODE_FOR_bcdadd_gt): Replaced with CODE_FOR_bcdadd_gt_v16qi and 
CODE_FOR_bcdadd_gt_v1ti.
(CODE_FOR_bcdsub): Replaced with CODE_FOR_bcdsub_v16qi and 
CODE_FOR_bcdsub_v1ti.
(CODE_FOR_bcdsub_lt): Replaced with CODE_FOR_bcdsub_lt_v16qi and 
CODE_FOR_bcdsub_lt_v1ti.
(CODE_FOR_bcdsub_eq): Replaced with CODE_FOR_bcdsub_eq_v16qi and 
CODE_FOR_bcdsub_eq_v1ti.
(CODE_FOR_bcdsub_gt): Replaced with CODE_FOR_bcdsub_gt_v16qi and 
CODE_FOR_bcdsub_gt_v1ti.
(rs6000_expand_ternop_builtin):  Add CODE_FOR_dfp_denbcd_v16qi to else 
if.
* doc/extend.texi: Add documentation for new builtins.
* testsuite/gcc.target/powerpc/bcd-3.c: Add include altivec.h.
* testsuite/gcc.target/powerpc/bcd-4.c: New test.
---
 gcc/config/rs6000/altivec.h  |  25 ++
 gcc/config/rs6000/altivec.md | 104 -
 gcc/config/rs6000/dfp.md |  22 +
 gcc/config/rs6000/rs6000-builtin.def |  67 ++-
 gcc/config/rs6000/rs6000-call.c  | 103 -
 gcc/doc/extend.texi  |  13 +
 gcc/testsuite/gcc.target/powerpc/

Re: [RS6000] altivec style lvx/stvx addresses vs power10

2020-10-23 Thread Alan Modra via Gcc-patches
Hi Segher,

On Fri, Oct 23, 2020 at 11:31:02AM -0500, Segher Boessenkool wrote:
> On Fri, Oct 23, 2020 at 05:15:08PM +1030, Alan Modra wrote:
> > The problem starts with fwprop creating
> > (insn 9 4 0 2 (set (mem:V8HI (and:DI (plus:DI (reg/v/f:DI 121 [ vpp ])
> > (const_int 12 [0xc]))
> > (const_int -16 [0xfff0])) [0 MEM  > short int> [(void *)_4 & -16B]+0 S16 A128])
> > (reg/v:V8HI 120 [ vp1 ])) "pixel.c":6:10 1237 {vsx_movv8hi_64bit}
> > which is finally thrown out as invalid by lra.  lra of course does that
> > by reloading the entire address.
> 
> While it could/should just reload that 12 into a reg :-(  Could you
> investigate doing that?  Is there any reason we should not?

My first thought was to write the necessary reloads too, but 
I think it's better to not generate the invalid addressing in the
first place.  Hiding the +12 in an invalid memory address means it
isn't exposed to optimization passes.

-- 
Alan Modra
Australia Development Lab, IBM


  1   2   >