C++ PATCH for c++/86098, ICE with template template parameter placeholder

2018-06-12 Thread Jason Merrill
When comparing two TEMPLATE_TYPE_PARM, we need to consider whether
they are acting as placeholders for templates.

Tested x86_64-pc-linux-gnu, applying to trunk.
commit 10e5cb6bf4c605741ef59f17120304a3c261c06c
Author: Jason Merrill 
Date:   Tue Jun 12 22:38:07 2018 -0400

PR c++/86098 - ICE with template placeholder for TTP.

* typeck.c (structural_comptypes) [TEMPLATE_TYPE_PARM]: Check
CLASS_PLACEHOLDER_TEMPLATE.

diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 9febdb908ae..b033afd9884 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -1375,6 +1375,11 @@ structural_comptypes (tree t1, tree t2, int strict)
 	 template parameters set, they can't be equal.  */
   if (!comp_template_parms_position (t1, t2))
 	return false;
+  /* If T1 and T2 don't represent the same class template deduction,
+ they aren't equal.  */
+  if (CLASS_PLACEHOLDER_TEMPLATE (t1)
+	  != CLASS_PLACEHOLDER_TEMPLATE (t2))
+	return false;
   /* Constrained 'auto's are distinct from parms that don't have the same
 	 constraints.  */
   if (!equivalent_placeholder_constraints (t1, t2))
diff --git a/gcc/testsuite/g++.dg/cpp1z/class-deduction58.C b/gcc/testsuite/g++.dg/cpp1z/class-deduction58.C
new file mode 100644
index 000..82c3f83710f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/class-deduction58.C
@@ -0,0 +1,16 @@
+// PR c++/86098
+// { dg-additional-options -std=c++17 }
+
+template  class future;
+template  T&& declval();
+
+template class T>
+struct construct_deduced {
+  template 
+  using deduced_t = decltype(T{declval()...});
+  template
+  deduced_t operator()(AN&&... an) const;
+};
+
+template
+future future_from(T singleSender);


Re: [PATCH] [PR86064] split single cross-partition range with nonzero locviews

2018-06-12 Thread Alexandre Oliva
On Jun 12, 2018, Alexandre Oliva  wrote:

> We didn't split cross-partition ranges in loclists to output a
> whole-function location expression, but with nonzero locviews, we
> force loclists, and then we have to split to avoid cross-partition
> list entries.

Regstrapped on x86_64-linux-gnu and i686-linux-gnu.  Ok to install?

> From: Alexandre Oliva 
> for  gcc/ChangeLog

>   PR debug/86064
>   * dwarf2out.c (loc_list_has_views): Adjust comments.
>   (dw_loc_list): Split single cross-partition range with
>   nonzero locview.

> for  gcc/testsuite/ChangeLog

>   PR debug/86064
>   * gcc.dg/pr86064.c: New.

-- 
Alexandre Oliva, freedom fighter   https://FSFLA.org/blogs/lxo
Be the change, be Free! FSF Latin America board member
GNU Toolchain EngineerFree Software Evangelist


[PATCH] [PR86064] split single cross-partition range with nonzero locviews

2018-06-12 Thread Alexandre Oliva


We didn't split cross-partition ranges in loclists to output a
whole-function location expression, but with nonzero locviews, we
force loclists, and then we have to split to avoid cross-partition
list entries.

From: Alexandre Oliva 
for  gcc/ChangeLog

PR debug/86064
* dwarf2out.c (loc_list_has_views): Adjust comments.
(dw_loc_list): Split single cross-partition range with
nonzero locview.

for  gcc/testsuite/ChangeLog

PR debug/86064
* gcc.dg/pr86064.c: New.
---
 gcc/dwarf2out.c| 18 --
 gcc/testsuite/gcc.dg/pr86064.c | 27 +++
 2 files changed, 43 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/pr86064.c

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 620e66986be6..0c5d7e0e0357 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -9982,7 +9982,15 @@ new_loc_list (dw_loc_descr_ref expr, const char *begin, 
var_loc_view vbegin,
   return retlist;
 }
 
-/* Return true iff there's any nonzero view number in the loc list.  */
+/* Return true iff there's any nonzero view number in the loc list.
+
+   ??? When views are not enabled, we'll often extend a single range
+   to the entire function, so that we emit a single location
+   expression rather than a location list.  With views, even with a
+   single range, we'll output a list if start or end have a nonzero
+   view.  If we change this, we may want to stop splitting a single
+   range in dw_loc_list just because of a nonzero view, even if it
+   straddles across hot/cold partitions.  */
 
 static bool
 loc_list_has_views (dw_loc_list_ref list)
@@ -17090,7 +17098,13 @@ dw_loc_list (var_loc_list *loc_list, tree decl, int 
want_address)
 of first partition and second one starting at the
 beginning of second partition.  */
  if (node == loc_list->last_before_switch
- && (node != loc_list->first || loc_list->first->next)
+ && (node != loc_list->first || loc_list->first->next
+ /* If we are to emit a view number, we will emit
+a loclist rather than a single location
+expression for the entire function (see
+loc_list_has_views), so we have to split the
+range that straddles across partitions.  */
+ || !ZERO_VIEW_P (node->view))
  && current_function_decl)
{
  endname = cfun->fde->dw_fde_end;
diff --git a/gcc/testsuite/gcc.dg/pr86064.c b/gcc/testsuite/gcc.dg/pr86064.c
new file mode 100644
index ..5be820c78f84
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr86064.c
@@ -0,0 +1,27 @@
+/* { dg-do compile } */
+/* { dg-options "-g -O2 -fno-var-tracking-assignments -gsplit-dwarf" } */
+
+/* This used to fail with location views (implicitly) enabled, because
+   var-tracking (not at assignments) creates a range for d starting at
+   the load after the first call, and we did not split the range,
+   despite its crossing between hot and cold partitions, because it's
+   a single range, that we normally extend to the entire function.
+   However, because the range starts at a (presumed) nonzero view, we
+   end up outputting a loclist instead of a single location entry.
+   But then, -gsplit-dwarf selects (startx,length) loclist entries,
+   and the length ends up computing the difference between symbols in
+   different subsections.  */
+
+int a;
+__attribute__((__cold__)) void b();
+
+void e(int *);
+int f();
+
+void c() {
+  int d;
+  e();
+  a = d;
+  if (f())
+b();
+}
-- 
2.17.1


-- 
Alexandre Oliva, freedom fighter   https://FSFLA.org/blogs/lxo
Be the change, be Free! FSF Latin America board member
GNU Toolchain EngineerFree Software Evangelist


Re: [PATCH 2/3] Temporary remove "at least 8 byte alignment" code from x86

2018-06-12 Thread Jeff Law
On 05/21/2018 07:55 AM, marxin wrote:
> 
> gcc/ChangeLog:
> 
> 2017-04-18  Denys Vlasenko  
> 
> * config/i386/i386-common.c (ix86_handle_option): Remove support
> for obsolete -malign-loops, -malign-jumps and -malign-functions
> options.
> * config/i386/i386.opt: Likewise.
The ChangeLog doesn't seem match the actual changes.  I think this patch
is more about using the additional info that's potentially provided by
the -falign options to drive backend decisions and dropping the
secondary alignment request.

The change seems to consistently do:

(1<<(LOG)))-1)

Which needs some horizontal whitespace.

The meat of the changes seem fairly reasonable.

jeff


Re: [PATCH 1/3] Add vec::reverse.

2018-06-12 Thread Jeff Law
On 05/22/2018 06:15 AM, marxin wrote:
> 
> gcc/ChangeLog:
> 
> 2018-05-25  Martin Liska  
>   David Malcolm  
> 
>   * vec.c (test_reverse): New.
>   (vec_c_tests): Add new test.
>   * vec.h (vl_ptr>::reverse): New function.
OK.  Seems generally useful, so from my point of view it can go in
immediately.

jeff



Re: Improve std::rotate usages

2018-06-12 Thread Jonathan Wakely

On 12/06/18 22:39 +0200, François Dumont wrote:

I'm struggling having a validation for this patch.

As it is a trivial one and to not bother you I plan to commit it 
tomorrow if not told otherwise.


No, please wait for review.



[PATCH] Let env var CLICOLOR_FORCE set -fdiagnostics-color=always.

2018-06-12 Thread Adam Borowski
Hi!
Here's a patch for Bugzilla 80271, to add support for env CLICOLOR_FORCE.

Automated build environments -- and even some which you run by hand --
redirect the output somewhere to save a log, even if they tee it to the
terminal anyway.  This kills all colored highlights for diagnostics.
Those highlights are really nice for a human -- unlike the old days when
a single-threaded build always had the failure at the end, modern setups
tend to spew pages of stuff after the real reason your build failed.  As
human vision evolved to be extremely good at noticing a fleck of color,
it's easy to spot that bit of red even when scrolling very fast.

Besides terminals, you can read colored logs via "less -R", ansi2html, etc.

For such piped setups, gcc has -fdiagnostics-color=always.  Alas, while this
flag is easy to set by someone writing a given piece of software, there's
no reasonable way to set it globally in the build environment.

Thus, in #80271 Jan Niklas Hasse requested, and I concur, to be able to
set the same via an env var.  This flag doesn't affect code produced by gcc
in any way, thus it's reasonable to set it via env.  There's already
GCC_COLORS letting you customize colors used, you just can't tell it to
ignore stderr not being a terminal.


Please forgive my lack of knowledge wrt proper ways of submitting patches to
gcc (ie, when biting please point to piece of TFM I failed to R).  In
particular, I'm not sure how to run the testsuite: it produces a lot of
fails even without my patch, and I don't know what is your way to spot new
failures.  The testsuite could be interesting as gcc in a lot of places sets
and unsets CLICOLOR_FORCE despite not supporting it itself (yet a number of
other tools do).  Weirdly, in every case you unset it in the very next line
after enabling it.

I've submitted an equivalent of this patch to llvm/clang as well.

-- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 -- >8 --
From: Adam Borowski 
Date: Mon, 11 Jun 2018 01:01:46 +0200
Subject: [PATCH] Let env var CLICOLOR_FORCE set -fdiagnostics-color=always.

---
 gcc/diagnostic.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c
index e22c17bc02c..d9e352932c6 100644
--- a/gcc/diagnostic.c
+++ b/gcc/diagnostic.c
@@ -190,12 +190,18 @@ diagnostic_color_init (diagnostic_context *context, int 
value /*= -1 */)
   /* value == -1 is the default value.  */
   if (value < 0)
 {
+  /* Explicit command-line args override env, but env prevails over
+ defaults, whatever they are.
+ The spec defines an existing but empty var to mean "yes".  */
+  const char* clic = getenv ("CLICOLOR_FORCE");
+  if (clic && strcmp (clic, "0"))
+   value = DIAGNOSTICS_COLOR_YES;
   /* If DIAGNOSTICS_COLOR_DEFAULT is -1, default to
 -fdiagnostics-color=auto if GCC_COLORS is in the environment,
 otherwise default to -fdiagnostics-color=never, for other
 values default to that
 -fdiagnostics-color={never,auto,always}.  */
-  if (DIAGNOSTICS_COLOR_DEFAULT == -1)
+  else if (DIAGNOSTICS_COLOR_DEFAULT == -1)
{
  if (!getenv ("GCC_COLORS"))
return;
-- 
2.17.1


Re: [PATCH, alpha] PR target/85095

2018-06-12 Thread Jeff Law
On 05/31/2018 12:56 PM, Gerald Pfeifer wrote:
> On Thu, 24 May 2018, Jeff Law wrote:
>>> I can try to fix openbsd soon, but freebsd dropped alpha in 2009.
>>> How does gcc feel about me picking up patches from openbsd ports, their
>>> package manager, that weren't written by myself?
>> So ISTM we should deprecate freebsd alpha.
> 
> Ab-so-lutely.  In fact, just yank it out, without any deprecation.
> 
>% grep sparc $PORTSDIR/lang/gcc*/Makefile | grep -i alpha | wc -l
>0
> 
> None of the GCC ports in the FreeBSD Ports Collection (the oldest of 
> which is gcc47 right now) has had any trace of alpha support left for 
> years and years, and there have been zero requests/complaints.
> 
> Gerald
> 
Done.

Jeff
diff --git a/contrib/ChangeLog b/contrib/ChangeLog
index 6c184f766b7..f3f7928859e 100644
--- a/contrib/ChangeLog
+++ b/contrib/ChangeLog
@@ -1,3 +1,7 @@
+2018-06-12  Jeff Law  
+
+   * config-list.mk (LIST): Remove alpha-freebsd6.
+
 2018-05-08  Richard Biener  
 
PR bootstrap/85571
diff --git a/contrib/config-list.mk b/contrib/config-list.mk
index fee08b02a2b..d04aca237f5 100644
--- a/contrib/config-list.mk
+++ b/contrib/config-list.mk
@@ -31,7 +31,7 @@ GCC_SRC_DIR=../../gcc
 
 # v850e1-elf is rejected by config.sub
 LIST = aarch64-elf aarch64-linux-gnu aarch64-rtems \
-  alpha-linux-gnu alpha-freebsd6 alpha-netbsd alpha-openbsd \
+  alpha-linux-gnu alpha-netbsd alpha-openbsd \
   alpha64-dec-vms alpha-dec-vms \
   arc-elf32OPT-with-cpu=arc600 arc-elf32OPT-with-cpu=arc700 \
   arc-linux-uclibcOPT-with-cpu=arc700 arceb-linux-uclibcOPT-with-cpu=arc700 \
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 1bba11ccd67..20d862c91f4 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2018-06-12  Jeff Law  
+
+   * config.gcc (alpha*-*-freebsd*): Remove.
+   * config/alpha/freebsd.h: Remove.
+
 2018-06-12  David Malcolm  
 
PR other/69968
diff --git a/gcc/config.gcc b/gcc/config.gcc
index 8b2fd908c38..2f17eb0d5fa 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -1026,11 +1026,6 @@ alpha*-*-linux*)
tmake_file="${tmake_file} alpha/t-linux alpha/t-alpha"
extra_options="${extra_options} alpha/elf.opt"
;;
-alpha*-*-freebsd*)
-   tm_file="elfos.h ${tm_file} ${fbsd_tm_file} alpha/elf.h alpha/freebsd.h"
-   tmake_file="${tmake_file} alpha/t-alpha"
-   extra_options="${extra_options} alpha/elf.opt"
-   ;;
 alpha*-*-netbsd*)
tm_file="elfos.h ${tm_file} ${nbsd_tm_file} alpha/elf.h alpha/netbsd.h"
tmake_file="${tmake_file} alpha/t-alpha"
diff --git a/gcc/config/alpha/freebsd.h b/gcc/config/alpha/freebsd.h
deleted file mode 100644
index 22362226627..000
--- a/gcc/config/alpha/freebsd.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/* Definitions for DEC Alpha/AXP running FreeBSD using the ELF format
-   Copyright (C) 2000-2018 Free Software Foundation, Inc.
-   Contributed by David E. O'Brien  and BSDi.
-
-This file is part of GCC.
-
-GCC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3, or (at your option)
-any later version.
-
-GCC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING3.  If not see
-.  */
-
-
-#undef  EXTRA_SPECS
-#define EXTRA_SPECS \
-  { "fbsd_dynamic_linker", FBSD_DYNAMIC_LINKER }
-
-/* Provide a CPP_SPEC appropriate for FreeBSD/alpha -- dealing with
-   the GCC option `-posix'.  */
-
-#undef  CPP_SPEC
-#define CPP_SPEC "%{posix:-D_POSIX_SOURCE}"
-
-#define LINK_SPEC "%{G*} %{relax:-relax}   \
-  %{p:%nconsider using '-pg' instead of '-p' with gprof(1)}\
-  %{assert*} %{R*} %{rpath*} %{defsym*}
\
-  %{shared:-Bshareable %{h*} %{soname*}}   \
-  %{!shared:   \
-%{!static: \
-  %{rdynamic:-export-dynamic}  \
-  -dynamic-linker %(fbsd_dynamic_linker) } \
-%{static:-Bstatic}}
\
-  %{symbolic:-Bsymbolic}"
-
-
-/[  Target stuff  ]***/
-
-/* Define the actual types of some ANSI-mandated types.  
-   Needs to agree with .  GCC defaults come from c-decl.c,
-   c-common.c, and config//.h.  */
-
-/* alpha.h gets this wrong for FreeBSD.  We use the GCC defaults instead.  */
-#undef WCHAR_TYPE
-
-#undef  WCHAR_TYPE_SIZE
-#define WCHAR_TYPE_SIZE32
-
-#define TARGET_ELF 1
-
-#undef HAS_INIT_SECTION
-

Re: [RFC][PATCH] Stabilize a few qsort comparison functions

2018-06-12 Thread Jeff Law
On 02/07/2018 09:58 AM, Franz Sirl wrote:
> Hi,
> 
> this is the result of an attempt to minimize the differences between the
> compile results of a Linux-based and a Cygwin64-based powerpc-eabi cross
> toolchain.
> The method used was:
> 
>     - find the -fverbose-asm assembler files that differ
>     - compile that file again on both platforms with
>    -O2 -g3 -fdump-tree-all-all -fdump-rtl-all -fdump-noaddr
>     - look for the first dump file with differences and check that pass
>   for qsort's
>     - stabilize the compare functions
> 
> With some help on IRC to better understand the passes and some serious
> debugging of GCC I came up with this patch. On the tested codebase the
> differences in the assembler sources are now down to 0.
> If the various pass maintainers have better ideas on how to stabilize
> the compare functions, I'll be happy to verify them on the codebase.
> For the SRA patch I already have an alternate version with an additional
> ID member.
> 
> Comments?
> 
> Bootstrapped on linux-x86_64, no testsuite regressions.
> 
> Franz Sirl
> 
> 
> 2018-02-07  Franz Sirl 
> 
>     * ira-build.c (object_range_compare_func): Stabilize sort.
>     * tree-sra.c (compare_access_positions): Likewise.
>     * varasm.c (output_object_block_compare): Likewise.
>     * tree-ssa-loop-ivopts.c (group_compare_offset): Likewise.
>     (struct iv_common_cand): New member.
>     (record_common_cand): Initialize new member.
>     (common_cand_cmp): Use new member to stabilize sort.
>     * tree-vrp.c (struct assert_locus): New member.
>     (register_new_assert_for): Initialize new member.
>     (compare_assert_loc): Use new member to stabilize sort.
This looks pretty reasonable.   I don't think you've contributed much
recently, do you still have write access to the repository?

jeff


Re: [PATCH] gracefully deal with invalid strlen declarations (PR 86114)

2018-06-12 Thread Jeff Law
On 06/12/2018 03:29 PM, Martin Sebor wrote:
> Declaring strlen() to return a pointer instead of size_t
> and then calling the function can result in an ICE due to
> both gimple-fold and tree-ssa-strlen assuming the function
> necessarily returns an integer.
> 
> As luck would have it, the incompatible declaration isn't
> detected by -Wbuiltin-declaration-mismatch (bug 86125), nor
> apparently even by gimple_builtin_call_types_compatible_p(),
> and so the invalid declaration makes its way where it isn't
> expected.
> 
> The attached patch avoids the ICE by removing the unsafe
> assumption from both the folder and the strlen pass.
> 
> Martin
> 
> gcc-86114.diff
> 
> 
> PR tree-optimization/86114 - ICE in gimple_fold_builtin_strlen with an 
> invalid call to strnlen
> 
> gcc/testsuite/ChangeLog:
> 
>   PR tree-optimization/86114
>   * gcc.dg/pr86114.c: New test.
> 
> gcc/ChangeLog:
> 
>   PR tree-optimization/86114
>   * gimple-fold.c (gimple_fold_builtin_strlen): Only handle LHS
>   of integer types.
>   * tree-ssa-strlen.c (maybe_set_strlen_range): Same.
OK.  However ISTM that catching this earlier would be advisable.

jeff


Re: [RFC PATCH 1/6] vxworks: add target/h/wrn/coreip to the set of system include paths

2018-06-12 Thread Olivier Hainque



> On 12 Jun 2018, at 23:12, Jeff Law  wrote:
> 
> I'm going to defer to Olivier on all 6 parts of this kit.  He knows
> vxworks far better than I.

No pb. I haven't forgotten about this :)

As I mentioned on another
thread,  exceptions on VxWorks is an intricate nest of
multiple parameters when you consider the possible variations
of kinds of modules you can make (RTP, DKMs, SKMs) combined
with different lines of VxWorks versions (6.7 introduced support
for dwarf eh for example), combined with the various context
in which a toolchain may be used (straight from a command line
or driven by the WindRiver IDEs).

This include path part alone looks sensible. I'd still like to
evaluate how it fares in a environment where many of there variations
are exercised, and I'm not quite done with this yet.

Olivier




PING^2: [PATCH v2] C/C++: Add -Waddress-of-packed-member

2018-06-12 Thread H.J. Lu
On Tue, May 29, 2018 at 5:15 AM, H.J. Lu  wrote:
> On Fri, May 18, 2018 at 4:36 AM, H.J. Lu  wrote:
>> On Thu, May 17, 2018 at 10:32:56AM -0700, H.J. Lu wrote:
>>> On Mon, May 14, 2018 at 8:00 PM, Martin Sebor  wrote:
>>> > On 05/14/2018 01:10 PM, H.J. Lu wrote:
>>> >>
>>> >> On Mon, May 14, 2018 at 10:40 AM, H.J. Lu  wrote:
>>> >>
>>> >> $ cat c.i
>>> >> struct B { int i; };
>>> >> struct C { struct B b; } __attribute__ ((packed));
>>> >>
>>> >> long* g8 (struct C *p) { return p; }
>>> >> $ gcc -O2 -S c.i -Wno-incompatible-pointer-types
>>> >> c.i: In function ‘g8’:
>>> >> c.i:4:33: warning: taking value of packed 'struct C *' may result in
>>> >> an
>>> >> unaligned pointer value [-Waddress-of-packed-member]
>>> 
>>> 
>>>   ^
>>>  That should read "taking address" (not value) but...
>>> >>>
>>> >>>
>>> >>> The value of 'struct C *' is an address. There is no address taken here.
>>> >>>
>>>  ...to help explain the problem I would suggest to mention the expected
>>>  and actual alignment in the warning message.  E.g.,
>>> 
>>>    storing the address of a packed 'struct C' in 'struct C *' increases
>>>  the
>>>  alignment of the pointer from 1 to 4.
>>> >>>
>>> >>>
>>> >>> I will take a look.
>>> >>>
>>>  (IIUC, the source type and destination type need not be the same so
>>>  including both should be helpful in those cases.)
>>> 
>>>  Adding a note pointing to the declaration of either the struct or
>>>  the member would help users find it if it's a header far removed
>>>  from the point of use.
>>> >>>
>>> >>>
>>> >>> I will see what I can do.
>>> >>
>>> >>
>>> >> How about this
>>> >>
>>> >> [hjl@gnu-skx-1 pr51628]$ cat n9.i
>>> >> struct B { int i; };
>>> >> struct C { struct B b; } __attribute__ ((packed));
>>> >>
>>> >> long* g8 (struct C *p) { return p; }
>>> >> [hjl@gnu-skx-1 pr51628]$
>>> >> /export/build/gnu/gcc-test/build-x86_64-linux/gcc/xgcc
>>> >> -B/export/build/gnu/gcc-test/build-x86_64-linux/gcc/ -O2 -S n9.i
>>> >> n9.i: In function ‘g8’:
>>> >> n9.i:4:33: warning: returning ‘struct C *’ from a function with
>>> >> incompatible return type ‘long int *’ [-Wincompatible-pointer-types]
>>> >>  long* g8 (struct C *p) { return p; }
>>> >>  ^
>>> >> n9.i:4:33: warning: taking value of packed ‘struct C *’ increases the
>>> >> alignment of the pointer from 1 to 8 [-Waddress-of-packed-member]
>>> >> n9.i:2:8: note: defined here
>>> >>  struct C { struct B b; } __attribute__ ((packed));
>>> >
>>> >
>>> > Mentioning the alignments looks good.
>>> >
>>> > I still find the "taking value" phrasing odd.  I think we would
>>> > describe what's going on as "converting a pointer to a packed C
>>> > to a pointer to C (with an alignment of 8)" so I'd suggest to
>>> > use the term converting instead.
>>>
>>> How about this?
>>>
>>> [hjl@gnu-skx-1 pr51628]$ cat n12.i
>>> struct B { int i; };
>>> struct C { struct B b; } __attribute__ ((packed));
>>>
>>> struct B* g8 (struct C *p) { return p; }
>>> [hjl@gnu-skx-1 pr51628]$ make n12.s
>>> /export/build/gnu/gcc-test/build-x86_64-linux/gcc/xgcc
>>> -B/export/build/gnu/gcc-test/build-x86_64-linux/gcc/ -O2 -S n12.i
>>> n12.i: In function ‘g8’:
>>> n12.i:4:37: warning: returning ‘struct C *’ from a function with
>>> incompatible return type ‘struct B *’ [-Wincompatible-pointer-types]
>>>  struct B* g8 (struct C *p) { return p; }
>>>  ^
>>> n12.i:4:37: warning: converting a pointer to packed ‘struct C *’
>>> increases the alignment of the pointer to ‘struct B *’ from 1 to 4
>>> [-Waddress-of-packed-member]
>>> n12.i:2:8: note: defined here
>>>  struct C { struct B b; } __attribute__ ((packed));
>>> ^
>>> n12.i:1:8: note: defined here
>>>  struct B { int i; };
>>> ^
>>> [hjl@gnu-skx-1 pr51628]$
>>>
>>> > I also think mentioning both the source and the destination types
>>> > is useful irrespective of -Wincompatible-pointer-types because
>>> > the latter is often suppressed using a cast, as in:
>>> >
>>> >   struct __attribute__ ((packed)) A { int i; };
>>> >   struct B {
>>> > struct A a;
>>> >   } b;
>>> >
>>> >   long *p = (long*)   // -Waddress-of-packed-member
>>> >   int *q = (int*)   // missing warning
>>> >
>>> > If the types above were obfuscated by macros, typedefs, or in
>>> > C++ template parameters, it could be difficult to figure out
>>> > what the type of the member is because neither it nor the name
>>> > of the member appears in the message.
>>>
>>> How about this
>>>
>>> [hjl@gnu-skx-1 pr51628]$ cat n13.i
>>> struct __attribute__ ((packed)) A { int i; };
>>> struct B {
>>>   struct A a;
>>> } b;
>>>
>>> long *p = (long*)
>>> int *q = (int*)
>>> [hjl@gnu-skx-1 pr51628]$ make n13.s
>>> /export/build/gnu/gcc-test/build-x86_64-linux/gcc/xgcc
>>> -B/export/build/gnu/gcc-test/build-x86_64-linux/gcc/ -O2 -S n13.i
>>> n13.i:6:18: 

[PATCH] gracefully deal with invalid strlen declarations (PR 86114)

2018-06-12 Thread Martin Sebor

Declaring strlen() to return a pointer instead of size_t
and then calling the function can result in an ICE due to
both gimple-fold and tree-ssa-strlen assuming the function
necessarily returns an integer.

As luck would have it, the incompatible declaration isn't
detected by -Wbuiltin-declaration-mismatch (bug 86125), nor
apparently even by gimple_builtin_call_types_compatible_p(),
and so the invalid declaration makes its way where it isn't
expected.

The attached patch avoids the ICE by removing the unsafe
assumption from both the folder and the strlen pass.

Martin
PR tree-optimization/86114 - ICE in gimple_fold_builtin_strlen with an invalid call to strnlen

gcc/testsuite/ChangeLog:

	PR tree-optimization/86114
	* gcc.dg/pr86114.c: New test.

gcc/ChangeLog:

	PR tree-optimization/86114
	* gimple-fold.c (gimple_fold_builtin_strlen): Only handle LHS
	of integer types.
	* tree-ssa-strlen.c (maybe_set_strlen_range): Same.

Index: gcc/gimple-fold.c
===
--- gcc/gimple-fold.c	(revision 261516)
+++ gcc/gimple-fold.c	(working copy)
@@ -3538,9 +3538,10 @@ gimple_fold_builtin_strlen (gimple_stmt_iterator *
   return true;
 }
 
-  tree lhs = gimple_call_lhs (stmt);
-  if (lhs && TREE_CODE (lhs) == SSA_NAME)
-set_range_info (lhs, VR_RANGE, minlen, maxlen);
+  if (tree lhs = gimple_call_lhs (stmt))
+if (TREE_CODE (lhs) == SSA_NAME
+	&& INTEGRAL_TYPE_P (TREE_TYPE (lhs)))
+  set_range_info (lhs, VR_RANGE, minlen, maxlen);
 
   return false;
 }
Index: gcc/tree-ssa-strlen.c
===
--- gcc/tree-ssa-strlen.c	(revision 261518)
+++ gcc/tree-ssa-strlen.c	(working copy)
@@ -1124,14 +1124,15 @@ adjust_last_stmt (strinfo *si, gimple *stmt, bool
   update_stmt (last.stmt);
 }
 
