[PATCH, PR d/88431] Fix link build errors when compiling with unsupported options

2019-04-23 Thread Iain Buclaw
Hi,

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

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

This patch fixes build failure in PR88431, bootstrapped and regression
tested on x86_64-linux-gnu.

Committed to trunk as r270531.

-- 
Iain
---
libphobos/ChangeLog:

2019-04-24  Iain Buclaw  

PR d/88431
* configure: Regenerate.
* m4/libtool.m4 (lt_simple_compile_test_code): Update to not have
dependencies on libphobos.
(lt_simple_link_test_code): Likewise.
(GDCFLAGS): Don't override for D compiler tests.
---
diff --git a/libphobos/configure b/libphobos/configure
index 8079a73527d..7c019899c5c 100755
--- a/libphobos/configure
+++ b/libphobos/configure
@@ -11981,10 +11981,16 @@ objext=o
 objext_D=$objext
 
 # Code to be used in simple compile tests
-lt_simple_compile_test_code="module mod; extern(C) int main() { return 0; }"
+lt_simple_compile_test_code="\
+  module object;
+  shared int some_variable = 0;
+"
 
 # Code to be used in simple link tests
-lt_simple_link_test_code='module mod; extern(C) int main() { return 0; }'
+lt_simple_link_test_code="\
+  module object;
+  extern(C) int main() { return 0; }
+"
 
 # ltmain only uses $CC for tagged configurations so make sure $CC is set.
 
@@ -12020,12 +12026,9 @@ $RM -r conftest*
 # Allow CC to be a program name with arguments.
 lt_save_CC=$CC
 lt_save_CFLAGS=$CFLAGS
-lt_save_DFLAGS=$GDCFLAGS
 lt_save_GCC=$GCC
 GCC=yes
 CC=${GDC-"gdc"}
-# Need to specify location for object.d
-GDCFLAGS="-nophoboslib $GDCFLAGS"
 CFLAGS=$GDCFLAGS
 compiler=$CC
 compiler_D=$CC
@@ -13867,7 +13870,6 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 GCC=$lt_save_GCC
 CC=$lt_save_CC
 CFLAGS=$lt_save_CFLAGS
-GDCFLAGS=$lt_save_DFLAGS
 
   GDCFLAGS=$gdc_save_DFLAGS
 
diff --git a/libphobos/m4/libtool.m4 b/libphobos/m4/libtool.m4
index 44ca572025b..0263a530cf0 100644
--- a/libphobos/m4/libtool.m4
+++ b/libphobos/m4/libtool.m4
@@ -20,10 +20,16 @@ objext=o
 _LT_TAGVAR(objext, $1)=$objext
 
 # Code to be used in simple compile tests
-lt_simple_compile_test_code="module mod; extern(C) int main() { return 0; }"
+lt_simple_compile_test_code="\
+  module object;
+  shared int some_variable = 0;
+"
 
 # Code to be used in simple link tests
-lt_simple_link_test_code='module mod; extern(C) int main() { return 0; }'
+lt_simple_link_test_code="\
+  module object;
+  extern(C) int main() { return 0; }
+"
 
 # ltmain only uses $CC for tagged configurations so make sure $CC is set.
 _LT_TAG_COMPILER
@@ -35,12 +41,9 @@ _LT_LINKER_BOILERPLATE
 # Allow CC to be a program name with arguments.
 lt_save_CC=$CC
 lt_save_CFLAGS=$CFLAGS
-lt_save_DFLAGS=$GDCFLAGS
 lt_save_GCC=$GCC
 GCC=yes
 CC=${GDC-"gdc"}
-# Need to specify location for object.d
-GDCFLAGS="-nophoboslib $GDCFLAGS"
 CFLAGS=$GDCFLAGS
 compiler=$CC
 _LT_TAGVAR(compiler, $1)=$CC
@@ -74,5 +77,4 @@ AC_LANG_RESTORE
 GCC=$lt_save_GCC
 CC=$lt_save_CC
 CFLAGS=$lt_save_CFLAGS
-GDCFLAGS=$lt_save_DFLAGS
 ])# _LT_LANG_D_CONFIG


Re: [PATCH, netbsd] Define TARGET_D_CRITSEC_SIZE for D language

2019-04-23 Thread Iain Buclaw
On Wed, 24 Apr 2019 at 01:56, Kamil Rytarowski  wrote:
>
> On 24.04.2019 01:13, Iain Buclaw wrote:
> > Hi,
> >
> > This patch adds missing implementation of TARGET_D_CRITSEC_SIZE, which
> > would be noticed when using any bare synchronized statements.
> >
> > I couldn't see any target-specific alternatives of pthread_mutex_t in
> > netbsd headers, so the condition should be right.
> >
> > OK for trunk?
> >
>
> This patch is wrong.
>
> sizeof(pthread_mutex_t) depends on CPU.
>
> Just check that __cpu_simple_lock_nv_t that can be char, int, struct.
>

Ah, thanks for pointing to that.  I've made a small working example,
and it looks like only three have a different size, aarch64, hppa, and
hppa64.

https://explore.dgnu.org/z/U29cni

I'll add special handling for them, but otherwise 48/28 looks like the
reasonable default.

-- 
Iain


Re: [PATCH, netbsd] Define TARGET_D_CRITSEC_SIZE for D language

2019-04-23 Thread Kamil Rytarowski
On 24.04.2019 01:13, Iain Buclaw wrote:
> Hi,
> 
> This patch adds missing implementation of TARGET_D_CRITSEC_SIZE, which
> would be noticed when using any bare synchronized statements.
> 
> I couldn't see any target-specific alternatives of pthread_mutex_t in
> netbsd headers, so the condition should be right.
> 
> OK for trunk?
> 

This patch is wrong.

sizeof(pthread_mutex_t) depends on CPU.

Just check that __cpu_simple_lock_nv_t that can be char, int, struct.



signature.asc
Description: OpenPGP digital signature


[PATCH] Add brief explanation of the unwind library

2019-04-23 Thread Jonathan Wakely

This is only a very slight improvement, but adding the link at least
tells people where to find more info.

OK for trunk?
commit def4749f46383ee16eacedcc2e7d42cc1ce71788
Author: Jonathan Wakely 
Date:   Wed Apr 24 00:38:18 2019 +0100

Add brief explanation of the unwind library

diff --git a/gcc/doc/libgcc.texi b/gcc/doc/libgcc.texi
index bf0ca9ccdab..7464110b6ee 100644
--- a/gcc/doc/libgcc.texi
+++ b/gcc/doc/libgcc.texi
@@ -,7 +,10 @@ with saturation.
 @node Exception handling routines
 @section Language-independent routines for exception handling
 
-document me!
+These functions form GCC's implementation of the Unwind Library interface,
+as described by @uref{https://itanium-cxx-abi.github.io/cxx-abi/abi-eh.html}.
+
+FIXME: document these functions.
 
 @smallexample
   _Unwind_DeleteException


[PATCH, dragonfly] Add D language support for DragonFlyBSD x86

2019-04-23 Thread Iain Buclaw
Hi,

This patch adds necessary DragonFlyBSD support code, which allows
libphobos to compile cleanly.

OK for trunk?

-- 
Iain
---
gcc/ChangeLog:

2019-04-24  Iain Buclaw  

* config.gcc (*-*-dragonfly*): Add dragonfly-d.o
* config/dragonfly-d.c: New file.
* config/t-dragonfly: New file.

libphobos/ChangeLog:

2019-04-24  Iain Buclaw  

* configure.tgt: Add *-*-dragonfly* as a supported target.

---
diff --git a/gcc/config.gcc b/gcc/config.gcc
index 09fb9ecd2cd..14f0a1abbc8 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -724,6 +724,9 @@ case ${target} in
   extra_options="$extra_options rpath.opt dragonfly.opt"
   default_use_cxa_atexit=yes
   use_gcc_stdint=wrap
+  d_target_objs="${d_target_objs} dragonfly-d.o"
+  tmake_file="${tmake_file} t-dragonfly"
+  target_has_targetdm=yes
   ;;
 *-*-freebsd*)
   # This is the generic ELF configuration of FreeBSD.  Later
diff --git a/gcc/config/dragonfly-d.c b/gcc/config/dragonfly-d.c
new file mode 100644
index 000..b8d4a9ff45d
--- /dev/null
+++ b/gcc/config/dragonfly-d.c
@@ -0,0 +1,49 @@
+/* DragonFly support needed only by D front-end.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+
+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 "coretypes.h"
+#include "tm_d.h"
+#include "d/d-target.h"
+#include "d/d-target-def.h"
+
+/* Implement TARGET_D_OS_VERSIONS for DragonFly targets.  */
+
+static void
+dragonfly_d_os_builtins (void)
+{
+  d_add_builtin_version ("DragonFlyBSD");
+  d_add_builtin_version ("Posix");
+}
+
+/* Implement TARGET_D_CRITSEC_SIZE for DragonFly targets.  */
+
+static unsigned
+dragonfly_d_critsec_size (void)
+{
+  /* This is the sizeof pthread_mutex_t, an opaque pointer.  */
+  return POINTER_SIZE_UNITS;
+}
+
+#undef TARGET_D_OS_VERSIONS
+#define TARGET_D_OS_VERSIONS dragonfly_d_os_builtins
+
+#undef TARGET_D_CRITSEC_SIZE
+#define TARGET_D_CRITSEC_SIZE dragonfly_d_critsec_size
+
+struct gcc_targetdm targetdm = TARGETDM_INITIALIZER;
diff --git a/gcc/config/t-dragonfly b/gcc/config/t-dragonfly
new file mode 100644
index 000..34fc389d965
--- /dev/null
+++ b/gcc/config/t-dragonfly
@@ -0,0 +1,21 @@
+# Copyright (C) 2019 Free Software Foundation, Inc.
+#
+# 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
+# .
+
+dragonfly-d.o: $(srcdir)/config/dragonfly-d.c
+   $(COMPILE) $<
+   $(POSTCOMPILE)
diff --git a/libphobos/configure.tgt b/libphobos/configure.tgt
index a53a3c3c3be..f9c881a8418 100644
--- a/libphobos/configure.tgt
+++ b/libphobos/configure.tgt
@@ -23,6 +23,9 @@
 # broken systems.  More targets shall be added after testing.
 LIBPHOBOS_SUPPORTED=no
 case "${target}" in
+  *-*-dragonfly*)
+	LIBPHOBOS_SUPPORTED=yes
+	;;
   arm*-*-linux*)
 	LIBPHOBOS_SUPPORTED=yes
 	;;


[PATCH, PR d/87818] Add D language support for FreeBSD x86

2019-04-23 Thread Iain Buclaw
Hi,

This patch adds necessary FreeBSD support code, which allows libphobos
to compile cleanly.

OK for trunk?

-- 
Iain
---
gcc/ChangeLog:

2019-04-24  Iain Buclaw  

PR d/87818
* config.gcc (*-*-freebsd*): Add freebsd-d.o
* config/freebsd-d.c: New file.
* config/t-freebsd: New file.

libphobos/ChangeLog:

2019-04-24  Iain Buclaw  

PR d/87818
* configure.tgt: Add x86_64-*-freebsd* and i?86-*-freebsd* as
supported targets.

---
diff --git a/gcc/config.gcc b/gcc/config.gcc
index 14f0a1abbc8..7a286bbaa50 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -775,6 +775,9 @@ case ${target} in
   default_use_cxa_atexit=yes;;
   esac
   use_gcc_stdint=wrap
+  d_target_objs="${d_target_objs} freebsd-d.o"
+  tmake_file="${tmake_file} t-freebsd"
+  target_has_targetdm=yes
   ;;
 *-*-fuchsia*)
   native_system_header_dir=/include
diff --git a/gcc/config/freebsd-d.c b/gcc/config/freebsd-d.c
new file mode 100644
index 000..cdff544d20c
--- /dev/null
+++ b/gcc/config/freebsd-d.c
@@ -0,0 +1,54 @@
+/* FreeBSD support needed only by D front-end.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+
+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 "coretypes.h"
+#include "tm.h"
+#include "tm_p.h"
+#include "d/d-target.h"
+#include "d/d-target-def.h"
+
+/* Implement TARGET_D_OS_VERSIONS for FreeBSD targets.  */
+
+static void
+freebsd_d_os_builtins (void)
+{
+  char buf[16];
+  snprintf (buf, sizeof (buf), "FreeBSD_%d", FBSD_MAJOR);
+
+  d_add_builtin_version ("FreeBSD");
+  d_add_builtin_version (xstrdup (buf));
+  d_add_builtin_version ("Posix");
+}
+
+/* Implement TARGET_D_CRITSEC_SIZE for FreeBSD targets.  */
+
+static unsigned
+freebsd_d_critsec_size (void)
+{
+  /* This is the sizeof pthread_mutex_t, an opaque pointer.  */
+  return POINTER_SIZE_UNITS;
+}
+
+#undef TARGET_D_OS_VERSIONS
+#define TARGET_D_OS_VERSIONS freebsd_d_os_builtins
+
+#undef TARGET_D_CRITSEC_SIZE
+#define TARGET_D_CRITSEC_SIZE freebsd_d_critsec_size
+
+struct gcc_targetdm targetdm = TARGETDM_INITIALIZER;
diff --git a/gcc/config/t-freebsd b/gcc/config/t-freebsd
new file mode 100644
index 000..15fcf226d08
--- /dev/null
+++ b/gcc/config/t-freebsd
@@ -0,0 +1,21 @@
+# Copyright (C) 2019 Free Software Foundation, Inc.
+#
+# 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
+# .
+
+freebsd-d.o: $(srcdir)/config/freebsd-d.c
+   $(COMPILE) $<
+   $(POSTCOMPILE)
diff --git a/libphobos/configure.tgt b/libphobos/configure.tgt
index f9c881a8418..2dc05e2cc51 100644
--- a/libphobos/configure.tgt
+++ b/libphobos/configure.tgt
@@ -38,6 +38,9 @@ case "${target}" in
   s390*-linux*)
 	LIBPHOBOS_SUPPORTED=yes
 	;;
