Re: [PATCH] remove HARD_FRAME_POINTER_IS_ARG_POINTER macro

2016-08-20 Thread Bernd Edlinger
 > its kind of silly, and this allows us to remove a few more #ifdefs.
 >
 > bootstrapped + regtest x86_64-linux-gnu, ok?

No, I don't think so, because:

 >  #if FRAME_POINTER_REGNUM != ARG_POINTER_REGNUM
 > -#if HARD_FRAME_POINTER_IS_ARG_POINTER
 > +#if HARD_FRAME_POINTER_REGNUM == ARG_POINTER_REGNUM
 >GR_ARG_POINTER = GR_HARD_FRAME_POINTER,
 >  #else

will likely break arm and mips.
The only targets that define HARD_FRAME_POINTER_IS_ARG_POINTER
probably for some reason.

see arm.h:

#define HARD_FRAME_POINTER_REGNUM   \
   (TARGET_ARM   \
? ARM_HARD_FRAME_POINTER_REGNUM  \
: THUMB_HARD_FRAME_POINTER_REGNUM)

#define FRAME_POINTER_REGNUM102

#define ARG_POINTER_REGNUM  103


see mips.h:

#define ARG_POINTER_REGNUM 77
#define FRAME_POINTER_REGNUM 78

#define HARD_FRAME_POINTER_REGNUM \
   (TARGET_MIPS16 ? GP_REG_FIRST + 17 : GP_REG_FIRST + 30)


so #if HARD_FRAME_POINTER_REGNUM == ARG_POINTER_REGNUM
will not be evaluatable by the preprocessor.



Bernd.


[wwwdocs,libstdc++] Remove libstdc++/

2016-08-20 Thread Gerald Pfeifer
Our libstdc++/ page dates back to when libstdc++ was merged into GCC in 
2000, 0x10 years ago.  It has been a mostly empty shell for most of that 
time period and hardly seen any updates in the last decade.

So, after https://gcc.gnu.org/ml/gcc-patches/2016-08/msg01467.html I 
suggest to streamline things, remove this page, and apply the patch
below.

Any big concerns or fierce objections?

Gerald

Index: .htaccess
===
RCS file: /cvs/gcc/wwwdocs/htdocs/.htaccess,v
retrieving revision 1.37
diff -u -r1.37 .htaccess
--- .htaccess   21 Apr 2016 23:04:36 -  1.37
+++ .htaccess   20 Aug 2016 18:23:20 -
@@ -33,6 +33,7 @@
 Redirect permanent /gcc-4.6/c99status.html 
https://gcc.gnu.org/c99status.html
 Redirect permanent /gcc-4.7/c99status.html 
https://gcc.gnu.org/c99status.html
 
+Redirect permanent /libstdc++/ https://gcc.gnu.org/
 Redirect permanent /libstdc++/mail.html
https://gcc.gnu.org/lists.html
 Redirect permanent /libstdc++/links.html   
https://gcc.gnu.org/readings.html
 Redirect permanent /onlinedocs/libstdc++/faq/index.html 
https://gcc.gnu.org/onlinedocs/libstdc++/faq.html
Index: index.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/index.html,v
retrieving revision 1.1021
diff -u -r1.1021 index.html
--- index.html  15 Aug 2016 14:25:03 -  1.1021
+++ index.html  20 Aug 2016 18:23:20 -
@@ -16,7 +16,7 @@
 C++,
 Objective-C, Fortran,
 Java, Ada, and Go, as well as libraries for these
-languages (libstdc++, libgcj,...).
+languages (libstdc++, libgcj,...).
 GCC was originally written as the compiler for the http://www.gnu.org/gnu/thegnuproject.html;>GNU operating system.
 The GNU system was developed to be 100% free software, free in the sense
Index: style.mhtml
===
RCS file: /cvs/gcc/wwwdocs/htdocs/style.mhtml,v
retrieving revision 1.130
diff -u -r1.130 style.mhtml
--- style.mhtml 23 Apr 2016 16:14:52 -  1.130
+++ style.mhtml 20 Aug 2016 18:23:20 -
@@ -19,13 +19,6 @@
  >
 >
 
- "libstdc../[^/]*.html">
- 
-  
- >
->
-
 ;;; Note that the  line really needs to start in the first column.
 
 
@@ -132,20 +125,6 @@
>
   >
 
-   "libstdc../[^/]*.html">
-   
-libstdc++ v3
-
-libstdc++ Home
-GCC Home
-https://gcc.gnu.org/onlinedocs/libstdc++/faq.html;>FAQ
-https://gcc.gnu.org/onlinedocs/libstdc++/;>Documentation
-
-
-   >
-  >
-
   
   About GCC
   
Index: gcc-3.0/features.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-3.0/features.html,v
retrieving revision 1.36
diff -u -r1.36 features.html
--- gcc-3.0/features.html   28 Jun 2014 07:45:10 -  1.36
+++ gcc-3.0/features.html   20 Aug 2016 18:23:20 -
@@ -101,7 +101,7 @@
 inter-operating with other IA-64 compilers. 
 The new ABI also significantly reduces the size of symbol and debug
 information.