-/* For an LHS that is an SSA_NAME and for strlen() argument SRC, set
-   LHS range info to [0, N] if SRC refers to a character array A[N]
-   with unknown length bounded by N.  */
+/* For an LHS that is an SSA_NAME with integer type and for strlen()
+   argument SRC, set LHS range info to [0, N] if SRC refers to
+   a character array A[N] with unknown length bounded by N.  */
 
 static void
 maybe_set_strlen_range (tree lhs, tree src)
 {
-  if (TREE_CODE (lhs) != SSA_NAME)
+  if (TREE_CODE (lhs) != SSA_NAME
+  || !INTEGRAL_TYPE_P (TREE_TYPE (lhs)))
 return;
 
   if (TREE_CODE (src) == SSA_NAME)
Index: gcc/testsuite/gcc.dg/pr86114.c
===
--- gcc/testsuite/gcc.dg/pr86114.c	(nonexistent)
+++ gcc/testsuite/gcc.dg/pr86114.c	(working copy)
@@ -0,0 +1,42 @@
+/* PR tree-optimization/86114 - ICE in gimple_fold_builtin_strlen with
+   an invalid call to strnlen
+   { dg-do compile }
+   { dg-options "-O2" }  */
+
+typedef __SIZE_TYPE__ size_t;
+
+extern char* strcmp (const char*, const char*);
+extern char* strncmp (const char*, const char*, size_t);
+extern char* strlen (const char*);
+extern char* strnlen (const char*, size_t);
+extern char* strcspn (const char*, const char*);
+extern char* strspn (const char*, const char*);
+extern char* strxfrm (const char*, const char*, size_t);
+
+char** q;
+
+void test_array (const char *s)
+{
+  extern char a[8];
+
+  q[0] = strcmp (a, s);
+  q[1] = strncmp (a, s, 7);
+  q[2] = strlen (a);
+  q[3] = strnlen (a, 7);
+  q[4] = strcspn (a, s);
+  q[5] = strspn (a, s);
+  q[6] = strxfrm (a, s, 7);
+}
+
+void test_pointer (const char *s, const char *t)
+{
+  q[0] = strcmp (s, t);
+  q[1] = strncmp (s, t, 7);
+  q[2] = strlen (s);
+  q[3] = strnlen (s, 7);
+  q[4] = strcspn (s, t);
+  q[5] = strspn (s, t);
+  q[6] = strxfrm (s, s, 7);
+}
+
+/* { dg-prune-output "-Wbuiltin-declaration-mismatch" } */


Re: [PATCH 1/5] emit-rtl.c: more typesafety

2018-06-12 Thread Jeff Law
On 06/12/2018 03:16 PM, David Malcolm wrote:
> On Tue, 2018-06-12 at 14:50 -0600, Jeff Law wrote:
> 
> Ultimately these boil down to:
> 
> gcc_checking_assert (INSN_P (rt)
>  || NOTE_P (rt)
>  || JUMP_TABLE_DATA_P (rt)
>  || BARRIER_P (rt)
>  || LABEL_P (rt));
> 
> (with an "if (rt)" for the safe_a_a variant), and hence they're runtime
> checks (and only enabled when #if CHECKING_P).
Ack.

> 
>> Obviously your testing ought to be sufficient for the
>> former.  Mine will help with the latter since it'll build arc, bfin
>> and
>> c6x elf targets through newlib.  For sh it'll build a mixture of -elf
>> things through newlib and it'll bootstrap sh4.
> 
> Is this testing something that you've already triggered, or does it
> happen upon commit to trunk?
THe jobs poll the various relevant git servers (gcc, binutils, newlib,
glibc, linux kernel) once per day .  When a change is detected in any of
the repos a full build is started.


> 
> (The sh changes are the only aspect of this kit that I'm keen for
> review/testing of, as it needed extra casts; I *think* everywhere I
> added them are places where rtx are already being unconditionally
> treated as instruction nodes, but your eyes/testing would be helpful).
They looked reasonable to me.  Thankfully sh is one that we can actually
bootstrap GCC within a chroot using qemu, so it'll get fairly extensive
testing.   It takes ~8hrs, but that's not too bad :-)

jeff


Re: [PATCH v3] add support for --disable-gcov

2018-06-12 Thread Jeff Law
On 06/11/2018 01:25 AM, Rasmus Villemoes wrote:
> For some targets (in my case VxWorks 5.5), libgcov does not compile due
> to missing functions and macros such as getpid() and F_OK.
> 
> Incidentally, gcc/Makefile.in already contains comments such as
> 
> # Install gcov if it was compiled.
> 
> but there is no logic in place to actually allow gcov to not be
> compiled.
I think in the past folks would do things like

make LANGUAGES="c c++"

Which would skip building gcov.



> 
> So add an option for disabling build and install of libgcov and the
> related host tools.
> 
> 2018-06-10  Rasmus Villemoes  
> 
> gcc/
>   * configure.ac: Add --disable-gcov option.
>   * configure: Regenerate.
>   * Makefile.in: Honour @enable_gcov@.
>   * doc/install.texi: Document --disable-gcov.
> 
> libgcc/
>   * configure.ac: Add --disable-gcov option.
>   * configure: Regenerate.
>   * Makefile.in: Honour @enable_gcov@.
OK.  Presumably you're going through the process to get write access.
Once that's wrapped up you can install this patch.

Thanks,
jeff


Re: [PATCH 1/5] emit-rtl.c: more typesafety

2018-06-12 Thread David Malcolm
On Tue, 2018-06-12 at 14:50 -0600, Jeff Law wrote:
> On 06/12/2018 12:54 PM, David Malcolm wrote:
> > This patch converts various rtx to rtx_insn * (or rtx_code_label
> > *).
> > It also convert the various "_loc" params from int to location_t
> > 
> > gcc/ChangeLog:
> > * emit-rtl.c (next_real_insn): Strengthen param from "rtx"
> > to "rtx_insn *".
> > (add_insn_after): Likewise for first two params.
> > (add_insn_before): Likewise.
> > (remove_insn): Likewise for param.
> > (emit_pattern_before_noloc): Likewise for second and third
> > params.
> > (emit_jump_insn_before_noloc): Convert NULL_RTX to NULL.
> > (emit_call_insn_before_noloc): Likewise.
> > (emit_debug_insn_before_noloc): Strengthen "before" param from
> > "rtx"
> > to "rtx_insn *".
> > (emit_barrier_before): Likewise.
> > (emit_label_before): Strengthen "label" param from "rtx" to
> > "rtx_code_label *".  Strengthen "before" param from "rtx" to
> > "rtx_insn *".
> > (emit_insn_after_1): Strengthen "after" param from "rtx" to
> > "rtx_insn *".
> > (emit_pattern_after_noloc): Likewise.
> > (emit_insn_after_noloc): Likewise.
> > (emit_jump_insn_after_noloc): Likewise.
> > (emit_call_insn_after_noloc): Likewise.
> > (emit_debug_insn_after_noloc): Likewise.
> > (emit_barrier_after): Likewise.
> > (emit_label_after): Likewise for both params.
> > (emit_pattern_after_setloc): Likewise for "after"
> > param.  Convert
> > "loc" param from "int" to "location_t".
> > (emit_insn_after_setloc): Likewise.
> > (emit_jump_insn_after_setloc): Likewise.
> > (emit_call_insn_after_setloc): Likewise.
> > (emit_debug_insn_after_setloc): Likewise.
> > (emit_pattern_before_setloc): Likewise for "before"
> > param.  Convert
> > "loc" param from "int" to "location_t".
> > (emit_pattern_before): Convert NULL_RTX to NULL.
> > (emit_insn_before_setloc): Convert "loc" param from "int" to
> > "location_t".
> > (emit_jump_insn_before_setloc): Likewise.
> > (emit_call_insn_before_setloc): Likewise.
> > (emit_debug_insn_before_setloc): Strengthen "before" param from
> > rtx to
> > rtx_insn *.  Convert "loc" param from "int" to "location_t".
> > * rtl.h (emit_insn_before_setloc, emit_jump_insn_before_setloc,
> > emit_call_insn_before_setloc, emit_debug_insn_before_setloc):
> > Convert 3rd param from "int" to "location_t".
> > (emit_barrier_before, emit_barrier_after, next_real_insn):
> > Strengthen param from rtx to rtx_insn *.
> > (emit_label_before): Strengthen 1st param from "rtx" to
> > "rtx_code_label *".  Strengthen 2nd param from "rtx" to
> > "rtx_insn *".
> > (emit_insn_after_noloc, emit_jump_insn_after_noloc,
> > emit_call_insn_after_noloc, emit_debug_insn_after_noloc):
> > Strengthen 2nd param from "rtx" to "rtx_insn *".
> > (emit_insn_after_setloc, emit_jump_insn_after_setloc)
> > emit_call_insn_after_setloc, emit_debug_insn_after_setloc):
> > Likewise. Convert 3rd param from "int" to "location_t".
> > (emit_label_after): Strengthen 1st param from "rtx" to
> > "rtx_code_label *".
> > (next_real_insn, remove_insn): Strengthen param from "rtx" to
> > "rtx_insn *".
> > (add_insn_before, add_insn_after): Strengthen 1st and 2nd
> > params
> > from "rtx" to "rtx_insn *".
> 
> OK.  I think that covers the entire set.
> 
> I can't immediately recall if the as-a and safe-as-a are compile or
> runtime checks.  

Ultimately these boil down to:

gcc_checking_assert (INSN_P (rt)
 || NOTE_P (rt)
 || JUMP_TABLE_DATA_P (rt)
 || BARRIER_P (rt)
 || LABEL_P (rt));

(with an "if (rt)" for the safe_a_a variant), and hence they're runtime
checks (and only enabled when #if CHECKING_P).

> Obviously your testing ought to be sufficient for the
> former.  Mine will help with the latter since it'll build arc, bfin
> and
> c6x elf targets through newlib.  For sh it'll build a mixture of -elf
> things through newlib and it'll bootstrap sh4.

Is this testing something that you've already triggered, or does it
happen upon commit to trunk?

(The sh changes are the only aspect of this kit that I'm keen for
review/testing of, as it needed extra casts; I *think* everywhere I
added them are places where rtx are already being unconditionally
treated as instruction nodes, but your eyes/testing would be helpful).

Thanks
Dave


Re: [RFC PATCH 1/6] vxworks: add target/h/wrn/coreip to the set of system include paths

2018-06-12 Thread Jeff Law
On 06/04/2018 08:46 AM, Rasmus Villemoes wrote:
> In order to build crtstuff.c, I need to ensure the headers in
> target/h/wrn/coreip are also searched. Of course, that can be done
> similar to how wrn/coreip gets manually added for libgcc, e.g. by adding
> 
>   CRTSTUFF_T_CFLAGS += -I$(WIND_BASE)/target/h 
> -I$(WIND_BASE)/target/h/wrn/coreip
> 
> But without target/h/wrn/coreip in the default search path, all
> user-code that include  (crtstuff.c just being one such
> example) will have to manually add an -isystem
> flag adding the wrn/coreip directory: unistd.h include ioLib.h, which
> has
> 
> #include "net/uio.h"
> 
> and that header is found in target/h/wrn/coreip. In other words, the
> VxWorks system headers (at least for VxWorks 5.5) are written in a way
> that assumes wrn/coreip is in the search path, so I think it makes sense
> to have that by default.
> 
> It will change the search order for existing setups that pass
> -I.../target/h/wrn/coreip (without -nostdinc), since that flag will now
> be ignored. I can't know whether that will break anything, but I do
> believe it makes sense to have the defaults actually usable without
> expecting all invocations to add -I/-isystem flags.
> 
> 2018-06-04  Rasmus Villemoes  
> 
> gcc/
> 
> * config/vxworks.h: Add $(WIND_BASE)/target/h/wrn/coreip to
>   default search path.
I'm going to defer to Olivier on all 6 parts of this kit.  He knows
vxworks far better than I.

jeff


Re: [PATCH] add support for strnlen (PR 81384)

2018-06-12 Thread Jeff Law
On 06/05/2018 03:43 PM, Martin Sebor wrote:
> The attached patch adds basic support for handling strnlen
> as a built-in function.  It touches the strlen pass where
> it folds constant results of the function, and builtins.c
> to add simple support for expanding strnlen calls with known
> results.  It also changes calls.c to detect excessive bounds
> to the function and unsafe calls with arguments declared
> attribute nonstring.
> 
> A side-effect of the strlen change I should call out is that
> strlen() calls to all zero-length arrays that aren't considered
> flexible array members (i.e., internal members or non-members)
> are folded into zero.  No warning is issued for such invalid
> uses of zero-length arrays but based on the responses to my
> question Re: aliasing between internal zero-length-arrays and
> other members(*) it sounds like one would be appropriate.
> I will see about adding one in a separate patch.
> 
> Martin
> 
> [*] https://gcc.gnu.org/ml/gcc/2018-06/msg00046.html
> 
> gcc-81384.diff
> 
> 
> PR tree-optimization/81384 - built-in form of strnlen missing
> 
> gcc/ChangeLog:
> 
>   PR tree-optimization/81384
>   * builtin-types.def (BT_FN_SIZE_CONST_STRING_SIZE): New.
>   * builtins.c (expand_builtin_strnlen): New function.
>   (expand_builtin): Call it.
>   (fold_builtin_n): Avoid setting TREE_NO_WARNING.
>   * builtins.def (BUILT_IN_STRNLEN): New.
>   * calls.c (maybe_warn_nonstring_arg): Handle BUILT_IN_STRNLEN.
>   Warn for bounds in excess of maximum object size.
>   * tree-ssa-strlen.c (maybe_set_strlen_range): Return tree representing
>   single-value ranges.  Handle strnlen.
>   (handle_builtin_strlen): Handle strnlen.
>   (strlen_check_and_optimize_stmt): Same.
> 
> gcc/testsuite/ChangeLog:
> 
>   PR tree-optimization/81384
>   * gcc.c-torture/execute/builtins/lib/strnlen.c: New test.
>   * gcc.c-torture/execute/builtins/strnlen-lib.c: New test.
>   * gcc.c-torture/execute/builtins/strnlen.c: New test.
>   * gcc.dg/attr-nonstring-2.c: New test.
>   * gcc.dg/attr-nonstring-3.c: New test.
>   * gcc.dg/attr-nonstring-4.c: New test.
>   * gcc.dg/strlenopt-44.c: New test.
>   * gcc.dg/strlenopt.h (strnlen):  Declare.
> 
> diff --git a/gcc/builtin-types.def b/gcc/builtin-types.def
> index 5365bef..1f15350 100644
> --- a/gcc/builtin-types.def
> +++ b/gcc/builtin-types.def
> @@ -322,6 +322,8 @@ DEF_FUNCTION_TYPE_2 (BT_FN_STRING_CONST_STRING_INT,
>BT_STRING, BT_CONST_STRING, BT_INT)
>  DEF_FUNCTION_TYPE_2 (BT_FN_STRING_CONST_STRING_SIZE,
>BT_STRING, BT_CONST_STRING, BT_SIZE)
> +DEF_FUNCTION_TYPE_2 (BT_FN_SIZE_CONST_STRING_SIZE,
> +  BT_SIZE, BT_CONST_STRING, BT_SIZE)
>  DEF_FUNCTION_TYPE_2 (BT_FN_INT_CONST_STRING_FILEPTR,
>BT_INT, BT_CONST_STRING, BT_FILEPTR)
>  DEF_FUNCTION_TYPE_2 (BT_FN_INT_INT_FILEPTR,
I believe Jakub already suggested these change and you ack'd that.

You have some hunks which will need updating now that the CHKP/MPX bits
are gone.

So OK after the cleanups noted above and a fresh bootstrap & regression
test cycle.

jeff


Re: [PATCH 1/5] emit-rtl.c: more typesafety

2018-06-12 Thread Jeff Law
On 06/12/2018 12:54 PM, David Malcolm wrote:
> This patch converts various rtx to rtx_insn * (or rtx_code_label *).
> It also convert the various "_loc" params from int to location_t
> 
> gcc/ChangeLog:
>   * emit-rtl.c (next_real_insn): Strengthen param from "rtx"
>   to "rtx_insn *".
>   (add_insn_after): Likewise for first two params.
>   (add_insn_before): Likewise.
>   (remove_insn): Likewise for param.
>   (emit_pattern_before_noloc): Likewise for second and third params.
>   (emit_jump_insn_before_noloc): Convert NULL_RTX to NULL.
>   (emit_call_insn_before_noloc): Likewise.
>   (emit_debug_insn_before_noloc): Strengthen "before" param from "rtx"
>   to "rtx_insn *".
>   (emit_barrier_before): Likewise.
>   (emit_label_before): Strengthen "label" param from "rtx" to
>   "rtx_code_label *".  Strengthen "before" param from "rtx" to
>   "rtx_insn *".
>   (emit_insn_after_1): Strengthen "after" param from "rtx" to
>   "rtx_insn *".
>   (emit_pattern_after_noloc): Likewise.
>   (emit_insn_after_noloc): Likewise.
>   (emit_jump_insn_after_noloc): Likewise.
>   (emit_call_insn_after_noloc): Likewise.
>   (emit_debug_insn_after_noloc): Likewise.
>   (emit_barrier_after): Likewise.
>   (emit_label_after): Likewise for both params.
>   (emit_pattern_after_setloc): Likewise for "after" param.  Convert
>   "loc" param from "int" to "location_t".
>   (emit_insn_after_setloc): Likewise.
>   (emit_jump_insn_after_setloc): Likewise.
>   (emit_call_insn_after_setloc): Likewise.
>   (emit_debug_insn_after_setloc): Likewise.
>   (emit_pattern_before_setloc): Likewise for "before" param.  Convert
>   "loc" param from "int" to "location_t".
>   (emit_pattern_before): Convert NULL_RTX to NULL.
>   (emit_insn_before_setloc): Convert "loc" param from "int" to
>   "location_t".
>   (emit_jump_insn_before_setloc): Likewise.
>   (emit_call_insn_before_setloc): Likewise.
>   (emit_debug_insn_before_setloc): Strengthen "before" param from rtx to
>   rtx_insn *.  Convert "loc" param from "int" to "location_t".
>   * rtl.h (emit_insn_before_setloc, emit_jump_insn_before_setloc,
>   emit_call_insn_before_setloc, emit_debug_insn_before_setloc):
>   Convert 3rd param from "int" to "location_t".
>   (emit_barrier_before, emit_barrier_after, next_real_insn):
>   Strengthen param from rtx to rtx_insn *.
>   (emit_label_before): Strengthen 1st param from "rtx" to
>   "rtx_code_label *".  Strengthen 2nd param from "rtx" to
>   "rtx_insn *".
>   (emit_insn_after_noloc, emit_jump_insn_after_noloc,
>   emit_call_insn_after_noloc, emit_debug_insn_after_noloc):
>   Strengthen 2nd param from "rtx" to "rtx_insn *".
>   (emit_insn_after_setloc, emit_jump_insn_after_setloc)
>   emit_call_insn_after_setloc, emit_debug_insn_after_setloc):
>   Likewise. Convert 3rd param from "int" to "location_t".
>   (emit_label_after): Strengthen 1st param from "rtx" to
>   "rtx_code_label *".
>   (next_real_insn, remove_insn): Strengthen param from "rtx" to
>   "rtx_insn *".
>   (add_insn_before, add_insn_after): Strengthen 1st and 2nd params
>   from "rtx" to "rtx_insn *".
OK.  I think that covers the entire set.

I can't immediately recall if the as-a and safe-as-a are compile or
runtime checks.  Obviously your testing ought to be sufficient for the
former.  Mine will help with the latter since it'll build arc, bfin and
c6x elf targets through newlib.  For sh it'll build a mixture of -elf
things through newlib and it'll bootstrap sh4.

jeff


Re: [PATCH 5/5] sh: update for emit-rtl.h changes

2018-06-12 Thread Jeff Law
On 06/12/2018 12:54 PM, David Malcolm wrote:
> gcc/ChangeLog:
>   * config/sh/sh-protos.h (get_dest_uid): Strengthen 1st param from
>   rtx to rtx_insn *.
>   * config/sh/sh.c (dump_table): Strengthen local "lab" from rtx to
>   rtx_code_label *, adding safe_as_a  casts to
>   the loops over LABEL_REFS.
>   (fixup_addr_diff_vecs): Add as_a  to usage of
>   braf_label.
>   (barrier_align): Convert usage of JUMP_LABEL to JUMP_LABEL_AS_INSN.
>   (get_dest_uid): Strengthen param "label" from rtx to rtx_insn *.
>   (split_branches): Strengthen local "olabel" from rtx to
>   rtx_insn *, adding a safe_as_a cast.
> ---
>  gcc/config/sh/sh-protos.h |  2 +-
>  gcc/config/sh/sh.c| 30 ++
>  2 files changed, 19 insertions(+), 13 deletions(-)
>
OK when prereqs are approved.

jeff


Re: [PATCH 4/5] c6x: update for emit-rtl.h changes

2018-06-12 Thread Jeff Law
On 06/12/2018 12:54 PM, David Malcolm wrote:
> gcc/ChangeLog:
>   * config/c6x/c6x.c (reorg_split_calls): Strengthen param "call_labels"
>   from rtx_insn ** to rtx_code_label **.
>   (reorg_emit_nops): Likewise.
>   (c6x_reorg): Likewise for local "call_labels".
OK when prereqs are approved.
jeff


Re: [PATCH 3/5] bfin: update for emit-rtl.h changes

2018-06-12 Thread Jeff Law
On 06/12/2018 12:54 PM, David Malcolm wrote:
> gcc/ChangeLog:
>   * config/bfin/bfin.c (hwloop_optimize): Strengthen local "label"
>   from rtx to rtx_insn *.
>   (add_sched_insns_for_speculation): Likewise local for "target",
>   converting usage of JUMP_LABEL to JUMP_LABEL_AS_INSN.
OK when prereqs are approved.

jeff


Re: [PATCH 2/5] arc: update for emit-rtl.h change

2018-06-12 Thread Jeff Law
On 06/12/2018 12:54 PM, David Malcolm wrote:
> gcc/ChangeLog:
>   * config/arc/arc.c (hwloop_optimize): Strengthen local "end_label"
>   from rtx to rtx_insn *.
OK when prereqs are approved.
jeff


Re: [PATCH 2/4] Switch other switch expansion methods into classes.

2018-06-12 Thread Jeff Law
On 06/05/2018 01:15 AM, marxin wrote:
> gcc/ChangeLog:
> 
> 2018-06-07  Martin Liska  
> 
>   * tree-switch-conversion.c (switch_conversion::collect):
> Record m_uniq property.
>   (switch_conversion::expand): Bail out for special conditions.
>   (group_cluster::~group_cluster): New.
>   (group_cluster::group_cluster): Likewise.
>   (group_cluster::dump): Likewise.
>   (jump_table_cluster::emit): New.
>   (switch_decision_tree::fix_phi_operands_for_edges): New.
>   (struct case_node): Remove struct.
>   (jump_table_cluster::can_be_handled): New.
>   (case_values_threshold): Moved to header.
>   (reset_out_edges_aux): Likewise.
>   (jump_table_cluster::is_beneficial): New.
>   (bit_test_cluster::can_be_handled): Likewise.
>   (add_case_node): Remove.
>   (bit_test_cluster::is_beneficial): New.
>   (case_bit_test::cmp): New.
>   (bit_test_cluster::emit): New.
>   (expand_switch_as_decision_tree_p): Remove.
>   (bit_test_cluster::hoist_edge_and_branch_if_true): New.
>   (fix_phi_operands_for_edge): Likewise.
>   (switch_decision_tree::analyze_switch_statement): New.
>   (compute_cases_per_edge): Move ...
>   (switch_decision_tree::compute_cases_per_edge): ... here.
>   (try_switch_expansion): Likewise.
>   (switch_decision_tree::try_switch_expansion): Likewise.
>   (record_phi_operand_mapping): Likewise.
>   (switch_decision_tree::record_phi_operand_mapping): Likewise.
>   (emit_case_decision_tree): Likewise.
>   (switch_decision_tree::emit): Likewise.
>   (balance_case_nodes): Likewise.
>   (switch_decision_tree::balance_case_nodes): Likewise.
>   (dump_case_nodes): Likewise.
>   (switch_decision_tree::dump_case_nodes): Likewise.
>   (emit_jump): Likewise.
>   (switch_decision_tree::emit_jump): Likewise.
>   (emit_cmp_and_jump_insns): Likewise.
>   (switch_decision_tree::emit_cmp_and_jump_insns): Likewise.
>   (emit_case_nodes): Likewise.
>   (switch_decision_tree::emit_case_nodes): Likewise.
>   (conditional_probability): Remove.
>   * tree-switch-conversion.h (enum cluster_type): New.
>   (PRINT_CASE): New.
>   (struct cluster): Likewise.
>   (cluster::cluster): Likewise.
>   (struct simple_cluster): Likewise.
>   (simple_cluster::simple_cluster): Likewise.
>   (struct group_cluster): Likewise.
>   (struct jump_table_cluster): Likewise.
>   (struct bit_test_cluster): Likewise.
>   (struct min_cluster_item): Likewise.
>   (struct case_tree_node): Likewise.
>   (case_tree_node::case_tree_node): Likewise.
>   (jump_table_cluster::case_values_threshold): Likewise.
>   (struct case_bit_test): Likewise.
>   (struct switch_decision_tree): Likewise.
>   (struct switch_conversion): Likewise.
>   (switch_decision_tree::reset_out_edges_aux): Likewise.
> 
> gcc/testsuite/ChangeLog:
> 
> 2018-06-07  Martin Liska  
> 
>   * gcc.dg/tree-ssa/vrp104.c: Grep just for GIMPLE IL.
So like the previous patch, we need to make sure functions have their
function comments.


> ---
>  gcc/testsuite/gcc.dg/tree-ssa/vrp104.c |2 +-
>  gcc/tree-switch-conversion.c   | 1343 ++--
>  gcc/tree-switch-conversion.h   |  545 ++
>  3 files changed, 1325 insertions(+), 565 deletions(-)
> 
> 
> 0002-Switch-other-switch-expansion-methods-into-classes.patch
> 
> 
> + The definition of "much bigger" depends on whether we are
> + optimizing for size or for speed.  If the former, the maximum
> + ratio range/count = 3, because this was found to be the optimal
> + ratio for size on i686-pc-linux-gnu, see PR11823.  The ratio
> + 10 is much older, and was probably selected after an extensive
> + benchmarking investigation on numerous platforms.  Or maybe it
> + just made sense to someone at some point in the history of GCC,
> + who knows...  */
"much older" is an understatement.  I believe the magic "10" pre-dates
my involvement in GCC.  You can find evidence of it as far back as
gcc-0.9.  I doubt it was extensively benchmarked, and even if it was,
the targets on which it was benchmarked don't reflect modern target
reality in terms of importance.

In general this patch is much harder to de-cipher as there's little
relation between chunks of code in the unidiff.  Given your long history
with GCC, I'm going to extend a lot of leeway that you got all this
stuff right as you moved code around.  However, in the future for this
kind of change we should seriously look at a different way to break down
a patch into meaningful chunks.

So, OK with adding the missing function comments.   I think that covers
the entire set.

Thanks,
Jeff


Re: [PATCH 3/4] Enable clustering for switch statements.

2018-06-12 Thread Jeff Law
On 06/05/2018 05:59 AM, marxin wrote:
> gcc/ChangeLog:
> 
> 2018-06-07  Martin Liska  
> 
>   * tree-switch-conversion.c (jump_table_cluster::find_jump_tables):
> New.
>   (bit_test_cluster::find_bit_tests): Likewise.
>   (switch_decision_tree::analyze_switch_statement): Find clusters.
>   * tree-switch-conversion.h (struct jump_table_cluster): Document
> hierarchy.
Needs function comments for the new member functions.  OK with those
added once the full set is approved.

Jeff


Re: Improve std::rotate usages

2018-06-12 Thread François Dumont

I'm struggling having a validation for this patch.

As it is a trivial one and to not bother you I plan to commit it 
tomorrow if not told otherwise.


François



On 08/06/2018 07:54, François Dumont wrote:

Gentle reminder.

On 27/05/2018 19:25, François Dumont wrote:

Still no chance to review it ?

I'd like this one to go in before submitting other algo related patches.

    * include/bits/stl_algo.h
    (__rotate(_Ite, _Ite, _Ite, forward_iterator_tag))
    (__rotate(_Ite, _Ite, _Ite, bidirectional_iterator_tag))
    (__rotate(_Ite, _Ite, _Ite, random_access_iterator_tag)): Move 
code duplication...

    (rotate(_Ite, _Ite, _Ite)): ...here.
    (__stable_partition_adaptive(_FIt, _FIt, _Pred, _Dist, _Pointer, 
_Dist)):

    Simplify rotate call.
    (__rotate_adaptive(_BIt1, _BIt1, _BIt1, _Dist, _Dist, _Bit2, 
_Dist)):

    Likewise.
    (__merge_without_buffer(_BIt, _BIt, _BIt, _Dist, _Dist, _Comp)):
    Likewise.

François

On 14/05/2018 22:14, François Dumont wrote:

Any feedback regarding this patch ?


On 02/05/2018 07:26, François Dumont wrote:

Hi

    std::rotate already returns the expected iterator so there is 
no need for calls to std::advance/std::distance.


Tested under Linux x86_64, ok to commit ?

François











Re: [PATCH 4/4] Change default for jump_table expansion ratio to 8.

2018-06-12 Thread Jeff Law
On 06/07/2018 03:04 AM, marxin wrote:
> 
> gcc/ChangeLog:
> 
> 2018-06-07  Martin Liska  
> 
>   * tree-switch-conversion.c (jump_table_cluster::can_be_handled):
> Change default ratio from 10 to 8.
> ---
>  gcc/tree-switch-conversion.c | 10 ++
>  1 file changed, 2 insertions(+), 8 deletions(-)
> 
This is fine once the other patches in the series are approved.

jeff


[PATCH, rs6000] clean up vec_neg related test options

2018-06-12 Thread Will Schmidt
Hi,
  A few of our vec_neg related tests are failing in some environments.
Clean up the options and requires stanzas to avoid running the tests where
the vec_neg() intrinsic does not work.

OK for trunk?
Thanks
-Will

[testsuite]

2018-06-12  Will Schmidt  

* gcc.target/powerpc/fold-vec-neg-int.p8.c: Specify powerpc_p8vector_ok
requirement for this test.
* gcc.target/powerpc/fold-vec-neg-int.c: Specify powerpc_p8vector_ok
requirement, and -mpower8-vector compile option.

diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-neg-int.c 
b/gcc/testsuite/gcc.target/powerpc/fold-vec-neg-int.c
index 4f35856..4cdcc35 100644
--- a/gcc/testsuite/gcc.target/powerpc/fold-vec-neg-int.c
+++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-neg-int.c
@@ -1,11 +1,11 @@
 /* Verify that overloaded built-ins for vec_neg with int
inputs produce the right code.  */
 
 /* { dg-do compile } */
-/* { dg-require-effective-target powerpc_altivec_ok } */
-/* { dg-options "-maltivec -O2" } */
+/* { dg-require-effective-target powerpc_p8vector_ok } */
+/* { dg-options "-mpower8-vector -maltivec -O2" } */
 
 #include 
 
 vector signed int
 test1 (vector signed int x)
diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-neg-int.p8.c 
b/gcc/testsuite/gcc.target/powerpc/fold-vec-neg-int.p8.c
index 91067ab..07a41e4 100644
--- a/gcc/testsuite/gcc.target/powerpc/fold-vec-neg-int.p8.c
+++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-neg-int.p8.c
@@ -1,10 +1,10 @@
 /* Verify that overloaded built-ins for vec_neg with int
inputs produce the right code when -mcpu=power8 is specified.  */
 
 /* { dg-do compile } */
-/* { dg-require-effective-target powerpc_altivec_ok } */
+/* { dg-require-effective-target powerpc_p8vector_ok } */
 /* { dg-options "-maltivec -O2 -mcpu=power8" } */
 /* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { 
"-mcpu=power8" } } */
 
 #include 
 




Re: [PATCH, rs6000 8/9] [v3] Enable gimple folding for vec_xl, vec_xst

2018-06-12 Thread Will Schmidt
Hi,
  version 3.

Gimple folding for unaligned vector loads and stores.
  
[v2] Added the type for the MEM_REF, per feedback.
Testcases for gimple-folding of the same are currently in-tree
as powerpc/fold-vec-load-*.c and powerpc/fold-vec-store-*.c.

[v3] Updated the alignment for the MEM_REF to be 4bytes.
Updated/added/removed comments in the code for clarity.

I want to do one more spin with the latest, just to be sure.
OK for trunk, assuming good test results?


Thanks
-Will

[gcc]

2018-06-12 Will Schmidt 

* config/rs6000/rs6000.c (rs6000_builtin_valid_without_lhs): Add
vec_xst variants to the list.
(rs6000_gimple_fold_builtin): Add support for folding unaligned
vector loads and stores.

diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 8bc4109..774c60a 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -15401,10 +15401,16 @@ rs6000_builtin_valid_without_lhs (enum 
rs6000_builtins fn_code)
 case ALTIVEC_BUILTIN_STVX_V8HI:
 case ALTIVEC_BUILTIN_STVX_V4SI:
 case ALTIVEC_BUILTIN_STVX_V4SF:
 case ALTIVEC_BUILTIN_STVX_V2DI:
 case ALTIVEC_BUILTIN_STVX_V2DF:
+case VSX_BUILTIN_STXVW4X_V16QI:
+case VSX_BUILTIN_STXVW4X_V8HI:
+case VSX_BUILTIN_STXVW4X_V4SF:
+case VSX_BUILTIN_STXVW4X_V4SI:
+case VSX_BUILTIN_STXVD2X_V2DF:
+case VSX_BUILTIN_STXVD2X_V2DI:
   return true;
 default:
   return false;
 }
 }
