Re: [PATCH] Correct -fdump-go-spec's handling of incomplete types

2020-12-15 Thread Nikhil Benesch via Gcc-patches

On 12/14/20 10:48 PM, Nikhil Benesch wrote:

On 12/14/20 10:34 PM, Ian Lance Taylor wrote:

On Mon, Dec 14, 2020 at 7:14 PM Nikhil Benesch  wrote:

Also godump now emits a dummy `type _u?pad128_t struct {}` entry,
so we just suppress that and conditionally add it back.


I don't understand this bit.  Why are we seeing an empty struct
definition, and why is this change the right fix?

Is the problem that because we don't know how to emit the definition
of the struct, godump.c winds up emitting an empty definition?  That
doesn't sound like the right thing to do for this case.


That's a good question. u?pad128_t is clearly getting marked as a
potential dummy type. But then you'd think it'd *also* get marked as
an invalid type, and then find_dummy_types would suppress it.


I misunderstood how find_dummy_types worked. Here is a correct
description.

find_dummy_types will output a dummy type for an entry in
pot_dummy_types if:

  (1) we never observed a definition for that type name, or
  (2) we observed an invalid definition for that type name.

I don't actually understand why condition (2) is considered. Since
types that refer to invalid types are themselves marked as invalid,
godump will recursively comment out all types that refer even
transitively to an invalid dummy type. So it doesn't seem necessary to
emit a dummy type in condition (2).

Ian, you added this behavior way back in 2012:


https://github.com/gcc-mirror/gcc/commit/3eb9e389a6460b6bd9400a3f4acf88fb2e258e07

Perhaps you remember why?

If consensus is this behavior is wrong, I've attached a patch
(invalid-dummy.patch) that removes condition (2) from find_dummy_types
along with some new test cases. I don't have enough context to say
whether this patch is the right solution though.



Separately, I'm actually not sure why we're extracting _u?pad128_t from
gen-sysinfo.go at all. Nothing in libgo refers to those types. And no
types in [runtime_]sysinfo.go could refer to them either, because if
they did they'd *also* be marked as invalid (right?). So I suspect we
can just nuke those extractions from mk[r]sysinfo.sh. I've attached a
patch that does so (solaris-godump.patch). I'm still waiting on my
compile to complete, but initial signs look promising.

If this patch looks good, I'll submit it upstream tomorrow.

The nice thing about this approach, if it works, is that it works both
with and without the change to find_dummy_types, so we can consider
that patch independently.

Cheers,
Nikhil
diff --git a/gcc/godump.c b/gcc/godump.c
index ff3a4a9c52c..78ff22d5f13 100644
--- a/gcc/godump.c
+++ b/gcc/godump.c
@@ -1351,11 +1351,9 @@ find_dummy_types (const char *const &ptr, 
godump_container *adata)
   class godump_container *data = (class godump_container *) adata;
   const char *type = (const char *) ptr;
   void **slot;
-  void **islot;
 
   slot = htab_find_slot (data->type_hash, type, NO_INSERT);
-  islot = htab_find_slot (data->invalid_hash, type, NO_INSERT);
-  if (slot == NULL || islot != NULL)
+  if (slot == NULL)
 fprintf (go_dump_file, "type _%s struct {}\n", type);
   return true;
 }
diff --git a/gcc/testsuite/gcc.misc-tests/godump-1.c 
b/gcc/testsuite/gcc.misc-tests/godump-1.c
index d37ab0b5af4..e22fb6b8a80 100644
--- a/gcc/testsuite/gcc.misc-tests/godump-1.c
+++ b/gcc/testsuite/gcc.misc-tests/godump-1.c
@@ -304,6 +304,11 @@ long double ld_v1;
 ld_t ld_v2;
 /* { dg-final { scan-file godump-1.out "(?n)^// var _ld_v2 
INVALID-float-\[0-9\]*$" } } */
 
+typedef struct ld_s { long double ld_s_f; } ld_s_t;
+/* { dg-final { scan-file godump-1.out "(?n)^// type _ld_s struct \{ ld_s_f 
INVALID-float-\[0-9\]*; \}$" } } */
+/* { dg-final { scan-file godump-1.out "(?n)^// type _ld_s_t _ld_s$" } } *
+/* { dg-final { scan-file-not godump-1.out "(?n)^type _ld_s struct \{\}$" } } 
*/
+
 /*** complex types ***/
 typedef _Complex cx_t;
 /* { dg-final { scan-file godump-1.out "(?n)^type _cx_t complex\[0-9\]*$" } } 
*/
@@ -476,6 +481,8 @@ struct { double d; uint8_t : 0; } sd_not_equiv;
 /* { dg-final { scan-file godump-1.out "(?n)^var _sd_not_equiv struct \{ d 
float\[0-9\]*; \}$" } } */
 
 typedef struct s_undef_t s_undef_t2;
+/* { dg-final { scan-file godump-1.out "(?n)^type _s_undef_t2 _s_undef_t$" } } 
*/
+/* { dg-final { scan-file godump-1.out "(?n)^type _s_undef_t struct \{\}$" } } 
*/
 
 typedef struct s_fwd *s_fwd_p;
 /* { dg-final { scan-file godump-1.out "(?n)^type _s_fwd_p \\*_s_fwd$" } } */
@@ -816,6 +823,8 @@ union { uint64_t : 1; uint8_t ca[5]; } u2_size;
 /* { dg-final { scan-file godump-1.out "(?n)^var _u2_size struct \{ ca 
\\\[4\\+1\\\]uint8; \}$" } } */
 
 typedef union u_undef_t u_undef_t2;
+/* { dg-final { scan-file godump-1.out "(?n)^type _u_undef_t2 _u_undef_t$" } } 
*/
+/* { dg-final { scan-file godump-1.out "(?n)^type _u_undef_t struct \{\}$" } } 
*/
 
 typedef union { uint64_t b : 1; uint8_t ca[5]; } tu3_size;
 /* { dg-final { scan-file godump-1.out "(?n)^type _tu3_size struct \{ ca 
\\\[4\\+1\\\]uint8; Godump_0_pad \\\[.\

[PATCH 1/2] Remove Report keyword for options

2020-12-15 Thread Martin Liška

There's a small clean up that removes Report as it's not used
any longer by -fverbose-asm.

Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

Ready to be installed?
Thanks,
Martin
>From 13c7f39e59862a639823d0f47bbe1f4d9aacd736 Mon Sep 17 00:00:00 2001
From: Martin Liska 
Date: Fri, 11 Dec 2020 17:06:49 +0100
Subject: [PATCH 1/2] Remove Report keyword for options

Since g:7caa49706316e650fb67719e1a1bf3a35054b685 the option is ignored
as we print used command line for -fverbose-asm output.

gcc/ChangeLog:

	* doc/options.texi: Remove Report keyword.
	* opt-functions.awk: Print error when Report keyword
	is used.
	* optc-gen.awk: Do not handle Report keyword.
	* opts.h (struct cl_option): Remove cl_report bitfield flag.
---
 gcc/doc/options.texi  | 3 ---
 gcc/opt-functions.awk | 4 +++-
 gcc/optc-gen.awk  | 4 
 gcc/opts.h| 2 --
 4 files changed, 3 insertions(+), 10 deletions(-)

diff --git a/gcc/doc/options.texi b/gcc/doc/options.texi
index a8e83fcb696..aabfb82c7cb 100644
--- a/gcc/doc/options.texi
+++ b/gcc/doc/options.texi
@@ -454,9 +454,6 @@ operands, which is passed to the @samp{warning} function.  If an alias
 is marked @code{Warn}, the target of the alias must not also be marked
 @code{Warn}.
 
-@item Report
-The state of the option should be printed by @option{-fverbose-asm}.
-
 @item Warning
 This is a warning option and should be shown as such in
 @option{--help} output.  This flag does not currently affect anything
diff --git a/gcc/opt-functions.awk b/gcc/opt-functions.awk
index b4952b89315..0c489e0e3be 100644
--- a/gcc/opt-functions.awk
+++ b/gcc/opt-functions.awk
@@ -166,9 +166,11 @@ function switch_bit_fields (flags)
 	  uinteger_flag \
 	  hwi_flag \
 	  flag_init("ToLower", flags) \
-	  flag_init("Report", flags) \
 	  byte_size_flag
 
+	if (flag_set_p("Report", flags))
+	print "#error Report option property is dropped"
+
 	sub(", $", "", result)
 	return result
 }
diff --git a/gcc/optc-gen.awk b/gcc/optc-gen.awk
index be5566b960a..0c9fa16cb00 100644
--- a/gcc/optc-gen.awk
+++ b/gcc/optc-gen.awk
@@ -332,8 +332,6 @@ for (i = 0; i < n_opts; i++) {
   print "#error Ignored option with Warn"
 if (var_name(flags[i]) != "")
   print "#error Ignored option with Var"
-if (flag_set_p("Report", flags[i]))
-  print "#error Ignored option with Report"
   }
 else if (flag_set_p("Deprecated", flags[i]))
 print "#error Deprecated was replaced with WarnRemoved"
@@ -341,8 +339,6 @@ for (i = 0; i < n_opts; i++) {
 			  alias_data = "NULL, NULL, OPT_SPECIAL_warn_removed"
 if (warn_message != "NULL")
   print "#error WarnRemoved option with Warn"
-if (flag_set_p("Report", flags[i]))
-  print "#error WarnRemoved option with Report"
   }
 		else
 			alias_data = "NULL, NULL, N_OPTS"
diff --git a/gcc/opts.h b/gcc/opts.h
index b36c0d18759..2cf24d1430d 100644
--- a/gcc/opts.h
+++ b/gcc/opts.h
@@ -104,8 +104,6 @@ struct cl_option
   BOOL_BITFIELD cl_host_wide_int : 1;
   /* Argument should be converted to lowercase.  */
   BOOL_BITFIELD cl_tolower : 1;
-  /* Report argument with -fverbose-asm  */
-  BOOL_BITFIELD cl_report : 1;
   /* Argument is an unsigned integer with an optional byte suffix.  */
   BOOL_BITFIELD cl_byte_size: 1;
   /* Offset of field for this option in struct gcc_options, or
-- 
2.29.2



[PATCH 2/2] opts: Remove all usages of Report keyword.

2020-12-15 Thread Martin Liška

I've tested this mechanical change for all cross compilers.

Ready to be installed?
Thanks,
Martin


Re: [PATCH 3/3] RISC-V: Support version controling for ISA standard extensions

2020-12-15 Thread Gerald Pfeifer
On Fri, 13 Nov 2020, Kito Cheng wrote:
>  - New option -misa-spec support: -misa-spec=[2.2|20190608|20191213] and
>corresponding configuration option --with-isa-spec.

I noticed https://gcc.gnu.org/gcc-11/changes.html is currently empty.

Are you planning to add updates for the GCC 11 release?  (It may be
useful to add them as they happen, so they we won't miss them and
also for the benefit of users tracking development.)

Gerald


[committed] wwwdocs: gcc-11/changes: Use https for wg21.link

2020-12-15 Thread Gerald Pfeifer
All other links to wg21.link we have use https, so make this
consistent.

Gerald
---
 htdocs/gcc-11/changes.html | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/htdocs/gcc-11/changes.html b/htdocs/gcc-11/changes.html
index 5c3519ba..ea9fe93c 100644
--- a/htdocs/gcc-11/changes.html
+++ b/htdocs/gcc-11/changes.html
@@ -30,7 +30,7 @@ a work-in-progress.
 
   The default mode for C++ is now -std=gnu++17 instead of
 -std=gnu++14.  Note
-  that http://wg21.link/p0522r0";>C++17 changes to template
+  that https://wg21.link/p0522r0";>C++17 changes to template
   template parameter matching can be disabled independently of other
   features with -fno-new-ttp-matching.
   
-- 
2.29.2


Re: [PATCH 29/31] PDP11: Use `const_double_zero' to express double zero constant

2020-12-15 Thread Martin Liška

On 11/20/20 4:36 AM, Maciej W. Rozycki wrote:

We do not define a comparison operation between floating-point and
integer data, including integer zero constant.  Consequently the RTL
instruction stream presented to the post-reload comparison elimination
pass will include, where applicable, floating-point comparison insns
against `const_double:DF 0.0 [0x0.0p+0]' rather than `const_int 0 [0]',
meaning that the latter expression will not match when used in machine
description.

Use `const_double_zero' then for the relevant patterns to match the
intended RTL instructions.

gcc/
* config/pdp11/pdp11.md (fcc_cc, fcc_ccnz): Use
`const_double_zero' to express double zero constant.
---
  gcc/config/pdp11/pdp11.md | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/config/pdp11/pdp11.md b/gcc/config/pdp11/pdp11.md
index 7a4d50fdba9..cdef49f3979 100644
--- a/gcc/config/pdp11/pdp11.md
+++ b/gcc/config/pdp11/pdp11.md
@@ -105,7 +105,7 @@ (define_subst "fcc_cc"
 (clobber (reg FCC_REGNUM))]
""
[(set (reg:CC FCC_REGNUM)
-   (compare:CC (match_dup 1) (const_int 0)))
+   (compare:CC (match_dup 1) (const_double_zero)))
 (set (match_dup 0) (match_dup 1))])
  
  (define_subst "fcc_ccnz"

@@ -113,7 +113,7 @@ (define_subst "fcc_ccnz"
 (clobber (reg FCC_REGNUM))]
""
[(set (reg:CCNZ FCC_REGNUM)
-   (compare:CCNZ (match_dup 1) (const_int 0)))
+   (compare:CCNZ (match_dup 1) (const_double_zero)))
 (set (match_dup 0) (match_dup 1))])
  
  (define_subst_attr "cc_cc" "cc_cc" "_nocc" "_cc")




Hello.

If I see correctly, starting from this revision I can't compile a cross
compiler of x86_64-linux-gnu:

../configure --target=pdp11-aout --disable-bootstrap --enable-languages=c,c++ 
--disable-multilib  --enable-obsolete

$ make
build/genemit ../../gcc/common.md ../../gcc/config/pdp11/pdp11.md \
  insn-conditions.md > tmp-emit.c
genemit: Internal error: abort in gen_exp, at genemit.c:202
make: *** [Makefile:2427: s-emit] Error 1

$ Breakpoint 1, fancy_abort (file=0x435238 "../../gcc/genemit.c", line=202, func=0x435230 
"gen_exp") at ../../gcc/errors.c:133
133   internal_error ("abort in %s, at %s:%d", func, trim_filename (file), 
line);
(gdb) bt
#0  fancy_abort (file=0x435238 "../../gcc/genemit.c", line=202, func=0x435230 
"gen_exp") at ../../gcc/errors.c:133
#1  0x00402e4b in gen_exp (x=0x470de0, subroutine_type=DEFINE_INSN, used=0x4aa4b0 
"", info=0x7fffdea0) at ../../gcc/genemit.c:202
#2  0x00402f68 in gen_exp (x=0x4d6c70, subroutine_type=DEFINE_INSN, used=0x4aa4b0 
"", info=0x7fffdea0) at ../../gcc/genemit.c:227
#3  0x00402f68 in gen_exp (x=0x4d6c50, subroutine_type=DEFINE_INSN, used=0x4aa4b0 
"", info=0x7fffdea0) at ../../gcc/genemit.c:227
#4  0x0040307d in gen_exp (x=0x4aa490, subroutine_type=DEFINE_INSN, used=0x4aa4b0 
"", info=0x7fffdea0) at ../../gcc/genemit.c:255
#5  0x004036c1 in gen_insn (info=0x7fffdea0) at 
../../gcc/genemit.c:435
#6  0x00404930 in main (argc=3, argv=0x7fffdfc8) at 
../../gcc/genemit.c:911

Can you please take a look?
Thanks,
Martin


[committed] libstdc++: Update link to Unicode-HOWTO

2020-12-15 Thread Gerald Pfeifer
https is the new lack.

Gerald


libstdc++-v3/ChangeLog:

2020-12-15  Gerald Pfeifer  

* doc/xml/manual/codecvt.xml: Update link to Unicode-HOWTO.
* doc/html/manual/facets.html: Regenerate.
---
 libstdc++-v3/doc/html/manual/facets.html | 2 +-
 libstdc++-v3/doc/xml/manual/codecvt.xml  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libstdc++-v3/doc/html/manual/facets.html 
b/libstdc++-v3/doc/html/manual/facets.html
index 0ca45e3cc4e..2dd36307fcd 100644
--- a/libstdc++-v3/doc/html/manual/facets.html
+++ b/libstdc++-v3/doc/html/manual/facets.html
@@ -456,7 +456,7 @@ codecvt usage.
   A brief description of Normative Addendum 1

   . Clive 
Feather. Extended 
Character Sets. 
-   http://tldp.org/HOWTO/Unicode-HOWTO.html"; 
target="_top">
+   https://tldp.org/HOWTO/Unicode-HOWTO.html"; 
target="_top">
  The Unicode HOWTO

   . Bruno 
Haible. 
diff --git a/libstdc++-v3/doc/xml/manual/codecvt.xml 
b/libstdc++-v3/doc/xml/manual/codecvt.xml
index d6158db7c75..395a2cfa9da 100644
--- a/libstdc++-v3/doc/xml/manual/codecvt.xml
+++ b/libstdc++-v3/doc/xml/manual/codecvt.xml
@@ -662,7 +662,7 @@ codecvt usage.
   
   
http://www.w3.org/1999/xlink";
- xlink:href="http://tldp.org/HOWTO/Unicode-HOWTO.html";>
+ xlink:href="https://tldp.org/HOWTO/Unicode-HOWTO.html";>
  The Unicode HOWTO

   
-- 
2.29.2


[PATCH] lto: set nthreads_var to 1 if it is zero

2020-12-15 Thread Martin Liška

This prevents using -j0 on target where we are unable
to detect number of core.

Ready to be installed?
Thanks,
Martin

gcc/ChangeLog:

PR lto/98275
* lto-wrapper.c: Do not use -j0 when we are unable to detect
number of cores.
---
 gcc/lto-wrapper.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gcc/lto-wrapper.c b/gcc/lto-wrapper.c
index 68ccb156521..da1305c1696 100644
--- a/gcc/lto-wrapper.c
+++ b/gcc/lto-wrapper.c
@@ -1780,6 +1780,8 @@ cont1:
{
  char buf[256];
  init_num_threads ();
+ if (nthreads_var == 0)
+   nthreads_var = 1;
  if (verbose)
fprintf (stderr, "LTO parallelism level set to %ld\n",
 nthreads_var);
--
2.29.2



[PATCH] i386: Fix up -march=x86-64-v[234] vs. target attribute [PR98274]

2020-12-15 Thread Jakub Jelinek via Gcc-patches
Hi!

The following testcase fails to compile.  The problem is that
when ix86_option_override_internal is called the first time for command
line, it sees -mtune= wasn't present on the command line and so as fallback
sets ix86_tune_string to ix86_arch_string value ("x86-64-v2"), but
ix86_tune_specified is false, so we don't find the tuning in the table
but don't error on it.
When processing the target attribute, ix86_tune_string is what
it was earlier left with, but this time ix86_tune_specified is true and
so we error on it.

The following patch does what is done already e.g. for "x86-64" march,
in particular default the tuning to "generic".

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2020-12-15  Jakub Jelinek  

PR target/98274
* config/i386/i386-options.c (ix86_option_override_internal): Set
ix86_tune_string to "generic" even when it wasn't specified and
ix86_arch_string is "x86-64-v2", "x86-64-v3" or "x86-64-v4".
Remove useless {}s around a single statement.

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

--- gcc/config/i386/i386-options.c.jj   2020-12-14 13:31:51.864733294 +0100
+++ gcc/config/i386/i386-options.c  2020-12-14 14:40:09.795222723 +0100
@@ -1884,9 +1884,7 @@ ix86_option_override_internal (bool main
 as -mtune=generic.  With native compilers we won't see the
 -mtune=native, as it was changed by the driver.  */
   if (!strcmp (opts->x_ix86_tune_string, "native"))
