Re: Add -lssp_nonshared to LINK_SSP_SPEC

2012-02-07 Thread Jakub Jelinek
On Mon, Jan 23, 2012 at 12:03:27PM +0100, Richard Guenther wrote:
 On Mon, Jan 23, 2012 at 12:23 AM, Gerald Pfeifer ger...@pfeifer.com wrote:
  On Sat, 21 Jan 2012, Tijl Coosemans wrote:
  I've been using this patch now. It's similar to the above url, but
  conditional on TARGET_LIBC_PROVIDES_SSP to support older FreeBSD
  versions.
 
  Gerald volunteered to commit. Gerald, just trunk for now or older
  branches too?
 
  If Richi agries, I'd apply this on trunk and the GCC 4.6 branch,
  since that is the stable release our users employ.
 
 Sure, go ahead.
 
 Richard.
 
  Gerald
 
  PS: We also need to update the copyright date at the top, and I'll
  take care of that when committing.
 
  2011-01-20  Tijl Coosemans  t...@coosemans.org
 
        * gcc/config/freebsd-spec.h [TARGET_LIBC_PROVIDES_SSP] 
  (LINK_SSP_SPEC): Define.

This change unfortunately broke all non-freebsd powerpc* targets.
For some weird reason freebsd-spec.h is included for all powerpc* targets
(to support -mcall-freebsd), which means that e.g. on powerpc64-linux
the above results in -fstack-protector being broken.

So, if this mess is really needed (does anybody actually use -mcall-freebsd
on non-freebsd targets?), IMHO freebsd-spec.h must avoid defining non-FBSD_
prefixed macros, as the following (completely untested) patch.  Don't have
access to FreeBSD to test it there though, can test on powerpc64-linux.

2012-02-07  Jakub Jelinek  ja...@redhat.com

* config/freebsd-spec.h (LINK_EH_SPEC, LINK_SSP_SPEC,
USE_LD_AS_NEEDED): Don't define.
(FBSD_LINK_EH_SPEC, FBSD_LINK_SSP_SPEC, FBSD_USE_LD_AS_NEEDED):
Define these instead.
* config/freebsd.h (LINK_EH_SPEC, LINK_SSP_SPEC, USE_LD_AS_NEEDED):
Redefine to FBSD_* macros if those are defined.

--- gcc/config/freebsd-spec.h.jj2012-01-30 00:10:01.0 +0100
+++ gcc/config/freebsd-spec.h   2012-02-07 09:46:05.031256945 +0100
@@ -135,14 +135,15 @@ is built with the --enable-threads confi
 #endif
 
 #if defined(HAVE_LD_EH_FRAME_HDR)
-#define LINK_EH_SPEC %{!static:--eh-frame-hdr} 
+#define FBSD_LINK_EH_SPEC %{!static:--eh-frame-hdr} 
 #endif
 
 #ifdef TARGET_LIBC_PROVIDES_SSP
-#define LINK_SSP_SPEC 
%{fstack-protector|fstack-protector-all:-lssp_nonshared}
+#define FBSD_LINK_SSP_SPEC \
+  %{fstack-protector|fstack-protector-all:-lssp_nonshared}
 #endif
 
 /* Use --as-needed -lgcc_s for eh support.  */
 #ifdef HAVE_LD_AS_NEEDED
-#define USE_LD_AS_NEEDED 1
+#define FBSD_USE_LD_AS_NEEDED 1
 #endif
--- gcc/config/freebsd.h.jj 2010-11-26 18:39:09.0 +0100
+++ gcc/config/freebsd.h2012-02-07 09:48:50.872294367 +0100
@@ -1,6 +1,6 @@
 /* Base configuration file for all FreeBSD targets.
Copyright (C) 1999, 2000, 2001, 2007, 2008, 2009,
-   2010 Free Software Foundation, Inc.
+   2010, 2011, 2012 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -45,6 +45,21 @@ along with GCC; see the file COPYING3.
 #undef  LIB_SPEC
 #define LIB_SPEC FBSD_LIB_SPEC
 
+#ifdef FBSD_LINK_EH_SPEC
+#undef LINK_EH_SPEC
+#defineLINK_EH_SPEC FBSD_LINK_EH_SPEC
+#endif
+
+#ifdef FBSD_LINK_SSP_SPEC
+#undef LINK_SSP_SPEC
+#defineLINK_SSP_SPEC FBSD_LINK_SSP_SPEC
+#endif
+ 
+#ifdef FBSD_USE_LD_AS_NEEDED
+#undef USE_LD_AS_NEEDED
+#defineUSE_LD_AS_NEEDED FBSD_USE_LD_AS_NEEDED
+#endif
+
 /[  Target stuff  ]***/
 
 /* All FreeBSD Architectures support the ELF object file format.  */

Jakub


Re: [PATCH] Fix expansion of constants with -fsection-anchors (PR middle-end/52074)

2012-02-07 Thread Eric Botcazou
 2012-02-01  Jakub Jelinek  ja...@redhat.com

   PR middle-end/52074
   * expr.c (expand_expr_addr_expr_1): For CONSTANT_CLASS_P or CONST_DECL
   if modifier  EXPAND_SUM call force_operand on the result.

   * gcc.c-torture/compile/pr52074.c: New test.

This looks fine to me.

-- 
Eric Botcazou


[PATCH] Don't look for lto-wrapper, liblto_plugin.so.0 nor collect2 if -E/-S/-c

2012-02-07 Thread Jakub Jelinek
Hi!

In Fedora (but several other distros do the same) we ship cpp
as a separate package, unfortunately the lto plugin support means (IMHO
unnecessarily) that the plugin needs to be included in the cpp package
rather than gcc, because the driver looks for the plugin and complains
if not found even when the driver is cpp (or for gcc -E/-S/-c).
I think we only need it when actually linking, so this patch should save
some unnecessary syscalls on every -E/-S/-c preprocessing/compilation
as well as make /usr/bin/cpp only need cc1 and no other files.
have_c is a variable used in a couple of places earlier.

2012-02-07  Jakub Jelinek  ja...@redhat.com

* gcc.c (main): Don't look for lto-wrapper or lto-wrapper
or LTOPLUGINSONAME if have_c.

--- gcc/gcc.c.jj2012-01-30 00:10:01.0 +0100
+++ gcc/gcc.c   2012-02-07 10:03:44.777138464 +0100
@@ -6447,7 +6447,11 @@ main (int argc, char **argv)
 
   /* Set up to remember the pathname of the lto wrapper. */
 
-  lto_wrapper_file = find_a_file (exec_prefixes, lto-wrapper, X_OK, false);
+  if (have_c)
+lto_wrapper_file = NULL;
+  else
+lto_wrapper_file = find_a_file (exec_prefixes, lto-wrapper,
+   X_OK, false);
   if (lto_wrapper_file)
 {
   lto_wrapper_spec = lto_wrapper_file;
@@ -6821,39 +6825,46 @@ warranty; not even for MERCHANTABILITY o
   if (num_linker_inputs  0  !seen_error ()  print_subprocess_help  2)
 {
   int tmp = execution_count;
+
+  if (! have_c)
+   {
 #if HAVE_LTO_PLUGIN  0
 #if HAVE_LTO_PLUGIN == 2
-  const char *fno_use_linker_plugin = fno-use-linker-plugin;
+ const char *fno_use_linker_plugin = fno-use-linker-plugin;
 #else
-  const char *fuse_linker_plugin = fuse-linker-plugin;
+ const char *fuse_linker_plugin = fuse-linker-plugin;
 #endif
 #endif
 
-  /* We'll use ld if we can't find collect2.  */
-  if (! strcmp (linker_name_spec, collect2))
-   {
- char *s = find_a_file (exec_prefixes, collect2, X_OK, false);
- if (s == NULL)
-   linker_name_spec = ld;
-   }
+ /* We'll use ld if we can't find collect2.  */
+ if (! strcmp (linker_name_spec, collect2))
+   {
+ char *s = find_a_file (exec_prefixes, collect2, X_OK, false);
+ if (s == NULL)
+   linker_name_spec = ld;
+   }
 
 #if HAVE_LTO_PLUGIN  0
 #if HAVE_LTO_PLUGIN == 2
-  if (!switch_matches (fno_use_linker_plugin,
-  fno_use_linker_plugin + strlen 
(fno_use_linker_plugin), 0))
+ if (!switch_matches (fno_use_linker_plugin,
+  fno_use_linker_plugin
+  + strlen (fno_use_linker_plugin), 0))
 #else
-  if (switch_matches (fuse_linker_plugin,
- fuse_linker_plugin + strlen (fuse_linker_plugin), 0))
+ if (switch_matches (fuse_linker_plugin,
+ fuse_linker_plugin
+ + strlen (fuse_linker_plugin), 0))
 #endif
-   {
- linker_plugin_file_spec = find_a_file (exec_prefixes,
-LTOPLUGINSONAME, R_OK,
-false);
- if (!linker_plugin_file_spec)
-   fatal_error (-fuse-linker-plugin, but %s not found, 
LTOPLUGINSONAME);
-   }
+   {
+ linker_plugin_file_spec = find_a_file (exec_prefixes,
+LTOPLUGINSONAME, R_OK,
+false);
+ if (!linker_plugin_file_spec)
+   fatal_error (-fuse-linker-plugin, but %s not found,
+LTOPLUGINSONAME);
+   }
 #endif
-  lto_gcc_spec = argv[0];
+ lto_gcc_spec = argv[0];
+   }
 
   /* Rebuild the COMPILER_PATH and LIBRARY_PATH environment variables
 for collect.  */

Jakub


Re: Gthreads patch to disable static initializer macros

2012-02-07 Thread Jonathan Wakely
On 6 February 2012 06:40, Jakub Jelinek wrote:
 On Sun, Feb 05, 2012 at 08:26:22PM +, Jonathan Wakely wrote:
 This has been testing on darwin, if Rainer tests it successfully on
 Tru64 will the gthr-posix.h change be acceptable?

 Ok with a suitable ChangeLog entry.

Jakub, further to the patch you approved this version unconditionally
defines a weak reference to pthread_cond_init (rather than only doing
it for libobjc) so that it can be used by
__gthread_cond_init_function() if _GTHREAD_USE_COND_INIT_FUNC is
defined.  Testing with _GTHREAD_USE_COND_INIT_FUNC revealed that was
necessary.

gthr-posix.h changes OK as attached, with this ChangeLog?

libgcc/
2012-02-07  Jonathan Wakely  jwakely@gmail.com

PR libstdc++/51906
PR libstdc++/51296
* gthr-posix.h: Allow static initializer macros to be disabled.
(__gthrw_pthread_cond_init): Define weak reference unconditionally.

libstdc++-v3/
2012-02-07  Jonathan Wakely  jwakely@gmail.com

PR libstdc++/51296
* include/std/mutex (__mutex_base::~__mutex_base): Declare noexcept.
* src/c++11/condition_variable.cc (condition_variable): Use macro for
initializer function.

PR libstdc++/51906
* config/os/bsd/darwin/os_defines.h: Disable static initializer for
recursive mutexes.

Tested x86_64-linux with --enable-languages=c,c++,objc,obj-c++, both
with and without the new _GTHREAD_USE_XXX_INIT_FUNC macros defined.

Also tested on i686-linux, powerpc-linux, x86_64-netbsd with default
configuration and just --enable-languages=c,c++
diff --git a/libgcc/gthr-posix.h b/libgcc/gthr-posix.h
index 46054f6..a935e92 100644
--- a/libgcc/gthr-posix.h
+++ b/libgcc/gthr-posix.h
@@ -74,6 +74,20 @@ typedef struct timespec __gthread_time_t;
 #define __GTHREAD_COND_INIT PTHREAD_COND_INITIALIZER
 #define __GTHREAD_TIME_INIT {0,0}
 
+#ifdef _GTHREAD_USE_MUTEX_INIT_FUNC
+# undef __GTHREAD_MUTEX_INIT
+# define __GTHREAD_MUTEX_INIT_FUNCTION __gthread_mutex_init_function
+#endif
+#ifdef _GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC
+# undef __GTHREAD_RECURSIVE_MUTEX_INIT
+# undef __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION
+# define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION 
__gthread_recursive_mutex_init_function
+#endif
+#ifdef _GTHREAD_USE_COND_INIT_FUNC
+# undef __GTHREAD_COND_INIT
+# define __GTHREAD_COND_INIT_FUNCTION __gthread_cond_init_function
+#endif
+
 #if SUPPORTS_WEAK  GTHREAD_USE_WEAK
 # ifndef __gthrw_pragma
 #  define __gthrw_pragma(pragma)
@@ -116,6 +130,7 @@ __gthrw3(pthread_mutex_unlock)
 __gthrw3(pthread_mutex_init)
 __gthrw3(pthread_mutex_destroy)
 
+__gthrw3(pthread_cond_init)
 __gthrw3(pthread_cond_broadcast)
 __gthrw3(pthread_cond_signal)
 __gthrw3(pthread_cond_wait)
@@ -145,6 +160,7 @@ __gthrw(pthread_mutex_unlock)
 __gthrw(pthread_mutex_init)
 __gthrw(pthread_mutex_destroy)
 
+__gthrw(pthread_cond_init)
 __gthrw(pthread_cond_broadcast)
 __gthrw(pthread_cond_signal)
 __gthrw(pthread_cond_wait)
@@ -162,10 +178,8 @@ __gthrw(pthread_mutexattr_destroy)
 #if defined(_LIBOBJC) || defined(_LIBOBJC_WEAK)
 /* Objective-C.  */
 #if defined(__osf__)  defined(_PTHREAD_USE_MANGLED_NAMES_)
-__gthrw3(pthread_cond_init)
 __gthrw3(pthread_exit)
 #else
-__gthrw(pthread_cond_init)
 __gthrw(pthread_exit)
 #endif /* __osf__  _PTHREAD_USE_MANGLED_NAMES_ */
 #ifdef _POSIX_PRIORITY_SCHEDULING
@@ -730,6 +744,15 @@ __gthread_setspecific (__gthread_key_t __key, const void 
*__ptr)
   return __gthrw_(pthread_setspecific) (__key, __ptr);
 }
 
+#ifdef _GTHREAD_USE_MUTEX_INIT_FUNC
+static inline void
+__gthread_mutex_init_function (__gthread_mutex_t *__mutex)
+{
+  if (__gthread_active_p ())
+__gthrw_(pthread_mutex_init) (__mutex, NULL);
+}
+#endif
+
 static inline int
 __gthread_mutex_destroy (__gthread_mutex_t *__mutex)
 {
@@ -778,7 +801,8 @@ __gthread_mutex_unlock (__gthread_mutex_t *__mutex)
 return 0;
 }
 
-#ifndef PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
+#if !defined( PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) \
+  || defined(_GTHREAD_USE_RECURSIVE_MUTEX_INIT_FUNC)
 static inline int
 __gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *__mutex)
 {
@@ -828,6 +852,15 @@ __gthread_recursive_mutex_unlock 
(__gthread_recursive_mutex_t *__mutex)
   return __gthread_mutex_unlock (__mutex);
 }
 