@@ -15910,10 +15916,79 @@ rs6000_gimple_fold_builtin (gimple_stmt_iterator *gsi)
gimple_set_location (g, loc);
gsi_replace (gsi, g, true);
return true;
   }
 
+/* unaligned Vector loads.  */
+case VSX_BUILTIN_LXVW4X_V16QI:
+case VSX_BUILTIN_LXVW4X_V8HI:
+case VSX_BUILTIN_LXVW4X_V4SF:
+case VSX_BUILTIN_LXVW4X_V4SI:
+case VSX_BUILTIN_LXVD2X_V2DF:
+case VSX_BUILTIN_LXVD2X_V2DI:
+  {
+arg0 = gimple_call_arg (stmt, 0);  // offset
+arg1 = gimple_call_arg (stmt, 1);  // address
+lhs = gimple_call_lhs (stmt);
+location_t loc = gimple_location (stmt);
+/* Since arg1 may be cast to a different type, just use ptr_type_node
+   here instead of trying to enforce TBAA on pointer types.  */
+tree arg1_type = ptr_type_node;
+tree lhs_type = TREE_TYPE (lhs);
+/* in GIMPLE the type of the MEM_REF specifies the alignment.  The
+  required alignment (power) is 4 bytes regardless of data type.  */
+tree align_ltype = build_aligned_type (lhs_type, 4);
+/* POINTER_PLUS_EXPR wants the offset to be of type 'sizetype'.  Create
+   the tree using the value from arg0.  The resulting type will match
+   the type of arg1.  */
+gimple_seq stmts = NULL;
+tree temp_offset = gimple_convert (, loc, sizetype, arg0);
+tree temp_addr = gimple_build (, loc, POINTER_PLUS_EXPR,
+  arg1_type, arg1, temp_offset);
+gsi_insert_seq_before (gsi, stmts, GSI_SAME_STMT);
+/* Use the build2 helper to set up the mem_ref.  The MEM_REF could also
+   take an offset, but since we've already incorporated the offset
+   above, here we just pass in a zero.  */
+gimple *g;
+g = gimple_build_assign (lhs, build2 (MEM_REF, align_ltype, temp_addr,
+   build_int_cst (arg1_type, 0)));
+gimple_set_location (g, loc);
+gsi_replace (gsi, g, true);
+return true;
+  }
+
+/* unaligned Vector stores.  */
+case VSX_BUILTIN_STXVW4X_V16QI:
+case VSX_BUILTIN_STXVW4X_V8HI:
+case VSX_BUILTIN_STXVW4X_V4SF:
+case VSX_BUILTIN_STXVW4X_V4SI:
+case VSX_BUILTIN_STXVD2X_V2DF:
+case VSX_BUILTIN_STXVD2X_V2DI:
+  {
+arg0 = gimple_call_arg (stmt, 0); /* Value to be stored.  */
+arg1 = gimple_call_arg (stmt, 1); /* Offset.  */
+tree arg2 = gimple_call_arg (stmt, 2); /* Store-to address.  */
+location_t loc = gimple_location (stmt);
+tree arg0_type = TREE_TYPE (arg0);
+/* Use ptr_type_node (no TBAA) for the arg2_type.  */
+tree arg2_type = ptr_type_node;
+/* POINTER_PLUS_EXPR wants the offset to be of type 'sizetype'.  Create
+   the tree using the value from arg0.  The resulting type will match
+   the type of arg2.  */
+gimple_seq stmts = NULL;
+tree temp_offset = gimple_convert (, loc, sizetype, arg1);
+tree temp_addr = gimple_build (, loc, POINTER_PLUS_EXPR,
+  arg2_type, arg2, temp_offset);
+gsi_insert_seq_before (gsi, stmts, GSI_SAME_STMT);
+gimple *g;
+g = gimple_build_assign (build2 (MEM_REF, arg0_type, temp_addr,
+  build_int_cst (arg2_type, 0)), arg0);
+gimple_set_location (g, loc);
+gsi_replace (gsi, g, true);
+return true;
+  }
+
 

Re: C++ PATCH for core issue 1331 (const mismatch with defaulted copy constructor)

2018-06-12 Thread Jason Merrill
OK.

On Tue, Jun 12, 2018 at 3:02 PM, Marek Polacek  wrote:
> As [class.copy.ctor] says, the type of an implicitly declared copy constructor
> will be either
>
>   X::X(const X&)
>
> if each potentially constructed subobject of a class type M (or array thereof)
> has a copy constructor whose first parameter is of type const M& or const
> volatile M&.  Otherwise, the implicitly-declared copy constructor will
> have the form
>
>   X::X(X&)
>
> Similarly for implicitly-declared copy assignment operator: it will be either
>
>   X& operator=(const X&)
>
> or
>
>   X& operator=(X&)
>
> Previously, the declared type of an explicitly defaulted function had to be 
> the
> same as if it had been implicitly declared, otherwise the code was ill-formed.
> But Core Issue 1331 [1] changes this in such a way that it be defined as 
> deleted
> instead, with two exceptions for an assignment operator with a mismatched 
> return
> type, and an assignment operator with a parameter type that's not a reference.
>
> The change itself seems trivial (unless I'm missing something), so most of my
> effort went into writing testcases for various scenarios I could think of.
> We already give errors for cases that are still considered ill-formed.
>
> [1] http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0641r2.html
>
> Bootstrapped/regtested on x86_64-linux, ok for trunk?
>
> 2018-06-12  Marek Polacek  
>
> Core issue 1331 - const mismatch with defaulted copy constructor
> * class.c (check_bases_and_members): When checking a defaulted
> function, mark it as deleted rather than giving an error.
>
> * g++.dg/cpp0x/defaulted15.C (struct F): Remove dg-error.
> * g++.dg/cpp0x/defaulted52.C: New test.
> * g++.dg/cpp0x/defaulted53.C: New test.
> * g++.dg/cpp0x/defaulted54.C: New test.
> * g++.dg/cpp0x/defaulted55.C: New test.
> * g++.dg/cpp0x/defaulted56.C: New test.
> * g++.dg/cpp0x/defaulted57.C: New test.
> * g++.dg/cpp0x/defaulted58.C: New test.
> * g++.dg/cpp0x/defaulted59.C: New test.
> * g++.dg/cpp0x/defaulted60.C: New test.
>
> diff --git gcc/cp/class.c gcc/cp/class.c
> index fbf39035e18..b6e78c6377d 100644
> --- gcc/cp/class.c
> +++ gcc/cp/class.c
> @@ -5660,9 +5660,9 @@ check_bases_and_members (tree t)
>
> if (fn_const_p && !imp_const_p)
>   /* If the function is defaulted outside the class, we just
> -give the synthesis error.  */
> - error ("%q+D declared to take const reference, but implicit "
> -"declaration would take non-const", fn);
> +give the synthesis error.  Core Issue #1331 says this is
> +no longer ill-formed, it is defined as deleted instead.  */
> + DECL_DELETED_FN (fn) = true;
>   }
> defaulted_late_check (fn);
>}
> diff --git gcc/testsuite/g++.dg/cpp0x/defaulted15.C 
> gcc/testsuite/g++.dg/cpp0x/defaulted15.C
> index fabcc23a150..1e0b3545840 100644
> --- gcc/testsuite/g++.dg/cpp0x/defaulted15.C
> +++ gcc/testsuite/g++.dg/cpp0x/defaulted15.C
> @@ -48,8 +48,7 @@ struct F
>
>  struct G: public F
>  {
> -  // Can't be const because F copy ctor isn't.
> -  G(const G&) = default;   // { dg-error "const" }
> +  G(const G&) = default;
>  };
>
>  struct H
> diff --git gcc/testsuite/g++.dg/cpp0x/defaulted52.C 
> gcc/testsuite/g++.dg/cpp0x/defaulted52.C
> index e69de29bb2d..c617230b493 100644
> --- gcc/testsuite/g++.dg/cpp0x/defaulted52.C
> +++ gcc/testsuite/g++.dg/cpp0x/defaulted52.C
> @@ -0,0 +1,20 @@
> +// Core Issue #1331 (const mismatch with defaulted copy constructor)
> +// { dg-do compile { target c++11 } }
> +
> +struct M
> +{
> +  M();
> +  // So that W wouldn't have had "const W&" copy ctor if it were
> +  // implicitly declared.
> +  M(M&);
> +};
> +
> +template struct W
> +{
> +  W();
> +  // This should now compile and be =deleted.
> +  W(const W&) = default;
> +  T t;
> +};
> +
> +W w;
> diff --git gcc/testsuite/g++.dg/cpp0x/defaulted53.C 
> gcc/testsuite/g++.dg/cpp0x/defaulted53.C
> index e69de29bb2d..8147e7e2ad1 100644
> --- gcc/testsuite/g++.dg/cpp0x/defaulted53.C
> +++ gcc/testsuite/g++.dg/cpp0x/defaulted53.C
> @@ -0,0 +1,35 @@
> +// Core Issue #1331 (const mismatch with defaulted copy constructor)
> +// { dg-do compile { target c++11 } }
> +
> +struct M
> +{
> +  M& operator=(M&);
> +};
> +
> +struct R
> +{
> +  R& operator=(R&) = default;
> +  M m;
> +};
> +
> +struct S
> +{
> +  S& operator=(const S&) = default;
> +  M m;
> +};
> +
> +struct T
> +{
> +  // If F is an assignment operator, and the return type of T1
> +  // differs from the return type of T2 the program is ill-formed.
> +  T operator=(T&) = default; // { dg-error "defaulted" }
> +  M m;
> +};
> +
> +struct U
> +{
> +  // If F is an assignment operator, and T1's parameter type is
> +  // not a reference, the program is ill-formed.
> +  U& operator=(U) = default; // { dg-error "defaulted" }
> + 

Re: [PATCH 6/6] [ARC] Reimplement return padding operation for ARC700.

2018-06-12 Thread Andrew Burgess
* Claudiu Zissulescu  [2018-05-21 13:18:39 +0300]:

> From: Claudiu Zissulescu 
> 
> For ARC700, adding padding if necessary to avoid a mispredict.  A
> return could happen immediately after the function start.  A
> call/return and return/return must be 6 bytes apart to avoid
> mispredict.
> 
> The old implementation was doing this operation very late in the
> compilation process, and the additional nop instructions and/or
> forcing some other instruction to take their long form was not taken
> into account when generating brcc instructions. Thus, wrong code could
> be generated.
> 
> Ok to apply?

This looks fine with a couple of small adjustments, inline below...

> Claudiu
> 
> gcc/
> 2017-03-24  Claudiu Zissulescu  
> 
>   * config/arc/arc-protos.h (arc_pad_return): Remove.
>   * config/arc/arc.c (machine_function): Remove force_short_suffix
>   and size_reason.
>   (arc_print_operand): Adjust printing of '&'.
>   (arc_verify_short): Remove conditional printing of short suffix.
>   (arc_final_prescan_insn): Remove reference to size_reason.
>   (pad_return): New function.
>   (arc_reorg): Call pad_return.
>   (arc_pad_return): Remove.
>   (arc_init_machine_status): Remove reference to force_short_suffix.
>   * config/arc/arc.md (vunspec): Add VUNSPEC_ARC_BLOCKAGE.
>   (attr length): When attribute iscompact is true force to 2
>   regardless; in the case of maybe check if we want to force the
>   instruction to have 4 bytes length.
>   (nopv): Change it to generate 4 byte long nop as well.
>   (blockage): New pattern.
>   (simple_return): Remove call to arc_pad_return.
>   (p_return_i): Likewise.
> 
> gcc/testsuite/
> 2017-03-24  Claudiu Zissulescu  
> 
>   * gcc.target/arc/pr9001107555.c: New file.
> ---
>  gcc/config/arc/arc-protos.h |   1 -
>  gcc/config/arc/arc.c| 156 
> +---
>  gcc/config/arc/arc.md   |  26 +++--
>  gcc/testsuite/gcc.target/arc/pr9001107555.c |  38 +++
>  4 files changed, 128 insertions(+), 93 deletions(-)
>  create mode 100644 gcc/testsuite/gcc.target/arc/pr9001107555.c
> 
> diff --git a/gcc/config/arc/arc-protos.h b/gcc/config/arc/arc-protos.h
> index 67f3b4e3226..ce4b6f84749 100644
> --- a/gcc/config/arc/arc-protos.h
> +++ b/gcc/config/arc/arc-protos.h
> @@ -89,7 +89,6 @@ extern void arc_clear_unalign (void);
>  extern void arc_toggle_unalign (void);
>  extern void split_addsi (rtx *);
>  extern void split_subsi (rtx *);
> -extern void arc_pad_return (void);
>  extern void arc_split_move (rtx *);
>  extern const char *arc_short_long (rtx_insn *insn, const char *, const char 
> *);
>  extern rtx arc_regno_use_in (unsigned int, rtx);
> diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c
> index b1a09d82b72..22f1442a027 100644
> --- a/gcc/config/arc/arc.c
> +++ b/gcc/config/arc/arc.c
> @@ -2648,8 +2648,6 @@ typedef struct GTY (()) machine_function
>struct arc_frame_info frame_info;
>/* To keep track of unalignment caused by short insns.  */
>int unalign;
> -  int force_short_suffix; /* Used when disgorging return delay slot insns.  
> */
> -  const char *size_reason;
>struct arc_ccfsm ccfsm_current;
>/* Map from uid to ccfsm state during branch shortening.  */
>rtx ccfsm_current_insn;
> @@ -4307,7 +4305,7 @@ arc_print_operand (FILE *file, rtx x, int code)
>   }
>break;
>  case '&':
> -  if (TARGET_ANNOTATE_ALIGN && cfun->machine->size_reason)
> +  if (TARGET_ANNOTATE_ALIGN)
>   fprintf (file, "; unalign: %d", cfun->machine->unalign);
>return;
>  case '+':
> @@ -4980,7 +4978,6 @@ static int
>  arc_verify_short (rtx_insn *insn, int, int check_attr)
>  {
>enum attr_iscompact iscompact;
> -  struct machine_function *machine;
>  
>if (check_attr > 0)
>  {
> @@ -4988,10 +4985,6 @@ arc_verify_short (rtx_insn *insn, int, int check_attr)
>if (iscompact == ISCOMPACT_FALSE)
>   return 0;
>  }
> -  machine = cfun->machine;
> -
> -  if (machine->force_short_suffix >= 0)
> -return machine->force_short_suffix;
>  
>return (get_attr_length (insn) & 2) != 0;
>  }
> @@ -5030,8 +5023,6 @@ arc_final_prescan_insn (rtx_insn *insn, rtx *opvec 
> ATTRIBUTE_UNUSED,
>cfun->machine->prescan_initialized = 1;
>  }
>arc_ccfsm_advance (insn, _ccfsm_current);
> -
> -  cfun->machine->size_reason = 0;
>  }
>  
>  /* Given FROM and TO register numbers, say whether this elimination is 
> allowed.
> @@ -7673,6 +7664,76 @@ jli_call_scan (void)
>  }
>  }
>  
> +/* Add padding if necessary to avoid a mispredict.  A return could
> +   happen immediately after the function start.  A call/return and
> +   return/return must be 6 bytes apart to avoid mispredict.  */
> +
> +static void
> +pad_return (void)
> +{
> +  rtx_insn *insn;
> +  long offset;
> +
> +  if (!TARGET_PAD_RETURN)
> +return;
> +
> +  for (insn = get_insns (); insn; insn 

Re: [PATCH, rs6000 8/9] [v2] Enable gimple folding for vec_xl, vec_xst

2018-06-12 Thread Will Schmidt
On Tue, 2018-06-12 at 13:17 -0500, Bill Schmidt wrote:
> On 6/12/18 11:56 AM, Will Schmidt wrote:
> > Hi,
> > Gimple folding for unaligned vector loads and stores.
> > Regtest completed across variety of systems, P6,P7,P8,P9.
> > 
> > [v2] Added the type for the MEM_REF, per feedback.
> > Testcases for gimple-folding of the same are currently in-tree
> > as powerpc/fold-vec-load-*.c and powerpc/fold-vec-store-*.c.
> > Re-tested, still looks good. :-)
> > 
> > Thanks
> > -Will
> > 
> > [gcc]
> > 
> > 2018-06-12 Will Schmidt 
> > 
> > * config/rs6000/rs6000.c (rs6000_builtin_valid_without_lhs): Add
> > vec_xst variants to the list.
> > (rs6000_gimple_fold_builtin): Add support for folding unaligned
> > vector loads and stores.
> >
> > diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
> > index d62abdf..374666c 100644
> > --- a/gcc/config/rs6000/rs6000.c
> > +++ b/gcc/config/rs6000/rs6000.c
> > @@ -15360,10 +15360,16 @@ rs6000_builtin_valid_without_lhs (enum 
> > rs6000_builtins fn_code)
> >  case ALTIVEC_BUILTIN_STVX_V8HI:
> >  case ALTIVEC_BUILTIN_STVX_V4SI:
> >  case ALTIVEC_BUILTIN_STVX_V4SF:
> >  case ALTIVEC_BUILTIN_STVX_V2DI:
> >  case ALTIVEC_BUILTIN_STVX_V2DF:
> > +case VSX_BUILTIN_STXVW4X_V16QI:
> > +case VSX_BUILTIN_STXVW4X_V8HI:
> > +case VSX_BUILTIN_STXVW4X_V4SF:
> > +case VSX_BUILTIN_STXVW4X_V4SI:
> > +case VSX_BUILTIN_STXVD2X_V2DF:
> > +case VSX_BUILTIN_STXVD2X_V2DI:
> >return true;
> >  default:
> >return false;
> >  }
> >  }
> > @@ -15869,10 +15875,78 @@ rs6000_gimple_fold_builtin (gimple_stmt_iterator 
> > *gsi)
> > gimple_set_location (g, loc);
> > gsi_replace (gsi, g, true);
> > return true;
> >}
> >
> > +/* unaligned Vector loads.  */
> > +case VSX_BUILTIN_LXVW4X_V16QI:
> > +case VSX_BUILTIN_LXVW4X_V8HI:
> > +case VSX_BUILTIN_LXVW4X_V4SF:
> > +case VSX_BUILTIN_LXVW4X_V4SI:
> > +case VSX_BUILTIN_LXVD2X_V2DF:
> > +case VSX_BUILTIN_LXVD2X_V2DI:
> > +  {
> > +arg0 = gimple_call_arg (stmt, 0);  // offset
> > +arg1 = gimple_call_arg (stmt, 1);  // address
> > +lhs = gimple_call_lhs (stmt);
> > +location_t loc = gimple_location (stmt);
> > +/* Since arg1 may be cast to a different type, just use ptr_type_node
> > +   here instead of trying to enforce TBAA on pointer types.  */
> > +tree arg1_type = ptr_type_node;
> > +tree lhs_type = TREE_TYPE (lhs);
> > +/* POINTER_PLUS_EXPR wants the offset to be of type 'sizetype'.  Create
> > +   the tree using the value from arg0.  The resulting type will match
> > +   the type of arg1.  */
> > +gimple_seq stmts = NULL;
> > +tree temp_offset = gimple_convert (, loc, sizetype, arg0);
> > +tree temp_addr = gimple_build (, loc, POINTER_PLUS_EXPR,
> > +  arg1_type, arg1, temp_offset);
> > +gsi_insert_seq_before (gsi, stmts, GSI_SAME_STMT);
> > +/* Use the build2 helper to set up the mem_ref.  The MEM_REF could also
> > +   take an offset, but since we've already incorporated the offset
> > +   above, here we just pass in a zero.  */
> > +gimple *g;
> > +tree align_ltype = build_aligned_type (lhs_type, TYPE_ALIGN 
> > ((lhs_type)));
> 
> This alignment is too strong (assuming lhs is a vector type).  lxvd2x and 
> lxvw4x only
> require word alignment, so
> 
>   tree align_ltype = build_aligned_type (lhs_type, 4);
> 
> seems like what you need.  See my earlier discussion with Richard.  Sorry I 
> didn't
> notice this before!
Ok.  Yeah, I had seen the conversation, but hadn't accurately connected
the dots. :-)   Thanks,.