-New C++ support library
+New C++ support library
 and many C++ bug fixes, vastly improving our conformance to the
 ISO C++ standard.
 New inliner for C++.
Index: libstdc++/index.html
===
RCS file: libstdc++/index.html
diff -N libstdc++/index.html
--- libstdc++/index.html29 Jun 2014 11:47:05 -  1.39
+++ /dev/null   1 Jan 1970 00:00:00 -
@@ -1,49 +0,0 @@
-
-
- 
- Standard C++ Library v3
-
-
-
-
-What... is your name?
-
-The GNU Standard C++ Library v3, or libstdc++-v3.  Older snapshots of
-   this library were given the name libstdc++-2.9x up until the release of
-   GCC 3.  This is a complete rewrite from the previous libstdc++-v2.
-
-
-What... is your quest?
-
-This is an ongoing project to implement the ISO 14882 Standard
-   C++ Library as described in chapters 17 through 30 and Annex D.
-   Participation is welcome!
-
-
-What... is the airspeed velocity of an unladen swallow?
-
-http://www.armory.com/swallowscenes.html;>African or 
European?
-
-
-
-
-Downloading
-
-libstdc++-v3 is developed and released as part of GCC, separate
-   snapshots are no longer made available.  The libstdc++-v3 sources are
-   included with the GCC sources and can be downloaded from the GCC FTP
-   area or from any of the GCC mirror sites.
-
-
-The SVN source repository is part of the GCC repository.  Instructions
-   for anonymous SVN access are the same as
-   those for the rest of the compiler.  Checking
-   out the GCC trunk or one of the branches will also get the
-   library sources; to retrieve only the library, check out
-   trunk/libstdc++-v3 instead.
-
-
-
-


[PATCH] remove HARD_FRAME_POINTER_IS_ARG_POINTER macro

2016-08-20 Thread tbsaunde+gcc
From: Trevor Saunders 

Hi,

its kind of silly, and this allows us to remove a few more #ifdefs.

bootstrapped + regtest x86_64-linux-gnu, ok?

Trev

gcc/ChangeLog:

2016-08-20  Trevor Saunders  

* rtl.h (HARD_FRAME_POINTER_IS_ARG_POINTER): Remove definition.
(enum global_rtl_index): Adjust.
* builtins.c (expand_builtin_setjmp_receiver): Likewise.
* config/arm/arm.h: Likewise.
* config/mips/mips.h: Likewise.
* dbxout.c (dbxout_symbol_location): Likewise.
(dbxout_parms): Likewise.
* doc/tm.texi: Regenerate.
* doc/tm.texi.in: Adjust.
* dse.c (scan_insn): Likewise.
* dwarf2out.c (rtl_for_decl_location): Likewise.
* emit-rtl.c (gen_rtx_REG): Likewise.
---
 gcc/builtins.c |  3 ++-
 gcc/config/arm/arm.h   |  1 -
 gcc/config/mips/mips.h |  1 -
 gcc/dbxout.c   | 10 ++
 gcc/doc/tm.texi|  8 
 gcc/doc/tm.texi.in |  8 
 gcc/dse.c  |  2 +-
 gcc/dwarf2out.c|  5 +
 gcc/emit-rtl.c |  7 ---
 gcc/rtl.h  |  7 +--
 10 files changed, 11 insertions(+), 41 deletions(-)

diff --git a/gcc/builtins.c b/gcc/builtins.c
index 03a0dc8..657fb74 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -859,7 +859,8 @@ expand_builtin_setjmp_receiver (rtx receiver_label)
   emit_clobber (hard_frame_pointer_rtx);
 }
 