+#ifdef _GTHREAD_USE_COND_INIT_FUNC
+static inline void
+__gthread_cond_init_function (__gthread_cond_t *__cond)
+{
+  if (__gthread_active_p ())
+__gthrw_(pthread_cond_init) (__cond, NULL);
+}
+#endif
+
 static inline int
 __gthread_cond_broadcast (__gthread_cond_t *__cond)
 {
diff --git a/libstdc++-v3/config/os/bsd/darwin/os_defines.h 
b/libstdc++-v3/config/os/bsd/darwin/os_defines.h
index ccefeaf..421478d 100644
--- a/libstdc++-v3/config/os/bsd/darwin/os_defines.h
+++ b/libstdc++-v3/config/os/bsd/darwin/os_defines.h
@@ -39,4 +39,7 @@
 // -flat_namespace to work around the way that it doesn't.
 #define _GLIBCXX_WEAK_DEFINITION __attribute__ ((weak))
 
+// Static initializer macro is buggy in darwin, 

Re: Gthreads patch to disable static initializer macros

2012-02-07 Thread Jakub Jelinek
On Tue, Feb 07, 2012 at 09:11:38AM +, Jonathan Wakely wrote:
 gthr-posix.h changes OK as attached, with this ChangeLog?

Okay.  Thanks.

 libgcc/
 2012-02-07  Jonathan Wakely  jwakely@gmail.com
 
 PR libstdc++/51906
 PR libstdc++/51296
 * gthr-posix.h: Allow static initializer macros to be disabled.
 (__gthrw_pthread_cond_init): Define weak reference unconditionally.
 
 libstdc++-v3/
 2012-02-07  Jonathan Wakely  jwakely@gmail.com
 
 PR libstdc++/51296
 * include/std/mutex (__mutex_base::~__mutex_base): Declare noexcept.
 * src/c++11/condition_variable.cc (condition_variable): Use macro for
 initializer function.
 
 PR libstdc++/51906
 * config/os/bsd/darwin/os_defines.h: Disable static initializer for
 recursive mutexes.
 
 Tested x86_64-linux with --enable-languages=c,c++,objc,obj-c++, both
 with and without the new _GTHREAD_USE_XXX_INIT_FUNC macros defined.
 
 Also tested on i686-linux, powerpc-linux, x86_64-netbsd with default
 configuration and just --enable-languages=c,c++

Jakub


Re: Add -lssp_nonshared to LINK_SSP_SPEC

2012-02-07 Thread Richard Guenther
On Tue, Feb 7, 2012 at 9:54 AM, Jakub Jelinek ja...@redhat.com wrote:
 On Mon, Jan 23, 2012 at 12:03:27PM +0100, Richard Guenther wrote:
 On Mon, Jan 23, 2012 at 12:23 AM, Gerald Pfeifer ger...@pfeifer.com wrote:
  On Sat, 21 Jan 2012, Tijl Coosemans wrote:
  I've been using this patch now. It's similar to the above url, but
  conditional on TARGET_LIBC_PROVIDES_SSP to support older FreeBSD
  versions.
 
  Gerald volunteered to commit. Gerald, just trunk for now or older
  branches too?
 
  If Richi agries, I'd apply this on trunk and the GCC 4.6 branch,
  since that is the stable release our users employ.

 Sure, go ahead.

 Richard.

  Gerald
 
  PS: We also need to update the copyright date at the top, and I'll
  take care of that when committing.
 
  2011-01-20  Tijl Coosemans  t...@coosemans.org
 
        * gcc/config/freebsd-spec.h [TARGET_LIBC_PROVIDES_SSP] 
  (LINK_SSP_SPEC): Define.

 This change unfortunately broke all non-freebsd powerpc* targets.
 For some weird reason freebsd-spec.h is included for all powerpc* targets
 (to support -mcall-freebsd), which means that e.g. on powerpc64-linux
 the above results in -fstack-protector being broken.

 So, if this mess is really needed (does anybody actually use -mcall-freebsd
 on non-freebsd targets?), IMHO freebsd-spec.h must avoid defining non-FBSD_
 prefixed macros, as the following (completely untested) patch.  Don't have
 access to FreeBSD to test it there though, can test on powerpc64-linux.

Ugh.

I propose to revert the original patch for now.

Richard.

 2012-02-07  Jakub Jelinek  ja...@redhat.com

        * config/freebsd-spec.h (LINK_EH_SPEC, LINK_SSP_SPEC,
        USE_LD_AS_NEEDED): Don't define.
        (FBSD_LINK_EH_SPEC, FBSD_LINK_SSP_SPEC, FBSD_USE_LD_AS_NEEDED):
        Define these instead.
        * config/freebsd.h (LINK_EH_SPEC, LINK_SSP_SPEC, USE_LD_AS_NEEDED):
        Redefine to FBSD_* macros if those are defined.

 --- gcc/config/freebsd-spec.h.jj        2012-01-30 00:10:01.0 +0100
 +++ gcc/config/freebsd-spec.h   2012-02-07 09:46:05.031256945 +0100
 @@ -135,14 +135,15 @@ is built with the --enable-threads confi
  #endif

  #if defined(HAVE_LD_EH_FRAME_HDR)
 -#define LINK_EH_SPEC %{!static:--eh-frame-hdr} 
 +#define FBSD_LINK_EH_SPEC %{!static:--eh-frame-hdr} 
  #endif

  #ifdef TARGET_LIBC_PROVIDES_SSP
 -#define LINK_SSP_SPEC 
 %{fstack-protector|fstack-protector-all:-lssp_nonshared}
 +#define FBSD_LINK_SSP_SPEC \
 +  %{fstack-protector|fstack-protector-all:-lssp_nonshared}
  #endif

  /* Use --as-needed -lgcc_s for eh support.  */
  #ifdef HAVE_LD_AS_NEEDED
 -#define USE_LD_AS_NEEDED 1
 +#define FBSD_USE_LD_AS_NEEDED 1
  #endif
 --- gcc/config/freebsd.h.jj     2010-11-26 18:39:09.0 +0100
 +++ gcc/config/freebsd.h        2012-02-07 09:48:50.872294367 +0100
 @@ -1,6 +1,6 @@
  /* Base configuration file for all FreeBSD targets.
    Copyright (C) 1999, 2000, 2001, 2007, 2008, 2009,
 -   2010 Free Software Foundation, Inc.
 +   2010, 2011, 2012 Free Software Foundation, Inc.

  This file is part of GCC.

 @@ -45,6 +45,21 @@ along with GCC; see the file COPYING3.
  #undef  LIB_SPEC
  #define LIB_SPEC FBSD_LIB_SPEC

 +#ifdef FBSD_LINK_EH_SPEC
 +#undef LINK_EH_SPEC
 +#define        LINK_EH_SPEC FBSD_LINK_EH_SPEC
 +#endif
 +
 +#ifdef FBSD_LINK_SSP_SPEC
 +#undef LINK_SSP_SPEC
 +#define        LINK_SSP_SPEC FBSD_LINK_SSP_SPEC
 +#endif
 +
 +#ifdef FBSD_USE_LD_AS_NEEDED
 +#undef USE_LD_AS_NEEDED
 +#define        USE_LD_AS_NEEDED FBSD_USE_LD_AS_NEEDED
 +#endif
 +
  /[  Target stuff  
 ]***/

  /* All FreeBSD Architectures support the ELF object file format.  */

        Jakub


[patch] Fix PR middle-end/51994

2012-02-07 Thread Eric Botcazou
Hi,

this is a regression present on mainline and 4.6 branch, apparently a fallout 
of the MEM_REF introduction.  get_inner_reference can be called on MEM_REFs 
whose base has been shifted to the left

  char *output = buf;

  output += a;
  output -= 1;

  output[0];

and, since the constant negative offset is merged into the MEM_REF, it will be 
returned as the BITPOS by get_inner_reference, which wreaks havoc later in the 
bitfield manipulation routines which expect non-negative bit positions.

Clearly nothing says that the returned BITPOS should be non-negative but, on 
the other hand, it de facto was in the pre-MEM_REF world for valid programs 
(except maybe in a very specific case in Ada).  The attached patch attempts to 
patch things up to bring us back to the previous de facto situation.

Bootstrapped/regtested on x86_64-suse-linux, OK for mainline and 4.6 branch?


2012-02-07  Eric Botcazou  ebotca...@adacore.com

PR middle-end/51994
* expr.c (get_inner_reference): If there is an offset, add a negative
bit position to it (if any).


2012-02-07  Eric Botcazou  ebotca...@adacore.com

* gcc.c-torture/execute/20120207-1.c: New test.


-- 
Eric Botcazou
Index: expr.c
===
--- expr.c	(revision 183864)
+++ expr.c	(working copy)
@@ -6716,6 +6716,24 @@ get_inner_reference (tree exp, HOST_WIDE
   /* Otherwise, split it up.  */
   if (offset)
 {
+  /* Avoid returning a negative bitpos as this may wreak havoc later.  */
+  if (double_int_negative_p (bit_offset))
+{
+	  double_int mask
+	= double_int_mask (BITS_PER_UNIT == 8
+			   ? 3 : exact_log2 (BITS_PER_UNIT));
+	  double_int tem = double_int_and_not (bit_offset, mask);
+	  /* TEM is the bitpos rounded to BITS_PER_UNIT towards -Inf.
+	 Subtract it to BIT_OFFSET and add it (scaled) to OFFSET.  */
+	  bit_offset = double_int_sub (bit_offset, tem);
+	  tem = double_int_rshift (tem,
+   BITS_PER_UNIT == 8
+   ? 3 : exact_log2 (BITS_PER_UNIT),
+   HOST_BITS_PER_DOUBLE_INT, true);
+	  offset = size_binop (PLUS_EXPR, offset,
+			   double_int_to_tree (sizetype, tem));
+	}
+
   *pbitpos = double_int_to_shwi (bit_offset);
   *poffset = offset;
 }
/* PR middle-end/51994 */
/* Testcase by Uros Bizjak ubiz...@gmail.com */

extern char *strcpy (char *, const char *);
extern void abort (void);

char __attribute__((noinline))
test (int a)
{
  char buf[16];
  char *output = buf;

  strcpy (buf[0], 0123456789);

  output += a;
  output -= 1;

  return output[0];
}

int main ()
{
  if (test (2) != '1')
abort ();

  return 0;
}


Re: [PATCH] Don't look for lto-wrapper, liblto_plugin.so.0 nor collect2 if -E/-S/-c

2012-02-07 Thread Richard Guenther
On Tue, Feb 7, 2012 at 10:11 AM, Jakub Jelinek ja...@redhat.com wrote:
 Hi!

 In Fedora (but several other distros do the same) we ship cpp
 as a separate package, unfortunately the lto plugin support means (IMHO
 unnecessarily) that the plugin needs to be included in the cpp package
 rather than gcc, because the driver looks for the plugin and complains
 if not found even when the driver is cpp (or for gcc -E/-S/-c).
 I think we only need it when actually linking, so this patch should save
 some unnecessary syscalls on every -E/-S/-c preprocessing/compilation
 as well as make /usr/bin/cpp only need cc1 and no other files.
 have_c is a variable used in a couple of places earlier.

Ok.

Thanks,
Richard.

 2012-02-07  Jakub Jelinek  ja...@redhat.com

        * gcc.c (main): Don't look for lto-wrapper or lto-wrapper
        or LTOPLUGINSONAME if have_c.

 --- gcc/gcc.c.jj        2012-01-30 00:10:01.0 +0100
 +++ gcc/gcc.c   2012-02-07 10:03:44.777138464 +0100
 @@ -6447,7 +6447,11 @@ main (int argc, char **argv)

   /* Set up to remember the pathname of the lto wrapper. */

 -  lto_wrapper_file = find_a_file (exec_prefixes, lto-wrapper, X_OK, 
 false);
 +  if (have_c)
 +    lto_wrapper_file = NULL;
 +  else
 +    lto_wrapper_file = find_a_file (exec_prefixes, lto-wrapper,
 +                                   X_OK, false);
   if (lto_wrapper_file)
     {
       lto_wrapper_spec = lto_wrapper_file;
 @@ -6821,39 +6825,46 @@ warranty; not even for MERCHANTABILITY o
   if (num_linker_inputs  0  !seen_error ()  print_subprocess_help  2)
     {
       int tmp = execution_count;
 +
 +      if (! have_c)
 +       {
  #if HAVE_LTO_PLUGIN  0
  #if HAVE_LTO_PLUGIN == 2
 -      const char *fno_use_linker_plugin = fno-use-linker-plugin;
 +         const char *fno_use_linker_plugin = fno-use-linker-plugin;
  #else
 -      const char *fuse_linker_plugin = fuse-linker-plugin;
 +         const char *fuse_linker_plugin = fuse-linker-plugin;
  #endif
  #endif

 -      /* We'll use ld if we can't find collect2.  */
 -      if (! strcmp (linker_name_spec, collect2))
 -       {
 -         char *s = find_a_file (exec_prefixes, collect2, X_OK, false);
 -         if (s == NULL)
 -           linker_name_spec = ld;
 -       }
 +         /* We'll use ld if we can't find collect2.  */
 +         if (! strcmp (linker_name_spec, collect2))
 +           {
 +             char *s = find_a_file (exec_prefixes, collect2, X_OK, false);
 +             if (s == NULL)
 +               linker_name_spec = ld;
 +           }

  #if HAVE_LTO_PLUGIN  0
  #if HAVE_LTO_PLUGIN == 2
 -      if (!switch_matches (fno_use_linker_plugin,
 -                          fno_use_linker_plugin + strlen 
 (fno_use_linker_plugin), 0))
 +         if (!switch_matches (fno_use_linker_plugin,
 +                              fno_use_linker_plugin
 +                              + strlen (fno_use_linker_plugin), 0))
  #else
 -      if (switch_matches (fuse_linker_plugin,
 -                         fuse_linker_plugin + strlen (fuse_linker_plugin), 
 0))
 +         if (switch_matches (fuse_linker_plugin,
 +                             fuse_linker_plugin
 +                             + strlen (fuse_linker_plugin), 0))
  #endif
 -       {
 -         linker_plugin_file_spec = find_a_file (exec_prefixes,
 -                                                LTOPLUGINSONAME, R_OK,
 -                                                false);
 -         if (!linker_plugin_file_spec)
 -           fatal_error (-fuse-linker-plugin, but %s not found, 
 LTOPLUGINSONAME);
 -       }
 +           {
 +             linker_plugin_file_spec = find_a_file (exec_prefixes,
 +                                                    LTOPLUGINSONAME, R_OK,
 +                                                    false);
 +             if (!linker_plugin_file_spec)
 +               fatal_error (-fuse-linker-plugin, but %s not found,
 +                            LTOPLUGINSONAME);
 +           }
  #endif
 -      lto_gcc_spec = argv[0];
 +         lto_gcc_spec = argv[0];
 +       }

       /* Rebuild the COMPILER_PATH and LIBRARY_PATH environment variables
         for collect.  */

        Jakub


Re: [PATCH 4.8, i386]: Enable post-reload compare optimization pass (PR28685)

2012-02-07 Thread Uros Bizjak
On Mon, Feb 6, 2012 at 10:30 PM, Uros Bizjak ubiz...@gmail.com wrote:

 Hmm.  Well, the only thing that's going to work for x86 is the double-compare
 elimination portion.

 If we want to use this pass for x86, then for 4.8 we should also fix the
 discrepancy between the compare-elim canonical

  [(operate)
   (set-cc)]

 and the combine canonical

  [(set-cc)
   (operate)]

 (Because of the simplicity of the substitution in compare-elim, I prefer
 the former as the canonical canonical.)

 You are probably referring to following testcase:

 --cut here--
 int test (int a, int b)
 {
  int lt = a + b  0;
  int eq = a + b == 0;
  if (lt)
    return 1;
  return eq;
 }
 --cut here--

 where combine creates:

 Trying 8 - 9:
 Successfully matched this instruction:
 (parallel [
        (set (reg:CCZ 17 flags)
            (compare:CCZ (plus:SI (reg/v:SI 63 [ a ])
                    (reg/v:SI 64 [ b ]))
                (const_int 0 [0])))
        (set (reg:SI 60 [ D.1710 ])
            (plus:SI (reg/v:SI 63 [ a ])
                (reg/v:SI 64 [ b ])))
    ])

Attached patch teaches combine to swap operands of a double set
pattern and retries recognition. Also added are minimum
target-dependant changes to handle the testcase above.

Unfortunately, compare elimination was not able to remove redundant
compare, although the testcase is carefully crafted to require only
sign flag to be valid. Following enters compare-elim pass:

(insn 9 8 10 2 (parallel [
(set (reg:SI 5 di [orig:60 D.1710 ] [60])
(plus:SI (reg/v:SI 5 di [orig:63 a ] [63])
(reg/v:SI 4 si [orig:64 b ] [64])))
(set (reg:CCZ 17 flags)
(compare:CCZ (plus:SI (reg/v:SI 5 di [orig:63 a ] [63])
(reg/v:SI 4 si [orig:64 b ] [64]))
(const_int 0 [0])))
]) cmp.c:4 261 {*addsi_2}
 (nil))

(note 10 9 33 2 NOTE_INSN_DELETED)

(insn 33 10 34 2 (set (reg:QI 1 dx [65])
(eq:QI (reg:CCZ 17 flags)
(const_int 0 [0]))) cmp.c:4 595 {*setcc_qi}
 (nil))

(insn 34 33 30 2 (set (reg:SI 1 dx [65])
(zero_extend:SI (reg:QI 1 dx [65]))) cmp.c:4 123
{*zero_extendqisi2_movzbl}
 (nil))

(insn 30 34 29 2 (set (reg/v:SI 0 ax [orig:59 eq ] [59])
(const_int 1 [0x1])) cmp.c:6 64 {*movsi_internal}
 (expr_list:REG_EQUAL (const_int 1 [0x1])
(nil)))

(insn 29 30 31 2 (set (reg:CCGOC 17 flags)
(compare:CCGOC (reg:SI 5 di [orig:60 D.1710 ] [60])
(const_int 0 [0]))) cmp.c:6 2 {*cmpsi_ccno_1}
 (nil))

(insn 31 29 25 2 (set (reg/v:SI 0 ax [orig:59 eq ] [59])
(if_then_else:SI (ge (reg:CCGOC 17 flags)
(const_int 0 [0]))
(reg:SI 1 dx [65])
(reg/v:SI 0 ax [orig:59 eq ] [59]))) cmp.c:6 903 {*movsicc_noc}
 (nil))

The resulting code still includes redundant test that sets sign flag:

test:
addl%esi, %edi
movl$1, %eax
sete%dl
testl   %edi, %edi
movzbl  %dl, %edx
cmovns  %edx, %eax
ret

(BTW: I think that the change to combine.c would be nice to have, to
find more other combine opportunities. I will propose the patch
separately.)

Uros.
Index: combine.c
===
--- combine.c   (revision 183953)
+++ combine.c   (working copy)
@@ -10687,6 +10687,30 @@ recog_for_combine (rtx *pnewpat, rtx insn, rtx *pn
   print_rtl_single (dump_file, pat);
 }
 
+  /* If PAT is a PARALLEL with two SETs, swap the SETs and try again.  */
+  if (insn_code_number  0
+   GET_CODE (pat) == PARALLEL
+   XVECLEN (pat, 0) == 2
+   GET_CODE (XVECEXP (pat, 0, 0)) == SET
+   GET_CODE (XVECEXP (pat, 0, 1)) == SET)
+{
+  rtx set0 = XVECEXP (pat, 0, 0);
+  rtx set1 = XVECEXP (pat, 0, 1);
+
+  SUBST (XVECEXP (pat, 0, 0), set1);
+  SUBST (XVECEXP (pat, 0, 1), set0);
+
+  insn_code_number = recog (pat, insn, num_clobbers_to_add);
+  if (dump_file  (dump_flags  TDF_DETAILS))
+   {
+ if (insn_code_number  0)
+   fputs (Failed to match this instruction:\n, dump_file);
+ else
+   fputs (Successfully matched this instruction:\n, dump_file);
+ print_rtl_single (dump_file, pat);
+   }
+}
+
   /* If it isn't, there is the possibility that we previously had an insn
  that clobbered some register as a side effect, but the combined
  insn doesn't need to do that.  So try once more without the clobbers
Index: config/i386/i386.md
===
--- config/i386/i386.md (revision 183953)
+++ config/i386/i386.md (working copy)
@@ -5808,14 +5808,14 @@
(zero_extend:DI (plus:SI (match_dup 1) (match_dup 2])
 
 (define_insn *addmode_2
-  [(set (reg FLAGS_REG)
+  [(set (match_operand:SWI 0 nonimmediate_operand =r,rm)
+   (plus:SWI
+ (match_operand:SWI 1 nonimmediate_operand %0,0)
+ 

Re: [patch] Fix PR middle-end/51994

2012-02-07 Thread Richard Guenther
On Tue, Feb 7, 2012 at 10:50 AM, Eric Botcazou ebotca...@adacore.com wrote:
 Hi,

 this is a regression present on mainline and 4.6 branch, apparently a fallout
 of the MEM_REF introduction.  get_inner_reference can be called on MEM_REFs
 whose base has been shifted to the left

  char *output = buf;

  output += a;
  output -= 1;

  output[0];

 and, since the constant negative offset is merged into the MEM_REF, it will be
 returned as the BITPOS by get_inner_reference, which wreaks havoc later in the
 bitfield manipulation routines which expect non-negative bit positions.

 Clearly nothing says that the returned BITPOS should be non-negative but, on
 the other hand, it de facto was in the pre-MEM_REF world for valid programs
 (except maybe in a very specific case in Ada).  The attached patch attempts to
 patch things up to bring us back to the previous de facto situation.

 Bootstrapped/regtested on x86_64-suse-linux, OK for mainline and 4.6 branch?

Ok.

Note that with your patch we can still get negative bitpos for invalid code
like

char *output = buf;
output[-1];

but I suppose we don't need to worry about this case too much (if we do
we'd need to adjust the TREE_CODE (offset) == INTEGER_CST case
as well).

Thanks,
Richard.


 2012-02-07  Eric Botcazou  ebotca...@adacore.com

        PR middle-end/51994
        * expr.c (get_inner_reference): If there is an offset, add a negative
        bit position to it (if any).


 2012-02-07  Eric Botcazou  ebotca...@adacore.com

        * gcc.c-torture/execute/20120207-1.c: New test.


 --
 Eric Botcazou


Re: [PATCH 4.8, i386]: Enable post-reload compare optimization pass (PR28685)

2012-02-07 Thread Richard Guenther
On Tue, Feb 7, 2012 at 11:00 AM, Uros Bizjak ubiz...@gmail.com wrote:
 On Mon, Feb 6, 2012 at 10:30 PM, Uros Bizjak ubiz...@gmail.com wrote:

 Hmm.  Well, the only thing that's going to work for x86 is the 
 double-compare
 elimination portion.

 If we want to use this pass for x86, then for 4.8 we should also fix the
 discrepancy between the compare-elim canonical

  [(operate)
   (set-cc)]

 and the combine canonical

  [(set-cc)
   (operate)]

 (Because of the simplicity of the substitution in compare-elim, I prefer
 the former as the canonical canonical.)

 You are probably referring to following testcase:

 --cut here--
 int test (int a, int b)
 {
  int lt = a + b  0;
  int eq = a + b == 0;
  if (lt)
    return 1;
  return eq;
 }
 --cut here--

 where combine creates:

 Trying 8 - 9:
 Successfully matched this instruction:
 (parallel [
        (set (reg:CCZ 17 flags)
            (compare:CCZ (plus:SI (reg/v:SI 63 [ a ])
                    (reg/v:SI 64 [ b ]))
                (const_int 0 [0])))
        (set (reg:SI 60 [ D.1710 ])
            (plus:SI (reg/v:SI 63 [ a ])
                (reg/v:SI 64 [ b ])))
    ])

 Attached patch teaches combine to swap operands of a double set
 pattern and retries recognition. Also added are minimum
 target-dependant changes to handle the testcase above.

 Unfortunately, compare elimination was not able to remove redundant
 compare, although the testcase is carefully crafted to require only
 sign flag to be valid. Following enters compare-elim pass:

 (insn 9 8 10 2 (parallel [
            (set (reg:SI 5 di [orig:60 D.1710 ] [60])
                (plus:SI (reg/v:SI 5 di [orig:63 a ] [63])
                    (reg/v:SI 4 si [orig:64 b ] [64])))
            (set (reg:CCZ 17 flags)
                (compare:CCZ (plus:SI (reg/v:SI 5 di [orig:63 a ] [63])
                        (reg/v:SI 4 si [orig:64 b ] [64]))
                    (const_int 0 [0])))
        ]) cmp.c:4 261 {*addsi_2}
     (nil))

 (note 10 9 33 2 NOTE_INSN_DELETED)

 (insn 33 10 34 2 (set (reg:QI 1 dx [65])
        (eq:QI (reg:CCZ 17 flags)
            (const_int 0 [0]))) cmp.c:4 595 {*setcc_qi}
     (nil))

 (insn 34 33 30 2 (set (reg:SI 1 dx [65])
        (zero_extend:SI (reg:QI 1 dx [65]))) cmp.c:4 123
 {*zero_extendqisi2_movzbl}
     (nil))

 (insn 30 34 29 2 (set (reg/v:SI 0 ax [orig:59 eq ] [59])
        (const_int 1 [0x1])) cmp.c:6 64 {*movsi_internal}
     (expr_list:REG_EQUAL (const_int 1 [0x1])
        (nil)))

 (insn 29 30 31 2 (set (reg:CCGOC 17 flags)
        (compare:CCGOC (reg:SI 5 di [orig:60 D.1710 ] [60])
            (const_int 0 [0]))) cmp.c:6 2 {*cmpsi_ccno_1}
     (nil))

 (insn 31 29 25 2 (set (reg/v:SI 0 ax [orig:59 eq ] [59])
        (if_then_else:SI (ge (reg:CCGOC 17 flags)
                (const_int 0 [0]))
            (reg:SI 1 dx [65])
            (reg/v:SI 0 ax [orig:59 eq ] [59]))) cmp.c:6 903 {*movsicc_noc}
     (nil))

 The resulting code still includes redundant test that sets sign flag:

 test:
        addl    %esi, %edi
        movl    $1, %eax
        sete    %dl
     testl   %edi, %edi
        movzbl  %dl, %edx
        cmovns  %edx, %eax
        ret

 (BTW: I think that the change to combine.c would be nice to have, to
 find more other combine opportunities. I will propose the patch
 separately.)

Shouldn't there be a canonical order for parallels throughout the whole
compiler?  Maybe just enforced by gen_rtx_PARALLEL / RTL checking?
At least as far as I understand execution order of insns inside a PARALLEL
is undefined.

Richard.

 Uros.


Re: [PATCH 4.8, i386]: Enable post-reload compare optimization pass (PR28685)

2012-02-07 Thread Uros Bizjak
On Tue, Feb 7, 2012 at 11:04 AM, Richard Guenther
richard.guent...@gmail.com wrote:

 (BTW: I think that the change to combine.c would be nice to have, to
 find more other combine opportunities. I will propose the patch
 separately.)

 Shouldn't there be a canonical order for parallels throughout the whole
 compiler?  Maybe just enforced by gen_rtx_PARALLEL / RTL checking?
 At least as far as I understand execution order of insns inside a PARALLEL
 is undefined.

All operations inside parallel happen at the same time. And there is
no canonical order enforced, as sadly shown by the discrepancy between
combine and compare elimination passes.

Uros.


Re: [PATCH 4.8, i386]: Enable post-reload compare optimization pass (PR28685)

2012-02-07 Thread Richard Guenther
On Tue, Feb 7, 2012 at 11:46 AM, Uros Bizjak ubiz...@gmail.com wrote:
 On Tue, Feb 7, 2012 at 11:04 AM, Richard Guenther
 richard.guent...@gmail.com wrote:

 (BTW: I think that the change to combine.c would be nice to have, to
 find more other combine opportunities. I will propose the patch
 separately.)

 Shouldn't there be a canonical order for parallels throughout the whole
 compiler?  Maybe just enforced by gen_rtx_PARALLEL / RTL checking?
 At least as far as I understand execution order of insns inside a PARALLEL
 is undefined.

 All operations inside parallel happen at the same time. And there is
 no canonical order enforced, as sadly shown by the discrepancy between
 combine and compare elimination passes.

Sure - all what I say is that the fix should be to enforce such canonical
order instead of dealing with both.

Richard.

 Uros.


Re: Gthreads patch to disable static initializer macros

2012-02-07 Thread Jonathan Wakely
On 6 February 2012 19:24, Mike Stump wrote:
 On Feb 5, 2012, at 12:26 PM, Jonathan Wakely wrote:
 PRs libstdc++/51296 and libstdc++/51906 are both caused by problems
 with the Pthreads static initializer macros such as
 PTHREAD_MUTEX_INITIALIZER.

 On Mac OS X 10.7 the PTHREAD_RECURSIVE_MUTEX_INITIALIZER is buggy.

 Thanks for all you work on this.

Well I broke it so I had to fix it ;)

I'm pleased to say we should now have an almost complete C++11 thread
implementation for most POSIX platforms, with hundreds of existing
libstdc++ tests moving from UNSUPPORTED to PASS on some secondary
platforms (aix and darwin, maybe hpux too.)


Re: [PATCH 4.8, i386]: Enable post-reload compare optimization pass (PR28685)

2012-02-07 Thread Uros Bizjak
On Tue, Feb 7, 2012 at 11:48 AM, Richard Guenther
richard.guent...@gmail.com wrote:

 (BTW: I think that the change to combine.c would be nice to have, to
 find more other combine opportunities. I will propose the patch
 separately.)

 Shouldn't there be a canonical order for parallels throughout the whole
 compiler?  Maybe just enforced by gen_rtx_PARALLEL / RTL checking?
 At least as far as I understand execution order of insns inside a PARALLEL
 is undefined.

 All operations inside parallel happen at the same time. And there is
 no canonical order enforced, as sadly shown by the discrepancy between
 combine and compare elimination passes.

 Sure - all what I say is that the fix should be to enforce such canonical
 order instead of dealing with both.

rth proposed to adopt new scheme to change combine.c. However, I don't
think this is a good idea, since it would mean fixing many existing
in-tree and out-of-tree targets. OTOH, I thought that swapping
operands in combine would also benefit other parts of the compiler,
namely load/store multiple patterns, maybe swap insns, and similar.

It was also fairly easy to teach combine to handle both approaches. ;)

Uros.


Re: Add -lssp_nonshared to LINK_SSP_SPEC

2012-02-07 Thread Tijl Coosemans
On Tuesday 07 February 2012 09:54:43 Jakub Jelinek wrote:
 On Mon, Jan 23, 2012 at 12:03:27PM +0100, Richard Guenther wrote:
 On Mon, Jan 23, 2012 at 12:23 AM, Gerald Pfeifer ger...@pfeifer.com wrote:
 On Sat, 21 Jan 2012, Tijl Coosemans wrote:
 I've been using this patch now. It's similar to the above url, but
 conditional on TARGET_LIBC_PROVIDES_SSP to support older FreeBSD
 versions.

 Gerald volunteered to commit. Gerald, just trunk for now or older
 branches too?

 If Richi agries, I'd apply this on trunk and the GCC 4.6 branch,
 since that is the stable release our users employ.
 
 Sure, go ahead.
 
 Richard.
 
 Gerald

 PS: We also need to update the copyright date at the top, and I'll
 take care of that when committing.

 2011-01-20  Tijl Coosemans  t...@coosemans.org

   * gcc/config/freebsd-spec.h [TARGET_LIBC_PROVIDES_SSP] 
 (LINK_SSP_SPEC): Define.
 
 This change unfortunately broke all non-freebsd powerpc* targets.
 For some weird reason freebsd-spec.h is included for all powerpc* targets
 (to support -mcall-freebsd), which means that e.g. on powerpc64-linux
 the above results in -fstack-protector being broken.
 
 So, if this mess is really needed (does anybody actually use -mcall-freebsd
 on non-freebsd targets?), IMHO freebsd-spec.h must avoid defining non-FBSD_
 prefixed macros, as the following (completely untested) patch.  Don't have
 access to FreeBSD to test it there though, can test on powerpc64-linux.

Everything still works on FreeBSD.

 --- gcc/config/freebsd.h.jj   2010-11-26 18:39:09.0 +0100
 +++ gcc/config/freebsd.h  2012-02-07 09:48:50.872294367 +0100
 @@ -45,6 +45,21 @@ along with GCC; see the file COPYING3.
  #undef  LIB_SPEC
  #define LIB_SPEC FBSD_LIB_SPEC
  
 +#ifdef   FBSD_LINK_EH_SPEC
 +#undef   LINK_EH_SPEC
 +#define  LINK_EH_SPEC FBSD_LINK_EH_SPEC
 +#endif
 +
 +#ifdef   FBSD_LINK_SSP_SPEC
 +#undef   LINK_SSP_SPEC
 +#define  LINK_SSP_SPEC FBSD_LINK_SSP_SPEC
 +#endif
 + 

FYI, there are extra spaces on this line.


Re: Add -lssp_nonshared to LINK_SSP_SPEC

2012-02-07 Thread Jakub Jelinek
On Tue, Feb 07, 2012 at 12:17:59PM +0100, Tijl Coosemans wrote:
 Everything still works on FreeBSD.

After discussion about this on IRC Richard expressed his preference
for the following variant instead:

2012-02-07  Jakub Jelinek  ja...@redhat.com

* config/freebsd-spec.h: Add comment about what macros can be defined
in this header.
(LINK_EH_SPEC, LINK_SSP_SPEC, USE_LD_AS_NEEDED): Don't define here.
* config/freebsd.h (LINK_EH_SPEC, LINK_SSP_SPEC, USE_LD_AS_NEEDED): But
here instead.

--- gcc/config/freebsd-spec.h.jj2012-01-30 00:10:01.0 +0100
+++ gcc/config/freebsd-spec.h   2012-02-07 12:44:47.0 +0100
@@ -134,15 +134,6 @@ is built with the --enable-threads confi
 #define FBSD_DYNAMIC_LINKER /libexec/ld-elf.so.1
 #endif
 
-#if defined(HAVE_LD_EH_FRAME_HDR)
-#define LINK_EH_SPEC %{!static:--eh-frame-hdr} 
-#endif
-
-#ifdef TARGET_LIBC_PROVIDES_SSP
-#define LINK_SSP_SPEC 
%{fstack-protector|fstack-protector-all:-lssp_nonshared}
-#endif
-
-/* Use --as-needed -lgcc_s for eh support.  */
-#ifdef HAVE_LD_AS_NEEDED
-#define USE_LD_AS_NEEDED 1
-#endif
+/* NOTE: The freebsd-spec.h header is included also for various
+   non-FreeBSD powerpc targets, thus it should never define macros
+   other than FBSD_* prefixed ones, or USING_CONFIG_FREEBSD_SPEC.  */
--- gcc/config/freebsd.h.jj 2010-11-26 18:39:09.0 +0100
+++ gcc/config/freebsd.h2012-02-07 12:45:34.497798123 +0100
@@ -1,6 +1,6 @@
 /* Base configuration file for all FreeBSD targets.
Copyright (C) 1999, 2000, 2001, 2007, 2008, 2009,
-   2010 Free Software Foundation, Inc.
+   2010, 2011, 2012 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -45,6 +45,19 @@ along with GCC; see the file COPYING3.
 #undef  LIB_SPEC
 #define LIB_SPEC FBSD_LIB_SPEC
 
+#if defined(HAVE_LD_EH_FRAME_HDR)
+#define LINK_EH_SPEC %{!static:--eh-frame-hdr} 
+#endif
+
+#ifdef TARGET_LIBC_PROVIDES_SSP
+#define LINK_SSP_SPEC 
%{fstack-protector|fstack-protector-all:-lssp_nonshared}
+#endif
+
+/* Use --as-needed -lgcc_s for eh support.  */
+#ifdef HAVE_LD_AS_NEEDED
+#define USE_LD_AS_NEEDED 1
+#endif
+
 /[  Target stuff  ]***/
 
 /* All FreeBSD Architectures support the ELF object file format.  */


Jakub


Re: Add -lssp_nonshared to LINK_SSP_SPEC

2012-02-07 Thread Richard Guenther
On Tue, Feb 7, 2012 at 12:53 PM, Jakub Jelinek ja...@redhat.com wrote:
 On Tue, Feb 07, 2012 at 12:17:59PM +0100, Tijl Coosemans wrote:
 Everything still works on FreeBSD.

 After discussion about this on IRC Richard expressed his preference
 for the following variant instead:

Ok.

Thanks,
Richard.

 2012-02-07  Jakub Jelinek  ja...@redhat.com

        * config/freebsd-spec.h: Add comment about what macros can be defined
        in this header.
        (LINK_EH_SPEC, LINK_SSP_SPEC, USE_LD_AS_NEEDED): Don't define here.
        * config/freebsd.h (LINK_EH_SPEC, LINK_SSP_SPEC, USE_LD_AS_NEEDED): But
        here instead.

 --- gcc/config/freebsd-spec.h.jj        2012-01-30 00:10:01.0 +0100
 +++ gcc/config/freebsd-spec.h   2012-02-07 12:44:47.0 +0100
 @@ -134,15 +134,6 @@ is built with the --enable-threads confi
  #define FBSD_DYNAMIC_LINKER /libexec/ld-elf.so.1
  #endif

 -#if defined(HAVE_LD_EH_FRAME_HDR)
 -#define LINK_EH_SPEC %{!static:--eh-frame-hdr} 
 -#endif
 -
 -#ifdef TARGET_LIBC_PROVIDES_SSP
 -#define LINK_SSP_SPEC 
 %{fstack-protector|fstack-protector-all:-lssp_nonshared}
 -#endif
 -
 -/* Use --as-needed -lgcc_s for eh support.  */
 -#ifdef HAVE_LD_AS_NEEDED
 -#define USE_LD_AS_NEEDED 1
 -#endif
 +/* NOTE: The freebsd-spec.h header is included also for various
 +   non-FreeBSD powerpc targets, thus it should never define macros
 +   other than FBSD_* prefixed ones, or USING_CONFIG_FREEBSD_SPEC.  */
 --- gcc/config/freebsd.h.jj     2010-11-26 18:39:09.0 +0100
 +++ gcc/config/freebsd.h        2012-02-07 12:45:34.497798123 +0100
 @@ -1,6 +1,6 @@
  /* Base configuration file for all FreeBSD targets.
    Copyright (C) 1999, 2000, 2001, 2007, 2008, 2009,
 -   2010 Free Software Foundation, Inc.
 +   2010, 2011, 2012 Free Software Foundation, Inc.

  This file is part of GCC.

 @@ -45,6 +45,19 @@ along with GCC; see the file COPYING3.
  #undef  LIB_SPEC
  #define LIB_SPEC FBSD_LIB_SPEC

 +#if defined(HAVE_LD_EH_FRAME_HDR)
 +#define LINK_EH_SPEC %{!static:--eh-frame-hdr} 
 +#endif
 +
 +#ifdef TARGET_LIBC_PROVIDES_SSP
 +#define LINK_SSP_SPEC 
 %{fstack-protector|fstack-protector-all:-lssp_nonshared}
 +#endif
 +
 +/* Use --as-needed -lgcc_s for eh support.  */
 +#ifdef HAVE_LD_AS_NEEDED
 +#define USE_LD_AS_NEEDED 1
 +#endif
 +
  /[  Target stuff  
 ]***/

  /* All FreeBSD Architectures support the ELF object file format.  */


        Jakub


[PATCH] Avoid excessive newline in -alias dumps

2012-02-07 Thread Richard Guenther

Committed as obvious.

Richard.

2012-02-07  Richard Guenther  rguent...@suse.de

* gimple-pretty-print.c (dump_gimple_phi): Avoid excessive
newline in -alias dumps.

Index: gcc/gimple-pretty-print.c
===
--- gcc/gimple-pretty-print.c   (revision 183959)
+++ gcc/gimple-pretty-print.c   (working copy)
@@ -1595,9 +1595,11 @@ dump_gimple_phi (pretty_printer *buffer,
   pp_points_to_solution (buffer, pi-pt);
   newline_and_indent (buffer, spc);
   if (pi-align != 1)
-   pp_printf (buffer, # ALIGN = %u, MISALIGN = %u,
-  pi-align, pi-misalign);
-  newline_and_indent (buffer, spc);
+   {
+ pp_printf (buffer, # ALIGN = %u, MISALIGN = %u,
+pi-align, pi-misalign);
+ newline_and_indent (buffer, spc);
+   }
   pp_string (buffer, # );
 }
 


[PATCH][4.8] C++ memory model bitfield handling rewrite

2012-02-07 Thread Richard Guenther

The following patch rewrites the bitfield handling of the C++ memory
model and enables it unconditionally to fix PR52080.  As I suggested
earlier at some point this moves computation of what the memory model
considers the underlying object we may access to the point where we
lay out a structure type.  This allows other passes like for example
SRA or a new bitfield lowering pass to use a canonical (and correct)
addressable object to access bitfields.  The underlying object is
represented as a FIELD_DECL that would be a suitable replacement
for all bitfield FIELD_DECLs if you wrap it inside a BIT_FIELD_REF
(see the gimplify.c hunk).  But the main purpose (for now) is to
make use of it in get_bit_range which no longer needs to walk
all fields of a record nor build new trees or use get_inner_reference.

If the C frontend would stop using DECL_INITIAL temporarily for
bitfield FIELD_DECLs we could avoid adding a new member to struct
tree_field_decl - Joseph, is it possible to avoid using DECL_INITIAL?

There are still corner-cases I also pointed out in the existing
get_bit_range code, namely if you consider tail-padding re-use
with C++ inheritance (I didn't try hard to construct a testcase yet).
The C++ memory model folks have not yet expressed their opinion as
to how this case is supposed to be handled - a testcase would look
like

struct Base {
  int i : 1;
};
struct Deriv : Base {
  char c;
};

where Deriv::c would be at byte offset 1 (the current code will
allow SImode accesses to Base:i).  Note that in the above case
tail-padding is _not_ reused (for some reason).

Bootstrapped and tested on x86_64-unknown-linux-gnu.

Any comments?

Thanks,
Richard.

2012-02-07  Richard Guenther  rguent...@suse.de

* tree.h (DECL_BIT_FIELD_REPRESENTATIVE): New define.
(struct tree_field_decl): New field bit_field_representative.
* stor-layout.c (start_bitfield_representative): New function.
(finish_bitfield_representative): Likewise.
(finish_bitfield_layout): Likewise.
(finish_record_layout): Call finish_bitfield_layout.
* tree-streamer-in.c (lto_input_ts_field_decl_tree_pointers):
Stream DECL_BIT_FIELD_REPRESENTATIVE.
* tree-streamer-out.c (write_ts_field_decl_tree_pointers): Likewise.

PR middle-end/52080
PR middle-end/52097
PR middle-end/48124
* expr.c (get_bit_range): Unconditionally extract bitrange
from DECL_BIT_FIELD_REPRESENTATIVE.
(expand_assignment): Adjust call to get_bit_range.

* gimplify.c (gimplify_expr): Translate bitfield accesses
to BIT_FIELD_REFs of the representative.

* tree-sra.c (create_access_replacement): Only rename the
replacement if we can rewrite it into SSA form.  Properly
mark register typed replacements that we cannot rewrite
with TREE_ADDRESSABLE.

* gcc.dg/torture/pr48124-1.c: New testcase.
* gcc.dg/torture/pr48124-2.c: Likewise.
* gcc.dg/torture/pr48124-3.c: Likewise.
* gcc.dg/torture/pr48124-4.c: Likewise.

Index: gcc/stor-layout.c
===
*** gcc/stor-layout.c.orig  2012-02-07 11:04:21.0 +0100
--- gcc/stor-layout.c   2012-02-07 11:19:55.0 +0100
*** finalize_type_size (tree type)
*** 1722,1727 
--- 1722,1908 
  }
  }
  
+ /* Return a new underlying object for a bitfield started with FIELD.  */
+ 
+ static tree
+ start_bitfield_representative (tree field)
+ {
+   tree repr = make_node (FIELD_DECL);
+   DECL_FIELD_OFFSET (repr) = DECL_FIELD_OFFSET (field);
+   /* Force the representative to begin at an BITS_PER_UNIT aligned
+  boundary - C++ may use tail-padding of a base object to
+  continue packing bits so the bitfield region does not start
+  at bit zero (see g++.dg/abi/bitfield5.C for example).
+  Unallocated bits may happen for other reasons as well,
+  for example Ada which allows explicit bit-granular structure layout.  */
+   DECL_FIELD_BIT_OFFSET (repr)
+ = size_binop (BIT_AND_EXPR,
+ DECL_FIELD_BIT_OFFSET (field),
+ bitsize_int (~(BITS_PER_UNIT - 1)));
+   SET_DECL_OFFSET_ALIGN (repr, DECL_OFFSET_ALIGN (field));
+   DECL_SIZE (repr) = DECL_SIZE (field);
+   DECL_PACKED (repr) = DECL_PACKED (field);
+   DECL_CONTEXT (repr) = DECL_CONTEXT (field);
+   return repr;
+ }
+ 
+ /* Finish up a bitfield group that was started by creating the underlying
+object REPR with the last fied in the bitfield group FIELD.  */
+ 
+ static void
+ finish_bitfield_representative (tree repr, tree field)
+ {
+   unsigned HOST_WIDE_INT bitsize, maxbitsize, modesize;
+   enum machine_mode mode;
+   tree nextf, size;
+ 
+   size = size_diffop (DECL_FIELD_OFFSET (field),
+ DECL_FIELD_OFFSET (repr));
+   gcc_assert (host_integerp (size, 1));
+   bitsize = (tree_low_cst (size, 1) * BITS_PER_UNIT
++ tree_low_cst 

[PATCH 4.8, i386]: Make CCZ mode compatible with CCGOC, CCGO and CCNO modes

2012-02-07 Thread Uros Bizjak
Hello!

Attached patch declares CCZmode compatible with CCGOC, CCGO and CCNO modes.

2012-02-07  Uros Bizjak  ubiz...@gmail.com

* config/i386/i386.c (ix86_cc_modes_compatible): Declare CCZmode
compatible with CCGOCmode, CCGCmode and CCNOmode.

Bootstrapped on x86_64-pc-linux-gnu, regression test still in progress.

This patch (together with previous combine/i386 proto-patch) is still
not enough to remove redundant test instruction from

int test (int a, int b)
{
  int lt = a + b  0;
  int eq = a + b == 0;
  if (lt)
return 1;
  return eq;
}

It looks to me that something is wrong with compare-elim pass. Since
CCZmode is now made compatible with CCGOCmode (and results in
CCGOCmode), compare-elim pass should update the comparison mode in

 (insn 9 8 10 2 (parallel [
(set (reg:SI 5 di [orig:60 D.1710 ] [60])
(plus:SI (reg/v:SI 5 di [orig:63 a ] [63])
(reg/v:SI 4 si [orig:64 b ] [64])))
(set (reg:CCZ 17 flags)
(compare:CCZ (plus:SI (reg/v:SI 5 di [orig:63 a ] [63])
(reg/v:SI 4 si [orig:64 b ] [64]))
(const_int 0 [0])))
]) cmp.c:4 261 {*addsi_2}
 (nil))

to CCGOCmode and eliminate CCGOC compare:

 (insn 29 30 31 2 (set (reg:CCGOC 17 flags)
(compare:CCGOC (reg:SI 5 di [orig:60 D.1710 ] [60])
(const_int 0 [0]))) cmp.c:6 2 {*cmpsi_ccno_1}
 (nil))

Uros.
Index: config/i386/i386.c
===
--- config/i386/i386.c  (revision 183953)
+++ config/i386/i386.c  (working copy)
@@ -17778,6 +17778,27 @@ ix86_cc_modes_compatible (enum machine_mode m1, en
   || (m1 == CCGOCmode  m2 == CCGCmode))
 return CCGCmode;
 
+  if (m1 == CCZmode)
+switch (m2)
+  {
+  default:
+   break;
+  case CCGOCmode:
+  case CCGCmode:
+  case CCNOmode:
+   return m2;
+  }
+  else if (m2 == CCZmode)
+switch (m1)
+  {
+  default:
+   break;
+  case CCGOCmode:
+  case CCGCmode:
+  case CCNOmode:
+   return m1;
+  }
+
   switch (m1)
 {
 default:


Re: Add -lssp_nonshared to LINK_SSP_SPEC

2012-02-07 Thread Joseph S. Myers
On Tue, 7 Feb 2012, Jakub Jelinek wrote:

 So, if this mess is really needed (does anybody actually use -mcall-freebsd
 on non-freebsd targets?), IMHO freebsd-spec.h must avoid defining non-FBSD_

I've argued for a long time that the -mcall-* support should be removed 
and targets using rs6000/sysv4.h should move to the standard approach of 
each configuration defining and using its own specs where the specs differ 
between targets (in particular, making powerpc*-linux* use linux.h and 
gnu-user.h like most other targets using the Linux kernel do).  There's a 
point about this in the development conventions document at 
https://docs.google.com/document/pub?id=10LO8y0YhjlKHya_PKM3jEGrJu0rllv-Nc9qP5LXqH_I.
  
I don't think -mcall-* will form any useful part of proper multi-target 
support.

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


Re: Add -lssp_nonshared to LINK_SSP_SPEC

2012-02-07 Thread Jakub Jelinek
On Tue, Feb 07, 2012 at 01:13:35PM +, Joseph S. Myers wrote:
 On Tue, 7 Feb 2012, Jakub Jelinek wrote:
 
  So, if this mess is really needed (does anybody actually use -mcall-freebsd
  on non-freebsd targets?), IMHO freebsd-spec.h must avoid defining non-FBSD_
 
 I've argued for a long time that the -mcall-* support should be removed 
 and targets using rs6000/sysv4.h should move to the standard approach of 
 each configuration defining and using its own specs where the specs differ 
 between targets (in particular, making powerpc*-linux* use linux.h and 
 gnu-user.h like most other targets using the Linux kernel do).  There's a 
 point about this in the development conventions document at 
 https://docs.google.com/document/pub?id=10LO8y0YhjlKHya_PKM3jEGrJu0rllv-Nc9qP5LXqH_I.
   
 I don't think -mcall-* will form any useful part of proper multi-target 
 support.

I agree, not sure if I'll have time for that though.  Not a stage4 material
though IMHO.

Jakub


Re: [PATCH][4.8] C++ memory model bitfield handling rewrite

2012-02-07 Thread Joseph S. Myers
On Tue, 7 Feb 2012, Richard Guenther wrote:

 If the C frontend would stop using DECL_INITIAL temporarily for
 bitfield FIELD_DECLs we could avoid adding a new member to struct
 tree_field_decl - Joseph, is it possible to avoid using DECL_INITIAL?

C++ does the same thing with DECL_INITIAL so I'd expect that to need to 
change as well - Jason?  C only needs an integer width within a limited 
range; C++ may actually need a general expression here.

C currently uses a TREE_LIST of field declarations when parsing a 
structure.  It should be reasonably straightforward to change that to a 
VEC of structures storing both the declaration and the width, so the width 
no longer need go in DECL_INITIAL of the declaration, though it will be 
necessary to check for other code using DECL_INITIAL to check for 
bit-fields.  For example, c-common.c:handle_packed_attribute uses 
DECL_INITIAL like that; it should be possible to make both C and C++ set 
DECL_C_BIT_FIELD early enough that such DECL_INITIAL checks can be 
replaced by a more meaningful DECL_C_BIT_FIELD check.

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


Re: Add -lssp_nonshared to LINK_SSP_SPEC

2012-02-07 Thread Tijl Coosemans
On Tuesday 07 February 2012 12:53:24 Jakub Jelinek wrote:
 On Tue, Feb 07, 2012 at 12:17:59PM +0100, Tijl Coosemans wrote:
 Everything still works on FreeBSD.
 
 After discussion about this on IRC Richard expressed his preference
 for the following variant instead:

Works too.


[committed] Remove myself as vectorizer maintainer

2012-02-07 Thread Ira Rosen

Hi,

I am starting to work on a new project and won't be able to continue with
vectorizer maintenance.

I'd like to thank all the people I had a chance to work with for making my
GCC experience so enjoyable.

All the best,
Ira


2012-02-08  Ira Rosen i...@il.ibm.com

* MAINTAINERS (Various Maintainers): Remove myself as
auto-vectorizer
maintainer.

Index: MAINTAINERS
===
--- MAINTAINERS (revision 183967)
+++ MAINTAINERS (working copy)
@@ -240,7 +240,6 @@ RTL optimizers  Eric Botcazou
ebotcazou@libertysu
 RTL optimizers Richard Sandiford   rdsandif...@googlemail.com
 auto-vectorizerRichard Guentherrguent...@suse.de
 auto-vectorizerZdenek Dvorak   o...@ucw.cz
-auto-vectorizerIra Rosen   i...@il.ibm.com
 loop infrastructureZdenek Dvorak   o...@ucw.cz
 OpenMP Jakub Jelinek   ja...@redhat.com
 testsuite  Rainer Orth r...@cebitec.uni-bielefeld.de




Re: [PATCH][4.8] C++ memory model bitfield handling rewrite

2012-02-07 Thread Richard Guenther
On Tue, 7 Feb 2012, Jonathan Wakely wrote:

 Hi Richard,
 
 re http://gcc.gnu.org/ml/gcc-patches/2012-02/msg00280.html (I'm not
 subscribed to gcc-patches so only read it in the archive)
 
  Note that in the above case
  tail-padding is _not_ reused (for some reason).
 
 Tail-padding in PODs can't be reused according to the ABI.  Give Base
 a user-defined constructor or destructor and it gets reused.

Ah, thanks.  Thus, for the following testcase

struct Base {
Base();
int i : 1;
};
struct Deriv : Base {
char d : 2;
char x;
};

Deriv s;
void foo ()
{
  s.i = 1;
  s.d = 2;
  s.x = 3;
}

What does the C++ memory model say about accesses to s.i, s.d and s.x?
What would it have said for -fabi-version=1 where for 
we place s.i and s.d into the same byte?

Thanks,
Richard.


Re: [PATCH][4.8] C++ memory model bitfield handling rewrite

2012-02-07 Thread Joseph S. Myers
On Tue, 7 Feb 2012, Richard Guenther wrote:

 That would be nice.  I suppose that doing
 
   if (DECL_INITIAL (x))
 {
   unsigned HOST_WIDE_INT width = tree_low_cst (DECL_INITIAL (x), 
 1);
   DECL_SIZE (x) = bitsize_int (width);
   DECL_BIT_FIELD (x) = 1;
   SET_DECL_C_BIT_FIELD (x);
 }
 
 at the time we set DECL_INITIAL to the width is not possible
 for some weird reason?  At least the struct-layout-1.exp tests
 seem to be happy with

I don't know, but given how many ABI variations there are it would need a 
lot of testing and understanding how DECL_SIZE and DECL_BIT_FIELD may be 
used.  Just setting DECL_C_BIT_FIELD early, and keeping the width 
somewhere separate, seems safer (although uses still need to be checked).

For C++ the width may depend on a template parameter so the integer value 
can't be determined immediately at parse time.

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


Re: [PATCH] Fix combiner with added_sets_[12] (PR rtl-optimization/52060)

2012-02-07 Thread Eric Botcazou
 2012-02-06  Jakub Jelinek  ja...@redhat.com

   PR rtl-optimization/52060
   * combine.c (try_combine): Add i0src_copy and i0src_copy2 variables,
   copy i1src to i1src_copy whenever added_sets_2  i1_feeds_i2_n already
   before i1dest - i1src substitution in newpat, copy i0src to i0src_copy
   and/or i0src_copy2 when needed.

   * gcc.dg/torture/pr52060.c: New test.

OK, thanks.

-- 
Eric Botcazou


Re: Memory corruption due to word sharing

2012-02-07 Thread Aldy Hernandez



Testcase is for example g++.dg/abi/bitfield5.C, bit layout annotated:

struct A {
   virtual void f();
   int f1 : 1;--- bit 64
};

struct B : public A {
   int f2 : 1;  // { dg-warning ABI }--- bit 65
   int : 0;
   int f3 : 4;
   int f4 : 3;
};

maybe it was a bug (above happens with -fabi-version=1 only),
but certainly an ABI may specify that we should do that packing.

What does the C++ memory model say here?  (incidentially that's
one case I was worried about when reviewing your patches,
just I didn't think of _bitfield_ tail-packing ... ;)).

I suppose I could just force the bitfield region to start
at a byte boundary.


I think we talked about this months ago when working on the memory model 
stuff.  Andrew Macleod brought it up, but I can't find the thread.


It is my understanding that f1 and f2 must be in distinct memory 
regions.  So writing to f1 cannot clobber f2.


I would like to get confirmation from Jason though.


[pph] Clear lexer state while replaying the symbol table (issue5645047)

2012-02-07 Thread Diego Novillo
When we re-play the symbol table for a PPH image, we are executing
from libcpp's #include handler.  This means that the lexer thinks that
it is inside the #include directive.

This alters the lexer behaviour in subtle ways.  In this test case,
for example, the parsing of the escaped quotes inside the asm()
instruction makes the lexer think that the string has ended before it
actually does.

This cascades into a lexing or syntax error later on because the
string got truncated.

This patch saves and restores the lexer state as we re-play the symbol
table.  Initially, I was trying to do this after we return from the
table are needed while we read the PPH file.

2012-02-06   Diego Novillo  dnovi...@google.com

libcpp/ChangeLog.pph
* directives.c (_cpp_clear_directive_state): New.
(end_directive): Call it.
(_cpp_save_directive_state): New.
(_cpp_restore_directive_state): New.
* internal.h (_cpp_clear_directive_state): Declare.
(_cpp_save_directive_state): Declare.
(_cpp_restore_directive_state): Declare.
* symtab.c (cpp_lt_replay): Call
_cpp_clear_directive_state, _cpp_save_directive_state and
_cpp_restore_directive_state.

gcc/testsuite/ChangeLog.pph
* g++.dg/pph/x0string-escapes.h: New.
* g++.dg/pph/x1string-escapes.h: New.
* g++.dg/pph/x2string-escapes.cc: New.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/pph@183952 
138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/testsuite/ChangeLog.pph  |6 
 gcc/testsuite/g++.dg/pph/x0string-escapes.h  |7 
 gcc/testsuite/g++.dg/pph/x1string-escapes.h  |4 ++
 gcc/testsuite/g++.dg/pph/x2string-escapes.cc |9 +
 libcpp/ChangeLog.pph |   13 
 libcpp/directives.c  |   42 ++---
 libcpp/internal.h|6 
 libcpp/symtab.c  |   11 +++
 8 files changed, 93 insertions(+), 5 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/pph/x0string-escapes.h
 create mode 100644 gcc/testsuite/g++.dg/pph/x1string-escapes.h
 create mode 100644 gcc/testsuite/g++.dg/pph/x2string-escapes.cc

diff --git a/gcc/testsuite/ChangeLog.pph b/gcc/testsuite/ChangeLog.pph
index 4037c01..3248e91 100644
--- a/gcc/testsuite/ChangeLog.pph
+++ b/gcc/testsuite/ChangeLog.pph
@@ -1,3 +1,9 @@
+2012-02-06   Diego Novillo  dnovi...@google.com
+
+   * g++.dg/pph/x0string-escapes.h: New.
+   * g++.dg/pph/x1string-escapes.h: New.
+   * g++.dg/pph/x2string-escapes.cc: New.
+
 2012-02-01   Lawrence Crowl  cr...@google.com
 
* g++.dg/pph/x4structover1.cc: Mark fixed.
diff --git a/gcc/testsuite/g++.dg/pph/x0string-escapes.h 
b/gcc/testsuite/g++.dg/pph/x0string-escapes.h
new file mode 100644
index 000..92db6bc
--- /dev/null
+++ b/gcc/testsuite/g++.dg/pph/x0string-escapes.h
@@ -0,0 +1,7 @@
+#ifndef X0_STRING_ESCAPES_H
+#define X0_STRING_ESCAPES_H
+#define FOO(s) \
+  asm(.pushsection \.section_name\, \MS\,%progbits,1\n \
+  .asciz \ s \\n \
+  .popsection \n);
+#endif
diff --git a/gcc/testsuite/g++.dg/pph/x1string-escapes.h 
b/gcc/testsuite/g++.dg/pph/x1string-escapes.h
new file mode 100644
index 000..2539688
--- /dev/null
+++ b/gcc/testsuite/g++.dg/pph/x1string-escapes.h
@@ -0,0 +1,4 @@
+#ifndef X1_STRING_ESCAPES_H
+#define X1_STRING_ESCAPES_H
+#include x0string-escapes.h
+#endif
diff --git a/gcc/testsuite/g++.dg/pph/x2string-escapes.cc 
b/gcc/testsuite/g++.dg/pph/x2string-escapes.cc
new file mode 100644
index 000..511f7b0
--- /dev/null
+++ b/gcc/testsuite/g++.dg/pph/x2string-escapes.cc
@@ -0,0 +1,9 @@
+#include x1string-escapes.h
+
+int foo(int);
+
+int foo(int i)
+{
+  FOO(name);
+  return i;
+}
diff --git a/libcpp/ChangeLog.pph b/libcpp/ChangeLog.pph
index a74344f..37216a4 100644
--- a/libcpp/ChangeLog.pph
+++ b/libcpp/ChangeLog.pph
@@ -1,3 +1,16 @@
+2012-02-06   Diego Novillo  dnovi...@google.com
+
+   * directives.c (_cpp_clear_directive_state): New.
+   (end_directive): Call it.
+   (_cpp_save_directive_state): New.
+   (_cpp_restore_directive_state): New.
+   * internal.h (_cpp_clear_directive_state): Declare.
+   (_cpp_save_directive_state): Declare.
+   (_cpp_restore_directive_state): Declare.
+   * symtab.c (cpp_lt_replay): Call
+   _cpp_clear_directive_state, _cpp_save_directive_state and
+   _cpp_restore_directive_state.
+
 2012-01-18   Diego Novillo  dnovi...@google.com
 
* internal.h (cpp_in_primary_file): Move ...
diff --git a/libcpp/directives.c b/libcpp/directives.c
index ecd1486..043d602 100644
--- a/libcpp/directives.c
+++ b/libcpp/directives.c
@@ -311,11 +311,7 @@ end_directive (cpp_reader *pfile, int skip_line)
 }
 
   /* Restore state.  */
-  pfile-state.save_comments = ! CPP_OPTION (pfile, discard_comments);
-  pfile-state.in_directive = 0;
-  pfile-state.in_expression = 0;
-  pfile-state.angled_headers = 0;
-  pfile-directive 

Re: [PATCH][4.8] C++ memory model bitfield handling rewrite

2012-02-07 Thread Jonathan Wakely
On 7 February 2012 14:00, Richard Guenther wrote:
 On Tue, 7 Feb 2012, Jonathan Wakely wrote:

 Hi Richard,

 re http://gcc.gnu.org/ml/gcc-patches/2012-02/msg00280.html (I'm not
 subscribed to gcc-patches so only read it in the archive)

  Note that in the above case
  tail-padding is _not_ reused (for some reason).

 Tail-padding in PODs can't be reused according to the ABI.  Give Base
 a user-defined constructor or destructor and it gets reused.

 Ah, thanks.  Thus, for the following testcase

 struct Base {
    Base();
    int i : 1;
 };
 struct Deriv : Base {
    char d : 2;
    char x;
 };

 Deriv s;
 void foo ()
 {
  s.i = 1;
  s.d = 2;
  s.x = 3;
 }

 What does the C++ memory model say about accesses to s.i, s.d and s.x?

It depends whether s.i and d.i are adjacent bit-fields or not.

A memory location is either an object of scalar type or a maximal
sequence of adjacent bit-fields all having non-zero width.

I think they are not adjacent, so [intro.memory] 1.7 in
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3337.pdf
(that clause is identical in n3337 and C++11 standard)  says s.i and
s.d are separate memory locations, so can be updated concurrently in
separate threads without races.

Two threads of execution (1.10) can update and access separate memory locations
without interfering with each other.

 What would it have said for -fabi-version=1 where for
 we place s.i and s.d into the same byte?

I think it says they shouldn't be in the same byte :-)

The memory model talks about separate memory locations. If the
compiler puts separate memory locations into the same byte then it
still has to allow concurrent updates to not interfere.

But I'm not an expert on the memory model so check those claims with
someone else.


Re: [PATCH][4.8] C++ memory model bitfield handling rewrite

2012-02-07 Thread Jakub Jelinek
On Tue, Feb 07, 2012 at 04:01:31PM +, Jonathan Wakely wrote:
  What would it have said for -fabi-version=1 where for
  we place s.i and s.d into the same byte?
 
 I think it says they shouldn't be in the same byte :-)

They don't, except for compatibility with the old ABI.
I think easiest would be either to error out on -fabi-version=1
mixed with an explicit option to request C++11 memory model,
or just ignore it (perhaps with a warning), people who care about the strict
memory model requirements just shouldn't use -fabi-version=1.
Using atomic modifications of the byte that has parts of the tail
padding bits used by another class would be IMHO an overkill.

Jakub


[PATCH 4.8 v2, i386]: Make CCZ mode compatible with CCGOC and CCGO modes

2012-02-07 Thread Uros Bizjak
On Tue, Feb 7, 2012 at 1:59 PM, Uros Bizjak ubiz...@gmail.com wrote:

 Attached patch declares CCZmode compatible with CCGOC, CCGO and CCNO modes.

Actually, CCZ mode is not compatible with CCNO mode, since the later
only declares that overflow flag is not set. CCGOC and CCGO declare
garbage in overflow (and carry in case of CCGOC) flag, so implicitly
declare that CCZ flag is valid. Following this reasoning, CCZ mode
should be compatible with CCGOC and CCGO modes.

2012-02-07  Uros Bizjak  ubiz...@gmail.com

   * config/i386/i386.c (ix86_cc_modes_compatible): Declare CCZmode
   compatible with CCGOCmode and CCGCmode.

Attached patch was bootstrapped and regression tested on x86_64-pc-linux-gnu.

Uros.
Index: config/i386/i386.c
===
--- config/i386/i386.c  (revision 183968)
+++ config/i386/i386.c  (working copy)
@@ -17778,6 +17778,11 @@ ix86_cc_modes_compatible (enum machine_mode m1, en
   || (m1 == CCGOCmode  m2 == CCGCmode))
 return CCGCmode;
 
+  if (m1 == CCZmode  (m2 == CCGCmode || m2 == CCGOCmode))
+return m2;
+  else if (m2 == CCZmode  (m1 == CCGCmode || m1 == CCGOCmode))
+return m1;
+
   switch (m1)
 {
 default:


Re: [PATCH 4.8 v2, i386]: Make CCZ mode compatible with CCGOC and CCGO modes

2012-02-07 Thread Uros Bizjak
On Tue, Feb 7, 2012 at 5:57 PM, Richard Henderson r...@redhat.com wrote:

 Attached patch declares CCZmode compatible with CCGOC, CCGO and CCNO modes.

 Actually, CCZ mode is not compatible with CCNO mode, since the later
 only declares that overflow flag is not set. CCGOC and CCGO declare
 garbage in overflow (and carry in case of CCGOC) flag, so implicitly
 declare that CCZ flag is valid. Following this reasoning, CCZ mode
 should be compatible with CCGOC and CCGO modes.

 We should probably fix this confusion by renaming the modes so that
 they're all positive:

  CCNO          - CCCSZ
  CCGC          - CCOSZ
  CCGOC         - CCSZ

No, no. Once you get the logic, it actually makes sense to name them
that way. Regarding your proposed change, CCNO does not say that CSZ
are all valid, it says that OF = 0, so the first line is wrong.

Uros.


[PATCH, committed] Fix error message for -mno-pointers-to-nested-functions

2012-02-07 Thread Michael Meissner
David pointed out that I had not updated the error message for
-mno-pointers-to-nested-functions when I changed the name of the switch.  I
installed the following patch as obvious after making sure it bootstrapped and
ran make check.

[gcc]
2012-02-07  Michael Meissner  meiss...@linux.vnet.ibm.com

* config/rs6000/rs6000.c (rs6000_trampoline_init): Fix error
message for -mno-pointers-to-nested-function.

[gcc/testsuite]
2012-02-07  Michael Meissner  meiss...@linux.vnet.ibm.com

* gcc.target/powerpc/no-r11-3.c (outer_func): Fix error message
for -mno-pointers-to-nested-functions.

Index: gcc/config/rs6000/rs6000.c
===
--- gcc/config/rs6000/rs6000.c  (revision 183975)
+++ gcc/config/rs6000/rs6000.c  (working copy)
@@ -24032,7 +24032,8 @@ rs6000_trampoline_init (rtx m_tramp, tre
rtx fnmem, fn_reg, toc_reg;
 
if (!TARGET_POINTERS_TO_NESTED_FUNCTIONS)
- error (-mno-r11 must not be used if you have trampolines);
+ error (You cannot take the address of a nested function if you use 
+the -mno-pointers-to-nested-functions option.);
 
fnmem = gen_const_mem (Pmode, force_reg (Pmode, fnaddr));
fn_reg = gen_reg_rtx (Pmode);
Index: gcc/testsuite/gcc.target/powerpc/no-r11-3.c
===
--- gcc/testsuite/gcc.target/powerpc/no-r11-3.c (revision 183975)
+++ gcc/testsuite/gcc.target/powerpc/no-r11-3.c (working copy)
@@ -5,7 +5,7 @@
 extern void ext_call (int (func) (void));
 
 int
-outer_func (int init)  /* { dg-error -mno-r11 must not be used if you have 
trampolines  } */
+outer_func (int init)  /* { dg-error -mno-pointers-to-nested-functions 
option  } */
 {
   int value = init;
 

-- 
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



Re: [PATCH 4.8, i386]: Enable post-reload compare optimization pass (PR28685)

2012-02-07 Thread Uros Bizjak
On Tue, Feb 7, 2012 at 11:00 AM, Uros Bizjak ubiz...@gmail.com wrote:

 Hmm.  Well, the only thing that's going to work for x86 is the 
 double-compare
 elimination portion.

 If we want to use this pass for x86, then for 4.8 we should also fix the
 discrepancy between the compare-elim canonical

  [(operate)
   (set-cc)]

 and the combine canonical

  [(set-cc)
   (operate)]

 (Because of the simplicity of the substitution in compare-elim, I prefer
 the former as the canonical canonical.)

 You are probably referring to following testcase:

 --cut here--
 int test (int a, int b)
 {
  int lt = a + b  0;
  int eq = a + b == 0;
  if (lt)
    return 1;
  return eq;
 }
 --cut here--

 where combine creates:

 Trying 8 - 9:
 Successfully matched this instruction:
 (parallel [
        (set (reg:CCZ 17 flags)
            (compare:CCZ (plus:SI (reg/v:SI 63 [ a ])
                    (reg/v:SI 64 [ b ]))
                (const_int 0 [0])))
        (set (reg:SI 60 [ D.1710 ])
            (plus:SI (reg/v:SI 63 [ a ])
                (reg/v:SI 64 [ b ])))
    ])

 Attached patch teaches combine to swap operands of a double set
 pattern and retries recognition. Also added are minimum
 target-dependant changes to handle the testcase above.

Please ignore this idea. I am preparing target-only patchset that
moves x86 entirely to post-reload flags handling (similar to rx and
mn10300 targets). Not a 4.7 material in any way.

Uros.


[MIPS, committed] va_arg and zero-sized objects take 2

2012-02-07 Thread Richard Sandiford
Given the unacceptability of the original builtins patch:

http://gcc.gnu.org/ml/gcc-patches/2012-01/msg01564.html

I've decided to go for this MIPS-specific version.  I've also made
the test specific to MIPS and XFAILed it for EABI32 (the failures
there don't seem to be a regression).  We could potentially make
both mips_std_gimplify_va_arg_expr and the testcase available to
all targets later.

This shows that mips_gimplify_va_arg_expr ought to be testing
EABI_FLOAT_VARARGS_P at the very beginning.  Stuff like:

  indirect_p = pass_by_reference (NULL, TYPE_MODE (type), type, 0);
  if (indirect_p)
type = build_pointer_type (type);

is at best redundant for !EABI_FLOAT_VARARGS_P, since the generic
functions do the same thing.  That's 4.8 material though.

Tested on mips64-linux-gnu and various ELF targets.  Applied.

Richard


gcc/
PR middle-end/24306
* config/mips/mips.c (mips_std_gimplify_va_arg_expr): New function.
(mips_gimplify_va_arg_expr): Call it instead of
std_gimplify_va_arg_expr.

gcc/testsuite/
PR middle-end/24306
PR target/52154
* lib/target-supports.exp (check_effective_target_mips_eabi): New.
* gcc.target/mips/va-arg-1.c: New test.

Index: gcc/config/mips/mips.c
===
--- gcc/config/mips/mips.c  2012-02-05 14:49:20.0 +
+++ gcc/config/mips/mips.c  2012-02-06 20:37:25.0 +
@@ -5576,6 +5576,95 @@ mips_va_start (tree valist, rtx nextarg)
 }
 }
 
+/* Like std_gimplify_va_arg_expr, but apply alignment to zero-sized
+   types as well.  */
+
+static tree
+mips_std_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p,
+  gimple_seq *post_p)
+{
+  tree addr, t, type_size, rounded_size, valist_tmp;
+  unsigned HOST_WIDE_INT align, boundary;
+  bool indirect;
+
+  indirect = pass_by_reference (NULL, TYPE_MODE (type), type, false);
+  if (indirect)
+type = build_pointer_type (type);
+
+  align = PARM_BOUNDARY / BITS_PER_UNIT;
+  boundary = targetm.calls.function_arg_boundary (TYPE_MODE (type), type);
+
+  /* When we align parameter on stack for caller, if the parameter
+ alignment is beyond MAX_SUPPORTED_STACK_ALIGNMENT, it will be
+ aligned at MAX_SUPPORTED_STACK_ALIGNMENT.  We will match callee
+ here with caller.  */
+  if (boundary  MAX_SUPPORTED_STACK_ALIGNMENT)
+boundary = MAX_SUPPORTED_STACK_ALIGNMENT;
+
+  boundary /= BITS_PER_UNIT;
+
+  /* Hoist the valist value into a temporary for the moment.  */
+  valist_tmp = get_initialized_tmp_var (valist, pre_p, NULL);
+
+  /* va_list pointer is aligned to PARM_BOUNDARY.  If argument actually
+ requires greater alignment, we must perform dynamic alignment.  */
+  if (boundary  align)
+{
+  t = build2 (MODIFY_EXPR, TREE_TYPE (valist), valist_tmp,
+ fold_build_pointer_plus_hwi (valist_tmp, boundary - 1));
+  gimplify_and_add (t, pre_p);
+
+  t = build2 (MODIFY_EXPR, TREE_TYPE (valist), valist_tmp,
+ fold_build2 (BIT_AND_EXPR, TREE_TYPE (valist),
+  valist_tmp,
+  build_int_cst (TREE_TYPE (valist), -boundary)));
+  gimplify_and_add (t, pre_p);
+}
+  else
+boundary = align;
+
+  /* If the actual alignment is less than the alignment of the type,
+ adjust the type accordingly so that we don't assume strict alignment
+ when dereferencing the pointer.  */
+  boundary *= BITS_PER_UNIT;
+  if (boundary  TYPE_ALIGN (type))
+{
+  type = build_variant_type_copy (type);
+  TYPE_ALIGN (type) = boundary;
+}
+
+  /* Compute the rounded size of the type.  */
+  type_size = size_in_bytes (type);
+  rounded_size = round_up (type_size, align);
+
+  /* Reduce rounded_size so it's sharable with the postqueue.  */
+  gimplify_expr (rounded_size, pre_p, post_p, is_gimple_val, fb_rvalue);
+
+  /* Get AP.  */
+  addr = valist_tmp;
+  if (PAD_VARARGS_DOWN  !integer_zerop (rounded_size))
+{
+  /* Small args are padded downward.  */
+  t = fold_build2_loc (input_location, GT_EXPR, sizetype,
+  rounded_size, size_int (align));
+  t = fold_build3 (COND_EXPR, sizetype, t, size_zero_node,
+  size_binop (MINUS_EXPR, rounded_size, type_size));
+  addr = fold_build_pointer_plus (addr, t);
+}
+
+  /* Compute new value for AP.  */
+  t = fold_build_pointer_plus (valist_tmp, rounded_size);
+  t = build2 (MODIFY_EXPR, TREE_TYPE (valist), valist, t);
+  gimplify_and_add (t, pre_p);
+
+  addr = fold_convert (build_pointer_type (type), addr);
+
+  if (indirect)
+addr = build_va_arg_indirect_ref (addr);
+
+  return build_va_arg_indirect_ref (addr);
+}
+
 /* Implement TARGET_GIMPLIFY_VA_ARG_EXPR.  */
 
 static tree
@@ -5590,7 +5679,7 @@ mips_gimplify_va_arg_expr (tree valist,
 type = build_pointer_type (type);
 
   if (!EABI_FLOAT_VARARGS_P)
-addr = 

[MIPS, committed] Avoid loongson.h conversion errors on 32-bit mips*-elf*

2012-02-07 Thread Richard Sandiford
As explained in PR 52155, a disagreement between GCC and newlib about
the best choice of 32-bit type causes lots of conversion errors when
loongson.h is included on 32-bit mips*-elf* targets.  This patch works
around them by forcing -mlong64.  An alternative would be to use
-flax-vector-conversions, like we do for loongson-simd.c, but I thought
it would be better to always have something that tests loongson.h without
that flag.

Tested on mips64-linux-gnu and various ELF targets.  Applied.

Richard


gcc/testsuite/
PR target/52155
* gcc.target/mips/mips.exp (mips-dg-options): Handle target.
* gcc.target/mips/loongson-shift-count-truncated-1.c: Force -mlong64
for MIPS ELF.

Index: gcc/testsuite/gcc.target/mips/mips.exp
===
--- gcc/testsuite/gcc.target/mips/mips.exp  2012-02-06 20:35:25.0 
+
+++ gcc/testsuite/gcc.target/mips/mips.exp  2012-02-07 18:51:32.0 
+
@@ -855,6 +855,15 @@ proc mips-dg-options { args } {
 # Information about this run.
 global mips_base_options
 
+if { [llength $args] = 3 } {
+switch { [dg-process-target [lindex $args 2]] } {
+S { }
+N { return }
+F { error [lindex $args 0]: `xfail' not allowed here }
+P { error [lindex $args 0]: `xfail' not allowed here }
+}
+}
+
 # Start out with the default option state.
 array set options [array get mips_base_options]
 
Index: gcc/testsuite/gcc.target/mips/loongson-shift-count-truncated-1.c
===
--- gcc/testsuite/gcc.target/mips/loongson-shift-count-truncated-1.c
2012-02-06 20:35:25.0 +
+++ gcc/testsuite/gcc.target/mips/loongson-shift-count-truncated-1.c
2012-02-07 18:59:41.0 +
@@ -5,6 +5,8 @@
seem any good reason for it to, given that the Loongson processors
do not support MIPS16.  */
 /* { dg-options isa=loongson -mhard-float -mno-mips16 -O1 } */
+/* See PR 52155.  */
+/* { dg-options isa=loongson -mhard-float -mno-mips16 -O1 -mlong64 { 
mips*-*-elf*  ilp32 } } */
 
 #include loongson.h
 #include assert.h


Go patch committed: Support //extern comments instead of __asm__

2012-02-07 Thread Ian Lance Taylor
The Go compiler currently supports using __asm__ in Go code to set the
externally visible name of a function declaration.  This is used to
permit Go code to call C code directly.  The problem with __asm__ is
that it is not supported by the gofmt program, which means that Go code
that uses can not be formatted automatically.  This patch adds a new
feature to gccgo: a function declaration may now be preceded by a
comment //extern NAME which sets the external name of the function
declaration.  Those comments are otherwise ignored.  This permits the
code to be run through gofmt without any trouble.  The existing __asm__
syntax remains as there is code out there which uses it.  It will be
removed in the future.  This patch changes the compiler to support
//extern and changes libgo to use it.  Bootstrapped and ran Go testsuite
on x86_64-unknown-linux-gnu.  Committed to mainline.

Ian


2012-02-07  Ian Lance Taylor  i...@google.com

* gccgo.texi (Function Names): Document //extern instead of
__asm__.


Index: gcc/go/gccgo.texi
===
--- gcc/go/gccgo.texi	(revision 183650)
+++ gcc/go/gccgo.texi	(working copy)
@@ -304,14 +304,20 @@ function is still using it.
 @node Function Names
 @section Function Names
 
-@cindex @code{__asm__}
+@cindex @code{extern}
+@cindex external names
 Go code can call C functions directly using a Go extension implemented
-in @command{gccgo}: a function declaration may be followed by
-@code{__asm__ (@var{name})}. For example, here is how the C function
-@code{open} can be declared in Go:
+in @command{gccgo}: a function declaration may be preceded by a
+comment giving the external name.  The comment must be at the
+beginning of the line and must start with @code{//extern}.  This must
+be followed by a space and then the external name of the function.
+The function declaration must be on the line immediately after the
+comment.  For example, here is how the C function @code{open} can be
+declared in Go:
 
 @smallexample
-func c_open(name *byte, mode int, perm int) int __asm__ (open);
+//extern open
+func c_open(name *byte, mode int, perm int) int
 @end smallexample
 
 The C function naturally expects a nul terminated string, which in Go
@@ -333,7 +339,7 @@ present the name of a Go function that d
 @option{-fgo-prefix} option used when the package is compiled; if the
 option is not used, the default is simply @code{go}.  To call the
 function from C you must set the name using the @command{gcc}
-extension similar to the @command{gccgo} extension.
+@code{__asm__} extension.
 
 @smallexample
 extern int go_function(int) __asm__ (myprefix.mypackage.Function);
Index: gcc/go/gofrontend/parse.cc
===
--- gcc/go/gofrontend/parse.cc	(revision 183814)
+++ gcc/go/gofrontend/parse.cc	(working copy)
@@ -2093,17 +2093,19 @@ Parse::simple_var_decl_or_assignment(con
 // FunctionDecl = func identifier Signature [ Block ] .
 // MethodDecl = func Receiver identifier Signature [ Block ] .
 
-// gcc extension:
+// Deprecated gcc extension:
 //   FunctionDecl = func identifier Signature
 //__asm__ ( string_lit ) .
 // This extension means a function whose real name is the identifier
-// inside the asm.
+// inside the asm.  This extension will be removed at some future
+// date.  It has been replaced with //extern comments.
 
 void
 Parse::function_decl()
 {
   go_assert(this-peek_token()-is_keyword(KEYWORD_FUNC));
   Location location = this-location();
+  std::string extern_name = this-lex_-extern_name();
   const Token* token = this-advance_token();
 
   Typed_identifier* rec = NULL;
@@ -2173,10 +2175,20 @@ Parse::function_decl()
 {
   if (named_object == NULL  !Gogo::is_sink_name(name))
 	{
-	  if (fntype != NULL)
-	this-gogo_-declare_function(name, fntype, location);
-	  else
+	  if (fntype == NULL)
 	this-gogo_-add_erroneous_name(name);
+	  else
+	{
+	  named_object = this-gogo_-declare_function(name, fntype,
+			   location);
+	  if (!extern_name.empty()
+		   named_object-is_function_declaration())
+		{
+		  Function_declaration* fd =
+		named_object-func_declaration_value();
+		  fd-set_asm_name(extern_name);
+		}
+	}
 	}
 }
   else
Index: gcc/go/gofrontend/lex.cc
===
--- gcc/go/gofrontend/lex.cc	(revision 183650)
+++ gcc/go/gofrontend/lex.cc	(working copy)
@@ -442,7 +442,7 @@ Token::print(FILE* file) const
 Lex::Lex(const char* input_file_name, FILE* input_file, Linemap* linemap)
   : input_file_name_(input_file_name), input_file_(input_file),
 linemap_(linemap), linebuf_(NULL), linebufsize_(120), linesize_(0),
-lineoff_(0), lineno_(0), add_semi_at_eol_(false)
+lineoff_(0), lineno_(0), add_semi_at_eol_(false), extern_()
 {
   this-linebuf_ = new char[this-linebufsize_];
   this-linemap_-start_file(input_file_name, 0);
@@ -541,6 

[Ada] Do not pass -Werror during linking

2012-02-07 Thread Eric Botcazou
This breaks LTO bootstrap because of warnings for apparently incompatible types 
at the interface between C and Ada.  Given that it's very likely not possible 
to fix them all, let's keep accepting them.

Tested on i586-suse-linux, applied on the mainline.


2012-02-07  Eric Botcazou  ebotca...@adacore.com

* gcc-interface/Make-lang.in (GCC_LINKERFLAGS): New variable.
(GCC_LINK): Use it.


-- 
Eric Botcazou
Index: gcc-interface/Make-lang.in
===
--- gcc-interface/Make-lang.in	(revision 183906)
+++ gcc-interface/Make-lang.in	(working copy)
@@ -165,7 +165,10 @@ else
   endif
 endif
 
-GCC_LINK=$(LINKER) $(ALL_LINKERFLAGS) -static-libgcc $(LDFLAGS)
+# Strip -Werror during linking for the LTO bootstrap
+GCC_LINKERFLAGS = $(filter-out -Werror, $(ALL_LINKERFLAGS))
+
+GCC_LINK=$(LINKER) $(GCC_LINKERFLAGS) -static-libgcc $(LDFLAGS)
 
 # Lists of files for various purposes.
 


RFA: Expand/update documentation on Epiphany interrupt attribute

2012-02-07 Thread Joern Rennecke

Tested by building 'info' for epiphany-elf, and by bootstrapping
x86_64-unknown-linux-gnu .
2012-02-07  Jeremy Bennett  jeremy.benn...@embecosm.com
Joern Rennecke  joern.renne...@embecosm.com

* doc/extend.texi: Expand and update information on interrupt
attribute for Epiphany.

Index: doc/extend.texi
===
--- doc/extend.texi (revision 183982)
+++ doc/extend.texi (working copy)
@@ -2727,7 +2727,8 @@ void bar (void)
 RL78, RX and Xstormy16 ports to indicate that the specified function is an
 interrupt handler.  The compiler will generate function entry and exit
 sequences suitable for use in an interrupt handler when this attribute
-is present.
+is present.  With Epiphany targets it may also generate a special section with
+code to initialize the interrupt vector table.
 
 Note, interrupt handlers for the Blackfin, H8/300, H8/300H, H8S, MicroBlaze,
 and SH processors can be specified via the @code{interrupt_handler} attribute.
@@ -2746,6 +2747,47 @@ void f () __attribute__ ((interrupt (IR
 On ARMv7-M the interrupt type is ignored, and the attribute means the function
 may be called with a word aligned stack pointer.
 
+On Epiphany targets one or more optional parameters may added like this:
+
+@smallexample
+void __attribute__ ((interrupt (dma0, dma1))) universal_dma_handler ();
+@end smallexample
+
+Permissible values for these parameters are: @w{@code{reset}},
+@w{@code{software_exception}}, @w{@code{page_miss}},
+@w{@code{timer0}}, @w{@code{timer1}}, @w{@code{message}},
+@w{@code{dma0}}, @w{@code{dma1}}, @w{@code{wand}} and @w{@code{swi}}.
+Multiple parameters indicate that multiple entries in the interrupt
+vector table should be initialized for this function.  The
+parameter(s) may be omitted entirely, in which case no interrupt
+vector table entry will be provided.
+
+Note, on Epiphany targets, interrupts are enabled inside the function
+unless the @code{disinterrupt} attribute is also specified.
+
+On Epiphany targets, you can also use the following attribute to
+modify the behavior of an interrupt handler:
+@table @code
+@item forwarder_section
+@cindex @code{forwarder_section} attribute
+The interrupt handler may be in external memory which cannot be
+reached by a branch instruction, so generate a local memory trampoline
+to transfer control.  The single parameter identifies the section where
+the trampoline will be placed.
+@end table
+
+The following examples are all valid uses of these attributes on
+Epiphany targets:
+@smallexample
+void __attribute__ ((interrupt)) universal_handler ();
+void __attribute__ ((interrupt (dma1))) dma1_handler ();
+void __attribute__ ((interrupt (dma0, dma1))) universal_dma_handler ();
+void __attribute__ ((interrupt (timer0), disinterrupt))
+  fast_timer_handler ();
+void __attribute__ ((interrupt (dma0, dma1), forwarder_section (tramp)))
+  external_dma_handler ();
+@end smallexample
+
 On MIPS targets, you can use the following attributes to modify the behavior
 of an interrupt handler:
 @table @code


New German PO file for 'gcc' (version 4.7-b20120128)

2012-02-07 Thread Translation Project Robot
Hello, gentle maintainer.

This is a message from the Translation Project robot.

A revised PO file for textual domain 'gcc' has been submitted
by the German team of translators.  The file is available at:

http://translationproject.org/latest/gcc/de.po

(This file, 'gcc-4.7-b20120128.de.po', has just now been sent to you in
a separate email.)

All other PO files for your package are available in:

http://translationproject.org/latest/gcc/

Please consider including all of these in your next release, whether
official or a pretest.

Whenever you have a new distribution with a new version number ready,
containing a newer POT file, please send the URL of that distribution
tarball to the address below.  The tarball may be just a pretest or a
snapshot, it does not even have to compile.  It is just used by the
translators when they need some extra translation context.

The following HTML page has been updated:

http://translationproject.org/domain/gcc.html

If any question arises, please contact the translation coordinator.

Thank you for all your work,

The Translation Project robot, in the
name of your translation coordinator.
coordina...@translationproject.org



[PATCH] Fix cfg_layout_merge_blocks (PR rtl-optimization/52139)

2012-02-07 Thread Jakub Jelinek
Hi!

On the following testcase we hit two bugs during cfglayout merge_blocks.

One is that b-il.rtl-header has some jumptable in it, followed by
barrier.  We call emit_insn_after_noloc to insert the whole b's header
after BB_END (a) and then delete_insn_chain it, with the intention that only
non-deletable insns like deleted label notes are kept around.  Unfortunately
delete_insn/remove_insn it uses isn't prepared to handle BARRIERs as part of
a bb (i.e. if BB_END is equal to some barrier because of the
emit_insn_after_noloc call, delete_insn_chain won't update BB_END properly).
As barriers aren't part of a BB, instead of adjusting remove_insn this patch
adjusts BB_END not to point to a barrier before calling delete_insn_chain.

The second bug is that remove_insn ICEs if deleting an insn with NEXT_INSN
NULL, unless that insn is part of a current sequence (or some sequence in
the sequence stack).  In the first version of the patch I've tried to
avoid calling delete_insn on insns that have NEXT_INSN NULL, but given that
having NULL NEXT_INSN is a pretty common situation when in cfglayout mode
if the insn is at BB_END, I think it is better to allow that in remove_insn.

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

2012-02-07  Jakub Jelinek  ja...@redhat.com

PR rtl-optimization/52139
* emit-rtl.c (remove_insn): Allow removing insns
with NEXT_INSN NULL, if they are at BB_END.
* cfgrtl.c (cfg_layout_merge_blocks): If BB_END
is a BARRIER after emit_insn_after_noloc, move BB_END
to the last non-BARRIER insn before it.  Cleanup.

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

--- gcc/emit-rtl.c.jj   2012-02-07 16:05:47.913534092 +0100
+++ gcc/emit-rtl.c  2012-02-07 16:14:32.529734964 +0100
@@ -1,7 +1,7 @@
 /* Emit RTL for the GCC expander.
Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
-   2010, 2011
+   2010, 2011, 2012
Free Software Foundation, Inc.
 
 This file is part of GCC.
@@ -3957,7 +3957,19 @@ remove_insn (rtx insn)
break;
  }
 
-  gcc_assert (stack);
+  if (stack == NULL)
+   {
+ /* In cfglayout mode allow remove_insn of
+insns at the end of bb.  */
+ if (BARRIER_P (insn))
+   {
+ gcc_assert (prev);
+ bb = BLOCK_FOR_INSN (prev);
+   }
+ else
+   bb = BLOCK_FOR_INSN (insn);
+ gcc_assert (bb  BB_END (bb) == insn);
+   }
 }
   if (!BARRIER_P (insn)
(bb = BLOCK_FOR_INSN (insn)))
--- gcc/cfgrtl.c.jj 2012-02-07 16:05:47.977533716 +0100
+++ gcc/cfgrtl.c2012-02-07 17:03:52.925956927 +0100
@@ -2818,6 +2818,7 @@ static void
 cfg_layout_merge_blocks (basic_block a, basic_block b)
 {
   bool forwarder_p = (b-flags  BB_FORWARDER_BLOCK) != 0;
+  rtx insn;
 
   gcc_checking_assert (cfg_layout_can_merge_blocks_p (a, b));
 
@@ -2871,6 +2872,11 @@ cfg_layout_merge_blocks (basic_block a,
   rtx first = BB_END (a), last;
 
   last = emit_insn_after_noloc (b-il.rtl-header, BB_END (a), a);
+  /* The above might add a BARRIER as BB_END, but as barriers
+aren't valid parts of a bb, remove_insn doesn't update
+BB_END if it is a barrier.  So adjust BB_END here.  */
+  while (BB_END (a) != first  BARRIER_P (BB_END (a)))
+   BB_END (a) = PREV_INSN (BB_END (a));
   delete_insn_chain (NEXT_INSN (first), last, false);
   b-il.rtl-header = NULL;
 }
@@ -2878,40 +2884,28 @@ cfg_layout_merge_blocks (basic_block a,
   /* In the case basic blocks are not adjacent, move them around.  */
   if (NEXT_INSN (BB_END (a)) != BB_HEAD (b))
 {
-  rtx first = unlink_insn_chain (BB_HEAD (b), BB_END (b));
+  insn = unlink_insn_chain (BB_HEAD (b), BB_END (b));
 
-  emit_insn_after_noloc (first, BB_END (a), a);
-  /* Skip possible DELETED_LABEL insn.  */
-  if (!NOTE_INSN_BASIC_BLOCK_P (first))
-   first = NEXT_INSN (first);
-  gcc_assert (NOTE_INSN_BASIC_BLOCK_P (first));
-  BB_HEAD (b) = NULL;
-
-  /* emit_insn_after_noloc doesn't call df_insn_change_bb.
- We need to explicitly call. */
-  update_bb_for_insn_chain (NEXT_INSN (first),
-   BB_END (b),
-   a);
-
-  delete_insn (first);
+  emit_insn_after_noloc (insn, BB_END (a), a);
 }
   /* Otherwise just re-associate the instructions.  */
   else
 {
-  rtx insn;
-
-  update_bb_for_insn_chain (BB_HEAD (b), BB_END (b), a);
-
   insn = BB_HEAD (b);
-  /* Skip possible DELETED_LABEL insn.  */
-  if (!NOTE_INSN_BASIC_BLOCK_P (insn))
-   insn = NEXT_INSN (insn);
-  gcc_assert (NOTE_INSN_BASIC_BLOCK_P (insn));
-  BB_HEAD (b) = NULL;
   BB_END (a) = BB_END (b);
-  delete_insn (insn);
 }
 
+  /* emit_insn_after_noloc doesn't call df_insn_change_bb.
+ We need to explicitly call. */
+  

Re: [PATCH][ARM] Improve 64-bit shifts (non-NEON)

2012-02-07 Thread Ramana Radhakrishnan
Hi Andrew

I find it interesting that cond_exec's in this form survive all the
way till reload and work.  AFAIK we could never have cond_exec's
before reload . The documentation doesn't appear to mention this,
therefore I would like to see if  the cond_exec's can be recast as
if_then_else forms from expand rather than these forms. Has this
survived bootstrap and testing ?


 +  /* If we're optimizing for size, we prefer the libgcc calls.  */
 +  if (optimize_size)
 + FAIL;

In addition you want to replace optimize_size with
optimize_function_for_size_p in these cases.

cheers
Ramana


[v3] remove duplicate target selectors

2012-02-07 Thread Jonathan Wakely
I added powerpc-ibm-aix* to some tests twice with an overzealous sed
command, this fixes it.

* testsuite/30_threads/call_once/39909.cc: Remove duplicate target
selector.
* testsuite/30_threads/call_once/49668.cc: Likewise.
* testsuite/30_threads/call_once/call_once1.cc: Likewise.
* testsuite/30_threads/lock_guard/cons/1.cc: Likewise.
* testsuite/30_threads/mutex/cons/1.cc: Likewise.
* testsuite/30_threads/mutex/dest/destructor_locked.cc: Likewise.
* testsuite/30_threads/mutex/lock/1.cc: Likewise.
* testsuite/30_threads/mutex/native_handle/1.cc: Likewise.
* testsuite/30_threads/mutex/native_handle/typesizes.cc: Likewise.
* testsuite/30_threads/mutex/try_lock/1.cc: Likewise.
* testsuite/30_threads/mutex/try_lock/2.cc: Likewise.
* testsuite/30_threads/mutex/unlock/1.cc: Likewise.
* testsuite/30_threads/unique_lock/cons/1.cc: Likewise.
* testsuite/30_threads/unique_lock/cons/2.cc: Likewise.
* testsuite/30_threads/unique_lock/cons/3.cc: Likewise.
* testsuite/30_threads/unique_lock/cons/4.cc: Likewise.
* testsuite/30_threads/unique_lock/cons/5.cc: Likewise.
* testsuite/30_threads/unique_lock/cons/6.cc: Likewise.
* testsuite/30_threads/unique_lock/locking/1.cc: Likewise.
* testsuite/30_threads/unique_lock/locking/2.cc: Likewise.
* testsuite/30_threads/unique_lock/locking/3.cc: Likewise.
* testsuite/30_threads/unique_lock/locking/4.cc: Likewise.
* testsuite/30_threads/unique_lock/modifiers/1.cc: Likewise.
* testsuite/30_threads/unique_lock/modifiers/2.cc: Likewise.

Tested x86_64-linux, committed to trunk.
commit 0f1a49a4c5b815e332ec76741b33c6366ecb63e2
Author: Jonathan Wakely jwakely@gmail.com
Date:   Tue Feb 7 21:43:52 2012 +

* testsuite/30_threads/call_once/39909.cc: Remove duplicate target
selector.
* testsuite/30_threads/call_once/49668.cc: Likewise.
* testsuite/30_threads/call_once/call_once1.cc: Likewise.
* testsuite/30_threads/lock_guard/cons/1.cc: Likewise.
* testsuite/30_threads/mutex/cons/1.cc: Likewise.
* testsuite/30_threads/mutex/dest/destructor_locked.cc: Likewise.
* testsuite/30_threads/mutex/lock/1.cc: Likewise.
* testsuite/30_threads/mutex/native_handle/1.cc: Likewise.
* testsuite/30_threads/mutex/native_handle/typesizes.cc: Likewise.
* testsuite/30_threads/mutex/try_lock/1.cc: Likewise.
* testsuite/30_threads/mutex/try_lock/2.cc: Likewise.
* testsuite/30_threads/mutex/unlock/1.cc: Likewise.
* testsuite/30_threads/unique_lock/cons/1.cc: Likewise.
* testsuite/30_threads/unique_lock/cons/2.cc: Likewise.
* testsuite/30_threads/unique_lock/cons/3.cc: Likewise.
* testsuite/30_threads/unique_lock/cons/4.cc: Likewise.
* testsuite/30_threads/unique_lock/cons/5.cc: Likewise.
* testsuite/30_threads/unique_lock/cons/6.cc: Likewise.
* testsuite/30_threads/unique_lock/locking/1.cc: Likewise.
* testsuite/30_threads/unique_lock/locking/2.cc: Likewise.
* testsuite/30_threads/unique_lock/locking/3.cc: Likewise.
* testsuite/30_threads/unique_lock/locking/4.cc: Likewise.
* testsuite/30_threads/unique_lock/modifiers/1.cc: Likewise.
* testsuite/30_threads/unique_lock/modifiers/2.cc: Likewise.

diff --git a/libstdc++-v3/testsuite/30_threads/call_once/39909.cc 
b/libstdc++-v3/testsuite/30_threads/call_once/39909.cc
index d3b4e7f..3fced50 100644
--- a/libstdc++-v3/testsuite/30_threads/call_once/39909.cc
+++ b/libstdc++-v3/testsuite/30_threads/call_once/39909.cc
@@ -1,5 +1,5 @@
-// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* 
*-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* powerpc-ibm-aix* 
powerpc-ibm-aix* } }
-// { dg-options  -std=gnu++0x -pthread { target *-*-freebsd* *-*-netbsd* 
*-*-linux* alpha*-*-osf* mips-sgi-irix6* powerpc-ibm-aix* powerpc-ibm-aix* } }
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* 
*-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* powerpc-ibm-aix* } }
+// { dg-options  -std=gnu++0x -pthread { target *-*-freebsd* *-*-netbsd* 
*-*-linux* alpha*-*-osf* mips-sgi-irix6* powerpc-ibm-aix* } }
 // { dg-options  -std=gnu++0x -pthreads { target *-*-solaris* } }
 // { dg-options  -std=gnu++0x  { target *-*-cygwin *-*-darwin* } }
 // { dg-require-cstdint  }
diff --git a/libstdc++-v3/testsuite/30_threads/call_once/49668.cc 
b/libstdc++-v3/testsuite/30_threads/call_once/49668.cc
index d6045d0..63b15c7 100644
--- a/libstdc++-v3/testsuite/30_threads/call_once/49668.cc
+++ b/libstdc++-v3/testsuite/30_threads/call_once/49668.cc
@@ -1,5 +1,5 @@
-// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-solaris* 
*-*-cygwin *-*-darwin* alpha*-*-osf* mips-sgi-irix6* powerpc-ibm-aix* 
powerpc-ibm-aix* } }
-// { dg-options  -std=gnu++0x -pthread { 

[committed] hppa testsuite cleanups

2012-02-07 Thread John David Anglin
The patch implements suggestions made by Andreas Schwab.  Tested on
hppa2.0w-hp-hpux11.11 and hppa64-hp-hpux11.11.  Committed to trunk.

Dave
-- 
J. David Anglin  dave.ang...@nrc-cnrc.gc.ca
National Research Council of Canada  (613) 990-0752 (FAX: 952-6602)

2012-02-07  John David Anglin  dave.ang...@nrc-cnrc.gc.ca

* gfortran.dg/guality/pr41558.f90: Use lp64 instead of hppa*64*-*-*.
* gcc.dg/special/weak-1.c: Likewise.
* gcc.dg/ucnid-12.c: Likewise.
* gcc.dg/torture/pr45678-1.c: Likewise.
* gcc.dg/torture/pr45678-2.c: Likewise.
* gcc.dg/vector-4.c: Likewise.
* gcc.dg/ipa/inline-5.c: Likewise.
* gcc.dg/ucnid-11.c: Likewise.
* gcc.misc-tests/gcov-13.c: Likewise.
* gcc.misc-tests/gcov-14.c: Likewise.
* g++.dg/ext/label13.C: Likewise.
* gcc.dg/tree-ssa/ssa-fre-31.c: Use dg-additional-options for extra
hppa*-*-hpux* options.
* gcc.dg/tree-ssa/ssa-fre-33.c: Likewise.
* gcc.dg/tree-ssa/ssa-fre-34.c: Likewise.
* gcc.dg/pr48616.c: Likewise.
* gcc.dg/pr17957.c: Likewise.
* gcc.dg/pr17055-1.c: Likewise.
* gcc.dg/pr32912-1.c: Likewise.
* gcc.dg/tm/pr51472.c: Likewise.
* c-c++-common/fold-bitand-4.c: Likewise.
* c-c++-common/Wunused-var-12.c: Use lp64 instead of hppa*64*-*-*.
Use dg-additional-options for extra options.

Index: gfortran.dg/guality/pr41558.f90
===
--- gfortran.dg/guality/pr41558.f90 (revision 183951)
+++ gfortran.dg/guality/pr41558.f90 (working copy)
@@ -1,6 +1,6 @@
 ! PR debug/41558
 ! { dg-do run }
-! { dg-skip-if PR testsuite/51875 { { hppa*-*-hpux* }  { ! hppa*64*-*-* } 
} { * } {  } }
+! { dg-skip-if PR testsuite/51875 { { hppa*-*-hpux* }  { ! lp64 } } { * 
} {  } }
 ! { dg-options -g }
 
 subroutine f (s)
Index: gcc.dg/special/weak-1.c
===
--- gcc.dg/special/weak-1.c (revision 183951)
+++ gcc.dg/special/weak-1.c (working copy)
@@ -1,4 +1,4 @@
-/* { dg-do run { xfail { hppa*-*-hpux*  { ! hppa*64*-*-* } } } } */
+/* { dg-do run { xfail { hppa*-*-hpux*  { ! lp64 } } } } */
 /* { dg-require-weak  } */
 /* { dg-additional-sources weak-1a.c } */
 /* See PR target/23387 for hppa xfail details.  */
Index: gcc.dg/ucnid-12.c
===
--- gcc.dg/ucnid-12.c   (revision 183951)
+++ gcc.dg/ucnid-12.c   (working copy)
@@ -1,7 +1,7 @@
 /* { dg-do run } */
 /* { dg-xfail-if  { powerpc-ibm-aix* } { * } {  } } */
 /* { dg-skip-if  { ! ucn } { * } {  } } */
-/* { dg-skip-if -ffunction-sections not supported { { hppa*-*-hpux* }  { ! 
hppa*64*-*-* } } { * } {  } } */
+/* { dg-skip-if -ffunction-sections not supported { { hppa*-*-hpux* }  { ! 
lp64 } } { * } {  } } */
 /* { dg-options -std=c99 -fextended-identifiers -ffunction-sections } */
 
 #include ucnid-4.c
Index: gcc.dg/torture/pr45678-1.c
===
--- gcc.dg/torture/pr45678-1.c  (revision 183951)
+++ gcc.dg/torture/pr45678-1.c  (working copy)
@@ -1,5 +1,5 @@
 /* { dg-do run } */
-/* { dg-options -fno-common { target { { hppa*-*-hpux* }  { ! hppa*64*-*-* 
} } } } */
+/* { dg-options -fno-common { target { { hppa*-*-hpux* }  { ! lp64 } } } } 
*/
 
 typedef float V __attribute__ ((vector_size (16)));
 V g;
Index: gcc.dg/torture/pr45678-2.c
===
--- gcc.dg/torture/pr45678-2.c  (revision 183951)
+++ gcc.dg/torture/pr45678-2.c  (working copy)
@@ -1,5 +1,5 @@
 /* { dg-do run } */
-/* { dg-options -fno-common { target { { hppa*-*-hpux* }  { ! hppa*64*-*-* 
} } } } */
+/* { dg-options -fno-common { target { { hppa*-*-hpux* }  { ! lp64 } } } } 
*/
 
 typedef float V __attribute__ ((vector_size (16)));
 V g;
Index: gcc.dg/tree-ssa/ssa-fre-31.c
===
--- gcc.dg/tree-ssa/ssa-fre-31.c(revision 183951)
+++ gcc.dg/tree-ssa/ssa-fre-31.c(working copy)
@@ -1,6 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options -O -fdump-tree-fre1-details } */
-/* { dg-options -O -fdump-tree-fre1-details -fno-common { target 
hppa*-*-hpux* } } */
+/* { dg-additional-options -fno-common { target hppa*-*-hpux* } } */
 
 typedef double d128 __attribute__((vector_size(16)));
 typedef float f128 __attribute__((vector_size(16)));
Index: gcc.dg/tree-ssa/ssa-fre-33.c
===
--- gcc.dg/tree-ssa/ssa-fre-33.c(revision 183951)
+++ gcc.dg/tree-ssa/ssa-fre-33.c(working copy)
@@ -1,6 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options -O -fdump-tree-fre1-details } */
-/* { dg-options -O -fdump-tree-fre1-details -fno-common { target 
hppa*-*-hpux* } } */
+/* { dg-additional-options -fno-common { target hppa*-*-hpux* } } 

Re: [PATCH][ARM] Improve 64-bit shifts (non-NEON)

2012-02-07 Thread Steven Bosscher
On Tue, Feb 7, 2012 at 11:19 PM, Ramana Radhakrishnan
ramana.radhakrish...@linaro.org wrote:
 Hi Andrew

 I find it interesting that cond_exec's in this form survive all the
 way till reload and work.  AFAIK we could never have cond_exec's
 before reload .

There is nothing wrong per-se with cond_execs before reload, as long
as you don't have to reload a predicate pseudo-reg. For ia64, with its
(IIRC) 64 predicate registers, it was not practical, or even possible,
to assign the predicate registers to hard regs during expand.

AFAIU this isn't an issue on ARM because there is just one condition
code register.

Ciao!
Steven


[Patch, fortran] PR50981 (elemental/optional interaction) follow-up fix

2012-02-07 Thread Mikael Morin

Hello,

this fixes the fairly recent PR50981 patch
[http://gcc.gnu.org/ml/fortran/2011-12/msg00170.html] which didn't work 
for subroutine calls, as they use code-resolved_sym instead of 
code-expr1 to store the procedure symbol.



The first patch moves gfc_walk_elemental_function_args's code to get the 
procedure interface into a new procedure.


The second patch moves the procedure call out of 
gfc_walk_elemental_function_args.


The third patch changes the function called in gfc_trans_call so that 
code-resolved_sym is used if code-expr1 fails to give the interface.
I choose to try code-expr1 first for fear that in typebound calls, 
code-resolved_sym may point to the base object, which is obviously not 
the procedure interface.


The testcase is Tobias' comment #13
[http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50981#c13] stripped down to 
the working part.


Regression tested on x86_64-unknown-freebsd9.0. OK for trunk?

Mikael







2012-02-07  Mikael Morin  mik...@gcc.gnu.org

* trans-array.c (gfc_get_proc_ifc_for_expr): New function.
(gfc_walk_elemental_function_args): Move code to
gfc_get_proc_ifc_for_expr and call it.


diff --git a/trans-array.c b/trans-array.c
index d3c81a8..2584e78 100644
--- a/trans-array.c
+++ b/trans-array.c
@@ -8427,6 +8427,36 @@ gfc_reverse_ss (gfc_ss * ss)
 }
 
 
+/* Given an expression refering to a procedure, return the symbol of its
+   interface.  We can't get the procedure symbol directly as we have to handle
+   the case of (deferred) type-bound procedures.  */
+
+gfc_symbol *
+gfc_get_proc_ifc_for_expr (gfc_expr *procedure_ref)
+{
+  gfc_symbol *sym;
+  gfc_ref *ref;
+
+  if (procedure_ref == NULL)
+return NULL;
+
+  /* Normal procedure case.  */
+  sym = procedure_ref-symtree-n.sym;
+
+  /* Typebound procedure case.  */
+  for (ref = procedure_ref-ref; ref; ref = ref-next)
+{
+  if (ref-type == REF_COMPONENT
+	   ref-u.c.component-attr.proc_pointer)
+	sym = ref-u.c.component-ts.interface;
+  else
+	sym = NULL;
+}
+
+  return sym;
+}
+
+
 /* Walk the arguments of an elemental function.
PROC_EXPR is used to check whether an argument is permitted to be absent.  If
it is NULL, we don't do the check and the argument is assumed to be present.
@@ -8436,6 +8466,7 @@ gfc_ss *
 gfc_walk_elemental_function_args (gfc_ss * ss, gfc_actual_arglist *arg,
   gfc_expr *proc_expr, gfc_ss_type type)
 {
+  gfc_symbol *proc_ifc;
   gfc_formal_arglist *dummy_arg;
   int scalar;
   gfc_ss *head;
@@ -8445,24 +8476,9 @@ gfc_walk_elemental_function_args (gfc_ss * ss, gfc_actual_arglist *arg,
   head = gfc_ss_terminator;
   tail = NULL;
 
-  if (proc_expr)
-{
-  gfc_ref *ref;
-
-  /* Normal procedure case.  */
-  dummy_arg = proc_expr-symtree-n.sym-formal;
-
-  /* Typebound procedure case.  */
-  for (ref = proc_expr-ref; ref; ref = ref-next)
-	{
-	  if (ref-type == REF_COMPONENT
-	   ref-u.c.component-attr.proc_pointer
-	   ref-u.c.component-ts.interface)
-	dummy_arg = ref-u.c.component-ts.interface-formal;
-	  else
-	dummy_arg = NULL;
-	}
-}
+  proc_ifc = gfc_get_proc_ifc_for_expr (proc_expr);
+  if (proc_ifc)
+dummy_arg = proc_ifc-formal;
   else
 dummy_arg = NULL;
 


2012-02-07  Mikael Morin  mik...@gcc.gnu.org

* trans-array.c (gfc_walk_elemental_function_args,
gfc_walk_function_expr): Move call to gfc_get_proc_ifc_for_expr out
of gfc_walk_elemental_function_args.
* trans-stmt.c (gfc_trans_call): Ditto.
* trans-array.h (gfc_get_proc_ifc_for_expr): New prototype.
(gfc_walk_elemental_function_args): Update prototype.


diff --git a/trans-array.c b/trans-array.c
index 2584e78..de6fa13 100644
--- a/trans-array.c
+++ b/trans-array.c
@@ -8464,9 +8464,8 @@ gfc_get_proc_ifc_for_expr (gfc_expr *procedure_ref)
 
 gfc_ss *
 gfc_walk_elemental_function_args (gfc_ss * ss, gfc_actual_arglist *arg,
-  gfc_expr *proc_expr, gfc_ss_type type)
+  gfc_symbol *proc_ifc, gfc_ss_type type)
 {
-  gfc_symbol *proc_ifc;
   gfc_formal_arglist *dummy_arg;
   int scalar;
   gfc_ss *head;
@@ -8476,7 +8475,6 @@ gfc_walk_elemental_function_args (gfc_ss * ss, gfc_actual_arglist *arg,
   head = gfc_ss_terminator;
   tail = NULL;
 
-  proc_ifc = gfc_get_proc_ifc_for_expr (proc_expr);
   if (proc_ifc)
 dummy_arg = proc_ifc-formal;
   else
@@ -8566,7 +8564,8 @@ gfc_walk_function_expr (gfc_ss * ss, gfc_expr * expr)
  by reference.  */
   if (sym-attr.elemental || (comp  comp-attr.elemental))
 return gfc_walk_elemental_function_args (ss, expr-value.function.actual,
-	 expr, GFC_SS_REFERENCE);
+	 gfc_get_proc_ifc_for_expr (expr),
+	 GFC_SS_REFERENCE);
 
   /* Scalar functions are OK as these are evaluated outside the scalarization
  loop.  Pass back and let the caller deal with it.  */
diff --git a/trans-array.h b/trans-array.h
index 6ca630e..9bafb94 100644
--- a/trans-array.h
+++ b/trans-array.h
@@ -66,6 +66,8 @@ void 

Re: [PATCH] PR48524 spec language does not cover switches with separated form

2012-02-07 Thread Magnus Granberg
tisdag 20 december 2011 22.56.45 skrev du:
 On Tue, 20 Dec 2011, Magnus Granberg wrote:
  This patch make -D and -U work in the spec language, bug pr48524.
  Tested on x86_64-unknown-linux-gnu snapshot 4.7-20111217
 
 Thanks for your contributions.  As you've contributed before, this patch
 brings things to about the point where a copyright assignment will be
 needed.  Please see http://gcc.gnu.org/wiki/CopyrightAssignment for the
 information to send to the FSF to get the assignment form.

The copyright assignment is done. (718297)
Wait for gcc 4.8?
/Magnus


Re: [PATCH][4.8] C++ memory model bitfield handling rewrite

2012-02-07 Thread Hans-Peter Nilsson
On Tue, 7 Feb 2012, Richard Guenther wrote:
 The following patch rewrites the bitfield handling of the C++ memory
 model and enables it unconditionally to fix PR52080.  As I suggested
 earlier at some point this moves computation of what the memory model
 considers the underlying object we may access to the point where we
 lay out a structure type.  This allows other passes like for example
 SRA or a new bitfield lowering pass to use a canonical (and correct)
 addressable object to access bitfields.  The underlying object is
 represented as a FIELD_DECL that would be a suitable replacement
 for all bitfield FIELD_DECLs if you wrap it inside a BIT_FIELD_REF
 (see the gimplify.c hunk).  But the main purpose (for now) is to
 make use of it in get_bit_range which no longer needs to walk
 all fields of a record nor build new trees or use get_inner_reference.

Please excuse an ignorant question: is there somewhere in that
new code where you should consider target bitfield layout macros
like EMPTY_FIELD_BOUNDARY and PCC_BITFIELD_TYPE_MATTERS?
(Just guessing: alignment.)  Or maybe that's a later stage?

brgds, H-P


Re: [patch] avoid '//' prefixes when sysroot is set to '/'

2012-02-07 Thread Matthias Klose

On 26.01.2012 18:57, Joseph S. Myers wrote:

On Thu, 26 Jan 2012, Matthias Klose wrote:


On 25.01.2012 17:45, Joseph S. Myers wrote:

On Wed, 25 Jan 2012, Matthias Klose wrote:


This can end up in generation for dependency files, and other files
parsing
the output. The solution I came up with is to check for sysroot set to '/'
and
special case this in two places. Afaics, there are no other places.


I could imagine a sysroot path that isn't just '/' but ends with '/'
resulting in duplicate '/' in the middle of the path - although that's not
a correctness issue in the way that '//' at the start could be, maybe the
best check is actually for '/' at end of sysroot (in which case skip the
'/' at the start of the path within the sysroot)?


as in the attached trailing.diff? built and regression tested.


Yes, that's OK (with copyright date updates in incpath.c).


there is one more issue, when configuring

 --with-sysroot=/ --with-gxx-include-dir=/usr/include/c++/4.7

in that the leading / is stripped away in configure.ac. This case needs an 
explicit check. Ok for the trunk?


  Matthias

* configure.ac (gcc_gxx_include_dir): Don't strip a `/' sysroot value.
--- a/src/gcc/configure.ac
+++ b/src/gcc/configure.ac
@@ -149,7 +149,9 @@
 if test ${with_sysroot+set} = set; then
   gcc_gxx_without_sysroot=`expr ${gcc_gxx_include_dir} : 
${with_sysroot}'\(.*\)'`
   if test ${gcc_gxx_without_sysroot}; then
-gcc_gxx_include_dir=${gcc_gxx_without_sysroot}
+if test x${with_sysroot} != x/; then
+  gcc_gxx_include_dir=${gcc_gxx_without_sysroot}
+fi
 gcc_gxx_include_dir_add_sysroot=1
   fi
 fi


Re: [PATCH] increase timeout in simulate-thread gdb test

2012-02-07 Thread Jack Howarth
On Wed, Dec 07, 2011 at 08:09:06PM +0100, Uros Bizjak wrote:
 On Wed, Dec 7, 2011 at 7:58 PM, Iain Sandoe
 develo...@sandoe-acoustics.co.uk wrote:
 
  Currently we are failing...
 
  FAIL: gcc.dg/simulate-thread/atomic-load-int128.c  -O1 -g  thread
  simulation test
  FAIL: gcc.dg/simulate-thread/atomic-load-int128.c  -O2 -g  thread
  simulation test
  FAIL: gcc.dg/simulate-thread/atomic-load-int128.c  -O3 -g  thread
  simulation test
  FAIL: gcc.dg/simulate-thread/atomic-load-int128.c  -Os -g  thread
  simulation test
 
  on x86_64-apple-darwin11 due to the 10 second timeout in simulate-thread
  of
  gcc/testsuite/lib/gcc-simulate-thread.exp. Increasing this timeout to 20
  seconds
  eliminates the failures (as these test take ~16 seconds on
  x86_64-apple-darwin11).
  Okay for gcc trunk?
 
 
  if it's only one test can't you use { dg-timeout-factor 2.0  ?
 
 
  As said elsewhere, this will double the amount of already large
  logfile in case of failed test.
 
  Do we really need such detailed log?
 
 
  anything to optimize what's in the logs would be welcome in debugging
 
 I fully agree, but it is trivial to re-run the test in the debugger
 outside the testsuite run. IMO, logging a couple of lines for
 execution of every instruction (in a loop!) is a bit excessive.
 
 Uros.

Any chance we can get some sort of fix into FSF gcc 4.7 for this issue?
FYI, it appears that the current setup of gcc-simulate-thread.exp doesn't honor
the use of { dg-timeout-factor 2.0 } as written. Only manually increasing the
time to 20, per the originally proposed patch, works.
   Jack




[wwwdocs] update gcc-4.7/changes.html

2012-02-07 Thread Jonathan Wakely
Add note on thread improvements to libstdc++ changes.

Committed to cvs.
Index: changes.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-4.7/changes.html,v
retrieving revision 1.75
diff -u -r1.75 changes.html
--- changes.html5 Feb 2012 15:11:23 -   1.75
+++ changes.html8 Feb 2012 00:42:40 -
@@ -412,6 +412,7 @@
  li uses-allocator construction for codetuple/code; /li
  li codevector/code meets the allocator-aware container 
requirements; /li
  li replacing codemonotonic_clock/code with 
codesteady_clock/code; /li
+ li enabling the thread support library on a wider range of targets; 
/li
  li many small improvements to conform to the FDIS. /li
/ul
  /li


Re: [PATCH] increase timeout in simulate-thread gdb test

2012-02-07 Thread Mike Stump
On Dec 7, 2011, at 10:43 AM, Jack Howarth wrote:
 Currently we are failing...
 
 FAIL: gcc.dg/simulate-thread/atomic-load-int128.c  -O1 -g  thread simulation 
 test
 FAIL: gcc.dg/simulate-thread/atomic-load-int128.c  -O2 -g  thread simulation 
 test
 FAIL: gcc.dg/simulate-thread/atomic-load-int128.c  -O3 -g  thread simulation 
 test
 FAIL: gcc.dg/simulate-thread/atomic-load-int128.c  -Os -g  thread simulation 
 test
 
 on x86_64-apple-darwin11 due to the 10 second timeout in simulate-thread of
 gcc/testsuite/lib/gcc-simulate-thread.exp. Increasing this timeout to 20 
 seconds
 eliminates the failures (as these test take ~16 seconds on 
 x86_64-apple-darwin11).
 Okay for gcc trunk?

Ok.  Ok for 4.7.


Re: [patch] avoid '//' prefixes when sysroot is set to '/'

2012-02-07 Thread Joseph S. Myers
On Wed, 8 Feb 2012, Matthias Klose wrote:

 there is one more issue, when configuring
 
  --with-sysroot=/ --with-gxx-include-dir=/usr/include/c++/4.7
 
 in that the leading / is stripped away in configure.ac. This case needs an
 explicit check. Ok for the trunk?

This looks like a case where any sysroot with a trailing '/' could 
misbehave and remove a leading '/' that should be left there, i.e. where 
gcc_gxx_without_sysroot should be computed in a way that ignores any 
trailing '/' on the sysroot setting.  Or is such a removal actually 
harmless in all cases except for plain '/' as the sysroot?

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


Re: [patch] avoid '//' prefixes when sysroot is set to '/'

2012-02-07 Thread Matthias Klose

On 08.02.2012 02:01, Joseph S. Myers wrote:

On Wed, 8 Feb 2012, Matthias Klose wrote:


there is one more issue, when configuring

  --with-sysroot=/ --with-gxx-include-dir=/usr/include/c++/4.7

in that the leading / is stripped away in configure.ac. This case needs an
explicit check. Ok for the trunk?


This looks like a case where any sysroot with a trailing '/' could
misbehave and remove a leading '/' that should be left there, i.e. where
gcc_gxx_without_sysroot should be computed in a way that ignores any
trailing '/' on the sysroot setting.  Or is such a removal actually
harmless in all cases except for plain '/' as the sysroot?


not harmless, but not seen unless you pass --sysroot=path with trailing / to 
the driver. so lets strip the trailing / as well.


this requires that the definition for
  AC_ARG_WITH(sysroot, ...)
is moved before the use of the fixed with_sysroot before checking with_sysroot 
in the gcc_gxx_without_sysroot check.


  Matthias
* configure.ac: Move AC_ARG_WITH checks for native-system-header-dir,
build-sysroot, sysroot from the `Miscenalleous configure options'
to the `Directories' section.

Index: gcc/configure.ac
===
--- gcc/configure.ac(revision 183991)
+++ gcc/configure.ac(working copy)
@@ -118,6 +118,68 @@
local_prefix=/usr/local
 fi
 
+AC_ARG_WITH([native-system-header-dir],
+  [  --with-native-system-header-dir=dir
+  use dir as the directory to look for standard
+  system header files in.  Defaults to /usr/include.],
+[
+ case ${with_native_system_header_dir} in
+ yes|no) AC_MSG_ERROR([bad value ${withval} given for 
--with-native-system-header-dir]) ;;
+ /* | [[A-Za-z]]:[[\\/]]*) ;;
+ *) AC_MSG_ERROR([--with-native-system-header-dir argument ${withval} must be 
an absolute directory]) ;;
+ esac
+ configured_native_system_header_dir=${withval}
+], [configured_native_system_header_dir=])
+
+AC_ARG_WITH(build-sysroot, 
+  [AS_HELP_STRING([--with-build-sysroot=sysroot],
+  [use sysroot as the system root during the build])],
+  [if test x$withval != x ; then
+ SYSROOT_CFLAGS_FOR_TARGET=--sysroot=$withval
+   fi],
+  [SYSROOT_CFLAGS_FOR_TARGET=])
+AC_SUBST(SYSROOT_CFLAGS_FOR_TARGET)
+
+AC_ARG_WITH(sysroot,
+[AS_HELP_STRING([[--with-sysroot[=DIR]]],
+   [search for usr/lib, usr/include, et al, within DIR])],
+[
+ case ${with_sysroot} in
+ yes) TARGET_SYSTEM_ROOT='${exec_prefix}/${target_noncanonical}/sys-root' ;;
+ *) TARGET_SYSTEM_ROOT=$with_sysroot ;;
+ esac
+   
+ TARGET_SYSTEM_ROOT_DEFINE='-DTARGET_SYSTEM_ROOT=\$(TARGET_SYSTEM_ROOT)\'
+ 
CROSS_SYSTEM_HEADER_DIR='$(TARGET_SYSTEM_ROOT)$${sysroot_headers_suffix}$(NATIVE_SYSTEM_HEADER_DIR)'
+   
+ if test x$prefix = xNONE; then
+  test_prefix=/usr/local
+ else
+  test_prefix=$prefix
+ fi
+ if test x$exec_prefix = xNONE; then
+  test_exec_prefix=$test_prefix
+ else
+  test_exec_prefix=$exec_prefix
+ fi
+ case ${TARGET_SYSTEM_ROOT} in
+ ${test_prefix}|${test_prefix}/*|\
+ ${test_exec_prefix}|${test_exec_prefix}/*|\
+ '${prefix}'|'${prefix}/'*|\
+ '${exec_prefix}'|'${exec_prefix}/'*)
+   t=$TARGET_SYSTEM_ROOT_DEFINE -DTARGET_SYSTEM_ROOT_RELOCATABLE
+   TARGET_SYSTEM_ROOT_DEFINE=$t
+   ;;
+ esac
+], [
+ TARGET_SYSTEM_ROOT=
+ TARGET_SYSTEM_ROOT_DEFINE=
+ CROSS_SYSTEM_HEADER_DIR='$(gcc_tooldir)/sys-include'
+])
+AC_SUBST(TARGET_SYSTEM_ROOT)
+AC_SUBST(TARGET_SYSTEM_ROOT_DEFINE)
+AC_SUBST(CROSS_SYSTEM_HEADER_DIR)
+
 # Don't set gcc_gxx_include_dir to gxx_include_dir since that's only
 # passed in by the toplevel make and thus we'd get different behavior
 # depending on where we built the sources.
@@ -739,68 +801,6 @@
 ], [enable_shared=yes])
 AC_SUBST(enable_shared)
 
-AC_ARG_WITH([native-system-header-dir],
-  [  --with-native-system-header-dir=dir
-  use dir as the directory to look for standard
-  system header files in.  Defaults to /usr/include.],
-[
- case ${with_native_system_header_dir} in
- yes|no) AC_MSG_ERROR([bad value ${withval} given for 
--with-native-system-header-dir]) ;;
- /* | [[A-Za-z]]:[[\\/]]*) ;;
- *) AC_MSG_ERROR([--with-native-system-header-dir argument ${withval} must be 
an absolute directory]) ;;
- esac
- configured_native_system_header_dir=${withval}
-], [configured_native_system_header_dir=])
-
-AC_ARG_WITH(build-sysroot, 
-  [AS_HELP_STRING([--with-build-sysroot=sysroot],
-  [use sysroot as the system root during the build])],
-  [if test x$withval != x ; then
- SYSROOT_CFLAGS_FOR_TARGET=--sysroot=$withval
-   fi],
-  [SYSROOT_CFLAGS_FOR_TARGET=])
-AC_SUBST(SYSROOT_CFLAGS_FOR_TARGET)
-
-AC_ARG_WITH(sysroot,
-[AS_HELP_STRING([[--with-sysroot[=DIR]]],
-   [search for usr/lib, usr/include, et al, within DIR])],
-[
- case ${with_sysroot} in
- yes) TARGET_SYSTEM_ROOT='${exec_prefix}/${target_noncanonical}/sys-root' ;;
- *) 

[trans-mem,darwin] PR/52042 find tm_clone_table with PIE

2012-02-07 Thread Patrick Marlier

Hi,

The problem in this PR is that with PIE, getsectdata does not return the 
position of tm_clone_table after the relocation.
While _dyld_get_image_vmaddr_slide(0) is enough for PIE, this is not 
enough for dylib.
I did not find an easy API function to get position of the 
tm_clone_table for a shared library (dylib). So the only way I found is 
to get the mach_header address of the current dylib (via 
_dyld_get_image_header_containing_address), iterate over loaded binaries 
to find the current shared library and use _dyld_get_image_vmaddr_slide 
to find the position.

Any other proposal (my knowledge of darwin is really limited)?

Can someone do a bootstrap and test libitm on darwin (I have a limited 
access to a darwin machine, at least libitm tests pass)? Thanks!


If tests passed, ok for 4.7?
--
Patrick Marlier.
libgcc:

PR libitm/52042
* config/darwin-crt-tm.c: Changes for PIE and shared library.

Index: config/darwin-crt-tm.c
===
--- config/darwin-crt-tm.c	(revision 183968)
+++ config/darwin-crt-tm.c	(working copy)
@@ -26,8 +26,20 @@ see the files COPYING3 and COPYING.RUNTIME respect
 #include mach-o/dyld.h
 
 /* not listed in mach-o/dyld.h for some reason.  */
-extern char * getsectdata (const char*,const char*,unsigned long*); 
+extern char *getsectdatafromheader (struct mach_header*, const char*,
+const char*, unsigned long*);
+extern char *getsectdatafromheader_64 (struct mach_header_64*, const char*,
+   const char*, unsigned long*);
 
+#ifdef __LP64__
+#define GET_DATA_TMCT(mh,size) \
+  getsectdatafromheader_64 ((struct mach_header_64*) mh, \
+			__DATA, __tm_clone_table, size)
+#else
+#define GET_DATA_TMCT(mh,size) \
+  getsectdatafromheader (mh, __DATA, __tm_clone_table, size)
+#endif
+
 #define WEAK __attribute__((weak))
 
 extern void _ITM_registerTMCloneTable (void *, size_t) WEAK;
@@ -39,17 +51,27 @@ void __doTMRegistrations (void) __attribute__ ((co
 
 void __doTMRegistrations (void)
 {
-  char * tm_clone_table_sect_data;
+  struct mach_header *mh;
+  char *tmct_fixed, *tmct = NULL;
   unsigned long tmct_siz;
+  unsigned int i, img_count; 
   
-  tm_clone_table_sect_data = getsectdata (__DATA,
-	  __tm_clone_table,
-	  tmct_siz);
+  mh = _dyld_get_image_header_containing_address (
+		(const void*)__doTMRegistrations);
+  tmct_fixed = GET_DATA_TMCT (mh, tmct_siz);
   tmct_siz /= (sizeof (size_t) * 2);
+
+  img_count = _dyld_image_count();
+  for (i = 0; i  img_count  tmct == NULL; i++)
+{
+  if (mh == _dyld_get_image_header(i))
+	tmct = tmct_fixed + (unsigned long)_dyld_get_image_vmaddr_slide(i); 
+}
+
   if (_ITM_registerTMCloneTable != NULL
-   tm_clone_table_sect_data != NULL
+   tmct != NULL
tmct_siz  0)
-_ITM_registerTMCloneTable (tm_clone_table_sect_data, (size_t)tmct_siz);
+_ITM_registerTMCloneTable ((void *)tmct, (size_t)tmct_siz);
 }
 
 #endif
@@ -60,18 +82,27 @@ void __doTMdeRegistrations (void) __attribute__ ((
 
 void __doTMdeRegistrations (void)
 {
-  char * tm_clone_table_sect_data;
+  struct mach_header *mh;
+  char *tmct_fixed, *tmct = NULL;
   unsigned long tmct_siz;
+  unsigned int i, img_count; 
   
-  tm_clone_table_sect_data = getsectdata (__DATA,
-	  __tm_clone_table,
-	  tmct_siz);
-  
+  mh = _dyld_get_image_header_containing_address (
+		(const void *)__doTMdeRegistrations);
+  tmct_fixed = GET_DATA_TMCT (mh, tmct_siz);
+  tmct_siz /= (sizeof (size_t) * 2);
+
+  img_count = _dyld_image_count();
+  for (i = 0; i  img_count  tmct == NULL; i++)
+{
+  if (mh == _dyld_get_image_header(i))
+	tmct = tmct_fixed + (unsigned long)_dyld_get_image_vmaddr_slide(i); 
+}
+
   if (_ITM_deregisterTMCloneTable != NULL
-   tm_clone_table_sect_data != NULL
+   tmct != NULL
tmct_siz  0)
-_ITM_deregisterTMCloneTable (tm_clone_table_sect_data);
-
+_ITM_deregisterTMCloneTable ((void *)tmct);
 }
 
 #endif


Re: [trans-mem,darwin] PR/52042 find tm_clone_table with PIE

2012-02-07 Thread Jack Howarth
On Tue, Feb 07, 2012 at 10:36:41PM -0500, Patrick Marlier wrote:
 Hi,

 The problem in this PR is that with PIE, getsectdata does not return the  
 position of tm_clone_table after the relocation.
 While _dyld_get_image_vmaddr_slide(0) is enough for PIE, this is not  
 enough for dylib.
 I did not find an easy API function to get position of the  
 tm_clone_table for a shared library (dylib). So the only way I found is  
 to get the mach_header address of the current dylib (via  
 _dyld_get_image_header_containing_address), iterate over loaded binaries  
 to find the current shared library and use _dyld_get_image_vmaddr_slide  
 to find the position.
 Any other proposal (my knowledge of darwin is really limited)?

 Can someone do a bootstrap and test libitm on darwin (I have a limited  
 access to a darwin machine, at least libitm tests pass)? Thanks!

Done.

Native configuration is x86_64-apple-darwin11.3.0

=== libitm tests ===


Running target unix/-m32
FAIL: libitm.c++/eh-1.C execution test

=== libitm Summary for unix/-m32 ===

# of expected passes25
# of unexpected failures1
# of expected failures  3
# of unsupported tests  1

Running target unix/-m64
FAIL: libitm.c++/eh-1.C execution test

=== libitm Summary for unix/-m64 ===

# of expected passes25
# of unexpected failures1
# of expected failures  3
# of unsupported tests  1

=== libitm Summary ===

# of expected passes50
# of unexpected failures2
# of expected failures  6
# of unsupported tests  2

Compiler version: gcc libitm 
Platform: x86_64-apple-darwin11.3.0
configure flags: --prefix=/sw --prefix=/sw/lib/gcc4.7 --mandir=/sw/share/man 
--infodir=/sw/lib/gcc4.7/info --with-build-config=bootstrap-lto 
--enable-stage1-languages=c,lto 
--enable-languages=c,c++,fortran,lto,objc,obj-c++,java --with-gmp=/sw 
--with-libiconv-prefix=/sw --with-ppl=/sw --with-cloog=/sw --with-mpc=/sw 
--with-system-zlib --x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib 
--program-suffix=-fsf-4.7 --enable-checking=release --enable-cloog-backend=isl

I believe the remaining libitm.c++/eh-1.C execution test failures are due to
the weakref linker bug currently in Xcode 4.x (radr://10466868) which I hae been
told will be fixed in the next Xcode release after Xcode 4.3.
Jack


 If tests passed, ok for 4.7?
 --
 Patrick Marlier.
 libgcc:

   PR libitm/52042
 * config/darwin-crt-tm.c: Changes for PIE and shared library.


 Index: config/darwin-crt-tm.c
 ===
 --- config/darwin-crt-tm.c(revision 183968)
 +++ config/darwin-crt-tm.c(working copy)
 @@ -26,8 +26,20 @@ see the files COPYING3 and COPYING.RUNTIME respect
  #include mach-o/dyld.h
  
  /* not listed in mach-o/dyld.h for some reason.  */
 -extern char * getsectdata (const char*,const char*,unsigned long*); 
 +extern char *getsectdatafromheader (struct mach_header*, const char*,
 + const char*, unsigned long*);
 +extern char *getsectdatafromheader_64 (struct mach_header_64*, const char*,
 +const char*, unsigned long*);
  
 +#ifdef __LP64__
 +#define GET_DATA_TMCT(mh,size) \
 +  getsectdatafromheader_64 ((struct mach_header_64*) mh, \
 + __DATA, __tm_clone_table, size)
 +#else
 +#define GET_DATA_TMCT(mh,size) \
 +  getsectdatafromheader (mh, __DATA, __tm_clone_table, size)
 +#endif
 +
  #define WEAK __attribute__((weak))
  
  extern void _ITM_registerTMCloneTable (void *, size_t) WEAK;
 @@ -39,17 +51,27 @@ void __doTMRegistrations (void) __attribute__ ((co
  
  void __doTMRegistrations (void)
  {
 -  char * tm_clone_table_sect_data;
 +  struct mach_header *mh;
 +  char *tmct_fixed, *tmct = NULL;
unsigned long tmct_siz;
 +  unsigned int i, img_count; 

 -  tm_clone_table_sect_data = getsectdata (__DATA,
 -   __tm_clone_table,
 -   tmct_siz);
 +  mh = _dyld_get_image_header_containing_address (
 + (const void*)__doTMRegistrations);
 +  tmct_fixed = GET_DATA_TMCT (mh, tmct_siz);
tmct_siz /= (sizeof (size_t) * 2);
 +
 +  img_count = _dyld_image_count();
 +  for (i = 0; i  img_count  tmct == NULL; i++)
 +{
 +  if (mh == _dyld_get_image_header(i))
 + tmct = tmct_fixed + (unsigned long)_dyld_get_image_vmaddr_slide(i); 
 +}
 +
if (_ITM_registerTMCloneTable != NULL
 -   tm_clone_table_sect_data != NULL
 +   tmct != NULL
 tmct_siz  0)
 -_ITM_registerTMCloneTable (tm_clone_table_sect_data, (size_t)tmct_siz);
 +_ITM_registerTMCloneTable ((void *)tmct, (size_t)tmct_siz);
  }
  
  #endif
 @@ -60,18 +82,27 @@ void __doTMdeRegistrations (void) __attribute__ ((
  
  void __doTMdeRegistrations (void)
  {
 -  char * 

Re: Go patch committed: Multiplex goroutines onto OS threads

2012-02-07 Thread Ian Lance Taylor
Ian Lance Taylor i...@google.com writes:

 Right now it looks like there is a bug, or at least an incompatibility,
 in the 64-bit versions of getcontext and setcontext.  It looks like
 calling setcontext on the 32-bit version does not change the value of
 TLS variables, which is also the case on GNU/Linux.  In the 64-bit
 version, calling setcontext does change the value of TLS variables.
 That is, on the 64-bit version, getcontext preserves the value of TLS
 variables and setcontext restores the old value.  (Of course it's really
 the pointer, not the TLS variables themselves).  This incompatibility
 has to be a bug, and of course I would prefer that the incompatibility
 be resolved in favor of the implementation used on GNU/Linux.

Well, I thought I could fix this in a sensible way, but I really
couldn't.  It's a fairly serious bug.  Calling setcontext in thread T2
when getcontext was called in thread T1 causes T2 to start using T1's
TLS variables, T1's pthread_getspecific values, and even T1's
pthread_self.  I couldn't figure out any way that T2 could do any thread
specific.

So I cheated and wrote a system-specific hack.  With this patch applied,
I see only 4 failures running the testsuite on x86/x86_64 Solaris.
Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu, where the
code is not used.  Committed to mainline.

Ian

diff -r d9bce1ef2e17 libgo/configure.ac
--- a/libgo/configure.ac	Tue Feb 07 11:19:23 2012 -0800
+++ b/libgo/configure.ac	Tue Feb 07 21:19:06 2012 -0800
@@ -549,6 +549,87 @@
 STRUCT_EPOLL_EVENT_FD_OFFSET=${libgo_cv_c_epoll_event_fd_offset}
 AC_SUBST(STRUCT_EPOLL_EVENT_FD_OFFSET)
 
+dnl See whether setcontext changes the value of TLS variables.
+AC_CACHE_CHECK([whether setcontext clobbers TLS variables],
+[libgo_cv_lib_setcontext_clobbers_tls],
+[LIBS_hold=$LIBS
+LIBS=$LIBS $PTHREAD_LIBS
+AC_RUN_IFELSE(
+  [AC_LANG_SOURCE([
+#include pthread.h
+#include stdlib.h
+#include ucontext.h
+#include unistd.h
+
+__thread int tls;
+
+static char stack[[10 * 1024 * 1024]];
+static ucontext_t c;
+
+/* Called via makecontext/setcontext.  */
+
+static void
+cfn (void)
+{
+  exit (tls);
+}
+
+/* Called via pthread_create.  */
+
+static void *
+tfn (void *dummy)
+{
+  /* The thread should still see this value after calling
+ setcontext.  */
+  tls = 0;
+
+  setcontext (c);
+
+  /* The call to setcontext should not return.  */
+  abort ();
+}
+
+int
+main ()
+{
+  pthread_t tid;
+
+  /* The thread should not see this value.  */
+  tls = 1;
+
+  if (getcontext (c)  0)
+abort ();
+
+  c.uc_stack.ss_sp = stack;
+  c.uc_stack.ss_flags = 0;
+  c.uc_stack.ss_size = sizeof stack;
+  c.uc_link = NULL;
+  makecontext (c, cfn, 0);
+
+  if (pthread_create (tid, NULL, tfn, NULL) != 0)
+abort ();
+
+  if (pthread_join (tid, NULL) != 0)
+abort ();
+
+  /* The thread should have called exit.  */
+  abort ();
+}
+])],
+[libgo_cv_lib_setcontext_clobbers_tls=no],
+[libgo_cv_lib_setcontext_clobbers_tls=yes],
+[case $target in
+  x86_64*-*-solaris2.10) libgo_cv_lib_setcontext_clobbers_tls=yes ;;
+  *) libgo_cv_lib_setcontext_clobbers_tls=no ;;
+ esac
+])
+LIBS=$LIBS_hold
+])
+if test $libgo_cv_lib_setcontext_clobbers_tls = yes; then
+  AC_DEFINE(SETCONTEXT_CLOBBERS_TLS, 1,
+	[Define if setcontext clobbers TLS variables])
+fi
+
 AC_CACHE_SAVE
 
 if test ${multilib} = yes; then
diff -r d9bce1ef2e17 libgo/runtime/proc.c
--- a/libgo/runtime/proc.c	Tue Feb 07 11:19:23 2012 -0800
+++ b/libgo/runtime/proc.c	Tue Feb 07 21:19:06 2012 -0800
@@ -60,6 +60,54 @@
 static __thread G *g;
 static __thread M *m;
 
+#ifndef SETCONTEXT_CLOBBERS_TLS
+
+static inline void
+initcontext(void)
+{
+}
+
+static inline void
+fixcontext(ucontext_t *c __attribute__ ((unused)))
+{
+}
+
+# else
+
+# if defined(__x86_64__)  defined(__sun__)
+
+// x86_64 Solaris 10 and 11 have a bug: setcontext switches the %fs
+// register to that of the thread which called getcontext.  The effect
+// is that the address of all __thread variables changes.  This bug
+// also affects pthread_self() and pthread_getspecific.  We work
+// around it by clobbering the context field directly to keep %fs the
+// same.
+
+static __thread greg_t fs;
+
+static inline void
+initcontext(void)
+{
+	ucontext_t c;
+
+	getcontext(c);
+	fs = c.uc_mcontext.gregs[REG_FSBASE];
+}
+
+static inline void
+fixcontext(ucontext_t* c)
+{
+	c-uc_mcontext.gregs[REG_FSBASE] = fs;
+}
+
+# else
+
+#  error unknown case for SETCONTEXT_CLOBBERS_TLS
+
+# endif
+
+#endif
+
 // We can not always refer to the TLS variables directly.  The
 // compiler will call tls_get_addr to get the address of the variable,
 // and it may hold it in a register across a call to schedule.  When
@@ -248,7 +296,9 @@
 #endif
 	g = newg;
 	newg-fromgogo = true;
+	fixcontext(newg-context);
 	setcontext(newg-context);
+	runtime_throw(gogo setcontext returned);
 }
 
 // Save context and call fn passing g as a parameter.  This is like
@@ -287,6 +337,7 @@
 		m-g0-entry = (byte*)pfn;
 		m-g0-param = g;
 		g 

Go patch committed: Check make int64 args for overflow

2012-02-07 Thread Ian Lance Taylor
This patch to the Go compiler checks arguments to make for overflow if
they have types larger than uintptr.  In an attempt to be efficient on
32-bit systems, gccgo will continue to pass uintptr arguments in the
normal case.  If make is called with a value whose type is larger than
uintptr (e.g., uint64 on a 32-bit system) then gccgo will call a
different function which takes uint64 values and checks them for
overflow.  Without this patch we would silently accept invalid values.
Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
Committed to mainline.

Ian

diff -r df952f89b74e go/expressions.cc
--- a/go/expressions.cc	Tue Feb 07 21:29:07 2012 -0800
+++ b/go/expressions.cc	Tue Feb 07 22:13:53 2012 -0800
@@ -7744,6 +7744,10 @@
   return Expression::make_error(this-location());
 }
 
+  bool have_big_args = false;
+  Type* uintptr_type = Type::lookup_integer_type(uintptr);
+  int uintptr_bits = uintptr_type-integer_type()-bits();
+
   ++parg;
   Expression* len_arg;
   if (parg == args-end())
@@ -7767,6 +7771,9 @@
 	  this-report_error(_(bad size for make));
 	  return Expression::make_error(this-location());
 	}
+  if (len_arg-type()-integer_type() != NULL
+	   len_arg-type()-integer_type()-bits()  uintptr_bits)
+	have_big_args = true;
   ++parg;
 }
 
@@ -7779,6 +7786,9 @@
 	  this-report_error(_(bad capacity when making slice));
 	  return Expression::make_error(this-location());
 	}
+  if (cap_arg-type()-integer_type() != NULL
+	   cap_arg-type()-integer_type()-bits()  uintptr_bits)
+	have_big_args = true;
   ++parg;
 }
 
@@ -7801,16 +7811,26 @@
   if (is_slice)
 {
   if (cap_arg == NULL)
-	call = Runtime::make_call(Runtime::MAKESLICE1, loc, 2, type_arg,
-  len_arg);
+	call = Runtime::make_call((have_big_args
+   ? Runtime::MAKESLICE1BIG
+   : Runtime::MAKESLICE1),
+  loc, 2, type_arg, len_arg);
   else
-	call = Runtime::make_call(Runtime::MAKESLICE2, loc, 3, type_arg,
-  len_arg, cap_arg);
+	call = Runtime::make_call((have_big_args
+   ? Runtime::MAKESLICE2BIG
+   : Runtime::MAKESLICE2),
+  loc, 3, type_arg, len_arg, cap_arg);
 }
   else if (is_map)
-call = Runtime::make_call(Runtime::MAKEMAP, loc, 2, type_arg, len_arg);
+call = Runtime::make_call((have_big_args
+			   ? Runtime::MAKEMAPBIG
+			   : Runtime::MAKEMAP),
+			  loc, 2, type_arg, len_arg);
   else if (is_chan)
-call = Runtime::make_call(Runtime::MAKECHAN, loc, 2, type_arg, len_arg);
+call = Runtime::make_call((have_big_args
+			   ? Runtime::MAKECHANBIG
+			   : Runtime::MAKECHAN),
+			  loc, 2, type_arg, len_arg);
   else
 go_unreachable();
 
diff -r df952f89b74e go/runtime.def
--- a/go/runtime.def	Tue Feb 07 21:29:07 2012 -0800
+++ b/go/runtime.def	Tue Feb 07 22:13:53 2012 -0800
@@ -72,10 +72,16 @@
 DEF_GO_RUNTIME(MAKESLICE1, __go_make_slice1, P2(TYPE, UINTPTR), R1(SLICE))
 DEF_GO_RUNTIME(MAKESLICE2, __go_make_slice2, P3(TYPE, UINTPTR, UINTPTR),
 	   R1(SLICE))
+DEF_GO_RUNTIME(MAKESLICE1BIG, __go_make_slice1_big, P2(TYPE, UINT64),
+	   R1(SLICE))
+DEF_GO_RUNTIME(MAKESLICE2BIG, __go_make_slice2_big, P3(TYPE, UINT64, UINT64),
+	   R1(SLICE))
 
 
 // Make a map.
 DEF_GO_RUNTIME(MAKEMAP, __go_new_map, P2(MAPDESCRIPTOR, UINTPTR), R1(MAP))
+DEF_GO_RUNTIME(MAKEMAPBIG, __go_new_map_big, P2(MAPDESCRIPTOR, UINT64),
+	   R1(MAP))
 
 // Build a map from a composite literal.
 DEF_GO_RUNTIME(CONSTRUCT_MAP, __go_construct_map,
@@ -116,6 +122,7 @@
 
 // Make a channel.
 DEF_GO_RUNTIME(MAKECHAN, __go_new_channel, P2(TYPE, UINTPTR), R1(CHAN))
+DEF_GO_RUNTIME(MAKECHANBIG, __go_new_channel_big, P2(TYPE, UINT64), R1(CHAN))
 
 // Get the length of a channel (the number of unread values).
 DEF_GO_RUNTIME(CHAN_LEN, __go_chan_len, P1(CHAN), R1(INT))
diff -r df952f89b74e libgo/runtime/chan.c
--- a/libgo/runtime/chan.c	Tue Feb 07 21:29:07 2012 -0800
+++ b/libgo/runtime/chan.c	Tue Feb 07 22:13:53 2012 -0800
@@ -130,6 +130,12 @@
 	return runtime_makechan_c(t, hint);
 }
 
+Hchan*
+__go_new_channel_big(ChanType *t, uint64 hint)
+{
+	return runtime_makechan_c(t, hint);
+}
+
 /*
  * generic single channel send/recv
  * if the bool pointer is nil,
diff -r df952f89b74e libgo/runtime/go-make-slice.c
--- a/libgo/runtime/go-make-slice.c	Tue Feb 07 21:29:07 2012 -0800
+++ b/libgo/runtime/go-make-slice.c	Tue Feb 07 22:13:53 2012 -0800
@@ -57,3 +57,27 @@
 {
   return __go_make_slice2 (td, len, len);
 }
+
+struct __go_open_array
+__go_make_slice2_big (const struct __go_type_descriptor *td, uint64_t len,
+		  uint64_t cap)
+{
+  uintptr_t slen;
+  uintptr_t scap;
+
+  slen = (uintptr_t) len;
+  if ((uint64_t) slen != len)
+runtime_panicstring (makeslice: len out of range);
+
+  scap = (uintptr_t) cap;
+  if ((uint64_t) scap != cap)
+runtime_panicstring (makeslice: cap out of range);
+
+  return __go_make_slice2 (td, slen, scap);
+}
+
+struct __go_open_array
+__go_make_slice1_big (const struct __go_type_descriptor *td, 

[v3] doxgen version update

2012-02-07 Thread Benjamin De Kosnik
Debugging pdf output on current linux indicates that the long-standing
PDF_HYPERLINKS issue turns out to just be a pool_size limitation in
TeX, which can be worked around by increasing pool size. Document.

tested x86_64/linux

-benjamin
2012-02-07  Benjamin Kosnik  b...@redhat.com

	* doc/doxygen/user.cfg.in: Update to doxygen 1.7.6.1.
	* doc/xml/manual/documentation_hacking.xml: Update.

diff --git a/libstdc++-v3/doc/doxygen/user.cfg.in b/libstdc++-v3/doc/doxygen/user.cfg.in
index adb8c7f..af667b5 100644
--- a/libstdc++-v3/doc/doxygen/user.cfg.in
+++ b/libstdc++-v3/doc/doxygen/user.cfg.in
@@ -1,4 +1,4 @@
-# Doxyfile 1.7.4
+# Doxyfile 1.7.6.1
 
 # This file describes the settings to be used by the documentation system
 # doxygen (www.doxygen.org) for a project.
@@ -22,8 +22,9 @@
 
 DOXYFILE_ENCODING  = UTF-8
 
-# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
-# by quotes) that should identify the project.
+# The PROJECT_NAME tag is a single word (or sequence of words) that should
+# identify the project. Note that if you do not use Doxywizard you need
+# to put quotes around the project name if it contains spaces.
 
 PROJECT_NAME   = libstdc++
 
@@ -196,6 +197,13 @@ ALIASES= doctodo=@todo\nNeeds documentation! See http://gcc.gnu
 			 headername{1}=Instead, include \1. \
 			 headername{2}=Instead, include \1 or \2.
 
+# This tag can be used to specify a number of word-keyword mappings (TCL only).
+# A mapping has the form name=value. For example adding
+# class=itcl::class will allow you to use the command class in the
+# itcl::class meaning.
+
+TCL_SUBST  =
+
 # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C
 # sources only. Doxygen will then generate output that is more tailored for C.
 # For instance, some of the names that are used will be different. The list
@@ -285,6 +293,15 @@ SUBGROUPING= YES
 
 INLINE_GROUPED_CLASSES = NO
 
+# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and
+# unions with only public data fields will be shown inline in the documentation
+# of the scope in which they are defined (i.e. file, namespace, or group
+# documentation), provided this scope is documented. If set to NO (the default),
+# structs, classes, and unions are shown on a separate page (for HTML and Man
+# pages) or section (for LaTeX and RTF).
+
+INLINE_SIMPLE_STRUCTS  = NO
+
 # When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum
 # is documented as struct, union, or enum with the name of the typedef. So
 # typedef struct TypeS {} TypeT, will appear in the documentation as a struct
@@ -307,10 +324,21 @@ TYPEDEF_HIDES_STRUCT   = NO
 # a logarithmic scale so increasing the size by one will roughly double the
 # memory usage. The cache size is given by this formula:
 # 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0,
-# corresponding to a cache size of 2^16 = 65536 symbols
+# corresponding to a cache size of 2^16 = 65536 symbols.
 
 SYMBOL_CACHE_SIZE  = 0
 
+# Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be
+# set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given
+# their name and scope. Since this can be an expensive process and often the
+# same symbol appear multiple times in the code, doxygen keeps a cache of
+# pre-resolved symbols. If the cache is too small doxygen will become slower.
+# If the cache is too large, memory is wasted. The cache size is given by this
+# formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0,
+# corresponding to a cache size of 2^16 = 65536 symbols.
+
+LOOKUP_CACHE_SIZE  = 0
+
 #---
 # Build related configuration options
 #---
@@ -552,6 +580,16 @@ FILE_VERSION_FILTER=
 
 LAYOUT_FILE=
 
+# The CITE_BIB_FILES tag can be used to specify one or more bib files
+# containing the references data. This must be a list of .bib files. The
+# .bib extension is automatically appended if omitted. Using this command
+# requires the bibtex tool to be installed. See also
+# http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style
+# of the bibliography can be controlled using LATEX_BIB_STYLE. To use this
+# feature you need bibtex and perl available in the search path.
+
+CITE_BIB_FILES =
+
 #---
 # configuration options related to warning and progress messages
 #---
@@ -805,13 +843,15 @@ FILE_PATTERNS  = *.h \
 
 RECURSIVE  = NO
 
-# The EXCLUDE tag can be used to specify files and/or directories that should
+# The EXCLUDE tag can be used to specify files and/or directories that should be
 # excluded from