[google] change dump_inline_decisions to make it print more useful and better looking info

2011-12-30 Thread Dehao Chen
Hi,

This patch makes the -fopt-info print more concise info:
1. only inline decisions after einline are printed
2. print in a more compact format

Bootstrapped with no problem.

Is it okay for google-4_6 and google-main branch?

Thanks,
Dehao

gcc/ChangeLog.google-4_6
2011-12-30  Dehao Chen  

* ipa-inline.c (dump_inline_decision): Print more concise info when
dumping inline decisions.

Index: gcc/ipa-inline.c
===
--- gcc/ipa-inline.c(revision 182739)
+++ gcc/ipa-inline.c(working copy)
@@ -303,26 +303,19 @@
   char *buf;
   size_t buf_size;
   const char *bfd_name = lang_hooks.dwarf_name (node->decl, 0);
-  const char *count_text = "count=";
-  const char *max_count_text = "max_count=";

   if (!bfd_name)
 bfd_name = "unknown";

   buf_size = strlen (bfd_name) + 1;
   if (flag_opt_info >= OPT_INFO_MED)
-buf_size += (strlen (count_text) + MAX_INT_LENGTH + 1);
-  if (flag_opt_info >= OPT_INFO_MAX)
-buf_size += (strlen (max_count_text) + MAX_INT_LENGTH + 1);
+buf_size += (2 * MAX_INT_LENGTH + 5);
   buf = (char *) xmalloc (buf_size);

   strcpy (buf, bfd_name);
   if (flag_opt_info >= OPT_INFO_MED)
-sprintf (buf, "%s,%s"HOST_WIDEST_INT_PRINT_DEC,
-buf, count_text, node->count);
-  if (flag_opt_info >= OPT_INFO_MAX)
-sprintf (buf, "%s,%s"HOST_WIDEST_INT_PRINT_DEC,
-buf, max_count_text, node->max_bb_count);
+sprintf (buf, "("HOST_WIDEST_INT_PRINT_DEC", "HOST_WIDEST_INT_PRINT_DEC")",
+node->count, node->max_bb_count);
   return buf;
 }

@@ -369,6 +362,14 @@
   const char *inline_chain_text;
   const char *call_count_text;
   struct cgraph_node *final_caller = edge->caller;
+  tree decl = edge->caller->decl;
+
+  if (decl)
+{
+  struct function *fn = DECL_STRUCT_FUNCTION (decl);
+  if (!fn || !fn->always_inline_functions_inlined)
+   return;
+}

   if (final_caller->global.inlined_to != NULL)
 inline_chain_text = cgraph_node_call_chain (final_caller, &final_caller);


Re: [google] change dump_inline_decisions to make it print more useful and better looking info

2011-12-30 Thread Xinliang David Li
the early inline decisions are still good to dump out. However the
opt-info should check 'if (profile_info)' to decide if count and max
count info need to be dumped.

David

On Fri, Dec 30, 2011 at 12:31 AM, Dehao Chen  wrote:
> Hi,
>
> This patch makes the -fopt-info print more concise info:
> 1. only inline decisions after einline are printed
> 2. print in a more compact format
>
> Bootstrapped with no problem.
>
> Is it okay for google-4_6 and google-main branch?
>
> Thanks,
> Dehao
>
> gcc/ChangeLog.google-4_6
> 2011-12-30  Dehao Chen  
>
>        * ipa-inline.c (dump_inline_decision): Print more concise info when
>        dumping inline decisions.
>
> Index: gcc/ipa-inline.c
> ===
> --- gcc/ipa-inline.c    (revision 182739)
> +++ gcc/ipa-inline.c    (working copy)
> @@ -303,26 +303,19 @@
>   char *buf;
>   size_t buf_size;
>   const char *bfd_name = lang_hooks.dwarf_name (node->decl, 0);
> -  const char *count_text = "count=";
> -  const char *max_count_text = "max_count=";
>
>   if (!bfd_name)
>     bfd_name = "unknown";
>
>   buf_size = strlen (bfd_name) + 1;
>   if (flag_opt_info >= OPT_INFO_MED)
> -    buf_size += (strlen (count_text) + MAX_INT_LENGTH + 1);
> -  if (flag_opt_info >= OPT_INFO_MAX)
> -    buf_size += (strlen (max_count_text) + MAX_INT_LENGTH + 1);
> +    buf_size += (2 * MAX_INT_LENGTH + 5);
>   buf = (char *) xmalloc (buf_size);
>
>   strcpy (buf, bfd_name);
>   if (flag_opt_info >= OPT_INFO_MED)
> -    sprintf (buf, "%s,%s"HOST_WIDEST_INT_PRINT_DEC,
> -            buf, count_text, node->count);
> -  if (flag_opt_info >= OPT_INFO_MAX)
> -    sprintf (buf, "%s,%s"HOST_WIDEST_INT_PRINT_DEC,
> -            buf, max_count_text, node->max_bb_count);
> +    sprintf (buf, "("HOST_WIDEST_INT_PRINT_DEC", 
> "HOST_WIDEST_INT_PRINT_DEC")",
> +            node->count, node->max_bb_count);
>   return buf;
>  }
>
> @@ -369,6 +362,14 @@
>   const char *inline_chain_text;
>   const char *call_count_text;
>   struct cgraph_node *final_caller = edge->caller;
> +  tree decl = edge->caller->decl;
> +
> +  if (decl)
> +    {
> +      struct function *fn = DECL_STRUCT_FUNCTION (decl);
> +      if (!fn || !fn->always_inline_functions_inlined)
> +       return;
> +    }
>
>   if (final_caller->global.inlined_to != NULL)
>     inline_chain_text = cgraph_node_call_chain (final_caller, &final_caller);


Re: [PATCH] Fix PR bootstrap/51705

2011-12-30 Thread Jakub Jelinek
On Thu, Dec 29, 2011 at 08:12:51PM -0800, Steve Kargl wrote:
> The audit trail in the PR pretty much sums up the problem.
> OK to commit?

Can you tune up the comments a little bit?
If you look up http://gcc.gnu.org/gcc-4.7/cxx0x_status.html
you'll see that most of the C++11 features are already implemented
(and e.g. at_quick_exit is implemented too in some libcs), so the
__cplusplus macro isn't lying.  Clang apparently defines __cplusplus
to 201103L much longer than GCC does, yet it supports much smaller subset
of C++11.  Apparently it parses the C++11 generalized attribute syntax,
but at least clang 3.0 doesn't complain at all about anything between
the [[ and ]] pair, [[foobar, foobaz (bar, baz, 2, 6, 0x1z2)]] void bar (void);
is parsed just fine, and with [[noreturn]] it miscompiles even the first
[[noreturn]] trivial testcase I wrote.
See
http://gcc.gnu.org/ml/gcc-patches/2011-10/msg02027.html
for why we set __cplusplus to the value we do.
So please leave about the "disgusting", "brain damage", "lies" etc.

> 2011-12-29  Steven G. Kargl  
> 
>   * inclhack.def:  Disgusting hack to workaround brain damage of
>   defining __cplusplus as 201103L with -std=c++11 when g++ does
>   not support c++11.
>   * fixincl.x: regenerated.
>   * genfixes: Fix to version test.
> 
> -- 
> Steve

> Index: inclhack.def
> ===
> --- inclhack.def  (revision 182738)
> +++ inclhack.def  (working copy)
> @@ -20,6 +20,21 @@ autogen definitions fixincl;
>  FIXINC_DEBUG = yes;
>  #endif
>  
> +/*
> + * g++ -std=c++11 defines __cplusplus to 201103L, which lies about
> + * the level of support g++ has for the C++11 standard.
> + */

Jakub


[v3] PR libstdc++/51711

2011-12-30 Thread Paolo Carlini

Hi,

applied mainline and 4_6-branch.

Thanks,
Paolo.

/
2011-12-30  Paolo Carlini  

PR libstdc++/51711
* include/bits/regex.h (regex_replace): Fix thinko.
* testsuite/28_regex/algorithms/regex_replace/char/51711.cc: New.
* testsuite/28_regex/algorithms/regex_replace/wchar_t/51711.cc:
Likewise.
Index: include/bits/regex.h
===
--- include/bits/regex.h(revision 182739)
+++ include/bits/regex.h(working copy)
@@ -2223,7 +2223,7 @@
  regex_constants::match_flag_type __flags
  = regex_constants::match_default)
 {
-  std::string __result;
+  basic_string<_Ch_type> __result;
   regex_replace(std::back_inserter(__result),
__s.begin(), __s.end(), __e, __fmt, __flags);
   return __result;
Index: testsuite/28_regex/algorithms/regex_replace/wchar_t/51711.cc
===
--- testsuite/28_regex/algorithms/regex_replace/wchar_t/51711.cc
(revision 0)
+++ testsuite/28_regex/algorithms/regex_replace/wchar_t/51711.cc
(revision 0)
@@ -0,0 +1,31 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+
+// Copyright (C) 2011 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.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// .
+//
+
+#include 
+#include 
+
+// libstdc++/51711
+void test01()
+{
+  std::wstring toProcess(L"Bug\r\n");
+  std::wstring result __attribute__((unused))
+= std::regex_replace(toProcess, std::wregex(L"\\r"), std::wstring(L"\\r"));
+}
Index: testsuite/28_regex/algorithms/regex_replace/char/51711.cc
===
--- testsuite/28_regex/algorithms/regex_replace/char/51711.cc   (revision 0)
+++ testsuite/28_regex/algorithms/regex_replace/char/51711.cc   (revision 0)
@@ -0,0 +1,31 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+
+// Copyright (C) 2011 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.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// .
+//
+
+#include 
+#include 
+
+// libstdc++/51711
+void test01()
+{
+  std::string toProcess("Bug\r\n");
+  std::string result __attribute__((unused))
+= std::regex_replace(toProcess, std::regex("\\r"), std::string("\\r"));
+}


Re: [RFA/ARM][Patch 02/05]: LDRD generation instead of POP in A15 Thumb2 epilogue.

2011-12-30 Thread Sameera Deshpande
Hi!

Please find attached revised LDRD generation patch for A15 Thumb-2 mode.

Because of the major rework in ARM and Thumb-2 RTL epilogue patches,
this patch has undergone some changes.

The patch is tested with check-gcc, bootstrap and check-gdb without
regression.

Ok for trunk?

-- diff --git a/gcc/config/arm/arm-protos.h b/gcc/config/arm/arm-protos.h
index 64d5993..49aae52 100644
--- a/gcc/config/arm/arm-protos.h
+++ b/gcc/config/arm/arm-protos.h
@@ -201,6 +201,7 @@ extern void thumb_reload_in_hi (rtx *);
 extern void thumb_set_return_address (rtx, rtx);
 extern const char *thumb1_output_casesi (rtx *);
 extern const char *thumb2_output_casesi (rtx *);
+extern bool bad_reg_pair_for_thumb_ldrd_strd (rtx, rtx);
 #endif
 
 /* Defined in pe.c.  */
diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index d671281..6d008c5 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -15847,6 +15847,154 @@ arm_emit_vfp_multi_reg_pop (int first_reg, int num_regs, rtx base_reg)
   REG_NOTES (par) = dwarf;
 }
 
+bool
+bad_reg_pair_for_thumb_ldrd_strd (rtx src1, rtx src2)
+{
+  return (GET_CODE (src1) != REG
+  || GET_CODE (src2) != REG
+  || (REGNO (src1) == PC_REGNUM)
+  || (REGNO (src1) == SP_REGNUM)
+  || (REGNO (src1) == REGNO (src2))
+  || (REGNO (src2) == PC_REGNUM)
+  || (REGNO (src2) == SP_REGNUM));
+}
+
+/* Generate and emit a pattern that will be recognized as LDRD pattern.  If even
+   number of registers are being popped, multiple LDRD patterns are created for
+   all register pairs.  If odd number of registers are popped, last register is
+   loaded by using LDR pattern.  */
+static void
+thumb2_emit_ldrd_pop (unsigned long saved_regs_mask, bool really_return)
+{
+  int num_regs = 0;
+  int i, j;
+  rtx par = NULL_RTX;
+  rtx dwarf = NULL_RTX;
+  rtx tmp, reg, tmp1;
+
+  for (i = 0; i <= LAST_ARM_REGNUM; i++)
+if (saved_regs_mask & (1 << i))
+  num_regs++;
+
+  gcc_assert (num_regs && num_regs <= 16);
+  gcc_assert (really_return || ((saved_regs_mask & (1 << PC_REGNUM)) == 0));
+
+  /* We cannot generate ldrd for PC.  Hence, reduce the count if PC is
+ to be popped.  So, if num_regs is even, now it will become odd,
+ and we can generate pop with PC.  If num_regs is odd, it will be
+ even now, and ldr with return can be generated for PC.  */
+  if (really_return && (saved_regs_mask & (1 << PC_REGNUM)))
+num_regs--;
+
+  /* Var j iterates over all the registers to gather all the registers in
+ saved_regs_mask.  Var i gives index of saved registers in stack frame.
+ A PARALLEL RTX of register-pair is created here, so that pattern for
+ LDRD can be matched.  As PC is always last register to be popped, and
+ we have already decremented num_regs if PC, we don't have to worry
+ about PC in this loop.  */
+  for (i = 0, j = 0; i < (num_regs - (num_regs % 2)); j++)
+if (saved_regs_mask & (1 << j))
+  {
+gcc_assert (j != SP_REGNUM);
+
+/* Create RTX for memory load.  */
+reg = gen_rtx_REG (SImode, j);
+tmp = gen_rtx_SET (SImode,
+   reg,
+   gen_frame_mem (SImode,
+   plus_constant (stack_pointer_rtx, 4 * i)));
+RTX_FRAME_RELATED_P (tmp) = 1;
+
+if (i % 2 == 0)
+  {
+/* When saved-register index (i) is even, the RTX to be emitted is
+   yet to be created.  Hence create it first.  The LDRD pattern we
+   are generating is :
+   [ (SET (reg_t0) (MEM (PLUS (SP) (NUM
+ (SET (reg_t1) (MEM (PLUS (SP) (NUM + 4 ]
+   where target registers need not be consecutive.  */
+par = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (2));
+dwarf = NULL_RTX;
+  }
+
+/* ith register is added in PARALLEL RTX.  If i is even, the reg_i is
+   added as 0th element and if i is odd, reg_i is added as 1st element
+   of LDRD pattern shown above.  */
+XVECEXP (par, 0, (i % 2)) = tmp;
+dwarf = alloc_reg_note (REG_CFA_RESTORE, reg, dwarf);
+
+if ((i % 2) == 1)
+  {
+/* When saved-register index (i) is odd, RTXs for both the registers
+   to be loaded are generated in above given LDRD pattern, and the
+   pattern can be emitted now.  */
+par = emit_insn (par);
+REG_NOTES (par) = dwarf;
+  }
+
+i++;
+  }
+
+  /* If the number of registers pushed is odd AND really_return is false OR
+ number of registers are even AND really_return is true, last register is
+ popped using LDR.  It can be PC as well.  Hence, adjust the stack first and
+ then LDR with post increment.  */
+
+  /* Increment the stack pointer, based on there being
+ num_regs 4-byte registers to restore.  */
+  tmp = gen_rtx_SET (VOIDmode,
+ stack_pointer_rtx,
+  

Re: [RFA/ARM][Patch 05/05]: LDRD generation instead of POP in A15 ARM epilogue.

2011-12-30 Thread Sameera Deshpande
Hi Ramana,

Please find attached revised LDRD generation patch for A15 ARM mode.

Because of the major rework in ARM RTL epilogue patch, this patch has
undergone some changes.

The patch is tested with check-gcc, bootstrap and check-gdb without
regression.

Ok for trunk?

-- diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index d5c651c..46becfb 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -16101,6 +16101,135 @@ bad_reg_pair_for_thumb_ldrd_strd (rtx src1, rtx src2)
   || (REGNO (src2) == SP_REGNUM));
 }
 
