Re: [PATCH] x32: Add and use libgnarl/s-taprop__x32.adb

2017-10-02 Thread Arnaud Charlet
> I have no idea how to do it.  I opened:
> 
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82384

See Pierre-Marie's suggested patch on the PR.

Arno


Re: [PATCH 10/13] D: The D runtime library and license.

2017-10-02 Thread Iain Buclaw
On 11 September 2017 at 19:01, Jeff Law  wrote:
> On 05/28/2017 03:47 PM, Iain Buclaw wrote:
>> This patch adds the D runtime library and license (Boost) files.  D
>> runtime is a low level that implements the building blocks of the
>> runtime environment, as well as C and C++ platform bindings.  Many
>> high level operations are lowered to generate calls to various
>> functions defined in this library.
>>
>> I've uploaded the patch to my ftp, sorry about the impromptu of this,
>> I had everything neatly lined up, but stumbled after being rejected by
>> the mail daemon.
> So with libphobos the big question is whether or not the library is
> supposed to be a part of GCC or if we're just a downstream user of a
> library with a reasonably permissive license (and I'm going to assume
> that all the files are under a suitable license, I spot checked, but did
> not look at each and every one).
>
> There's a lot of code in here I'd want to look at more closely if we're
> maintaining it within the GCC project, but which I'd let go if we're
> strictly downstream.
>
> Jeff
>

For Phobos, we are strictly downstream.  All sources are Boost license.

https://dlang.org/phobos/index.html

For D runtime library, there's a little more integration going on
between library and compiler, and is the one component that is
absolutely vital if you want to link anything.

Iain.


[PATCH v3 1/14] D: The front-end (DMD) language implementation and license.

2017-10-02 Thread Iain Buclaw
Changes since previous are just merge latest 2.076 release.

Uploaded patch to my ftp due to size limitations.

Regards
Iain.

---

ftp://ftp.gdcproject.org/patches/v3/01-v3-d-frontend-dmd.patch.xz

 gcc/d/dfrontend/aav.c|  193 +
 gcc/d/dfrontend/aav.h|   19 +
 gcc/d/dfrontend/access.c |  670 +++
 gcc/d/dfrontend/aggregate.h  |  342 ++
 gcc/d/dfrontend/aliasthis.c  |  158 +
 gcc/d/dfrontend/aliasthis.h  |   39 +
 gcc/d/dfrontend/apply.c  |  145 +
 gcc/d/dfrontend/argtypes.c   |  502 ++
 gcc/d/dfrontend/array.h  |  237 +
 gcc/d/dfrontend/arrayop.c|  639 +++
 gcc/d/dfrontend/arraytypes.h |   71 +
 gcc/d/dfrontend/attrib.c | 1599 +++
 gcc/d/dfrontend/attrib.h |  278 ++
 gcc/d/dfrontend/blockexit.c  |  503 ++
 gcc/d/dfrontend/boostlicense.txt |   23 +
 gcc/d/dfrontend/canthrow.c   |  318 ++
 gcc/d/dfrontend/checkedint.c |  564 +++
 gcc/d/dfrontend/checkedint.h |   24 +
 gcc/d/dfrontend/clone.c  | 1235 +
 gcc/d/dfrontend/complex_t.h  |   75 +
 gcc/d/dfrontend/cond.c   |  376 ++
 gcc/d/dfrontend/cond.h   |  111 +
 gcc/d/dfrontend/constfold.c  | 1950 
 gcc/d/dfrontend/cppmangle.c  | 2001 
 gcc/d/dfrontend/ctfe.h   |  279 ++
 gcc/d/dfrontend/ctfeexpr.c   | 2112 +
 gcc/d/dfrontend/ctfloat.h|   51 +
 gcc/d/dfrontend/dcast.c  | 3841 +++
 gcc/d/dfrontend/dclass.c | 1947 
 gcc/d/dfrontend/declaration.c| 2568 ++
 gcc/d/dfrontend/declaration.h|  902 
 gcc/d/dfrontend/delegatize.c |  212 +
 gcc/d/dfrontend/denum.c  |  726 +++
 gcc/d/dfrontend/dimport.c|  501 ++
 gcc/d/dfrontend/dinterpret.c | 7009 
 gcc/d/dfrontend/dmacro.c |  468 ++
 gcc/d/dfrontend/dmangle.c|  897 
 gcc/d/dfrontend/dmodule.c| 1427 ++
 gcc/d/dfrontend/doc.c| 2803 +++
 gcc/d/dfrontend/doc.h|   22 +
 gcc/d/dfrontend/dscope.c |  741 +++
 gcc/d/dfrontend/dstruct.c| 1472 ++
 gcc/d/dfrontend/dsymbol.c| 1796 +++
 gcc/d/dfrontend/dsymbol.h|  416 ++
 gcc/d/dfrontend/dtemplate.c  | 8703 ++
 gcc/d/dfrontend/dversion.c   |  199 +
 gcc/d/dfrontend/entity.c | 2393 ++
 gcc/d/dfrontend/enum.h   |  102 +
 gcc/d/dfrontend/errors.h |   55 +
 gcc/d/dfrontend/escape.c | 1152 +
 gcc/d/dfrontend/expression.c | 7009 
 gcc/d/dfrontend/expression.h | 1561 +++
 gcc/d/dfrontend/expressionsem.c  | 8840 +++
 gcc/d/dfrontend/file.c   |  266 ++
 gcc/d/dfrontend/file.h   |   62 +
 gcc/d/dfrontend/filename.c   |  672 +++
 gcc/d/dfrontend/filename.h   |   59 +
 gcc/d/dfrontend/func.c   | 5667 +++
 gcc/d/dfrontend/globals.h|  334 ++
 gcc/d/dfrontend/hash.h   |   75 +
 gcc/d/dfrontend/hdrgen.c | 3461 ++
 gcc/d/dfrontend/hdrgen.h |   51 +
 gcc/d/dfrontend/identifier.c |  191 +
 gcc/d/dfrontend/identifier.h |   57 +
 gcc/d/dfrontend/idgen.c  |  493 ++
 gcc/d/dfrontend/impcnvgen.c  |  600 +++
 gcc/d/dfrontend/imphint.c|   73 +
 gcc/d/dfrontend/import.h |   69 +
 gcc/d/dfrontend/init.c   |  288 ++
 gcc/d/dfrontend/init.h   |  121 +
 gcc/d/dfrontend/initsem.c|  922 
 gcc/d/dfrontend/inline.c | 1938 
 gcc/d/dfrontend/inlinecost.c |  421 ++
 gcc/d/dfrontend/intrange.c   | 1107 +
 gcc/d/dfrontend/intrange.h   |  153 +
 gcc/d/dfrontend/json.c   |  890 
 gcc/d/dfrontend/json.h   |   26 +
 gcc/d/dfrontend/lexer.c  | 2424 ++
 gcc/d/dfrontend/lexer.h  |   83 +
 gcc/d/dfrontend/macro.h  |   46 +
 gcc/d/dfrontend/mars.h   |  103 +
 gcc/d/dfrontend/module.h |  187 +
 gcc/d/dfrontend/mtype.c  | 9517 ++
 gcc/d/dfrontend/mtype.h  |  942 
 gcc/d/dfrontend/newdelete.c  |   59 +
 gcc/d/dfrontend/nogc.c   |  242 +
 gcc/d/dfrontend/nspace.c |  229 +
 gcc/d/dfrontend/nspace.h |   42 +
 gcc/d/dfrontend/objc.c   |   85 +
 gcc/d/dfrontend/objc.h   |   57 +
 gcc/d/dfrontend/object.h |   68 +
 gcc/d/dfrontend/opover.c | 1964 
 gcc/d/dfrontend/optimize.c   | 1273 +
 gcc/d/dfrontend/outbuffer.c  |  402 ++
 gcc/d/dfrontend/outbuffer.h  |   85 +
 gcc/d/dfrontend/parse.c  | 8283 +
 gcc/d/dfrontend/parse.h  |  202 +
 gcc/d/dfrontend/port.h   |   47 +
 gcc/d/dfrontend/readme.txt   |   13 +
 gcc/d/dfrontend/rmem.c   |  163 +
 gcc/d/dfrontend/rmem.h   |   39 +
 gcc/d/dfrontend/root.h   |   27 +
 gcc/d

[PATCH v3 3/14] D: The front-end (GDC) changelogs.

2017-10-02 Thread Iain Buclaw
Updated changelogs following updates to patch 2/14.

Regards
Iain.

---


03-v3-d-frontend-changelogs.patch.xz
Description: application/xz


[PATCH v3 5/14] D: GCC configuration file changes and documentation.

2017-10-02 Thread Iain Buclaw
No change from the previous, just rebasing against trunk.

---
ChangeLog:

	* Makefile.def (target_modules): Add libphobos.
	(flags_to_pass): Add GDC_FOR_TARGET and GDCFLAGS_FOR_TARGET.
	(dependencies): Add dependency from configure-target-libphobos to
	configure-target-zlib.  Add dependency from all-target-libphobos to
	all-target-zlib and all-target-libatomic.
	(language): Add languge d.
	* Makefile.in: Rebuild.
	* Makefile.tpl (BUILT_EXPORTS): Add GDC and GDCFLAGS.
	(HOST_EXPORTS): Add GDC.
	(BASE_TARGET_EXPORTS): Add GDC.
	(GDC_FOR_BUILD, GDC_FOR_TARGET): New variables.
	(GDCFLAGS, GDCFLAGS_FOR_TARGET): New variables.
	(EXTRA_HOST_FLAGS): Add GDC.
	(EXTRA_TARGET_FLAGS): Add GDC and GDCFLAGS.
	* config-ml.in: Treat GDC and GDCFLAGS like other compiler/flag
	environment variables.
	* configure: Rebuild.
	* configure.ac: Add target-libphobos to target_libraries.  Set and
	substitute GDC_FOR_BUILD and GDC_FOR_TARGET.

config/ChangeLog:

	* multi.m4: Set GDC.

gcc/ChangeLog:

	* doc/contrib.texi (Contributors): Add self for the D frontend.
	* doc/frontends.texi (G++ and GCC): Mention D as a supported language.
	* doc/install.texi (Configuration): Mention libphobos as an option for
	--enable-shared.  Mention d as an option for --enable-languages.
	(Testing): Mention check-d as a target.
	* doc/invoke.texi (Overall Options): Mention .d, .dd, and .di as file
	name suffixes.  Mention d as a -x option.
	* doc/sourcebuild.texi (Top Level): Mention libphobos.
	* doc/standards.texi (Standards): Add section on D language.

diff --git a/Makefile.def b/Makefile.def
index bd7b080d905..786f3174bfe 100644
--- a/Makefile.def
+++ b/Makefile.def
@@ -158,6 +158,7 @@ target_modules = { module= libgfortran; };
 target_modules = { module= libobjc; };
 target_modules = { module= libgo; };
 target_modules = { module= libhsail-rt; };