> 
> > +g = gimple_build_assign (lhs, build2 (MEM_REF, align_ltype, temp_addr,
> > +   build_int_cst (arg1_type, 0)));
> > +gimple_set_location (g, loc);
> > +gsi_replace (gsi, g, true);
> > +return true;
> > +  }
> > +
> > +/* unaligned Vector stores.  */
> > +case VSX_BUILTIN_STXVW4X_V16QI:
> > +case VSX_BUILTIN_STXVW4X_V8HI:
> > +case VSX_BUILTIN_STXVW4X_V4SF:
> > +case VSX_BUILTIN_STXVW4X_V4SI:
> > +case VSX_BUILTIN_STXVD2X_V2DF:
> > +case VSX_BUILTIN_STXVD2X_V2DI:
> > +  {
> > +arg0 = gimple_call_arg (stmt, 0); /* Value to be stored.  */
> > +arg1 = gimple_call_arg (stmt, 1); /* Offset.  */
> > +tree arg2 = gimple_call_arg (stmt, 2); /* Store-to address.  */
> > +location_t loc = gimple_location (stmt);
> > +tree arg0_type = TREE_TYPE (arg0);
> > +/* Use ptr_type_node (no TBAA) for the arg2_type.  */
> > +tree arg2_type = ptr_type_node;
> > +/* POINTER_PLUS_EXPR wants the offset to be of type 'sizetype'.  Create
> > +   the tree using the value from arg0.  The resulting type will match
> > +   the type of arg2.  */
> > +gimple_seq stmts = NULL;
> > +tree temp_offset = gimple_convert (, loc, sizetype, arg1);
> > +

Re: [PATCH 5/6] [ARC] Update fma expansions.

2018-06-12 Thread Andrew Burgess
* Claudiu Zissulescu  [2018-05-21 13:18:38 +0300]:

> Make sure only one operand has an immediate.
> 
> OK to apply?

Looks good.

Thanks,
Andrew

> Claudiu
> 
> gcc/
> 2018-03-21  Claudiu Zissulescu  
> 
>   * config/arc/fpu.md (fmasf4): Force operand to register.
>   (fnmasf4): Likewise.
> 
> gcc/testsuite
> 2018-03-21  Claudiu Zissulescu  
> 
>   * gcc.target/arc/fma-1.c: New test.
> ---
>  gcc/config/arc/fpu.md|  6 ++
>  gcc/testsuite/gcc.target/arc/fma-1.c | 13 +
>  2 files changed, 19 insertions(+)
>  create mode 100644 gcc/testsuite/gcc.target/arc/fma-1.c
> 
> diff --git a/gcc/config/arc/fpu.md b/gcc/config/arc/fpu.md
> index de876cac0c1..9457922667e 100644
> --- a/gcc/config/arc/fpu.md
> +++ b/gcc/config/arc/fpu.md
> @@ -64,6 +64,9 @@
> tmp = gen_rtx_REG (SFmode, ACCL_REGNO);
> emit_move_insn (tmp, operands[3]);
> operands[3] = tmp;
> +   if (!register_operand (operands[1], SFmode)
> +&& !register_operand (operands[2], SFmode))
> + operands[2] = force_reg (SFmode, operands[2]);
> }")
>  
>  (define_expand "fnmasf4"
> @@ -77,6 +80,9 @@
> tmp = gen_rtx_REG (SFmode, ACCL_REGNO);
> emit_move_insn (tmp, operands[3]);
> operands[3] = tmp;
> +   if (!register_operand (operands[1], SFmode)
> +&& !register_operand (operands[2], SFmode))
> + operands[2] = force_reg (SFmode, operands[2]);
>  }")
>  
>  (define_insn "fmasf4_fpu"
> diff --git a/gcc/testsuite/gcc.target/arc/fma-1.c 
> b/gcc/testsuite/gcc.target/arc/fma-1.c
> new file mode 100644
> index 000..c195ad98127
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/arc/fma-1.c
> @@ -0,0 +1,13 @@
> +/* { dg-do compile } */
> +/* { dg-skip-if "FPU not available" { arc700 || arc6xx } } */
> +/* { dg-options "-s -std=gnu11  -O2 -frounding-math -mfpu=fpus_all" } */
> +
> +const float a, b = 7.8539818525e01;
> +
> +/* Check if the fma operation is generated correctly.  */
> +
> +int foo (void)
> +{
> +  return (float)3.0 * b + a;
> +}
> +/* { dg-final { scan-assembler "fsmadd" } } */
> -- 
> 2.14.3
> 


Re: [PATCH 1/4] Transform switch_conversion into a class.

2018-06-12 Thread Jeff Law
On 06/04/2018 07:32 AM, marxin wrote:
> gcc/ChangeLog:
> 
> 2018-06-07  Martin Liska  
> 
>   * tree-switch-conversion.c (MAX_CASE_BIT_TESTS): Remove.
>   (hoist_edge_and_branch_if_true): Likewise.
>   (expand_switch_using_bit_tests_p): Likewise.
>   (struct case_bit_test): Likewise.
>   (case_bit_test_cmp): Likewise.
>   (emit_case_bit_tests): Likewise.
>   (switch_conversion::switch_conversion): New class.
>   (struct switch_conv_info): Remove old struct.
>   (collect_switch_conv_info): More to ...
>   (switch_conversion::collect): ... this.
>   (check_range): Likewise.
>   (switch_conversion::check_range): Likewise.
>   (check_all_empty_except_final): Likewise.
>   (switch_conversion::check_all_empty_except_final): Likewise.
>   (check_final_bb): Likewise.
>   (switch_conversion::check_final_bb): Likewise.
>   (create_temp_arrays): Likewise.
>   (switch_conversion::create_temp_arrays): Likewise.
>   (free_temp_arrays): Likewise.
>   (gather_default_values): Likewise.
>   (switch_conversion::gather_default_values): Likewise.
>   (build_constructors): Likewise.
>   (switch_conversion::build_constructors): Likewise.
>   (constructor_contains_same_values_p): Likewise.
>   (switch_conversion::contains_same_values_p): Likewise.
>   (array_value_type): Likewise.
>   (switch_conversion::array_value_type): Likewise.
>   (build_one_array): Likewise.
>   (switch_conversion::build_one_array): Likewise.
>   (build_arrays): Likewise.
>   (switch_conversion::build_arrays): Likewise.
>   (gen_def_assigns): Likewise.
>   (switch_conversion::gen_def_assigns): Likewise.
>   (prune_bbs): Likewise.
>   (switch_conversion::prune_bbs): Likewise.
>   (fix_phi_nodes): Likewise.
>   (switch_conversion::fix_phi_nodes): Likewise.
>   (gen_inbound_check): Likewise.
>   (switch_conversion::gen_inbound_check): Likewise.
>   (process_switch): Use the newly created class.
>   (switch_conversion::expand): New.
>   (switch_conversion::~switch_conversion): New.
>   * tree-switch-conversion.h: New file.
So generally this looks good.

I do note that a lot of the function comments are removed from the
implementation side and moved into the header file.

I personally prefer that approach, particularly for publicly visible
members.  However I think our coding conventions still indicate the
implementation side should have the function comment.  So let's keep
those in place, with obvious changes since many of the arguments are now
class data.

During my initial high level pass over the changes it looked like
various chunks of functionality were missing.  It turns out they were
removed in patch #1, then re-introduced in subsequent patches.   That's
fine, but it's slightly better from a review standpoint if such things
are at least called out.


> +using namespace tree_switch_conversion;
I thought our coding conventions discouraged "using namespace".  But
after reviewing, that's for header files, so I won't object to this.



This patch is fine.  However, please do not install until the full set
is approved.

Thanks,
jeff



Re: [PATCH 1/6] [ARC] Add modes scheduler HS

2018-06-12 Thread Andrew Burgess
* Claudiu Zissulescu  [2018-05-21 13:18:34 +0300]:

> From: Claudiu Zissulescu 
> 
> An update on how the instructions are scheduled for HS processor.
> 
> Ok to apply?

Looks good.

Thanks,
Andrew


> Claudiu
> 
> ---
>  gcc/config/arc/arcHS.md | 21 +++--
>  1 file changed, 15 insertions(+), 6 deletions(-)
> 
> diff --git a/gcc/config/arc/arcHS.md b/gcc/config/arc/arcHS.md
> index d49b90c4970..5c1ab5413ab 100644
> --- a/gcc/config/arc/arcHS.md
> +++ b/gcc/config/arc/arcHS.md
> @@ -35,12 +35,14 @@
> (eq_attr "type" "store"))
>"hs_issue+hs_ld_st")
>  
> -(define_insn_reservation "hs_alu0" 2
> +;; Advanced ALU
> +(define_insn_reservation "hs_alu0" 4
>(and (match_test "TARGET_HS")
> (eq_attr "tune" "none")
> (eq_attr "type" "cc_arith, two_cycle_core, shift, lr, sr"))
> -  "hs_issue+x1,x2")
> +  "hs_issue+x1,x2, nothing*2")
>  
> +;; Basic ALU
>  (define_insn_reservation "hs_alu1" 4
>(and (match_test "TARGET_HS")
> (eq_attr "tune" "none")
> @@ -54,19 +56,26 @@
> (eq_attr "type" "div_rem"))
>"hs_issue+divrem_hs, (divrem_hs)*12")
>  
> -(define_insn_reservation "hs_mul" 3
> +(define_insn_reservation "hs_mul" 4
>(and (match_test "TARGET_HS")
> (eq_attr "tune" "none")
> (eq_attr "type" "mul16_em, multi, umulti"))
>"hs_issue+mul_hs, nothing*3")
>  
> -;; BYPASS EALU ->
> +;; BYPASS Advanced ALU ->
>  (define_bypass 1 "hs_alu0" "hs_divrem")
>  (define_bypass 1 "hs_alu0" "hs_mul")
> +(define_bypass 2 "hs_alu0" "hs_alu0")
> +(define_bypass 1 "hs_alu0" "hs_alu1")
> +(define_bypass 1 "hs_alu0" "hs_data_load")
> +(define_bypass 1 "hs_alu0" "hs_data_store" "store_data_bypass_p")
> +(define_bypass 2 "hs_alu0" "hs_data_store")
>  
> -;; BYPASS BALU ->
> +;; BYPASS Basic ALU ->
>  (define_bypass 1 "hs_alu1" "hs_alu1")
>  (define_bypass 1 "hs_alu1" "hs_data_store" "store_data_bypass_p")
> +(define_bypass 3 "hs_alu1" "hs_mul")
> +(define_bypass 3 "hs_alu1" "hs_divrem")
>  
>  ;; BYPASS LD ->
>  (define_bypass 1 "hs_data_load" "hs_alu1")
> @@ -76,7 +85,7 @@
>  (define_bypass 1 "hs_data_load" "hs_data_store" "store_data_bypass_p")
>  
>  ;; BYPASS MPY ->
> -;;(define_bypass 3 "hs_mul" "hs_mul")
> +(define_bypass 3 "hs_mul" "hs_mul")
>  (define_bypass 1 "hs_mul" "hs_alu1")
>  (define_bypass 3 "hs_mul" "hs_divrem")
>  (define_bypass 1 "hs_mul" "hs_data_store" "store_data_bypass_p")
> -- 
> 2.14.3
> 


Re: [PATCH 2/6] [ARC] Allow EX instruction for ARC700 and ARCv2.

2018-06-12 Thread Andrew Burgess
* Claudiu Zissulescu  [2018-05-21 13:18:35 +0300]:

> From: claziss 
> 
> The EX instruction is base line for both architectures. Reflect this in the 
> compiler.
> 
> OK to apply?

Looks good.

Thanks,
Andrew


> Claudiu
> 
> gcc/
> 2017-05-02  Claudiu Zissulescu  
> 
>   * config/arc/arc.c (atomic_exchangesi): EX instruction is default
>   for ARC700 and ARCv2.
> ---
>  gcc/config/arc/atomic.md | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/gcc/config/arc/atomic.md b/gcc/config/arc/atomic.md
> index 13a2e34549c..4a56ca229cc 100644
> --- a/gcc/config/arc/atomic.md
> +++ b/gcc/config/arc/atomic.md
> @@ -120,7 +120,7 @@
> (match_operand:SI 1 "mem_noofs_operand" "")
> (match_operand:SI 2 "register_operand" "")
> (match_operand:SI 3 "const_int_operand" "")]
> -  "TARGET_ATOMIC"
> +  "TARGET_ARC700 || TARGET_V2"
>  {
>enum memmodel model = (enum memmodel) INTVAL (operands[3]);
>  
> -- 
> 2.14.3
> 


Re: [PATCH 4/6] [ARC] Define LINK_GCC_C_SEQUENCE_SPEC.

2018-06-12 Thread Andrew Burgess
* Claudiu Zissulescu  [2018-05-21 13:18:37 +0300]:

> From: claziss 
> 
> If no specs file is provided, default to nosys library.
> 
> Ok to apply?

Looks good.

Thanks,
Andrew


> Claudiu
> 
> gcc/
> 2017-05-03  Claudiu Zissulescu  
> 
>   * config/arc/elf.h (LINK_GCC_C_SEQUENCE_SPEC): Define.
> ---
>  gcc/config/arc/elf.h | 5 +
>  1 file changed, 5 insertions(+)
> 
> diff --git a/gcc/config/arc/elf.h b/gcc/config/arc/elf.h
> index 43ced3b720f..66ee5b698ea 100644
> --- a/gcc/config/arc/elf.h
> +++ b/gcc/config/arc/elf.h
> @@ -73,3 +73,8 @@ along with GCC; see the file COPYING3.  If not see
>  
>  #undef TARGET_ASM_FILE_END
>  #define TARGET_ASM_FILE_END arc_file_end
> +
> +/* If no specs file is enforced, default to nosys libarary.  */
> +#undef LINK_GCC_C_SEQUENCE_SPEC
> +#define LINK_GCC_C_SEQUENCE_SPEC \
> +  "--start-group %G %{!specs=*:-lc -lnosys} --end-group"
> -- 
> 2.14.3
> 


Re: [PATCH 3/6] [ARC] SYNC instruction is valid on all ARC cores.

2018-06-12 Thread Andrew Burgess
* Claudiu Zissulescu  [2018-05-21 13:18:36 +0300]:

> From: claziss 
> 
> The sync instruction is part of all ARC architectures. Fix this in the 
> compiler.
> 
> Ok to apply?

Looks good.

Thanks,
Andrew


> Claudiu
> 
> gcc/
> 2017-05-03  Claudiu Zissulescu  
> 
>   * config/arc/builtins.def (SYNC): SYNC instruction is valid on all
>   ARC cores.
> ---
>  gcc/config/arc/builtins.def | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/gcc/config/arc/builtins.def b/gcc/config/arc/builtins.def
> index 349f39fab23..5171ab40842 100644
> --- a/gcc/config/arc/builtins.def
> +++ b/gcc/config/arc/builtins.def
> @@ -34,7 +34,7 @@
>  /* Special builtins.  */
>  DEF_BUILTIN (NOP,0, void_ftype_void,nothing, 1)
>  DEF_BUILTIN (RTIE,   0, void_ftype_void,rtie,1)
> -DEF_BUILTIN (SYNC,   0, void_ftype_void,sync,
> TARGET_ARC700)
> +DEF_BUILTIN (SYNC,   0, void_ftype_void,sync,1)
>  DEF_BUILTIN (BRK,0, void_ftype_void,brk, 1)
>  DEF_BUILTIN (SWI,0, void_ftype_void,swi, 1)
>  DEF_BUILTIN (UNIMP_S,0, void_ftype_void,unimp_s, 
> !TARGET_ARC600_FAMILY)
> -- 
> 2.14.3
> 


[PATCH] P0935R0 Eradicating unnecessarily explicit default constructors

2018-06-12 Thread Jonathan Wakely

Explicit default constructors are problematic, so this change removes
them from  and , as per P0935R0.

* include/bits/random.h (linear_congruential_engine)
(mersenne_twister_engine, subtract_with_carry_engine, random_device)
(uniform_real_distribution, normal_distribution)
(lognormal_distribution, gamma_distribution, chi_squared_distribution)
(cauchy_distribution, fisher_f_distribution, student_t_distribution)
(bernoulli_distribution, binomial_distribution,geometric_distribution)
(negative_binomial_distribution, exponential_distribution)
(weibull_distribution, extreme_value_distribution): Add non-explicit
default constructors. Remove default argument for first parameter of
explicit constructors.
(piecewise_constant_distribution, piecewise_linear_distribution):
Make default constructor non-explicit.
* include/bits/uniform_int_dist.h (uniform_int_distribution): Add
non-explicit default constructors. Remove default argument for first
parameter of explicit constructor.
(simd_fast_mersenne_twister_engine, beta_distribution)
(rice_distribution, nakagami_distribution, pareto_distribution)
(k_distribution, arcsine_distribution, hoyt_distribution)
(triangular_distribution, von_mises_distribution)
(hypergeometric_distribution, logistic_distribution)
(uniform_inside_sphere_distribution): Likewise.
(uniform_on_sphere_distribution): Make default constructor
non-explicit.
* testsuite/26_numerics/random/bernoulli_distribution/cons/default.cc:
Test for non-explicit default constructor. Fix references to standard.
* testsuite/26_numerics/random/binomial_distribution/cons/default.cc:
Likewise.
* testsuite/26_numerics/random/cauchy_distribution/cons/default.cc:
Likewise.
* testsuite/26_numerics/random/chi_squared_distribution/cons/default.cc:
Likewise.
* testsuite/26_numerics/random/discrete_distribution/cons/default.cc:
Likewise.
* testsuite/26_numerics/random/exponential_distribution/cons/default.cc:
Likewise.
* 
testsuite/26_numerics/random/extreme_value_distribution/cons/default.cc:
Likewise.
* testsuite/26_numerics/random/fisher_f_distribution/cons/default.cc:
Likewise.
* testsuite/26_numerics/random/gamma_distribution/cons/default.cc:
Likewise.
* testsuite/26_numerics/random/geometric_distribution/cons/default.cc:
Likewise.
* testsuite/26_numerics/random/lognormal_distribution/cons/default.cc:
Likewise.
* 
testsuite/26_numerics/random/negative_binomial_distribution/cons/default.cc:
Likewise.
* testsuite/26_numerics/random/normal_distribution/cons/default.cc:
Likewise.
* 
testsuite/26_numerics/random/piecewise_constant_distribution/cons/default.cc:
Likewise.
* 
testsuite/26_numerics/random/piecewise_linear_distribution/cons/default.cc:
Likewise.
* testsuite/26_numerics/random/poisson_distribution/cons/default.cc:
Likewise.
* testsuite/26_numerics/random/student_t_distribution/cons/default.cc:
Likewise.
* testsuite/26_numerics/random/uniform_int_distribution/cons/default.cc:
Likewise.
* 
testsuite/26_numerics/random/uniform_real_distribution/cons/default.cc:
Likewise.
* testsuite/26_numerics/random/weibull_distribution/cons/default.cc:
Likewise.
* testsuite/ext/random/arcsine_distribution/cons/default.cc: Likewise.
* testsuite/ext/random/beta_distribution/cons/default.cc: Likewise.
* testsuite/ext/random/hoyt_distribution/cons/default.cc: Likewise.
* testsuite/ext/random/hypergeometric_distribution/cons/default.cc:
Likewise.
* testsuite/ext/random/k_distribution/cons/default.cc: Likewise.
* testsuite/ext/random/logistic_distribution/cons/default.cc: Likewise.
* testsuite/ext/random/nakagami_distribution/cons/default.cc: Likewise.
* testsuite/ext/random/normal_mv_distribution/cons/default.cc:
Likewise.
* testsuite/ext/random/pareto_distribution/cons/default.cc: Likewise.
* testsuite/ext/random/rice_distribution/cons/default.cc: Likewise.
* testsuite/ext/random/triangular_distribution/cons/default.cc:
Likewise.
* 
testsuite/ext/random/uniform_inside_sphere_distribution/cons/default.cc:
Likewise.
* testsuite/ext/random/uniform_on_sphere_distribution/cons/default.cc:
Likewise.
* testsuite/ext/random/von_mises_distribution/cons/default.cc:
Likewise.
* testsuite/util/testsuite_common_types.h
(implicitly_default_constructible): New helper.

Tested powerpc64le-linux, committed to trunk.

commit 5725c25679751b72c4f070b6d504c0a1a8b0121c
Author: Jonathan Wakely 

C++ PATCH for core issue 1331 (const mismatch with defaulted copy constructor)

2018-06-12 Thread Marek Polacek
As [class.copy.ctor] says, the type of an implicitly declared copy constructor
will be either

  X::X(const X&)

if each potentially constructed subobject of a class type M (or array thereof)
has a copy constructor whose first parameter is of type const M& or const
volatile M&.  Otherwise, the implicitly-declared copy constructor will
have the form

  X::X(X&)

Similarly for implicitly-declared copy assignment operator: it will be either

  X& operator=(const X&)

or

  X& operator=(X&)

Previously, the declared type of an explicitly defaulted function had to be the
same as if it had been implicitly declared, otherwise the code was ill-formed.
But Core Issue 1331 [1] changes this in such a way that it be defined as deleted
instead, with two exceptions for an assignment operator with a mismatched return
type, and an assignment operator with a parameter type that's not a reference.

The change itself seems trivial (unless I'm missing something), so most of my
effort went into writing testcases for various scenarios I could think of.
We already give errors for cases that are still considered ill-formed.

[1] http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0641r2.html

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

2018-06-12  Marek Polacek  

Core issue 1331 - const mismatch with defaulted copy constructor
* class.c (check_bases_and_members): When checking a defaulted
function, mark it as deleted rather than giving an error.

* g++.dg/cpp0x/defaulted15.C (struct F): Remove dg-error.
* g++.dg/cpp0x/defaulted52.C: New test.
* g++.dg/cpp0x/defaulted53.C: New test.
* g++.dg/cpp0x/defaulted54.C: New test.
* g++.dg/cpp0x/defaulted55.C: New test.
* g++.dg/cpp0x/defaulted56.C: New test.
* g++.dg/cpp0x/defaulted57.C: New test.
* g++.dg/cpp0x/defaulted58.C: New test.
* g++.dg/cpp0x/defaulted59.C: New test.
* g++.dg/cpp0x/defaulted60.C: New test.

diff --git gcc/cp/class.c gcc/cp/class.c
index fbf39035e18..b6e78c6377d 100644
--- gcc/cp/class.c
+++ gcc/cp/class.c
@@ -5660,9 +5660,9 @@ check_bases_and_members (tree t)
 
if (fn_const_p && !imp_const_p)
  /* If the function is defaulted outside the class, we just
-give the synthesis error.  */
- error ("%q+D declared to take const reference, but implicit "
-"declaration would take non-const", fn);
+give the synthesis error.  Core Issue #1331 says this is
+no longer ill-formed, it is defined as deleted instead.  */
+ DECL_DELETED_FN (fn) = true;
  }
defaulted_late_check (fn);
   }
diff --git gcc/testsuite/g++.dg/cpp0x/defaulted15.C 
gcc/testsuite/g++.dg/cpp0x/defaulted15.C
index fabcc23a150..1e0b3545840 100644
--- gcc/testsuite/g++.dg/cpp0x/defaulted15.C
+++ gcc/testsuite/g++.dg/cpp0x/defaulted15.C
@@ -48,8 +48,7 @@ struct F
 
 struct G: public F
 {
-  // Can't be const because F copy ctor isn't.
-  G(const G&) = default;   // { dg-error "const" }
+  G(const G&) = default;
 };
 
 struct H
diff --git gcc/testsuite/g++.dg/cpp0x/defaulted52.C 
gcc/testsuite/g++.dg/cpp0x/defaulted52.C
index e69de29bb2d..c617230b493 100644
--- gcc/testsuite/g++.dg/cpp0x/defaulted52.C
+++ gcc/testsuite/g++.dg/cpp0x/defaulted52.C
@@ -0,0 +1,20 @@
+// Core Issue #1331 (const mismatch with defaulted copy constructor)
+// { dg-do compile { target c++11 } }
+
+struct M
+{
+  M();
+  // So that W wouldn't have had "const W&" copy ctor if it were
+  // implicitly declared.
+  M(M&);
+};
+
+template struct W
+{
+  W();
+  // This should now compile and be =deleted.
+  W(const W&) = default;
+  T t;
+};
+
+W w;
diff --git gcc/testsuite/g++.dg/cpp0x/defaulted53.C 
gcc/testsuite/g++.dg/cpp0x/defaulted53.C
index e69de29bb2d..8147e7e2ad1 100644
--- gcc/testsuite/g++.dg/cpp0x/defaulted53.C
+++ gcc/testsuite/g++.dg/cpp0x/defaulted53.C
@@ -0,0 +1,35 @@
+// Core Issue #1331 (const mismatch with defaulted copy constructor)
+// { dg-do compile { target c++11 } }
+
+struct M
+{
+  M& operator=(M&);
+};
+
+struct R
+{
+  R& operator=(R&) = default;
+  M m;
+};
+
+struct S
+{
+  S& operator=(const S&) = default;
+  M m;
+};
+
+struct T
+{
+  // If F is an assignment operator, and the return type of T1
+  // differs from the return type of T2 the program is ill-formed.
+  T operator=(T&) = default; // { dg-error "defaulted" }
+  M m;
+};
+
+struct U
+{
+  // If F is an assignment operator, and T1's parameter type is
+  // not a reference, the program is ill-formed.
+  U& operator=(U) = default; // { dg-error "defaulted" }
+  M m;
+};
diff --git gcc/testsuite/g++.dg/cpp0x/defaulted54.C 
gcc/testsuite/g++.dg/cpp0x/defaulted54.C
index e69de29bb2d..f8ddc4e47ce 100644
--- gcc/testsuite/g++.dg/cpp0x/defaulted54.C
+++ gcc/testsuite/g++.dg/cpp0x/defaulted54.C
@@ -0,0 +1,18 @@
+// Core Issue #1331 (const mismatch with defaulted copy constructor)
+// { dg-do compile { 

Re: [C++ Patch] Fix coerce_new_type and coerce_delete_type locations

2018-06-12 Thread Jason Merrill
OK.

On Tue, Jun 12, 2018 at 4:07 AM, Paolo Carlini  wrote:
> Hi,
>
> yesterday I didn't notice that grok_op_properties calls a couple of helpers
> which are affected by exactly the same location issues. The below simply
> forwards the location to the helpers. Tested x86_64-linux.
>
> Thanks, Paolo.
>
> 
>


Re: [PATCH, rs6000 8/9] [v2] Enable gimple folding for vec_xl, vec_xst

2018-06-12 Thread Bill Schmidt
On 6/12/18 11:56 AM, Will Schmidt wrote:
> Hi,
> Gimple folding for unaligned vector loads and stores.
> Regtest completed across variety of systems, P6,P7,P8,P9.
> 
> [v2] Added the type for the MEM_REF, per feedback.
> Testcases for gimple-folding of the same are currently in-tree
> as powerpc/fold-vec-load-*.c and powerpc/fold-vec-store-*.c.
> Re-tested, still looks good. :-)
> 
> Thanks
> -Will
> 
> [gcc]
> 
> 2018-06-12 Will Schmidt 
> 
>   * config/rs6000/rs6000.c (rs6000_builtin_valid_without_lhs): Add
>   vec_xst variants to the list.
>   (rs6000_gimple_fold_builtin): Add support for folding unaligned
>   vector loads and stores.
>
> diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
> index d62abdf..374666c 100644
> --- a/gcc/config/rs6000/rs6000.c
> +++ b/gcc/config/rs6000/rs6000.c
> @@ -15360,10 +15360,16 @@ rs6000_builtin_valid_without_lhs (enum 
> rs6000_builtins fn_code)
>  case ALTIVEC_BUILTIN_STVX_V8HI:
>  case ALTIVEC_BUILTIN_STVX_V4SI:
>  case ALTIVEC_BUILTIN_STVX_V4SF:
>  case ALTIVEC_BUILTIN_STVX_V2DI:
>  case ALTIVEC_BUILTIN_STVX_V2DF:
> +case VSX_BUILTIN_STXVW4X_V16QI:
> +case VSX_BUILTIN_STXVW4X_V8HI:
> +case VSX_BUILTIN_STXVW4X_V4SF:
> +case VSX_BUILTIN_STXVW4X_V4SI:
> +case VSX_BUILTIN_STXVD2X_V2DF:
> +case VSX_BUILTIN_STXVD2X_V2DI:
>return true;
>  default:
>return false;
>  }
>  }
> @@ -15869,10 +15875,78 @@ rs6000_gimple_fold_builtin (gimple_stmt_iterator 
> *gsi)
>   gimple_set_location (g, loc);
>   gsi_replace (gsi, g, true);
>   return true;
>}
>
> +/* unaligned Vector loads.  */
> +case VSX_BUILTIN_LXVW4X_V16QI:
> +case VSX_BUILTIN_LXVW4X_V8HI:
> +case VSX_BUILTIN_LXVW4X_V4SF:
> +case VSX_BUILTIN_LXVW4X_V4SI:
> +case VSX_BUILTIN_LXVD2X_V2DF:
> +case VSX_BUILTIN_LXVD2X_V2DI:
> +  {
> +  arg0 = gimple_call_arg (stmt, 0);  // offset
> +  arg1 = gimple_call_arg (stmt, 1);  // address
> +  lhs = gimple_call_lhs (stmt);
> +  location_t loc = gimple_location (stmt);
> +  /* Since arg1 may be cast to a different type, just use ptr_type_node
> + here instead of trying to enforce TBAA on pointer types.  */
> +  tree arg1_type = ptr_type_node;
> +  tree lhs_type = TREE_TYPE (lhs);
> +  /* POINTER_PLUS_EXPR wants the offset to be of type 'sizetype'.  Create
> + the tree using the value from arg0.  The resulting type will match
> + the type of arg1.  */
> +  gimple_seq stmts = NULL;
> +  tree temp_offset = gimple_convert (, loc, sizetype, arg0);
> +  tree temp_addr = gimple_build (, loc, POINTER_PLUS_EXPR,
> +arg1_type, arg1, temp_offset);
> +  gsi_insert_seq_before (gsi, stmts, GSI_SAME_STMT);
> +  /* Use the build2 helper to set up the mem_ref.  The MEM_REF could also
> + take an offset, but since we've already incorporated the offset
> + above, here we just pass in a zero.  */
> +  gimple *g;
> +  tree align_ltype = build_aligned_type (lhs_type, TYPE_ALIGN 
> ((lhs_type)));

This alignment is too strong (assuming lhs is a vector type).  lxvd2x and 
lxvw4x only
require word alignment, so

tree align_ltype = build_aligned_type (lhs_type, 4);

seems like what you need.  See my earlier discussion with Richard.  Sorry I 
didn't
notice this before!

> +  g = gimple_build_assign (lhs, build2 (MEM_REF, align_ltype, temp_addr,
> + build_int_cst (arg1_type, 0)));
> +  gimple_set_location (g, loc);
> +  gsi_replace (gsi, g, true);
> +  return true;
> +  }
> +
> +/* unaligned Vector stores.  */
> +case VSX_BUILTIN_STXVW4X_V16QI:
> +case VSX_BUILTIN_STXVW4X_V8HI:
> +case VSX_BUILTIN_STXVW4X_V4SF:
> +case VSX_BUILTIN_STXVW4X_V4SI:
> +case VSX_BUILTIN_STXVD2X_V2DF:
> +case VSX_BUILTIN_STXVD2X_V2DI:
> +  {
> +  arg0 = gimple_call_arg (stmt, 0); /* Value to be stored.  */
> +  arg1 = gimple_call_arg (stmt, 1); /* Offset.  */
> +  tree arg2 = gimple_call_arg (stmt, 2); /* Store-to address.  */
> +  location_t loc = gimple_location (stmt);
> +  tree arg0_type = TREE_TYPE (arg0);
> +  /* Use ptr_type_node (no TBAA) for the arg2_type.  */
> +  tree arg2_type = ptr_type_node;
> +  /* POINTER_PLUS_EXPR wants the offset to be of type 'sizetype'.  Create
> + the tree using the value from arg0.  The resulting type will match
> + the type of arg2.  */
> +  gimple_seq stmts = NULL;
> +  tree temp_offset = gimple_convert (, loc, sizetype, arg1);
> +  tree temp_addr = gimple_build (, loc, POINTER_PLUS_EXPR,
> +arg2_type, arg2, temp_offset);
> +  /* Mask off any lower bits from the address.  */

Spurious comment?  You're not doing that, nor do you want to...

Thanks,
Bill

> +  gsi_insert_seq_before (gsi, 

Re: [PATCH] restore -Wstringop-overflow for checked strcpy/strcat (PR 85259)

2018-06-12 Thread Martin Sebor

On 06/11/2018 03:25 PM, Jeff Law wrote:

On 05/14/2018 04:41 PM, Martin Sebor wrote:

r256683 committed to GCC 8 to avoiding duplicate instances of
-Wstringop-overflow warnings on some targets has the unintended
side-effect of suppressing even singleton instances of the warning
in cases such as 'strcat (strcpy (buf, "hello "), "world!")' when
_FORTIFY_SOURCE is defined.

The attached patch restores the warning for the trunk.

Since this is a regression in a security feature and the warning
isn't prone to false positives (I don't think I've seen any when
_FORTIFY_SOURCE is defined), I'd also like the fix considered for
the 8 branch.

Thanks
Martin

gcc-85259.diff


PR tree-optimization/85259 - Missing -Wstringop-overflow= since r256683

gcc/ChangeLog:

PR tree-optimization/85259
* builtins.c (compute_objsize): Handle constant offsets.
* gimple-ssa-warn-restrict.c (maybe_diag_offset_bounds): Return
true iff a warning has been issued.
* gimple.h (gimple_nonartificial_location): New function.
* tree-ssa-strlen.c (maybe_diag_stxncpy_trunc): Call
gimple_nonartificial_location and handle -Wno-system-headers.
(handle_builtin_stxncpy): Same.

gcc/testsuite/ChangeLog:

PR tree-optimization/85259
* gcc.dg/Wstringop-overflow-5.c: New test.
* gcc.dg/Wstringop-overflow-6.c: New test.

OK for the trunk.


On retesting the patch I noticed a failure in one of the test
cases it adds.  It turns out that a recent change made to improve
code generation (r261061) has resulted in transforming one of
the strcat calls in the test into a MEM_REF, which defeats
the -Wstringop-overflow checker (the checker only looks at
built-ins, not MEM_REF expressions).  It feels like one step
forward and one step back with these MEM_REFs.  I've xfailed
the test case until the -Wstringop-overflow checker is made
smarter and opened bug 86121 to track this regression.

(Though, IMO, GCC should check calls to make sure they're
valid before transforming them into MEM_REFs and only do
the transformation if it is within the bounds of the objects .)



The general guidance we've received is to not try and fix these on the
release branches.  However, I think this one deserves an exception to
the general guidance.  So OK for the gcc-8 branch.


Okay.  (GCC 8 is not affected by the above.)

Martin


[PATCH 5/5] sh: update for emit-rtl.h changes

2018-06-12 Thread David Malcolm
gcc/ChangeLog:
* config/sh/sh-protos.h (get_dest_uid): Strengthen 1st param from
rtx to rtx_insn *.
* config/sh/sh.c (dump_table): Strengthen local "lab" from rtx to
rtx_code_label *, adding safe_as_a  casts to
the loops over LABEL_REFS.
(fixup_addr_diff_vecs): Add as_a  to usage of
braf_label.
(barrier_align): Convert usage of JUMP_LABEL to JUMP_LABEL_AS_INSN.
(get_dest_uid): Strengthen param "label" from rtx to rtx_insn *.
(split_branches): Strengthen local "olabel" from rtx to
rtx_insn *, adding a safe_as_a cast.
---
 gcc/config/sh/sh-protos.h |  2 +-
 gcc/config/sh/sh.c| 30 ++
 2 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/gcc/config/sh/sh-protos.h b/gcc/config/sh/sh-protos.h
index 23405b4..66ee315 100644
--- a/gcc/config/sh/sh-protos.h
+++ b/gcc/config/sh/sh-protos.h
@@ -88,7 +88,7 @@ extern int shl_sext_length (rtx);
 extern bool gen_shl_sext (rtx, rtx, rtx, rtx);
 extern int regs_used (rtx, int);
 extern void fixup_addr_diff_vecs (rtx_insn *);
-extern int get_dest_uid (rtx, int);
+extern int get_dest_uid (rtx_insn *, int);
 extern void final_prescan_insn (rtx_insn *, rtx *, int);
 extern enum tls_model tls_symbolic_operand (rtx, machine_mode);
 extern bool system_reg_operand (rtx, machine_mode);
diff --git a/gcc/config/sh/sh.c b/gcc/config/sh/sh.c
index ced6640..5f6fbb3 100644
--- a/gcc/config/sh/sh.c
+++ b/gcc/config/sh/sh.c
@@ -4583,7 +4583,7 @@ dump_table (rtx_insn *start, rtx_insn *barrier)
 {
   rtx_insn *scan = barrier;
   bool need_align = true;
-  rtx lab;
+  rtx_code_label *lab;
   label_ref_list_t ref;
   bool have_df = false;
 
@@ -4600,7 +4600,8 @@ dump_table (rtx_insn *start, rtx_insn *barrier)
  scan = emit_insn_after (gen_align_2 (), scan);
  need_align = false;
}
- for (lab = p->label; lab; lab = LABEL_REFS (lab))
+ for (lab = p->label; lab;
+  lab = safe_as_a  (LABEL_REFS (lab)))
scan = emit_label_after (lab, scan);
  scan = emit_insn_after (gen_consttable_2 (p->value, const0_rtx),
  scan);
@@ -4627,7 +4628,7 @@ dump_table (rtx_insn *start, rtx_insn *barrier)
rtx src = SET_SRC (XVECEXP (PATTERN (start), 0, 0));
rtx lab = XEXP (XVECEXP (src, 0, 3), 0);
 
-   scan = emit_label_after (lab, scan);
+   scan = emit_label_after (as_a  (lab), scan);
  }
 }
   if (TARGET_FMOVD && TARGET_ALIGN_DOUBLE && have_df)
@@ -4650,7 +4651,8 @@ dump_table (rtx_insn *start, rtx_insn *barrier)
case E_SFmode:
  if (align_insn && !p->part_of_sequence_p)
{
- for (lab = p->label; lab; lab = LABEL_REFS (lab))
+ for (lab = p->label; lab;
+  lab = safe_as_a  (LABEL_REFS (lab)))
emit_label_before (lab, align_insn);
  emit_insn_before (gen_consttable_4 (p->value, const0_rtx),
align_insn);
@@ -4666,7 +4668,8 @@ dump_table (rtx_insn *start, rtx_insn *barrier)
}
  else
{
- for (lab = p->label; lab; lab = LABEL_REFS (lab))
+ for (lab = p->label; lab;
+  lab = safe_as_a  (LABEL_REFS (lab)))
scan = emit_label_after (lab, scan);
  scan = emit_insn_after (gen_consttable_4 (p->value,
const0_rtx), scan);
@@ -4682,7 +4685,8 @@ dump_table (rtx_insn *start, rtx_insn *barrier)
}
  /* FALLTHRU */