+/* LDRD in ARM mode needs consecutive registers to be stored.  This function
+   keeps accumulating non-consecutive registers until first consecutive register
+   pair is found.  It then generates multi-reg POP for all accumulated
+   registers, and then generates LDRD with write-back for consecutive register
+   pair.  This process is repeated until all the registers are loaded from
+   stack.  multi register POP takes care of lone registers as well.  However,
+   LDRD cannot be generated for PC, as results are unpredictable.  Hence, if PC
+   is in SAVED_REGS_MASK, generate multi-reg POP with RETURN or LDR with RETURN
+   depending upon number of registers in REGS_TO_BE_POPPED_MASK.  */
+static void
+arm_emit_ldrd_pop (unsigned long saved_regs_mask, bool really_return)
+{
+  int num_regs = 0;
+  int i, j;
+  rtx par = NULL_RTX;
+  rtx insn = NULL_RTX;
+  rtx dwarf = NULL_RTX;
+  rtx tmp;
+  unsigned long regs_to_be_popped_mask = 0;
+  bool pc_in_list = false;
+
+  for (i = 0; i <= LAST_ARM_REGNUM; i++)
+if (saved_regs_mask & (1 << i))
+  num_regs++;
+
+  gcc_assert (num_regs && num_regs <= 16);
+
+  for (i = 0, j = 0; i < num_regs; j++)
+if (saved_regs_mask & (1 << j))
+  {
+i++;
+if ((j % 2) == 0
+&& (saved_regs_mask & (1 << (j + 1)))
+&& (j + 1) != SP_REGNUM
+&& (j + 1) != PC_REGNUM
+&& regs_to_be_popped_mask)
+  {
+/* Current register and next register form register pair for which
+   LDRD can be generated.  Generate POP for accumulated registers
+   and reset regs_to_be_popped_mask.  SP should be handled here as
+   the results are unpredictable if register being stored is same
+   as index register (in this case, SP).  PC is always the last
+   register being popped.  Hence, we don't have to worry about PC
+   here.  */
+arm_emit_multi_reg_pop (regs_to_be_popped_mask, pc_in_list);
+pc_in_list = false;
+regs_to_be_popped_mask = 0;
+continue;
+  }
+
+if (j == PC_REGNUM)
+  {
+gcc_assert (really_return);
+pc_in_list = 1;
+  }
+
+regs_to_be_popped_mask |= (1 << j);
+
+if ((j % 2) == 1
+&& (saved_regs_mask & (1 << (j - 1)))
+&& j != SP_REGNUM
+&& j != PC_REGNUM)
+  {
+ /* Generate a LDRD for register pair R_, R_.  The pattern
+generated here is
+[(SET SP, (PLUS SP, 8))
+ (SET R_, (MEM SP))
+ (SET R_, (MEM (PLUS SP, 4)))].  */
+ par = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (3));
+
+ tmp = gen_rtx_SET (VOIDmode,
+stack_pointer_rtx,
+plus_constant (stack_pointer_rtx, 8));
+ RTX_FRAME_RELATED_P (tmp) = 1;
+ XVECEXP (par, 0, 0) = tmp;
+
+ tmp = gen_rtx_SET (SImode,
+gen_rtx_REG (SImode, j - 1),
+gen_frame_mem (SImode, stack_pointer_rtx));
+ RTX_FRAME_RELATED_P (tmp) = 1;
+ XVECEXP (par, 0, 1) = tmp;
+ dwarf = alloc_reg_note (REG_CFA_RESTORE,
+ gen_rtx_REG (SImode, j - 1),
+ dwarf);
+
+ tmp = gen_rtx_SET (SImode,
+ gen_rtx_REG (SImode, j),
+ gen_frame_mem (SImode,
+   plus_constant (stack_pointer_rtx, 4)));
+ RTX_FRAME_RELATED_P (tmp) = 1;
+ XVECEXP (par, 0, 2) = tmp;
+ dwarf = alloc_reg_note (REG_CFA_RESTORE,
+ gen_rtx_REG (SImode, j),
+ dwarf);
+
+ insn = emit_insn (par);
+ REG_NOTES (insn) = dwarf;
+ pc_in_list = false;
+ regs_to_be_popped_mask = 0;
+ dwarf = NULL_RTX;
+  }
+  }
+
+  if (regs_to_be_popped_mask)
+{
+  /* single PC pop can happen here.  Take care of that.  */
+  if (pc_in_list && (regs_to_be_popped_mask == (1 << PC_REGNUM)))
+{
+  /* Only PC is to be popped.  */
+  par = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (2));
+  XVECEXP (par

Re: adjust installation docs to discourage installing GMP, MPFR and MPC separately

2011-12-30 Thread Jonathan Wakely
On 22 December 2011 00:23, Jonathan Wakely wrote:
> The most frequently asked question on gcc-help, and a frequently
> reported "bug" in bugzilla, is
> http://gcc.gnu.org/wiki/FAQ#configure_suffix
>
> It is almost always caused by installing libgmp.so etc. in a
> non-standard location and not using ldconfig, DT_RUNPATH,
> $LD_LIBRARY_PATH or some other method to tell the dynamic linker how
> to find them.  The current installation docs mention --with-gmp right
> away, which probably gives the impression that it's the recommended
> method, whereas it actually causes problems for the majority of users
> who don't understand dynamic linker search paths.  I think rewording
> the installation docs to suggest building the support libs as part of
> GCC first, and only using --with-gmp second, might steer people in the
> right direction.
>
> Separately, I also plan to write an "Installing GCC" page on the GCC
> wiki which (among other things) discourages installing the support
> libraries by hand, recommending installing prebuilt packages in
> standard system dirs instead, or if that's not an option then using
> contrib/download_prerequisites to get the sources and build them
> in-tree.
>
>
>        * doc/install.text (Prerequisites): Suggest building GMP, MPFR and
>        MPC as part of GCC before describing configuring with --with-gmp etc.
>
> Tested by running "make doc" and viewing the resulting .info pages, OK
> for trunk?

Here's an updated patch which also adjusts the --with-gmp docs in the
Configuration chapter to mention the option of putting the support lib
sources under the GCC sources

* doc/install.texi (Prerequisites): Suggest building GMP, MPFR and
MPC as part of GCC before describing configuring with --with-gmp etc.
(Installing GCC: Configuration): State that --with-gmp etc. aren't
needed if sources are present.

OK for trunk?
Index: doc/install.texi
===
--- doc/install.texi(revision 182629)
+++ doc/install.texi(working copy)
@@ -333,32 +333,35 @@ newer versions, though.
 @table @asis
 @item GNU Multiple Precision Library (GMP) version 4.3.2 (or later)
 
-Necessary to build GCC@.  If you do not have it installed in your
+Necessary to build GCC@.  If a GMP source distribution is found in a
+subdirectory of your GCC sources named @file{gmp}, it will be built
+together with GCC, this avoids the need to build GMP separately.
+Alternatively, if GMP is already installed but it is not in your
 library search path, you will have to configure with the
 @option{--with-gmp} configure option.  See also @option{--with-gmp-lib}
-and @option{--with-gmp-include}.  Alternatively, if a GMP source
-distribution is found in a subdirectory of your GCC sources named
-@file{gmp}, it will be built together with GCC@.
+and @option{--with-gmp-include}.
 
 @item MPFR Library version 2.4.2 (or later)
 
 Necessary to build GCC@.  It can be downloaded from
-@uref{http://www.mpfr.org/}.  The @option{--with-mpfr} configure
-option should be used if your MPFR Library is not installed in your
-default library search path.  See also @option{--with-mpfr-lib} and
-@option{--with-mpfr-include}.  Alternatively, if a MPFR source
-distribution is found in a subdirectory of your GCC sources named
-@file{mpfr}, it will be built together with GCC@.
+@uref{http://www.mpfr.org/}.  If an MPFR source distribution is found
+in a subdirectory of your GCC sources named @file{mpfr}, it will be
+built together with GCC, this avoids the need to build MPFR separately.
+Alternatively, if MPFR is already installed but it is not in your
+default library search path, the @option{--with-mpfr} configure
+option should be used.  See also @option{--with-mpfr-lib} and
+@option{--with-mpfr-include}.
 
 @item MPC Library version 0.8.1 (or later)
 
 Necessary to build GCC@.  It can be downloaded from
-@uref{http://www.multiprecision.org/}.  The @option{--with-mpc}
-configure option should be used if your MPC Library is not installed
-in your default library search path.  See also @option{--with-mpc-lib}
-and @option{--with-mpc-include}.  Alternatively, if an MPC source
-distribution is found in a subdirectory of your GCC sources named
-@file{mpc}, it will be built together with GCC@.
+@uref{http://www.multiprecision.org/}.  If an MPC source distribution
+is found in a subdirectory of your GCC sources named @file{mpc}, it
+will be built together with GCC, this avoids the need to build MPC
+separately.  Alternatively, if MPC is already installed but it is
+not in your default library search path, the @option{--with-mpc}
+configure option should be used.  See also @option{--with-mpc-lib}
+and @option{--with-mpc-include}.
 
 @item Parma Polyhedra Library (PPL) version 0.11
 
@@ -1608,9 +1611,10 @@ When neither of these configure options 
 @itemx --with-mpc=@var{pathname}
 @itemx --with-mpc-include=@var{pathname}
 @itemx --with-mpc-lib=@var{pathname}
-If you do not 

[v3] doc updates

2011-12-30 Thread Jonathan Wakely
* doc/xml/manual/extensions.xml: Improve markup and note that some
extensions are included in C++11.
* doc/xml/manual/concurrency_extensions.xml: Likewise.

Tested with 'make doc-xml-validate-docbook doc-html-docbook'

Committed to trunk
Index: doc/xml/manual/extensions.xml
===
--- doc/xml/manual/extensions.xml   (revision 182724)
+++ doc/xml/manual/extensions.xml   (working copy)
@@ -160,7 +160,7 @@ extensions, be aware of two things:
 There are
versions of single-bit test, set, reset, and flip member functions which
do no range-checking.  If we call them member functions of an instantiation
-   of "bitset," then their names and signatures are:
+   of bitset, then their names and signatures are:
 

bitset&   _Unchecked_set   (size_t pos);
@@ -173,14 +173,10 @@ extensions, be aware of two things:
no present plans to do so (and there doesn't seem to be any immediate
reason to).
 
-The semantics of member function operator[] are not 
specified
-   in the C++ standard.  A long-standing defect report calls for sensible
-   obvious semantics, which are already implemented here:  op[]
-   on a const bitset returns a bool, and for a non-const bitset returns a
-   reference (a nested type).  However, this implementation does
-   no range-checking on the index argument, which is in keeping with other
-   containers' op[] requirements.  The defect report's proposed
-   resolution calls for range-checking to be done.  We'll just wait and see...
+The member function operator[] on a const bitset returns
+   a bool, and for a non-const bitset returns a reference (a
+   nested type).  No range-checking is done on the index argument, in keeping
+   with other containers' operator[] requirements.
 
 Finally, two additional searching functions have been added.  They return
the index of the first "on" bit, and the index of the first
@@ -214,16 +210,20 @@ extensions, be aware of two things:
  

are all here;
-   and 
+   and
+  
   are deprecated but available as backwards-compatible extensions,
-  as discussed further below.   is the
-  SGI specialization for large strings ("rope,"
-  "large strings," get it? Love that geeky humor.)
-   is a singly-linked list, for when the
-  doubly-linked list<> is too much space
-  overhead, and  exposes the red-black
-  tree classes used in the implementation of the standard maps and
-  sets.
+  as discussed further below.
+   is the SGI
+  specialization for large strings ("rope," "large strings," get it? Love
+  that geeky humor.)
+   (superseded in
+  C++11 by )
+  is a singly-linked list, for when the doubly-linked 
list<>
+  is too much space overhead, and
+   exposes the
+  red-black tree classes used in the implementation of the standard maps
+  and sets.

Each of the associative containers map, multimap, set, and multiset
   have a counterpart which uses a
@@ -256,6 +256,13 @@ extensions, be aware of two things:
  

 
+   
+  The deprecated hash tables are superseded by the standard unordered
+  associative containers defined in the ISO C++ 2011 standard in the
+  headers 
+  and .
+   
+
   
 
 
@@ -264,36 +271,37 @@ extensions, be aware of two things:
 
 
   
-The  header contains many additional functors
+The  header
+contains many additional functors
 and helper functions, extending section 20.3.  They are
 implemented in the file stl_function.h:
   
   
   
-  identity_element for addition and multiplication. *
+  identity_element for addition and multiplication.
   
   
   
 The functor identity, whose operator()
-  returns the argument unchanged. *
+  returns the argument unchanged.
   
   
   
 Composition functors unary_function and
   binary_function, and their helpers compose1
-  and compose2. *
+  and compose2.
 
   
   
-  select1st and select2nd, to strip pairs. *
+  select1st and select2nd, to strip pairs.
   
   
-  project1st and project2nd. * 

+  project1st and project2nd. 

   A set of functors/functions which always return the same 
result.  They
   are constant_void_fun, constant_binary_fun,
   constant_unary_fun, constant0,
-  constant1, and constant2. * 
-  The class subtractive_rng. * 
+  constant1, and constant2. 
+  The class subtractive_rng. 
   mem_fun adaptor helpers mem_fun1 and
   mem_fun1_ref are provided for backwards compatibility. 

 
@@ -320,11 +328,11 @@ you can also use
 get_temporary_buffer(5, (int*)0);
 
 
-  A class temporary_buffer is given in stl_tempbuf.h. *
+  A class temporary_buffer is given in stl_tempbu

[Patch, Fortran] Deregister allocatable COARRAYS, fixes to (de)allocate

2011-12-30 Thread Tobias Burnus

Dear all,

first, I want to wish all of you a happy New Year.

Attached you find a patch which calls _gfortran_caf_deregister for 
allocatable coarrays - for -fcoarray=lib. In the caf libraray version, 
coarrays are allocated/deallocated in the library. The 
allocation/deallocation was working before for coarrays in static memory 
("SAVE") and the ALLOCATE ("register") of allocatable coarrays. This 
patch adds the deallocation support ("deregister") both for explicit 
(DEALLOCATE) as well as for the implicit deallocation (when leaving the 
scope).


While implementing this, I fixed and changes some other items:
* The "token" which identifies the coarray in the library was not 
properly implemented in the library.

* ERRMSG= of ALLOCATE/DEALLOCATE did not pad the string
* ALLOCATE of coarrays with -fcoarray=lib: The status and errmsg of 
_gfortran_caf_register were overridden.


Instead of counting the deallocate failures, we now directly abort, 
which makes life a bit easier which coarrays. (Without coarrays, the 
only failure can be that the variable is already deallocated as "free()" 
does not give an error and we currently do not check whether pointer 
targets may be deallocated. With coarrays, additional issues can occur.)


Build and regtested on x86-64-linux.
OK for the trunk?

Tobias

PS: Regarding the stat= value, I got confused and ask at 
http://j3-fortran.org/pipermail/j3/2011-December/004948.html
2011-12-30  Tobias Burnus 

	* trans-openmp.c (gfc_omp_clause_dtor, gfc_trans_omp_array_reduction):
	Update call to gfc_trans_dealloc_allocated.
	* trans.c (gfc_allocate_using_malloc): Fix spacing.
	(gfc_allocate_allocatable): For gfc_allocate_using_lib, jump to
	label_finish when an error occurs.
	(gfc_deallocate_with_status): Call caf_deregister for -fcoarray=lib.
	* trans.h (gfc_allocate_allocatable, gfc_deallocate_with_status):
	Update prototype.
	(gfor_fndecl_caf_deregister): New tree symbol.
	* trans-expr.c (gfc_conv_procedure_call): Update
	gfc_deallocate_with_status and gfc_trans_dealloc_allocated calls.
	* trans-array.c (gfc_array_allocate, gfc_trans_dealloc_allocated,
	structure_alloc_comps, gfc_trans_deferred_array): Ditto.
	(gfc_array_deallocate): Handle coarrays with -fcoarray=lib.
	* trans-array.h (gfc_array_deallocate, gfc_array_allocate,
	gfc_trans_dealloc_allocated): Update prototypes.
	* trans-stmt.c (gfc_trans_sync): Fix indentation.
	(gfc_trans_allocate): Fix errmsg padding and label handling.
	(gfc_trans_deallocate): Ditto and handle -fcoarray=lib.
	* expr.c (gfc_is_coarray): Fix algorithm for BT_CLASS.
	* libgfortran.h (GFC_STAT_STOPPED_IMAGE): Use large value
	to avoid other stats accidentally matching this one.
	* trans-decl.c (gfor_fndecl_caf_deregister): New global var.
	(gfc_build_builtin_function_decls): Fix prototype decl of caf_register
	and add decl for caf_deregister.
	(gfc_trans_deferred_vars): Handle CAF vars with -fcoarrays=lib.
	* trans-intrinsic.c (conv_intrinsic_move_alloc): Update call to
	gfc_deallocate_with_status.

2011-12-30  Tobias Burnus 

	* caf/single.c (_gfortran_caf_register, _gfortran_caf_deregister):
	Fix token handling.
	* caf/mpi.c  (_gfortran_caf_register, _gfortran_caf_deregister): Ditto.
	* caf/libcaf.h (STAT_STOPPED_IMAGE): Sync with libgfortran.h.
	(_gfortran_caf_register, _gfortran_caf_deregister): Update prototype.

2011-12-30  Tobias Burnus 

	* gfortran.dg/deallocate_stat_2.f90: New.
	* coarray/allocate_errgmsg.f90: New.
	* gfortran.dg/coarray_lib_alloc_1.f90: New.
	* gfortran.dg/coarray_lib_alloc_2.f90: New.
	* coarray/subobject_1.f90: Fix for num_images > 1.
	* gfortran.dg/deallocate_stat.f90: Update due to changed
	stat= handling.

Index: gcc/fortran/trans-openmp.c
===
--- gcc/fortran/trans-openmp.c	(Revision 182728)
+++ gcc/fortran/trans-openmp.c	(Arbeitskopie)
@@ -326,7 +326,7 @@ gfc_omp_clause_dtor (tree clause ATTRIBUTE_UNUSED,
 
   /* Allocatable arrays in FIRSTPRIVATE/LASTPRIVATE etc. clauses need
  to be deallocated if they were allocated.  */
-  return gfc_trans_dealloc_allocated (decl);
+  return gfc_trans_dealloc_allocated (decl, false);
 }
 
 
@@ -708,7 +708,7 @@ gfc_trans_omp_array_reduction (tree c, gfc_symbol
   gfc_start_block (&block);
   gfc_add_expr_to_block (&block, gfc_trans_assignment (e3, e4, false,
 			 true));
-  gfc_add_expr_to_block (&block, gfc_trans_dealloc_allocated (decl));
+  gfc_add_expr_to_block (&block, gfc_trans_dealloc_allocated (decl, false));
   stmt = gfc_finish_block (&block);
 }
   else
Index: gcc/fortran/trans.c
===
--- gcc/fortran/trans.c	(Revision 182728)
+++ gcc/fortran/trans.c	(Arbeitskopie)
@@ -653,7 +653,7 @@ gfc_allocate_using_malloc (stmtblock_t * block, tr
 boolean_type_node, pointer,
 build_int_cst (prvoid_type_node, 0));
   tmp = fold_build3_loc (input_location, COND_EXPR, void_type_node,
-			 gfc_unlikely(error_cond), o

Re: [RFC]: use cgraph to emit alpha vas trampoline entry point

2011-12-30 Thread Richard Guenther
On Sat, Dec 24, 2011 at 8:00 PM, Steven Bosscher  wrote:
> On Tue, Dec 20, 2011 at 9:46 AM, Tristan Gingold  wrote:
>> Hi,
>>
>> currently alpha/vms backend emits a trampoline entry point for all nested 
>> functions.  This is a waste of code space, as although nested functions are 
>> very common in Ada, address of nested functions are only seldom taken.
>>
>> The fact that the address of a function is taken seems only be available in 
>> cgraph.  Is it OK to use cgraph in alpha.c ?
>
> Since no-one has answered yet, I'll just toss in my $0.02.
> (Hold on to them a bit, they may be worth a million Euro soon :-)
>
> I think that in general you cannot rely on cgraph in the backends,
> this has to be analyzed case-by-case. In your case I'm not sure, but I
> think it should be OK.
>
> Your patch uses cgraph in alpha_start_function, which is apparently
> only used for the target hook ASM_DECLARE_FUNCTION_NAME. This hook is
> called from varasm.c:assemble_start_function(), and this is in turn
> only called from final.c:rest_of_handle_final() to generate assembly
> from RTL, and from cgraphunit.c:assemble_thunk() to output assembly
> for MI thunks. AFAICT cgraph should be correct and complete at the
> stage when those two functions are called. Therefore your patch should
> be OK.
>
> Perhaps Honza can throw in his 0.02h?

Err - are not _all_ backends using trampolines to represent address-taken
nested functions?  At least I remeber to see them for x86 and plain C
nested functions as well.  So - is this really a target issue?  At the time
the address of a nested fn is taken the C frontend arranges to (dynamically?)
create the trampoline via some builtin.

Richard.

> Ciao!
> Steven


Re: PR middle-end/48641 (tree-ssa-threadupdate messing up profile)

2011-12-30 Thread Richard Guenther
On Tue, Dec 27, 2011 at 11:44 AM, Jan Hubicka  wrote:
> Hi
> this patch solves problem with negative frequency that is result of overflow
> in profile updating code.  The testcase shows quite pathological case where
> profile is misguessed and the mistake is propagated across the CFG by jump
> threading.  I can't of think of much better solution than adding a capping
> to that code. It should not have bad effect, since frequency will be hot 
> anyway.
>
> Bootstrapped/regtested x86_64-linux, comitted.
> Honza
>
> Index: ChangeLog
> ===
> *** ChangeLog   (revision 182685)
> --- ChangeLog   (working copy)
> ***
> *** 1,3 
> --- 1,8 
> + 2011-12-25  Jan Hubicka  
> +
> +       PR middle-end/48641
> +       * tree-ssa-threadupdate.c (redirect_edges): Watch for overflow.
> +
>  2011-12-23  Richard Henderson  
>
>        * tree.def (VEC_EXTRACT_EVEN_EXPR, VEC_EXTRACT_ODD_EXPR): Remove.
> Index: tree-ssa-threadupdate.c
> ===
> *** tree-ssa-threadupdate.c     (revision 182676)
> --- tree-ssa-threadupdate.c     (working copy)
> *** redirect_edges (void **slot, void *data)
> *** 513,519 
>                     e->src->index, e->dest->index, rd->dup_block->index);
>
>          rd->dup_block->count += e->count;
> !         rd->dup_block->frequency += EDGE_FREQUENCY (e);
>          EDGE_SUCC (rd->dup_block, 0)->count += e->count;
>          /* Redirect the incoming edge to the appropriate duplicate
>             block.  */
> --- 513,523 
>                     e->src->index, e->dest->index, rd->dup_block->index);
>
>          rd->dup_block->count += e->count;
> !
> !         /* Excessive jump threading may make frequencies large enough so
> !            the computation overflows.  */
> !         if (rd->dup_block->frequency < BB_FREQ_MAX * 2)
> !           rd->dup_block->frequency += EDGE_FREQUENCY (e);

I think this really asks for some (inline) helpers that do frequency adjustment
(and properly saturate, which is missing in the above case).

Richard.

>          EDGE_SUCC (rd->dup_block, 0)->count += e->count;
>          /* Redirect the incoming edge to the appropriate duplicate
>             block.  */
> Index: testsuite/gcc.c-torture/compile/pr48641.c
> ===
> *** testsuite/gcc.c-torture/compile/pr48641.c   (revision 0)
> --- testsuite/gcc.c-torture/compile/pr48641.c   (revision 0)
> ***
> *** 0 
> --- 1,249 
> + /* { dg-options "-O -fno-tree-ccp -fno-tree-copy-prop" } */
> + #define CSF __builtin_copysignf
> + #define CSD __builtin_copysign
> + #define CSL __builtin_copysignl
> + #define MODFF __builtin_modff
> + #define MODFD __builtin_modf
> + #define MODFL __builtin_modfl
> +
> + extern void link_error (void);
> +
> + void
> + foo (void)
> + {
> +   float iptrf;
> +   double iptr;
> +   long double iptrl;
> +   long long iptrll;
> +   if ((CSF (1.0F, MODFF (0x1p10F + 0.5f, &iptrf)) != CSF (1.0F, 0.5f))
> +       || (CSF (1.0F, iptrf) != 0x1p10f))
> +     link_error ();
> +   if (MODFD (0x1p10F + 0.5, &iptr) != 0.5
> +       || (CSD (1.0, MODFD (0x1p10F + 0.5, &iptr)) != CSD (1.0, 0.5))
> +       || (CSD (1.0, iptr) != CSD (1.0, 0x1p10)))
> +     link_error ();
> +   if (MODFL (0x1p10F + 0.5l, &iptrl) != 0.5l
> +       || (CSL (1.0L, MODFL (0x1p10F + 0.5l, &iptrl)) != CSL (1.0L, 0.5l))
> +       || (CSL (1.0L, iptrl) != CSL (1.0L, 0x1p10l)))
> +     link_error ();
> +   if ((CSF (1.0F, (MODFF (0x1p10F + 0x1p-10f, &iptrf)))
> +        != CSF (1.0F, 0x1p-10f))
> +       || (CSF (1.0F, iptrf) != CSF (1.0F, 0x1p10f)))
> +     link_error ();
> +   if (MODFD (0x1p10F + 0x1p-10, &iptr) != 0x1p-10
> +       || (CSD (1.0, (MODFD (0x1p10F + 0x1p-10, &iptr)))
> +         != CSD (1.0, 0x1p-10)) || (CSD (1.0, iptr) != CSD (1.0, 0x1p10)))
> +     link_error ();
> +   if (MODFL (0x1p10F + 0x1p-10l, &iptrl) != 0x1p-10l
> +       || (CSL (1.0L, (MODFL (0x1p10F + 0x1p-10l, &iptrl)))
> +         != CSL (1.0L, 0x1p-10l))
> +       || (CSL (1.0L, iptrl) != CSL (1.0L, 0x1p10l)))
> +     link_error ();
> +   if ((CSF (1.0F, (MODFF (12345678L / 17.0f, &iptrf)))
> +        != CSF (1.0F, (-726216L + 12345678L / 17.0f)))
> +       || (CSF (1.0F, iptrf) != CSF (1.0F, 726216.0f)))
> +     link_error ();
> +   if (MODFD (12345678L / 17.0, &iptr) != -726216L + 12345678L / 17.0
> +       || (CSD (1.0, (MODFD (12345678L / 17.0, &iptr)))
> +         != CSD (1.0, (-726216L + 12345678L / 17.0)))
> +       || (CSD (1.0, iptr) != CSD (1.0, 726216.0)))
> +     link_error ();
> +   if ((CSL (1.0L, (MODFL (12345678L / 17.0l, &iptrl)))
> +        != CSL (1.0L, (-726216L + 12345678L / 17.0l)))
> +       || (CSL (1.0L, iptrl) != CSL (1.0L, 726216.0l)))
> +     link_error ();
> +   if (MODFF (555.555f, &iptrf) != -555 + 555.555f
> +       || (CSF (1.0F, iptrf) != CSF (1.0F, 555.0f)))
> +     link_error ();
> +  

Re: [PATCH] Don't optimize away non-pure/const calls during ccp (PR tree-optimization/51683)

2011-12-30 Thread Richard Guenther
On Wed, Dec 28, 2011 at 8:04 PM, Jakub Jelinek  wrote:
> Hi!
>
> For some calls (like memcpy and other builtins that are known to pass
> through the first argument) we know the value of the lhs, but still
> we shouldn't be replacing the call with just a mere assignment of that
> known value to the LHS SSA_NAME, because the call has other side-effects.
> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
> ok for trunk?

Ok.

Thanks,
Richard.

> 2011-12-28  Jakub Jelinek  
>
>        PR tree-optimization/51683
>        * tree-ssa-propagate.c (substitute_and_fold): Don't optimize away
>        calls with side-effects.
>        * tree-ssa-ccp.c (ccp_fold_stmt): Likewise.
>
>        * gcc.dg/pr51683.c: New test.
>
> --- gcc/tree-ssa-propagate.c.jj 2011-11-11 20:54:59.0 +0100
> +++ gcc/tree-ssa-propagate.c    2011-12-27 12:23:41.334187258 +0100
> @@ -1056,6 +1056,12 @@ substitute_and_fold (ssa_prop_get_value_
>          }
>        else if (is_gimple_call (def_stmt))
>          {
> +           int flags = gimple_call_flags (def_stmt);
> +
> +           /* Don't optimize away calls that have side-effects.  */
> +           if ((flags & (ECF_CONST|ECF_PURE)) == 0
> +               || (flags & ECF_LOOPING_CONST_OR_PURE))
> +             continue;
>            if (update_call_from_tree (&gsi, val)
>                && maybe_clean_or_replace_eh_stmt (def_stmt, gsi_stmt (gsi)))
>              gimple_purge_dead_eh_edges (gimple_bb (gsi_stmt (gsi)));
> --- gcc/tree-ssa-ccp.c.jj       2011-12-19 09:21:07.0 +0100
> +++ gcc/tree-ssa-ccp.c  2011-12-27 12:29:48.620880857 +0100
> @@ -1878,6 +1878,7 @@ ccp_fold_stmt (gimple_stmt_iterator *gsi
>     case GIMPLE_CALL:
>       {
>        tree lhs = gimple_call_lhs (stmt);
> +       int flags = gimple_call_flags (stmt);
>        tree val;
>        tree argt;
>        bool changed = false;
> @@ -1888,7 +1889,10 @@ ccp_fold_stmt (gimple_stmt_iterator *gsi
>           type issues.  */
>        if (lhs
>            && TREE_CODE (lhs) == SSA_NAME
> -           && (val = get_constant_value (lhs)))
> +           && (val = get_constant_value (lhs))
> +           /* Don't optimize away calls that have side-effects.  */
> +           && (flags & (ECF_CONST|ECF_PURE)) != 0
> +           && (flags & ECF_LOOPING_CONST_OR_PURE) == 0)
>          {
>            tree new_rhs = unshare_expr (val);
>            bool res;
> --- gcc/testsuite/gcc.dg/pr51683.c.jj   2011-12-27 12:21:43.662925435 +0100
> +++ gcc/testsuite/gcc.dg/pr51683.c      2011-12-27 12:21:23.0 +0100
> @@ -0,0 +1,18 @@
> +/* PR tree-optimization/51683 */
> +/* { dg-do compile } */
> +/* { dg-options "-O2 -fdump-tree-optimized" } */
> +
> +static inline void *
> +bar (void *p, void *q, int r)
> +{
> +  return __builtin_memcpy (p, q, r);
> +}
> +
> +void *
> +foo (void *p)
> +{
> +  return bar ((void *) 0x12345000, p, 256);
> +}
> +
> +/* { dg-final { scan-tree-dump "memcpy" "optimized" } } */
> +/* { dg-final { cleanup-tree-dump "optimized" } } */
>
>        Jakub


Re: [RFC]: use cgraph to emit alpha vas trampoline entry point

2011-12-30 Thread Jakub Jelinek
On Fri, Dec 30, 2011 at 03:20:30PM +0100, Richard Guenther wrote:
> Err - are not _all_ backends using trampolines to represent address-taken
> nested functions?  At least I remeber to see them for x86 and plain C

Targets using function descriptors (powerpc64-*linux*,
powerpc*-*aix*, ia64-*) don't use trampolines.

Jakub


Re: [C++ Patch] deprecation of access declarations

2011-12-30 Thread Jason Merrill

Why // { dg-warning "" } deprecated on some tests, and
// { dg-warning "deprecated" } on others?  I would think all of the 
could use the second form.



+  cp_token *diag_token;


Let's initialize this to NULL to make sure we avoid spurious warnings 
about it being used without being set.


OK with those changes.

Jason



[RFC, ARM][PATCH 0/5] Enhancements to handling of Thumb-2 conditional insns

2011-12-30 Thread Dmitry Melnik

Hi,

This series of patches solves few issues we found with Thumb-2 
conditional insns.  These fixes include:


1) Split if_then_else into cond_execs to generate only required minimum 
of IT-blocks;
2) Grouping conditional insns of same INSN_PRIORITY to avoid excessive 
splitting of IT-blocks;
3) In if-conversion, set the maximum number of converted insns in a 
branch to 4, to match the limit for IT-block;
4) Don't perform if-conversion, if one of branches has significantly 
greater probability then the other;
5) Swap passes peephole2 and if_after_reload in order to generate more 
conditional insns (this one is actually more like a problem report, than 
a fix).


The combined effect on code size from patches 1-4 on SPEC2K INT with -O2 
is as follows:


Test bytes
name saved
--
gzip4
vpr 0
gcc   100
mcf 4
crafty 16
parser  0
eon 8
perlbmk 8
gap44
vortex  8
bzip2  16
twolf  24
--
Total:232

Do you think some of this patches are OK for trunk?

--
Best regards,
  Dmitry


[RFC, ARM][PATCH 1/5] Split if_then_else into cond_execs

2011-12-30 Thread Dmitry Melnik
This patch adds splits for if_then_else into cond_execs. This helps 
generating the minimum number of IT-blocks for two consequent 
if_then_elses, e.g. one ITETE insn instead of two ITE insns, if 
if_then_else were expanded directly into assembly code.
There are three splitters for the cases when both IF and THEN branches 
are present, and when there's only one of them (the last two splitters 
are required to prevent generation of code like "(cc) r0 = r0").

On SPEC2K INT with -O2 this reduces code size by 76 bytes (no regressions).

2011-12-08  Sevak Sargsyan 

gcc/
* config/arm/thumb2.md (new splitters for if_then_else): Turn them
into cond_execs.

diff --git a/gcc/config/arm/thumb2.md b/gcc/config/arm/thumb2.md
index 05585da..662f995 100644
--- a/gcc/config/arm/thumb2.md
+++ b/gcc/config/arm/thumb2.md
@@ -299,6 +299,57 @@
(set_attr "conds" "use")]
 )
 
+(define_split
+ [(set (match_operand:SI 0 "s_register_operand" "")
+   (if_then_else:SI
+ (match_operator 3 "arm_comparison_operator"
+  [(match_operand 4 "cc_register" "") (const_int 0)])
+ (match_operand:SI 1 "arm_not_operand" "")
+ (match_operand:SI 2 "arm_not_operand" "")))]
+  "TARGET_THUMB2 && reload_completed
+   && (!REG_P (operands[1]) || REGNO (operands[0]) != REGNO (operands[1]))
+   && (!REG_P (operands[2]) || REGNO (operands[0]) != REGNO (operands[2]))"
+[(cond_exec (match_dup 5) (set (match_dup 0) (match_dup 1)))
+ (cond_exec (match_dup 6) (set (match_dup 0) (match_dup 2)))]
+{
+   operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[3]), VOIDmode,
+ operands[4], const0_rtx);
+   operands[6] = gen_rtx_fmt_ee (reversed_comparison_code (operands[3], NULL_RTX),
+ VOIDmode, operands[4], const0_rtx);
+})
+
+(define_split
+ [(set (match_operand:SI 0 "s_register_operand" "")
+   (if_then_else:SI
+ (match_operator 3 "arm_comparison_operator"
+  [(match_operand 4 "cc_register" "") (const_int 0)])
+ (match_operand:SI 1 "arm_not_operand" "")
+ (match_operand:SI 2 "arm_not_operand" "")))]
+  "TARGET_THUMB2 && reload_completed
+   && REG_P (operands[1]) && REGNO (operands[0]) == REGNO (operands[1])
+   && (!REG_P (operands[2]) || REGNO (operands[0]) != REGNO (operands[2]))"
+[(cond_exec (match_dup 5) (set (match_dup 0) (match_dup 2)))]
+{
+   operands[5] = gen_rtx_fmt_ee (reversed_comparison_code (operands[3], NULL_RTX),
+ VOIDmode, operands[4], const0_rtx);
+})
+
+(define_split
+ [(set (match_operand:SI 0 "s_register_operand" "")
+   (if_then_else:SI
+ (match_operator 3 "arm_comparison_operator"
+  [(match_operand 4 "cc_register" "") (const_int 0)])
+ (match_operand:SI 1 "arm_not_operand" "")
+ (match_operand:SI 2 "arm_not_operand" "")))]
+  "TARGET_THUMB2 && reload_completed
+   && (!REG_P (operands[1]) || REGNO (operands[0]) != REGNO (operands[1]))
+   && REG_P (operands[2]) && REGNO (operands[0]) == REGNO (operands[2])"
+[(cond_exec (match_dup 5) (set (match_dup 0) (match_dup 1)))]
+{
+   operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[3]), VOIDmode, operands[4],
+ const0_rtx);
+})
+
 (define_insn "*call_reg_thumb2"
   [(call (mem:SI (match_operand:SI 0 "s_register_operand" "r"))
  (match_operand 1 "" ""))


[RFC, ARM][PATCH 2/5] Try not to split IT-blocks by scheduling conditional insns together

2011-12-30 Thread Dmitry Melnik
GCC's scheduler has no idea about Thumb-2 IT blocks, which are generated 
from cond_execs at the stage of emitting assembly code. So it treats 
conditional instructions independently, and may intermix them with 
non-conditional instructions, which will cause generation of extra IT 
instructions.
We have added arm_sched_reorder target hook, which moves conditional 
instructions to the top of the ready list if the last scheduled insn was 
conditional, and vice versa.  This is only done for insns with the same 
INSN_PRIORITY, so works only for resolving tie-breaks.  Also it required 
few more target hooks just to save correct can_issue_more value.
This has reduced code size by 144 bytes on SPEC2K INT with -O2 (no 
regressions).


2011-12-29  Dmitry Melnik  

gcc/
* config/arm/arm.c (arm_variable_issue, arm_sched_init, arm_sched_finish,
  arm_sched_reorder, arm_dfa_post_advance_cycle): New functions.
  (TARGET_SCHED_VARIABLE_ISSUE, TARGET_SCHED_INIT, TARGET_SCHED_FINISH,
  TARGET_SCHED_SCHED_REORDER, TARGET_SCHED_SCHED_REORDER2, 
  TARGET_SCHED_DFA_POST_ADVANCE_CYCLE): Added hooks.
  (last_scheduled_insn): New variable.

diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index ee26c51..cabf343 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -57,6 +57,7 @@
 #include "libfuncs.h"
 #include "params.h"
 #include "opts.h"
+#include "sched-int.h"
 
 /* Forward definitions of types.  */
 typedef struct minipool_nodeMnode;
@@ -133,6 +134,12 @@ static void arm_output_function_prologue (FILE *, HOST_WIDE_INT);
 static int arm_comp_type_attributes (const_tree, const_tree);
 static void arm_set_default_type_attributes (tree);
 static int arm_adjust_cost (rtx, rtx, rtx, int);
+static int arm_variable_issue (FILE *, int, rtx, int);
+static void arm_sched_init (FILE *, int, int);
+static void arm_sched_finish (FILE *, int);
+static int arm_sched_reorder (FILE *, int, rtx *, int *, int);
+static void arm_dfa_post_advance_cycle (state_t state);
+
 static int optimal_immediate_sequence (enum rtx_code code,
    unsigned HOST_WIDE_INT val,
    struct four_ints *return_sequence);
@@ -361,6 +368,19 @@ static const struct attribute_spec arm_attribute_table[] =
 #undef  TARGET_SCHED_ADJUST_COST
 #define TARGET_SCHED_ADJUST_COST arm_adjust_cost
 
+#undef TARGET_SCHED_VARIABLE_ISSUE
+#define TARGET_SCHED_VARIABLE_ISSUE arm_variable_issue
+#undef TARGET_SCHED_INIT
+#define TARGET_SCHED_INIT arm_sched_init
+#undef TARGET_SCHED_FINISH
+#define TARGET_SCHED_FINISH arm_sched_finish
+#undef TARGET_SCHED_REORDER
+#define TARGET_SCHED_REORDER arm_sched_reorder
+#undef TARGET_SCHED_REORDER2
+#define TARGET_SCHED_REORDER2 arm_sched_reorder
+#undef TARGET_SCHED_DFA_POST_ADVANCE_CYCLE
+#define TARGET_SCHED_DFA_POST_ADVANCE_CYCLE arm_dfa_post_advance_cycle
+
 #undef TARGET_ENCODE_SECTION_INFO
 #ifdef ARM_PE
 #define TARGET_ENCODE_SECTION_INFO  arm_pe_encode_section_info
@@ -804,6 +824,9 @@ int arm_condexec_mask = 0;
 /* The number of bits used in arm_condexec_mask.  */
 int arm_condexec_masklen = 0;
 
+/* Last scheduled instruction.  */
+static rtx last_scheduled_insn;
+
 /* The condition codes of the ARM, and the inverse function.  */
 static const char * const arm_condition_codes[] =
 {
@@ -8428,6 +8451,101 @@ fa726te_sched_adjust_cost (rtx insn, rtx link, rtx dep, int * cost)
   return true;
 }
 
+/* Holds correct CAN_ISSUE_MORE so arm_sched_reorder can return correct value.  */
+static int cached_can_issue_more;
+
+/* Save CAN_ISSUE_MORE in CACHED_CAN_ISSUE_MORE.  Also move the code from 
+   haifa-sched.c that won't work with arm_variable_issue hook defined.  */
+static int
+arm_variable_issue (FILE *dump ATTRIBUTE_UNUSED,
+int sched_verbose ATTRIBUTE_UNUSED,
+rtx insn,
+int can_issue_more)
+{
+  last_scheduled_insn = insn;
+
+  cached_can_issue_more = can_issue_more;
+
+  if (GET_CODE (PATTERN (insn)) != USE
+  && GET_CODE (PATTERN (insn)) != CLOBBER)
+cached_can_issue_more = can_issue_more - 1;
+
+  return cached_can_issue_more;
+}
+
+/* Init LAST_SCHEDULED_INSN.  */
+static void
+arm_sched_init (FILE *dump ATTRIBUTE_UNUSED,
+int sched_verbose ATTRIBUTE_UNUSED,
+int max_ready ATTRIBUTE_UNUSED)
+{
+  last_scheduled_insn = NULL_RTX;
+}
+
+/* Reset LAST_SCHEDULED_INSN.  */
+static void
+arm_sched_finish (FILE *dump ATTRIBUTE_UNUSED, 
+  int sched_verbose ATTRIBUTE_UNUSED)
+{
+  last_scheduled_insn = NULL_RTX;
+}
+
+/* Remove the instruction at index LOWER from ready queue READY and
+   reinsert it in front of the instruction at index HIGHER.  LOWER must
+   be <= HIGHER.  */
+static void
+arm_promote_ready (rtx *ready, int lower, int higher)
+{
+  rtx new_head;
+  int i;
+
+  new_head = ready[lower];
+  for (i = lower; i < higher; i++)
+ready[i] = ready[i + 1];
+  ready[i] = new_head;
+}
+
+/* Move conditional instructions to the top of the ready list if the las

[RFC, ARM][PATCH 3/5] Adjust the maximum number of if-converted insns to 4

2011-12-30 Thread Dmitry Melnik
This patch adjusts the maximum number of instructions in a basic block 
to be converted into conditional form from 5 to 4. The idea is that the 
5-th conditional instruction comes at cost of extra IT-instruction, 
while 4 insns fit into single IT-block, so this IT-instruction replaces 
eliminated branch insn and code won't grow. This limit is applied for 
each of converted conditional branches.
This reduces code size by 96 bytes on SPEC2K INT with -O2 (with +4 byte 
regression on one test).
2011-12-29  Dmitry Melnik  

gcc/
* config/arm/arm.h (MAX_CONDITIONAL_EXECUTE): New macro.

diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h
index 85e2b99..acad3ec 100644
--- a/gcc/config/arm/arm.h
+++ b/gcc/config/arm/arm.h
@@ -1990,6 +1990,15 @@ typedef struct
 #define BRANCH_COST(speed_p, predictable_p) \
   (current_tune->branch_cost (speed_p, predictable_p))
 
+/* One IT-block consists of 4 insns at maximum.  If-conversion can eliminate
+   2 branches for IFs with both THEN and ELSE branches, and 1 branch for
+   those with only THEN branch.  If we don't want code size to grow, and just
+   allow trading branch insns for IT insns, we should limit number of converted
+   insns to 4 (and in ifcvt.c it will be doubled if there are 2 branches).  */
+#define MAX_CONDITIONAL_EXECUTE \
+  ((TARGET_THUMB2) ? 4 : BRANCH_COST (optimize_function_for_speed_p (cfun), \
+  false) + 1)
+
 
 /* Position Independent Code.  */
 /* We decide which register to use based on the compilation options and


[RFC, ARM][PATCH 4/5] Limit on frequency in if-conversion

2011-12-30 Thread Dmitry Melnik
If one of branches has significantly greater probability than the other, 
then it may be better to rely on CPU's branch prediction and block 
reordering, than putting rarely executed instructions into the pipeline. 
 In this patch we set 10% frequency ratio as a cutoff.

On SPEC2K INT with -O2 this reduced code size for 28 bytes (no regressions).
2011-12-29  Dmitry Plotnikov  

gcc/
* ifcvt.c (cond_exec_process_if_block): Added check for frequency ratio.

diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c
index ce60ce2..330034e 100644
--- a/gcc/ifcvt.c
+++ b/gcc/ifcvt.c
@@ -445,6 +445,16 @@ cond_exec_process_if_block (ce_if_block_t * ce_info,
   int then_n_insns, else_n_insns, n_insns;
   enum rtx_code false_code;
 
+  /* If one of branches has significantly greater probability than the other,
+ then we'd better rely on CPU's branch prediction and block reordering
+ than putting rarely executed instructions into the pipeline.  10% ratio
+ seems like a reasonable cutoff.  */
+  if (then_bb && then_bb->frequency < (test_bb->frequency / 10))
+return FALSE;
+
+  if (else_bb && else_bb->frequency < (test_bb->frequency / 10))
+return FALSE;
+
   /* If test is comprised of && or || elements, and we've failed at handling
  all of them together, just use the last test if it is the special case of
  && elements without an ELSE block.  */


[RFC, ARM][PATCH 5/5] Swap passes peephole2 and if_after_reload

2011-12-30 Thread Dmitry Melnik
After Thumb-2's peephole2 adds flag clobbering on suitable insns in 
order to generate 16-bit encoding for them, if-conversion can't 
transform these insns into cond_execs.  In theory, if the instruction 
were converted to conditional form, it would also use 16-bit encoding, 
so the flag clobbering doesn't have to be added to force 16-bit encoding.
Swapping order of these passes has actually increased the number of 
if-conversions (it results in 2% more it-blocks on SPEC2K INT and
4% more "long" it-blocks that contain two or more instructions). 
However, this actually caused 2038 code size regression on SPEC2K INT. 
At first, we blamed this growth on the effects described in patches 1-4, 
but with these fixes the regression has only reduced by 474 bytes.  I.e. 
the more there are conditional insns, the better is the code size 
reduction from patches 1-4, but altered pass order still loses 1564 
bytes to the original one.

What do you think about the order of these passes on Thumb-2?

(The patch is obvious, and is not attached).


alignof(int[]) (was Re: [C++ Patch] PR 51316)

2011-12-30 Thread Jason Merrill

On 12/28/2011 07:07 PM, Paolo Carlini wrote:

I think the resolution of core/930 and C++11 itself are pretty clear:
alignof of an array of unknown bound is fine, provided the element type
is complete of course.


I think it makes sense for this change to apply to C as well, on the 
same principle that an array of unknown bound does have known alignment. 
 C maintainers?


Jason


Re: alignof(int[]) (was Re: [C++ Patch] PR 51316)

2011-12-30 Thread Paolo Carlini

Hi,

On 12/30/2011 06:27 PM, Jason Merrill wrote:

On 12/28/2011 07:07 PM, Paolo Carlini wrote:

I think the resolution of core/930 and C++11 itself are pretty clear:
alignof of an array of unknown bound is fine, provided the element type
is complete of course.
I think it makes sense for this change to apply to C as well, on the 
same principle that an array of unknown bound does have known 
alignment.  C maintainers?
FWIW, I also think it would make sense but - I'm not sure whether you 
went through the audit trail - Joseph maintained in Comment #3 that C1X 
is pretty clear about a required diagnostics.


Paolo.


Re: alignof(int[]) (was Re: [C++ Patch] PR 51316)

2011-12-30 Thread Joseph S. Myers
On Fri, 30 Dec 2011, Jason Merrill wrote:

> On 12/28/2011 07:07 PM, Paolo Carlini wrote:
> > I think the resolution of core/930 and C++11 itself are pretty clear:
> > alignof of an array of unknown bound is fine, provided the element type
> > is complete of course.
> 
> I think it makes sense for this change to apply to C as well, on the same
> principle that an array of unknown bound does have known alignment.  C
> maintainers?

In the absence of a resolution of a DR against C11 that allows alignof in 
this case, I think we should continue to disallow it for C.

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


Re: alignof(int[]) (was Re: [C++ Patch] PR 51316)

2011-12-30 Thread Jason Merrill

On 12/30/2011 12:38 PM, Joseph S. Myers wrote:

In the absence of a resolution of a DR against C11 that allows alignof in
this case, I think we should continue to disallow it for C.


Ah, I didn't realize that C11 had alignof as well.  OK, then.

Jason


[gcov] fix program detection

2011-12-30 Thread Nathan Sidwell

I've committed this patch which does 2 things in libgcov:

1) Robustifies the error recovery if malloc fails during buffering coverage 
data.  It also generates more informative error messages.


2) Fixes a long standing bug regarding detecting when an object file is used in 
multiple programs.  Consider a program made of a.o and b.o.  If b.c is edited 
and a new b.o generated, the resulting program needs to be considered as a 
different program to the original program.  Not doing so can result in an 
erroneous merge error on a.o's coverage data as the program's counts can have 
changed.  Previously we just used the set of object file names to detect a 
different program, but this example shows that filenames are insufficient (and 
essentially irrelevant) for this purpose.  This patch uses the actual coverage 
data of the entire program to generate a crc, and verifies the expected coverage 
counts up front.  Notice this example is not contrived -- it's what the usually 
happens with a make-based build system.