+target_modules = { module= libphobos; };
 target_modules = { module= libtermcap; no_check=true;
missing=mostlyclean;
missing=clean;
@@ -283,6 +284,8 @@ flags_to_pass = { flag= FLAGS_FOR_TARGET ; };
 flags_to_pass = { flag= GFORTRAN_FOR_TARGET ; };
 flags_to_pass = { flag= GOC_FOR_TARGET ; };
 flags_to_pass = { flag= GOCFLAGS_FOR_TARGET ; };
+flags_to_pass = { flag= GDC_FOR_TARGET ; };
+flags_to_pass = { flag= GDCFLAGS_FOR_TARGET ; };
 flags_to_pass = { flag= LD_FOR_TARGET ; };
 flags_to_pass = { flag= LIPO_FOR_TARGET ; };
 flags_to_pass = { flag= LDFLAGS_FOR_TARGET ; };
@@ -550,6 +553,9 @@ dependencies = { module=configure-target-libgo; on=all-target-libstdc++-v3; };
 dependencies = { module=all-target-libgo; on=all-target-libbacktrace; };
 dependencies = { module=all-target-libgo; on=all-target-libffi; };
 dependencies = { module=all-target-libgo; on=all-target-libatomic; };
+dependencies = { module=configure-target-libphobos; on=configure-target-zlib; };
+dependencies = { module=all-target-libphobos; on=all-target-zlib; };
+dependencies = { module=all-target-libphobos; on=all-target-libatomic; };
 dependencies = { module=configure-target-libstdc++-v3; on=configure-target-libgomp; };
 dependencies = { module=configure-target-liboffloadmic; on=configure-target-libgomp; };
 dependencies = { module=configure-target-libsanitizer; on=all-target-libstdc++-v3; };
@@ -563,6 +569,7 @@ dependencies = { module=all-target-liboffloadmic; on=all-target-libgomp; };
 dependencies = { module=install-target-libgo; on=install-target-libatomic; };
 dependencies = { module=install-target-libgfortran; on=install-target-libquadmath; };
 dependencies = { module=install-target-libgfortran; on=install-target-libgcc; };
+dependencies = { module=install-target-libphobos; on=install-target-libatomic; };
 dependencies = { module=install-target-libsanitizer; on=install-target-libstdc++-v3; };
 dependencies = { module=install-target-libsanitizer; on=install-target-libgcc; };
 dependencies = { module=install-target-libvtv; on=install-target-libstdc++-v3; };
@@ -605,6 +612,8 @@ languages = { language=go;	gcc-check-target=check-go;
 lib-check-target=check-gotools; };
 languages = { language=brig;	gcc-check-target=check-brig;
 lib-check-target=check-target-libhsail-rt; };
+languages = { language=d;	gcc-check-target=check-d;
+lib-check-target=check-target-libphobos; };
 
 // Toplevel bootstrap
 bootstrap_stage = { id=1 ; };
diff --git a/Makefile.in b/Makefile.in
index 78db0982ba2..8ecae7fdf37 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -156,6 +156,8 @@ BUILD_EXPORTS = \
 	GFORTRAN="$(GFORTRAN_FOR_BUILD)"; export GFORTRAN; \
 	GOC="$(GOC_FOR_BUILD)"; export GOC; \
 	GOCFLAGS="$(GOCFLAGS_FOR_BUILD)"; export GOCFLAGS; \
+	GDC="$(GDC_FOR_BUILD)"; export GDC; \
+	GDCFLAGS="$(GDCFLAGS_FOR_BUILD)"; export GDCFLAGS; \
 	DLLTOOL="$(DLLTOOL_FOR_BUILD)"; export DLLTOOL; \
 	LD="$(LD_FOR_BUILD)"; export LD; \
 	LDFLAGS="$(LDFLAGS_FOR_BUILD)"; export LDFLAGS; \
@@ -192,6 +194,7 @@ HOST_EXPORTS = \
 	CXXFLAGS="$(CXXFLAGS)"; export CXXFLAGS; \
 	GFORTRAN="$(GFORTRAN)"; export GFORTRAN; \
 	GOC="$(

[PATCH v3 6/14] D: Add D language support to GCC proper.

2017-10-02 Thread Iain Buclaw
No changes from previous, just rebased against trunk.

Regards
Iain

---
gcc/ChangeLog

	* config/powerpcspe/powerpcspe.c (rs6000_output_function_epilogue):
	Support GNU D by using 0 as the language type.
	* config/rs6000/rs6000.c (rs6000_output_function_epilogue):
	Support GNU D by using 0 as the language type.
	* dwarf2out.c (is_dlang): New function.
	(gen_compile_unit_die): Use DW_LANG_D for D.
	(declare_in_namespace): Return module die for D, instead of adding
	extra declarations into the namespace.
	(gen_namespace_die): Generate DW_TAG_module for D.
	(gen_decl_die, dwarf2out_decl): Handle CONST_DECLSs for D.
	* gcc.c (default_compilers): Add entries for ".d", ".dd" and ".di".

gcc/po/ChangeLog:

* EXCLUDES: Add sources from d/dfrontend.

diff --git a/gcc/config/powerpcspe/powerpcspe.c b/gcc/config/powerpcspe/powerpcspe.c
index 12af88417ba..b322b91a652 100644
--- a/gcc/config/powerpcspe/powerpcspe.c
+++ b/gcc/config/powerpcspe/powerpcspe.c
@@ -32019,11 +32019,12 @@ rs6000_output_function_epilogue (FILE *file)
 	 use language_string.
 	 C is 0.  Fortran is 1.  Pascal is 2.  Ada is 3.  C++ is 9.
 	 Java is 13.  Objective-C is 14.  Objective-C++ isn't assigned
-	 a number, so for now use 9.  LTO, Go and JIT aren't assigned numbers
-	 either, so for now use 0.  */
+	 a number, so for now use 9.  LTO, Go, D and JIT aren't assigned
+	 numbers either, so for now use 0.  */
   if (lang_GNU_C ()
 	  || ! strcmp (language_string, "GNU GIMPLE")
 	  || ! strcmp (language_string, "GNU Go")
+	  || ! strcmp (language_string, "GNU D")
 	  || ! strcmp (language_string, "libgccjit"))
 	i = 0;
   else if (! strcmp (language_string, "GNU F77")
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 1e794a0faa6..3e1cfc65ad7 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -29214,11 +29214,12 @@ rs6000_output_function_epilogue (FILE *file)
 	 use language_string.
 	 C is 0.  Fortran is 1.  Pascal is 2.  Ada is 3.  C++ is 9.
 	 Java is 13.  Objective-C is 14.  Objective-C++ isn't assigned
-	 a number, so for now use 9.  LTO, Go and JIT aren't assigned numbers
-	 either, so for now use 0.  */
+	 a number, so for now use 9.  LTO, Go, D, and JIT aren't assigned
+	 numbers either, so for now use 0.  */
   if (lang_GNU_C ()
 	  || ! strcmp (language_string, "GNU GIMPLE")
 	  || ! strcmp (language_string, "GNU Go")
+	  || ! strcmp (language_string, "GNU D")
 	  || ! strcmp (language_string, "libgccjit"))
 	i = 0;
   else if (! strcmp (language_string, "GNU F77")
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index e97ceb61b46..732851faf36 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -5176,6 +5176,16 @@ is_ada (void)
   return lang == DW_LANG_Ada95 || lang == DW_LANG_Ada83;
 }
 
+/* Return TRUE if the language is D.  */
+
+static inline bool
+is_dlang (void)
+{
+  unsigned int lang = get_AT_unsigned (comp_unit_die (), DW_AT_language);
+
+  return lang == DW_LANG_D;
+}
+
 /* Remove the specified attribute if present.  Return TRUE if removal
was successful.  */
 
@@ -23535,6 +23545,8 @@ gen_compile_unit_die (const char *filename)
 	language = DW_LANG_ObjC;
   else if (strcmp (language_string, "GNU Objective-C++") == 0)
 	language = DW_LANG_ObjC_plus_plus;
+  else if (strcmp (language_string, "GNU D") == 0)
+	language = DW_LANG_D;
   else if (dwarf_version >= 5 || !dwarf_strict)
 	{
 	  if (strcmp (language_string, "GNU Go") == 0)
@@ -25138,7 +25150,7 @@ declare_in_namespace (tree thing, dw_die_ref context_die)
 
   if (ns_context != context_die)
 {
-  if (is_fortran ())
+  if (is_fortran () || is_dlang ())
 	return ns_context;
   if (DECL_P (thing))
 	gen_decl_die (thing, NULL, NULL, ns_context);
@@ -25161,7 +25173,7 @@ gen_namespace_die (tree decl, dw_die_ref context_die)
 {
   /* Output a real namespace or module.  */
   context_die = setup_namespace_context (decl, comp_unit_die ());
-  namespace_die = new_die (is_fortran ()
+  namespace_die = new_die (is_fortran () || is_dlang ()
 			   ? DW_TAG_module : DW_TAG_namespace,
 			   context_die, decl);
   /* For Fortran modules defined in different CU don't add src coords.  */
@@ -25233,7 +25245,7 @@ gen_decl_die (tree decl, tree origin, struct vlr_context *ctx,
   break;
 
 case CONST_DECL:
-  if (!is_fortran () && !is_ada ())
+  if (!is_fortran () && !is_ada () && !is_dlang ())
 	{
 	  /* The individual enumerators of an enum type get output when we output
 	 the Dwarf representation of the relevant enum type itself.  */
@@ -25807,7 +25819,7 @@ dwarf2out_decl (tree decl)
 case CONST_DECL:
   if (debug_info_level <= DINFO_LEVEL_TERSE)
 	return;
-  if (!is_fortran () && !is_ada ())
+  if (!is_fortran () && !is_ada () && !is_dlang ())
 	return;
   if (TREE_STATIC (decl) && decl_function_context (decl))
 	context_die = lookup_decl_die (DECL_CONTEXT (decl));
diff --git a/gcc/gcc.c b/gcc/gcc.c
index cec3ed5be

[PATCH v3 7/14] D: Add D language support to GCC targets.

2017-10-02 Thread Iain Buclaw
This patch add D language support to targets of GCC itself.

Changes since previous are just removing patches for untested target
configurations, these can be re-added later on an as-per basis.

---
gcc/ChangeLog

	* gcc/Makefile.in (tm_d_file_list, tm_d_include_list,
	TM_D_H, D_TARGET_DEF, D_TARGET_H, D_TARGET_OBJS): New variables.
	(tm_d.h, cs-tm_d.h, default-d.o, d/d-target-hooks-def.h,
	s-d-target-hooks-def-h): New rules.
	(s-tm-texi): Also check timestamp on d-target.def.
	(generated_files): Add TM_D_H and d-target-hooks-def.h.
	(build/genhooks.o): Also depend on D_TARGET_DEF.
	* gcc/config.gcc (tm_d_file, d_target_objs, target_has_targetdm):
	New variables.
	* config/aarch64/aarch64-d.c: New file.
	* config/aarch64/aarch64-linux.h (GNU_USER_TARGET_D_CRITSEC_SIZE):
	Define.
	* config/aarch64/aarch64-protos.h (aarch64_d_target_versions): New
	prototype.
	* config/aarch64/aarch64.h (TARGET_D_CPU_VERSIONS): Define.
	* config/aarch64/t-aarch64 (aarch64-d.o): New rule.
	* config/arm/arm-d.c: New file.
	* config/arm/arm-protos.h (arm_d_target_versions): New prototype.
	* config/arm/arm.h (TARGET_D_CPU_VERSIONS): Define.
	* config/arm/linux-eabi.h (EXTRA_TARGET_D_OS_VERSIONS): Define.
	* config/arm/t-arm (arm-d.o): New rule.
	* config/default-d.c: New file.
	* config/glibc-d.c: New file.
	* config/gnu.h (GNU_USER_TARGET_D_OS_VERSIONS): Define.
	* config/i386/i386-d.c: New file.
	* config/i386/i386-protos.h (ix86_d_target_versions): New prototype.
	* config/i386/i386.h (TARGET_D_CPU_VERSIONS): Define.
	* config/i386/linux-common.h (EXTRA_TARGET_D_OS_VERSIONS,
	GNU_USER_TARGET_D_CRITSEC_SIZE): Define.
	* config/i386/t-i386 (i386-d.o): New rule.
	* config/kfreebsd-gnu.h (GNU_USER_TARGET_D_OS_VERSIONS): Define.
	* config/kopensolaris-gnu.h (GNU_USER_TARGET_D_OS_VERSIONS): Define.
	* config/linux-android.h (ANDROID_TARGET_D_OS_VERSIONS): Define.
	* config/linux.h (GNU_USER_TARGET_D_OS_VERSIONS): Define.
	* config/mips/linux-common.h (EXTRA_TARGET_D_OS_VERSIONS): Define.
	* config/mips/mips-d.c: New file.
	* config/mips/mips-protos.h (mips_d_target_versions): New prototype.
	* config/mips/mips.h (TARGET_D_CPU_VERSIONS): Define.
	* config/mips/t-mips (mips-d.o): New rule.
	* config/powerpcspe/linux.h (GNU_USER_TARGET_D_OS_VERSIONS): Define.
	* config/powerpcspe/linux64.h (GNU_USER_TARGET_D_OS_VERSIONS): Define.
	* config/powerpcspe/powerpcspe-d.c: New file.
	* config/powerpcspe/powerpcspe-protos.h (rs6000_d_target_versions):
	New prototype.
	* config/powerpcspe/powerpcspe.h (TARGET_D_CPU_VERSIONS): Define.
	* config/powerpcspe/t-powerpcspe (powerpcspe-d.o): New rule.
	* config/rs6000/linux.h (GNU_USER_TARGET_D_OS_VERSIONS): Define.
	* config/rs6000/linux64.h (GNU_USER_TARGET_D_OS_VERSIONS): Define.
	* config/rs6000/rs6000-d.c: New file.
	* config/rs6000/rs6000-protos.h (rs6000_d_target_versions): New
	prototype.
	* config/rs6000/t-rs6000 (rs6000-d.o): New rule.
	* config/s390/s390-d.c: New file.
	* config/s390/s390-protos.h (s390_d_target_versions): New prototype.
	* config/s390/s390.h (TARGET_D_CPU_VERSIONS): Define.
	* config/s390/t-s390 (s390-d.o): New rule.
	* config/sparc/sparc-d.c: New file.
	* config/sparc/sparc-protos.h (sparc_d_target_versions): New prototype.
	* config/sparc/sparc.h (TARGET_D_CPU_VERSIONS): Define.
	* config/sparc/t-sparc (sparc-d.o): New rule.
	* config/t-glibc (glibc-d.o): New rule.
	* gcc/configure.ac (tm_d_file): New variable.
	(tm_d_file_list, tm_d_include_list, d_target_objs): Add substitute.
	* gcc/configure: Regenerated. 
	* doc/tm.texi.in: Add @node for D language, and @hook for
	TARGET_D_CPU_VERSIONS, TARGET_D_OS_VERSIONS, and TARGET_D_CRITSEC_SIZE.
	* doc/tm.texi: Regenerated.
	* gcc/genhooks.c: Include d/d-target.def.

diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 0bde7acf914..c8b58bb8d23 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -546,6 +546,8 @@ tm_include_list=@tm_include_list@
 tm_defines=@tm_defines@
 tm_p_file_list=@tm_p_file_list@
 tm_p_include_list=@tm_p_include_list@
+tm_d_file_list=@tm_d_file_list@
+tm_d_include_list=@tm_d_include_list@
 build_xm_file_list=@build_xm_file_list@
 build_xm_include_list=@build_xm_include_list@
 build_xm_defines=@build_xm_defines@
@@ -840,6 +842,7 @@ BCONFIG_H = bconfig.h $(build_xm_file_list)
 CONFIG_H  = config.h  $(host_xm_file_list)
 TCONFIG_H = tconfig.h $(xm_file_list)
 TM_P_H= tm_p.h$(tm_p_file_list)
+TM_D_H= tm_d.h$(tm_d_file_list)
 GTM_H = tm.h  $(tm_file_list) insn-constants.h
 TM_H  = $(GTM_H) insn-flags.h $(OPTIONS_H)
 
@@ -897,9 +900,11 @@ EXCEPT_H = except.h $(HASHTAB_H)
 TARGET_DEF = target.def target-hooks-macros.h target-insns.def
 C_TARGET_DEF = c-family/c-target.def target-hooks-macros.h
 COMMON_TARGET_DEF = common/common-target.def target-hooks-macros.h
+D_TARGET_DEF = d/d-target.def target-hooks-macros.h
 TARGET_H = $(TM_H) target.h $(TARGET_DEF) insn-modes.h insn-codes.h
 C_TARGET_H = c-family/c-target.h $(C_TARGET_DEF)
 COMMON_TARGET_H = common/common-target.h $(INPUT_H)

[PATCH v3 8/14] D: D2 Testsuite compilable tests.

2017-10-02 Thread Iain Buclaw
Just added some more tests since previous patch for bug fixes made to
the D frontend.

Tests specific to GDC have also been removed also and put in a
separate directory with new dejagnu files.

I've uploaded the patch to my ftp server due to size limitations.

Regards
Iain

---

ftp://ftp.gdcproject.org/patches/v3/08-v3-d-testsuite.patch.xz

 gcc/testsuite/gdc.test/compilable/99bottles.d  |   52 +
 gcc/testsuite/gdc.test/compilable/a3682.d  |   20 +
 gcc/testsuite/gdc.test/compilable/aliasdecl.d  |   40 +
 gcc/testsuite/gdc.test/compilable/art4769.d|   19 +
 gcc/testsuite/gdc.test/compilable/b1215.d  |  146 +
 gcc/testsuite/gdc.test/compilable/b15428.d |   13 +
 gcc/testsuite/gdc.test/compilable/b16598.d |   15 +
 gcc/testsuite/gdc.test/compilable/b16697.d |   13 +
 gcc/testsuite/gdc.test/compilable/b16967.d |   33 +
 gcc/testsuite/gdc.test/compilable/b33.d|   12 +
 gcc/testsuite/gdc.test/compilable/b6395.d  |   25 +
 gcc/testsuite/gdc.test/compilable/bug11735.d   |   36 +
 gcc/testsuite/gdc.test/compilable/bug6963.d|   73 +
 gcc/testsuite/gdc.test/compilable/callconv.d   |   75 +
 gcc/testsuite/gdc.test/compilable/compile1.d   |  920 +++
 gcc/testsuite/gdc.test/compilable/const.d  |   41 +
 gcc/testsuite/gdc.test/compilable/cppmangle.d  |  309 +
 gcc/testsuite/gdc.test/compilable/ddoc1.d  |   69 +
 gcc/testsuite/gdc.test/compilable/ddoc10.d |  210 +
 gcc/testsuite/gdc.test/compilable/ddoc10236.d  |   59 +
 gcc/testsuite/gdc.test/compilable/ddoc10236b.d |   69 +
 gcc/testsuite/gdc.test/compilable/ddoc10325.d  |   17 +
 gcc/testsuite/gdc.test/compilable/ddoc10334.d  |   29 +
 gcc/testsuite/gdc.test/compilable/ddoc10366.d  |   20 +
 gcc/testsuite/gdc.test/compilable/ddoc10367.d  |   28 +
 gcc/testsuite/gdc.test/compilable/ddoc10869.d  |   27 +
 gcc/testsuite/gdc.test/compilable/ddoc10870.d  |   10 +
 gcc/testsuite/gdc.test/compilable/ddoc11.d |   69 +
 gcc/testsuite/gdc.test/compilable/ddoc11479.d  |   96 +
 gcc/testsuite/gdc.test/compilable/ddoc11511.d  |   20 +
 gcc/testsuite/gdc.test/compilable/ddoc11823.d  |7 +
 gcc/testsuite/gdc.test/compilable/ddoc12.d |   20 +
 gcc/testsuite/gdc.test/compilable/ddoc12706.d  |9 +
 gcc/testsuite/gdc.test/compilable/ddoc12745.d  |   25 +
 gcc/testsuite/gdc.test/compilable/ddoc13.d |   26 +
 gcc/testsuite/gdc.test/compilable/ddoc13270.d  |   18 +
 gcc/testsuite/gdc.test/compilable/ddoc13502.d  |   24 +
 gcc/testsuite/gdc.test/compilable/ddoc13645.d  |9 +
 gcc/testsuite/gdc.test/compilable/ddoc14.d |   97 +
 gcc/testsuite/gdc.test/compilable/ddoc198.d|   35 +
 gcc/testsuite/gdc.test/compilable/ddoc2.d  |   42 +
 gcc/testsuite/gdc.test/compilable/ddoc2273.d   |   37 +
 gcc/testsuite/gdc.test/compilable/ddoc3.d  |   71 +
 gcc/testsuite/gdc.test/compilable/ddoc4.d  |   11 +
 gcc/testsuite/gdc.test/compilable/ddoc4162.d   |   17 +
 gcc/testsuite/gdc.test/compilable/ddoc4899.d   |   20 +
 gcc/testsuite/gdc.test/compilable/ddoc5.d  |   31 +
 gcc/testsuite/gdc.test/compilable/ddoc5446.d   |   69 +
 gcc/testsuite/gdc.test/compilable/ddoc5446a.d  |   15 +
 gcc/testsuite/gdc.test/compilable/ddoc5446b.d  |6 +
 gcc/testsuite/gdc.test/compilable/ddoc6.d  |   25 +
 gcc/testsuite/gdc.test/compilable/ddoc648.d|   90 +
 gcc/testsuite/gdc.test/compilable/ddoc6491.d   |   14 +
 gcc/testsuite/gdc.test/compilable/ddoc7.d  |   59 +
 gcc/testsuite/gdc.test/compilable/ddoc7555.d   |   53 +
 gcc/testsuite/gdc.test/compilable/ddoc7656.d   |   24 +
 gcc/testsuite/gdc.test/compilable/ddoc7715.d   |   16 +
 gcc/testsuite/gdc.test/compilable/ddoc7795.d   |   17 +
 gcc/testsuite/gdc.test/compilable/ddoc8.d  |9 +
 gcc/testsuite/gdc.test/compilable/ddoc8271.d   |   15 +
 gcc/testsuite/gdc.test/compilable/ddoc8739.d   |   19 +
 gcc/testsuite/gdc.test/compilable/ddoc9.d  |   26 +
 gcc/testsuite/gdc.test/compilable/ddoc9037.d   |   18 +
 gcc/testsuite/gdc.test/compilable/ddoc9155.d   |   80 +
 gcc/testsuite/gdc.test/compilable/ddoc9305.d   |   38 +
 gcc/testsuite/gdc.test/compilable/ddoc9369.d   |   18 +
 gcc/testsuite/gdc.test/compilable/ddoc9475.d   |   29 +
 gcc/testsuite/gdc.test/compilable/ddoc9497a.d  |   12 +
 gcc/testsuite/gdc.test/compilable/ddoc9497b.d  |   12 +
 gcc/testsuite/gdc.test/compilable/ddoc9497c.d  |   12 +
 gcc/testsuite/gdc.test/compilable/ddoc9497d.d  |   12 +
 gcc/testsuite/gdc.test/compilable/ddoc9676a.d  |9 +
 gcc/testsuite/gdc.test/compilable/ddoc9676b.d  |8 +
 gcc/testsuite/gdc.test/compilable/ddoc9727.d   |   25 +
 gcc/testsuite/gdc.test/compilable/ddoc9789.d   |   11 +
 gcc/testsuite/gdc.test/compilable/ddoc9903.d   |   35 +
 gcc/testsuite/gd

[PATCH v3 9/14] D: D2 Testsuite Dejagnu files.

2017-10-02 Thread Iain Buclaw
No changes from previous patch, just a refresh.

Mike, you don't need to look at this, just an FYI.

---
diff --git a/gcc/testsuite/gdc.test/d_do_test.exp b/gcc/testsuite/gdc.test/d_do_test.exp
new file mode 100644
index 000..4c03989443c
--- /dev/null
+++ b/gcc/testsuite/gdc.test/d_do_test.exp
@@ -0,0 +1,387 @@
+#   Copyright (C) 2012-2017 Free Software Foundation, Inc.
+
+# This program 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 of the License, or
+# (at your option) any later version.
+#
+# This program 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
+# .
+
+# Test using the DMD testsuite.
+# Load support procs.
+load_lib gdc-dg.exp
+
+#
+# Convert DMD arguments to GDC equivalent
+#
+
+proc gdc-convert-args { base args } {
+set out ""
+
+foreach arg [split [lindex $args 0] " "] {
+# List of switches kept in ASCII collated order.
+if { [regexp -- {^-I([\w+/-]+)} $arg pattern path] } {
+lappend out "-I$base/$path"
+
+} elseif { [regexp -- {^-J([\w+/-]+)} $arg pattern path] } {
+lappend out "-J$base/$path"
+
+} elseif [string match "-allinst" $arg] {
+lappend out "-femit-templates"
+
+} elseif { [string match "-boundscheck" $arg]
+ || [string match "-boundscheck=on" $arg] } {
+lappend out "-fbounds-check"
+
+} elseif { [string match "-boundscheck=off" $arg]
+   || [string match "-noboundscheck" $arg] } {
+lappend out "-fno-bounds-check"
+
+} elseif [string match "-boundscheck=safeonly" $arg] {
+lappend out "-fbounds-check=safeonly"
+
+} elseif [string match "-c" $arg] {
+lappend out "-c"
+
+} elseif [string match "-d" $arg] {
+lappend out "-Wno-deprecated"
+
+} elseif [string match "-de" $arg] {
+lappend out "-Wdeprecated"
+lappend out "-Werror"
+
+} elseif [string match "-debug" $arg] {
+lappend out "-fdebug"
+
+} elseif [string match "-dip1000" $arg] {
+lappend out "-ftransition=safe"
+
+} elseif [string match "-dip25" $arg] {
+lappend out "-ftransition=dip25"
+
+} elseif [string match "-dw" $arg] {
+lappend out "-Wdeprecated"
+lappend out "-Wno-error"
+
+} elseif [string match "-fPIC" $arg] {
+lappend out "-fPIC"
+
+} elseif { [string match "-g" $arg]
+   || [string match "-gc" $arg] } {
+lappend out "-g"
+
+} elseif [string match "-inline" $arg] {
+lappend out "-finline-functions"
+
+} elseif [regexp -- {^-mv=([\w+=./-]+)} $arg pattern value] {
+lappend out "-fmodule-filepath=$value"
+
+} elseif [string match "-O" $arg] {
+lappend out "-O2"
+
+} elseif [string match "-property" $arg] {
+lappend out "-fproperty"
+
+} elseif [string match "-release" $arg] {
+lappend out "-frelease"
+
+} elseif [regexp -- {^-transition=(\w+)} $arg pattern value] {
+lappend out "-ftransition=$value"
+
+} elseif [string match "-unittest" $arg] {
+lappend out "-funittest"
+
+} elseif [string match "-verrors=spec" $arg] {
+lappend out "-Wspeculative"
+
+} elseif [regexp -- {^-verrors=(\d+)} $arg pattern num] {
+lappend out "-fmax-errors=$num"
+
+} elseif [regexp -- {^-version=(\w+)} $arg pattern value] {
+lappend out "-fversion=$value"
+
+} elseif [string match "-w" $arg] {
+lappend out "-Wall"
+lappend out "-Werror"
+
+} elseif [string match "-wi" $arg] {
+lappend out "-Wall"
+lappend out "-Wno-error"
+
+} else {
+# print "Unhandled Argument: $arg"
+}
+}
+
+return $out
+}
+
+proc gdc-copy-extra { base extra } {
+# Split base, folder/file.
+set type [file dirname $extra]
+
+# print "Filename: $base - $extra"
+
+set fdin [open $base/$extra r]
+fconfigure $fdin -encoding binary
+
+file mkdir $type
+set fdout [open $extra w]
+fconfigure $fdout -encoding binary
+
+while { [gets $fdin copy_line] >= 0 } {
+set out_line $copy_line
+puts $fdout $out_line
+}
+
+close $fdin
+close $fdout
+
+return $extra
+}
+
+#
+# Translate DMD test directives to dejagnu equivalent.
+#
+#   COMPILE_SEPARATELY: Not handled.
+#   EXECUTE_ARG

Re: [PATCH][AArch64] Add BIC-imm and ORR-imm SIMD pattern

2017-10-02 Thread Sudi Das

Hi Richard

Thanks, I have made the change to the patch.


2017-10-02 Sudakshina Das  

* config/aarch64/aarch64-protos.h (enum simd_immediate_check): New 
check type
for aarch64_simd_valid_immediate.
(aarch64_output_simd_mov_immediate): Update prototype.
(aarch64_simd_valid_immediate): Update prototype.

* config/aarch64/aarch64-simd.md (orr3): modified pattern to add
support for ORR-immediate.
(and3): modified pattern to add support for BIC-immediate.

* config/aarch64/aarch64.c (aarch64_simd_valid_immediate): Function now 
checks
for valid immediate for BIC and ORR based on new enum argument.
(aarch64_output_simd_mov_immediate): Function now used to output 
BIC/ORR imm
as well based on new enum argument.
 
* config/aarch64/constraints.md (Do): New vector immediate constraint.
(Db) : Likewise.

* config/aarch64/predicates.md (aarch64_reg_or_orr_imm): New predicate.
(aarch64_reg_or_bic_imm): Likewise.


2017-10-02 Sudakshina Das  

* gcc.target/aarch64/bic_imm_1.c: New test.
* gcc.target/aarch64/orr_imm_1.c: Likewise.


From: Richard Earnshaw (lists) 
Sent: Thursday, September 28, 2017 9:55 AM
To: Sudi Das; James Greenhalgh
Cc: gcc-patches@gcc.gnu.org; nd; Marcus Shawcroft
Subject: Re: [PATCH][AArch64] Add BIC-imm and ORR-imm SIMD pattern
    
On 27/09/17 18:57, Sudi Das wrote:
> 
> 
> Hi James
> 
> I have made the requested changes to the patch.
> 
> 
> 2017-09-27 Sudakshina Das  
> 
>    * config/aarch64/aarch64-protos.h (enum simd_immediate_check): New 
>check type
>    for aarch64_simd_valid_immediate.
>    (aarch64_output_simd_mov_immediate): Update prototype.
>    (aarch64_simd_valid_immediate): Update prototype.
> 
>    * config/aarch64/aarch64-simd.md (orr3): modified pattern to add
>    support for ORR-immediate.
>    (and3): modified pattern to add support for BIC-immediate.
> 
>    * config/aarch64/aarch64.c (aarch64_simd_valid_immediate): Function 
>now checks
>    for valid immediate for BIC and ORR based on new enum argument.
>    (aarch64_output_simd_mov_immediate): Function now used to output 
>BIC/ORR imm
>    as well based on new enum argument.
>  
>    * config/aarch64/constraints.md (Do): New vector immediate constraint.
>    (Db): Likewise.
> 
> 2017-09-27 Sudakshina Das  
> 
>    * gcc.target/aarch64/bic_imm_1.c: New test.
>    * gcc.target/aarch64/orr_imm_1.c: Likewise.
> 
> 
> Thanks
> Sudi
> 
>   
> From: James Greenhalgh 
> Sent: Tuesday, September 26, 2017 8:04:38 PM
> To: Sudi Das
> Cc: Richard Earnshaw; gcc-patches@gcc.gnu.org; nd; Marcus Shawcroft
> Subject: Re: [PATCH][AArch64] Add BIC-imm and ORR-imm SIMD pattern
> 
> On Mon, Sep 25, 2017 at 11:13:57AM +0100, Sudi Das wrote:
>>
>> Hi James
>>
>> I put aarch64_output_simd_general_immediate looking at the similarities of
>> the immediates for mov/mvni and orr/bic. The CHECK macro in
>> aarch64_simd_valid_immediate both checks
>> and converts the immediates in a manner that are needed for the instructions.
>>
>> Having said that, I agree that maybe I could have refactored
>> aarch64_output_simd_mov_immediate to do the work rather than creating a new
>> functions to do similar things. I have done so in this patch.
> 
> Thanks, this looks much neater.
> 
>> I have also changed the names of the enum simd_immediate_check to be better
>> indicative of what they are doing. 
> 
> Thanks, I'd tweak them to look more like the bitmasks you use them as, but
> that is a small change for my personal preference.
> 
>> Lastly I have added more cases in the tests (according to all the possible
>> CHECKs) and made them dg-do assemble (although I had to add --save-temps so
>> that the scan-assembler would work). Do you think I should not put that
>> option and rather create separate tests?
> 
> This is good - thanks.
> 
> I think clean up the enum definitions and this patch will be good.
> 
>> @@ -308,6 +308,16 @@ enum aarch64_parse_opt_result
>> AARCH64_PARSE_INVALID_ARG  /* Invalid arch, tune, cpu arg.  */
>>   };
>>   
>> +/* Enum to distinguish which type of check is to be done in
>> +   aarch64_simd_valid_immediate.  This is used as a bitmask where
>> +   AARCH64_CHECK_MOV has both bits set.  Thus AARCH64_CHECK_MOV will
>> +   perform all checks.  Adding new types would require changes accordingly. 
>>  */
>> +enum simd_immediate_check {
>> +  AARCH64_CHECK_ORR  = 1,    /* Perform immediate checks for ORR.  */
>> +  AARCH64_CHECK_BIC  = 2,    /* Perform immediate checks for BIC.  */
>> +  AARCH64_CHECK_MOV  = 3 /* Perform all checks (used for MOVI/MNVI).  */
> 
> These are used in bit-mask style, so how about:
> 
>   AARCH64_CHECK_ORR = 1 << 0,
>   AARCH64_CHECK_BIC = 1 << 1,
>   AARCH64_CHECK_MOV = AARCH64_CHECK_ORR | AARCH64_CHECK_BIC
> 
> Which is more self-documenting.
> 
>> @@ -13001,7 +13013,8 @@ aarch64_float_const_repr

[PATCH v3 10/14] D: GDC Testsuite tests and config.

2017-10-02 Thread Iain Buclaw
This was split out from patch 9/14.  Added test directories for ASAN
and LTO tests.

Regards
Iain.

---
diff --git a/gcc/testsuite/gdc.dg/asan/asan.exp b/gcc/testsuite/gdc.dg/asan/asan.exp
new file mode 100644
index 000..83bff4693e7
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/asan/asan.exp
@@ -0,0 +1,32 @@
+#   Copyright (C) 2017 Free Software Foundation, Inc.
+
+# This program 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 of the License, or
+# (at your option) any later version.
+#
+# This program 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
+# .
+
+# Load support procs.
+load_lib gdc-dg.exp
+load_lib asan-dg.exp
+
+# Initialize `dg'.
+dg-init
+asan_init
+
+# Main loop.
+if [check_effective_target_fsanitize_address] {
+  gdc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.d]] "" ""
+}
+
+# All done.
+asan_finish
+dg-finish
diff --git a/gcc/testsuite/gdc.dg/asan/gdc272.d b/gcc/testsuite/gdc.dg/asan/gdc272.d
new file mode 100644
index 000..c3de64b4c82
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/asan/gdc272.d
@@ -0,0 +1,16 @@
+/* { dg-options "-fsanitize=address" } */
+/* { dg-do compile } */
+
+module asantests;
+
+
+/**/
+
+// Bug 272
+
+extern(C) void my_memcmp(const(void) *s1, const(void) *s2);
+
+void bug(const(char)* p)
+{
+my_memcmp(p, "__FILE__".ptr);
+}
diff --git a/gcc/testsuite/gdc.dg/dg.exp b/gcc/testsuite/gdc.dg/dg.exp
new file mode 100644
index 000..736d09ed599
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/dg.exp
@@ -0,0 +1,50 @@
+#   Copyright (C) 2017 Free Software Foundation, Inc.
+
+# This program 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 of the License, or
+# (at your option) any later version.
+#
+# This program 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
+# .
+
+# GCC testsuite that uses the `dg.exp' driver.
+
+# Load support procs.
+load_lib gdc-dg.exp
+
+# The default option list can be overridden by
+# TORTURE_OPTIONS="{ { list1 } ... { listN } }"
+
+if ![info exists TORTURE_OPTIONS] {
+set TORTURE_OPTIONS [list \
+{ -O0 } { -O1 } { -O2 } { -O3 } { -Os } \
+{ -O0 -frelease } { -O0 -g } { -O0 -frelease -g } \
+{ -O1 -frelease } { -O1 -g } { -O1 -frelease -g } \
+{ -O2 -frelease } { -O2 -g } { -O2 -frelease -g } \
+{ -O3 -frelease } { -O3 -g } { -O3 -frelease -g } \
+{ -Os -frelease } { -Os -g } { -Os -frelease -g }]
+}
+
+# Initialize `dg'.
+dg-init
+
+# Initialize use of torture lists.
+torture-init
+set-torture-options $TORTURE_OPTIONS
+
+# Main loop.
+gdc-dg-runtest [lsort \
+   [glob -nocomplain $srcdir/$subdir/*.d ] ] "" ""
+
+# Finalize use of torture lists.
+torture-finish
+
+# All done.
+dg-finish
diff --git a/gcc/testsuite/gdc.dg/gdc170.d b/gcc/testsuite/gdc.dg/gdc170.d
new file mode 100644
index 000..8ad73c5bad6
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/gdc170.d
@@ -0,0 +1,18 @@
+// { dg-options "-I $srcdir/gdc.dg" }
+import imports.gdc170a;
+
+void main()
+{
+foo!void.foo1!void();
+foo!void.foo2!void();
+foo!void.foo3();
+foo!void.foo3!void();
+foo!void.foo4();
+foo!void.foo4!void();
+foo!void.foo5!void(null);
+foo!void.foo6!void(null);
+foo!void.foo7(null);
+foo!void.foo7!void(null);
+foo!void.foo8(null);
+foo!void.foo8!void(null);
+}
diff --git a/gcc/testsuite/gdc.dg/gdc204.d b/gcc/testsuite/gdc.dg/gdc204.d
new file mode 100644
index 000..de90766da0a
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/gdc204.d
@@ -0,0 +1,9 @@
+interface I204
+{
+  void f();
+}
+
+class C204 : I204
+{
+  void f();
+}
diff --git a/gcc/testsuite/gdc.dg/gdc212.d b/gcc/testsuite/gdc.dg/gdc212.d
new file mode 100644
index 000..bfe4b960794
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/gdc212.d
@@ -0,0 +1,45 @@
+template hasElaborateAssign(S)
+{
+enum hasElaborateAssign = is(typeof(S.init.opAssign(rvalueOf!S))) ||
+is(typeof(lvalueOf!S)) ;
+}
+
+T rvalueOf(T)();
+
+T lvalueOf(T)();
+
+
+template TypeTuple(TList...)
+{
+alias TypeTuple = TList;
+}
+
+template Tuple()

[testsuite, nvptx, committed] Require nonlocal_goto for gcc.c-torture/compile/pr82337.c

2017-10-02 Thread Tom de Vries

Hi,

this patch requires effective target nonlocal_goto for 
gcc.c-torture/compile/pr82337.c.


Committed.

Thanks,
- Tom
Require nonlocal_goto for gcc.c-torture/compile/pr82337.c

2017-10-02  Tom de Vries  

	* gcc.c-torture/compile/pr82337.c: Add
	dg-require-effective-target nonlocal_goto.

---
 gcc/testsuite/gcc.c-torture/compile/pr82337.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gcc/testsuite/gcc.c-torture/compile/pr82337.c b/gcc/testsuite/gcc.c-torture/compile/pr82337.c
index f8afa74..e6060e4 100644
--- a/gcc/testsuite/gcc.c-torture/compile/pr82337.c
+++ b/gcc/testsuite/gcc.c-torture/compile/pr82337.c
@@ -1,5 +1,7 @@
 /* PR82337: SLSR needs to prevent abnormal SSA names from
serving as a basis. */
+/* { dg-require-effective-target nonlocal_goto } */
+
 char *a, *b, *c;
 
 struct d {


[PATCH v3 11/14] D: The D runtime library and license.

2017-10-02 Thread Iain Buclaw
Changes since last patch are update to version 2.076.

As iterated before, these are maintained upstream, and are necessary
to link D applications.

Uploaded to ftp server due to size limitations.

Regards
Iain.

---

ftp://ftp.gdcproject.org/patches/v3/11-v3-d-runtime-library.patch.xz

 libphobos/libdruntime/LICENSE  |   26 +
 libphobos/libdruntime/core/atomic.d| 1765 ++
 libphobos/libdruntime/core/attribute.d |   57 +
 libphobos/libdruntime/core/bitop.d | 1018 
 libphobos/libdruntime/core/checkedint.d|  781 +++
 libphobos/libdruntime/core/cpuid.d | 1132 
 libphobos/libdruntime/core/demangle.d  | 2630 
 libphobos/libdruntime/core/exception.d |  721 +++
 libphobos/libdruntime/core/internal/abort.d|   45 +
 libphobos/libdruntime/core/internal/arrayop.d  |  451 ++
 libphobos/libdruntime/core/internal/convert.d  |  638 ++
 libphobos/libdruntime/core/internal/hash.d |  534 ++
 libphobos/libdruntime/core/internal/spinlock.d |  103 +
 libphobos/libdruntime/core/internal/string.d   |  213 +
 libphobos/libdruntime/core/internal/traits.d   |  212 +
 libphobos/libdruntime/core/math.d  |  166 +
 libphobos/libdruntime/core/memory.d|  920 +++
 libphobos/libdruntime/core/runtime.d   |  908 +++
 libphobos/libdruntime/core/simd.d  |  553 ++
 libphobos/libdruntime/core/stdc/assert_.d  |   70 +
 libphobos/libdruntime/core/stdc/complex.d  |  177 +
 libphobos/libdruntime/core/stdc/config.d   |  164 +
 libphobos/libdruntime/core/stdc/ctype.d|   49 +
 libphobos/libdruntime/core/stdc/errno.d| 1898 ++
 libphobos/libdruntime/core/stdc/errno_.c   |   25 +
 libphobos/libdruntime/core/stdc/fenv.d |  702 +++
 libphobos/libdruntime/core/stdc/float_.d   |   92 +
 libphobos/libdruntime/core/stdc/inttypes.d |  443 ++
 libphobos/libdruntime/core/stdc/limits.d   |   61 +
 libphobos/libdruntime/core/stdc/locale.d   |  229 +
 libphobos/libdruntime/core/stdc/math.d | 3744 
 libphobos/libdruntime/core/stdc/signal.d   |   78 +
 libphobos/libdruntime/core/stdc/stdarg.d   |  687 +++
 libphobos/libdruntime/core/stdc/stddef.d   |   33 +
 libphobos/libdruntime/core/stdc/stdint.d   |  262 +
 libphobos/libdruntime/core/stdc/stdio.d| 1600 +
 libphobos/libdruntime/core/stdc/stdlib.d   |  234 +
 libphobos/libdruntime/core/stdc/string.d   |  112 +
 libphobos/libdruntime/core/stdc/tgmath.d   | 2217 +++
 libphobos/libdruntime/core/stdc/time.d |  200 +
 libphobos/libdruntime/core/stdc/wchar_.d   |  260 +
 libphobos/libdruntime/core/stdc/wctype.d   |   65 +
 libphobos/libdruntime/core/stdcpp/exception.d  |  106 +
 libphobos/libdruntime/core/stdcpp/typeinfo.d   |  148 +
 libphobos/libdruntime/core/sync/barrier.d  |  151 +
 libphobos/libdruntime/core/sync/condition.d|  606 ++
 libphobos/libdruntime/core/sync/config.d   |   68 +
 libphobos/libdruntime/core/sync/exception.d|   32 +
 libphobos/libdruntime/core/sync/mutex.d|  425 ++
 libphobos/libdruntime/core/sync/rwmutex.d  |  528 ++
 libphobos/libdruntime/core/sync/semaphore.d|  454 ++
 libphobos/libdruntime/core/sys/bionic/fcntl.d  |5 +
 libphobos/libdruntime/core/sys/bionic/unistd.d |5 +
 libphobos/libdruntime/core/sys/darwin/dlfcn.d  |   40 +
 libphobos/libdruntime/core/sys/darwin/execinfo.d   |   26 +
 libphobos/libdruntime/core/sys/darwin/mach/dyld.d  |   38 +
 .../libdruntime/core/sys/darwin/mach/getsect.d |   33 +
 .../libdruntime/core/sys/darwin/mach/kern_return.d |   82 +
 .../libdruntime/core/sys/darwin/mach/loader.d  |  106 +
 libphobos/libdruntime/core/sys/darwin/mach/port.d  |   36 +
 .../libdruntime/core/sys/darwin/mach/semaphore.d   |   67 +
 .../libdruntime/core/sys/darwin/mach/thread_act.d  |  137 +
 libphobos/libdruntime/core/sys/darwin/pthread.d|   60 +
 libphobos/libdruntime/core/sys/darwin/sys/cdefs.d  |   25 +
 libphobos/libdruntime/core/sys/darwin/sys/event.d  |  141 +
 libphobos/libdruntime/core/sys/darwin/sys/mman.d   |  112 +
 libphobos/libdruntime/core/sys/freebsd/dlfcn.d |  114 +
 libphobos/libdruntime/core/sys/freebsd/execinfo.d  |  133 +
 .../libdruntime/core/sys/freebsd/pthread_np.d  |   44 +
 .../libdruntime/core/sys/freebsd/sys/_bitset.d |   45 +
 .../libdruntime/core/sys/freebsd/sys/_cpuset.d |   29 +
 libphobos/libdruntime/core/sys/freebsd/sys/cdefs.d |   16 +
 libphobos/libdruntime/core/sys/freebsd/sys/elf.d   |   11 +
 libphobos/libdruntime/core/sys/freebsd/sys/elf32.d |  187 +
 libphobos/libdruntime/core/sys/freebsd/sys/elf64.d |  193 +
 .../libdruntime/core/sys/freebsd/sys/elf_common.d  |  853 +++
 libphob

Re: Fix mismatched precisions in tree arithmetic

2017-10-02 Thread Richard Biener
On Sun, Oct 1, 2017 at 6:13 PM, Richard Sandiford
 wrote:
> The tree wi:: decompose routine wasn't asserting that the requested
> precision matched the tree's precision.  This could make a difference
> for unsigned trees that are exactly N HWIs wide and that have the upper
> bit set, since we then need an extra zero HWI when extending it to wider
> precisions (as for wi::to_widest).
>
> This patch adds the assert and fixes the fallout shown by the testsuite.
> Go seems to be unaffected.
>
> Other fixed-precision decompose routines already had an assert.
>
> Tested on aarch64-linux-gnu, x86_64-linux-gnu and powerpc64le-linux-gnu.
> Also tested by comparing the testsuite assembly output on at least one
> target per CPU directory.  OK to install?

Ok.

Thanks,
Richard.

> Richard
>
>
> 2017-10-01  Richard Sandiford  
>
> gcc/
> * tree.h (wi::int_traits ::decompose): Assert that the
> requested precision matches the type's.
> * calls.c (alloc_max_size): Calculate the new candidate size as
> a widest_int and use wi::to_widest when comparing it with the
> current candidate size.
> * gimple-ssa-warn-alloca.c (pass_walloca::execute): Compare with
> zero rather than integer_zero_node.
> * match.pd: Check for a no-op conversion before using wi::add
> rather than after.  Use tree_to_uhwi when summing small shift
> counts into an unsigned int.
>
> gcc/c-family/
> * c-warn.c (warn_tautological_bitwise_comparison): Use wi::to_widest
> when combining the original unconverted comparison operands.
>
> gcc/cp/
> * constexpr.c (cxx_eval_store_expression): Use wi::to_widest
> when comparing the array bounds with an ARRAY_REF index.
>
> gcc/ada/
> * gcc-interface/decl.c (annotate_value): Use wi::to_widest when
> handling the form (plus/mult (convert @0) @1).
>
> Index: gcc/tree.h
> ===
> --- gcc/tree.h  2017-09-25 13:33:39.989814299 +0100
> +++ gcc/tree.h  2017-10-01 17:08:55.827120507 +0100
> @@ -5176,6 +5176,7 @@ wi::int_traits ::get_precisi
>  wi::int_traits ::decompose (HOST_WIDE_INT *,
> unsigned int precision, const_tree x)
>  {
> +  gcc_checking_assert (precision == TYPE_PRECISION (TREE_TYPE (x)));
>return wi::storage_ref (&TREE_INT_CST_ELT (x, 0), TREE_INT_CST_NUNITS (x),
>   precision);
>  }
> Index: gcc/calls.c
> ===
> --- gcc/calls.c 2017-09-21 12:13:48.336399601 +0100
> +++ gcc/calls.c 2017-10-01 17:08:55.825112782 +0100
> @@ -1252,9 +1252,8 @@ alloc_max_size (void)
>
>   if (unit)
> {
> - wide_int w = wi::uhwi (limit, HOST_BITS_PER_WIDE_INT + 64);
> - w *= unit;
> - if (wi::ltu_p (w, alloc_object_size_limit))
> + widest_int w = wi::mul (limit, unit);
> + if (w < wi::to_widest (alloc_object_size_limit))
> alloc_object_size_limit = wide_int_to_tree (ssizetype, w);
> }
> }
> Index: gcc/gimple-ssa-warn-alloca.c
> ===
> --- gcc/gimple-ssa-warn-alloca.c2017-03-28 16:19:28.0 +0100
> +++ gcc/gimple-ssa-warn-alloca.c2017-10-01 17:08:55.826116645 +0100
> @@ -491,7 +491,7 @@ pass_walloca::execute (function *fun)
>   is_vla ? G_("argument to variable-length array "
>   "may be too large")
>   : G_("argument to % may be too large"))
> - && t.limit != integer_zero_node)
> + && t.limit != 0)
> {
>   print_decu (t.limit, buff);
>   inform (loc, G_("limit is %u bytes, but argument "
> @@ -504,7 +504,7 @@ pass_walloca::execute (function *fun)
>   is_vla ? G_("argument to variable-length array "
>   "is too large")
>   : G_("argument to % is too large"))
> - && t.limit != integer_zero_node)
> + && t.limit != 0)
> {
>   print_decu (t.limit, buff);
>   inform (loc, G_("limit is %u bytes, but argument is %s"),
> Index: gcc/match.pd
> ===
> --- gcc/match.pd2017-09-25 13:57:11.698158636 +0100
> +++ gcc/match.pd2017-10-01 17:08:55.827120507 +0100
> @@ -358,8 +358,8 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
>(div (convert? (bit_and @0 INTEGER_CST@1)) INTEGER_CST@2)
>(if (integer_pow2p (@2)
> && tree_int_cst_sgn (@2) > 0
> -   && wi::add (@2, @1) == 0
> -   && tree_nop_conversion_p (type, TREE_TYPE (@0)))
> +   && tree_nop_conversion_

[PATCH v3 12/14] D: GCC builtins and runtime support.

2017-10-02 Thread Iain Buclaw
Just updated copyright dates as per comments on previous revision, I
think everything should be in order.

---
diff --git a/libphobos/libdruntime/__entrypoint.di b/libphobos/libdruntime/__entrypoint.di
new file mode 100644
index 000..d04fe5d0889
--- /dev/null
+++ b/libphobos/libdruntime/__entrypoint.di
@@ -0,0 +1,56 @@
+/* GDC -- D front-end for GCC
+   Copyright (C) 2013-2017 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
+   .
+*/
+
+/* This module provides the C main() function supplied by the user's program.  */
+
+module __entrypoint;
+
+extern(C):
+
+/* The D main() function supplied by the user's program
+
+   It always has `_Dmain` symbol name and uses C calling convention.
+   But D frontend returns its type as `extern(D)` because of Issue 9028.
+   As we need to deal with actual calling convention we have to mark it
+   as `extern(C)` and use its symbol name.
+*/
+
+int _Dmain(char[][] args);
+int _d_run_main(int argc, char **argv, void* mainFunc);
+
+/* Substitutes for the C main() function.  Just calls into d_run_main with
+   the default main function.  Applications are free to implement their own
+   main function and call the _d_run_main function themselves with any main
+   function.
+*/
+
+int main(int argc, char **argv)
+{
+return _d_run_main(argc, argv, &_Dmain);
+}
+
+/* This is apparently needed on Solaris because the C tool chain seems to
+   expect the main function to be called _main.  It needs both not just one!
+*/
+
+version (Solaris)
+int _main(int argc, char** argv)
+{
+return main(argc, argv);
+}
+
diff --git a/libphobos/libdruntime/gcc/attribute.d b/libphobos/libdruntime/gcc/attribute.d
new file mode 100644
index 000..2498c27e7cc
--- /dev/null
+++ b/libphobos/libdruntime/gcc/attribute.d
@@ -0,0 +1,33 @@
+// GNU D Compiler attribute support declarations.
+// Copyright (C) 2013-2017 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.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+// .
+
+module gcc.attribute;
+
+private struct Attribute(A...)
+{
+A args;
+}
+
+auto attribute(A...)(A args) if(A.length > 0 && is(A[0] == string))
+{
+return Attribute!A(args);
+}
diff --git a/libphobos/libdruntime/gcc/backtrace.d b/libphobos/libdruntime/gcc/backtrace.d
new file mode 100644
index 000..c24a53a42fb
--- /dev/null
+++ b/libphobos/libdruntime/gcc/backtrace.d
@@ -0,0 +1,575 @@
+// GNU D Compiler routines for stack backtrace support.
+// Copyright (C) 2013-2017 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.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+// .
+
+module gcc.backtrace;
+
+import gcc.libbacktrace;
+
+
+version( Posix )
+{
+// NOTE: The first 

Re: [PATCH] [graphite] translate reads and writes in a single traversal of memory ops

2017-10-02 Thread Richard Biener
On Mon, Oct 2, 2017 at 6:53 AM, Sebastian Pop  wrote:
> The patch moves the code that translates reads and writes to isl 
> representation
> in a same loop.  This is to avoid traversing the scop blocks and arrays with
> memory operations 3 times.

LGTM.

Richard.

> * graphite-dependences.c (scop_get_reads): Move code to...
> (scop_get_must_writes): Move code to...
> (scop_get_may_writes): Move code to...
> (scop_get_reads_and_writes): ... here.
> (scop_get_dependences): Call scop_get_reads_and_writes.
> ---
>  gcc/graphite-dependences.c | 78 
> +-
>  1 file changed, 21 insertions(+), 57 deletions(-)
>
> diff --git a/gcc/graphite-dependences.c b/gcc/graphite-dependences.c
> index 4ed9d00..2066b2e 100644
> --- a/gcc/graphite-dependences.c
> +++ b/gcc/graphite-dependences.c
> @@ -63,20 +63,21 @@ add_pdr_constraints (poly_dr_p pdr, poly_bb_p pbb)
>return constrain_domain (x, isl_set_copy (pbb->domain));
>  }
>
> -/* Returns all the memory reads in SCOP.  */
> +/* Returns an isl description of all memory operations in SCOP.  The memory
> +   reads are returned in READS and writes in MUST_WRITES and MAY_WRITES.  */
>
> -static isl_union_map *
> -scop_get_reads (scop_p scop)
> +static void
> +scop_get_reads_and_writes (scop_p scop, isl_union_map *reads,
> +  isl_union_map *must_writes,
> +  isl_union_map *may_writes)
>  {
>int i, j;
>poly_bb_p pbb;
>poly_dr_p pdr;
> -  isl_space *space = isl_set_get_space (scop->param_context);
> -  isl_union_map *res = isl_union_map_empty (space);
>
>FOR_EACH_VEC_ELT (scop->pbbs, i, pbb)
>  {
> -  FOR_EACH_VEC_ELT (PBB_DRS (pbb), j, pdr)
> +  FOR_EACH_VEC_ELT (PBB_DRS (pbb), j, pdr) {
> if (pdr_read_p (pdr))
>   {
> if (dump_file)
> @@ -86,33 +87,14 @@ scop_get_reads (scop_p scop)
>   }
> isl_union_map *um
>   = isl_union_map_from_map (add_pdr_constraints (pdr, pbb));
> -   res = isl_union_map_union (res, um);
> +   reads = isl_union_map_union (reads, um);
> if (dump_file)
>   {
> fprintf (dump_file, "Reads depedence graph: ");
> -   print_isl_union_map (dump_file, res);
> +   print_isl_union_map (dump_file, reads);
>   }
>   }
> -}
> -
> -  return isl_union_map_coalesce (res);
> -}
> -
> -/* Returns all the memory must writes in SCOP.  */
> -
> -static isl_union_map *
> -scop_get_must_writes (scop_p scop)
> -{
> -  int i, j;
> -  poly_bb_p pbb;
> -  poly_dr_p pdr;
> -  isl_space *space = isl_set_get_space (scop->param_context);
> -  isl_union_map *res = isl_union_map_empty (space);
> -
> -  FOR_EACH_VEC_ELT (scop->pbbs, i, pbb)
> -{
> -  FOR_EACH_VEC_ELT (PBB_DRS (pbb), j, pdr)
> -   if (pdr_write_p (pdr))
> +   else if (pdr_write_p (pdr))
>   {
> if (dump_file)
>   {
> @@ -121,33 +103,14 @@ scop_get_must_writes (scop_p scop)
>   }
> isl_union_map *um
>   = isl_union_map_from_map (add_pdr_constraints (pdr, pbb));
> -   res = isl_union_map_union (res, um);
> +   must_writes = isl_union_map_union (must_writes, um);
> if (dump_file)
>   {
> fprintf (dump_file, "Must writes depedence graph: ");
> -   print_isl_union_map (dump_file, res);
> +   print_isl_union_map (dump_file, must_writes);
>   }
>   }
> -}
> -
> -  return isl_union_map_coalesce (res);
> -}
> -
> -/* Returns all the memory may writes in SCOP.  */
> -
> -static isl_union_map *
> -scop_get_may_writes (scop_p scop)
> -{
> -  int i, j;
> -  poly_bb_p pbb;
> -  poly_dr_p pdr;
> -  isl_space *space = isl_set_get_space (scop->param_context);
> -  isl_union_map *res = isl_union_map_empty (space);
> -
> -  FOR_EACH_VEC_ELT (scop->pbbs, i, pbb)
> -{
> -  FOR_EACH_VEC_ELT (PBB_DRS (pbb), j, pdr)
> -   if (pdr_may_write_p (pdr))
> +   else if (pdr_may_write_p (pdr))
>   {
> if (dump_file)
>   {
> @@ -156,16 +119,15 @@ scop_get_may_writes (scop_p scop)
>   }
> isl_union_map *um
>   = isl_union_map_from_map (add_pdr_constraints (pdr, pbb));
> -   res = isl_union_map_union (res, um);
> +   may_writes = isl_union_map_union (may_writes, um);
> if (dump_file)
>   {
> fprintf (dump_file, "May writes depedence graph: ");
> -   print_isl_union_map (dump_file, res);
> +   print_isl_union_map (dump_file, may_writes);
>   }
>   }
> +  }
>  }
> -
> -  return isl_union_map_coalesce (res);
>  }
>
>  /* Helper function used on each MAP of a isl_union_map.  Computes the
> @@ -300,9 +262,11 @@ scop_get_dependences (scop_p scop)
>if (scop->depe

[PATCH v3 13/14] D: The Phobos runtime library and license.

2017-10-02 Thread Iain Buclaw
Changes since last patch are updating to version 2.076.

Phobos is the one part that could be arguably not strictly necessary,
as it is not tied to the compiler in any way, and is supposed to be
agnostic to any platform.

However it is typically expected that the compiler comes with this
library included, so it might not please too many to find it absent -
e.g: why doesn't "hello world" work?

Here we are strictly a downstream user, but if pressed, there are be
parts that could be omitted if the size really is a problem. For
instance, the etc.c and std.experimental packages are nice, but not
necessary.

Regards
Iain.

---

ftp://ftp.gdcproject.org/patches/v3/13-v3-d-phobos-library.patch.xz

 libphobos/src/LICENSE_1_0.txt  |23 +
 libphobos/src/etc/c/curl.d |  2336 
 libphobos/src/etc/c/sqlite3.d  |  2126 
 libphobos/src/etc/c/zlib.d |  1788 +++
 libphobos/src/index.d  |   526 +
 libphobos/src/std/algorithm/comparison.d   |  2159 
 libphobos/src/std/algorithm/internal.d |77 +
 libphobos/src/std/algorithm/iteration.d|  5187 
 libphobos/src/std/algorithm/mutation.d |  2909 +
 libphobos/src/std/algorithm/package.d  |   198 +
 libphobos/src/std/algorithm/searching.d|  4600 +++
 libphobos/src/std/algorithm/setops.d   |  1521 +++
 libphobos/src/std/algorithm/sorting.d  |  4468 +++
 libphobos/src/std/array.d  |  3775 ++
 libphobos/src/std/ascii.d  |   729 ++
 libphobos/src/std/base64.d |  2099 
 libphobos/src/std/bigint.d |  1705 +++
 libphobos/src/std/bitmanip.d   |  4009 +++
 libphobos/src/std/c/fenv.d |14 +
 libphobos/src/std/c/freebsd/socket.d   |17 +
 libphobos/src/std/c/linux/linux.d  |70 +
 libphobos/src/std/c/linux/linuxextern.d|17 +
 libphobos/src/std/c/linux/pthread.d|17 +
 libphobos/src/std/c/linux/socket.d |82 +
 libphobos/src/std/c/linux/termios.d|12 +
 libphobos/src/std/c/linux/tipc.d   |17 +
 libphobos/src/std/c/locale.d   |15 +
 libphobos/src/std/c/math.d |14 +
 libphobos/src/std/c/osx/socket.d   |62 +
 libphobos/src/std/c/process.d  |93 +
 libphobos/src/std/c/stdarg.d   |14 +
 libphobos/src/std/c/stddef.d   |14 +
 libphobos/src/std/c/stdio.d|14 +
 libphobos/src/std/c/stdlib.d   |16 +
 libphobos/src/std/c/string.d   |14 +
 libphobos/src/std/c/time.d |14 +
 libphobos/src/std/c/wcharh.d   |14 +
 libphobos/src/std/c/windows/com.d  |11 +
 libphobos/src/std/c/windows/stat.d |15 +
 libphobos/src/std/c/windows/windows.d  |15 +
 libphobos/src/std/c/windows/winsock.d  |16 +
 libphobos/src/std/compiler.d   |58 +
 libphobos/src/std/complex.d|   994 ++
 libphobos/src/std/concurrency.d|  2531 
 libphobos/src/std/container/array.d|  2419 
 libphobos/src/std/container/binaryheap.d   |   595 +
 libphobos/src/std/container/dlist.d|  1039 ++
 libphobos/src/std/container/package.d  |  1156 ++
 libphobos/src/std/container/rbtree.d   |  2065 
 libphobos/src/std/container/slist.d|   846 ++
 libphobos/src/std/container/util.d |   189 +
 libphobos/src/std/conv.d   |  6290 ++
 libphobos/src/std/csv.d|  1701 +++
 libphobos/src/std/datetime/date.d  | 10580 
 libphobos/src/std/datetime/interval.d  |  9131 ++
 libphobos/src/std/datetime/package.d   |   733 ++
 libphobos/src/std/datetime/stopwatch.d |   425 +
 libphobos/src/std/datetime/systime.d   | 11151 +
 libphobos/src/std/datetime/timezone.d  |  4235 +++
 libphobos/src/std/demangle.d   |89 +
 libphobos/src/std/digest/crc.d |   705 ++
 libphobos/src/std/digest/digest.d  |21 +
 libphobos/src/std/digest/hmac.d|   336 +
 libphobos/src/std/digest/md.d  |   590 +
 libphobos/src/std/digest/murmurhash.d  |   755 ++
 libphobos/src/std/digest/package.d |  1171 ++
 libphobos/src/std/digest/ripemd.d  |   762 ++
 libphobos/sr

[PATCH][GRAPHITE] Test for code generation errors

2017-10-02 Thread Richard Biener

The following patch adjust GRAPHITE testing to check that existing
code generation issues occur and makes code generation ICE with
-fchecking --param graphite-allow-codegen-errors=0.  The param
is really a testsuite artifact so we can have testcases with
issues where we have papered over GRAPHITE issues with aborting
code generation.

This avoids regressing testcases that do not show code generation
issues and it allows detecting testcases that no longer show
code generation issues (so we can avoid regressing that feat later).

I'm now working on code-generation issues so that's an important
feature for me.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.

Richard.

2017-10-02  Richard Biener  

* graphite-isl-ast-to-gimple.c (set_codegen_error): With
-fchecking and --param graphite-allow-codegen-errors=0 ICE.
* params.def (PARAM_GRAPHITE_ALLOW_CODEGEN_ERRORS): New param.

* gcc.dg/graphite/graphite.exp: Add -fdump-tree-graphite-details.
* gcc.dg/graphite/id-16.c: Adjust for existing codegen errors.
* gcc.dg/graphite/pr46168.c: Likewise.
* gcc.dg/graphite/pr68756.c: Likewise.
* gcc.dg/graphite/pr69728.c: Likewise.
* gcc.dg/graphite/pr71575-2.c: Likewise.
* gcc.dg/graphite/pr77362.c: Likewise.
* gcc.dg/graphite/pr81373.c: Likewise.
* gcc.dg/graphite/run-id-pr67700-1.c: Likewise.
* gfortran.dg/graphite/interchange-1.f: Likewise.
* gfortran.dg/graphite/pr29581.f90: Likewise.
* gfortran.dg/graphite/pr42334-1.f: Likewise.
* gfortran.dg/graphite/pr42393-1.f90: Likewise.
* gfortran.dg/graphite/pr42393.f90: Likewise.
* gfortran.dg/graphite/pr47019.f: Likewise.

Index: gcc/graphite-isl-ast-to-gimple.c
===
--- gcc/graphite-isl-ast-to-gimple.c(revision 253336)
+++ gcc/graphite-isl-ast-to-gimple.c(working copy)
@@ -240,7 +240,14 @@ class translate_isl_ast_to_gimple
   void gsi_insert_earliest (gimple_seq seq);
   tree rename_all_uses (tree new_expr, basic_block new_bb, basic_block old_bb);
   bool codegen_error_p () const { return codegen_error; }
-  void set_codegen_error () { codegen_error = true; }
+
+  void set_codegen_error ()
+  {
+codegen_error = true;
+gcc_assert (! flag_checking
+   || PARAM_VALUE (PARAM_GRAPHITE_ALLOW_CODEGEN_ERRORS));
+  }
+
   bool is_constant (tree op) const
   {
 return TREE_CODE (op) == INTEGER_CST
Index: gcc/params.def
===
--- gcc/params.def  (revision 253336)
+++ gcc/params.def  (working copy)
@@ -894,6 +894,12 @@ DEFPARAM (PARAM_MAX_ISL_OPERATIONS,
  "maximum number of isl operations, 0 means unlimited",
  35, 0, 0)
 
+/* For testsuite purposes allow to check for codegen error handling.  */
+DEFPARAM (PARAM_GRAPHITE_ALLOW_CODEGEN_ERRORS,
+ "graphite-allow-codegen-errors",
+ "whether codegen errors should be ICEs when -fchecking.",
+ 0, 0, 1)
+
 /* Avoid data dependence analysis on very large loops.  */
 DEFPARAM (PARAM_LOOP_MAX_DATAREFS_FOR_DATADEPS,
  "loop-max-datarefs-for-datadeps",
Index: gcc/testsuite/gcc.dg/graphite/graphite.exp
===
--- gcc/testsuite/gcc.dg/graphite/graphite.exp  (revision 253336)
+++ gcc/testsuite/gcc.dg/graphite/graphite.exp  (working copy)
@@ -57,11 +57,11 @@ set vect_files[lsort [glob -noco
 # Tests to be compiled.
 set dg-do-what-default compile
 dg-runtest $scop_files"" "-O2 -fgraphite -fdump-tree-graphite-all"
-dg-runtest $id_files  "" "-O2 -fgraphite-identity -ffast-math"
+dg-runtest $id_files  "" "-O2 -fgraphite-identity -ffast-math 
-fdump-tree-graphite-details"
 
 # Tests to be run.
 set dg-do-what-default run
-dg-runtest $run_id_files  "" "-O2 -fgraphite-identity"
+dg-runtest $run_id_files  "" "-O2 -fgraphite-identity 
-fdump-tree-graphite-details"
 dg-runtest $opt_files "" "-O2 -ffast-math -floop-nest-optimize 
-fdump-tree-graphite-all"
 
 # Vectorizer tests, to be run or compiled, depending on target capabilities.
Index: gcc/testsuite/gcc.dg/graphite/id-16.c
===
--- gcc/testsuite/gcc.dg/graphite/id-16.c   (revision 253336)
+++ gcc/testsuite/gcc.dg/graphite/id-16.c   (working copy)
@@ -1,3 +1,5 @@
+/* { dg-additional-options "--param graphite-allow-codegen-errors=1" } */
+
 int transformation[(2*19 - 1) * (2*19 - 1)][8];
 
 const int transformation2[8][2][2] = {
@@ -42,3 +44,5 @@ transformation_init (void)
}
 }
 }
+
+/* { dg-final { scan-tree-dump-times "code generation error" 1 "graphite" } } 
*/
Index: gcc/testsuite/gcc.dg/graphite/pr46168.c
===
--- gcc/testsuite/gcc.dg/graphite/pr46168.c (revision 253336)

Re: [PATCH], Add PowerPC ISA 3.0 IEEE 128-bit floating point round to odd built-in functions

2017-10-02 Thread Segher Boessenkool
On Fri, Sep 29, 2017 at 08:42:45PM +, Joseph Myers wrote:
> On Fri, 29 Sep 2017, Joseph Myers wrote:
> 
> > On Fri, 29 Sep 2017, Segher Boessenkool wrote:
> > 
> > > How do other ports deal with this?  Insns with a specific rounding mode?
> > > Have a separate unspec for every operation?  Not very nice either :-(
> > 
> > Well, ideally you'd have a machine-independent representation of constant 
> > rounding modes that could be used with the TS 18661-1 FENV_ROUND pragma, 
> > respectively FENV_DEC_ROUND for decimal floating point (as the standard 
> > machine-independent way of accessing such a facility at the C language 
> > level - you'd then need to extend it to handle round-to-odd, but given the 
> > basic facility, accepting additional rounding mode names with it should be 
> > easy).  But I don't know what that would look like in either GIMPLE or 
> > RTL, and I'd certainly expect it to be a large project (quite likely 
> > depending on other large projects to handle dynamic rounding modes 
> > properly through optimizers).  So you probably can't do much better than 
> > lots of unspecs and machine-specific built-in functions at present.
> 
> (But the answer to your question seems to be that AVX512 uses something 
> involving UNSPEC_EMBEDDED_ROUNDING.)

Thanks.

So this seems to be the same as Mike's patch does.  I was hoping for a
nifty trick, not another huge project :-)  Oh well.


Segher


Re: [PATCH][PR sanitizer/77631] Support separate debug info in libbacktrace

2017-10-02 Thread Martin Liška
Hi.

Currently I see with --with-build-config=bootstrap-ubsan:

/home/marxin/BIG/buildbot/slave/gcc-master-bootstrap-ubsan/build/builddir/prev-x86_64-pc-linux-gnu/libsanitizer/ubsan/.libs/libubsan.a(elf.o):
 In function `backtrace_uncompress_zdebug':
/home/marxin/BIG/buildbot/slave/gcc-master-bootstrap-ubsan/build/builddir/x86_64-pc-linux-gnu/libsanitizer/libbacktrace/../../.././../libsanitizer/libbacktrace/../../libbacktrace/elf.c:2489:
 multiple definition of `backtrace_uncompress_zdebug'
../libbacktrace/.libs/libbacktrace.a(elf.o):/home/marxin/BIG/buildbot/slave/gcc-master-bootstrap-ubsan/build/builddir/libbacktrace/.././../libbacktrace/elf.c:2489:
 first defined here
collect2: error: ld returned 1 exit status
make[3]: *** [Makefile:2904: gcov] Error 1
make[3]: *** Waiting for unfinished jobs

Thanks,
Martin


Re: [committed][PATCH] Simplify relationals into simple equality conditionals in DOM

2017-10-02 Thread Trevor Saunders
On Sun, Oct 01, 2017 at 09:22:56AM -0600, Jeff Law wrote:
> 
> A short while ago Martin Liska posted a patch that lowered certain
> switch statements into cascading conditionals.
> 
> His work tripped two regressions in the testsuite, both cases where we
> did not optimize as well as we should have.
> 
> Upon investigation I realized a simple improvement to DOM would fix
> things up.  Further testing showed that the situation occurred
> reasonably often in practice and that the situation did occur even when
> VRP was enabled.
> 
> What we want to do is detect cases where we have something like this in
> the expression hash table
> 
> TRUE = (i <= 1)
> 
> And we're presented with the condition we want to optimize like (i >= 1)
> 
> The only value of i that satisfies both is i == 1  So we can change the
> conditional to (i == 1).
> 
> The simplified conditional is useful because it exposes a constant in
> one arm of the conditional which we can propagate.  Furthermore the
> equality test is easier for tree-ssa-uninit.c to consume.
> 
> The implementation is pretty simple.  For  X GE/LE Y we lookup X LE/GE Y
> and if we get a hit then we know we can optimize the conditional to X ==
> Y.  If Y is a constant, we can handle GT/LT with trivial canonicalization.
> 
> The testcase I've added is potentially overly simplistic -- it'll likely
> be compromised by work from Aldy or Andrew at some point.   We'll likely
> have to reduce a new testcase at that time.

Wouldn't testing this with the gimple fe make this much less of an
issue?

Thanks

Trev



Re: [PATCH][PR sanitizer/77631] Support separate debug info in libbacktrace

2017-10-02 Thread Jakub Jelinek
On Mon, Oct 02, 2017 at 01:12:24PM +0200, Martin Liška wrote:
> Hi.
> 
> Currently I see with --with-build-config=bootstrap-ubsan:
> 
> /home/marxin/BIG/buildbot/slave/gcc-master-bootstrap-ubsan/build/builddir/prev-x86_64-pc-linux-gnu/libsanitizer/ubsan/.libs/libubsan.a(elf.o):
>  In function `backtrace_uncompress_zdebug':
> /home/marxin/BIG/buildbot/slave/gcc-master-bootstrap-ubsan/build/builddir/x86_64-pc-linux-gnu/libsanitizer/libbacktrace/../../.././../libsanitizer/libbacktrace/../../libbacktrace/elf.c:2489:
>  multiple definition of `backtrace_uncompress_zdebug'
> ../libbacktrace/.libs/libbacktrace.a(elf.o):/home/marxin/BIG/buildbot/slave/gcc-master-bootstrap-ubsan/build/builddir/libbacktrace/.././../libbacktrace/elf.c:2489:
>  first defined here
> collect2: error: ld returned 1 exit status
> make[3]: *** [Makefile:2904: gcov] Error 1
> make[3]: *** Waiting for unfinished jobs

I think this should fix it, I'm going to bootstrap/regtest this now (though
not --with-build-config=bootstrap-ubsan).

2017-10-02  Jakub Jelinek  

* libbacktrace/backtrace-rename.h (backtrace_uncompress_zdebug):
Define.

--- libsanitizer/libbacktrace/backtrace-rename.h.jj 2014-09-25 
15:01:25.0 +0200
+++ libsanitizer/libbacktrace/backtrace-rename.h2017-10-02 
13:30:23.096271411 +0200
@@ -11,6 +11,7 @@
 #define backtrace_qsort __asan_backtrace_qsort
 #define backtrace_release_view __asan_backtrace_release_view
 #define backtrace_syminfo __asan_backtrace_syminfo
+#define backtrace_uncompress_zdebug __asan_backtrace_uncompress_zdebug
 #define backtrace_vector_finish __asan_backtrace_vector_finish
 #define backtrace_vector_grow __asan_backtrace_vector_grow
 #define backtrace_vector_release __asan_backtrace_vector_release


Jakub


Re: libbacktrace patch committed: Support compressed debug sections

2017-10-02 Thread Thomas Schwinge
Hi!

On Thu, 28 Sep 2017 17:30:53 -0700, Ian Lance Taylor  wrote:
> This patch to libbacktrace adds support for compressed debug sections.
> [...]

> --- ztest.c   (revision 0)
> +++ ztest.c   (working copy)
> @@ -0,0 +1,446 @@
> +/* ztest.c -- Test for libbacktrace inflate code.
> +[...]
> +  cid = CLOCK_REALTIME;
> +#ifdef CLOCK_PROCESS_CPUTIME_ID
> +  cid = CLOCK_PROCESS_CPUTIME_ID;
> +#endif
> +  if (clock_gettime (cid, &ts1) < 0)
> +[...]

On an elderly system, I ran into that not linking, and thus *all*
libbacktrace testing disappearing:

[...]
{+ztest-ztest.o: In function `test_large':+}
{+[...]/source-gcc/libbacktrace/ztest.c:350: undefined reference to 
`clock_gettime'+}
{+[...]/source-gcc/libbacktrace/ztest.c:368: undefined reference to 
`clock_gettime'+}
{+[...]/source-gcc/libbacktrace/ztest.c:378: undefined reference to 
`clock_gettime'+}
{+[...]/source-gcc/libbacktrace/ztest.c:387: undefined reference to 
`clock_gettime'+}
{+collect2: error: ld returned 1 exit status+}
{+make[3]: *** [ztest] Error 1+}
[...]
[-make[3]: Leaving directory `[...]/build-gcc/libbacktrace'-]
[-make  check-TESTS-]
[-make[3]: Entering directory `[...]/build-gcc/libbacktrace'-]
[-objcopy --only-keep-debug btest btest.debug-]
[-objcopy --strip-debug --add-gnu-debuglink=btest.debug btest dtest-]
[-PASS: backtrace_full noinline-]
[-PASS: backtrace_full inline-]
[-PASS: backtrace_simple noinline-]
[-PASS: backtrace_simple inline-]
[-PASS: backtrace_syminfo variable-]
[-PASS: btest-]
[-PASS: stest-]
[-PASS: backtrace_full alloc stress-]
[-PASS: edtest-]
[-PASS: threaded backtrace_full noinline-]
[-PASS: ttest-]
[-PASS: backtrace_full noinline-]
[-PASS: backtrace_full inline-]
[-PASS: backtrace_simple noinline-]
[-PASS: backtrace_simple inline-]
[-PASS: backtrace_syminfo variable-]
[-PASS: dtest-]
[-==[PID][PID][PID][PID]-]
[-All 5 tests passed-]
[-==[PID][PID][PID][PID]-]
make[3]: Leaving directory `[...]/build-gcc/libbacktrace'
{+make[2]: *** [check-am] Error 2+}
{+make[2]: Target `check' not remade because of errors.+}
make[2]: Leaving directory `[...]/build-gcc/libbacktrace'
{+make[1]: *** [check-libbacktrace] Error 2+}
[...]

Committed to trunk r253344, as obvious:

commit c476d11ef7dbd508067067fbd0b8450d27f1f057
Author: tschwinge 
Date:   Mon Oct 2 11:56:25 2017 +

libbacktrace: Conditionalize test timing on clock_gettime availability

libbacktrace/
PR other/67165
* configure.ac: Check for clock_gettime.
* config.h.in: Regenerate.
* configure: Likewise.
* ztest.c (average_time, test_large): Conditionalize test timing
on clock_gettime availability.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@253344 
138bc75d-0d04-0410-961f-82ee72b054a4
---
 libbacktrace/ChangeLog|  9 +
 libbacktrace/config.h.in  |  3 +++
 libbacktrace/configure| 13 +
 libbacktrace/configure.ac |  3 +++
 libbacktrace/ztest.c  | 12 +++-
 5 files changed, 39 insertions(+), 1 deletion(-)

diff --git libbacktrace/ChangeLog libbacktrace/ChangeLog
index 9597a68..0e4cfd2 100644
--- libbacktrace/ChangeLog
+++ libbacktrace/ChangeLog
@@ -1,3 +1,12 @@
+2017-10-02  Thomas Schwinge  
+
+   PR other/67165
+   * configure.ac: Check for clock_gettime.
+   * config.h.in: Regenerate.
+   * configure: Likewise.
+   * ztest.c (average_time, test_large): Conditionalize test timing
+   on clock_gettime availability.
+
 2017-09-29  Tony Reix  
 
* xcoff.c: Initial support for DWARF debug sections in XCOFF.
diff --git libbacktrace/config.h.in libbacktrace/config.h.in
index a9f70da..c19b6e4 100644
--- libbacktrace/config.h.in
+++ libbacktrace/config.h.in
@@ -9,6 +9,9 @@
 /* Define to 1 if you have the __atomic functions */
 #undef HAVE_ATOMIC_FUNCTIONS
 
+/* Define to 1 if you have the `clock_gettime' function. */
+#undef HAVE_CLOCK_GETTIME
+
 /* Define to 1 if you have the declaration of `strnlen', and to 0 if you
don't. */
 #undef HAVE_DECL_STRNLEN
diff --git libbacktrace/configure libbacktrace/configure
index ece4151..062dc77 100755
--- libbacktrace/configure
+++ libbacktrace/configure
@@ -12747,6 +12747,19 @@ $as_echo "#define HAVE_GETEXECNAME 1" >>confdefs.h
 
 fi
 
+# Check for the clock_gettime function.
+for ac_func in clock_gettime
+do :
+  ac_fn_c_check_func "$LINENO" "clock_gettime" "ac_cv_func_clock_gettime"
+if test "x$ac_cv_func_clock_gettime" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_CLOCK_GETTIME 1
+_ACEOF
+
+fi
+done
+
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -pthread is 
supported" >&5
 $as_echo_n "checking whether -pthread is supported... " >&6; }
 if test "${libgo_cv_lib_pthread+set}" = set; then :
diff --git libbacktrace/configure.ac libbac

Re: libbacktrace patch committed: Support compressed debug sections

2017-10-02 Thread Thomas Schwinge
Hi!

On Mon, 02 Oct 2017 14:00:36 +0200, I wrote:
> On Thu, 28 Sep 2017 17:30:53 -0700, Ian Lance Taylor  wrote:
> > This patch to libbacktrace adds support for compressed debug sections.
> > [...]
> 
> > --- ztest.c (revision 0)
> > +++ ztest.c (working copy)
> > @@ -0,0 +1,446 @@
> > +/* ztest.c -- Test for libbacktrace inflate code.
> > +[...]
> > +  cid = CLOCK_REALTIME;
> > +#ifdef CLOCK_PROCESS_CPUTIME_ID
> > +  cid = CLOCK_PROCESS_CPUTIME_ID;
> > +#endif
> > +  if (clock_gettime (cid, &ts1) < 0)
> > +[...]
> 
> On an elderly system, I ran into that not linking [...]

> {+ztest-ztest.o: In function `test_large':+}
> {+[...]/source-gcc/libbacktrace/ztest.c:350: undefined reference to 
> `clock_gettime'+}

That's because the version of glibc used still provided clock_gettime in
librt only.

Committed to trunk r253345, as obvious:

commit 0b986d3d7a36d3b3f84a0221f8a48af55e9aa08a
Author: tschwinge 
Date:   Mon Oct 2 11:56:39 2017 +

libbacktrace: Support the case that clock_gettime is in librt

libbacktrace/
PR other/67165
* Makefile.am: Append the content of clock_gettime_link to
ztest_LDADD.
* configure.ac: Test for the case that clock_gettime is in librt.
* Makefile.in: Regenerate.
* configure: Likewise.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@253345 
138bc75d-0d04-0410-961f-82ee72b054a4
---
 libbacktrace/ChangeLog|  7 ++
 libbacktrace/Makefile.am  |  1 +
 libbacktrace/Makefile.in  |  6 +++--
 libbacktrace/configure| 56 +--
 libbacktrace/configure.ac | 12 ++
 5 files changed, 78 insertions(+), 4 deletions(-)

diff --git libbacktrace/ChangeLog libbacktrace/ChangeLog
index 0e4cfd2..fde5a1b 100644
--- libbacktrace/ChangeLog
+++ libbacktrace/ChangeLog
@@ -1,6 +1,13 @@
 2017-10-02  Thomas Schwinge  
 
PR other/67165
+   * Makefile.am: Append the content of clock_gettime_link to
+   ztest_LDADD.
+   * configure.ac: Test for the case that clock_gettime is in librt.
+   * Makefile.in: Regenerate.
+   * configure: Likewise.
+
+   PR other/67165
* configure.ac: Check for clock_gettime.
* config.h.in: Regenerate.
* configure: Likewise.
diff --git libbacktrace/Makefile.am libbacktrace/Makefile.am
index 11d94eb..b4f4df4 100644
--- libbacktrace/Makefile.am
+++ libbacktrace/Makefile.am
@@ -108,6 +108,7 @@ ztest_LDADD = libbacktrace.la
 if HAVE_ZLIB
 ztest_LDADD += -lz
 endif
+ztest_LDADD += $(clock_gettime_link)
 
 check_PROGRAMS += ztest
 
diff --git libbacktrace/Makefile.in libbacktrace/Makefile.in
index ceb769d..30a1442 100644
--- libbacktrace/Makefile.in
+++ libbacktrace/Makefile.in
@@ -165,7 +165,7 @@ ttest_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) 
$(LIBTOOLFLAGS) \
 @NATIVE_TRUE@  ztest-testlib.$(OBJEXT)
 ztest_OBJECTS = $(am_ztest_OBJECTS)
 @NATIVE_TRUE@ztest_DEPENDENCIES = libbacktrace.la \
-@NATIVE_TRUE@  $(am__DEPENDENCIES_1)
+@NATIVE_TRUE@  $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
 ztest_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CCLD) $(ztest_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
$(LDFLAGS) -o $@
@@ -287,6 +287,7 @@ build_cpu = @build_cpu@
 build_os = @build_os@
 build_vendor = @build_vendor@
 builddir = @builddir@
+clock_gettime_link = @clock_gettime_link@
 datadir = @datadir@
 datarootdir = @datarootdir@
 docdir = @docdir@
@@ -383,7 +384,8 @@ TESTS = $(check_PROGRAMS) $(am__append_4)
 @NATIVE_TRUE@stest_LDADD = libbacktrace.la
 @NATIVE_TRUE@ztest_SOURCES = ztest.c testlib.c
 @NATIVE_TRUE@ztest_CFLAGS = -DSRCDIR=\"$(srcdir)\"
-@NATIVE_TRUE@ztest_LDADD = libbacktrace.la $(am__append_2)
+@NATIVE_TRUE@ztest_LDADD = libbacktrace.la $(am__append_2) \
+@NATIVE_TRUE@  $(clock_gettime_link)
 @NATIVE_TRUE@edtest_SOURCES = edtest.c edtest2_build.c testlib.c
 @NATIVE_TRUE@edtest_LDADD = libbacktrace.la
 @HAVE_PTHREAD_TRUE@@NATIVE_TRUE@ttest_SOURCES = ttest.c testlib.c
diff --git libbacktrace/configure libbacktrace/configure
index 062dc77..57ca5eb 100755
--- libbacktrace/configure
+++ libbacktrace/configure
@@ -614,6 +614,7 @@ HAVE_ZLIB_TRUE
 HAVE_PTHREAD_FALSE
 HAVE_PTHREAD_TRUE
 PTHREAD_CFLAGS
+clock_gettime_link
 BACKTRACE_USES_MALLOC
 ALLOC_FILE
 VIEW_FILE
@@ -11145,7 +11146,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11148 "configure"
+#line 11149 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11251,7 +11252,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11254 "configure"
+#line 11255 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12759,6 +12760,57 @@ _ACEOF
 fi
 done
 
+clock_gettime_link=
+# At least for glibc, clock_gettime is in librt.  But don't
+# pull that in if it still doesn't give us the function 

Re: Backtrace library [3/3]

2017-10-02 Thread Thomas Schwinge
Hi!

On Fri, 22 Sep 2017 09:26:19 +0200 (CEST), Richard Biener  
wrote:
> On Thu, 21 Sep 2017, Matthias Klose wrote:
> > On 21.09.2017 17:50, Ian Lance Taylor via gcc-patches wrote:
> > > On Thu, Sep 21, 2017 at 4:52 AM, Thomas Schwinge
> > >  wrote:
> > >> I just happened to notice that contrib/gcc_update never got updated for
> > >> libbacktrace.  OK to commit [...]

> > > Fine by me.  Thanks.
> > 
> > ok to backport to the active branches?
> 
> This one specifically?  Yes.

Thanks for the review, and thinking about the release branches, too.

As posted, committed to trunk r253346:

commit 9df4986761da78fddce6c63b7d13b455802b059d
Author: tschwinge 
Date:   Mon Oct 2 11:56:50 2017 +

Handle libbacktrace in contrib/gcc_update

contrib/
* gcc_update (files_and_dependencies): Handle libbacktrace.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@253346 
138bc75d-0d04-0410-961f-82ee72b054a4
---
 contrib/ChangeLog  | 4 
 contrib/gcc_update | 4 
 2 files changed, 8 insertions(+)

diff --git contrib/ChangeLog contrib/ChangeLog
index 45ccc16..df4b1bc 100644
--- contrib/ChangeLog
+++ contrib/ChangeLog
@@ -1,3 +1,7 @@
+2017-10-02  Thomas Schwinge  
+
+   * gcc_update (files_and_dependencies): Handle libbacktrace.
+
 2017-09-18  Richard Biener  
 
* download_prerequisites (isl): Bump version to 0.18.
diff --git contrib/gcc_update contrib/gcc_update
index 8c11195..2e5d5ff 100755
--- contrib/gcc_update
+++ contrib/gcc_update
@@ -168,6 +168,10 @@ liboffloadmic/configure: liboffloadmic/configure.ac
 liboffloadmic/plugin/aclocal.m4: liboffloadmic/plugin/configure.ac
 liboffloadmic/plugin/Makefile.in: liboffloadmic/plugin/Makefile.am
 liboffloadmic/plugin/configure: liboffloadmic/plugin/configure.ac
+libbacktrace/aclocal.m4: libbacktrace/configure.ac
+libbacktrace/Makefile.in: libbacktrace/Makefile.am libbacktrace/aclocal.m4
+libbacktrace/configure: libbacktrace/configure.ac libbacktrace/aclocal.m4
+libbacktrace/config.h.in: libbacktrace/configure.ac libbacktrace/aclocal.m4
 # Top level
 Makefile.in: Makefile.tpl Makefile.def
 configure: configure.ac config/acx.m4

..., gcc-7-branch r253347:

commit 4db7352aa2dabf8ed7ab11f1c79f6e4fd4f86709
Author: tschwinge 
Date:   Mon Oct 2 11:58:11 2017 +

Handle libbacktrace in contrib/gcc_update

contrib/
* gcc_update (files_and_dependencies): Handle libbacktrace.

trunk r253346

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-7-branch@253347 
138bc75d-0d04-0410-961f-82ee72b054a4
---
 contrib/ChangeLog  | 4 
 contrib/gcc_update | 4 
 2 files changed, 8 insertions(+)

diff --git contrib/ChangeLog contrib/ChangeLog
index b030f67..e5b4ee8 100644
--- contrib/ChangeLog
+++ contrib/ChangeLog
@@ -1,3 +1,7 @@
+2017-10-02  Thomas Schwinge  
+
+   * gcc_update (files_and_dependencies): Handle libbacktrace.
+
 2017-08-14  Release Manager
 
* GCC 7.2.0 released.
diff --git contrib/gcc_update contrib/gcc_update
index fe643af..47fff16 100755
--- contrib/gcc_update
+++ contrib/gcc_update
@@ -172,6 +172,10 @@ liboffloadmic/configure: liboffloadmic/configure.ac
 liboffloadmic/plugin/aclocal.m4: liboffloadmic/plugin/configure.ac
 liboffloadmic/plugin/Makefile.in: liboffloadmic/plugin/Makefile.am
 liboffloadmic/plugin/configure: liboffloadmic/plugin/configure.ac
+libbacktrace/aclocal.m4: libbacktrace/configure.ac
+libbacktrace/Makefile.in: libbacktrace/Makefile.am libbacktrace/aclocal.m4
+libbacktrace/configure: libbacktrace/configure.ac libbacktrace/aclocal.m4
+libbacktrace/config.h.in: libbacktrace/configure.ac libbacktrace/aclocal.m4
 # Top level
 Makefile.in: Makefile.tpl Makefile.def
 configure: configure.ac config/acx.m4

..., gcc-6-branch r253348:

commit 163a2819fe7ad4746542eaf5afe727838d30dc14
Author: tschwinge 
Date:   Mon Oct 2 11:58:32 2017 +

Handle libbacktrace in contrib/gcc_update

contrib/
* gcc_update (files_and_dependencies): Handle libbacktrace.

trunk r253346

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-6-branch@253348 
138bc75d-0d04-0410-961f-82ee72b054a4
---
 contrib/ChangeLog  | 4 
 contrib/gcc_update | 4 
 2 files changed, 8 insertions(+)

diff --git contrib/ChangeLog contrib/ChangeLog
index 552c05c..2ca2cdd 100644
--- contrib/ChangeLog
+++ contrib/ChangeLog
@@ -1,3 +1,7 @@
+2017-10-02  Thomas Schwinge  
+
+   * gcc_update (files_and_dependencies): Handle libbacktrace.
+
 2017-07-04  Release Manager
 
* GCC 6.4.0 released.
diff --git contrib/gcc_update contrib/gcc_update
index 2df9da4..29329d5 100755
--- contrib/gcc_update
+++ contrib/gcc_update
@@ -173,6 +173,10 @@ liboffloadmic/configure: liboffloadmic/configure.ac
 liboffloadmic/plugin/aclocal.m4: liboffloadmic/plugin/configure.ac
 liboffloadmic/plugin/Makefile.in: liboffloadmic/plugin/Makefile.am
 liboffloadmic/plugin/configure: liboffloadmic/plugin/configure.ac
+libbacktrace/aclocal.m4: libbacktrace/co

[PATCH][GCC][testsuite][mid-end][ARM][AARCH64] Fix failing vec align tests.

2017-10-02 Thread Tamar Christina
Hi All,

Previously I had corrected the vect_hw_misalign check which prompted these
three test to start failing because the condition needs to be inverted in the
testcases.

Regtested on aarch64-none-elf, arm-none-linux-gnueabihf and x86_64-pc-linux-gnu.

Ok for trunk?

Thanks,
Tamar.

gcc/testsuite/
2017-10-02  Tamar Christina  

* gcc.dg/vect/vect-align-1.c: Fix vect_hw_misalign condition.
* gcc.dg/vect/vect-align-2.c: Likewise.
* gcc.dg/vect/vect-multitypes-1.c: Likewise.

-- 
diff --git a/gcc/testsuite/gcc.dg/vect/vect-align-1.c b/gcc/testsuite/gcc.dg/vect/vect-align-1.c
index ea5ac0444fab4b6139e0e4b1019a98d92291ed4a..d56898c4d23406b4c8cc53fa1409974b6ab05485 100644
--- a/gcc/testsuite/gcc.dg/vect/vect-align-1.c
+++ b/gcc/testsuite/gcc.dg/vect/vect-align-1.c
@@ -47,6 +47,6 @@ int main (void)
   return 0;
 }
 
-/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 1 "vect" { target vect_hw_misalign } } } */
-/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 1 "vect" { xfail vect_hw_misalign} } } */
+/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 1 "vect" { target { vect_hw_misalign && { arm_vect_no_misalign } } } } } */
+/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 1 "vect" { target { vect_hw_misalign && arm_vect_no_misalign } } } } */
 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