-  if (!HARD_FRAME_POINTER_IS_ARG_POINTER && fixed_regs[ARG_POINTER_REGNUM])
+  if (HARD_FRAME_POINTER_REGNUM!= ARG_POINTER_REGNUM
+  && fixed_regs[ARG_POINTER_REGNUM])
 {
 #ifdef ELIMINABLE_REGS
   /* If the argument pointer can be eliminated in favor of the
diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h
index c7149d1..352d859 100644
--- a/gcc/config/arm/arm.h
+++ b/gcc/config/arm/arm.h
@@ -916,7 +916,6 @@ extern int arm_arch_crc;
: THUMB_HARD_FRAME_POINTER_REGNUM)
 
 #define HARD_FRAME_POINTER_IS_FRAME_POINTER 0
-#define HARD_FRAME_POINTER_IS_ARG_POINTER 0
 
 #define FP_REGNUM  HARD_FRAME_POINTER_REGNUM
 
diff --git a/gcc/config/mips/mips.h b/gcc/config/mips/mips.h
index e8897d1..7b71fe3 100644
--- a/gcc/config/mips/mips.h
+++ b/gcc/config/mips/mips.h
@@ -1967,7 +1967,6 @@ FP_ASM_SPEC "\
   (TARGET_MIPS16 ? GP_REG_FIRST + 17 : GP_REG_FIRST + 30)
 
 #define HARD_FRAME_POINTER_IS_FRAME_POINTER 0
-#define HARD_FRAME_POINTER_IS_ARG_POINTER 0
 
 /* Register in which static-chain is passed to a function.  */
 #define STATIC_CHAIN_REGNUM (GP_REG_FIRST + 15)
diff --git a/gcc/dbxout.c b/gcc/dbxout.c
index ad256c7..9d6ecf3 100644
--- a/gcc/dbxout.c
+++ b/gcc/dbxout.c
@@ -3078,10 +3078,7 @@ dbxout_symbol_location (tree decl, tree type, const char 
*suffix, rtx home)
   || (REG_P (XEXP (home, 0))
   && REGNO (XEXP (home, 0)) != HARD_FRAME_POINTER_REGNUM
   && REGNO (XEXP (home, 0)) != STACK_POINTER_REGNUM
-#if !HARD_FRAME_POINTER_IS_ARG_POINTER
-  && REGNO (XEXP (home, 0)) != ARG_POINTER_REGNUM
-#endif
-  )))
+  && REGNO (XEXP (home, 0)) != ARG_POINTER_REGNUM)))
 /* If the value is indirect by memory or by a register
that isn't the frame pointer
then it means the object is variable-sized and address through
@@ -3492,10 +3489,7 @@ dbxout_parms (tree parms)
 && REG_P (XEXP (DECL_RTL (parms), 0))
 && REGNO (XEXP (DECL_RTL (parms), 0)) != 
HARD_FRAME_POINTER_REGNUM
 && REGNO (XEXP (DECL_RTL (parms), 0)) != STACK_POINTER_REGNUM
-#if !HARD_FRAME_POINTER_IS_ARG_POINTER
-&& REGNO (XEXP (DECL_RTL (parms), 0)) != ARG_POINTER_REGNUM
-#endif
-)
+&& REGNO (XEXP (DECL_RTL (parms), 0)) != ARG_POINTER_REGNUM)
  {
/* Parm was passed via invisible reference.
   That is, its address was passed in a register.
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index 9edb006..129ca82 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -3472,14 +3472,6 @@ the same.  The default definition is 
@samp{(HARD_FRAME_POINTER_REGNUM
 definition is not suitable for use in preprocessor conditionals.
 @end defmac
 
-@defmac HARD_FRAME_POINTER_IS_ARG_POINTER
-Define this to a preprocessor constant that is nonzero if
-@code{hard_frame_pointer_rtx} and @code{arg_pointer_rtx} should be the
-same.  The default definition is @samp{(HARD_FRAME_POINTER_REGNUM ==
-ARG_POINTER_REGNUM)}; you only need to define this macro if that
-definition is not suitable for use in preprocessor conditionals.
-@end defmac
-
 @defmac RETURN_ADDRESS_POINTER_REGNUM
 The register number of the return address pointer register, which is used to
 access the current function's return address from the stack.  On some
diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
index a72c3d8..0adde80 100644
--- a/gcc/doc/tm.texi.in
+++ b/gcc/doc/tm.texi.in
@@ -3058,14 +3058,6 @@ 

[PATCH] remove conditional compilation of HAVE_AS_LEB128 code

2016-08-20 Thread tbsaunde+gcc
From: Trevor Saunders 

Hi,

basically just $subject, always define HAVE_AS_LEB128, and then use if / else
instead of #ifdef.  Note the diff has a bit of whitespace noise, so there's a 
-w diff below the full one.

bootstrapped and regtested on x86_64-linux-gnu, ok?

Trev

gcc/ChangeLog:

2016-08-20  Trevor Saunders  

* acinclude.m4 (gcc_GAS_CHECK_FEATURE): Support doing an action
if the feature isn't available.
* configure: Regenerate.
* configure.ac: define HAVE_AS_LEB128 to 0 when not available.
* dwarf2asm.c (dw2_asm_output_data_uleb128): Always compile code
for HAVE_AS_LEB128.
(dw2_asm_output_data_sleb128): Likewise.
(dw2_asm_output_delta_uleb128): Likewise.
(dw2_asm_output_delta_sleb128): Likewise.
* except.c (output_one_function_exception_table): Likewise.
(dw2_size_of_call_site_table): Likewise.
(sjlj_size_of_call_site_table): Likewise.
---
 gcc/acinclude.m4 |   4 ++
 gcc/configure| 106 +++-
 gcc/configure.ac |   2 +
 gcc/dwarf2asm.c  | 184 +++
 gcc/except.c | 162 
 5 files changed, 283 insertions(+), 175 deletions(-)

diff --git a/gcc/acinclude.m4 b/gcc/acinclude.m4
index 38dd899..791f2a7 100644
--- a/gcc/acinclude.m4
+++ b/gcc/acinclude.m4
@@ -550,6 +550,10 @@ AC_CACHE_CHECK([assembler for $1], [$2],
 ifelse([$7],,,[dnl
 if test $[$2] = yes; then
   $7
+fi])
+ifelse([$8],,,[dnl
+if test $[$2] != yes; then
+  $8
 fi])])
 
 dnl gcc_SUN_LD_VERSION
diff --git a/gcc/configure b/gcc/configure
index 871ed0c..e286123 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -22485,6 +22485,7 @@ $as_echo "#define HAVE_GAS_BALIGN_AND_P2ALIGN 1" 
>>confdefs.h
 
 fi
 
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for .p2align with 
maximum skip" >&5
 $as_echo_n "checking assembler for .p2align with maximum skip... " >&6; }
 if test "${gcc_cv_as_max_skip_p2align+set}" = set; then :
@@ -22520,6 +22521,7 @@ $as_echo "#define HAVE_GAS_MAX_SKIP_P2ALIGN 1" 
>>confdefs.h
 
 fi
 
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for .literal16" >&5
 $as_echo_n "checking assembler for .literal16... " >&6; }
 if test "${gcc_cv_as_literal16+set}" = set; then :
@@ -22555,6 +22557,7 @@ $as_echo "#define HAVE_GAS_LITERAL16 1" >>confdefs.h
 
 fi
 
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for working 
.subsection -1" >&5
 $as_echo_n "checking assembler for working .subsection -1... " >&6; }
 if test "${gcc_cv_as_subsection_m1+set}" = set; then :
@@ -22602,6 +22605,7 @@ $as_echo "#define HAVE_GAS_SUBSECTION_ORDERING 1" 
>>confdefs.h
 
 fi
 
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for .weak" >&5
 $as_echo_n "checking assembler for .weak... " >&6; }
 if test "${gcc_cv_as_weak+set}" = set; then :
@@ -22637,6 +22641,7 @@ $as_echo "#define HAVE_GAS_WEAK 1" >>confdefs.h
 
 fi
 
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for .weakref" >&5
 $as_echo_n "checking assembler for .weakref... " >&6; }
 if test "${gcc_cv_as_weakref+set}" = set; then :
@@ -22672,6 +22677,7 @@ $as_echo "#define HAVE_GAS_WEAKREF 1" >>confdefs.h
 
 fi
 
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for .nsubspa 
comdat" >&5
 $as_echo_n "checking assembler for .nsubspa comdat... " >&6; }
 if test "${gcc_cv_as_nsubspa_comdat+set}" = set; then :
@@ -22708,6 +22714,7 @@ $as_echo "#define HAVE_GAS_NSUBSPA_COMDAT 1" 
>>confdefs.h
 
 fi
 
+
 # .hidden needs to be supported in both the assembler and the linker,
 # because GNU LD versions before 2.12.1 have buggy support for STV_HIDDEN.
 # This is irritatingly difficult to feature test for; we have to check the
@@ -22747,6 +22754,7 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_hidden" >&5
 $as_echo "$gcc_cv_as_hidden" >&6; }
 
+
 case "${target}" in
   *-*-darwin*)
 # Darwin as has some visibility support, though with a different syntax.
@@ -23199,6 +23207,11 @@ if test $gcc_cv_as_leb128 = yes; then
 $as_echo "#define HAVE_AS_LEB128 1" >>confdefs.h
 
 fi
+if test $gcc_cv_as_leb128 != yes; then
+
+$as_echo "#define HAVE_AS_LEB128 0" >>confdefs.h
+
+fi
 
 # Check if we have assembler support for unwind directives.
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for cfi 
directives" >&5
@@ -23278,6 +23291,7 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_cfi_directive" >&5
 $as_echo "$gcc_cv_as_cfi_directive" >&6; }
 
+
 if test $gcc_cv_as_cfi_directive = yes && test x$gcc_cv_objdump != x; then
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for working cfi 
advance" >&5
 $as_echo_n "checking assembler for working cfi advance... " >&6; }
@@ -23315,6 +23329,7 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: 
$gcc_cv_as_cfi_advance_working" >&5
 $as_echo 

Re: [PATCH build/doc] Replacing libiberty with gnulib

2016-08-20 Thread Manuel López-Ibáñez
On 20 August 2016 at 11:22, ayush goel  wrote:
>>
>> We're talking about a one-line change, but this is absolutely
>> crucial and central to use of gnulib. Until this is correct,
>> any previous host-specific testing is invalid, unfortunately.
>>
>> In the previous revision, you had:
>>
>> INCGNU = -I../gnulib -I$(srcdir)/../gnulib/import
>>
>> and I was expecting to see in the new revision something
>> like:
>>
>> INCGNU = -I../gnulib/import -I$(srcdir)/../gnulib/import
>>
>> or perhaps even better:
>>
>> INCGNU = -I$(build_libobjdir)/gnulib/import -I$(srcdir)/../gnulib/import
>>
>> Try hacking one of the generated replacement headers, one that gcc
>> is sure to include, to cause a compilation error. E.g. add an #error call
>> to the generated gnulib/import/unistd.h. If a gcc build, from scratch since
>> there are no Makefile dependencies, still compiles with that, then we're
>> still not picking the right headers.
>
> So your concern seems valid, however the build process seems to pick
> the correct headers.
> I did try to raise an error from the gnulib generated header unitstd.h
> and it gives me a compile time error:

Perhaps adding #error is not the best way to test this, since gnulib
may still pick the correct headers, but gcc the wrong ones and the
error you showed happens when building gnulib. A better way, perhaps,
would be to add to unitsdt.h something like

#define unitstd_h_gnulib

then in some gcc/ file that includes this header, like gcov-tool.c or
system.h, you can do just after the #include

#ifndef unitstd_h_gnulib
#error "unitstd_h_gnulib not defined"
#endif

Test that it fails when not having the correct INCGNU and that it
works when having it. This should settle it, I hope.

Cheers,

Manuel.


[Patch] Reduce regex _M_dfs frame size

2016-08-20 Thread Tim Shen
I merely split _M_dfs() into small functions to see how it goes. It
turns out to save half of the stack consumption in -O0 without
observable performance impact.

If we want, we can use __attribute__((always_inline)) and
__attribute__((noinline)) to make those handler functions back and
forth for reasons. We know that we are going to do better than the
inliner on complicated recursive functions, right? :)

Thanks!


-- 
Regards,
Tim Shen
commit d15f3ded9ca5133a23b511a1dbe127673609ce92
Author: Tim Shen 
Date:   Sat Aug 20 03:14:40 2016 -0700

2016-08-20  Tim Shen  

Split _M_dfs() into smaller functions. This seems don't affect
performance, but reduces -O0 stack consumption by half (on my
x86_64-linux-gnu). NFC.

* regex_executor.h: Add separate function declarations.
* regex_executor.tcc: Split _M_dfs() into multiple handler
functions.

diff --git a/libstdc++-v3/include/bits/regex_executor.h 
b/libstdc++-v3/include/bits/regex_executor.h
index ef8aa91..33a68dd 100644
--- a/libstdc++-v3/include/bits/regex_executor.h
+++ b/libstdc++-v3/include/bits/regex_executor.h
@@ -109,6 +109,39 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   _M_rep_once_more(_Match_mode __match_mode, _StateIdT);
 
   void
+  _M_handle_repeat(_Match_mode, _StateIdT);
+
+  void
+  _M_handle_subexpr_begin(_Match_mode, _StateIdT);
+
+  void
+  _M_handle_subexpr_end(_Match_mode, _StateIdT);
+
+  void
+  _M_handle_line_begin_assertion(_Match_mode, _StateIdT);
+
+  void
+  _M_handle_line_end_assertion(_Match_mode, _StateIdT);
+
+  void
+  _M_handle_word_boundary(_Match_mode, _StateIdT);
+
+  void
+  _M_handle_subexpr_lookahead(_Match_mode, _StateIdT);
+
+  void
+  _M_handle_match(_Match_mode, _StateIdT);
+
+  void
+  _M_handle_backref(_Match_mode, _StateIdT);
+
+  void
+  _M_handle_accept(_Match_mode, _StateIdT);
+
+  void
+  _M_handle_alternative(_Match_mode, _StateIdT);
+
+  void
   _M_dfs(_Match_mode __match_mode, _StateIdT __start);
 
   bool
diff --git a/libstdc++-v3/include/bits/regex_executor.tcc 
b/libstdc++-v3/include/bits/regex_executor.tcc
index 6bbcb1b..382909f 100644
--- a/libstdc++-v3/include/bits/regex_executor.tcc
+++ b/libstdc++-v3/include/bits/regex_executor.tcc
@@ -195,213 +195,295 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
 };
 
+  // _M_alt branch is "match once more", while _M_next is "get me out
+  // of this quantifier". Executing _M_next first or _M_alt first don't
+  // mean the same thing, and we need to choose the correct order under
+  // given greedy mode.
   template
 void _Executor<_BiIter, _Alloc, _TraitsT, __dfs_mode>::
-_M_dfs(_Match_mode __match_mode, _StateIdT __i)
+_M_handle_repeat(_Match_mode __match_mode, _StateIdT __i)
 {
-  if (_M_states._M_visited(__i))
-   return;
-
   const auto& __state = _M_nfa[__i];
-  // Every change on _M_cur_results and _M_current will be rolled back 
after
-  // finishing the recursion step.
-  switch (__state._M_opcode())
+
+  // Greedy.
+  if (!__state._M_neg)
{
-   // _M_alt branch is "match once more", while _M_next is "get me out
-   // of this quantifier". Executing _M_next first or _M_alt first don't
-   // mean the same thing, and we need to choose the correct order under
-   // given greedy mode.
-   case _S_opcode_repeat:
- {
-   // Greedy.
-   if (!__state._M_neg)
- {
-   _M_rep_once_more(__match_mode, __i);
-   // If it's DFS executor and already accepted, we're done.
-   if (!__dfs_mode || !_M_has_sol)
- _M_dfs(__match_mode, __state._M_next);
- }
-   else // Non-greedy mode
- {
-   if (__dfs_mode)
- {
-   // vice-versa.
-   _M_dfs(__match_mode, __state._M_next);
-   if (!_M_has_sol)
- _M_rep_once_more(__match_mode, __i);
- }
-   else
- {
-   // DON'T attempt anything, because there's already another
-   // state with higher priority accepted. This state cannot
-   // be better by attempting its next node.
-   if (!_M_has_sol)
- {
-   _M_dfs(__match_mode, __state._M_next);
-   // DON'T attempt anything if it's already accepted. An
-   // accepted state *must* be better than a solution that
-   // matches a non-greedy quantifier one more time.
-   if (!_M_has_sol)
- _M_rep_once_more(__match_mode, __i);
- }
- }
- }
-   }
- break;
-   case 

Re: [PATCH build/doc] Replacing libiberty with gnulib

2016-08-20 Thread ayush goel
>
> We're talking about a one-line change, but this is absolutely
> crucial and central to use of gnulib. Until this is correct,
> any previous host-specific testing is invalid, unfortunately.
>
> In the previous revision, you had:
>
> INCGNU = -I../gnulib -I$(srcdir)/../gnulib/import
>
> and I was expecting to see in the new revision something
> like:
>
> INCGNU = -I../gnulib/import -I$(srcdir)/../gnulib/import
>
> or perhaps even better:
>
> INCGNU = -I$(build_libobjdir)/gnulib/import -I$(srcdir)/../gnulib/import
>
> Try hacking one of the generated replacement headers, one that gcc
> is sure to include, to cause a compilation error. E.g. add an #error call
> to the generated gnulib/import/unistd.h. If a gcc build, from scratch since
> there are no Makefile dependencies, still compiles with that, then we're
> still not picking the right headers.

So your concern seems valid, however the build process seems to pick
the correct headers.
I did try to raise an error from the gnulib generated header unitstd.h
and it gives me a compile time error:

--
gcc -DHAVE_CONFIG_H -I. -I/Users/ayushgoel/gsoc/src/gnulib/import -I..
    -g -O2 -MT exitfail.o -MD -MP -MF .deps/exitfail.Tpo -c -o
exitfail.o /Users/ayushgoel/gsoc/src/gnulib/import/exitfail.c
gcc -DHAVE_CONFIG_H -I. -I/Users/ayushgoel/gsoc/src/gnulib/import -I..
    -g -O2 -MT unistd.o -MD -MP -MF .deps/unistd.Tpo -c -o unistd.o
/Users/ayushgoel/gsoc/src/gnulib/import/unistd.c
gcc -DHAVE_CONFIG_H -I. -I/Users/ayushgoel/gsoc/src/gnulib/import -I..
    -g -O2 -MT obstack.o -MD -MP -MF .deps/obstack.Tpo -c -o obstack.o
/Users/ayushgoel/gsoc/src/gnulib/import/obstack.c
In file included from /Users/ayushgoel/gsoc/src/gnulib/import/unistd.c:3:
./unistd.h:18:2: error: “Unistd header file being invoked"
#error “unistd from gnulib being invoked"
 ^
config.status: creating config.h
1 error generated.
make[5]: *** [unistd.o] Error 1

Also, I’m sure of the fact that gnulib headers are being used because
all the functions that I’ve replaced from libiberty, I locally removed
both the .c and .h files from libiberty to confirm that the gnulib’s
version is indeed being used, and it compiled just fine.

I’m not really sure how else it is being able to figure out where to
look for the header files however just to be on the safer side I’ve
made the change that you’ve mentioned.

>
> > Index: src/gcc/mkconfig.sh
> > ===
> > --- src/gcc/mkconfig.sh (revision 237184)
> > +++ src/gcc/mkconfig.sh (working copy)
> > @@ -43,6 +43,7 @@
> > # A special test to ensure that build-time files don't blindly use
> > # config.h.
> > if test x"$output" = x"config.h"; then
> > + echo '#include "../gnulib/config.h"' >> ${output}T
> > echo "#ifdef GENERATOR_FILE" >> ${output}T
> > echo "#error config.h is for the host, not build, machine." >> ${output}T
> > echo "#endif" >> ${output}T
>
> Hmm, this looks incorrect/incomplete, for not considering the generator
> programs that are built for the "build" machine. AFAICS, those include
> "bconfig.h" instead of "config.h". Note the GENERATOR_FILE check above.
>
> My recollection is that those build-machine programs link with libiberty
> too today, and should thus switch to gnulib as well, right?
>

So my understanding of this is that the gnulib.h is also required to
be included inside bconfig.h?


[libstdc++,wwwdocs] Do not refer to libstdc++/ for more information

2016-08-20 Thread Gerald Pfeifer
Working on something else, I noticed that in news.html we have various 
references to libstdc++/ (the libstdc++ "micro site") for further 
information.  Except there really isn't much further information
there, so let's remove those links.

(This also is in preparation of another, forthcoming patch.)

Applied.

Gerald

Index: news.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/news.html,v
retrieving revision 1.150
diff -u -r1.150 news.html
--- news.html   24 Jan 2016 23:54:36 -  1.150
+++ news.html   20 Aug 2016 09:41:56 -
@@ -1467,8 +1467,6 @@
 August 4, 1999
 
 A new snapshot of the new Standard C++ Library V3 has been released.
-You can find more information from the
-libstdc++ project's home page.
 
 Cygnus Solutions has released libgcj
 version 2.95 Java runtime libraries for use with GCC 2.95.
@@ -1530,8 +1528,7 @@
 The sixth snapshot of the ongoing re-written C++ Standard Library has
 been released.  It includes SGI STL 3.2, an automatically generated
 limits, a partially re-written valarray, a working
-stringbuf and stringstream (for basic types). For more information,
-please check libstdc++ home page.
+stringbuf and stringstream (for basic types).
 
 
 April 23, 1999
@@ -1583,8 +1580,7 @@
 
 A new snapshot of the C++ standard library re-write has been
 released. This release includes SGI STL 3.12, a working valarray, and
-several (but not all) parts of templatized iostreams--for more information see:
-libstdc++ home page.
+several (but not all) parts of templatized iostreams.
 
 
 March 23, 1999
@@ -1684,8 +1680,7 @@
 
 
 November 5, 1998
-The third snapshot of the rewritten libstdc++ is available.
-You can read some more on libstdc++/.
+The third snapshot of the rewritten libstdc++ is available.
 
 
 October 27, 1998
@@ -1734,8 +1729,7 @@
 
 
 July 15, 1998
-The first snapshot of the rewritten libstdc++ is available.
-You can read some more here.
+The first snapshot of the rewritten libstdc++ is available.
 
 
 June 29, 1998


Re: [PATCH] Restrict jump threading statement simplifier to scalar types (PR71077)

2016-08-20 Thread Uros Bizjak
> Turning it into a compile test that counts the number of jumps threaded
> seems potentially flaky but I'm not against it.  And I'm not sure how to
> reliably turn it into an execution test.  Would the directives
>
> /* { dg-do run }  */
> /* { dg-require-effective-target avx2 }  */
> /* { dg-require-effective-target ia32 }  */
> /* { dg-options "-O3 -mavx2" }  */
>
> work?