built and tested on i686-pc-linux-gnu.

nathan
2011-12-30  Nathan Sidwell  

	* libgcov.c (gcov_crc32): Remove global var.
	(free_fn_data): New function.
	(buffer_fn_data): Pass in filename, more robust error recovery.
	(crc32_unsigned): New function.
	(gcov_exit): More robust detection of new program. More robust
	error recovery.
	(__gcov_init): Do not update program's crc here.

Index: libgcc/libgcov.c
===
--- libgcc/libgcov.c	(revision 182730)
+++ libgcc/libgcov.c	(working copy)
@@ -89,10 +89,6 @@ struct gcov_fn_buffer
 /* Chain of per-object gcov structures.  */
 static struct gcov_info *gcov_list;
 
-/* A program checksum allows us to distinguish program data for an
-   object file included in multiple programs.  */
-static gcov_unsigned_t gcov_crc32;
-
 /* Size of the longest file name. */
 static size_t gcov_max_filename = 0;
 
@@ -143,22 +139,41 @@ create_file_directory (char *filename)
 #endif
 }
 
+static struct gcov_fn_buffer *
+free_fn_data (const struct gcov_info *gi_ptr, struct gcov_fn_buffer *buffer,
+	  unsigned limit)
+{
+  struct gcov_fn_buffer *next;
+  unsigned ix, n_ctr = 0;
+  
+  if (!buffer)
+return 0;
+  next = buffer->next;
+
+  for (ix = 0; ix != limit; ix++)
+if (gi_ptr->merge[ix])
+  free (buffer->info.ctrs[n_ctr++].values);
+  free (buffer);
+  return next;
+}
+  
 static struct gcov_fn_buffer **