diff --git a/gcc/testsuite/gcc.dg/vect/vect-align-2.c b/gcc/testsuite/gcc.dg/vect/vect-align-2.c
index 200d556927446cd706f454a388d3a83a004004e2..39708648703357e9360e0b63ca7070c4c21def03 100644
--- a/gcc/testsuite/gcc.dg/vect/vect-align-2.c
+++ b/gcc/testsuite/gcc.dg/vect/vect-align-2.c
@@ -43,5 +43,5 @@ int main (void)
 
 
 /* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 0 "vect" } } */
-/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 1 "vect" { xfail vect_hw_misalign} } } */
+/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 1 "vect" { target { vect_hw_misalign && arm_vect_no_misalign } } } } */
 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
diff --git a/gcc/testsuite/gcc.dg/vect/vect-multitypes-1.c b/gcc/testsuite/gcc.dg/vect/vect-multitypes-1.c
index fd7cacb483d9cfbea6d909ba12e67544fa32a190..836fa76d7887c8f67cb634021ab3c01f08da7a70 100644
--- a/gcc/testsuite/gcc.dg/vect/vect-multitypes-1.c
+++ b/gcc/testsuite/gcc.dg/vect/vect-multitypes-1.c
@@ -83,5 +83,5 @@ int main (void)
 
 /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" { xfail { vect_no_align && { ! vect_hw_misalign } } } } } */
 /* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 2 "vect" { xfail {{ vect_no_align && { ! vect_hw_misalign } } || {vect_sizes_32B_16B }}} } } */