No, this only checks that the target is able to compile the testcase.
In gcc.target/i386, there is ialready present nfrastructure that
handles runtime checks (avx2_test) in your case. You can see many
examples there.

Uros.


Re: [PATCH] tree-optimization/71831 - __builtin_object_size poor results with no optimization

2016-08-20 Thread Jakub Jelinek
On Sat, Aug 20, 2016 at 09:02:37AM +0200, Florian Weimer wrote:
> Does this mean that with this patch, glibc should remove its
> _FORTIFY_SOURCE warning for non-optimized builds when compiling under
> GCC >= 7?

Of course not, you really need optimizations for _FORTIFY_SOURCE to be
useful.

Jakub


Re: [PATCH] tree-optimization/71831 - __builtin_object_size poor results with no optimization

2016-08-20 Thread Jakub Jelinek
On Fri, Aug 19, 2016 at 04:30:47PM -0600, Martin Sebor wrote:
> The patch looks bigger than it actually is because:
> 
> 1) It modifies the return type of the function to bool rather than
>unsigned HOST_WIDE_INT representing the object size (this was
>necessary to avoid having its callers misinterpret zero as
>unknown when it means zero bytes).

Can you explain why do you need this?  I don't understand why do you need to
differentiate between unknown and maximum (or minimum for modes 2 and 3 that
nobody actually uses in real-world), the builtin after all returns the same
value for both.  If you want to know if the compiler knows the size
precisely, you can request both mode 0 (or 1) and 2 (or 3) and compare, if
the values are the same, it is the exact size, if there is a range, then you
have minimum and maximum (and, if minimum is 0, but maximum non-zero, you
really don't know minimum, if maximum is -1, then you really don't know the
maximum (no object should be better that big).  For the return value, I
don't see how you could reliably differentiate between the two even if it
made for whatever strange reason sense - for SSA_NAMEs etc. you have just
recorded the sizes, not also a flag whether it is unknown or known.

> 2) As a result of a small change to the conditional that controls
>the main algorithm of the compute_builtin_object_size function
>it changes the depth of its indentation (without actually
>changing any of the code there).