-buffer_fn_data (struct gcov_info *gi_ptr, struct gcov_fn_buffer **end_ptr,
-		unsigned fn_ix)
+buffer_fn_data (const char *filename, const struct gcov_info *gi_ptr,
+		struct gcov_fn_buffer **end_ptr, unsigned fn_ix)
 {
-  unsigned n_ctrs = 0, ix;
+  unsigned n_ctrs = 0, ix = 0;
   struct gcov_fn_buffer *fn_buffer;
+  unsigned len;
 
   for (ix = GCOV_COUNTERS; ix--;)
 if (gi_ptr->merge[ix])
   n_ctrs++;
 
-  fn_buffer = (struct gcov_fn_buffer *)malloc
-(sizeof (*fn_buffer) + sizeof (fn_buffer->info.ctrs[0]) * n_ctrs);
+  len = sizeof (*fn_buffer) + sizeof (fn_buffer->info.ctrs[0]) * n_ctrs;
+  fn_buffer = (struct gcov_fn_buffer *)malloc (len);
 
   if (!fn_buffer)
-return 0; /* We'll horribly fail.  */
+goto fail;
   
   fn_buffer->next = 0;
   fn_buffer->fn_ix = fn_ix;
@@ -175,16 +190,17 @@ buffer_fn_data (struct gcov_info *gi_ptr
 	continue;
   
   if (gcov_read_unsigned () != GCOV_TAG_FOR_COUNTER (ix))
-	goto fail;
-
-  length = GCOV_TAG_COUNTER_NUM (gcov_read_unsigned ());
-  values = (gcov_type *)malloc (length * sizeof (gcov_type));
-  if (!values)
 	{
-	  while (n_ctrs--)
-	free (fn_buffer->info.ctrs[n_ctrs].values);
+	  len = 0;
 	  goto fail;
 	}
+
+  length = GCOV_TAG_COUNTER_NUM (gcov_read_unsigned ());
+  len = length * sizeof (gcov_type);
+  values = (gcov_type *)malloc (len);
+  if (!values)
+	goto fail;
+  
   fn_buffer->info.ctrs[n_ctrs].num = length;
   fn_buffer->info.ctrs[n_ctrs].values = values;
 
@@ -197,8 +213,29 @@ buffer_fn_data (struct gcov_info *gi_ptr
   return &fn_buffer->next;
 
  fail:
-  free (fn_buffer);
-  return 0;
+  fprintf (stderr, "profiling:%s:Function %u %s %u \n", filename, fn_ix,
+	   len ? "cannot allocate" : "counter mismatch", len ? len : ix);
+
+  return (struct gcov_fn_buffer **)free_fn_data (gi_ptr, fn_buffer, ix);
+}
+
+/* Add an unsigned value to the current crc */
+
+static gcov_unsigned_t
+crc32_unsigned (gcov_unsigned_t crc32, gcov_unsigned_t value)
+{
+  unsigned ix;
+
+  for (ix = 32; ix--; value <<= 1)
+{
+  unsigned feedback;
+
+  feedback = (value ^ crc32) & 0x8000 ? 0x04c11db7 : 0;
+  crc32 <<= 1;
+  crc32 ^= feedback;
+}
+
+  return crc32;
 }
 
 /* Check if VERSION of the info block PTR matches libgcov one.
@@ -241,41 +278,56 @@ gcov_exit (void)
   struct gcov_summary all_prg;  /* summary for all instances of program.  */
   struct gcov_ctr_summary *cs_ptr;
   const struct gcov_ctr_info *ci_ptr;
-  unsigned t_ix, f_ix;
+  unsigned t_ix;
+ 

Re: [C++ Patch] deprecation of access declarations

2011-12-30 Thread Fabien Chêne
2011/12/30 Jason Merrill :
> Why // { dg-warning "" } deprecated on some tests, and
> // { dg-warning "deprecated" } on others?  I would think all of the could
> use the second form.

I was believing that "// { dg-warning "" } deprecated" was the way to
test a warning in old-deja. If we can use the modern deja-gnu syntax
in old-deja, that's great, I would be much less reluctant to adjust
the tests there ;-)

-- 
Fabien


[gcov] a few improvements

2011-12-30 Thread Nathan Sidwell

I've committed this patch to fix and improve coverage reporting:

1) the time stamp local_tick will be -1 if the user overrides the random seed. 
In such cases the gcov data file should be deleted, just as it would if the time 
cannot be determined.


