[patch, fortran, testsuite, committed] Fix some more coarray stuff

2020-12-20 Thread Thomas König

Hi,

I have just committed the attached patch to a test case that
was failing on the shared coarray branch.

Again, the person who wrote the test case depended on only
running on a single image :-)

Best regards

Thomas

Correct coarray indices for test case.

gcc/testsuite/ChangeLog:

* gfortran.dg/coarray/send_char_array_1.f90: Correct coarray
indces.
diff --git a/gcc/testsuite/gfortran.dg/coarray/send_char_array_1.f90 b/gcc/testsuite/gfortran.dg/coarray/send_char_array_1.f90
index 3e16fa83685..b3caf80b1ad 100644
--- a/gcc/testsuite/gfortran.dg/coarray/send_char_array_1.f90
+++ b/gcc/testsuite/gfortran.dg/coarray/send_char_array_1.f90
@@ -25,28 +25,28 @@ program send_convert_char_array
   allocate(character(kind=4, len=5)::co_str_k4_arr(4)[*])
 
   ! First check send/copy to self
-  co_str_k1_scal[1] = str_k1_scal
+  co_str_k1_scal[this_image()] = str_k1_scal
   if (co_str_k1_scal /= str_k1_scal // '  ') STOP 1
 
-  co_str_k4_scal[1] = str_k4_scal
+  co_str_k4_scal[this_image()] = str_k4_scal
   if (co_str_k4_scal /= str_k4_scal // 4_'  ') STOP 2
 
-  co_str_k4_scal[1] = str_k1_scal
+  co_str_k4_scal[this_image()] = str_k1_scal
   if (co_str_k4_scal /= str_k4_scal // 4_'  ') STOP 3
 
-  co_str_k1_scal[1] = str_k4_scal
+  co_str_k1_scal[this_image()] = str_k4_scal
   if (co_str_k1_scal /= str_k1_scal // '  ') STOP 4
 
-  co_str_k1_arr(:)[1] = str_k1_arr
+  co_str_k1_arr(:)[this_image()] = str_k1_arr
   if (any(co_str_k1_arr /= ['abc  ', 'EFG  ', 'klm  ', 'NOP  '])) STOP 5
  
-  co_str_k4_arr(:)[1] = [4_'abc', 4_'EFG', 4_'klm', 4_'NOP']! str_k4_arr
+  co_str_k4_arr(:)[this_image()] = [4_'abc', 4_'EFG', 4_'klm', 4_'NOP']! str_k4_arr
   if (any(co_str_k4_arr /= [4_'abc  ', 4_'EFG  ', 4_'klm  ', 4_'NOP  '])) STOP 6
 
-  co_str_k4_arr(:)[1] = str_k1_arr
+  co_str_k4_arr(:)[this_image()] = str_k1_arr
   if (any(co_str_k4_arr /= [ 4_'abc  ', 4_'EFG  ', 4_'klm  ', 4_'NOP  '])) STOP 7
 
-  co_str_k1_arr(:)[1] = str_k4_arr
+  co_str_k1_arr(:)[this_image()] = str_k4_arr
   if (any(co_str_k1_arr /= ['abc  ', 'EFG  ', 'klm  ', 'NOP  '])) STOP 8
 
 end program send_convert_char_array


[patch, fortran, committed] Set DECL_ARTIFICIAL on auxiliary variables

2020-12-20 Thread Thomas König

Hello world,

committed to trunk as obvious and simple.

Best regards

Thomas

Set DECL_ARTIFICIAL on gfortran internal variables.

It seems we sometimes use DECL_ARTIFICIAL as choosing between
different code paths.  In order not to make -fdebug-aux-vars
do different things, set DECL_ARTIFICIAL on the variables to
avoid these different code paths (and the corresponding
regressions).

gcc/fortran/ChangeLog:

* trans.c (create_var_debug_raw): Set DECL_ARTIFICIAL
on variables.

diff --git a/gcc/fortran/trans.c b/gcc/fortran/trans.c
index fa7fd9d88aa..57a344a63c9 100644
--- a/gcc/fortran/trans.c
+++ b/gcc/fortran/trans.c
@@ -128,6 +128,9 @@ create_var_debug_raw (tree type, const char *prefix)
 
   t = build_decl (input_location, VAR_DECL, get_identifier (name_buf), type);
 
+  /* Not setting this causes some regressions.  */
+  DECL_ARTIFICIAL (t) = 1;
+
   /* We want debug info for it.  */
   DECL_IGNORED_P (t) = 0;
   /* It should not be nameless.  */


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

2020-12-20 Thread Alejandro Colomar (man-pages) via Gcc-patches
Ping

On 12/15/20 2:30 PM, Alejandro Colomar wrote:
> 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
> 

-- 
Alejandro Colomar
Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/
http://www.alejandro-colomar.es/


Re: [PATCH] store VLA bounds in attribute access as strings (PR 97172)

2020-12-20 Thread Martin Sebor via Gcc-patches

On 12/19/20 12:48 AM, Richard Biener via Gcc-patches wrote:

On December 19, 2020 1:55:02 AM GMT+01:00, Martin Sebor via Gcc-patches 
 wrote:

To keep tree expressions stored by the front end in attribute
access for nontrivial VLA bounds from getting corrupted during
Gimplification and to avoid breaking the preconditions verified
by the LTO streamer that no such trees exist in the IL,
the attached patch replaces those bounds with a string
representation of those expressions (as STRING_CST).  It also
tweaks the pretty-printer to improve the formatting of the VLA
bounds and avoid inserting spurious spaces in some cases.

The strings are only used by the front end to verify that
redeclarations of the same function match in the form and bounds
of their VLA arguments, and they're not needed in the middle end.
I considered removing them just before the front end finishes but
I couldn't find an efficient way to do that.  Is there some data
structure that stores all function declarations in a translation
unit?  If there is, then traversing it and removing the attribute
arguments might also be an option, either in addition to this
change or in lieu of it.


There is the free lang data pass in tree.c which walks all reachable tree nodes.


You said in response to Honza's suggestion in pr97172 to do that:

  The frontend needs to make sure no frontend specific tree codes
  leak into GENERIC so GENERICization is the place where the FE
  should clear those.  FLD is too late and doing it there would
  be a hack.

Are you now saying you've had a change of heart and that doing it
there isn't a hack after all?

Martin


The patch was tested on x86_64-linux.

Martin






[committed] doc: Fix a typo [PR98400]

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

Fix a typo in an option name in documentation.

Committed to trunk as obvious.

2020-12-20  Jakub Jelinek  

PR other/98400
* doc/invoke.texi (-mbackchain): Fix a typo - -mmo-backchain ->
-mno-backchain.

--- gcc/doc/invoke.texi
+++ gcc/doc/invoke.texi
@@ -28172,7 +28172,7 @@ the backchain is placed into the topmost word of the 
96/160 byte register
 save area.
 
 In general, code compiled with @option{-mbackchain} is call-compatible with
-code compiled with @option{-mmo-backchain}; however, use of the backchain
+code compiled with @option{-mno-backchain}; however, use of the backchain
 for debugging purposes usually requires that the whole binary is built with
 @option{-mbackchain}.  Note that the combination of @option{-mbackchain},
 @option{-mpacked-stack} and @option{-mhard-float} is not supported.  In order

Jakub



[committed] libstdc++: Fix indentation in

2020-12-20 Thread Jonathan Wakely via Gcc-patches
libstdc++-v3/ChangeLog:

* include/std/semaphore: Fix indentation.

Tested x86_64-linux. Committed to trunk.

commit 3621a7bb5795ad4e47b30e1a8a06f1abe2b3b036
Author: Jonathan Wakely 
Date:   Sun Dec 20 18:49:13 2020

libstdc++: Fix indentation in 

libstdc++-v3/ChangeLog:

* include/std/semaphore: Fix indentation.

diff --git a/libstdc++-v3/include/std/semaphore 
b/libstdc++-v3/include/std/semaphore
index ff83a56af4b..9648c3da7ce 100644
--- a/libstdc++-v3/include/std/semaphore
+++ b/libstdc++-v3/include/std/semaphore
@@ -87,7 +87,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{ return _M_sem._M_try_acquire_until(__atime); }
 };
 
- using binary_semaphore = std::counting_semaphore<1>;
+  using binary_semaphore = std::counting_semaphore<1>;
+
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
 #endif // __cpp_lib_atomic_wait


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

2020-12-20 Thread Michael Kerrisk (man-pages) via Gcc-patches
On 12/15/20 2:30 PM, Alejandro Colomar wrote:
> 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 *'.

Thanks, Alex. Patch applied.

Cheers,

Michael

>  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
> 


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/


Re: [PATCH 3/4] libstdc++: Add floating-point std::to_chars implementation

2020-12-20 Thread Maciej W. Rozycki
On Thu, 17 Dec 2020, Patrick Palka via Gcc-patches wrote:

> > >libstdc++-v3/ChangeLog:
> > >
> > >   * config/abi/pre/gnu.ver: Add new exports.
> > >   * include/std/charconv (to_chars): Declare the floating-point
> > >   overloads for float, double and long double.
> > >   * src/c++17/Makefile.am (sources): Add floating_to_chars.cc.
> > >   * src/c++17/Makefile.in: Regenerate.
> > >   * src/c++17/floating_to_chars.cc: New file.
> > >   (to_chars): Define for float, double and long double.
> > >   * testsuite/20_util/to_chars/long_double.cc: New test.
> >
> > Sorry it took so long to review, this is OK for trunk.
> >
> > The patch needs some minor changes to rebase it on the current trunk:
> > The linker script has additions since you send this patch, so the
> > context in the patch is wrong and it doesn't apply, and in 
> > the first line of context in the patch needs to have 'noexcept' added.
> > That rebase should be easy though.
> >
> > I'll look at adding __float128 support for powerpc64le.
> 
> Thanks a lot.  I committed the patch series just now, after rebasing
> and retesting on x86_64, aarch64 and ppc64le.

 This breaks with the `vax-netbsdelf' target in GCC compilation:

.../libstdc++-v3/src/c++17/floating_to_chars.cc:126:38: error: static assertion 
failed
  126 |   static_assert(__DBL_MANT_DIG__ == 53);
  |  ^
make[5]: *** [Makefile:577: floating_to_chars.lo] Error 1

So what's the fallback/alternative for non-IEEE-754 FP targets?  Shouldn't 
we call into libc (possibly with a warning attribute) for the formats we 
don't have explicit handcoded support for?

  Maciej


[COMMITTED] gcc: xtensa: implement bswapsi2, bswapdi2 and helpers

2020-12-20 Thread Max Filippov via Gcc-patches
2020-12-20  Max Filippov  
gcc/
* config/xtensa/xtensa.md (bswapsi2, bswapdi2): New patterns.

gcc/testsuite/
* gcc.target/xtensa/bswap.c: New test.

libgcc/
* config/xtensa/lib1funcs.S (__bswapsi2, __bswapdi2): New
functions.
* config/xtensa/t-xtensa (LIB1ASMFUNCS): Add _bswapsi2 and
_bswapdi2.
---
 gcc/config/xtensa/xtensa.md | 21 +
 gcc/testsuite/gcc.target/xtensa/bswap.c | 14 +
 libgcc/config/xtensa/lib1funcs.S| 39 +
 libgcc/config/xtensa/t-xtensa   |  1 +
 4 files changed, 75 insertions(+)
 create mode 100644 gcc/testsuite/gcc.target/xtensa/bswap.c

diff --git a/gcc/config/xtensa/xtensa.md b/gcc/config/xtensa/xtensa.md
index 462a7244a35d..cfb6a546d922 100644
--- a/gcc/config/xtensa/xtensa.md
+++ b/gcc/config/xtensa/xtensa.md
@@ -469,6 +469,27 @@
 })
 
 
+;; Byte swap.
+
+(define_insn "bswapsi2"
+  [(set (match_operand:SI 0 "register_operand" "=&a")
+   (bswap:SI (match_operand:SI 1 "register_operand" "r")))]
+  "!optimize_size"
+  "ssai\t8\;srli\t%0, %1, 16\;src\t%0, %0, %1\;src\t%0, %0, %0\;src\t%0, %1, 
%0"
+  [(set_attr "type""arith")
+   (set_attr "mode""SI")
+   (set_attr "length"  "15")])
+
+(define_insn "bswapdi2"
+  [(set (match_operand:DI 0 "register_operand" "=&a")
+   (bswap:DI (match_operand:DI 1 "register_operand" "r")))]
+  "!optimize_size"
+  "ssai\t8\;srli\t%0, %D1, 16\;src\t%0, %0, %D1\;src\t%0, %0, %0\;src\t%0, 
%D1, %0\;srli\t%D0, %1, 16\;src\t%D0, %D0, %1\;src\t%D0, %D0, %D0\;src\t%D0, 
%1, %D0"
+  [(set_attr "type""arith")
+   (set_attr "mode""DI")
+   (set_attr "length"  "27")])
+
+
 ;; Negation and one's complement.
 
 (define_insn "negsi2"
diff --git a/gcc/testsuite/gcc.target/xtensa/bswap.c 
b/gcc/testsuite/gcc.target/xtensa/bswap.c
new file mode 100644
index ..057a3569703f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/xtensa/bswap.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-O1" } */
+
+unsigned long f32(unsigned long v)
+{
+  return __builtin_bswap32(v);
+}
+
+unsigned long long f64(unsigned long long v)
+{
+  return __builtin_bswap64(v);
+}
+
+/* { dg-final { scan-assembler-times "ssai" 2 } } */
diff --git a/libgcc/config/xtensa/lib1funcs.S b/libgcc/config/xtensa/lib1funcs.S
index 77e78885d84b..b19deae14483 100644
--- a/libgcc/config/xtensa/lib1funcs.S
+++ b/libgcc/config/xtensa/lib1funcs.S
@@ -840,5 +840,44 @@ __lshrdi3:
 #endif /* L_lshrdi3 */
 
 
+#ifdef L_bswapsi2
+   .align  4
+   .global __bswapsi2
+   .type   __bswapsi2, @function
+__bswapsi2:
+   leaf_entry sp, 16
+   ssai8
+   srlia3, a2, 16
+   src a3, a3, a2
+   src a3, a3, a3
+   src a2, a2, a3
+   leaf_return
+   .size   __bswapsi2, . - __bswapsi2
+
+#endif /* L_bswapsi2 */
+
+
+#ifdef L_bswapdi2
+   .align  4
+   .global __bswapdi2
+   .type   __bswapdi2, @function
+__bswapdi2:
+   leaf_entry sp, 16
+   ssai8
+   srlia4, a2, 16
+   src a4, a4, a2
+   src a4, a4, a4
+   src a4, a2, a4
+   srlia2, a3, 16
+   src a2, a2, a3
+   src a2, a2, a2
+   src a2, a3, a2
+   mov a3, a4
+   leaf_return
+   .size   __bswapdi2, . - __bswapdi2
+
+#endif /* L_bswapdi2 */
+
+
 #include "ieee754-df.S"
 #include "ieee754-sf.S"
diff --git a/libgcc/config/xtensa/t-xtensa b/libgcc/config/xtensa/t-xtensa
index 90df5f15daa9..9836c96aefc6 100644
--- a/libgcc/config/xtensa/t-xtensa
+++ b/libgcc/config/xtensa/t-xtensa
@@ -2,6 +2,7 @@ LIB1ASMSRC = xtensa/lib1funcs.S
 LIB1ASMFUNCS = _mulsi3 _divsi3 _modsi3 _udivsi3 _umodsi3 \
_umulsidi3 _clz _clzsi2 _ctzsi2 _ffssi2 \
_ashldi3 _ashrdi3 _lshrdi3 \
+   _bswapsi2 _bswapdi2 \
_negsf2 _addsubsf3 _mulsf3 _divsf3 _cmpsf2 _fixsfsi _fixsfdi \
_fixunssfsi _fixunssfdi _floatsisf _floatunsisf \
_sqrtf _recipsf2 _rsqrtsf2 \
-- 
2.20.1



[PATCH] PR fortran/93685 - [9/10/11 Regression] ICE in gfc_constructor_append_expr, at fortran/constructor.c:135

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

the patch is almost self-explaining.  We mishandled the case of initializing
pointer components to derived types of type CHARACTER via DATA, which screwed
up both legal and illegal uses.  The attached patch fixes that, and checks
that the legal cases work.

Regtests cleanly on x86_64-pc-linux-gnu.

OK for master?  As it is a regression, I intend to backport as seems applicable.

(As one part of the patch partially reverts sth. that was part of

commit eb401400f59e4d1f28bbdc788c3234e0968081d7
Author: Andre Vehreschild 
Date:   Wed Dec 14 12:52:09 2016 +0100

re PR fortran/78672 (Gfortran test suite failures with a sanitized compiler)

I'd be glad if somebody else cross-checks on a different platform.)

Thanks,
Harald


PR93685 - ICE in gfc_constructor_append_expr, at fortran/constructor.c:135

Fix handling of F2018 enhancements to DATA statements that allows
initialization of pointer components to derived types, and adjust error
handling for the CHARACTER case.

gcc/fortran/ChangeLog:

* data.c (gfc_assign_data_value): Restrict use of
create_character_initializer to constant initializers.
* trans-expr.c (gfc_conv_initializer): Ensure that character
initializer is constant, otherwise fall through to get the same
error handling as for non-character cases.

gcc/testsuite/ChangeLog:

* gfortran.dg/pr93685_1.f90: New test.
* gfortran.dg/pr93685_2.f90: New test.

diff --git a/gcc/fortran/data.c b/gcc/fortran/data.c
index 3e52a5717b5..76ddd9dab7f 100644
--- a/gcc/fortran/data.c
+++ b/gcc/fortran/data.c
@@ -546,12 +546,11 @@ gfc_assign_data_value (gfc_expr *lvalue, gfc_expr *rvalue, mpz_t index,
 	return false;
 }

-  if (ref || last_ts->type == BT_CHARACTER)
+  if (ref || (last_ts->type == BT_CHARACTER
+	  && rvalue->expr_type == EXPR_CONSTANT))
 {
   /* An initializer has to be constant.  */
-  if (rvalue->expr_type != EXPR_CONSTANT
-	  || (lvalue->ts.u.cl->length == NULL
-	  && !(ref && ref->u.ss.length != NULL)))
+  if (lvalue->ts.u.cl->length == NULL && !(ref && ref->u.ss.length != NULL))
 	return false;
   expr = create_character_initializer (init, last_ts, ref, rvalue);
 }
diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index bfe08be2a94..f66afab85d1 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -7877,12 +7877,14 @@ gfc_conv_initializer (gfc_expr * expr, gfc_typespec * ts, tree type,
 	  return se.expr;

 	case BT_CHARACTER:
-	  {
-	tree ctor = gfc_conv_string_init (ts->u.cl->backend_decl,expr);
-	TREE_STATIC (ctor) = 1;
-	return ctor;
-	  }
+	  if (expr->expr_type == EXPR_CONSTANT)
+	{
+	  tree ctor = gfc_conv_string_init (ts->u.cl->backend_decl, expr);
+	  TREE_STATIC (ctor) = 1;
+	  return ctor;
+	}

+	  /* Fallthrough.  */
 	default:
 	  gfc_init_se (&se, NULL);
 	  gfc_conv_constant (&se, expr);
diff --git a/gcc/testsuite/gfortran.dg/pr93685_1.f90 b/gcc/testsuite/gfortran.dg/pr93685_1.f90
new file mode 100644
index 000..34d6e2cf355
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr93685_1.f90
@@ -0,0 +1,20 @@
+! { dg-do run }
+! PR93685 - ICE in gfc_constructor_append_expr, at fortran/constructor.c:135
+
+program p
+  implicit none
+  type t
+ character, pointer :: a
+  end type t
+  type u
+ integer,   pointer :: i
+  end type u
+  type(t) :: x
+  type(u) :: y
+  character, target :: c = 'c'
+  integer  , target :: i = 10
+  data x%a /c/
+  data y%i /i/
+  if (x% a /= "c") stop 1
+  if (y% i /= 10)  stop 2
+end
diff --git a/gcc/testsuite/gfortran.dg/pr93685_2.f90 b/gcc/testsuite/gfortran.dg/pr93685_2.f90
new file mode 100644
index 000..2e3ef5a62fd
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr93685_2.f90
@@ -0,0 +1,18 @@
+! { dg-do compile }
+! PR93685 - ICE in gfc_constructor_append_expr, at fortran/constructor.c:135
+
+program p
+  implicit none
+  type t
+ character :: a
+  end type t
+  type u
+ integer   :: i
+  end type u
+  type(t) :: x
+  type(u) :: y
+  character, target :: c = 'c'
+  integer  , target :: i = 10
+  data x%a /c/  ! { dg-error "non-constant initialization expression"}
+  data y%i /i/  ! { dg-error "non-constant initialization expression"}
+end


Re: [PATCH] Hurd: Enable ifunc by default

2020-12-20 Thread Samuel Thibault via Gcc-patches
Ping?

Samuel Thibault, le dim. 08 nov. 2020 23:52:51 +0100, a ecrit:
> The binutils bugs seem to have been fixed.
> 
> 2020-11-08  Samuel Thibault  
> 
>   gcc/
>   * config.gcc: Enable default_gnu_indirect_function in *-*-gnu*
>   target (but not *-*-kfreebsd*-gnu | *-*-kopensolaris*-gnu).
> ---
>  gcc/config.gcc | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/gcc/config.gcc b/gcc/config.gcc
> index b42ebc4e5be..a347c2cec7c 100644
> --- a/gcc/config.gcc
> +++ b/gcc/config.gcc
> @@ -3538,7 +3538,9 @@ esac
>  case ${target} in
>  *-*-linux*android*|*-*-linux*uclibc*|*-*-linux*musl*)
>  ;;
> -*-*-linux*)
> +*-*-kfreebsd*-gnu | *-*-kopensolaris*-gnu)
> +;;
> +*-*-linux* | *-*-gnu*)
>   case ${target} in
>   aarch64*-* | arm*-* | i[34567]86-* | powerpc*-* | s390*-* | sparc*-* | 
> x86_64-*)
>   default_gnu_indirect_function=yes
> -- 
> 2.20.1
> 


[PATCH, fix bootstrap] libcody: Include as needed

2020-12-20 Thread Gerald Pfeifer
libcody as originally added to GCC fails to build on *-unknown-freebsd11.4 
and presumably others:

  c++ -std=c++11 -g -include config.h -I ... -MMD -MP -MF netclient.d -c
-o netclient.o
  .../libcody/netclient.cc:114:3: error: unknown type sockaddr_in6 addr;
  ^~~~

sockaddr_in6 is declared in /usr/include/netinet6/in6.h,
which is included by /usr/include/netinet/in.h.

Indeed, per https://man7.org/linux/man-pages/man7/ipv6.7.html

#include 
#include 

should be included, and our own gcc/ada/gsocket.h also has

#if !(defined (VMS) || defined (__MINGW32__))
#include 
#include 
#include 
:
#endif


Okay to push?

Gerald


libcody/ChangeLog:

2020-12-21  Gerald Pfeifer  

* netclient.cc: Include .
* netserver.cc: Ditto.
---
 libcody/netclient.cc | 1 +
 libcody/netserver.cc | 1 +
 2 files changed, 2 insertions(+)

diff --git a/libcody/netclient.cc b/libcody/netclient.cc
index 8cccface71c..c97ed4ca126 100644
--- a/libcody/netclient.cc
+++ b/libcody/netclient.cc
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #ifndef AI_NUMERICSERV
 #define AI_NUMERICSERV 0
diff --git a/libcody/netserver.cc b/libcody/netserver.cc
index 7e43eb033f4..4e55089161e 100644
--- a/libcody/netserver.cc
+++ b/libcody/netserver.cc
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #ifndef AI_NUMERICSERV
 #define AI_NUMERICSERV 0
-- 
2.29.2


Re: C++ 20 modules

2020-12-20 Thread Gerald Pfeifer
On Thu, 17 Dec 2020, Nathan Sidwell wrote:
> As yesterday, several issues fixed:

Here is a new one, *-unknown-freebsd11.4; with my previous patch
applied, libcody builds and we now fail in gcc/cp:

c++ -std=c++11 -fno-PIE -c -DIN_GCC_FRONTEND -g -DIN_GCC 
-fno-strict-aliasing -fno-exceptions -fno-rtti 
-fasynchronous-unwind-tables -W -Wall -Wno-narrow ing -Wwrite-strings 
-Wcast-qual -Wno-error=format-diag -Wno-format -Wmissing-fo rmat-attribute 
-Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macr os 
-Wno-overlength-strings -fno-common -DHAVE_CONFIG_H -I. -Icp 
-I/scratch/tmp /gerald/GCC-HEAD/gcc -I/scratch/tmp/gerald/GCC-HEAD/gcc/cp 
-I/scratch/tmp/geral d/GCC-HEAD/gcc/../include -I./../intl 
-I/scratch/tmp/gerald/GCC-HEAD/gcc/../lib cpp/include 
-I/scratch/tmp/gerald/GCC-HEAD/gcc/../libcody -I/home/gerald/11-i38 
6/include -I/scratch/tmp/gerald/GCC-HEAD/gcc/../libdecnumber 
-I/scratch/tmp/ge rald/GCC-HEAD/gcc/../libdecnumber/dpd -I../libdecnumber 
-I/scratch/tmp/gerald/G CC-HEAD/gcc/../libbacktrace -o cp/mapper-client.o 
-MT cp/mapper-client.o -MMD -MP -MF cp/.deps/mapper-client.TPo 
/scratch/tmp/gerald/GCC-HEAD/gcc/cp/mapper-client.cc
In file included from /scratch/tmp/gerald/GCC-HEAD/gcc/cp/mapper-client.cc:31:
In file included from /scratch/tmp/gerald/GCC-HEAD/gcc/cp/mapper-client.h:26:
In file included from /scratch/tmp/gerald/GCC-HEAD/gcc/../libcody/cody.hh:24:
In file included from /usr/include/c++/v1/memory:653:
/usr/include/c++/v1/typeinfo:346:5: error: no member named 'fancy_abort' in 
namespace 'std::__1'; did you mean simply 'fancy_abort'?
_VSTD::abort();
^~~
/usr/include/c++/v1/__config:782:15: note: expanded from macro '_VSTD'
#define _VSTD std::_LIBCPP_ABI_NAMESPACE
  ^

Compiler is clang version 10.0.1.

Gerald


Re: [PATCH] Hurd: Enable ifunc by default

2020-12-20 Thread Almudena Garcia via Gcc-patches
What do you need exactly? How can we test It?

El lun, 21 dic 2020 a las 0:11, Samuel Thibault ()
escribió:

> Ping?
>
> Samuel Thibault, le dim. 08 nov. 2020 23:52:51 +0100, a ecrit:
> > The binutils bugs seem to have been fixed.
> >
> > 2020-11-08  Samuel Thibault  
> >
> >   gcc/
> >   * config.gcc: Enable default_gnu_indirect_function in *-*-gnu*
> >   target (but not *-*-kfreebsd*-gnu | *-*-kopensolaris*-gnu).
> > ---
> >  gcc/config.gcc | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/gcc/config.gcc b/gcc/config.gcc
> > index b42ebc4e5be..a347c2cec7c 100644
> > --- a/gcc/config.gcc
> > +++ b/gcc/config.gcc
> > @@ -3538,7 +3538,9 @@ esac
> >  case ${target} in
> >  *-*-linux*android*|*-*-linux*uclibc*|*-*-linux*musl*)
> >  ;;
> > -*-*-linux*)
> > +*-*-kfreebsd*-gnu | *-*-kopensolaris*-gnu)
> > +;;
> > +*-*-linux* | *-*-gnu*)
> >   case ${target} in
> >   aarch64*-* | arm*-* | i[34567]86-* | powerpc*-* | s390*-* |
> sparc*-* | x86_64-*)
> >   default_gnu_indirect_function=yes
> > --
> > 2.20.1
> >
>
>


Re: [PATCH] Hurd: Enable ifunc by default

2020-12-20 Thread Samuel Thibault via Gcc-patches
Almudena Garcia, le lun. 21 déc. 2020 01:05:29 +0100, a ecrit:
> What do you need exactly?

I need gcc people to apply it.

> How can we test It?

The answer would be lengthy. Basically recompile gcc with it, write or
find a program that uses it, and check that it works.

But I have already done that simply by letting glibc use ifunc, and it
does work, so there is nothing more to be done on the Hurd developers'
side.

Samuel


Re: [gcc r11-5968] middle-end: Refactor and expose some vectorizer helper functions.

2020-12-20 Thread Maciej W. Rozycki
On Sun, 13 Dec 2020, Tamar Christina via Gcc-cvs wrote:

> https://gcc.gnu.org/g:10bbba9145700e2c3b4709c1041c66d8ff85c7f1
> 
> commit r11-5968-g10bbba9145700e2c3b4709c1041c66d8ff85c7f1
> Author: Tamar Christina 
> Date:   Sun Dec 13 13:53:48 2020 +
> 
> middle-end: Refactor and expose some vectorizer helper functions.

 Umm, this commit does not build:

.../gcc/tree-vect-slp.c:197:1: error: '_slp_tree* 
vect_create_new_slp_node(vec<_stmt_vec_info*>, unsigned int)' was declared 
'extern' and later 'static' [-fpermissive]
  197 | vect_create_new_slp_node (vec scalar_stmts, unsigned 
nops)
  | ^~~~
In file included from .../gcc/tree-vect-slp.c:39:
.../gcc/tree-vectorizer.h:2011:17: note: previous declaration of '_slp_tree* 
vect_create_new_slp_node(vec<_stmt_vec_info*>, unsigned int)'
 2011 | extern slp_tree vect_create_new_slp_node (vec, 
unsigned);  | ^~~~
make[2]: *** [Makefile:1122: tree-vect-slp.o] Error 1

due to swapped hunks with a subsequent change.  This disturbs bisection, 
requiring a manual intervention to proceed.  Please be more careful and 
always compile individual changes in a patch series.

  Maciej


Re: [PATCH] match.pd: Add ~(X - Y) -> ~X + Y simplification [PR96685]

2020-12-20 Thread Maciej W. Rozycki
On Sat, 12 Dec 2020, Jakub Jelinek via Gcc-patches wrote:

> This patch adds the ~(X - Y) -> ~X + Y simplification requested
> in the PR (plus also ~(X + C) -> ~X + (-C) for constants C that can
> be safely negated.

 This regresses VAX code produced by the cmpelim-eq-notsi.c test case (and 
its similar counterparts) with the `vax-netbsdelf' target.

 Previously this assembly:

.text
.align 1
.globl eq_notsi
.type   eq_notsi, @function
eq_notsi:
.word 0 # 35[c=0]  procedure_entry_mask
subl2 $4,%sp# 46[c=32]  *addsi3
mcoml 4(%ap),%r0# 32[c=16]  *one_cmplsi2_ccz
jeql .L1# 34[c=26]  *branch_ccz
addl2 $2,%r0# 31[c=32]  *addsi3
.L1:
ret # 40[c=0]  return
.size   eq_notsi, .-eq_notsi

was produced.  Now this:

.text
.align 1
.globl eq_notsi
.type   eq_notsi, @function
eq_notsi:
.word 0 # 36[c=0]  procedure_entry_mask
subl2 $4,%sp# 48[c=32]  *addsi3
movl 4(%ap),%r0 # 33[c=16]  *movsi_2
cmpl %r0,$-1# 34[c=8]  *cmpsi_ccz/1
jeql .L3# 35[c=26]  *branch_ccz
subl3 %r0,$1,%r0# 32[c=32]  *subsi3/1
ret # 27[c=0]  return
.L3:
clrl %r0# 31[c=2]  *movsi_2
ret # 41[c=0]  return
.size   eq_notsi, .-eq_notsi

is, which is clearly worse, both in terms of performance and size.

 The key here is that the cost of constant 0, here used with a comparison 
operation eliminated after MCOML in the former assembly sequence, is lower 
(as per `vax_rtx_costs') in the VAX ISA than the cost of constant -1, used 
with CMPL in the latter sequence.  Not only constant 0 is an implied 
operand with some machine instructions saving cycles and space otherwise 
used for an explicitly encoded operand, but if used with a comparison 
operation it can usually be eliminated, so it should be preferred over all 
other constants.

 With the example you gave with the PR I can see progression with f3, f4, 
f7, f8, regression with f1, f2, and no change in operation cost with f5, 
f6.

 Shouldn't a transformation like this respect target-specific expression 
costs somehow then?  Depending on the individual case one form or the 
other might be cheaper, and somehow we assume here both are equivalent in 
terms of performance and/or code size (as applicable for the optimisation 
mode chosen).

  Maciej


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

2020-12-20 Thread Ian Lance Taylor via Gcc-patches
On Thu, Dec 17, 2020 at 10:22 AM Nikhil Benesch
 wrote:
>
> On 12/17/20 1:05 PM, Ian Lance Taylor wrote:
> > Thanks for looking into this.  I've gotten confused now, though.
> > Which patch fixes the problem on Solaris?  Thanks.
> >
> > Ian
>
> The patch I submitted upstream is all that is needed to fix the
> compilation failures on Solaris:
>
>  https://go-review.googlesource.com/c/gofrontend/+/278672
>
> That is the same patch as "solaris-godump.patch" in this thread.
>
> That patch does not fix the fishiness around dummy types that you
> pointed out earlier. That is what the other patch was trying (but
> failing) to address. But we don't need to fix that fishiness to fix
> Solaris. The code in mk[r]sysinfo.sh that is getting confused by the
> u?pad128_t dummy type turns out to be unnecessary. So the patch I sent
> upstream just removes that code.

Thanks.  Committed to mainline.

Ian


Re: [PATCH] match.pd: Add ~(X - Y) -> ~X + Y simplification [PR96685]

2020-12-20 Thread Jakub Jelinek via Gcc-patches
On Mon, Dec 21, 2020 at 02:50:24AM +, Maciej W. Rozycki wrote:
> On Sat, 12 Dec 2020, Jakub Jelinek via Gcc-patches wrote:
> 
> > This patch adds the ~(X - Y) -> ~X + Y simplification requested
> > in the PR (plus also ~(X + C) -> ~X + (-C) for constants C that can
> > be safely negated.
> 
>  This regresses VAX code produced by the cmpelim-eq-notsi.c test case (and 
> its similar counterparts) with the `vax-netbsdelf' target.

The point of the match.pd changes is to canonicalize GIMPLE on some form
when there are several from GIMPLE POV equivalent or better forms of writing
the same thing.  The advantage of having one canonical way is that ICF,
SCCVN etc. optimizations can then understand the different forms are
equivalent.

If another form is then better for a particular machine, it should be done
either during expansion (being able to produce both RTLs and computing their
costs), or during combine with either combine splitters or
define_insn_and_split in the backend, or, if it can't be done in RTL, during
the isel pass.

Jakub