+  x86_64-*-freebsd* | i?86-*-freebsd*)
+	LIBPHOBOS_SUPPORTED=yes
+	;;
   x86_64-*-kfreebsd*-gnu | i?86-*-kfreebsd*-gnu)
 	LIBPHOBOS_SUPPORTED=yes
 	;;


Re: [PATCH] Fix std::variant regression caused by never-valueless optimization

2019-04-23 Thread Jonathan Wakely

On 23/04/19 10:56 +0100, Jonathan Wakely wrote:

+} catch (__gnu_cxx::forced_error) {


This triggers a warning if compiled with -Wcatch-value.

Fixed by this patch, committed to trunk.

commit 72ffe1dada2f747fec7b9949835c0dcbe86d892f
Author: Jonathan Wakely 
Date:   Wed Apr 24 00:15:56 2019 +0100

Avoid -Wcatch-value warning in testsuite

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

diff --git a/libstdc++-v3/testsuite/20_util/variant/run.cc b/libstdc++-v3/testsuite/20_util/variant/run.cc
index ec1e86805cd..f7353ad96b6 100644
--- a/libstdc++-v3/testsuite/20_util/variant/run.cc
+++ b/libstdc++-v3/testsuite/20_util/variant/run.cc
@@ -286,7 +286,7 @@ void emplace()
   Vector::allocator_type::set_limit(0);
   vv.emplace<2>(1, 1);
   VERIFY(false);
-} catch (__gnu_cxx::forced_error) {
+} catch (const __gnu_cxx::forced_error&) {
 }
 VERIFY(vv.valueless_by_exception());
   }


[PATCH, netbsd] Define TARGET_D_CRITSEC_SIZE for D language

2019-04-23 Thread Iain Buclaw
Hi,

This patch adds missing implementation of TARGET_D_CRITSEC_SIZE, which
would be noticed when using any bare synchronized statements.

I couldn't see any target-specific alternatives of pthread_mutex_t in
netbsd headers, so the condition should be right.

OK for trunk?

-- 
Iain
---
gcc/ChangeLog:

2019-04-24  Iain Buclaw  

* config/netbsd-d.c (netbsd_d_critsec_size): New function.
(TARGET_D_CRITSEC_SIZE): Define as netbsd_d_critsec_size.

---
diff --git a/gcc/config/netbsd-d.c b/gcc/config/netbsd-d.c
index 76342aacae3..c49366dc23b 100644
--- a/gcc/config/netbsd-d.c
+++ b/gcc/config/netbsd-d.c
@@ -28,6 +28,8 @@ along with GCC; see the file COPYING3.  If not see
 #include "d/d-target.h"
 #include "d/d-target-def.h"
 
+/* Implement TARGET_D_OS_VERSIONS for NetBSD targets.  */
+
 static void
 netbsd_d_os_builtins (void)
 {
@@ -35,7 +37,19 @@ netbsd_d_os_builtins (void)
   d_add_builtin_version ("NetBSD");
 }
 
+/* Implement TARGET_D_CRITSEC_SIZE for NetBSD targets.  */
+
+static unsigned
+netbsd_d_critsec_size (void)
+{
+  /* This is the sizeof pthread_mutex_t.  */
+  return (POINTER_SIZE == 64) ? 48 : 28;
+}
+
 #undef TARGET_D_OS_VERSIONS
 #define TARGET_D_OS_VERSIONS netbsd_d_os_builtins
 
+#undef TARGET_D_CRITSEC_SIZE
+#define TARGET_D_CRITSEC_SIZE netbsd_d_critsec_size
+
 struct gcc_targetdm targetdm = TARGETDM_INITIALIZER;


[PATCH] Remove disabling of D front-end as an unsupported language

2019-04-23 Thread Iain Buclaw
Hi,

The bootstrap for darwin was fixed a couple months back, so there is
no need to disable it any more.

OK for trunk?

-- 
Iain
---
ChangeLog:

2019-04-24  Iain Buclaw  

* configure.ac: Remove target addition of d to unsupported languages.
* configure: Regenerate.

---
diff --git a/configure b/configure
index abd93a990a9..db9341ebd24 100755
--- a/configure
+++ b/configure
@@ -3389,20 +3389,6 @@ if test "${ENABLE_LIBSTDCXX}" = "default" ; then
   esac
 fi
 
-# Disable D on systems where it is known to not work.
-# For testing, you can override this with --enable-languages=d.
-case ,${enable_languages}, in
-  *,d,*)
-;;
-  *)
-case "${target}" in
-  *-*-darwin*)
-	unsupported_languages="$unsupported_languages d"
-	;;
-esac
-;;
-esac
-
 # Disable libphobos on unsupported systems.
 # For testing, you can override this with --enable-libphobos.
 if test -d ${srcdir}/libphobos; then
diff --git a/configure.ac b/configure.ac
index 9db4fd14aa2..c463989d56f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -674,20 +674,6 @@ if test "${ENABLE_LIBSTDCXX}" = "default" ; then
   esac
 fi
 
-# Disable D on systems where it is known to not work.
-# For testing, you can override this with --enable-languages=d.
-case ,${enable_languages}, in
-  *,d,*)
-;;
-  *)
-case "${target}" in
-  *-*-darwin*)
-	unsupported_languages="$unsupported_languages d"
-	;;
-esac
-;;
-esac
-
 # Disable libphobos on unsupported systems.
 # For testing, you can override this with --enable-libphobos.
 if test -d ${srcdir}/libphobos; then


[PATCH] Implement LWG 2904 for std::variant assignment

2019-04-23 Thread Jonathan Wakely

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

Tested powerpc64le-linux, committed to trunk.

commit 4f31464fa45bfde54dfb2fb72b172797acf28c69
Author: Jonathan Wakely 
Date:   Tue Apr 23 23:24:46 2019 +0100

Implement LWG 2904 for std::variant assignment

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

diff --git a/libstdc++-v3/include/std/variant b/libstdc++-v3/include/std/variant
index 0c9f8a39c5c..8c7d7f37fe2 100644
--- a/libstdc++-v3/include/std/variant
+++ b/libstdc++-v3/include/std/variant
@@ -477,9 +477,9 @@ namespace __variant
 -> __detail::__variant::__variant_cookie
 {
  __variant_construct_single(std::forward<_Tp>(__lhs),
- std::forward( __rhs_mem));
+ std::forward(__rhs_mem));
  return {};
-   }, __variant_cast<_Types...>(std::forward(__rhs)));
+   }, __variant_cast<_Types...>(std::forward<_Up>(__rhs)));
 }
 
   // The following are (Copy|Move) (ctor|assign) layers for forwarding
@@ -522,41 +522,23 @@ namespace __variant
   _Move_ctor_base(_Move_ctor_base&& __rhs)
  noexcept(_Traits<_Types...>::_S_nothrow_move_ctor)
   {
-   __variant_construct<_Types...>(*this,
- std::forward<_Move_ctor_base>(__rhs));
+   __variant_construct<_Types...>(*this, std::move(__rhs));
   }
 
   template
 void _M_destructive_move(unsigned short __rhs_index, _Up&& __rhs)
 {
  this->_M_reset();
+ __variant_construct_single(*this, std::forward<_Up>(__rhs));
  this->_M_index = __rhs_index;
- __try
-   {
- __variant_construct_single(*this,
-std::forward<_Up>(__rhs));
-   }
- __catch (...)
-   {
- this->_M_index = variant_npos;
- __throw_exception_again;
-   }
}
 
   template
 void _M_destructive_copy(unsigned short __rhs_index, const _Up& __rhs)
 {
  this->_M_reset();
+ __variant_construct_single(*this, __rhs);
  this->_M_index = __rhs_index;
- __try
-   {
- __variant_construct_single(*this, __rhs);
-   }
- __catch (...)
-   {
- this->_M_index = variant_npos;
- __throw_exception_again;
-   }
}
 
   _Move_ctor_base(const _Move_ctor_base&) = default;
@@ -574,17 +556,16 @@ namespace __variant
 void _M_destructive_move(unsigned short __rhs_index, 

[PATCH, libphobos] Committed added AArch64 Linux as a supported target.

2019-04-23 Thread Iain Buclaw
Hi,

This patch adds arch64*-*-linux* as a supported libphobos target,
something that has been passing the testsuite for a while now.

Committed to trunk as r270524.

-- 
Iain
---
libphobos/ChangeLog:

2019-04-24  Iain Buclaw  

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

---
diff --git a/libphobos/configure.tgt b/libphobos/configure.tgt
index a53a3c3c3be..b2fe849752c 100644
--- a/libphobos/configure.tgt
+++ b/libphobos/configure.tgt
@@ -23,6 +23,9 @@
 # broken systems.  More targets shall be added after testing.
 LIBPHOBOS_SUPPORTED=no
 case "${target}" in
+  aarch64*-*-linux*)
+	LIBPHOBOS_SUPPORTED=yes
+	;;
   arm*-*-linux*)
 	LIBPHOBOS_SUPPORTED=yes
 	;;


Re: [PATCH] Document PSTL linker flags

2019-04-23 Thread Thomas Rodgers


Jonathan Wakely writes:

> On 23/04/19 09:54 -0700, Thomas Rodgers wrote:
>>
>>   * doc/xml/manual/using.xml: Add PSTL linker flags to table 3.1.
>
> OK - thanks.

Committed to trunk


Re: Adding noexcept-specification on tuple constructors (LWG 2899)

2019-04-23 Thread Jonathan Wakely

On 23/04/19 18:43 +0100, Nina Dinka Ranns wrote:

On Thu, 18 Apr 2019 at 21:35, Jonathan Wakely  wrote:


On 16/04/19 17:59 +0100, Nina Dinka Ranns wrote:
>On Tue, 16 Apr 2019 at 15:18, Jonathan Wakely  wrote:
>>
>> On 16/04/19 14:08 +0100, Nina Dinka Ranns wrote:
>> >Tested on Linux-PPC64
>> >Adding noexcept-specification on tuple constructors (LWG 2899)
>>
>> Thanks, Nina!
>>
>> This looks great, although as I think Ville has explained we won't
>> commit it until the next stage 1, after the GCC 9 release.
>ack
>
>>
>> The changes look good, I just have some mostly-stylistic comments,
>> which are inline below ...
>>
>>
>> >2019-04-13 Nina Dinka Ranns 
>> >
>> >Adding noexcept-specification on tuple constructors (LWG 2899)
>> >* libstdc++-v3/include/std/tuple:
>> >(tuple()): Add noexcept-specification.
>> >(tuple(const _Elements&...)): Likewise
>> >(tuple(_UElements&&...)): Likewise
>> >(tuple(const tuple<_UElements...>&)): Likewise
>> >(tuple(tuple<_UElements...>&&)): Likewise
>> >(tuple(const _T1&, const _T2&)): Likewise
>> >(tuple(_U1&&, _U2&&)): Likewise
>> >(tuple(const tuple<_U1, _U2>&): Likewise
>> >(tuple(tuple<_U1, _U2>&&): Likewise
>> >(tuple(const pair<_U1, _U2>&): Likewise
>> >(tuple(pair<_U1, _U2>&&): Likewise
>> >
>> >
>>
>> There should be no blank lines in the changelog entry here. A single
>> change should be recorded as a single block in the changelog, with no
>> blank lines within it.
>ack. Do you need me to do anything about this or is it for future
>reference only ?

For future reference. Whoever commits the patch can correct the
changelog.

>>
>> >* libstdc++-v3/testsuite/20_util/tuple/cons/noexcept_specs.cc: New
>> >* libstdc++-v3/testsuite/20_util/tuple/cons/noexcept_specs2.cc: New
>> >* libstdc++-v3/testsuite/20_util/tuple/cons/noexcept_specs3.cc: New
>> >* libstdc++-v3/testsuite/20_util/tuple/cons/noexcept_specs4.cc: New
>> >* libstdc++-v3/testsuite/20_util/tuple/cons/noexcept_specs5.cc: New
>> >* libstdc++-v3/testsuite/20_util/tuple/cons/noexcept_specs6.cc: New
>>
>> This is a lot of new test files for a small-ish QoI feature. Could
>> they be combined into one file?  Generally we do want one test file
>> per feature, but I think all of these are arguably testing one feature
>> (just on different constructors). The downside of lots of smaller
>> files is that we have to compile+assemble+link+run each one, which
>> adds several fork()s to launch a new process for each step. On some
>> platforms that can be quite slow.
>I can do that, but there may be an issue. See below.
>
>>
>>
>> >@@ -624,6 +634,7 @@
>> >   && (sizeof...(_Elements) >= 1),
>> > bool>::type=true>
>> > constexpr tuple(_UElements&&... __elements)
>> >+
noexcept(__and_...>::value)
>>
>> Can this be __nothrow_constructible<_UElements>() ?
>It should have been that in the first place. Apologies. Fixed.
>
>
>>
>> > : _Inherited(std::forward<_UElements>(__elements)...) { }
>> >
>> >   template> >@@ -635,6 +646,7 @@
>> >   && (sizeof...(_Elements) >= 1),
>> > bool>::type=false>
>> > explicit constexpr tuple(_UElements&&... __elements)
>> >+noexcept(__nothrow_constructible<_UElements&&...>())
>>
>> The && here is redundant, though harmless.
>>
>> is_constructible is exactly equivalent to is_constructible
>> because U means construction from an rvalue of type U and so does U&&.
>>
>> It's fine to leave the && there though.
>I'm happy to go either way. The only reason I used && form is because
>it mimics the wording in the LWG resolution.

I suspect if STL had reviewed the wording in the resolution he'd have
asked for the && to be removed :-)

:) ack. Removed.





>> >@@ -966,6 +995,7 @@
>> > && !is_same<__remove_cvref_t<_U1>, allocator_arg_t>::value,
>> >   bool>::type = true>
>> > constexpr tuple(_U1&& __a1, _U2&& __a2)
>> >+noexcept(__nothrow_constructible<_U1&&,_U2&&>())
>>
>> There should be a space after the comma here, and all the later
>> additions in the file.
>ack. Fixed
>
>>
>>
>> >Index: libstdc++-v3/testsuite/20_util/tuple/cons/noexcept_specs.cc
>> >===
>> >--- libstdc++-v3/testsuite/20_util/tuple/cons/noexcept_specs.cc
(nonexistent)
>> >+++ libstdc++-v3/testsuite/20_util/tuple/cons/noexcept_specs.cc
(working copy)
>> >@@ -0,0 +1,191 @@
>> >+// { dg-options { -std=gnu++2a } }
>> >+// { dg-do run { target c++2a } }
>>
>> This new file doesn't use std::is_nothrow_convertible so could just
>> use: { dg-do run { target c++11 } } and no dg-options.
>>
>> For the other new tests that do use is_nothrow_convertible, I'm
>> already planning to add std::is_nothrow_convertible for our internal
>> use in C++11, so they could use that.
>>
>> Alternatively, the test 

[PATCH, d] Committed support for compiling without libphobos library.

2019-04-23 Thread Iain Buclaw
Hi,

This patch backports support from the dmd front-end the options to
omit generating code that depends on libdruntime existing, and enables
the controlling of them by adding the options -fdruntime, and -frtti.
The other two options -fexceptions and -fmoduleinfo have also been
adapted accordingly.

Bootstrapped and regression tested on x86_64-linux-gnu.

Committed to trunk as r270518.
--
Iain
---
gcc/d/ChangeLog:

2019-04-23  Iain Buclaw  

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

gcc/testsuite/ChangeLog:

2019-04-23  Iain Buclaw  

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

---
diff --git a/gcc/d/d-builtins.cc b/gcc/d/d-builtins.cc
index f263aafbd59..3dbdafb492a 100644
--- a/gcc/d/d-builtins.cc
+++ b/gcc/d/d-builtins.cc
@@ -447,6 +447,15 @@ d_init_versions (void)
   if (global.params.useArrayBounds == BOUNDSCHECKoff)
 VersionCondition::addPredefinedGlobalIdent ("D_NoBoundsChecks");
 
+  if (global.params.betterC)
+VersionCondition::addPredefinedGlobalIdent ("D_BetterC");
+  else
+{
+  VersionCondition::addPredefinedGlobalIdent ("D_ModuleInfo");
+  VersionCondition::addPredefinedGlobalIdent ("D_Exceptions");
+  VersionCondition::addPredefinedGlobalIdent ("D_TypeInfo");
+}
+
   VersionCondition::addPredefinedGlobalIdent ("all");
 
   /* Emit all target-specific version identifiers.  */
diff --git a/gcc/d/d-codegen.cc b/gcc/d/d-codegen.cc
index 26929109b48..2abff92fc88 100644
--- a/gcc/d/d-codegen.cc
+++ b/gcc/d/d-codegen.cc
@@ -1762,7 +1762,10 @@ build_bounds_condition (const Loc& loc, tree index, tree len, bool inclusive)
  have already taken care of implicit casts to unsigned.  */
   tree condition = fold_build2 (inclusive ? GT_EXPR : GE_EXPR,
 d_bool_type, index, len);
-  tree boundserr = d_assert_call (loc, LIBCALL_ARRAY_BOUNDS);
+  /* Terminate the program with a trap if no D runtime present.  */
+  tree boundserr = (global.params.checkAction == CHECKACTION_D)
+? d_assert_call (loc, LIBCALL_ARRAY_BOUNDS)
+: build_call_expr (builtin_decl_explicit (BUILT_IN_TRAP), 0);
 
   return build_condition (TREE_TYPE (index), condition, boundserr, index);
 }
diff --git a/gcc/d/d-frontend.cc b/gcc/d/d-frontend.cc
index d1d3c78ec86..ccd5f50130f 100644
--- a/gcc/d/d-frontend.cc
+++ b/gcc/d/d-frontend.cc
@@ -612,8 +612,40 @@ eval_builtin (Loc loc, FuncDeclaration *fd, Expressions *arguments)
 /* Build and return typeinfo type for TYPE.  */
 
 Type *
-getTypeInfoType (Type *type, Scope *sc)
+getTypeInfoType (Loc loc, Type *type, Scope *sc)
 {
+  if (!global.params.useTypeInfo)
+{
+  /* Even when compiling without RTTI we should still be able to evaluate
+	 TypeInfo at compile-time, just not at run-time.  */
+  if (!sc || !(sc->flags & SCOPEctfe))
+	{
+	  static int warned = 0;
+
+	  if (!warned)
+	{
+	  error_at (make_location_t (loc),
+			"% cannot be used with -fno-rtti");
+	  warned = 1;
+	}
+	}
+}
+
+  if (Type::dtypeinfo == NULL
+  || (Type::dtypeinfo->storage_class & STCtemp))
+{
+  /* If TypeInfo has not been declared, warn about each location once.  */
+  static Loc warnloc;
+
+  if (!loc.equals (warnloc))
+	{
+	  error_at (make_location_t (loc),
+		"% could not be found, "
+		"but is implicitly used");
+	  warnloc 

Re: [PATCH] Document PSTL linker flags

2019-04-23 Thread Jonathan Wakely

On 23/04/19 09:54 -0700, Thomas Rodgers wrote:


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


OK - thanks.




Re: Adding noexcept-specification on tuple constructors (LWG 2899)

2019-04-23 Thread Nina Dinka Ranns
On Thu, 18 Apr 2019 at 21:35, Jonathan Wakely  wrote:
>
> On 16/04/19 17:59 +0100, Nina Dinka Ranns wrote:
> >On Tue, 16 Apr 2019 at 15:18, Jonathan Wakely  wrote:
> >>
> >> On 16/04/19 14:08 +0100, Nina Dinka Ranns wrote:
> >> >Tested on Linux-PPC64
> >> >Adding noexcept-specification on tuple constructors (LWG 2899)
> >>
> >> Thanks, Nina!
> >>
> >> This looks great, although as I think Ville has explained we won't
> >> commit it until the next stage 1, after the GCC 9 release.
> >ack
> >
> >>
> >> The changes look good, I just have some mostly-stylistic comments,
> >> which are inline below ...
> >>
> >>
> >> >2019-04-13 Nina Dinka Ranns 
> >> >
> >> >Adding noexcept-specification on tuple constructors (LWG 2899)
> >> >* libstdc++-v3/include/std/tuple:
> >> >(tuple()): Add noexcept-specification.
> >> >(tuple(const _Elements&...)): Likewise
> >> >(tuple(_UElements&&...)): Likewise
> >> >(tuple(const tuple<_UElements...>&)): Likewise
> >> >(tuple(tuple<_UElements...>&&)): Likewise
> >> >(tuple(const _T1&, const _T2&)): Likewise
> >> >(tuple(_U1&&, _U2&&)): Likewise
> >> >(tuple(const tuple<_U1, _U2>&): Likewise
> >> >(tuple(tuple<_U1, _U2>&&): Likewise
> >> >(tuple(const pair<_U1, _U2>&): Likewise
> >> >(tuple(pair<_U1, _U2>&&): Likewise
> >> >
> >> >
> >>
> >> There should be no blank lines in the changelog entry here. A single
> >> change should be recorded as a single block in the changelog, with no
> >> blank lines within it.
> >ack. Do you need me to do anything about this or is it for future
> >reference only ?
>
> For future reference. Whoever commits the patch can correct the
> changelog.
>
> >>
> >> >* libstdc++-v3/testsuite/20_util/tuple/cons/noexcept_specs.cc: New
> >> >* libstdc++-v3/testsuite/20_util/tuple/cons/noexcept_specs2.cc: 
> >> > New
> >> >* libstdc++-v3/testsuite/20_util/tuple/cons/noexcept_specs3.cc: 
> >> > New
> >> >* libstdc++-v3/testsuite/20_util/tuple/cons/noexcept_specs4.cc: 
> >> > New
> >> >* libstdc++-v3/testsuite/20_util/tuple/cons/noexcept_specs5.cc: 
> >> > New
> >> >* libstdc++-v3/testsuite/20_util/tuple/cons/noexcept_specs6.cc: 
> >> > New
> >>
> >> This is a lot of new test files for a small-ish QoI feature. Could
> >> they be combined into one file?  Generally we do want one test file
> >> per feature, but I think all of these are arguably testing one feature
> >> (just on different constructors). The downside of lots of smaller
> >> files is that we have to compile+assemble+link+run each one, which
> >> adds several fork()s to launch a new process for each step. On some
> >> platforms that can be quite slow.
> >I can do that, but there may be an issue. See below.
> >
> >>
> >>
> >> >@@ -624,6 +634,7 @@
> >> >   && (sizeof...(_Elements) >= 1),
> >> > bool>::type=true>
> >> > constexpr tuple(_UElements&&... __elements)
> >> >+
> >> >noexcept(__and_...>::value)
> >>
> >> Can this be __nothrow_constructible<_UElements>() ?
> >It should have been that in the first place. Apologies. Fixed.
> >
> >
> >>
> >> > : _Inherited(std::forward<_UElements>(__elements)...) { }
> >> >
> >> >   template >> >@@ -635,6 +646,7 @@
> >> >   && (sizeof...(_Elements) >= 1),
> >> > bool>::type=false>
> >> > explicit constexpr tuple(_UElements&&... __elements)
> >> >+noexcept(__nothrow_constructible<_UElements&&...>())
> >>
> >> The && here is redundant, though harmless.
> >>
> >> is_constructible is exactly equivalent to is_constructible
> >> because U means construction from an rvalue of type U and so does U&&.
> >>
> >> It's fine to leave the && there though.
> >I'm happy to go either way. The only reason I used && form is because
> >it mimics the wording in the LWG resolution.
>
> I suspect if STL had reviewed the wording in the resolution he'd have
> asked for the && to be removed :-)
:) ack. Removed.


>
>
> >> >@@ -966,6 +995,7 @@
> >> > && !is_same<__remove_cvref_t<_U1>, 
> >> > allocator_arg_t>::value,
> >> >   bool>::type = true>
> >> > constexpr tuple(_U1&& __a1, _U2&& __a2)
> >> >+noexcept(__nothrow_constructible<_U1&&,_U2&&>())
> >>
> >> There should be a space after the comma here, and all the later
> >> additions in the file.
> >ack. Fixed
> >
> >>
> >>
> >> >Index: libstdc++-v3/testsuite/20_util/tuple/cons/noexcept_specs.cc
> >> >===
> >> >--- libstdc++-v3/testsuite/20_util/tuple/cons/noexcept_specs.cc
> >> >(nonexistent)
> >> >+++ libstdc++-v3/testsuite/20_util/tuple/cons/noexcept_specs.cc
> >> >(working copy)
> >> >@@ -0,0 +1,191 @@
> >> >+// { dg-options { -std=gnu++2a } }
> >> >+// { dg-do run { target c++2a } }
> >>
> >> This new file doesn't use std::is_nothrow_convertible so could just
> >> use: { dg-do run { 

[PATCH] Document PSTL linker flags

2019-04-23 Thread Thomas Rodgers

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

>From eabe72642bf51b813f454c54ae3cc4e873cf34be Mon Sep 17 00:00:00 2001
From: Thomas Rodgers 
Date: Tue, 23 Apr 2019 09:50:13 -0700
Subject: [PATCH] Document PSTL linker flags

	 * doc/xml/manual/using.xml: Add PSTL linker flags to table
   3.1.
---
 libstdc++-v3/doc/xml/manual/using.xml | 9 +
 1 file changed, 9 insertions(+)

diff --git a/libstdc++-v3/doc/xml/manual/using.xml b/libstdc++-v3/doc/xml/manual/using.xml
index 9e8fe0715a3..8e099d9c3d8 100644
--- a/libstdc++-v3/doc/xml/manual/using.xml
+++ b/libstdc++-v3/doc/xml/manual/using.xml
@@ -107,6 +107,15 @@
   -fopenmp
   For parallel mode.
 
+
+
+  -ltbb
+  Linking to tbb (Thread Building Blocks) is required for use of the
+Parallel Standard Algorithms and execution policies in
+execution.
+  
+
+
   
 
 
-- 
2.20.1



Re: [Patch] [Aarch64] PR rtl-optimization/87763 - this patch fixes gcc.target/aarch64/lsl_asr_sbfiz.c

2019-04-23 Thread Jeff Law
On 4/16/19 10:29 AM, Steve Ellcey wrote:
> Re-ping.  I know there are discussions about bigger changes to fix the
> various failures listed in PR rtl-optimization/87763 but this patch
> at least fixes one of them (gcc.target/aarch64/lsl_asr_sbfiz.c).
So I think we can address this by making the extv/extzv expander handle
both modes just like we do for insv.That's cleaner than addding new
patterns to match the subreg nonsense IMHO.

Something like this:

> (define_expand ""
>   [(set (match_operand:GPI 0 "register_operand" "=r")
> (ANY_EXTRACT:GPI (match_operand:GPI 1 "register_operand")
> (match_operand 2
>   "aarch64_simd_shift_imm_offset_")
> (match_operand 3 "aarch64_simd_shift_imm_")))]
>   ""
>   {
> if (!IN_RANGE (INTVAL (operands[2]) + INTVAL (operands[3]),
>1, GET_MODE_BITSIZE (mode) - 1))
>  FAIL;
>   }
> )

Note how we're using ,  and the GPI iterator.  With that
updated expander I get:

sbfiz32:
sbfiz   w0, w0, 19, 3   // 12   [c=8 l=4]  *ashiftsi_extv_bfiz
ret // 21   [c=0 l=4]  *do_return


and

sbfiz64:
sbfiz   x0, x0, 38, 6   // 12   [c=8 l=4]  *ashiftdi_extv_bfiz
ret // 21   [c=0 l=4]  *do_return


I'm going to throw that into the tester and see what we get...

jeff


RE: [PATCH, GCC, AARCH64] Add GNU note section with BTI and PAC.

2019-04-23 Thread Sudakshina Das
Hi James

-Original Message-
From: James Greenhalgh  
Sent: 18 April 2019 09:56
To: Sudakshina Das 
Cc: Richard Henderson ; H.J. Lu 
; Richard Henderson ; 
gcc-patches@gcc.gnu.org; nd ; Richard Earnshaw 
; Marcus Shawcroft ; 
ni...@redhat.com
Subject: Re: [PATCH, GCC, AARCH64] Add GNU note section with BTI and PAC.

On Thu, Apr 04, 2019 at 05:01:06PM +0100, Sudakshina Das wrote:
> Hi Richard
> 
> On 03/04/2019 11:28, Richard Henderson wrote:
> > On 4/3/19 5:19 PM, Sudakshina Das wrote:
> >> +  /* PT_NOTE header: namesz, descsz, type.
> >> +   namesz = 4 ("GNU\0")
> >> +   descsz = 16 (Size of the program property array)
> >> +   type   = 5 (NT_GNU_PROPERTY_TYPE_0).  */
> >> +  assemble_align (POINTER_SIZE);
> >> +  assemble_integer (GEN_INT (4), 4, 32, 1);
> >> +  assemble_integer (GEN_INT (16), 4, 32, 1);
> > 
> > So, it's 16 only if POINTER_SIZE == 64.
> > 
> > I think ROUND_UP (12, POINTER_BYTES) is what you want here.
> >
> 
> 
> Ah yes. I have made that change now.

This is OK, but instead of:

> diff --git a/gcc/testsuite/gcc.target/aarch64/va_arg_1.c 
> b/gcc/testsuite/gcc.target/aarch64/va_arg_1.c
> index 
> e8e3cdac51350b545e5c2a644a3e1f4d1c37f88d..1fe92ff08935d4c6f08affcbd77e
> a91537030640 100644
> --- a/gcc/testsuite/gcc.target/aarch64/va_arg_1.c
> +++ b/gcc/testsuite/gcc.target/aarch64/va_arg_1.c
> @@ -4,7 +4,9 @@
>  int
>  f (int a, ...)
>  {
> -  /* { dg-final { scan-assembler-not "str" } } */
> +  /* Fails on aarch64*-*-linux* if configured with
> +--enable-standard-branch-protection because of the GNU NOTE 
> + section.  */
> +  /* { dg-final { scan-assembler-not "str" { target { ! 
> + aarch64*-*-linux* } || { ! default_branch_protection } } } } */
>return a;
>  }

> Can you just change the regex to check for str followed by a tab, or 
> something that looks else which looks like the instruction and doesn't match 
> against 'string'.

>Thanks,
>James

Ah yes, I have reduced the diff in this test to only update the scan directive 
to look for 'str\t' instead.
Committed as r270515.

Thanks
Sudi

> 
> Thanks
> Sudi
> 
> > 
> > r~
> > 
> 


Re: [4/4][PATCH] Discussing PR83507

2019-04-23 Thread Segher Boessenkool
Hi Roman,

On Mon, Apr 22, 2019 at 07:36:40PM +0300, Roman Zhuykov wrote:
> > > In pr84524.c we got a loop with an extended inline asm:
> > > asm volatile ("" : "+r" (v))
> > > which also gives us a “surprising” situation Alexander predicts.
> > >
> > > For sched-deps scanner such volatile asm is a “true barrier” and we
> > > create dependencies to almost all other instructions, while DF scanners
> > > don’t give us such information.
> >
> > There is no such thing as a "true barrier" in extended asm.  The only thing
> > volatile asm means is that the asm has a side effect unknown to the 
> > compiler;
> > this can *not* be a modification of a register or of memory contents, such
> > things are known by the compiler, that's what clobbers and "memory" clobber
> > are about.
> 
> In sched-deps.c we got:
> case ASM_OPERANDS:
> case ASM_INPUT:
>   {
>/* Traditional and volatile asm instructions must be considered to use
>   and clobber all hard registers, all pseudo-registers and all of
>   memory.  So must TRAP_IF and UNSPEC_VOLATILE operations.
> 
>   Consider for instance a volatile asm that changes the fpu rounding
>   mode.  An insn should not be moved across this even if it only uses
>   pseudo-regs because it might give an incorrectly rounded result.  */
>if ((code != ASM_OPERANDS || MEM_VOLATILE_P (x))
>&& !DEBUG_INSN_P (insn))
>  reg_pending_barrier = TRUE_BARRIER;
>...

This code was added in 1997 (r14770).  In 2004 the documentation was
changed to clarify how things really work (r88999):

"Note that even a volatile @code{asm} instruction can be moved relative to
other code, including across jump instructions."

(followed by an example exactly about what this means for FPU control).

> I understand that mentioned “changing fpu rounding mode” example may
> not be relevant in current compiler.  But we still got TRUE_BARRIER
> for all volatile asms.

> > > Maybe it is a good idea somehow re-implement modulo scheduler using only
> > > one scanner instead of two, but at the moment the best thing to do is to
> > > detect the situation earlier and skip such loops.
> >
> > Or fix the broken code...
> 
> I’m not sure what you mean here,

I mean have the modulo scheduler implement the correct asm semantics, not
some more restrictive thing that gets it into conflicts with DF, etc.

I don't think this will turn out to be a problem in any way.  Some invalid
asm will break, sure.


Segher


Re: [Patch] [Aarch64] PR rtl-optimization/87763 - this patch fixes gcc.target/aarch64/lsl_asr_sbfiz.c

2019-04-23 Thread Jeff Law
On 4/16/19 10:29 AM, Steve Ellcey wrote:
> Re-ping.  I know there are discussions about bigger changes to fix the
> various failures listed in PR rtl-optimization/87763 but this patch
> at least fixes one of them (gcc.target/aarch64/lsl_asr_sbfiz.c).
So we actually call simplify_set with:

(set (reg:SI 93)
(ashiftrt:SI (ashift:SI (reg:SI 95)
(const_int 29 [0x1d]))
(const_int 10 [0xa])))

Then we expand that via make_compound_operation into:

(set (reg:SI 93)
(ashift:SI (subreg:SI (sign_extract:DI (subreg:DI (reg:SI 95) 0)
(const_int 3 [0x3])
(const_int 0 [0])) 0)
(const_int 19 [0x13])))


This is almost certainly related to the target preferring DImode for its
insertion/extraction insns.  See get_best_extraction_insn.

Still investigating...

jeff



[PATCH, PR d/90079] Committed fix SEGV in _aaKeys, _aaValues on 32-bit SPARC

2019-04-23 Thread Iain Buclaw
Hi,

This patch merges the libdruntime sub-library with upstream druntime
b43203a1, fixing PR d/90079.

Bootstrapped and regression tested on x86_64-linux-gnu and committed
to trunk as r270514.

-- 
Iain
---
diff --git a/libphobos/libdruntime/MERGE b/libphobos/libdruntime/MERGE
index 8a3790142cf..27dfc5fc1d9 100644
--- a/libphobos/libdruntime/MERGE
+++ b/libphobos/libdruntime/MERGE
@@ -1,4 +1,4 @@
-109f0f2e11aaaddd2b158117928e10c3c4688870
+b43203a134fb5e259ffc1711cc061c6e869b56f6
 
 The first line of this file holds the git revision number of the last
 merge done from the dlang/druntime repository.
diff --git a/libphobos/libdruntime/object.d b/libphobos/libdruntime/object.d
index 38bd0ae1f6b..d7588dccbed 100644
--- a/libphobos/libdruntime/object.d
+++ b/libphobos/libdruntime/object.d
@@ -661,12 +661,12 @@ class TypeInfo_AssociativeArray : TypeInfo
 
 override bool equals(in void* p1, in void* p2) @trusted const
 {
-return !!_aaEqual(this, *cast(const void**) p1, *cast(const void**) p2);
+return !!_aaEqual(this, *cast(const AA*) p1, *cast(const AA*) p2);
 }
 
 override hash_t getHash(scope const void* p) nothrow @trusted const
 {
-return _aaGetHash(cast(void*)p, this);
+return _aaGetHash(cast(AA*)p, this);
 }
 
 // BUG: need to add the rest of the functions
@@ -1862,30 +1862,31 @@ extern (C)
 {
 // from druntime/src/rt/aaA.d
 
-// size_t _aaLen(in void* p) pure nothrow @nogc;
-private void* _aaGetY(void** paa, const TypeInfo_AssociativeArray ti, in size_t valuesize, in void* pkey) pure nothrow;
-private void* _aaGetX(void** paa, const TypeInfo_AssociativeArray ti, in size_t valuesize, in void* pkey, out bool found) pure nothrow;
-// inout(void)* _aaGetRvalueX(inout void* p, in TypeInfo keyti, in size_t valuesize, in void* pkey);
-inout(void)[] _aaValues(inout void* p, in size_t keysize, in size_t valuesize, const TypeInfo tiValArray) pure nothrow;
-inout(void)[] _aaKeys(inout void* p, in size_t keysize, const TypeInfo tiKeyArray) pure nothrow;
-void* _aaRehash(void** pp, in TypeInfo keyti) pure nothrow;
-void _aaClear(void* p) pure nothrow;
+private struct AA { void* impl; }
+// size_t _aaLen(in AA aa) pure nothrow @nogc;
+private void* _aaGetY(AA* paa, const TypeInfo_AssociativeArray ti, in size_t valsz, in void* pkey) pure nothrow;
+private void* _aaGetX(AA* paa, const TypeInfo_AssociativeArray ti, in size_t valsz, in void* pkey, out bool found) pure nothrow;
+// inout(void)* _aaGetRvalueX(inout AA aa, in TypeInfo keyti, in size_t valsz, in void* pkey);
+inout(void[]) _aaValues(inout AA aa, in size_t keysz, in size_t valsz, const TypeInfo tiValueArray) pure nothrow;
+inout(void[]) _aaKeys(inout AA aa, in size_t keysz, const TypeInfo tiKeyArray) pure nothrow;
+void* _aaRehash(AA* paa, in TypeInfo keyti) pure nothrow;
+void _aaClear(AA aa) pure nothrow;
 
 // alias _dg_t = extern(D) int delegate(void*);
-// int _aaApply(void* aa, size_t keysize, _dg_t dg);
+// int _aaApply(AA aa, size_t keysize, _dg_t dg);
 
 // alias _dg2_t = extern(D) int delegate(void*, void*);
-// int _aaApply2(void* aa, size_t keysize, _dg2_t dg);
+// int _aaApply2(AA aa, size_t keysize, _dg2_t dg);
 
-private struct AARange { void* impl; size_t idx; }
-AARange _aaRange(void* aa) pure nothrow @nogc @safe;
+private struct AARange { AA impl; size_t idx; }
+AARange _aaRange(AA aa) pure nothrow @nogc @safe;
 bool _aaRangeEmpty(AARange r) pure nothrow @nogc @safe;
 void* _aaRangeFrontKey(AARange r) pure nothrow @nogc @safe;
 void* _aaRangeFrontValue(AARange r) pure nothrow @nogc @safe;
 void _aaRangePopFront(ref AARange r) pure nothrow @nogc @safe;
 
-int _aaEqual(in TypeInfo tiRaw, in void* e1, in void* e2);
-hash_t _aaGetHash(in void* aa, in TypeInfo tiRaw) nothrow;
+int _aaEqual(in TypeInfo tiRaw, in AA aa1, in AA aa2);
+hash_t _aaGetHash(in AA* aa, in TypeInfo tiRaw) nothrow;
 
 /*
 _d_assocarrayliteralTX marked as pure, because aaLiteral can be called from pure code.
@@ -1910,13 +1911,13 @@ alias AssociativeArray(Key, Value) = Value[Key];
  */
 void clear(T : Value[Key], Value, Key)(T aa)
 {
-_aaClear(*cast(void **) );
+_aaClear(*cast(AA *) );
 }
 
 /* ditto */
 void clear(T : Value[Key], Value, Key)(T* aa)
 {
-_aaClear(*cast(void **) aa);
+_aaClear(*cast(AA *) aa);
 }
 
 /***
@@ -1929,28 +1930,28 @@ void clear(T : Value[Key], Value, Key)(T* aa)
  */
 T rehash(T : Value[Key], Value, Key)(T aa)
 {
-_aaRehash(cast(void**), typeid(Value[Key]));
+_aaRehash(cast(AA*), typeid(Value[Key]));
 return aa;
 }
 
 /* ditto */
 T rehash(T : Value[Key], Value, Key)(T* aa)
 {
-_aaRehash(cast(void**)aa, typeid(Value[Key]));
+_aaRehash(cast(AA*)aa, typeid(Value[Key]));
 return *aa;
 }
 
 /* ditto */
 T rehash(T : shared Value[Key], Value, Key)(T aa)
 {
-

[C++ Patch] PR 90173 ("[9 Regression] ICE: Segmentation fault (in strip_declarator_types)")

2019-04-23 Thread Paolo Carlini

Hi,

I tried a few different things to avoid this simple error-recovery 
regression but, all in all, I think it makes sense to simply bail out 
early from grokdeclarator upon the first error. Tested x86_64-linux.


Thanks, Paolo.

///

/cp
2019-04-23  Paolo Carlini  

PR c++/90173
* decl.c (grokdeclarator): Early return error_mark_node
upon error about template placeholder type non followed
by a simple declarator-id.

/testsuite
2019-04-23  Paolo Carlini  

PR c++/90173
* g++.dg/cpp1z/class-deduction66.C: New.
Index: cp/decl.c
===
--- cp/decl.c   (revision 270500)
+++ cp/decl.c   (working copy)
@@ -10973,6 +10973,7 @@ grokdeclarator (const cp_declarator *declarator,
   error_at (typespec_loc, "template placeholder type %qT must be followed "
"by a simple declarator-id", type);
   inform (DECL_SOURCE_LOCATION (tmpl), "%qD declared here", tmpl);
+  return error_mark_node;
 }
 
   staticp = 0;
Index: testsuite/g++.dg/cpp1z/class-deduction66.C
===
--- testsuite/g++.dg/cpp1z/class-deduction66.C  (nonexistent)
+++ testsuite/g++.dg/cpp1z/class-deduction66.C  (working copy)
@@ -0,0 +1,10 @@
+// PR c++/90173
+// { dg-do run { target c++17 } }
+
+template  struct A { };
+
+A(int) -> A;
+
+namespace decl {
+  A (*fp)() = 0;  // { dg-error "placeholder" }
+}


Re: [Patch] [Aarch64] PR rtl-optimization/87763 - this patch fixes gcc.target/aarch64/lsl_asr_sbfiz.c

2019-04-23 Thread Jeff Law
On 4/16/19 10:29 AM, Steve Ellcey wrote:
> Re-ping.  I know there are discussions about bigger changes to fix the
> various failures listed in PR rtl-optimization/87763 but this patch
> at least fixes one of them (gcc.target/aarch64/lsl_asr_sbfiz.c).
So one thing to ponder here is whether or not combine should be handling
the subregs better.  A year or so ago I improved make_field_assignment
to handle some cases where subregs were appearing.  It may be the case
that we just need further refinements to subreg handling.

At some point we call combine_simplify_rtx with:

(set (reg:SI 93)
(ashift:SI (subreg:SI (sign_extract:DI (subreg:DI (reg:SI 95) 0)
(const_int 3 [0x3])
(const_int 0 [0])) 0)
(const_int 19 [0x13])))

The subregs are obviously inconvenient.  More importantly, I think
they're redundant.  I think that's equivalent to:

(set (reg:SI 93)
(ashift:SI (sign_extract:SI (reg:SI 95)
(const_int 3 [0x3])
(const_int 0 [0]))
(const_int 19 [0x13])))


At which point I think it'd match the existing pattern in aarch64.md

Thoughts?

jeff


[committed] Mark cr16 as keeping null pointer checks in target-supports.exp

2019-04-23 Thread Jeff Law

My tester showed a spurious regression with a recent patch on cr16.  In
reviewing the logs I saw unexpected results for the proposed changes to
isolate-2.c and isolate-4.c.

The cr16 turns off NULL pointer check elimination, but isn't listed as
doing so in target-supports.exp.  As a result we run the tests, but they
fail.

This patch adds cr16 to the list of targets that keep null pointer
checks and those tests are now skipped.

I'm installing this on the trunk momentarily.

Jeff
* lib/target-supports.exp
(check_effective_target_keeps_null_pointer_checks): Add cr16.

diff --git a/gcc/testsuite/lib/target-supports.exp 
b/gcc/testsuite/lib/target-supports.exp
index 0dc1e184f55..4bb7da283f1 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -559,7 +559,7 @@ proc check_effective_target_keeps_null_pointer_checks { } {
 if [target_info exists keeps_null_pointer_checks] {
   return 1
 }
-if { [istarget msp430-*-*] } {
+if { [istarget msp430-*-*] || [istarget cr16-*-*] } {
return 1;   
 }
 return 0


[RFA][tree-optimization/90037] Cleanup const/copies between DOM and erroneous path isolation

2019-04-23 Thread Jeff Law

As discussed in the BZ, this patch addresses the false positive warning
by cleaning up the const/copy propagations left in the IL between DOM's
jump threading and erroneous path isolation.

In the past we'd been handling this stuff with phi only cprop.  To make
phi only cprop work in this case we'd have to change it to scan
statements within some subset of blocks where it had previously only
scanned PHIs.

I was concerned about the compile-time cost of the additional scanning
plus the extra pass.  So I compared that against using the lattice based
const/copy propagation as well as against the RPO VN bits.

It turns out that the lattice based const/copy propagation does the
least amount of work, closely followed by a limited RPO VN.  The
improved "phi only" copy propagator being the worst.

Given that we can use the lattice copy propagator by just adding the
pass to passes.def whereas using the RPN VN actually requires a little
bit of real code (to set up the entry/exits for the relevant SEME
regions), I went with the lattice copy propagator.

This change adds around .4% instruction executions to my testbed of .i
files.  It has no significant impact on the resulting code -- I see
different register allocation decisions in a lot of places which seem to
primarily result in reversing arguments to comparisons.

FWIW I also considered delaying the erroneous path isolation pass.  I
ultimately decided against that.  My recollection is that its location
came from the desire to clean up those paths early enough in the
pipeline so that other optimizers could do a better job.

We could consider an early/late split here.  Essentially we do the
optimization early, leaving enough data lying around somewhere for a
late pass to look for and issue the warning.  Something like a
__builtin_warning that we leave in the IL, then just before expanding to
RTL, we scan the IL once and issue the __builtin_warnings.

In this specific case the __builtin_warning would be on a path that we
eventually would determine was unreachable at compile time and the path
would be removed.  I suspect we could do something similar for other
warnings coming out of the middle end.

Anyway, this has been bootstrapped and regression tested on x86_64,
ppc64, i686, sparc64, & ppc64le.  It's also been bootstrapped on alpha,
ppc (32 bit), armeb, m68k, riscv64, mipsisa32r4, arm, sh4, & sh4eb.
It's also built and regression tested all the *-elf targets in my tester.

OK for the trunk, or do we want to defer to gcc-10?

Jeff



diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index d186d71c91e..5f43d9de00e 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -1559,7 +1559,6 @@ OBJS = \
tree-ssa-loop.o \
tree-ssa-math-opts.o \
tree-ssa-operands.o \
-   tree-ssa-phionlycprop.o \
tree-ssa-phiopt.o \
tree-ssa-phiprop.o \
tree-ssa-pre.o \
diff --git a/gcc/passes.def b/gcc/passes.def
index 446a7c48276..2f01a2dd72b 100644
--- a/gcc/passes.def
+++ b/gcc/passes.def
@@ -222,19 +222,16 @@ along with GCC; see the file COPYING3.  If not see
 trying to move or duplicate pass_dominator somewhere earlier.  */
   NEXT_PASS (pass_thread_jumps);
   NEXT_PASS (pass_dominator, true /* may_peel_loop_headers_p */);
-  /* At this point the majority of const/copy propagations
-are exposed.  Go ahead and identify paths that should never
-be executed in a conforming program and isolate those paths.
-
-This will expose more degenerate PHIs in the main path and
-expose more PRE/DOM optimization opportunities.  */
+  /* Threading can leave many const/copy propagations in the IL.
+Clean them up.  Failure to do so well can lead to false
+positives from warnings for erroneous code.  */
+  NEXT_PASS (pass_copy_prop);
+  /* Identify paths that should never be executed in a conforming
+program and isolate those paths.  */
   NEXT_PASS (pass_isolate_erroneous_paths);
-  /* The only const/copy propagation opportunities left after
-DOM and erroneous path isolation should be due to degenerate PHI nodes.
-So rather than run the full propagators, run a specialized pass which
-only examines PHIs to discover const/copy propagation
-opportunities.  */
-  NEXT_PASS (pass_phi_only_cprop);
+  /* Path isolation can leave many const/copy propagations in the IL.
+Clean them up.  */
+  NEXT_PASS (pass_copy_prop);
   NEXT_PASS (pass_dse);
   NEXT_PASS (pass_reassoc, true /* insert_powi_p */);
   NEXT_PASS (pass_dce);
@@ -321,13 +318,10 @@ along with GCC; see the file COPYING3.  If not see
   NEXT_PASS (pass_strlen);
   NEXT_PASS (pass_thread_jumps);
   NEXT_PASS (pass_vrp, false /* warn_array_bounds_p */);
-  /* The only const/copy propagation opportunities left after
-DOM and VRP should be due to degenerate PHI nodes.  So rather than
-run the full propagators, run a 

[PATCH] Implement correct std::variant triviality rules from P0602R4

2019-04-23 Thread Jonathan Wakely

The std::variant move assignment operator should not be trivial if the
variant is not trivially move constructible.

* include/std/variant (__detail::__variant::_Traits): Make
_S_trivial_copy_assign depend on _S_trivial_copy_ctor and make
_S_trivial_move_assign depend on _S_trivial_move_ctor, as per
P0602R4.
(__detail::__variant::_Copy_assign_alias): Only depend on
_S_trivial_copy_assign, which subsumes _S_trivial_copy_ctor now.
* testsuite/20_util/variant/compile.cc: Correct checks for trivial
move assignment operators.

Tested powerpc64le-linux, committed to trunk.


commit be9abfb0cf0ccb183fde175762778409d901f708
Author: Jonathan Wakely 
Date:   Tue Apr 23 13:31:24 2019 +0100

Implement correct std::variant triviality rules from P0602R4

The std::variant move assignment operator should not be trivial if the
variant is not trivially move constructible.

* include/std/variant (__detail::__variant::_Traits): Make
_S_trivial_copy_assign depend on _S_trivial_copy_ctor and make
_S_trivial_move_assign depend on _S_trivial_move_ctor, as per
P0602R4.
(__detail::__variant::_Copy_assign_alias): Only depend on
_S_trivial_copy_assign, which subsumes _S_trivial_copy_ctor now.
* testsuite/20_util/variant/compile.cc: Correct checks for trivial
move assignment operators.

diff --git a/libstdc++-v3/include/std/variant b/libstdc++-v3/include/std/variant
index d65084eeb1f..0c9f8a39c5c 100644
--- a/libstdc++-v3/include/std/variant
+++ b/libstdc++-v3/include/std/variant
@@ -289,9 +289,11 @@ namespace __variant
   static constexpr bool _S_trivial_move_ctor =
  (is_trivially_move_constructible_v<_Types> && ...);
   static constexpr bool _S_trivial_copy_assign =
- _S_trivial_dtor && (is_trivially_copy_assignable_v<_Types> && ...);
+ _S_trivial_dtor && _S_trivial_copy_ctor
+ && (is_trivially_copy_assignable_v<_Types> && ...);
   static constexpr bool _S_trivial_move_assign =
- _S_trivial_dtor && (is_trivially_move_assignable_v<_Types> && ...);
+ _S_trivial_dtor && _S_trivial_move_ctor
+ && (is_trivially_move_assignable_v<_Types> && ...);
 
   // The following nothrow traits are for non-trivial SMFs. Trivial SMFs
   // are always nothrow.
@@ -303,7 +305,8 @@ namespace __variant
  (is_nothrow_move_constructible_v<_Types> && ...);
   static constexpr bool _S_nothrow_copy_assign = false;
   static constexpr bool _S_nothrow_move_assign =
- _S_nothrow_move_ctor && (is_nothrow_move_assignable_v<_Types> && ...);
+ _S_nothrow_move_ctor
+ && (is_nothrow_move_assignable_v<_Types> && ...);
 };
 
   // Defines members and ctors.
@@ -654,9 +657,7 @@ namespace __variant
 
   template
 using _Copy_assign_alias =
-   _Copy_assign_base<_Traits<_Types...>::_S_trivial_copy_assign
- && _Traits<_Types...>::_S_trivial_copy_ctor,
- _Types...>;
+  _Copy_assign_base<_Traits<_Types...>::_S_trivial_copy_assign, _Types...>;
 
   template
 struct _Move_assign_base : _Copy_assign_alias<_Types...>
diff --git a/libstdc++-v3/testsuite/20_util/variant/compile.cc 
b/libstdc++-v3/testsuite/20_util/variant/compile.cc
index 6acf5bc627e..c6b18d08258 100644
--- a/libstdc++-v3/testsuite/20_util/variant/compile.cc
+++ b/libstdc++-v3/testsuite/20_util/variant/compile.cc
@@ -522,17 +522,17 @@ void test_triviality()
   TEST_TEMPLATE(=default, =default, =default, =default, ,  true,  
true,  true, false)
   TEST_TEMPLATE(=default, =default, =default, , =default,  true,  
true, false,  true)
   TEST_TEMPLATE(=default, =default, =default, , ,  true,  
true, false, false)
-  TEST_TEMPLATE(=default, =default, , =default, =default,  true, 
false,  true,  true)
+  TEST_TEMPLATE(=default, =default, , =default, =default,  true, 
false,  true, false)
   TEST_TEMPLATE(=default, =default, , =default, ,  true, 
false,  true, false)
-  TEST_TEMPLATE(=default, =default, , , =default,  true, 
false, false,  true)
+  TEST_TEMPLATE(=default, =default, , , =default,  true, 
false, false, false)
   TEST_TEMPLATE(=default, =default, , , ,  true, 
false, false, false)
-  TEST_TEMPLATE(=default, , =default, =default, =default, false,  
true,  false,  true)
-  TEST_TEMPLATE(=default, , =default, =default, , false,  
true,  false, false)
+  TEST_TEMPLATE(=default, , =default, =default, =default, false,  
true, false,  true)
+  TEST_TEMPLATE(=default, , =default, =default, , false,  
true, false, false)
   TEST_TEMPLATE(=default, , =default, , =default, false,  
true, false,  true)
   TEST_TEMPLATE(=default, , =default, , , false,  

[PATCH] PR libstdc++/90165 constrain variant(T&&) constructor

2019-04-23 Thread Jonathan Wakely

Also refactor some constraints slightly to be more readable.

PR libstdc++/90165
* include/std/variant (variant::__not_self): New helper for the
is_same_v, variant>==false constraints.
(variant::__to_type_impl): Remove.
(variant::__to_type): Add default argument to check pack size, instead
of using __to_type_impl.
(variant::__accepted_type): Add default argument using __not_self.
(variant::__is_in_place_tag, variant::__not_in_place_tag): New helpers
for variant(T&&) constructor constraint.
(variant::variant(T&&)): Use __not_in_place_tag in constraints.
Extract __accepted_type into a named template parameter for reuse in
other constraints and in the exception specification.
(variant::variant(in_place_type_t, Args&&...))
(variant::variant(in_place_type_t, initializer_list, Args&&...))
(variant::variant(in_place_index_t, Args&&...))
(variant::variant(in_place_index_t, initializer_list, Args&&...))
(variant::operator=T&&)): Remove redundant && from trait arguments.
* testsuite/20_util/variant/compile.cc: Check variant(T&&) constructor
isn't used for in_place_type or in_place_index arguments.

Tested powerpc64le-linux, committed to trunk.

I'll consider a simpler version of this for gcc-8-branch, that just
applies the __not_in_place_tag constraint to the variant(T&&) ctor.

commit db75c3d6a787c315ed79ace15ef60206719b6420
Author: Jonathan Wakely 
Date:   Tue Apr 23 12:24:05 2019 +0100

PR libstdc++/90165 constrain variant(T&&) constructor

Also refactor some constraints slightly to be more readable.

PR libstdc++/90165
* include/std/variant (variant::__not_self): New helper for the
is_same_v, variant>==false constraints.
(variant::__to_type_impl): Remove.
(variant::__to_type): Add default argument to check pack size, 
instead
of using __to_type_impl.
(variant::__accepted_type): Add default argument using __not_self.
(variant::__is_in_place_tag, variant::__not_in_place_tag): New 
helpers
for variant(T&&) constructor constraint.
(variant::variant(T&&)): Use __not_in_place_tag in constraints.
Extract __accepted_type into a named template parameter for reuse in
other constraints and in the exception specification.
(variant::variant(in_place_type_t, Args&&...))
(variant::variant(in_place_type_t, initializer_list, 
Args&&...))
(variant::variant(in_place_index_t, Args&&...))
(variant::variant(in_place_index_t, initializer_list, 
Args&&...))
(variant::operator=T&&)): Remove redundant && from trait arguments.
* testsuite/20_util/variant/compile.cc: Check variant(T&&) 
constructor
isn't used for in_place_type or in_place_index arguments.

diff --git a/libstdc++-v3/include/std/variant b/libstdc++-v3/include/std/variant
index b71bb027f2b..d65084eeb1f 100644
--- a/libstdc++-v3/include/std/variant
+++ b/libstdc++-v3/include/std/variant
@@ -1284,6 +1284,10 @@ namespace __variant
  __detail::__variant::_Traits<_Types...>::_S_default_ctor,
variant<_Types...>>;
 
+  template
+   static constexpr bool __not_self
+ = !is_same_v<__remove_cvref_t<_Tp>, variant>;
+
   template
static constexpr bool
__exactly_once = __detail::__variant::__exactly_once<_Tp, _Types...>;
@@ -1292,17 +1296,10 @@ namespace __variant
static constexpr size_t __accepted_index =
  __detail::__variant::__accepted_index<_Tp&&, variant>::value;
 
-  template
-   struct __to_type_impl;
+  template>
+   using __to_type = variant_alternative_t<_Np, variant>;
 
-  template
-   struct __to_type_impl<_Np, true>
-   { using type = variant_alternative_t<_Np, variant>; };
-
-  template
-   using __to_type = typename __to_type_impl<_Np>::type;
-
-  template
+  template>>
using __accepted_type = __to_type<__accepted_index<_Tp>>;
 
   template
@@ -1311,6 +1308,17 @@ namespace __variant
 
   using _Traits = __detail::__variant::_Traits<_Types...>;
 
+  template
+   struct __is_in_place_tag : false_type { };
+  template
+   struct __is_in_place_tag> : true_type { };
+  template
+   struct __is_in_place_tag> : true_type { };
+
+  template
+   static constexpr bool __not_in_place_tag
+ = !__is_in_place_tag<__remove_cvref_t<_Tp>>::value;
+
 public:
   variant() = default;
   variant(const variant& __rhs) = default;
@@ -1320,20 +1328,21 @@ namespace __variant
   ~variant() = default;
 
   template, variant>>,
-  typename = enable_if_t<(sizeof...(_Types)>0)>,
-  typename = enable_if_t<__exactly_once<__accepted_type<_Tp&&>>
- && 

[PATCH] Corrections for C++2a std::unwrap_reference traits

2019-04-23 Thread Jonathan Wakely

The P0318R1 paper added to the C++2a draft recently was not the latest
version of the paper, and should have included these changes. These
changes will be made to the working draft via a Defect Report, so I'm
applying them to libstdc++ now.

* include/std/type_traits (unwrap_reference_t): Define for C++2a.
(unwrap_ref_decay): Remove inheritance from unwrap_reference.
* testsuite/20_util/unwrap_reference/1.cc: Adjust test to use alias.

Tested powerpc64le-linux, committed to trunk.


commit 9e09c9a4b99b3be725144aeaebe902783a9e70a3
Author: Jonathan Wakely 
Date:   Tue Apr 23 10:58:22 2019 +0100

Corrections for C++2a std::unwrap_reference traits

The P0318R1 paper added to the C++2a draft recently was not the latest
version of the paper, and should have included these changes. These
changes will be made to the working draft via a Defect Report, so I'm
applying them to libstdc++ now.

* include/std/type_traits (unwrap_reference_t): Define for C++2a.
(unwrap_ref_decay): Remove inheritance from unwrap_reference.
* testsuite/20_util/unwrap_reference/1.cc: Adjust test to use alias.

diff --git a/libstdc++-v3/include/std/type_traits 
b/libstdc++-v3/include/std/type_traits
index c3cb67a457d..e0ac5c88dfc 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -3067,9 +3067,12 @@ template 
   template
 struct unwrap_reference> { using type = _Tp&; };
 
+  template
+using unwrap_reference_t = typename unwrap_reference<_Tp>::type;
+
   /// Decay type and if it's a reference_wrapper, unwrap it
   template
-struct unwrap_ref_decay : unwrap_reference> { };
+struct unwrap_ref_decay { using type = unwrap_reference_t>; };
 
   template
 using unwrap_ref_decay_t = typename unwrap_ref_decay<_Tp>::type;
diff --git a/libstdc++-v3/testsuite/20_util/unwrap_reference/1.cc 
b/libstdc++-v3/testsuite/20_util/unwrap_reference/1.cc
index 38feca4bb5b..243526725a0 100644
--- a/libstdc++-v3/testsuite/20_util/unwrap_reference/1.cc
+++ b/libstdc++-v3/testsuite/20_util/unwrap_reference/1.cc
@@ -28,7 +28,7 @@ template
   {
 using std::unwrap_reference;
 using T2 = typename unwrap_reference::type;
-static_assert(expect_same::type>::value);
+static_assert(expect_same>::value);
 return expect_same::value;
   }
 


Re: [PATCH] Fix ARM exception handling (PR target/89093)

2019-04-23 Thread Jakub Jelinek
On Tue, Apr 23, 2019 at 09:17:50AM +0100, Ramana Radhakrishnan wrote:
> > Ok for trunk?
> 
> Ok. Thanks a lot for working on this and fixing the rest of this up.
> I've been busy with a few other things.

Thanks.  Based on this and Iain and Jonathan's acks, I've committed
the patch except for the 

> > 2019-04-22  Ramana Radhakrishnan  
> > Bernd Edlinger  
> > Jakub Jelinek  
> >
> > PR target/89093
> > gcc/ada/
> > * raise-gcc.c (TARGET_ATTRIBUTE): Define.
> > (continue_unwind, personality_body, PERSONALITY_FUNCTION): Add
> > TARGET_ATTRIBUTE.
> > libgo/
> > * runtime/go-unwind.c (PERSONALITY_FUNCTION,
> > __gccgo_personality_dummy): Add general-regs-only target
> > attribute for ARM.

parts, where for gcc/ada/ I'm waiting for an Ada maintainer review (CCed all
maintainers now) and for libgo I think this needs to be fixed upstream and
also dealt with non-gcc compilers or gcc 8.x and earlier.

Jakub


Re: [PATCH][stage1] Enhance target and target_clone error messages.

2019-04-23 Thread Martin Liška
On 4/19/19 2:28 AM, Martin Sebor wrote:
> On 4/18/19 5:09 AM, Martin Liška wrote:
>> Hi.
>>
>> The patch distinguishes among target and target_clone attribute when
>> reporting for an error. I've also reworded the affected error messages
>> a bit.
>>
>> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
>>
>> Ready to be installed after stage1 opens?
>> Thanks,
>> Martin
>>
>> ---
>>   gcc/cgraphclones.c |  2 +-
>>   gcc/config/i386/i386-c.c   |  5 +-
>>   gcc/config/i386/i386-protos.h  |  4 +-
>>   gcc/config/i386/i386.c | 54 +-
>>   gcc/testsuite/gcc.target/i386/funcspec-4.c |  2 +-
>>   5 files changed, 39 insertions(+), 28 deletions(-)
> 
> Just a suggestion to also consider making the phrasing in the messages
> consistent by adding "is" below
> 
> @@ -5316,7 +5322,7 @@ ix86_valid_target_attribute_inner_p (tree args, char 
> *p_strings[],
> 
>    else if (TREE_CODE (args) != STRING_CST)
>  {
> -  error ("attribute % argument not a string");
> +  error_at (loc, "attribute %qs argument not a string", attr_name);
>    return false;
> 
> i.e., "is not a string" and changing the below
> 
> @@ -5382,7 +5386,8 @@ ix86_valid_target_attribute_inner_p (tree args, char 
> *p_strings[],
>    /* Process the option.  */
>    if (opt == N_OPTS)
>  {
> -  error ("attribute(target(\"%s\")) is unknown", orig_p);
> +  error_at (loc, "attribute value %qs is unknown in %qs attribute",
> +    orig_p, attr_name);
> 
> to
> 
>   error_at (loc, "attribute %qs argument %qs is unknown",
>     attr_name, orig_p);
> 
> Martin

Thank you Martin. I'm sending updated patch.

Martin
>From 2778f9ab4f1cd091780694e8cc1335d6125d95ec Mon Sep 17 00:00:00 2001
From: marxin 
Date: Wed, 17 Apr 2019 13:59:14 +0200
Subject: [PATCH] Enhance target and target_clone error messages.

gcc/ChangeLog:

2019-04-18  Martin Liska  

	* cgraphclones.c: Call valid_attribute_p with 1 for
	target_clone.
	* config/i386/i386-c.c (ix86_pragma_target_parse): Use 0 as
	it's for target attribute.
	* config/i386/i386-protos.h (ix86_valid_target_attribute_tree):
	Add new boolean argument.
	* config/i386/i386.c (ix86_valid_target_attribute_inner_p):
	Likewise.
	(ix86_valid_target_attribute_tree): Pass target_clone_attr
	to ix86_valid_target_attribute_inner_p.
	(ix86_valid_target_attribute_p): Pass flags argument to
	ix86_valid_target_attribute_inner_p.
	(get_builtin_code_for_version): Use 0 as it's target attribute.

gcc/testsuite/ChangeLog:

2019-04-18  Martin Liska  

	* gcc.target/i386/funcspec-4.c: Update scanned pattern.
	* g++.target/i386/pr57362.C: Likewise.
---
 gcc/cgraphclones.c |  2 +-
 gcc/config/i386/i386-c.c   |  5 +-
 gcc/config/i386/i386-protos.h  |  4 +-
 gcc/config/i386/i386.c | 56 +-
 gcc/testsuite/g++.target/i386/pr57362.C|  2 +-
 gcc/testsuite/gcc.target/i386/funcspec-4.c |  2 +-
 6 files changed, 42 insertions(+), 29 deletions(-)

diff --git a/gcc/cgraphclones.c b/gcc/cgraphclones.c
index 15f7e119d18..fd867ecac91 100644
--- a/gcc/cgraphclones.c
+++ b/gcc/cgraphclones.c
@@ -1056,7 +1056,7 @@ cgraph_node::create_version_clone_with_body
   location_t saved_loc = input_location;
   tree v = TREE_VALUE (target_attributes);
   input_location = DECL_SOURCE_LOCATION (new_decl);
-  bool r = targetm.target_option.valid_attribute_p (new_decl, NULL, v, 0);
+  bool r = targetm.target_option.valid_attribute_p (new_decl, NULL, v, 1);
   input_location = saved_loc;
   if (!r)
 	return NULL;
diff --git a/gcc/config/i386/i386-c.c b/gcc/config/i386/i386-c.c
index 5e7e46fcebe..50cac3b1a9f 100644
--- a/gcc/config/i386/i386-c.c
+++ b/gcc/config/i386/i386-c.c
@@ -586,8 +586,9 @@ ix86_pragma_target_parse (tree args, tree pop_target)
 }
   else
 {
-  cur_tree = ix86_valid_target_attribute_tree (args, _options,
-		   _options_set);
+  cur_tree = ix86_valid_target_attribute_tree (NULL_TREE, args,
+		   _options,
+		   _options_set, 0);
   if (!cur_tree || cur_tree == error_mark_node)
{
  cl_target_option_restore (_options,
diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h
index 83645e89a81..cfc4783205e 100644
--- a/gcc/config/i386/i386-protos.h
+++ b/gcc/config/i386/i386-protos.h
@@ -215,9 +215,9 @@ extern unsigned int ix86_minimum_alignment (tree, machine_mode,
 extern tree ix86_handle_shared_attribute (tree *, tree, tree, int, bool *);
 extern tree ix86_handle_selectany_attribute (tree *, tree, tree, int, bool *);
 extern int x86_field_alignment (tree, int);
-extern tree ix86_valid_target_attribute_tree (tree,
+extern tree ix86_valid_target_attribute_tree (tree, tree,
 	  struct gcc_options *,
-	  struct gcc_options *);
+	  struct gcc_options *, bool);
 extern unsigned int ix86_get_callcvt 

[PATCH] Fix std::variant regression caused by never-valueless optimization

2019-04-23 Thread Jonathan Wakely

A regression was introduced by the recent changes to provide the strong
exception safety guarantee for "never valueless" types that have O(1),
non-throwing move assignment. The problematic code is:

 else if constexpr (__detail::__variant::_Never_valueless_alt())
   {
 // This construction might throw:
 variant __tmp(in_place_index<_Np>, __il,
   std::forward<_Args>(__args)...);
 // But _Never_valueless_alt means this won't:
 *this = std::move(__tmp);
   }

When the variant is not assignable, the assignment is ill-formed, so
should not be attempted. When the variant has a copy assignment operator
but not a move assignment operator, the assignment performs a copy
assignment and that could throw, so should not be attempted.

The solution is to only take that branch when the variant has a move
assignment operator, which is determined by the _Traits::_S_move_assign
constant. When that is false the strong exception safety guarantee is
not possible, and so the __never_valueless function should also depend
on _S_move_assign.

While testing the fixes for this I noticed that the partial
specialization _Never_valueless_alt> incorrectly
assumed that is_nothrow_move_constructible> is
always true, but that's wrong for fully-dynamic COW strings. Fix the
partial specialization, and improve the comment describing
_Never_valueless_alt to be clear it depends on move construction as well
as move assignment.

Finally, I also observed that _Variant_storage::_M_valid()
was not taking advantage of the __never_valueless() function to
avoid a runtime check. Only the _Variant_storage::_M_valid()
function was using __never_valueless. That is also fixed.

PR libstdc++/87431
* include/bits/basic_string.h (_Never_valueless_alt): Make partial
specialization also depend on is_nothrow_move_constructible.
* include/std/variant (__detail::__variant::__never_valueless()):
Only true if the variant would have a move assignment operator.
(__detail::__variant::_Variant_storage::_M_valid()):
Check __never_valueless().
(variant::emplace): Only perform non-throwing move assignments
for never-valueless alternatives if the variant has a move assignment
operator.
* testsuite/20_util/variant/compile.cc: Check that never-valueless
types can be emplaced into non-assignable variants.
* testsuite/20_util/variant/run.cc: Check that never-valueless types
don't get copied when emplaced into non-assignable variants.


Tested powerpc64le-linux, committed to trunk.


commit d97dc3efa90199d57c106942e7bf5ba122d963a9
Author: Jonathan Wakely 
Date:   Thu Apr 18 14:45:40 2019 +0100

Fix std::variant regression caused by never-valueless optimization

A regression was introduced by the recent changes to provide the strong
exception safety guarantee for "never valueless" types that have O(1),
non-throwing move assignment. The problematic code is:

  else if constexpr (__detail::__variant::_Never_valueless_alt())
{
  // This construction might throw:
  variant __tmp(in_place_index<_Np>, __il,
std::forward<_Args>(__args)...);
  // But _Never_valueless_alt means this won't:
  *this = std::move(__tmp);
}

When the variant is not assignable, the assignment is ill-formed, so
should not be attempted. When the variant has a copy assignment operator
but not a move assignment operator, the assignment performs a copy
assignment and that could throw, so should not be attempted.

The solution is to only take that branch when the variant has a move
assignment operator, which is determined by the _Traits::_S_move_assign
constant. When that is false the strong exception safety guarantee is
not possible, and so the __never_valueless function should also depend
on _S_move_assign.

While testing the fixes for this I noticed that the partial
specialization _Never_valueless_alt> incorrectly
assumed that is_nothrow_move_constructible> is
always true, but that's wrong for fully-dynamic COW strings. Fix the
partial specialization, and improve the comment describing
_Never_valueless_alt to be clear it depends on move construction as well
as move assignment.

Finally, I also observed that _Variant_storage::_M_valid()
was not taking advantage of the __never_valueless() function to
avoid a runtime check. Only the _Variant_storage::_M_valid()
function was using __never_valueless. That is also fixed.

PR libstdc++/87431
* include/bits/basic_string.h (_Never_valueless_alt): Make partial
specialization also depend on is_nothrow_move_constructible.
* include/std/variant (__detail::__variant::__never_valueless()):
Only true if the variant would have a move assignment operator.

[PATCH] Make some std::variant helper functions noexcept

2019-04-23 Thread Jonathan Wakely

It's a day with a Y in the name, so time for more std::variant fixes.

* include/std/variant (__detail::__variant::__ref_cast): Remove
unused function.
(__detail::__variant::_Uninitialized::_M_get)
(__detail::__variant::__get)
(__gen_vtable_impl::__element_by_index_or_cookie): Add noexcept.

Tested powerpc64le-linux, committed to trunk.


commit 3c5c5dadbc204d46b0ee61d1fb78cc498169c371
Author: Jonathan Wakely 
Date:   Thu Apr 18 14:03:57 2019 +0100

Make some std::variant helper functions noexcept

* include/std/variant (__detail::__variant::__ref_cast): Remove
unused function.
(__detail::__variant::_Uninitialized::_M_get)
(__detail::__variant::__get)
(__gen_vtable_impl::__element_by_index_or_cookie): Add noexcept.

diff --git a/libstdc++-v3/include/std/variant b/libstdc++-v3/include/std/variant
index e153363bbf3..08378eee816 100644
--- a/libstdc++-v3/include/std/variant
+++ b/libstdc++-v3/include/std/variant
@@ -203,16 +203,16 @@ namespace __variant
: _M_storage(std::forward<_Args>(__args)...)
{ }
 
-  constexpr const _Type& _M_get() const &
+  constexpr const _Type& _M_get() const & noexcept
   { return _M_storage; }
 
-  constexpr _Type& _M_get() &
+  constexpr _Type& _M_get() & noexcept
   { return _M_storage; }
 
-  constexpr const _Type&& _M_get() const &&
+  constexpr const _Type&& _M_get() const && noexcept
   { return std::move(_M_storage); }
 
-  constexpr _Type&& _M_get() &&
+  constexpr _Type&& _M_get() && noexcept
   { return std::move(_M_storage); }
 
   _Type _M_storage;
@@ -229,33 +229,29 @@ namespace __variant
_Type(std::forward<_Args>(__args)...);
}
 
-  const _Type& _M_get() const &
+  const _Type& _M_get() const & noexcept
   { return *_M_storage._M_ptr(); }
 
-  _Type& _M_get() &
+  _Type& _M_get() & noexcept
   { return *_M_storage._M_ptr(); }
 
-  const _Type&& _M_get() const &&
+  const _Type&& _M_get() const && noexcept
   { return std::move(*_M_storage._M_ptr()); }
 
-  _Type&& _M_get() &&
+  _Type&& _M_get() && noexcept
   { return std::move(*_M_storage._M_ptr()); }
 
   __gnu_cxx::__aligned_membuf<_Type> _M_storage;
 };
 
-  template
-_Ref __ref_cast(void* __ptr)
-{
-  return static_cast<_Ref>(*static_cast*>(__ptr));
-}
-
   template
-constexpr decltype(auto) __get(in_place_index_t<0>, _Union&& __u)
+constexpr decltype(auto)
+__get(in_place_index_t<0>, _Union&& __u) noexcept
 { return std::forward<_Union>(__u)._M_first._M_get(); }
 
   template
-constexpr decltype(auto) __get(in_place_index_t<_Np>, _Union&& __u)
+constexpr decltype(auto)
+__get(in_place_index_t<_Np>, _Union&& __u) noexcept
 {
   return __variant::__get(in_place_index<_Np-1>,
  std::forward<_Union>(__u)._M_rest);
@@ -263,7 +259,8 @@ namespace __variant
 
   // Returns the typed storage for __v.
   template
-constexpr decltype(auto) __get(_Variant&& __v)
+constexpr decltype(auto)
+__get(_Variant&& __v) noexcept
 {
   return __variant::__get(std::in_place_index<_Np>,
  std::forward<_Variant>(__v)._M_u);
@@ -981,7 +978,7 @@ namespace __variant
 
   template
static constexpr decltype(auto)
-   __element_by_index_or_cookie(_Variant&& __var)
+   __element_by_index_or_cookie(_Variant&& __var) noexcept
 {
  if constexpr (__index != variant_npos)
return __variant::__get<__index>(std::forward<_Variant>(__var));
@@ -1166,8 +1163,7 @@ namespace __variant
 
   template
 constexpr add_pointer_t
-get_if(const variant<_Types...>* __ptr)
-noexcept
+get_if(const variant<_Types...>* __ptr) noexcept
 {
   static_assert(__detail::__variant::__exactly_once<_Tp, _Types...>,
"T should occur for exactly once in alternatives");


Re: [PATCH] Fix ARM exception handling (PR target/89093)

2019-04-23 Thread Jonathan Wakely

On 22/04/19 11:14 +0200, Jakub Jelinek wrote:

Hi!

As detailed in the PR, unlike most other targets, on ARM EABI the floating
point registers are saved lazily, when EH personality routine calls
__gnu_unwind_frame (usually in the CONTINUE_UNWINDING macro).
That means the unwinder itself and the personality routines (and whatever
other functions those call in the path to CONTINUE_UNWINDING) must be
compiled so that it doesn't use floating point registers.  Calling some
function that saves those on entry and restores on exit is fine, but calling
some function which saves those on entry and then calls __gnu_unwind_frame
and then restores on exit is not fine.
In 8.x and earlier we were just lucky that the RA when compiling those
didn't decide to use any of those registers, but starting with the combiner
hard register changes we are no longer so lucky.

The following patch introduces -mgeneral-regs-only option and
general-regs-only target attribute for ARM (similarly to how other targets
like AArch64 and x86), changes the ARM unwinder to be compiled with that
and changes the personality routines of all languages so that either just
the personality routine, or whatever other routines called by personality
routines that call directly or indirectly __gnu_unwind_frame to be compiled
that way.

Bootstrapped/regtested on armv7hl-linux-gnueabi (and x86_64-linux to make
sure it compiles on other targets too).

Ok for trunk?


The libsupc++ part is OK.




Re: [PATCH v2] Add error message for target_clones and AVX512 ISAs (PR target/89929).

2019-04-23 Thread Martin Liška
On 4/18/19 7:44 PM, H.J. Lu wrote:
> On Thu, Apr 18, 2019 at 4:07 AM Martin Liška  wrote:
>>
>> Hi.
>>
>> I'm sending updated version of that patch. The patch rejects usage of AVX512 
>> ISAs (except AVX512F)
>> for target attribute for C++ multiversioning and for target_clone attribute.
>>
>> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
>>
>> Ready to be installed?
>> Thanks,
>> Martin
> 
> Your patch doesn't handle cmov nor gfni properly, which aren't AVX512.
> I prefer this patch.
> 

I like the patch. Thanks for working on that.

Martin




[PATCH v2] go: disable mvsx and maltivec for aix/ppc

2019-04-23 Thread CHIGOT, CLEMENT
Description: 
  * This patch removes -mvsx and -maltivec for go aix/ppc. 
     These options don't seem compatible with Go stack layout. 

Tests: 
  * AIX 7.2:  Configure/Build: SUCCESS

Changelog:
  * config/rs6000/aix71.h (SUBTARGET_OVERRIDE_OPTIONS): Remove OPTION_MASK_VSX 
     and OPTION_MASK_ALTIVEC from rs6000_isa_flags with Go on 32 bits. 
  * config/rs6000/aix72.h (SUBTARGET_OVERRIDE_OPTIONS): Likewise.



Clément Chigot
ATOS Bull SAS
1 rue de Provence - 38432 Échirolles - FranceIndex: config/rs6000/aix71.h
===
--- config/rs6000/aix71.h	(revision 270457)
+++ config/rs6000/aix71.h	(working copy)
@@ -56,6 +56,12 @@ do {	\
 {	\
   rs6000_current_cmodel = CMODEL_LARGE;\
 }	\
+  if (! strcmp (lang_hooks.name, "GNU Go")\
+  && TARGET_32BIT)			\
+{	\
+  /* aix/ppc doesn't support -mvsx and -maltivec with Go */	\
+  rs6000_isa_flags &= ~(OPTION_MASK_VSX | OPTION_MASK_ALTIVEC);	\
+}	\
 } while (0)
 
 #undef ASM_SPEC
Index: config/rs6000/aix72.h
===
--- config/rs6000/aix72.h	(revision 270457)
+++ config/rs6000/aix72.h	(working copy)
@@ -56,6 +56,12 @@ do {	\
 {	\
   rs6000_current_cmodel = CMODEL_LARGE;\
 }	\
+  if (! strcmp (lang_hooks.name, "GNU Go")\
+  && TARGET_32BIT)			\
+{	\
+  /* aix/ppc doesn't support -mvsx and -maltivec with Go */	\
+  rs6000_isa_flags &= ~(OPTION_MASK_VSX | OPTION_MASK_ALTIVEC);	\
+}	\
 } while (0)
 
 #undef ASM_SPEC


Add commentary to (SET_)TYPE_VECTOR_SUBPARTS

2019-04-23 Thread Richard Sandiford
This patch explains the encoding used for the precision field in
TYPE_VECTOR_SUBPARTS when NUM_POLY_INT_COEFFS == 2.  OK to install?

Richard


2019-04-19  Richard Sandiford  

gcc/
* tree.h (TYPE_VECTOR_SUBPARTS, SET_TYPE_VECTOR_SUBPARTS): Add
commentary about the encoding of precision.

Index: gcc/tree.h
===
--- gcc/tree.h  2019-04-23 09:21:46.206208219 +0100
+++ gcc/tree.h  2019-04-23 09:21:58.898166354 +0100
@@ -3734,6 +3734,8 @@ TYPE_VECTOR_SUBPARTS (const_tree node)
   unsigned int precision = VECTOR_TYPE_CHECK (node)->type_common.precision;
   if (NUM_POLY_INT_COEFFS == 2)
 {
+  /* See the corresponding code in SET_TYPE_VECTOR_SUBPARTS for a
+description of the encoding.  */
   poly_uint64 res = 0;
   res.coeffs[0] = HOST_WIDE_INT_1U << (precision & 0xff);
   if (precision & 0x100)
@@ -3756,6 +3758,21 @@ SET_TYPE_VECTOR_SUBPARTS (tree node, pol
   gcc_assert (index >= 0);
   if (NUM_POLY_INT_COEFFS == 2)
 {
+  /* We have two coefficients that are each in the range 1 << [0, 63],
+so supporting all combinations would require 6 bits per coefficient
+and 12 bits in total.  Since the precision field is only 10 bits
+in size, we need to be more restrictive than that.
+
+At present, coeff[1] is always either 0 (meaning that the number
+of units is constant) or equal to coeff[0] (meaning that the number
+of units is N + X * N for some target-dependent zero-based runtime
+parameter X).  We can therefore encode coeff[1] in a single bit.
+
+The most compact encoding would be to use mask 0x3f for coeff[0]
+and 0x40 for coeff[1], leaving 0x380 unused.  It's possible to
+get slightly more efficient code on some hosts if we instead
+treat the shift amount as an independent byte, so here we use
+0xff for coeff[0] and 0x100 for coeff[1].  */
   unsigned HOST_WIDE_INT coeff1 = subparts.coeffs[1];
   gcc_assert (coeff1 == 0 || coeff1 == coeff0);
   VECTOR_TYPE_CHECK (node)->type_common.precision


Re: [PATCH] Fix ARM exception handling (PR target/89093)

2019-04-23 Thread Ramana Radhakrishnan
On Mon, Apr 22, 2019 at 10:15 AM Jakub Jelinek  wrote:
>
> Hi!
>
> As detailed in the PR, unlike most other targets, on ARM EABI the floating
> point registers are saved lazily, when EH personality routine calls
> __gnu_unwind_frame (usually in the CONTINUE_UNWINDING macro).
> That means the unwinder itself and the personality routines (and whatever
> other functions those call in the path to CONTINUE_UNWINDING) must be
> compiled so that it doesn't use floating point registers.  Calling some
> function that saves those on entry and restores on exit is fine, but calling
> some function which saves those on entry and then calls __gnu_unwind_frame
> and then restores on exit is not fine.
> In 8.x and earlier we were just lucky that the RA when compiling those
> didn't decide to use any of those registers, but starting with the combiner
> hard register changes we are no longer so lucky.
>
> The following patch introduces -mgeneral-regs-only option and
> general-regs-only target attribute for ARM (similarly to how other targets
> like AArch64 and x86), changes the ARM unwinder to be compiled with that
> and changes the personality routines of all languages so that either just
> the personality routine, or whatever other routines called by personality
> routines that call directly or indirectly __gnu_unwind_frame to be compiled
> that way.
>
> Bootstrapped/regtested on armv7hl-linux-gnueabi (and x86_64-linux to make
> sure it compiles on other targets too).
>
> Ok for trunk?

Ok. Thanks a lot for working on this and fixing the rest of this up.
I've been busy with a few other things.


> While the libgo changes are included in the patch, I think those need to go
> through go upstream and will likely need some changes if that code can be
> compiled by earlier GCC versions or other compilers.
>




> Not sure about libphobos D stuff, does it need to go through upstream and
> is libdruntime/gcc/deh.d compiled by compilers other than GDC?
>
> The Ada changes need those guards because the file is compiled by both
> the system compiler and by the newly built compilers; when compiled by
> system compiler, as the FE is built with -fno-exceptions I'd hope the EH
> stuff isn't really used there and at least until GCC 9.1 is released we have
> the issue that the system compiler could be some earlier GCC 9.0.1 snapshot
> which doesn't support general-regs-only.

I don't grok enough ada to approve this and will leave that part to
Eric or others.

Ramana

>
> 2019-04-22  Ramana Radhakrishnan  
> Bernd Edlinger  
> Jakub Jelinek  
>
> PR target/89093
> * config/arm/arm.c (aapcs_vfp_is_call_or_return_candidate): Diagnose
> if used with general-regs-only.
> (arm_conditional_register_usage): Don't add non-general regs if
> general-regs-only.
> (arm_valid_target_attribute_rec): Handle general-regs-only.
> * config/arm/arm.h (TARGET_HARD_FLOAT): Return false if
> general-regs-only.
> (TARGET_HARD_FLOAT_SUB): Define.
> (TARGET_SOFT_FLOAT): Define as negation of TARGET_HARD_FLOAT_SUB.
> (TARGET_REALLY_IWMMXT): Add && !TARGET_GENERAL_REGS_ONLY.
> (TARGET_REALLY_IWMMXT2): Likewise.
> * config/arm/arm.opt: Add -mgeneral-regs-only.
> * doc/extend.texi: Document ARM general-regs-only target.
> * doc/invoke.texi: Document ARM -mgeneral-regs-only.
> gcc/ada/
> * raise-gcc.c (TARGET_ATTRIBUTE): Define.
> (continue_unwind, personality_body, PERSONALITY_FUNCTION): Add
> TARGET_ATTRIBUTE.
> libgcc/
> * config/arm/pr-support.c: Add #pragma GCC 
> target("general-regs-only").
> * config/arm/unwind-arm.c: Likewise.
> * unwind-c.c (PERSONALITY_FUNCTION): Add general-regs-only target
> attribute for ARM.
> libobjc/
> * exception.c (PERSONALITY_FUNCTION): Add general-regs-only target
> attribute for ARM.
> libphobos/
> * libdruntime/gcc/deh.d: Import gcc.attribute.
> (personality_fn_attributes): New enum.
> (scanLSDA, CONTINUE_UNWINDING, gdc_personality, __gdc_personality):
> Add @personality_fn_attributes.
> libstdc++-v3/
> * libsupc++/eh_personality.cc (PERSONALITY_FUNCTION): Add
> general-regs-only target attribute for ARM.
> libgo/
> * runtime/go-unwind.c (PERSONALITY_FUNCTION,
> __gccgo_personality_dummy): Add general-regs-only target
> attribute for ARM.
>
> --- gcc/config/arm/arm.c(revision 270444)
> +++ gcc/config/arm/arm.c(working copy)
> @@ -6112,6 +6112,11 @@ aapcs_vfp_is_call_or_return_candidate (enum arm_pc
>  return false;
>
>*base_mode = new_mode;
> +
> +  if (TARGET_GENERAL_REGS_ONLY)
> +error ("argument of type %qT not permitted with -mgeneral-regs-only",
> +  type);
> +
>return true;
>  }
>
> @@ -28404,7 +28409,7 @@ arm_conditional_register_usage (void)
> }
>  }
>
> -  if (TARGET_REALLY_IWMMXT)
> + 

[PATCH] libiberty: Only declare vasprintf if it was checked for

2019-04-23 Thread Michael Forney
This matches how the the rest of the libc functions are declared and
prevents a potential conflict with the system declaration when libiberty.h
is included from a directory that did not check for vasprintf, but it is
available. It also corresponds to a similar previous change for asprintf
(r223589).

2019-04-22  Michael Forney  

* libiberty.h (vasprintf): Don't declare if HAVE_DECL_VASPRINTF
is not defined.

---
 include/libiberty.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/libiberty.h b/include/libiberty.h
index 57476135026..e11aa97f0ba 100644
--- a/include/libiberty.h
+++ b/include/libiberty.h
@@ -649,7 +649,7 @@ extern int asprintf (char **, const char *, ...) 
ATTRIBUTE_PRINTF_2;
 
 extern char *xasprintf (const char *, ...) ATTRIBUTE_MALLOC ATTRIBUTE_PRINTF_1;
 
-#if !HAVE_DECL_VASPRINTF
+#if defined(HAVE_DECL_VASPRINTF) && !HAVE_DECL_VASPRINTF
 /* Like vsprintf but provides a pointer to malloc'd storage, which
must be freed by the caller.  */
 
-- 
2.20.1