2) there was a typo in gcov_dump when dumping function data

3) when processing coverage data files, it's informative for gcov to emit the 
overall line coverage -- in addition to the individual line coverage.


built & tested on i686-pc-linux-gnu

nathan
2011-12-30  Nathan Sidwell  

* gcov.c (total_lines, total_executed): New global vars.
(generate_results): Call executed_summary.
(executed_summary): New function, broken out of ...
(function_summary): ... here.  Call it.
* coverage.c (coverage_finish): Also check for local_tick == -1.
* gcov-dump (tag_function): Correct labelling typo.

Index: gcov.c
===
--- gcov.c  (revision 182730)
+++ gcov.c  (working copy)
@@ -278,6 +278,9 @@ static unsigned a_names;/* Allocated
 static unsigned object_runs;
 static unsigned program_count;
 
+static unsigned total_lines;
+static unsigned total_executed;
+
 /* Modification time of graph file.  */
 
 static time_t bbg_file_time;
@@ -380,6 +383,7 @@ static void solve_flow_graph (function_t
 static void find_exception_blocks (function_t *);
 static void add_branch_counts (coverage_t *, const arc_t *);
 static void add_line_counts (coverage_t *, function_t *);
+static void executed_summary (unsigned, unsigned);
 static void function_summary (const coverage_t *, const char *);
 static const char *format_gcov (gcov_type, gcov_type, int);
 static void accumulate_line_counts (source_t *);
@@ -702,6 +706,8 @@ generate_results (const char *file_name)
   
   accumulate_line_counts (src);
   function_summary (&src->coverage, "File");
+  total_lines += src->coverage.lines;
+  total_executed += src->coverage.lines_executed;
   if (flag_gcov_file && src->coverage.lines)
{
  char *gcov_file_name
@@ -724,6 +730,9 @@ generate_results (const char *file_name)
}
   fnotice (stdout, "\n");
 }