-   {
- opts->x_ix86_tune_string = "generic";
-   }
+   opts->x_ix86_tune_string = "generic";
   else if (!strcmp (opts->x_ix86_tune_string, "x86-64"))
 warning (OPT_Wdeprecated,
 main_args_p
@@ -1908,10 +1906,12 @@ ix86_option_override_internal (bool main
 
   /* opts->x_ix86_tune_string is set to opts->x_ix86_arch_string
 or defaulted.  We need to use a sensible tune option.  */
-  if (!strcmp (opts->x_ix86_tune_string, "x86-64"))
-   {
- opts->x_ix86_tune_string = "generic";
-   }
+  if (!strncmp (opts->x_ix86_tune_string, "x86-64", 6)
+ && (opts->x_ix86_tune_string[6] == '\0'
+ || (!strcmp (opts->x_ix86_tune_string + 6, "-v2")
+ || !strcmp (opts->x_ix86_tune_string + 6, "-v3")
+ || !strcmp (opts->x_ix86_tune_string + 6, "-v4"
+   opts->x_ix86_tune_string = "generic";
 }
 
   if (opts->x_ix86_stringop_alg == rep_prefix_8_byte
--- gcc/testsuite/gcc.target/i386/pr98274.c.jj  2020-12-14 14:44:09.197559567 
+0100
+++ gcc/testsuite/gcc.target/i386/pr98274.c 2020-12-14 14:43:22.406080077 
+0100
@@ -0,0 +1,8 @@
+/* PR target/98274 */
+/* { dg-do compile { target lp64 } } */
+/* { dg-options "-mabi=sysv -O2 -march=x86-64-v2" } */
+
+void __attribute__((target ("avx")))
+foo (void)
+{
+}

Jakub



[PATCH] match.pd: Optimize X / bool_range_Y to X [PR96094]

2020-12-15 Thread Jakub Jelinek via Gcc-patches
Hi!

When the divisor is bool or has [0, 1] range, as division by
0 is UB, the only remaining option in valid programs is division by 1,
so we can optimize X / bool_range_Y into X.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2020-12-15  Jakub Jelinek  

PR tree-optimization/96094
* match.pd (X / bool_range_Y -> X): New simplification.

* gcc.dg/tree-ssa/pr96094.c: New test.

--- gcc/match.pd.jj 2020-12-12 14:49:47.0 +0100
+++ gcc/match.pd2020-12-14 12:49:58.056803883 +0100
@@ -348,11 +348,16 @@ (define_operator_list COND_TERNARY
   /* But not for 0 / 0 so that we can get the proper warnings and errors.  */
   (if (!integer_zerop (@1))
@0))
-  /* X / -1 is -X.  */
+ /* X / -1 is -X.  */
  (simplify
-   (div @0 integer_minus_onep@1)
-   (if (!TYPE_UNSIGNED (type))
-(negate @0)))
+  (div @0 integer_minus_onep@1)
+  (if (!TYPE_UNSIGNED (type))
+   (negate @0)))
+ /* X / bool_range_Y is X.  */ 
+ (simplify
+  (div @0 SSA_NAME@1)
+  (if (INTEGRAL_TYPE_P (type) && ssa_name_has_boolean_range (@1))
+   @0))
  /* X / X is one.  */
  (simplify
   (div @0 @0)
--- gcc/testsuite/gcc.dg/tree-ssa/pr96094.c.jj  2020-12-14 13:06:56.910417897 
+0100
+++ gcc/testsuite/gcc.dg/tree-ssa/pr96094.c 2020-12-14 13:06:39.311614421 
+0100
@@ -0,0 +1,34 @@
+/* PR tree-optimization/96094 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+/* { dg-final { scan-tree-dump-times "return 34;" 2 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "return y_\[0-9]*\\\(D\\\);" 2 
"optimized" } } */
+/* { dg-final { scan-tree-dump-times "return \[^\n\r;]*;" 4 "optimized" } } */
+
+int
+foo (int x)
+{
+  if (x >= 2U)
+return 34;
+  return 34 / x;
+}
+
+int
+bar (int x, int y)
+{
+  if (x >= 2U)
+return y;
+  return y / x;
+}
+
+int
+baz (_Bool x)
+{
+  return 34 / x;
+}
+
+int
+qux (_Bool x, int y)
+{
+  return y / x;
+}

Jakub



Re: [PATCH] lto: set nthreads_var to 1 if it is zero

2020-12-15 Thread Jakub Jelinek via Gcc-patches
On Tue, Dec 15, 2020 at 10:00:35AM +0100, Martin Liška wrote:
> This prevents using -j0 on target where we are unable
> to detect number of core.
> 
> Ready to be installed?
> Thanks,
> Martin
> 
> gcc/ChangeLog:
> 
>   PR lto/98275
>   * lto-wrapper.c: Do not use -j0 when we are unable to detect
>   number of cores.

Ok.

Jakub



[committed] wwwdocs: readings: Update R32C/M32C/M16C and SuperH references

2020-12-15 Thread Gerald Pfeifer
renesas.com is an interesting site: I got "403 Forbidden" for these 
two links, when really it's about them having moved once again, URLs
of 100+ characters, and blocking depending on user-agent. Oh, and try
regularly accessing robots.txt -- good luck.

If any of you has contacts there it would be nice to reach out.

Gerald

---
 htdocs/readings.html | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/htdocs/readings.html b/htdocs/readings.html
index f1bc116d..13e9e71e 100644
--- a/htdocs/readings.html
+++ b/htdocs/readings.html
@@ -164,7 +164,7 @@ names.
  
  m32c
   Manufacturer: Renesas
-  https://www.renesas.com/us/en/products/microcontrollers-microprocessors/m16c.html";>Renesas
 M16C Family (R32C/M32C/M16C) Site
+  https://www.renesas.com/us/en/products/microcontrollers-microprocessors/other-mcus-mpus/m16c-family-mcus-r32c-m32c-m16c";>Renesas
 M16C Family (R32C/M32C/M16C) Site
   GDB includes a simulator.
  
  
@@ -282,7 +282,7 @@ names.
  sh
   Manufacturer: Renesas, various licensees.
   CPUs include: SH1, SH2, SH2-DSP, SH3, SH3-DSP, SH4, SH4A, SH5 series.
-  https://www.renesas.com/us/en/products/microcontrollers-microprocessors/superh.html";>Renesas
 SuperH Processors
+  https://www.renesas.com/us/en/products/microcontrollers-microprocessors/other-mcus-mpus/superh-risc-engine-family-mcus";>Renesas
 SuperH Processors
   http://shared-ptr.com/sh_insns.html";>SuperH Instruction Set 
Summary
   GDB includes a simulator.
  
-- 
2.29.2


Re: [PATCH] i386: Fix up -march=x86-64-v[234] vs. target attribute [PR98274]

2020-12-15 Thread Uros Bizjak via Gcc-patches
On Tue, Dec 15, 2020 at 10:03 AM Jakub Jelinek  wrote:
>
> Hi!
>
> The following testcase fails to compile.  The problem is that
> when ix86_option_override_internal is called the first time for command
> line, it sees -mtune= wasn't present on the command line and so as fallback
> sets ix86_tune_string to ix86_arch_string value ("x86-64-v2"), but
> ix86_tune_specified is false, so we don't find the tuning in the table
> but don't error on it.
> When processing the target attribute, ix86_tune_string is what
> it was earlier left with, but this time ix86_tune_specified is true and
> so we error on it.
>
> The following patch does what is done already e.g. for "x86-64" march,
> in particular default the tuning to "generic".
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>
> 2020-12-15  Jakub Jelinek  
>
> PR target/98274
> * config/i386/i386-options.c (ix86_option_override_internal): Set
> ix86_tune_string to "generic" even when it wasn't specified and
> ix86_arch_string is "x86-64-v2", "x86-64-v3" or "x86-64-v4".
> Remove useless {}s around a single statement.
>
> * gcc.target/i386/pr98274.c: New test.

OK.

Thanks,
Uros.

> --- gcc/config/i386/i386-options.c.jj   2020-12-14 13:31:51.864733294 +0100
> +++ gcc/config/i386/i386-options.c  2020-12-14 14:40:09.795222723 +0100
> @@ -1884,9 +1884,7 @@ ix86_option_override_internal (bool main
>  as -mtune=generic.  With native compilers we won't see the
>  -mtune=native, as it was changed by the driver.  */
>if (!strcmp (opts->x_ix86_tune_string, "native"))
> -   {
> - opts->x_ix86_tune_string = "generic";
> -   }
> +   opts->x_ix86_tune_string = "generic";
>else if (!strcmp (opts->x_ix86_tune_string, "x86-64"))
>  warning (OPT_Wdeprecated,
>  main_args_p
> @@ -1908,10 +1906,12 @@ ix86_option_override_internal (bool main
>
>/* opts->x_ix86_tune_string is set to opts->x_ix86_arch_string
>  or defaulted.  We need to use a sensible tune option.  */
> -  if (!strcmp (opts->x_ix86_tune_string, "x86-64"))
> -   {
> - opts->x_ix86_tune_string = "generic";
> -   }
> +  if (!strncmp (opts->x_ix86_tune_string, "x86-64", 6)
> + && (opts->x_ix86_tune_string[6] == '\0'
> + || (!strcmp (opts->x_ix86_tune_string + 6, "-v2")
> + || !strcmp (opts->x_ix86_tune_string + 6, "-v3")
> + || !strcmp (opts->x_ix86_tune_string + 6, "-v4"
> +   opts->x_ix86_tune_string = "generic";
>  }
>
>if (opts->x_ix86_stringop_alg == rep_prefix_8_byte
> --- gcc/testsuite/gcc.target/i386/pr98274.c.jj  2020-12-14 14:44:09.197559567 
> +0100
> +++ gcc/testsuite/gcc.target/i386/pr98274.c 2020-12-14 14:43:22.406080077 
> +0100
> @@ -0,0 +1,8 @@
> +/* PR target/98274 */
> +/* { dg-do compile { target lp64 } } */
> +/* { dg-options "-mabi=sysv -O2 -march=x86-64-v2" } */
> +
> +void __attribute__((target ("avx")))
> +foo (void)
> +{
> +}
>
> Jakub
>


Re: [gcc r11-4816] Fix Ada build failure for the SuSE PowerPC64/Linux compiler

2020-12-15 Thread Eric Botcazou
> Are you saying that ADA doesn't support multilibs and you can only
> have/use the default lib?

It's Ada (the first name of Lady Lovelace), not ADA (an acronym for various 
organizations), see e.g https://en.wikipedia.org/wiki/Ada_Lovelace

> A --target=powerpc64-linux compiler can either default to -m32 or -m64
> depending on how you configure and build it.  If you configure and build
> GCC, you will get a compiler that matches the default to the system you
> are on.  If you want a compiler the defaults to the other -m32/-m64 mode
> from what the system uses, then you need to do some extra work.  I can
> help anyone with that if they are interested in doing that.

What does not work with the current system is to have the same triplet that 
either defaults to -m32 or to -m64 depending on the --with-cpu option.

Under PR ada/97504, Martin and Richard explained that the SuSE system compiler 
defaults to -m32 for historical reason, so I adjusted the Ada configuration 
accordingly.  Now Andreas says the opposite, i.e. that the system compiler 
defaults to -m64.  The two assertions cannot possibly be true at the time.

> It is true that older ppc64 BE distro releases defaulted to -m32.
> Newer ppc64 BE distro releases now default to -m64.

No problem with that, as long as the default is clearly set.

-- 
Eric Botcazou




[PATCH] bswap: Handle vector CONSTRUCTORs [PR96239]

2020-12-15 Thread Jakub Jelinek via Gcc-patches
Hi!

The following patch teaches the bswap pass to handle for small (2/4/8 byte
long) vectors a CONSTRUCTOR by determining if the bytes of the constructor
come from non-vector sources and are either nop or bswap and changing the
CONSTRUCTOR in that case to VIEW_CONVERT_EXPR from scalar integer to
the vector type.

Unfortunately, as I found after the patch was written, due to pass ordering
this doesn't really fix the original testcase, just the one I wrote,
because both loop and slp vectorization is done only after the bswap pass.
A possible way out of that would be to perform just this particular bswap
optimization (i.e. for CONSTRUCTOR assignments with integral vector types
call find_bswap_or_nop and bswap_replace if successful) also during the
store merging pass, it isn't really a store, but the store merging pass
already performs bswapping when handling store, so it wouldn't be that big
hack.  What do you think?

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2020-12-15  Jakub Jelinek  

PR tree-optimization/96239
* gimple-ssa-store-merging.c (find_bswap_or_nop): Handle a vector
CONSTRUCTOR.
(bswap_replace): Likewise.

* gcc.dg/pr96239.c: New test.

--- gcc/gimple-ssa-store-merging.c.jj   2020-11-20 12:26:23.777860152 +0100
+++ gcc/gimple-ssa-store-merging.c  2020-12-14 19:10:30.887578930 +0100
@@ -865,7 +865,66 @@ find_bswap_or_nop (gimple *stmt, struct
   gimple *ins_stmt = find_bswap_or_nop_1 (stmt, n, limit);
 
   if (!ins_stmt)
-return NULL;
+{
+  if (gimple_assign_rhs_code (stmt) != CONSTRUCTOR
+ || BYTES_BIG_ENDIAN != WORDS_BIG_ENDIAN)
+   return NULL;
+  unsigned HOST_WIDE_INT sz = tree_to_uhwi (type_size) * BITS_PER_UNIT;
+  if (sz != 16 && sz != 32 && sz != 64)
+   return NULL;
+  tree rhs = gimple_assign_rhs1 (stmt);
+  tree eltype = TREE_TYPE (TREE_TYPE (rhs));
+  unsigned HOST_WIDE_INT eltsz
+   = int_size_in_bytes (eltype) * BITS_PER_UNIT;
+  if (TYPE_PRECISION (eltype) != eltsz)
+   return NULL;
+  constructor_elt *elt;
+  unsigned int i;
+  tree type = build_nonstandard_integer_type (sz, 1);
+  FOR_EACH_VEC_SAFE_ELT (CONSTRUCTOR_ELTS (rhs), i, elt)
+   {
+ if (TREE_CODE (elt->value) != SSA_NAME
+ || !INTEGRAL_TYPE_P (TREE_TYPE (elt->value)))
+   return NULL;
+ struct symbolic_number n1;
+ gimple *source_stmt
+   = find_bswap_or_nop_1 (SSA_NAME_DEF_STMT (elt->value), &n1,
+  limit - 1);
+
+ if (!source_stmt)
+   return NULL;
+
+ n1.type = type;
+ if (!n1.base_addr)
+   n1.range = sz / BITS_PER_UNIT;
+
+ if (i == 0)
+   {
+ ins_stmt = source_stmt;
+ *n = n1;
+   }
+ else
+   {
+ if (n->vuse != n1.vuse)
+   return NULL;
+
+ struct symbolic_number n0 = *n;
+
+ if (!BYTES_BIG_ENDIAN)
+   {
+ if (!do_shift_rotate (LSHIFT_EXPR, &n1, i * eltsz))
+   return NULL;
+   }
+ else if (!do_shift_rotate (LSHIFT_EXPR, &n0, eltsz))
+   return NULL;
+ ins_stmt
+   = perform_symbolic_merge (ins_stmt, &n0, source_stmt, &n1, n);
+
+ if (!ins_stmt)
+   return NULL;
+   }
+   }
+}
 
   uint64_t cmpxchg, cmpnop;
   find_bswap_or_nop_finalize (n, &cmpxchg, &cmpnop);
@@ -939,11 +998,18 @@ bswap_replace (gimple_stmt_iterator gsi,
 {
   tree src, tmp, tgt = NULL_TREE;
   gimple *bswap_stmt;
+  tree_code conv_code = NOP_EXPR;
 
   gimple *cur_stmt = gsi_stmt (gsi);
   src = n->src;
   if (cur_stmt)
-tgt = gimple_assign_lhs (cur_stmt);
+{
+  tgt = gimple_assign_lhs (cur_stmt);
+  if (gimple_assign_rhs_code (cur_stmt) == CONSTRUCTOR
+ && tgt
+ && VECTOR_TYPE_P (TREE_TYPE (tgt)))
+   conv_code = VIEW_CONVERT_EXPR;
+}
 
   /* Need to load the value from memory first.  */
   if (n->base_addr)
@@ -1031,7 +1097,9 @@ bswap_replace (gimple_stmt_iterator gsi,
  load_stmt = gimple_build_assign (val_tmp, val_expr);
  gimple_set_vuse (load_stmt, n->vuse);
  gsi_insert_before (&gsi, load_stmt, GSI_SAME_STMT);
- gimple_assign_set_rhs_with_ops (&gsi, NOP_EXPR, val_tmp);
+ if (conv_code == VIEW_CONVERT_EXPR)
+   val_tmp = build1 (VIEW_CONVERT_EXPR, TREE_TYPE (tgt), val_tmp);
+ gimple_assign_set_rhs_with_ops (&gsi, conv_code, val_tmp);
  update_stmt (cur_stmt);
}
  else if (cur_stmt)
@@ -1073,7 +1141,9 @@ bswap_replace (gimple_stmt_iterator gsi,
{
  if (!is_gimple_val (src))
return NULL_TREE;
- g = gimple_build_assign (tgt, NOP_EXPR, src);
+ if (conv_code == VIEW_CONVERT_EXPR)
+   src = build1 (VIEW_CONVERT_EXPR, 

Re: [gcc r11-4816] Fix Ada build failure for the SuSE PowerPC64/Linux compiler

2020-12-15 Thread Andreas Schwab
On Dez 15 2020, Eric Botcazou wrote:

> The two assertions cannot possibly be true at the time.

But they are.

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: [gcc r11-4816] Fix Ada build failure for the SuSE PowerPC64/Linux compiler

2020-12-15 Thread Jakub Jelinek via Gcc-patches
On Tue, Dec 15, 2020 at 10:54:47AM +0100, Andreas Schwab wrote:
> On Dez 15 2020, Eric Botcazou wrote:
> 
> > The two assertions cannot possibly be true at the time.
> 
> But they are.

Yeah, it is the same thing for Fedora/RHEL when we were supporting -m32
for powerpc.
The bi-arch compiler with 32-bit binaries that defaults to -m32, but also
supports -m64 was configured
--build=powerpc64-redhat-linux --target=powerpc64-redhat-linux 
--with-cpu=default32
while the bi-arch compiler with 64-bit binaries that defaults to -m64, but
also supports -m32 was simply
--build=powerpc64-redhat-linux
configured.

Similarly for sparc,
--build=sparc64-redhat-linux --target=sparc64-redhat-linux --with-cpu=v7
was the bi-arch compiler with 32-bit binaries that defaults to -m32, but
also supports -m64, while
--build=sparc64-redhat-linux
was the 64-bit binary that defaults to -m64 but also supports -m32.

Jakub



Re: [PATCH] ira.c: Fix ICE in ira-color [PR97092]

2020-12-15 Thread Andrea Corallo via Gcc-patches
Vladimir Makarov  writes:

> On 2020-12-14 11:23 a.m., Andrea Corallo wrote:
>> Vladimir Makarov  writes:
>>
>>> On 2020-12-10 10:12 a.m., Andrea Corallo wrote:
 Hi all,

 following discussion on PR97092 I'd like to submit the following patch
 with a fix plus associated testcase.

 With this patch applied mode is recomputed at each iteration while
 looping across different copies in 'update_costs_from_allocno', this
 instead of carrying mode over subsequent iterations.

 bootstrapped and regtested on aarch64-unknown-linux-gnu.

 Okay for trunk?

>>> Yes.
>>>
>>> The patch is safe.. Thank you for working on the PR.
>> Hi Vladimir,
>>
>> the same patch cleanly applies on gcc-10 where the same bug is present.
>>
>> I bootstrapped and regtested gcc-10 on aarch64-unknown-linux-gnu.
>>
>> Is it okay to backport?
>>
> Yes.
>
> Thank you.

Installed as 41a2a54476c.

Thanks!

  Andrea


[PATCH] [X86] Fold more shuffle builtins to VEC_PERM_EXPR.

2020-12-15 Thread Hongtao Liu via Gcc-patches
Hi:
  As indicated in PR98167, this patch is a follow-up to [1].
  Bootstrapped and regtested on x86_64-linux-gnu.
  Ok for trunk?

gcc/
PR target/98167
* config/i386/i386.c (ix86_gimple_fold_builtin): Handle
IX86_BUILTIN_SHUFPD512, IX86_BUILTIN_SHUFPS512,
IX86_BUILTIN_SHUFPD256, IX86_BUILTIN_SHUFPS,
IX86_BUILTIN_SHUFPS256.

gcc/testsuite/
* gcc.target/i386/avx512f-vshufpd-1.c: Adjust testcase.
* gcc.target/i386/avx512f-vshufps-1.c: Adjust testcase.

[1]. https://gcc.gnu.org/pipermail/gcc-patches/2019-May/521983.html

-- 
BR,
Hongtao
From 74596b08a91dafcb29441de59544dd857a090564 Mon Sep 17 00:00:00 2001
From: liuhongt 
Date: Fri, 11 Dec 2020 19:02:43 +0800
Subject: [PATCH] [X86] Fold more shuffle builtins to VEC_PERM_EXPR.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

A follow-up to https://gcc.gnu.org/pipermail/gcc-patches/2019-May/521983.html

gcc/
	PR target/98167
	* config/i386/i386.c (ix86_gimple_fold_builtin): Handle
	IX86_BUILTIN_SHUFPD512, IX86_BUILTIN_SHUFPS512,
	IX86_BUILTIN_SHUFPD256, IX86_BUILTIN_SHUFPS,
	IX86_BUILTIN_SHUFPS256.

gcc/testsuite/
	* gcc.target/i386/avx512f-vshufpd-1.c: Adjust testcase.
	* gcc.target/i386/avx512f-vshufps-1.c: Adjust testcase.
---
 gcc/config/i386/i386.c| 64 ---
 .../gcc.target/i386/avx512f-vshufpd-1.c   |  3 +-
 .../gcc.target/i386/avx512f-vshufps-1.c   |  3 +-
 3 files changed, 59 insertions(+), 11 deletions(-)

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 54b7e103ba2..432470a916c 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -18187,21 +18187,67 @@ ix86_gimple_fold_builtin (gimple_stmt_iterator *gsi)
 	}
   break;
 
+case IX86_BUILTIN_SHUFPD512:
+case IX86_BUILTIN_SHUFPS512:
+  if (n_args > 2)
+	{
+	  /* This is masked shuffle.  Only optimize if the mask is all ones.  */
+	  tree argl = gimple_call_arg (stmt, n_args - 1);
+	  arg0 = gimple_call_arg (stmt, 0);
+	  if (!tree_fits_uhwi_p (argl))
+	break;
+	  unsigned HOST_WIDE_INT mask = tree_to_uhwi (argl);
+	  unsigned elems = TYPE_VECTOR_SUBPARTS (TREE_TYPE (arg0));
+	  if ((mask | (HOST_WIDE_INT_M1U << elems)) != HOST_WIDE_INT_M1U)
+	break;
+	}
+  /* Fall thru.  */
 case IX86_BUILTIN_SHUFPD:
+case IX86_BUILTIN_SHUFPD256:
+case IX86_BUILTIN_SHUFPS:
+case IX86_BUILTIN_SHUFPS256:
   arg2 = gimple_call_arg (stmt, 2);
   if (TREE_CODE (arg2) == INTEGER_CST)
 	{
-	  location_t loc = gimple_location (stmt);
-	  unsigned HOST_WIDE_INT imask = TREE_INT_CST_LOW (arg2);
 	  arg0 = gimple_call_arg (stmt, 0);
+	  unsigned elems = TYPE_VECTOR_SUBPARTS (TREE_TYPE (arg0));
+	  machine_mode imode = GET_MODE_INNER (TYPE_MODE (TREE_TYPE (arg0)));
+	  unsigned HOST_WIDE_INT imask = TREE_INT_CST_LOW (arg2);
+
+	  /* Check valid imm, refer to gcc.target/i386/testimm-10.c.  */
+	  if (imask > 255
+	  || (imask >= HOST_WIDE_INT_1U << elems
+		  && imode == E_DFmode))
+	return false;
+
 	  arg1 = gimple_call_arg (stmt, 1);
-	  tree itype = long_long_integer_type_node;
-	  tree vtype = build_vector_type (itype, 2); /* V2DI */
-	  tree_vector_builder elts (vtype, 2, 1);
-	  /* Ignore bits other than the lowest 2.  */
-	  elts.quick_push (build_int_cst (itype, imask & 1));
-	  imask >>= 1;
-	  elts.quick_push (build_int_cst (itype, 2 + (imask & 1)));
+	  location_t loc = gimple_location (stmt);
+	  tree itype = imode == E_DFmode
+	? long_long_integer_type_node : integer_type_node;
+	  /* V2DI/V4DI/V8DI/V4SI/V8SI/V16SI  */
+	  tree vtype = build_vector_type (itype, elems);
+	  tree_vector_builder elts (vtype, elems, 1);
+
+	  for (unsigned i = 0; i != elems; i++)
+	{
+	  unsigned sel_idx;
+	  /* Imm[1:0](if VL > 128, then use Imm[3:2],Imm[5:4],Imm[7:6])
+		 provide 2 select constrols for each element of the
+		 destination.  */
+	  if (imode == E_DFmode)
+		sel_idx = (i & 1) * elems
+		  + (i >> 1 << 1) + ((imask & 1 << i) >> i);
+	  else
+		{
+		  /* Imm[7:0](if VL > 128, also use Imm[7:0]) provide 4 select
+		 controls for each element of the destination.  */
+		  unsigned j = i % 4;
+		  sel_idx = ((i & 2) >> 1) * elems
+		+ (i >> 2 << 2) + ((imask & 3 << j << j) >> j >> j);
+		}
+	  elts.quick_push (build_int_cst (itype, sel_idx));
+	}
+
 	  tree omask = elts.build ();
 	  gimple *g = gimple_build_assign (gimple_call_lhs (stmt),
 	   VEC_PERM_EXPR,
diff --git a/gcc/testsuite/gcc.target/i386/avx512f-vshufpd-1.c b/gcc/testsuite/gcc.target/i386/avx512f-vshufpd-1.c
index d1ac01e1c88..8df5b9d4441 100644
--- a/gcc/testsuite/gcc.target/i386/avx512f-vshufpd-1.c
+++ b/gcc/testsuite/gcc.target/i386/avx512f-vshufpd-1.c
@@ -7,11 +7,12 @@
 #include 
 
 __m512d x;
+__m512d y;
 
 void extern
 avx512f_test (void)
 {
-  x = _mm512_shuffle_pd (x, x, 56);
+  x = _mm512_shuffle_pd (x, y, 56);
   x = _mm512_mask_shuffle_pd (x, 2, x, x, 56);
   x = _mm512_maskz_shuff

Re: [gcc r11-4816] Fix Ada build failure for the SuSE PowerPC64/Linux compiler

2020-12-15 Thread Eric Botcazou
> Yeah, it is the same thing for Fedora/RHEL when we were supporting -m32
> for powerpc.
> The bi-arch compiler with 32-bit binaries that defaults to -m32, but also
> supports -m64 was configured
> --build=powerpc64-redhat-linux --target=powerpc64-redhat-linux
> --with-cpu=default32 while the bi-arch compiler with 64-bit binaries that
> defaults to -m64, but also supports -m32 was simply
> --build=powerpc64-redhat-linux
> configured.
> 
> Similarly for sparc,
> --build=sparc64-redhat-linux --target=sparc64-redhat-linux --with-cpu=v7
> was the bi-arch compiler with 32-bit binaries that defaults to -m32, but
> also supports -m64, while
> --build=sparc64-redhat-linux
> was the 64-bit binary that defaults to -m64 but also supports -m32.

OK, but what was the configuration of the system compiler of the distribution?
Or do you mean that you had two different packages for the system compiler?

-- 
Eric Botcazou




[PATCH] libstdc++: Fix the test for rvalue stream extraction

2020-12-15 Thread Ville Voutilainen via Gcc-patches
libstdc++-v3/ChangeLog:

* testsuite/27_io/rvalue_streams.cc: Run the extraction to a char*
for C++17 and lower only.
diff --git a/libstdc++-v3/testsuite/27_io/rvalue_streams.cc b/libstdc++-v3/testsuite/27_io/rvalue_streams.cc
index ad4d11c7cf3..487aa4deedd 100644
--- a/libstdc++-v3/testsuite/27_io/rvalue_streams.cc
+++ b/libstdc++-v3/testsuite/27_io/rvalue_streams.cc
@@ -53,7 +53,9 @@ test02()
   VERIFY( x.as_rvalue == true );
 
   char arr[2];
+#if __cplusplus <= 201703L
   std::istringstream("x") >> &arr[0];
+#endif
   std::istringstream("x") >> arr;
 }
 


Re: [patch] Fix PR tree-optimization/96344

2020-12-15 Thread Eric Botcazou
> OK.

Thanks.  Unfortunately I overlooked the comment of the function:

MINVAL is the lowest case value of in the case nodes,
and RANGE is highest value minus MINVAL.  MINVAL and RANGE
are not guaranteed to be of the same type as INDEX_EXPR
(the gimplifier doesn't change the type of case label values,
and MINVAL and RANGE are derived from those values).

so PR tree-optimization/98272 exhibits a precision mismatch now.

Bootstrapped/regtested on x86-64/Linux, OK for the mainline?


2020-12-15  Eric Botcazou  

PR tree-optimization/98272
* tree-switch-conversion.c (bit_test_cluster::emit): When finding
out whether the entry test can be merged in the bit test, do the
computation using the type of the index expression.


2020-12-15  Eric Botcazou  

* gcc.dg/pr98272.c: New test.

-- 
Eric Botcazoudiff --git a/gcc/tree-switch-conversion.c b/gcc/tree-switch-conversion.c
index 989bd7710d1..08dfd6f3580 100644
--- a/gcc/tree-switch-conversion.c
+++ b/gcc/tree-switch-conversion.c
@@ -1557,21 +1557,22 @@ bit_test_cluster::emit (tree index_expr, tree index_type,
   && get_range_info (index_expr, &min, &max) == VR_RANGE
   && wi::leu_p (max - min, prec - 1))
 {
+  tree index_type = TREE_TYPE (index_expr);
+  minval = fold_convert (index_type, minval);
   wide_int iminval = wi::to_wide (minval);
-  tree minval_type = TREE_TYPE (minval);
-  if (wi::lt_p (min, iminval, TYPE_SIGN (minval_type)))
+  if (wi::lt_p (min, iminval, TYPE_SIGN (index_type)))
 	{
-	  minval = wide_int_to_tree (minval_type, min);
+	  minval = wide_int_to_tree (index_type, min);
 	  for (i = 0; i < count; i++)
 	test[i].mask = wi::lshift (test[i].mask, iminval - min);
 	}
-  else if (wi::gt_p (min, iminval, TYPE_SIGN (minval_type)))
+  else if (wi::gt_p (min, iminval, TYPE_SIGN (index_type)))
 	{
-	  minval = wide_int_to_tree (minval_type, min);
+	  minval = wide_int_to_tree (index_type, min);
 	  for (i = 0; i < count; i++)
 	test[i].mask = wi::lrshift (test[i].mask, min - iminval);
 	}
-  maxval = wide_int_to_tree (minval_type, max);
+  maxval = wide_int_to_tree (index_type, max);
   entry_test_needed = false;
 }
   else
/* PR tree-optimization/98272 */
/* Reported by Zdenek Sojka  */

/* { dg-do compile } */
/* { dg-options "-O -fno-tree-forwprop" } */

void bar (void);

void
foo (unsigned char uc)
{
  if (uc >= 5)
return;

  switch (uc)
{
case 0:
case 2:
case 4:
  bar ();
}
}


Re: [gcc r11-4816] Fix Ada build failure for the SuSE PowerPC64/Linux compiler

2020-12-15 Thread Jakub Jelinek via Gcc-patches
On Tue, Dec 15, 2020 at 11:10:17AM +0100, Eric Botcazou wrote:
> > Similarly for sparc,
> > --build=sparc64-redhat-linux --target=sparc64-redhat-linux --with-cpu=v7
> > was the bi-arch compiler with 32-bit binaries that defaults to -m32, but
> > also supports -m64, while
> > --build=sparc64-redhat-linux
> > was the 64-bit binary that defaults to -m64 but also supports -m32.
> 
> OK, but what was the configuration of the system compiler of the distribution?

There were 32-bit and 64-bit distributions.  The gcc build created (well,
still does, but the only remaining multilib we use is i686 for x86_64) some
subpackages that were for the primary multilib only (the compiler
subpackages) and others that were for both (the library subpackages).
So, in the 32-bit ppc distro, one had:

gcc-*.ppc.rpm - 32-bit C compiler
gcc-c++-*.ppc.rpm - 32-bit C++ compiler
...
libgcc-*.ppc.rpm - 32-bit libgcc.so
libgcc-*.ppc64.rpm - 64-bit libgcc.so
libstdc++-*.ppc.rpm - 32-bit libstdc++.so
libstdc++-*.ppc64.rpm - 64-bit libstdc++.so
etc.,

while in the 64-bit ppc distro one had:

gcc-*.ppc64.rpm - 64-bit C compiler
gcc-c++-*.ppc64.rpm - 64-bit C++ compiler
...
libgcc-*.ppc.rpm - 32-bit libgcc.so
libgcc-*.ppc64.rpm - 64-bit libgcc.so
libstdc++-*.ppc.rpm - 32-bit libstdc++.so
libstdc++-*.ppc64.rpm - 64-bit libstdc++.so
etc.

Similarly for *.sparcv9.rpm and *.sparc64.rpm.
Installing both gcc-*.ppc.rpm and gcc-*.ppc64.rpm wasn't possible,
both because they wouldn't appear in the repositories together and
because they conflicted if one manually downloaded them from the other
repository and tried to install.

Jakub



Re: [PING] [PATCH] testsuite/libstdc++: Fix required locales of a testcase

2020-12-15 Thread Jonathan Wakely via Gcc-patches

On 14/12/20 11:19 +0100, Marius Hillenbrand wrote:

I'd like to ping the small fixup in
https://gcc.gnu.org/pipermail/gcc-patches/2020-November/560100.html

Please review and merge, if OK.


Patches for libstdc++ need to be CC'd to the libstdc++ list, or I
won't see them (this is mentioned at https://gcc.gnu.org/lists.html
which https://gcc.gnu.org/contribute.html#patches links to).

The patch itself is good, so I'll merge it today, thanks!


Marius


 Forwarded Message 
Subject: [PATCH] testsuite/libstdc++: Fix required locales of a testcase
Date: Tue, 24 Nov 2020 17:26:26 +0100
From: Marius Hillenbrand 
To: gcc-patches@gcc.gnu.org
CC: Marius Hillenbrand 

The testsuite for libstdc++ aims to skips test cases for which not all
required locales are installed. This patch adds missing directives about
required locales to one test case to avoid false positive test failures
on systems that have a partial set of locales installed.

Verified by test suite runs that this patch changes the test case from
FAIL to UNSUPPORTED when not all required locales are available and that
the test case will run and PASS when the necessary locales have been
added.

Please review and merge this patch if you agree. While this patch is
trivial, it may safe others a few minutes of confusion ;-)

Marius


libstdc++-v3/ChangeLog:

2020-11-24  Marius Hillenbrand  

* testsuite/22_locale/locale/cons/5.cc: Add missing directives
for required locales.
---
libstdc++-v3/testsuite/22_locale/locale/cons/5.cc | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/testsuite/22_locale/locale/cons/5.cc
b/libstdc++-v3/testsuite/22_locale/locale/cons/5.cc
index 8fd73960abb..49e863ec85c 100644
--- a/libstdc++-v3/testsuite/22_locale/locale/cons/5.cc
+++ b/libstdc++-v3/testsuite/22_locale/locale/cons/5.cc
@@ -1,5 +1,7 @@
-// { dg-require-namedlocale "en_PH" }
// { dg-require-namedlocale "de_DE" }
+// { dg-require-namedlocale "en_PH" }
+// { dg-require-namedlocale "es_MX" }
+// { dg-require-namedlocale "fr_FR" }
// { dg-require-namedlocale "it_IT" }
 // 2000-09-13 Benjamin Kosnik 
--
2.26.2





[PATCH] options: fix integer overflow

2020-12-15 Thread Martin Liška

The patch reports an error when a non-HOST_WIDE_INT options is used
and its value is bigger than INT_MAX.

Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

Ready to be installed?
Thanks,
Martin

gcc/ChangeLog:

PR rtl-optimization/98271
PR rtl-optimization/98276
PR tree-optimization/98279
* opts-common.c (set_option): Do not allow overflow for integer
arguments.

gcc/testsuite/ChangeLog:

PR rtl-optimization/98271
PR rtl-optimization/98276
PR tree-optimization/98279
* gcc.dg/pr98271.c: New test.
---
 gcc/opts-common.c  | 12 +---
 gcc/testsuite/gcc.dg/pr98271.c | 13 +
 2 files changed, 22 insertions(+), 3 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/pr98271.c

diff --git a/gcc/opts-common.c b/gcc/opts-common.c
index 8ec8c1ec1a8..30be7d5bf47 100644
--- a/gcc/opts-common.c
+++ b/gcc/opts-common.c
@@ -1466,9 +1466,15 @@ set_option (struct gcc_options *opts, struct gcc_options 
*opts_set,
  }
else
  {
-   *(int *) flag_var = value;
-   if (set_flag_var)
- *(int *) set_flag_var = 1;
+   if (value > INT_MAX)
+ error_at (loc, "argument to %qs is bigger than %d",
+   option->opt_text, INT_MAX);
+   else
+ {
+   *(int *) flag_var = value;
+   if (set_flag_var)
+ *(int *) set_flag_var = 1;
+ }
  }
 
 	break;

diff --git a/gcc/testsuite/gcc.dg/pr98271.c b/gcc/testsuite/gcc.dg/pr98271.c
new file mode 100644
index 000..b453434612e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr98271.c
@@ -0,0 +1,13 @@
+/* PR rtl-optimization/98271 */
+/* PR rtl-optimization/98276 */
+/* PR tree-optimization/98279 */
+/* { dg-do compile } */
+/* { dg-options "-O --param=align-loop-iterations=1197120096074465280 
--param=gcse-cost-distance-ratio=2147483648 
--param=hot-bb-frequency-fraction=2147483648" } */
+/* { dg-error "argument to .--param=align-loop-iterations=. is bigger than 2147483647" 
"" { target *-*-* } 0 } */
+/* { dg-error "argument to .--param=gcse-cost-distance-ratio=. is bigger than 
2147483647" "" { target *-*-* } 0 } */
+/* { dg-error "argument to .--param=hot-bb-frequency-fraction=. is bigger than 
2147483647" "" { target *-*-* } 0 } */
+
+void
+foo (void)
+{
+}
--
2.29.2



Re: [gcc r11-4816] Fix Ada build failure for the SuSE PowerPC64/Linux compiler

2020-12-15 Thread Andreas Schwab
https://build.opensuse.org/package/live_build_log/openSUSE:Factory:PowerPC/gcc10/standard/ppc
https://build.opensuse.org/package/live_build_log/openSUSE:Factory:PowerPC/gcc10/standard/ppc64

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] libstdc++: Fix the test for rvalue stream extraction

2020-12-15 Thread Jonathan Wakely via Gcc-patches

On 15/12/20 12:13 +0200, Ville Voutilainen via Libstdc++ wrote:

   libstdc++-v3/ChangeLog:

   * testsuite/27_io/rvalue_streams.cc: Run the extraction to a char*
   for C++17 and lower only.


OK, thanks.



diff --git a/libstdc++-v3/testsuite/27_io/rvalue_streams.cc 
b/libstdc++-v3/testsuite/27_io/rvalue_streams.cc
index ad4d11c7cf3..487aa4deedd 100644
--- a/libstdc++-v3/testsuite/27_io/rvalue_streams.cc
+++ b/libstdc++-v3/testsuite/27_io/rvalue_streams.cc
@@ -53,7 +53,9 @@ test02()
  VERIFY( x.as_rvalue == true );

  char arr[2];
+#if __cplusplus <= 201703L
  std::istringstream("x") >> &arr[0];
+#endif
  std::istringstream("x") >> arr;
}





Re: [PATCH] [X86] Fold more shuffle builtins to VEC_PERM_EXPR.

2020-12-15 Thread Jakub Jelinek via Gcc-patches
On Tue, Dec 15, 2020 at 06:10:57PM +0800, Hongtao Liu via Gcc-patches wrote:
> --- a/gcc/config/i386/i386.c
> +++ b/gcc/config/i386/i386.c
> @@ -18187,21 +18187,67 @@ ix86_gimple_fold_builtin (gimple_stmt_iterator *gsi)
>   }
>break;
>  
> +case IX86_BUILTIN_SHUFPD512:
> +case IX86_BUILTIN_SHUFPS512:
> +  if (n_args > 2)
> + {
> +   /* This is masked shuffle.  Only optimize if the mask is all ones.  */
> +   tree argl = gimple_call_arg (stmt, n_args - 1);
> +   arg0 = gimple_call_arg (stmt, 0);
> +   if (!tree_fits_uhwi_p (argl))
> + break;
> +   unsigned HOST_WIDE_INT mask = tree_to_uhwi (argl);
> +   unsigned elems = TYPE_VECTOR_SUBPARTS (TREE_TYPE (arg0));

I think it would be better not to mix the argl and arg0 stuff.
So e.g. do
  arg0 = gimple_call_arg (stmt, 0);
  unsigned elems = TYPE_VECTOR_SUBPARTS (TREE_TYPE (arg0));
first and then the argl stuff, or vice versa.
Furthermore, you don't really care about the upper bits of argl,
so why don't punt just if (TREE_CODE (argl) != INTEGER_CST)
and use mask = TREE_LOW_CST (argl);
?

> +   if ((mask | (HOST_WIDE_INT_M1U << elems)) != HOST_WIDE_INT_M1U)
> + break;
> + }
> +  /* Fall thru.  */
>  case IX86_BUILTIN_SHUFPD:
> +case IX86_BUILTIN_SHUFPD256:
> +case IX86_BUILTIN_SHUFPS:
> +case IX86_BUILTIN_SHUFPS256:
>arg2 = gimple_call_arg (stmt, 2);
>if (TREE_CODE (arg2) == INTEGER_CST)
>   {
> -   location_t loc = gimple_location (stmt);
> -   unsigned HOST_WIDE_INT imask = TREE_INT_CST_LOW (arg2);
> arg0 = gimple_call_arg (stmt, 0);
> +   unsigned elems = TYPE_VECTOR_SUBPARTS (TREE_TYPE (arg0));
> +   machine_mode imode = GET_MODE_INNER (TYPE_MODE (TREE_TYPE (arg0)));
> +   unsigned HOST_WIDE_INT imask = TREE_INT_CST_LOW (arg2);
> +
> +   /* Check valid imm, refer to gcc.target/i386/testimm-10.c.  */
> +   if (imask > 255
> +   || (imask >= HOST_WIDE_INT_1U << elems
> +   && imode == E_DFmode))
> + return false;

Why is this extra checking done only for DFmode and not for SFmode?

> +   tree itype = imode == E_DFmode
> + ? long_long_integer_type_node : integer_type_node;

Formatting.  Should be e.g.
  tree itype
= (imode == E_DFmode
   ? long_long_integer_type_node : integer_type_node);
or
  tree itype = (imode == E_DFmode ? long_long_integer_type_node
  : integer_type_node);
but the ? which is part of the imode == E_DFmode ... subexpression
can't just be below something unrelated.

> +   if (imode == E_DFmode)
> + sel_idx = (i & 1) * elems
> +   + (i >> 1 << 1) + ((imask & 1 << i) >> i);

Again, formatting.  Plus, i >> 1 << 1 looks too ugly/unreadable,
if you mean i & ~1, write it like that, it is up to the compiler to emit
it like i >> 1 << 1 if that is the best implementation.

> +   else
> + {
> +   /* Imm[7:0](if VL > 128, also use Imm[7:0]) provide 4 select
> +  controls for each element of the destination.  */
> +   unsigned j = i % 4;
> +   sel_idx = ((i & 2) >> 1) * elems
> + + (i >> 2 << 2) + ((imask & 3 << j << j) >> j >> j);

Ditto.

Jakub



Re: [committed][wwwdocs] gcc-11/changes: "used" attribute saves decls from linker garbage collection

2020-12-15 Thread Jozef Lawrynowicz
On Tue, Dec 15, 2020 at 12:48:47AM +0100, Gerald Pfeifer wrote:
> On Mon, 7 Dec 2020, Jozef Lawrynowicz wrote:
> > Committed as obvious.
> 
> Thank you!
> 
> +  
> +For ELF targets that support the GNU or FreeBSD OSABIs, the
> +used attribute will now save the symbol declaration it is
> +applied to from linker garbage collection.
> +
> +To support this behavior, used symbols that have not
> +been placed in specific sections (e.g. with the section
> +attribute, or the -f{function,data}-sections options) will
> +be placed in new, unique sections.
> +
> +This functionality requires Binutils version 2.36 or later.
> +  
> 
> Have you considered using ... around the three blocks of
> text instead of  in between?
> 
> An open question, it's okay to keep as is if you prefer.

I did try with ..., but I thought the additional line spacing
just looked a little out of place amongst all the other lines in this
section, which are list items so have compact line spacing. However,
since they are separate paragraphs there should be some formatting to
show this.

Also, I guess that using  to override the house style in this way is
a bit of a no-no, so I will change it to 

Committed the attached patch.

Thanks,
Jozef
>From fb048b7d45422cd869772462cba591a46f1b3b2f Mon Sep 17 00:00:00 2001
From: Jozef Lawrynowicz 
Date: Tue, 15 Dec 2020 11:19:41 +
Subject: [PATCH] gcc-11/changes: Use  instead of  for "used" attribute
 description

---
 htdocs/gcc-11/changes.html | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/htdocs/gcc-11/changes.html b/htdocs/gcc-11/changes.html
index ea9fe93c..1a9e72c1 100644
--- a/htdocs/gcc-11/changes.html
+++ b/htdocs/gcc-11/changes.html
@@ -159,16 +159,20 @@ a work-in-progress.
 
   
   
+
 For ELF targets that support the GNU or FreeBSD OSABIs, the
 used attribute will now save the symbol declaration it is
 applied to from linker garbage collection.
-
+
+
 To support this behavior, used symbols that have not
 been placed in specific sections (e.g. with the section
 attribute, or the -f{function,data}-sections options) will
 be placed in new, unique sections.
-
+
+
 This functionality requires Binutils version 2.36 or later.
+
   
 
 
-- 
2.29.2



[Ada] Refactor repeated code for Value attributes

2020-12-15 Thread Pierre-Marie de Rodat
Check related to restriction No_Enumeration_Maps and marking enumeration
literals as referenced were done to attribute Value in both compilation
and semantic checking mode (-gnatc), but to attributes Wide_Value and
Wide_Wide_Value only in compilation (because those attributes are
rewritten into attribute Value and reanalyzed).

Now those checks are applied to all attributes in both compilation and
semantic checking modes.

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

gcc/ada/

* sem_attr.adb (Analyze_Attribute): Reuse existing code for
attribute Value when analyzing attributes Wide_Value and
Wide_Wide_Value.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
@@ -7088,7 +7088,10 @@ package body Sem_Attr is
   -- Value --
   ---
 
-  when Attribute_Value =>
+  when Attribute_Value
+ | Attribute_Wide_Value
+ | Attribute_Wide_Wide_Value
+  =>
  Check_E1;
  Check_Scalar_Type;
 
@@ -7174,45 +7177,13 @@ package body Sem_Attr is
   -- Wide_Value --
   
 
-  when Attribute_Wide_Value =>
- Check_E1;
- Check_Scalar_Type;
-
- --  Set Etype before resolving expression because expansion
- --  of expression may require enclosing type.
-
- Set_Etype (N, P_Type);
- Validate_Non_Static_Attribute_Function_Call;
-
- --  Check restriction No_Fixed_IO
-
- if Restriction_Check_Required (No_Fixed_IO)
-   and then Is_Fixed_Point_Type (P_Type)
- then
-Check_Restriction (No_Fixed_IO, P);
- end if;
+  --  Shares processing with Value attribute
 
   -
   -- Wide_Wide_Value --
   -
 
-  when Attribute_Wide_Wide_Value =>
- Check_E1;
- Check_Scalar_Type;
-
- --  Set Etype before resolving expression because expansion
- --  of expression may require enclosing type.
-
- Set_Etype (N, P_Type);
- Validate_Non_Static_Attribute_Function_Call;
-
- --  Check restriction No_Fixed_IO
-
- if Restriction_Check_Required (No_Fixed_IO)
-   and then Is_Fixed_Point_Type (P_Type)
- then
-Check_Restriction (No_Fixed_IO, P);
- end if;
+  --  Shares processing with Value attribute
 
   -
   -- Wide_Wide_Width --




[Ada] Fix possible infinite recursion in directory iterator

2020-12-15 Thread Pierre-Marie de Rodat
When the directory iterator Find is called we need to ensure that
symbolic links are skipped to avoid possible circularities or exploring
unrelated directories.

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

gcc/ada/

* libgnat/g-diopit.adb (Find): Fix possible infinite recursion
in Find iterator.
* libgnat/g-diopit.ads (Find): Update comments accordingly.diff --git a/gcc/ada/libgnat/g-diopit.adb b/gcc/ada/libgnat/g-diopit.adb
--- a/gcc/ada/libgnat/g-diopit.adb
+++ b/gcc/ada/libgnat/g-diopit.adb
@@ -32,6 +32,7 @@
 with Ada.Characters.Handling;
 with Ada.Strings.Fixed;
 with Ada.Strings.Maps;
+
 with GNAT.OS_Lib;
 with GNAT.Regexp;
 
@@ -49,7 +50,7 @@ package body GNAT.Directory_Operations.Iteration is
is
   File_Regexp : constant Regexp.Regexp := Regexp.Compile (File_Pattern);
   Index   : Natural := 0;
-  Quit: Boolean;
+  Quit: Boolean := False;
 
   procedure Read_Directory (Directory : Dir_Name_Str);
   --  Open Directory and read all entries. This routine is called
@@ -113,6 +114,7 @@ package body GNAT.Directory_Operations.Iteration is
 
if not (Dir_Entry = "." or else Dir_Entry = "..")
  and then OS_Lib.Is_Directory (Pathname)
+ and then not OS_Lib.Is_Symbolic_Link (Pathname)
then
   Read_Directory (Pathname);
   exit when Quit;
@@ -124,7 +126,6 @@ package body GNAT.Directory_Operations.Iteration is
   end Read_Directory;
 
begin
-  Quit := False;
   Read_Directory (Root_Directory);
end Find;
 


diff --git a/gcc/ada/libgnat/g-diopit.ads b/gcc/ada/libgnat/g-diopit.ads
--- a/gcc/ada/libgnat/g-diopit.ads
+++ b/gcc/ada/libgnat/g-diopit.ads
@@ -50,6 +50,8 @@ package GNAT.Directory_Operations.Iteration is
--  will pass in the value False on each call to Action. The iterator will
--  terminate after passing the last matched path to Action or after
--  returning from a call to Action which sets Quit to True.
+   --  The iterator does not follow symbolic links avoiding possible
+   --  circularities or exploring unrelated directories.
--  Raises GNAT.Regexp.Error_In_Regexp if File_Pattern is ill formed.
 
generic




[Ada] Crash on unnesting unnamed blocks

2020-12-15 Thread Pierre-Marie de Rodat
As seen on e.g. ACATS ca5006a when front-end unnesting is enabled.

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

gcc/ada/

* exp_ch7.adb (Reset_Scopes_To_Block_Elab_Proc): Do not crash on
a block with no Identifier. Code cleanups.diff --git a/gcc/ada/exp_ch7.adb b/gcc/ada/exp_ch7.adb
--- a/gcc/ada/exp_ch7.adb
+++ b/gcc/ada/exp_ch7.adb
@@ -4132,20 +4132,23 @@ package body Exp_Ch7 is
   procedure Reset_Scopes_To_Block_Elab_Proc (L : List_Id) is
  Id   : Entity_Id;
  Stat : Node_Id;
+ Node : Node_Id;
 
   begin
  Stat := First (L);
  while Present (Stat) loop
 case Nkind (Stat) is
when N_Block_Statement =>
-  Id := Entity (Identifier (Stat));
+  if Present (Identifier (Stat)) then
+ Id := Entity (Identifier (Stat));
 
-  --  The Scope of this block needs to be reset to the new
-  --  procedure if the block contains nested subprograms.
+ --  The Scope of this block needs to be reset to the new
+ --  procedure if the block contains nested subprograms.
 
-  if Present (Id) and then Contains_Subprogram (Id) then
- Set_Block_Elab_Proc;
- Set_Scope (Id, Block_Elab_Proc);
+ if Present (Id) and then Contains_Subprogram (Id) then
+Set_Block_Elab_Proc;
+Set_Scope (Id, Block_Elab_Proc);
+ end if;
   end if;
 
when N_Loop_Statement =>
@@ -4168,34 +4171,20 @@ package body Exp_Ch7 is
 
when N_If_Statement =>
   Reset_Scopes_To_Block_Elab_Proc (Then_Statements (Stat));
-
   Reset_Scopes_To_Block_Elab_Proc (Else_Statements (Stat));
 
-  declare
- Elif : Node_Id;
-
-  begin
- Elif := First (Elsif_Parts (Stat));
- while Present (Elif) loop
-Reset_Scopes_To_Block_Elab_Proc
-  (Then_Statements (Elif));
-
-Next (Elif);
- end loop;
-  end;
+  Node := First (Elsif_Parts (Stat));
+  while Present (Node) loop
+ Reset_Scopes_To_Block_Elab_Proc (Then_Statements (Node));
+ Next (Node);
+  end loop;
 
when N_Case_Statement =>
-  declare
- Alt : Node_Id;
-
-  begin
- Alt := First (Alternatives (Stat));
- while Present (Alt) loop
-Reset_Scopes_To_Block_Elab_Proc (Statements (Alt));
-
-Next (Alt);
- end loop;
-  end;
+  Node := First (Alternatives (Stat));
+  while Present (Node) loop
+ Reset_Scopes_To_Block_Elab_Proc (Statements (Node));
+ Next (Node);
+  end loop;
 
--  Reset the Scope of a subprogram occurring at the top level
 




[Ada] Remove redundant calls to UI_To_Int in relational operands

2020-12-15 Thread Pierre-Marie de Rodat
Relational operations on Uint are overloaded to accept Int as one of the
operands. There is no need to explicitly convert such operands with
UI_To_Int. Cleanup only; semantics is unaffected.

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

gcc/ada/

* exp_disp.adb (Make_Tags): Remove call to UI_To_Int.
* sem_attr.adb (Check_Array_Type): Likewise; also, refine type
of a local variable.
(Analyze_Attribute): Likewise.
(Get_Enclosing_Object): Likewise.
* sem_util.adb (Get_Enum_Lit_From_Pos): Likewise.diff --git a/gcc/ada/exp_disp.adb b/gcc/ada/exp_disp.adb
--- a/gcc/ada/exp_disp.adb
+++ b/gcc/ada/exp_disp.adb
@@ -7241,7 +7241,7 @@ package body Exp_Disp is
   -- is used by Build_Get_Prim_Op_Address to expand dispatching calls
   -- through the primary dispatch table.
 
-  if UI_To_Int (DT_Entry_Count (First_Tag_Component (Typ))) = 0 then
+  if DT_Entry_Count (First_Tag_Component (Typ)) = 0 then
  Analyze_List (Result);
 
   -- Generate:


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
@@ -1656,7 +1656,7 @@ package body Sem_Attr is
   --
 
   procedure Check_Array_Type is
- D : Int;
+ D : Pos;
  --  Dimension number for array attributes
 
   begin
@@ -1741,9 +1741,7 @@ package body Sem_Attr is
  ("expression for dimension must be static!", E1);
Error_Attr;
 
-elsif UI_To_Int (Expr_Value (E1)) > D
-  or else UI_To_Int (Expr_Value (E1)) < 1
-then
+elsif Expr_Value (E1) > D or else Expr_Value (E1) < 1 then
Error_Attr ("invalid dimension number for array type", E1);
 end if;
  end if;
@@ -4838,7 +4836,7 @@ package body Sem_Attr is
Error_Attr;
 
 elsif UI_To_Int (Intval (E1)) > Number_Formals (Entity (P))
-  or else UI_To_Int (Intval (E1)) < 0
+  or else Intval (E1) < 0
 then
Error_Attr ("invalid parameter number for % attribute", E1);
 end if;


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
@@ -10553,7 +10553,7 @@ package body Sem_Util is
 
  --  Position in the enumeration type starts at 0
 
- if UI_To_Int (Pos) < 0 then
+ if Pos < 0 then
 raise Constraint_Error;
  end if;
 




[Ada] Transform_Function_Array issues

2020-12-15 Thread Pierre-Marie de Rodat
As shown by ACATS c74209a, there are remaining cases where the
Transform_Function_Array does not trigger properly, related to private
types on one hand, and to freezing of function with no separate spec on
the other hand.

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

gcc/ada/

* exp_ch6.adb (Build_Procedure_Body_Form): Adjust, the
declaration of the procedure form is now insert before the
original function body rather than after.
(Expand_N_Subprogram_Declaration): Deal with private types whose
full views are arrays.
* exp_unst.adb (Unnest_Subprogram): Deal with private types.
(Needs_Fat_Pointer): Code cleanup.
* freeze.adb (Freeze_Subprogram): Ditto.
* exp_util.adb (Build_Procedure_Form): Insert the procedure form
decl before and not after.
* sem_ch6.adb (Analyze_Subprogram_Body_Helper): Build missing
spec when needed for Transform_Function_Array.
* sem_util.adb (Get_Fullest_View): Deal with null entity.diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb
--- a/gcc/ada/exp_ch6.adb
+++ b/gcc/ada/exp_ch6.adb
@@ -883,9 +883,8 @@ package body Exp_Ch6 is
is
   Loc : constant Source_Ptr := Sloc (Func_Body);
 
-  Proc_Decl : constant Node_Id   :=
-Next (Unit_Declaration_Node (Func_Id));
-  --  It is assumed that the next node following the declaration of the
+  Proc_Decl : constant Node_Id := Prev (Unit_Declaration_Node (Func_Id));
+  --  It is assumed that the node before the declaration of the
   --  corresponding subprogram spec is the declaration of the procedure
   --  form.
 
@@ -6571,6 +6570,7 @@ package body Exp_Ch6 is
   Prot_Bod  : Node_Id;
   Prot_Decl : Node_Id;
   Prot_Id   : Entity_Id;
+  Typ   : Entity_Id;
 
begin
   --  Deal with case of protected subprogram. Do not generate protected
@@ -6645,10 +6645,12 @@ package body Exp_Ch6 is
   --  are not needed by the C generator (and this also produces cleaner
   --  output).
 
+  Typ := Get_Fullest_View (Etype (Subp));
+
   if Transform_Function_Array
 and then Nkind (Specification (N)) = N_Function_Specification
-and then Is_Array_Type (Etype (Subp))
-and then Is_Constrained (Etype (Subp))
+and then Is_Array_Type (Typ)
+and then Is_Constrained (Typ)
 and then not Is_Unchecked_Conversion_Instance (Subp)
   then
  Build_Procedure_Form (N);


diff --git a/gcc/ada/exp_unst.adb b/gcc/ada/exp_unst.adb
--- a/gcc/ada/exp_unst.adb
+++ b/gcc/ada/exp_unst.adb
@@ -251,13 +251,8 @@ package body Exp_Unst is
---
 
function Needs_Fat_Pointer (E : Entity_Id) return Boolean is
-  Typ : Entity_Id := Etype (E);
-
+  Typ : constant Entity_Id := Get_Fullest_View (Etype (E));
begin
-  if Is_Private_Type (Typ) and then Present (Full_View (Typ)) then
- Typ := Full_View (Typ);
-  end if;
-
   return Is_Array_Type (Typ) and then not Is_Constrained (Typ);
end Needs_Fat_Pointer;
 
@@ -898,6 +893,8 @@ package body Exp_Unst is
  DT : Boolean := False;
  Formal : Node_Id;
  Subp   : Entity_Id;
+ F_Type : Entity_Id;
+ A_Type : Entity_Id;
 
   begin
  if Nkind (Name (N)) = N_Explicit_Dereference then
@@ -908,12 +905,16 @@ package body Exp_Unst is
 
  Actual := First_Actual (N);
  Formal := First_Formal_With_Extras (Subp);
+
  while Present (Actual) loop
-if Is_Array_Type (Etype (Formal))
-  and then not Is_Constrained (Etype (Formal))
-  and then Is_Constrained (Etype (Actual))
+F_Type := Get_Fullest_View (Etype (Formal));
+A_Type := Get_Fullest_View (Etype (Actual));
+
+if Is_Array_Type (F_Type)
+  and then not Is_Constrained (F_Type)
+  and then Is_Constrained (A_Type)
 then
-   Check_Static_Type (Etype (Actual), Empty, DT);
+   Check_Static_Type (A_Type, Empty, DT);
 end if;
 
 Next_Actual (Actual);


diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb
--- a/gcc/ada/exp_util.adb
+++ b/gcc/ada/exp_util.adb
@@ -3994,9 +3994,11 @@ package body Exp_Util is
   Out_Present => True,
   Parameter_Type  => New_Occurrence_Of (Etype (Subp), Loc)));
 
-  --  The new procedure declaration is inserted immediately after the
-  --  function declaration. The processing in Build_Procedure_Body_Form
-  --  relies on this order.
+  --  The new procedure declaration is inserted before the function
+  --  declaration. The pr

[Ada] Mark generic body outside of SPARK

2020-12-15 Thread Pierre-Marie de Rodat
New body for Ada.Text_IO.Float_IO makes explicit use of Long_Long_Float
which is not supported by GNATprove for now. Exclude that generic body
from SPARK explicitly so that the unit can be instantiated from SPARK
code.

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

gcc/ada/

* libgnat/a-tiflio.adb: Mark body not in SPARK.
* libgnat/a-tiflio.ads: Mark spec in SPARK.diff --git a/gcc/ada/libgnat/a-tiflio.adb b/gcc/ada/libgnat/a-tiflio.adb
--- a/gcc/ada/libgnat/a-tiflio.adb
+++ b/gcc/ada/libgnat/a-tiflio.adb
@@ -31,7 +31,7 @@
 
 with Ada.Text_IO.Float_Aux;
 
-package body Ada.Text_IO.Float_IO is
+package body Ada.Text_IO.Float_IO with SPARK_Mode => Off is
 
package Aux renames Ada.Text_IO.Float_Aux;
 


diff --git a/gcc/ada/libgnat/a-tiflio.ads b/gcc/ada/libgnat/a-tiflio.ads
--- a/gcc/ada/libgnat/a-tiflio.ads
+++ b/gcc/ada/libgnat/a-tiflio.ads
@@ -43,7 +43,7 @@
 private generic
type Num is digits <>;
 
-package Ada.Text_IO.Float_IO is
+package Ada.Text_IO.Float_IO with SPARK_Mode => On is
 
Default_Fore : Field := 2;
Default_Aft  : Field := Num'Digits - 1;




[Ada] Small adjustment to System.Val_Real

2020-12-15 Thread Pierre-Marie de Rodat
This recovers a few bits of precision by always using the Extra digit.

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

gcc/ada/

* libgnat/s-valrea.adb (Integer_to_Real): Always use Extra.diff --git a/gcc/ada/libgnat/s-valrea.adb b/gcc/ada/libgnat/s-valrea.adb
--- a/gcc/ada/libgnat/s-valrea.adb
+++ b/gcc/ada/libgnat/s-valrea.adb
@@ -82,13 +82,12 @@ package body System.Val_Real is
  System.Float_Control.Reset;
   end if;
 
-  --  Take into account the extra digit near the limit to avoid anomalies
+  --  Take into account the extra digit
 
-  if Extra > 0 and then Val <= Precision_Limit / Uns (Base) then
- R_Val := Num (Val * Uns (Base)) + Num (Extra);
+  R_Val := Num (Val);
+  if Extra > 0 then
+ R_Val := R_Val * Num (Base) + Num (Extra);
  S := S - 1;
-  else
- R_Val := Num (Val);
   end if;
 
   --  Compute the final value




[Ada] Small adjustment to parameterization of System.Value_R

2020-12-15 Thread Pierre-Marie de Rodat
This changes Precision_Limit from being computed based on the unsigned
type to being explicitly specified in the instantiation, and restores
its value to the precision of the mantissa for floating-pointt types.

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

gcc/ada/

* doc/gnat_ugn/gnat_and_program_execution.rst: Minor fix.
* gnat_ugn.texi: Regenerate.
* libgnat/s-valuer.ads (Precision_Limit): New formal parameter.
* libgnat/s-valuer.adb (Precision_Limit): Remove.
(Scan_Decimal_Digits): Robustify overflow check.
(Scan_Integral_Digits): Likewise.
* libgnat/s-valrea.adb: Add assertion on the size of the unsigned
type and instantiate System.Value_R with the mantissa limit.
(Integer_to_Real): Add Extra parameter and take it into account.
(Scan_Real): Pass Extra to Integer_to_Real.
(Value_Real): Likewise.
* libgnat/s-valued.adb: Add assertion on the size of the unsigned
type and instantiate System.Value_R with the mantissa limit.
* libgnat/s-valuef.adb: Likewise.diff --git a/gcc/ada/doc/gnat_ugn/gnat_and_program_execution.rst b/gcc/ada/doc/gnat_ugn/gnat_and_program_execution.rst
--- a/gcc/ada/doc/gnat_ugn/gnat_and_program_execution.rst
+++ b/gcc/ada/doc/gnat_ugn/gnat_and_program_execution.rst
@@ -1840,7 +1840,7 @@ improves performance for your program.
 
 .. _Floating_Point_Operations:
 
-Floating_Point_Operations
+Floating Point Operations
 ^
 
 .. index:: Floating-Point Operations


diff --git a/gcc/ada/gnat_ugn.texi b/gcc/ada/gnat_ugn.texi
--- a/gcc/ada/gnat_ugn.texi
+++ b/gcc/ada/gnat_ugn.texi
@@ -381,7 +381,7 @@ Performance Considerations
 * Optimization Levels:: 
 * Debugging Optimized Code:: 
 * Inlining of Subprograms:: 
-* Floating_Point_Operations:: 
+* Floating Point Operations:: 
 * Vectorization of loops:: 
 * Other Optimization Switches:: 
 * Optimization and Strict Aliasing:: 
@@ -19652,7 +19652,7 @@ some guidelines on debugging optimized code.
 * Optimization Levels:: 
 * Debugging Optimized Code:: 
 * Inlining of Subprograms:: 
-* Floating_Point_Operations:: 
+* Floating Point Operations:: 
 * Vectorization of loops:: 
 * Other Optimization Switches:: 
 * Optimization and Strict Aliasing:: 
@@ -20001,7 +20001,7 @@ Note that if you use @code{-g} you can then use the @code{strip} program
 on the resulting executable,
 which removes both debugging information and global symbols.
 
-@node Inlining of Subprograms,Floating_Point_Operations,Debugging Optimized Code,Performance Considerations
+@node Inlining of Subprograms,Floating Point Operations,Debugging Optimized Code,Performance Considerations
 @anchor{gnat_ugn/gnat_and_program_execution id32}@anchor{185}@anchor{gnat_ugn/gnat_and_program_execution inlining-of-subprograms}@anchor{100}
 @subsubsection Inlining of Subprograms
 
@@ -20140,9 +20140,9 @@ automatically assume that @code{-O3} is better than @code{-O2}, and
 indeed you should use @code{-O3} only if tests show that it actually
 improves performance for your program.
 
-@node Floating_Point_Operations,Vectorization of loops,Inlining of Subprograms,Performance Considerations
+@node Floating Point Operations,Vectorization of loops,Inlining of Subprograms,Performance Considerations
 @anchor{gnat_ugn/gnat_and_program_execution floating-point-operations}@anchor{186}@anchor{gnat_ugn/gnat_and_program_execution id33}@anchor{187}
-@subsubsection Floating_Point_Operations
+@subsubsection Floating Point Operations
 
 
 @geindex Floating-Point Operations
@@ -20188,7 +20188,7 @@ Note that the ABI has the same form for both floating-point models,
 so it is permissible to mix units compiled with and without these
 switches.
 
-@node Vectorization of loops,Other Optimization Switches,Floating_Point_Operations,Performance Considerations
+@node Vectorization of loops,Other Optimization Switches,Floating Point Operations,Performance Considerations
 @anchor{gnat_ugn/gnat_and_program_execution id34}@anchor{188}@anchor{gnat_ugn/gnat_and_program_execution vectorization-of-loops}@anchor{189}
 @subsubsection Vectorization of loops
 


diff --git a/gcc/ada/libgnat/s-valrea.adb b/gcc/ada/libgnat/s-valrea.adb
--- a/gcc/ada/libgnat/s-valrea.adb
+++ b/gcc/ada/libgnat/s-valrea.adb
@@ -36,13 +36,20 @@ with System.Value_R;
 
 package body System.Val_Real is
 
-   package Impl is new Value_R (Uns, Floating => True);
+   pragma Assert (Num'Machine_Mantissa <= Uns'Size);
+   --  We need an unsigned type large enough to represent the mantissa
+
+   Precision_Limit : constant Uns := 2**Num'Machine_Mantissa - 1;
+   --  We use the precision of the floating-point type
+
+   package Impl is new Value_R (Uns, Precision_Limit, Floating => True);
 
function Integer_to_Real
  (Str   : String;
   Val   : Uns;
   Base  : Unsigned;
   Scale : Integer;
+  Extra : Unsigned;
   Minus : Boolean) return Num;
--  Convert the real value from integer to real representation
 

[Ada] Implement tiered support for floating-point input operations

2020-12-15 Thread Pierre-Marie de Rodat
This changes the implementation of input operations for floating-point
types from using Long_Long_Float for all floating-point types to using
a base type tailored to the type being operated on.

This comprises adjusting Ada.Text_IO.Float_IO and Ada.Text_IO.Complex_IO
to the new approach, as well as sibling packages in the Ada.Wide_Text_IO
and Ada.Wide_Wide_Text_IO hierarchies.

Note that this skips Short_Float, because Short_Float has always been a
copy of Float for GNAT and, for good measures, remove System.Fat_SFlt.

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

gcc/ada/

* Makefile.rtl (GNATRTL_NONTASKING_OBJS): Remove s-fatsfl$(objext)
and add s-valflt$(objext), s-vallfl$(objext), s-valllf$(objext).
* exp_attr.adb (Find_Fat_Info): Merge Short_Float and Float cases.
* exp_imgv.adb (Expand_Value_Attribute): Replace RE_Value_Real with
RE_Value_Long_Long_Float for fixed-point types and use appropriate
base type for floating-point types.
* rtsfind.ads (RTU_Id): Remove System_Fat_IEEE_Long_Float,
System_Fat_IEEE_Short_Float and System_Val_Real, add System_Val_Flt,
System_Val_LFlt and System_Val_LLF.
(RE_Id): Remove RE_Attr_IEEE_Long, RE_Fat_IEEE_Long,
RE_Attr_IEEE_Short, RE_Fat_IEEE_Short, RE_Attr_Short_Float, add
RE_Value_Float, RE_Value_Long_Float, RE_Value_Long_Long_Float,
(RE_Unit_Table): Likewise.
* libgnat/a-ticoau.ads: Add with clause for Float_Aux and make the
package generic.
(Get): Change parameter types to Num.
(Put): Likewise.
(Gets): Likewise.
(Puts): Likewise.
* libgnat/a-ticoau.adb: Remove clause and renaming for Float_Aux.
(Get): Change parameter types to Num.
(Gets): Likewise.
(Put): Likewise.
(Puts): Likewise.  Add conversion to Long_Long_Float.
* libgnat/a-ticoio.adb: Remove with clause for Ada.Text_IO, add with
clause for Float_Aux, add with and use clauses for System.Val_Flt,
System.Val_LFlt and System.Val_LLF. Instantiate Float_Aux and
Complex_Aux on Float, Long_Float, and Long_Long_Float.
(OK_Float): New boolean constant.
(OK_Long_Float): Likewise.
(Get): Call appropriate Get routine from auxiliary package.
(Get): Call appropriate Gets routine from auxiliary package.
(Put): Call appropriate Put routine from auxiliary package.
(Put): Call appropriate Puts routine from auxiliary package.
* libgnat/a-tideau.adb: Remove with and use clause for Float_Aux.
* libgnat/a-tifiau.adb: Likewise.
* libgnat/a-tifiio.adb: Add with and use clause for System.Val_LLF.
Instantiate Float_Aux on Long_Long_Float.
(Get): Adjust call to Get routine from auxiliary package.
(Get): Adjust call to Gets routine from auxiliary package.
(Put): Adjust call to Put routine from auxiliary package.
(Put): Adjust call to Puts routine from auxiliary package.
* libgnat/a-tifiio__128.adb: Likewise.
(Get): Likewise.
(Get): Likewise.
(Put): Likewise.
(Put): Likewise.
* libgnat/a-tiflau.ads: Make the package generic.
(Get): Change parameter type to Num.
(Put): Likewise.
(Gets): Likewise.
(Puts): Likewise.
* libgnat/a-tiflau.adb: Remove clauses for System.Val_Real.
(Get): Change parameter type to Num and call Scan routine.
(Gets): Likewise.
(Load_Real): Move to...
(Put): Change parameter type and add conversion to Long_Long_Float.
(Puts): Likewise.
* libgnat/a-tiflio.adb: Add with and use clauses for System.Val_Flt,
System.Val_LFlt and System.Val_LLF. Instantiate Float_Aux on Float,
Long_Float and Long_Long_Float.
(OK_Float): New boolean constant.
(OK_Long_Float): Likewise.
(Get): Call appropriate Get routine from auxiliary package.
(Get): Call previous variant.
(Get): Call appropriate Gets routine from auxiliary package.
(Put): Call appropriate Put routine from auxiliary package.
(Put): Call previous variant.
(Put): Call appropriate Puts routine from auxiliary package.
* libgnat/a-tigeau.ads (Load_Real): New procedure.
* libgnat/a-tigeau.adb (Load_Real): ...here.
* libgnat/a-wtcoau.ads: Add with clause for Float_Aux and make the
package generic.
(Get): Change parameter types to Num.
(Put): Likewise.
(Gets): Likewise.
(Puts): Likewise.
* libgnat/a-wtcoau.adb: Remove clause and renaming for Float_Aux.
(Get): Change parameter types to Num.
(Gets): Likewise.
(Put): Likewise.
(Puts): Likewise.  Add conversion to Long_Long_Float.
* libgnat/a-wtcoio.ads: Remove use clause for Complex_Types and use
qualified names throughout accordingly.
* libgnat/a-wtcoio.adb: Re

[Ada] Complain about missing -gnat2020 switch on iterator_filter

2020-12-15 Thread Pierre-Marie de Rodat
Reuse Error_Msg_Ada_2020_Feature to complain about a missing -gnat2020
switch when compiling iterator_filter that would be legal in Ada 2020,
but the compiler is expecting an earlier version of the language.

A small enhancement; opportunity spotted while adding support for
iterator filters in GNATprove.

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

gcc/ada/

* par-ch5.adb (P_Loop_Parameter_Specification): Complain about
missing -gnat2020 switch.
(P_Iterator_Specification): Likewise.diff --git a/gcc/ada/par-ch5.adb b/gcc/ada/par-ch5.adb
--- a/gcc/ada/par-ch5.adb
+++ b/gcc/ada/par-ch5.adb
@@ -1712,9 +1712,9 @@ package body Ch5 is
   Set_Discrete_Subtype_Definition
 (Loop_Param_Specification_Node, P_Discrete_Subtype_Definition);
 
-  if Ada_Version >= Ada_2020
- and then Token = Tok_When
-  then
+  if Token = Tok_When then
+ Error_Msg_Ada_2020_Feature ("iterator filter", Token_Ptr);
+
  Scan; -- past WHEN
  Set_Iterator_Filter
(Loop_Param_Specification_Node, P_Condition);
@@ -1773,9 +1773,9 @@ package body Ch5 is
 
   Set_Name (Node1, P_Name);
 
-  if Ada_Version >= Ada_2020
- and then Token = Tok_When
-  then
+  if Token = Tok_When then
+ Error_Msg_Ada_2020_Feature ("iterator filter", Token_Ptr);
+
  Scan; -- past WHEN
  Set_Iterator_Filter
(Node1, P_Condition);




[Ada] Refactor repeated complains about missing -gnat2005 switch

2020-12-15 Thread Pierre-Marie de Rodat
Refactor repeated code in the parser for complaining about a missing
-gnat2005 switch. Fix singular-vs-plural phrasing.

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

gcc/ada/

* errout.ads (Error_Msg_Ada_2005_Extension): New routine (spec).
* errout.adb (Error_Msg_Ada_2005_Extension): New routine (body).
* par-ch10.adb: Reuse new routine; correct casing for "LIMITED
WITH".
* par-ch11.adb: Likewise.
* par-ch12.adb: Likewise.
* par-ch3.adb: Likewise.
* par-ch4.adb: Likewise; replace "box" with "<>".
* par-ch6.adb: Likewise.
* par-ch9.adb: Likewise; correct casing for "THEN ABORT".diff --git a/gcc/ada/errout.adb b/gcc/ada/errout.adb
--- a/gcc/ada/errout.adb
+++ b/gcc/ada/errout.adb
@@ -612,6 +612,25 @@ package body Errout is
   end;
end Error_Msg;
 
+   --
+   -- Error_Msg_Ada_2005_Extension --
+   --
+
+   procedure Error_Msg_Ada_2005_Extension (Extension : String) is
+  Loc : constant Source_Ptr := Token_Ptr;
+   begin
+  if Ada_Version < Ada_2005 then
+ Error_Msg (Extension & " is an Ada 2005 extension", Loc);
+
+ if No (Ada_Version_Pragma) then
+Error_Msg ("\unit must be compiled with -gnat05 switch", Loc);
+ else
+Error_Msg_Sloc := Sloc (Ada_Version_Pragma);
+Error_Msg ("\incompatible with Ada version set#", Loc);
+ end if;
+  end if;
+   end Error_Msg_Ada_2005_Extension;
+

-- Error_Msg_Ada_2012_Feature --



diff --git a/gcc/ada/errout.ads b/gcc/ada/errout.ads
--- a/gcc/ada/errout.ads
+++ b/gcc/ada/errout.ads
@@ -902,6 +902,11 @@ package Errout is
--  overridden interface primitive Iface_Prim) indicating wrong mode of the
--  first formal (RM 9.4(11.9/3)).
 
+   procedure Error_Msg_Ada_2005_Extension (Extension : String);
+   --  Analogous to Error_Msg_Ada_2012_Feature, but phrase the message using
+   --  "extension" and not "feature". This routine is only used in the parser,
+   --  so the error is always placed at the Token_Ptr.
+
procedure Error_Msg_Ada_2012_Feature (Feature : String; Loc : Source_Ptr);
--  If not operating in Ada 2012 mode or higher, posts errors complaining
--  that Feature is only supported in Ada 2012, with appropriate suggestions


diff --git a/gcc/ada/par-ch10.adb b/gcc/ada/par-ch10.adb
--- a/gcc/ada/par-ch10.adb
+++ b/gcc/ada/par-ch10.adb
@@ -861,11 +861,7 @@ package body Ch10 is
  ("unexpected LIMITED ignored");
 end if;
 
-if Ada_Version < Ada_2005 then
-   Error_Msg_SP ("LIMITED WITH is an Ada 2005 extension");
-   Error_Msg_SP
- ("\unit must be compiled with -gnat05 switch");
-end if;
+Error_Msg_Ada_2005_Extension ("`LIMITED WITH`");
 
  elsif Token = Tok_Private then
 Has_Limited := False;
@@ -879,13 +875,10 @@ package body Ch10 is
 
Restore_Scan_State (Scan_State); -- to PRIVATE
return Item_List;
-
-elsif Ada_Version < Ada_2005 then
-   Error_Msg_SP ("`PRIVATE WITH` is an Ada 2005 extension");
-   Error_Msg_SP
- ("\unit must be compiled with -gnat05 switch");
 end if;
 
+Error_Msg_Ada_2005_Extension ("`PRIVATE WITH`");
+
  else
 Has_Limited := False;
 Has_Private := False;


diff --git a/gcc/ada/par-ch11.adb b/gcc/ada/par-ch11.adb
--- a/gcc/ada/par-ch11.adb
+++ b/gcc/ada/par-ch11.adb
@@ -227,10 +227,7 @@ package body Ch11 is
   end if;
 
   if Token = Tok_With then
- if Ada_Version < Ada_2005 then
-Error_Msg_SC ("string expression in raise is Ada 2005 extension");
-Error_Msg_SC ("\unit must be compiled with -gnat05 switch");
- end if;
+ Error_Msg_Ada_2005_Extension ("string expression in raise");
 
  Scan; -- past WITH
  Set_Expression (Raise_Node, P_Expression);


diff --git a/gcc/ada/par-ch12.adb b/gcc/ada/par-ch12.adb
--- a/gcc/ada/par-ch12.adb
+++ b/gcc/ada/par-ch12.adb
@@ -349,13 +349,8 @@ package body Ch12 is
   --  Ada 2005: an association can be given by: others => <>
 
   if Token = Tok_Others then
- if Ada_Version < Ada_2005 then
-Error_Msg_SP
-  ("partial parameterization of formal packages"
-   & " is an Ada 2005 extension");
-Error_Msg_SP
-  ("\unit must be compiled with -gnat05 switch");
- end if;
+ Error_Msg_Ada_2005_Extension
+   ("partial parameterization of formal package");
 
  Scan;  --  past OTHERS
 
@@ -478,12 +473,8 @@ package body Ch12 is
 Set_Access_Definition (Decl_Node,
   P_Access_Definition (Not_Null_Present));
 
-if Ada_Version < Ada_2005 th

[Ada] Postcondition checks performed before finalization

2020-12-15 Thread Pierre-Marie de Rodat
This patch fixes an issue in the compiler whereby postconditions were
incorrectly checked prior to the execution of finalization.

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

gcc/ada/

* contracts.adb, contracts.ads (Build_Postconditions_Procedure):
Add declarations for Postcond_Enabled,
Result_Object_For_Postcondition, and
Return_Success_For_Postcond, and place all postconditions within
an if statement to control their execution for interactions when
cleanup actions get generated.
(Get_Postcond_Enabled): Created to fetch object declared to
handle new expansion of postconditions.
(Get_Result_Object_For_Postcond): Created to fetch object
declared to handle new expansion of postconditions.
(Get_Return_Success_For_Postcond): Created to fetch object
declared to handle new expansion of postconditions.
* einfo.adb, einfo.ads: Modify flag Stores_Attribute_Old_Prefix
to apply to constants, variables, and types.
* exp_ch6.adb (Add_Return): Add assignment to
Return_Success_For_Postcond.
(Expand_Non_Function_Return): Add assignment to
Return_Success_For_Postcond
(Expand_Simple_Function_Return): Add assignment to
Result_Object_For_Postcond and Return_Success_For_Postcond.
* exp_ch7.adb (Build_Finalization_Master): Mark finalization
masters which finalize types created store 'Old objects as
storing 'Old objects.
(Build_Finalizer): Created to generated a unified and special
expansion for finalization when postconditions are present.
(Build_Finalizer_Helper): Renamed Build_Finalizer and added
parameter to facilitate the creation of separate finalization
routines for 'Old objects and general objects.
(Create_Finalizer): Add condition for the insertion of the
finalizer spec to avoid malformed trees.
(Expand_Cleanup_Actions): Move _postconditions and related
declarations to the new declarative section.  Fix the loop to
properly stop at the subprogram declaration for the
postconditions procedure and exclude its body from being moved
to the new list of declarations to avoid freezing issues.
* exp_prag.adb (Expand_Attributes): Mark temporary created to
store 'Old objects as storing a 'Old attribute.
* sem_ch6.adb (Find_What_Applies_To): Remove strange exception
to postconditions when traversing the scope stack.
* sem_prag.adb (Find_Related_Declaration_Or_Body): Use the newly
created Enclosing_HSS function to find the HSS for a potentially
nested statement.
* sem_util.adb, sem_util.ads (Declare_Indirect_Temp): Mark types
created to store 'Old objects as storing 'Old attributes.
(Enclosing_HSS): Created to find the enclosing handled sequence
of statements for a given statement.
* snames.ads-tmpl: Add multiple names to aid in the expansion of
finalization and to control the evaluation of postconditions.
Including _finalization_controller, a new routine to centralize
finalization actions and postcondition evaluation.

patch.diff.gz
Description: application/gzip


[Ada] Fix serial port baud rate setting on GNU/Linux

2020-12-15 Thread Pierre-Marie de Rodat
This fixes an issue when setting the baud rate. The baud rate is set
using the cfsetospeed and cfsetispeed system calls. The code is using
speed_t for clarity. The non-blocking status is only reset when Block is
True. And serial blocking mode is now properly set according to termios
manual.

Add documentation about a way to debug and test a serial port on
GNU/Linux without the need for a physical serial port.

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

gcc/ada/

* libgnat/g-sercom__linux.adb (Set): Use cfsetospeed and
cfsetispeed to set the baud rate. Clear non-blocking serial port
status when blocking is requested.diff --git a/gcc/ada/libgnat/g-sercom__linux.adb b/gcc/ada/libgnat/g-sercom__linux.adb
--- a/gcc/ada/libgnat/g-sercom__linux.adb
+++ b/gcc/ada/libgnat/g-sercom__linux.adb
@@ -30,6 +30,33 @@
 --
 
 --  This is the GNU/Linux implementation of this package
+--
+--  Testing on GNU/Linux can be done with socat & stty tools.
+--
+--  First in a terminal create a virtual serial port:
+--
+--  * First solution, the terminal is one of the side of the channel
+--characters written with Write into the port will be displayed
+--there and characters typed into the terminal will be send to the
+--channel and will be received by a Read call.
+--
+-- $ socat PTY,link=/tmp/virtual-tty,raw,echo=1 -
+--
+--  * Second solution, the virtual channel contains two side and the
+--program can Read and Write date to it.
+--
+-- $ socat PTY,link=/tmp/virtual-tty,raw,echo=1 \
+-- PTY,link=/tmp/virtual-tty,raw,echo=1
+--
+--  Connect to this virtual serial port with:
+--
+-- Open (Port => P, Name => "/tmp/virtual-tty");
+--
+--  Do any settings using the Set routine below, then you can check
+--  the serial port configuration with:
+--
+-- $ stty --file /tmp/virtual-tty
+--
 
 with Ada.Streams;  use Ada.Streams;
 
@@ -52,6 +79,34 @@ package body GNAT.Serial_Communications is
function fcntl (fd : int; cmd : int; value : int) return int;
pragma Import (C, fcntl, "fcntl");
 
+   C_Data_Rate : constant array (Data_Rate) of unsigned :=
+   (B75  => OSC.B75,
+B110 => OSC.B110,
+B150 => OSC.B150,
+B300 => OSC.B300,
+B600 => OSC.B600,
+B1200=> OSC.B1200,
+B2400=> OSC.B2400,
+B4800=> OSC.B4800,
+B9600=> OSC.B9600,
+B19200   => OSC.B19200,
+B38400   => OSC.B38400,
+B57600   => OSC.B57600,
+B115200  => OSC.B115200,
+B230400  => OSC.B230400,
+B460800  => OSC.B460800,
+B50  => OSC.B50,
+B576000  => OSC.B576000,
+B921600  => OSC.B921600,
+B100 => OSC.B100,
+B1152000 => OSC.B1152000,
+B150 => OSC.B150,
+B200 => OSC.B200,
+B250 => OSC.B250,
+B300 => OSC.B300,
+B350 => OSC.B350,
+B400 => OSC.B400);
+
C_Bits  : constant array (Data_Bits) of unsigned :=
(CS7 => OSC.CS7, CS8 => OSC.CS8);
 
@@ -162,6 +217,8 @@ package body GNAT.Serial_Communications is
is
   use OSC;
 
+  subtype speed_t is unsigned;
+
   type termios is record
  c_iflag  : unsigned;
  c_oflag  : unsigned;
@@ -169,8 +226,8 @@ package body GNAT.Serial_Communications is
  c_lflag  : unsigned;
  c_line   : unsigned_char;
  c_cc : Interfaces.C.char_array (0 .. 31);
- c_ispeed : unsigned;
- c_ospeed : unsigned;
+ c_ispeed : speed_t;
+ c_ospeed : speed_t;
   end record;
   pragma Convention (C, termios);
 
@@ -184,9 +241,15 @@ package body GNAT.Serial_Communications is
   function tcflush (fd : int; queue_selector : int) return int;
   pragma Import (C, tcflush, "tcflush");
 
+  function cfsetospeed (termios_p : Address; speed : speed_t) return int;
+  pragma Import (C, cfsetospeed, "cfsetospeed");
+
+  function cfsetispeed (termios_p : Address; speed : speed_t) return int;
+  pragma Import (C, cfsetispeed, "cfsetispeed");
+
   Current : termios;
 
-  Res : int;
+  Res : int := 0;
   pragma Warnings (Off, Res);
   --  Warnings off, since we don't always test the result
 
@@ -205,6 +268,7 @@ package body GNAT.Serial_Communications is
or C_Stop_Bits (Stop_Bits)
or C_Parity (Parity)
or CREAD;
+
   Current.c_iflag := 0;
   Current.c_lflag := 0;
   Current.c_of

[committed] libstdc++: Use init_priority attribute for Init object [PR 98108]

2020-12-15 Thread Jonathan Wakely via Gcc-patches
This causes the global objects that run the  initialization
code to be constructed earlier, which avoids some bugs in user code due
to incorrectly relying on static initialization order.

libstdc++-v3/ChangeLog:

PR libstdc++/98108
* include/std/iostream (__ioinit): Add init_priority attribute.

Tested powerpc64le-linux. Committed to trunk.

commit cf4ed3b41594b6935a337fe0aaf8149eadf88751
Author: Jonathan Wakely 
Date:   Tue Dec 15 11:40:06 2020

libstdc++: Use init_priority attribute for Init object [PR 98108]

This causes the global objects that run the  initialization
code to be constructed earlier, which avoids some bugs in user code due
to incorrectly relying on static initialization order.

libstdc++-v3/ChangeLog:

PR libstdc++/98108
* include/std/iostream (__ioinit): Add init_priority attribute.

diff --git a/libstdc++-v3/include/std/iostream 
b/libstdc++-v3/include/std/iostream
index f988342b90a..6b2f964f688 100644
--- a/libstdc++-v3/include/std/iostream
+++ b/libstdc++-v3/include/std/iostream
@@ -70,8 +70,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 #endif
   //@}
 
+#if __has_attribute(__init_priority__)
+# define _GLIBCXX_INIT_PRIO(N) __attribute__((__init_priority__(N)))
+#else
+# define _GLIBCXX_INIT_PRIO(N)
+#endif
+
   // For construction of filebuffers for cout, cin, cerr, clog et. al.
-  static ios_base::Init __ioinit;
+  static ios_base::Init __ioinit _GLIBCXX_INIT_PRIO(90);
+
+#undef _GLIBCXX_INIT_PRIO
 
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace


Re: Problem building libstdc++ for the avr target

2020-12-15 Thread Jonathan Wakely via Gcc-patches

On 10/12/20 18:39 +0100, Vladimir V via Libstdc++ wrote:

Hello.

Could you please have a look at my trivial patch.
It works as intended with avr-libc and doesn't seem to introduce
regressions for x86_64 hosts.


I've pushed this to master now, thanks for the patch.


What would be your suggestions for testing?

Thank you
Vladimir

чт, 10 дек. 2020 г. в 00:00, Vladimir V :


Thank you for the quick response.
The patch solves the problem.

ср, 9 дек. 2020 г. в 18:01, Jonathan Wakely :


On 09/12/20 12:49 +, Jonathan Wakely wrote:
>On 09/12/20 13:32 +0100, Vladimir V wrote:
>>Hello.
>>
>>While testing with the current upstream I encountered a compilation
issue.
>>Although I build with "--disable-threads" flag the following error
occurs:
>>
>>../../../../../libstdc++-v3/src/c++11/thread.cc:39:4: error: #error "No
>>sleep function known for this target"
>>
>>Previously the check was inside the  #ifdef _GLIBCXX_HAS_GTHREADS that
>>prevented the error from happening (in my case with gcc v10.1),
>>So I would like to ask if the thread.cc should be involved in the build
if
>>the threads support is configured to be disabled?
>
>Yes, the file is always built, but which definitions it contains
>depends on what is configured for the target.
>
>The std::this_thread::sleep_for and std::this_thread::sleep_until
>functions don't actually depend on threads at all. They just sleep.
>
>But that still requires target support, just different support from
>threads.
>
>>And if it should, then can the condition be reworked to cover the
described
>>case?
>
>Yes, I'll do that. Thanks for bringing it to my attention.
>
>I assume we can't use avr-libc's delay functions, because they depend
>on the CPU clock frequency, which isn't known when we compile
>libstdc++. So I'll just suppress the declarations of those functions
>and remove the #error.

The attached patch adds a new _GLIBCXX_NO_SLEEP configure macro which
should get defined for your hosted AVR build. That should mean that
std::this_thread::sleep_for is not defined, and src/c++11/thread.cc
will no longer insist on some way to sleep being supported.

I've only tested this on powerpc64le-linux, so please let me know if
it works for you.

Pushed to master.






From fbb2144b56625adf594f8812189b983fa66c910a Mon Sep 17 00:00:00 2001
From: Vladimir Vishnevsky 
Date: Tue, 8 Dec 2020 21:45:26 +0100
Subject: [PATCH] Disabling AC_LIBTOOL_DLOPEN check if building with avr-libc

The AC_LIBTOOL_DLOPEN checks were previously disabled for newlib targets.
The patch applies similar logic to avr-libc based builds.

2020-12-08 Vladimir Vishnevsky 

libstdc++-v3/ChangeLog:
   Disabling AC_LIBTOOL_DLOPEN check if building with avr-libc.
   * configure.ac: Skip AC_LIBTOOL_DLOPEN check if avr-libc is used.
   * configure: Regenerate.
---
libstdc++-v3/configure.ac | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libstdc++-v3/configure.ac b/libstdc++-v3/configure.ac
index cbfdf4c6bad..771814110a1 100644
--- a/libstdc++-v3/configure.ac
+++ b/libstdc++-v3/configure.ac
@@ -90,7 +90,7 @@ AC_SYS_LARGEFILE
GLIBCXX_CONFIGURE

# Libtool setup.
-if test "x${with_newlib}" != "xyes"; then
+if test "x${with_newlib}" != "xyes" && test "x${with_avrlibc}" != "xyes"; then
  AC_LIBTOOL_DLOPEN
fi
AM_PROG_LIBTOOL
--
2.17.1





[committed] libstdc++: Remove workaround for PR c++/78173

2020-12-15 Thread Jonathan Wakely via Gcc-patches
Now that the G++ bug is fixed we no longer need to protect this partial
specialization from complaining about subtracting void pointers.

libstdc++-v3/ChangeLog:

* include/bits/iterator_concepts.h (incrementable_traits):
Remove workaround for PR c++/78173.

Tested powerpc64le-linux. Committed to trunk.

commit fa452a843d26a64a5ca0fd7c17ea1bd6e1b81a69
Author: Jonathan Wakely 
Date:   Tue Dec 15 11:40:07 2020

libstdc++: Remove workaround for PR c++/78173

Now that the G++ bug is fixed we no longer need to protect this partial
specialization from complaining about subtracting void pointers.

libstdc++-v3/ChangeLog:

* include/bits/iterator_concepts.h (incrementable_traits):
Remove workaround for PR c++/78173.

diff --git a/libstdc++-v3/include/bits/iterator_concepts.h 
b/libstdc++-v3/include/bits/iterator_concepts.h
index 6668caa8185..414a81e7249 100644
--- a/libstdc++-v3/include/bits/iterator_concepts.h
+++ b/libstdc++-v3/include/bits/iterator_concepts.h
@@ -163,10 +163,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template
 requires (!requires { typename _Tp::difference_type; }
  && requires(const _Tp& __a, const _Tp& __b)
- {
-   requires (!is_void_v>); // PR c++/78173
-   { __a - __b } -> integral;
- })
+ { { __a - __b } -> integral; })
 struct incrementable_traits<_Tp>
 {
   using difference_type


[PATCH v6] cacheflush.2: Document __builtin___clear_cache() as a more portable alternative

2020-12-15 Thread Alejandro Colomar via Gcc-patches
Reported-by: Heinrich Schuchardt 
Signed-off-by: Alejandro Colomar 
Cc: Martin Sebor 
Cc: Dave Martin 
---

v6:
- GCC has always exposed 'void *', as Martin Sebor noted.
  It's Clang (and maybe others) that (following GCC's docs)
  exposed 'char *'.

 man2/cacheflush.2 | 24 
 1 file changed, 24 insertions(+)

diff --git a/man2/cacheflush.2 b/man2/cacheflush.2
index aba625721..7a2eed506 100644
--- a/man2/cacheflush.2
+++ b/man2/cacheflush.2
@@ -86,6 +86,30 @@ On Linux, this call first appeared on the MIPS architecture,
 but nowadays, Linux provides a
 .BR cacheflush ()
 system call on some other architectures, but with different arguments.
+.SH NOTES
+Unless you need the finer grained control that this system call provides,
+you probably want to use the GCC built-in function
+.BR __builtin___clear_cache (),
+which provides a portable interface
+across platforms supported by GCC and compatible compilers:
+.PP
+.in +4n
+.EX
+.BI "void __builtin___clear_cache(void *" begin ", void *" end );
+.EE
+.in
+.PP
+On platforms that don't require instruction cache flushes,
+.BR __builtin___clear_cache ()
+has no effect.
+.PP
+.IR Note :
+On some GCC-compatible compilers,
+the prototype for this built-in function uses
+.I char *
+instead of
+.I void *
+for the parameters.
 .SH BUGS
 Linux kernels older than version 2.6.11 ignore the
 .I addr
-- 
2.29.2



Re: [PATCH] nvptx: Cache stacks block for OpenMP kernel launch

2020-12-15 Thread Julian Brown
On Tue, 8 Dec 2020 20:11:38 +0300
Alexander Monakov  wrote:

> On Tue, 8 Dec 2020, Julian Brown wrote:
> 
> > Ping?  
> 
> This has addressed my concerns, thanks.

Jakub, Tom -- just to confirm, is this OK for trunk now?

I noticed a slight bugfix myself in the no-stacks/out-of-memory case --
i.e. for OpenACC, in nvptx_stacks_free. The attached version of the
patch includes that fix.

Thanks,

Julian

commit 2e4160f0f0532890f6a2b405222f02c7ee1bb0ac
Author: Julian Brown 
Date:   Wed Oct 21 10:00:19 2020 -0700

nvptx: Cache stacks block for OpenMP kernel launch

2020-11-13  Julian Brown  

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

diff --git a/libgomp/plugin/plugin-nvptx.c b/libgomp/plugin/plugin-nvptx.c
index 11d4ceeae62e..e08c36094098 100644
--- a/libgomp/plugin/plugin-nvptx.c
+++ b/libgomp/plugin/plugin-nvptx.c
@@ -49,6 +49,15 @@
 #include 
 #include 
 
+/* An arbitrary fixed limit (128MB) for the size of the OpenMP soft stacks
+   block to cache between kernel invocations.  For soft-stacks blocks bigger
+   than this, we will free the block before attempting another GPU memory
+   allocation (i.e. in GOMP_OFFLOAD_alloc).  Otherwise, if an allocation fails,
+   we will free the cached soft-stacks block anyway then retry the
+   allocation.  If that fails too, we lose.  */
+
+#define SOFTSTACK_CACHE_LIMIT 134217728
+
 #if CUDA_VERSION < 6000
 extern CUresult cuGetErrorString (CUresult, const char **);
 #define CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_MULTIPROCESSOR 82
@@ -307,6 +316,14 @@ struct ptx_device
   struct ptx_free_block *free_blocks;
   pthread_mutex_t free_blocks_lock;
 
+  /* OpenMP stacks, cached between kernel invocations.  */
+  struct
+{
+  CUdeviceptr ptr;
+  size_t size;
+  pthread_mutex_t lock;
+} omp_stacks;
+
   struct ptx_device *next;
 };
 
@@ -514,6 +531,10 @@ nvptx_open_device (int n)
   ptx_dev->free_blocks = NULL;
   pthread_mutex_init (&ptx_dev->free_blocks_lock, NULL);
 
+  ptx_dev->omp_stacks.ptr = 0;
+  ptx_dev->omp_stacks.size = 0;
+  pthread_mutex_init (&ptx_dev->omp_stacks.lock, NULL);
+
   return ptx_dev;
 }
 
@@ -534,6 +555,11 @@ nvptx_close_device (struct ptx_device *ptx_dev)
   pthread_mutex_destroy (&ptx_dev->free_blocks_lock);
   pthread_mutex_destroy (&ptx_dev->image_lock);
 
+  pthread_mutex_destroy (&ptx_dev->omp_stacks.lock);
+
+  if (ptx_dev->omp_stacks.ptr)
+CUDA_CALL (cuMemFree, ptx_dev->omp_stacks.ptr);
+
   if (!ptx_dev->ctx_shared)
 CUDA_CALL (cuCtxDestroy, ptx_dev->ctx);
 
@@ -999,12 +1025,40 @@ goacc_profiling_acc_ev_alloc (struct goacc_thread *thr, void *dp, size_t s)
   GOMP_PLUGIN_goacc_profiling_dispatch (prof_info, &data_event_info, api_info);
 }
 
+/* Free the cached soft-stacks block if it is above the SOFTSTACK_CACHE_LIMIT
+   size threshold, or if FORCE is true.  */
+
+static void
+nvptx_stacks_free (struct ptx_device *ptx_dev, bool force)
+{
+  pthread_mutex_lock (&ptx_dev->omp_stacks.lock);
+  if (ptx_dev->omp_stacks.ptr
+  && (force || ptx_dev->omp_stacks.size > SOFTSTACK_CACHE_LIMIT))
+{
+  CUresult r = CUDA_CALL_NOCHECK (cuMemFree, ptx_dev->omp_stacks.ptr);
+  if (r != CUDA_SUCCESS)
+	GOMP_PLUGIN_fatal ("cuMemFree error: %s", cuda_error (r));
+  ptx_dev->omp_stacks.ptr = 0;
+  ptx_dev->omp_stacks.size = 0;
+}
+  pthread_mutex_unlock (&ptx_dev->omp_stacks.lock);
+}
+
 static void *
-nvptx_alloc (size_t s)
+nvptx_alloc (size_t s, bool suppress_errors)
 {
   CUdeviceptr d;
 
-  CUDA_CALL_ERET (NULL, cuMemAlloc, &d, s);
+  CUresult r = CUDA_CALL_NOCHECK (cuMemAlloc, &d, s);
+  if (suppress_errors && r == CUDA_ERROR_OUT_OF_MEMORY)
+return NULL;
+  else if (r != CUDA_SUCCESS)
+{
+  GOMP_PLUGIN_error ("nvptx_alloc error: %s", cuda_error (r));
+  return NULL;
+}
+
+  /* NOTE: We only do profiling stuff if the memory allocation succeeds.  */
   struct goacc_thread *thr = GOMP_PLUGIN_goacc_thread ();
   bool profiling_p
 = __builtin_expect (thr != NULL && thr->prof_info != NULL, false);
@@ -1352,6 +1406,8 @@ GOMP_OFFLOAD_alloc (int ord, size_t size)
   ptx_dev->free_blocks = NULL;
   pthread_mutex_unlock (&ptx_dev->free_blocks_lock);
 
+  nvptx_stacks_free (ptx_dev, false);
+
   while (blocks)
 {
   tmp 

Re: [PATCH] nvptx: Cache stacks block for OpenMP kernel launch

2020-12-15 Thread Jakub Jelinek via Gcc-patches
On Tue, Dec 15, 2020 at 01:39:13PM +, Julian Brown wrote:
> @@ -1922,7 +1997,9 @@ GOMP_OFFLOAD_run (int ord, void *tgt_fn, void 
> *tgt_vars, void **args)
>nvptx_adjust_launch_bounds (tgt_fn, ptx_dev, &teams, &threads);
>  
>size_t stack_size = nvptx_stacks_size ();
> -  void *stacks = nvptx_stacks_alloc (stack_size, teams * threads);
> +
> +  pthread_mutex_lock (&ptx_dev->omp_stacks.lock);
> +  void *stacks = nvptx_stacks_acquire (ptx_dev, stack_size, teams * threads);
>void *fn_args[] = {tgt_vars, stacks, (void *) stack_size};
>size_t fn_args_size = sizeof fn_args;
>void *config[] = {
> @@ -1944,7 +2021,8 @@ GOMP_OFFLOAD_run (int ord, void *tgt_fn, void 
> *tgt_vars, void **args)
>  maybe_abort_msg);
>else if (r != CUDA_SUCCESS)
>  GOMP_PLUGIN_fatal ("cuCtxSynchronize error: %s", cuda_error (r));
> -  nvptx_stacks_free (stacks, teams * threads);
> +
> +  pthread_mutex_unlock (&ptx_dev->omp_stacks.lock);
>  }

Do you need to hold the omp_stacks.lock across the entire offloading?
Doesn't that serialize all offloading kernels to the same device?
I mean, can't the lock be taken just shortly at the start to either acquire
the cached stacks or allocate a fresh stack, and then at the end to put the
stack back into the cache?

Also, how will this caching interact with malloc etc. performed in target
regions?  Shall we do the caching only if there is no other concurrent
offloading to the device because the newlib malloc will not be able to
figure out it could free this and let the host know it has freed it.

Jakub



Re: [PATCH 29/31] PDP11: Use `const_double_zero' to express double zero constant

2020-12-15 Thread Maciej W. Rozycki
On Tue, 15 Dec 2020, Martin Liška wrote:

> If I see correctly, starting from this revision I can't compile a cross
> compiler of x86_64-linux-gnu:
> 
> ../configure --target=pdp11-aout --disable-bootstrap --enable-languages=c,c++
> --disable-multilib  --enable-obsolete

 Thanks for the heads-up and the details of the configuration, and sorry 
for the breakage.

> $ make
> build/genemit ../../gcc/common.md ../../gcc/config/pdp11/pdp11.md \
>   insn-conditions.md > tmp-emit.c
> genemit: Internal error: abort in gen_exp, at genemit.c:202
> make: *** [Makefile:2427: s-emit] Error 1
> 
> $ Breakpoint 1, fancy_abort (file=0x435238 "../../gcc/genemit.c", line=202,
> func=0x435230 "gen_exp") at ../../gcc/errors.c:133
> 133 internal_error ("abort in %s, at %s:%d", func, trim_filename (file),
> line);
> (gdb) bt
> #0  fancy_abort (file=0x435238 "../../gcc/genemit.c", line=202, func=0x435230
> "gen_exp") at ../../gcc/errors.c:133
> #1  0x00402e4b in gen_exp (x=0x470de0, subroutine_type=DEFINE_INSN,
> used=0x4aa4b0 "", info=0x7fffdea0) at ../../gcc/genemit.c:202
> #2  0x00402f68 in gen_exp (x=0x4d6c70, subroutine_type=DEFINE_INSN,
> used=0x4aa4b0 "", info=0x7fffdea0) at ../../gcc/genemit.c:227
> #3  0x00402f68 in gen_exp (x=0x4d6c50, subroutine_type=DEFINE_INSN,
> used=0x4aa4b0 "", info=0x7fffdea0) at ../../gcc/genemit.c:227
> #4  0x0040307d in gen_exp (x=0x4aa490, subroutine_type=DEFINE_INSN,
> used=0x4aa4b0 "", info=0x7fffdea0) at ../../gcc/genemit.c:255
> #5  0x004036c1 in gen_insn (info=0x7fffdea0) at
> ../../gcc/genemit.c:435
> #6  0x00404930 in main (argc=3, argv=0x7fffdfc8) at
> ../../gcc/genemit.c:911

 I don't have the target environment available and consequently the target 
does not complete building for me:

The directory that should contain system headers does not exist:
  .../usr/sysroot/usr/include
make[2]: *** [Makefile:3218: stmp-fixinc] Error 1

or otherwise I would have at least tried to compile it before submitting 
the change.  The configuration does build far enough to trigger this issue 
though and I can confirm the change is indeed the culprit.

> Can you please take a look?

 I'm fairly sure this is due to the difference in TARGET_SUPPORTS_WIDE_INT
with the VAX backend vs the PDP-11 one.  I have an idea how this should be 
addressed and will be implementing it shortly.

 NB the backend fails `-Werror' compilation:

In file included from ./tm.h:18,
 from .../gcc/backend.h:28,
 from .../gcc/varasm.c:31:
.../gcc/varasm.c: In function 'void assemble_zeros(long unsigned int)':
.../gcc/config/pdp11/pdp11.h:622:20: error: format '%o' expects argument of 
type 'unsigned int', but argument 3 has type 'long unsigned int' 
[-Werror=format=]
  622 | fprintf (FILE, "\t.blkb\t%o\n", (SIZE) & 0x);   \
  |^~~  ~~~
  ||
  |long unsigned int

etc., so that has to be disabled.  This may be with 64-bit hosts only, I'm 
not sure, however the way varargs are handled means the issue will likely 
cause a broken compiler to be built if the warning is ignored, at least 
with some hosts.

 Paul, can you please look into it sometime?

  Maciej


Re: AVR maintainership (was: [patch, avr, 1/3] Support 64-bit (long) double: The gcc part.)

2020-12-15 Thread Segher Boessenkool
On Tue, Dec 15, 2020 at 08:40:08AM +0100, Gerald Pfeifer wrote:
> On Mon, 6 Jan 2020, Jeff Law wrote:
> >> p.s. You know anything about Denis Chertykov? He used to reply to avr 
> >> patches within hours, but my latest patches (after a long period where I 
> >> didn't propose any patches) where all approved by you; not a single mail 
> >> from Denis.  So I am concerned if he's well.  Maybe he left you or some 
> >> other global maintainer a note? He's still listed as maintainer though.
> > I haven't heard much from him for a while.  I'm trying to leave enough
> > space that he can step in on this stuff, but I'm also hesitant to let
> > patches linger for too long.
> 
> I don't think I have seen mails from Denis since then (more than 
> eleven months).
> 
> Do we need to get a new maintainer for AVR in place? Any nominations?

I nominate Georg-Johann Lay as the obvious choice, since he has authored
333 of the 511 patches that went into config/avr/ the last ten years.


Segher


Re: [PATCH] rs6000: Use subreg for QI/HI vector init

2020-12-15 Thread Segher Boessenkool
Hi Ke Wen,

On Tue, Dec 15, 2020 at 03:53:29PM +0800, Kewen.Lin wrote:
> on 2020/12/15 上午2:51, Segher Boessenkool wrote:
> > On Wed, Dec 02, 2020 at 05:44:24PM +0800, Kewen.Lin wrote:
> >> --- a/gcc/config/rs6000/rs6000.c
> >> +++ b/gcc/config/rs6000/rs6000.c
> >> @@ -6793,17 +6793,8 @@ rs6000_expand_vector_init (rtx target, rtx vals)
> >>/* Force the values into word_mode registers.  */
> >>for (i = 0; i < n_elts; i++)
> >>{
> >> -rtx tmp = force_reg (GET_MODE_INNER (mode), XVECEXP (vals, 0, i));
> >> -if (TARGET_POWERPC64)
> >> -  {
> >> -op[i] = gen_reg_rtx (DImode);
> >> -emit_insn (gen_zero_extendqidi2 (op[i], tmp));
> >> -  }
> >> -else
> >> -  {
> >> -op[i] = gen_reg_rtx (SImode);
> >> -emit_insn (gen_zero_extendqisi2 (op[i], tmp));
> >> -  }
> >> +rtx tmp = force_reg (inner_mode, XVECEXP (vals, 0, i));
> >> +op[i] = simplify_gen_subreg (Pmode, tmp, inner_mode, 0);
> >>}
> > 
> > Pmode is defined based on TARGET_64BIT, not TARGET_POWERPC64.
> 
> Good point, you are right, is it ok to change this part with one
> explicit mode based on TARGET_POWERPC64?
> 
>   rtx tmp = force_reg (inner_mode, XVECEXP (vals, 0, i));
>   machine_mode tmode = TARGET_POWERPC64 ? DImode : SImode;
>   op[i] = simplify_gen_subreg (tmode, tmp, inner_mode, 0);

That looks fine, yes.

> > But, can you not always use SImode here?
> 
> Sorry that I didn't quite follow here.

I mean do

  rtx tmp = force_reg (inner_mode, XVECEXP (vals, 0, i));
  op[i] = simplify_gen_subreg (SImode, tmp, inner_mode, 0);

If that works (also in 64-bit mode), that is preferred.  It might need
some more adjustment elsewhere, not sure if that is worth it.

It is okay for trunk with either of those changes.  Thanks!


Segher


commit checker

2020-12-15 Thread Nathan Sidwell

Add toplevel dirs

contrib/
* gcc-changelog/git_commit.py (changelog_locations): Add
libcody, c++tools.

pushed to trunk

--
Nathan Sidwell
diff --git c/contrib/gcc-changelog/git_commit.py w/contrib/gcc-changelog/git_commit.py
index 0c438165516..01f49874652 100755
--- c/contrib/gcc-changelog/git_commit.py
+++ w/contrib/gcc-changelog/git_commit.py
@@ -21,6 +21,7 @@ import os
 import re
 
 changelog_locations = {
+'c++tools',
 'config',
 'contrib',
 'contrib/header-tools',
@@ -51,6 +52,7 @@ changelog_locations = {
 'libatomic',
 'libbacktrace',
 'libcc1',
+'libcody',
 'libcpp',
 'libcpp/po',
 'libdecnumber',


Re: [PATCH] Fix _GLIBCXX_DEBUG tests

2020-12-15 Thread Jonathan Wakely via Gcc-patches

On 14/12/20 22:36 +0100, François Dumont wrote:

On 14/12/20 11:08 am, Jonathan Wakely wrote:



On Mon, 14 Dec 2020, 06:51 François Dumont via Libstdc++, 
mailto:libstdc%2b...@gcc.gnu.org>> wrote:


   On 13/12/20 11:17 pm, Jonathan Wakely wrote:
   > On 13/12/20 15:52 +0100, François Dumont via Libstdc++ wrote:
   >> Some tests are XPASS because array assertions have been
   disabled for
   >> a good reason in C++11.
   >>
   >> I wonder if the respective non-constexpr _GLIBCXX_ASSERTION checks
   >> shouldn't target C++14 too. At the moment they are failing as
   >> expected but because of an Undefined Behavior no ?
   >
   > Hmm, maybe my "fix" for the bug was too hasty, and I should have
   done
   > this instead:
   >
   > --- a/libstdc++-v3/include/bits/c++config
   > +++ b/libstdc++-v3/include/bits/c++config
   > @@ -684,7 +684,7 @@ namespace std
   >
   >  #undef _GLIBCXX_HAS_BUILTIN
   >
   > -#if _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED
   > +#if _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED && __cplusplus >=
   > 201402L
   >  # define __glibcxx_assert_1(_Condition)    \
   >  if (__builtin_is_constant_evaluated()) \
   >   { \
   >
   > That would allow us to keep the std::array runtime assertions for
   > C++11, and only disable them in constexpr contexts.

   I already tried to restore this check in C++11 runtime without
   success
   but I didn't try this approach.

   I'll have a try but C++11 forces constexpr to be just a return
   statement
   so I fear that it won't appreciate the additional assertion.



Ah yes, we'd need something like Daniel suggested, and it's not 
worth it just for C++11.


Just limiting the tests to c++14 is fine.



Attached patch committed then.


Thanks.




Re: [PATCH] Fix _GLIBCXX_DEBUG tests

2020-12-15 Thread Jonathan Wakely via Gcc-patches

On 15/12/20 15:20 +, Jonathan Wakely wrote:

On 14/12/20 22:36 +0100, François Dumont wrote:

On 14/12/20 11:08 am, Jonathan Wakely wrote:



On Mon, 14 Dec 2020, 06:51 François Dumont via Libstdc++, 
mailto:libstdc%2b...@gcc.gnu.org>> wrote:


  On 13/12/20 11:17 pm, Jonathan Wakely wrote:
  > On 13/12/20 15:52 +0100, François Dumont via Libstdc++ wrote:
  >> Some tests are XPASS because array assertions have been
  disabled for
  >> a good reason in C++11.
  >>
  >> I wonder if the respective non-constexpr _GLIBCXX_ASSERTION checks
  >> shouldn't target C++14 too. At the moment they are failing as
  >> expected but because of an Undefined Behavior no ?
  >
  > Hmm, maybe my "fix" for the bug was too hasty, and I should have
  done
  > this instead:
  >
  > --- a/libstdc++-v3/include/bits/c++config
  > +++ b/libstdc++-v3/include/bits/c++config
  > @@ -684,7 +684,7 @@ namespace std
  >
  >  #undef _GLIBCXX_HAS_BUILTIN
  >
  > -#if _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED
  > +#if _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED && __cplusplus >=
  > 201402L
  >  # define __glibcxx_assert_1(_Condition)                \
  >      if (__builtin_is_constant_evaluated())     \
  >       {                                
         \
  >
  > That would allow us to keep the std::array runtime assertions for
  > C++11, and only disable them in constexpr contexts.

  I already tried to restore this check in C++11 runtime without
  success
  but I didn't try this approach.

  I'll have a try but C++11 forces constexpr to be just a return
  statement
  so I fear that it won't appreciate the additional assertion.



Ah yes, we'd need something like Daniel suggested, and it's not 
worth it just for C++11.


Just limiting the tests to c++14 is fine.



Attached patch committed then.


Thanks.


I'm committing this anyway, because although it won't fix those tests,
it is useless to check __builtin_is_constant_evaluated() in C++11
mode.

Tested powerpc64le-linux, normal mode and debug mode. Pushed to trunk.


commit f072d1021e3e80539afe58ba0019fafa9a0bb7a6
Author: Jonathan Wakely 
Date:   Tue Dec 15 15:39:58 2020

libstdc++: Do not define constexpr assertions for C++11

There's no point even checking is_constant_evaluated() in C++11 mode,
because the 'if' statement used for the assertion wouldn't be valid in a
C++11 constexpr function anyway.

libstdc++-v3/ChangeLog:

* include/bits/c++config (__glibcxx_assert_1): Define as empty
for C++11.

diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config
index 27302ed392e..155d0f46b16 100644
--- a/libstdc++-v3/include/bits/c++config
+++ b/libstdc++-v3/include/bits/c++config
@@ -684,7 +684,7 @@ namespace std
 
 #undef _GLIBCXX_HAS_BUILTIN
 
-#if _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED
+#if _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED && __cplusplus >= 201402L
 # define __glibcxx_assert_1(_Condition)		\
 if (__builtin_is_constant_evaluated())	\
  {		\


[committed] libstdc++: Increase timeout for tests in debug mode

2020-12-15 Thread Jonathan Wakely via Gcc-patches
These tests FAIL when testing debug mode with a small tool_timeout
value. Give them a longer relative timeout.

libstdc++-v3/ChangeLog:

* testsuite/25_algorithms/lexicographical_compare/deque_iterators/1.cc:
Add dg-timeout-factor directive.
* testsuite/ext/pb_ds/regression/tree_map_rand_debug.cc:
Increase timeout factor from 2.0 to 3.0.
* testsuite/ext/pb_ds/regression/tree_set_rand_debug.cc:
Likewise.
* testsuite/lib/libstdc++.exp (check_effective_target_debug-mode):
Define "debug-mode" as an effective-target keyword.

Tested powerpc64le-linux (normal and debug mode). Committed to trunk.

commit e831ad4dab9d693885a5654d49e8f219e53eaee1
Author: Jonathan Wakely 
Date:   Tue Dec 15 15:39:58 2020

libstdc++: Increase timeout for tests in debug mode

These tests FAIL when testing debug mode with a small tool_timeout
value. Give them a longer relative timeout.

libstdc++-v3/ChangeLog:

* 
testsuite/25_algorithms/lexicographical_compare/deque_iterators/1.cc:
Add dg-timeout-factor directive.
* testsuite/ext/pb_ds/regression/tree_map_rand_debug.cc:
Increase timeout factor from 2.0 to 3.0.
* testsuite/ext/pb_ds/regression/tree_set_rand_debug.cc:
Likewise.
* testsuite/lib/libstdc++.exp (check_effective_target_debug-mode):
Define "debug-mode" as an effective-target keyword.

diff --git 
a/libstdc++-v3/testsuite/25_algorithms/lexicographical_compare/deque_iterators/1.cc
 
b/libstdc++-v3/testsuite/25_algorithms/lexicographical_compare/deque_iterators/1.cc
index 14a75358db4..65aafdcf03d 100644
--- 
a/libstdc++-v3/testsuite/25_algorithms/lexicographical_compare/deque_iterators/1.cc
+++ 
b/libstdc++-v3/testsuite/25_algorithms/lexicographical_compare/deque_iterators/1.cc
@@ -15,6 +15,8 @@
 // with this library; see the file COPYING3.  If not see
 // .
 
+// { dg-timeout-factor 2 { target debug-mode } }
+
 #include 
 #include 
 #include 
diff --git a/libstdc++-v3/testsuite/ext/pb_ds/regression/tree_map_rand_debug.cc 
b/libstdc++-v3/testsuite/ext/pb_ds/regression/tree_map_rand_debug.cc
index 627f3864347..411a906d598 100644
--- a/libstdc++-v3/testsuite/ext/pb_ds/regression/tree_map_rand_debug.cc
+++ b/libstdc++-v3/testsuite/ext/pb_ds/regression/tree_map_rand_debug.cc
@@ -2,7 +2,7 @@
 // { dg-require-time "" }
 // This can take long on simulators, timing out the test.
 // { dg-options "-DITERATIONS=5" { target simulator } }
-// { dg-timeout-factor 2.0 }
+// { dg-timeout-factor 3.0 }
 
 // -*- C++ -*-
 
diff --git a/libstdc++-v3/testsuite/ext/pb_ds/regression/tree_set_rand_debug.cc 
b/libstdc++-v3/testsuite/ext/pb_ds/regression/tree_set_rand_debug.cc
index cd7b1118e26..dd1b45c3491 100644
--- a/libstdc++-v3/testsuite/ext/pb_ds/regression/tree_set_rand_debug.cc
+++ b/libstdc++-v3/testsuite/ext/pb_ds/regression/tree_set_rand_debug.cc
@@ -2,7 +2,7 @@
 // { dg-require-time "" }
 // This can take long on simulators, timing out the test.
 // { dg-options "-DITERATIONS=5" { target simulator } }
-// { dg-timeout-factor 2.0 }
+// { dg-timeout-factor 3.0 }
 
 // -*- C++ -*-
 
diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp 
b/libstdc++-v3/testsuite/lib/libstdc++.exp
index 35817a8870a..aeb881f91a6 100644
--- a/libstdc++-v3/testsuite/lib/libstdc++.exp
+++ b/libstdc++-v3/testsuite/lib/libstdc++.exp
@@ -1004,6 +1004,11 @@ proc check_v3_target_debug_mode { } {
 }]
 }
 
+# Define "debug-mode" as an effective-target keyword.
+proc check_effective_target_debug-mode { } {
+return [check_v3_target_debug_mode]
+}
+
 # Return 1 if normal mode is active, 0 otherwise.
 # i.e. neither Debug Mode nor Parallel Mode is active.
 proc check_v3_target_normal_mode { } {


c++: module mapper

2020-12-15 Thread Nathan Sidwell
To avoid always requiring an active mapper to connect to, we provide a 
default in-process mapper with similar functionality to the sample 
server.  This is that code.  Also included is the client-side connection 
mechanism, which determines what server to use and how to

connect to it.

gcc/cp/
* Make-lang.in (CXX_AND_OBJCXX_OBJS): Add mapper-client &
mapper-resolver.
* mapper-client.h: New.
* mapper-client.cc: New.
* mapper-resolver.cc: New.

pushing to trunk
--
Nathan Sidwell
diff --git c/gcc/cp/Make-lang.in w/gcc/cp/Make-lang.in
index 52116652900..49272464409 100644
--- c/gcc/cp/Make-lang.in
+++ w/gcc/cp/Make-lang.in
@@ -94,7 +94,8 @@ CXX_AND_OBJCXX_OBJS = \
 	cp/error.o cp/except.o cp/expr.o \
 	cp/friend.o cp/init.o \
 	cp/lambda.o cp/lex.o cp/logic.o \
-	cp/mangle.o cp/method.o cp/module.o \
+	cp/mangle.o cp/mapper-client.o cp/mapper-resolver.o \
+	cp/method.o cp/module.o \
 	cp/name-lookup.o cp/optimize.o \
 	cp/parser.o cp/pt.o cp/ptree.o \
 	cp/rtti.o \
diff --git c/gcc/cp/mapper-client.cc w/gcc/cp/mapper-client.cc
new file mode 100644
index 000..acec591296a
--- /dev/null
+++ w/gcc/cp/mapper-client.cc
@@ -0,0 +1,356 @@
+/* C++ modules.  Experimental!
+   Copyright (C) 2017-2020 Free Software Foundation, Inc.
+   Written by Nathan Sidwell  while at FaceBook
+
+   This file is part of GCC.
+
+   GCC 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.
+
+   GCC 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.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+.  */
+
+#include "config.h"
+#include "system.h"
+
+#include "line-map.h"
+#include "diagnostic-core.h"
+#include "mapper-client.h"
+#include "intl.h"
+
+#include "../../c++tools/resolver.h"
+
+module_client::module_client (pex_obj *p, int fd_from, int fd_to)
+  : Client (fd_from, fd_to), pex (p)
+{
+}
+
+static module_client *
+spawn_mapper_program (char const **errmsg, std::string &name,
+		  char const *full_program_name)
+{
+  /* Split writable at white-space.  No space-containing args for
+ you!  */
+  // At most every other char could be an argument
+  char **argv = new char *[name.size () / 2 + 2];
+  unsigned arg_no = 0;
+  char *str = new char[name.size ()];
+  memcpy (str, name.c_str () + 1, name.size ());
+
+  for (auto ptr = str; ; ++ptr)
+{
+  while (*ptr == ' ')
+	ptr++;
+  if (!*ptr)
+	break;
+
+  if (!arg_no)
+	{
+	  /* @name means look in the compiler's install dir.  */
+	  if (ptr[0] == '@')
+	ptr++;
+	  else
+	full_program_name = nullptr;
+	}
+
+  argv[arg_no++] = ptr;
+  while (*ptr && *ptr != ' ')
+	ptr++;
+  if (!*ptr)
+	break;
+  *ptr = 0;
+}
+  argv[arg_no] = nullptr;
+
+  auto *pex = pex_init (PEX_USE_PIPES, progname, NULL);
+  FILE *to = pex_input_pipe (pex, false);
+  name = argv[0];
+  if (!to)
+*errmsg = "connecting input";
+  else
+{
+  int flags = PEX_SEARCH;
+
+  if (full_program_name)
+	{
+	  /* Prepend the invoking path, if the mapper is a simple
+	 file name.  */
+	  size_t dir_len = progname - full_program_name;
+	  std::string argv0;
+	  argv0.reserve (dir_len + name.size ());
+	  argv0.append (full_program_name, dir_len).append (name);
+	  name = std::move (argv0);
+	  argv[0] = const_cast  (name.c_str ());
+	  flags = 0;
+	}
+  int err;
+  *errmsg = pex_run (pex, flags, argv[0], argv, NULL, NULL, &err);
+}
+  delete[] str;
+  delete[] argv;
+
+  int fd_from = -1, fd_to = -1;
+  if (!*errmsg)
+{
+  FILE *from = pex_read_output (pex, false);
+  if (from && (fd_to = dup (fileno (to))) >= 0)
+	fd_from = fileno (from);
+  else
+	*errmsg = "connecting output";
+  fclose (to);
+}
+
+  if (*errmsg)
+{
+  pex_free (pex);
+  return nullptr;
+}
+
+  return new module_client (pex, fd_from, fd_to);
+}
+
+module_client *
+module_client::open_module_client (location_t loc, const char *o,
+   void (*set_repo) (const char *),
+   char const *full_program_name)
+{
+  module_client *c = nullptr;
+  std::string ident;
+  std::string name;
+  char const *errmsg = nullptr;
+  unsigned line = 0;
+
+  if (o && o[0])
+{
+  /* Maybe a local or ipv6 address.  */
+  name = o;
+  auto last = name.find_last_of ('?');
+  if (last != name.npos)
+	{
+	  ident = name.substr (last + 1);
+	  name.erase (last);
+	}
+
+  if (name.size ())
+	{
+	  switch (name[0])
+	{
+	case '<':
+	  // to or <>fromto, or <>
+	  {
+		size_t pos = name.find ('>'

doc: Document C++ 20 modules

2020-12-15 Thread Nathan Sidwell

And here is the user-facing documentation.

gcc/
* doc/cppopts.texi: Document new cpp opt.
* doc/invoke.texi: Add C++20 module option & documentation.

--
Nathan Sidwell
diff --git c/gcc/doc/cppopts.texi w/gcc/doc/cppopts.texi
index 7f1849d841f..e5ece92487b 100644
--- c/gcc/doc/cppopts.texi
+++ w/gcc/doc/cppopts.texi
@@ -139,6 +139,10 @@ this useless.
 
 This feature is used in automatic updating of makefiles.
 
+@item -Mno-modules
+@opindex Mno-modules
+Disable dependency generation for compiled module interfaces.
+
 @item -MP
 @opindex MP
 This option instructs CPP to add a phony target for each dependency
diff --git c/gcc/doc/invoke.texi w/gcc/doc/invoke.texi
index 691b4cbd287..5f20dc13bac 100644
--- c/gcc/doc/invoke.texi
+++ w/gcc/doc/invoke.texi
@@ -172,6 +172,7 @@ listing and explanation of the binary and decimal byte size prefixes.
 * Spec Files::  How to pass switches to sub-processes.
 * Environment Variables:: Env vars that affect GCC.
 * Precompiled Headers:: Compiling a header once, and using it many times.
+* C++ Modules::		Experimental C++20 module system.
 @end menu
 
 @c man begin OPTIONS
@@ -219,7 +220,13 @@ in the following sections.
 -fno-gnu-keywords @gol
 -fno-implicit-templates @gol
 -fno-implicit-inline-templates @gol
--fno-implement-inlines  -fms-extensions @gol
+-fno-implement-inlines  @gol
+-fmodule-header@r{[}=@var{kind}@r{]} -fmodule-only -fmodules-ts @gol
+-fmodule-implicit-inline @gol
+-fno-module-lazy @gol
+-fmodule-mapper=@var{specification} @gol
+-fmodule-version-ignore @gol
+-fms-extensions @gol
 -fnew-inheriting-ctors @gol
 -fnew-ttp-matching @gol
 -fno-nonansi-builtins  -fnothrow-opt  -fno-operator-names @gol
@@ -233,15 +240,18 @@ in the following sections.
 -fvisibility-inlines-hidden @gol
 -fvisibility-ms-compat @gol
 -fext-numeric-literals @gol
+-flang-info-include-translate@r{[}=@var{name}@r{]} @gol
+-flang-info-include-translate-not @gol
 -Wabi-tag  -Wcatch-value  -Wcatch-value=@var{n} @gol
 -Wno-class-conversion  -Wclass-memaccess @gol
 -Wcomma-subscript  -Wconditionally-supported @gol
 -Wno-conversion-null  -Wctad-maybe-unsupported @gol
 -Wctor-dtor-privacy  -Wno-delete-incomplete @gol
--Wdelete-non-virtual-dtor  -Wdeprecated-copy  -Wdeprecated-copy-dtor @gol
+-Wdelete-non-virtual-dtor  -Wdeprecated-copy -Wdeprecated-copy-dtor @gol
 -Wno-deprecated-enum-enum-conversion -Wno-deprecated-enum-float-conversion @gol
 -Weffc++  -Wno-exceptions -Wextra-semi  -Wno-inaccessible-base @gol
 -Wno-inherited-variadic-ctor  -Wno-init-list-lifetime @gol
+-Winvalid-imported-macros @gol
 -Wno-invalid-offsetof  -Wno-literal-suffix @gol
 -Wno-mismatched-new-delete -Wmismatched-tags @gol
 -Wmultiple-inheritance  -Wnamespaces  -Wnarrowing @gol
@@ -600,7 +610,7 @@ Objective-C and Objective-C++ Dialects}.
 -fpreprocessed  -ftabstop=@var{width}  -ftrack-macro-expansion  @gol
 -fwide-exec-charset=@var{charset}  -fworking-directory @gol
 -H  -imacros @var{file}  -include @var{file} @gol
--M  -MD  -MF  -MG  -MM  -MMD  -MP  -MQ  -MT @gol
+-M  -MD  -MF  -MG  -MM  -MMD  -MP  -MQ  -MT -Mno-modules @gol
 -no-integrated-cpp  -P  -pthread  -remap @gol
 -traditional  -traditional-cpp  -trigraphs @gol
 -U@var{macro}  -undef  @gol
@@ -1572,7 +1582,7 @@ name suffix).  This option applies to all following input files until
 the next @option{-x} option.  Possible values for @var{language} are:
 @smallexample
 c  c-header  cpp-output
-c++  c++-header  c++-cpp-output
+c++  c++-header  c++-system-header c++-user-header c++-cpp-output
 objective-c  objective-c-header  objective-c-cpp-output
 objective-c++ objective-c++-header objective-c++-cpp-output
 assembler  assembler-with-cpp
@@ -3057,6 +3067,52 @@ To save space, do not emit out-of-line copies of inline functions
 controlled by @code{#pragma implementation}.  This causes linker
 errors if these functions are not inlined everywhere they are called.
 
+@item -fmodules-ts
+@itemx -fno-modules-ts
+@opindex fmodules-ts
+@opindex fno-modules-ts
+Enable support for C++20 modules (@xref{C++ Modules}).  The
+@option{-fno-modules-ts} is usually not needed, as that is the
+default.  Even though this is a C++20 feature, it is not currently
+implicitly enabled by selecting that standard version.
+
+@item -fmodule-header
+@itemx -fmodule-header=user
+@itemx -fmodule-header=system
+@opindex fmodule-header
+Compile a header file to create an importable header unit.
+
+@item -fmodule-implicit-inline
+@opindex fmodule-implicit-inline
+Member functions defined in their class definitions are not implicitly
+inline for modular code.  This is different to traditional C++
+behavior, for good reasons.  However, it may result in a difficulty
+during code porting.  This option makes such function definitions
+implicitly inline.  It does however generate an ABI incompatibility,
+so you must use it everywhere or nowhere.  (Such definitions outside
+of a named module remain implicitly inline, regardless.)
+
+@item -fno-module-lazy
+@opin

C++ 20 modules

2020-12-15 Thread Nathan Sidwell
I've completed merging modules to trunk modulo the testsuite.  I 
included a few smoke tests, but nothing more.  I'll add the rest when 
the smoke clears.


There will undoubtedly be issues related to configs that I've not built. 
 As I mentioned I did what I could.


Further, it'll undoubtedly break when you go poking at it, as we all 
have unique and special sticks to poke with.  This might disappoint. 
But just think what had to go right to get you there :)  Recently these 
kinds of bugs have been simple to fix -- a thinko or simply forgetting 
about a piece of C++.  Please file issues in bugzilla.


There are some known omissions listed in the documentation (go read it).

Finally, thanks to the early testers, those that supported me in 
implementing such an exciting feature, and those who listened to my 
comments and suggestions in many WG21 meetings.


nathan

--
Nathan Sidwell


Re: [patch, fortran] Optionally improve debugging of auxiliary variables

2020-12-15 Thread Thomas Koenig via Gcc-patches

Am 13.12.20 um 20:59 schrieb Iain Sandoe via Fortran:

For bonus points you can prefix with _GFC_ which puts the symbols
in the implementation’s namespace (at least for C-Family purposes)
and therefore means that a clash with a user’s symbols is the user’s
problem …


I don't think this is necessary.  Specifying uppercase letters is
already a technical impossibility, we don't need to add convention
to it as well :-)

After reading some tree dumps, I have also now come to the conclusion
that adding GFC_ to everything makes for poor reading.  In the
version I have committed as r11-6087, I have now capitalized
all prefixes, if present, and used GFC_ otherweise.

Just one more remark: This version lets you set a watchpoint on
num_var so you can easily stop if a certain variable is generated.
That also helps :-)

Best regards, and thanks again for the comments.

Thomas

Add the -fdebug-aux-vars flag to debug variables generated by Fortran.

gcc/fortran/ChangeLog:

PR fortran/90207
* invoke.texi: Document -fdebug-aux-vars.
* lang.opt: Add -fdebug-aux-vars.
* trans.c (MAX_PREFIX_LEN): New macro.
(create_var_debug_raw): New function.
(gfc_create_var_np): Call create_var_debug_raw if
flag_debug_aux_vars is set.

diff --git a/gcc/fortran/invoke.texi b/gcc/fortran/invoke.texi
index 8bdc8a6b038..069ccd339f3 100644
--- a/gcc/fortran/invoke.texi
+++ b/gcc/fortran/invoke.texi
@@ -160,7 +160,7 @@ and warnings}.
 @item Debugging Options
 @xref{Debugging Options,,Options for debugging your program or GNU Fortran}.
 @gccoptlist{-fbacktrace -fdump-fortran-optimized -fdump-fortran-original @gol
--fdump-fortran-global -fdump-parse-tree -ffpe-trap=@var{list} @gol
+-fdebug-aux-vars -fdump-fortran-global -fdump-parse-tree -ffpe-trap=@var{list} @gol
 -ffpe-summary=@var{list}
 }
 
@@ -1219,6 +1219,15 @@ change between releases. This option may also generate internal
 compiler errors for features which have only recently been added. This
 option is deprecated; use @code{-fdump-fortran-original} instead.
 
+@item -fdebug-aux-vars
+@opindex @code{fdebug-aux-vars}
+Renames internal variables created by the gfortran front end and makes
+them accessible to a debugger.  The name of the internal variables then
+start with upper-case letters followed by an underscore.  This option is
+useful for debugging the compiler's code generation together with
+@code{-fdump-tree-original} and enabling debugging of the executable
+program by using @code{-g} or @code{-ggdb3}.
+
 @item -fdump-fortran-global
 @opindex @code{fdump-fortran-global}
 Output a list of the global identifiers after translating into
diff --git a/gcc/fortran/lang.opt b/gcc/fortran/lang.opt
index 96ed208cb85..57b0264458e 100644
--- a/gcc/fortran/lang.opt
+++ b/gcc/fortran/lang.opt
@@ -452,6 +452,10 @@ fd-lines-as-comments
 Fortran RejectNegative
 Treat lines with 'D' in column one as comments.
 
+fdebug-aux-vars
+Fortran Var(flag_debug_aux_vars)
+Issue debug information for compiler-generated auxiliary variables.
+
 fdec
 Fortran Var(flag_dec)
 Enable all DEC language extensions.
diff --git a/gcc/fortran/trans.c b/gcc/fortran/trans.c
index 025abe38985..ca0b10ca73d 100644
--- a/gcc/fortran/trans.c
+++ b/gcc/fortran/trans.c
@@ -73,6 +73,45 @@ gfc_advance_chain (tree t, int n)
   return t;
 }
 
+static int num_var;
+
+#define MAX_PREFIX_LEN 20
+
+static tree
+create_var_debug_raw (tree type, const char *prefix)
+{
+  /* Space for prefix + "_" + 10-digit-number + \0.  */
+  char name_buf[MAX_PREFIX_LEN + 1 + 10 + 1];
+  tree t;
+  int i;
+
+  if (prefix == NULL)
+prefix = "gfc";
+  else
+gcc_assert (strlen (prefix) <= MAX_PREFIX_LEN);
+
+  for (i = 0; prefix[i] != 0; i++)
+name_buf[i] = gfc_wide_toupper (prefix[i]);
+
+  snprintf (name_buf + i, sizeof (name_buf) - i, "_%d", num_var++);
+
+  t = build_decl (input_location, VAR_DECL, get_identifier (name_buf), type);
+
+  /* We want debug info for it.  */
+  DECL_IGNORED_P (t) = 0;
+  /* It should not be nameless.  */
+  DECL_NAMELESS (t) = 0;
+
+  /* Make the variable writable.  */
+  TREE_READONLY (t) = 0;
+
+  DECL_EXTERNAL (t) = 0;
+  TREE_STATIC (t) = 0;
+  TREE_USED (t) = 1;
+
+  return t;
+}
+
 /* Creates a variable declaration with a given TYPE.  */
 
 tree
@@ -80,6 +119,9 @@ gfc_create_var_np (tree type, const char *prefix)
 {
   tree t;
 
+  if (flag_debug_aux_vars)
+return create_var_debug_raw (type, prefix);
+
   t = create_tmp_var_raw (type, prefix);
 
   /* No warnings for anonymous variables.  */


Re: [PATCH] nvptx: Cache stacks block for OpenMP kernel launch

2020-12-15 Thread Julian Brown
On Tue, 15 Dec 2020 14:49:40 +0100
Jakub Jelinek  wrote:

> On Tue, Dec 15, 2020 at 01:39:13PM +, Julian Brown wrote:
> > @@ -1922,7 +1997,9 @@ GOMP_OFFLOAD_run (int ord, void *tgt_fn, void
> > *tgt_vars, void **args) nvptx_adjust_launch_bounds (tgt_fn,
> > ptx_dev, &teams, &threads); 
> >size_t stack_size = nvptx_stacks_size ();
> > -  void *stacks = nvptx_stacks_alloc (stack_size, teams * threads);
> > +
> > +  pthread_mutex_lock (&ptx_dev->omp_stacks.lock);
> > +  void *stacks = nvptx_stacks_acquire (ptx_dev, stack_size, teams
> > * threads); void *fn_args[] = {tgt_vars, stacks, (void *)
> > stack_size}; size_t fn_args_size = sizeof fn_args;
> >void *config[] = {
> > @@ -1944,7 +2021,8 @@ GOMP_OFFLOAD_run (int ord, void *tgt_fn, void
> > *tgt_vars, void **args) maybe_abort_msg);
> >else if (r != CUDA_SUCCESS)
> >  GOMP_PLUGIN_fatal ("cuCtxSynchronize error: %s", cuda_error
> > (r));
> > -  nvptx_stacks_free (stacks, teams * threads);
> > +
> > +  pthread_mutex_unlock (&ptx_dev->omp_stacks.lock);
> >  }  
> 
> Do you need to hold the omp_stacks.lock across the entire offloading?
> Doesn't that serialize all offloading kernels to the same device?
> I mean, can't the lock be taken just shortly at the start to either
> acquire the cached stacks or allocate a fresh stack, and then at the
> end to put the stack back into the cache?

I think you're suggesting something like what Alexander mentioned -- a
pool of cached stacks blocks in case the single, locked block is
contested. Obviously at present kernel launches are serialised on the
target anyway, so it's a question of whether having the device wait for
the host to unlock the stacks block (i.e. a context switch, FSVO context
switch), or allocating a new stacks block, is quicker. I think the
numbers posted in the parent email show that memory allocation is so
slow that just waiting for the lock wins. I'm wary of adding
unnecessary complication, especially if it'll only be exercised in
already hard-to-debug cases (i.e. lots of threads)!

Just ignoring the cache if it's "in use" (and doing an allocation/free
of another stacks block, as at present) is something I'd not quite
considered. Indeed that might work, but I'm not sure if it'll be
any faster in practice.

> Also, how will this caching interact with malloc etc. performed in
> target regions?  Shall we do the caching only if there is no other
> concurrent offloading to the device because the newlib malloc will
> not be able to figure out it could free this and let the host know it
> has freed it.

Does target-side memory allocation call back into the plugin's
GOMP_OFFLOAD_alloc? I'm not sure how that works. If not, target-side
memory allocation shouldn't be affected, I don't think?

Thanks,

Julian


Re: [PATCH] nvptx: Cache stacks block for OpenMP kernel launch

2020-12-15 Thread Jakub Jelinek via Gcc-patches
On Tue, Dec 15, 2020 at 04:49:38PM +, Julian Brown wrote:
> > Do you need to hold the omp_stacks.lock across the entire offloading?
> > Doesn't that serialize all offloading kernels to the same device?
> > I mean, can't the lock be taken just shortly at the start to either
> > acquire the cached stacks or allocate a fresh stack, and then at the
> > end to put the stack back into the cache?
> 
> I think you're suggesting something like what Alexander mentioned -- a
> pool of cached stacks blocks in case the single, locked block is
> contested. Obviously at present kernel launches are serialised on the
> target anyway, so it's a question of whether having the device wait for
> the host to unlock the stacks block (i.e. a context switch, FSVO context
> switch), or allocating a new stacks block, is quicker. I think the
> numbers posted in the parent email show that memory allocation is so
> slow that just waiting for the lock wins. I'm wary of adding
> unnecessary complication, especially if it'll only be exercised in
> already hard-to-debug cases (i.e. lots of threads)!

I'm not suggesting to have multiple stacks, on the contrary.  I've suggested
to do the caching only if at most one host thread is offloading to the
device.

If one uses
#pragma omp parallel num_threads(3)
{
  #pragma omp target
  ...
}
then I don't see what would previously prevent the concurrent offloading,
yes, we take the device lock during gomp_map_vars and again during
gomp_unmap_vars, but don't hold it across the offloading in between.

> Does target-side memory allocation call back into the plugin's
> GOMP_OFFLOAD_alloc? I'm not sure how that works. If not, target-side
> memory allocation shouldn't be affected, I don't think?

Again, I'm not suggesting that it should, but what I'm saying is that
if target region ends but some other host tasks are doing target regions to
the same device concurrently with that, or if there are async target in fly,
we shouldn't try to cache the stack, but free it right away, because
what the other target regions might need to malloc larger amounts of memory
and fail because of the caching.

Jakub



[PATCH] maintainer-scripts: Prefer temp dir /sourceware/snapshot-tmp/gcc for update_version_git

2020-12-15 Thread Jakub Jelinek via Gcc-patches
On Mon, Dec 14, 2020 at 11:58:05PM +, Joseph Myers wrote:
> > Thanks for heads up. I'm aware of it and I don't see reason why (running the
> > update script in dry mode works).
> 
> https://gcc.gnu.org/pipermail/gccadmin/2020q4/017037.html
> 
> OSError: [Errno 28] No space left on device: 
> '/tmp/tmp.Zq3p6D4MxS/gcc/.git/objects/objn31xpefh' -> 
> '/tmp/tmp.Zq3p6D4MxS/gcc/.git/objects/db/ffb02a4bcdd4ec04af3db75d86b8cc2e52bdff'
> 
> Maybe change the script to use /sourceware/snapshot-tmp/gcc (which has 
> rather more space) instead of /tmp?

So like this?  Ok for trunk?

2020-12-15  Jakub Jelinek  

* update_version_git: Put BASEDIR into /sourceware/snapshot-tmp/gcc
if it exist.

--- maintainer-scripts/update_version_git.jj2020-07-28 15:39:10.222753285 
+0200
+++ maintainer-scripts/update_version_git   2020-12-15 17:50:56.945413943 
+0100
@@ -5,24 +5,31 @@
 # commit messages.
 
 GITROOT=${GITROOT:-"/git/gcc.git"}
+if [ -z "$TMPDIR" ]; then
+  if [ -d /sourceware/snapshot-tmp/gcc ]; then
+TMPDIR=/sourceware/snapshot-tmp/gcc
+  else
+TMPDIR=/tmp
+  fi
+fi
 
-# Run this from /tmp.
-export GITROOT
+# Run this from $TMPDIR.
+export GITROOT TMPDIR
 BASEDIR=`mktemp -d`
 cd "$BASEDIR"
 
 GIT=${GIT:-/usr/local/bin/git}
 
 # Assume all will go well.
-SUBDIR=$BASEDIR/gcc
+SUBDIR="$BASEDIR/gcc"
 ${GIT} clone -q -b master "$GITROOT" "$SUBDIR"
 
-cp -a $SUBDIR/contrib/gcc-changelog $BASEDIR/gcc-changelog
+cp -a "$SUBDIR"/contrib/gcc-changelog "$BASEDIR"/gcc-changelog
 cd "$SUBDIR"
 python3 ../gcc-changelog/git_update_version.py -p
 RESULT=$?
 
-cd /tmp
+cd "$TMPDIR"
 
-/bin/rm -rf $BASEDIR
+/bin/rm -rf "$BASEDIR"
 exit $RESULT


Jakub



PING^1 [PATCH 0/3] Enable PGO/LTO build for binutils+gdb

2020-12-15 Thread H.J. Lu via Gcc-patches
On Thu, Oct 29, 2020 at 12:11 PM H.J. Lu  wrote:
>
> Add the --enable-pgo-build[=lto] configure option.  When binutils+gdb
> is not built together with GCC, --enable-pgo-build enables the PGO build:
>
> 0. Pass --plugin to AR and RANLIB.
> 1. First build with -fprofile-generate.
> 2. Use "make maybe-check-*" to generate profiling data.
> 3. Use "make clean" to remove the previous build.
> 4. Rebuild with -fprofile-use.
>
>
> H.J. Lu (3):
>   GCC: Pass --plugin to AR and RANLIB
>   Binutils: Pass --plugin to AR and RANLIB
>   Support the PGO build for binutils+gdb
>
>  Makefile.in|  63 -
>  Makefile.tpl   |  63 -
>  bfd/configure  |  27 +-
>  binutils/configure |  27 +-
>  config/gcc-plugin.m4   |  28 ++
>  configure  | 139 ++-
>  configure.ac   |  80 
>  gas/configure  |  27 +-
>  gprof/configure|  27 +-
>  ld/configure   |  27 +-
>  libctf/configure   |  27 +-
>  libiberty/Makefile.in  |   5 +-
>  libiberty/aclocal.m4   |   1 +
>  libiberty/configure|  37 
>  libiberty/configure.ac |  12 +++
>  libtool.m4 |  25 -
>  opcodes/configure  |  27 +-
>  zlib/configure | 206 -
>  18 files changed, 818 insertions(+), 30 deletions(-)
>

Any comments from GCC and GDB:

https://sourceware.org/pipermail/binutils/2020-October/113943.html

-- 
H.J.


V4 [PATCH 0/3] Switch to a new section if the SECTION_RETAIN bit doesn't match

2020-12-15 Thread H.J. Lu via Gcc-patches
When SECTION_RETAIN is used, definitions marked with used attribute and
unmarked definitions are placed in a section with the same name.  Instead
of issue an error:

[hjl@gnu-cfl-2 gcc]$ /usr/gcc-11.0.0-x32/bin/gcc -S c.c 
-fdiagnostics-plain-output
c.c:2:49: error: ‘foo1’ causes a section type conflict with ‘foo2’
c.c:1:54: note: ‘foo2’ was declared here
[hjl@gnu-cfl-2 gcc]$

the first patch switches to a new section if the SECTION_RETAIN bit
doesn't match.  The second optional patch issues a warning:

[hjl@gnu-cfl-2 gcc]$ ./xgcc -B./ -S c.c
c.c:2:49: warning: ‘foo1’ without ‘used’ attribute and ‘foo2’ with ‘used’ 
attribute are placed in a section with the same name [-Wattributes]
2 | const int __attribute__((section(".data.foo"))) foo1 = 1;
  | ^~~~
c.c:1:54: note: ‘foo2’ was declared here
1 | const int __attribute__((used,section(".data.foo"))) foo2 = 2;
  |
[hjl@gnu-cfl-2 gcc]$

Changes from V3:

1. Add DECL_P (decl) to switch_to_section ().
2. Update comments for get_section ().
3. Require .init_array/.fini_array support for SHF_GNU_RETAIN.

Changes from V2:

1. Add (new_section->common.flags & SECTION_NAMED) check since
SHF_GNU_RETAIN section must be named.
2. Move c-c++-common/attr-used-9.c to the fist patch since there are
no new warnings.
3. Check new warnings only for R_flag_in_section target.


H.J. Lu (3):
  Switch to a new section if the SECTION_RETAIN bit doesn't match
  Warn used and not used symbols in section with the same name
  Require .init_array/.fini_array support for SHF_GNU_RETAIN

 gcc/defaults.h   | 11 +
 gcc/output.h |  2 +-
 gcc/testsuite/c-c++-common/attr-used-5.c | 27 
 gcc/testsuite/c-c++-common/attr-used-6.c | 27 
 gcc/testsuite/c-c++-common/attr-used-7.c |  9 
 gcc/testsuite/c-c++-common/attr-used-8.c |  9 
 gcc/testsuite/c-c++-common/attr-used-9.c | 28 
 gcc/testsuite/lib/target-supports.exp|  2 +-
 gcc/varasm.c | 56 
 9 files changed, 161 insertions(+), 10 deletions(-)
 create mode 100644 gcc/testsuite/c-c++-common/attr-used-5.c
 create mode 100644 gcc/testsuite/c-c++-common/attr-used-6.c
 create mode 100644 gcc/testsuite/c-c++-common/attr-used-7.c
 create mode 100644 gcc/testsuite/c-c++-common/attr-used-8.c
 create mode 100644 gcc/testsuite/c-c++-common/attr-used-9.c

-- 
2.29.2



V4 [PATCH 3/3] Require .init_array/.fini_array support for SHF_GNU_RETAIN

2020-12-15 Thread H.J. Lu via Gcc-patches
Since SHF_GNU_RETAIN support doesn't work for crtstuff.c which switches
the output section directly with asm statement:

---
static void __attribute__((used))
__do_global_dtors_aux (void)
{
  static _Bool completed;

  if (__builtin_expect (completed, 0))
return;
  completed = 1;
}

static void __attribute__((__used__))
call___do_global_dtors_aux (void)
{
  asm ("\t.section\t.fini");
  __do_global_dtors_aux ();
  asm ("\t.section\t.text");
}
---

use SHF_GNU_RETAIN only if .init_array/.fini_array section is supported.

gcc/

PR target/98146
* defaults.h (SUPPORTS_SHF_GNU_RETAIN): New.
* varasm.c (get_section): Replace HAVE_GAS_SHF_GNU_RETAIN with
SUPPORTS_SHF_GNU_RETAIN.
(resolve_unique_section): Likewise.
(get_variable_section): Likewise.
(switch_to_section): Likewise.

gcc/testsuite/

PR target/98146
* lib/target-supports.exp
(check_effective_target_R_flag_in_section): Also check
HAVE_INITFINI_ARRAY_SUPPORT != 0.
---
 gcc/defaults.h| 11 +++
 gcc/testsuite/lib/target-supports.exp |  2 +-
 gcc/varasm.c  |  8 
 3 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/gcc/defaults.h b/gcc/defaults.h
index f1a38626624..80a84dde2d6 100644
--- a/gcc/defaults.h
+++ b/gcc/defaults.h
@@ -286,6 +286,17 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  
If not, see
 #endif
 #endif
 
+/* This determines whether or not we support marking sections with
+   SHF_GNU_RETAIN flag.  Also require .init_array/.fini_array section
+   for constructors and destructors.  */
+#ifndef SUPPORTS_SHF_GNU_RETAIN
+#if HAVE_GAS_SHF_GNU_RETAIN && HAVE_INITFINI_ARRAY_SUPPORT
+#define SUPPORTS_SHF_GNU_RETAIN 1
+#else
+#define SUPPORTS_SHF_GNU_RETAIN 0
+#endif
+#endif
+
 /* This determines whether or not we support link-once semantics.  */
 #ifndef SUPPORTS_ONE_ONLY
 #ifdef MAKE_DECL_ONE_ONLY
diff --git a/gcc/testsuite/lib/target-supports.exp 
b/gcc/testsuite/lib/target-supports.exp
index 3c02f763e7e..11343d0192f 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -10840,7 +10840,7 @@ proc check_effective_target_R_flag_in_section { } {
 
set f [open $src "w"]
puts $f "#include \"../../auto-host.h\""
-   puts $f "#if HAVE_GAS_SHF_GNU_RETAIN == 0"
+   puts $f "#if HAVE_GAS_SHF_GNU_RETAIN == 0 || 
HAVE_INITFINI_ARRAY_SUPPORT == 0"
puts $f "# error Assembler does not support 'R' flag in .section 
directive."
puts $f "#endif"
close $f
diff --git a/gcc/varasm.c b/gcc/varasm.c
index 72d5379303a..46f79ea28e6 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -293,7 +293,7 @@ get_section (const char *name, unsigned int flags, tree 
decl,
   slot = section_htab->find_slot_with_hash (name, htab_hash_string (name),
INSERT);
   flags |= SECTION_NAMED;
-  if (HAVE_GAS_SHF_GNU_RETAIN
+  if (SUPPORTS_SHF_GNU_RETAIN
   && decl != nullptr
   && DECL_P (decl)
   && DECL_PRESERVE_P (decl))
@@ -483,7 +483,7 @@ resolve_unique_section (tree decl, int reloc 
ATTRIBUTE_UNUSED,
   if (DECL_SECTION_NAME (decl) == NULL
   && targetm_common.have_named_sections
   && (flag_function_or_data_sections
- || (HAVE_GAS_SHF_GNU_RETAIN && DECL_PRESERVE_P (decl))
+ || (SUPPORTS_SHF_GNU_RETAIN && DECL_PRESERVE_P (decl))
  || DECL_COMDAT_GROUP (decl)))
 {
   targetm.asm_out.unique_section (decl, reloc);
@@ -1223,7 +1223,7 @@ get_variable_section (tree decl, bool prefer_noswitch_p)
 vnode->get_constructor ();
 
   if (DECL_COMMON (decl)
-  && !(HAVE_GAS_SHF_GNU_RETAIN && DECL_PRESERVE_P (decl)))
+  && !(SUPPORTS_SHF_GNU_RETAIN && DECL_PRESERVE_P (decl)))
 {
   /* If the decl has been given an explicit section name, or it resides
 in a non-generic address space, then it isn't common, and shouldn't
@@ -7752,7 +7752,7 @@ switch_to_section (section *new_section, tree decl)
 {
   if (in_section == new_section)
 {
-  if (HAVE_GAS_SHF_GNU_RETAIN
+  if (SUPPORTS_SHF_GNU_RETAIN
  && (new_section->common.flags & SECTION_NAMED)
  && decl != nullptr
  && DECL_P (decl)
-- 
2.29.2



V4 [PATCH 2/3] Warn used and not used symbols in section with the same name

2020-12-15 Thread H.J. Lu via Gcc-patches
When SECTION_RETAIN is used, issue a warning when a symbol without used
attribute and a symbol with used attribute are placed in the section with
the same name, like

int __attribute__((used,section(".data.foo"))) foo2 = 2;
int __attribute__((section(".data.foo"))) foo1 = 1;

since assembler will put them in different sections with the same section
name.

gcc/

PR target/98146
* varasm.c (switch_to_section): Warn when a symbol without used
attribute and a symbol with used attribute are placed in the
section with the same name.

gcc/testsuite/

PR target/98146
* c-c++-common/attr-used-5.c: Updated.
* c-c++-common/attr-used-6.c: Likewise.
* c-c++-common/attr-used-7.c: Likewise.
* c-c++-common/attr-used-8.c: Likewise.
---
 gcc/testsuite/c-c++-common/attr-used-5.c |  1 +
 gcc/testsuite/c-c++-common/attr-used-6.c |  1 +
 gcc/testsuite/c-c++-common/attr-used-7.c |  1 +
 gcc/testsuite/c-c++-common/attr-used-8.c |  1 +
 gcc/varasm.c | 22 +++---
 5 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/gcc/testsuite/c-c++-common/attr-used-5.c 
b/gcc/testsuite/c-c++-common/attr-used-5.c
index 9fc0d3834e9..ba59326e452 100644
--- a/gcc/testsuite/c-c++-common/attr-used-5.c
+++ b/gcc/testsuite/c-c++-common/attr-used-5.c
@@ -10,6 +10,7 @@ extern struct dtv_slotinfo_list *list;
 
 static int __attribute__ ((section ("__libc_freeres_fn")))
 free_slotinfo (struct dtv_slotinfo_list **elemp)
+/* { dg-warning "'.*' without 'used' attribute and '.*' with 'used' attribute 
are placed in a section with the same name" "" { target R_flag_in_section } .-1 
} */
 {
   if (!free_slotinfo (&(*elemp)->next))
 return 0;
diff --git a/gcc/testsuite/c-c++-common/attr-used-6.c 
b/gcc/testsuite/c-c++-common/attr-used-6.c
index 0cb82ade5a9..5d20f875bf0 100644
--- a/gcc/testsuite/c-c++-common/attr-used-6.c
+++ b/gcc/testsuite/c-c++-common/attr-used-6.c
@@ -18,6 +18,7 @@ free_slotinfo (struct dtv_slotinfo_list **elemp)
 
 __attribute__ ((section ("__libc_freeres_fn")))
 void free_mem (void)
+/* { dg-warning "'.*' without 'used' attribute and '.*' with 'used' attribute 
are placed in a section with the same name" "" { target R_flag_in_section } .-1 
} */
 {
   free_slotinfo (&list);
 }
diff --git a/gcc/testsuite/c-c++-common/attr-used-7.c 
b/gcc/testsuite/c-c++-common/attr-used-7.c
index fba2706ffc1..75576bcabe5 100644
--- a/gcc/testsuite/c-c++-common/attr-used-7.c
+++ b/gcc/testsuite/c-c++-common/attr-used-7.c
@@ -3,6 +3,7 @@
 
 int __attribute__((used,section(".data.foo"))) foo2 = 2;
 int __attribute__((section(".data.foo"))) foo1 = 1;
+/* { dg-warning "'.*' without 'used' attribute and '.*' with 'used' attribute 
are placed in a section with the same name" "" { target R_flag_in_section } .-1 
} */
 
 /* { dg-final { scan-assembler ".data.foo,\"aw\"" { target R_flag_in_section } 
} } */
 /* { dg-final { scan-assembler ".data.foo,\"awR\"" { target R_flag_in_section 
} } } */
diff --git a/gcc/testsuite/c-c++-common/attr-used-8.c 
b/gcc/testsuite/c-c++-common/attr-used-8.c
index 4da4aabe573..e4982db1044 100644
--- a/gcc/testsuite/c-c++-common/attr-used-8.c
+++ b/gcc/testsuite/c-c++-common/attr-used-8.c
@@ -2,6 +2,7 @@
 /* { dg-options "-Wall -O2" } */
 
 int __attribute__((section(".data.foo"))) foo1 = 1;
+/* { dg-warning "'.*' without 'used' attribute and '.*' with 'used' attribute 
are placed in a section with the same name" "" { target R_flag_in_section } .-1 
} */
 int __attribute__((used,section(".data.foo"))) foo2 = 2;
 
 /* { dg-final { scan-assembler ".data.foo,\"aw\"" { target R_flag_in_section } 
} } */
diff --git a/gcc/varasm.c b/gcc/varasm.c
index e3e49d53e5d..72d5379303a 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -7761,11 +7761,27 @@ switch_to_section (section *new_section, tree decl)
{
  /* If the SECTION_RETAIN bit doesn't match, switch to a new
 section.  */
+ tree used_decl, no_used_decl;
+
  if (DECL_PRESERVE_P (decl))
-   new_section->common.flags |= SECTION_RETAIN;
+   {
+ new_section->common.flags |= SECTION_RETAIN;
+ used_decl = decl;
+ no_used_decl = new_section->named.decl;
+   }
  else
-   new_section->common.flags &= ~(SECTION_RETAIN
-  | SECTION_DECLARED);
+   {
+ new_section->common.flags &= ~(SECTION_RETAIN
+| SECTION_DECLARED);
+ used_decl = new_section->named.decl;
+ no_used_decl = decl;
+   }
+ warning (OPT_Wattributes,
+  "%+qD without % attribute and %qD with "
+  "% attribute are placed in a section with "
+  "the same name", no_used_decl, used_decl);
+ inform (DECL_SOURCE_LOCATION (used_decl),
+ "%qD was declared here", used_decl);
}
   else

V4 [PATCH 1/3] Switch to a new section if the SECTION_RETAIN bit doesn't match

2020-12-15 Thread H.J. Lu via Gcc-patches
When definitions marked with used attribute and unmarked definitions are
placed in the section with the same name, switch to a new section if the
SECTION_RETAIN bit doesn't match.

gcc/

PR target/98146
* output.h (switch_to_section): Add a tree argument, default to
nullptr.
* varasm.c (get_section): If the SECTION_RETAIN bit doesn't match,
return and switch to a new section later.
(assemble_start_function): Pass decl to switch_to_section.
(assemble_variable): Likewise.
(switch_to_section): If the SECTION_RETAIN bit doesn't match,
switch to a new section.

gcc/testsuite/

PR target/98146
* c-c++-common/attr-used-5.c: New test.
* c-c++-common/attr-used-6.c: Likewise.
* c-c++-common/attr-used-7.c: Likewise.
* c-c++-common/attr-used-8.c: Likewise.
* c-c++-common/attr-used-9.c: Likewise.
---
 gcc/output.h |  2 +-
 gcc/testsuite/c-c++-common/attr-used-5.c | 26 ++
 gcc/testsuite/c-c++-common/attr-used-6.c | 26 ++
 gcc/testsuite/c-c++-common/attr-used-7.c |  8 ++
 gcc/testsuite/c-c++-common/attr-used-8.c |  8 ++
 gcc/testsuite/c-c++-common/attr-used-9.c | 28 +++
 gcc/varasm.c | 34 
 7 files changed, 126 insertions(+), 6 deletions(-)
 create mode 100644 gcc/testsuite/c-c++-common/attr-used-5.c
 create mode 100644 gcc/testsuite/c-c++-common/attr-used-6.c
 create mode 100644 gcc/testsuite/c-c++-common/attr-used-7.c
 create mode 100644 gcc/testsuite/c-c++-common/attr-used-8.c
 create mode 100644 gcc/testsuite/c-c++-common/attr-used-9.c

diff --git a/gcc/output.h b/gcc/output.h
index fa8ace1f394..1f9af46da1d 100644
--- a/gcc/output.h
+++ b/gcc/output.h
@@ -548,7 +548,7 @@ extern void switch_to_other_text_partition (void);
 extern section *get_cdtor_priority_section (int, bool);
 
 extern bool unlikely_text_section_p (section *);
-extern void switch_to_section (section *);
+extern void switch_to_section (section *, tree = nullptr);
 extern void output_section_asm_op (const void *);
 
 extern void record_tm_clone_pair (tree, tree);
diff --git a/gcc/testsuite/c-c++-common/attr-used-5.c 
b/gcc/testsuite/c-c++-common/attr-used-5.c
new file mode 100644
index 000..9fc0d3834e9
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/attr-used-5.c
@@ -0,0 +1,26 @@
+/* { dg-do compile } */
+/* { dg-options "-Wall -O2" } */
+
+struct dtv_slotinfo_list
+{
+  struct dtv_slotinfo_list *next;
+};
+
+extern struct dtv_slotinfo_list *list;
+
+static int __attribute__ ((section ("__libc_freeres_fn")))
+free_slotinfo (struct dtv_slotinfo_list **elemp)
+{
+  if (!free_slotinfo (&(*elemp)->next))
+return 0;
+  return 1;
+}
+
+__attribute__ ((used, section ("__libc_freeres_fn")))
+static void free_mem (void)
+{
+  free_slotinfo (&list);
+}
+
+/* { dg-final { scan-assembler "__libc_freeres_fn,\"ax\"" { target 
R_flag_in_section } } } */
+/* { dg-final { scan-assembler "__libc_freeres_fn,\"axR\"" { target 
R_flag_in_section } } } */
diff --git a/gcc/testsuite/c-c++-common/attr-used-6.c 
b/gcc/testsuite/c-c++-common/attr-used-6.c
new file mode 100644
index 000..0cb82ade5a9
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/attr-used-6.c
@@ -0,0 +1,26 @@
+/* { dg-do compile } */
+/* { dg-options "-Wall -O2" } */
+
+struct dtv_slotinfo_list
+{
+  struct dtv_slotinfo_list *next;
+};
+
+extern struct dtv_slotinfo_list *list;
+
+static int __attribute__ ((used, section ("__libc_freeres_fn")))
+free_slotinfo (struct dtv_slotinfo_list **elemp)
+{
+  if (!free_slotinfo (&(*elemp)->next))
+return 0;
+  return 1;
+}
+
+__attribute__ ((section ("__libc_freeres_fn")))
+void free_mem (void)
+{
+  free_slotinfo (&list);
+}
+
+/* { dg-final { scan-assembler "__libc_freeres_fn,\"ax\"" { target 
R_flag_in_section } } } */
+/* { dg-final { scan-assembler "__libc_freeres_fn,\"axR\"" { target 
R_flag_in_section } } } */
diff --git a/gcc/testsuite/c-c++-common/attr-used-7.c 
b/gcc/testsuite/c-c++-common/attr-used-7.c
new file mode 100644
index 000..fba2706ffc1
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/attr-used-7.c
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-Wall -O2" } */
+
+int __attribute__((used,section(".data.foo"))) foo2 = 2;
+int __attribute__((section(".data.foo"))) foo1 = 1;
+
+/* { dg-final { scan-assembler ".data.foo,\"aw\"" { target R_flag_in_section } 
} } */
+/* { dg-final { scan-assembler ".data.foo,\"awR\"" { target R_flag_in_section 
} } } */
diff --git a/gcc/testsuite/c-c++-common/attr-used-8.c 
b/gcc/testsuite/c-c++-common/attr-used-8.c
new file mode 100644
index 000..4da4aabe573
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/attr-used-8.c
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-Wall -O2" } */
+
+int __attribute__((section(".data.foo"))) foo1 = 1;
+int __attribute__((used,section(".data.foo"))) foo2 = 2;
+
+/* { dg-final { scan

Re: [PATCH 29/31] PDP11: Use `const_double_zero' to express double zero constant

2020-12-15 Thread Paul Koning via Gcc-patches



> On Dec 15, 2020, at 9:06 AM, Maciej W. Rozycki  wrote:
> 
> On Tue, 15 Dec 2020, Martin Liška wrote:
> 
>> If I see correctly, starting from this revision I can't compile a cross
>> compiler of x86_64-linux-gnu:
>> 
>> ../configure --target=pdp11-aout --disable-bootstrap --enable-languages=c,c++
>> --disable-multilib  --enable-obsolete

PDP11 doesn't do C++, there isn't any way to do that with aout that I have seen 
(no named section support).  There's been some experimental work on ELF for 
pdp11 (!) which should make this possible but I haven't tried that yet.

> 
> Thanks for the heads-up and the details of the configuration, and sorry 
> for the breakage.
> ...
> 
>> Can you please take a look?
> 
> I'm fairly sure this is due to the difference in TARGET_SUPPORTS_WIDE_INT
> with the VAX backend vs the PDP-11 one.  I have an idea how this should be 
> addressed and will be implementing it shortly.

What's the difference?  pdp11 does support wide int.

> NB the backend fails `-Werror' compilation:
> 
> In file included from ./tm.h:18,
> from .../gcc/backend.h:28,
> from .../gcc/varasm.c:31:
> .../gcc/varasm.c: In function 'void assemble_zeros(long unsigned int)':
> .../gcc/config/pdp11/pdp11.h:622:20: error: format '%o' expects argument of 
> type 'unsigned int', but argument 3 has type 'long unsigned int' 
> [-Werror=format=]
>  622 | fprintf (FILE, "\t.blkb\t%o\n", (SIZE) & 0x);   \
>  |^~~  ~~~
>  ||
>  |long unsigned int
> 
> etc., so that has to be disabled.  This may be with 64-bit hosts only, I'm 
> not sure, however the way varargs are handled means the issue will likely 
> cause a broken compiler to be built if the warning is ignored, at least 
> with some hosts.
> 
> Paul, can you please look into it sometime?

Will do, thanks.

paul




Re: [PATCH 29/31] PDP11: Use `const_double_zero' to express double zero constant

2020-12-15 Thread Maciej W. Rozycki
On Tue, 15 Dec 2020, Paul Koning wrote:

> > I'm fairly sure this is due to the difference in TARGET_SUPPORTS_WIDE_INT
> > with the VAX backend vs the PDP-11 one.  I have an idea how this should be 
> > addressed and will be implementing it shortly.
> 
> What's the difference?  pdp11 does support wide int.

 The VAX backend, being old-fashioned, does not and therefore overloads 
the CONST_DOUBLE rtx for that purpose, making it possibly relevant here 
(it has turned out not after all: the cause is the use of named patterns 
for the CC-setting insns referred to by splitters, which the VAX backend 
does not have).  NB there's been no rush to update the VAX backend for 
proper wide integer support, which will require some caution AFAICT.

 Anyway I have a fix now I am satisfied with and will be posting it 
shortly.  I'll appreciate it if you verify it as I have no means beyond 
making sure that it builds.  I'll cc you on the upcoming submission; a 
general maintainer will have to approve it though.

  Maciej


Re: [PATCH 1/2] libstdc++: Add --enable-stdio=stdio_pure option [v2]

2020-12-15 Thread Jonathan Wakely via Gcc-patches

On 10/12/20 12:56 -0800, Keith Packard via Libstdc++ wrote:

Jonathan Wakely  writes:


I'll do a bit more testing and push it next week.


That's awesome news. Thanks so much for you help; I'm looking forward to
having real C++ support for my embedded customers!


Pushed to master.


commit 75aee072696a711f3e5b3bd1ab1f2b10fef4c7dd
Author: Keith Packard 
Date:   Tue Dec 15 17:39:24 2020

libstdc++: Support libc with stdio-only I/O in libstdc++

The current libstdc++ basic_file_stdio.cc code assumes a POSIX API
underneath the stdio implementation provided by the host libc. This
means that the host must provide a fairly broad POSIX file API,
including read, write, open, close, lseek and ioctl.

This patch changes basic_file_stdio.cc to only use basic ANSI-C stdio
functions, allowing it to be used with libc implementations like
picolibc which may not have a POSIX operating system underneath.

This is enabled by a new --enable-cstdio=stdio_pure configure option.

Aided-by: Jonathan Wakely 
Signed-off-by: Keith Packard 

libstdc++-v3/ChangeLog:

* acinclude.m4 (GLIBCXX_ENABLE_CSTDIO): Allow "stdio_pure"
option and define _GLIBCXX_USE_PURE_STDIO when it is used. Also
add "stdio_posix" option as an alias for "stdio".
* config/io/basic_file_stdio.cc [_GLIBCXX_USE_PURE_STDIO]: Only
use defined stdio entry points for all I/O operations, without
direct calls to underlying POSIX functions.
* config.h.in: Regenerate.
* configure: Regenerate.

diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index 61191812c92..df8be3bf805 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -2868,24 +2868,30 @@ AC_DEFUN([GLIBCXX_ENABLE_PARALLEL], [
 
 
 dnl
-dnl Check for which I/O library to use:  stdio, or something specific.
+dnl Check for which I/O library to use:  stdio and POSIX, or pure stdio.
 dnl
-dnl Default is stdio.
+dnl Default is stdio_posix.
 dnl
 AC_DEFUN([GLIBCXX_ENABLE_CSTDIO], [
   AC_MSG_CHECKING([for underlying I/O to use])
   GLIBCXX_ENABLE(cstdio,stdio,[[[=PACKAGE]]],
-[use target-specific I/O package], [permit stdio])
+[use target-specific I/O package], [permit stdio|stdio_posix|stdio_pure])
 
-  # Now that libio has been removed, you can have any color you want as long
-  # as it's black.  This is one big no-op until other packages are added, but
-  # showing the framework never hurts.
+  # The only available I/O model is based on stdio, via basic_file_stdio.
+  # The default "stdio" is actually "stdio + POSIX" because it uses fdopen(3)
+  # to get a file descriptor and then uses read(3) and write(3) with it.
+  # The "stdio_pure" model doesn't use fdopen and only uses FILE* for I/O.
   case ${enable_cstdio} in
-stdio)
+stdio*)
   CSTDIO_H=config/io/c_io_stdio.h
   BASIC_FILE_H=config/io/basic_file_stdio.h
   BASIC_FILE_CC=config/io/basic_file_stdio.cc
   AC_MSG_RESULT(stdio)
+
+  if test "x$enable_cstdio" = "xstdio_pure" ; then
+	AC_DEFINE(_GLIBCXX_USE_STDIO_PURE, 1,
+		  [Define to restrict std::__basic_file<> to stdio APIs.])
+  fi
   ;;
   esac
 
diff --git a/libstdc++-v3/config/io/basic_file_stdio.cc b/libstdc++-v3/config/io/basic_file_stdio.cc
index ba830fb9e97..eedffb017b6 100644
--- a/libstdc++-v3/config/io/basic_file_stdio.cc
+++ b/libstdc++-v3/config/io/basic_file_stdio.cc
@@ -111,13 +111,21 @@ namespace
 
   // Wrapper handling partial write.
   static std::streamsize
+#ifdef _GLIBCXX_USE_STDIO_PURE
+  xwrite(FILE *__file, const char* __s, std::streamsize __n)
+#else
   xwrite(int __fd, const char* __s, std::streamsize __n)
+#endif
   {
 std::streamsize __nleft = __n;
 
 for (;;)
   {
+#ifdef _GLIBCXX_USE_STDIO_PURE
+	const std::streamsize __ret = fwrite(__file, 1, __nleft, __file);
+#else
 	const std::streamsize __ret = write(__fd, __s, __nleft);
+#endif
 	if (__ret == -1L && errno == EINTR)
 	  continue;
 	if (__ret == -1L)
@@ -133,7 +141,7 @@ namespace
 return __n - __nleft;
   }
 
-#ifdef _GLIBCXX_HAVE_WRITEV
+#if defined(_GLIBCXX_HAVE_WRITEV) && !defined(_GLIBCXX_USE_STDIO_PURE)
   // Wrapper handling partial writev.
   static std::streamsize
   xwritev(int __fd, const char* __s1, std::streamsize __n1,
@@ -286,9 +294,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   __basic_file::is_open() const throw ()
   { return _M_cfile != 0; }
 
+#ifndef _GLIBCCXX_USE_STDIO_PURE
   int
   __basic_file::fd() throw ()
   { return fileno(_M_cfile); }
+#endif
 
   __c_file*
   __basic_file::file() throw ()
@@ -315,28 +325,46 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   {
 streamsize __ret;
 do
+#ifdef _GLIBCXX_USE_STDIO_PURE
+  __ret = fread(__s, 1, __n, this->file());
+#else
   __ret = read(this->fd(), __s, __n);
+#endif
 while (__ret == -1L && errno == EINTR);
 return __ret;
   }
 
   streamsize
   __basic_file::xsputn(const char* __s, 

Re: [committed] libstdc++: Use init_priority attribute for Init object [PR 98108]

2020-12-15 Thread Jonathan Wakely via Gcc-patches

On 15/12/20 11:47 +, Jonathan Wakely wrote:

This causes the global objects that run the  initialization
code to be constructed earlier, which avoids some bugs in user code due
to incorrectly relying on static initialization order.

libstdc++-v3/ChangeLog:

PR libstdc++/98108
* include/std/iostream (__ioinit): Add init_priority attribute.



I've reverted this because it doesn't work on darwin, and isn't
required for correctness anyway.

Tested powerpc64le-linux. Committed to trunk.




commit cf4ed3b41594b6935a337fe0aaf8149eadf88751
Author: Jonathan Wakely 
Date:   Tue Dec 15 11:40:06 2020

   libstdc++: Use init_priority attribute for Init object [PR 98108]

   This causes the global objects that run the  initialization
   code to be constructed earlier, which avoids some bugs in user code due
   to incorrectly relying on static initialization order.

   libstdc++-v3/ChangeLog:

   PR libstdc++/98108
   * include/std/iostream (__ioinit): Add init_priority attribute.

diff --git a/libstdc++-v3/include/std/iostream 
b/libstdc++-v3/include/std/iostream
index f988342b90a..6b2f964f688 100644
--- a/libstdc++-v3/include/std/iostream
+++ b/libstdc++-v3/include/std/iostream
@@ -70,8 +70,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#endif
  //@}

+#if __has_attribute(__init_priority__)
+# define _GLIBCXX_INIT_PRIO(N) __attribute__((__init_priority__(N)))
+#else
+# define _GLIBCXX_INIT_PRIO(N)
+#endif
+
  // For construction of filebuffers for cout, cin, cerr, clog et. al.
-  static ios_base::Init __ioinit;
+  static ios_base::Init __ioinit _GLIBCXX_INIT_PRIO(90);
+
+#undef _GLIBCXX_INIT_PRIO

_GLIBCXX_END_NAMESPACE_VERSION
} // namespace




Re: [PATCH] match.pd: Optimize X / bool_range_Y to X [PR96094]

2020-12-15 Thread Jeff Law via Gcc-patches



On 12/15/20 2:05 AM, Jakub Jelinek wrote:
> Hi!
>
> When the divisor is bool or has [0, 1] range, as division by
> 0 is UB, the only remaining option in valid programs is division by 1,
> so we can optimize X / bool_range_Y into X.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>
> 2020-12-15  Jakub Jelinek  
>
>   PR tree-optimization/96094
>   * match.pd (X / bool_range_Y -> X): New simplification.
>
>   * gcc.dg/tree-ssa/pr96094.c: New test.
OK
jeff



libcody: Fix for dash

2020-12-15 Thread Nathan Sidwell

Apparently 'var+=...' is not a dash thing.  Fixed thusly.

* config.m4: Avoid non-dash idiom
* configure: Rebuilt.

pushed (2 patches, because I didn't look carefully enough the first time)

--
Nathan Sidwell
diff --git i/libcody/config.m4 w/libcody/config.m4
index 364195a9f0b..0ae7b2665f0 100644
--- i/libcody/config.m4
+++ w/libcody/config.m4
@@ -35,7 +35,8 @@ if test "$tools" && test -d "$tools/lib" ; then
   if os=$(CXX -print-multi-os-directory 2>/dev/null) ; then
 toollib+="/${os}"
   fi
-  LDFLAGS+=" -L $toollib"
+  ## VAR+=... is not dashing
+  LDFLAGS="$LDFLAGS -L $toollib"
   unset toollib
 fi])
 
diff --git i/libcody/configure w/libcody/configure
index 35fd4e9db7e..8f22dd78134 100755
--- i/libcody/configure
+++ w/libcody/configure
@@ -2632,7 +2632,8 @@ if test "$tools" && test -d "$tools/lib" ; then
   if os=$(CXX -print-multi-os-directory 2>/dev/null) ; then
 toollib+="/${os}"
   fi
-  LDFLAGS+=" -L $toollib"
+  ## VAR+=... is not dashing
+  LDFLAGS="$LDFLAGS -L $toollib"
   unset toollib
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking adding -Wl,--no-undefined to linker" >&5
diff --git i/libcody/config.m4 w/libcody/config.m4
index 0ae7b2665f0..801cfbdb593 100644
--- i/libcody/config.m4
+++ w/libcody/config.m4
@@ -173,7 +173,7 @@ AC_SUBST(EXCEPTIONS)])
 AC_DEFUN([NMS_LINK_OPT],
 [AC_MSG_CHECKING([adding $1 to linker])
 ORIG_LDFLAGS="$LDFLAGS"
-LDFLAGS+=" $1"
+LDFLAGS="$LDFLAGS $1"
 AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
 [AC_MSG_RESULT([ok])],
 [LDFLAGS="$ORIG_LDFLAGS"
@@ -229,8 +229,8 @@ elif test "$withval" = "no" ; then
   AC_MSG_RESULT(installed)
 else
   AC_MSG_RESULT(${withval})
-  CPPFLAGS+=" -I${withval}/include"
-  LDFLAGS+=" -L${withval}/lib"
+  CPPFLAGS="$CPPFLAGS -I${withval}/include"
+  LDFLAGS="$LDFLAGS -L${withval}/lib"
 fi,
 AC_MSG_RESULT(installed))])
 
diff --git i/libcody/configure w/libcody/configure
index 8f22dd78134..1a119c59b9f 100755
--- i/libcody/configure
+++ w/libcody/configure
@@ -2639,7 +2639,7 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking adding -Wl,--no-undefined to linker" >&5
 $as_echo_n "checking adding -Wl,--no-undefined to linker... " >&6; }
 ORIG_LDFLAGS="$LDFLAGS"
-LDFLAGS+=" -Wl,--no-undefined"
+LDFLAGS="$LDFLAGS -Wl,--no-undefined"
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 


Re: [PATCH 1/2] Remove Report keyword for options

2020-12-15 Thread Jeff Law via Gcc-patches



On 12/15/20 1:01 AM, Martin Liška wrote:
> There's a small clean up that removes Report as it's not used
> any longer by -fverbose-asm.
>
> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
>
> Ready to be installed?
> Thanks,
> Martin
>
> 0001-Remove-Report-keyword-for-options.patch
>
> From 13c7f39e59862a639823d0f47bbe1f4d9aacd736 Mon Sep 17 00:00:00 2001
> From: Martin Liska 
> Date: Fri, 11 Dec 2020 17:06:49 +0100
> Subject: [PATCH 1/2] Remove Report keyword for options
>
> Since g:7caa49706316e650fb67719e1a1bf3a35054b685 the option is ignored
> as we print used command line for -fverbose-asm output.
>
> gcc/ChangeLog:
>
>   * doc/options.texi: Remove Report keyword.
>   * opt-functions.awk: Print error when Report keyword
>   is used.
>   * optc-gen.awk: Do not handle Report keyword.
>   * opts.h (struct cl_option): Remove cl_report bitfield flag.
Arguably not a bugfix.  But I think this is reasonable, even during stage3.

OK by me, but give Richi and Jakub a couple days if they object due to
it not being a bugfix.

jeff



Re: [PATCH 2/2] opts: Remove all usages of Report keyword.

2020-12-15 Thread Jeff Law via Gcc-patches



On 12/15/20 1:02 AM, Martin Liška wrote:
> I've tested this mechanical change for all cross compilers.
>
> Ready to be installed?
ENOPATCH, but same as 1/1 of this series. OK by me given I can guess
what it looks like, but give Jakub and Richi time to chime in.

jeff



Re: [PATCH]AArch64: Add NEON, SVE and SVE2 RTL patterns for Complex Addition, Multiply and FMA.

2020-12-15 Thread Tamar Christina via Gcc-patches
Hi Richard,

Here's the split off complex add.

Bootstrapped Regtested on aarch64-none-linux-gnu and no issues.
Checked with armv8-a+sve2+fp16 and no issues.  Note that due to a mid-end
limitation SLP for SVE currently fails for some permutes.  The tests have these
marked as XFAIL.

Matching tests for these are in the mid-end patches.

Ok for master?

The rest will be respun when I have a working tree again and can test them
again.

Thanks,
Tamar


gcc/ChangeLog:

* config/aarch64/aarch64-simd.md (cadd3): New.
* config/aarch64/iterators.md (SVE2_INT_CADD_OP): New.
* config/aarch64/aarch64-sve.md (cadd3): New.
* config/aarch64/aarch64-sve2.md (cadd3): New.

The 12/14/2020 16:11, Richard Sandiford wrote:
> Tamar Christina  writes:
> > Hi Richard, 
> >
> > Do you object to me splitting off complex add and addressing your remaining
> > feedback later when the rewrite of mul and fma are done. 
> 
> No, sounds good to me.
> 
> Thanks,
> Richard

-- 
diff --git a/gcc/config/aarch64/aarch64-simd.md b/gcc/config/aarch64/aarch64-simd.md
index 68baf416045178b0ebcfeb8de2d201f625f1c317..05d18f8bd3ac09c56c82dc73cff855315eb302b7 100644
--- a/gcc/config/aarch64/aarch64-simd.md
+++ b/gcc/config/aarch64/aarch64-simd.md
@@ -449,6 +449,14 @@ (define_insn "aarch64_fcadd"
   [(set_attr "type" "neon_fcadd")]
 )
 
+(define_expand "cadd3"
+  [(set (match_operand:VHSDF 0 "register_operand")
+	(unspec:VHSDF [(match_operand:VHSDF 1 "register_operand")
+		   (match_operand:VHSDF 2 "register_operand")]
+		   FCADD))]
+  "TARGET_COMPLEX && !BYTES_BIG_ENDIAN"
+)
+
 (define_insn "aarch64_fcmla"
   [(set (match_operand:VHSDF 0 "register_operand" "=w")
 	(plus:VHSDF (match_operand:VHSDF 1 "register_operand" "0")
diff --git a/gcc/config/aarch64/aarch64-sve.md b/gcc/config/aarch64/aarch64-sve.md
index 6359c40bdecda6c126bd70bef66561dd1da44dc9..6a5194f54f9c3d7b985890df523ceb4221b0cc63 100644
--- a/gcc/config/aarch64/aarch64-sve.md
+++ b/gcc/config/aarch64/aarch64-sve.md
@@ -5480,6 +5480,20 @@ (define_expand "@cond_"
   "TARGET_SVE"
 )
 
+;; Predicated FCADD using ptrue for unpredicated optab for auto-vectorizer
+(define_expand "@cadd3"
+  [(set (match_operand:SVE_FULL_F 0 "register_operand")
+	(unspec:SVE_FULL_F
+	  [(match_dup 3)
+	   (const_int SVE_RELAXED_GP)
+	   (match_operand:SVE_FULL_F 1 "register_operand")
+	   (match_operand:SVE_FULL_F 2 "register_operand")]
+	  SVE_COND_FCADD))]
+  "TARGET_SVE"
+{
+  operands[3] = aarch64_ptrue_reg (mode);
+})
+
 ;; Predicated FCADD, merging with the first input.
 (define_insn_and_rewrite "*cond__2_relaxed"
   [(set (match_operand:SVE_FULL_F 0 "register_operand" "=w, ?&w")
diff --git a/gcc/config/aarch64/aarch64-sve2.md b/gcc/config/aarch64/aarch64-sve2.md
index 772c35079c9441448534471fba4dba622322b8fc..1897ddf69c34496247e40ba36d97b93a9a9d7670 100644
--- a/gcc/config/aarch64/aarch64-sve2.md
+++ b/gcc/config/aarch64/aarch64-sve2.md
@@ -1799,6 +1799,16 @@ (define_insn "@aarch64_sve_"
   [(set_attr "movprfx" "*,yes")]
 )
 
+;; unpredicated optab pattern for auto-vectorizer
+(define_expand "cadd3"
+  [(set (match_operand:SVE_FULL_I 0 "register_operand")
+	(unspec:SVE_FULL_I
+	  [(match_operand:SVE_FULL_I 1 "register_operand")
+	   (match_operand:SVE_FULL_I 2 "register_operand")]
+	  SVE2_INT_CADD_OP))]
+  "TARGET_SVE2"
+)
+
 ;; -
 ;;  [INT] Complex ternary operations
 ;; -
diff --git a/gcc/config/aarch64/iterators.md b/gcc/config/aarch64/iterators.md
index fb1426b7752890848cb49722ef7442d96cb1408b..b8ee4220603ce6da4e8044f61042d98a7e60b17d 100644
--- a/gcc/config/aarch64/iterators.md
+++ b/gcc/config/aarch64/iterators.md
@@ -2598,6 +2598,10 @@ (define_int_iterator SVE2_INT_CMLA [UNSPEC_CMLA
 UNSPEC_SQRDCMLAH180
 UNSPEC_SQRDCMLAH270])
 
+;; Same as SVE2_INT_CADD but exclude the saturating instructions
+(define_int_iterator SVE2_INT_CADD_OP [UNSPEC_CADD90
+   UNSPEC_CADD270])
+
 (define_int_iterator SVE2_INT_CDOT [UNSPEC_CDOT
 UNSPEC_CDOT90
 UNSPEC_CDOT180



[r11-6072 Regression] FAIL: g++.dg/warn/Wstringop-overflow-6.C -std=gnu++2a (test for excess errors) on Linux/x86_64

2020-12-15 Thread sunil.k.pandey via Gcc-patches
On Linux/x86_64,

cf4ed3b41594b6935a337fe0aaf8149eadf88751 is the first bad commit
commit cf4ed3b41594b6935a337fe0aaf8149eadf88751
Author: Jonathan Wakely 
Date:   Tue Dec 15 11:40:06 2020 +

libstdc++: Use init_priority attribute for Init object [PR 98108]

caused

FAIL: g++.dg/pch/system-1.C  -g assembly comparison
FAIL: g++.dg/pch/system-1.C  -O2 assembly comparison
FAIL: g++.dg/pch/system-1.C  -O2 -g assembly comparison
FAIL: g++.dg/pch/system-2.C  -g assembly comparison
FAIL: g++.dg/pch/system-2.C  -O2 assembly comparison
FAIL: g++.dg/pch/system-2.C  -O2 -g assembly comparison
FAIL: g++.dg/warn/Wstringop-overflow-6.C  -std=gnu++14 (test for excess errors)
FAIL: g++.dg/warn/Wstringop-overflow-6.C  -std=gnu++17 (test for excess errors)
FAIL: g++.dg/warn/Wstringop-overflow-6.C  -std=gnu++2a (test for excess errors)

with GCC configured with

../../gcc/configure 
--prefix=/local/skpandey/gccwork/toolwork/gcc-bisect-master/master/r11-6072/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="pch.exp=g++.dg/pch/system-1.C 
--target_board='unix{-m32\ -march=cascadelake}'"
$ cd {build_dir}/gcc && make check RUNTESTFLAGS="pch.exp=g++.dg/pch/system-1.C 
--target_board='unix{-m64}'"
$ cd {build_dir}/gcc && make check RUNTESTFLAGS="pch.exp=g++.dg/pch/system-1.C 
--target_board='unix{-m64\ -march=cascadelake}'"
$ cd {build_dir}/gcc && make check RUNTESTFLAGS="pch.exp=g++.dg/pch/system-2.C 
--target_board='unix{-m32}'"
$ cd {build_dir}/gcc && make check RUNTESTFLAGS="pch.exp=g++.dg/pch/system-2.C 
--target_board='unix{-m32\ -march=cascadelake}'"
$ cd {build_dir}/gcc && make check RUNTESTFLAGS="pch.exp=g++.dg/pch/system-2.C 
--target_board='unix{-m64}'"
$ cd {build_dir}/gcc && make check RUNTESTFLAGS="pch.exp=g++.dg/pch/system-2.C 
--target_board='unix{-m64\ -march=cascadelake}'"
$ cd {build_dir}/gcc && make check 
RUNTESTFLAGS="dg.exp=g++.dg/warn/Wstringop-overflow-6.C 
--target_board='unix{-m32}'"
$ cd {build_dir}/gcc && make check 
RUNTESTFLAGS="dg.exp=g++.dg/warn/Wstringop-overflow-6.C 
--target_board='unix{-m32\ -march=cascadelake}'"
$ cd {build_dir}/gcc && make check 
RUNTESTFLAGS="dg.exp=g++.dg/warn/Wstringop-overflow-6.C 
--target_board='unix{-m64}'"
$ cd {build_dir}/gcc && make check 
RUNTESTFLAGS="dg.exp=g++.dg/warn/Wstringop-overflow-6.C 
--target_board='unix{-m64\ -march=cascadelake}'"

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


[PATCH] genemit: Handle `const_double_zero' rtx

2020-12-15 Thread Maciej W. Rozycki
Complement commit 20ab43b5cad6 ("RTL: Add `const_double_zero' syntactic 
rtx") and remove a commit c60d0736dff7 ("PDP11: Use `const_double_zero' 
to express double zero constant") build regression observed with the 
`pdp11-aout' target:

genemit: Internal error: abort in gen_exp, at genemit.c:202
make[2]: *** [Makefile:2427: s-emit] Error 1

where a:

(const_double 0 [0] 0 [0] 0 [0] 0 [0])

rtx coming from:

(parallel [
(set (reg:CC 16)
(compare:CC (abs:DF (match_operand:DF 1 ("general_operand") 
("0,0")))
(const_double 0 [0] 0 [0] 0 [0] 0 [0])))
(set (match_operand:DF 0 ("nonimmediate_operand") ("=fR,Q"))
(abs:DF (match_dup 1)))
])

and ultimately `(const_double_zero)' referred in a named RTL insn cannot 
be interpreted.  Handle the rtx then by supplying the constant 0 double 
operand requested, resulting in the following update to insn-emit.c code 
produced for the `pdp11-aout' target, relative to before the triggering 
commit:

@@ -1514,7 +1514,7 @@ gen_absdf2_cc (rtx operand0 ATTRIBUTE_UN
gen_rtx_COMPARE (CCmode,
gen_rtx_ABS (DFmode,
operand1),
-   const0_rtx)),
+   CONST_DOUBLE_ATOF ("0", VOIDmode))),
gen_rtx_SET (operand0,
gen_rtx_ABS (DFmode,
copy_rtx (operand1);
@@ -1555,7 +1555,7 @@ gen_negdf2_cc (rtx operand0 ATTRIBUTE_UN
gen_rtx_COMPARE (CCmode,
gen_rtx_NEG (DFmode,
operand1),
-   const0_rtx)),
+   CONST_DOUBLE_ATOF ("0", VOIDmode))),
gen_rtx_SET (operand0,
gen_rtx_NEG (DFmode,
copy_rtx (operand1);
@@ -1790,7 +1790,7 @@ gen_muldf3_cc (rtx operand0 ATTRIBUTE_UN
gen_rtx_MULT (DFmode,
operand1,
operand2),
-   const0_rtx)),
+   CONST_DOUBLE_ATOF ("0", VOIDmode))),
gen_rtx_SET (operand0,
gen_rtx_MULT (DFmode,
copy_rtx (operand1),
@@ -1942,7 +1942,7 @@ gen_divdf3_cc (rtx operand0 ATTRIBUTE_UN
gen_rtx_DIV (DFmode,
operand1,
operand2),
-   const0_rtx)),
+   CONST_DOUBLE_ATOF ("0", VOIDmode))),
gen_rtx_SET (operand0,
gen_rtx_DIV (DFmode,
copy_rtx (operand1),

gcc/
* genemit.c (gen_exp) : Handle `const_double_zero' 
rtx.
---
Hi,

 I have verified this with a bootstrap of a `powerpc64le-linux-gnu' native 
compiler, and that it builds a `pdp11-aout' cross-compiler up to the point 
of failing to find target headers.  I have no means to verify it further, 
the target configuration is too exotic to me, so I will appreciate help.

 NB this only triggers with insn-emit.c code produced from named RTL insns 
for the purpose of calling them directly, which does not apply for the VAX 
backend, as it does not give names to any insns using `const_double_zero'.  
Which is why I didn't spot this issue with all my VAX verification.

 Thanks to Martin for bringing my attention to this regression, and sorry 
to miss this in testing.

 OK to apply?

  Maciej
---
 gcc/genemit.c |8 
 1 file changed, 8 insertions(+)

gcc-genemit-const-double-zero.diff
Index: gcc/gcc/genemit.c
===
--- gcc.orig/gcc/genemit.c
+++ gcc/gcc/genemit.c
@@ -195,6 +195,14 @@ gen_exp (rtx x, enum rtx_code subroutine
   return;
 
 case CONST_DOUBLE:
+  /* Handle `const_double_zero' rtx.  */
+  if (CONST_DOUBLE_REAL_VALUE (x)->cl == rvc_zero)
+   {
+ printf ("CONST_DOUBLE_ATOF (\"0\", %smode)",
+ GET_MODE_NAME (GET_MODE (x)));
+ return;
+   }
+  /* Fall through.  */
 case CONST_FIXED:
 case CONST_WIDE_INT:
   /* These shouldn't be written in MD files.  Instead, the appropriate


Re: AVR maintainership (was: [patch,avr, 1/3] Support 64-bit (long) double: The gcc part.)

2020-12-15 Thread Jeff Law via Gcc-patches



On 12/15/20 7:30 AM, Segher Boessenkool wrote:
> On Tue, Dec 15, 2020 at 08:40:08AM +0100, Gerald Pfeifer wrote:
>> On Mon, 6 Jan 2020, Jeff Law wrote:
 p.s. You know anything about Denis Chertykov? He used to reply to avr 
 patches within hours, but my latest patches (after a long period where I 
 didn't propose any patches) where all approved by you; not a single mail 
 from Denis.  So I am concerned if he's well.  Maybe he left you or some 
 other global maintainer a note? He's still listed as maintainer though.
>>> I haven't heard much from him for a while.  I'm trying to leave enough
>>> space that he can step in on this stuff, but I'm also hesitant to let
>>> patches linger for too long.
>> I don't think I have seen mails from Denis since then (more than 
>> eleven months).
>>
>> Do we need to get a new maintainer for AVR in place? Any nominations?
> I nominate Georg-Johann Lay as the obvious choice, since he has authored
> 333 of the 511 patches that went into config/avr/ the last ten years.
I'd support that if Georg-Johann wants it.

jeff



[PATCH] varasm: Fix up __patchable_function_entries handling

2020-12-15 Thread Jakub Jelinek via Gcc-patches
On Wed, Dec 02, 2020 at 05:15:21AM -0800, H.J. Lu via Gcc-patches wrote:
> gcc/
> 
>   PR middle-end/93195
>   PR middle-end/93197
>   * configure.ac (HAVE_GAS_SECTION_LINK_ORDER): New.  Define 1 if
>   the assembler supports the section flag 'o' for specifying
>   section with link-order.
>   * output.h (SECTION_LINK_ORDER): New.  Defined to 0x800.
>   (SECTION_MACH_DEP): Changed from 0x800 to 0x1000.
>   * targhooks.c (default_print_patchable_function_entry): Pass
>   SECTION_LINK_ORDER to switch_to_section if the section flag 'o'
>   works.  Pass current_function_decl to switch_to_section.
>   * varasm.c (default_elf_asm_named_section): Use 'o' flag for
>   SECTION_LINK_ORDER if assembler supports it.
>   * config.in: Regenerated.
>   * configure: Likewise.

Dunno if it is an assembler bug or gcc bug, but this SECTION_LINK_ORDER
stuff doesn't seem to work properly.

If I compile:
static inline __attribute__((__gnu_inline__)) __attribute__((__unused__)) 
__attribute__((patchable_function_entry(0, 0))) int foo (int x)
{
  return x + 1;
}

static inline __attribute__((__gnu_inline__)) __attribute__((__unused__)) 
__attribute__((patchable_function_entry(0, 0))) int bar (int x)
{
  return x + 2;
}

int
baz (int x)
{
  return foo (x) + 1;
}

int
qux (int x)
{
  return bar (x) + 2;
}
(distilled from aarch64 Linux kernel) with
-O2 -fpatchable-function-entry=2 on aarch64 compiler configured against
latest binutils, I get:
...
.section__patchable_function_entries,"awo",@progbits,baz
...
.section__patchable_function_entries
...
in the assembly, but when it is assembled, one gets:
  [ 4] __patchable_function_entries PROGBITS 60 
08 00 WAL  1   0  8
  [ 5] .rela__patchable_function_entries RELA 
000280 18 18   I 12   4  8
  [ 6] __patchable_function_entries PROGBITS 68 
08 00  0   0  8
  [ 7] .rela__patchable_function_entries RELA 
000298 18 18   I 12   6  8
i.e. one writable allocated section with SHF_LINK_ORDER and another
non-allocated non-writable without link order.  In the kernel case there is
always one entry in the WAL section and then dozens or more in the
non-allocated one.
The kernel then fails to link:
WARNING: modpost: vmlinux.o (__patchable_function_entries): unexpected 
non-allocatable section.
Did you forget to use "ax"/"aw" in a .S file?
Note that for example  contains
section definitions for use in .S files.
ld: .init.data has both ordered [`__patchable_function_entries' in init/main.o] 
and unordered [`.init.data' in ./drivers/firmware/efi/libstub/vsprintf.stub.o] 
sections
ld: final link failed: bad value
make: *** [Makefile:1175: vmlinux] Error 1

If it is correct that the assembler requires full section flags for the
SECTION_LINK_ORDER .section directives in every case (like it does for
comdat or for retain), then we should do something like the following
untested change, but if it is gas bug, it should be fixed there.

2020-12-15  Jakub Jelinek  

* varasm.c (default_elf_asm_named_section): Always force
section flags even for sections with SECTION_LINK_ORDER flag.

--- gcc/varasm.c.jj 2020-12-13 17:07:53.910477664 +0100
+++ gcc/varasm.c2020-12-15 21:33:35.169314414 +0100
@@ -6781,10 +6781,10 @@ default_elf_asm_named_section (const cha
 
   /* If we have already declared this section, we can use an
  abbreviated form to switch back to it -- unless this section is
- part of a COMDAT groups or with SHF_GNU_RETAIN, in which case GAS
- requires the full declaration every time.  */
+ part of a COMDAT groups or with SHF_GNU_RETAIN or with SHF_LINK_ORDER,
+ in which case GAS requires the full declaration every time.  */
   if (!(HAVE_COMDAT_GROUP && (flags & SECTION_LINKONCE))
-  && !(flags & SECTION_RETAIN)
+  && !(flags & (SECTION_RETAIN | SECTION_LINK_ORDER))
   && (flags & SECTION_DECLARED))
 {
   fprintf (asm_out_file, "\t.section\t%s\n", name);


Jakub



Go patch committed: Better error for unexpected digit

2020-12-15 Thread Ian Lance Taylor via Gcc-patches
This patch to the Go frontend generates a better error for an
unexpected digit.  A digit character is not invalid in general, but
it's not permitted at the start of an identifier.  Report a better
error message.  The test case is issue11359.go in the source repo.
Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.  Committed
to mainline.

Ian
68556694c83efd397b04dffa9248c9acc537ab97
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index 681debb0392..1bada25300d 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-3e8f49a2137a87fdaba51c3002ddbe41ab18ed46
+8b913a1865e36d4bd105f29aa0b12264a4e03515
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
diff --git a/gcc/go/gofrontend/lex.cc b/gcc/go/gofrontend/lex.cc
index 156a90c7baf..e71b8cddf65 100644
--- a/gcc/go/gofrontend/lex.cc
+++ b/gcc/go/gofrontend/lex.cc
@@ -743,6 +743,13 @@ Lex::next_token()
if (Lex::is_unicode_letter(ci))
  return this->gather_identifier();
 
+   if (!issued_error && Lex::is_unicode_digit(ci))
+ {
+   go_error_at(this->location(),
+   "identifier cannot begin with digit");
+   issued_error = true;
+ }
+
if (!issued_error)
  go_error_at(this->location(),
  "invalid character 0x%x in input file",


Go patch committed: Discard global sinks with static initializers

2020-12-15 Thread Ian Lance Taylor via Gcc-patches
This patch to the Go frontend discards global sink variables with
static initializers.  This is specifically for the test issue23781.go,
which builds a large static array.  The code does compile and work
without this change, but it takes a long time and generates a large
object file.  Discarding the unnecessary static initializer makes this
test much faster.  Bootstrapped and ran Go testsuite on
x86_64-pc-linux-gnu.  Committed to mainline.

Ian
8a5b8fc719f5c5bd6bd732d95646193238343f39
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index 1bada25300d..a596b241a4e 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-8b913a1865e36d4bd105f29aa0b12264a4e03515
+85c390ec75c6c3f3fbfe08f6dac58585588c6211
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
diff --git a/gcc/go/gofrontend/gogo.cc b/gcc/go/gofrontend/gogo.cc
index e31a038dbd3..fbf8935bb06 100644
--- a/gcc/go/gofrontend/gogo.cc
+++ b/gcc/go/gofrontend/gogo.cc
@@ -1558,6 +1558,17 @@ Gogo::write_globals()
  || (no->is_const() && no->const_value()->is_sink()))
 continue;
 
+  // Skip global sink variables with static initializers.  With
+  // non-static initializers we have to evaluate for side effects,
+  // and we wind up initializing a dummy variable.  That is not
+  // ideal but it works and it's a rare case.
+  if (no->is_variable()
+ && no->var_value()->is_global_sink()
+ && !no->var_value()->has_pre_init()
+ && (no->var_value()->init() == NULL
+ || no->var_value()->init()->is_static_initializer()))
+   continue;
+
   // There is nothing useful we can output for constants which
   // have ideal or non-integral type.
   if (no->is_const())
@@ -7447,7 +7458,7 @@ Variable::Variable(Type* type, Expression* init, bool 
is_global,
   : type_(type), init_(init), preinit_(NULL), location_(location),
 backend_(NULL), is_global_(is_global), is_parameter_(is_parameter),
 is_closure_(false), is_receiver_(is_receiver),
-is_varargs_parameter_(false), is_used_(false),
+is_varargs_parameter_(false), is_global_sink_(false), is_used_(false),
 is_address_taken_(false), is_non_escaping_address_taken_(false),
 seen_(false), init_is_lowered_(false), init_is_flattened_(false),
 type_from_init_tuple_(false), type_from_range_index_(false),
diff --git a/gcc/go/gofrontend/gogo.h b/gcc/go/gofrontend/gogo.h
index 49d7bd9b98a..bdb3166006d 100644
--- a/gcc/go/gofrontend/gogo.h
+++ b/gcc/go/gofrontend/gogo.h
@@ -2113,6 +2113,20 @@ class Variable
   is_varargs_parameter() const
   { return this->is_varargs_parameter_; }
 
+  // Return whether this is a global sink variable, created only to
+  // run an initializer.
+  bool
+  is_global_sink() const
+  { return this->is_global_sink_; }
+
+  // Record that this is a global sink variable.
+  void
+  set_is_global_sink()
+  {
+go_assert(this->is_global_);
+this->is_global_sink_ = true;
+  }
+
   // Whether this variable's address is taken.
   bool
   is_address_taken() const
@@ -2340,6 +2354,9 @@ class Variable
   bool is_receiver_ : 1;
   // Whether this is the varargs parameter of a function.
   bool is_varargs_parameter_ : 1;
+  // Whether this is a global sink variable created to run an
+  // initializer.
+  bool is_global_sink_ : 1;
   // Whether this variable is ever referenced.
   bool is_used_ : 1;
   // Whether something takes the address of this variable.  For a
diff --git a/gcc/go/gofrontend/parse.cc b/gcc/go/gofrontend/parse.cc
index a4740cfad0e..3b2e5a7aa86 100644
--- a/gcc/go/gofrontend/parse.cc
+++ b/gcc/go/gofrontend/parse.cc
@@ -2075,6 +2075,7 @@ Parse::create_dummy_global(Type* type, Expression* init,
   if (type == NULL && init == NULL)
 type = Type::lookup_bool_type();
   Variable* var = new Variable(type, init, true, false, false, location);
+  var->set_is_global_sink();
   static int count;
   char buf[30];
   snprintf(buf, sizeof buf, "_.%d", count);


[PATCH] PR fortran/98284 - ICE in get_array_index

2020-12-15 Thread Harald Anlauf via Gcc-patches
Dear all,

ICE-on-invalid: testcase by Arseny, draft patch by Steve,
slightly polished and regtested by me on x86_64-pc-linux-gnu.

OK for master?

Thanks,
Harald


PR fortran/98284 - ICE in get_array_index

Reject DATA elements with the ALLOCATABLE attribute also when they are
components of a derived type.

gcc/fortran/ChangeLog:

PR fortran/98284
* resolve.c (check_data_variable): Reject DATA elements with the
ALLOCATABLE attribute.

gcc/testsuite/ChangeLog:

PR fortran/98284
* gfortran.dg/pr98284.f90: New test.

diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 327dffbebf2..05a5e43c90b 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -16169,6 +16169,13 @@ check_data_variable (gfc_data_variable *var, locus *where)
 	  return false;
 	}
 	}
+
+  if (ref->type == REF_COMPONENT && ref->u.c.component->attr.allocatable)
+	{
+	  gfc_error ("DATA element %qs at %L cannot have the ALLOCATABLE "
+		 "attribute", ref->u.c.component->name, &e->where);
+	  return false;
+	}
 }

   if (e->rank == 0 || has_pointer)
diff --git a/gcc/testsuite/gfortran.dg/pr98284.f90 b/gcc/testsuite/gfortran.dg/pr98284.f90
new file mode 100644
index 000..aa4b95c667c
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr98284.f90
@@ -0,0 +1,12 @@
+! { dg-do compile }
+! PR fortran/98284 - ICE in get_array_index
+
+program p
+  implicit none
+  type t
+ integer, allocatable :: h(:)
+  end type t
+  type(t) :: u
+  integer :: i
+  data (u% h(i),i=1,8) /8*1/ ! { dg-error "cannot have the ALLOCATABLE attribute" }
+end


Go patch committed: Avoid knock-on errors from invalid interfaces

2020-12-15 Thread Ian Lance Taylor via Gcc-patches
This patch to the Go frontend avoids knock-on errors from invalid
interfaces.  The test case for this is issue11614.go in the source
repo.  Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.
Committed to mainline.

Ian
788d204885c187d5604e3960d7c78e1523f04861
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index a596b241a4e..a28294c594f 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-85c390ec75c6c3f3fbfe08f6dac58585588c6211
+10d3dd939d4cea7f40b76f8ff82c16aa12c01188
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc
index 79ed44510a9..adc1ebb4643 100644
--- a/gcc/go/gofrontend/expressions.cc
+++ b/gcc/go/gofrontend/expressions.cc
@@ -174,7 +174,13 @@ Expression::export_name(Export_function_body* efb, const 
Named_object* no)
 void
 Expression::unused_value_error()
 {
-  this->report_error(_("value computed is not used"));
+  if (this->type()->is_error())
+{
+  go_assert(saw_errors());
+  this->set_is_error();
+}
+  else
+this->report_error(_("value computed is not used"));
 }
 
 // Note that this expression is an error.  This is called by children
@@ -888,8 +894,7 @@ Type_expression : public Expression
   { }
 
   void
-  do_check_types(Gogo*)
-  { this->report_error(_("invalid use of type")); }
+  do_check_types(Gogo*);
 
   Expression*
   do_copy()
@@ -906,6 +911,18 @@ Type_expression : public Expression
   Type* type_;
 };
 
+void
+Type_expression::do_check_types(Gogo*)
+{
+  if (this->type_->is_error())
+{
+  go_assert(saw_errors());
+  this->set_is_error();
+}
+  else
+this->report_error(_("invalid use of type"));
+}
+
 void
 Type_expression::do_dump_expression(Ast_dump_context* ast_dump_context) const
 {
diff --git a/gcc/go/gofrontend/types.cc b/gcc/go/gofrontend/types.cc
index f9097d5e130..ecb93b099db 100644
--- a/gcc/go/gofrontend/types.cc
+++ b/gcc/go/gofrontend/types.cc
@@ -8984,8 +8984,11 @@ Interface_type::finalize_methods()
   else if (this->find_method(p->name()) == NULL)
this->all_methods_->push_back(*p);
   else
-   go_error_at(p->location(), "duplicate method %qs",
-Gogo::message_name(p->name()).c_str());
+   {
+ go_error_at(p->location(), "duplicate method %qs",
+ Gogo::message_name(p->name()).c_str());
+ this->set_is_error();
+   }
 }
 
   std::vector seen;
@@ -9001,7 +9004,10 @@ Interface_type::finalize_methods()
   if (it == NULL)
{
  if (!t->is_error())
-   go_error_at(tl, "interface contains embedded non-interface");
+   {
+ go_error_at(tl, "interface contains embedded non-interface");
+ this->set_is_error();
+   }
  continue;
}
   if (it == this)
@@ -9009,6 +9015,7 @@ Interface_type::finalize_methods()
  if (!issued_recursive_error)
{
  go_error_at(tl, "invalid recursive interface");
+ this->set_is_error();
  issued_recursive_error = true;
}
  continue;
@@ -9027,6 +9034,7 @@ Interface_type::finalize_methods()
  if (*q == nt)
{
  go_error_at(tl, "inherited interface loop");
+ this->set_is_error();
  break;
}
}
@@ -9049,8 +9057,11 @@ Interface_type::finalize_methods()
   q->type(), tl));
  else if (!Type::are_identical(q->type(), oldm->type(),
Type::COMPARE_TAGS, NULL))
-   go_error_at(tl, "duplicate method %qs",
-   Gogo::message_name(q->name()).c_str());
+   {
+ go_error_at(tl, "duplicate method %qs",
+ Gogo::message_name(q->name()).c_str());
+ this->set_is_error();
+   }
}
}
 


Go patch committed: Correct grammar in error message

2020-12-15 Thread Ian Lance Taylor via Gcc-patches
This patch to the Go frontend corrects the grammar in an error
message.  Noticed while looking at https://golang.org/issue/43200.
Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.  Committed
to mainline.

Ian
5aba02667113fbe43d74c37724f29868f098dd1c
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index a28294c594f..6567db167a2 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-10d3dd939d4cea7f40b76f8ff82c16aa12c01188
+526037336231593939a517b7c0b2892d413adb40
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
diff --git a/gcc/go/gofrontend/statements.cc b/gcc/go/gofrontend/statements.cc
index af82f36bc43..398b8fd82f2 100644
--- a/gcc/go/gofrontend/statements.cc
+++ b/gcc/go/gofrontend/statements.cc
@@ -4538,7 +4538,7 @@ Switch_statement::do_lower(Gogo*, Named_object*, Block* 
enclosing,
  Type::make_nil_type(), NULL))
 {
   go_error_at(this->val_->location(),
- "cannot switch on value whose type that may not be compared");
+ "cannot switch on value whose type may not be compared");
   return Statement::make_error_statement(loc);
 }
 


Re: Go patch committed: Avoid knock-on errors from invalid interfaces

2020-12-15 Thread Ian Lance Taylor via Gcc-patches
On Tue, Dec 15, 2020 at 1:01 PM Ian Lance Taylor  wrote:
>
> This patch to the Go frontend avoids knock-on errors from invalid
> interfaces.  The test case for this is issue11614.go in the source
> repo.  Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.
> Committed to mainline.

Sorry, I forgot that this change requires updating a couple of tests.
This patch committed to mainline.

Ian
34c7d3d3b216d674192678443bcfd379ec575d9f
diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug195.go 
b/gcc/testsuite/go.test/test/fixedbugs/bug195.go
index aef7bd2d894..94f61fff7f1 100644
--- a/gcc/testsuite/go.test/test/fixedbugs/bug195.go
+++ b/gcc/testsuite/go.test/test/fixedbugs/bug195.go
@@ -19,7 +19,7 @@ type I4 interface { // GC_ERROR "invalid recursive type 
I4\n\tLINE: I4 refers to
 }
 
 type I5 interface { // GC_ERROR "invalid recursive type I5\n\tLINE: I5 refers 
to\n\tLINE+4: I6 refers to\n\tLINE: I5$"
-   I6 // GCCGO_ERROR "interface"
+   I6
 }
 
 type I6 interface {
diff --git a/gcc/testsuite/go.test/test/fixedbugs/bug251.go 
b/gcc/testsuite/go.test/test/fixedbugs/bug251.go
index 706bb8d6901..977aa49e6a0 100644
--- a/gcc/testsuite/go.test/test/fixedbugs/bug251.go
+++ b/gcc/testsuite/go.test/test/fixedbugs/bug251.go
@@ -8,7 +8,7 @@ package main
 
 type I1 interface { // GC_ERROR "invalid recursive type"
m() I2
-   I2 // GCCGO_ERROR "loop|interface"
+   I2
 }
 
 type I2 interface {


[committed] d: Fix ICE in gimplify_expr, at gimplify.c (PR98277)

2020-12-15 Thread Iain Buclaw via Gcc-patches
Hi,

This patch fixes an ICE during gimplify_expr for code generated by the D
front-end.  The DMD front-end shouldn't, but can sometimes leak manifest
constants in the AST passed to the code generator.  To prevent this
being an issue, the setting of DECL_INITIAL has been moved to the point
where the CONST_DECL is used, rather than in the declaration handler.

Bootstrapped and regression tested on x86_64-linux-gnu/-m32/-mx32.
Committed to mainline, and backported to the GCC-10 and GCC-9.

Regards
Iain

---
gcc/d/ChangeLog:

PR d/98277
* decl.cc (DeclVisitor::visit (VarDeclaration *)): Move setting of
DECL_INITIAL for manifest constants to ...
(get_symbol_decl): ... here.

gcc/testsuite/ChangeLog:

PR d/98277
* gdc.dg/pr98277.d: New test.
---
 gcc/d/decl.cc  | 43 +-
 gcc/testsuite/gdc.dg/pr98277.d | 13 ++
 2 files changed, 35 insertions(+), 21 deletions(-)
 create mode 100644 gcc/testsuite/gdc.dg/pr98277.d

diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc
index 218f35838fd..a3db4ae6d89 100644
--- a/gcc/d/decl.cc
+++ b/gcc/d/decl.cc
@@ -653,31 +653,13 @@ public:
return;
   }
 
-/* Do not store variables we cannot take the address of,
-   but keep the values for purposes of debugging.  */
 if (!d->canTakeAddressOf ())
   {
-   /* Don't know if there is a good way to handle instantiations.  */
-   if (d->isInstantiated ())
- return;
-
-   /* Cannot make an expression out of a void initializer.  */
-   if (!d->_init || d->_init->isVoidInitializer ())
- return;
-
-   tree decl = get_symbol_decl (d);
-   Expression *ie = initializerToExpression (d->_init);
-
-   /* CONST_DECL was initially intended for enumerals and may be used for
-  scalars in general, but not for aggregates.  Here a non-constant
-  value is generated anyway so as the CONST_DECL only serves as a
-  placeholder for the value, however the DECL itself should never be
-  referenced in any generated code, or passed to the back-end.  */
+   /* Do not store variables we cannot take the address of,
+  but keep the values for purposes of debugging.  */
if (!d->type->isscalar ())
- DECL_INITIAL (decl) = build_expr (ie, false);
-   else
  {
-   DECL_INITIAL (decl) = build_expr (ie, true);
+   tree decl = get_symbol_decl (d);
d_pushdecl (decl);
rest_of_decl_compilation (decl, 1, 0);
  }
@@ -1106,6 +1088,25 @@ get_symbol_decl (Declaration *decl)
 
   if (vd->storage_class & STCextern)
DECL_EXTERNAL (decl->csym) = 1;
+
+  /* CONST_DECL was initially intended for enumerals and may be used for
+scalars in general, but not for aggregates.  Here a non-constant
+value is generated anyway so as the CONST_DECL only serves as a
+placeholder for the value, however the DECL itself should never be
+referenced in any generated code, or passed to the back-end.  */
+  if (vd->storage_class & STCmanifest)
+   {
+ /* Cannot make an expression out of a void initializer.  */
+ if (vd->_init && !vd->_init->isVoidInitializer ())
+   {
+ Expression *ie = initializerToExpression (vd->_init);
+
+ if (!vd->type->isscalar ())
+   DECL_INITIAL (decl->csym) = build_expr (ie, false);
+ else
+   DECL_INITIAL (decl->csym) = build_expr (ie, true);
+   }
+   }
 }
 
   /* Set the declaration mangled identifier if static.  */
diff --git a/gcc/testsuite/gdc.dg/pr98277.d b/gcc/testsuite/gdc.dg/pr98277.d
new file mode 100644
index 000..d3b859fcbda
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/pr98277.d
@@ -0,0 +1,13 @@
+// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98277
+// { dg-do compile }
+
+enum Side
+{
+left,
+right
+}
+
+ref int getSide(Side side, ref int left, ref int right)
+{
+return side == Side.left ? left : right;
+}
-- 
2.27.0



libcody: Work with older gccs

2020-12-15 Thread Nathan Sidwell
Older GCCs don't have all the exciting options we have now.  let's just 
turn them off.


Makefile.in: Disable some flags

--
Nathan Sidwell
>From 98b960b40ba4934bdbd8d87d9432475e148d1022 Mon Sep 17 00:00:00 2001
From: Nathan Sidwell 
Date: Tue, 15 Dec 2020 13:34:26 -0800
Subject: [PATCH] libcody:  Work with older gccs

Older GCCs don't have all the exciting options we have now.  let's just
turn them off.

	Makefile.in: Disable some flags
---
 libcody/Makefile.in | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libcody/Makefile.in b/libcody/Makefile.in
index 7b8a6418027..4b457adc3a4 100644
--- a/libcody/Makefile.in
+++ b/libcody/Makefile.in
@@ -66,7 +66,10 @@ ifeq ($(filter -fdebug-prefix-map=%,$(CXXOPTS)),)
 CXXOPTS += -fdebug-prefix-map=${srcdir}/=
 endif
 # Warning options
-CXXOPTS += -W -Wall -Woverloaded-virtual -Wshadow
+CXXOPTS += -W -Wall
+ifeq (no,)
+# just turn off for now
+CXXOPTS += -Woverloaded-virtual -Wshadow
 CXXOPTS += -Wno-invalid-offsetof -Wno-unused-variable
 CXXOPTS += -Wno-missing-field-initializers
 # Diagnostic options, look at controlling terminal so that piping
@@ -76,6 +79,7 @@ ifneq (,$(MLEN))
 CXXOPTS += -fmessage-length=$(MLEN)
 endif
 CXXOPTS += -fdiagnostics-color=always -fno-diagnostics-show-option
+endif
 else
 ifeq ($(notdir $(firstword $(CXX))),clang++)
 CXXOPTS += -fno-stack-protector -fno-threadsafe-statics
-- 
2.27.0



gcc_update update

2020-12-15 Thread Nathan Sidwell

I missed adding these two configure files.

gcc_update: Add c++tools & libcody


thanks David for pointing at the fix.

nathan
--
Nathan Sidwell
>From c6d406f5039072938d308fe3a7fc4cd2a0bac952 Mon Sep 17 00:00:00 2001
From: Nathan Sidwell 
Date: Tue, 15 Dec 2020 13:42:23 -0800
Subject: [PATCH] gcc_update update

I missed adding these two configure files.

	gcc_update: Add c++tools & libcody
---
 contrib/gcc_update | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/contrib/gcc_update b/contrib/gcc_update
index 5e8af0e9a7c..28e2f3797a2 100755
--- a/contrib/gcc_update
+++ b/contrib/gcc_update
@@ -76,6 +76,7 @@ intl/plural-config.h: intl/plural.y
 intl/configure: intl/configure.ac intl/aclocal.m4
 intl/config.h.in: intl/configure.ac intl/aclocal.m4
 # Now, proceed to gcc automatically generated files
+c++tools/configure: c++tools/configure.ac
 gcc/configure: gcc/configure.ac
 gcc/cstamp-h.in: gcc/configure.ac
 gcc/config.in: gcc/cstamp-h.in
@@ -126,6 +127,7 @@ libquadmath/configure: libquadmath/configure.ac libquadmath/aclocal.m4
 libquadmath/aclocal.m4: libquadmath/configure.ac libquadmath/acinclude.m4
 libquadmath/Makefile.in: libquadmath/Makefile.am libquadmath/configure.ac libgfortran/aclocal.m4
 libgfortran/configure: libgfortran/configure.ac libgfortran/aclocal.m4
+libcody/configure: libcody/configure.ac libcody/config.m4
 libcpp/aclocal.m4: libcpp/configure.ac
 libcpp/Makefile.in: libcpp/configure.ac libcpp/aclocal.m4
 libcpp/configure: libcpp/configure.ac libcpp/aclocal.m4
-- 
2.27.0



Re: [PATCH] libstdc++: Avoid zero-probability events in discrete_distribution [PR61369]

2020-12-15 Thread Lewis Hyatt via Gcc-patches
On Thu, Nov 19, 2020 at 07:16:52PM +, Jonathan Wakely wrote:
> On 19/11/20 12:57 -0500, Lewis Hyatt via Libstdc++ wrote:
> > Hello-
> > 
> > PR61369 (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61369) points out
> > that std::discrete_distribution can return an event even if it has 0
> > probability, and proposes a simple fix. It seems that this fix was never
> > applied, because there was an expectation of redoing this code anyway to
> > use a more efficient algorithm (PR57925). Given that this new algorithm
> > has not been implemented so far, would it make sense to apply the simple
> > fix to address this issue? The attached patch does this.
> > 
> > One question about the patch, a slight annoyance is that only
> > std::lower_bound() is currently available in random.tcc, as this file
> > includes only bits/stl_algobase.h and not bits/stl_algo.h (via including
> > ). Is there a preference between simply including stl_algo.h, or
> > moving upper_bound to stl_algobase.h, where lower_bound is? I noticed
> > that in C++20 mode,  includes stl_algo.h already, so I figured
> > it would be fine to just include it in random.tcc unconditionally.
> 
> But the increase in header sizes in C++20 is a regression:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92546
> 
> Anyway, I'll review this patch tomorrow, thanks for sending it.
> 
> > bootstrap + testing were done on x86-64 GNU/Linux, all tests the same
> > before + after plus 2 new passes from the new test. Thanks for taking a
> > look!
> > 
> > -Lewis
>

Sorry for the noise on this... I realized the patch I sent before missed
one line. I guess there is an internal __generate() function that
presumably needs the same change as operator()(). This version modifies
that one as well and adds a test case. Would you mind please reviewing this
one instead? Thanks!

-Lewis
From: Lewis Hyatt 
Date: Tue, 1 Dec 2020 11:17:23 -0500
Subject: [PATCH] libstdc++: Avoid zero-probability events in 
discrete_distribution [PR61369]

Fixes PR61369, as recommended by the PR's submitter, by replacing
lower_bound() with upper_bound(). Currently, if there is an initial subset of
events with probability 0, the first of them will be returned with non-zero
probability (if the underlying RNG returns exactly 0). Switching to
upper_bound() ensures that this will not happen.

libstdc++-v3/ChangeLog:

PR libstdc++/61369
* include/bits/random.tcc: Include bits/stl_algo.h.
(discrete_distribution::operator()): Use upper_bound rather than
lower_bound.
(discrete_distribution::__generate_impl): Likewise.
* testsuite/26_numerics/random/pr60037-neg.cc: Adapt to new line
numbering in random.tcc.
* testsuite/26_numerics/random/discrete_distribution/pr61369.cc: New
test.

diff --git a/libstdc++-v3/include/bits/random.tcc 
b/libstdc++-v3/include/bits/random.tcc
index 3205442f2f6..a7b33b0739e 100644
--- a/libstdc++-v3/include/bits/random.tcc
+++ b/libstdc++-v3/include/bits/random.tcc
@@ -31,6 +31,7 @@
 #define _RANDOM_TCC 1
 
 #include  // std::accumulate and std::partial_sum
+#include  // std::upper_bound
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
@@ -2706,7 +2707,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
  __aurng(__urng);
 
const double __p = __aurng();
-   auto __pos = std::lower_bound(__param._M_cp.begin(),
+   auto __pos = std::upper_bound(__param._M_cp.begin(),
  __param._M_cp.end(), __p);
 
return __pos - __param._M_cp.begin();
@@ -2736,7 +2737,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
while (__f != __t)
  {
const double __p = __aurng();
-   auto __pos = std::lower_bound(__param._M_cp.begin(),
+   auto __pos = std::upper_bound(__param._M_cp.begin(),
  __param._M_cp.end(), __p);
 
*__f++ = __pos - __param._M_cp.begin();
diff --git 
a/libstdc++-v3/testsuite/26_numerics/random/discrete_distribution/pr61369.cc 
b/libstdc++-v3/testsuite/26_numerics/random/discrete_distribution/pr61369.cc
new file mode 100644
index 000..03fd3da
--- /dev/null
+++ b/libstdc++-v3/testsuite/26_numerics/random/discrete_distribution/pr61369.cc
@@ -0,0 +1,60 @@
+// 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.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not se

Re: Optimize combination of comparisons to dec+compare

2020-12-15 Thread Eugene Rozenfeld via Gcc-patches
Richard,

> Do we already handle x < y || x <= CST to x <= y - CST?

That is an invalid transformation: e.g., consider x=3, y=4, CST=2.
Can you please clarify?

Thanks,

Eugene

-Original Message-
From: Richard Biener  
Sent: Thursday, December 10, 2020 12:21 AM
To: Eugene Rozenfeld 
Cc: gcc-patches@gcc.gnu.org
Subject: Re: Optimize combination of comparisons to dec+compare

On Thu, Dec 10, 2020 at 1:52 AM Eugene Rozenfeld via Gcc-patches 
 wrote:
>
> This patch adds a pattern for optimizing x < y || x == XXX_MIN to x <= 
> y-1 if y is an integer with TYPE_OVERFLOW_WRAPS.

Do we already handle x < y || x <= CST to x <= y - CST?
That is, the XXX_MIN case is just a special-case of generic anti-range testing? 
 For anti-range testing with signed types we pun to unsigned when possible.

> This fixes pr96674.
>
> Tested on x86_64-pc-linux-gnu.
>
> For this function
>
> bool f(unsigned a, unsigned b)
> {
> return (b == 0) | (a < b);
> }
>
> the code without the patch is
>
> test   esi,esi
> sete   al
> cmpesi,edi
> seta   dl
> or eax,edx
> ret
>
> the code with the patch is
>
> subesi,0x1
> cmpesi,edi
> setae  al
> ret
>
> Eugene
>
> gcc/
> PR tree-optimization/96674
> * match.pd: New pattern x < y || x == XXX_MIN --> x <= y - 1
>
> gcc/testsuite
> * gcc.dg/pr96674.c: New test.
>


[pushed] cody: Remove unused variable.

2020-12-15 Thread Marek Polacek via Gcc-patches
Tested x86_64-pc-linux-gnu, applying to trunk.

libcody/ChangeLog:

* buffer.cc (MessageBuffer::Lex): Remove unused variable.
---
 libcody/buffer.cc | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libcody/buffer.cc b/libcody/buffer.cc
index 52df3176c9a..3256c37399b 100644
--- a/libcody/buffer.cc
+++ b/libcody/buffer.cc
@@ -224,7 +224,6 @@ int MessageBuffer::Lex (std::vector &result)
 {
   result.clear ();
 
-  int err = ENOENT;
   if (IsAtEnd ())
 return ENOENT;
 

base-commit: 4f0c800ba6091e77228c7ef73eb5efebc45559d7
-- 
2.29.2



Re: C++ 20 modules

2020-12-15 Thread Nathan Sidwell
as expected there are a bunch of configurey type errors.  I am aware of 
the following:


windows build (pr 98300), insufficient #ifing.  A patch is being tested

solaris 11, sys/socket.h, bcopy and poisoning.  Asked jwakely to try a 
patch, he seems to have a build set up.


AIX install.  Testing a patch

gcc_update not touching files: fixed

libcody uses too-new options: fixed, hopefully

libcody unused variable: fixed by Marek, thanks!

nathan

--
Nathan Sidwell


Re: C++ 20 modules

2020-12-15 Thread Rainer Orth
Hi Nathan,

> as expected there are a bunch of configurey type errors.  I am aware of the
> following:
[...]
> solaris 11, sys/socket.h, bcopy and poisoning.  Asked jwakely to try a
> patch, he seems to have a build set up.

two more Solaris issues (will file proper PRs tomorrow):

* Solaris 11.4  uses bzero in an unused macro, also poisoned

* Solaris 11.3 requires -lsocket -lnsl for socket functions, cc1plus
  fails to link.  11.4 is fine, folded those into libc.

Rainer

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


Re: [Ada] Fix serial port baud rate setting on GNU/Linux

2020-12-15 Thread Rainer Orth
Hi Pierre-Marie,

> This fixes an issue when setting the baud rate. The baud rate is set
> using the cfsetospeed and cfsetispeed system calls. The code is using
> speed_t for clarity. The non-blocking status is only reset when Block is
> True. And serial blocking mode is now properly set according to termios
> manual.
>
> Add documentation about a way to debug and test a serial port on
> GNU/Linux without the need for a physical serial port.
>
> Tested on x86_64-pc-linux-gnu, committed on trunk

this patch broke Linux/x86_64 bootstrap (Fedora 29):

g-sercom.adb:307:53: "ICANON" is undefined
make[7]: *** [../gcc-interface/Makefile:299: g-sercom.o] Error 1

I suspect s-oscons-tmplt.c needs a change to define ICANON.

Rainer

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


Re: [PATCH] nvptx: Cache stacks block for OpenMP kernel launch

2020-12-15 Thread Julian Brown
On Tue, 15 Dec 2020 18:00:36 +0100
Jakub Jelinek  wrote:

> On Tue, Dec 15, 2020 at 04:49:38PM +, Julian Brown wrote:
> > > Do you need to hold the omp_stacks.lock across the entire
> > > offloading? Doesn't that serialize all offloading kernels to the
> > > same device? I mean, can't the lock be taken just shortly at the
> > > start to either acquire the cached stacks or allocate a fresh
> > > stack, and then at the end to put the stack back into the cache?  
> > 
> > I think you're suggesting something like what Alexander mentioned
> > -- a pool of cached stacks blocks in case the single, locked block
> > is contested. Obviously at present kernel launches are serialised
> > on the target anyway, so it's a question of whether having the
> > device wait for the host to unlock the stacks block (i.e. a context
> > switch, FSVO context switch), or allocating a new stacks block, is
> > quicker. I think the numbers posted in the parent email show that
> > memory allocation is so slow that just waiting for the lock wins.
> > I'm wary of adding unnecessary complication, especially if it'll
> > only be exercised in already hard-to-debug cases (i.e. lots of
> > threads)!  
> 
> I'm not suggesting to have multiple stacks, on the contrary.  I've
> suggested to do the caching only if at most one host thread is
> offloading to the device.
> 
> If one uses
> #pragma omp parallel num_threads(3)
> {
>   #pragma omp target
>   ...
> }
> then I don't see what would previously prevent the concurrent
> offloading, yes, we take the device lock during gomp_map_vars and
> again during gomp_unmap_vars, but don't hold it across the offloading
> in between.

I still don't think I quite understand what you're getting at.

We only implement synchronous launches for OpenMP on NVPTX at present,
and those all use the default CUDA runtime driver stream. Only one
kernel executes on the hardware at once, even if launched from
different host threads. The serialisation isn't due to the device lock
being held, but by the queueing semantics of the underlying API.

> > Does target-side memory allocation call back into the plugin's
> > GOMP_OFFLOAD_alloc? I'm not sure how that works. If not, target-side
> > memory allocation shouldn't be affected, I don't think?  
> 
> Again, I'm not suggesting that it should, but what I'm saying is that
> if target region ends but some other host tasks are doing target
> regions to the same device concurrently with that, or if there are
> async target in fly, we shouldn't try to cache the stack, but free it
> right away, because what the other target regions might need to
> malloc larger amounts of memory and fail because of the caching.

I'm assuming you're not suggesting fundamentally changing APIs or
anything to determine if we're launching target regions from multiple
threads at once, but instead that we try to detect the condition
dynamically in the plugin?

So, would kernel launch look something like this? (Excuse
pseudo-code-isms!)

void GOMP_OFFLOAD_run (...)
{
  bool used_cache;

  pthread_mutex_lock (&ptx_dev->omp_stacks.lock);
  if (&ptx_dev->omp_stacks.usage_count > 0)
  {
cuCtxSynchronize ();
nvptx_stacks_free (&ptx_dev);
...allocate fresh stack, no caching...
used_cache = false;
  }
  else
  {
/* Allocate or re-use cached stacks, and then... */
ptx_dev->omp_stacks.usage_count++;
used_cache = true;
  }
  pthread_mutex_unlock (&ptx_dev->omp_stacks.lock);

  /* Launch kernel */

  if (used_cache) {
cuStreamAddCallback (
  pthread_mutex_lock (&ptx_dev->omp_stacks.lock);
  ptx_dev->omp_stacks.usage_count--;
  pthread_mutex_unlock (&ptx_dev->omp_stacks.lock);
);
  } else {
pthread_mutex_lock (&ptx_dev->omp_stacks.lock);
/* Free uncached stack */
pthread_mutex_unlock (&ptx_dev->omp_stacks.lock);
  }
}

This seems like it'd be rather fragile to me, and would offer some
benefit perhaps only if a previous cached stacks block was much larger
than the one required for some given later launch. It wouldn't allow
any additional parallelism on the target I don't think.

Is that sort-of what you meant?

Oh, or perhaps something more like checking cuStreamQuery at the end of
the kernel launch to see if more work (...from other threads) is
outstanding on the same queue? I think that only usefully returns
CUDA_SUCCESS/CUDA_ERROR_NOT_READY, so I'm not sure if that'd help.

Thanks for clarification (& apologies for being slow!),

Julian


Re: [PATCH] genemit: Handle `const_double_zero' rtx

2020-12-15 Thread Jeff Law via Gcc-patches



On 12/15/20 1:38 PM, Maciej W. Rozycki wrote:
> Complement commit 20ab43b5cad6 ("RTL: Add `const_double_zero' syntactic 
> rtx") and remove a commit c60d0736dff7 ("PDP11: Use `const_double_zero' 
> to express double zero constant") build regression observed with the 
> `pdp11-aout' target:
>
> genemit: Internal error: abort in gen_exp, at genemit.c:202
> make[2]: *** [Makefile:2427: s-emit] Error 1
>
> where a:
>
> (const_double 0 [0] 0 [0] 0 [0] 0 [0])
>
> rtx coming from:
>
> (parallel [
> (set (reg:CC 16)
> (compare:CC (abs:DF (match_operand:DF 1 ("general_operand") 
> ("0,0")))
> (const_double 0 [0] 0 [0] 0 [0] 0 [0])))
> (set (match_operand:DF 0 ("nonimmediate_operand") ("=fR,Q"))
> (abs:DF (match_dup 1)))
> ])
>
> and ultimately `(const_double_zero)' referred in a named RTL insn cannot 
> be interpreted.  Handle the rtx then by supplying the constant 0 double 
> operand requested, resulting in the following update to insn-emit.c code 
> produced for the `pdp11-aout' target, relative to before the triggering 
> commit:
>
> @@ -1514,7 +1514,7 @@ gen_absdf2_cc (rtx operand0 ATTRIBUTE_UN
>   gen_rtx_COMPARE (CCmode,
>   gen_rtx_ABS (DFmode,
>   operand1),
> - const0_rtx)),
> + CONST_DOUBLE_ATOF ("0", VOIDmode))),
>   gen_rtx_SET (operand0,
>   gen_rtx_ABS (DFmode,
>   copy_rtx (operand1);
> @@ -1555,7 +1555,7 @@ gen_negdf2_cc (rtx operand0 ATTRIBUTE_UN
>   gen_rtx_COMPARE (CCmode,
>   gen_rtx_NEG (DFmode,
>   operand1),
> - const0_rtx)),
> + CONST_DOUBLE_ATOF ("0", VOIDmode))),
>   gen_rtx_SET (operand0,
>   gen_rtx_NEG (DFmode,
>   copy_rtx (operand1);
> @@ -1790,7 +1790,7 @@ gen_muldf3_cc (rtx operand0 ATTRIBUTE_UN
>   gen_rtx_MULT (DFmode,
>   operand1,
>   operand2),
> - const0_rtx)),
> + CONST_DOUBLE_ATOF ("0", VOIDmode))),
>   gen_rtx_SET (operand0,
>   gen_rtx_MULT (DFmode,
>   copy_rtx (operand1),
> @@ -1942,7 +1942,7 @@ gen_divdf3_cc (rtx operand0 ATTRIBUTE_UN
>   gen_rtx_DIV (DFmode,
>   operand1,
>   operand2),
> - const0_rtx)),
> + CONST_DOUBLE_ATOF ("0", VOIDmode))),
>   gen_rtx_SET (operand0,
>   gen_rtx_DIV (DFmode,
>   copy_rtx (operand1),
>
>   gcc/
>   * genemit.c (gen_exp) : Handle `const_double_zero' 
>   rtx.
> ---
> Hi,
>
>  I have verified this with a bootstrap of a `powerpc64le-linux-gnu' native 
> compiler, and that it builds a `pdp11-aout' cross-compiler up to the point 
> of failing to find target headers.  I have no means to verify it further, 
> the target configuration is too exotic to me, so I will appreciate help.
>
>  NB this only triggers with insn-emit.c code produced from named RTL insns 
> for the purpose of calling them directly, which does not apply for the VAX 
> backend, as it does not give names to any insns using `const_double_zero'.  
> Which is why I didn't spot this issue with all my VAX verification.
>
>  Thanks to Martin for bringing my attention to this regression, and sorry 
> to miss this in testing.
>
>  OK to apply?
Presumably you can't use CONST0_RTX (mode) here?  Assuming that's the
case, then this is fine.

jeff



Re: [PATCH] options: fix integer overflow

2020-12-15 Thread Jeff Law via Gcc-patches



On 12/15/20 3:30 AM, Martin Liška wrote:
> The patch reports an error when a non-HOST_WIDE_INT options is used
> and its value is bigger than INT_MAX.
>
> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
>
> Ready to be installed?
> Thanks,
> Martin
>
> gcc/ChangeLog:
>
>     PR rtl-optimization/98271
>     PR rtl-optimization/98276
>     PR tree-optimization/98279
>     * opts-common.c (set_option): Do not allow overflow for integer
>     arguments.
>
> gcc/testsuite/ChangeLog:
>
>     PR rtl-optimization/98271
>     PR rtl-optimization/98276
>     PR tree-optimization/98279
>     * gcc.dg/pr98271.c: New test.
OK
jeff



[pushed] c++: Remove dg-ice in constexpr-52830.C [PR52830]

2020-12-15 Thread Marek Polacek via Gcc-patches
It turned out that r11-5942 fixed this old PR, and it was detected
by one of the few dg-ice tests -- exactly the point of them!  Now
the PR won't be opened until someone notices that it'd been fixed.
The patch failed to remove the dg-ice though, so now it XPASSes.  Fixing
this now.

Tested x86_64-pc-linux-gnu, applying to trunk.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/constexpr-52830.C: Remove dg-ice.
---
 gcc/testsuite/g++.dg/cpp0x/constexpr-52830.C | 1 -
 1 file changed, 1 deletion(-)

diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-52830.C 
b/gcc/testsuite/g++.dg/cpp0x/constexpr-52830.C
index 2c9d2f9b329..04f039fac43 100644
--- a/gcc/testsuite/g++.dg/cpp0x/constexpr-52830.C
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-52830.C
@@ -1,6 +1,5 @@
 // PR c++/52830
 // { dg-do compile { target c++11 } }
-// { dg-ice "comptypes" }
 
 template struct eif { typedef void type; };
 template<>   struct eif {};

base-commit: 65eac818dbc4d307ed109b71e9f737da7eae64e5
-- 
2.29.2



Change to gcc/testsuite/go.test/test rejected by ChangeLog checker

2020-12-15 Thread Ian Lance Taylor via Gcc-patches
I'm trying to commit a change that adds a bunch of new files to
gcc/testsuite/go.test/test.  It's being rejected because the hook
can't deduce a ChangeLog file.  But this directory has no ChangeLog
files.  I've committed other changes to this directory without a
ChangeLog entry.

What is going wrong?  What can I do to commit this change?  What
information can I provide?

Thanks.

Ian

> git push
Enumerating objects: 854, done.
Counting objects: 100% (854/854), done.
Delta compression using up to 8 threads
Compressing objects: 100% (824/824), done.
Writing objects: 100% (847/847), 266.10 KiB | 2.25 MiB/s, done.
Total 847 (delta 167), reused 3 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (167/167), completed with 4 local objects.
remote: *** The following commit was rejected by your
hooks.commit-extra-checker script (status: 1)
remote: *** commit: b09ac944e04a59af95a5767f6835edad7da4f152
remote: *** ChangeLog format failed:
remote: *** ERR: could not deduce ChangeLog file
remote: ***
remote: *** Please see: https://gcc.gnu.org/codingconventions.html#ChangeLogs
remote: ***
remote: error: hook declined to update refs/heads/master
To git+ssh://gcc.gnu.org/git/gcc
 ! [remote rejected] master -> master (hook declined)
error: failed to push some refs to 'git+ssh://gcc.gnu.org/git/gcc'


  1   2   >