case E_DImode:
- for (lab = p->label; lab; lab = LABEL_REFS (lab))
+ for (lab = p->label; lab;
+  lab = safe_as_a  (LABEL_REFS (lab)))
scan = emit_label_after (lab, scan);
  scan = emit_insn_after (gen_consttable_8 (p->value, const0_rtx),
  scan);
@@ -4721,7 +4725,8 @@ dump_table (rtx_insn *start, rtx_insn *barrier)
  scan = emit_label_after (gen_label_rtx (), scan);
  scan = emit_insn_after (gen_align_4 (), scan);
}
- for (lab = p->label; lab; lab = LABEL_REFS (lab))
+ for (lab = p->label; lab;
+  lab = safe_as_a  (LABEL_REFS (lab)))
scan = emit_label_after (lab, scan);
  scan = emit_insn_after (gen_consttable_4 (p->value, const0_rtx),
  scan);
@@ -4734,7 +4739,8 @@ dump_table (rtx_insn *start, rtx_insn *barrier)
  scan = emit_label_after (gen_label_rtx (), scan);
  scan = emit_insn_after (gen_align_4 (), scan);
}
- for (lab = p->label; lab; lab = LABEL_REFS (lab))
+ for (lab = p->label; lab;
+  lab = safe_as_a  (LABEL_REFS (lab)))
scan = 

[PATCH 4/5] c6x: update for emit-rtl.h changes

2018-06-12 Thread David Malcolm
gcc/ChangeLog:
* config/c6x/c6x.c (reorg_split_calls): Strengthen param "call_labels"
from rtx_insn ** to rtx_code_label **.
(reorg_emit_nops): Likewise.
(c6x_reorg): Likewise for local "call_labels".
---
 gcc/config/c6x/c6x.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/gcc/config/c6x/c6x.c b/gcc/config/c6x/c6x.c
index f12edfd..38fbd7e 100644
--- a/gcc/config/c6x/c6x.c
+++ b/gcc/config/c6x/c6x.c
@@ -4835,7 +4835,7 @@ find_last_same_clock (rtx_insn *insn)
the SEQUENCEs that represent execute packets.  */
 
 static void
-reorg_split_calls (rtx_insn **call_labels)
+reorg_split_calls (rtx_code_label **call_labels)
 {
   unsigned int reservation_mask = 0;
   rtx_insn *insn = get_insns ();
@@ -5009,7 +5009,7 @@ reorg_split_calls (rtx_insn **call_labels)
scheduling was run earlier.  */
 
 static void
-reorg_emit_nops (rtx_insn **call_labels)
+reorg_emit_nops (rtx_code_label **call_labels)
 {
   bool first;
   rtx last_call;
@@ -5947,7 +5947,7 @@ c6x_reorg (void)
 }
   sched_no_dce = false;
 
-  rtx_insn **call_labels = XCNEWVEC (rtx_insn *, get_max_uid () + 1);
+  rtx_code_label **call_labels = XCNEWVEC (rtx_code_label *, get_max_uid () + 
1);
 
   reorg_split_calls (call_labels);
 
-- 
1.8.5.3



[PATCH 1/5] emit-rtl.c: more typesafety

2018-06-12 Thread David Malcolm
This patch converts various rtx to rtx_insn * (or rtx_code_label *).
It also convert the various "_loc" params from int to location_t

gcc/ChangeLog:
* emit-rtl.c (next_real_insn): Strengthen param from "rtx"
to "rtx_insn *".
(add_insn_after): Likewise for first two params.
(add_insn_before): Likewise.
(remove_insn): Likewise for param.
(emit_pattern_before_noloc): Likewise for second and third params.
(emit_jump_insn_before_noloc): Convert NULL_RTX to NULL.
(emit_call_insn_before_noloc): Likewise.
(emit_debug_insn_before_noloc): Strengthen "before" param from "rtx"
to "rtx_insn *".
(emit_barrier_before): Likewise.
(emit_label_before): Strengthen "label" param from "rtx" to
"rtx_code_label *".  Strengthen "before" param from "rtx" to
"rtx_insn *".
(emit_insn_after_1): Strengthen "after" param from "rtx" to
"rtx_insn *".
(emit_pattern_after_noloc): Likewise.
(emit_insn_after_noloc): Likewise.
(emit_jump_insn_after_noloc): Likewise.
(emit_call_insn_after_noloc): Likewise.
(emit_debug_insn_after_noloc): Likewise.
(emit_barrier_after): Likewise.
(emit_label_after): Likewise for both params.
(emit_pattern_after_setloc): Likewise for "after" param.  Convert
"loc" param from "int" to "location_t".
(emit_insn_after_setloc): Likewise.
(emit_jump_insn_after_setloc): Likewise.
(emit_call_insn_after_setloc): Likewise.
(emit_debug_insn_after_setloc): Likewise.
(emit_pattern_before_setloc): Likewise for "before" param.  Convert
"loc" param from "int" to "location_t".
(emit_pattern_before): Convert NULL_RTX to NULL.
(emit_insn_before_setloc): Convert "loc" param from "int" to
"location_t".
(emit_jump_insn_before_setloc): Likewise.
(emit_call_insn_before_setloc): Likewise.
(emit_debug_insn_before_setloc): Strengthen "before" param from rtx to
rtx_insn *.  Convert "loc" param from "int" to "location_t".
* rtl.h (emit_insn_before_setloc, emit_jump_insn_before_setloc,
emit_call_insn_before_setloc, emit_debug_insn_before_setloc):
Convert 3rd param from "int" to "location_t".
(emit_barrier_before, emit_barrier_after, next_real_insn):
Strengthen param from rtx to rtx_insn *.
(emit_label_before): Strengthen 1st param from "rtx" to
"rtx_code_label *".  Strengthen 2nd param from "rtx" to
"rtx_insn *".
(emit_insn_after_noloc, emit_jump_insn_after_noloc,
emit_call_insn_after_noloc, emit_debug_insn_after_noloc):
Strengthen 2nd param from "rtx" to "rtx_insn *".
(emit_insn_after_setloc, emit_jump_insn_after_setloc)
emit_call_insn_after_setloc, emit_debug_insn_after_setloc):
Likewise. Convert 3rd param from "int" to "location_t".
(emit_label_after): Strengthen 1st param from "rtx" to
"rtx_code_label *".
(next_real_insn, remove_insn): Strengthen param from "rtx" to
"rtx_insn *".
(add_insn_before, add_insn_after): Strengthen 1st and 2nd params
from "rtx" to "rtx_insn *".
---
 gcc/emit-rtl.c | 84 ++
 gcc/rtl.h  | 41 ++--
 2 files changed, 58 insertions(+), 67 deletions(-)

diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c
index 613030f..a327ff2 100644
--- a/gcc/emit-rtl.c
+++ b/gcc/emit-rtl.c
@@ -3602,10 +3602,8 @@ prev_nonnote_nondebug_insn_bb (rtx_insn *insn)
SEQUENCEs.  */
 
 rtx_insn *