+
+  if (!file_name)
+executed_summary (total_lines, total_executed);
 }
 
 /* Release a function structure */
@@ -1666,20 +1675,25 @@ format_gcov (gcov_type top, gcov_type bo
   return buffer;
 }
 
-
-/* Output summary info for a function.  */
+/* Summary of execution */
 
 static void
-function_summary (const coverage_t *coverage, const char *title)
+executed_summary (unsigned lines, unsigned executed)
 {
-  fnotice (stdout, "%s '%s'\n", title, coverage->name);
-
-  if (coverage->lines)
+  if (lines)
 fnotice (stdout, "Lines executed:%s of %d\n",
-format_gcov (coverage->lines_executed, coverage->lines, 2),
-coverage->lines);
+format_gcov (executed, lines, 2), lines);
   else
 fnotice (stdout, "No executable lines\n");
+}
+  
+/* Output summary info for a function or file.  */
+
+static void
+function_summary (const coverage_t *coverage, const char *title)
+{
+  fnotice (stdout, "%s '%s'\n", title, coverage->name);
+  executed_summary (coverage->lines, coverage->lines_executed);
 
   if (flag_branches)
 {
Index: coverage.c
===
--- coverage.c  (revision 182730)
+++ coverage.c  (working copy)
@@ -1119,7 +1119,7 @@ coverage_finish (void)
   if (bbg_file_name && gcov_close ())
 unlink (bbg_file_name);
   
-  if (!local_tick)
+  if (!local_tick || local_tick == (unsigned)-1)
 /* Only remove the da file, if we cannot stamp it.  If we can
stamp it, libgcov will DTRT.  */
 unlink (da_file_name);
Index: gcov-dump.c
===
--- gcov-dump.c (revision 182730)
+++ gcov-dump.c (working copy)
@@ -286,7 +286,7 @@ tag_function (const char *filename ATTRI
 {
   printf (" ident=%u", gcov_read_unsigned ());
   printf (", lineno_checksum=0x%08x", gcov_read_unsigned ());
-  printf (", cfg_checksum_checksum=0x%08x", gcov_read_unsigned ());
+  printf (", cfg_checksum=0x%08x", gcov_read_unsigned ());
 
   if (gcov_position () - pos < length)
{


[Patch, fortran] PR46328 - [OOP] type-bound operator call with non-trivial polymorphic operand

2011-12-30 Thread Paul Richard Thomas
Dear All,

This patch represents a rather complete fix for this PR.  In fact, I
suspect that it also fixes other PRs but I have been out of internet
range for a week and have not been able to check.

The processing of typebound operators has been made more straight
forward here by the addition of a new field in gfc_expression to hold
the base object expression.  I tried to avoid this but ran into a mess
of other problems in resolution, when I tried to do otherwise.  It
turns out that this works well,however, so another pointer in the
gfc_expr seems a small price to pay.  A big plus, which has not been
tested in the testcase submitted but will be in future patches, is
that the handling of the typebound operators and procedures now admits
the base object changing dynamic type in the course of the call.

Another essential part of the patch involves the triming of extraneous
trailing references in the base object expressions, such as _vptrs and
so on.

Finally, the patch includes two extra bits: one brings back the
nullification of newly assigned class array _data. (Tobias, is there a
PR for this?); The other is to fix pointer assignment of class valued
procedure pointers.  This permits a fully elaborated version of Arjen
Markus's pde solver to compile and run correctly - of which a bit more
in one of two following emails to the fortran list.

Bootstrapped and regtested on i686/Ubuntu 11.1 - OK for trunk?

A Happy New Year to one and all!

Paul

2011-12-30  Paul Thomas  

* trans-array.c (gfc_array_allocate): Null allocated memory of
newly allocted class arrays.

PR fortran/46328
* interface.c(build_compcall_for_operator): Add a type to the
expression.
* trans-expr.c (conv_base_obj_fcn_val): New function.
(gfc_conv_procedure_call): Use base_expr to detect non-variable
base objects and, ensuring that there is a temporary variable,
build up the typebound call using conv_base_obj_fcn_val.
(gfc_trans_class_assign): Pick out class procedure pointer
assignments and do the assignment with no further prcessing.
* gfortran.h : Add 'base_expr' field to gfc_expr.
* resolve.c (get_declared_from_expr): Add 'types' argument to
switch checking of derived types on or off.
(resolve_typebound_generic_call): Set the new argument.
(resolve_typebound_function, resolve_typebound_subroutine):
Set 'types' argument for get_declared_from_expr appropriately.
Identify base expression, if not a variable, in the argument
list of class valued calls. Assign it to the 'base_expr' field
of the final expression. Strip away all references after the
last class reference.


2011-12-30  Paul Thomas  

PR fortran/46328
* gfortran.dg/typebound_operator_7.f03: New.
Index: gcc/fortran/interface.c
===
*** gcc/fortran/interface.c	(revision 182566)
--- gcc/fortran/interface.c	(working copy)
***
*** 3256,3261 
--- 3256,3269 
e->value.compcall.base_object = base;
e->value.compcall.ignore_pass = 1;
e->value.compcall.assign = 0;
+   if (e->ts.type == BT_UNKNOWN
+ 	&& target->function)
+ {
+   if (target->is_generic)
+ 	e->ts = target->u.generic->specific->u.specific->n.sym->ts;
+   else
+ 	e->ts = target->u.specific->n.sym->ts;
+ }
  }
  
  
***
*** 3383,3389 
  
  	  gcc_assert (tb_base);
  	  build_compcall_for_operator (e, actual, tb_base, tbo, gname);
- 
  	  result = gfc_resolve_expr (e);
  	  if (result == FAILURE)
  	return MATCH_ERROR;
--- 3391,3396 
Index: gcc/fortran/trans-array.c
===
*** gcc/fortran/trans-array.c	(revision 182566)
--- gcc/fortran/trans-array.c	(working copy)
***
*** 5069,5074 
--- 5069,5086 
  
gfc_add_expr_to_block (&se->pre, tmp);
  
+   if (expr->ts.type == BT_CLASS && expr3)
+ {
+   tmp = build_int_cst (unsigned_char_type_node, 0);
+   /* With class objects, it is best to play safe and null the 
+ 	 memory because we cannot know if dynamic types have allocatable
+ 	 components or not.  */
+   tmp = build_call_expr_loc (input_location,
+  builtin_decl_explicit (BUILT_IN_MEMSET),
+  3, pointer, tmp,  size);
+   gfc_add_expr_to_block (&se->pre, tmp);
+ }
+ 
/* Update the array descriptors. */
if (dimension)
  gfc_conv_descriptor_offset_set (&set_descriptor_block, se->expr, offset);
Index: gcc/fortran/trans-expr.c
===
*** gcc/fortran/trans-expr.c	(revision 182566)
--- gcc/fortran/trans-expr.c	(working copy)
***
*** 302,307 
--- 302,480 
parmse->expr = gfc_build_addr_expr (NULL_TREE, var);
  }
  
+ 
+ static tree
+ gfc_trans_class_array_init_assign (gfc_expr *rhs, gfc_expr *lhs, gfc_expr *obj)
+ {
+   g

Re: [PATCH] Fix PR bootstrap/51705

2011-12-30 Thread Steve Kargl
On Fri, Dec 30, 2011 at 10:38:03AM +0100, Jakub Jelinek wrote:
> On Thu, Dec 29, 2011 at 08:12:51PM -0800, Steve Kargl wrote:
> > The audit trail in the PR pretty much sums up the problem.
> > OK to commit?
> 
> Can you tune up the comments a little bit?
> If you look up http://gcc.gnu.org/gcc-4.7/cxx0x_status.html
> you'll see that most of the C++11 features are already implemented
> (and e.g. at_quick_exit is implemented too in some libcs), so the
> __cplusplus macro isn't lying.  Clang apparently defines __cplusplus
> to 201103L much longer than GCC does, yet it supports much smaller subset
> of C++11.  Apparently it parses the C++11 generalized attribute syntax,
> but at least clang 3.0 doesn't complain at all about anything between
> the [[ and ]] pair, [[foobar, foobaz (bar, baz, 2, 6, 0x1z2)]] void bar 
> (void);
> is parsed just fine, and with [[noreturn]] it miscompiles even the first
> [[noreturn]] trivial testcase I wrote.
> See
> http://gcc.gnu.org/ml/gcc-patches/2011-10/msg02027.html
> for why we set __cplusplus to the value we do.

I'm sorry, but I find "clang did this, so g++ better follow
suit" to be a rather uncompelling technical reason for 
defining __cplusplus to be 201103L [1].  The technical question
is fairly simple: "Does g++ conform to the C++11 standard?"
>From my cursory scanning of n3242.pdf, the answer is obviously
'no' given that [[noreturn]] appears to be neither a 
conditionally-supported feature nor implementation-defined
behavior.  So, we now look at what n3242.pdf says about
__cplusplus:

Sec. 16.8 (p. 415)
 __cplusplus
   The name __cplusplus is defined to the value 201103L when compiling
   a C++ translation unit. [155]

155) It is intended that future versions of this standard will replace
the value of this macro with a greater value.  Non-conforming compilers
should use a value with at most five decimal digits.

201103 is 6 digits!

Again, a cursory scan of n3242.pdf does not reveal whether a footnote
is normative or non-normative text.  So, footnote [155] may simply
be a suggestion rather than a requirement.

[1] Interestly, in a 1334 page document, n3242.pdf does not state
how one is to interpret __cplusplus nor its value.

So, once again OK for trunk?

2011-12-29  Steven G. Kargl  

* inclhack.def: 'g++ -std=c++11' defines __cplusplus to 201103L,
which suggests that 'g++ -std=c++11' is a compiler conforming
to the C++ programming language defined by ISO/IEC 14882:2011.
Setting __cplusplus to 201103L appears to be a direct violation
of ISO/IEC 14882:2011.  The standard conforming sys/cdefs.h
header file on FreeBSD 10 (and above) needs be (un)damaged, so
GCC can use 'g++ -std=c++11' to build libstdc++v3 during bootstrap.
* fixincl.x: Regenerated.
* genfixes: Fix to version test.

-- 
Steve

Index: inclhack.def
===
--- inclhack.def	(revision 182738)
+++ inclhack.def	(working copy)
@@ -20,6 +20,27 @@ autogen definitions fixincl;
 FIXINC_DEBUG = yes;
 #endif
 
+/*
+ * 'g++ -std=c++11' defines __cplusplus to 201103L, which suggests
+ * that 'g++ -std=c++11' is a compiler conforming to the C++ programming
+ * language defined by ISO/IEC 14882:2011.  Setting __cplusplus to 
+ * 201103L appears to be a direct violation of ISO/IEC 14882:2011
+ * [as inferred from Secs. 1.4 and 16.8 in n3242.pdf (I'm not interested
+ * in spending CHF 352.00 for the actual standard)].  The standard
+ * conforming sys/cdefs.h header file on FreeBSD 10 (and above) needs be
+ * (un)damaged, so GCC can use 'g++ -std=c++11' to build libstdc++v3 
+ * during bootstrap. 
+ */
+fix = {
+hackname  = cdef_cplusplus;
+mach  = "*-*-freebsd10.*";
+files = sys/cdefs.h;
+select= "\\[\\[noreturn\\]\\]";
+sed   = "s/\\[\\[noreturn\\]\\]/__attribute__\(\(__noreturn__\)\)/";
+test_text = "#include ";
+};
+
+
 /* On AIX when _LARGE_FILES is defined stdio.h defines fopen to
  * fopen64 etc. and this causes problems when building with g++
  * because cstdio udefs everything from stdio.h, leaving us with
Index: fixincl.x
===
--- fixincl.x	(revision 182738)
+++ fixincl.x	(working copy)
@@ -2,11 +2,11 @@
  * 
  * DO NOT EDIT THIS FILE   (fixincl.x)
  * 
- * It has been AutoGen-ed  November  7, 2011 at 01:16:39 PM by AutoGen 5.10
+ * It has been AutoGen-ed  December 30, 2011 at 11:21:34 AM by AutoGen 5.12
  * From the definitionsinclhack.def
  * and the template file   fixincl
  */
-/* DO NOT SVN-MERGE THIS FILE, EITHER Mon Nov  7 13:16:39 EST 2011
+/* DO NOT SVN-MERGE THIS FILE, EITHER Fri Dec 30 11:21:34 PST 2011
  *
  * You must regenerate it.  Use the ./genfixes script.
  *
@@ -15,7 +15,7 @@
  * certain ANSI-incompatible system header files which are fixed to work
  * correctly with ANSI C and placed in a directory that GNU C will search.
  *
- * This file contains 222 fixup 

Re: [C++ Patch] deprecation of access declarations

2011-12-30 Thread Mike Stump
On Dec 30, 2011, at 10:18 AM, Fabien Chêne wrote:
> 2011/12/30 Jason Merrill :
>> Why // { dg-warning "" } deprecated on some tests, and
>> // { dg-warning "deprecated" } on others?  I would think all of the could
>> use the second form.
> 
> I was believing that "// { dg-warning "" } deprecated" was the way to
> test a warning in old-deja. If we can use the modern deja-gnu syntax
> in old-deja, that's great, I would be much less reluctant to adjust
> the tests there ;-)

So, I'm wondering why it was done this way originally:

r66317 | mmitchel | 2003-04-30 19:02:59 -0700 (Wed, 30 Apr 2003) | 10 lines

* lib/g++-dg.exp (g++-dg-test): Add "repo" option.
(dg-gpp-additional-sources): New function.
(dg-gpp-additional-files): Likewise.
* lib/g++.exp (additional_sources): New variable.
(additional_files): Likewise.
(g++_target_compile): Deal with them.
* lib/old-dejagnu.exp: Remove.
* g++.old-deja/old-deja.exp: Use dg.exp, not old-dejagnu.exp.
* g++.old-deja: Revise all tests to use dg commands.


-  static int S1;   // ERROR - uses same name 9.3   
 
+  static int S1;   // { dg-error "" } uses same name 9.3   
 


and not:

-  static int S1;   // ERROR - uses same name 9.3   
 
+  static int S1;   // { dg-error "uses same name 9.3" }

?  Mark, you recall?


Re: [PATCH] Fix PR bootstrap/51705

2011-12-30 Thread Joseph S. Myers
On Fri, 30 Dec 2011, Steve Kargl wrote:

> I'm sorry, but I find "clang did this, so g++ better follow
> suit" to be a rather uncompelling technical reason for 
> defining __cplusplus to be 201103L [1].  The technical question
> is fairly simple: "Does g++ conform to the C++11 standard?"

I think this is just the same issue as where trouble.texi says:

Sometimes people say that defining @code{__STDC__} in a compiler that
does not completely conform to the ISO C standard somehow violates the
standard.  This is illogical.  The standard is a standard for compilers
that claim to support ISO C, such as @samp{gcc -ansi}---not for other
compilers such as plain @command{gcc}.  Whatever the ISO C standard says
is relevant to the design of plain @command{gcc} without @option{-ansi} only
for pragmatic reasons, not as a requirement.

Note that -std=c++11 is documented to be incomplete, not to claim to 
support the full standard.  I think the most pragmatically useful value of 
__cplusplus is to reflect the intent - the C++ version followed insofar as 
differences between versions are implemented - and this does not mean the 
support is complete, just as __STDC_VERSION__ had the C99 value with 
-std=c99 even in versions predating the implementation of C99 inline 
semantics (for example).

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


Re: [Patch, fortran] PR46328 - [OOP] type-bound operator call with non-trivial polymorphic operand

2011-12-30 Thread Tobias Burnus

Dear Paul,

Paul Richard Thomas wrote:

Bootstrapped and regtested on i686/Ubuntu 11.1 - OK for trunk?

2011-12-30  Paul Thomas

* trans-array.c (gfc_array_allocate): Null allocated memory of
newly allocted class arrays.


PR fortran/51529


PR fortran/46328
* interface.c(build_compcall_for_operator): Add a type to the
expression.


You might want to quote additionally PR fortran/51052 and PR fortran/51052.


*** gcc/fortran/interface.c (revision 182566)
--- gcc/fortran/interface.c (working copy)
***
*** 3256,3261 
--- 3256,3269 


I would have liked a diff with "-p" flag which shows the function name 
in the diff (for instance "svn diff -x -p" or "svn diff -x '-p -u'").




+   if (expr->ts.type == BT_CLASS&&  expr3)
+ {
+   tmp = build_int_cst (unsigned_char_type_node, 0);
+   /* With class objects, it is best to play safe and null the
+memory because we cannot know if dynamic types have allocatable
+components or not.  */


I don't like the comment; how about something along the following: "For 
class objects we need to nullify the memory in case they have 
allocatable components; the reason is that _copy, which is used for 
initialization, first frees the destination."




+ gfc_trans_class_init_assign (gfc_code *code)
+ {
+   stmtblock_t block;
+   tree tmp;
+   gfc_se dst,src,memsz;


Space after each comma.


+   gfc_expr *lhs,*rhs,*sz;


Ditto.



***
*** 3301,3306 
--- 3502,3514 
{
  gfc_conv_expr_reference (&parmse, e);

+ /* Catch base objects that are not variables.  */
+ if (e->ts.type == BT_CLASS
+   &&  e->expr_type != EXPR_VARIABLE
+   &&  expr&&  e == expr->base_expr)


The indentation looks wrong.



+ for (args= e->value.function.actual; args; args = args->next)
+   {
+ if (expr == args->expr)
+   expr = args->expr;
+   }


Space before the equal sign in "args=". If you want, you can also remove 
the curly braces as they are not required.



+ args= code->expr1->value.function.actual;
+ for (; args; args = args->next)
+   {
+ if (expr == args->expr)
+   expr = args->expr;
+   }


Ditto.


   get_declared_from_expr (gfc_ref **class_ref, gfc_ref **new_ref,
!   gfc_expr *e)
--- 5623,5629 
   get_declared_from_expr (gfc_ref **class_ref, gfc_ref **new_ref,
!   gfc_expr *e, bool types)


I think "types" deserves a comment line in the comment block before the 
function; additionally - and related - I wonder whether the name is well 
chosen. "types" reminds me of "bt" rather than of "bool". In the 
changelog, you use: "Add 'types' argument to switch checking of derived 
types on or off." Thus, "check_types" would be a possible choice.


Otherwise, the patch looks okay to me.

Happy new year to every one!

Tobias


[PATCH, committed] Fix thinko in powerpc target function pragma/attribute

2011-12-30 Thread Michael Meissner
In working on something else, I was using the target pragmas I added in late
November, and I noticed that I had a thinko in setting some of the options like
-mfriz that aren't bitmasks.  I committed the patch as obvious:

2011-12-30  Michael Meissner  

* config/rs6000/rs6000.c (rs6000_inner_target_options): Fix thinko
in setting options via target #pragma or attribute.

Index: gcc/config/rs6000/rs6000.c
===
--- gcc/config/rs6000/rs6000.c  (revision 182746)
+++ gcc/config/rs6000/rs6000.c  (working copy)
@@ -27138,7 +27138,7 @@ rs6000_inner_target_options (tree args, 
if (strcmp (r, rs6000_opt_vars[i].name) == 0)
  {
size_t j = rs6000_opt_vars[i].global_offset;
-   ((int *) &global_options)[j] = !invert;
+   *((int *) ((char *)&global_options + j)) = !invert;
error_p = false;
break;
  }


-- 
Michael Meissner, IBM
5 Technology Place Drive, M/S 2757, Westford, MA 01886-3141, USA
meiss...@linux.vnet.ibm.com fax +1 (978) 399-6899



[patch] Fix PR tree-optimization/51624

2011-12-30 Thread Eric Botcazou
This is the bootstrap failure of the Ada compiler on MIPS/IRIX, a recent 
regression present on mainline and 4.6 branch.  The stage 2 compiler 
miscompiles the stage 3 compiler (sem_type.adb:Disambiguate) because of an 
oversight in the fix for PR tree-opt/50569 which changed build_ref_for_model to 
replicate chains of COMPONENT_REFs instead of just the last ones.

The problem is that, when build_ref_for_model is called on the RHS of an 
aggregate assignment of the form:

  b1.f1 = b2

with the model associated with a child of the LHS (say b1.f1.f2), it will build 
something like:

  MEM [&b2 + -4B].f1.f2

which will wreak havoc downstream.  I think that the most straightforward way 
out is to stop going up the chain of COMPONENT_REFs as soon as the type of the 
COMPONENT_REF matches that of the base.

Bootstrapped on MIPS/IRIX and regtested on x86_64-suse-linux.  OK after a full 
testing cycle?


2011-12-30  Eric Botcazou  

PR tree-optimization/51624
* tree-sra.c (build_ref_for_model): When replicating a chain of
COMPONENT_REFs, stop as soon as the type of the COMPONENT_REF
matches that of the base.


-- 
Eric Botcazou
Index: tree-sra.c
===
--- tree-sra.c	(revision 182691)
+++ tree-sra.c	(working copy)
@@ -1478,7 +1478,8 @@ build_ref_for_model (location_t loc, tre
 
 	expr = TREE_OPERAND (expr, 0);
 	type = TREE_TYPE (expr);
-  } while (TREE_CODE (expr) == COMPONENT_REF);
+  } while (TREE_CODE (expr) == COMPONENT_REF
+	   && !types_compatible_p (TREE_TYPE (expr), TREE_TYPE (base)));
 }
 
   t = build_ref_for_offset (loc, base, offset, type, gsi, insert_after);


[PATCH, committed] Update powerpc www files

2011-12-30 Thread Michael Meissner
I udpated the powerpc changes in the GCC 4.7 summary:

--- htdocs/gcc-4.7/changes.html.~1~ 2011-12-30 18:43:34.885278709 -0500
+++ htdocs/gcc-4.7/changes.html 2011-12-30 18:55:33.455278920 -0500
@@ -576,19 +576,32 @@ well.
 PowerPC/PowerPC64
   
 Vectors of type vector long long or vector long are
-   passed and returned in the same method as other vectors with the VSX
-   instruction set.  Previously the GCC compiler did not adhere to the ABI
-   for 128-bit vectors with 64-bit integer base types (PR 48857).
-   This will also be fixed in the GCC 4.6.1 and 4.5.4 releases.
-
- A new option (-mno-r11) was added to allow AIX
-   32-bit/64-bit and GNU/Linux 64-bit PowerPC users to specify that
-   the compiler should not load up the chain register
-   (r11) before calling a
-   function through a pointer.  If you use this option, you cannot call
-   nested functions through a pointer, or call other languages that might
-   use the static chain.
- 
+   passed and returned in the same method as other vectors with the VSX
+   instruction set.  Previously the GCC compiler did not adhere to the ABI
+   for 128-bit vectors with 64-bit integer base types (PR 48857).
+   This will also be fixed in the GCC 4.6.1 and 4.5.4 releases.
+
+ A new option (-mno-pointers-to-nested-functions) was
+   added to allow AIX 32-bit/64-bit and GNU/Linux 64-bit PowerPC users to
+   specify that the compiler should not load up the chain register
+   (r11) before calling a function through a pointer.
+   If you use this option, you cannot call nested functions through a
+   pointer, or call other languages that might use the static chain.
+
+ A new option (msave-toc-indirect was added to allow AIX
+   32-bit/64-bit and GNU/Linux 64-bit PowerPC users control whether we
+   save the TOC in the prologue for indirect calls or generate the save
+   inline.  This can speed up some programs that call through a function
+   pointer a lot, but it can slow down other functions that only call
+   through a function pointer in exceptional cases.
+
+  The powerpc will now enable machine specific builtin functions when
+   the user switches the target machine using the
+   #pragma GCC target or GCC target attribute
+   code sequences.  In additon, the target macros are updated.
+   However, due to the way the -save-temps switch is
+   implemented, you won't see the effect of these additional macros
+   being defined in preprocessor output.
   
 
 SPARC

-- 
Michael Meissner, IBM
5 Technology Place Drive, M/S 2757, Westford, MA 01886-3141, USA
meiss...@linux.vnet.ibm.com fax +1 (978) 399-6899



[PATCH] New port resubmission for TILEPro and TILE-Gx

2011-12-30 Thread Walter Lee
I'm resubmitting the gcc ports to TILE-Gx and TILEPro as replies to
this email.  The resubmission addresses the feedback made by Richard
Henderson in:

http://gcc.gnu.org/ml/gcc-patches/2011-11/msg01232.html, and
http://gcc.gnu.org/ml/gcc-patches/2011-11/msg01247.html

Feedback by Joseph Myers made in:

http://gcc.gnu.org/ml/gcc-patches/2011-10/msg01385.html
http://gcc.gnu.org/ml/gcc-patches/2011-10/msg01387.html

was addressed in a previous submission.

Here is a summary of the issues addressed:

Changes made to both ports:

- added vector patterns for suitable vector ops.

- cleaned up various move pattens, deleting dead alternatives,
  deleting redundant immediate insn_and_split patterns, and delete
  unnecessary movdi multi-word move pattern (tilepro only).

- added extra insv patterns.

- combined all the conditional moves into one pattern.

- combined "*lh" and "*extendhisi2" pattern, and "*lb" and
  "*extendqihi2".

- partially remove the divsi stubs that were there to work around an
  old gcc bug that has been partially fixed.  Previously gcc would not
  turn divide by constant into multiply by constant unless there is a
  pattern for the divide of the given mode.  It now seems to do
  better, but we still need the stub on tilegx, else it turns 32-bit
  divide by constant into 64-bit multiply by constant.

- wrap the GOT and TLS unspec addresses in const, and handle them with
  a single pattern.

- add support for post_{inc,dec,modify} addressing modes.

- fixed invalid rtl sharing in alloca handling routines.

- use REG_CFA_* notes in prologue and epilogue.

- Use post-inc load in TARGET_ASM_TRAMPOLINE_TEMPLATE.

- converted the following to target hooks: LIBCALL_VALUE,
  FUNCTION_VALUE_REGNO_P, GO_IF_LEGITIMATE_ADDRESS.  Delete
  GO_IF_MODE_DEPENDENT_ADDRESS and use the default.

- use the new atomics_ names and patterns.

Changes made to tilegx port:

- merged the AND patterns.

- add patterns that sign extends an SI result to DI for all the 32-bit
  insns.

Here are replies to a few feedback items:

> optabs.c will do exactly this if the pattern is not present.  Similarly
> for the DImode logicals (popcount, parity, etc).

I tried taking out the patterns for ctzdi2, clzdi2, ffsdi2, paritydi2,
and popcountdi2, and I found that the compiler generates libgcc
function calls for all of them except clzdi2.  For clzdi2 the tilepro
pattern is better than the default because it uses mvnz to get rid of
a branch.

This is all true for gcc 4.4.6...  gcc 4.7 does not use my patterns at
all, which seems like a bug.

I need the paritysi2 as well; without it the compiler does not
generate code for paritydi2 properly.

> Post merge, consider changing this to simple_return to enable shrink
> wrapping.  This may also involve epilogue unwind fixups though.

I have not enabled the "simple_return" pattern.  On the tile ports,
the prologue defines a register not accounted for in the shrink
wrapping code (the PIC_TEXT_LABEL_REGNUM register).  Is there a plan
to provide a target hook to support this?  I did verify that shrink
wrapping work properly when I account for this register.

> I also don't see support for AND addresses, as for lw_na.  And yet you
> seem to be using those addressing modes in tilepro_expand_unaligned_load.
> I can only assume these are failing validate_mem, and forcing the
> address into a register first?

Yeah there is no AND addressing mode; the addresses are being put into
registers.

> Why not use gp-relative references?  A small matter of extending the
> assembler with new relocations, perhaps.

We don't have that support in the tool chain currently.  I can look
into it, but I haven't done it.

> > /* We represent all SI values as sign-extended DI values in
> >registers.  */
> > #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) \
> >   ((INPREC) <= 32 || (OUTPREC) > 32)
> 
> I think you should be *very* careful before you insist on this.  Do
> you not have a memory mode that ignores the high bits for 32-bit
> pointers?  From the description of "memoryReadWord", it does seem like
> you've got modes that pre-process input addresses.

Unfortunately all the address bits are read; we do not ignore the high
bits of 32-bit pointers.

> MIPS uses this because, technically, the 32-bit operation insns
> produce undefined results when given inputs that are not
> sign-extended.  I see no such restriction in the TileGx manual.

I think the issue is that we do not have 32-bit compares; we just
reuse the 64-bit ones.  This requires that the inputs be sign
extended.

> At least in 64-bit pointer mode, I think you should drop this and make
> sure that you've got appropriate sign_extend patterns for all of the
> "x" insns.  Similar to how x86_64 does for the zero_extend patterns.

I've added the sign_extend patterns for the 32-bit insns.

Please let me know if there is anything I need to address.

Thanks,

Walter Lee


[PATCH] New port resubmission for TILEPro and TILE-Gx 2/6: changes in contrib

2011-12-30 Thread Walter Lee
Here are the contrib changes.

2011-12-30  Walter Lee 

* config-list.mk (tilegx-linux-gnu): Add.
(tilepro-linux-gnu): Add.
* gcc_update (gcc/config/tilegx/mul-tables.c): New dependencies.
(gcc/config/tilepro/mul-tables.c): New dependencies.
diff -r -u -p -N /home/packages/gcc-4.7.0-182680/contrib/config-list.mk 
./contrib/config-list.mk
--- /home/packages/gcc-4.7.0-182680/contrib/config-list.mk  2011-12-08 
13:43:41.0 -0500
+++ ./contrib/config-list.mk2011-12-29 22:06:40.921926000 -0500
@@ -60,7 +60,8 @@ LIST = alpha-linux-gnu alpha-freebsd6 al
   sparc-leon3-linux-gnuOPT-enable-target=all sparc-netbsdelf \
   
sparc64-sun-solaris2.10OPT-with-gnu-ldOPT-with-gnu-asOPT-enable-threads=posix \
   sparc-wrs-vxworks sparc64-elf sparc64-rtems sparc64-linux sparc64-freebsd6 \
-  sparc64-netbsd sparc64-openbsd spu-elf v850e-elf v850-elf vax-linux-gnu \
+  sparc64-netbsd sparc64-openbsd spu-elf tilegx-linux-gnu tilepro-linux-gnu \
+  v850e-elf v850-elf vax-linux-gnu \
   vax-netbsdelf vax-openbsd x86_64-apple-darwin \
   x86_64-pc-linux-gnuOPT-with-fpmath=avx \
   x86_64-elfOPT-with-fpmath=sse x86_64-freebsd6 x86_64-netbsd \
diff -r -u -p -N /home/packages/gcc-4.7.0-182680/contrib/gcc_update 
./contrib/gcc_update
--- /home/packages/gcc-4.7.0-182680/contrib/gcc_update  2011-12-08 
13:43:41.0 -0500
+++ ./contrib/gcc_update2011-12-29 22:06:40.934902000 -0500
@@ -88,6 +88,8 @@ gcc/config/c6x/c6x-mult.md: gcc/config/c
 gcc/config/m68k/m68k-tables.opt: gcc/config/m68k/m68k-devices.def 
gcc/config/m68k/m68k-isas.def gcc/config/m68k/m68k-microarchs.def 
gcc/config/m68k/genopt.sh
 gcc/config/mips/mips-tables.opt: gcc/config/mips/mips-cpus.def 
gcc/config/mips/genopt.sh
 gcc/config/rs6000/rs6000-tables.opt: gcc/config/rs6000/rs6000-cpus.def 
gcc/config/rs6000/genopt.sh
+gcc/config/tilegx/mul-tables.c: gcc/config/tilepro/gen-mul-tables.cc
+gcc/config/tilepro/mul-tables.c: gcc/config/tilepro/gen-mul-tables.cc
 # And then, language-specific files
 gcc/cp/cfns.h: gcc/cp/cfns.gperf
 gcc/java/keyword.h: gcc/java/keyword.gperf


New port resubmission for TILEPro and TILE-Gx 4/6: libcpp port

2011-12-30 Thread Walter Lee
Here is the libcpp port.

2011-12-30  Walter Lee 

* configure.ac: Require 64-bit hwint for tilegx and tilepro.
* configure: Regenerate.
diff -r -u -p -N /home/packages/gcc-4.7.0-182680/libcpp/configure 
./libcpp/configure
--- /home/packages/gcc-4.7.0-182680/libcpp/configure2011-12-25 
17:50:24.0 -0500
+++ ./libcpp/configure  2011-12-29 22:06:47.767943000 -0500
@@ -7382,7 +7382,8 @@ case $target in
s390*-*-* | \
sparc*-*-* | \
spu-*-* | \
-   sh[123456789lbe]*-*-* | sh-*-*)
+   sh[123456789lbe]*-*-* | sh-*-* | \
+   tilegx-*-* | tilepro-*-* )
need_64bit_hwint=yes ;;
*)
need_64bit_hwint=no ;;
diff -r -u -p -N /home/packages/gcc-4.7.0-182680/libcpp/configure.ac 
./libcpp/configure.ac
--- /home/packages/gcc-4.7.0-182680/libcpp/configure.ac 2011-12-08 
13:45:51.0 -0500
+++ ./libcpp/configure.ac   2011-12-29 22:06:47.784911000 -0500
@@ -162,7 +162,8 @@ case $target in
s390*-*-* | \
sparc*-*-* | \
spu-*-* | \
-   sh[123456789lbe]*-*-* | sh-*-*)
+   sh[123456789lbe]*-*-* | sh-*-* | \
+   tilegx-*-* | tilepro-*-* )
need_64bit_hwint=yes ;;
*)
need_64bit_hwint=no ;;


[PATCH] New port resubmission for TILEPro and TILE-Gx 5/6: libgcc port

2011-12-30 Thread Walter Lee
Here is the libgcc port.

2011-12-30  Walter Lee 

* config.host: Handle tilegx and tilepro.
* config/tilegx/sfp-machine.h: New file.
* config/tilegx/sfp-machine32.h: New file.
* config/tilegx/sfp-machine64.h: New file.
* config/tilegx/t-crtstuff: New file.
* config/tilegx/t-softfp: New file.
* config/tilegx/t-tilegx: New file.
* config/tilepro/atomic.c: New file.
* config/tilepro/atomic.h: New file.
* config/tilepro/linux-unwind.h: New file.
* config/tilepro/sfp-machine.h: New file.
* config/tilepro/softdivide.c: New file.
* config/tilepro/softmpy.S: New file.
* config/tilepro/t-crtstuff: New file.
* config/tilepro/t-tilepro: New file.


libgcc.diff.gz
Description: GNU Zip compressed data


[PATCH] New port resubmission for TILEPro and TILE-Gx 6/6: libgomp port

2011-12-30 Thread Walter Lee
Here is the libgomp port.

2011-12-30  Walter Lee 

* configure.tgt: Handle tilegx and tilepro.
* config/linux/tile/futex.h: New file.
diff -r -u -p -N 
/home/packages/gcc-4.7.0-182680/libgomp/config/linux/tile/futex.h 
./libgomp/config/linux/tile/futex.h
--- /home/packages/gcc-4.7.0-182680/libgomp/config/linux/tile/futex.h   
1969-12-31 19:00:00.0 -0500
+++ ./libgomp/config/linux/tile/futex.h 2011-12-29 22:06:53.524965000 -0500
@@ -0,0 +1,73 @@
+/* Copyright (C) 2011
+   Free Software Foundation, Inc.
+   Contributed by Walter Lee (w...@tilera.com)
+
+   This file is part of the GNU OpenMP Library (libgomp).
+
+   Libgomp 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.
+
+   Libgomp 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
+   .  */
+
+/* Provide target-specific access to the futex system call.  */
+
+#include 
+#include 
+
+static inline void
+sys_futex0 (int *addr, int op, int val)
+{
+  long _sys_result;
+  long _clobber_r2, _clobber_r3, _clobber_r4, _clobber_r5, _clobber_r10;
+  int err;
+
+  __asm__ __volatile__ (
+"swint1"
+: "=R00" (_sys_result), "=R01" (err), "=R02" (_clobber_r2),
+  "=R03" (_clobber_r3), "=R04" (_clobber_r4), "=R05" (_clobber_r5),
+  "=R10" (_clobber_r10)
+: "R10" (SYS_futex), "R00" (addr), "R01" (op), "R02" (val),
+  "R03" (0)
+:  "r6",  "r7",
+   "r8",  "r9","r11", "r12", "r13", "r14", "r15",
+  "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23",
+  "r24", "r25", "r26", "r27", "r28", "r29", "memory");
+}
+
+static inline void
+futex_wait (int *addr, int val)
+{
+  sys_futex0 (addr, FUTEX_WAIT, val);
+}
+
+static inline void
+futex_wake (int *addr, int count)
+{
+  sys_futex0 (addr, FUTEX_WAKE, count);
+}
+
+static inline void
+cpu_relax (void)
+{
+  __asm volatile ("" : : : "memory");
+}
+
+static inline void
+atomic_write_barrier (void)
+{
+  __sync_synchronize ();
+}
diff -r -u -p -N /home/packages/gcc-4.7.0-182680/libgomp/configure.tgt 
./libgomp/configure.tgt
--- /home/packages/gcc-4.7.0-182680/libgomp/configure.tgt   2011-10-14 
00:46:46.0 -0400
+++ ./libgomp/configure.tgt 2011-12-29 22:06:48.781929000 -0500
@@ -51,6 +51,10 @@ if test $enable_linux_futex = yes; then
config_path="linux/s390 linux posix"
;;
 