-/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 4 "vect" { xfail {{ vect_no_align && { ! vect_hw_misalign } } || {vect_sizes_32B_16B }}} } } */
+/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 4 "vect" { target {{ vect_no_align && { ! vect_hw_misalign } } || {vect_sizes_32B_16B }}} } } */
 



[GCC][PATCH][testsuite][mid-end] Fix failing slp test on aarch64 and arm.

2017-10-02 Thread Tamar Christina
Hi All,

The slp vectorization test currently fails on AArch32 and AArch64
due to it not taking into account that we do have 128 bit vectors in
NEON. This means that two of the loops get vectorized instead of just 1.

So update the conditions to include a check for neon.

Regtested on aarch64-none-elf.

Respin of patch https://gcc.gnu.org/ml/gcc-patches/2017-09/msg01805.html

Ok for trunk?

Thanks,
Tamar.

gcc/testsuite/
2017-10-02  Tamar Christina  

* gcc.dg/vect/slp-perm-9.c: Use vect_sizes_16B_8B.
* lib/target-supports.exp (vect_sizes_16B_8B): New.

gcc/doc

* sourcebuild.texi (vect_sizes_16B_8B, vect_sizes_32B_16B): New.

-- 
diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi
index 56e1b4eb103ab412b29d6dcd9b556515ebc2ac63..98cebf7b58798abdcaa108daadcd6273667dc785 100644
--- a/gcc/doc/sourcebuild.texi
+++ b/gcc/doc/sourcebuild.texi
@@ -1507,6 +1507,12 @@ Target supports conversion from @code{float} to @code{unsigned int}.
 
 @item vect_max_reduc
 Target supports max reduction for vectors.
+
+@item vect_sizes_16B_8B
+Target supports 16- and 8-bytes vectors.
+
+@item vect_sizes_32B_16B
+Target supports 32- and 16-bytes vectors.
 @end table
 
 @subsubsection Thread Local Storage attributes
diff --git a/gcc/testsuite/gcc.dg/vect/slp-perm-9.c b/gcc/testsuite/gcc.dg/vect/slp-perm-9.c
index 4d9c11dcc476a8023b3eaac2ae76cc01bd0db182..b9b5a3b87ad031a5ab7421efce2c2b0fdf9145f3 100644
--- a/gcc/testsuite/gcc.dg/vect/slp-perm-9.c
+++ b/gcc/testsuite/gcc.dg/vect/slp-perm-9.c
@@ -54,8 +54,8 @@ int main (int argc, const char* argv[])
   return 0;
 }
 
-/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect"  { target { {! vect_perm } || {! vect_sizes_32B_16B } } } } } */
-/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect"  { target { { vect_perm } && { vect_sizes_32B_16B } } } } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect"  { target { {! vect_perm } || {! vect_sizes_16B_8B } } } } } */
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect"  { target { { vect_perm } && { vect_sizes_16B_8B } } } } } */
 /* { dg-final { scan-tree-dump-times "permutation requires at least three vectors" 1 "vect" { target vect_perm_short } } } */
 /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 0 "vect" { target { {! vect_perm } || {! vect_sizes_32B_16B } } } } } */
 /* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 1 "vect" { target { { vect_perm } && { vect_sizes_32B_16B } } } } } */
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 57f646ce2df5bcd5619870403242e73f6e91ff77..8ad9b602d277c28a6e34942a564d2ce05da7857f 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -7561,6 +7561,19 @@ proc check_effective_target_vect_sizes_32B_16B { } {
   }
 }
 
+# Return true if 16- and 8-bytes vectors are available.
+
+proc check_effective_target_vect_sizes_16B_8B { } {
+  if { [check_avx_available]
+   || [is-effective-target arm_neon]
+   || [istarget aarch64*-*-*] } {
+ return 1;
+  } else {
+return 0;
+  }
+}
+
+
 # Return true if 128-bits vectors are preferred even if 256-bits vectors
 # are available.
 



[PATCH] Fix recent tree-ssa-dse.c regressions (PR tree-optimization/8238[789])

2017-10-02 Thread Jakub Jelinek
Hi!

live_bytes is non-NULL always, m_live_bytes is auto_sbitmap that is
constructed in dse_dom_walker ctor:
  dse_dom_walker (cdi_direction direction)
: dom_walker (direction),
m_live_bytes (PARAM_VALUE (PARAM_DSE_MAX_OBJECT_SIZE)),
m_byte_tracking_enabled (false) {}
Whether live_bytes tracks anything right now or not is determined by
byte_tracking_enabled flag.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?

2017-10-02  Jakub Jelinek  

PR tree-optimization/82387
PR tree-optimization/82388
PR tree-optimization/82389
* tree-ssa-dse.c (dse_classify_store): Test byte_tracking_enabled
instead of live_bytes non-NULL.

* gcc.c-torture/compile/pr82389.c: New test.
* gcc.c-torture/execute/pr82387.c: New test.
* gcc.c-torture/execute/pr82388.c: New test.

