Re: [PATCH 8/8] Add a common .md file and define standard constraints there

2014-06-14 Thread Richard Sandiford
Steve Ellcey  writes:
> Richard,
>
> Something in these constraint patches broke my mips16 build (I cannot
> build glibc in mips16 mode).  I have cut down a test case and verified
> that the problem started with this checkin:
>
> 2014-06-11  Richard Sandiford  
>
>   * common.md: New file.
>   * doc/md.texi: Update description of generic, machine-independent
>   constraints.
>   * config/s390/constraints.md (e): Delete.
>   * Makefile.in (md_file): Include common.md.
>   * config/m32c/t-m32c (md_file): Likewise.
>   * genpreds.c (general_mem): New array.
>   (etc)
>
> Attached is a small test case (its ugly but it comes from vfscanf in glibc) 
> that
> fails to compile for me with these options:
>
>   -mips32r2 -mips16 -mabi=32 -std=gnu99 -fgnu89-inline -O2 -c x.c
>
> Error message:
>
> /tmp/ccAltddb.s: Assembler messages:
> /tmp/ccAltddb.s:23: Error: invalid operands `sb $3,24($sp)'

The problem here is that mips_regno_mode_ok_for_base_p allows invalid
hard registers as bases if !strict_p.  It was always a bit of a hack
and the reason it was added no longer applies.  Robert's LRA patch
already included a fix, so maybe we should just apply that part now.

The patch below fixes the testcase.  Please could you give it a spin
and see whether there's any other fallout?  I assume this would have
shown up in a testsuite run if you'd been able to get that far.

Thanks,
Richard


2014-03-26  Robert Suchanek  

* config/mips/mips.c (mips_regno_mode_ok_for_base_p): Remove use
!strict_p for MIPS16.

diff --git gcc/config/mips/mips.c gcc/config/mips/mips.c
index 45256e9..81b6c26 100644
--- gcc/config/mips/mips.c
+++ gcc/config/mips/mips.c
@@ -2241,22 +2241,9 @@ mips_regno_mode_ok_for_base_p (int regno, enum 
machine_mode mode,
 return true;
 
   /* In MIPS16 mode, the stack pointer can only address word and doubleword
- values, nothing smaller.  There are two problems here:
-
-   (a) Instantiating virtual registers can introduce new uses of the
-  stack pointer.  If these virtual registers are valid addresses,
-  the stack pointer should be too.
-
-   (b) Most uses of the stack pointer are not made explicit until
-  FRAME_POINTER_REGNUM and ARG_POINTER_REGNUM have been eliminated.
-  We don't know until that stage whether we'll be eliminating to the
-  stack pointer (which needs the restriction) or the hard frame
-  pointer (which doesn't).
-
- All in all, it seems more consistent to only enforce this restriction
- during and after reload.  */
+ values, nothing smaller.  */
   if (TARGET_MIPS16 && regno == STACK_POINTER_REGNUM)
-return !strict_p || GET_MODE_SIZE (mode) == 4 || GET_MODE_SIZE (mode) == 8;
+return GET_MODE_SIZE (mode) == 4 || GET_MODE_SIZE (mode) == 8;
 
   return TARGET_MIPS16 ? M16_REG_P (regno) : GP_REG_P (regno);
 }
l


Re: RFA: speeding up dg-extract-results.sh

2014-06-14 Thread Richard Sandiford
Bernd Schmidt  writes:
> On 05/25/2014 11:35 AM, Richard Sandiford wrote:
>> Bernd Schmidt  writes:
>>> On 02/13/2014 10:18 AM, Richard Sandiford wrote:
 contrib/
* dg-extract-results.py: New file.
* dg-extract-results.sh: Use it if the environment seems suitable.
>>>
>>> I'm now seeing the following:
>>>
>>> Traceback (most recent call last):
>>> File "../../git/gcc/../contrib/dg-extract-results.py", line 581, in
>>> 
>>>   Prog().main()
>>> File "../../git/gcc/../contrib/dg-extract-results.py", line 569, in main
>>>   self.output_tool (self.runs[name])
>>> File "../../git/gcc/../contrib/dg-extract-results.py", line 534, in
>>> output_tool
>>>   self.output_variation (tool, variation)
>>> File "../../git/gcc/../contrib/dg-extract-results.py", line 483, in
>>> output_variation
>>>   for harness in sorted (variation.harnesses.values()):
>>> TypeError: unorderable types: HarnessRun() < HarnessRun()
>>>
>>> $ /usr/bin/python --version
>>> Python 3.3.3
>>
>> Sorry, thought I'd tested it with python3, but obviously not.
>> I've applied the fix below after testing that it didn't change the
>> output for python 2.6 and python 2.7.
>
> I've recently been trying to add ada to my set of tested languages, and 
> I now encounter the following:
>
> Traceback (most recent call last):
>File "../../git/gcc/../contrib/dg-extract-results.py", line 580, in 
> 
>  Prog().main()
>File "../../git/gcc/../contrib/dg-extract-results.py", line 544, in main
>  self.parse_file (filename, file)
>File "../../git/gcc/../contrib/dg-extract-results.py", line 427, in 
> parse_file
>  self.parse_acats_run (filename, file)
>File "../../git/gcc/../contrib/dg-extract-results.py", line 342, in 
> parse_acats_run
>  self.parse_run (filename, file, tool, variation, 1)
>File "../../git/gcc/../contrib/dg-extract-results.py", line 242, in 
> parse_run
>  line = file.readline()
>File "/usr/lib64/python3.3/codecs.py", line 301, in decode
>  (result, consumed) = self._buffer_decode(data, self.errors, final)
> UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe1 in position 
> 5227: invalid continuation byte

Bah.  I'm seriously beginning to regret choosing Python for this.
Getting code to work with both Python 2 and Python 3 is like the bad
old days of getting stuff to work with both K&R and ANSI C.

I see the weird character is coming from C250002, which is specifically
testing that some arbitrary byte above 127 can be used in identifier names.
The actual choice of byte or its meaning in the locale encoding doesn't
seem to be relevant.

I committed the fix below after checking it against an Ada log for
both python2 and python3.

Thanks,
Richard


contrib/
* dg-extract-results.py: For Python 3, force sys.stdout to handle
surrogate escape sequences.
(safe_open): New function.
(output_segment, main): Use it.

Index: contrib/dg-extract-results.py
===
--- contrib/dg-extract-results.py   2014-06-14 10:17:41.698438403 +0100
+++ contrib/dg-extract-results.py   2014-06-14 10:45:12.586546139 +0100
@@ -10,6 +10,7 @@
 import sys
 import getopt
 import re
+import io
 from datetime import datetime
 from operator import attrgetter
 
@@ -21,6 +22,18 @@ strict = False
 # they should keep the original order.
 sort_logs = True
 
+# A version of open() that is safe against whatever binary output
+# might be added to the log.
+def safe_open (self, filename):
+if sys.version_info >= (3, 0):
+return open (filename, 'r', errors = 'surrogateescape')
+return open (filename, 'r')
+
+# Force stdout to handle escape sequences from a safe_open file.
+if sys.version_info >= (3, 0):
+sys.stdout = io.TextIOWrapper (sys.stdout.buffer,
+   errors = 'surrogateescape')
+
 class Named:
 def __init__ (self, name):
 self.name = name
@@ -457,7 +470,7 @@ class Prog:
 
 # Output a segment of text.
 def output_segment (self, segment):
-with open (segment.filename, 'r') as file:
+with safe_open (segment.filename) as file:
 file.seek (segment.start)
 for i in range (segment.lines):
 sys.stdout.write (file.readline())
@@ -540,7 +553,7 @@ class Prog:
 try:
 # Parse the input files.
 for filename in self.files:
-with open (filename, 'r') as file:
+with safe_open (filename) as file:
 self.parse_file (filename, file)
 
 # Decide what to output.


Re: [PATCH 8/8] Add a common .md file and define standard constraints there

2014-06-14 Thread Richard Sandiford
Segher Boessenkool  writes:
>> > * cris, m68k, pdp11, and vax actually use "g".
>> > 
>> > So it won't be all that much work to completely get rid of "g".
>> > Do we want that?
>> 
>> Is it simply a matter of replacing “g” by “mri”?  That’s what the doc
>> suggests.  Or is there more to the story than that?
>
> As far as I know "g" and "rmi" are equivalent, yes.  "g" is easier to
> type and read if you use it a lot (only ancient targets really); the
> compiler will probably become somewhat slower for those targets, and
> perhaps somewhat faster for all others.  Hard to say without doing the
> work and measuring the result :-)

FWIW, I had a follow-on patch that created the recog_op_alt data at
build time and made the constraints field of that structure point to
CONSTRAINT_* bytes rather than raw strings.  That involved converting
"g" to "rmi" like you say and also meant adding CONSTRAINT_*s for "#"
and "?".  (Other non-operand characters can be dropped since the information
is given directly in the recog_op_alt.)

It didn't really seem to be much of a win though.

Richard


[Ada] PR ada/61505

2014-06-14 Thread Bernd Edlinger
Hi,

this should fix the current makeinfo build-problems with gnat_rm.texi.

The main problem seems to be, that
@item is not working inside @cartouche
so I moved all @items up by 3 lines.

Then the System.Task_Info (s-tasinf.ads) needs to be
in the menu.

While editing, I saw the following:

Initially there were two paragraphs *53*

one about "The semantics of operations on invalid representations."

and one about "The manner of choosing a storage pool for an access type"

And the latter was referenced from two other paragraphs:

"See documentation in the sources of the run time mentioned in paragraph
@strong{53}"


I am not sure how to handle that without paragraph numbers,
maybe like this:

"See documentation in the sources of the run time mentioned in the previous
paragraph."

2014-06-14  Bernd Edlinger  

PR ada/61505
* gnat_rm.texi: Fix errors with makeinfo 5.1.

Thanks
Bernd.
  

patch-gnat.diff
Description: Binary data


Re: [PATCH,MIPS] MIPS64r6 support

2014-06-14 Thread Richard Sandiford
Sorry for the slow review.

Matthew Fortune  writes:
> The initial support for MIP64r6 is intentionally minimal to make review
> easier. Performance enhancements and use of new MIPS64r6 features will
> be introduced separately. The current patch makes no attempt to
> get the testsuite appropriately configured for MIPS64r6 as the existing
> structure relies on each MIPS revision being a superset of the previous.
> Recommendations on how to rework the mips.exp logic to cope with this
> would be appreciated.

Could you give an example of the kind of thing you mean?

If tests really do need r5 or earlier, we should enforce that in the
dg-options.  E.g. for conditional moves we should add an isa_rev
limit to the existing tests and add new ones with isa_rev>=6.

I suppose we'll need a way of specifying an isa_rev range, say
"isa_rev=2-5".  That should be a fairly localised change though.

The:

# Handle dependencies between the pre-arch options and the arch option.
# This should mirror the arch and post-arch code below.
if { !$arch_test_option_p } {

block should start with something like:

if (isa_rev >= 6
&& ...tests for things r6 doesn't support..) {
if { $gp_size == 32 } {
mips_make_test_option options "-mips32r2"
} else {
mips_make_test_option options "-mips64r2"
}

And:

if { $arch_test_option_p } {

should have a corresponding:

if { $isa_rev > 5 } {
...force options that r6 doesn't support to off...
}

before the unsets.

> diff --git a/gcc/config/mips/constraints.md b/gcc/config/mips/constraints.md
> index f6834fd..f93ae1c 100644
> --- a/gcc/config/mips/constraints.md
> +++ b/gcc/config/mips/constraints.md
> @@ -324,10 +324,14 @@ (define_address_constraint "ZD"
>"When compiling microMIPS code, this constraint matches an address operand
> that is formed from a base register and a 12-bit offset.  These operands
> can be used for microMIPS instructions such as @code{prefetch}.  When
> -   not compiling for microMIPS code, @code{ZD} is equivalent to @code{p}."
> +   not compiling for microMIPS code, @code{ZD} is either equivalent to
> +   @code{p} or matches an address operand that is formed from a base register
> +   and a 9-bit offset, depending on ISA support."

Maybe just change the comment to:

  "An address suitable for a @code{prefetch} instruction, or for any other
instruction with the same addressing mode as @code{prefetch}."

perhaps going on to say what the microMIPS, r6 and other cases are,
if you think that's better.

You need to update md.texi too; it isn't "yet" automatic.

> (if_then_else (match_test "TARGET_MICROMIPS")
>(match_test "umips_12bit_offset_address_p (op, mode)")
> -  (match_test "mips_address_insns (op, mode, false)")))
> +  (if_then_else (match_test "ISA_HAS_PREFETCH_9BIT")
> + (match_test "mipsr6_9bit_offset_address_p (op, mode)")
> + (match_test "mips_address_insns (op, mode, false)"

Please use (cond ...) instead.

> diff --git a/gcc/config/mips/linux.h b/gcc/config/mips/linux.h
> index e539422..751623f 100644
> --- a/gcc/config/mips/linux.h
> +++ b/gcc/config/mips/linux.h
> @@ -18,8 +18,9 @@ along with GCC; see the file COPYING3.  If not see
>  .  */
>  
>  #define GLIBC_DYNAMIC_LINKER \
> -  "%{mnan=2008:/lib/ld-linux-mipsn8.so.1;:/lib/ld.so.1}"
> +  "%{mnan=2008|mips32r6|mips64r6:/lib/ld-linux-mipsn8.so.1;:/lib/ld.so.1}"
>  
>  #undef UCLIBC_DYNAMIC_LINKER
>  #define UCLIBC_DYNAMIC_LINKER \
> -  "%{mnan=2008:/lib/ld-uClibc-mipsn8.so.0;:/lib/ld-uClibc.so.0}"
> +  "%{mnan=2008|mips32r6|mips64r6:/lib/ld-uClibc-mipsn8.so.0;" \
> +  ":/lib/ld-uClibc.so.0}"

Rather than update all the specs like this, I think we should force
-mnan=2008 onto the command line for r6 using DRIVER_SELF_SPECS.
See e.g. MIPS_ISA_SYNCI_SPEC.

> diff --git a/gcc/config/mips/mips-protos.h b/gcc/config/mips/mips-protos.h
> index 0b32a70..9560506 100644
> --- a/gcc/config/mips/mips-protos.h
> +++ b/gcc/config/mips/mips-protos.h
> @@ -341,6 +341,7 @@ extern bool umips_load_store_pair_p (bool, rtx *);
>  extern void umips_output_load_store_pair (bool, rtx *);
>  extern bool umips_movep_target_p (rtx, rtx);
>  extern bool umips_12bit_offset_address_p (rtx, enum machine_mode);
> +extern bool mipsr6_9bit_offset_address_p (rtx, enum machine_mode);

Would prefer just mips_9bit..., since a 9-bit offset looks the same
for all ISA levels.   I suppose it should have been just mips_12bit... too.

Same for MIPSR6_9BIT_OFFSET_P.

> @@ -4186,6 +4230,46 @@ mips_rtx_costs (rtx x, int code, int outer_code, int 
> opno ATTRIBUTE_UNUSED,
>   }
>*total = mips_zero_extend_cost (mode, XEXP (x, 0));
>return false;
> +case TRUNCATE:
> +  /* Costings for highpart multiplies.  */
> +  if (ISA_HAS_R6MUL
> +   && (GET_CODE (XEXP (x, 

Re: [Ada] PR ada/61505

2014-06-14 Thread Arnaud Charlet
> 2014-06-14  Bernd Edlinger  
> 
> PR ada/61505
> * gnat_rm.texi: Fix errors with makeinfo 5.1.

This looks good, except that there's a last change needed (at least according
to older versions of makeinfo), now detected:

--- gnat_rm.texi(revision 211665)
+++ gnat_rm.texi(working copy)
@@ -18268,7 +18268,6 @@
 * System.Restrictions (s-restri.ads)::
 * System.Rident (s-rident.ads)::
 * System.Strings.Stream_Ops (s-ststop.ads)::
-* System.Task_Info (s-tasinf.ads)::
 * System.Unsigned_Types (s-unstyp.ads)::
 * System.Wch_Cnv (s-wchcnv.ads)::
 * System.Wch_Con (s-wchcon.ads)::

OK with the above additional change, thanks.


Re: [PATCH][RFC] Make FRE/PRE apply copy/constant propagation

2014-06-14 Thread Eric Botcazou
> 2014-06-13  Richard Biener  
> 
>   * tree-ssa-pre.c (eliminate_dom_walker::before_dom_children):
>   Rewrite to propagate the VN result into all uses where
>   possible and to remove stmts becoming dead because of that.
>   (eliminate): Generalize stmt removal handling, remove in
>   reverse dominator order to support proper debug stmt
>   generation.  Update stmts before removing stmts.
>   * tree-ssa-propagate.c (propagate_tree_value): Remove
>   bogus assert.

This breaks Ada bootstrap with non-standard build options (-gnatpgn).  I have 
attached a reduced testcase, but you need the Ada SJLJ scheme to see it so the 
following procedure can be used:

 1. Put p.ad[bs] in $(BUILDDIR)
 2. Do "gcc/gnat1 -quiet p.adb -I $(SRCDIR)/gcc/ada -I gcc/ada -O2 -gnatn"

eric@polaris:~/build/gcc/native> gcc/gnat1 -quiet p.adb -I ~/svn/gcc/gcc/ada -
I gcc/ada -O2 -gnatn
+===GNAT BUG DETECTED==+
| 4.10.0 20140614 (experimental) [trunk revision 211664] (x86_64-suse-linux) 
GCC error:|
| in forward_edge_to_pdom, at tree-ssa-dce.c:1042  |
| Error detected around /home/eric/svn/gcc/gcc/ada/sinfo.adb:6010:8|

-- 
Eric Botcazouwith Atree;use Atree;
with Einfo;use Einfo;
with Elists;   use Elists;
with Exp_Ch6;  use Exp_Ch6;
with Nmake;use Nmake;
with Opt;  use Opt;
with Rtsfind;  use Rtsfind;
with Sem_Aux;  use Sem_Aux;
with Sinfo;use Sinfo;
with Tbuild;   use Tbuild;

package body P is

   procedure Expand_Allocator_Expression (N : Node_Id) is
  Loc: constant Source_Ptr := Sloc (N);
  Exp: constant Node_Id:= Expression (Expression (N));

  procedure Apply_Accessibility_Check (Ref : Node_Id) is
  begin
 null;
  end Apply_Accessibility_Check;

  Indic : constant Node_Id   := Subtype_Mark (Expression (N));
  T : constant Entity_Id := Entity (Indic);
  Tag_Assign: Node_Id;
  Temp  : Entity_Id;
  TagT : Entity_Id := Empty;
  TagR : Node_Id := Empty;

   begin

  if Ada_Version >= Ada_2012 and then Nkind (Exp) = N_Function_Call then
 declare
Subp : Entity_Id;
 begin
if Nkind (Name (Exp)) = N_Explicit_Dereference then
   Subp := Designated_Type (Etype (Prefix (Name (Exp;
else
   Subp := Entity (Name (Exp));
end if;
 end;
  end if;

  if Is_Tagged_Type (T) then

 if Ada_Version >= Ada_2005 then
Make_Build_In_Place_Call_In_Allocator (N, Exp);
Apply_Accessibility_Check (N);
return;
 end if;

 Temp := Make_Temporary (Loc, 'P', N);

 if Is_Private_Type (T)
   and then Is_Tagged_Type (Underlying_Type (T))
 then
TagT := Underlying_Type (T);
TagR :=
  Unchecked_Convert_To (Underlying_Type (T),
Make_Explicit_Dereference (Loc,
  Prefix => New_Occurrence_Of (Temp, Loc)));
 end if;

 if Present (TagT) then
declare
   Full_T : constant Entity_Id := Underlying_Type (TagT);
begin
   Tag_Assign :=
 Make_Assignment_Statement (Loc,
   Name   =>
 Make_Selected_Component (Loc,
   Prefix=> TagR,
   Selector_Name =>
 New_Occurrence_Of
   (First_Tag_Component (Full_T), Loc)),

   Expression =>
 Unchecked_Convert_To (RTE (RE_Tag),
   New_Occurrence_Of
 (Elists.Node
   (First_Elmt (Access_Disp_Table (Full_T))), Loc)));
end;
 end if;

  end if;

   exception
  when RE_Not_Available => return;
   end;

end P;with Types; use Types;

package P is

   procedure Expand_Allocator_Expression (N : Node_Id);

end P;

Re: [patch] implement std::experimental::any

2014-06-14 Thread Jonathan Wakely

On 10/06/14 14:44 +0100, Jonathan Wakely wrote:

This patch implements std::experimental::any from the Fundamentals TS,
including small-object optimisation, uses-allocator construction and
partial support for -fno-rtti (I should probably disable the
allocator-extended constructors when RTTI is disabled, or any_cast
doesn't work).

The allocator-extended copy constructor is not implemented, I don't
think it's possible!

It could probably do with some more tests before I commit it, but
posting for comments as I've had it sitting in my tree for some time
and I might as well share it.


Here's what I'm committing, with more tests, improved -fno-rtti
handling and complete Doxygen comments (which are currently useless
because doc/doxygen/user.cfg.in defines __cplusplus to 2001103L so we
don't generate docs for any C++14 or TS components).

Tested x86_64-linux, committed to trunk.

commit db17f8703215b90918a663257792b3b66381bb5c
Author: Jonathan Wakely 
Date:   Thu Feb 20 20:22:42 2014 +

	* doc/xml/manual/status_cxx2014.xml: Update Fundamentals TS status.
	* include/Makefile.am: Add new header.
	* include/Makefile.in: Regenerate.
	* include/experimental/any: New.
	* include/ext/aligned_buffer.h (__aligned_buffer(nullptr_t)): New
	constructor.
	* testsuite/experimental/any/assign/1.cc: New.
	* testsuite/experimental/any/assign/2.cc: New.
	* testsuite/experimental/any/cons/1.cc: New.
	* testsuite/experimental/any/cons/2.cc: New.
	* testsuite/experimental/any/cons/3.cc: New.
	* testsuite/experimental/any/misc/any_cast.cc: New.
	* testsuite/experimental/any/misc/any_cast_neg.cc: New.
	* testsuite/experimental/any/misc/any_cast_no_rtti.cc: New.
	* testsuite/experimental/any/misc/swap.cc: New.
	* testsuite/experimental/any/modifiers/1.cc: New.
	* testsuite/experimental/any/observers/type.cc: New.

diff --git a/libstdc++-v3/doc/xml/manual/status_cxx2014.xml b/libstdc++-v3/doc/xml/manual/status_cxx2014.xml
index c6f89c9..82abd88 100644
--- a/libstdc++-v3/doc/xml/manual/status_cxx2014.xml
+++ b/libstdc++-v3/doc/xml/manual/status_cxx2014.xml
@@ -306,14 +306,13 @@ not in any particular release.
 
 
 
-  
   
 	http://www.w3.org/1999/xlink"; xlink:href="http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2013/n3804.html";>
 	  N3804
 	
   
   Any library proposal
-  N
+  Y
   Library Fundamentals TS
 
 
diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am
index a079ff6..8fe82da 100644
--- a/libstdc++-v3/include/Makefile.am
+++ b/libstdc++-v3/include/Makefile.am
@@ -638,6 +638,7 @@ decimal_headers = \
 experimental_srcdir = ${glibcxx_srcdir}/include/experimental
 experimental_builddir = ./experimental
 experimental_headers = \
+	${experimental_srcdir}/any \
 	${experimental_srcdir}/optional \
 	${experimental_srcdir}/string_view \
 	${experimental_srcdir}/string_view.tcc
diff --git a/libstdc++-v3/include/experimental/any b/libstdc++-v3/include/experimental/any
new file mode 100644
index 000..2839af1
--- /dev/null
+++ b/libstdc++-v3/include/experimental/any
@@ -0,0 +1,626 @@
+//  -*- C++ -*-
+
+// Copyright (C) 2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+// .
+
+/** @file experimental/any
+ *  This is a TS C++ Library header.
+ */
+
+#ifndef _GLIBCXX_EXPERIMENTAL_ANY
+#define _GLIBCXX_EXPERIMENTAL_ANY 1
+
+#pragma GCC system_header
+
+#if __cplusplus <= 201103L
+# include 
+#else
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+namespace experimental
+{
+inline namespace any_v1
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+  /**
+   * @defgroup any Type-safe container of any type
+   * @ingroup experimental
+   *
+   * A type-safe container for single values of value types, as
+   * described in n3804 "Any Library Proposal (Revision 3)".
+   *
+   * @{
+   */
+
+  /**
+   *  @brief Exception class thrown by a failed @c any_cast
+   *  @ingroup

[patch] Fix doxygen warnings

2014-06-14 Thread Jonathan Wakely

Ensure parameter names and doxygen comments match, document missing
parameters, fix markup etc.

Tested x86_64-linux, committed to trunk.

The C++14 headers added to the .cfg file won't produce any output
until we bump the value of __cplusplus Doxygen uses. I suppose we
should really document classes and functions to say if they're only
available since C++11 or C++14, but can anyone think of any other
reason not to default to generating docs for C++14?
commit cba91b68bd2eb7afb2ee8f7ba7d0047f7f0474e9
Author: Jonathan Wakely 
Date:   Sat Jun 14 17:18:21 2014 +0100

	* doc/doxygen/user.cfg.in (INPUT): Add C++14 headers.
	* include/bits/random.h (subtract_with_carry_engine): Fix Doxygen
	warnings.
	* include/bits/shared_ptr.h (shared_ptr): Likewise.
	* include/bits/unordered_map.h (unordered_map, unordered_multimap):
	Likewise.
	* include/bits/unordered_set.h (unordered_set, unordered_multiset):
	Likewise.
	* include/parallel/list_partition.h (__parallel::list_partition):
	Likewise.
	* include/std/iomanip (quoted): Likewise.
	* include/tr2/dynamic_bitset (dynamic_bitset): Likewise.

diff --git a/libstdc++-v3/doc/doxygen/user.cfg.in b/libstdc++-v3/doc/doxygen/user.cfg.in
index 26395d6..7ec91a1 100644
--- a/libstdc++-v3/doc/doxygen/user.cfg.in
+++ b/libstdc++-v3/doc/doxygen/user.cfg.in
@@ -783,6 +783,7 @@ INPUT  = @srcdir@/doc/doxygen/doxygroups.cc \
  include/regex \
  include/scoped_allocator \
  include/set \
+ include/shared_mutex \
  include/sstream \
  include/stack \
  include/stdexcept \
@@ -885,6 +886,9 @@ INPUT  = @srcdir@/doc/doxygen/doxygroups.cc \
  include/tr2/ratio \
  include/tr2/type_traits \
  include/decimal/decimal \
+ include/experimental/any \
+ include/experimental/optional \
+ include/experimental/string_view \
  include/ext \
  include/ext/pb_ds \
  include/ext/pb_ds/detail \
diff --git a/libstdc++-v3/include/bits/random.h b/libstdc++-v3/include/bits/random.h
index edfd797..a466a45 100644
--- a/libstdc++-v3/include/bits/random.h
+++ b/libstdc++-v3/include/bits/random.h
@@ -659,10 +659,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*
* The size of the state is @f$r@f$
* and the maximum period of the generator is @f$(m^r - m^s - 1)@f$.
-   *
-   * @var _M_x The state of the generator.  This is a ring buffer.
-   * @var _M_carry The carry.
-   * @var _M_p Current index of x(i - r).
*/
   template
 class subtract_with_carry_engine
@@ -794,9 +790,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template
 	friend std::basic_ostream<_CharT, _Traits>&
-	operator<<(std::basic_ostream<_CharT, _Traits>&,
+	operator<<(std::basic_ostream<_CharT, _Traits>& __os,
 		   const std::subtract_with_carry_engine<_UIntType1, __w1,
-		   __s1, __r1>&);
+		   __s1, __r1>& __x);
 
   /**
* @brief Extracts the current state of a % subtract_with_carry_engine
@@ -813,14 +809,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template
 	friend std::basic_istream<_CharT, _Traits>&
-	operator>>(std::basic_istream<_CharT, _Traits>&,
+	operator>>(std::basic_istream<_CharT, _Traits>& __is,
 		   std::subtract_with_carry_engine<_UIntType1, __w1,
-		   __s1, __r1>&);
+		   __s1, __r1>& __x);
 
 private:
+  /// The state of the generator.  This is a ring buffer.
   _UIntType  _M_x[long_lag];
-  _UIntType  _M_carry;
-  size_t _M_p;
+  _UIntType  _M_carry;		///< The carry
+  size_t _M_p;			///< Current index of x(i - r).
 };
 
   /**
diff --git a/libstdc++-v3/include/bits/shared_ptr.h b/libstdc++-v3/include/bits/shared_ptr.h
index 290a0c9..f611e53 100644
--- a/libstdc++-v3/include/bits/shared_ptr.h
+++ b/libstdc++-v3/include/bits/shared_ptr.h
@@ -259,7 +259,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   /**
*  @brief  Construct an empty %shared_ptr.
-   *  @param  __p  A null pointer constant.
*  @post   use_count() == 0 && get() == nullptr
*/
   constexpr shared_ptr(nullptr_t) noexcept : shared_ptr() { }
diff --git a/libstdc++-v3/include/bits/unordered_map.h b/libstdc++-v3/include/bits/unordered_map.h
index e93663c..914d26a 100644
--- a/libstdc++-v3/include/bits/unordered_map.h
+++ b/libstdc++-v3/include/bits/unordered_map.h
@@ -157,12 +157,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
*  distance(__first,__last)).
*/
   template
-	unordered_map(_InputIterator __f, _InputIterator __l,
+	unordered_map(_InputIterator __first, _InputIterator __last,
 		  size_type __n = 0,
 		  const hasher& __hf = hasher(),
 		  const key_equal& __eql = key_equal(),
 	

Re: [libgfortran, patch] Fix compilation on HP/UX 10

2014-06-14 Thread FX
ping

> Attached patch should fix compilation of libgfortran on hppa1.1-hp-hpux10.20 
> (see PR60468: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60468), by adding 
> a missing  header to the configure checks.
> 
> I’ve tested that it doesn’t break bootstrap on x86_64-apple-darwin, but not 
> on hpux10. It seems safe enough to me to proceed first, and let John test in 
> his next build of trunk (bootstrap on those machines probably isn’t fast).
> 
> OK to commit?
> 
> FX



hpux.ChangeLog
Description: Binary data


hpux.diff
Description: Binary data


[PATCH 0/6] Make df_ref representation more efficient

2014-06-14 Thread Richard Sandiford
Walks of things like DF_REF_INSN_USES were showing up high in the profile
of a fold-const.ii compilation.  These reference lists are represented
as pointers to null-terminated lists of pointers, and since there's
little locality when walking all insns, each loop over the uses or defs
generally has two major cache misses before it can do anything
(or one major cache miss before doing nothing), on top of accessing
the underlying df_insn_info.  Also, for -O0, the overhead of mallocing
lots of small arrays is itself noticeable.

I don't think there's any real need for this representation.  Each
df_ref belongs to exactly one of these null-terminated pointer arrays,
so using a normal linked list would be more efficient memory-wise
(because we'd save on the null terminator and separate malloced memory).

The idea might have been to allow the array to be sorted easily.
That doesn't really apply now though.  We collect the references in a
df_collection_rec and sort them there before populating the df_insn_info.
After that we just insert single elements or merge two sorted lists.
(Both of these are currently done as full qsorts, but don't need to be.)

Using a linked list gives a consistent 2% compile-time improvement for
fold-const.ii -O0 and ~1% for various -O2 compiles I tried.  The df
routines do still show up high on the profile though.

Tested on x86_64-linux-gnu.  OK to install?

Thanks,
Richard


[PATCH 2/6] FOR_EACH_ARTIFICIAL_{DEF,USE}

2014-06-14 Thread Richard Sandiford
Similar to patch 1, but for artificial uses and defs.

Richard


gcc/
* df.h (FOR_EACH_ARTIFICIAL_USE, FOR_EACH_ARTIFICIAL_DEF): New macros.
* cse.c (cse_extended_basic_block): Use them.
* dce.c (mark_artificial_use): Likewise.
* df-problems.c (df_rd_simulate_artificial_defs_at_top): Likewise.
(df_lr_bb_local_compute, df_live_bb_local_compute): Likewise.
(df_chain_remove_problem, df_chain_bb_dump): Likewise.
(df_word_lr_bb_local_compute, df_note_bb_compute): Likewise.
(df_simulate_initialize_backwards): Likewise.
(df_simulate_finalize_backwards): Likewise.
(df_simulate_initialize_forwards): Likewise.
(df_md_simulate_artificial_defs_at_top): Likewise.
* df-scan.c (df_reorganize_refs_by_reg_by_insn): Likewise.
* regrename.c (init_rename_info): Likewise.
* regstat.c (regstat_bb_compute_ri): Likewise.
(regstat_bb_compute_calls_crossed): Likewise.

Index: gcc/df.h
===
--- gcc/df.h2014-06-14 19:40:28.450704775 +0100
+++ gcc/df.h2014-06-14 20:01:12.353400410 +0100
@@ -775,6 +775,14 @@ #define FOR_EACH_INSN_USE(ITER, INSN) \
 #define FOR_EACH_INSN_EQ_USE(ITER, INSN) \
   FOR_EACH_INSN_INFO_EQ_USE(ITER, DF_INSN_INFO_GET (INSN))
 
+#define FOR_EACH_ARTIFICIAL_USE(ITER, BB_INDEX) \
+  for (df_ref *ITER##_ = df_get_artificial_uses (BB_INDEX); \
+   (ITER = *ITER##_); ++ITER##_)
+
+#define FOR_EACH_ARTIFICIAL_DEF(ITER, BB_INDEX) \
+  for (df_ref *ITER##_ = df_get_artificial_defs (BB_INDEX); \
+   (ITER = *ITER##_); ++ITER##_)
+
 /* An obstack for bitmap not related to specific dataflow problems.
This obstack should e.g. be used for bitmaps with a short life time
such as temporary bitmaps.  This obstack is declared in df-core.c.  */
Index: gcc/cse.c
===
--- gcc/cse.c   2014-06-14 19:40:26.919671918 +0100
+++ gcc/cse.c   2014-06-14 20:01:12.351400390 +0100
@@ -6406,14 +6406,11 @@ cse_extended_basic_block (struct cse_bas
 edge pointing to that bb.  */
   if (bb_has_eh_pred (bb))
{
- df_ref *def_rec;
+ df_ref def;
 
- for (def_rec = df_get_artificial_defs (bb->index); *def_rec; 
def_rec++)
-   {
- df_ref def = *def_rec;
- if (DF_REF_FLAGS (def) & DF_REF_AT_TOP)
-   invalidate (DF_REF_REG (def), GET_MODE (DF_REF_REG (def)));
-   }
+ FOR_EACH_ARTIFICIAL_DEF (def, bb->index)
+   if (DF_REF_FLAGS (def) & DF_REF_AT_TOP)
+ invalidate (DF_REF_REG (def), GET_MODE (DF_REF_REG (def)));
}
 
   optimize_this_for_speed_p = optimize_bb_for_speed_p (bb);
Index: gcc/dce.c
===
--- gcc/dce.c   2014-06-14 19:40:44.451212858 +0100
+++ gcc/dce.c   2014-06-14 20:01:23.401510789 +0100
@@ -661,16 +661,13 @@ mark_artificial_uses (void)
 {
   basic_block bb;
   struct df_link *defs;
-  df_ref *use_rec;
+  df_ref use;
 
   FOR_ALL_BB_FN (bb, cfun)
-{
-  for (use_rec = df_get_artificial_uses (bb->index);
-  *use_rec; use_rec++)
-   for (defs = DF_REF_CHAIN (*use_rec); defs; defs = defs->next)
- if (! DF_REF_IS_ARTIFICIAL (defs->ref))
-   mark_insn (DF_REF_INSN (defs->ref), false);
-}
+FOR_EACH_ARTIFICIAL_USE (use, bb->index)
+  for (defs = DF_REF_CHAIN (use); defs; defs = defs->next)
+   if (!DF_REF_IS_ARTIFICIAL (defs->ref))
+ mark_insn (DF_REF_INSN (defs->ref), false);
 }
 
 
Index: gcc/df-problems.c
===
--- gcc/df-problems.c   2014-06-14 19:47:23.317957520 +0100
+++ gcc/df-problems.c   2014-06-14 20:01:12.352400400 +0100
@@ -245,20 +245,17 @@ df_rd_alloc (bitmap all_blocks)
 df_rd_simulate_artificial_defs_at_top (basic_block bb, bitmap local_rd)
 {
   int bb_index = bb->index;
-  df_ref *def_rec;
-  for (def_rec = df_get_artificial_defs (bb_index); *def_rec; def_rec++)
-{
-  df_ref def = *def_rec;
-  if (DF_REF_FLAGS (def) & DF_REF_AT_TOP)
-   {
- unsigned int dregno = DF_REF_REGNO (def);
- if (!(DF_REF_FLAGS (def) & (DF_REF_PARTIAL | DF_REF_CONDITIONAL)))
-   bitmap_clear_range (local_rd,
-   DF_DEFS_BEGIN (dregno),
-   DF_DEFS_COUNT (dregno));
- bitmap_set_bit (local_rd, DF_REF_ID (def));
-   }
-}
+  df_ref def;
+  FOR_EACH_ARTIFICIAL_DEF (def, bb_index)
+if (DF_REF_FLAGS (def) & DF_REF_AT_TOP)
+  {
+   unsigned int dregno = DF_REF_REGNO (def);
+   if (!(DF_REF_FLAGS (def) & (DF_REF_PARTIAL | DF_REF_CONDITIONAL)))
+ bitmap_clear_range (local_rd,
+ DF_DEFS_BEGIN (dregno),
+ DF_DEFS_COUNT (dregno));
+   bitmap_set_bit (local_rd, DF_REF_ID (def));
+  }
 }
 
 /* Add th

[PATCH 3/6] Add FOR_EACH_INSN_INFO_MW

2014-06-14 Thread Richard Sandiford
Similar to patch 1, but for df_mw_hardregs.  I think the "S" in "MWS"
is a plural, so I went for "mw" in the variable names for single entries.

Richard


gcc/
* df.h (FOR_EACH_INSN_INFO_MW): New macro.
* df-problems.c (df_note_bb_compute): Use it.
* regstat.c (regstat_bb_compute_ri): Likewise.

Index: gcc/df.h
===
--- gcc/df.h2014-06-13 22:29:06.691558913 +0100
+++ gcc/df.h2014-06-13 22:39:44.653179269 +0100
@@ -766,6 +766,10 @@ #define FOR_EACH_INSN_INFO_EQ_USE(ITER,
   for (df_ref *ITER##_ = DF_INSN_INFO_EQ_USES (INSN); (ITER = *ITER##_); \
++ITER##_)
 
+#define FOR_EACH_INSN_INFO_MW(ITER, INSN) \
+  for (df_mw_hardreg **ITER##_ = DF_INSN_INFO_MWS (INSN); (ITER = *ITER##_); \
+   ++ITER##_)
+
 #define FOR_EACH_INSN_DEF(ITER, INSN) \
   FOR_EACH_INSN_INFO_DEF(ITER, DF_INSN_INFO_GET (INSN))
 
Index: gcc/df-problems.c
===
--- gcc/df-problems.c   2014-06-13 22:29:06.690558904 +0100
+++ gcc/df-problems.c   2014-06-13 22:39:32.271064973 +0100
@@ -3114,7 +3114,7 @@ df_note_bb_compute (unsigned int bb_inde
   FOR_BB_INSNS_REVERSE (bb, insn)
 {
   df_insn_info *insn_info = DF_INSN_INFO_GET (insn);
-  struct df_mw_hardreg **mws_rec;
+  df_mw_hardreg *mw;
   int debug_insn;
 
   if (!INSN_P (insn))
@@ -3137,17 +3137,11 @@ df_note_bb_compute (unsigned int bb_inde
 
  /* We only care about real sets for calls.  Clobbers cannot
 be depended on to really die.  */
- mws_rec = DF_INSN_INFO_MWS (insn_info);
- while (*mws_rec)
-   {
- struct df_mw_hardreg *mws = *mws_rec;
- if ((DF_MWS_REG_DEF_P (mws))
- && !df_ignore_stack_reg (mws->start_regno))
- df_set_unused_notes_for_mw (insn,
- mws, live, do_not_gen,
+ FOR_EACH_INSN_INFO_MW (mw, insn_info)
+   if ((DF_MWS_REG_DEF_P (mw))
+   && !df_ignore_stack_reg (mw->start_regno))
+ df_set_unused_notes_for_mw (insn, mw, live, do_not_gen,
  artificial_uses, &debug);
- mws_rec++;
-   }
 
  /* All of the defs except the return value are some sort of
 clobber.  This code is for the return.  */
@@ -3168,16 +3162,10 @@ df_note_bb_compute (unsigned int bb_inde
   else
{
  /* Regular insn.  */
- mws_rec = DF_INSN_INFO_MWS (insn_info);
- while (*mws_rec)
-   {
- struct df_mw_hardreg *mws = *mws_rec;
- if (DF_MWS_REG_DEF_P (mws))
-   df_set_unused_notes_for_mw (insn,
-   mws, live, do_not_gen,
-   artificial_uses, &debug);
- mws_rec++;
-   }
+ FOR_EACH_INSN_INFO_MW (mw, insn_info)
+   if (DF_MWS_REG_DEF_P (mw))
+ df_set_unused_notes_for_mw (insn, mw, live, do_not_gen,
+ artificial_uses, &debug);
 
  FOR_EACH_INSN_INFO_DEF (def, insn_info)
{
@@ -3194,25 +3182,19 @@ df_note_bb_compute (unsigned int bb_inde
}
 
   /* Process the uses.  */
-  mws_rec = DF_INSN_INFO_MWS (insn_info);
-  while (*mws_rec)
-   {
- struct df_mw_hardreg *mws = *mws_rec;
- if (DF_MWS_REG_USE_P (mws)
- && !df_ignore_stack_reg (mws->start_regno))
-   {
- bool really_add_notes = debug_insn != 0;
-
- df_set_dead_notes_for_mw (insn,
-   mws, live, do_not_gen,
-   artificial_uses,
-   &really_add_notes);
-
- if (really_add_notes)
-   debug_insn = -1;
-   }
- mws_rec++;
-   }
+  FOR_EACH_INSN_INFO_MW (mw, insn_info)
+   if (DF_MWS_REG_USE_P (mw)
+   && !df_ignore_stack_reg (mw->start_regno))
+ {
+   bool really_add_notes = debug_insn != 0;
+
+   df_set_dead_notes_for_mw (insn, mw, live, do_not_gen,
+ artificial_uses,
+ &really_add_notes);
+
+   if (really_add_notes)
+ debug_insn = -1;
+ }
 
   FOR_EACH_INSN_INFO_USE (use, insn_info)
{
Index: gcc/regstat.c
===
--- gcc/regstat.c   2014-06-13 22:29:06.691558913 +0100
+++ gcc/regstat.c   2014-06-13 22:30:12.519134950 +0100
@@ -153,7 +153,7 @@ regstat_bb_compute_ri (unsigned int bb_i
 {
   struct df_insn_info *insn_info = DF_INSN_INFO_GET (insn);
   bitmap_iterator bi;
-  struct df_mw_hardreg **mws_rec;
+  df_mw_hardreg *mw;
   rtx link;
 
   if (!NONDEBUG_INSN_P (insn))
@@ -202,29 +202,26 @@ r

[PATCH 4/6] Add df_single_{def,use} helper functions

2014-06-14 Thread Richard Sandiford
IRA wants to know whether a particular insn has a single def or use.
That seems worth putting in a utility function, again to hide the
underlying representation a bit.

Richard


gcc/
* df.h (df_single_def, df_single_use): New functions.
* ira.c (find_moveable_pseudos): Use them.

Index: gcc/df.h
===
--- gcc/df.h2014-06-14 20:09:44.725239874 +0100
+++ gcc/df.h2014-06-14 20:09:50.254289996 +0100
@@ -1165,6 +1165,25 @@ df_get_artificial_uses (unsigned int bb_
   return df_scan_get_bb_info (bb_index)->artificial_uses;
 }
 
+/* If INSN defines exactly one register, return the associated reference,
+   otherwise return null.  */
+
+static inline df_ref
+df_single_def (const df_insn_info *info)
+{
+  df_ref *defs = DF_INSN_INFO_DEFS (info);
+  return defs[0] && !defs[1] ? defs[0] : NULL;
+}
+
+/* If INSN uses exactly one register, return the associated reference,
+   otherwise return null.  */
+
+static inline df_ref
+df_single_use (const df_insn_info *info)
+{
+  df_ref *uses = DF_INSN_INFO_USES (info);
+  return uses[0] && !uses[1] ? uses[0] : NULL;
+}
 
 /* web */
 
Index: gcc/ira.c
===
--- gcc/ira.c   2014-06-14 20:09:44.726239882 +0100
+++ gcc/ira.c   2014-06-14 20:10:29.210640914 +0100
@@ -4437,20 +4437,19 @@ find_moveable_pseudos (void)
if (NONDEBUG_INSN_P (insn))
  {
df_insn_info *insn_info = DF_INSN_INFO_GET (insn);
-   df_ref *u_rec, *d_rec;
df_ref def, use;
 
uid_luid[INSN_UID (insn)] = i++;

-   u_rec = DF_INSN_INFO_USES (insn_info);
-   d_rec = DF_INSN_INFO_DEFS (insn_info);
-   if (d_rec[0] != NULL && d_rec[1] == NULL
-   && u_rec[0] != NULL && u_rec[1] == NULL
-   && DF_REF_REGNO (*u_rec) == DF_REF_REGNO (*d_rec)
-   && !bitmap_bit_p (&set, DF_REF_REGNO (*u_rec))
+   def = df_single_def (insn_info);
+   use = df_single_use (insn_info);
+   if (use
+   && def
+   && DF_REF_REGNO (use) == DF_REF_REGNO (def)
+   && !bitmap_bit_p (&set, DF_REF_REGNO (use))
&& rtx_moveable_p (&PATTERN (insn), OP_IN))
  {
-   unsigned regno = DF_REF_REGNO (*u_rec);
+   unsigned regno = DF_REF_REGNO (use);
bitmap_set_bit (moveable, regno);
bitmap_set_bit (&set, regno);
bitmap_set_bit (&used, regno);
@@ -4487,16 +4486,16 @@ find_moveable_pseudos (void)
   FOR_BB_INSNS (bb, insn)
if (NONDEBUG_INSN_P (insn))
  {
+   df_insn_info *insn_info = DF_INSN_INFO_GET (insn);
rtx def_insn, closest_use, note;
-   df_ref *def_rec, def, use;
+   df_ref def, use;
unsigned regno;
bool all_dominated, all_local;
enum machine_mode mode;
 
-   def_rec = DF_INSN_DEFS (insn);
+   def = df_single_def (insn_info);
/* There must be exactly one def in this insn.  */
-   def = *def_rec;
-   if (!def || def_rec[1] || !single_set (insn))
+   if (!def || !single_set (insn))
  continue;
/* This must be the only definition of the reg.  We also limit
   which modes we deal with so that we can assume we can generate


[PATCH 5/6] Remove dead code

2014-06-14 Thread Richard Sandiford
This patch removes some dead code that would otherwise need to be
changed in the final patch.

Richard


gcc/
* df.h (df_ref_create, df_ref_remove): Delete.
* df-scan.c (df_ref_create, df_ref_compress_rec): Likewise.
(df_ref_remove): Likewise.

Index: gcc/df.h
===
--- gcc/df.h2014-06-13 22:36:35.314501770 +0100
+++ gcc/df.h2014-06-13 22:36:39.482538550 +0100
@@ -1027,10 +1027,7 @@ extern void df_scan_add_problem (void);
 extern void df_grow_reg_info (void);
 extern void df_grow_insn_info (void);
 extern void df_scan_blocks (void);
-extern df_ref df_ref_create (rtx, rtx *, rtx,basic_block,
-enum df_ref_type, int ref_flags);
 extern void df_uses_create (rtx *, rtx, int);
-extern void df_ref_remove (df_ref);
 extern struct df_insn_info * df_insn_create_insn_record (rtx);
 extern void df_insn_delete (rtx);
 extern void df_bb_refs_record (int, bool);
Index: gcc/df-scan.c
===
--- gcc/df-scan.c   2014-06-13 22:36:23.478397337 +0100
+++ gcc/df-scan.c   2014-06-13 22:36:39.481538541 +0100
@@ -111,10 +111,6 @@ static void df_uses_record (struct df_co
int ref_flags);
 
 static void df_install_ref_incremental (df_ref);
-static df_ref df_ref_create_structure (enum df_ref_class,
-  struct df_collection_rec *, rtx, rtx *,
-  basic_block, struct df_insn_info *,
-  enum df_ref_type, int ref_flags);
 static void df_insn_refs_collect (struct df_collection_rec*,
  basic_block, struct df_insn_info *);
 static void df_canonize_collection_rec (struct df_collection_rec *);
@@ -694,32 +690,6 @@ df_uses_create (rtx *loc, rtx insn, int
   ref_flags);
 }
 
-/* Create a new ref of type DF_REF_TYPE for register REG at address
-   LOC within INSN of BB.  This function is only used externally.  */
-
-df_ref
-df_ref_create (rtx reg, rtx *loc, rtx insn,
-  basic_block bb,
-  enum df_ref_type ref_type,
-  int ref_flags)
-{
-  enum df_ref_class cl;
-
-  df_grow_reg_info ();
-
-  /* You cannot hack artificial refs.  */
-  gcc_assert (insn);
-
-  if (loc)
-cl = DF_REF_REGULAR;
-  else
-cl = DF_REF_BASE;
-
-  return df_ref_create_structure (cl, NULL, reg, loc, bb,
-  DF_INSN_INFO_GET (insn),
-  ref_type, ref_flags);
-}
-
 static void
 df_install_ref_incremental (df_ref ref)
 {
@@ -934,89 +904,6 @@ df_reg_chain_unlink (df_ref ref)
 }
 
 
-/* Remove REF from VEC.  */
-
-static void
-df_ref_compress_rec (df_ref **vec_ptr, df_ref ref)
-{
-  df_ref *vec = *vec_ptr;
-
-  if (vec[1])
-{
-  while (*vec && *vec != ref)
-   vec++;
-
-  while (*vec)
-   {
- *vec = *(vec+1);
- vec++;
-   }
-}
-  else
-{
-  free (vec);
-  *vec_ptr = df_null_ref_rec;
-}
-}
-
-
-/* Unlink REF from all def-use/use-def chains, etc.  */
-
-void
-df_ref_remove (df_ref ref)
-{
-#if 0
-  if (dump_file)
-{
-  fprintf (dump_file, "removing ref ");
-  df_ref_debug (ref, dump_file);
-}
-#endif
-
-  if (DF_REF_REG_DEF_P (ref))
-{
-  if (DF_REF_IS_ARTIFICIAL (ref))
-   {
- struct df_scan_bb_info *bb_info
-   = df_scan_get_bb_info (DF_REF_BBNO (ref));
- df_ref_compress_rec (&bb_info->artificial_defs, ref);
-   }
-  else
-   {
- unsigned int uid = DF_REF_INSN_UID (ref);
- struct df_insn_info *insn_rec = DF_INSN_UID_GET (uid);
- df_ref_compress_rec (&insn_rec->defs, ref);
-   }
-}
-  else
-{
-  if (DF_REF_IS_ARTIFICIAL (ref))
-   {
- struct df_scan_bb_info *bb_info
-   = df_scan_get_bb_info (DF_REF_BBNO (ref));
- df_ref_compress_rec (&bb_info->artificial_uses, ref);
-   }
-  else
-   {
- unsigned int uid = DF_REF_INSN_UID (ref);
- struct df_insn_info *insn_rec = DF_INSN_UID_GET (uid);
-
- if (DF_REF_FLAGS (ref) & DF_REF_IN_NOTE)
-   df_ref_compress_rec (&insn_rec->eq_uses, ref);
- else
-   df_ref_compress_rec (&insn_rec->uses, ref);
-   }
-}
-
-  /* By deleting the ref directly, df_insn_rescan my not find any
- differences even though the block will have changed.  So we need
- to mark the block dirty ourselves.  */
-  if (!DEBUG_INSN_P (DF_REF_INSN (ref)))
-df_set_bb_dirty (DF_REF_BB (ref));
-  df_reg_chain_unlink (ref);
-}
-
-
 /* Create the insn record for INSN.  If there was one there, zero it
out.  */
 


[PATCH 6/6] Use a linked list for insn defs and uses

2014-06-14 Thread Richard Sandiford
This is the main change, which is hard to break down much further.

Most of this is pretty mechanical.  Some of it is reindentation,
since it's no longer meaningful (if it was before) to test the
defs or artificial_defs against null to see whether a structure
had been initialised.  Also, df_ref_change_reg_with_loc_1 would
choose the wrong reference array for definitions.

Richard


gcc/
* df.h (df_mw_hardreg, df_base_ref): Add a link pointer.
(df_insn_info): Turn defs, uses, eq_uses and mw_hardregs into linked
lists.
(df_scan_bb_info): Likewise artificial_defs and artificial_uses.
(FOR_EACH_INSN_INFO_DEF, FOR_EACH_INSN_INFO_USE)
(FOR_EACH_INSN_INFO_EQ_USE, FOR_EACH_INSN_INFO_MW)
(FOR_EACH_ARTIFICIAL_USE, FOR_EACH_ARTIFICIAL_DEF)
(df_get_artificial_defs, df_get_artificial_uses)
(df_single_def, df_single_use): Update accordingly.
(df_refs_chain_dump): Take the first element in a linked list as
parameter, rather than a pointer to an array of pointers.
* df-core.c (df_refs_chain_dump, df_mws_dump): Likewise.
* df-problems.c (df_rd_bb_local_compute_process_def): Likewise.
(df_chain_create_bb_process_use): Likewise.
(df_md_bb_local_compute_process_def): Likewise.
* fwprop.c (process_defs, process_uses): Likewise.
(register_active_defs, update_uses): Likewise.
(forward_propagate_asm): Update for new df_ref linking.
* df-scan.c (df_scan_free_ref_vec, df_scan_free_mws_vec): Delete.
(df_null_ref_rec, df_null_mw_rec): Likewise.
(df_scan_free_internal): Don't free df_ref and df_mw_hardreg lists
explicitly.
(df_scan_free_bb_info): Remove check for null artificial_defs.
(df_install_ref_incremental): Adjust for new df_ref linking.
Use a single-element insertion rather than a full sort.
(df_ref_chain_delete_du_chain): Take the first element
in a linked list as parameter, rather than a pointer to an array of
pointers.
(df_ref_chain_delete, df_mw_hardreg_chain_delete): Likewise.
(df_add_refs_to_table, df_refs_verify, df_mws_verify): Likewise.
(df_insn_info_delete): Remove check for null defs and call to
df_scan_free_mws_vec.
(df_insn_rescan): Initialize df_ref and df_mw_hardreg lists to
null rather than df_null_*_rec.
(df_insn_rescan_debug_internal): Likewise, and update null
checks in the same way.  Remove check for null defs.
(df_ref_change_reg_with_loc_1): Fix choice of list for defs.
Move a single element rather doing a full sort.
(df_mw_hardreg_chain_delete_eq_uses): Adjust for new df_mw_hardreg
linking.
(df_notes_rescan): Likewise.  Use a merge rather than a full sort.
Initialize df_ref and df_mw_hardreg lists to null rather than
df_null_*_rec.
(df_ref_compare): Take df_refs as parameter, transferring the
old interface to...
(df_ref_ptr_compare): ...this new function.
(df_sort_and_compress_refs): Update accordingly.
(df_mw_compare): Take df_mw_hardregs as parameter, transferring the
old interface to...
(df_mw_ptr_compare): ...this new function.
(df_sort_and_compress_mws): Update accordingly.
(df_install_refs, df_install_mws): Return a linked list rather than
an array of pointers.
(df_refs_add_to_chains): Assert that old lists are empty rather
than freeing them.
(df_insn_refs_verify): Don't handle null defs speciailly.
* web.c (union_match_dups): Update for new df_ref linking.

Index: gcc/df.h
===
--- gcc/df.h2014-06-14 20:16:24.996757215 +0100
+++ gcc/df.h2014-06-14 20:16:25.448761158 +0100
@@ -339,6 +339,7 @@ struct dataflow
REG_UNUSED notes.  */
 struct df_mw_hardreg
 {
+  df_mw_hardreg *next; /* Next entry for this instruction.  */
   rtx mw_reg;   /* The multiword hardreg.  */
   /* These two bitfields are intentionally oversized, in the hope that
  accesses to 16-bit fields will usually be quicker.  */
@@ -365,6 +366,7 @@ struct df_base_ref
   int flags : 16;  /* Various df_ref_flags.  */
   unsigned int regno;  /* The register number referenced.  */
   rtx reg; /* The register referenced.  */
+  union df_ref_d *next_loc;/* Next ref for same insn or bb.  */
   struct df_link *chain;   /* Head of def-use, use-def.  */
   /* Pointer to the insn info of the containing instruction.  FIXME!
  Currently this is NULL for artificial refs but this will be used
@@ -420,11 +422,11 @@ typedef union df_ref_d *df_ref;
 struct df_insn_info
 {
   rtx insn; /* The insn this info comes from.  */
-  df_ref *defs;/* Head of insn-def chain.  */
-  df_ref *uses;/* Hea

Remove some unnecessary null checks in df.h

2014-06-14 Thread Richard Sandiford
DF_REF_REG_USE_P and DF_MWS_REG_USE_P checked for null arguments
but the def equivalents didn't.  There doesn't seem to be any
need for this difference.

Tested on x86_64-linux-gnu.  OK to install?

Thanks,
Richard


gcc/
* df.h (DF_REF_REG_USE_P, DF_MWS_REG_USE_P): Remove null checks.

Index: gcc/df.h
===
--- gcc/df.h2014-06-13 09:50:18.408426173 +0100
+++ gcc/df.h2014-06-13 10:03:38.465506737 +0100
@@ -678,14 +678,14 @@ #define DF_REF_EXTRACT_MODE(REF) ((REF)-
 
 /* Macros to determine the reference type.  */
 #define DF_REF_REG_DEF_P(REF) (DF_REF_TYPE (REF) == DF_REF_REG_DEF)
-#define DF_REF_REG_USE_P(REF) ((REF) && !DF_REF_REG_DEF_P (REF))
+#define DF_REF_REG_USE_P(REF) (!DF_REF_REG_DEF_P (REF))
 #define DF_REF_REG_MEM_STORE_P(REF) (DF_REF_TYPE (REF) == DF_REF_REG_MEM_STORE)
 #define DF_REF_REG_MEM_LOAD_P(REF) (DF_REF_TYPE (REF) == DF_REF_REG_MEM_LOAD)
 #define DF_REF_REG_MEM_P(REF) (DF_REF_REG_MEM_STORE_P (REF) \
|| DF_REF_REG_MEM_LOAD_P (REF))
 
 #define DF_MWS_REG_DEF_P(MREF) (DF_MWS_TYPE (MREF) == DF_REF_REG_DEF)
-#define DF_MWS_REG_USE_P(MREF) ((MREF) && !DF_MWS_REG_DEF_P (MREF))
+#define DF_MWS_REG_USE_P(MREF) (!DF_MWS_REG_DEF_P (MREF))
 #define DF_MWS_TYPE(MREF) ((MREF)->type)
 
 /* Macros to get the refs out of def_info or use_info refs table.  If


Re: [PATCH 1/6] Add FOR_EACH_INSN{_INFO}_{DEFS,USES,EQ_USES}

2014-06-14 Thread Steven Bosscher
On Sat, Jun 14, 2014 at 9:43 PM, Richard Sandiford wrote:
> gcc/
> * df.h (DF_INSN_INFO_MWS, FOR_EACH_INSN_INFO_DEF): New macros.
> (FOR_EACH_INSN_INFO_USE, FOR_EACH_INSN_INFO_EQ_USE): Likewise.
> (FOR_EACH_INSN_DEF, FOR_EACH_INSN_USE, FOR_EACH_INSN_EQ_USE): 
> Likewise.
> * auto-inc-dec.c (find_inc, merge_in_block): Use them.
> * combine.c (create_log_links): Likewise.
> * compare-elim.c (find_flags_uses_in_insn): Likewise.
> (try_eliminate_compare): Likewise.
> * cprop.c (make_set_regs_unavailable, mark_oprs_set): Likewise.
> * dce.c (deletable_insn_p, find_call_stack_args): Likewise.
> (remove_reg_equal_equiv_notes_for_defs): Likewise.
> (reset_unmarked_insns_debug_uses, mark_reg_dependencies): Likewise.
> (word_dce_process_block, dce_process_block): Likewise.
> * ddg.c (def_has_ccmode_p): Likewise.
> * df-core.c (df_bb_regno_first_def_find): Likewise.
> (df_bb_regno_last_def_find, df_find_def, df_find_use): Likewise.
> * df-problems.c (df_rd_simulate_one_insn): Likewise.
> (df_lr_bb_local_compute, df_live_bb_local_compute): Likewise.
> (df_chain_remove_problem, df_chain_insn_top_dump): Likewise.
> (df_chain_insn_bottom_dump, df_word_lr_bb_local_compute): Likewise.
> (df_word_lr_simulate_defs, df_word_lr_simulate_uses): Likewise.
> (df_remove_dead_eq_notes, df_note_bb_compute): Likewise.
> (df_simulate_find_defs, df_simulate_find_uses): Likewise.
> (df_simulate_find_noclobber_defs, df_simulate_defs): Likewise.
> (df_simulate_uses, df_md_simulate_one_insn): Likewise.
> * df-scan.c (df_reorganize_refs_by_reg_by_insn): Likewise.
> * fwprop.c (local_ref_killed_between_p): Likewise.
> (all_uses_available_at, free_load_extend): Likewise.
> * gcse.c (update_bb_reg_pressure, calculate_bb_reg_pressure): 
> Likewise.
> * hw-doloop.c (scan_loop): Likewise.
> * ifcvt.c (dead_or_predicable): Likewise.
> * init-regs.c (initialize_uninitialized_regs): Likewise.
> * ira-lives.c (mark_hard_reg_early_clobbers): Likewise.
> (process_bb_node_lives): Likewise.
> * ira.c (compute_regs_asm_clobbered, build_insn_chain): Likewise.
> (find_moveable_pseudos): Likewise.
> * loop-invariant.c (check_dependencies, record_uses): Likewise.
> * recog.c (peep2_find_free_register): Likewise.
> * ree.c (get_defs): Likewise.
> * regstat.c (regstat_bb_compute_ri): Likewise.
> (regstat_bb_compute_calls_crossed): Likewise.
> * sched-deps.c (find_inc, find_mem): Likewise.
> * sel-sched-ir.c (maybe_downgrade_id_to_use): Likewise.
> (maybe_downgrade_id_to_use, setup_id_reg_sets): Likewise.
> * shrink-wrap.c (requires_stack_frame_p): Likewise.
> (prepare_shrink_wrap): Likewise.
> * store-motion.c (compute_store_table, build_store_vectors): Likewise.
> * web.c (union_defs, pass_web::execute): Likewise.
> * config/i386/i386.c (increase_distance, insn_defines_reg): Likewise.
> (insn_uses_reg_mem, ix86_ok_to_clobber_flags): Likewise.

OK. Nice :-)

Ciao!
Steven


Re: [PATCH 2/6] FOR_EACH_ARTIFICIAL_{DEF,USE}

2014-06-14 Thread Steven Bosscher
On Sat, Jun 14, 2014 at 9:44 PM, Richard Sandiford wrote:
> gcc/
> * df.h (FOR_EACH_ARTIFICIAL_USE, FOR_EACH_ARTIFICIAL_DEF): New macros.
> * cse.c (cse_extended_basic_block): Use them.
> * dce.c (mark_artificial_use): Likewise.
> * df-problems.c (df_rd_simulate_artificial_defs_at_top): Likewise.
> (df_lr_bb_local_compute, df_live_bb_local_compute): Likewise.
> (df_chain_remove_problem, df_chain_bb_dump): Likewise.
> (df_word_lr_bb_local_compute, df_note_bb_compute): Likewise.
> (df_simulate_initialize_backwards): Likewise.
> (df_simulate_finalize_backwards): Likewise.
> (df_simulate_initialize_forwards): Likewise.
> (df_md_simulate_artificial_defs_at_top): Likewise.
> * df-scan.c (df_reorganize_refs_by_reg_by_insn): Likewise.
> * regrename.c (init_rename_info): Likewise.
> * regstat.c (regstat_bb_compute_ri): Likewise.
> (regstat_bb_compute_calls_crossed): Likewise.

OK.

Ciao!
Steven


Re: [PATCH 3/6] Add FOR_EACH_INSN_INFO_MW

2014-06-14 Thread Steven Bosscher
On Sat, Jun 14, 2014 at 9:45 PM, Richard Sandiford wrote:
> gcc/
> * df.h (FOR_EACH_INSN_INFO_MW): New macro.
> * df-problems.c (df_note_bb_compute): Use it.
> * regstat.c (regstat_bb_compute_ri): Likewise.

OK.

Ciao!
Steven


Re: [PATCH 4/6] Add df_single_{def,use} helper functions

2014-06-14 Thread Steven Bosscher
On Sat, Jun 14, 2014 at 9:47 PM, Richard Sandiford wrote:
> IRA wants to know whether a particular insn has a single def or use.
> That seems worth putting in a utility function, again to hide the
> underlying representation a bit.

I would have sworn we already had functions for this, but apparently not...

> * ira.c (find_moveable_pseudos): Use them.

OK.

Ciao!
Steven


Re: [PATCH 5/6] Remove dead code

2014-06-14 Thread Steven Bosscher
On Sat, Jun 14, 2014 at 9:48 PM, Richard Sandiford wrote:
> This patch removes some dead code that would otherwise need to be
> changed in the final patch.

These functions were intended to allow passes to update DF info
manually. That never was a very practical idea, apparently.

> gcc/
> * df.h (df_ref_create, df_ref_remove): Delete.
> * df-scan.c (df_ref_create, df_ref_compress_rec): Likewise.
> (df_ref_remove): Likewise.

OK.

Ciao!
Steven


[patch] Fix links in libstdc++ doxygen comments

2014-06-14 Thread Jonathan Wakely

Fix old, broken links from Doxygen comments to pages in the manual
that have a different URL now. Unfortunately the URLs make some lines
too long to fit in 80 chars, but I'm not sure what we can do about
that. Any suggestions?

Tested x86_64-linux, committed to trunk.
commit 2a0f6d650951c63f1b56a6113a8a1c003f0b06c8
Author: Jonathan Wakely 
Date:   Sat Jun 14 21:02:47 2014 +0100

	* doc/xml/api.xml: Link to more recent API docs.
	* include/bits/allocator.h: Fix link in doxygen comment.
	* include/bits/char_traits.h: Likewise.
	* include/bits/ios_base.h: Likewise.
	* include/bits/stl_map.h: Likewise.
	* include/bits/stl_multimap.h: Likewise.
	* include/bits/stl_multiset.h: Likewise.
	* include/bits/stl_set.h: Likewise.
	* include/bits/unordered_map.h: Likewise.
	* include/bits/unordered_set.h: Likewise.
	* include/ext/mt_allocator.h: Likewise.
	* include/std/fstream: Likewise.
	* include/std/iosfwd: Likewise.
	* include/std/ostream: Likewise.
	* include/std/sstream: Likewise.
	* include/std/streambuf: Likewise.
	* doc/html/*: Regenerate.

diff --git a/libstdc++-v3/doc/xml/api.xml b/libstdc++-v3/doc/xml/api.xml
index 7c02dff..f9478c3 100644
--- a/libstdc++-v3/doc/xml/api.xml
+++ b/libstdc++-v3/doc/xml/api.xml
@@ -13,6 +13,9 @@
 
   2010
 
+
+  2014
+
 
   http://www.w3.org/1999/xlink"; xlink:href="http://www.fsf.org/";>FSF
   
@@ -85,6 +88,24 @@
   
   
 
+  http://www.w3.org/1999/xlink"; xlink:href="http://gcc.gnu.org/onlinedocs/gcc-4.7.4/libstdc++/api/";>for the 4.7.4 release
+  
+
+  
+  
+
+  http://www.w3.org/1999/xlink"; xlink:href="http://gcc.gnu.org/onlinedocs/gcc-4.8.3/libstdc++/api/";>for the 4.8.3 release
+  
+
+  
+  
+
+  http://www.w3.org/1999/xlink"; xlink:href="http://gcc.gnu.org/onlinedocs/gcc-4.9.0/libstdc++/api/";>for the 4.9.0 release
+  
+
+  
+  
+
   http://www.w3.org/1999/xlink"; xlink:href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/index.html";>"the latest collection"
   
   (For the main development tree; see the date on the first page.)
@@ -94,7 +115,7 @@
 
 
   The rendered HTML, as above, is also available for download on the
-  gcc.org site in a directory located at
+  gcc.gnu.org site in a directory located at
;.
You will almost certainly need to use one of the
http://www.w3.org/1999/xlink"; xlink:href="http://gcc.gnu.org/mirrors.html";>mirror sites to download
diff --git a/libstdc++-v3/include/bits/allocator.h b/libstdc++-v3/include/bits/allocator.h
index 05a06ba..37248ab 100644
--- a/libstdc++-v3/include/bits/allocator.h
+++ b/libstdc++-v3/include/bits/allocator.h
@@ -83,7 +83,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   /**
* @brief  The @a standard allocator, as per [20.4].
*
-   *  See http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt04ch11.html
+   *  See https://gcc.gnu.org/onlinedocs/libstdc++/manual/memory.html#std.util.memory.allocator
*  for further details.
*
*  @tparam  _Tp  Type of allocated object.
diff --git a/libstdc++-v3/include/bits/char_traits.h b/libstdc++-v3/include/bits/char_traits.h
index 8c3bf96..2b7cd3f 100644
--- a/libstdc++-v3/include/bits/char_traits.h
+++ b/libstdc++-v3/include/bits/char_traits.h
@@ -75,7 +75,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*  may not be specialized for fundamental types, but classes in
*  namespace __gnu_cxx may be.
*
-   *  See http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt05ch13s03.html
+   *  See https://gcc.gnu.org/onlinedocs/libstdc++/manual/strings.html#strings.string.character_types
*  for advice on how to make use of this class for @a unusual character
*  types. Also, check out include/ext/pod_char_traits.h.  
*/
@@ -219,7 +219,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*  __gnu_cxx::char_traits, it is possible to achieve a more
*  appropriate definition by specializing __gnu_cxx::char_traits.
*
-   *  See http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt05ch13s03.html
+   *  See https://gcc.gnu.org/onlinedocs/libstdc++/manual/strings.html#strings.string.character_types
*  for advice on how to make use of this class for @a unusual character
*  types. Also, check out include/ext/pod_char_traits.h.
   */
diff --git a/libstdc++-v3/include/bits/ios_base.h b/libstdc++-v3/include/bits/ios_base.h
index 59c5066..4aade68 100644
--- a/libstdc++-v3/include/bits/ios_base.h
+++ b/libstdc++-v3/include/bits/ios_base.h
@@ -368,7 +368,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
 /// Perform input and output in binary mode (as opposed to text mode).
 /// This is probably not what you think it is; see
-/// http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt11ch27s02.html
+/// https://gcc.gnu.org/onlinedocs/libstdc++/manual/fstreams.html#std.io.filestreams.binary
 static const openmode binary =	_S_bin;
 
 //

Re: [PATCH 6/6] Use a linked list for insn defs and uses

2014-06-14 Thread Steven Bosscher
On Sat, Jun 14, 2014 at 9:53 PM, Richard Sandiford wrote:
> gcc/
> * df.h (df_mw_hardreg, df_base_ref): Add a link pointer.
> (df_insn_info): Turn defs, uses, eq_uses and mw_hardregs into linked
> lists.
> (df_scan_bb_info): Likewise artificial_defs and artificial_uses.
> (FOR_EACH_INSN_INFO_DEF, FOR_EACH_INSN_INFO_USE)
> (FOR_EACH_INSN_INFO_EQ_USE, FOR_EACH_INSN_INFO_MW)
> (FOR_EACH_ARTIFICIAL_USE, FOR_EACH_ARTIFICIAL_DEF)
> (df_get_artificial_defs, df_get_artificial_uses)
> (df_single_def, df_single_use): Update accordingly.
> (df_refs_chain_dump): Take the first element in a linked list as
> parameter, rather than a pointer to an array of pointers.
> * df-core.c (df_refs_chain_dump, df_mws_dump): Likewise.
> * df-problems.c (df_rd_bb_local_compute_process_def): Likewise.
> (df_chain_create_bb_process_use): Likewise.
> (df_md_bb_local_compute_process_def): Likewise.
> * fwprop.c (process_defs, process_uses): Likewise.
> (register_active_defs, update_uses): Likewise.
> (forward_propagate_asm): Update for new df_ref linking.
> * df-scan.c (df_scan_free_ref_vec, df_scan_free_mws_vec): Delete.
> (df_null_ref_rec, df_null_mw_rec): Likewise.
> (df_scan_free_internal): Don't free df_ref and df_mw_hardreg lists
> explicitly.
> (df_scan_free_bb_info): Remove check for null artificial_defs.
> (df_install_ref_incremental): Adjust for new df_ref linking.
> Use a single-element insertion rather than a full sort.
> (df_ref_chain_delete_du_chain): Take the first element
> in a linked list as parameter, rather than a pointer to an array of
> pointers.
> (df_ref_chain_delete, df_mw_hardreg_chain_delete): Likewise.
> (df_add_refs_to_table, df_refs_verify, df_mws_verify): Likewise.
> (df_insn_info_delete): Remove check for null defs and call to
> df_scan_free_mws_vec.
> (df_insn_rescan): Initialize df_ref and df_mw_hardreg lists to
> null rather than df_null_*_rec.
> (df_insn_rescan_debug_internal): Likewise, and update null
> checks in the same way.  Remove check for null defs.
> (df_ref_change_reg_with_loc_1): Fix choice of list for defs.
> Move a single element rather doing a full sort.
> (df_mw_hardreg_chain_delete_eq_uses): Adjust for new df_mw_hardreg
> linking.
> (df_notes_rescan): Likewise.  Use a merge rather than a full sort.
> Initialize df_ref and df_mw_hardreg lists to null rather than
> df_null_*_rec.
> (df_ref_compare): Take df_refs as parameter, transferring the
> old interface to...
> (df_ref_ptr_compare): ...this new function.
> (df_sort_and_compress_refs): Update accordingly.
> (df_mw_compare): Take df_mw_hardregs as parameter, transferring the
> old interface to...
> (df_mw_ptr_compare): ...this new function.
> (df_sort_and_compress_mws): Update accordingly.
> (df_install_refs, df_install_mws): Return a linked list rather than
> an array of pointers.
> (df_refs_add_to_chains): Assert that old lists are empty rather
> than freeing them.
> (df_insn_refs_verify): Don't handle null defs speciailly.
> * web.c (union_match_dups): Update for new df_ref linking.


I would prefer a macro for base.next_loc (DF_REF_NEXT_LOC?).

Other than that: OK.

Ciao!
Steven


Re: Remove some unnecessary null checks in df.h

2014-06-14 Thread Steven Bosscher
On Sat, Jun 14, 2014 at 10:02 PM, Richard Sandiford wrote:
> DF_REF_REG_USE_P and DF_MWS_REG_USE_P checked for null arguments
> but the def equivalents didn't.  There doesn't seem to be any
> need for this difference.

Right, looking at the users (one user for each) of these macros, I
don't think REF ever can be NULL.

> gcc/
> * df.h (DF_REF_REG_USE_P, DF_MWS_REG_USE_P): Remove null checks.


OK.

Ciao!
Steven


Re: [PATCH 0/6] Make df_ref representation more efficient

2014-06-14 Thread Steven Bosscher
On Sat, Jun 14, 2014 at 9:36 PM, Richard Sandiford wrote:
> Using a linked list gives a consistent 2% compile-time improvement for
> fold-const.ii -O0 and ~1% for various -O2 compiles I tried.  The df
> routines do still show up high on the profile though.

Can you explain a bit more about what shows up high?

Ciao!
Steven


[patch] Improve some doxygen comments

2014-06-14 Thread Jonathan Wakely

One last set of Doxygen-related updates for today.

This removes some redundancy, moves std::bitset to the "Utilities"
group in the docs (which is where it lives in the C++11 standard) and
gets rid of the "Global I/O operators for bitsets" group, which only
contained two operators for the dytnamic_bitset extension.

Tested x86_64-linux, committed to trunk.
commit 450e81f751bc2d8bac4cf9965fcda4b933eb3a61
Author: Jonathan Wakely 
Date:   Sat Jun 14 21:26:32 2014 +0100

	* include/experimental/any (any_cast): Combine duplicate doxygen
	comments.
	* include/experimental/string_view (basic_string_view): Update
	doxygen comment.
	* include/std/bitset (bitset): Move to Doxygen 'utilities' group.
	* include/tr2/dynamic_bitset (_Bool2UChar): Remove unused templates.
	(dynamic_bitset): Improve Doxygen comments.
	* include/tr2/dynamic_bitset.tcc (operator>>): Improve Doxygen
	comment.

diff --git a/libstdc++-v3/include/experimental/any b/libstdc++-v3/include/experimental/any
index 2839af1..1e8d9b2 100644
--- a/libstdc++-v3/include/experimental/any
+++ b/libstdc++-v3/include/experimental/any
@@ -81,11 +81,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   }
 
   /**
-* @brief A type-safe container of any type.
-*
-* An @c any object's state is either empty or it stores a contained object
-* of CopyConstructible type.
-*/
+   *  @brief A type-safe container of any type.
+   * 
+   *  An @c any object's state is either empty or it stores a contained object
+   *  of CopyConstructible type.
+   */
   class any
   {
 // Holds either pointer to a heap object or the contained object itself.
@@ -391,6 +391,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* @throw   bad_any_cast If 
*  __any.type() != typeid(remove_reference_t<_ValueType>)
*  
+   *
+   * @{
*/
   template
 inline _ValueType any_cast(any& __any)
@@ -403,16 +405,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   __throw_bad_any_cast();
 }
 
-  /**
-   * @brief Access the contained object.
-   *
-   * @tparam  _ValueType  A reference or CopyConstructible type.
-   * @param   __any   The object to access.
-   * @return  The contained object.
-   * @throw   bad_any_cast If 
-   *  __any.type() != typeid(remove_reference_t<_ValueType>)
-   *  
-   */
   template
 inline _ValueType any_cast(any&& __any)
 {
@@ -423,6 +415,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	return *__p;
   __throw_bad_any_cast();
 }
+  // @}
 
   /**
* @brief Access the contained object.
@@ -432,6 +425,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* @return  The address of the contained object if 
*  __any != nullptr && __any.type() == typeid(_ValueType)
*  , otherwise a null pointer.
+   *
+   * @{
*/
   template
 inline const _ValueType* any_cast(const any* __any) noexcept
@@ -441,15 +436,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   return nullptr;
 }
 
-  /**
-   * @brief Access the contained object.
-   *
-   * @tparam  _ValueType  The type of the contained object.
-   * @param   __any   A pointer to the object to access.
-   * @return  The address of the contained object if 
-   *  __any != nullptr && __any.type() == typeid(_ValueType)
-   *  , otherwise a null pointer.
-   */
   template
 inline _ValueType* any_cast(any* __any) noexcept
 {
@@ -457,6 +443,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	return static_cast<_ValueType*>(__any_caster<_ValueType>(__any));
   return nullptr;
 }
+  // @}
 
 #ifdef __GXX_RTTI
   template
diff --git a/libstdc++-v3/include/experimental/string_view b/libstdc++-v3/include/experimental/string_view
index 49f46af..b54c9e8 100644
--- a/libstdc++-v3/include/experimental/string_view
+++ b/libstdc++-v3/include/experimental/string_view
@@ -49,11 +49,12 @@ namespace experimental
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   /**
-   *  @class basic_string_view 
+   *  @class basic_string_view 
*  @brief  A non-owning reference to a string.
*
*  @ingroup strings
*  @ingroup sequences
+   *  @ingroup experimental
*
*  @tparam _CharT  Type of character
*  @tparam _Traits  Traits for character type, defaults to
diff --git a/libstdc++-v3/include/std/bitset b/libstdc++-v3/include/std/bitset
index b89a283..c58da82 100644
--- a/libstdc++-v3/include/std/bitset
+++ b/libstdc++-v3/include/std/bitset
@@ -681,9 +681,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 #endif
 
   /**
-   *  The %bitset class represents a @e fixed-size sequence of bits.
+   *  @class bitset 
*
-   *  @ingroup containers
+   *  @brief The %bitset class represents a @e fixed-size sequence of bits.
+   *  @ingroup utilities
*
*  (Note that %bitset does @e not meet the formal requirements of a
*  container.  Mainly, it lacks iterators.)
diff --git a/libstdc++-v3/include/tr2/dynamic_bitset b/libstdc++-v3/include/tr2/dynamic_bitset
index dba145b..755584f 100644
--- a/libstdc++-v3/include/tr2/dynamic_b

Re: [PATCH] proposed fix for bug # 61144

2014-06-14 Thread Rich Felker
Ping. Do you have any feedback on my tests? What is the next step?

Rich

On Mon, Jun 09, 2014 at 03:40:44PM +0400, Alexander Monakov wrote:
> 
> 
> On Fri, 6 Jun 2014, Rich Felker wrote:
> 
> > On Fri, May 23, 2014 at 12:26:18PM -0600, Jeff Law wrote:
> > > On 05/21/14 21:59, Rich Felker wrote:
> > > >On Wed, May 21, 2014 at 11:17:53AM +0200, Richard Biener wrote:
> > > >>On Wed, May 21, 2014 at 3:59 AM, Rich Felker  wrote:
> > > >>>Bug # 61144 is a regression in 4.9.0 that breaks building of musl libc
> > > >>>due to aggressive and semantically-incorrect constant folding of weak
> > > >>>aliases. The attached patch seems to fix the issue. A weak alias
> > > >>>should never be a candidate for constant folding because it may always
> > > >>>be replaced by a strong definition from another translation unit.
> > > >>>
> > > >>>For details see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61144
> > > >>>
> > > >>>I do not have a copyright assignment on file but this patch should be
> > > >>>sufficiently trivial not to require it.
> > > >>
> > > >>Please add a testcase.  Also I wonder why it isn't better to generalize
> > > >
> > > >How should a testcase be done? On the PR there's a testcase that shows
> > > >the problem in the generated code, but no automated check for it.
> > > >Testing this is actually a bit of a pain unless you're allowed to run
> > > >the generated program.
> > > You can run the test program.  Have it exit (0) on success, abort ()
> > > on failure if at all possible.  Then drop the test source file into
> > > gcc/testsuite/gcc.c-torture/execute/pr61144.c
> > 
> > The test needs to be two translation units linked together: one with
> > a weak definition of the object as 0, and the other with a strong
> > definition. The test should show the weak value being used rather than
> > the strong one. But I'm not sure how this should be integrated with
> > the build process.
> 
> Please have a look at gcc/testsuite/gcc.dg/special/wkali-2{,a,b}.c.  This is a
> three-TU test for weak aliases, so you should be able to very easily adjust it
> for this bug.
> 
> Thanks.
> Alexander


Re: [C++ Patch] PR 33101

2014-06-14 Thread Jason Merrill

OK, thanks.  :)

Jason


Re: [C++ Patch] PR 33101

2014-06-14 Thread Paolo Carlini

Hi,

On 06/15/2014 12:17 AM, Jason Merrill wrote:

OK, thanks.  :)
Committed... but, I don't think we are done yet, because it seems to me 
that DR577 means that in C++11 mode we have to accept the typedef?!? 
That's what current icc does... (I thought the issue was only about 
clearer diagnostic ;)


Paolo.


libstdc++ regressions with "Move DECL_SECTION_NAME into symtab"

2014-06-14 Thread Hans-Peter Nilsson
On Wed, 11 Jun 2014, Jan Hubicka wrote:

>   * varasm.c (set_implicit_section): New function.
>   (resolve_unique_section): Use it to set implicit section
>   for aliases, too.
>   (get_named_text_section): Use symtab_get_node (decl)->implicit_section
>   (default_function_section): Likewise.
>   (decl_binds_to_current_def_p): Constify argument.
>   * varasm.h (decl_binds_to_current_def_p): Update prototype.
>   * asan.c (asan_protect_global): Use symtab_get_node 
> (decl)->implicit_section.
>   * symtab.c (dump_symtab_base): Dump implicit sections.
>   (verify_symtab_base): Verify sanity of sectoins and comdats.
>   (symtab_resolve_alias): Alias share the section of its target.
>   (set_section_1): New function.
>   (symtab_node::set_section): Move here, recurse to aliases.
>   (verify_symtab): Check for duplicated symtab lists.
>   * tree-core.h (implicit_section_name_p): Remove.
>   * tree-vect-data-refs.c: Include varasm.h.
>   (vect_can_force_dr_alignment_p): Fix conditional on when
>   decl bints to current definition; use
>   symtab_get_node (decl)->implicit_section.
>   * cgraph.c (cgraph_make_node_local_1): Fix section set.
>   * cgraph.h (struct symtab_node): Add implicit_section.
>   (set_section): Rename to ...
>   (set_section_for_node): ... this one.
>   (set_section): Declare.
>   * tree.h (DECL_HAS_IMPLICIT_SECTION_NAME_P): Remove.
>   * lto-cgraph.c (lto_output_node, lto_output_varpool_node,
>   input_overwrite_node, input_varpool_node): Stream implicit_section.
>   * ipa.c (symtab_remove_unreachable_nodes): Do not check symtab before
>   removal; it will fail in LTO.
>
>   * vtable-class-hierarchy.c: Use symtab_get_node 
> (var_decl)->implicit_section.
>   * optimize.c (cdtor_comdat_group): Fix handling of aliases.
>   (maybe_clone_body): Move symbol across comdat groups.
>   * method.c (use_thunk): Copy implicit section flag.
>
>   * go/go-gcc.cc (Gcc_backend::global_variable_set_init): Use
>   symtab_get_node(var_decl)->implicit_section.
>
>   * lto.c (read_cgraph_and_symbols): Remove unreachable symbols.
>   (do_whole_program_analysis): Use verify_symtab.

This (r211434) seems to have caused PR61510.

brgds, H-P


Re: [PATCH 1/n] Add conditional compare framework in middle-end

2014-06-14 Thread Andrew Pinski
On Mon, Feb 24, 2014 at 1:18 AM, Zhenqiang Chen
 wrote:
> Hi,
>
> The patch (http://gcc.gnu.org/ml/gcc-patches/2014-11/msg03622.html) is
> re-based (the arm port change is stripped as a separate patch), which
> includes only the middle-end changes. The basic logic for the patch
> is:
>
>   1) Identify conditional compare candidates when expanding one GIMPLE_COND.
>   2) For a candidate, it uses two target hooks to generate the expected codes:
>  - gen_ccmp_first expands the first compare in CCMP.
>  - gen_ccmp_next expands the following compares.
>
>  Another hook select_ccmp_cmp_order is called to determine which compare
>  is done first since not all combination of compares are legal in some
>  target like ARM.  We might get more chance when swapping the compares.
>  For AARCH64 and IA64, we do not need such check.
>
>  During expanding, we must make sure that no instruction can clobber the
>  CC reg except the compares.
>
>  If the final result is not used in a COND_EXPR, it calls cstorecc4 
> pattern
>   to store the CC to a general register.
>
> Bootstrap and no make check regression on X86-64.

I was testing this patch set out on AARCH64 with an addition patch to
define cstorecc4 and found an issue:
+  rtx target = gen_reg_rtx (word_mode);
+  tmp = emit_cstore (target, icode, NE, CCmode, CCmode,
+ 0, tmp, const0_rtx, 1, word_mode);
+  if (tmp)
+return tmp;

The wrong mode is being used in the above code.
The testcase is:
_Bool f(int a, int b)
{
  return a != 0 && b != 0;
}
 CUT 

I am working on the patch to fix this issue.

Thanks,
Andrew


>
> Is is OK for next stage1?
>
> Thanks!
> -Zhenqiang
>
> ChangeLog:
> 2014-02-24  Zhenqiang Chen  
>
> * cfgexpand.c (expand_gimple_cond): Check ccmp support.
> * doc/md.texi (ccmp): New index.
> * doc/tm.texi (TARGET_SELECT_CCMP_CMP_ORDER, TARGET_GEN_CCMP_FIRST,
> TARGET_GEN_CCMP_NEXT): New hooks.
> * doc/tm.texi (TARGET_SELECT_CCMP_CMP_ORDER, TARGET_GEN_CCMP_FIRST,
> TARGET_GEN_CCMP_NEXT): New hooks.
> * doc/tm.texi.in (TARGET_SELECT_CCMP_CMP_ORDER, TARGET_GEN_CCMP_FIRST,
> TARGET_GEN_CCMP_NEXT): New hooks.
> * expmed.c (emit_cstore): Make it global.
> * expr.c: Include tree-phinodes.h and ssa-iterators.h.
> (ccmp_candidate_p, used_in_cond_stmt_p, check_clobber_cc, clobber_cc_p,
> gen_ccmp_next, expand_ccmp_expr_1, expand_ccmp_expr): New functions.
> (expand_expr_real_1): Handle conditional compare.
> * optabs.c (get_rtx_code): Make it global and handle BIT_AND_EXPR and
> BIT_IOR_EXPR.
> * optabs.h (get_rtx_code, emit_cstore): New prototypes.
> * recog.c (ccmp_insn_p): New function.
> (simplify_while_replacing): Do not swap ccmp insn.
> * target.def (select_ccmp_cmp_order, gen_ccmp_first, gen_ccmp_next):
> Define hooks.
> * targhooks.c (default_select_ccmp_cmp_order): New function.
> * targhooks.h (default_select_ccmp_cmp_order): New prototypes.


Re: [PATCH, libgfortran] Add overflow check to xmalloc

2014-06-14 Thread Janne Blomqvist
PING #3

On Sat, Jun 7, 2014 at 5:46 AM, Janne Blomqvist
 wrote:
> PING #2
>
> On Fri, May 30, 2014 at 5:53 PM, Janne Blomqvist
>  wrote:
>> PING
>>
>> On Tue, May 20, 2014 at 12:42 AM, Janne Blomqvist
>>  wrote:
>>> On Thu, May 15, 2014 at 1:00 AM, Janne Blomqvist
>>>  wrote:
 Hi,

 a common malloc() pattern is "malloc(num_foo * sizeof(foo_t)", that
 is, create space for an array of type foo_t with num_foo elements.
 There is a slight danger here in that the multiplication can overflow
 and wrap around, and then the caller thinks it has a larger array than
 what malloc has actually created. The attached patch changes the
 libgfortran xmalloc() function to have an API similar to calloc() with
 two arguments, and the implementation checks for wraparound.
>>>
>>> Hello,
>>>
>>> attached is an updated patch which instead introduces a new function,
>>> xmallocarray, with the overflow check, and leaves the existing xmalloc
>>> as is. Thus avoiding the extra checking in the common case where one
>>> of the arguments to xmallocarray would be 1.
>>>
>>> Tested on x86_64-unknown-linux-gnu, Ok for trunk?
>>>
>>> 2014-05-20  Janne Blomqvist  
>>>
>>> * libgfortran.h (xmallocarray): New prototype.
>>> * runtime/memory.c (xmallocarray): New function.
>>> (xcalloc): Check for nonzero separately instead of multiplying.
>>> * generated/*.c: Regenerated.
>>> * intrinsics/cshift0.c (cshift0): Call xmallocarray instead of
>>> xmalloc.
>>> * intrinsics/eoshift0.c (eoshift0): Likewise.
>>> * intrinsics/eoshift2.c (eoshift2): Likewise.
>>> * intrinsics/pack_generic.c (pack_internal): Likewise.
>>> (pack_s_internal): Likewise.
>>> * intrinsics/reshape_generic.c (reshape_internal): Likewise.
>>> * intrinsics/spread_generic.c (spread_internal): Likewise.
>>> (spread_internal_scalar): Likewise.
>>> * intrinsics/string_intrinsics_inc.c (string_trim): Likewise.
>>> (string_minmax): Likewise.
>>> * intrinsics/transpose_generic.c (transpose_internal): Likewise.
>>> * intrinsics/unpack_generic.c (unpack_internal): Likewise.
>>> * io/list_read.c (nml_touch_nodes): Don't cast xmalloc return value.
>>> * io/transfer.c (st_set_nml_var): Call xmallocarray instead of
>>> xmalloc.
>>> * io/unit.c (get_internal_unit): Likewise.
>>> (filename_from_unit): Don't cast xmalloc return value.
>>> * io/write.c (nml_write_obj): Likewise, formatting.
>>> * m4/bessel.m4 (bessel_jn_r'rtype_kind`): Call xmallocarray
>>> instead of xmalloc.
>>> (besse_yn_r'rtype_kind`): Likewise.
>>> * m4/cshift1.m4 (cshift1): Likewise.
>>> * m4/eoshift1.m4 (eoshift1): Likewise.
>>> * m4/eoshift3.m4 (eoshift3): Likewise.
>>> * m4/iforeach.m4: Likewise.
>>> * m4/ifunction.m4: Likewise.
>>> * m4/ifunction_logical.m4 (name`'rtype_qual`_'atype_code):
>>> Likewise.
>>> * m4/in_pack.m4 (internal_pack_'rtype_ccode`): Likewise.
>>> * m4/matmul.m4 (matmul_'rtype_code`): Likewise.
>>> * m4/matmull.m4 (matmul_'rtype_code`): Likewise.
>>> * m4/pack.m4 (pack_'rtype_code`): Likewise.
>>> * m4/reshape.m4 (reshape_'rtype_ccode`): Likewise.
>>> * m4/shape.m4 (shape_'rtype_kind`): Likewise.
>>> * m4/spread.m4 (spread_'rtype_code`): Likewise.
>>> (spread_scalar_'rtype_code`): Likewise.
>>> * m4/transpose.m4 (transpose_'rtype_code`): Likewise.
>>> * m4/unpack.m4 (unpack0_'rtype_code`): Likewise.
>>> (unpack1_'rtype_code`): Likewise.
>>> * runtime/convert_char.c (convert_char1_to_char4): Likewise.
>>> (convert_char4_to_char1): Simplify.
>>> * runtime/environ.c (init_unformatted): Call xmallocarray instead
>>> of xmalloc.
>>> * runtime/in_pack_generic.c (internal_pack): Likewise.
>>>
>>>
>>>
>>>
>>> --
>>> Janne Blomqvist
>>
>>
>>
>> --
>> Janne Blomqvist
>
>
>
> --
> Janne Blomqvist



-- 
Janne Blomqvist


Re: [libgfortran, patch] Fix compilation on HP/UX 10

2014-06-14 Thread Janne Blomqvist
Ok.

(as an aside, has anyone ever heard of anyone actually using gfortran on hp-ux?)

On Sat, Jun 14, 2014 at 10:07 PM, FX  wrote:
> ping
>
>> Attached patch should fix compilation of libgfortran on hppa1.1-hp-hpux10.20 
>> (see PR60468: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60468), by adding 
>> a missing  header to the configure checks.
>>
>> I’ve tested that it doesn’t break bootstrap on x86_64-apple-darwin, but not 
>> on hpux10. It seems safe enough to me to proceed first, and let John test in 
>> his next build of trunk (bootstrap on those machines probably isn’t fast).
>>
>> OK to commit?
>>
>> FX
>



-- 
Janne Blomqvist


Re: [PATCH, libgfortran] Add overflow check to xmalloc

2014-06-14 Thread Bernhard Reutner-Fischer



>> On Tue, May 20, 2014 at 12:42 AM, Janne Blomqvist
>>  wrote:
>>> On Thu, May 15, 2014 at 1:00 AM, Janne Blomqvist
>>>  wrote:
 Hi,

 a common malloc() pattern is "malloc(num_foo * sizeof(foo_t)", that
 is, create space for an array of type foo_t with num_foo elements.
 There is a slight danger here in that the multiplication can overflow
 and wrap around, and then the caller thinks it has a larger array than
 what malloc has actually created. The attached patch changes the
 libgfortran xmalloc() function to have an API similar to calloc() with
 two arguments, and the implementation checks for wraparound.
>>>
>>> Hello,
>>>
>>> attached is an updated patch which instead introduces a new function,
>>> xmallocarray, with the overflow check, and leaves the existing xmalloc
>>> as is. Thus avoiding the extra checking in the common case where one
>>> of the arguments to xmallocarray would be 1.
>>>
>>> Tested on x86_64-unknown-linux-gnu, Ok for trunk?
>>>


I would prefer if xcmalloc would not be named xmallocarray.

Thanks,

Sent with AquaMail for Android
http://www.aqua-mail.com