+tile*-*-linux*)
+   config_path="linux/tile linux posix"
+   ;;
+
 # Note that bare i386 is not included here.  We need cmpxchg.
 i[456]86-*-linux*)
config_path="linux/x86 linux posix"


Re: [PATCH] New port resubmission for TILEPro and TILE-Gx 1/6: toplevel changes

2011-12-30 Thread Walter Lee
Here are the toplevel changes.

2011-12-30  Walter Lee 
* MAINTAINERS (tilegx port): Add self.
(tilepro port): Add self.
diff -r -u -p -N /home/packages/gcc-4.7.0-182680/MAINTAINERS ./MAINTAINERS
--- /home/packages/gcc-4.7.0-182680/MAINTAINERS 2011-12-18 01:31:26.0 
-0500
+++ ./MAINTAINERS   2011-12-29 22:06:38.548864000 -0500
@@ -104,6 +104,8 @@ sparc port  Eric Botcazou   ebotcazou@lib
 spu port   Trevor Smigiel  
trevor_smig...@playstation.sony.com
 spu port   David Edelsohn  dje@gmail.com
 spu port   Ulrich Weigand  uweig...@de.ibm.com
+tilegx portWalter Lee  w...@tilera.com
+tilepro port   Walter Lee  w...@tilera.com
 v850 port  Nick Cliftonni...@redhat.com
 vax port   Matt Thomas m...@3am-software.com
 x86-64 portJan Hubicka j...@suse.cz


[Cilkplus] Patches about Array Notations

2011-12-30 Thread Balaji V. Iyer
Hello Everyone,
 Here are seven patches about array notations that were submitted
to GCC patches mailing list for the Cilkplus branch. If anyone finds
any problems or have any objections, please let me know. Otherwise, I
will check them into the Cilkplus branch Monday.

Here are the patch emails:

http://gcc.gnu.org/ml/gcc-patches/2011-12/msg00691.html
http://gcc.gnu.org/ml/gcc-patches/2011-12/msg01397.html
http://gcc.gnu.org/ml/gcc-patches/2011-12/msg01398.html
http://gcc.gnu.org/ml/gcc-patches/2011-12/msg01473.html
http://gcc.gnu.org/ml/gcc-patches/2011-12/msg01581.html
http://gcc.gnu.org/ml/gcc-patches/2011-12/msg01667.html
http://gcc.gnu.org/ml/gcc-patches/2011-12/msg01698.html


Thanks,

Balaji V. Iyer.