If you've done lots of redindentation, then additionally diff -upb would be
appreciated.

Jakub


[PATCH, C++] Warn on redefinition of builtin functions (PR c++/71973)

2016-08-20 Thread Bernd Edlinger
Hi!

Currently C++ does not warn at all when built-in functions are re-defined
with a different signature, while C does warn on that even without -Wall.

Thus I'd like to propose a -Wall enabled warning for that in C++.

Initially I tried to warn unconditionally but that made too  many tests
in the C++ testsuite emit that warning :-(

So making the warning dependent on Wall is a compromise due
to the very many compile only tests, that use this "feature".

There is also a wrong-code side on this redefinition, because
even if the new function has the nothrow attribute the code is
generated as if it could throw.  Fixed as well.


Boot-strap and reg-testing on x86_64-linux-gnu.
Is it OK for trunk?


Thanks
Bernd.gcc:
2016-08-20  Bernd Edlinger  

PR c++/71973
* doc/invoke.texi: Document -Wbuiltin-function-redefined.

c-family:
2016-08-20  Bernd Edlinger  

PR c++/71973
* c.opt (Wbuiltin-function-redefined): New warning.

cp:
2016-08-20  Bernd Edlinger  

PR c++/71973
* decl.c (duplicate_decls): Warn when a built-in function is redefined.
Copy the TREE_NOTHROW flag unmodified to the old decl.

testsuite:
2016-08-20  Bernd Edlinger  

PR c++/71973
* g++.dg/pr71973.C: New test.
* g++.dg/warn/noeffect5.C: Add extern "C" to built-in function.
* g++.old-deja/g++.other/warn01.C: Likewise.
Index: gcc/c-family/c.opt
===
--- gcc/c-family/c.opt	(revision 239624)
+++ gcc/c-family/c.opt	(working copy)
@@ -299,6 +299,10 @@ Wframe-address
 C ObjC C++ ObjC++ Var(warn_frame_address) Warning LangEnabledBy(C ObjC C++ ObjC++,Wall)
 Warn when __builtin_frame_address or __builtin_return_address is used unsafely.
 
+Wbuiltin-function-redefined
+C++ ObjC++ Var(warn_builtin_function_redefined) Warning LangEnabledBy(C++ ObjC++,Wall)
+Warn when a built-in function is redefined.
+
 Wbuiltin-macro-redefined
 C ObjC C++ ObjC++ CPP(warn_builtin_macro_redefined) CppReason(CPP_W_BUILTIN_MACRO_REDEFINED) Var(cpp_warn_builtin_macro_redefined) Init(1) Warning
 Warn when a built-in preprocessor macro is undefined or redefined.
Index: gcc/cp/decl.c
===
--- gcc/cp/decl.c	(revision 239624)
+++ gcc/cp/decl.c	(working copy)
@@ -1502,6 +1502,14 @@ duplicate_decls (tree newdecl, tree olddecl, bool
 		  }
 		else if (! same_type_p (TREE_VALUE (t1), TREE_VALUE (t2)))
 		  break;
+	  if (t1 || t2
+		  || DECL_LANGUAGE (newdecl) != DECL_LANGUAGE (olddecl)
+		  || ! same_type_p (TREE_TYPE (TREE_TYPE (olddecl)),
+TREE_TYPE (TREE_TYPE (newdecl
+		warning_at (DECL_SOURCE_LOCATION (newdecl),
+			OPT_Wbuiltin_function_redefined,
+			"declaration of %q+#D conflicts with built-in "
+			"declaration %q#D", newdecl, olddecl);
 	}
 	  else if ((DECL_EXTERN_C_P (newdecl)
 		&& DECL_EXTERN_C_P (olddecl))
@@ -1555,7 +1563,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool
 
   /* Whether or not the builtin can throw exceptions has no
 	 bearing on this declarator.  */
-  TREE_NOTHROW (olddecl) = 0;
+  TREE_NOTHROW (olddecl) = TREE_NOTHROW (newdecl);
 
   if (DECL_THIS_STATIC (newdecl) && !DECL_THIS_STATIC (olddecl))
 	{
Index: gcc/doc/invoke.texi
===
--- gcc/doc/invoke.texi	(revision 239624)
+++ gcc/doc/invoke.texi	(working copy)
@@ -256,8 +256,8 @@ Objective-C and Objective-C++ Dialects}.
 -pedantic-errors @gol
 -w  -Wextra  -Wall  -Waddress  -Waggregate-return  @gol
 -Wno-aggressive-loop-optimizations -Warray-bounds -Warray-bounds=@var{n} @gol
--Wno-attributes -Wbool-compare -Wno-builtin-macro-redefined @gol
--Wc90-c99-compat -Wc99-c11-compat @gol
+-Wno-attributes -Wbool-compare -Wbuiltin-function-redefined @gol
+-Wno-builtin-macro-redefined -Wc90-c99-compat -Wc99-c11-compat @gol
 -Wc++-compat -Wc++11-compat -Wc++14-compat -Wcast-align  -Wcast-qual  @gol
 -Wchar-subscripts -Wclobbered  -Wcomment -Wconditionally-supported  @gol
 -Wconversion -Wcoverage-mismatch -Wno-cpp -Wdangling-else -Wdate-time @gol
@@ -5460,6 +5460,13 @@ unrecognized attributes, function attributes appli
 etc.  This does not stop errors for incorrect use of supported
 attributes.
 
+@item -Wbuiltin-function-redefined @r{(C++ and Objective-C++ only)}
+@opindex Wbuiltin-function-redefined
+@opindex Wno-builtin-function-redefined
+Do warn if built-in functions are redefined.  This option is only
+supported for C++ and Objective-C++.  It is implied by @option{-Wall},
+which can be disabled with @option{-Wno-builtin-function-redefined}.
+
 @item -Wno-builtin-macro-redefined
 @opindex Wno-builtin-macro-redefined
 @opindex Wbuiltin-macro-redefined
Index: gcc/testsuite/g++.dg/pr71973.C
===
--- 

Re: [PATCH] tree-optimization/71831 - __builtin_object_size poor results with no optimization

2016-08-20 Thread Florian Weimer
* Martin Sebor:

> As requested in the review of the following patch
>
>   https://gcc.gnu.org/ml/gcc-patches/2016-08/msg01363.html
>
> attached is the small enhancement to compute_builtin_object_size to
> make the function usable even without optimization without the full
> overhead of the tree-object-size pass.

Is its overhead that significant?

Does this mean that with this patch, glibc should remove its
_FORTIFY_SOURCE warning for non-optimized builds when compiling under
GCC >= 7?