-next_real_insn (rtx uncast_insn)
+next_real_insn (rtx_insn *insn)
 {
-  rtx_insn *insn = safe_as_a  (uncast_insn);
-
   while (insn)
 {
   insn = NEXT_INSN (insn);
@@ -4230,10 +4228,8 @@ add_insn_before_nobb (rtx_insn *insn, rtx_insn *before)
they know how to update a SEQUENCE. */
 
 void
-add_insn_after (rtx uncast_insn, rtx uncast_after, basic_block bb)
+add_insn_after (rtx_insn *insn, rtx_insn *after, basic_block bb)
 {
-  rtx_insn *insn = as_a  (uncast_insn);
-  rtx_insn *after = as_a  (uncast_after);
   add_insn_after_nobb (insn, after);
   if (!BARRIER_P (after)
   && !BARRIER_P (insn)
@@ -4260,10 +4256,8 @@ add_insn_after (rtx uncast_insn, rtx uncast_after, 
basic_block bb)
they know how to update a SEQUENCE. */
 
 void
-add_insn_before (rtx uncast_insn, rtx uncast_before, basic_block bb)
+add_insn_before (rtx_insn *insn, rtx_insn *before, basic_block bb)
 {
-  rtx_insn *insn = as_a  (uncast_insn);
-  rtx_insn *before = as_a  (uncast_before);
   add_insn_before_nobb (insn, before);
 
   if (!bb
@@ -4313,9 +4307,8 @@ set_insn_deleted (rtx insn)
To really delete an insn and related DF information, use delete_insn.  */
 
 void
-remove_insn (rtx uncast_insn)
+remove_insn (rtx_insn *insn)
 {
-  rtx_insn *insn = as_a  (uncast_insn);
   rtx_insn *next = NEXT_INSN (insn);
   rtx_insn *prev = 

[PATCH 3/5] bfin: update for emit-rtl.h changes

2018-06-12 Thread David Malcolm
gcc/ChangeLog:
* config/bfin/bfin.c (hwloop_optimize): Strengthen local "label"
from rtx to rtx_insn *.
(add_sched_insns_for_speculation): Likewise local for "target",
converting usage of JUMP_LABEL to JUMP_LABEL_AS_INSN.
---
 gcc/config/bfin/bfin.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/config/bfin/bfin.c b/gcc/config/bfin/bfin.c
index b656f13..1d98e55 100644
--- a/gcc/config/bfin/bfin.c
+++ b/gcc/config/bfin/bfin.c
@@ -3773,7 +3773,7 @@ hwloop_optimize (hwloop_info loop)
  point.  */
   if (!loop->incoming_src && loop->head != loop->incoming_dest)
 {
-  rtx label = BB_HEAD (loop->incoming_dest);
+  rtx_insn *label = BB_HEAD (loop->incoming_dest);
   /* If we're jumping to the final basic block in the loop, and there's
 only one cheap instruction before the end (typically an increment of
 an induction variable), we can just emit a copy here instead of a
@@ -4607,7 +4607,7 @@ add_sched_insns_for_speculation (void)
  && any_condjump_p (insn)
  && (cbranch_predicted_taken_p (insn)))
{
- rtx target = JUMP_LABEL (insn);
+ rtx_insn *target = JUMP_LABEL_AS_INSN (insn);
  rtx_insn *next = next_real_insn (target);
 
  if (GET_CODE (PATTERN (next)) == UNSPEC_VOLATILE
-- 
1.8.5.3



[PATCH 2/5] arc: update for emit-rtl.h change

2018-06-12 Thread David Malcolm
gcc/ChangeLog:
* config/arc/arc.c (hwloop_optimize): Strengthen local "end_label"
from rtx to rtx_insn *.
---
 gcc/config/arc/arc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c
index 2bedc9a..987abfd 100644
--- a/gcc/config/arc/arc.c
+++ b/gcc/config/arc/arc.c
@@ -7287,8 +7287,8 @@ hwloop_optimize (hwloop_info loop)
   int i;
   edge entry_edge;
   basic_block entry_bb, bb;
-  rtx iter_reg, end_label;
-  rtx_insn *insn, *seq, *entry_after, *last_insn;
+  rtx iter_reg;
+  rtx_insn *insn, *seq, *entry_after, *last_insn, *end_label;
   unsigned int length;
   bool need_fix = false;
   rtx lp_reg = gen_rtx_REG (SImode, LP_COUNT);
-- 
1.8.5.3



[PATCH 0/5] More rtx->rtx_insn * cleanups

2018-06-12 Thread David Malcolm
This patch kit strengthens various parameters in emit-rtl.h/c from
rtx to rtx_insn *, eliminating 14 "as_a"/"safe_as_a" casts from
emit-rtl.c (though requiring a few new ones elsewhere).

It's effectively one patch; I've split it up for ease of review.

Nearly all of it is trivial, and would be covered by the pre-approval
here:
  https://gcc.gnu.org/ml/gcc-patches/2014-08/msg01310.html

However, some of the sh.c changes appear to need review.

Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu.

Successfully built "cc1" binaries on all 198 configurations in
contrib/config-list.mk.

OK for trunk?

David Malcolm (5):
  emit-rtl.c: more typesafety
  arc: update for emit-rtl.h change
  bfin: update for emit-rtl.h changes
  c6x: update for emit-rtl.h changes
  sh: update for emit-rtl.h changes

 gcc/config/arc/arc.c  |  4 +--
 gcc/config/bfin/bfin.c|  4 +--
 gcc/config/c6x/c6x.c  |  6 ++--
 gcc/config/sh/sh-protos.h |  2 +-
 gcc/config/sh/sh.c| 30 ++---
 gcc/emit-rtl.c| 84 +--
 gcc/rtl.h | 41 ---
 7 files changed, 84 insertions(+), 87 deletions(-)

-- 
1.8.5.3



[Committed] PR fortran/44491 -- Select non-NULL locus

2018-06-12 Thread Steve Kargl
The attached patch has been committed to trunk after
regression testing.  Two loci are available for the
error messages.  If the first locus is NULL, then it
uses the second one to report the error.

In the audit trail of the PR manu@ suggested removing
the assert() that caused the ICE.  His patch tested
for a NULL locus, and simply reported UNKNOWN LOCATION
in the error message.  I find the ICE to be an aid
in locating where gfortran goes sideways, so I've left
the assert() in place.

Index: gcc/fortran/expr.c
===
--- gcc/fortran/expr.c  (revision 261376)
+++ gcc/fortran/expr.c  (working copy)
@@ -3414,6 +3414,8 @@ gfc_check_assign (gfc_expr *lvalue, gfc_expr *rvalue, 
   /* Only DATA Statements come here.  */
   if (!conform)
 {
+  locus *where;
+
   /* Numeric can be converted to any other numeric. And Hollerith can be
 converted to any other type.  */
   if ((gfc_numeric_ts (>ts) && gfc_numeric_ts (>ts))
@@ -3423,8 +3425,9 @@ gfc_check_assign (gfc_expr *lvalue, gfc_expr *rvalue, 
   if (lvalue->ts.type == BT_LOGICAL && rvalue->ts.type == BT_LOGICAL)
return true;
 
+  where = lvalue->where.lb ? >where : >where;
   gfc_error ("Incompatible types in DATA statement at %L; attempted "
-"conversion of %s to %s", >where,
+"conversion of %s to %s", where,
 gfc_typename (>ts), gfc_typename (>ts));
 
   return false;
Index: gcc/testsuite/gfortran.dg/pr44491.f90
===
--- gcc/testsuite/gfortran.dg/pr44491.f90   (nonexistent)
+++ gcc/testsuite/gfortran.dg/pr44491.f90   (working copy)
@@ -0,0 +1,4 @@
+! { dg-do compile }
+! PR fortran/44491
+  character*2 escape /z'1B'/  { dg-error "Incompatible types in DATA" }
+  end
-- 
Steve
Index: gcc/fortran/expr.c
===
--- gcc/fortran/expr.c	(revision 261376)
+++ gcc/fortran/expr.c	(working copy)
@@ -3414,6 +3414,8 @@ gfc_check_assign (gfc_expr *lvalue, gfc_expr *rvalue, 
   /* Only DATA Statements come here.  */
   if (!conform)
 {
+  locus *where;
+
   /* Numeric can be converted to any other numeric. And Hollerith can be
 	 converted to any other type.  */
   if ((gfc_numeric_ts (>ts) && gfc_numeric_ts (>ts))
@@ -3423,8 +3425,9 @@ gfc_check_assign (gfc_expr *lvalue, gfc_expr *rvalue, 
   if (lvalue->ts.type == BT_LOGICAL && rvalue->ts.type == BT_LOGICAL)
 	return true;
 
+  where = lvalue->where.lb ? >where : >where;
   gfc_error ("Incompatible types in DATA statement at %L; attempted "
-		 "conversion of %s to %s", >where,
+		 "conversion of %s to %s", where,
 		 gfc_typename (>ts), gfc_typename (>ts));
 
   return false;
Index: gcc/testsuite/gfortran.dg/pr44491.f90
===
--- gcc/testsuite/gfortran.dg/pr44491.f90	(nonexistent)
+++ gcc/testsuite/gfortran.dg/pr44491.f90	(working copy)
@@ -0,0 +1,4 @@
+! { dg-do compile }
+! PR fortran/44491
+  character*2 escape /z'1B'/  ! { dg-error "Incompatible types in DATA" }
+  end


RE: [PATCH] MIPS: Add support for P6600

2018-06-12 Thread Robert Suchanek
Hi Matthew,

As already discussed, the link to the P6600 doesn't
appear to be referenced on mips.com but reachable
when searching for 'p6600':

https://www.mips.com/downloads/p6600-multiprocessing-programmers-guide/

I'm resubmitting the whole patch again with updated
ChangeLog.

> >
> > +/* Classifies an unconditional branch of interest for the P6600.  */
> > +
> > +enum mips_ucbranch_type {
> 
> Newline for brace.

Done.

> > +/* Subroutine of mips_avoid_hazard.  We classify unconditional
> > branches
> > +   of interest for the P6600 for performance reasons.  We're
> > interested
> > +   in differentiating BALC from JIC, JIALC and BC.  */
> > +
> > +static enum mips_ucbranch_type
> > +mips_classify_branch_p6600 (rtx_insn *insn) {
> > +  if (!(insn
> > +  && USEFUL_INSN_P (insn)
> > +  && GET_CODE (PATTERN (insn)) != SEQUENCE))
> > +return UC_UNDEFINED;
> 
> Let's switch this around to the following with a comment to say ignore
> sequences because they represent a filled delay slot branch (which
> presumably is not affected by the uArch issue).
> 
>   if (insn
>   || !USEFUL_INSN_P (insn)
>   || GET_CODE (PATTERN (insn)) == SEQUENCE))
> return UC_UNDEFINED;

Switched around and added a comment.
> 
> > +
> > +  if (get_attr_jal (insn) == JAL_INDIRECT /* JIC and JIALC.  */
> > +  || get_attr_type (insn) == TYPE_JUMP) /* BC as it is a loose
> > jump.  */
> > +return UC_OTHER;
> 
> I don't recall what a loose jump was supposed to refer to, presumably
> 'direct jump'.

Left it just as 'BC'.

> 
> >  /* Subroutine of mips_reorg_process_insns.  If there is a hazard
> > between
> > INSN and a previous instruction, avoid it by inserting nops after
> > instruction AFTER.
> > @@ -18699,14 +18744,36 @@ mips_avoid_hazard (rtx_insn *after, rtx_insn
> > *insn, int *hilo_delay,
> >&& GET_CODE (pattern) != ASM_INPUT
> >&& asm_noperands (pattern) < 0)
> >  nops = 1;
> > +  /* The P6600's branch predictor does not handle certain static
> > + sequences of back-to-back jumps well.  Inserting a no-op only
> > + costs space as the dispatch unit will disregard the nop.
> > + Here we handle the cases of back to back unconditional branches
> > + that are inefficent.  */
> > +  else if (TUNE_P6600 && TARGET_CB_MAYBE && !optimize_size
> > +  && ((mips_classify_branch_p6600 (after) == UC_BALC
> > +   && mips_classify_branch_p6600 (insn) == UC_OTHER)
> > +  || (mips_classify_branch_p6600 (insn) == UC_BALC
> > +  && (mips_classify_branch_p6600 (after) == UC_OTHER
> 
> Unnecessary braces on the last clause here.

Removed the braces and change the comment.

> 
> > +nops = 1;
> 
> This appears to show that a BALC with a compact branch (other than BALC)
> is the problem case either before or after the BALC. This is what we need
> to see in a public document. Or at least (re)confirmed as the issue.
> 
> >else
> >  nops = 0;
> >
> >/* Insert the nops between this instruction and the previous one.
> >   Each new nop takes us further from the last hilo hazard.  */
> >*hilo_delay += nops;
> > +
> > +  /* If we're tuning for the P6600, we come across an annoying GCC
> > + assumption that debug information always follows a call.  Move
> > + past any debug information in that case.  */
> > +  rtx_insn *real_after = after;
> > +  if (real_after && nops && CALL_P (real_after))
> > +while (TUNE_P6600 && real_after
> > +  && (NOTE_P (NEXT_INSN (real_after))
> > +  || BARRIER_P (NEXT_INSN (real_after
> > +  real_after = NEXT_INSN (real_after);
> > +
> 
> This looks OK but it seems unnecessary to limit to the P6600.  It is just
> that we have not had hazards on branches before now.

Removed the restriction.

> 
> >while (nops-- > 0)
> > -emit_insn_after (gen_hazard_nop (), after);
> > +emit_insn_after (gen_hazard_nop (), real_after);
> >
> >/* Set up the state for the next instruction.  */
> >*hilo_delay += ninsns;
> > @@ -18716,6 +18783,14 @@ mips_avoid_hazard (rtx_insn *after, rtx_insn
> > *insn, int *hilo_delay,
> >  switch (get_attr_hazard (insn))
> >{
> >case HAZARD_NONE:
> > +   /* For the P6600, flag some unconditional branches as having a
> > +  pseudo-forbidden slot.  This will cause additional nop
> > insertion
> > +  or SEQUENCE breaking as required.  */
> > +   if (TUNE_P6600
> > +   && !optimize_size
> > +   && TARGET_CB_MAYBE
> > +   && mips_classify_branch_p6600 (insn) == UC_OTHER)
> > + *fs_delay = true;
> 
> This appears to be saying that all unconditional branches (except
> BALC) will introduce a performance penalty if followed by any other non-
> delay/non-forbidden slot instruction.

Added a comment that this is for performance reasons.
> 
> > break;
> >
> >case HAZARD_FORBIDDEN_SLOT:
> > @@ -18957,7 +19032,10 @@ mips_reorg_process_insns (void)
> >  sequence and replace it 

Re: [PATCH/RFC] enable -Wstrict-prototypes (PR 82922)

2018-06-12 Thread Joseph Myers
On Tue, 12 Jun 2018, Martin Sebor wrote:

> The proposal to enable -Wstrict-prototypes discussed below
> was considered too late for GCC 8.  I'd like to revive it
> now for GCC 9.
> 
>   https://gcc.gnu.org/ml/gcc-patches/2018-01/msg00935.html

My point from that discussion stands that () for no arguments should be 
considered separately from warning for all the other cases.

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


Re: [PATCH] relax -Wsizeof-pointer-memaccess for strncpy with size of source (PR 85931)

2018-06-12 Thread Martin Sebor

On 06/11/2018 03:57 PM, Jeff Law wrote:

On 05/29/2018 08:57 PM, Martin Sebor wrote:

Warning for a strncpy call whose bound is the same as the size
of the source and suggesting to use the size of the source is
less than helpful when both sizes are the same, as in:

  char a[4], b[4];
  strncpy (a, b, sizeof b);

The attached patch suppresses the -Wsizeof-pointer-memaccess
warning for these cases.  To do that even for VLAs (in some
cases), the patch enhances operand_equal_p() to handle
SAVE_EXPR to detect when VLA in sizeof VLA refers to the size
of a variable-length array.

Is this okay for trunk and GCC 8?

Martin

gcc-85931.diff


PR c/85931 -  -Wsizeof-pointer-memaccess for strncpy with size of source

gcc/c-family/ChangeLog:

PR c/85931
* c-warn.c (sizeof_pointer_memaccess_warning): Avoid warning when
sizeof source and destination yields the same value.

gcc/ChangeLog:

PR c/85931
* fold-const.c (operand_equal_p): Handle SAVE_EXPR.

gcc/testsuite/ChangeLog:

PR c/85931
* gcc.dg/Wstringop-truncation-3.c: New test.

OK for the trunk.  Richi and Jakub have the final say for the branch.

I'm a bit surprised that you don't just use operand_equal_p for both the
INTEGER_CST and !INTEGER_CST cases when testing dstsz == srcsz


It seemed that since the CST case compared the values of the size
expressions and the other case their lexicographic form they needed
to be different.  But operand_equal_p() does value comparison for
constants so the conditional can be simplified by using just it
for both cases.  Thanks for the suggestion!  I've made that
simplification and committed r261515.

Jakub/Richard, can you please review the commit and let me know
if you have any concerns with backporting it to the GCC 8 branch?
(I will proceed if I don't hear anything this week.)

Thanks
Martin


Re: libgo patch committed: Add riscv and js/wasm

2018-06-12 Thread Palmer Dabbelt

On Mon, 11 Jun 2018 20:46:01 PDT (-0700), i...@golang.org wrote:

On Mon, Jun 11, 2018 at 12:22 PM, Palmer Dabbelt  wrote:

On Mon, 11 Jun 2018 12:16:39 PDT (-0700), i...@golang.org wrote:


This libgo patch add riscv and js/wasm as known targets.  This
incorporates cut down versions of https://golang.org/cl/102835 and
https://golang.org/cl/106256 from the master sources.  This will tell
the go/build to skip files with those tags.  Bootstrapped and ran Go
testsuite on x86_64-pc-linux-gnu.  Committed to mainline.



[...]


--- libgo/goarch.sh (revision 261203)
+++ libgo/goarch.sh (working copy)
@@ -153,6 +153,11 @@ case $goarch in
;;
esac
;;
+riscv)
+   family=RISCV
+   pcquantum=2
+   ptrsize=4
+   ;;
 riscv64)
family=RISCV64
pcquantum=2



I don't know anything about Go, but we've generally been calling the RISC-V
architectures "riscv32" and "riscv64" as opposed to "riscv" and "riscv64",
with the idea being that it's a bit more explicit.  Technically, RISC-V is
the name of a family of ISAs, with "RV32I" and "RV64I" being two base ISAs
so this also matches the ISA's naming scheme.

Obviously this isn't a big deal, I just saw the patch go by and thought I'd
bring it up.


Thanks.  This is just copying the master sources for the library, at
https://go.googlesource.com/go/+/master/src/go/build/syslist.go .

The naming scheme used here--riscv and riscv64--is pretty conventional for Go.


Ya, it looks like that's what everyone else is doing so I don't see any reason 
to mess with it.


Re: [PATCH, rs6000 8/9] [v2] Enable gimple folding for vec_xl, vec_xst

2018-06-12 Thread Will Schmidt
Hi,
Gimple folding for unaligned vector loads and stores.
Regtest completed across variety of systems, P6,P7,P8,P9.

[v2] Added the type for the MEM_REF, per feedback.
Testcases for gimple-folding of the same are currently in-tree
as powerpc/fold-vec-load-*.c and powerpc/fold-vec-store-*.c.
Re-tested, still looks good. :-)

Thanks
-Will

[gcc]

2018-06-12 Will Schmidt 

* config/rs6000/rs6000.c (rs6000_builtin_valid_without_lhs): Add
vec_xst variants to the list.
(rs6000_gimple_fold_builtin): Add support for folding unaligned
vector loads and stores.

diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index d62abdf..374666c 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -15360,10 +15360,16 @@ rs6000_builtin_valid_without_lhs (enum 
rs6000_builtins fn_code)
 case ALTIVEC_BUILTIN_STVX_V8HI:
 case ALTIVEC_BUILTIN_STVX_V4SI:
 case ALTIVEC_BUILTIN_STVX_V4SF:
 case ALTIVEC_BUILTIN_STVX_V2DI:
 case ALTIVEC_BUILTIN_STVX_V2DF:
+case VSX_BUILTIN_STXVW4X_V16QI:
+case VSX_BUILTIN_STXVW4X_V8HI:
+case VSX_BUILTIN_STXVW4X_V4SF:
+case VSX_BUILTIN_STXVW4X_V4SI:
+case VSX_BUILTIN_STXVD2X_V2DF:
+case VSX_BUILTIN_STXVD2X_V2DI:
   return true;
 default:
   return false;
 }
 }
@@ -15869,10 +15875,78 @@ rs6000_gimple_fold_builtin (gimple_stmt_iterator *gsi)
gimple_set_location (g, loc);
gsi_replace (gsi, g, true);
return true;
   }
 
+/* unaligned Vector loads.  */
+case VSX_BUILTIN_LXVW4X_V16QI:
+case VSX_BUILTIN_LXVW4X_V8HI:
+case VSX_BUILTIN_LXVW4X_V4SF:
+case VSX_BUILTIN_LXVW4X_V4SI:
+case VSX_BUILTIN_LXVD2X_V2DF:
+case VSX_BUILTIN_LXVD2X_V2DI:
+  {
+arg0 = gimple_call_arg (stmt, 0);  // offset
+arg1 = gimple_call_arg (stmt, 1);  // address
+lhs = gimple_call_lhs (stmt);
+location_t loc = gimple_location (stmt);
+/* Since arg1 may be cast to a different type, just use ptr_type_node
+   here instead of trying to enforce TBAA on pointer types.  */
+tree arg1_type = ptr_type_node;
+tree lhs_type = TREE_TYPE (lhs);
+/* POINTER_PLUS_EXPR wants the offset to be of type 'sizetype'.  Create
+   the tree using the value from arg0.  The resulting type will match
+   the type of arg1.  */
+gimple_seq stmts = NULL;
+tree temp_offset = gimple_convert (, loc, sizetype, arg0);
+tree temp_addr = gimple_build (, loc, POINTER_PLUS_EXPR,
+  arg1_type, arg1, temp_offset);
+gsi_insert_seq_before (gsi, stmts, GSI_SAME_STMT);
+/* Use the build2 helper to set up the mem_ref.  The MEM_REF could also
+   take an offset, but since we've already incorporated the offset
+   above, here we just pass in a zero.  */
+gimple *g;
+tree align_ltype = build_aligned_type (lhs_type, TYPE_ALIGN 
((lhs_type)));
+g = gimple_build_assign (lhs, build2 (MEM_REF, align_ltype, temp_addr,
+   build_int_cst (arg1_type, 0)));
+gimple_set_location (g, loc);
+gsi_replace (gsi, g, true);
+return true;
+  }
+
+/* unaligned Vector stores.  */
+case VSX_BUILTIN_STXVW4X_V16QI:
+case VSX_BUILTIN_STXVW4X_V8HI:
+case VSX_BUILTIN_STXVW4X_V4SF:
+case VSX_BUILTIN_STXVW4X_V4SI:
+case VSX_BUILTIN_STXVD2X_V2DF:
+case VSX_BUILTIN_STXVD2X_V2DI:
+  {
+arg0 = gimple_call_arg (stmt, 0); /* Value to be stored.  */
+arg1 = gimple_call_arg (stmt, 1); /* Offset.  */
+tree arg2 = gimple_call_arg (stmt, 2); /* Store-to address.  */
+location_t loc = gimple_location (stmt);
+tree arg0_type = TREE_TYPE (arg0);
+/* Use ptr_type_node (no TBAA) for the arg2_type.  */
+tree arg2_type = ptr_type_node;
+/* POINTER_PLUS_EXPR wants the offset to be of type 'sizetype'.  Create
+   the tree using the value from arg0.  The resulting type will match
+   the type of arg2.  */
+gimple_seq stmts = NULL;
+tree temp_offset = gimple_convert (, loc, sizetype, arg1);
+tree temp_addr = gimple_build (, loc, POINTER_PLUS_EXPR,
+  arg2_type, arg2, temp_offset);
+/* Mask off any lower bits from the address.  */
+gsi_insert_seq_before (gsi, stmts, GSI_SAME_STMT);
+gimple *g;
+g = gimple_build_assign (build2 (MEM_REF, arg0_type, temp_addr,
+  build_int_cst (arg2_type, 0)), arg0);
+gimple_set_location (g, loc);
+gsi_replace (gsi, g, true);
+return true;
+  }
+
 /* Vector Fused multiply-add (fma).  */
 case ALTIVEC_BUILTIN_VMADDFP:
 case VSX_BUILTIN_XVMADDDP:
 case ALTIVEC_BUILTIN_VMLADDUHM:
   {




Re: [PATCH/RFC] enable -Wstrict-prototypes (PR 82922)

2018-06-12 Thread Martin Sebor

The proposal to enable -Wstrict-prototypes discussed below
was considered too late for GCC 8.  I'd like to revive it
now for GCC 9.

  https://gcc.gnu.org/ml/gcc-patches/2018-01/msg00935.html

On 01/11/2018 11:41 AM, Martin Sebor wrote:

Declaring a function without a prototype has been deprecated
for nearly two decades (since C99) and may be removed from
the C language in C2X.  To prompt programs to transition to
the more modern and safer style, PR 82922 requests to enable
Wstrict-prototypes in -Wextra.

With the recent changes to add prototypes to a handful of
functions in Go and libgo, GCC bootstraps with the option
on x86_64 but there are a number of testsuite failures.
The attached patch either avoids or, in a small number of
instances, prunes out the warnings to let the tests pass
on x86_64.

It's possible that enabling the option could cause bootstrap
to break on other targets but since (if) only libraries are
compiled as C code anymore and not GCC back-end code, it seems
unlikely.  Handling such cases is also trivial, so unless I'm
missing something, enabling the option should be low risk for
GCC.

It seems more plausible that are tests for other targets that
would fail with the option, but if the the small number of
x86_64-specific tests in the patch is any indication (AFAICS
just 1) they could be dealt with as they are uncovered during
testing with only a minimum of disruption.

Assuming there is consensus to enable -Wstrict-prototypes, does
enabling the option and dealing with individual failures case-
by-case sound like a reasonable approach, or are are there
other/better ways to proceed without a lot of overhead that
I'm not thinking of?

I'm in the process of testing powerpc64le but I don't have
the ability or the cycles to do other targets.

Martin




Re: [PING] [PATCH] refine -Wstringop-truncation and -Wsizeof-pointer-memaccess for strncat of nonstrings (PR 85602)

2018-06-12 Thread Jeff Law
On 05/29/2018 01:21 PM, Martin Sebor wrote:
> To make review and testing easier (thank you, Franz), attached
> is an updated patch rebased on top of today's trunk.
> 
> (Note that the patch intentionally doesn't suppress the warning
> for the submitted test case without adding the nonstring attribute.)
> 
> On 05/25/2018 02:59 PM, Martin Sebor wrote:
>> Ping:
>> https://gcc.gnu.org/ml/gcc-patches/2018-05/msg00869.html
>>
>> On 05/17/2018 08:01 PM, Martin Sebor wrote:
>>> The -Wstringop-truncation and -Wsizeof-pointer-memaccess warnings
>>> I added and enhanced, respectively, in GCC 8 are arguably overly
>>> strict for source arguments declared with the nonstring attribute.
>>>
>>> For example, -Wsizeof-pointer-memaccess triggers for the strncat
>>> call below:
>>>
>>>   __attribute__ ((nonstring)) char nonstr[8];
>>>   extern char *d;
>>>   strncat (d, nonstr, sizeof nonstr);
>>>
>>> even though it's still a fairly common (if unsafe) idiom from
>>> the early UNIX days (V7 from 1979 to be exact) where strncat
>>> was introduced.  (This use case, modulo the attribute, was
>>> reduced from coreutils.)
>>>
>>> Simialrly, -Wstringop-truncation warns for some strcat calls that
>>> are actually safe, such as in:
>>>
>>>   strcpy (nonstr, "123");
>>>   strncat (d, nonstr, 32);
>>>
>>> To help with the adoption of the warnings and the attribute and
>>> avoid unnecessary churn the attached patch relaxes both warnings
>>> to accept code like this without diagnostics.
>>>
>>> The patch doesn't add any new warnings so I'd like it considered
>>> for GCC 8 in addition to trunk.
>>>
>>> Thanks
>>> Martin
>>
> 
> 
> gcc-85602.diff
> 
> 
> PR middle-end/85602 - -Wsizeof-pointer-memaccess for strncat with size of 
> source
> 
> gcc/c-family/ChangeLog:
> 
>   PR middle-end/85602
>   * c-warn.c (sizeof_pointer_memaccess_warning): Check for attribute
>   nonstring.
> 
> gcc/ChangeLog:
> 
>   PR middle-end/85602
>   * calls.c (maybe_warn_nonstring_arg): Handle strncat.
>   * tree-ssa-strlen.c (is_strlen_related_p): Make extern.
>   Handle integer subtraction.
>   (maybe_diag_stxncpy_trunc): Handle nonstring source arguments.
>   * tree-ssa-strlen.h (is_strlen_related_p): Declare.
> 
> gcc/testsuite/ChangeLog:
> 
>   PR middle-end/85602
>   * c-c++-common/attr-nonstring-8.c: New test.
I wonder if get_attr_nonstring_decl belongs somewhere other than
calls.[ch].  It's really got nothing to do with calls.  That might be a
followup cleanup.

I suspect some of the hunks  need updating now that MPX is gone.  In
particular you no longer need to worry about _BND calls which should
simplify things somewhat.

OK for the trunk after updating for MPX removal and re-bootstrapping &
testing.

jeff





[PATCH] Linux/x86: Update TARGET_THREAD_SPLIT_STACK_OFFSET comments

2018-06-12 Thread H.J. Lu
Glibc 2.18 was changed by

commit ecbf434213c0333d81706074e4d107ac45011635
Author: Andreas Jaeger 
Date:   Wed May 15 20:20:54 2013 +0200

Reserve new TLS field for x86 and x86_64

[BZ #10686]
* sysdeps/x86_64/tls.h (struct tcbhead_t): Add __private_ss
field.
* sysdeps/i386/tls.h (struct tcbhead_t): Likewise.

to reduce the size of __private_tm to make room for __private_ss, which
was supposed to be used for TARGET_THREAD_SPLIT_STACK_OFFSET:

typedef struct
{
  void *tcb;/* Pointer to the TCB.  Not necessarily the
   thread descriptor used by libpthread.  */
  dtv_t *dtv;
  void *self;   /* Pointer to the thread descriptor.  */
  int multiple_threads;
  uintptr_t sysinfo;
  uintptr_t stack_guard;
  uintptr_t pointer_guard;
  int gscope_flag;
  int __glibc_reserved1;
  /* Reservation of some values for the TM ABI.  */
  void *__private_tm[4];
  /* GCC split stack support.  */
  void *__private_ss;
} tcbhead_t;

But the offset of __private_ss for i386 was mistakenly set to 0x30,
instead of 0x34 and libgcc/config/i386/morestack.S has:

cmpl%gs:0x30,%eax   # See if we have enough space.
movl%eax,%gs:0x30   # Save the new stack boundary.
movl%eax,%gs:0x30   # Save the new stack boundary.
movl%ecx,%gs:0x30   # Save new stack boundary.
movl%eax,%gs:0x30
movl%gs:0x30,%eax
movl%eax,%gs:0x30

Since update TARGET_THREAD_SPLIT_STACK_OFFSET changes split stack ABI,
glibc 2.28 has been changed by

commit 0221ce2a90be2d40fc90f0b5dcec77a1ec013f53
Author: H.J. Lu 
Date:   Tue Jun 12 06:23:28 2018 -0700

i386: Change offset of __private_ss to 0x30 [BZ #23250]

to match GCC:

typedef struct
{
  void *tcb;/* Pointer to the TCB.  Not necessarily the
   thread descriptor used by libpthread.  */
  dtv_t *dtv;
  void *self;   /* Pointer to the thread descriptor.  */
  int multiple_threads;
  uintptr_t sysinfo;
  uintptr_t stack_guard;
  uintptr_t pointer_guard;
  int gscope_flag;
  int __glibc_reserved1;
  /* Reservation of some values for the TM ABI.  */
  void *__private_tm[3];
  /* GCC split stack support.  */
  void *__private_ss;
  void *__glibc_reserved2;
} tcbhead_t;

I am going to check it in as an obvious patch.

Thanks.

H.J.

PR target/85990
* config/i386/gnu-user.h (TARGET_THREAD_SPLIT_STACK_OFFSET):
Update comments.
* config/i386/gnu-user64.h (TARGET_THREAD_SPLIT_STACK_OFFSET):
Likewise.
---
 gcc/config/i386/gnu-user.h   | 2 +-
 gcc/config/i386/gnu-user64.h | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/gcc/config/i386/gnu-user.h b/gcc/config/i386/gnu-user.h
index d1dad685e72..56449a5439e 100644
--- a/gcc/config/i386/gnu-user.h
+++ b/gcc/config/i386/gnu-user.h
@@ -134,6 +134,6 @@ along with GCC; see the file COPYING3.  If not see
 /* i386 glibc provides __stack_chk_guard in %gs:0x14.  */
 #define TARGET_THREAD_SSP_OFFSET   0x14
 
-/* We steal the last transactional memory word.  */
+/* i386 glibc provides __private_ss in %gs:0x30.  */
 #define TARGET_THREAD_SPLIT_STACK_OFFSET 0x30
 #endif
diff --git a/gcc/config/i386/gnu-user64.h b/gcc/config/i386/gnu-user64.h
index 491416fec0c..f7a68fdecf0 100644
--- a/gcc/config/i386/gnu-user64.h
+++ b/gcc/config/i386/gnu-user64.h
@@ -86,7 +86,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If 
not, see
 #define TARGET_THREAD_SSP_OFFSET \
   (TARGET_64BIT ? (TARGET_X32 ? 0x18 : 0x28) : 0x14)
 
-/* We steal the last transactional memory word.  */
+/* i386 glibc provides __private_ss in %gs:0x30.
+   x32 glibc provides it in %fs:0x40.
+   x86_64 glibc provides it in %fs:0x70.  */
 #define TARGET_THREAD_SPLIT_STACK_OFFSET \
   (TARGET_64BIT ? (TARGET_X32 ? 0x40 : 0x70) : 0x30)
 #endif
-- 
2.17.1



Re: fix libcc1 dependencies in toplevel Makefile

2018-06-12 Thread Jeff Law
On 06/11/2018 08:50 PM, Alexandre Oliva wrote:
> So I see two possible ways to go from now:
> 
> 1. address the previously-mentioned fragility in the patch I posted, to
> catch all cases of postbootstrap targets and their deps on
> non-postbootstrap targets.
> 
> 
> 2. revamp the bootstrap/non-bootstrap dependencies, using GNU make
> conditionals rather than configure-time enable/disable-bootstrap, so
> that we can have a different set of dependencies while running the
> bootstrap proper, having non-stage dependencies activated by default
> when any of the all-* targets are named in the command line, and also
> when building post-bootstrap all-host all-target.  This might seem to
> bring the problem back, but rather by having the full dependency set,
> we'd avoid the race not by refraining from reentering dirs, but rather
> by having them entered or reentered according to the full dependencies,
> without mixing stage and non-stage dependencies.  I'm not yet sure this
> is actually doable, but it seems to me that if it is, it would be more
> robust than what we have now.
Your call.  I've wanted the build system revamped for 20+ years, but
it's nontrivial and the most serious problems were addressed as we
continued to pull the runtime bits out of gcc/

Jeff


Re: [PATCH] fixincludes: partly repair broken fix for assert.h in vxworks

2018-06-12 Thread Jeff Law
On 06/12/2018 09:19 AM, Olivier Hainque wrote:
> 
> 
>> On 12 Jun 2018, at 16:58, Jeff Law  wrote:
> 
>> Installed on the trunk.
> 
> Thanks Jeff. I missed that Rasmus doesn't have commit rights.
No worries.  I'm thinking that Rasmus ought to go ahead and get commit
privs since it seems like he's making regular contributions.

Rasmus, you'll want to fill out this form.  List me as approving/sponsoring:

https://sourceware.org/cgi-bin/pdw/ps_form.cgi

Jeff


Re: [PATCH] fixincludes: partly repair broken fix for assert.h in vxworks

2018-06-12 Thread Olivier Hainque



> On 12 Jun 2018, at 16:58, Jeff Law  wrote:

> Installed on the trunk.

Thanks Jeff. I missed that Rasmus doesn't have commit rights.





PING [PATCH] add support for strnlen (PR 81384)

2018-06-12 Thread Martin Sebor

I'm looking for a review of the patch below (beyond using
DEF_EXT_LIB_BUILTIN to declare the built-in rather than
DEF_LIB_BUILTIN, as already pointed out by Jakub):

  https://gcc.gnu.org/ml/gcc-patches/2018-06/msg00267.html

On 06/05/2018 03:43 PM, Martin Sebor wrote:

The attached patch adds basic support for handling strnlen
as a built-in function.  It touches the strlen pass where
it folds constant results of the function, and builtins.c
to add simple support for expanding strnlen calls with known
results.  It also changes calls.c to detect excessive bounds
to the function and unsafe calls with arguments declared
attribute nonstring.

A side-effect of the strlen change I should call out is that
strlen() calls to all zero-length arrays that aren't considered
flexible array members (i.e., internal members or non-members)
are folded into zero.  No warning is issued for such invalid
uses of zero-length arrays but based on the responses to my
question Re: aliasing between internal zero-length-arrays and
other members(*) it sounds like one would be appropriate.
I will see about adding one in a separate patch.

Martin

[*] https://gcc.gnu.org/ml/gcc/2018-06/msg00046.html




Re: [PATCH] fixincludes: a few genfixes changes

2018-06-12 Thread Jeff Law
On 06/12/2018 08:25 AM, Bruce Korb wrote:
> This looks pretty reasonable to me. I'm sure "set -- fixincl.x"
> meant something two decades ago when I wrote it. :)
> I should update my e-address since I can be off gnu mail for
> weeks at a time nowadays. (We retired folk are less consistent
> about checking project emails ...)
I hope to join the list of "retired folk" at some point.  Good to hear
from you again Bruce...  Hard to believe it was 20 years ago you
revamped the old fixincludes script to use autogen...


> 
> Oh, the assert.h thingy seems fine, too. RE:
> https://gcc.gnu.org/ml/gcc-patches/2018-06/msg00370.html
Olivier ack'd the assert.h change earlier today as well :-)

> 
> On 06/09/18 06:22, Rasmus Villemoes wrote:
>> 2018-06-09Rasmus Villemoes 
>>
>> fixincludes/
>>
>>  * genfixes: exit 1 when autogen not found.
>>  * genfixes: Remove some redundant code.
>>  * genfixes: Update URL to autogen source code.
Installed.


Jeff


Re: [PATCH] fixincludes: partly repair broken fix for assert.h in vxworks

2018-06-12 Thread Jeff Law
On 06/12/2018 03:17 AM, Olivier Hainque wrote:
> Hello Rasmus,
> 
>> On 7 Jun 2018, at 11:50, Rasmus Villemoes  wrote:
>>
>> 2018-06-07Rasmus Villemoes 
>>
>> fixinclude/
>>
>>  * inclhack.def: Fix fixup for assert.h on vxworks.
>>  * fixincl.x: Regenerate.
> 
> Ok by me, thanks.
Installed on the trunk.
jeff


Re: [PATCH] Document IntegerRange in internal documentation.

2018-06-12 Thread Martin Liška
On 06/12/2018 04:27 PM, Kyrill Tkachov wrote:
> Hi Martin,
> 
> Just a couple of typos...
> 
> On 12/06/18 15:24, Martin Liška wrote:
>> Hi.
>>
>> The patch is mentioning IntegerRange in documentation.
>>
>> Ready for trunk?
>> Martin
>>
>> gcc/ChangeLog:
>>
>> 2018-06-12  Martin Liska  
>>
>>     * doc/options.texi: Document IntegerRange.
>> ---
>>  gcc/doc/options.texi | 5 +
>>  1 file changed, 5 insertions(+)
>>
>>
>  
> +@item IntegerRange(@var{n}, @var{m})
> +The options's arguments are integer numbers.  The option parser
> 
> "option's"
> 
> +will check that value of an option is inclusively withing
> +range [@var{n}, @var{m}].
> 
> "within the range ..."
> 
> Cheers,
> Kyrill

Thanks for the review Kyrill!
Patch installed as r261498.

Martin

Martin


Re: [PATCH] Document IntegerRange in internal documentation.

2018-06-12 Thread Kyrill Tkachov

Hi Martin,

Just a couple of typos...

On 12/06/18 15:24, Martin Liška wrote:

Hi.

The patch is mentioning IntegerRange in documentation.

Ready for trunk?
Martin

gcc/ChangeLog:

2018-06-12  Martin Liska  

* doc/options.texi: Document IntegerRange.
---
 gcc/doc/options.texi | 5 +
 1 file changed, 5 insertions(+)


 
+@item IntegerRange(@var{n}, @var{m})

+The options's arguments are integer numbers.  The option parser

"option's"

+will check that value of an option is inclusively withing
+range [@var{n}, @var{m}].

"within the range ..."

Cheers,
Kyrill


Re: [PATCH] fixincludes: a few genfixes changes

2018-06-12 Thread Bruce Korb
This looks pretty reasonable to me. I'm sure "set -- fixincl.x"
meant something two decades ago when I wrote it. :)
I should update my e-address since I can be off gnu mail for
weeks at a time nowadays. (We retired folk are less consistent
about checking project emails ...)

Oh, the assert.h thingy seems fine, too. RE:
https://gcc.gnu.org/ml/gcc-patches/2018-06/msg00370.html

On 06/09/18 06:22, Rasmus Villemoes wrote:
> 2018-06-09Rasmus Villemoes 
> 
> fixincludes/
> 
>   * genfixes: exit 1 when autogen not found.
>   * genfixes: Remove some redundant code.
>   * genfixes: Update URL to autogen source code.
> ---
>  fixincludes/genfixes | 9 +++--
>  1 file changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/fixincludes/genfixes b/fixincludes/genfixes
> index f0fc5e64f8b..47aad01289d 100755
> --- a/fixincludes/genfixes
> +++ b/fixincludes/genfixes
> @@ -55,19 +55,16 @@ do
>esac
>  done
>  
> -if [ $# -eq 0 ] ; then
> -  set -- fixincl.x
> -fi
> -
>  AG="autogen $AG"
>  set -e
>  
>  if [ -z "`${AG} -v | fgrep ' 5.'`" ]
>  then
>echo "AutoGen appears to be out of date or not correctly installed."
> -  echo "Please download and install:"
> -  echo "   ftp://gcc.gnu.org/pub/gcc/infrastructure/autogen.tar.gz;
> +  echo "Please download and install from:"
> +  echo "   https://ftp.gnu.org/gnu/autogen/;
>touch fixincl.x
> +  exit 1
>  else
>echo AutoGen-ing fixincl.x
>$AG inclhack.def
> 



[PATCH] Document IntegerRange in internal documentation.

2018-06-12 Thread Martin Liška
Hi.

The patch is mentioning IntegerRange in documentation.

Ready for trunk?
Martin

gcc/ChangeLog:

2018-06-12  Martin Liska  

* doc/options.texi: Document IntegerRange.
---
 gcc/doc/options.texi | 5 +
 1 file changed, 5 insertions(+)


diff --git a/gcc/doc/options.texi b/gcc/doc/options.texi
index 69743125c22..f30f077983f 100644
--- a/gcc/doc/options.texi
+++ b/gcc/doc/options.texi
@@ -264,6 +264,11 @@ option handler.  @code{UInteger} should also be used on options like
 @code{-falign-loops}=@var{n} are supported to make sure the saved
 options are given a full integer.
 
+@item IntegerRange(@var{n}, @var{m})
+The options's arguments are integer numbers.  The option parser
+will check that value of an option is inclusively withing
+range [@var{n}, @var{m}].
+
 @item ToLower
 The option's argument should be converted to lowercase as part of
 putting it in canonical form, and before comparing with the strings



Re: [PATCH] Come up with Deprecated option flag.

2018-06-12 Thread Martin Liška
On 06/11/2018 09:33 PM, Paul Koning wrote:
> 
> 
>> On Jun 8, 2018, at 7:09 AM, Martin Liška  wrote:
>>
>> Hi.
>>
>> First follow-up MPX removal patch comes up with Deprecated option flag.
>> That prints warning for options that have no effect:
> 
> Should this be mentioned in the internals manual (section 8.2)?
> 
>   paul
> 

Thanks for noticing that.
Done and installed as r261497.

Martin


RE: [PATCH] MIPS: Update I6400 scheduler

2018-06-12 Thread Robert Suchanek
Hi,


> > There does seem to be a temporal issue in submission for this as the
> > i6400_fpu_minmax reservation refers to fminmax and fclass types that
> > do not exist in trunk. Can you drop that reservation please?
> >
> > Otherwise, OK to commit.
> 
> Reservation dropped.
> 
> Committed as r261489.

There was also a reference to frint type that does not exist in the trunk.

Committed as obvious (r261494).

Regards,
Robert

gcc/
* config/mips/i6400.md (i6400_fpu_fadd): Remove frint.

diff --git a/gcc/config/mips/i6400.md b/gcc/config/mips/i6400.m
index 8058a8dd807..97f6c0b44e7 100644  
--- a/gcc/config/mips/i6400.md 
+++ b/gcc/config/mips/i6400.md 
@@ -222,7 +222,7 @@ (define_insn_reservation "i6400_fpu_fabs" 1
 ;; fadd, fsub, fcvt   
 (define_insn_reservation "i6400_fpu_fadd" 4   
   (and (eq_attr "cpu" "i6400")
-   (eq_attr "type" "fadd, fcvt, frint"))  
+   (eq_attr "type" "fadd,fcvt"))  
   "i6400_fpu_long, i6400_fpu_apu")
   
 ;; fmul   


[PATCH] Add initial version of rtl.vim syntax file.

2018-06-12 Thread Martin Liška
Hi.

This is equivalent of gimple.vim file. I'm aware of not full coverage of RTL
instructions, but hope it's a good start point.

Screenshots:

https://drive.google.com/open?id=14y-Hca2hf1gyWDfHaht6Wjv-Btf3Bdvl
https://drive.google.com/open?id=1LiqsJq2ng-aeKsvw3PhUnDjLWh54Y1Vc

Ready for trunk?
Thanks,
Martin

contrib/ChangeLog:

2018-06-12  Martin Liska  

* rtl.vim: New file.
---
 contrib/rtl.vim | 55 +
 1 file changed, 55 insertions(+)
 create mode 100644 contrib/rtl.vim


diff --git a/contrib/rtl.vim b/contrib/rtl.vim
new file mode 100644
index 000..c584b56e3f3
--- /dev/null
+++ b/contrib/rtl.vim
@@ -0,0 +1,55 @@
+" Syntax highlighting rules for RTL dump files (for Vim).
+"
+" Copyright (C) 2018 Free Software Foundation, Inc.
+"
+" This script 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
+"
+" For more instructions please see gimple.vim file in the same folder.
+
+
+" Do not continue, if syntax is already enabled in current buffer.
+if exists("b:current_syntax")
+finish
+endif
+
+" General-purpose comments.
+syn match   rtlComment  ";;.*$"
+
+syn keyword rtlInstruction  insn parallel_insn set mem simple_return plus
+\ clobber parallel compare minus xor subreg
+\ ashift ashiftrt lshiftrt symbol_reg
+\ zero_extend symbol_ref label_ref call
+\ vec_merge vec_duplicate vec_concat
+syn keyword rtlConditional  jump_insn  if_then_else call_insn eq
+syn keyword rtlNote note barrier code_label
+syn keyword rtlVariableLoation  var_location
+syn keyword rtlExpressionList   expr_list
+syn keyword rtlPcRegister   pc
+
+" String literals
+syn region  rtlString   start=/\v"/ skip=/\v\\./ end=/\v"/
+
+syn match   rtlNoteInsn "NOTE_INSN_[A-Z_]*"
+syn match   rtlIntegerConstant  "\vconst_int -?\d+"
+syn match   rtlFloatConstant"\vconst_double:[A-Z]+ -?\d*\.\d+(e\+\d+)?"
+syn match   rtlRegister "\vreg(\/[a-z])?:[A-Z0-9]+ \d+ [a-z0-9]+"
+syn match   rtlLocation /\v"[^"]*":\d+/
+
+hi def link rtlInstruction  Statement
+hi def link rtlConditional  Conditional
+hi def link rtlNote Debug
+hi def link rtlNoteInsn Debug
+hi def link rtlIntegerConstant  Number
+hi def link rtlFloatConstantNumber
+hi def link rtlRegister Type
+hi def link rtlPcRegister   Type
+hi def link rtlVariableLoation  Debug
+hi def link rtlExpressionList   Debug
+hi def link rtlComment  Comment
+hi def link rtlLocation Debug
+hi def link rtlString   String
+
+let b:current_syntax = "rtl"



[PATCH] Improve gimple.vim syntax file.

2018-06-12 Thread Martin Liška
Hi.

Following patch improves GIMPLE VIM syntax format. Please take a look
at attached screenshots.

Ready for trunk?
Martin

https://drive.google.com/file/d/1KK3GvfX-VXtI_S-TOcIrPq-pex1WTAIJ/view?usp=sharing
https://drive.google.com/file/d/1LpKpBJX5jepFgYBjujWbMyUZGfkPBzDD/view?usp=sharing


---
 contrib/gimple.vim | 14 ++
 1 file changed, 14 insertions(+)


diff --git a/contrib/gimple.vim b/contrib/gimple.vim
index 6334dfab619..8edde04c56f 100644
--- a/contrib/gimple.vim
+++ b/contrib/gimple.vim
@@ -89,6 +89,14 @@ if s:unknown_tree_is_error
 syn match   gimpleUnknownTree   "\vUnknown tree: \w+"
 end
 
+" Ignore probability of edges and basic blocks
+"   [70.00%]:
+syn match   gimpleFrequency " \[\d*\.\d*%\]"
+
+" Ignore basic block with a count
+"   [local count: 118111601]:
+syn match   gimpleBBCount   "\v\[(local )?count: \d+\]"
+
 " Numbers
 syn match   gimpleNumber"\v([^.a-zA-Z0-9_])\zs-?\d+B?"
 syn match   gimpleFloat "\v\W\zs-?\d*\.\d+(e\+\d+)?"
@@ -109,6 +117,9 @@ syn match   gimpleGotoLabel "\v[^:]"
 " Line numbers, generated with -fdump-tree-*-lineno
 syn match   gimpleLineNo"\v\[[^\]]+:\d+:\d+\]"
 
+" DEBUG statements
+syn match   gimpleDebug "\v# DEBUG.*"
+
 " Misc C/C++-like keywords
 syn keyword gimpleStructure struct union enum typedef class
 syn keyword gimpleStorageClass  static register auto volatile extern const
@@ -134,6 +145,9 @@ hi def link gimpleAnnotationOp  Debug
 hi def link gimpleAnnotationMark Debug
 hi def link gimpleStringString
 hi def link gimpleUnknownTree   Error
+hi def link gimpleDebug Debug
+hi def link gimpleFrequency Debug
+hi def link gimpleBBCount   Debug
 
 let b:current_syntax = "gimple"
 



RE: [PATCH,MIPS] Fix pr86067 ICE: scal-to-vec1.c:86:1: error: unrecognizable insn with -march=loongson3a

2018-06-12 Thread Matthew Fortune
Paul Hua  writes:
> The gcc.c-torture/execute/scal-to-vec1.c  trigger a gcc ICE bug.
> 
> It's a mistake in define_expand vec_setv4hi in loongson.md file.
> 
> 375 (define_expand "vec_setv4hi"
> 376   [(set (match_operand:V4HI 0 "register_operand" "=f")
> 377 (unspec:V4HI [(match_operand:V4HI 1 "register_operand" "f")
> 378   (match_operand:HI 2 "register_operand" "f")
> 379   (match_operand:SI 3 "const_0_to_3_operand"
> "")]
> 380  UNSPEC_LOONGSON_PINSRH))]
> 381   "TARGET_HARD_FLOAT && TARGET_LOONGSON_VECTORS"
> 382 {
> 383   rtx ext = gen_reg_rtx (SImode);
> 384   emit_move_insn (ext, gen_lowpart (SImode, operands[1]));
> 385   operands[1] = ext;
> 386 })
> 
> The line 384 gen_lowpart the operands[1], should be gen_lowpart
> operands[2], cause the operands[2] are HImode.
> 
> 
> The attached patch fixed this bug.
> 
> Bootstrapped and reg-tested on mips64el-unknown-linux-gnu.
> Ok for commit ?
> 
> 
> ---

Hi Paul,

This looks good, just one issue with the changelog entry. The entry
would go in the gcc/ChangeLog file and the path is then relative to
the gcc/ directory. The PR should be referenced as target/:

2018-03-24  Chenghua Xu 
 
PR target/86076
* config/mips/loongson.md (vec_setv4hi): Gen_lowpart for
operands[2] instead of operands[1].

OK to commit, thanks for finding and fixing. This has been broken
since 2011!

Matthew



RE: [PATCH 1/2] [ARC][QuarkSE] Update

2018-06-12 Thread Claudiu Zissulescu
Hi,

The purpose of this field is to hold all other possible configurations which 
doesn't fit in the general scheme. The LP_COUNT width is an example, other can 
be the information about register banks used for interrupts.
I will add extra comments in the sources.

Thanks,
Claudiu

From: Andrew Burgess [andrew.burg...@embecosm.com]
Sent: Monday, June 04, 2018 11:42 PM
To: Claudiu Zissulescu
Cc: gcc-patches@gcc.gnu.org; francois.bed...@synopsys.com; 
claz...@synopsys.comq; claziss
Subject: Re: [PATCH 1/2] [ARC][QuarkSE] Update

* Claudiu Zissulescu  [2018-05-21 13:20:28 +0300]:

> From: claziss 
>
> QuarkSE has lp_count width set to 16 bits. Update the compiler to
> consider it.
>
> Ok to apply?
> Claudiu
>
> gcc/
> 2017-07-11  Claudiu Zissulescu  
>
>   * config/arc/arc-arch.h (arc_extras): New enum.
>   (arc_cpu_t): Add field extra.
>   (arc_cpu_types): Consider the extras.
>   * config/arc/arc-cpus.def: Add extras info.
>   * config/arc/arc-opts.h (processor_type): Consider extra field.
>   * config/arc/arc.c (arc_override_options): Handle extra field.

The field name 'extra' seems a little vague.  Can this field ever be
used for more than just lp_count size?  Would a name related more to
lp_count be better?  Or if the intention is that other flags might get
added, maybe there's a name that could suggest that usage?

As a minimum maybe the comment on the new field could describe what
the field is for?

Thanks,
Andrew


> ---
>  gcc/config/arc/arc-arch.h   | 19 ---
>  gcc/config/arc/arc-cpus.def | 59 
> -
>  gcc/config/arc/arc-opts.h   |  2 +-
>  gcc/config/arc/arc.c| 10 
>  4 files changed, 57 insertions(+), 33 deletions(-)
>
> diff --git a/gcc/config/arc/arc-arch.h b/gcc/config/arc/arc-arch.h
> index 01f95946623..f90be66e200 100644
> --- a/gcc/config/arc/arc-arch.h
> +++ b/gcc/config/arc/arc-arch.h
> @@ -79,6 +79,14 @@ enum arc_tune_attr
>  ARC_TUNE_ARCHS4XD_SLOW
>};
>
> +/* Extra options for a processor.  */
> +
> +enum arc_extras
> +{
> +  HAS_NONE,
> +  HAS_LPCOUNT_16
> +};
> +
>  /* CPU specific properties.  */
>
>  typedef struct
> @@ -95,6 +103,9 @@ typedef struct
>/* Specific flags.  */
>const unsigned long long flags;
>
> +  /* Extra value.  */
> +  enum arc_extras extra;
> +
>/* Tune value.  */
>enum arc_tune_attr tune;
>
> @@ -112,12 +123,12 @@ const arc_arch_t arc_arch_types[] =
>
>  const arc_cpu_t arc_cpu_types[] =
>{
> -{"none", NULL, PROCESSOR_NONE, 0, ARC_TUNE_NONE},
> -#define ARC_CPU(NAME, ARCH, FLAGS, TUNE) \
> -{#NAME, _arch_types [BASE_ARCH_##ARCH], PROCESSOR_##NAME, FLAGS, 
> ARC_TUNE_##TUNE },
> +{"none", NULL, PROCESSOR_NONE, 0, HAS_NONE, ARC_TUNE_NONE},
> +#define ARC_CPU(NAME, ARCH, FLAGS, EXTRA, TUNE)  
> \
> +{#NAME, _arch_types [BASE_ARCH_##ARCH], PROCESSOR_##NAME, FLAGS, 
> HAS_##EXTRA, ARC_TUNE_##TUNE },
>  #include "arc-cpus.def"
>  #undef ARC_CPU
> -{NULL, NULL, PROCESSOR_NONE, 0, ARC_TUNE_NONE}
> +{NULL, NULL, PROCESSOR_NONE, 0, HAS_NONE, ARC_TUNE_NONE}
>};
>
>  /* Currently selected cpu type.  */
> diff --git a/gcc/config/arc/arc-cpus.def b/gcc/config/arc/arc-cpus.def
> index 4aa422f1a39..eea83917b42 100644
> --- a/gcc/config/arc/arc-cpus.def
> +++ b/gcc/config/arc/arc-cpus.def
> @@ -43,36 +43,39 @@
> as defined in arc-options.def file, and allowed by arc-arches.def
> file.  The specific hardware flags are enumerated without using
> spaces between the '|' character and consequtive flags.
> +   EXTRA  Extra hardware flags, different than the ones in
> +   arc-arches.def.  Here we can specify the width of lp_count,
> +   for example.
> TUNETune value for the given configuration, otherwise NONE.  */
>
> -ARC_CPU (em, em, 0, NONE)
> -ARC_CPU (em_mini,   em, FL_RF16, NONE)
> -ARC_CPU (arcem,  em, FL_MPYOPT_2|FL_CD|FL_BS, NONE)
> -ARC_CPU (em4,em, FL_CD, NONE)
> -ARC_CPU (em4_dmips, em, FL_MPYOPT_2|FL_CD|FL_DIVREM|FL_NORM|FL_SWAP|FL_BS, 
> NONE)
> -ARC_CPU (em4_fpus,  em, 
> FL_MPYOPT_2|FL_CD|FL_DIVREM|FL_NORM|FL_SWAP|FL_BS|FL_FPU_FPUS, NONE)
> -ARC_CPU (em4_fpuda, em, 
> FL_MPYOPT_2|FL_CD|FL_DIVREM|FL_NORM|FL_SWAP|FL_BS|FL_FPU_FPUDA, NONE)
> -ARC_CPU (quarkse_em, em, 
> FL_MPYOPT_3|FL_CD|FL_DIVREM|FL_NORM|FL_SWAP|FL_BS|FL_FPX_QUARK|FL_SPFP|FL_DPFP,
>  NONE)
> -
> -ARC_CPU (hs,  hs, 0, NONE)
> -ARC_CPU (archs,   hs, FL_MPYOPT_2|FL_DIVREM|FL_LL64, NONE)
> -ARC_CPU (hs34,hs, FL_MPYOPT_2, NONE)
> -ARC_CPU (hs38,hs, FL_MPYOPT_9|FL_DIVREM|FL_LL64, NONE)
> -ARC_CPU (hs38_linux, hs, FL_MPYOPT_9|FL_DIVREM|FL_LL64|FL_FPU_FPUD_ALL, NONE)
> -ARC_CPU (hs4x,  hs, FL_MPYOPT_9|FL_DIVREM|FL_LL64, ARCHS4X)
> -ARC_CPU (hs4xd, hs, FL_MPYOPT_9|FL_DIVREM|FL_LL64, ARCHS4XD)
> -
> -ARC_CPU (arc600,  6xx, FL_BS, ARC600)
> -ARC_CPU (arc600_norm, 6xx, 

Re: [patch] Remove redundant intrinsics

2018-06-12 Thread H.J. Lu
On Mon, Jun 4, 2018 at 3:27 AM, Koval, Julia  wrote:
> Hi,
>
> Since pre-Icelake ISA already had 128bit version vpclmul and vaes, we already 
> have intrinsics for them(_mm_aesdec_si128, _mm_aesdeclast_si128, 
> _mm_aesenc_si128, _mm_aesenclast_si128, _mm_clmulepi64_si128). Therefore 
> intrinsics for them, introduced with Icelake instructions are redundant. This 
> patch removes them. Ok for trunk?
>
> gcc/
> * config/i386/vaesintrin.h (_mm_aesdec_epi128, _mm_aesdeclast_epi128,
> _mm_aesenc_epi128, _mm_aesenclast_epi128): Remove.
> * config/i386/vpclmulqdqintrin.h (_mm_clmulepi64_epi128): Remove.
>
> gcc/testsuite/
> * gcc.target/i386/avx512fvl-vaes-1.c: Remove 128bit versions from 
> test.
> * gcc.target/i386/vpclmulqdq.c: Ditto.

This caused:

[hjl@gnu-skx-1 gcc]$
/export/build/gnu/gcc-test/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/gcc-test/build-x86_64-linux/gcc/
/export/gnu/import/git/sources/gcc/gcc/testsuite/gcc.target/i386/avx512vl-vpclmulqdq-2.c
-fno-diagnostics-show-caret -fdiagnostics-color=never -O2 -mavx512bw
-mavx512vl -mvpclmulqdq -lm -o ./avx512vl-vpclmulqdq-2.exe
In file included from
/export/gnu/import/git/sources/gcc/gcc/testsuite/gcc.target/i386/avx512f-vpclmulqdq-2.c:9,
 from
/export/gnu/import/git/sources/gcc/gcc/testsuite/gcc.target/i386/avx512vl-vpclmulqdq-2.c:17:
/export/gnu/import/git/sources/gcc/gcc/testsuite/gcc.target/i386/avx512f-vpclmulqdq-2.c:
In function \u2018test_128\u2019:
/export/gnu/import/git/sources/gcc/gcc/testsuite/gcc.target/i386/avx512f-helper.h:107:25:
warning: implicit declaration of function
\u2018_mm_clmulepi64_epi128\u2019; did you mean
\u2018_mm_clmulepi64_si128\u2019? [-Wimplicit-function-declaration]
/export/gnu/import/git/sources/gcc/gcc/testsuite/gcc.target/i386/avx512f-vpclmulqdq-2.c:56:11:
note: in expansion of macro \u2018INTRINSIC\u2019
In file included from
/export/gnu/import/git/sources/gcc/gcc/testsuite/gcc.target/i386/avx512vl-vpclmulqdq-2.c:17:
/export/gnu/import/git/sources/gcc/gcc/testsuite/gcc.target/i386/avx512f-vpclmulqdq-2.c:56:9:
error: incompatible types when assigning to type \u2018__m128i\u2019
{aka \u2018__vector(2) long long int\u2019} from type \u2018int\u2019
[hjl@gnu-skx-1 gcc]$
/export/build/gnu/gcc-test/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/gcc-test/build-x86_64-linux/gcc/
/export/gnu/import/git/sources/gcc/gcc/testsuite/gcc.target/i386/avx512vl-vpclmulqdq-2.c
-fno-diagnostics-show-caret -fdiagnostics-color=never -O2 -mavx512bw
-mavx512vl -mvpclmulqdq -lm -o ./avx512vl-vpclmulqdq-2.exe
In file included from
/export/gnu/import/git/sources/gcc/gcc/testsuite/gcc.target/i386/avx512f-vpclmulqdq-2.c:9,
 from
/export/gnu/import/git/sources/gcc/gcc/testsuite/gcc.target/i386/avx512vl-vpclmulqdq-2.c:17:
/export/gnu/import/git/sources/gcc/gcc/testsuite/gcc.target/i386/avx512f-vpclmulqdq-2.c:
In function \u2018test_128\u2019:
/export/gnu/import/git/sources/gcc/gcc/testsuite/gcc.target/i386/avx512f-helper.h:107:25:
warning: implicit declaration of function
\u2018_mm_clmulepi64_epi128\u2019; did you mean
\u2018_mm_clmulepi64_si128\u2019? [-Wimplicit-function-declaration]
/export/gnu/import/git/sources/gcc/gcc/testsuite/gcc.target/i386/avx512f-vpclmulqdq-2.c:56:11:
note: in expansion of macro \u2018INTRINSIC\u2019
In file included from
/export/gnu/import/git/sources/gcc/gcc/testsuite/gcc.target/i386/avx512vl-vpclmulqdq-2.c:17:
/export/gnu/import/git/sources/gcc/gcc/testsuite/gcc.target/i386/avx512f-vpclmulqdq-2.c:56:9:
error: incompatible types when assigning to type \u2018__m128i\u2019
{aka \u2018__vector(2) long long int\u2019} from type \u2018int\u2019
[hjl@gnu-skx-1 gcc]$

FAIL: gcc.target/i386/avx512vl-vpclmulqdq-2.c (test for excess errors)


-- 
H.J.


Re: [PATCH] libitm/x86: Correct offsets of __private_tm and pointer_guard

2018-06-12 Thread H.J. Lu
On Tue, Jun 12, 2018 at 1:23 AM, Torvald Riegel  wrote:
> On Wed, 2018-05-30 at 07:54 -0700, H.J. Lu wrote:
>> In glibc, sysdeps/i386/nptl/tls.h has
>>
>> typedef struct
>> {
>>   void *tcb;/* Pointer to the TCB.  Not necessarily the
>>thread descriptor used by libpthread.  */
>>   dtv_t *dtv;
>>   void *self;   /* Pointer to the thread descriptor.  */
>>   int multiple_threads;
>>   uintptr_t sysinfo;
>>   uintptr_t stack_guard;
>>   uintptr_t pointer_guard;
>>   int gscope_flag;
>>   int __glibc_reserved1;
>>   /* Reservation of some values for the TM ABI.  */
>>   void *__private_tm[4];
>>   /* GCC split stack support.  */
>>   void *__private_ss;
>> } tcbhead_t;
>>
>> and sysdeps/x86_64/nptl/tls.h has
>>
>> typedef struct
>> {
>>   void *tcb;/* Pointer to the TCB.  Not necessarily the
>>thread descriptor used by libpthread.  */
>>   dtv_t *dtv;
>>   void *self;   /* Pointer to the thread descriptor.  */
>>   int multiple_threads;
>>   int gscope_flag;
>>   uintptr_t sysinfo;
>>   uintptr_t stack_guard;
>>   uintptr_t pointer_guard;
>>   unsigned long int vgetcpu_cache[2];
>>   int __glibc_reserved1;
>>   int __glibc_unused1;
>>   /* Reservation of some values for the TM ABI.  */
>>   void *__private_tm[4];
>>   /* GCC split stack support.  */
>>   void *__private_ss;
>>   long int __glibc_reserved2;
>>   /* Must be kept even if it is no longer used by glibc since programs,
>>  like AddressSanitizer, depend on the size of tcbhead_t.  */
>>   __128bits __glibc_unused2[8][4] __attribute__ ((aligned (32)));
>>
>>   void *__padding[8];
>> } tcbhead_t;
>>
>> The offsets of __private_tm are
>>
>> i386:   36 bytes
>> x32:48 bytes
>> x86_64: 80 bytes
>>
>> and the offsets of pointer_guard are:
>>
>> i386:   24 bytes
>> x32:28 bytes
>> x86_64: 48 bytes
>>
>> Update SEG_READ and SEG_WRITE to use the offset of __private_tm as base
>> and correct the offset of pointer_guard for x32.
>>
>> Tested on i686, x86-64 and x32.  OK for trunk and release branches?
>
> The patch itself looks okay to me, but the commit message is pretty
> cryptic.  I can't ack for release branches.
>

I checked in the patch with the updated commit message:

https://gcc.gnu.org/ml/gcc-cvs/2018-06/msg00446.html

Jakub, is this OK for release branches.

Thanks.

-- 
H.J.


RE: [PATCH] MIPS: Add i6500 processor as an alias for i6400

2018-06-12 Thread Robert Suchanek
Hi,

> Looks good, OK to commit.

Committed as r261490.

Regards,
Robert


RE: [PATCH] MIPS: Update I6400 scheduler

2018-06-12 Thread Robert Suchanek
Hi Matthew,

> There does seem to be a temporal issue in submission for this as the 
> i6400_fpu_minmax reservation refers to fminmax and fclass types that 
> do not exist in trunk. Can you drop that reservation please?
> 
> Otherwise, OK to commit.

Reservation dropped.

Committed as r261489.

Regards,
Robert


[Ada] Minor tweaks in gigi

2018-06-12 Thread Eric Botcazou
Tested on x86-64/Linux, applied on mainline, 8 and 7 branches.


2018-06-12  Eric Botcazou  

* gcc-interface/ada-tree.h (TYPE_RETURN_BY_DIRECT_REF_P): Change from
using TYPE_LANG_FLAG_4 to using TYPE_LANG_FLAG_0.
(TYPE_ALIGN_OK): Move around.
(TYPE_PADDING_FOR_COMPONENT): Remove superfluous parentheses.
* gcc-interface/decl.c (change_qualified_type): Move to...
(gnat_to_gnu_entity): Adjust comment.
* gcc-interface/gigi.h (change_qualified_type): ...here; make inline.
(ceil_pow2): Use ceil_log2.
* gcc-interface/utils.c (finish_subprog_decl): Add couple of comments
and do not set TREE_SIDE_EFFECTS.
(handle_noreturn_attribute): Use change_qualified_type.

-- 
Eric Botcazou
Index: gcc-interface/ada-tree.h
===
--- gcc-interface/ada-tree.h	(revision 261473)
+++ gcc-interface/ada-tree.h	(working copy)
@@ -83,6 +83,12 @@ do {			 \
   ((TREE_CODE (NODE) == INTEGER_TYPE || TREE_CODE (NODE) == ARRAY_TYPE) \
&& TYPE_PACKED_ARRAY_TYPE_P (NODE))
 
+/* For FUNCTION_TYPEs, nonzero if the function returns by direct reference,
+   i.e. the callee returns a pointer to a memory location it has allocated
+   and the caller only needs to dereference the pointer.  */
+#define TYPE_RETURN_BY_DIRECT_REF_P(NODE) \
+  TYPE_LANG_FLAG_0 (FUNCTION_TYPE_CHECK (NODE))
+
 /* For INTEGER_TYPE, nonzero if this is a modular type with a modulus that
is not equal to two to the power of its mode's size.  */
 #define TYPE_MODULAR_P(NODE) TYPE_LANG_FLAG_1 (INTEGER_TYPE_CHECK (NODE))
@@ -152,12 +158,6 @@ do {			 \
 #define TYPE_CONVENTION_FORTRAN_P(NODE) \
   TYPE_LANG_FLAG_4 (ARRAY_TYPE_CHECK (NODE))
 
-/* For FUNCTION_TYPEs, nonzero if the function returns by direct reference,
-   i.e. the callee returns a pointer to a memory location it has allocated
-   and the caller only needs to dereference the pointer.  */
-#define TYPE_RETURN_BY_DIRECT_REF_P(NODE) \
-  TYPE_LANG_FLAG_4 (FUNCTION_TYPE_CHECK (NODE))
-
 /* For RECORD_TYPE, UNION_TYPE and ENUMERAL_TYPE, nonzero if this is a dummy
type, made to correspond to a private or incomplete type.  */
 #define TYPE_DUMMY_P(NODE) \
@@ -186,6 +186,9 @@ do {			 \
 /* True for a dummy type if TYPE appears in a profile.  */
 #define TYPE_DUMMY_IN_PROFILE_P(NODE) TYPE_LANG_FLAG_6 (NODE)
 
+/* True if objects of this type are guaranteed to be properly aligned.  */
+#define TYPE_ALIGN_OK(NODE) TYPE_LANG_FLAG_7 (NODE)
+
 /* True for types that implement a packed array and for original packed array
types.  */
 #define TYPE_IMPL_PACKED_ARRAY_P(NODE) \
@@ -199,9 +202,6 @@ do {			 \
alignment value the type ought to have.  */
 #define TYPE_MAX_ALIGN(NODE) (TYPE_PRECISION (RECORD_OR_UNION_CHECK (NODE)))
 
-/* True if objects of tagged types are guaranteed to be properly aligned.  */
-#define TYPE_ALIGN_OK(NODE) TYPE_LANG_FLAG_7 (NODE)
-
 /* For an UNCONSTRAINED_ARRAY_TYPE, this is the record containing both the
template and the object.
 
@@ -238,7 +238,7 @@ do {			 \
 /* For an ARRAY_TYPE with variable size, this is the padding type built for
the array type when it is itself the component type of another array.  */
 #define TYPE_PADDING_FOR_COMPONENT(NODE) \
-  (TYPE_LANG_SLOT_1 (ARRAY_TYPE_CHECK (NODE)))
+  TYPE_LANG_SLOT_1 (ARRAY_TYPE_CHECK (NODE))
 
 /* For a VECTOR_TYPE, this is the representative array type.  */
 #define TYPE_REPRESENTATIVE_ARRAY(NODE) \
Index: gcc-interface/decl.c
===
--- gcc-interface/decl.c	(revision 261483)
+++ gcc-interface/decl.c	(working copy)
@@ -210,7 +210,6 @@ static tree gnat_to_gnu_subprog_type (En
 static int adjust_packed (tree, tree, int);
 static tree gnat_to_gnu_field (Entity_Id, tree, int, bool, bool);
 static tree gnu_ext_name_for_subprog (Entity_Id, tree);
-static tree change_qualified_type (tree, int);
 static void set_nonaliased_component_on_array_type (tree);
 static void set_reverse_storage_order_on_array_type (tree);
 static bool same_discriminant_p (Entity_Id, Entity_Id);
@@ -4447,7 +4446,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entit
   /* If this is not an unconstrained array type, set some flags.  */
   if (TREE_CODE (gnu_type) != UNCONSTRAINED_ARRAY_TYPE)
 	{
-	  /* Tell the middle-end that objects of tagged types are guaranteed to
+	  /* Record the property that objects of tagged types are guaranteed to
 	 be properly aligned.  This is necessary because conversions to the
 	 class-wide type are translated into conversions to the root type,
 	 which can be less aligned than some of its derived types.  */
@@ -6065,19 +6064,6 @@ gnu_ext_name_for_subprog (Entity_Id gnat
   return gnu_ext_name;
 }
 
-/* Like build_qualified_type, but TYPE_QUALS is added to the existing
-   qualifiers on TYPE.  */
-
-static tree
-change_qualified_type (tree type, int type_quals)
-{
-  /* Qualifiers must be 

[Ada] Fix missing resolution data for secondary dispatch table with LTO

2018-06-12 Thread Eric Botcazou
Dispatch tables are implemented the same way as in the C++ front-end, i.e. by 
importing and then exporting them to break the inherent circularity.  There 
was a glitch in gigi that was preventing the two views from being merged in 
the case of secondary dispatch tables in LTO mode.

Fixed thusly, tested on x86-64/Linux, applied on mainline, 8 and 7 branches.


2018-06-12  Eric Botcazou  

* gcc-interface/decl.c (gnat_to_gnu_entity) : Do not get
the expression of a dispatch table that is not being defined.
: Remove obsolete kludge.

-- 
Eric BotcazouIndex: gcc-interface/decl.c
===
--- gcc-interface/decl.c	(revision 261480)
+++ gcc-interface/decl.c	(working copy)
@@ -603,13 +603,18 @@ gnat_to_gnu_entity (Entity_Id gnat_entit
   /* If we have a constant that we are not defining, get the expression it
 	 was defined to represent.  This is necessary to avoid generating dumb
 	 elaboration code in simple cases, but we may throw it away later if it
-	 is not a constant.  But do not retrieve it if it is an allocator since
+	 is not a constant.  But do not do it for dispatch tables because they
+	 are only referenced indirectly and we need to have a consistent view
+	 of the exported and of the imported declarations of the tables from
+	 external units for them to be properly merged in LTO mode.  Moreover
+	 simply do not retrieve the expression it if it is an allocator since
 	 the designated type might still be dummy at this point.  Note that we
 	 invoke gnat_to_gnu_external and not gnat_to_gnu because the expression
 	 may contain N_Expression_With_Actions nodes and thus declarations of
 	 objects from other units that we need to discard.  */
   if (!definition
 	  && !No_Initialization (Declaration_Node (gnat_entity))
+	  && !Is_Dispatch_Table_Entity (gnat_entity)
 	  && Present (gnat_temp = Expression (Declaration_Node (gnat_entity)))
 	  && Nkind (gnat_temp) != N_Allocator
 	  && (!type_annotate_only || Compile_Time_Known_Value (gnat_temp)))
@@ -3406,20 +3411,6 @@ gnat_to_gnu_entity (Entity_Id gnat_entit
 	  break;
 	}
 
-	  /* If this is a record subtype associated with a dispatch table,
-	 strip the suffix.  This is necessary to make sure 2 different
-	 subtypes associated with the imported and exported views of a
-	 dispatch table are properly merged in LTO mode.  */
-	  if (Is_Dispatch_Table_Entity (gnat_entity))
-	{
-	  char *p;
-	  Get_Encoded_Name (gnat_entity);
-	  p = strchr (Name_Buffer, '_');
-	  gcc_assert (p);
-	  strcpy (p+2, "dtS");
-	  gnu_entity_name = get_identifier (Name_Buffer);
-	}
-
 	  /* When the subtype has discriminants and these discriminants affect
 	 the initial shape it has inherited, factor them in.  But for an
 	 Unchecked_Union (it must be an Itype), just return the type.  */


Re: [PATCH, contrib] Add contrib/maintainers-verify.sh

2018-06-12 Thread Tom de Vries
[ Fixed ENOPATCH ]

On Tue, Jun 12, 2018 at 11:57:13AM +0200, Tom de Vries wrote:
> [ was: Re: [MAINTAINERS, committed] Remove redundant write-after-approval
> entries ]
> 
> On Tue, Jun 12, 2018 at 10:26:31AM +0200, Martin Liška wrote:
> > Hi.
> > 
> > Thanks for the script, it also found me in Write After Approval section.
> > Thus I'll install following patch.
> > 
> > Tom what about installing the script into contrib?
> 
> I've renamed the script to contrib/maintainers-verify.sh.
> 
> Also I've added a regression test that runs it:
> ...
> Running src/gcc/testsuite/gcc.src/maintainers.exp ...
> PASS: maintainers-verify.sh
> ...
> 
> When failing (by reverting your patch on MAINTAINERS), it shows in gcc.log:
> ...
> Running src/gcc/testsuite/gcc.src/maintainers.exp ...
> Redundant in write approval: Martin Liska
> FAIL: maintainers-verify.sh
> ...
> 
> OK for trunk?
> 
> Thanks,
> - Tom

[contrib] Add contrib/maintainers-verify.sh

---
 contrib/maintainers-verify.sh | 45 +++
 gcc/testsuite/gcc.src/maintainers.exp | 35 +++
 2 files changed, 80 insertions(+)

diff --git a/contrib/maintainers-verify.sh b/contrib/maintainers-verify.sh
new file mode 100755
index 000..226c158fdaa
--- /dev/null
+++ b/contrib/maintainers-verify.sh
@@ -0,0 +1,45 @@
+#!/bin/sh
+
+# Copyright (C) 2018 Free Software Foundation, Inc.
+#
+# This file is part of GCC.
+#
+# GCC is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GCC is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING.  If not, write to
+# the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+
+if [ "$1" != "" ]; then
+f="$1"
+else
+f=./MAINTAINERS
+fi
+
+grep @ $f \
+| sed 's/[\t][\t]*/\t/g' \
+| awk -F '\t' \
+ "
+{
+  if (NF == 2) {
+name=\$1
+email=\$2
+if (names[name] == 1) {
+printf \"Redundant in write approval: %s\n\", name
+}
+  } else if (NF == 3 ) {
+name=\$2
+email=\$3
+names[name] = 1
+  }
+}
+"
diff --git a/gcc/testsuite/gcc.src/maintainers.exp 
b/gcc/testsuite/gcc.src/maintainers.exp
new file mode 100644
index 000..89a062fb7ad
--- /dev/null
+++ b/gcc/testsuite/gcc.src/maintainers.exp
@@ -0,0 +1,35 @@
+#   Copyright (C) 2018 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
+# .
+
+proc gcc_src_run_maintainers_verify_sh {} {
+set script maintainers-verify.sh
+
+global srcdir
+set rootdir $srcdir/../..
+set contrib $rootdir/contrib
+
+set maintainers $rootdir/MAINTAINERS
+
+set verify_output [exec $contrib/$script $maintainers]
+if { "$verify_output"  == "" } {
+   pass "$script"
+} else {
+   send_log "$verify_output\n"
+   fail "$script"
+}
+}
+
+gcc_src_run_maintainers_verify_sh


[Ada] Plug loophole in warn_on_field_placement

2018-06-12 Thread Eric Botcazou
Only the first component of a group of reordered bitfields was warned about.

Tested on x86-64/Linux, applied on mainline and 8 branch.


2018-06-12  Eric Botcazou  

* gcc-interface/decl.c (warn_on_field_placement): Use specific wording
for discriminants.
(warn_on_list_placement): New static function.
(components_to_record): Use it to warn on multiple fields in list.

-- 
Eric BotcazouIndex: gcc-interface/decl.c
===
--- gcc-interface/decl.c	(revision 261479)
+++ gcc-interface/decl.c	(working copy)
@@ -7296,31 +7296,44 @@ warn_on_field_placement (tree gnu_field,
   if (!Comes_From_Source (gnat_record_type))
 return;
 
+  Entity_Id gnat_field
+= gnu_field_to_gnat (gnu_field, gnat_component_list, gnat_record_type);
+  gcc_assert (Present (gnat_field));
+
   const char *msg1
 = in_variant
   ? "?variant layout may cause performance issues"
   : "?record layout may cause performance issues";
   const char *msg2
-= field_has_self_size (gnu_field)
-  ? "?component & whose length depends on a discriminant"
-  : field_has_variable_size (gnu_field)
-	? "?component & whose length is not fixed"
-	: "?component & whose length is not multiple of a byte";
+= Ekind (gnat_field) == E_Discriminant
+  ? "?discriminant & whose length is not multiple of a byte"
+  : field_has_self_size (gnu_field)
+	? "?component & whose length depends on a discriminant"
+	: field_has_variable_size (gnu_field)
+	  ? "?component & whose length is not fixed"
+	  : "?component & whose length is not multiple of a byte";
   const char *msg3
 = do_reorder
   ? "?comes too early and was moved down"
   : "?comes too early and ought to be moved down";
 
-  Entity_Id gnat_field
-= gnu_field_to_gnat (gnu_field, gnat_component_list, gnat_record_type);
-
-  gcc_assert (Present (gnat_field));
-
   post_error (msg1, gnat_field);
   post_error_ne (msg2, gnat_field, gnat_field);
   post_error (msg3, gnat_field);
 }
 
+/* Likewise but for every field present on GNU_FIELD_LIST.  */
+
+static void
+warn_on_list_placement (tree gnu_field_list, Node_Id gnat_component_list,
+		Entity_Id gnat_record_type, bool in_variant,
+		bool do_reorder)
+{
+  for (tree gnu_tmp = gnu_field_list; gnu_tmp; gnu_tmp = DECL_CHAIN (gnu_tmp))
+warn_on_field_placement (gnu_tmp, gnat_component_list, gnat_record_type,
+			 in_variant, do_reorder);
+}
+
 /* Structure holding information for a given variant.  */
 typedef struct vinfo
 {
@@ -7895,11 +7908,18 @@ components_to_record (Node_Id gnat_compo
 	  if (tmp_bitp_size != 0)
 		{
 		  if (w_reorder && tmp_last_reorder_field_type < 2)
-		warn_on_field_placement (gnu_tmp_bitp_list
-	 ? gnu_tmp_bitp_list : gnu_last,
-	 gnat_component_list,
-	 gnat_record_type, in_variant,
-	 do_reorder);
+		{
+		  if (gnu_tmp_bitp_list)
+			warn_on_list_placement (gnu_tmp_bitp_list,
+		gnat_component_list,
+		gnat_record_type, in_variant,
+		do_reorder);
+		  else
+			warn_on_field_placement (gnu_last,
+		 gnat_component_list,
+		 gnat_record_type, in_variant,
+		 do_reorder);
+		}
 
 		  if (do_reorder)
 		gnu_bitp_list = chainon (gnu_tmp_bitp_list, gnu_bitp_list);
@@ -7953,10 +7973,16 @@ components_to_record (Node_Id gnat_compo
   if (last_reorder_field_type == 2
 	  && tmp_bitp_size != 0
 	  && tmp_last_reorder_field_type < 2)
-	warn_on_field_placement (gnu_tmp_bitp_list
- ? gnu_tmp_bitp_list : gnu_field_list,
- gnat_component_list, gnat_record_type,
- in_variant, do_reorder);
+	{
+	  if (gnu_tmp_bitp_list)
+	warn_on_list_placement (gnu_tmp_bitp_list,
+gnat_component_list, gnat_record_type,
+in_variant, do_reorder);
+	  else
+	warn_on_field_placement (gnu_field_list,
+ gnat_component_list, gnat_record_type,
+ in_variant, do_reorder);
+	}
 }
 
   if (do_reorder)


[PATCH, contrib] Add contrib/maintainers-verify.sh

2018-06-12 Thread Tom de Vries
[ was: Re: [MAINTAINERS, committed] Remove redundant write-after-approval
entries ]

On Tue, Jun 12, 2018 at 10:26:31AM +0200, Martin Liška wrote:
> Hi.
> 
> Thanks for the script, it also found me in Write After Approval section.
> Thus I'll install following patch.
> 
> Tom what about installing the script into contrib?

I've renamed the script to contrib/maintainers-verify.sh.

Also I've added a regression test that runs it:
...
Running src/gcc/testsuite/gcc.src/maintainers.exp ...
PASS: maintainers-verify.sh
...

When failing (by reverting your patch on MAINTAINERS), it shows in gcc.log:
...
Running src/gcc/testsuite/gcc.src/maintainers.exp ...
Redundant in write approval: Martin Liska
FAIL: maintainers-verify.sh
...

OK for trunk?

Thanks,
- Tom


[Ada] Improve generated code for records with rep clauses

2018-06-12 Thread Eric Botcazou
This makes sure the handling of bit-fields is uniform in packed records or 
records with representation clause.

Tested on x86-64/Linux, applied on mainline,


2018-06-12  Eric Botcazou  

* gcc-interface/decl.c (variant_desc): Add AUX field.
(gnat_to_gnu_entity) : Do not call compute_record_mode
directly.
(reverse_sort_field_list): New static function.
(components_to_record): Place the variant part at the beginning of the
field list when there is an obvious order of increasing position.
(build_variant_list): Initialize it.
(create_variant_part_from): Do not call compute_record_mode directly.
(copy_and_substitute_in_layout): Likewise.  Always sort the fields with
fixed position in order of increasing position, in the record and all
the variants, in any.  Call reverse_sort_field_list.
* gcc-interface/utils.c (make_packable_type): Compute the sizes before
calling finish_record_type.  Do not call compute_record_mode directly.
(finish_record_type): Overhaul final processing depending on REP_LEVEL
and call finish_bitfield_layout if it is equal to one or two.


2018-06-12  Eric Botcazou  

* gnat.dg/opt72a.ad[sb]: New test.
* gnat.dg/opt72_pkg.ads: New helper.

-- 
Eric BotcazouIndex: gcc-interface/decl.c
===
--- gcc-interface/decl.c	(revision 261473)
+++ gcc-interface/decl.c	(working copy)
@@ -123,6 +123,9 @@ typedef struct variant_desc_d {
 
   /* The type of the variant after transformation.  */
   tree new_type;
+
+  /* The auxiliary data.  */
+  tree aux;
 } variant_desc;
 
 
@@ -1927,7 +1930,6 @@ gnat_to_gnu_entity (Entity_Id gnat_entit
 
 	  /* We will output additional debug info manually below.  */
 	  finish_record_type (gnu_type, gnu_field, 2, false);
-	  compute_record_mode (gnu_type);
 	  TYPE_JUSTIFIED_MODULAR_P (gnu_type) = 1;
 
 	  if (debug_info_p)
@@ -7228,6 +7230,28 @@ compare_field_bitpos (const PTR rt1, con
   return ret ? ret : (int) (DECL_UID (field1) - DECL_UID (field2));
 }
 
+/* Sort the LIST of fields in reverse order of increasing position.  */
+
+static tree
+reverse_sort_field_list (tree list)
+{
+  const int len = list_length (list);
+  tree *field_arr = XALLOCAVEC (tree, len);
+
+  for (int i = 0; list; list = DECL_CHAIN (list), i++)
+field_arr[i] = list;
+
+  qsort (field_arr, len, sizeof (tree), compare_field_bitpos);
+
+  for (int i = 0; i < len; i++)
+{
+  DECL_CHAIN (field_arr[i]) = list;
+  list = field_arr[i];
+}
+
+  return list;
+}
+
 /* Reverse function from gnat_to_gnu_field: return the GNAT field present in
either GNAT_COMPONENT_LIST or the discriminants of GNAT_RECORD_TYPE, and
corresponding to the GNU tree GNU_FIELD.  */
@@ -8037,7 +8061,23 @@ components_to_record (Node_Id gnat_compo
 
   /* Chain the variant part at the end of the field list.  */
   if (gnu_variant_part)
-gnu_field_list = chainon (gnu_field_list, gnu_variant_part);
+{
+  /* We make an exception if the variant part is at offset 0, has a fixed
+	 size, and there is a single rep'ed field placed after it because, in
+	 this case, there is an obvious order of increasing position.  */
+  if (variants_have_rep
+	  && TREE_CODE (DECL_SIZE_UNIT (gnu_variant_part)) == INTEGER_CST
+	  && gnu_rep_list
+	  && gnu_field_list == gnu_rep_list
+	  && !tree_int_cst_lt (DECL_FIELD_OFFSET (gnu_rep_list),
+			   DECL_SIZE_UNIT (gnu_variant_part)))
+	{
+	  DECL_CHAIN (gnu_variant_part) = gnu_field_list;
+	  gnu_field_list = gnu_variant_part;
+	}
+  else
+	gnu_field_list = chainon (gnu_field_list, gnu_variant_part);
+}
 
   if (cancel_alignment)
 SET_TYPE_ALIGN (gnu_record_type, 0);
@@ -8527,7 +8567,8 @@ build_variant_list (tree qual_union_type
   if (!integer_zerop (qual))
 	{
 	  tree variant_type = TREE_TYPE (gnu_field), variant_subpart;
-	  variant_desc v = { variant_type, gnu_field, qual, NULL_TREE };
+	  variant_desc v
+	= { variant_type, gnu_field, qual, NULL_TREE, NULL_TREE };
 
 	  gnu_list.safe_push (v);
 
@@ -9301,7 +9342,6 @@ create_variant_part_from (tree old_varia
 
   /* Finish up the new variant and create the field.  */
   finish_record_type (new_variant, nreverse (field_list), 2, debug_info_p);
-  compute_record_mode (new_variant);
   create_type_decl (TYPE_NAME (new_variant), new_variant, true,
 			debug_info_p, Empty);
 
@@ -9319,7 +9359,6 @@ create_variant_part_from (tree old_varia
  reverse the field list because VARIANT_LIST has been traversed in reverse
  order.  */
   finish_record_type (new_union_type, union_field_list, 2, debug_info_p);
-  compute_record_mode (new_union_type);
   create_type_decl (TYPE_NAME (new_union_type), new_union_type, true,
 		debug_info_p, Empty);
 
@@ -9417,7 +9456,8 @@ copy_and_substitute_in_layout (Entity_Id
 {
   const bool is_subtype = (Ekind (gnat_new_type) == 

[Ada] Fix wrong code for initialization of fat pointer with -Og

2018-06-12 Thread Eric Botcazou
This fixes a long-standing issue with the initialization of fat pointer types.
The compiler incorrectly optimizes out the initialization to Null of a 
variable of an access-to-unconstrained-array type, if the variable is declared 
in the same declarative part as the access type and the array type, there is 
no other related declaration between the three aforementioned declarations.

Fixed thusly, tested on x86-64/Linux, applied on mainline, 8 and 7 branches.


2018-06-12  Eric Botcazou  

* gcc-interface/decl.c (gnat_to_gnu_entity) : Reuse the
existing fields of a dummy fat pointer type, if any.  Clear the
TYPE_DECL_SUPPRESS_DEBUG on the fat pointer type after completing it.

-- 
Eric BotcazouIndex: gcc-interface/decl.c
===
--- gcc-interface/decl.c	(revision 261430)
+++ gcc-interface/decl.c	(revision 261431)
@@ -2055,11 +2055,16 @@ gnat_to_gnu_entity (Entity_Id gnat_entit
 	  {
 	gnu_fat_type = TYPE_MAIN_VARIANT (TYPE_POINTER_TO (gnu_type));
 	TYPE_NAME (gnu_fat_type) = NULL_TREE;
-	/* Save the contents of the dummy type for update_pointer_to.  */
-	TYPE_POINTER_TO (gnu_type) = copy_type (gnu_fat_type);
 	gnu_ptr_template =
-	  TREE_TYPE (TREE_CHAIN (TYPE_FIELDS (gnu_fat_type)));
+	  TREE_TYPE (DECL_CHAIN (TYPE_FIELDS (gnu_fat_type)));
 	gnu_template_type = TREE_TYPE (gnu_ptr_template);
+
+	/* Save the contents of the dummy type for update_pointer_to.  */
+	TYPE_POINTER_TO (gnu_type) = copy_type (gnu_fat_type);
+	TYPE_FIELDS (TYPE_POINTER_TO (gnu_type))
+	  = copy_node (TYPE_FIELDS (gnu_fat_type));
+	DECL_CHAIN (TYPE_FIELDS (TYPE_POINTER_TO (gnu_type)))
+	  = copy_node (DECL_CHAIN (TYPE_FIELDS (gnu_fat_type)));
 	  }
 	else
 	  {
@@ -2080,29 +2085,39 @@ gnat_to_gnu_entity (Entity_Id gnat_entit
 
 	/* Build the fat pointer type.  Use a "void *" object instead of
 	   a pointer to the array type since we don't have the array type
-	   yet (it will reference the fat pointer via the bounds).  */
-	tem
-	  = create_field_decl (get_identifier ("P_ARRAY"), ptr_type_node,
-			   gnu_fat_type, NULL_TREE, NULL_TREE, 0, 0);
-	DECL_CHAIN (tem)
-	  = create_field_decl (get_identifier ("P_BOUNDS"), gnu_ptr_template,
-			   gnu_fat_type, NULL_TREE, NULL_TREE, 0, 0);
+	   yet (it will reference the fat pointer via the bounds).  Note
+	   that we reuse the existing fields of a dummy type because for:
+
+	 type Arr is array (Positive range <>) of Element_Type;
+	 type Array_Ref is access Arr;
+	 Var : Array_Ref := Null;
 
+	   in a declarative part, Arr will be frozen only after Var, which
+	   means that the fields used in the CONSTRUCTOR built for Null are
+	   those of the dummy type, which in turn means that COMPONENT_REFs
+	   of Var may be built with these fields.  Now if COMPONENT_REFs of
+	   Var are also built later with the fields of the final type, the
+	   aliasing machinery may consider that the accesses are distinct
+	   if the FIELD_DECLs are distinct as objects.  */
 	if (COMPLETE_TYPE_P (gnu_fat_type))
 	  {
-	/* We are going to lay it out again so reset the alias set.  */
-	alias_set_type alias_set = TYPE_ALIAS_SET (gnu_fat_type);
-	TYPE_ALIAS_SET (gnu_fat_type) = -1;
-	finish_fat_pointer_type (gnu_fat_type, tem);
-	TYPE_ALIAS_SET (gnu_fat_type) = alias_set;
+	tem = TYPE_FIELDS (gnu_fat_type);
+	TREE_TYPE (tem) = ptr_type_node;
+	TREE_TYPE (DECL_CHAIN (tem)) = gnu_ptr_template;
+	TYPE_DECL_SUPPRESS_DEBUG (TYPE_STUB_DECL (gnu_fat_type)) = 0;
 	for (t = gnu_fat_type; t; t = TYPE_NEXT_VARIANT (t))
-	  {
-		TYPE_FIELDS (t) = tem;
-		SET_TYPE_UNCONSTRAINED_ARRAY (t, gnu_type);
-	  }
+	  SET_TYPE_UNCONSTRAINED_ARRAY (t, gnu_type);
 	  }
 	else
 	  {
+	tem
+	  = create_field_decl (get_identifier ("P_ARRAY"),
+   ptr_type_node, gnu_fat_type,
+   NULL_TREE, NULL_TREE, 0, 0);
+	DECL_CHAIN (tem)
+	  = create_field_decl (get_identifier ("P_BOUNDS"),
+   gnu_ptr_template, gnu_fat_type,
+   NULL_TREE, NULL_TREE, 0, 0);
 	finish_fat_pointer_type (gnu_fat_type, tem);
 	SET_TYPE_UNCONSTRAINED_ARRAY (gnu_fat_type, gnu_type);
 	  }


Re: [PATCH] fixincludes: partly repair broken fix for assert.h in vxworks

2018-06-12 Thread Olivier Hainque
Hello Rasmus,

> On 7 Jun 2018, at 11:50, Rasmus Villemoes  wrote:
> 
> 2018-06-07Rasmus Villemoes 
> 
> fixinclude/
> 
>   * inclhack.def: Fix fixup for assert.h on vxworks.
>   * fixincl.x: Regenerate.

Ok by me, thanks.

Olivier



Re: fix libcc1 dependencies in toplevel Makefile

2018-06-12 Thread Olivier Hainque
Hi Alex,

Thanks for your feedback and help looking into this.

> On 12 Jun 2018, at 04:50, Alexandre Oliva  wrote:
> 
> I was missing one possibility: that the problem occurred during the
> post-bootstrap all-host all-target build.  As far as I can tell from
> Nicolas' analysis, this was indeed the case.

Yes, indeed. I intended to convey this in the
opening message of this thread by referring to concurrency
between libcc1 and libquadmath. That was admittedly
too implicit :)


> I still don't see how any
> staging or unstaging might have taken place, but I can now see that we
> do reenter the gcc dir before building all-libcc1.  If that reentering
> rebuilds anything, particularly headers, that may be enough to explain
> the reported symptoms.

Right.

> Now, I do vaguely recall build output within the gcc subdir that
> possibly recreated the gcc/include subtree, which might explain the
> observed errors.

That's consistent at least, as the problem we had was the compilation
of a libquadmath source not finding limits.h.
 
> The good news is that the patch I posted the other day actually
> addresses this problem: the dep on stage_last is not enough to trigger a
> rebuild of gcc, so a post-bootstrap all-host all-target build will not
> reenter the bootstrapped dirs,

Nice :-)

> but that dep does trigger an initial
> build of gcc if one has not gone through bootstrapping yet.
> 
> So I see two possible ways to go from now:
> 
> 1. address the previously-mentioned fragility in the patch I posted, to
> catch all cases of postbootstrap targets and their deps on
> non-postbootstrap targets.
> 
> 2. revamp the bootstrap/non-bootstrap dependencies, using GNU make
> conditionals rather than configure-time enable/disable-bootstrap, so
> that we can have a different set of dependencies while running the
> bootstrap proper, having non-stage dependencies activated by default
> when any of the all-* targets are named in the command line, and also
> when building post-bootstrap all-host all-target.  This might seem to
> bring the problem back, but rather by having the full dependency set,
> we'd avoid the race not by refraining from reentering dirs, but rather
> by having them entered or reentered according to the full dependencies,
> without mixing stage and non-stage dependencies.  I'm not yet sure this
> is actually doable, but it seems to me that if it is, it would be more
> robust than what we have now.

I'm really not familiar enough with the dependencies organization
to provide informed input here.

Maybe a reasonable effort on 1 would be good enough in practice and
we can get to 2 only as a second step if we still observe failures.

Or start with a reasonable effort on 2 to evaluate feasibility and 
get a rough guesstimate of the effort it would take to get there, then
reassess.

For sure, I'm happy to try any patch in our development (!production)
builds and see where this leads.

Thanks again for your help on this!

With Kind Regards,

Olivier





Re: [RFC] Add gcc.dg-selftests/dg-final.exp

2018-06-12 Thread Tom de Vries
On Mon, Jun 11, 2018 at 04:00:39PM -0600, Jeff Law wrote:
> On 05/30/2018 04:41 AM, Tom de Vries wrote:
> > Hi,
> > 
> > this patch tests the error behaviour of dg-final directives when called 
> > with an
> > incorrect number of arguments.
> > 
> > The test is lazy, in that it doesn't bother to pass correct arguments, 
> > assuming
> > that the number of arguments check is done before checking the actual 
> > arguments.
> > 
> > Using the patch, I managed to find a few things that needed to be fixed:
> > - [testsuite] Fix error message in scan-hidden/scan-not-hidden
> >   https://gcc.gnu.org/ml/gcc-patches/2018-05/msg01599.html
> > - [testsuite] Use correct proc names in scanasm.exp
> >   https://gcc.gnu.org/ml/gcc-patches/2018-05/msg01600.html
> > - [testsuite] Fix "too few/many" error messages in scan-*-times procs
> >   https://gcc.gnu.org/ml/gcc-patches/2018-05/msg01601.html
> > 
> > Ok for trunk?

> > Add gcc.dg-selftests/dg-final.exp
> > 
> > 2018-05-30  Tom de Vries  
> > 
> > * gcc.dg-selftests/dg-final.exp: New file.

> OK.

Hi,

I've added two changes before commit.

I've made the PASS/FAIL id minimal (removed the actual args part), which makes
it easier to read:
...
PASS: scan-tree-dump: too many arguments
PASS: scan-tree-dump: too few arguments
PASS: scan-tree-dump-times: too many arguments
PASS: scan-tree-dump-times: too few arguments
...

And I've move the test into a dedicated function
dg_final_directive_check_num_args.

Committed as attached.

Thanks,
- Tom

[testsuite] Add gcc.dg-selftests/dg-final.exp

2018-05-30  Tom de Vries  

* gcc.dg-selftests/dg-final.exp: New file.

---
 gcc/testsuite/gcc.dg-selftests/dg-final.exp | 101 
 1 file changed, 101 insertions(+)

diff --git a/gcc/testsuite/gcc.dg-selftests/dg-final.exp 
b/gcc/testsuite/gcc.dg-selftests/dg-final.exp
new file mode 100644
index 000..6aa0f64db87
--- /dev/null
+++ b/gcc/testsuite/gcc.dg-selftests/dg-final.exp
@@ -0,0 +1,101 @@
+#   Copyright (C) 2018 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
+# .
+
+# Tests that test dejagnu extensions used in gcc testing
+
+load_lib "scantree.exp"
+load_lib "scanrtl.exp"
+load_lib "scanipa.exp"
+load_lib "scanlang.exp"
+load_lib "lto.exp"
+load_lib "scanasm.exp"
+load_lib "scanwpaipa.exp"
+load_lib "scanltranstree.exp"
+load_lib "scanoffloadtree.exp"
+
+proc dg_final_directive_check_num_args {} {
+proc verify_call { args } {
+   set call_name [lindex $args 0]
+   set call_args [lindex $args 1]
+   set expected_error [lindex $args 2]
+
+   set errMsg ""
+   catch {
+   eval $call_name $call_args
+   } errMsg
+
+   if { "$errMsg" != "$call_name: $expected_error" } {
+   send_log "For call $call_name $call_args\n"
+   send_log "expected: $call_name: $expected_error\n"
+   send_log "but got: $errMsg\n"
+   fail "$call_name: $expected_error"
+   return
+   } else {
+   pass "$call_name: $expected_error"  
+   }
+}
+
+proc verify_args { args } {
+   set proc_name [lindex $args 0]
+   set min [lindex $args 1]
+   set max [lindex $args 2]
+   set too_many [list]
+   set too_few [list]
+   for {set i 0} {$i < $min - 1}  {incr i} {
+   lappend too_few $i
+   }
+   for {set i 0} {$i < $max + 1}  {incr i} {
+   lappend too_many $i
+   }
+   verify_call $proc_name $too_many "too many arguments"
+   verify_call $proc_name $too_few "too few arguments"
+}
+
+foreach kind [list "tree" "rtl" "ipa" "ltrans-tree" "wpa-ipa" 
"offload-tree"] {
+   verify_args scan-$kind-dump 2 3
+   verify_args scan-$kind-dump-times 3 4
+   verify_args scan-$kind-dump-not 2 3
+   verify_args scan-$kind-dump-dem 2 3
+   verify_args scan-$kind-dump-dem-not 2 3
+}
+
+verify_args scan-lang-dump 2 3
+
+verify_args object-readelf 2 3
+
+verify_args scan-assembler-times 2 3
+verify_args scan-assembler-dem 1 2
+verify_args scan-assembler-dem-not 1 2
+
+verify_args object-size 3 4
+
+global testname_with_flags
+set testname_with_flags "test.c"
+verify_args scan-assembler 1 2
+verify_args scan-assembler-not 1 2
+verify_args scan-hidden 1 2
+verify_args scan-not-hidden 1 2
+verify_args scan-file 2 3
+

Re: [MAINTAINERS, committed] Remove redundant write-after-approval entries

2018-06-12 Thread Martin Liška
Hi.

Thanks for the script, it also found me in Write After Approval section.
Thus I'll install following patch.

Tom what about installing the script into contrib?

Martin
>From ae02963208cf24d7b0df133507a89f776b3c4599 Mon Sep 17 00:00:00 2001
From: marxin 
Date: Tue, 12 Jun 2018 10:24:17 +0200
Subject: [PATCH] Remove me from Write After Approval.

---
 MAINTAINERS | 1 -
 1 file changed, 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 62f74a8d74e..928f5cb37ae 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -467,7 +467,6 @@ Kriang Lerdsuwanakij
 Renlin Li	
 Xinliang David Li
 Chen Liqin	
-Martin Liska	
 Jiangning Liu	
 Sa Liu		
 Ralph Loader	
-- 
2.17.1



Re: [PATCH] libitm/x86: Correct offsets of __private_tm and pointer_guard

2018-06-12 Thread Torvald Riegel
On Wed, 2018-05-30 at 07:54 -0700, H.J. Lu wrote:
> In glibc, sysdeps/i386/nptl/tls.h has
> 
> typedef struct
> {
>   void *tcb;/* Pointer to the TCB.  Not necessarily the
>thread descriptor used by libpthread.  */
>   dtv_t *dtv;
>   void *self;   /* Pointer to the thread descriptor.  */
>   int multiple_threads;
>   uintptr_t sysinfo;
>   uintptr_t stack_guard;
>   uintptr_t pointer_guard;
>   int gscope_flag;
>   int __glibc_reserved1;
>   /* Reservation of some values for the TM ABI.  */
>   void *__private_tm[4];
>   /* GCC split stack support.  */
>   void *__private_ss;
> } tcbhead_t;
> 
> and sysdeps/x86_64/nptl/tls.h has
> 
> typedef struct
> {
>   void *tcb;/* Pointer to the TCB.  Not necessarily the
>thread descriptor used by libpthread.  */
>   dtv_t *dtv;
>   void *self;   /* Pointer to the thread descriptor.  */
>   int multiple_threads;
>   int gscope_flag;
>   uintptr_t sysinfo;
>   uintptr_t stack_guard;
>   uintptr_t pointer_guard;
>   unsigned long int vgetcpu_cache[2];
>   int __glibc_reserved1;
>   int __glibc_unused1;
>   /* Reservation of some values for the TM ABI.  */
>   void *__private_tm[4];
>   /* GCC split stack support.  */
>   void *__private_ss;
>   long int __glibc_reserved2;
>   /* Must be kept even if it is no longer used by glibc since programs,
>  like AddressSanitizer, depend on the size of tcbhead_t.  */
>   __128bits __glibc_unused2[8][4] __attribute__ ((aligned (32)));
> 
>   void *__padding[8];
> } tcbhead_t;
> 
> The offsets of __private_tm are
> 
> i386:   36 bytes
> x32:48 bytes
> x86_64: 80 bytes
> 
> and the offsets of pointer_guard are:
> 
> i386:   24 bytes
> x32:28 bytes
> x86_64: 48 bytes
> 
> Update SEG_READ and SEG_WRITE to use the offset of __private_tm as base
> and correct the offset of pointer_guard for x32.
> 
> Tested on i686, x86-64 and x32.  OK for trunk and release branches?

The patch itself looks okay to me, but the commit message is pretty
cryptic.  I can't ack for release branches.




[C++ Patch] Fix coerce_new_type and coerce_delete_type locations

2018-06-12 Thread Paolo Carlini

Hi,

yesterday I didn't notice that grok_op_properties calls a couple of 
helpers which are affected by exactly the same location issues. The 
below simply forwards the location to the helpers. Tested x86_64-linux.


Thanks, Paolo.



/cp
2018-06-12  Paolo Carlini  

* decl2.c (coerce_new_type, coerce_delete_type): Add location_t
parameter and adjust error_at calls.
* decl.c (grok_op_properties): Adjust calls.
* cp-tree.h (oerce_new_type, coerce_delete_type): Adjust decls.

/testsuite
2018-06-12  Paolo Carlini  

* g++.dg/init/delete3.C: New.
* g++.dg/init/new49.C: Likewise.
* g++.dg/init/new25.C: Test locations too.
* g++.dg/template/new4.C: Likewise.
* g++.old-deja/g++.jason/operator.C: Likewise.
Index: cp/cp-tree.h
===
--- cp/cp-tree.h(revision 261457)
+++ cp/cp-tree.h(working copy)
@@ -6346,8 +6346,8 @@ extern bool attributes_naming_typedef_ok  (tree);
 extern void cplus_decl_attributes  (tree *, tree, int);
 extern void finish_anon_union  (tree);
 extern void cxx_post_compilation_parsing_cleanups (void);
-extern tree coerce_new_type(tree);
-extern tree coerce_delete_type (tree);
+extern tree coerce_new_type(tree, location_t);
+extern tree coerce_delete_type (tree, location_t);
 extern void comdat_linkage (tree);
 extern void determine_visibility   (tree);
 extern void constrain_class_visibility (tree);
Index: cp/decl.c
===
--- cp/decl.c   (revision 261457)
+++ cp/decl.c   (working copy)
@@ -13153,11 +13153,11 @@ grok_op_properties (tree decl, bool complain)
}
 
   if (op_flags & OVL_OP_FLAG_DELETE)
-   TREE_TYPE (decl) = coerce_delete_type (TREE_TYPE (decl));
+   TREE_TYPE (decl) = coerce_delete_type (TREE_TYPE (decl), loc);
   else
{
  DECL_IS_OPERATOR_NEW (decl) = 1;
- TREE_TYPE (decl) = coerce_new_type (TREE_TYPE (decl));
+ TREE_TYPE (decl) = coerce_new_type (TREE_TYPE (decl), loc);
}
 
   return true;
Index: cp/decl2.c
===
--- cp/decl2.c  (revision 261457)
+++ cp/decl2.c  (working copy)
@@ -1676,7 +1676,7 @@ finish_anon_union (tree anon_union_decl)
what compiler will be expecting.  */
 
 tree
-coerce_new_type (tree type)
+coerce_new_type (tree type, location_t loc)
 {
   int e = 0;
   tree args = TYPE_ARG_TYPES (type);
@@ -1686,7 +1686,8 @@ tree
   if (!same_type_p (TREE_TYPE (type), ptr_type_node))
 {
   e = 1;
-  error ("% must return type %qT", ptr_type_node);
+  error_at (loc, "% must return type %qT",
+   ptr_type_node);
 }
 
   if (args && args != void_list_node)
@@ -1697,8 +1698,8 @@ tree
 
 The first parameter shall not have an associated default
 argument.  */
- error ("the first parameter of % cannot "
-"have a default argument");
+ error_at (loc, "the first parameter of % cannot "
+   "have a default argument");
  /* Throw away the default argument.  */
  TREE_PURPOSE (args) = NULL_TREE;
}
@@ -1713,7 +1714,7 @@ tree
 e = 2;
 
   if (e == 2)
-permerror (input_location, "% takes type % (%qT) "
+permerror (loc, "% takes type % (%qT) "
   "as first parameter", size_type_node);
 
   switch (e)
@@ -1732,7 +1733,7 @@ tree
 }
 
 tree
-coerce_delete_type (tree type)
+coerce_delete_type (tree type, location_t loc)
 {
   int e = 0;
   tree args = TYPE_ARG_TYPES (type);
@@ -1742,7 +1743,8 @@ tree
   if (!same_type_p (TREE_TYPE (type), void_type_node))
 {
   e = 1;
-  error ("% must return type %qT", void_type_node);
+  error_at (loc, "% must return type %qT",
+   void_type_node);
 }
 
   if (!args || args == void_list_node
@@ -1751,8 +1753,8 @@ tree
   e = 2;
   if (args && args != void_list_node)
args = TREE_CHAIN (args);
-  error ("% takes type %qT as first parameter",
-ptr_type_node);
+  error_at (loc, "% takes type %qT as first parameter",
+   ptr_type_node);
 }
   switch (e)
   {
Index: testsuite/g++.dg/init/delete3.C
===
--- testsuite/g++.dg/init/delete3.C (nonexistent)
+++ testsuite/g++.dg/init/delete3.C (working copy)
@@ -0,0 +1 @@
+int operator delete (void*, int);  // { dg-error "5:.operator delete. must 
return type .void." }
Index: testsuite/g++.dg/init/new25.C
===
--- testsuite/g++.dg/init/new25.C   (revision 261457)
+++ testsuite/g++.dg/init/new25.C   (working copy)
@@ -4,14 +4,14 @@
 class C