--- gcc/tree-ssa-dse.c.jj   2017-09-29 23:05:40.0 +0200
+++ gcc/tree-ssa-dse.c  2017-10-02 11:04:56.231304016 +0200
@@ -577,10 +577,10 @@ dse_classify_store (ao_ref *ref, gimple
  /* If the statement is a use the store is not dead.  */
  else if (ref_maybe_used_by_stmt_p (use_stmt, ref))
{
- /* Handle common cases where we can easily build a ao_ref
+ /* Handle common cases where we can easily build an ao_ref
 structure for USE_STMT and in doing so we find that the
 references hit non-live bytes and thus can be ignored.  */
- if (live_bytes && (!gimple_vdef (use_stmt) || !temp))
+ if (byte_tracking_enabled && (!gimple_vdef (use_stmt) || !temp))
{
  if (is_gimple_assign (use_stmt))
{
--- gcc/testsuite/gcc.c-torture/compile/pr82389.c.jj2017-10-02 
12:46:39.921427169 +0200
+++ gcc/testsuite/gcc.c-torture/compile/pr82389.c   2017-10-02 
12:44:43.0 +0200
@@ -0,0 +1,13 @@
+/* PR tree-optimization/82389 */
+
+void bar (short);
+
+void
+foo (void)
+{
+  short a[5];
+  int b;
+  for (b = -1290603998; b < 5; b++)
+a[b] = 0;
+  bar (a[3]);
+}
--- gcc/testsuite/gcc.c-torture/execute/pr82387.c.jj2017-10-02 
12:46:18.474690151 +0200
+++ gcc/testsuite/gcc.c-torture/execute/pr82387.c   2017-10-02 
12:46:03.0 +0200
@@ -0,0 +1,27 @@
+/* PR tree-optimization/82387 */
+
+struct A { int b; };
+int f = 1;
+
+struct A
+foo (void)
+{
+  struct A h[] = { 
+{1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, 
+{1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, 
+{1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, 
+{1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, 
+{1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, 
+{1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, 
+{1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, 
+  };
+  return h[24];
+}
+
+int
+main ()
+{
+  struct A i = foo (), j = i;
+  j.b && (f = 0);
+  return f; 
+}
--- gcc/testsuite/gcc.c-torture/execute/pr82388.c.jj2017-10-02 
12:46:22.675638638 +0200
+++ gcc/testsuite/gcc.c-torture/execute/pr82388.c   2017-10-02 
12:45:14.0 +0200
@@ -0,0 +1,17 @@
+/* PR tree-optimization/82388 */
+
+struct A { int b; int c; int d; } e;
+
+struct A
+foo (void)
+{
+  struct A h[30] = {{0,0,0}};
+  return h[29]; 
+}
+
+int
+main ()
+{
+  e = foo ();
+  return e.b; 
+}

Jakub


[PATCH] Avoid UB in tree-ssa-{dse,alias}*

2017-10-02 Thread Jakub Jelinek
Hi!

On the following testcase we get a ref where
ref->offset fits into shwi, so does ref->size, but ref->offset + ref->size
doesn't.  I see many spots where we just assume that ref->offset + ref->size
is meaningful, so rather than adding overflow checking in all those spots,
this patch instead let us punt in those cases.

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

2017-10-02  Jakub Jelinek  

* tree-dfa.c (get_ref_base_and_extent): Set *pmax_size to -1
if *poffset + *pmax_size overflows in HOST_WIDE_INT.
Set *poffset to 0 and *psize and *pmax_size to -1 if
*poffset + *psize overflows in HOST_WIDE_INT.

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

--- gcc/tree-dfa.c.jj   2017-05-22 10:50:07.0 +0200
+++ gcc/tree-dfa.c  2017-10-02 12:29:01.103394300 +0200
@@ -654,7 +654,22 @@ get_ref_base_and_extent (tree exp, HOST_
   if (!wi::fits_shwi_p (maxsize) || wi::neg_p (maxsize))
 *pmax_size = -1;
   else
-*pmax_size = maxsize.to_shwi ();
+{
+  *pmax_size = maxsize.to_shwi ();
+  if (*poffset > HOST_WIDE_INT_MAX - *pmax_size)
+   *pmax_size = -1;
+}
+
+  /* Punt if *POFFSET + *PSIZE overflows in HOST_WIDE_INT, the callers don't
+ check for such overflows individually and assume it works.  */
+  if (*psize != -1 && *poffset > HOST_WIDE_INT_MAX - *psize)
+{
+  *poffset = 0;
+  *psize = -1;
+  *pmax_size = -1;
+
+  return exp;
+}
 
   return exp;
 }
--- gcc/testsuite/gcc.dg/pr82389.c.jj   2017-10-02 12:56:28.504213166 +0200
+++ gcc/testsuite/gcc.dg/pr82389.c  2017-10-02 12:57:46.820254081 +0200
@@ -0,0 +1,13 @@
+/* PR tree-optimization/82389 */
+/* { dg-do compile { target lp64 } } */
+/* { dg-options "-w -O3" } */
+
+struct S { char s[0x4000]; } s;
+
+void
+foo (struct S *p)
+{
+  char b[0x0000L];
+  *(struct S *)&b[0x0fffef00L] = s;
+  *p = *(struct S *)&b[0x0fffefffL];
+}

Jakub


Re: [PATCH][PR sanitizer/77631] Support separate debug info in libbacktrace

2017-10-02 Thread Jakub Jelinek
On Mon, Oct 02, 2017 at 01:32:01PM +0200, Jakub Jelinek wrote:
> On Mon, Oct 02, 2017 at 01:12:24PM +0200, Martin Liška wrote:
> > Hi.
> > 
> > Currently I see with --with-build-config=bootstrap-ubsan:
> > 
> > /home/marxin/BIG/buildbot/slave/gcc-master-bootstrap-ubsan/build/builddir/prev-x86_64-pc-linux-gnu/libsanitizer/ubsan/.libs/libubsan.a(elf.o):
> >  In function `backtrace_uncompress_zdebug':
> > /home/marxin/BIG/buildbot/slave/gcc-master-bootstrap-ubsan/build/builddir/x86_64-pc-linux-gnu/libsanitizer/libbacktrace/../../.././../libsanitizer/libbacktrace/../../libbacktrace/elf.c:2489:
> >  multiple definition of `backtrace_uncompress_zdebug'
> > ../libbacktrace/.libs/libbacktrace.a(elf.o):/home/marxin/BIG/buildbot/slave/gcc-master-bootstrap-ubsan/build/builddir/libbacktrace/.././../libbacktrace/elf.c:2489:
> >  first defined here
> > collect2: error: ld returned 1 exit status
> > make[3]: *** [Makefile:2904: gcov] Error 1
> > make[3]: *** Waiting for unfinished jobs
> 
> I think this should fix it, I'm going to bootstrap/regtest this now (though
> not --with-build-config=bootstrap-ubsan).
> 
> 2017-10-02  Jakub Jelinek  
> 
>   * libbacktrace/backtrace-rename.h (backtrace_uncompress_zdebug):
>   Define.

Committed as obvious after bootstrap/regtest on x86_64-linux and i686-linux.
> 
> --- libsanitizer/libbacktrace/backtrace-rename.h.jj   2014-09-25 
> 15:01:25.0 +0200
> +++ libsanitizer/libbacktrace/backtrace-rename.h  2017-10-02 
> 13:30:23.096271411 +0200
> @@ -11,6 +11,7 @@
>  #define backtrace_qsort __asan_backtrace_qsort
>  #define backtrace_release_view __asan_backtrace_release_view
>  #define backtrace_syminfo __asan_backtrace_syminfo
> +#define backtrace_uncompress_zdebug __asan_backtrace_uncompress_zdebug
>  #define backtrace_vector_finish __asan_backtrace_vector_finish
>  #define backtrace_vector_grow __asan_backtrace_vector_grow
>  #define backtrace_vector_release __asan_backtrace_vector_release

Jakub


[PATCH] C++17 P0067R5 std::to_chars and std::from_chars (partial)

2017-10-02 Thread Jonathan Wakely

This adds the integral overloads of std::to_chars and std::from_chars,
including the changes made by P0682R0. Support for floating point types
is absent.

This uses a number of suggestions from Lars (thanks!) but I might have
missed some of his ideas and so could be missing some potential
optimizations.

An earlier version of the patch was posted in
https://gcc.gnu.org/ml/libstdc++/2017-04/msg00025.html

* include/Makefile.am: Add new  header.
* include/Makefile.in: Regenerate.
* include/precompiled/stdc++.h: Include .
* include/std/charconv: New file.
(to_chars_result, to_chars, from_chars_result, from_chars): Define.
* testsuite/20_util/from_chars/1.cc: New test.
* testsuite/20_util/from_chars/1_neg.cc: New test.
* testsuite/20_util/from_chars/2.cc: New test.
* testsuite/20_util/from_chars/requirements.cc: New test.
* testsuite/20_util/to_chars/1.cc: New test.
* testsuite/20_util/to_chars/1_neg.cc: New test.
* testsuite/20_util/to_chars/2.cc: New test.
* testsuite/20_util/to_chars/requirements.cc: New test.

Tested powerpc64le-linux, committed to trunk.


commit 7ba3c7e0a812cf8ec33605974c052e773a77d013
Author: Jonathan Wakely 
Date:   Mon Oct 2 12:47:45 2017 +0100

C++17 P0067R5 std::to_chars and std::from_chars (partial)

This adds the integral overloads of std::to_chars and std::from_chars,
including the changes made by P0682R0. Support for floating point types
is absent.

* include/Makefile.am: Add new  header.
* include/Makefile.in: Regenerate.
* include/precompiled/stdc++.h: Include .
* include/std/charconv: New file.
(to_chars_result, to_chars, from_chars_result, from_chars): Define.
* testsuite/20_util/from_chars/1.cc: New test.
* testsuite/20_util/from_chars/1_neg.cc: New test.
* testsuite/20_util/from_chars/2.cc: New test.
* testsuite/20_util/from_chars/requirements.cc: New test.
* testsuite/20_util/to_chars/1.cc: New test.
* testsuite/20_util/to_chars/1_neg.cc: New test.
* testsuite/20_util/to_chars/2.cc: New test.
* testsuite/20_util/to_chars/requirements.cc: New test.

diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am
index 87a41f59027..236c2d6059f 100644
--- a/libstdc++-v3/include/Makefile.am
+++ b/libstdc++-v3/include/Makefile.am
@@ -31,6 +31,7 @@ std_headers = \
${std_srcdir}/array \
${std_srcdir}/atomic \
${std_srcdir}/bitset \
+   ${std_srcdir}/charconv \
${std_srcdir}/chrono \
${std_srcdir}/codecvt \
${std_srcdir}/complex \
diff --git a/libstdc++-v3/include/precompiled/stdc++.h 
b/libstdc++-v3/include/precompiled/stdc++.h
index 262743a3c1b..b2993cd379f 100644
--- a/libstdc++-v3/include/precompiled/stdc++.h
+++ b/libstdc++-v3/include/precompiled/stdc++.h
@@ -121,3 +121,7 @@
 #if __cplusplus >= 201402L
 #include 
 #endif
+
+#if __cplusplus > 201402L
+#include 
+#endif
diff --git a/libstdc++-v3/include/std/charconv 
b/libstdc++-v3/include/std/charconv
new file mode 100644
index 000..b8221e4e434
--- /dev/null
+++ b/libstdc++-v3/include/std/charconv
@@ -0,0 +1,654 @@
+// Primitive numeric conversions (to_chars and from_chars) -*- C++ -*-
+
+// Copyright (C) 2017 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+// .
+
+/** @file include/charconv
+ *  This is a Standard C++ Library header.
+ */
+
+#ifndef _GLIBCXX_CHARCONV
+#define _GLIBCXX_CHARCONV 1
+
+#pragma GCC system_header
+
+#if __cplusplus >= 201402L
+
+#include 
+#include 
+#include 
+#include  // for std::errc
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+  /// Result type of std::to_chars
+  struct to_chars_result
+  {
+char* ptr;
+errc ec;
+  };
+
+  /// Result type of std::from_chars
+  struct from_chars_result
+  {
+const char* ptr;
+errc ec;
+  

Re: [Patch][aarch64] Use IFUNCs to enable LSE instructions in libatomic on aarch64

2017-10-02 Thread Szabolcs Nagy
On 29/09/17 21:29, Steve Ellcey wrote:
> On Thu, 2017-09-28 at 12:31 +0100, Szabolcs Nagy wrote:
>>  
>> i think this should be improved, see below.
> 
> Those were all good suggestions, here is a new patch that incorporates
> the changes.  I fixed the IFUNC_OPTIONS argument,
> renamed ARCH_AARCH64_LINUX_LSE, got rid of the auxv references, and
> changed HWCAP_TYPE to IFUNC_RESOLVER_ARGS.
> 
> Here is the new patch, tested with no regressions.
> 

looks good to me, but i cannot approve.

(this will make libatomic depend on ifuncs on aarch64*-linux-gnu.)

> Steve Ellcey
> sell...@cavium.com
> 
> 
> 2017-09-29  Steve Ellcey  
> 
>   * Makefile.am (ARCH_AARCH64_LINUX): Add IFUNC_OPTIONS and
>   libatomic_la_LIBADD.
>   * config/linux/aarch64/host-config.h: New file.
>   * configure.ac (IFUNC_RESOLVER_ARGS): Define.
>   (ARCH_AARCH64_LINUX): New conditional for IFUNC builds.
>   * configure.tgt (aarch64): Set ARCH and try_ifunc.
>   (aarch64*-*-linux*) Update config_path.
>   (aarch64*-*-linux*) Set IFUNC_RESOLVER_ARGS.
>   * libatomic_i.h (GEN_SELECTOR): Add IFUNC_RESOLVER_ARGS argument.
>   * Makefile.in: Regenerate.
>   * auto-config.h.in: Regenerate.
>   * configure: Regenerate.
> 



Re: [PATCH][GRAPHITE] Test for code generation errors

2017-10-02 Thread Sebastian Pop
On Mon, Oct 2, 2017 at 4:58 AM, Richard Biener  wrote:
>
> The following patch adjust GRAPHITE testing to check that existing
> code generation issues occur and makes code generation ICE with
> -fchecking --param graphite-allow-codegen-errors=0.  The param
> is really a testsuite artifact so we can have testcases with
> issues where we have papered over GRAPHITE issues with aborting
> code generation.
>
> This avoids regressing testcases that do not show code generation
> issues and it allows detecting testcases that no longer show
> code generation issues (so we can avoid regressing that feat later).
>
> I'm now working on code-generation issues so that's an important
> feature for me.
>
> Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.
>
> Richard.
>
> 2017-10-02  Richard Biener  
>
> * graphite-isl-ast-to-gimple.c (set_codegen_error): With
> -fchecking and --param graphite-allow-codegen-errors=0 ICE.
> * params.def (PARAM_GRAPHITE_ALLOW_CODEGEN_ERRORS): New param.
>
> * gcc.dg/graphite/graphite.exp: Add -fdump-tree-graphite-details.
> * gcc.dg/graphite/id-16.c: Adjust for existing codegen errors.
> * gcc.dg/graphite/pr46168.c: Likewise.
> * gcc.dg/graphite/pr68756.c: Likewise.
> * gcc.dg/graphite/pr69728.c: Likewise.
> * gcc.dg/graphite/pr71575-2.c: Likewise.
> * gcc.dg/graphite/pr77362.c: Likewise.
> * gcc.dg/graphite/pr81373.c: Likewise.
> * gcc.dg/graphite/run-id-pr67700-1.c: Likewise.
> * gfortran.dg/graphite/interchange-1.f: Likewise.
> * gfortran.dg/graphite/pr29581.f90: Likewise.
> * gfortran.dg/graphite/pr42334-1.f: Likewise.
> * gfortran.dg/graphite/pr42393-1.f90: Likewise.
> * gfortran.dg/graphite/pr42393.f90: Likewise.
> * gfortran.dg/graphite/pr47019.f: Likewise.

Looks good.


Re: [PATCH] Avoid UB in tree-ssa-{dse,alias}*

2017-10-02 Thread Richard Biener
On October 2, 2017 3:54:18 PM GMT+02:00, Jakub Jelinek  wrote:
>Hi!
>
>On the following testcase we get a ref where
>ref->offset fits into shwi, so does ref->size, but ref->offset +
>ref->size
>doesn't.  I see many spots where we just assume that ref->offset +
>ref->size
>is meaningful, so rather than adding overflow checking in all those
>spots,
>this patch instead let us punt in those cases.
>
>Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

OK. 

Richard. 

>2017-10-02  Jakub Jelinek  
>
>   * tree-dfa.c (get_ref_base_and_extent): Set *pmax_size to -1
>   if *poffset + *pmax_size overflows in HOST_WIDE_INT.
>   Set *poffset to 0 and *psize and *pmax_size to -1 if
>   *poffset + *psize overflows in HOST_WIDE_INT.
>
>   * gcc.dg/pr82389.c: New test.
>
>--- gcc/tree-dfa.c.jj  2017-05-22 10:50:07.0 +0200
>+++ gcc/tree-dfa.c 2017-10-02 12:29:01.103394300 +0200
>@@ -654,7 +654,22 @@ get_ref_base_and_extent (tree exp, HOST_
>   if (!wi::fits_shwi_p (maxsize) || wi::neg_p (maxsize))
> *pmax_size = -1;
>   else
>-*pmax_size = maxsize.to_shwi ();
>+{
>+  *pmax_size = maxsize.to_shwi ();
>+  if (*poffset > HOST_WIDE_INT_MAX - *pmax_size)
>+  *pmax_size = -1;
>+}
>+
>+  /* Punt if *POFFSET + *PSIZE overflows in HOST_WIDE_INT, the callers
>don't
>+ check for such overflows individually and assume it works.  */
>+  if (*psize != -1 && *poffset > HOST_WIDE_INT_MAX - *psize)
>+{
>+  *poffset = 0;
>+  *psize = -1;
>+  *pmax_size = -1;
>+
>+  return exp;
>+}
> 
>   return exp;
> }
>--- gcc/testsuite/gcc.dg/pr82389.c.jj  2017-10-02 12:56:28.504213166
>+0200
>+++ gcc/testsuite/gcc.dg/pr82389.c 2017-10-02 12:57:46.820254081 +0200
>@@ -0,0 +1,13 @@
>+/* PR tree-optimization/82389 */
>+/* { dg-do compile { target lp64 } } */
>+/* { dg-options "-w -O3" } */
>+
>+struct S { char s[0x4000]; } s;
>+
>+void
>+foo (struct S *p)
>+{
>+  char b[0x0000L];
>+  *(struct S *)&b[0x0fffef00L] = s;
>+  *p = *(struct S *)&b[0x0fffefffL];
>+}
>
>   Jakub



Re: [PATCH] Fix recent tree-ssa-dse.c regressions (PR tree-optimization/8238[789])

2017-10-02 Thread Richard Biener
On October 2, 2017 3:51:04 PM GMT+02:00, Jakub Jelinek  wrote:
>Hi!
>
>live_bytes is non-NULL always, m_live_bytes is auto_sbitmap that is
>constructed in dse_dom_walker ctor:
>  dse_dom_walker (cdi_direction direction)
>: dom_walker (direction),
>m_live_bytes (PARAM_VALUE (PARAM_DSE_MAX_OBJECT_SIZE)),
>m_byte_tracking_enabled (false) {}
>Whether live_bytes tracks anything right now or not is determined by
>byte_tracking_enabled flag.
>
>Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok
>for
>trunk?

OK. 

Richard. 

>2017-10-02  Jakub Jelinek  
>
>   PR tree-optimization/82387
>   PR tree-optimization/82388
>   PR tree-optimization/82389
>   * tree-ssa-dse.c (dse_classify_store): Test byte_tracking_enabled
>   instead of live_bytes non-NULL.
>
>   * gcc.c-torture/compile/pr82389.c: New test.
>   * gcc.c-torture/execute/pr82387.c: New test.
>   * gcc.c-torture/execute/pr82388.c: New test.
>
>--- gcc/tree-ssa-dse.c.jj  2017-09-29 23:05:40.0 +0200
>+++ gcc/tree-ssa-dse.c 2017-10-02 11:04:56.231304016 +0200
>@@ -577,10 +577,10 @@ dse_classify_store (ao_ref *ref, gimple
> /* If the statement is a use the store is not dead.  */
> else if (ref_maybe_used_by_stmt_p (use_stmt, ref))
>   {
>-/* Handle common cases where we can easily build a ao_ref
>+/* Handle common cases where we can easily build an ao_ref
>structure for USE_STMT and in doing so we find that the
>references hit non-live bytes and thus can be ignored.  */
>-if (live_bytes && (!gimple_vdef (use_stmt) || !temp))
>+if (byte_tracking_enabled && (!gimple_vdef (use_stmt) ||
>!temp))
>   {
> if (is_gimple_assign (use_stmt))
>   {
>--- gcc/testsuite/gcc.c-torture/compile/pr82389.c.jj   2017-10-02
>12:46:39.921427169 +0200
>+++ gcc/testsuite/gcc.c-torture/compile/pr82389.c  2017-10-02
>12:44:43.0 +0200
>@@ -0,0 +1,13 @@
>+/* PR tree-optimization/82389 */
>+
>+void bar (short);
>+
>+void
>+foo (void)
>+{
>+  short a[5];
>+  int b;
>+  for (b = -1290603998; b < 5; b++)
>+a[b] = 0;
>+  bar (a[3]);
>+}
>--- gcc/testsuite/gcc.c-torture/execute/pr82387.c.jj   2017-10-02
>12:46:18.474690151 +0200
>+++ gcc/testsuite/gcc.c-torture/execute/pr82387.c  2017-10-02
>12:46:03.0 +0200
>@@ -0,0 +1,27 @@
>+/* PR tree-optimization/82387 */
>+
>+struct A { int b; };
>+int f = 1;
>+
>+struct A
>+foo (void)
>+{
>+  struct A h[] = { 
>+{1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, 
>+{1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, 
>+{1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, 
>+{1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, 
>+{1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, 
>+{1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, 
>+{1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}, 
>+  };
>+  return h[24];
>+}
>+
>+int
>+main ()
>+{
>+  struct A i = foo (), j = i;
>+  j.b && (f = 0);
>+  return f; 
>+}
>--- gcc/testsuite/gcc.c-torture/execute/pr82388.c.jj   2017-10-02
>12:46:22.675638638 +0200
>+++ gcc/testsuite/gcc.c-torture/execute/pr82388.c  2017-10-02
>12:45:14.0 +0200
>@@ -0,0 +1,17 @@
>+/* PR tree-optimization/82388 */
>+
>+struct A { int b; int c; int d; } e;
>+
>+struct A
>+foo (void)
>+{
>+  struct A h[30] = {{0,0,0}};
>+  return h[29]; 
>+}
>+
>+int
>+main ()
>+{
>+  e = foo ();
>+  return e.b; 
>+}
>
>   Jakub



Re: [PATCH] Fix recent tree-ssa-dse.c regressions (PR tree-optimization/8238[789])

2017-10-02 Thread Jeff Law
On 10/02/2017 07:51 AM, Jakub Jelinek wrote:
> Hi!
> 
> live_bytes is non-NULL always, m_live_bytes is auto_sbitmap that is
> constructed in dse_dom_walker ctor:
>   dse_dom_walker (cdi_direction direction)
> : dom_walker (direction),
> m_live_bytes (PARAM_VALUE (PARAM_DSE_MAX_OBJECT_SIZE)),
> m_byte_tracking_enabled (false) {}
> Whether live_bytes tracks anything right now or not is determined by
> byte_tracking_enabled flag.
> 
> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
> trunk?
> 
> 2017-10-02  Jakub Jelinek  
> 
>   PR tree-optimization/82387
>   PR tree-optimization/82388
>   PR tree-optimization/82389
>   * tree-ssa-dse.c (dse_classify_store): Test byte_tracking_enabled
>   instead of live_bytes non-NULL.
> 
>   * gcc.c-torture/compile/pr82389.c: New test.
>   * gcc.c-torture/execute/pr82387.c: New test.
>   * gcc.c-torture/execute/pr82388.c: New test.
OK.  Sorry for the breakage.  I wonder how that slipped through given
how badly it appears to be broken.

Anyway, thank for cleaning up my mess.

jeff


Re: [RFA] [PATCH 4/4] Ignore reads of "dead" memory locations in DSE

2017-10-02 Thread Richard Sandiford
Jeff Law  writes:
> @@ -468,6 +468,36 @@ maybe_trim_partially_dead_store (ao_ref *ref, sbitmap 
> live, gimple *stmt)
>  }
>  }
>  
> +/* Return TRUE if USE_REF reads bytes from LIVE where live is
> +   derived from REF, a write reference.
> +
> +   While this routine may modify USE_REF, it's passed by value, not
> +   location.  So callers do not see those modifications.  */
> +
> +static bool
> +live_bytes_read (ao_ref use_ref, ao_ref *ref, sbitmap live)
> +{
> +  /* We have already verified that USE_REF and REF hit the same object.
> + Now verify that there's actually an overlap between USE_REF and REF.  */
> +  if (ranges_overlap_p (use_ref.offset, use_ref.size, ref->offset, 
> ref->size))
> +{
> +  normalize_ref (&use_ref, ref);
> +
> +  /* If USE_REF covers all of REF, then it will hit one or more
> +  live bytes.   This avoids useless iteration over the bitmap
> +  below.  */
> +  if (use_ref.offset <= ref->offset
> +   && use_ref.offset + use_ref.size >= ref->offset + ref->size)
> + return true;
> +
> +  /* Now check if any of the remaining bits in use_ref are set in LIVE.  
> */
> +  unsigned int start = (use_ref.offset - ref->offset) / BITS_PER_UNIT;
> +  unsigned int end  = (use_ref.offset + use_ref.size) / BITS_PER_UNIT;
> +  return bitmap_bit_in_range_p (live, start, end);
> +}
> +  return true;
> +}

When rebasing the SVE changes on top of this, I wasn't sure why the
function returned true rather than false when there's no overlap.
Is that deliberate?  It might be worth a comment if so.

Thanks,
Richard


Re: [PATCH, rs6000] Follow-on fix for PR target/80210: ICE in extract_insn

2017-10-02 Thread Peter Bergner
On 9/29/17 5:31 PM, Segher Boessenkool wrote:
>> +  /* PowerPC 64-bit LE requires at least ISA 2.07.  */
>> +  const char *default_cpu = ((!TARGET_POWERPC64)
>> + ? "powerpc"
>> + : ((BYTES_BIG_ENDIAN)
>> +? "powerpc64"
>> +: "powerpc64le"));
> 
> Please remove the parens around !TARGET_POWERPC64 and BYTES_BIG_ENDIAN
> while you're at it (one of the copies you removed had that already :-) )

Done.


> Looks great to me, please commit.  But hold off until Monday please, it
> will interfere with testing otherwise.

Ok, committed now (Monday).  I'd also like to back port this to the
GCC 7 and 6 release branches, where the earlier fix was also back
ported to.  Ok there after a week or so of burn in on trunk?

Thanks.

Peter




Re: [PATCH, rs6000] Follow-on fix for PR target/80210: ICE in extract_insn

2017-10-02 Thread Segher Boessenkool
On Mon, Oct 02, 2017 at 12:00:55PM -0500, Peter Bergner wrote:
> On 9/29/17 5:31 PM, Segher Boessenkool wrote:
> >> +/* PowerPC 64-bit LE requires at least ISA 2.07.  */
> >> +const char *default_cpu = ((!TARGET_POWERPC64)
> >> +   ? "powerpc"
> >> +   : ((BYTES_BIG_ENDIAN)
> >> +  ? "powerpc64"
> >> +  : "powerpc64le"));
> > 
> > Please remove the parens around !TARGET_POWERPC64 and BYTES_BIG_ENDIAN
> > while you're at it (one of the copies you removed had that already :-) )
> 
> Done.
> 
> 
> > Looks great to me, please commit.  But hold off until Monday please, it
> > will interfere with testing otherwise.
> 
> Ok, committed now (Monday).  I'd also like to back port this to the
> GCC 7 and 6 release branches, where the earlier fix was also back
> ported to.  Ok there after a week or so of burn in on trunk?

Certainly.  Thanks!


Segher


[PR 82363] Fix thinko in SRA subaccess propagation

2017-10-02 Thread Martin Jambor
Hi,

the following fixes a thinko in propagate_subaccesses_across_link.
When we cannot copy over a tree of accesses of RHS to LHS because of
some conflict, we must mark the whole LHS access (sub-)tree as
potentially written, even when the RHS access describing this level is
not, because some of its sub-accesses might be, which is exactly what
happens in the PR.

Bootstrapped and tested on x86_64-linux.  OK for trunk?

Thanks,

Martin



2017-10-02  Martin Jambor  

PR tree-optimization/82363
* tree-sra.c (propagate_subaccesses_across_link): In unrecoverable
mismatch, mark lacc written regardless of racc.

testsuite/
* gcc.dg/tree-ssa/pr82363.c: New test.
---
 gcc/testsuite/gcc.dg/tree-ssa/pr82363.c | 50 +
 gcc/tree-sra.c  |  2 +-
 2 files changed, 51 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr82363.c

diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr82363.c 
b/gcc/testsuite/gcc.dg/tree-ssa/pr82363.c
new file mode 100644
index 000..6652468976b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr82363.c
@@ -0,0 +1,50 @@
+/* { dg-do run } */
+/* { dg-options "-O" } */
+
+struct A
+{
+  int b;
+  int c;
+  int d;
+};
+
+struct E
+{
+  int f;
+  int g:18;
+  struct A h;
+};
+
+struct I
+{
+  int b;
+  int j;
+  struct E k;
+};
+
+int l, *m = &l;
+
+struct A n;
+struct I o;
+
+void __attribute__ ((noipa))
+test_l (void)
+{
+  if (l != 1)
+__builtin_abort ();
+}
+
+int main ()
+{
+  while (1)
+{
+  struct I q = { 0, 0, {0, 0, {1, 1, 1}}}, p = q, r = p, *s = &q;
+  if (p.k.h.c)
+o = p;
+  *m = r.k.h.d;
+  n = (*s).k.h;
+  break;
+}
+  test_l ();
+  return 0;
+}
diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c
index f5675edc7f1..bac593951e7 100644
--- a/gcc/tree-sra.c
+++ b/gcc/tree-sra.c
@@ -2691,7 +2691,7 @@ propagate_subaccesses_across_link (struct access *lacc, 
struct access *racc)
}
  else
{
- if (rchild->grp_write && !lacc->grp_write)
+ if (!lacc->grp_write)
{
  ret = true;
  subtree_mark_written_and_enqueue (lacc);
-- 
2.14.1




Re: [PATCH], Define __FP_FAST_FMAF128 on PowerPC ISA 3.0

2017-10-02 Thread Michael Meissner
On Thu, Sep 28, 2017 at 12:40:24AM +, Joseph Myers wrote:
> On Wed, 27 Sep 2017, Michael Meissner wrote:
> 
> > The glibc team has requested we define the standard macro 
> > (__FP_FAST_FMAF128)
> > for PowerPC code when we have the IEEE 128-bit floating point hardware
> > instructions enabled.
> 
> It's not a standard macro.  TS 18661-3 has FP_FAST_FMAF128 as an optional 
> math.h macro (but glibc doesn't define it anywhere at present).
> 
> > This patch does this in the PowerPC backend.  As I look at the whole issue, 
> > at
> > some point we should do this more in the machine independent portion of the
> > compiler.  I have some initial patches to do this in the c-family files, 
> > but at
> > the present time, the patches are not complete, and I need to think about it
> > more.
> 
> I think a machine-independent definition (for _FloatN / _FloatNx types in 
> general) should go along with machine-independent fmafN / fmafNx built-in 
> functions; when the built-in function is machine-specific, it's natural 
> for the macro to be as well.

I have patches for this that I will submit shortly to replace the rs6000
specific patch.

I haven't yet found all of the places that need to be changed for more
traditional math functions like sqrtf128.

> But in any case, the new macro should be documented in cpp.texi alongside 
> the existing __FP_FAST_FMA* macros (probably in the generic 
> __FP_FAST_FMAF@var{n} and __FP_FAST_FMAF@var{n}X form).

-- 
Michael Meissner, IBM
IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA
email: meiss...@linux.vnet.ibm.com, phone: +1 (978) 899-4797



Re: [PR 82363] Fix thinko in SRA subaccess propagation

2017-10-02 Thread Richard Biener
On October 2, 2017 7:19:19 PM GMT+02:00, Martin Jambor  wrote:
>Hi,
>
>the following fixes a thinko in propagate_subaccesses_across_link.
>When we cannot copy over a tree of accesses of RHS to LHS because of
>some conflict, we must mark the whole LHS access (sub-)tree as
>potentially written, even when the RHS access describing this level is
>not, because some of its sub-accesses might be, which is exactly what
>happens in the PR.
>
>Bootstrapped and tested on x86_64-linux.  OK for trunk?

OK. 

Richard. 

>Thanks,
>
>Martin
>
>
>
>2017-10-02  Martin Jambor  
>
>   PR tree-optimization/82363
>   * tree-sra.c (propagate_subaccesses_across_link): In unrecoverable
>   mismatch, mark lacc written regardless of racc.
>
>   testsuite/
>   * gcc.dg/tree-ssa/pr82363.c: New test.
>---
>gcc/testsuite/gcc.dg/tree-ssa/pr82363.c | 50
>+
> gcc/tree-sra.c  |  2 +-
> 2 files changed, 51 insertions(+), 1 deletion(-)
> create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr82363.c
>
>diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr82363.c
>b/gcc/testsuite/gcc.dg/tree-ssa/pr82363.c
>new file mode 100644
>index 000..6652468976b
>--- /dev/null
>+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr82363.c
>@@ -0,0 +1,50 @@
>+/* { dg-do run } */
>+/* { dg-options "-O" } */
>+
>+struct A
>+{
>+  int b;
>+  int c;
>+  int d;
>+};
>+
>+struct E
>+{
>+  int f;
>+  int g:18;
>+  struct A h;
>+};
>+
>+struct I
>+{
>+  int b;
>+  int j;
>+  struct E k;
>+};
>+
>+int l, *m = &l;
>+
>+struct A n;
>+struct I o;
>+
>+void __attribute__ ((noipa))
>+test_l (void)
>+{
>+  if (l != 1)
>+__builtin_abort ();
>+}
>+
>+int main ()
>+{
>+  while (1)
>+{
>+  struct I q = { 0, 0, {0, 0, {1, 1, 1}}}, p = q, r = p, *s = &q;
>+  if (p.k.h.c)
>+o = p;
>+  *m = r.k.h.d;
>+  n = (*s).k.h;
>+  break;
>+}
>+  test_l ();
>+  return 0;
>+}
>diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c
>index f5675edc7f1..bac593951e7 100644
>--- a/gcc/tree-sra.c
>+++ b/gcc/tree-sra.c
>@@ -2691,7 +2691,7 @@ propagate_subaccesses_across_link (struct access
>*lacc, struct access *racc)
>   }
> else
>   {
>-if (rchild->grp_write && !lacc->grp_write)
>+if (!lacc->grp_write)
>   {
> ret = true;
> subtree_mark_written_and_enqueue (lacc);



Re: [PATCH], Add PowerPC ISA 3.0 IEEE 128-bit floating point round to odd built-in functions

2017-10-02 Thread Michael Meissner
On Fri, Sep 29, 2017 at 12:10:07PM -0500, Segher Boessenkool wrote:
> Hi Mike,
> 
> On Thu, Sep 28, 2017 at 06:34:23PM -0400, Michael Meissner wrote:
> > This patch addss built-in functions on PowerPC ISA 3.0 (power9) that allow 
> > the
> > user to access the round to odd IEEE 128-bit floating point instructions.
> 
> > --- gcc/config/rs6000/rs6000.md (revision 253267)
> > +++ gcc/config/rs6000/rs6000.md (working copy)
> > @@ -14505,7 +14505,9 @@ (define_insn_and_split "truncsf2_h
> >"#"
> >"&& 1"
> >[(set (match_dup 2)
> > -   (unspec:DF [(match_dup 1)] UNSPEC_ROUND_TO_ODD))
> > +   (unspec:DF [(float_truncate:DF
> > +(match_dup 1))]
> > +  UNSPEC_ROUND_TO_ODD))
> > (set (match_dup 0)
> > (float_truncate:SF (match_dup 2)))]
> >  {
> 
> I don't think this is correct.  It says to first truncate the f128 to DF,
> and then round it to odd; I think you want to do the truncation with
> round-to-odd rounding mode already.
> 
> > +(define_insn "mul3_odd"
> > +  [(set (match_operand:IEEE128 0 "altivec_register_operand" "=v")
> > +   (unspec:IEEE128
> > +[(mult:IEEE128
> > +  (match_operand:IEEE128 1 "altivec_register_operand" "v")
> > +  (match_operand:IEEE128 2 "altivec_register_operand" "v"))]
> > +UNSPEC_ROUND_TO_ODD))]
> > +  "TARGET_FLOAT128_HW && FLOAT128_IEEE_P (mode)"
> > +  "xsmulqpo %0,%1,%2"
> > +  [(set_attr "type" "vecfloat")
> > +   (set_attr "size" "128")])
> 
> Similar here (and everywhere else): it does an f128 mul, so rounding
> with whatever rounding mode is current, and *then* it rounds to odd.
> 
> > +(define_insn "sqrt2_odd"
> > +  [(set (match_operand:IEEE128 0 "altivec_register_operand" "=v")
> > +   (unspec:IEEE128
> > +[(sqrt:IEEE128
> > +  (match_operand:IEEE128 1 "altivec_register_operand" "v"))]
> > +UNSPEC_ROUND_TO_ODD))]
> > +  "TARGET_FLOAT128_HW && FLOAT128_IEEE_P (mode)"
> > +   "xssqrtqpo %0,%1"
> 
> (One space too many here).
> 
> Everything else looks fine, but that unspec thing needs fixing.  Can be
> later, things will likely work for now, so okay for trunk.  Thanks.
> 
> How do other ports deal with this?  Insns with a specific rounding mode?
> Have a separate unspec for every operation?  Not very nice either :-(

I just want to do the minimal work so the glibc people can use this
instruction, but I am not that motivated to go back and modify it further.  So,
I would prefer to do it right before committing it, unless you want to refine
it.

As I see it, there are 2 ways to encode the RTL:

1)  Use one UNSPEC name, and add the operation inside of the spec;

2)  Add separate UNSPEC's for each operation.

Either one is fine with me.  If you would prefer separate names, I can do it.

In theory we could do something like define_subst, but that is a large time
waster to learn how to do it for 8 specialized instructions.

Similarly, I don't see the need for doing more general support, until we have
more data types and more rounding modes.

-- 
Michael Meissner, IBM
IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA
email: meiss...@linux.vnet.ibm.com, phone: +1 (978) 899-4797



Re: [Patch, fortran] PR 82312 - [7/8 Regression] Pointer assignment to component of class variable results wrong vptr for the variable

2017-10-02 Thread Paul Richard Thomas
Committed as revision 253362.

Thanks for taking a look at it. I will wait a week or so before
committing to 7-branch.

Paul


On 1 October 2017 at 14:43, Thomas Koenig  wrote:
> Hi Paul,
>
>> Bootstraps and regtests on FC23/x86_64 - OK for trunk and 7 branch?
>
>
> OK for both. Thanks for the patch!
>
> Regards
>
> Thomas



-- 
"If you can't explain it simply, you don't understand it well enough"
- Albert Einstein


Re: [PATCH], Add PowerPC ISA 3.0 IEEE 128-bit floating point round to odd built-in functions

2017-10-02 Thread Segher Boessenkool
Hi!

On Mon, Oct 02, 2017 at 02:01:57PM -0400, Michael Meissner wrote:
> On Fri, Sep 29, 2017 at 12:10:07PM -0500, Segher Boessenkool wrote:
> > On Thu, Sep 28, 2017 at 06:34:23PM -0400, Michael Meissner wrote:
> > > --- gcc/config/rs6000/rs6000.md   (revision 253267)
> > > +++ gcc/config/rs6000/rs6000.md   (working copy)
> > > @@ -14505,7 +14505,9 @@ (define_insn_and_split "truncsf2_h
> > >"#"
> > >"&& 1"
> > >[(set (match_dup 2)
> > > - (unspec:DF [(match_dup 1)] UNSPEC_ROUND_TO_ODD))
> > > + (unspec:DF [(float_truncate:DF
> > > +  (match_dup 1))]
> > > +UNSPEC_ROUND_TO_ODD))
> > > (set (match_dup 0)
> > >   (float_truncate:SF (match_dup 2)))]
> > >  {
> > 
> > I don't think this is correct.  It says to first truncate the f128 to DF,
> > and then round it to odd; I think you want to do the truncation with
> > round-to-odd rounding mode already.
> > 
> > > +(define_insn "mul3_odd"
> > > +  [(set (match_operand:IEEE128 0 "altivec_register_operand" "=v")
> > > + (unspec:IEEE128
> > > +  [(mult:IEEE128
> > > +(match_operand:IEEE128 1 "altivec_register_operand" "v")
> > > +(match_operand:IEEE128 2 "altivec_register_operand" "v"))]
> > > +  UNSPEC_ROUND_TO_ODD))]
> > > +  "TARGET_FLOAT128_HW && FLOAT128_IEEE_P (mode)"
> > > +  "xsmulqpo %0,%1,%2"
> > > +  [(set_attr "type" "vecfloat")
> > > +   (set_attr "size" "128")])
> > 
> > Similar here (and everywhere else): it does an f128 mul, so rounding
> > with whatever rounding mode is current, and *then* it rounds to odd.

> > Everything else looks fine, but that unspec thing needs fixing.  Can be
> > later, things will likely work for now, so okay for trunk.  Thanks.
> > 
> > How do other ports deal with this?  Insns with a specific rounding mode?
> > Have a separate unspec for every operation?  Not very nice either :-(
> 
> I just want to do the minimal work so the glibc people can use this
> instruction, but I am not that motivated to go back and modify it further.  
> So,
> I would prefer to do it right before committing it, unless you want to refine
> it.
> 
> As I see it, there are 2 ways to encode the RTL:
> 
> 1)Use one UNSPEC name, and add the operation inside of the spec;

But this is incorrect as far as I see: it does not correctly describe
what the instruction does.

> 2)Add separate UNSPEC's for each operation.
> 
> Either one is fine with me.  If you would prefer separate names, I can do it.

Yes please.

Thanks,


Segher


[PATCH] simplify-rtx: Remove non-simplifying simplification (PR77729)

2017-10-02 Thread Segher Boessenkool
If we have (X&C1)|C2 simplify_binary_operation_1 makes C1 as small as
possible.  This makes worse code in common cases like when the AND with
C1 is from a zero-extension.  This patch fixes it by removing this
transformation (twice).

I tested this on 31 targets, also some variations that do the
transformation only for some conditions (like, do not do it if the
resulting constant looks "worse", e.g. has more stretches of ones).
22 of those targets show no difference; 8 are best with this patch
variant (never do the transformation); and 64-bit hppa is not best,
but the difference is only four insns in a million.

Bootstrapped and tested on powerpc64-linux {-m32,-m64}.  Is this okay
for trunk?  And backports?


Segher


2017-10-02  Segher Boessenkool  

PR rtl-optimization/77729
* simplify-rtx.c (simplify_binary_operation_1): Delete the (X&C1)|C2
to (X&(C1&~C2))|C2 transformations.

---
 gcc/simplify-rtx.c | 25 -
 1 file changed, 25 deletions(-)

diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c
index 1b960b9..3b6cf6f 100644
--- a/gcc/simplify-rtx.c
+++ b/gcc/simplify-rtx.c
@@ -2673,14 +2673,6 @@ simplify_binary_operation_1 (enum rtx_code code, 
machine_mode mode,
  /* If (C1|C2) == ~0 then (X&C1)|C2 becomes X|C2.  */
  if (((c1|c2) & mask) == mask)
return simplify_gen_binary (IOR, mode, XEXP (op0, 0), op1);
-
- /* Minimize the number of bits set in C1, i.e. C1 := C1 & ~C2.  */
- if (((c1 & ~c2) & mask) != (c1 & mask))
-   {
- tem = simplify_gen_binary (AND, mode, XEXP (op0, 0),
-gen_int_mode (c1 & ~c2, mode));
- return simplify_gen_binary (IOR, mode, tem, op1);
-   }
}
 
   /* Convert (A & B) | A to A.  */
@@ -2736,23 +2728,6 @@ simplify_binary_operation_1 (enum rtx_code code, 
machine_mode mode,
return gen_rtx_ROTATE (int_mode, XEXP (opright, 0),
   XEXP (SUBREG_REG (opleft), 1));
 
-  /* If we have (ior (and (X C1) C2)), simplify this by making
-C1 as small as possible if C1 actually changes.  */
-  if (CONST_INT_P (op1)
- && (HWI_COMPUTABLE_MODE_P (mode)
- || INTVAL (op1) > 0)
- && GET_CODE (op0) == AND
- && CONST_INT_P (XEXP (op0, 1))
- && CONST_INT_P (op1)
- && (UINTVAL (XEXP (op0, 1)) & UINTVAL (op1)) != 0)
-   {
- rtx tmp = simplify_gen_binary (AND, mode, XEXP (op0, 0),
-gen_int_mode (UINTVAL (XEXP (op0, 1))
-  & ~UINTVAL (op1),
-  mode));
- return simplify_gen_binary (IOR, mode, tmp, op1);
-   }
-
   /* If OP0 is (ashiftrt (plus ...) C), it might actually be
  a (sign_extend (plus ...)).  Then check if OP1 is a CONST_INT and
 the PLUS does not affect any of the bits in OP1: then we can do
-- 
1.8.3.1



Re: [PATCH] detect incompatible aliases (PR c/81854)

2017-10-02 Thread Steve Ellcey
On Wed, 2017-09-20 at 08:37 -0700, Steve Ellcey wrote:
> On Tue, 2017-09-19 at 09:16 -0600, Martin Sebor wrote:
> > On 09/18/2017 03:44 PM, Joseph Myers wrote:
> > > On Mon, 18 Sep 2017, Martin Sebor wrote:
> > > > It's meant as an escape hatch.  It allows declaring
> > > > compatibility
> > > > symbols, for example by the libstdc++ _GLIBCXX_3_4_SYMVER macro
> > > > defined in libstdc++-v3/src/c++98/compatibility.cc.  The macro
> > > > is
> > > > used to declare compatibility functions of all sorts of
> > > > incompatible
> > > > types.  The originally posted patch had libstdc++ disable the
> > > > warning
> > > > for the file with the symbols but Jonathan preferred this
> > > > solution.
> > > > 
> > > > It could perhaps be tightened up to detect some of the cases on
> > > > your
> > > > list but I'm not sure it's worth the effort and added
> > > > complexity.
> > > > Let me know if you feel differently (or have a different
> > > > suggestion),
> > > > otherwise I will go ahead and commit the patch as is.
> > > Please add a comment explaining this reasoning and commit the
> > > patch.
> > Done in r252976.
> > 
> > Thanks
> > Martin
> This patch is causing my gcc/glibc ToT build to fail on aarch64.  I am
> not sure if everything should be working at this point or not or if
> there is more that needs to be done.  The problem is with the memcpy,
> memmove, etc. ifuncs on aarch64.
> 
> Steve Ellcey
> sell...@cavium.com

Martin,

I think there is more fallout from this patch.  The libatomic library
can use ifuncs and right now it is not working on aarch64 (testing a
proposed patch I sent) because the ifunc check fails due to the new
warnings.  I believe this can be reproduced with ToT on x86 or arm as
they use ifuncs in the checked in sources but I have not tried that
yet.  Note that the build does not fail, it is just that the check for
ifunc support fails and thus the library is built without them.

Steve Ellcey
sell...@cavium.com

configure:14698: checking whether the target supports the ifunc attribute
configure:14720: /home/sellcey/gcc-libatomic/obj/gcc/./gcc/xgcc
-B/home/sellcey/gcc-libatomic/obj/gcc/./gcc/ -B/home/sellcey/gcc-
libatomic/install/aarch64-unknown-linux-gnu/bin/ -B/home/sellcey/gcc-
libatomic/install/aarch64-unknown-linux-gnu/lib/ -isystem
/home/sellcey/gcc-libatomic/install/aarch64-unknown-linux-gnu/include
-isystem /home/sellcey/gcc-libatomic/install/aarch64-unknown-linux-
gnu/sys-include-o conftest -g -O2  -pthread
-Werror   conftest.c  >&5
conftest.c:68:9: error: 'foo' 'ifunc' resolver should return a function
pointer [-Werror=attributes]
 int foo(void) __attribute__((ifunc("foo_sel")));
 ^~~
conftest.c:67:11: note: resolver declaration here
 void *foo_sel(void) { return foo_alt; }
   ^~~
cc1: all warnings being treated as errors
configure:14720: $? = 1




Re: [PATCH] C++17 P0067R5 std::to_chars and std::from_chars (partial)

2017-10-02 Thread Jakub Jelinek
On Mon, Oct 02, 2017 at 03:13:17PM +0100, Jonathan Wakely wrote:
> This adds the integral overloads of std::to_chars and std::from_chars,
> including the changes made by P0682R0. Support for floating point types
> is absent.
> 
> This uses a number of suggestions from Lars (thanks!) but I might have
> missed some of his ideas and so could be missing some potential
> optimizations.
> 
> An earlier version of the patch was posted in
> https://gcc.gnu.org/ml/libstdc++/2017-04/msg00025.html
> 
>   * include/Makefile.am: Add new  header.
>   * include/Makefile.in: Regenerate.
>   * include/precompiled/stdc++.h: Include .
>   * include/std/charconv: New file.
>   (to_chars_result, to_chars, from_chars_result, from_chars): Define.
>   * testsuite/20_util/from_chars/1.cc: New test.
>   * testsuite/20_util/from_chars/1_neg.cc: New test.
>   * testsuite/20_util/from_chars/2.cc: New test.
>   * testsuite/20_util/from_chars/requirements.cc: New test.
>   * testsuite/20_util/to_chars/1.cc: New test.
>   * testsuite/20_util/to_chars/1_neg.cc: New test.
>   * testsuite/20_util/to_chars/2.cc: New test.
>   * testsuite/20_util/to_chars/requirements.cc: New test.
> 
> Tested powerpc64le-linux, committed to trunk.

This fails on 32-bit targets, there are too many closing >s if
__int128_t is missing.

Either of the attached patches fixes this, which one do you prefer (or do
you want yet another formatting)?

Jakub
2017-10-02  Jakub Jelinek  

* include/std/charconv (__unsigned_least_t): Fix number of closing >s 
for
!_GLIBCXX_USE_INT128.

--- libstdc++-v3/include/std/charconv.jj2017-10-02 18:51:40.0 
+0200
+++ libstdc++-v3/include/std/charconv   2017-10-02 21:37:16.085823955 +0200
@@ -81,7 +81,11 @@ namespace __detail
 #if _GLIBCXX_USE_INT128
conditional_t<(sizeof(_Tp) <= sizeof(__int128)), unsigned __int128,
 #endif
-   void;
+   void
+#if _GLIBCXX_USE_INT128
+   >
+#endif
+   >>>;
 
   // Generic implementation for arbitrary bases.
   template
2017-10-02  Jakub Jelinek  

* include/std/charconv (__unsigned_least_t): Fix number of closing >s 
for
!_GLIBCXX_USE_INT128.

--- libstdc++-v3/include/std/charconv.jj2017-10-02 18:51:40.0 
+0200
+++ libstdc++-v3/include/std/charconv   2017-10-02 21:44:02.416799016 +0200
@@ -80,8 +80,10 @@ namespace __detail
conditional_t<(sizeof(_Tp) <= sizeof(long long)), unsigned long long,
 #if _GLIBCXX_USE_INT128
conditional_t<(sizeof(_Tp) <= sizeof(__int128)), unsigned __int128,
-#endif
void;
+#else
+   void>>>;
+#endif
 
   // Generic implementation for arbitrary bases.
   template


Re: [PATCH] detect incompatible aliases (PR c/81854)

2017-10-02 Thread Joseph Myers
On Mon, 2 Oct 2017, Steve Ellcey wrote:

> I think there is more fallout from this patch.  The libatomic library
> can use ifuncs and right now it is not working on aarch64 (testing a
> proposed patch I sent) because the ifunc check fails due to the new
> warnings.  I believe this can be reproduced with ToT on x86 or arm as
> they use ifuncs in the checked in sources but I have not tried that
> yet.  Note that the build does not fail, it is just that the check for
> ifunc support fails and thus the library is built without them.

In the ARM case we don't enable ifunc attribute support by default.  I 
think we *should* add arm*-* to that case statement to enable it by 
default (for GNU/Linux targets); it just so happens the absence for ARM 
doesn't break building glibc because all IFUNCs in glibc on ARM are 
defined in .S files, not in C code.

-- 
Joseph S. Myers
jos...@codesourcery.com

[PATCH] C: underline parameters in mismatching function calls

2017-10-02 Thread David Malcolm
In r253096
  ("C++: underline parameters in mismatching function calls"
  aka 5d78d423a5f7a1d135c7bb678e82007678d1313c
https://gcc.gnu.org/ml/gcc-patches/2017-09/msg01546.html )
I updated the C++ FE's handling of mismatched types in function calls
so that it underlines the pertinent param of the callee, rather than
just the function name.

The following patch does the same for the C frontend.

Given e.g. this type mismatch:

  extern int callee (int one, const char *two, float three);

  int caller (int first, int second, float third)
  {
return callee (first, second, third);
  }

the C FE currently emits (trunk):

  test.c: In function 'caller':
  test.c:5:25: warning: passing argument 2 of 'callee' makes pointer from
  integer without a cast [-Wint-conversion]
 return callee (first, second, third);
   ^~
  test.c:1:12: note: expected 'const char *' but argument is of type 'int'
   extern int callee (int one, const char *two, float three);
  ^~

whereas with this patch the note underlines the pertinent param of
the callee:

  test.c: In function 'caller':
  test.c:5:25: warning: passing argument 2 of 'callee' makes pointer from
  integer without a cast [-Wint-conversion]
 return callee (first, second, third);
   ^~
  test.c:1:41: note: expected 'const char *' but argument is of type 'int'
   extern int callee (int one, const char *two, float three);
   ^~~

making the problem more obvious to the user.

As with the C++ patch, the patch:

(a) updates the locations of the params to cover the range of all
of their tokens, putting the caret on the first character of the
param name (if present), otherwise at the start of the first token
(doing so requires adding a last_token_location to the c_parser, so
we can determine the location of the last consumed token).

(b) updates the "note" to use the param location, rather than the
fndecl location

Successfully bootstrapped®rtested on x86_64-pc-linux-gnu.

OK for trunk?

gcc/c/ChangeLog:
* c-decl.c (push_parm_decl): Store c_parm's location into the
PARAM_DECL.
(build_c_parm): Add "loc" param and store it within the c_parm.
* c-parser.c (struct c_parser): Add "last_token_location" field.
(c_parser_consume_token): Store location of the token into the
new field.
(c_parser_declaration_or_fndef): Store params into DECL_ARGUMENTS
when handling a FUNCTION_DECL, if it doesn't already have them.
(c_parser_parameter_declaration): Generate a location for the
parameter, and pass it to the call to build_c_parm.
* c-tree.h (struct c_parm): Add field "loc".
(build_c_parm): Add location_t param.
* c-typeck.c (get_fndecl_argument_location): New function.
(inform_for_arg): New function.
(convert_for_assignment): Use inform_for_arg when dealing with
ic_argpass.

gcc/testsuite/ChangeLog:
* gcc.dg/diagnostic-range-bad-called-object.c: Update expected
underlining for param.
* gcc.dg/param-type-mismatch.c: Update expected results to reflect
highlighting of parameters; add test coverage for trivial
parameter decls, and for callback parameters.
* gcc.dg/pr68533.c: Update location of two errors to reflect
location of params.
---
 gcc/c/c-decl.c |  6 +-
 gcc/c/c-parser.c   | 38 +-
 gcc/c/c-tree.h |  4 +-
 gcc/c/c-typeck.c   | 78 +---
 .../gcc.dg/diagnostic-range-bad-called-object.c|  2 +-
 gcc/testsuite/gcc.dg/param-type-mismatch.c | 83 --
 gcc/testsuite/gcc.dg/pr68533.c |  8 +--
 7 files changed, 177 insertions(+), 42 deletions(-)

diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
index 080a2e9..405c301 100644
--- a/gcc/c/c-decl.c
+++ b/gcc/c/c-decl.c
@@ -5190,6 +5190,8 @@ push_parm_decl (const struct c_parm *parm, tree *expr)
 
   decl = grokdeclarator (parm->declarator, parm->specs, PARM, false, NULL,
 &attrs, expr, NULL, DEPRECATED_NORMAL);
+  if (decl && DECL_P (decl))
+DECL_SOURCE_LOCATION (decl) = parm->loc;
   decl_attributes (&decl, attrs, 0);
 
   decl = pushdecl (decl);
@@ -9699,12 +9701,14 @@ build_void_list_node (void)
 
 struct c_parm *
 build_c_parm (struct c_declspecs *specs, tree attrs,
- struct c_declarator *declarator)
+ struct c_declarator *declarator,
+ location_t loc)
 {
   struct c_parm *ret = XOBNEW (&parser_obstack, struct c_parm);
   ret->specs = specs;
   ret->attrs = attrs;
   ret->declarator = declarator;
+  ret->loc = loc;
   return ret;
 }
 
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index a36397b..1a5e39e 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -206,6 +206,9 @@ struct

Re: [PATCH] detect incompatible aliases (PR c/81854)

2017-10-02 Thread Martin Sebor

On 10/02/2017 01:49 PM, Steve Ellcey wrote:

On Wed, 2017-09-20 at 08:37 -0700, Steve Ellcey wrote:

On Tue, 2017-09-19 at 09:16 -0600, Martin Sebor wrote:

On 09/18/2017 03:44 PM, Joseph Myers wrote:

On Mon, 18 Sep 2017, Martin Sebor wrote:

It's meant as an escape hatch.  It allows declaring
compatibility
symbols, for example by the libstdc++ _GLIBCXX_3_4_SYMVER macro
defined in libstdc++-v3/src/c++98/compatibility.cc.  The macro
is
used to declare compatibility functions of all sorts of
incompatible
types.  The originally posted patch had libstdc++ disable the
warning
for the file with the symbols but Jonathan preferred this
solution.

It could perhaps be tightened up to detect some of the cases on
your
list but I'm not sure it's worth the effort and added
complexity.
Let me know if you feel differently (or have a different
suggestion),
otherwise I will go ahead and commit the patch as is.

Please add a comment explaining this reasoning and commit the
patch.

Done in r252976.

Thanks
Martin

This patch is causing my gcc/glibc ToT build to fail on aarch64.  I am
not sure if everything should be working at this point or not or if
there is more that needs to be done.  The problem is with the memcpy,
memmove, etc. ifuncs on aarch64.

Steve Ellcey
sell...@cavium.com


Martin,

I think there is more fallout from this patch.  The libatomic library
can use ifuncs and right now it is not working on aarch64 (testing a
proposed patch I sent) because the ifunc check fails due to the new
warnings.  I believe this can be reproduced with ToT on x86 or arm as
they use ifuncs in the checked in sources but I have not tried that
yet.  Note that the build does not fail, it is just that the check for
ifunc support fails and thus the library is built without them.

Steve Ellcey
sell...@cavium.com

configure:14698: checking whether the target supports the ifunc attribute
configure:14720: /home/sellcey/gcc-libatomic/obj/gcc/./gcc/xgcc
-B/home/sellcey/gcc-libatomic/obj/gcc/./gcc/ -B/home/sellcey/gcc-
libatomic/install/aarch64-unknown-linux-gnu/bin/ -B/home/sellcey/gcc-
libatomic/install/aarch64-unknown-linux-gnu/lib/ -isystem
/home/sellcey/gcc-libatomic/install/aarch64-unknown-linux-gnu/include
-isystem /home/sellcey/gcc-libatomic/install/aarch64-unknown-linux-
gnu/sys-include-o conftest -g -O2  -pthread
-Werror   conftest.c  >&5
conftest.c:68:9: error: 'foo' 'ifunc' resolver should return a function
pointer [-Werror=attributes]
 int foo(void) __attribute__((ifunc("foo_sel")));
 ^~~
conftest.c:67:11: note: resolver declaration here
 void *foo_sel(void) { return foo_alt; }
   ^~~
cc1: all warnings being treated as errors
configure:14720: $? = 1


Looks like the libatomic/configure script needs to be updated
to have the ifunc test either declare the resolver to return
a function pointer or avoid using -Werror.  I assume the below
is the preferred fix but I need to get the right version of
autoconf etc. to regenerate configure.  Let me work on that
and submit a patch.

Martin

diff --git a/libatomic/acinclude.m4 b/libatomic/acinclude.m4
index 485d731..383218f 100644
--- a/libatomic/acinclude.m4
+++ b/libatomic/acinclude.m4
@@ -195,7 +195,8 @@ AC_DEFUN([LIBAT_CHECK_IFUNC], [
   CFLAGS="$CFLAGS -Werror"
   AC_TRY_LINK([
 int foo_alt(void) { return 0; }
-void *foo_sel(void) { return foo_alt; }
+typedef int F (void);
+F *foo_sel(void) { return foo_alt; }
 int foo(void) __attribute__((ifunc("foo_sel")));],
 [return foo();], libat_cv_have_ifunc=yes, libat_cv_have_ifunc=no)])
   LIBAT_DEFINE_YESNO([HAVE_IFUNC], [$libat_cv_have_ifunc],


Martin


Re: [PATCH] C: underline parameters in mismatching function calls

2017-10-02 Thread Paul Koning

> On Oct 2, 2017, at 4:05 PM, David Malcolm  wrote:
> 
> ...
> the C FE currently emits (trunk):
> 
>  test.c: In function 'caller':
>  test.c:5:25: warning: passing argument 2 of 'callee' makes pointer from
>  integer without a cast [-Wint-conversion]
> return callee (first, second, third);
>   ^~
>  test.c:1:12: note: expected 'const char *' but argument is of type 'int'
>   extern int callee (int one, const char *two, float three);
>  ^~
> 
> whereas with this patch the note underlines the pertinent param of
> the callee:
> 
>  test.c: In function 'caller':
>  test.c:5:25: warning: passing argument 2 of 'callee' makes pointer from
>  integer without a cast [-Wint-conversion]
> return callee (first, second, third);
>   ^~
>  test.c:1:41: note: expected 'const char *' but argument is of type 'int'
>   extern int callee (int one, const char *two, float three);
>   ^~~
> 
> making the problem more obvious to the user.

I'm not sure why you'd point at the formal parameter name, which isn't 
significant and might not be present.  The issue is with the type, so pointing 
at the type ("const char *") would seem more obvious.

paul



Re: [PATCH] C: underline parameters in mismatching function calls

2017-10-02 Thread David Malcolm
On Mon, 2017-10-02 at 16:22 -0400, Paul Koning wrote:
> > On Oct 2, 2017, at 4:05 PM, David Malcolm 
> > wrote:
> > 
> > ...
> > the C FE currently emits (trunk):
> > 
> >  test.c: In function 'caller':
> >  test.c:5:25: warning: passing argument 2 of 'callee' makes pointer
> > from
> >  integer without a cast [-Wint-conversion]
> > return callee (first, second, third);
> >   ^~
> >  test.c:1:12: note: expected 'const char *' but argument is of type
> > 'int'
> >   extern int callee (int one, const char *two, float three);
> >  ^~
> > 
> > whereas with this patch the note underlines the pertinent param of
> > the callee:
> > 
> >  test.c: In function 'caller':
> >  test.c:5:25: warning: passing argument 2 of 'callee' makes pointer
> > from
> >  integer without a cast [-Wint-conversion]
> > return callee (first, second, third);
> >   ^~
> >  test.c:1:41: note: expected 'const char *' but argument is of type
> > 'int'
> >   extern int callee (int one, const char *two, float three);
> >   ^~~
> > 
> > making the problem more obvious to the user.
> 
> I'm not sure why you'd point at the formal parameter name, which
> isn't significant and might not be present.  

The patch copes with this case:

test.c:1:25: note: expected ‘const char *’ but argument is of type
‘int’
 extern int callee (int, const char *, float);
 ^~~~

> The issue is with the type, so pointing at the type ("const char *")
> would seem more obvious.

Yes, there's an argument for highlighting just the type, but if there's
a name it's arguably significant information also - to the user, at
least, in that hopefully it contains a clue to the user as to the
meaning of the param.

Currently there isn't a natural place to store the location of the
*type* of a param decl.  At my talk at Cauldron I proposed a new
internal representation that would allow for pointing at just the type
("BLT"), and I've posted patches that could implement that [1] but
Jason and Nathan were strongly opposed to my implementation approach,
and wanted me to use and/or extend the pre-existing representation, so
I went with this approach for C++, which I hope to mirror with this C
patch.

Hence given that DECL_ARGUMENTS exists, and that the PARAM_DECL has a
DECL_SOURCE_LOCATION, this patch (like the C++ one) takes the approach
of extending the PARAM_DECL's DECL_SOURCE_LOCATION to cover the range
described above (previously it was just that of one token).  In theory
we could add some kind of additional location_t field to PARAM_DECL to
cover the location of the *type* part of the decl, but I suspect that
it would be vetoed on the grounds of memory cost, and given that the
benefits seems to me to be marginal, I went with the approach in the
patch.

The patch gets much more useful as the number of params increases and
visual comma-counting becomes a pain.

Hope the above makes sense
Dave

[1]: [PATCH 06/17] C: use BLT to highlight parameter of callee decl for
mismatching types
https://gcc.gnu.org/ml/gcc-patches/2017-07/msg01459.html
and  [PATCH 07/17] C++: use BLT to highlight parameter of callee decl
for mismatching types
https://gcc.gnu.org/ml/gcc-patches/2017-07/msg01458.html

(these highlight the name as well as the type, but could be modified to
just highlight the type)



Go patch committed to GCC 7 branch: update to Go 1.8.3 release

2017-10-02 Thread Ian Lance Taylor
I have committed the appended patch to update the GCC 7 branch to the
Go 1.8.3 release of the Go standard library.  The branch was
previously on the Go 1.8.1 release.  This is a fairly small patch that
fixes various bugs, a subset of the ones listed at:

https://github.com/golang/go/issues?q=is%3Aissue+milestone%3AGo1.8.2+is%3Aclosed
https://github.com/golang/go/issues?q=is%3Aissue+milestone%3AGo1.8.3+is%3Aclosed

Bootstrapped and ran Go tests on x86_64-pc-linux-gnu.  Committed to
GCC 7 branch.

Ian
Index: libgo/MERGE
===
--- libgo/MERGE (revision 253365)
+++ libgo/MERGE (working copy)
@@ -1,4 +1,4 @@
-a4c18f063b6659079ca2848ca217a0587dabc001
+352996a381701cfa0c16e8de29cbde8f3922182f
 
 The first line of this file holds the git revision number of the
 last merge done from the master library sources.
Index: libgo/VERSION
===
--- libgo/VERSION   (revision 253365)
+++ libgo/VERSION   (working copy)
@@ -1 +1 @@
-go1.8.1
+go1.8.3
Index: libgo/go/cmd/go/build.go
===
--- libgo/go/cmd/go/build.go(revision 253365)
+++ libgo/go/cmd/go/build.go(working copy)
@@ -3133,6 +3133,26 @@ func (b *builder) ccompile(p *Package, o
desc := p.ImportPath
output, err := b.runOut(p.Dir, desc, nil, compiler, flags, "-o", 
outfile, "-c", file)
if len(output) > 0 {
+   // On FreeBSD 11, when we pass -g to clang 3.8 it
+   // invokes its internal assembler with -dwarf-version=2.
+   // When it sees .section .note.GNU-stack, it warns
+   // "DWARF2 only supports one section per compilation unit".
+   // This warning makes no sense, since the section is empty,
+   // but it confuses people.
+   // We work around the problem by detecting the warning
+   // and dropping -g and trying again.
+   if bytes.Contains(output, []byte("DWARF2 only supports one 
section per compilation unit")) {
+   newFlags := make([]string, 0, len(flags))
+   for _, f := range flags {
+   if !strings.HasPrefix(f, "-g") {
+   newFlags = append(newFlags, f)
+   }
+   }
+   if len(newFlags) < len(flags) {
+   return b.ccompile(p, outfile, newFlags, file, 
compiler)
+   }
+   }
+
b.showOutput(p.Dir, desc, b.processOutput(output))
if err != nil {
err = errPrintedOutput
Index: libgo/go/crypto/elliptic/elliptic_test.go
===
--- libgo/go/crypto/elliptic/elliptic_test.go   (revision 253365)
+++ libgo/go/crypto/elliptic/elliptic_test.go   (working copy)
@@ -300,6 +300,29 @@ var p224BaseMultTests = []baseMultTest{
},
 }
 
+type scalarMultTest struct {
+   k  string
+   xIn, yIn   string
+   xOut, yOut string
+}
+
+var p256MultTests = []scalarMultTest{
+   {
+   
"2a265f8bcbdcaf94d58519141e578124cb40d64a501fba9c11847b28965bc737",
+   
"023819813ac969847059028ea88a1f30dfbcde03fc791d3a252c6b41211882ea",
+   
"f93e4ae433cc12cf2a43fc0ef26400c0e125508224cdb649380f25479148a4ad",
+   
"4d4de80f1534850d261075997e3049321a0864082d24a917863366c0724f5ae3",
+   
"a22d2b7f7818a3563e0f7a76c9bf0921ac55e06e2e4d11795b233824b1db8cc0",
+   },
+   {
+   
"313f72ff9fe811bf573176231b286a3bdb6f1b14e05c40146590727a71c3bccd",
+   
"cc11887b2d66cbae8f4d306627192522932146b42f01d3c6f92bd5c8ba739b06",
+   
"a2f08a029cd06b46183085bae9248b0ed15b70280c7ef13a457f5af382426031",
+   
"831c3f6b5f762d2f461901577af41354ac5f228c2591f84f8a6e51e2e3f17991",
+   
"93f90934cd0ef2c698cc471c60a93524e87ab31ca2412252337f364513e43684",
+   },
+}
+
 func TestBaseMult(t *testing.T) {
p224 := P224()
for i, e := range p224BaseMultTests {
@@ -379,6 +402,19 @@ func TestP256Mult(t *testing.T) {
break
}
}
+
+   for i, e := range p256MultTests {
+   x, _ := new(big.Int).SetString(e.xIn, 16)
+   y, _ := new(big.Int).SetString(e.yIn, 16)
+   k, _ := new(big.Int).SetString(e.k, 16)
+   expectedX, _ := new(big.Int).SetString(e.xOut, 16)
+   expectedY, _ := new(big.Int).SetString(e.yOut, 16)
+
+   xx, yy := p256.ScalarMult(x, y, k.Bytes())
+   if xx.Cmp(expectedX) != 0 || yy.Cmp(expectedY) != 0 {
+   t.Errorf("#%d: got (%x, %x), want (%x, %x)", i, xx, yy, 
expectedX, expectedY)
+   }
+   }
 }
 
 func TestInfinity(t

Re: [PATCH 3/4] enhance overflow and truncation detection in strncpy and strncat (PR 81117)

2017-10-02 Thread Jeff Law
On 08/10/2017 01:29 PM, Martin Sebor wrote:
>>> diff --git a/gcc/builtins.c b/gcc/builtins.c
>>> index 016f68d..1aa9e22 100644
>>> --- a/gcc/builtins.c
>>> +++ b/gcc/builtins.c
>> [ ... ]
>>> +
>>> +  if (TREE_CODE (type) == ARRAY_TYPE)
>>> +    {
>>> +  /* Return the constant size unless it's zero (that's a
>>> zero-length
>>> + array likely at the end of a struct).  */
>>> +  tree size = TYPE_SIZE_UNIT (type);
>>> +  if (size && TREE_CODE (size) == INTEGER_CST
>>> +  && !integer_zerop (size))
>>> +    return size;
>>> +    }
>> Q. Do we have a canonical test for the trailing array idiom?   In some
>> contexts isn't it size 1?  ISTM This test needs slight improvement.
>> Ideally we'd use some canonical test for detect the trailing array idiom
>> rather than open-coding it here.  You might look at the array index
>> warnings in tree-vrp.c to see if it's got a canonical test you can call
>> or factor and use.
> 
> You're right, there is an API for this (array_at_struct_end_p,
> as Richard pointed out).  I didn't want to use it because it
> treats any array at the end of a struct as a flexible array
> member, but simple tests show that that's what -Wstringop-
> overflow does now, and it wasn't my intention to tighten up
> the checking under this change.  It surprises me that no tests
> exposed this. Let me relax the check and think about proposing
> to tighten it up separately.
> 
> 
> 
>> What might be even better would be to use the immediate uses of the
>> memory tag.  For your case there should be only one immediate use and it
>> should point to the statement which NUL terminates the destination.  Or
>> maybe that would be worse in that you only want to allow this exception
>> when the statements are consecutive.
> 
> I'll have to try this to better understand how it might work.
It's actually quite simple.

Rather than looking at the next statement in the chain via
gsi_next_nondebug you follow the def->use chain for the memory tag
associated with the string copy statement.

/* Get the memory tag that is defined by this statement.  */
defvar = gimple_vdef (gsi_stmt (gsi));

imm_use_iterator iter;
gimple *use_stmt;

if (num_imm_uses (defvar) == 1)
  {
imm_use_terator iter;
gimple *use_stmt;

/* Iterate over the immediate uses of the memory tag.  */
FOR_EACH_IMM_USE_STMT (use_stmt, ui, defvar)
  {
Check if STMT is dst[i] = '\0'
  }
  }



The check that there is a single immediate use is designed to make sure
you get a warning for this scenario:

strxncpy
read the destination
terminate the destination

Which I think you'd want to consider non-terminated because of the read
of the destination prior to termination.

But avoids warnings for

strxncpy
stuff that doesn't read the destination
terminate the destintion



>> You still need to rename strlen_optimize_stmt since after your changes
>> it does both optimizations and warnings.
> 
> I'm not sure I understand why.  It's a pre-existing function that
> just dispatches to the built-in handlers.  We don't rename function
> callers each time we improve error/warning detection in some
> function they call (case in point: all the expanders in builtins.c)
> Why do it here?  And what would be a suitable name?  All that comes
> to my mind is awkward variations on strlen_optimize_stmt_and_warn.
Actually we often end up renaming functions as their capabilities
change.  If I was to read that name, I'd think its only purpose was to
optimize.  Given its static with a single use we should just fix it.


Something in compute_objsize I just noticed.

When DEST is an SSA_NAME, you follow the use->def chain back to its
defining statement, then get a new dest from the RHS of that statement:

> +  if (TREE_CODE (dest) == SSA_NAME)
> +{
> +  gimple *stmt = SSA_NAME_DEF_STMT (dest);
> +  if (!is_gimple_assign (stmt))
> + return NULL_TREE;
> +
> +  dest = gimple_assign_rhs1 (stmt);
> +}

This seems wrong as-written -- you have no idea what the RHS code is.
You're just blindly taking the first operand, then digging into its
type.  It probably works in practice, but it would seem better to verify
that gimple_assign_rhs_code is a conversion first (CONVERT_EXPR_CODE_P).
 If it's not a CONVERT_EXPR_CODE_P, return NULL_TREE.

[ Assuming the point here here is to look back through a conversion from
an array type to a pointer. ]



Jeff


Re: [PATCH 1/3] improve detection of attribute conflicts (PR 81544)

2017-10-02 Thread Jeff Law
On 09/20/2017 12:04 PM, Martin Sebor wrote:
> On 09/19/2017 03:00 PM, Joseph Myers wrote:
>> On Tue, 19 Sep 2017, Martin Sebor wrote:
>>
 In general, the data structures where you need to ensure manually that if

 attribute A is listed in EXCL for B, then attribute B is also listed in
 EXCL for A, seem concerning.  I'd expect either data structures that make

 such asymmetry impossible, or a self-test that verifies that the tables in

 use are in fact symmetric (unless there is some reason the symmetry is not

 in fact required and symmetric diagnostics still result from asymmetric
 tables - in which case the various combinations and orderings of
 gnu_inline and noinline definitely need tests to show that the diagnostics

 work).
>>>
>>> If I understand correctly what you're concerned about then I don't
>>> think there are any such cases in the updated version of the patch.
>>
>> I don't see how you ensure that it's not possible to have such asymmetry.
>> My point wasn't so much "there was a bug in the previous patch version" as
>>
>> "the choice of data structures for defining such exclusions is prone to
>> such bugs".  Which can be addressed either by using different data
>> structures (e.g. listing incompatible pairs in a single array) or by a
>> self-test to verify symmetry so a compiler with asymmetry doesn't build.
> 
> Okay, that's a useful thing to add.  It exposed a couple of missing
> attribute exclusions that I had overlooked.  Thanks for the suggestion!
> Attached is an incremental diff with just these changes to make review
> easier and an updated patch.
> 
> As an aside, there are a number of other possible logic errors in
> the attribute specifications that could be detected by self-tests.
> The one I ran into is misspelled attribute names.  The added test
> detects misspelled names in exclusions, but not in the main specs.
> 
> Martin
> 
> gcc-81544-1-inc.diff
> 
> 


> gcc-81544-1.diff
> 
> 
> PR c/81544 - attribute noreturn and warn_unused_result on the same function 
> accepted
> 
> gcc/c/ChangeLog:
> 
>   PR c/81544
>   * c-decl.c (c_decl_attributes): Look up existing declaration and
>   pass it to decl_attributes.
> 
> gcc/c-family/ChangeLog:
> 
>   PR c/81544
>   * c-attribs.c (attr_aligned_exclusions): New array.
>   (attr_alloc_exclusions, attr_cold_hot_exclusions): Same.
>   (attr_common_exclusions, attr_const_pure_exclusions): Same.
>   (attr_gnu_inline_exclusions, attr_inline_exclusions): Same.
>   (attr_noreturn_exclusions, attr_returns_twice_exclusions): Same.
>   (attr_warn_unused_result_exclusions): Same.
>   (handle_hot_attribute, handle_cold_attribute): Simplify.
>   (handle_const_attribute): Warn on function returning void.
>   (handle_pure_attribute): Same.
>   * c-warn.c (diagnose_mismatched_attributes): Simplify.
> 
> gcc/ChangeLog:
> 
>   PR c/81544
>   * attribs.c (empty_attribute_table): Initialize new member of
>   struct attribute_spec.
>   (decl_attributes): Add argument.  Handle mutually exclusive
>   combinations of attributes.
>   * attribs.h (decl_attributes): Add default argument.
>   * selftest.h (attribute_c_tests): Declare.
>   * selftest-run-tests.c (selftest::run_tests): Call attribute_c_tests.
>   * tree-core.h (attribute_spec::exclusions, exclude): New type and
>   member.
>   * doc/extend.texi (Common Function Attributes): Update const and pure.
> 
> gcc/testsuite/ChangeLog:
> 
>   PR c/81544
>   * c-c++-common/Wattributes-2.c: New test.
>   * c-c++-common/Wattributes.c: New test.
>   * c-c++-common/attributes-3.c: Adjust.
>   * gcc.dg/attr-noinline.c: Adjust.
>   * gcc.dg/pr44964.c: Same.
>   * gcc.dg/torture/pr42363.c: Same.
>   * gcc.dg/tree-ssa/ssa-ccp-2.c: Same.
OK.
jeff


Re: [PATCH 2/3] improve detection of attribute conflicts (PR 81544)

2017-10-02 Thread Jeff Law
On 08/08/2017 10:13 AM, Martin Sebor wrote:
> Part 2 of the series contains the mechanical changes to all
> the back ends and to front ends other than C and C++.  There
> are no functional changes here.
> 
> Martin
> 
> 
> gcc-81544-2.diff
> 
> 
> PR c/81544 - attribute noreturn and warn_unused_result on the same function 
> accepted
> 
> gcc/ChangeLog:
> 
>   PR c/81544
>   * config/alpha/alpha.c (vms_attribute_table): Initialize new member
>   of struct attribute_spec.
>   * config/arm/arm.c (arm_attribute_table): Same.
>   * config/avr/avr.c ( avr_attribute_table): Same.
>   * config/bfin/bfin.c (bfin_attribute_table): Same.
>   * config/cr16/cr16.c (cr16_attribute_table): Same.
>   * config/epiphany/epiphany.c (epiphany_attribute_table): Same.
>   * config/h8300/h8300.c (h8300_attribute_table): Same.
>   * config/i386/i386.c (ix86_attribute_table): Same.
>   * config/ia64/ia64.c (ia64_attribute_table): Same.
>   * config/m32c/m32c.c (m32c_attribute_table): Same.
>   * config/m32r/m32r.c (m32r_attribute_table): Same.
>   * config/m68k/m68k.c (m68k_attribute_table): Same.
>   * config/mcore/mcore.c (mcore_attribute_table): Same.
>   * config/mips/mips.c (mips_attribute_table): Same.
>   * config/nds32/nds32.c (nds32_attribute_table): Same.
>   * config/nvptx/nvptx.c (nvptx_attribute_table): Same.
>   * config/powerpcspe/powerpcspe.c (rs6000_attribute_table): Same.
>   * config/rs6000/rs6000.c (rs6000_attribute_table): Same.
>   * config/s390/s390.c (s390_handle_vectorbool_attribute): Same.
>   * config/sh/sh.c (sh_attribute_table): Same.
>   * config/sparc/sparc.c (sparc_attribute_table): Same.
>   * config/spu/spu.c (spu_attribute_table): Same.
>   * config/stormy16/stormy16.c (xstormy16_attribute_table): Same.
>   * config/v850/v850.c (v850_attribute_table): Same.
>   * config/visium/visium.c (visium_attribute_table): Same.
> 
> gcc/ada/ChangeLog:
> 
>   PR c/81544
>   * gcc-interface/utils.c (gnat_internal_attribute_table): Initialize
>   new member of struct attribute_spec.
> 
> gcc/fortran/ChangeLog:
> 
>   PR c/81544
>   * f95-lang.c (gfc_attribute_table): Initialize new member of struct
>   attribute_spec.
> 
> gcc/lto/ChangeLog:
> 
>   PR c/81544
>   * lto-lang.c (lto_attribute_table): Initialize new member of struct
>   attribute_spec.
OK.
jeff


Re: [PATCH 3/3] diagnose attribute aligned conflicts (PR 81566)

2017-10-02 Thread Jeff Law
On 08/08/2017 10:13 AM, Martin Sebor wrote:
> Patch 3 in the series restores the diagnostics for conflicting
> attribute aligned on the same function (this regressed in r192199
> in GCC 4.9), and also makes use of the enhanced infrastructure to
> enhance the detection of the same conflicts on distinct declarations
> of the same function.
> 
> Rather than issuing an error for the confluct as was done in GCC 4.8
> I made it a -Wattributes warning.  That seems more in line with how
> otherwise syntactically valid attributes are handled elsewhere, and
> it also lets code developed since the regression was introduced to
> temporarily suppress the warning until the problem is conflict is
> corrected.
> 
> Martin
> 
> gcc-81544-3.diff
> 
> 
> PR c/81566 - invalid attribute aligned accepted on functions
> 
> gcc/c-family/ChangeLog:
> 
>   PR c/81566
>   c-attribs.c (handle_aligned_attribute): Diagnose conflicting
>   attribute specifications.
> 
> gcc/testsuite/ChangeLog:
> 
>   PR c/8166
>   * c-c++-common/Wattributes-2.c: New test.
OK.
jeff


Re: [PATCH 3/5] New target check: vect_long_mult

2017-10-02 Thread Jeff Law
On 09/28/2017 05:50 AM, Andreas Krebbel wrote:
> We don't have a 64 bit vector integer multiply on z.  Add a specific
> check for that.
> 
> gcc/ChangeLog:
> 
> 2017-09-28  Andreas Krebbel  
> 
>   * doc/sourcebuild.texi: Document vect_long_mult.
> 
> gcc/testsuite/ChangeLog:
> 
> 2017-09-28  Andreas Krebbel  
> 
>   * gcc.dg/vect/pr60656.c: Check vect_long_mult.
>   * lib/target-supports.exp (check_effective_target_vect_long_mult):
>   New proc.
OK.
jeff



Re: [PATCH 1/5] Enable vect_float with S/390 VXE and adjust testcases

2017-10-02 Thread Jeff Law
On 09/28/2017 05:50 AM, Andreas Krebbel wrote:
> The target supports routines provide vect_double and vect_float but
> these do not appear to be used consequently in the vect testcases.
> With z13 we only have support for vector double but with z14 also for
> vector float.  This patch adds vect_float to the testcases using the
> float data type and make the vect_float target check to return 1 only
> on z14.
> 
> gcc/testsuite/ChangeLog:
> 
> 2017-09-28  Andreas Krebbel  
> 
>   * lib/target-supports.exp (check_effective_target_vect_float):
>   Return 1 being on a S/390 with VXE.
>   * gcc.dg/vect/pr31699.c: Require vec_float.
>   * gcc.dg/vect/pr61194.c: Likewise.
>   * gcc.dg/vect/pr65947-10.c: Likewise.
>   * gcc.dg/vect/pr66142.c: Likewise.
>   * gcc.dg/vect/slp-10.c: Likewise.
>   * gcc.dg/vect/slp-11c.c: Likewise.
>   * gcc.dg/vect/slp-12b.c: Likewise.
>   * gcc.dg/vect/slp-18.c: Likewise.
>   * gcc.dg/vect/slp-33.c: Likewise.
>   * gcc.dg/vect/slp-cond-2-big-array.c: Likewise.
>   * gcc.dg/vect/slp-cond-2.c: Likewise.
>   * gcc.dg/vect/vect-cond-10.c: Likewise.
>   * gcc.dg/vect/vect-cond-8.c: Likewise.
>   * gcc.dg/vect/vect-cond-9.c: Likewise.
>   * gcc.dg/vect/vect-float-extend-1.c: Likewise.
>   * gcc.dg/vect/vect-float-truncate-1.c: Likewise.
OK.
jeff


Re: [PATCH 2/5] Testcases using dg-options require at least -mzarch.

2017-10-02 Thread Jeff Law
On 09/28/2017 05:50 AM, Andreas Krebbel wrote:
> Testcases which override the vect default options using dg-options
> need at least -mzarch on S/390 32 bit.
> 
> gcc/testsuite/ChangeLog:
> 
> 2017-09-28  Andreas Krebbel  
> 
>   * gfortran.dg/vect/fast-math-mgrid-resid.f: Use -mzarch on S/390.
>   * gfortran.dg/vect/pr77848.f: Likewise.
OK.
jeff


Re: [PATCH 4/5] New target check for double<->int conversions

2017-10-02 Thread Jeff Law
On 09/28/2017 05:50 AM, Andreas Krebbel wrote:
> gcc/ChangeLog:
> 
> 2017-09-28  Andreas Krebbel  
> 
>   * doc/sourcebuild.texi: Document vect_intdouble_cvt and
>   vect_doubleint_cvt.
> 
> gcc/testsuite/ChangeLog:
> 
> 2017-09-28  Andreas Krebbel  
> 
>   * gcc.dg/vect/pr66251.c: Replace vect_floatint_cvt with
>   vect_doubleint_cvt and vect_intfloat_cvt with vect_intdouble_cvt.
>   * gcc.dg/vect/vect-floatint-conversion-2.c: Replace
>   vect_floatint_cvt with vect_doubleint_cvt.
>   * gcc.dg/vect/vect-intfloat-conversion-3.c: Replace
>   vect_intfloat_cvt with vect_intdouble_cvt.
>   * gfortran.dg/vect/pr60510.f: Require vect_intdouble_cvt.
>   * gfortran.dg/vect/vect-8.f90: Make number of vectorized loops
>   depend on vect_intdouble_cvt.
>   * lib/target-supports.exp
>   (check_effective_target_vect_doubleint_cvt)
>   (check_effective_target_vect_intdouble_cvt): New procs.
OK.
jeff


Re: [PATCH 5/5] New target check: vect_can_peel

2017-10-02 Thread Jeff Law
On 09/28/2017 05:50 AM, Andreas Krebbel wrote:
> gcc/ChangeLog:
> 
> 2017-09-28  Andreas Krebbel  
> 
>   * doc/sourcebuild.texi: Document vect_can_peel.
> 
> gcc/testsuite/ChangeLog:
> 
> 2017-09-28  Andreas Krebbel  
> 
>   * g++.dg/vect/slp-pr56812.cc: xfail for targets which don't want
>   vector loop peeling.
>   * lib/target-supports.exp (check_effective_target_vect_can_peel):
>   New proc.
Can you come up with a better name than vect_can_peel?  The comments
indicate it's more about peeling to improve alignment is profitable on
the target rather than the target's ability to peel.

OK with a better name.

jeff


Re: [PATCH] simplify-rtx: Remove non-simplifying simplification (PR77729)

2017-10-02 Thread Jeff Law
On 10/02/2017 01:35 PM, Segher Boessenkool wrote:
> If we have (X&C1)|C2 simplify_binary_operation_1 makes C1 as small as
> possible.  This makes worse code in common cases like when the AND with
> C1 is from a zero-extension.  This patch fixes it by removing this
> transformation (twice).
> 
> I tested this on 31 targets, also some variations that do the
> transformation only for some conditions (like, do not do it if the
> resulting constant looks "worse", e.g. has more stretches of ones).
> 22 of those targets show no difference; 8 are best with this patch
> variant (never do the transformation); and 64-bit hppa is not best,
> but the difference is only four insns in a million.
> 
> Bootstrapped and tested on powerpc64-linux {-m32,-m64}.  Is this okay
> for trunk?  And backports?
> 
> 
> Segher
> 
> 
> 2017-10-02  Segher Boessenkool  
> 
>   PR rtl-optimization/77729
>   * simplify-rtx.c (simplify_binary_operation_1): Delete the (X&C1)|C2
>   to (X&(C1&~C2))|C2 transformations.
OK for the trunk.  I'm not sure if the BZ in question qualifies this
patch for backporting though.  Release managers have the final say on
the backport question.

And FWIW, the PA being an outlier on an optimization question should
never IMHO be a blocker :-)

jeff


Re: [PATCH] C++17 P0067R5 std::to_chars and std::from_chars (partial)

2017-10-02 Thread Jonathan Wakely

On 02/10/17 21:53 +0200, Jakub Jelinek wrote:

On Mon, Oct 02, 2017 at 03:13:17PM +0100, Jonathan Wakely wrote:

This adds the integral overloads of std::to_chars and std::from_chars,
including the changes made by P0682R0. Support for floating point types
is absent.

This uses a number of suggestions from Lars (thanks!) but I might have
missed some of his ideas and so could be missing some potential
optimizations.

An earlier version of the patch was posted in
https://gcc.gnu.org/ml/libstdc++/2017-04/msg00025.html

* include/Makefile.am: Add new  header.
* include/Makefile.in: Regenerate.
* include/precompiled/stdc++.h: Include .
* include/std/charconv: New file.
(to_chars_result, to_chars, from_chars_result, from_chars): Define.
* testsuite/20_util/from_chars/1.cc: New test.
* testsuite/20_util/from_chars/1_neg.cc: New test.
* testsuite/20_util/from_chars/2.cc: New test.
* testsuite/20_util/from_chars/requirements.cc: New test.
* testsuite/20_util/to_chars/1.cc: New test.
* testsuite/20_util/to_chars/1_neg.cc: New test.
* testsuite/20_util/to_chars/2.cc: New test.
* testsuite/20_util/to_chars/requirements.cc: New test.

Tested powerpc64le-linux, committed to trunk.


This fails on 32-bit targets, there are too many closing >s if
__int128_t is missing.

Either of the attached patches fixes this, which one do you prefer (or do
you want yet another formatting)?


The first one please.

Sorry for not testing it on 32-bit, I must remember to check on
multilib targets, not just ppc64le.




[PATCH] avoid ifunc warnings in libatomic configure

2017-10-02 Thread Martin Sebor

The attached patch tweaks the configuration check for attribute
ifunc support in libatomic to avoid the new type safety warnings.
It also changes the libatomic declarations of ifunc resolvers to
avoid the new warnings.  With it conftest.c compiles successfully
(see below) as does libatomic, and no there are regressions in
tests on x86_64.  Does it look good to check in?

I haven't been paying close attention so if Steve or someone else
already submitted a patch with the libatomic_i.h changes I can take
mine out.

Martin

configure:14689: checking whether the target supports the ifunc attribute
configure:14712: /ssd/build/gcc-git-maint/./gcc/xgcc 
-B/ssd/build/gcc-git-maint/./gcc/ -B/usr/local/x86_64-pc-linux-gnu/bin/ 
-B/usr/local/x86_64-pc-linux-gnu/lib/ -isystem 
/usr/local/x86_64-pc-linux-gnu/include -isystem 
/usr/local/x86_64-pc-linux-gnu/sys-include  -m32 -o conftest -O2 -O0 -g3 
 -pthread  -pthread -Werror   conftest.c  >&5

configure:14712: $? = 0
configure:14720: result: yes
PR c/81854 -  weak alias of an incompatible symbol accepted

libatomic/ChangeLog:

2017-10-02  Martin Sebor  

	PR c/81854
	* acinclude.m4 (LIBAT_CHECK_IFUNC): Have ifunc resolver return
	a function pointer rather than void* to avoid GCC 8 warnings.
	* configure: Regenerate.
	* libatomic_i.h: Declare ifunc resolvers to return function
	pointers rather than void*.

diff --git a/libatomic/acinclude.m4 b/libatomic/acinclude.m4
index 485d731..383218f 100644
--- a/libatomic/acinclude.m4
+++ b/libatomic/acinclude.m4
@@ -195,7 +195,8 @@ AC_DEFUN([LIBAT_CHECK_IFUNC], [
   CFLAGS="$CFLAGS -Werror"
   AC_TRY_LINK([
 int foo_alt(void) { return 0; }
-void *foo_sel(void) { return foo_alt; }
+typedef int F (void);
+F *foo_sel(void) { return foo_alt; }
 int foo(void) __attribute__((ifunc("foo_sel")));],
 [return foo();], libat_cv_have_ifunc=yes, libat_cv_have_ifunc=no)])
   LIBAT_DEFINE_YESNO([HAVE_IFUNC], [$libat_cv_have_ifunc],
diff --git a/libatomic/configure b/libatomic/configure
index c05fc9d..e88a7b8 100755
--- a/libatomic/configure
+++ b/libatomic/configure
@@ -12333,6 +12333,7 @@ _ACEOF
 
 
 
+
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __atomic_load/store for size 2" >&5
 $as_echo_n "checking for __atomic_load/store for size 2... " >&6; }
 if test "${libat_cv_have_at_ldst_2+set}" = set; then :
@@ -12400,6 +12401,7 @@ _ACEOF
 
 
 
+
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __atomic_load/store for size 4" >&5
 $as_echo_n "checking for __atomic_load/store for size 4... " >&6; }
 if test "${libat_cv_have_at_ldst_4+set}" = set; then :
@@ -12467,6 +12469,7 @@ _ACEOF
 
 
 
+
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __atomic_load/store for size 8" >&5
 $as_echo_n "checking for __atomic_load/store for size 8... " >&6; }
 if test "${libat_cv_have_at_ldst_8+set}" = set; then :
@@ -12534,6 +12537,7 @@ _ACEOF
 
 
 
+
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __atomic_load/store for size 16" >&5
 $as_echo_n "checking for __atomic_load/store for size 16... " >&6; }
 if test "${libat_cv_have_at_ldst_16+set}" = set; then :
@@ -12602,6 +12606,7 @@ _ACEOF
 
 
 
+
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __atomic_test_and_set for size 1" >&5
 $as_echo_n "checking for __atomic_test_and_set for size 1... " >&6; }
 if test "${libat_cv_have_at_tas_1+set}" = set; then :
@@ -14693,7 +14698,8 @@ else
 /* end confdefs.h.  */
 
 int foo_alt(void) { return 0; }
-void *foo_sel(void) { return foo_alt; }
+typedef int F (void);
+F *foo_sel(void) { return foo_alt; }
 int foo(void) __attribute__((ifunc("foo_sel")));
 int
 main ()
diff --git a/libatomic/libatomic_i.h b/libatomic/libatomic_i.h
index 4eb372a..2dad4a8 100644
--- a/libatomic/libatomic_i.h
+++ b/libatomic/libatomic_i.h
@@ -240,7 +240,7 @@ bool libat_is_lock_free (size_t, void *) MAN(is_lock_free);
 # if IFUNC_NCOND(N) == 1
 #  define GEN_SELECTOR(X)	\
 	extern typeof(C2(libat_,X)) C3(libat_,X,_i1) HIDDEN;	\
-	static void * C2(select_,X) (void)			\
+	static typeof(C2(libat_,X)) * C2(select_,X) (void)	\
 	{			\
 	  if (IFUNC_COND_1)	\
 	return C3(libat_,X,_i1);\
@@ -250,7 +250,7 @@ bool libat_is_lock_free (size_t, void *) MAN(is_lock_free);
 #  define GEN_SELECTOR(X)	\
 	extern typeof(C2(libat_,X)) C3(libat_,X,_i1) HIDDEN;	\
 	extern typeof(C2(libat_,X)) C3(libat_,X,_i2) HIDDEN;	\
-	static void * C2(select_,X) (void)			\
+	static typeof(C2(libat_,X)) * C2(select_,X) (void)	\
 	{			\
 	  if (IFUNC_COND_1)	\
 	return C3(libat_,X,_i1);\
@@ -263,7 +263,7 @@ bool libat_is_lock_free (size_t, void *) MAN(is_lock_free);
 	extern typeof(C2(libat_,X)) C3(libat_,X,_i1) HIDDEN;	\
 	extern typeof(C2(libat_,X)) C3(libat_,X,_i2) HIDDEN;	\
 	extern typeof(C2(libat_,X)) C3(libat_,X,_i3) HIDDEN;	\
-	static void * C2(select_,X) (void)			\
+	static typeof(C2(libat_,X)) * C2(select_,X) (void)	\
 	{			\
 	  if (IFUNC_COND_1)	\
 	return C3(libat_,X,_i1);\


Re: [PATCH] avoid ifunc warnings in libatomic configure

2017-10-02 Thread Joseph Myers
On Mon, 2 Oct 2017, Martin Sebor wrote:

> The attached patch tweaks the configuration check for attribute
> ifunc support in libatomic to avoid the new type safety warnings.
> It also changes the libatomic declarations of ifunc resolvers to
> avoid the new warnings.  With it conftest.c compiles successfully
> (see below) as does libatomic, and no there are regressions in
> tests on x86_64.  Does it look good to check in?

OK.

-- 
Joseph S. Myers
jos...@codesourcery.com


Re: [PATCH] avoid ifunc warnings in libatomic configure

2017-10-02 Thread Steve Ellcey
On Mon, 2017-10-02 at 17:00 -0600, Martin Sebor wrote:
> The attached patch tweaks the configuration check for attribute
> ifunc support in libatomic to avoid the new type safety warnings.
> It also changes the libatomic declarations of ifunc resolvers to
> avoid the new warnings.  With it conftest.c compiles successfully
> (see below) as does libatomic, and no there are regressions in
> tests on x86_64.  Does it look good to check in?
> 
> I haven't been paying close attention so if Steve or someone else
> already submitted a patch with the libatomic_i.h changes I can take
> mine out.
> 
> Martin

I haven't submitted anything for this problem.  This patch fixed things
for my aarch64 build.  I definitely needed the libatomic_i.h changes as
well as the configure change.

Steve Ellcey
sell...@cavium.com


Re: [PATCH #2], Define __FP_FAST_FMAF128 on PowerPC ISA 3.0

2017-10-02 Thread Michael Meissner
On Thu, Sep 28, 2017 at 12:40:24AM +, Joseph Myers wrote:
> On Wed, 27 Sep 2017, Michael Meissner wrote:
> 
> > The glibc team has requested we define the standard macro 
> > (__FP_FAST_FMAF128)
> > for PowerPC code when we have the IEEE 128-bit floating point hardware
> > instructions enabled.
> 
> It's not a standard macro.  TS 18661-3 has FP_FAST_FMAF128 as an optional 
> math.h macro (but glibc doesn't define it anywhere at present).
> 
> > This patch does this in the PowerPC backend.  As I look at the whole issue, 
> > at
> > some point we should do this more in the machine independent portion of the
> > compiler.  I have some initial patches to do this in the c-family files, 
> > but at
> > the present time, the patches are not complete, and I need to think about it
> > more.
> 
> I think a machine-independent definition (for _FloatN / _FloatNx types in 
> general) should go along with machine-independent fmafN / fmafNx built-in 
> functions; when the built-in function is machine-specific, it's natural 
> for the macro to be as well.
> 
> But in any case, the new macro should be documented in cpp.texi alongside 
> the existing __FP_FAST_FMA* macros (probably in the generic 
> __FP_FAST_FMAF@var{n} and __FP_FAST_FMAF@var{n}X form).

This patch adds support for adding the built-in __builtin_fmaf and
__builtin_fmafx functions if the target machine supports an appropriate
fused multiply-add (FMA) instruction.  This patch replaces the original PowerPC
specific patch.

Because it involves changes in the built-in support, both the c and c-family
subdirectories, as well as PowerPC changes, I added the global/release
maintainers to the To: list.

I have done a bootstrap and make check on a little endian Power8 with no
regresions in the tests.  I have verified that the changed and new tests both
ran fine.

I have also bootstrapped the changes on an x86-64 compiler, and it bootstrapped
fine.  I am currently running the unmodified build, but I'm not expecting any
changes in the test suite.

Assuming the x86-64 tests also have no regressions, can I check these changes
into the trunk?

[gcc]
2017-10-02  Michael Meissner  

* builtins.def (BUILT_IN_FMAF16): Add support for fused
multiply-add built-in functions for _Float and _Floatx
types.
(BUILT_IN_FMAF32): Likewise.
(BUILT_IN_FMAF64): Likewise.
(BUILT_IN_FMAF128): Likewise.
(BUILT_IN_FMAF32X): Likewise.
(BUILT_IN_FMAF64X): Likewise.
(BUILT_IN_FMAF128X): Likewise.
* builtin-types.def (BT_FN_FLOAT16_FLOAT16_FLOAT16_FLOAT16):
Likewise.
(BT_FN_FLOAT32_FLOAT32_FLOAT32_FLOAT32): Likewise.
(BT_FN_FLOAT64_FLOAT64_FLOAT64_FLOAT64): Likewise.
(BT_FN_FLOAT128_FLOAT128_FLOAT128_FLOAT128): Likewise.
(BT_FN_FLOAT32X_FLOAT32X_FLOAT32X_FLOAT32X): Likewise.
(BT_FN_FLOAT64X_FLOAT64X_FLOAT64X_FLOAT64X): Likewise.
(BT_FN_FLOAT128X_FLOAT128X_FLOAT128X_FLOAT128X): Likewise.
* builtins.c (expand_builtin_mathfn_ternary): Likewise.
(expand_builtin): Add fused multiply-add builtin support for
_Float and _FloatX types.  Issue a warning if the machine
does not provide an appropriate FMA insn.
(fold_builtin_3): Add support for fused multiply-add built-in
functions for _Float and _Floatx types.
* config/rs6000/rs6000-builtins.def (FMAF128): Delete creating
__builtin_fmaf128, since this is now done in machine independent
code.
* doc/cpp.texi (__FP_FAST_FMAF16): Document macros set to declare
that the appropriate fused multiply-add on _Float and
_FloatX types is implemented.
(__FP_FAST_FMAF32): Likewise.
(__FP_FAST_FMAF64): Likewise.
(__FP_FAST_FMAF128): Likewise.
(__FP_FAST_FMAF32X): Likewise.
(__FP_FAST_FMAF64X): Likewise.
(__FP_FAST_FMAF128X): Likewise.

[gcc/c]
2017-10-02  Michael Meissner  

* c-decl.c (header_for_builtin_fn): Add support for fused
multiply-add built-in functions for _Float and _Floatx
types.

[gcc/c-family]
2017-10-02  Michael Meissner  

* c-cppbuiltin.c (mode_has_fma): Add support for PowerPC _float128
FMA (KFmode) if long double != __float128.
(c_cpp_builtins): Define __FP_FAST_FMAF if _Float fused
multiply-add is supported.  Define __FP_FAST_FMAFX if
_Floatx fused multiply-add is supported.

[gcc/testsuite]
2017-10-02  Michael Meissner  

* gcc.target/powerpc/float128-fma2.c: Change error to new
warning.
* gcc.target/powerpc/float128-fma3.c: New test.


-- 
Michael Meissner, IBM
IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA
email: meiss...@linux.vnet.ibm.com, phone: +1 (978) 899-4797



Re: [PATCH #2], Define __FP_FAST_FMAF128 on PowerPC ISA 3.0

2017-10-02 Thread Michael Meissner
Whoops, I forgot to attach the patch.

On Mon, Oct 02, 2017 at 07:51:00PM -0400, Michael Meissner wrote:
> On Thu, Sep 28, 2017 at 12:40:24AM +, Joseph Myers wrote:
> > On Wed, 27 Sep 2017, Michael Meissner wrote:
> > 
> > > The glibc team has requested we define the standard macro 
> > > (__FP_FAST_FMAF128)
> > > for PowerPC code when we have the IEEE 128-bit floating point hardware
> > > instructions enabled.
> > 
> > It's not a standard macro.  TS 18661-3 has FP_FAST_FMAF128 as an optional 
> > math.h macro (but glibc doesn't define it anywhere at present).
> > 
> > > This patch does this in the PowerPC backend.  As I look at the whole 
> > > issue, at
> > > some point we should do this more in the machine independent portion of 
> > > the
> > > compiler.  I have some initial patches to do this in the c-family files, 
> > > but at
> > > the present time, the patches are not complete, and I need to think about 
> > > it
> > > more.
> > 
> > I think a machine-independent definition (for _FloatN / _FloatNx types in 
> > general) should go along with machine-independent fmafN / fmafNx built-in 
> > functions; when the built-in function is machine-specific, it's natural 
> > for the macro to be as well.
> > 
> > But in any case, the new macro should be documented in cpp.texi alongside 
> > the existing __FP_FAST_FMA* macros (probably in the generic 
> > __FP_FAST_FMAF@var{n} and __FP_FAST_FMAF@var{n}X form).
> 
> This patch adds support for adding the built-in __builtin_fmaf and
> __builtin_fmafx functions if the target machine supports an appropriate
> fused multiply-add (FMA) instruction.  This patch replaces the original 
> PowerPC
> specific patch.
> 
> Because it involves changes in the built-in support, both the c and c-family
> subdirectories, as well as PowerPC changes, I added the global/release
> maintainers to the To: list.
> 
> I have done a bootstrap and make check on a little endian Power8 with no
> regresions in the tests.  I have verified that the changed and new tests both
> ran fine.
> 
> I have also bootstrapped the changes on an x86-64 compiler, and it 
> bootstrapped
> fine.  I am currently running the unmodified build, but I'm not expecting any
> changes in the test suite.
> 
> Assuming the x86-64 tests also have no regressions, can I check these changes
> into the trunk?
> 
> [gcc]
> 2017-10-02  Michael Meissner  
> 
>   * builtins.def (BUILT_IN_FMAF16): Add support for fused
>   multiply-add built-in functions for _Float and _Floatx
>   types.
>   (BUILT_IN_FMAF32): Likewise.
>   (BUILT_IN_FMAF64): Likewise.
>   (BUILT_IN_FMAF128): Likewise.
>   (BUILT_IN_FMAF32X): Likewise.
>   (BUILT_IN_FMAF64X): Likewise.
>   (BUILT_IN_FMAF128X): Likewise.
>   * builtin-types.def (BT_FN_FLOAT16_FLOAT16_FLOAT16_FLOAT16):
>   Likewise.
>   (BT_FN_FLOAT32_FLOAT32_FLOAT32_FLOAT32): Likewise.
>   (BT_FN_FLOAT64_FLOAT64_FLOAT64_FLOAT64): Likewise.
>   (BT_FN_FLOAT128_FLOAT128_FLOAT128_FLOAT128): Likewise.
>   (BT_FN_FLOAT32X_FLOAT32X_FLOAT32X_FLOAT32X): Likewise.
>   (BT_FN_FLOAT64X_FLOAT64X_FLOAT64X_FLOAT64X): Likewise.
>   (BT_FN_FLOAT128X_FLOAT128X_FLOAT128X_FLOAT128X): Likewise.
>   * builtins.c (expand_builtin_mathfn_ternary): Likewise.
>   (expand_builtin): Add fused multiply-add builtin support for
>   _Float and _FloatX types.  Issue a warning if the machine
>   does not provide an appropriate FMA insn.
>   (fold_builtin_3): Add support for fused multiply-add built-in
>   functions for _Float and _Floatx types.
>   * config/rs6000/rs6000-builtins.def (FMAF128): Delete creating
>   __builtin_fmaf128, since this is now done in machine independent
>   code.
>   * doc/cpp.texi (__FP_FAST_FMAF16): Document macros set to declare
>   that the appropriate fused multiply-add on _Float and
>   _FloatX types is implemented.
>   (__FP_FAST_FMAF32): Likewise.
>   (__FP_FAST_FMAF64): Likewise.
>   (__FP_FAST_FMAF128): Likewise.
>   (__FP_FAST_FMAF32X): Likewise.
>   (__FP_FAST_FMAF64X): Likewise.
>   (__FP_FAST_FMAF128X): Likewise.
> 
> [gcc/c]
> 2017-10-02  Michael Meissner  
> 
>   * c-decl.c (header_for_builtin_fn): Add support for fused
>   multiply-add built-in functions for _Float and _Floatx
>   types.
> 
> [gcc/c-family]
> 2017-10-02  Michael Meissner  
> 
>   * c-cppbuiltin.c (mode_has_fma): Add support for PowerPC _float128
>   FMA (KFmode) if long double != __float128.
>   (c_cpp_builtins): Define __FP_FAST_FMAF if _Float fused
>   multiply-add is supported.  Define __FP_FAST_FMAFX if
>   _Floatx fused multiply-add is supported.
> 
> [gcc/testsuite]
> 2017-10-02  Michael Meissner  
> 
>   * gcc.target/powerpc/float128-fma2.c: Change error to new
>   warning.
>   * gcc.target/powerpc/float128-fma3.c: New test.
> 
> 
> -- 
> Michael Meissner, IBM
> IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA
> emai

Re: [PATCH] avoid ifunc warnings in libatomic configure

2017-10-02 Thread Martin Sebor

On 10/02/2017 05:29 PM, Steve Ellcey wrote:

On Mon, 2017-10-02 at 17:00 -0600, Martin Sebor wrote:

The attached patch tweaks the configuration check for attribute
ifunc support in libatomic to avoid the new type safety warnings.
It also changes the libatomic declarations of ifunc resolvers to
avoid the new warnings.  With it conftest.c compiles successfully
(see below) as does libatomic, and no there are regressions in
tests on x86_64.  Does it look good to check in?

I haven't been paying close attention so if Steve or someone else
already submitted a patch with the libatomic_i.h changes I can take
mine out.

Martin


I haven't submitted anything for this problem.  This patch fixed things
for my aarch64 build.  I definitely needed the libatomic_i.h changes as
well as the configure change.


Great, thank you for verifying it there!  I just committed it
in r253372.

Martin



Re: [PATCH #2], Define __FP_FAST_FMAF128 on PowerPC ISA 3.0

2017-10-02 Thread Joseph Myers
On Mon, 2 Oct 2017, Michael Meissner wrote:

> > > But in any case, the new macro should be documented in cpp.texi alongside 
> > > the existing __FP_FAST_FMA* macros (probably in the generic 
> > > __FP_FAST_FMAF@var{n} and __FP_FAST_FMAF@var{n}X form).
> > 
> > This patch adds support for adding the built-in __builtin_fmaf and
> > __builtin_fmafx functions if the target machine supports an appropriate
> > fused multiply-add (FMA) instruction.  This patch replaces the original 
> > PowerPC
> > specific patch.

Certainly the  FP_FAST_FMA* macros are supposed to relate to 
whether the public functions such as fmaf128 are fast rather than to 
__builtin_* names.

I think there's a strong case that you should provide built-in functions 
under the public names when defining __FP_FAST_FMA*.  I.e., add a variant 
of DEF_GCC_FLOATN_NX_BUILTINS that uses DEF_EXT_LIB_BUILTIN instead of 
DEF_GCC_BUILTIN, and use that for the new built-in functions.

Then, the built-in functions, in whatever form they are provided, should 
be documented in extend.texi, alongside the documentation of 
__builtin_fabsf@var{n} etc. (with, of course, the caveats about 
availability when appropriate instruction support isn't available - the 
__builtin_fabsfN, __builtin_copysignfN functions are always inlined, the 
fma ones aren't, and people may well lack C library support for the 
underlying functions).

Given that, I don't think the warning about lack of instruction support is 
appropriate; a call to __builtin_fmaf128, if the type is supported but 
there is no corresponding instruction (on x86_64, say), would just fall 
back to calling an external fmaf128 function (which in that case would 
work with glibc 2.26 or later, though calls to fmaf64 etc. wouldn't), much 
like any other such built-in function (we don't warn about e.g. calling 
__builtin_clog10 on systems whose C library may not have clog10).

-- 
Joseph S. Myers
jos...@codesourcery.com


Re: libbacktrace patch committed: Support compressed debug sections

2017-10-02 Thread Ian Lance Taylor
Thanks for the fixes.  I made some style tweaks, committed as follows
after bootstrap and testing.

Ian

2017-10-02  Ian Lance Taylor  

* ztest.c: #include .
(TEST_TIMING): Don't define, don't test.
(xclock_gettime, xclockid_t): Define if !HAVE_CLOCK_GETTIME.
(clockid_t, clock_gettime, CLOCK_REALTIME): Likewise.
(ZLIB_CLOCK_GETTIME_ARG): Define.
* configure.ac: Change clock_gettime_link to CLOCK_GETTIME_LINK.
* Makefile.am: Likewise.
* configure, Makefile.in: Rebuild.
Index: Makefile.am
===
--- Makefile.am (revision 253376)
+++ Makefile.am (working copy)
@@ -108,7 +108,7 @@ ztest_LDADD = libbacktrace.la
 if HAVE_ZLIB
 ztest_LDADD += -lz
 endif
-ztest_LDADD += $(clock_gettime_link)
+ztest_LDADD += $(CLOCK_GETTIME_LINK)
 
 check_PROGRAMS += ztest
 
Index: configure.ac
===
--- configure.ac(revision 253376)
+++ configure.ac(working copy)
@@ -397,11 +397,11 @@ clock_gettime_link=
 # we're using this for test timing only.
 if test "$ac_cv_func_clock_gettime" = no; then
   AC_CHECK_LIB(rt, clock_gettime,
-[clock_gettime_link=-lrt
+[CLOCK_GETTIME_LINK=-lrt
  AC_DEFINE(HAVE_CLOCK_GETTIME, 1,
   [Define to 1 if you have the `clock_gettime' function.])])
 fi
-AC_SUBST(clock_gettime_link)
+AC_SUBST(CLOCK_GETTIME_LINK)
 
 dnl Test whether the compiler supports the -pthread option.
 AC_CACHE_CHECK([whether -pthread is supported],
Index: ztest.c
===
--- ztest.c (revision 253376)
+++ ztest.c (working copy)
@@ -32,6 +32,7 @@ POSSIBILITY OF SUCH DAMAGE.  */
 
 #include "config.h"
 
+#include 
 #include 
 #include 
 #include 
@@ -43,16 +44,37 @@ POSSIBILITY OF SUCH DAMAGE.  */
 #include 
 #endif
 
-#ifdef HAVE_CLOCK_GETTIME
-# define TEST_TIMING
-#endif
-
 #include "backtrace.h"
 #include "backtrace-supported.h"
 
 #include "internal.h"
 #include "testlib.h"
 
+#ifndef HAVE_CLOCK_GETTIME
+
+typedef int xclockid_t;
+
+static int
+xclock_gettime (xclockid_t id ATTRIBUTE_UNUSED,
+   struct timespec *ts ATTRIBUTE_UNUSED)
+{
+  errno = EINVAL;
+  return -1;
+}
+
+#define clockid_t xclockid_t
+#define clock_gettime xclock_gettime
+#undef CLOCK_REALTIME
+#define CLOCK_REALTIME 0
+
+#endif /* !defined(HAVE_CLOCK_GETTIME) */
+
+#ifdef CLOCK_PROCESS_CPUTIME_ID
+#define ZLIB_CLOCK_GETTIME_ARG CLOCK_PROCESS_CPUTIME_ID
+#else
+#define ZLIB_CLOCK_GETTIME_ARG CLOCK_REALTIME
+#endif
+
 /* Some tests for the local zlib inflation code.  */
 
 struct zlib_test
@@ -161,7 +183,7 @@ test_samples (struct backtrace_state *st
 }
 }
 
-#if defined HAVE_ZLIB && defined TEST_TIMING
+#ifdef HAVE_ZLIB
 
 /* Given a set of TRIALS timings, discard the lowest and highest
values and return the mean average of the rest.  */
@@ -220,7 +242,6 @@ test_large (struct backtrace_state *stat
   unsigned char *uncompressed_buf;
   size_t uncompressed_bufsize;
   int r;
-# ifdef TEST_TIMING
   clockid_t cid;
   struct timespec ts1;
   struct timespec ts2;
@@ -229,7 +250,6 @@ test_large (struct backtrace_state *stat
   const size_t trials = 16;
   size_t ctimes[16];
   size_t ztimes[16];
-# endif /* TEST_TIMING */
   static const char * const names[] = {
 "Mark.Twain-Tom.Sawyer.txt",
 "../libgo/go/compress/testdata/Mark.Twain-Tom.Sawyer.txt"
@@ -347,16 +367,13 @@ test_large (struct backtrace_state *stat
 
   printf ("PASS: inflate large\n");
 
-# ifdef TEST_TIMING
-
   for (i = 0; i < trials; ++i)
 {
-  cid = CLOCK_REALTIME;
-#ifdef CLOCK_PROCESS_CPUTIME_ID
-  cid = CLOCK_PROCESS_CPUTIME_ID;
-#endif
+  cid = ZLIB_CLOCK_GETTIME_ARG;
   if (clock_gettime (cid, &ts1) < 0)
{
+ if (errno == EINVAL)
+   return;
  perror ("clock_gettime");
  return;
}
@@ -419,8 +436,6 @@ test_large (struct backtrace_state *stat
   printf ("zlib time:: %zu ns\n", ztime);
   printf ("percentage: %g\n", (double) ztime / (double) ctime);
 
-# endif /* TEST_TIMING */
-
   return;
 
  fail: