Re: [Patch, fortran] PR48946 - Deferred Overloaded Assignment

2012-01-04 Thread Thomas Koenig

Hi Paul,


Dear All,

This is a straightforward patch that adds a last ditch attempt to find
a specific typebound procedure when all that has been found for a
derived type base object is 'deferred'.  typebound_operator_7.f03 has
been extended to test derived type as well as class base objects.

Bootstrapped and regtested on x86_64/FC9 - OK for trunk?


I am not really familiar with the OOP stuff, but this looks OK for me.
Just one nit:



2012-01-03  Paul Thomas

PR fortran/PR48946
* gfortran.dg/typebound_operator_7.f03: Add test for derived
type typebound operators as well as class bound operators.


Wouldn't it be better to make a new test case?  If there turns out
to be a regression later, changing test cases makes it harder to
find.

You could just commit the test case 'as is' as typebound_operator_8.f03
and leave the old one.

Regards

Thomas



Re: [committed] copy-edit -flto documentation

2012-01-04 Thread Eric Botcazou
> Done.

Great, thanks.

-- 
Eric Botcazou


Re: [Patch, fortran] PR48946 - Deferred Overloaded Assignment

2012-01-04 Thread Paul Richard Thomas
Dear Thomas,

Happy New Year!


> Wouldn't it be better to make a new test case?  If there turns out
> to be a regression later, changing test cases makes it harder to
> find.
>
> You could just commit the test case 'as is' as typebound_operator_8.f03
> and leave the old one.
>
> Regards
>
>        Thomas
>
I am happy enough to do that.  *_8.f03 already exists :-)

Cheers

Paul


Re: [patch, Fortran] Fix PR 49693, unused variable warnings in common blocks

2012-01-04 Thread Tobias Burnus
Thomas Koenig wrote:
> the attached patch fixes the PR by unconditionally disabling warnings
> about unused variables in common blocks.

I was wondering whether it disables intended diagnostic. However, I think
setting TREE_USED () is OK. Common-related diagnostic is better done by the
front end (via attr.referenced) - such as for '"a" explicitly use-associated
but not used'.

> Regression-tested. OK for trunk?
OK. Thanks for the patch.

Tobias

PS: If I have not missed anything, the current patch review/committal status is:

Reviewed but not committed:
- This patch ;-)
- Mikael's scalarizer patch for OPTIONAL + ELEMENTAL
  http://gcc.gnu.org/ml/fortran/2012-01/msg5.html

Unreviewed:
- Rainer's [libgfortran, libitm] Link with -shared-libgcc
  http://gcc.gnu.org/ml/fortran/2011-12/msg00117.html
- My Deregister allocatable COARRAYS, fixes to (de)allocate
  http://gcc.gnu.org/ml/fortran/2011-12/msg00157.html
- Paul's PR48946 - Deferred Overloaded Assignment
  (half reviewed) http://gcc.gnu.org/ml/fortran/2012-01/msg00026.html


[google] Dump inline decisions more wisely

2012-01-04 Thread Dehao Chen
Hi,

This patch:

* dump inline decisions with profile info whenever available.
* disable dump of einline decisions at OPT_INFO_MIN.

Is it ok for google branches?

thanks,
Dehao

2012-01-04  Dehao Chen  

* ipa-inline.c (cgraph_node_opt_info): Print profile info if available
(dump_inline_decision): Disable einline dump at OPT_INFO_MIN

Index: gcc/ipa-inline.c
===
--- gcc/ipa-inline.c(revision 182864)
+++ gcc/ipa-inline.c(working copy)
@@ -308,12 +308,12 @@
 bfd_name = "unknown";

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

   strcpy (buf, bfd_name);
-  if (flag_opt_info >= OPT_INFO_MED && profile_info)
+  if (profile_info)
 sprintf (buf,
 "%s ("HOST_WIDEST_INT_PRINT_DEC", "HOST_WIDEST_INT_PRINT_DEC")",
 buf, node->count, node->max_bb_count);
@@ -364,6 +364,16 @@
   const char *call_count_text;
   struct cgraph_node *final_caller = edge->caller;

+  if (flag_opt_info < OPT_INFO_MED)
+{
+  tree decl = edge->caller->decl;
+  if (decl)
+   {
+ struct function *fn = DECL_STRUCT_FUNCTION (decl);
+ if (!fn || !fn->always_inline_functions_inlined)
+   return;
+   }
+}
   if (final_caller->global.inlined_to != NULL)
 inline_chain_text = cgraph_node_call_chain (final_caller, &final_caller);
   else


Re: [Patch, fortran] PR48946 - Deferred Overloaded Assignment [fwd: tobias.bur...@physik.fu-berlin.de]

2012-01-04 Thread Tobias Burnus
Dear Paul,

On Tue, Jan 03, 2012 at 09:30:28PM +0100, Paul Richard Thomas wrote:
> Bootstrapped and regtested on x86_64/FC9 - OK for trunk?

OK. Thanks for the patch.


> +  /* If we find a deferred typebound procedure, check for derived types
> + that an over-riding typebound procedure has not been missed.  */

s/over-riding/overriding/.
(I somehow miss something before "that" - such as "ensuring" or similar.)

> +  if (e->value.compcall.tbp->deferred
> +&& e->value.compcall.name
> +&& !e->value.compcall.tbp->non_overridable
> +&& e->value.compcall.base_object
> +&& e->value.compcall.base_object->ts.type == BT_DERIVED)

Indentation looks wrong.

While I also tend to reduce the number of run tests, it probably makes sense
to follow Thomas' suggestion and add a new test case instead of modifying
the old one.

Tobias

- End forwarded message -


Re: [PATCH] Another canonical cselib_val bootstrap fix (PR bootstrap/51725)

2012-01-04 Thread Richard Guenther
On Tue, 3 Jan 2012, Jakub Jelinek wrote:

> Hi!
> 
> My previous patch apparently wasn't enough.  If at add_mem_*
> time mem_elt is still its own canonical cselib_val, but only afterwards
> new_elt_loc_list adds a new canonical cselib_val to it (and moves

Hm, shouldn't an existing cselib_val be always the canonical one?

> over its locs), then we can still crash in cselib_invalidate_mem.
> This patch ensures that new_elt_loc_list when moving over the locs also
> adds the canonical cselib_val to first_containing_mem list if it
> wasn't already there and the old val was (it would be better to
> remove it, but the chain is only single linked list and it would be
> expensive to remove it there - the next cselib_invalidate_mem
> will handle it automatically, as non-canonical values don't have any mem
> locs and thus are removed from the chain).
> In cselib_invalidate_mem it needs to call canonical_cselib_val on the
> addr_list chain elts (those aren't canonicalized by anything).
> There is no need to call canonical_cselib_val on v, the new_elt_loc_list
> change ensures that the canonical value is in the list always too
> and non-canonical values don't have MEM locs.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, tested with
> cross jc1 to ia64-linux on gnu-CORBA.list compilation.  Ok for trunk?
> 
> 2012-01-03  Jakub Jelinek  
> 
>   PR bootstrap/51725
>   * cselib.c (new_elt_loc_list): When moving locs from one
>   cselib_val to its new canonical_cselib_val and the
>   cselib_val was in first_containing_mem chain, but
>   the canonical_cselib_val was not, add the latter into the
>   chain.
>   (cselib_invalidate_mem): Compare canonical_cselib_val of
>   addr_list chain elt with v.
> 
> --- gcc/cselib.c.jj   2012-01-03 16:22:48.0 +0100
> +++ gcc/cselib.c  2012-01-03 17:29:10.096229315 +0100
> @@ -277,6 +277,12 @@ new_elt_loc_list (cselib_val *val, rtx l
>   }
> el->next = val->locs;
> next = val->locs = CSELIB_VAL_PTR (loc)->locs;
> +   if (CSELIB_VAL_PTR (loc)->next_containing_mem != NULL
> +   && val->next_containing_mem == NULL)
> + {
> +   val->next_containing_mem = first_containing_mem;
> +   first_containing_mem = val;
> + }
>   }
>  
>/* Chain LOC back to VAL.  */
> @@ -2211,7 +2217,7 @@ cselib_invalidate_mem (rtx mem_rtx)
> mem_chain = &addr->addr_list;
> for (;;)
>   {
> -   if ((*mem_chain)->elt == v)
> +   if (canonical_cselib_val ((*mem_chain)->elt) == v)
>   {
> unchain_one_elt_list (mem_chain);
> break;
> 
>   Jakub
> 
> 

-- 
Richard Guenther 
SUSE / SUSE Labs
SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer

Re: [PATCH] Another canonical cselib_val bootstrap fix (PR bootstrap/51725)

2012-01-04 Thread Jakub Jelinek
On Wed, Jan 04, 2012 at 10:33:50AM +0100, Richard Guenther wrote:
> > My previous patch apparently wasn't enough.  If at add_mem_*
> > time mem_elt is still its own canonical cselib_val, but only afterwards
> > new_elt_loc_list adds a new canonical cselib_val to it (and moves
> 
> Hm, shouldn't an existing cselib_val be always the canonical one?

Canonical is the one with lower uid.  If cselib_add_permanent_equiv
is called with two existing cselib_vals, just one of them will be
canonical.

Jakub


Re: [SH] PR 31640 - cache block alignment is too aggressive on sh-elf

2012-01-04 Thread Kaz Kojima
Oleg Endo  wrote:
> The attached patch addresses PR 31640.
> It reduces the the default function alignment when not optimizing for
> size from cache line size (32 bytes) to 4 bytes and sets the loop
> alignment to 4 bytes when not optimizing for size.  Moreover, it brings
> back the -falign-loops option which was always overridden and disabled
> for -m4.
> 
> Tested against rev 182734 with 
> make -k -check RUNTESTFLAGS="--target_board=sh-sim
> \{-m2/-ml,
> -m2/-mb,
> -m2a-single/-mb,
> -m4-single/-ml,
> -m4-single/-mb,
> -m4a-single/-ml,
> -m4a-single/-mb}"
> 
> and no new failures. 
> OK for trunk?
> 
> 2012-01-02  Oleg Endo  
> 
>   PR target/31640
>   * config/sh/sh.h (LOOP_ALIGN): Move logic to ...
>   * config/sh/sh.c (sh_loop_align): ... here.  Don't disable loop
>   alignment for TARGET_HARD_SH4.
>   (sh_option_override): Reduce default function alignment.  Set 
>   loop alignment to 4 bytes when not optimizing for size.

OK for trunk when it returns to stage 1 or 2.

Regards,
kaz


[Committed] S/390: PR51734 Default to -fPIC for s390 and s390x in picflag.m4

2012-01-04 Thread Andreas Krebbel
Hi,

I've applied the attached patch to mainline in order to fix the Ada
bootstrap failure reported by Jakub in PR51734 and the libiberty build
failure reported here:
http://gcc.gnu.org/ml/gcc-patches/2011-12/msg00465.html

Bye,

-Andreas-

config/
2012-01-04 Andreas Krebbel 

PR bootstrap/51734
* picflag.m4: Remove s390 case statement.

gcc/
2012-01-04  Andreas Krebbel  

* configure: Regenerate.

libada/
2012-01-04  Andreas Krebbel  

* configure: Regenerate.

libgcc/
2012-01-04  Andreas Krebbel  

* configure: Regenerate.
* config/s390/t-crtstuff: Remove -fPIC.

libiberty/
2012-01-04  Andreas Krebbel  

* configure: Regenerate.


---
 config/picflag.m4 |3 ---
 gcc/configure |7 ---
 libada/configure  |3 ---
 libgcc/config/s390/t-crtstuff |2 !!
 libgcc/configure  |3 ---
 libiberty/configure   |3 ---
 6 files changed, 15 deletions(-), 6 modifications(!)

Index: libiberty/configure
===
*** libiberty/configure.orig
--- libiberty/configure
*** case "${host}" in
*** 4899,4907 
  m68k-*-*)
PICFLAG=-fpic
;;
- s390*-*-*)
-   PICFLAG=-fpic
-   ;;
  # FIXME: Override -fPIC default in libgcc only?
  sh-*-linux* | sh[2346lbe]*-*-linux*)
PICFLAG=-fpic
--- 4899,4904 
Index: config/picflag.m4
===
*** config/picflag.m4.orig
--- config/picflag.m4
*** case "${$2}" in
*** 51,59 
  m68k-*-*)
$1=-fpic
;;
- s390*-*-*)
-   $1=-fpic
-   ;;
  # FIXME: Override -fPIC default in libgcc only? 
  sh-*-linux* | sh[[2346lbe]]*-*-linux*)
$1=-fpic
--- 51,56 
Index: libgcc/config/s390/t-crtstuff
===
*** libgcc/config/s390/t-crtstuff.orig
--- libgcc/config/s390/t-crtstuff
***
*** 2,5 
  # because then __FRAME_END__ might not be the last thing in .eh_frame
  # section.
  CRTSTUFF_T_CFLAGS += -fno-asynchronous-unwind-tables
! CRTSTUFF_T_CFLAGS_S += -fno-asynchronous-unwind-tables -fPIC
--- 2,5 
  # because then __FRAME_END__ might not be the last thing in .eh_frame
  # section.
  CRTSTUFF_T_CFLAGS += -fno-asynchronous-unwind-tables
! CRTSTUFF_T_CFLAGS_S += -fno-asynchronous-unwind-tables
Index: libgcc/configure
===
*** libgcc/configure.orig
--- libgcc/configure
*** case "${host}" in
*** 2322,2330 
  m68k-*-*)
PICFLAG=-fpic
;;
- s390*-*-*)
-   PICFLAG=-fpic
-   ;;
  # FIXME: Override -fPIC default in libgcc only?
  sh-*-linux* | sh[2346lbe]*-*-linux*)
PICFLAG=-fpic
--- 2322,2327 
Index: gcc/configure
===
*** gcc/configure.orig
--- gcc/configure
*** case "${target}" in
*** 4925,4933 
  m68k-*-*)
PICFLAG_FOR_TARGET=-fpic
;;
- s390*-*-*)
-   PICFLAG_FOR_TARGET=-fpic
-   ;;
  # FIXME: Override -fPIC default in libgcc only?
  sh-*-linux* | sh[2346lbe]*-*-linux*)
PICFLAG_FOR_TARGET=-fpic
--- 4925,4930 
*** else
*** 18109,18115 
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
! #line 18112 "configure"
  #include "confdefs.h"
  
  #if HAVE_DLFCN_H
--- 18106,18112 
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
! #line 18109 "configure"
  #include "confdefs.h"
  
  #if HAVE_DLFCN_H
*** else
*** 18215,18221 
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
! #line 18218 "configure"
  #include "confdefs.h"
  
  #if HAVE_DLFCN_H
--- 18212,18218 
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
! #line 18215 "configure"
  #include "confdefs.h"
  
  #if HAVE_DLFCN_H
Index: libada/configure
===
*** libada/configure.orig
--- libada/configure
*** case "${host}" in
*** 2868,2876 
  m68k-*-*)
PICFLAG=-fpic
;;
- s390*-*-*)
-   PICFLAG=-fpic
-   ;;
  # FIXME: Override -fPIC default in libgcc only?
  sh-*-linux* | sh[2346lbe]*-*-linux*)
PICFLAG=-fpic
--- 2868,2873 



Re: [patch, Fortran] Fix PR 49693, unused variable warnings in common blocks

2012-01-04 Thread Thomas Koenig

Hi Tobias,



Regression-tested. OK for trunk?

OK. Thanks for the patch.


Committed (rev. 182869).  Thanks for the review!  (I also updated the
copyright years, as requested in private E-Mail.)

Thomas


Unreviewed libffi, libgfortran, libitm patches

2012-01-04 Thread Rainer Orth
The following patches have remained unreviewed for two or three weeks:

[libffi] Build 64-bit multilib for i?86-linux
http://gcc.gnu.org/ml/gcc-patches/2011-12/msg01011.html

In the absence of a listed libffi maintainer, it probably needs a global
reviewer.

[libgfortran, libitm] Link with -shared-libgcc
http://gcc.gnu.org/ml/gcc-patches/2011-12/msg01382.html

This will need a fortran resp. libitm maintainer.

Rainer

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


Re: [patch] Fix PR tree-optimization/51624

2012-01-04 Thread Eric Botcazou
> > OK, I see.  Then the only way out I can think of is to stop going up the
> > chain of COMPONENT_REFs as soon as the offset becomes negative.
>
> Yeah, that sounds like a better solution.

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

2012-01-04  Eric Botcazou  

PR tree-optimization/51624
* tree-sra.c (build_ref_for_model): When replicating a chain of
COMPONENT_REFs, stop as soon as the offset would become negative.


-- 
Eric Botcazou
Index: tree-sra.c
===
--- tree-sra.c	(revision 182784)
+++ tree-sra.c	(working copy)
@@ -1472,8 +1472,14 @@ build_ref_for_model (location_t loc, tre
 
   do {
 	tree field = TREE_OPERAND (expr, 1);
-	offset -= int_bit_position (field);
+	HOST_WIDE_INT bit_pos = int_bit_position (field);
 
+	/* We can be called with a model different from the one associated
+	   with BASE so we need to avoid going up the chain too far.  */
+	if (offset - bit_pos < 0)
+	  break;
+
+	offset -= bit_pos;
 	VEC_safe_push (tree, stack, cr_stack, expr);
 
 	expr = TREE_OPERAND (expr, 0);


Re: [patch] Fix PR tree-optimization/51624

2012-01-04 Thread Richard Guenther
On Wed, Jan 4, 2012 at 1:27 PM, Eric Botcazou  wrote:
>> > OK, I see.  Then the only way out I can think of is to stop going up the
>> > chain of COMPONENT_REFs as soon as the offset becomes negative.
>>
>> Yeah, that sounds like a better solution.
>
> Bootstrapped on MIPS/IRIX and regtested on {i586,x86_64}-suse-linux.  OK after
> a full testing cycle?

Ok.

Thanks,
Richard.

> 2012-01-04  Eric Botcazou  
>
>        PR tree-optimization/51624
>        * tree-sra.c (build_ref_for_model): When replicating a chain of
>        COMPONENT_REFs, stop as soon as the offset would become negative.
>
>
> --
> Eric Botcazou


Re: [libgfortran, libitm] Link with -shared-libgcc

2012-01-04 Thread Tobias Burnus
Dear Rainer,

Rainer Orth wrote on Wed, 04 Jan 2012:
> The following patches have remained unreviewed for two or three weeks

I had hoped that a build maintainer or someone else more knowledgeable about
the lib dependencies would reply.


Rainer Orth wrote on Mon, 19 Dec 2011:
> Indeed, libgfortran.so contains unresolved references to libgcc_s.so
> functions

> The patch below fixes both issues and let the i386-pc-solaris2.11
> bootstrap complete without unexpected failures.
>
> Ok for mainline?

The libgfortran patch looks fine. Thanks for the patch and the patience.

Tobias

> 2011-12-18  Rainer Orth  
>   libgfortran:
>   * Makefile.am (libgfortran_la_LDFLAGS): Add -Wc,-shared-libgcc.
>   * Makefile.in: Regenerate.


PR rtl-optimization/49710 (segfault in loop peeling)

2012-01-04 Thread Jan Hubicka
Hi,
in the testcase bellow the loop peeling simplifies exit condition in a way
that the outer loop is destroyed.  After some discussion with Zdenek I learnt
that remove_path is then supposed to destroy the outer loop by calling unloop
on it, but there is thinko in the function assuming that just the immediately
outer loop can be eliminated.  This is not true in this case: inner loop
has two exists, one closing outer loop and the ohter closing outer loop of the
outer loop.  Outer loop stays, but outer loop of outer loop needs to be removed,
so we need to walk the whole hiarchy upwards.

Bootstrapped/regtested x86_64-linux, OK?

Honza

int a, b, c, d;

static void
foo (int *x)
{
  c = 0;
  while (1)
{
  if (*x)
break;
  while (b)
for (; c; c = 0);
  for (d = 18; d != 18; d++)
if (c)
  {
foo (x);
return;
  }
}
}

static void
bar ()
{
  foo (0);
  foo (0);
  for (;;)
;
}

baz ()
{
  for (; a;)
bar ();
}
PR middle-end/49710 
* cfgloopmanip.c (remove_path): Walk loop hiearchy upwards when
unlooping loops.
Index: cfgloopmanip.c
===
*** cfgloopmanip.c  (revision 182871)
--- cfgloopmanip.c  (working copy)
*** remove_path (edge e)
*** 291,296 
--- 291,297 
sbitmap seen;
bool irred_invalidated = false;
edge_iterator ei;
+   struct loop *l;
  
if (!can_remove_branch_p (e))
  return false;
*** remove_path (edge e)
*** 315,323 
   normally.   We may assume that e->dest is not a header of any loop,
   as it now has exactly one predecessor.  */
while (loop_outer (e->src->loop_father)
!&& dominated_by_p (CDI_DOMINATORS,
!   e->src->loop_father->latch, e->dest))
  unloop (e->src->loop_father, &irred_invalidated);
  
/* Identify the path.  */
nrem = find_path (e, &rem_bbs);
--- 316,333 
   normally.   We may assume that e->dest is not a header of any loop,
   as it now has exactly one predecessor.  */
while (loop_outer (e->src->loop_father)
! && dominated_by_p (CDI_DOMINATORS,
!e->src->loop_father->latch, e->dest))
  unloop (e->src->loop_father, &irred_invalidated);
+   l = e->src->loop_father;
+   while (l && loop_outer (l))
+ {
+   while (loop_outer (loop_outer (l))
+&& dominated_by_p (CDI_DOMINATORS,
+   loop_outer (l)->latch, e->dest))
+ unloop (loop_outer (l), &irred_invalidated);
+   l = loop_outer (l);
+ }
  
/* Identify the path.  */
nrem = find_path (e, &rem_bbs);


Re: PR rtl-optimization/49710 (segfault in loop peeling)

2012-01-04 Thread Richard Guenther
On Wed, Jan 4, 2012 at 2:01 PM, Jan Hubicka  wrote:
> Hi,
> in the testcase bellow the loop peeling simplifies exit condition in a way
> that the outer loop is destroyed.  After some discussion with Zdenek I learnt
> that remove_path is then supposed to destroy the outer loop by calling unloop
> on it, but there is thinko in the function assuming that just the immediately
> outer loop can be eliminated.  This is not true in this case: inner loop
> has two exists, one closing outer loop and the ohter closing outer loop of the
> outer loop.  Outer loop stays, but outer loop of outer loop needs to be 
> removed,
> so we need to walk the whole hiarchy upwards.
>
> Bootstrapped/regtested x86_64-linux, OK?
>
> Honza
>
> int a, b, c, d;
>
> static void
> foo (int *x)
> {
>  c = 0;
>  while (1)
>    {
>      if (*x)
> break;
>      while (b)
> for (; c; c = 0);
>      for (d = 18; d != 18; d++)
> if (c)
>  {
>    foo (x);
>    return;
>  }
>    }
> }
>
> static void
> bar ()
> {
>  foo (0);
>  foo (0);
>  for (;;)
>    ;
> }
>
> baz ()
> {
>  for (; a;)
>    bar ();
> }
>        PR middle-end/49710
>        * cfgloopmanip.c (remove_path): Walk loop hiearchy upwards when
>        unlooping loops.
> Index: cfgloopmanip.c
> ===
> *** cfgloopmanip.c      (revision 182871)
> --- cfgloopmanip.c      (working copy)
> *** remove_path (edge e)
> *** 291,296 
> --- 291,297 
>    sbitmap seen;
>    bool irred_invalidated = false;
>    edge_iterator ei;
> +   struct loop *l;
>
>    if (!can_remove_branch_p (e))
>      return false;
> *** remove_path (edge e)
> *** 315,323 
>       normally.   We may assume that e->dest is not a header of any loop,
>       as it now has exactly one predecessor.  */
>    while (loop_outer (e->src->loop_father)
> !        && dominated_by_p (CDI_DOMINATORS,
> !                           e->src->loop_father->latch, e->dest))
>      unloop (e->src->loop_father, &irred_invalidated);
>
>    /* Identify the path.  */
>    nrem = find_path (e, &rem_bbs);
> --- 316,333 
>       normally.   We may assume that e->dest is not a header of any loop,
>       as it now has exactly one predecessor.  */
>    while (loop_outer (e->src->loop_father)
> !         && dominated_by_p (CDI_DOMINATORS,
> !                            e->src->loop_father->latch, e->dest))
>      unloop (e->src->loop_father, &irred_invalidated);
> +   l = e->src->loop_father;
> +   while (l && loop_outer (l))
> +     {
> +       while (loop_outer (loop_outer (l))
> +            && dominated_by_p (CDI_DOMINATORS,
> +                               loop_outer (l)->latch, e->dest))
> +         unloop (loop_outer (l), &irred_invalidated);
> +       l = loop_outer (l);
> +     }

It must be possible to merge the two loops, no?  And it asks for a
comment.

>    /* Identify the path.  */
>    nrem = find_path (e, &rem_bbs);


Re: PR rtl-optimization/49710 (segfault in loop peeling)

2012-01-04 Thread Jan Hubicka
> > +   l = e->src->loop_father;
> > +   while (l && loop_outer (l))
> > +     {
> > +       while (loop_outer (loop_outer (l))
> > +            && dominated_by_p (CDI_DOMINATORS,
> > +                               loop_outer (l)->latch, e->dest))
> > +         unloop (loop_outer (l), &irred_invalidated);
> > +       l = loop_outer (l);
> > +     }
> 
> It must be possible to merge the two loops, no?  And it asks for a
> comment.

The problem is that unloop can cascade, so looking up loop_father for the
innermost loop and looking at loop_outer pointer elsewhere is the only up to
date way to get to the next unlooping candidate, so I did not see any natural
way to really merge the loops.

The comment before the two loops is still correct, just implementation was
buggy.

Honza
> 
> >    /* Identify the path.  */
> >    nrem = find_path (e, &rem_bbs);


Re: PR rtl-optimization/49710 (segfault in loop peeling)

2012-01-04 Thread Richard Guenther
2012/1/4 Jan Hubicka :
>> > +   l = e->src->loop_father;
>> > +   while (l && loop_outer (l))
>> > +     {
>> > +       while (loop_outer (loop_outer (l))
>> > +            && dominated_by_p (CDI_DOMINATORS,
>> > +                               loop_outer (l)->latch, e->dest))
>> > +         unloop (loop_outer (l), &irred_invalidated);
>> > +       l = loop_outer (l);
>> > +     }
>>
>> It must be possible to merge the two loops, no?  And it asks for a
>> comment.
>
> The problem is that unloop can cascade, so looking up loop_father for the
> innermost loop and looking at loop_outer pointer elsewhere is the only up to
> date way to get to the next unlooping candidate, so I did not see any natural
> way to really merge the loops.
>
> The comment before the two loops is still correct, just implementation was
> buggy.

I see.  Patch is ok then.

Richard.

> Honza
>>
>> >    /* Identify the path.  */
>> >    nrem = find_path (e, &rem_bbs);


[PATCH] Fix PR51750

2012-01-04 Thread Richard Guenther

Another manifestation about the issue we have wrt sizetypes
implicitly sign-extending but types-compatible types not.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.

Richard.

2012-01-04  Richard Guenther  

PR middle-end/51750
* tree.c (size_low_cst): New function.
* tree.h (size_low_cst): Declare.
* fold-const.c (fold_comparison): Use it to extract the low
part of the POINTER_PLUS_EXPR offset.

Index: gcc/tree.c
===
--- gcc/tree.c  (revision 182867)
+++ gcc/tree.c  (working copy)
@@ -6509,6 +6509,17 @@ tree_low_cst (const_tree t, int pos)
   return TREE_INT_CST_LOW (t);
 }
 
+/* Return the HOST_WIDE_INT least significant bits of T, a sizetype
+   kind INTEGER_CST.  This makes sure to properly sign-extend the
+   constant.  */
+
+HOST_WIDE_INT
+size_low_cst (const_tree t)
+{
+  double_int d = tree_to_double_int (t);
+  return double_int_sext (d, TYPE_PRECISION (TREE_TYPE (t))).low;
+}
+
 /* Return the most significant (sign) bit of T.  */
 
 int
Index: gcc/tree.h
===
--- gcc/tree.h  (revision 182867)
+++ gcc/tree.h  (working copy)
@@ -4428,6 +4428,7 @@ tree_low_cst (const_tree t, int pos)
   return TREE_INT_CST_LOW (t);
 }
 #endif
+extern HOST_WIDE_INT size_low_cst (const_tree);
 extern int tree_int_cst_sgn (const_tree);
 extern int tree_int_cst_sign_bit (const_tree);
 extern unsigned int tree_int_cst_min_precision (tree, bool);
Index: gcc/fold-const.c
===
--- gcc/fold-const.c(revision 182867)
+++ gcc/fold-const.c(working copy)
@@ -8886,13 +8886,16 @@ fold_comparison (location_t loc, enum tr
  indirect_base0 = true;
}
  offset0 = TREE_OPERAND (arg0, 1);
- if (host_integerp (offset0, 0)
- && ((HOST_WIDE_INT) (TREE_INT_CST_LOW (offset0) * BITS_PER_UNIT)
- / BITS_PER_UNIT
- == (HOST_WIDE_INT) TREE_INT_CST_LOW (offset0)))
+ if (host_integerp (offset0, 0))
{
- bitpos0 = TREE_INT_CST_LOW (offset0) * BITS_PER_UNIT;
- offset0 = NULL_TREE;
+ HOST_WIDE_INT off = size_low_cst (offset0);
+ if ((HOST_WIDE_INT) (((unsigned HOST_WIDE_INT) off)
+  * BITS_PER_UNIT)
+ / BITS_PER_UNIT == (HOST_WIDE_INT) off)
+   {
+ bitpos0 = off * BITS_PER_UNIT;
+ offset0 = NULL_TREE;
+   }
}
}
 
@@ -8917,13 +8920,16 @@ fold_comparison (location_t loc, enum tr
  indirect_base1 = true;
}
  offset1 = TREE_OPERAND (arg1, 1);
- if (host_integerp (offset1, 0)
- && ((HOST_WIDE_INT) (TREE_INT_CST_LOW (offset1) * BITS_PER_UNIT)
- / BITS_PER_UNIT
- == (HOST_WIDE_INT) TREE_INT_CST_LOW (offset1)))
+ if (host_integerp (offset1, 0))
{
- bitpos1 = TREE_INT_CST_LOW (offset1) * BITS_PER_UNIT;
- offset1 = NULL_TREE;
+ HOST_WIDE_INT off = size_low_cst (offset1);
+ if ((HOST_WIDE_INT) (((unsigned HOST_WIDE_INT) off)
+  * BITS_PER_UNIT)
+ / BITS_PER_UNIT == (HOST_WIDE_INT) off)
+   {
+ bitpos1 = off * BITS_PER_UNIT;
+ offset1 = NULL_TREE;
+   }
}
}
 


Re: PR rtl-optimization/49710 (segfault in loop peeling)

2012-01-04 Thread Zdenek Dvorak
Hi,

> --- 316,333 
>normally.   We may assume that e->dest is not a header of any loop,
>as it now has exactly one predecessor.  */
> while (loop_outer (e->src->loop_father)
> ! && dominated_by_p (CDI_DOMINATORS,
> !e->src->loop_father->latch, e->dest))
>   unloop (e->src->loop_father, &irred_invalidated);
> +   l = e->src->loop_father;
> +   while (l && loop_outer (l))
> + {
> +   while (loop_outer (loop_outer (l))
> +  && dominated_by_p (CDI_DOMINATORS,
> + loop_outer (l)->latch, e->dest))
> + unloop (loop_outer (l), &irred_invalidated);
> +   l = loop_outer (l);
> + }

this will not work when e->src->loop_father is the cancelled loop,
since the first loop tested for removal is loop_outer (e->src->loop_father).

I would suggest

for (l = e->src->loop_father; loop_outer (l); l = f)
  {
f = loop_outer (l);
if (dominated_by_p (CDI_DOMINATORS, l->latch, e->dest))
  unloop (l, &irred_invalidated);
  }

Otherwise ok,

Zdenek


Re: PR rtl-optimization/49710 (segfault in loop peeling)

2012-01-04 Thread Jan Hubicka
> Hi,
> 
> > --- 316,333 
> >normally.   We may assume that e->dest is not a header of any loop,
> >as it now has exactly one predecessor.  */
> > while (loop_outer (e->src->loop_father)
> > ! && dominated_by_p (CDI_DOMINATORS,
> > !e->src->loop_father->latch, e->dest))
> >   unloop (e->src->loop_father, &irred_invalidated);
> > +   l = e->src->loop_father;
> > +   while (l && loop_outer (l))
> > + {
> > +   while (loop_outer (loop_outer (l))
> > +&& dominated_by_p (CDI_DOMINATORS,
> > +   loop_outer (l)->latch, e->dest))
> > + unloop (loop_outer (l), &irred_invalidated);
> > +   l = loop_outer (l);
> > + }
> 
> this will not work when e->src->loop_father is the cancelled loop,
> since the first loop tested for removal is loop_outer (e->src->loop_father).
> 
> I would suggest
> 
> for (l = e->src->loop_father; loop_outer (l); l = f)
>   {
> f = loop_outer (l);
> if (dominated_by_p (CDI_DOMINATORS, l->latch, e->dest))
>   unloop (l, &irred_invalidated);
>   }
> 
> Otherwise ok,

OK, I will re-test with this variant, it is shorter indeed ;)

Thanks,
Honza
> 
> Zdenek


[C++ Patch] PR 51064

2012-01-04 Thread Paolo Carlini

Hi,

we emit spurious -Wparentheses warnings for template arguments, 
evidently because we are not propagating TREE_NO_WARNING during 
tsubstitution.


I'm fixing the problem in a straightforward way, by using the same idiom 
already used elsewhere: call build_x_binary_op and then propagate 
TREE_NO_WARNING to the resulting tree before returning it. The testcase 
is somewhat extended vs that in the PR: I wanted to exercise the warning 
a bit more and double check that we are still producing it when in order.


Tested x86_64-linux.

Thanks,
Paolo.

///
/cp
2012-01-04  Paolo Carlini  

PR c++/51064
* pt.c (tsubst_copy_and_build): Maybe set TREE_NO_WARNING on
the tree returned by build_x_binary_op.

/testsuite
2012-01-04  Paolo Carlini  

PR c++/51064
* g++.dg/warn/Wparentheses-26.C: New.

Index: testsuite/g++.dg/warn/Wparentheses-26.C
===
--- testsuite/g++.dg/warn/Wparentheses-26.C (revision 0)
+++ testsuite/g++.dg/warn/Wparentheses-26.C (revision 0)
@@ -0,0 +1,26 @@
+// PR c++/51064
+// { dg-options "-Wparentheses" }
+
+template> 3)> class foo1 { };
+typedef foo1<10> bar1;
+
+template> 3)> class foo2 { };
+typedef foo2<10> bar2;  // { dg-warning "suggest parentheses around '\\+'" }
+
+template> (i + 2))> class foo3 { };
+typedef foo3<3> bar3;
+
+template> i + 2)> class foo4 { }; 
+typedef foo4<3> bar4;   // { dg-warning "suggest parentheses around '\\+'" }
+
+template class foo5 { };
+typedef foo5<10> bar5;
+
+template class foo6 { };
+typedef foo6<10> bar6;  // { dg-warning "suggest parentheses around 
arithmetic" }
+
+template class foo7 { };
+typedef foo7<10> bar7;
+
+template class foo8 { };
+typedef foo8<10> bar8;  // { dg-warning "suggest parentheses around 
arithmetic" }
Index: cp/pt.c
===
--- cp/pt.c (revision 182870)
+++ cp/pt.c (working copy)
@@ -13563,18 +13563,23 @@ tsubst_copy_and_build (tree t,
 case GT_EXPR:
 case MEMBER_REF:
 case DOTSTAR_EXPR:
-  return build_x_binary_op
-   (TREE_CODE (t),
-RECUR (TREE_OPERAND (t, 0)),
-(TREE_NO_WARNING (TREE_OPERAND (t, 0))
- ? ERROR_MARK
- : TREE_CODE (TREE_OPERAND (t, 0))),
-RECUR (TREE_OPERAND (t, 1)),
-(TREE_NO_WARNING (TREE_OPERAND (t, 1))
- ? ERROR_MARK
- : TREE_CODE (TREE_OPERAND (t, 1))),
-/*overload=*/NULL,
-complain);
+  {
+   tree r = build_x_binary_op
+ (TREE_CODE (t),
+  RECUR (TREE_OPERAND (t, 0)),
+  (TREE_NO_WARNING (TREE_OPERAND (t, 0))
+   ? ERROR_MARK
+   : TREE_CODE (TREE_OPERAND (t, 0))),
+  RECUR (TREE_OPERAND (t, 1)),
+  (TREE_NO_WARNING (TREE_OPERAND (t, 1))
+   ? ERROR_MARK
+   : TREE_CODE (TREE_OPERAND (t, 1))),
+  /*overload=*/NULL,
+  complain);
+   if (TREE_NO_WARNING (t))
+ TREE_NO_WARNING (r) = TREE_NO_WARNING (t);
+   return r;
+  }
 
 case SCOPE_REF:
   return tsubst_qualified_id (t, args, complain, in_decl, /*done=*/true,


[PATCH] Add missed adjustment to label_nuses in reload.

2012-01-04 Thread Marcus Shawcroft
Reload (find_reloads) has code that can replace a register with a 
label_ref when presented with RTL of the form:


(set (reg) (reg) (notes (rtx_equal (label_ref)))

Label references are initially counted in jump.c:mark_all_labels() and 
friends. This code traverses the RTL and counts each observed label_ref. 
The code inserts REG_LABEL_OPERAND or REG_LABEL_TARGET as appropriate. 
Notes are not traversed therefore the (rtx_equal (label_ref)) shown 
above is not treated as a reference.


Instruction deletion, in cfgrtl.c:delete_insn() does not re-traverse the 
RTL, The code traverses only the notes looking for REG_LABEL_OPERAND and 
REG_TARGET_OPERAND notes in order to count down the label_nuses field.


The code in reload.c:find_reloads() converts a register to a label_ref 
and inserts the associated REG_LABEL_OPERAND but does not adjust 
label_nuses, this may result in the inappropriate deletion of a live label.


This issue was discovered during the development of the ARM aarch64 gcc 
backend and results in an ICE due to deletion of a live jump table.


The issue has not been re-created on another target. The proposed patch 
has been regressed on x86 (and aarch64).


Proposed ChangeLog entry below, patch attached:

2012-01-04  Marcus Shawcroft  

* reload.c (find_reloads): Adjust LABEL_NUSES on
  REG_LABEL_OPERAND insertion.

/Marcusdiff --git a/gcc/reload.c b/gcc/reload.c
index 53dcd2d..206fb36 100644
--- a/gcc/reload.c
+++ b/gcc/reload.c
@@ -4212,7 +4212,12 @@ find_reloads (rtx insn, int replace, int ind_levels, int live_known,
 	  && (!JUMP_P (insn)
 		  || !label_is_jump_target_p (XEXP (substitution, 0),
 	  insn)))
-	add_reg_note (insn, REG_LABEL_OPERAND, XEXP (substitution, 0));
+	{
+	  add_reg_note (insn, REG_LABEL_OPERAND, XEXP (substitution, 0));
+	  if (LABEL_P (XEXP (substitution, 0)))
+		++ LABEL_NUSES(XEXP (substitution, 0));
+	}
+
 	}
   else
 	retval |= (substed_operand[i] != *recog_data.operand_loc[i]);

[Patch,AVR]: Cleanup avr_replace_prefix

2012-01-04 Thread Georg-Johann Lay
This removes avr_replace_prefix and rewrites the callers to use ACONCAT.

Passes without regressions.

Ok for trunk?

Johann

* config/avr/avr.c (avr_replace_prefix): Remove.
(avr_asm_named_section): Use ACONCAT instead of avr_replace_prefix.
(avr_asm_function_rodata_section): Ditto.
(avr_asm_select_section): Ditto.
Index: config/avr/avr.c
===
--- config/avr/avr.c	(revision 182871)
+++ config/avr/avr.c	(working copy)
@@ -301,31 +301,6 @@ bool avr_need_copy_data_p = false;
 
 
 
-/* Custom function to replace string prefix.
-
-   Return a ggc-allocated string with strlen (OLD_PREFIX) characters removed
-   from the start of OLD_STR and then prepended with NEW_PREFIX.  */
-
-static inline const char*
-avr_replace_prefix (const char *old_str,
-const char *old_prefix, const char *new_prefix)
-{
-  char *new_str;
-  size_t len = strlen (old_str) + strlen (new_prefix) - strlen (old_prefix);
-
-  gcc_assert (strlen (old_prefix) <= strlen (old_str));
-
-  /* Unfortunately, ggc_alloc_string returns a const char* and thus cannot be
- used here.  */
- 
-  new_str = (char*) ggc_alloc_atomic (1 + len);
-
-  strcat (stpcpy (new_str, new_prefix), old_str + strlen (old_prefix));
-  
-  return (const char*) new_str;
-}
-
-
 /* Custom function to count number of set bits.  */
 
 static inline int
@@ -7196,9 +7171,8 @@ avr_asm_function_rodata_section (tree de
 
   if (STR_PREFIX_P (name, old_prefix))
 {
-  const char *rname = avr_replace_prefix (name,
-  old_prefix, new_prefix);
-
+  const char *rname = ACONCAT ((new_prefix,
+name + strlen (old_prefix), NULL));
   flags &= ~SECTION_CODE;
   flags |= AVR_HAVE_JMP_CALL ? 0 : SECTION_CODE;
   
@@ -7223,15 +7197,16 @@ avr_asm_named_section (const char *name,
   int segment = avr_addrspace[as].segment % avr_current_arch->n_segments;
   const char *old_prefix = ".rodata";
   const char *new_prefix = progmem_section_prefix[segment];
-  const char *sname = new_prefix;
   
   if (STR_PREFIX_P (name, old_prefix))
 {
-  sname = avr_replace_prefix (name, old_prefix, new_prefix);
+  const char *sname = ACONCAT ((new_prefix,
+name + strlen (old_prefix), NULL));
+  default_elf_asm_named_section (sname, flags, decl);
+  return;
 }
 
-  default_elf_asm_named_section (sname, flags, decl);
-
+  default_elf_asm_named_section (new_prefix, flags, decl);
   return;
 }
   
@@ -7326,9 +7301,8 @@ avr_asm_select_section (tree decl, int r
 
   if (STR_PREFIX_P (name, old_prefix))
 {
-  const char *sname = avr_replace_prefix (name,
-  old_prefix, new_prefix);
-
+  const char *sname = ACONCAT ((new_prefix,
+name + strlen (old_prefix), NULL));
   return get_section (sname, sect->common.flags, sect->named.decl);
 }
 }


Re: PR middle-end/51212: sorry out on -fgnu-tm + -fnon-call-exceptions

2012-01-04 Thread Aldy Hernandez

On 01/03/12 14:33, Richard Henderson wrote:

On 01/04/2012 01:10 AM, Aldy Hernandez wrote:

I can certainly do this.  I am however, waiting for the final approval.  It 
wasn't clear whether that was an approval from Richard Henderson, or whether I 
should wait for an official ok.

OK for mainline?


Yes, it was approval.


r~


Richi, this is the patch I committed with your suggestions for the 
documentation (*).  Let me know if you'd like it worded different.


(*) Note, the test got committed by mistake in my previous commit a few 
minutes ago along with my previous fix.  Sorry about that.
PR middle-end/51212
* opts.c (finish_options): Sorry out when using transactional
memory and non-call exceptions.
* doc/invoke.texi (C Dialect Options): Document it.

Index: doc/invoke.texi
===
--- doc/invoke.texi (revision 182848)
+++ doc/invoke.texi (working copy)
@@ -1742,6 +1742,9 @@ For more information on GCC's support fo
 @xref{Enabling libitm,,The GNU Transactional Memory Library,libitm,GNU
 Transactional Memory Library}.
 
+Note that the transactional memory feature is not supported with
+non-call exceptions (@option{-fnon-call-exceptions}).
+
 @item -fms-extensions
 @opindex fms-extensions
 Accept some non-standard constructs used in Microsoft header files.
Index: opts.c
===
--- opts.c  (revision 182876)
+++ opts.c  (working copy)
@@ -666,6 +666,9 @@ finish_options (struct gcc_options *opts
   if (opts->x_flag_tm && opts->x_flag_non_call_exceptions)
 sorry ("transactional memory is not supported with non-call exceptions");
 
+  if (opts->x_flag_tm && opts->x_flag_non_call_exceptions)
+sorry ("transactional memory is not supported with non-call exceptions");
+
   /* -Wmissing-noreturn is alias for -Wsuggest-attribute=noreturn.  */
   if (opts->x_warn_missing_noreturn)
 opts->x_warn_suggest_attribute_noreturn = true;


Re: PR middle-end/51212: sorry out on -fgnu-tm + -fnon-call-exceptions

2012-01-04 Thread Aldy Hernandez

On 01/04/12 08:55, Aldy Hernandez wrote:

On 01/03/12 14:33, Richard Henderson wrote:

On 01/04/2012 01:10 AM, Aldy Hernandez wrote:

I can certainly do this. I am however, waiting for the final
approval. It wasn't clear whether that was an approval from Richard
Henderson, or whether I should wait for an official ok.

OK for mainline?


Yes, it was approval.


r~


Richi, this is the patch I committed with your suggestions for the
documentation (*). Let me know if you'd like it worded different.

(*) Note, the test got committed by mistake in my previous commit a few
minutes ago along with my previous fix. Sorry about that.


Arghhh... It seems I had already committed this patch before the 
holidays, but I had mistakenly thought it hadn't been approved nor 
committed.  Consequently, the last patch was a duplicate (with the 
exception of the documentation change).


I am embarrassingly committing the following.  Blame it on the holiday 
mojitos.
* opts.c (finish_options): Remove duplicate sorry.

Index: opts.c
===
--- opts.c  (revision 182877)
+++ opts.c  (working copy)
@@ -666,9 +666,6 @@ finish_options (struct gcc_options *opts
   if (opts->x_flag_tm && opts->x_flag_non_call_exceptions)
 sorry ("transactional memory is not supported with non-call exceptions");
 
-  if (opts->x_flag_tm && opts->x_flag_non_call_exceptions)
-sorry ("transactional memory is not supported with non-call exceptions");
-
   /* -Wmissing-noreturn is alias for -Wsuggest-attribute=noreturn.  */
   if (opts->x_warn_missing_noreturn)
 opts->x_warn_suggest_attribute_noreturn = true;


Re: [C++ Patch] PR 51064

2012-01-04 Thread Jason Merrill
I'm a bit nervous about the instantiated tree being a different kind of 
tree from the template one, such that TREE_NO_WARNING doesn't make sense 
on the new one.  Maybe just check EXPR_P (r) as well.


Jason


Re: [C++ Patch] PR 51064

2012-01-04 Thread Paolo Carlini

Hi,
I'm a bit nervous about the instantiated tree being a different kind 
of tree from the template one, such that TREE_NO_WARNING doesn't make 
sense on the new one.  Maybe just check EXPR_P (r) as well.

I see, better be safe. The below still passes testing. Ok?

Thanks,
Paolo.


Index: testsuite/g++.dg/warn/Wparentheses-26.C
===
--- testsuite/g++.dg/warn/Wparentheses-26.C (revision 0)
+++ testsuite/g++.dg/warn/Wparentheses-26.C (revision 0)
@@ -0,0 +1,26 @@
+// PR c++/51064
+// { dg-options "-Wparentheses" }
+
+template> 3)> class foo1 { };
+typedef foo1<10> bar1;
+
+template> 3)> class foo2 { };
+typedef foo2<10> bar2;  // { dg-warning "suggest parentheses around '\\+'" }
+
+template> (i + 2))> class foo3 { };
+typedef foo3<3> bar3;
+
+template> i + 2)> class foo4 { }; 
+typedef foo4<3> bar4;   // { dg-warning "suggest parentheses around '\\+'" }
+
+template class foo5 { };
+typedef foo5<10> bar5;
+
+template class foo6 { };
+typedef foo6<10> bar6;  // { dg-warning "suggest parentheses around 
arithmetic" }
+
+template class foo7 { };
+typedef foo7<10> bar7;
+
+template class foo8 { };
+typedef foo8<10> bar8;  // { dg-warning "suggest parentheses around 
arithmetic" }
Index: cp/pt.c
===
--- cp/pt.c (revision 182870)
+++ cp/pt.c (working copy)
@@ -13563,18 +13563,23 @@ tsubst_copy_and_build (tree t,
 case GT_EXPR:
 case MEMBER_REF:
 case DOTSTAR_EXPR:
-  return build_x_binary_op
-   (TREE_CODE (t),
-RECUR (TREE_OPERAND (t, 0)),
-(TREE_NO_WARNING (TREE_OPERAND (t, 0))
- ? ERROR_MARK
- : TREE_CODE (TREE_OPERAND (t, 0))),
-RECUR (TREE_OPERAND (t, 1)),
-(TREE_NO_WARNING (TREE_OPERAND (t, 1))
- ? ERROR_MARK
- : TREE_CODE (TREE_OPERAND (t, 1))),
-/*overload=*/NULL,
-complain);
+  {
+   tree r = build_x_binary_op
+ (TREE_CODE (t),
+  RECUR (TREE_OPERAND (t, 0)),
+  (TREE_NO_WARNING (TREE_OPERAND (t, 0))
+   ? ERROR_MARK
+   : TREE_CODE (TREE_OPERAND (t, 0))),
+  RECUR (TREE_OPERAND (t, 1)),
+  (TREE_NO_WARNING (TREE_OPERAND (t, 1))
+   ? ERROR_MARK
+   : TREE_CODE (TREE_OPERAND (t, 1))),
+  /*overload=*/NULL,
+  complain);
+   if (EXPR_P (r) && TREE_NO_WARNING (t))
+ TREE_NO_WARNING (r) = TREE_NO_WARNING (t);
+   return r;
+  }
 
 case SCOPE_REF:
   return tsubst_qualified_id (t, args, complain, in_decl, /*done=*/true,


[vms]: factorize vms entries in config.build

2012-01-04 Thread Tristan Gingold
Hi,

little clean-up for the VMS entries in config.build.

Tested on both ia64-hp-openvms and alpha64-dec-openvms.

Committed on trunk.

Tristan.

2012-01-04  Tristan Gingold  

* config/vms/xm-vms.h (HOST_LONG_FORMAT, HOST_PTR_PRINTF): Define
when long pointers are used.
* config.build (*-*-*vms*): Handle all OpenVMS targets.
(alpha64-dec-*vms*, alpha*-dec-*vms*)
(ia64-hp-*vms*): Remove.
* config/vms/xm-vms64.h: Delete.

Index: config/vms/xm-vms64.h
===
--- config/vms/xm-vms64.h   (revision 182878)
+++ config/vms/xm-vms64.h   (working copy)
@@ -1,23 +0,0 @@
-/* Configuration for GCC for hosting on 64bit VMS
-   using a Unix style C library.
-   Copyright (C) 2009
-   Free Software Foundation, Inc.
-
-This file is part of GCC.
-
-GCC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3, or (at your option)
-any later version.
-
-GCC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING3.  If not see
-.  */
-
-#define HOST_LONG_FORMAT "ll"
-#define HOST_PTR_PRINTF "%llp"
Index: config/vms/xm-vms.h
===
--- config/vms/xm-vms.h (revision 182878)
+++ config/vms/xm-vms.h (working copy)
@@ -53,4 +53,12 @@
}  \
   } while (0)
 
+/* If 64 bit pointers are used, use 64 bit specifier.  */
+
+#if (defined (__INITIAL_POINTER_SIZE) && __INITIAL_POINTER_SIZE == 64) \
+  || defined (__LONG_POINTERS)
+#define HOST_LONG_FORMAT "ll"
+#define HOST_PTR_PRINTF "%llp"
+#endif
+
 #define STANDARD_STARTFILE_PREFIX "/gnu/lib/"
Index: config.build
===
--- config.build(revision 182878)
+++ config.build(working copy)
@@ -52,20 +52,6 @@
 
 # System-specific settings.
 case $build in
-  alpha64-dec-*vms*)
-build_xm_file="vms/xm-vms.h vms/xm-vms64.h"
-build_exeext=.exe
-build_install_headers_dir=install-headers-cp
-prefix=/gnu
-local_prefix=/gnu/local
-;;
-  alpha*-dec-*vms*)
-build_xm_file="vms/xm-vms.h"
-build_exeext=.exe
-build_install_headers_dir=install-headers-cp
-prefix=/gnu
-local_prefix=/gnu/local
-;;
   hppa1.0-*-hpux1[01]* | \
   hppa*64*-*-hpux11* | \
   hppa1.1-*-hpux11* | \
@@ -114,13 +100,6 @@
   i386-*-vsta) 
 # Intel 80386's running VSTa kernel
 ;;
-  ia64-hp-*vms*)
-build_xm_file="vms/xm-vms.h vms/xm-vms64.h"
-build_exeext=.exe
-build_install_headers_dir=install-headers-cp
-prefix=/gnu
-local_prefix=/gnu/local
-;;
   m68000-hp-hpux* | m68k-hp-hpux*) 
 # HP 9000 series 300
 build_install_headers_dir=install-headers-cpio
@@ -129,5 +108,11 @@
 # All other System V variants.
 build_install_headers_dir=install-headers-cpio
 ;;
+  *-*-*vms*)
+# All OpenVMS targets.
+build_xm_file="vms/xm-vms.h"
+build_exeext=.exe
+build_install_headers_dir=install-headers-cp
+;;
 esac
 



Re: [RFC][patch] trans-mem: mark transaction begins as returns-twice

2012-01-04 Thread Patrick Marlier

On 01/02/2012 01:10 PM, Torvald Riegel wrote:

This was motivated by the miscompilation of one of the STAMP
applications (Genome), where a stack slot was used as temp storage for a
CPU register but not restored when the transaction got aborted and
restarted (then, after restart, the program crashed because it used
inconsistent data).  With the attached patch and in this particular
example, the stack slots that are written to in the transaction do not
get read during the transaction.  (-fno-caller-saves was not a
sufficient solution, BTW.)


Are you sure this not due to the missing of tm-logging? We xfail until 
now for the testsuite but this should be addressed. (Note that I tested 
genome months ago and it was working correctly.)


By the way, what's the status of this problem of tm-logging?

Patrick.


Re: [C++ Patch] PR 51064

2012-01-04 Thread Jason Merrill

OK.

Jason


Re: [PATCH] Fix PR tree-optimization/51315

2012-01-04 Thread Eric Botcazou
> OK.  But passing small structures by value doesn't seem that rare --
> especially in C++ -- and it doesn't feel right to disable SRA just because
> the backend likes to increase the alignment of stack vars.

Agreed.

> ...something like this sounds good, although you seem less than happy
> with it :-)

Just not very comfortable with it, as we're walking a thin line.  I've attached 
a more "dangerous" testcase that is now optimized again (and still works).

Regtested on SPARC/Solaris.  Can you confirm that this fixes the pessimization 
in all cases (and run the C testsuite for your favorite ABI variant)?  TIA.


PR tree-optimization/51315
* tree-sra.c (tree_non_aligned_mem_for_access_p): New predicate.
(build_accesses_from_assign): Use it instead of tree_non_aligned_mem_p.


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


-- 
Eric Botcazou
struct __attribute__((packed)) S
{
  int a, b, c;
};

static int __attribute__ ((noinline,noclone))
extract(const char *p)
{
  struct S s;
  __builtin_memcpy (&s, p, sizeof(struct S));
  return s.a;
}

int i;

int main (void)
{
  char p[sizeof(struct S) + 1];

  __builtin_memset (p, 0, sizeof(struct S) + 1);
  i = extract (p + 1);

  return 0;
}
Index: tree-sra.c
===
--- tree-sra.c	(revision 182780)
+++ tree-sra.c	(working copy)
@@ -1095,6 +1095,25 @@ tree_non_aligned_mem_p (tree exp, unsign
   return false;
 }
 
+/* Return true if EXP is a memory reference less aligned than what the access
+   ACC would require.  This is invoked only on strict-alignment targets.  */
+
+static bool
+tree_non_aligned_mem_for_access_p (tree exp, struct access *acc)
+{
+  unsigned int acc_align;
+
+  /* The alignment of the access is that of its expression.  However, it may
+ have been artificially increased, e.g. by a local alignment promotion,
+ so we cap it to the alignment of the type of the base, on the grounds
+ that valid sub-accesses cannot be more aligned than that.  */
+  acc_align = get_object_alignment (acc->expr);
+  if (acc->base && acc_align > TYPE_ALIGN (TREE_TYPE (acc->base)))
+acc_align = TYPE_ALIGN (TREE_TYPE (acc->base));
+
+  return tree_non_aligned_mem_p (exp, acc_align);
+}
+
 /* Scan expressions occuring in STMT, create access structures for all accesses
to candidates for scalarization and remove those candidates which occur in
statements or expressions that prevent them from being split apart.  Return
@@ -1123,8 +1142,7 @@ build_accesses_from_assign (gimple stmt)
   if (lacc)
 {
   lacc->grp_assignment_write = 1;
-  if (STRICT_ALIGNMENT
-	  && tree_non_aligned_mem_p (rhs, get_object_alignment (lhs)))
+  if (STRICT_ALIGNMENT && tree_non_aligned_mem_for_access_p (rhs, lacc))
 lacc->grp_unscalarizable_region = 1;
 }
 
@@ -1134,8 +1152,7 @@ build_accesses_from_assign (gimple stmt)
   if (should_scalarize_away_bitmap && !gimple_has_volatile_ops (stmt)
 	  && !is_gimple_reg_type (racc->type))
 	bitmap_set_bit (should_scalarize_away_bitmap, DECL_UID (racc->base));
-  if (STRICT_ALIGNMENT
-	  && tree_non_aligned_mem_p (lhs, get_object_alignment (rhs)))
+  if (STRICT_ALIGNMENT && tree_non_aligned_mem_for_access_p (lhs, racc))
 racc->grp_unscalarizable_region = 1;
 }
 


Re: [RFC][patch] trans-mem: mark transaction begins as returns-twice

2012-01-04 Thread Aldy Hernandez

On 01/04/12 09:53, Patrick Marlier wrote:

On 01/02/2012 01:10 PM, Torvald Riegel wrote:

This was motivated by the miscompilation of one of the STAMP
applications (Genome), where a stack slot was used as temp storage for a
CPU register but not restored when the transaction got aborted and
restarted (then, after restart, the program crashed because it used
inconsistent data). With the attached patch and in this particular
example, the stack slots that are written to in the transaction do not
get read during the transaction. (-fno-caller-saves was not a
sufficient solution, BTW.)


Are you sure this not due to the missing of tm-logging? We xfail until
now for the testsuite but this should be addressed. (Note that I tested
genome months ago and it was working correctly.)

By the way, what's the status of this problem of tm-logging?


I'm chugging along on the TM PR's, but so far the bug reporters are 
beating me :).  I can move this problem to the top of the list if you 
want.  If so, what is the PR?


Re: [PATCH 9/9] [ARM] Remove artificial doloop_end pattern

2012-01-04 Thread Richard Earnshaw
On 21/07/11 17:30, zhr...@ispras.ru wrote:
> This patch eliminates fake doloop_end pattern for ARM platform.  The problem
> with such a pattern is that it slows down the loop when SMS doesn't create 
> good
> schedule.  So, i suppose fake pattern is no longer needed with new loop forms
> supported.
> 
> 2011-07-20  Roman Zhuykov  
>   * config/arm/thumb2.md (doloop_end): Delete.

I have no objections to this patch, but committing it needs to be
co-ordinated with the other SMS changes that are being discussed.
Deleting it today will, I think, cause SMS to be disabled and I don't
want that to happen.

R.

> ---
>  gcc/config/arm/thumb2.md |   51 
> --
>  1 files changed, 0 insertions(+), 51 deletions(-)
> 
> diff --git a/gcc/config/arm/thumb2.md b/gcc/config/arm/thumb2.md
> index 9a11012..492e765 100644
> --- a/gcc/config/arm/thumb2.md
> +++ b/gcc/config/arm/thumb2.md
> @@ -1101,54 +1101,3 @@
>operands[2] = GEN_INT (32 - INTVAL (operands[2]));
>")
>  
> -;; Define the subtract-one-and-jump insns so loop.c
> -;; knows what to generate.
> -(define_expand "doloop_end"
> -  [(use (match_operand 0 "" ""))  ; loop pseudo
> -   (use (match_operand 1 "" ""))  ; iterations; zero if unknown
> -   (use (match_operand 2 "" ""))  ; max iterations
> -   (use (match_operand 3 "" ""))  ; loop level
> -   (use (match_operand 4 "" ""))] ; label
> -  "TARGET_32BIT"
> -  "
> - {
> -   /* Currently SMS relies on the do-loop pattern to recognize loops
> -  where (1) the control part consists of all insns defining and/or
> -  using a certain 'count' register and (2) the loop count can be
> -  adjusted by modifying this register prior to the loop.
> -  ??? The possible introduction of a new block to initialize the
> -  new IV can potentially affect branch optimizations.  */
> -   if (optimize > 0 && flag_modulo_sched)
> -   {
> - rtx s0;
> - rtx bcomp;
> - rtx loc_ref;
> - rtx cc_reg;
> - rtx insn;
> - rtx cmp;
> -
> - /* Only use this on innermost loops.  */
> - if (INTVAL (operands[3]) > 1)
> -   FAIL;
> -
> - if (GET_MODE (operands[0]) != SImode)
> -   FAIL;
> -
> - s0 = operands [0];
> - if (TARGET_THUMB2)
> -   insn = emit_insn (gen_thumb2_addsi3_compare0 (s0, s0, GEN_INT (-1)));
> - else
> -   insn = emit_insn (gen_addsi3_compare0 (s0, s0, GEN_INT (-1)));
> -
> - cmp = XVECEXP (PATTERN (insn), 0, 0);
> - cc_reg = SET_DEST (cmp);
> - bcomp = gen_rtx_NE (VOIDmode, cc_reg, const0_rtx);
> - loc_ref = gen_rtx_LABEL_REF (VOIDmode, operands [4]);
> - emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx,
> -  gen_rtx_IF_THEN_ELSE (VOIDmode, bcomp,
> -loc_ref, pc_rtx)));
> - DONE;
> -   }else
> -  FAIL;
> - }")
> -




[trans-mem] remove xfail for tm alias testcases

2012-01-04 Thread Patrick Marlier

(From a old email in sent after the merge)

The output for "ealias" was changed in revision 158374.
* tree-ssa-structalias.c
(dump_solution_for_var): Always dump the solution.
Example
before: pp = same as mystruct
after:  pp = { ESCAPED NONLOCAL } same as mystruct

So the patch adjusts the output to be checked in the testcases and 
remove the xfail.


Tested on i686.
Ok to commit?
(don't have an account yet, thanks in advance for committer)

Patrick Marlier.

2012-01-04  Patrick Marlier  

* gcc.dg/tm/alias-1.c:  Adjust regexp.
* gcc.dg/tm/alias-2.c:  Adjust regexp.

Index: gcc.dg/tm/alias-1.c
===
--- gcc.dg/tm/alias-1.c (revision 182878)
+++ gcc.dg/tm/alias-1.c (working copy)
@@ -34,7 +34,7 @@ void f(void)
 }
 
 /* { dg-final { scan-tree-dump-times "mystruct = \{ .*ESCAPED" 1 "ealias" } } 
*/
-/* { dg-final { scan-tree-dump-times "someptr = same as mystruct" 1 "ealias" { 
xfail *-*-* } } } */
-/* { dg-final { scan-tree-dump-times "ui\..* = same as mystruct" 1 "ealias" { 
xfail *-*-* } } } */
-/* { dg-final { scan-tree-dump-times "pp\..* = same as mystruct" 1 "ealias" { 
xfail *-*-* } } } */
+/* { dg-final { scan-tree-dump-times "someptr = .*same as mystruct" 1 "ealias" 
} } */
+/* { dg-final { scan-tree-dump-times "ui\..* = .*same as mystruct" 1 "ealias" 
} } */
+/* { dg-final { scan-tree-dump-times "pp\..* = .*same as mystruct" 1 "ealias" 
} } */
 /* { dg-final { cleanup-tree-dump "ealias" } } */
Index: gcc.dg/tm/alias-2.c
===
--- gcc.dg/tm/alias-2.c (revision 182878)
+++ gcc.dg/tm/alias-2.c (working copy)
@@ -36,7 +36,7 @@ void foo()
   candy();
 }
 
-/* { dg-final { scan-tree-dump-times "ui\..* = same as mystruct" 1 "ealias" { 
xfail *-*-* } } } */
+/* { dg-final { scan-tree-dump-times "ui\..* = .*same as mystruct" 1 "ealias" 
} } */
 /* { dg-final { scan-tree-dump-times "mystruct.*ESCAPED" 1 "ealias" } } */
-/* { dg-final { scan-tree-dump-times "pp = same as mystruct" 1 "ealias" { 
xfail *-*-* } } } */
+/* { dg-final { scan-tree-dump-times "pp = .*same as mystruct" 1 "ealias" } } 
*/
 /* { dg-final { cleanup-tree-dump "ealias" } } */


Re: [trans-mem] remove xfail for tm alias testcases

2012-01-04 Thread Aldy Hernandez

On 01/04/12 10:51, Patrick Marlier wrote:

(From a old email in sent after the merge)

The output for "ealias" was changed in revision 158374.
* tree-ssa-structalias.c
(dump_solution_for_var): Always dump the solution.
Example
before: pp = same as mystruct
after: pp = { ESCAPED NONLOCAL } same as mystruct

So the patch adjusts the output to be checked in the testcases and
remove the xfail.

Tested on i686.
Ok to commit?
(don't have an account yet, thanks in advance for committer)


Absolutely!  OK as obvious.

Thanks.

I will commit.  Is there a PR associated with this so we can close it as 
well?


Re: [trans-mem] remove xfail for tm alias testcases

2012-01-04 Thread Patrick Marlier

I have just realized that there are bugreports for them.
So here the ChangeLog adjusted.

Patrick.

On 01/04/2012 11:51 AM, Patrick Marlier wrote:

(From a old email in sent after the merge)

The output for "ealias" was changed in revision 158374.
* tree-ssa-structalias.c
(dump_solution_for_var): Always dump the solution.
Example
before: pp = same as mystruct
after: pp = { ESCAPED NONLOCAL } same as mystruct

So the patch adjusts the output to be checked in the testcases and
remove the xfail.

Tested on i686.
Ok to commit?
(don't have an account yet, thanks in advance for committer)

Patrick Marlier.



2012-01-04  Patrick Marlier  

PR other/51163
PR other/51164
* gcc.dg/tm/alias-1.c:  Adjust regexp.
* gcc.dg/tm/alias-2.c:  Adjust regexp.



Re: [trans-mem] remove xfail for tm alias testcases

2012-01-04 Thread Aldy Hernandez

On 01/04/12 10:59, Patrick Marlier wrote:

I have just realized that there are bugreports for them.
So here the ChangeLog adjusted.


Adjusted, committed, and closed both PRs.

Thanks.


Re: [RFC][patch] trans-mem: mark transaction begins as returns-twice

2012-01-04 Thread Patrick Marlier

On 01/04/2012 11:40 AM, Aldy Hernandez wrote:

On 01/04/12 09:53, Patrick Marlier wrote:

On 01/02/2012 01:10 PM, Torvald Riegel wrote:

This was motivated by the miscompilation of one of the STAMP
applications (Genome), where a stack slot was used as temp storage for a
CPU register but not restored when the transaction got aborted and
restarted (then, after restart, the program crashed because it used
inconsistent data). With the attached patch and in this particular
example, the stack slots that are written to in the transaction do not
get read during the transaction. (-fno-caller-saves was not a
sufficient solution, BTW.)


Are you sure this not due to the missing of tm-logging? We xfail until
now for the testsuite but this should be addressed. (Note that I tested
genome months ago and it was working correctly.)

By the way, what's the status of this problem of tm-logging?


I'm chugging along on the TM PR's, but so far the bug reporters are
beating me :). I can move this problem to the top of the list if you
want. If so, what is the PR?


PR: 51165 51166 51167 51168
I let Torvald and you decide about the priority.

Patrick.


[PATCH] Prevent cselib substitution of FP, SP, SFP

2012-01-04 Thread Marcus Shawcroft

Alias analysis by DSE based on CSELIB expansion assumes that
references to the stack frame from different base registers (ie FP, SP)
never alias.

The comment block in cselib explains that cselib does not allow
substitution of FP, SP or SFP specifically in order not to break DSE.

However, the logic implemented in CSELIB uses two mutually recursive
functions to perform cse expansion, cselib_expand_value_rtx_1() and
expand_loc(). The first explicitly checks and rejects an attempt to
expand FP, SFP, SP, otherwise it calls expand_loc() to choose and
expansion for a value from the list of available expansions.

expand_loc() does not implement the equivalent logic for
SFP, FP and SP, rather it always prefers the first available value
expansion, falling back to a simple regno expansion.

Therefore given a value that can be expanded to either FP or another
value, expand_loc() will always reject FP in favour of the available
value expansion.

This patch ensures that expand_loc() prefers to substitute for a frame
register in order to preserve the behaviour expected by DSE.

This issue was found while developing the ARM aarch64 backend where
gcc.c-torture/execute/vector-2.c is mis-compiled with 
-fno-omit-frame-pointer. The issue has not been observed on another 
target. The patch has been regressed on x86 (and aarch64).


Patch attached, proposed ChangeLog:

2012-01-04  Marcus Shawcroft  

* cselib.c (expand_loc): Prefer a frame register
substitution.


/Marcusdiff --git a/gcc/cselib.c b/gcc/cselib.c
index fc86ef1..7159ca4 100644
--- a/gcc/cselib.c
+++ b/gcc/cselib.c
@@ -1331,11 +1331,32 @@ cselib_lookup_mem (rtx x, int create)
   return mem_elt;
 }
 
-/* Search thru the possible substitutions in P.  We prefer a non reg
-   substitution because this allows us to expand the tree further.  If
-   we find, just a reg, take the lowest regno.  There may be several
-   non-reg results, we just take the first one because they will all
-   expand to the same place.  */
+/* Search through the possible substitutions in P.
+
+   We prefer in order:
+   1) STACK_POINTER_REGNUM, FRAME_POINTER or the HARD_FRAME_POINTER.
+   2) A non reg substitution because this allows us to expand the tree further.
+   3) The lowest regno.
+
+   We are not willing to substitute the STACK_POINTER_REGNUM,
+   FRAME_POINTER or the HARD_FRAME_POINTER. This is requirement of
+   DSE.
+
+   These expansions confuse the code that notices that stores
+   into the frame go dead at the end of the function and that the
+   frame is not affected by calls to subroutines.
+
+   If STACK_POINTER_REGNUM substitution is allowed, DSE will think
+   that parameter pushing also goes dead which is wrong.
+
+   If FRAME_POINTER or HARD_FRAME_POINTER substitution is allowed then
+   you lose the opportunity to make the frame assumptions.
+
+   If other potential uses need to substitute these frame registers we
+   should add a parameter to control this behavior.
+
+   There may be several non register results, we just take the first
+   one because they will all expand to the same place.  */
 
 static rtx
 expand_loc (struct elt_loc_list *p, struct expand_value_data *evd,
@@ -1345,7 +1366,24 @@ expand_loc (struct elt_loc_list *p, struct expand_value_data *evd,
   unsigned int regno = UINT_MAX;
   struct elt_loc_list *p_in = p;
 
-  for (; p; p = p -> next)
+  /* Prefer a frame related register over any other option.  */
+  for (p = p_in; p; p = p -> next)
+{
+  if ((REG_P (p->loc))
+	  && (REGNO (p->loc) < regno)
+	  && !bitmap_bit_p (evd->regs_active, REGNO (p->loc)))
+	{
+	  unsigned int candidate_regno = REGNO (p->loc);
+	  if (candidate_regno == STACK_POINTER_REGNUM
+	  || candidate_regno == FRAME_POINTER_REGNUM
+	  || candidate_regno == HARD_FRAME_POINTER_REGNUM)
+	{
+	  return p->loc;
+	}
+	}
+}
+
+  for (p = p_in; p; p = p -> next)
 {
   /* Avoid infinite recursion trying to expand a reg into a
 	 the same reg.  */

[PATCH] Fix arm var-tracking ICE (PR debug/51746)

2012-01-04 Thread Jakub Jelinek
Hi!

In this case the problem is that during cselib_process_insn
the cselib hashtab is expanded.  Before the htab expansion
cselib_lookup on r1 - 1 gave value 18:18 which contains the right value, but
doesn't have the hash value for r1 - 1 (8169), thus is found only by
accident.  Unfortunately after the expansion we don't look at the 18:18
value at all, don't find a value and thus a new value for r1 - 1 is
created (27:8169).  Unfortunately the expected MEM value is in 18:18's
addr_list, not in 27:8169, so add_stores doesn't find it (and is create=0
call, thus it returns NULL).
In other places we don't assume that cselib_lookup with create=0 will
always return non-NULL, so we shouldn't do it here either.

For 4.8 I guess we should investigate if we can improve this somehow.

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

2012-01-04  Jakub Jelinek  

PR debug/51746
* var-tracking.c (add_stores): For COND_EXEC allow oval to be NULL.

--- gcc/var-tracking.c.jj   2012-01-01 19:54:46.0 +0100
+++ gcc/var-tracking.c  2012-01-04 11:30:44.033223790 +0100
@@ -5519,7 +5519,7 @@ add_stores (rtx loc, const_rtx expr, voi
   gcc_assert (oval != v);
   gcc_assert (REG_P (oloc) || MEM_P (oloc));
 
-  if (!cselib_preserved_value_p (oval))
+  if (oval && !cselib_preserved_value_p (oval))
{
  micro_operation moa;
 

Jakub


[PATCH] Don't ICE on >= 64KB expressions in dwarf2out (PR debug/51695)

2012-01-04 Thread Jakub Jelinek
Hi!

.debug_loc section format only uses 2 byte long size field for expressions,
therefore we can't emit >= 64KB expressions.
Unfortunately from time to time we do generate them, I hope Alex will look
at how to prevent that from happening at var-tracking time, but still
this isn't something we should assert on.  The following patch drops them
on the floor, it is questionable how much useful would they be compared to
their huge size, another alternative would be to create
DW_TAG_dwarf_procedure for them or for portions thereof (for subexpressions
it would be even a potential nice debug info shrinking method, but would
mean a lot of work and gdb support isn't there yet).
So, for the time being I'm suggesting to just don't emit anything.

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

2012-01-04  Jakub Jelinek  

PR debug/51695
* dwarf2out.c (output_loc_list): For now drop >= 64KB expressions
in .debug_loc on the floor.

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

--- gcc/dwarf2out.c.jj  2012-01-03 16:22:48.0 +0100
+++ gcc/dwarf2out.c 2012-01-04 16:01:19.522191886 +0100
@@ -8166,6 +8166,13 @@ output_loc_list (dw_loc_list_ref list_he
   /* Don't output an entry that starts and ends at the same address.  */
   if (strcmp (curr->begin, curr->end) == 0 && !curr->force)
continue;
+  size = size_of_locs (curr->expr);
+  /* If the expression is too large, drop it on the floor.  We could
+perhaps put it into DW_TAG_dwarf_procedure and refer to that
+in the expression, but >= 64KB expressions for a single value
+in a single range are unlikely very useful.  */
+  if (size > 0x)
+   continue;
   if (!have_multiple_function_sections)
{
  dw2_asm_output_delta (DWARF2_ADDR_SIZE, curr->begin, curr->section,
@@ -8184,7 +8191,6 @@ output_loc_list (dw_loc_list_ref list_he
   "Location list end address (%s)",
   list_head->ll_symbol);
}
-  size = size_of_locs (curr->expr);
 
   /* Output the block length for this list of location operations.  */
   gcc_assert (size <= 0x);
--- gcc/testsuite/gcc.dg/pr51695.c.jj   2012-01-04 16:04:51.990964287 +0100
+++ gcc/testsuite/gcc.dg/pr51695.c  2012-01-04 16:03:16.0 +0100
@@ -0,0 +1,52 @@
+/* PR debug/51695 */
+/* { dg-do compile { target { int32plus } } } */
+/* { dg-options "-O2 -g" } */
+
+typedef struct
+{
+  struct { unsigned int t1, t2, t3, t4, t5, t6; } t;
+  int p;
+  struct { double X, Y, Z; } r;
+} T;
+typedef struct { T *h; } S;
+
+static unsigned int v = 0x12345678;
+
+int
+foo (void)
+{
+  v = (v & 0x8000) ? ((v << 1) ^ 0xa398655d) : (v << 1);
+  return 0;
+}
+
+double
+bar (void)
+{
+  unsigned int o;
+  v = (v & 0x8000) ? ((v << 1) ^ 0xa398655d) : (v << 1);
+  o = v & 0x;
+  return (double) o / 32768.0;
+}
+
+int
+baz (void)
+{
+  foo ();
+  return 0;
+}
+
+void
+test (S *x)
+{
+  T *t = x->h;
+  t->t.t1 = foo ();
+  t->t.t2 = foo ();
+  t->t.t3 = foo ();
+  t->t.t4 = foo ();
+  t->t.t5 = foo ();
+  t->t.t6 = foo ();
+  t->p = baz ();
+  t->r.X = bar ();
+  t->r.Y = bar ();
+  t->r.Z = bar ();
+}

Jakub


PR middle-end/51472: handle TM memmove with non-addressable destinations

2012-01-04 Thread Aldy Hernandez
I fixed this PR, and then it got reopened because the testcase triggered 
a different problem on Alpha, Mips, and other architectures.  The 
problem is actually totally different than the previous fix for 51472, 
and has nothing to do with --param tm-max-aggregate-size.


This problem here is that a load is transformed into a transactional 
memmove in such a way that the subsequent SSA uses are pointing to the 
wrong thing.  For example, originally we have:


global_var_ssa_999 = global_var;
*p = global_var_ssa_999;

Through expand_assign_tm -> gimplify_addr -> force_gimple_operand_gsi, 
the above gets transformed into this:


D.1234 = global_var_ssa_999; <-- BOO HISS! Uninitialized.
__builtin__ITM_memmoveRtWt (&D.1234, &global_var, 16);
*p = global_var_ssa_999; <-- Wt?

We should either propagate D.1234 to the uses of global_var_ssa_999, or 
copy D.1234 into global_var_ssa_999 and happily proceed.
  Option B is pretty straightforward, and with the attached patch we 
end up with:


__builtin__ITM_memmoveRtWt (&D.1234, &global_var, 16);
global_var_ssa_999 = D.1234;

The attached patch fixes the ICE on alpha-linux-gnu as tested with a 
cross-cc1 build.  Fully bootregtested on x86-64 Linux.


OK?
PR middle-end/51472
* trans-mem.c (expand_assign_tm): Handle TM_MEMMOVE loads correctly.
testsuite/
PR middle-end/51472
* gcc.dg/tm/memopt-6.c: Adjust regexp.

Index: testsuite/gcc.dg/tm/memopt-6.c
===
--- testsuite/gcc.dg/tm/memopt-6.c  (revision 182848)
+++ testsuite/gcc.dg/tm/memopt-6.c  (working copy)
@@ -17,5 +17,5 @@ int f()
   return lala.x[i];
 }
 
-/* { dg-final { scan-tree-dump-times "memmoveRtWt \\\(&lala, &lacopy" 1 
"tmedge" } } */
+/* { dg-final { scan-tree-dump-times "memmoveRtWt \\\(.*, &lacopy" 1 "tmedge" 
} } */
 /* { dg-final { cleanup-tree-dump "tmedge" } } */
Index: trans-mem.c
===
--- trans-mem.c (revision 182876)
+++ trans-mem.c (working copy)
@@ -2174,7 +2174,7 @@ expand_assign_tm (struct tm_region *regi
 }
   if (!gcall)
 {
-  tree lhs_addr, rhs_addr;
+  tree lhs_addr, rhs_addr, tmp;
 
   if (load_p)
transaction_subcode_ior (region, GTMA_HAVE_LOAD);
@@ -2183,13 +2183,29 @@ expand_assign_tm (struct tm_region *regi
 
   /* ??? Figure out if there's any possible overlap between the LHS
 and the RHS and if not, use MEMCPY.  */
-  lhs_addr = gimplify_addr (gsi, lhs);
+
+  if (load_p && is_gimple_non_addressable (lhs))
+   {
+ tmp = create_tmp_var (TREE_TYPE (lhs), NULL);
+ lhs_addr = build_fold_addr_expr (tmp);
+   }
+  else
+   {
+ tmp = NULL_TREE;
+ lhs_addr = gimplify_addr (gsi, lhs);
+   }
   rhs_addr = gimplify_addr (gsi, rhs);
   gcall = gimple_build_call (builtin_decl_explicit (BUILT_IN_TM_MEMMOVE),
 3, lhs_addr, rhs_addr,
 TYPE_SIZE_UNIT (TREE_TYPE (lhs)));
   gimple_set_location (gcall, loc);
   gsi_insert_before (gsi, gcall, GSI_SAME_STMT);
+
+  if (tmp)
+   {
+ gcall = gimple_build_assign (lhs, tmp);
+ gsi_insert_before (gsi, gcall, GSI_SAME_STMT);
+   }
 }
 
   /* Now that we have the load/store in its instrumented form, add


Re: [PATCH] Don't ICE on >= 64KB expressions in dwarf2out (PR debug/51695)

2012-01-04 Thread Jason Merrill

OK.

Jason


Re: [Patch, fortran] PR fortran/50981 segmentation fault when trying to access absent elemental actual arg

2012-01-04 Thread Mikael Morin
On Monday 02 January 2012 12:20:36 Tobias Burnus wrote:
> Hello Mikael,
> 
> Mikael Morin wrote:
> > Regression tested on x86_64-unknown-linux-gnu. OK for 4.7/4.6/4.5[/4.4] ?
> 
> OK - thanks for the comprehensive patch explanation and for the patch
> itself.
> 
> > + else
> > +   {
> > + /* Otherwise, evaluate the argument out of the loop and pass
> > +a reference to the value.  */
> > + gfc_conv_expr (&se, expr);
> 
> s/out of/outside/
Fixed

> 
> > + if (dummy_arg != NULL
> > +   &&  dummy_arg->sym->attr.optional

> > +   &&  arg->expr
I removed that one as it is guarded by:
if (!arg->expr)
  continue;

> > +   &&  arg->expr->symtree
> > +   &&  arg->expr->symtree->n.sym->attr.optional
> > +   &&  arg->expr->ref == NULL)
> > +   newss->info->data.scalar.can_be_null_ref = true;
> 
> I wonder whether one needs to take special care for the following
> Fortran 2008 feature: "A null pointer can be used to denote an absent
> nonallocatable nonpoin-
> ter optional argument." - I guess, one doesn't.
> 
I think there is an issue. I will look at it separately.

Mikael
Index: fortran/trans-expr.c
===
--- fortran/trans-expr.c	(révision 182873)
+++ fortran/trans-expr.c	(révision 182874)
@@ -5331,6 +5331,11 @@ gfc_conv_expr (gfc_se * se, gfc_expr * expr)
   /* Substitute a scalar expression evaluated outside the scalarization
  loop.  */
   se->expr = ss_info->data.scalar.value;
+  /* If the reference can be NULL, the value field contains the reference,
+	 not the value the reference points to (see gfc_add_loop_ss_code).  */
+  if (ss_info->data.scalar.can_be_null_ref)
+	se->expr = build_fold_indirect_ref_loc (input_location, se->expr);
+
   se->string_length = ss_info->string_length;
   gfc_advance_se_ss_chain (se);
   return;
Index: fortran/trans-array.c
===
--- fortran/trans-array.c	(révision 182873)
+++ fortran/trans-array.c	(révision 182874)
@@ -2422,10 +2422,21 @@ gfc_add_loop_ss_code (gfc_loopinfo * loop, gfc_ss
 	  break;
 
 	case GFC_SS_REFERENCE:
-	  /* Scalar argument to elemental procedure.  Evaluate this
-	 now.  */
+	  /* Scalar argument to elemental procedure.  */
 	  gfc_init_se (&se, NULL);
-	  gfc_conv_expr (&se, expr);
+	  if (ss_info->data.scalar.can_be_null_ref)
+	{
+	  /* If the actual argument can be absent (in other words, it can
+		 be a NULL reference), don't try to evaluate it; pass instead
+		 the reference directly.  */
+	  gfc_conv_expr_reference (&se, expr);
+	}
+	  else
+	{
+	  /* Otherwise, evaluate the argument outside the loop and pass
+		 a reference to the value.  */
+	  gfc_conv_expr (&se, expr);
+	}
 	  gfc_add_block_to_block (&outer_loop->pre, &se.pre);
 	  gfc_add_block_to_block (&outer_loop->post, &se.post);
 	  if (gfc_is_class_scalar_expr (expr))
Index: fortran/ChangeLog
===
--- fortran/ChangeLog	(révision 182873)
+++ fortran/ChangeLog	(révision 182874)
@@ -1,5 +1,14 @@
 2012-01-04  Mikael Morin  
 
+	PR fortran/50981
+	* trans.h (struct gfc_ss_info): New field data::scalar::can_be_null_ref
+	* trans-array.c: If the reference can be NULL, save the reference
+	instead of the value.
+	* trans-expr.c (gfc_conv_expr): If we have saved a reference,
+	dereference it.
+
+2012-01-04  Mikael Morin  
+
 	* trans-expr.c (gfc_conv_expr): Move address taking...
 	(gfc_conv_expr_reference): ... here.
 
Index: fortran/trans.h
===
--- fortran/trans.h	(révision 182873)
+++ fortran/trans.h	(révision 182874)
@@ -145,8 +145,9 @@ typedef enum
   GFC_SS_SCALAR,
 
   /* Like GFC_SS_SCALAR it evaluates the expression outside the
- loop. Is always evaluated as a reference to the temporary.
- Used for elemental function arguments.  */
+ loop.  Is always evaluated as a reference to the temporary, unless
+ temporary evaluation can result in a NULL pointer dereferencing (case of
+ optional arguments).  Used for elemental function arguments.  */
   GFC_SS_REFERENCE,
 
   /* An array section.  Scalarization indices will be substituted during
@@ -196,6 +197,9 @@ typedef struct gfc_ss_info
 struct
 {
   tree value;
+  /* Tells whether the reference can be null in the GFC_SS_REFERENCE case.
+	 Used to handle elemental procedures' optional arguments.  */
+  bool can_be_null_ref;
 }
 scalar;
 
Index: testsuite/gfortran.dg/elemental_optional_args_2.f90
===
--- testsuite/gfortran.dg/elemental_optional_args_2.f90	(révision 0)
+++ testsuite/gfortran.dg/elemental_optional_args_2.f90	(révision 182875)
@@ -0,0 +1,80 @@
+! { dg-do run }
+!
+! PR fortran/50981
+! The program used to dereference a NULL pointer when trying to access
+! an option

Re: [PATCH] Add Octeon2 indexed load instruction support (and also DSP64 LDX support)

2012-01-04 Thread Andrew Pinski
On Sat, Dec 17, 2011 at 3:11 AM, Richard Sandiford
 wrote:
> Andrew Pinski  writes:
>> Index: testsuite/gcc.target/mips/octeon2-lx-1.c
>> ===
>> --- testsuite/gcc.target/mips/octeon2-lx-1.c  (revision 0)
>> +++ testsuite/gcc.target/mips/octeon2-lx-1.c  (revision 0)
>> @@ -0,0 +1,18 @@
>> +/* { dg-do compile } */
>> +/* { dg-options "-march=octeon2 -O -mgp64" } */
>> +
>> +#define TEST(N, R, T) \
>> +  T f##N (T j, R *b, long long i) { return j + b[i]; } \
>> +  T g##N (T j, unsigned R *b, long long i) { return j + b[i]; }
>> +
>> +TEST (1, char, int)
>> +TEST (2, char, long long)
>> +/* { dg-final { scan-assembler-times "\tlbx\t" 2 } } */
>> +/* { dg-final { scan-assembler-times "\tlbux\t" 2 } } */
>> +TEST (3, short, int)
>> +TEST (4, short, long long)
>> +/* { dg-final { scan-assembler-times "\tlhx\t" 2 } } */
>> +/* { dg-final { scan-assembler-times "\tlhux\t" 2 } } */
>> +TEST (5, int, long long)
>> +/* { dg-final { scan-assembler-times "\tlwx\t" 1 } } */
>> +/* { dg-final { scan-assembler-times "\tlwux\t" 1 } } */
>
> There's obviously nothing wrong with testing long long indices,
> but it doesn't seem very typical.  I'd prefer the attached, which
> tests both "long long" and "int".  (I checked that it works for
> -mabi=n32 and -mabi=64 on mips64-linux-gnu.)
>
>> -(define_insn "mips_lwx_"
>> -  [(set (match_operand:SI 0 "register_operand" "=d")
>> -     (mem:SI (plus:P (match_operand:P 1 "register_operand" "d")
>> -                     (match_operand:P 2 "register_operand" "d"]
>> -  "ISA_HAS_DSP"
>> -  "lwx\t%0,%2(%1)"
>
> (Reviewing the patch made me realise that this ought to be using IMOVE32,
> just like lwxs does.  But that's something for another time.)
>
>> +(define_expand "mips_ldx"
>> +  [(match_operand:DI 0 "register_operand")
>> +   (match_operand 1 "pmode_register_operand")
>> +   (match_operand:SI 2 "register_operand")]
>> +  "ISA_HAS_DSP && TARGET_64BIT"
>> +{
>> +  operands[2] = convert_to_mode (Pmode, operands[2], false);
>> +  emit_insn (PMODE_INSN (gen_mips_ldx,
>> +                      (operands[0], operands[1], operands[2])));
>> +  DONE;
>> +})
>
> Seems like this and lwx could be combined using :GPR.
>
>> -;; This attribute gives the length suffix for a sign- or zero-extension
>> -;; instruction.
>> -(define_mode_attr size [(QI "b") (HI "h")])
>> +;; This attribute gives the length suffix for a sign-, zero-extension
>> +;; load and store instruction.
>> +(define_mode_attr size [(QI "b") (HI "h") (SI "w") (DI "d")])
>> +(define_mode_attr SIZE [(QI "B") (HI "H") (SI "W") (DI "D")])
>
> ;; This attribute gives the length suffix for a load or store instruction.
> ;; The same suffixes work for zero and sign extensions.
>
>> Index: config/mips/mips.c
>> ===
>> --- config/mips/mips.c        (revision 182342)
>> +++ config/mips/mips.c        (working copy)
>> @@ -2159,6 +2159,29 @@ mips_lwxs_address_p (rtx addr)
>>      }
>>    return false;
>>  }
>> +
>> +/* Return true if ADDR matches the pattern for the L{B,H,W,D}{,U}X load
>> +   indexed address instruction.  Note that such addresses are
>> +   not considered legitimate in the TARGET_LEGITIMATE_ADDRESS_P
>> +   sense, because their use is so restricted.  */
>> +
>> +static bool
>> +mips_loadindexed_address_p (rtx addr, enum machine_mode mode)
>
> Nitlet, but I'd prefer mips_lx_address_p or mips_load_indexed_address_p.
>
>> @@ -3552,6 +3575,11 @@ mips_rtx_costs (rtx x, int code, int out
>>         *total = COSTS_N_INSNS (2);
>>         return true;
>>       }
>> +      if (mips_loadindexed_address_p (addr, mode))
>> +     {
>> +       *total = COSTS_N_INSNS (2);
>> +       return true;
>> +     }
>
> Please combine this with the lwxs condition.
>
>> @@ -12959,6 +12988,9 @@ static const struct mips_builtin_descrip
>>    DIRECT_BUILTIN (mult, MIPS_DI_FTYPE_SI_SI, dsp_32),
>>    DIRECT_BUILTIN (multu, MIPS_DI_FTYPE_USI_USI, dsp_32),
>>
>> +  /* Built-in functions for the DSP ASE (64-bit only).  */
>> +  DIRECT_BUILTIN (ldx, MIPS_DI_FTYPE_POINTER_SI, dsp_64),
>> +
>>    /* The following are for the MIPS DSP ASE REV 2 (32-bit only).  */
>>    DIRECT_BUILTIN (dpa_w_ph, MIPS_DI_FTYPE_DI_V2HI_V2HI, dspr2_32),
>>    DIRECT_BUILTIN (dps_w_ph, MIPS_DI_FTYPE_DI_V2HI_V2HI, dspr2_32),
>
> You need to add this to the list in extend.texi too.
>
>> +#define ISA_HAS_LDX          ((ISA_HAS_DSP || TARGET_OCTEON2) && 
>> TARGET_64BIT)
>
> Long line:
>
> #define ISA_HAS_LDX             ((ISA_HAS_DSP || TARGET_OCTEON2) \
>                                 && TARGET_64BIT)
>
> OK otherwise, thanks.

Here is the patch which I committed after a bootstrap/test on mips64-linux-gnu.

Thanks,
Andrew Pinski

gcc/ChangeLog:
* config/mips/mips.md (size): Add SI and DI.
(SIZE): New mode attribute.
(U): New code attribute.
* config/mips/mips-dsp.md (mips_lbux): Use gen_mips_lbux_extsi.
(mips_lbux_): Delete.
(mips_lx_ext_): New pattern.
(mi

Re: [RFC][patch] trans-mem: mark transaction begins as returns-twice

2012-01-04 Thread Torvald Riegel
On Wed, 2012-01-04 at 12:13 -0500, Patrick Marlier wrote:
> On 01/04/2012 11:40 AM, Aldy Hernandez wrote:
> > On 01/04/12 09:53, Patrick Marlier wrote:
> >> On 01/02/2012 01:10 PM, Torvald Riegel wrote:
> >>> This was motivated by the miscompilation of one of the STAMP
> >>> applications (Genome), where a stack slot was used as temp storage for a
> >>> CPU register but not restored when the transaction got aborted and
> >>> restarted (then, after restart, the program crashed because it used
> >>> inconsistent data). With the attached patch and in this particular
> >>> example, the stack slots that are written to in the transaction do not
> >>> get read during the transaction. (-fno-caller-saves was not a
> >>> sufficient solution, BTW.)
> >>
> >> Are you sure this not due to the missing of tm-logging? We xfail until
> >> now for the testsuite but this should be addressed. (Note that I tested
> >> genome months ago and it was working correctly.)
> >>
> >> By the way, what's the status of this problem of tm-logging?
> >
> > I'm chugging along on the TM PR's, but so far the bug reporters are
> > beating me :). I can move this problem to the top of the list if you
> > want. If so, what is the PR?
> 
> PR: 51165 51166 51167 51168
> I let Torvald and you decide about the priority.

If that's indeed just a missed optimization as Aldy says on those
reports, then I think this has lower priority.  51752 is higher
priority, for example, even though I'm not very optimistic that we can
fix this quickly...



Re: [RFC][patch] trans-mem: mark transaction begins as returns-twice

2012-01-04 Thread Torvald Riegel
On Wed, 2012-01-04 at 10:53 -0500, Patrick Marlier wrote:
> On 01/02/2012 01:10 PM, Torvald Riegel wrote:
> > This was motivated by the miscompilation of one of the STAMP
> > applications (Genome), where a stack slot was used as temp storage for a
> > CPU register but not restored when the transaction got aborted and
> > restarted (then, after restart, the program crashed because it used
> > inconsistent data).  With the attached patch and in this particular
> > example, the stack slots that are written to in the transaction do not
> > get read during the transaction.  (-fno-caller-saves was not a
> > sufficient solution, BTW.)
> 
> Are you sure this not due to the missing of tm-logging? We xfail until 
> now for the testsuite but this should be addressed. (Note that I tested 
> genome months ago and it was working correctly.)

I think so.  This could be fixed with logging, but I don't think that's
the right way to handle this.  Perhaps its related though (unless the
PR's you cited are indeed just missed optimizations).

Patrick, I forwarded you the details of the issue...



Re: PR middle-end/51472: handle TM memmove with non-addressable destinations

2012-01-04 Thread Patrick Marlier

On 01/04/2012 01:20 PM, Aldy Hernandez wrote:

The attached patch fixes the ICE on alpha-linux-gnu as tested with a
cross-cc1 build.


Note that it was also failing with i686/linux and the patch fixes the ICE.

Patrick.


Re: [PATCH] Don't ICE on >= 64KB expressions in dwarf2out (PR debug/51695)

2012-01-04 Thread Tom Tromey
> "Jakub" == Jakub Jelinek  writes:

Jakub> another alternative would be to create DW_TAG_dwarf_procedure for
Jakub> them or for portions thereof (for subexpressions it would be even
Jakub> a potential nice debug info shrinking method, but would mean a
Jakub> lot of work and gdb support isn't there yet).

AFAIK, gdb supports DW_OP_call2 and DW_OP_call4 correctly.
If you know otherwise, please file a bug + reproducer.

gdb doesn't support DW_OP_call_ref yet.  I'm not sure why.
If it is important, we can add it.

Tom


Re: [PATCH] Don't ICE on >= 64KB expressions in dwarf2out (PR debug/51695)

2012-01-04 Thread Jakub Jelinek
On Wed, Jan 04, 2012 at 12:11:29PM -0700, Tom Tromey wrote:
> > "Jakub" == Jakub Jelinek  writes:
> 
> Jakub> another alternative would be to create DW_TAG_dwarf_procedure for
> Jakub> them or for portions thereof (for subexpressions it would be even
> Jakub> a potential nice debug info shrinking method, but would mean a
> Jakub> lot of work and gdb support isn't there yet).
> 
> AFAIK, gdb supports DW_OP_call2 and DW_OP_call4 correctly.
> If you know otherwise, please file a bug + reproducer.
> 
> gdb doesn't support DW_OP_call_ref yet.  I'm not sure why.
> If it is important, we can add it.

Honza said that GDB doesn't support DW_TAG_dwarf_procedure though.
We'd need to represent it as nameless artificial DW_TAG_variable
or something similar.

Jakub


Re: [PATCH] Add missed adjustment to label_nuses in reload.

2012-01-04 Thread Jeff Law
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 01/04/12 07:07, Marcus Shawcroft wrote:
> Reload (find_reloads) has code that can replace a register with a 
> label_ref when presented with RTL of the form:
> 
> (set (reg) (reg) (notes (rtx_equal (label_ref)))
> 
> Label references are initially counted in jump.c:mark_all_labels()
> and friends. This code traverses the RTL and counts each observed
> label_ref. The code inserts REG_LABEL_OPERAND or REG_LABEL_TARGET
> as appropriate. Notes are not traversed therefore the (rtx_equal
> (label_ref)) shown above is not treated as a reference.
> 
> Instruction deletion, in cfgrtl.c:delete_insn() does not
> re-traverse the RTL, The code traverses only the notes looking for
> REG_LABEL_OPERAND and REG_TARGET_OPERAND notes in order to count
> down the label_nuses field.
> 
> The code in reload.c:find_reloads() converts a register to a
> label_ref and inserts the associated REG_LABEL_OPERAND but does not
> adjust label_nuses, this may result in the inappropriate deletion
> of a live label.
> 
> This issue was discovered during the development of the ARM aarch64
> gcc backend and results in an ICE due to deletion of a live jump
> table.
> 
> The issue has not been re-created on another target. The proposed
> patch has been regressed on x86 (and aarch64).
> 
> Proposed ChangeLog entry below, patch attached:
> 
> 2012-01-04  Marcus Shawcroft  
> 
> * reload.c (find_reloads): Adjust LABEL_NUSES on REG_LABEL_OPERAND
> insertion.
Approved after you fix some minor fomatting nits. Your code has:

++ LABEL_NUSES(XEXP (substitution, 0));

The line should be:

++LABEL_NUSES (XEXP (substitution, 0));

No space between autoincrement operator and its operand.
Space before the open paren of the XEXP

Thanks,
Jeff
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJPBKbUAAoJEBRtltQi2kC7wMcH/3UMAgEj7d7nXwPfuMaZSl84
6lme27/Ox8LxsqFYrqnR3QKdU3/B0aZmS/CVzrPQQoC/xTSy1Y0aPTyBx3+p7tqa
tVkcCl/PgjhNCFROLe0n7YZ9FoS3el8CyC7Yha9Z0C17fiv6tetCElijiSluOxB0
OeOxgzE1qekwsQSZs6ZEiTpxGQJ/POqlhHHC9ILZV+iEUfGTAHW1EdKTupsLx9Q1
o26gXu6mTGsLEuSLkdKLkPJ+1+wV4h3291Ec41FC8Eo1E4fB9H82vBXxvy8fvO35
VnHXuyLrr7LMN0REDiQ6Oz8yh52Un/76l5/+kjFBPdQ6RzNPFsu8qwboNRirWSI=
=fNJ9
-END PGP SIGNATURE-


Re: [PATCH] Don't ICE on >= 64KB expressions in dwarf2out (PR debug/51695)

2012-01-04 Thread Tom Tromey
> "Jakub" == Jakub Jelinek  writes:

Jakub> Honza said that GDB doesn't support DW_TAG_dwarf_procedure though.
Jakub> We'd need to represent it as nameless artificial DW_TAG_variable
Jakub> or something similar.

I think gdb will issue a complaint if it sees one.  I'm not sure, I
don't think I've ever seen a program using this DWARF feature.

IIUC, the DW_OP_call* includes the needed DIE offset.  So, I think gdb
doesn't need to do anything for DW_TAG_dwarf_procedure except ignore it.

Doing this and eliminating the complaint is trivial.
I'm reluctant to do it without a way to test the change, though.
(And the complaint itself is harmless and not visible to users by
default anyway.)

Tom


[Google/main Patch] Cleanup pubnames/pubtypes and test-suite (issue5514045)

2012-01-04 Thread Sterling Augustine
The enclosed patch to google/main contains certain small fixes for pubnames and
pubtypes, which are now emitted completely and canonically. It also fixes the
expected output of various tests to match the canonical names of functions.

OK for google/main?


Tested:
With full make-check and no new failures observed.

gcc/ChangeLog:

2012-01-04   Sterling Augustine  

* gcc/dwarf2out.c (add_pubname): Move conditional clause from outer to
inner if-statement.
(dwarf2out_finish): Fix conditions to output DW_AT_GNU_pubnames and
DW_AT_GNU_pubtypes.  Move decision to output pubnames and pubtypes from
here...
(output_pubnames): ...to here.
(pubtypes_section_empty): Delete unused function.

gcc/testsuite/ChangeLog:

2012-01-04   Sterling Augustine  

* gcc/testsuite/g++.dg/diagnostic/bindings1.C: Adjust expected output.
* gcc/testsuite/g++.dg/ext/pretty3.C: Likewise.
* gcc/testsuite/g++.dg/pr44486.C: Likewise.
* gcc/testsuite/g++.dg/warn/Wuninitializable-member.C: Likewise.
* gcc/testsuite/g++.dg/warn/pr35711.C: Likewise.
* gcc/testsuite/g++.old-deja/g++.pt/memtemp77.C: Likewise.

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 6512292..3788cf8 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -8659,9 +8659,7 @@ add_pubname_string (const char *str, dw_die_ref die)
 static void
 add_pubname (tree decl, dw_die_ref die)
 {
-  if (!GENERATE_MINIMUM_LINE_TABLE
-  && targetm.want_debug_pub_sections
-  && TREE_PUBLIC (decl))
+  if (!GENERATE_MINIMUM_LINE_TABLE && targetm.want_debug_pub_sections)
 {
   if ((TREE_PUBLIC (decl) && !is_class_die (die->die_parent))
   || is_cu_die (die->die_parent) || is_namespace_die (die->die_parent))
@@ -8756,10 +8754,18 @@ output_pubnames (VEC (pubname_entry, gc) * names)
   unsigned long pubnames_length = size_of_pubnames (names);
   pubname_ref pub;
 
+  if (!targetm.want_debug_pub_sections)
+return;
   if (names == pubname_table)
-ASM_OUTPUT_LABEL (asm_out_file, debug_pubnames_section_label);
+{
+  switch_to_section (debug_pubnames_section);
+  ASM_OUTPUT_LABEL (asm_out_file, debug_pubnames_section_label);
+}
   else
-ASM_OUTPUT_LABEL (asm_out_file, debug_pubtypes_section_label);
+{
+  switch_to_section (debug_pubtypes_section);
+  ASM_OUTPUT_LABEL (asm_out_file, debug_pubtypes_section_label);
+}
   if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4)
 dw2_asm_output_data (4, 0x,
   "Initial length escape value indicating 64-bit DWARF extension");
@@ -22462,29 +22468,6 @@ optimize_location_lists (dw_die_ref die)
 }
 
 
-/* Report if the pubtypes_section is either empty or will be pruned to
-   empty.  */
-
-static bool
-pubtypes_section_empty (void)
-{
-  if (!VEC_empty (pubname_entry, pubtype_table))
-{
-  if (flag_eliminate_unused_debug_types)
-   {
- /* The pubtypes table might be emptied by pruning unused items.  */
- unsigned i;
- pubname_ref p;
- FOR_EACH_VEC_ELT (pubname_entry, pubtype_table, i, p)
-   if (p->die->die_offset != 0)
-  return false;
-   }
-  return true;
-}
-  return false;
-}
-
-
 /* Output stuff that dwarf requires at the end of every file,
and generate the DWARF-2 debugging info.  */
 
@@ -22749,17 +22732,12 @@ dwarf2out_finish (const char *filename)
   htab_delete (comdat_type_table);
 
   /* Add the DW_AT_GNU_pubnames and DW_AT_GNU_pubtypes attributes.  */
-  if (!VEC_empty (pubname_entry, pubname_table))
+  if (targetm.want_debug_pub_sections)
 {
-  /* FIXME: Should use add_AT_pubnamesptr.  This works because
- most targets don't care what the base section is.  */
+  /* FIXME: Should use add_AT_pubnamesptr.  This works because most targets
+ don't care what the base section is.  */
   add_AT_lineptr (comp_unit_die (), DW_AT_GNU_pubnames,
- debug_pubnames_section_label);
-}
-  if (!pubtypes_section_empty ())
-{
-  /* FIXME: Should use add_AT_pubtypesptr.  This works because
- most targets don't care what the base section is.  */
+  debug_pubnames_section_label);
   add_AT_lineptr (comp_unit_die (), DW_AT_GNU_pubtypes,
   debug_pubtypes_section_label);
 }
@@ -22787,22 +22765,12 @@ dwarf2out_finish (const char *filename)
   output_location_lists (comp_unit_die ());
 }
 
-  /* Output public names table if necessary.  */
-  if (!VEC_empty (pubname_entry, pubname_table) && info_section_emitted)
-{
-  switch_to_section (debug_pubnames_section);
-  output_pubnames (pubname_table);
-}
-
-  /* Output public types table if necessary.  */
+  /* Output public names and types tables if necessary.  */
+  output_pubnames (pubname_table);
   /* ??? Only defined by DWARF3, but emitted by Darwin for DWARF2.
  It shouldn't hurt to emit it always, since

Re: [PATCH] [MIPS] Add Octeon2 cpu support to GCC

2012-01-04 Thread Andrew Pinski
On Fri, Dec 16, 2011 at 2:22 PM, Joseph S. Myers
 wrote:
> On Mon, 12 Dec 2011, Andrew Pinski wrote:
>
>> * config/mips/mips-cpus.def: Add Octeon2.
>
> You need to update the documentation for MIPS -march= in invoke.texi,
> which lists the supported CPUs.

Woops, I had missed that.  Here is the patch which adds both octeon+
and octeon2 to that list.

I committed as obvious after a build.

Thanks,
Andrew Pinski

* doc/invoke.texi (-march=@var{arch}): Add octeon+ and octeon2.
Index: doc/invoke.texi
===
--- doc/invoke.texi (revision 182884)
+++ doc/invoke.texi (working copy)
@@ -14812,7 +14812,7 @@ The processor names are:
 @samp{1004kc}, @samp{1004kf2_1}, @samp{1004kf1_1},
 @samp{loongson2e}, @samp{loongson2f}, @samp{loongson3a},
 @samp{m4k},
-@samp{octeon},
+@samp{octeon}, @samp{octeon+}, @samp{octeon2},
 @samp{orion},
 @samp{r2000}, @samp{r3000}, @samp{r3900}, @samp{r4000}, @samp{r4400},
 @samp{r4600}, @samp{r4650}, @samp{r6000}, @samp{r8000},


Re: [Google/main Patch] Cleanup pubnames/pubtypes and test-suite (issue5514045)

2012-01-04 Thread Cary Coutant
LGTM for google/main.

Before submitting for trunk, we'll want to take care of this FIXME:

> +      /* FIXME: Should use add_AT_pubnamesptr.  This works because most 
> targets
> +         don't care what the base section is.  */

-cary


Re: [Patch,AVR]: Cleanup avr_replace_prefix

2012-01-04 Thread Denis Chertykov
2012/1/4 Georg-Johann Lay :
> This removes avr_replace_prefix and rewrites the callers to use ACONCAT.
>
> Passes without regressions.
>
> Ok for trunk?
>
> Johann
>
>        * config/avr/avr.c (avr_replace_prefix): Remove.
>        (avr_asm_named_section): Use ACONCAT instead of avr_replace_prefix.
>        (avr_asm_function_rodata_section): Ditto.
>        (avr_asm_select_section): Ditto.

Ok.

Denis.


Re: PR middle-end/51472: handle TM memmove with non-addressable destinations

2012-01-04 Thread Richard Henderson
On 01/05/2012 05:20 AM, Aldy Hernandez wrote:
>   PR middle-end/51472
>   * trans-mem.c (expand_assign_tm): Handle TM_MEMMOVE loads correctly.
> testsuite/
>   PR middle-end/51472
>   * gcc.dg/tm/memopt-6.c: Adjust regexp.

Ok.


r~


Re: [PATCH] Fix PR tree-optimization/51315

2012-01-04 Thread Richard Sandiford
Eric Botcazou  writes:
> Regtested on SPARC/Solaris.  Can you confirm that this fixes the
> pessimization in all cases (and run the C testsuite for your favorite
> ABI variant)?  TIA.

It does, and there were no regression on a C-only build & test for
mips64-linux-gnu (-mabi=32/-mips16, -mabi=32, -mabi=n32, -mabi=64).

Thanks for the quick fix!

Richard


Re: [PATCH] Fix arm var-tracking ICE (PR debug/51746)

2012-01-04 Thread Richard Henderson
On 01/05/2012 04:45 AM, Jakub Jelinek wrote:
>   PR debug/51746
>   * var-tracking.c (add_stores): For COND_EXEC allow oval to be NULL.

Ok.


r~


Re: PR middle-end/51472: handle TM memmove with non-addressable destinations

2012-01-04 Thread Patrick Marlier

On 01/04/2012 01:20 PM, Aldy Hernandez wrote:

I fixed this PR, and then it got reopened because the testcase triggered
a different problem on Alpha, Mips, and other architectures. The problem
is actually totally different than the previous fix for 51472, and has
nothing to do with --param tm-max-aggregate-size.


Also solve PR/51685 because it is a duplicate.

Patrick.



[PATCH] Fix fake edge handling in branch_prob (PR middle-end/44777)

2012-01-04 Thread Jakub Jelinek
Hi!

This testcase fails with corrupted profile info error.
The problem is that we have a basic block which starts with a computed goto
target label (thus has an EDGE_ABNORMAL predecessor and wants an EDGE_FAKE
predecessor from entry) and ends with a non-const/pure call (which
incidentally doesn't ever return directly, exits through a non-local goto),
thus wants an EDGE_FAKE edge to exit.
Unfortunately when constructing the spanning tree we would just add the fake
edge from entry and not the fake edge to exit, because entry and exit blocks
are already in the same union and because of the first fake edge this
block is unioned with it too.
The following patch fixes that by splitting such basic blocks after
labels, so that counter updating can be inserted on the new edge (and
thus inside of the block).  This fixed the testcase, unfortunately
regressed tree-prof/pr34999.c on i686.  The problem there is the weirdo
split of __builtin_setjmp into __builtin_setjmp_{setup,receiver,dispatcher}.
As the block containing (solely __builtin_setjmp_receiver (resp. dispatcher)
has both EDGE_ABNORMAL incoming and outgoing edges, it has EDGE_FAKE from
entry as well as EDGE_FAKE to exit.  The patch would try to insert the
counter adjustments in between __builtin_setjmp_setup and
__builtin_setjmp_receiver, which apparently at least on some targets the
expander isn't able to handle well.  Optimizations decided to cache some
64-bit counter values in registers, due to high register pressure were
spilled, but in between __builtin_setjmp_setup and __builtin_setjmp_receiver
the hard frame pointer isn't valid, the code adjusts it/restores it, so
we were reading through incorrect frame pointer value.
These edges (to/from __builtin_setjmp_dispatcher bb) are really artificial
and thus I think it is safe to keep status quo for them and avoid inserting
instrumentation there.

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

2012-01-04  Jakub Jelinek  

PR middle-end/44777
* profile.c (branch_prob): Split bbs that have exit edge
and need a fake entry edge too.

* gcc.dg/tree-prof/pr44777.c: New test.

--- gcc/profile.c.jj2011-12-21 19:24:35.0 +0100
+++ gcc/profile.c   2012-01-04 15:39:41.002668865 +0100
@@ -1040,6 +1040,41 @@ branch_prob (void)
fprintf (dump_file, "Adding fake entry edge to bb %i\n",
 bb->index);
  make_edge (ENTRY_BLOCK_PTR, bb, EDGE_FAKE);
+ /* Avoid bbs that have both fake entry edge and also some
+exit edge.  One of those edges wouldn't be added to the
+spanning tree, but we can't instrument any of them.  */
+ if (have_exit_edge || need_exit_edge)
+   {
+ gimple_stmt_iterator gsi;
+ gimple first;
+ tree fndecl;
+
+ gsi = gsi_after_labels (bb);
+ gcc_checking_assert (!gsi_end_p (gsi));
+ first = gsi_stmt (gsi);
+ if (is_gimple_debug (first))
+   {
+ gsi_next_nondebug (&gsi);
+ gcc_checking_assert (!gsi_end_p (gsi));
+ first = gsi_stmt (gsi);
+   }
+ /* Don't split the bbs containing __builtin_setjmp_receiver
+or __builtin_setjmp_dispatcher calls.  These are very
+special and don't expect anything to be inserted before
+them.  */
+ if (!is_gimple_call (first)
+ || (fndecl = gimple_call_fndecl (first)) == NULL
+ || DECL_BUILT_IN_CLASS (fndecl) != BUILT_IN_NORMAL
+ || (DECL_FUNCTION_CODE (fndecl) != BUILT_IN_SETJMP_RECEIVER
+ && (DECL_FUNCTION_CODE (fndecl)
+ != BUILT_IN_SETJMP_DISPATCHER)))
+   {
+ if (dump_file)
+   fprintf (dump_file, "Splitting bb %i after labels\n",
+bb->index);
+ split_block_after_labels (bb);
+   }
+   }
}
 }
 
--- gcc/testsuite/gcc.dg/tree-prof/pr44777.c.jj 2012-01-04 15:44:46.007904541 
+0100
+++ gcc/testsuite/gcc.dg/tree-prof/pr44777.c2012-01-04 15:47:29.469958984 
+0100
@@ -0,0 +1,43 @@
+/* PR middle-end/44777 */
+/* { dg-options "-O0" } */
+/* A variant of gcc.c-torture/execute/comp-goto-2.c.  */
+
+extern void abort (void);
+extern void exit (int);
+
+#ifdef STACK_SIZE
+#define DEPTH ((STACK_SIZE) / 512 + 1)
+#else
+#define DEPTH 1000
+#endif
+
+#if ! defined (NO_LABEL_VALUES) && !defined (NO_TRAMPOLINES)
+int
+x (int a)
+{
+  __label__ xlab;
+  void y (int a)
+{
+  void *x = &&llab;
+  if (a==-1)
+   goto *x;
+  if (a==0)
+   goto xlab;
+llab:
+  y (a-1);
+}
+  y (a);
+ xlab:;
+  return a;
+}
+#endif
+
+int
+main ()
+{
+#if ! defined (NO_LABEL_VALUES) && !defined (NO_TRAMPOLINES)
+  if (x (DEPTH) != DEPTH)
+abort ();
+#endif
+  exit (0);
+}

Jakub


[PATCH] Fix profiledbootstrap with -fexceptions (PR bootstrap/51648)

2012-01-04 Thread Jakub Jelinek
Hi!

profiledbootstrap with --disable-poststage-build-with-cxx and -fexceptions
currently fails on x86_64-linux.  The problem is that no EDGE_FAKE edge is
added from noreturn fatal_error call to the exit block, eventhough
fatal_error calls exit.
The problem is that we have several places which add EDGE_FAKE edges.
One is add_noreturn_fake_exit_edges, which adds EDGE_FAKE to bbs with zero
successor (not this case, because after the call there is EDGE_EH (to a
={v} {CLOBBER} bb, which is why this is a regression)).
And another one is gimple_flow_call_edges_add, but that one skips
all ECF_NORETURN calls, based on the assumption (apparently wrong) that
all noreturn calls have zero successor edges.
And the third place that adds EDGE_FAKE edges is branch_prob
itself, but it does so only for abnormal edges.

I think this bug can be fixed in any of the 3 places, the following patch
changes the second one.

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

2012-01-04  Jakub Jelinek  

PR bootstrap/51648
* tree-cfg.c (need_fake_edge_p): Return true also for noreturn
calls that have any non-fake successor edges.

--- gcc/tree-cfg.c.jj   2011-12-27 11:39:49.0 +0100
+++ gcc/tree-cfg.c  2012-01-04 22:30:22.072838130 +0100
@@ -6882,9 +6882,20 @@ need_fake_edge_p (gimple t)
   && DECL_FUNCTION_CODE (fndecl) == BUILT_IN_FORK))
 return false;
 
-  if (is_gimple_call (t)
-  && !(call_flags & ECF_NORETURN))
-return true;
+  if (is_gimple_call (t))
+{
+  edge_iterator ei;
+  edge e;
+  basic_block bb;
+
+  if (!(call_flags & ECF_NORETURN))
+   return true;
+
+  bb = gimple_bb (t);
+  FOR_EACH_EDGE (e, ei, bb->succs)
+   if ((e->flags & EDGE_FAKE) == 0)
+ return true;
+}
 
   if (gimple_code (t) == GIMPLE_ASM
&& (gimple_asm_volatile_p (t) || gimple_asm_input_p (t)))
@@ -6895,9 +6906,10 @@ need_fake_edge_p (gimple t)
 
 
 /* Add fake edges to the function exit for any non constant and non
-   noreturn calls, volatile inline assembly in the bitmap of blocks
-   specified by BLOCKS or to the whole CFG if BLOCKS is zero.  Return
-   the number of blocks that were split.
+   noreturn calls (or noreturn calls with EH/abnormal edges),
+   volatile inline assembly in the bitmap of blocks specified by BLOCKS
+   or to the whole CFG if BLOCKS is zero.  Return the number of blocks
+   that were split.
 
The goal is to expose cases in which entering a basic block does
not imply that all subsequent instructions must be executed.  */

Jakub


[libitm] fix reentrant.c testcase

2012-01-04 Thread Patrick Marlier
In the reentrant.c testcase, the first transaction has no transactional 
access and thus removed.

In order to keep this transaction, I added a shared access inside.
Tested on i686.

OK to commit?
(I don't have an account, so thanks in advance to committer)
--
Patrick Marlier.
2012-01-04  Patrick Marlier  

* testsuite/libitm.c/reentrant.c: Adjust testcase.
Index: testsuite/libitm.c/reentrant.c
===
--- testsuite/libitm.c/reentrant.c	(revision 182883)
+++ testsuite/libitm.c/reentrant.c	(working copy)
@@ -1,4 +1,4 @@
-/* { dg-do run { xfail *-*-* } }
+/* { dg-do run }
 /* { dg-options "-pthread" } */
 
 /* Tests that new transactions can be started from both transaction_pure and
@@ -36,7 +36,7 @@ int __attribute__((transaction_unsafe)) unsafe(int
 static void *thread (void *dummy __attribute__((unused)))
 {
   __transaction_atomic {
-pure(1);
+pure(x);
   }
   __transaction_relaxed {
 unsafe(1);


Fix bootstrap/51072 -- libitm not disabled without c++

2012-01-04 Thread Richard Henderson
Second try.  Unlike adjusting the gcc/cp fragment, I can't imagine 
this has any other side effects.

Tested on x86_64-linux.  Committed.


r~
diff --git a/ChangeLog b/ChangeLog
index b9d08f3..a8019b3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2012-01-05  Richard Henderson  
+
+   PR bootstrap/51072
+   * configure.ac: Disable libitm if c++ is not enabled.
+   * configure: Rebuild.
+
 2012-01-02  Balaji V. Iyer  
 
* MAINTAINERS (Write After Approval): Add myself.
diff --git a/configure b/configure
index fd6defa..d970c1d 100755
--- a/configure
+++ b/configure
@@ -6473,6 +6473,14 @@ case ,${enable_languages},:${enable_objc_gc} in
 ;;
 esac
 
+# Disable libitm if we're not building C++
+case ,${enable_languages}, in
+  *,c++) ;;
+  *)
+noconfigdirs="$noconfigdirs target-libitm"
+;;
+esac
+
 # Remove the entries in $skipdirs and $noconfigdirs from $configdirs,
 # $build_configdirs and $target_configdirs.
 # If we have the source for $noconfigdirs entries, add them to $notsupp.
diff --git a/configure.ac b/configure.ac
index 9fee563..b97c505 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1982,6 +1982,14 @@ case ,${enable_languages},:${enable_objc_gc} in
 ;;
 esac
 
+# Disable libitm if we're not building C++
+case ,${enable_languages}, in
+  *,c++) ;;
+  *)
+noconfigdirs="$noconfigdirs target-libitm"
+;;
+esac
+
 # Remove the entries in $skipdirs and $noconfigdirs from $configdirs,
 # $build_configdirs and $target_configdirs.
 # If we have the source for $noconfigdirs entries, add them to $notsupp.


Re: Fix bootstrap/51072 -- libitm not disabled without c++

2012-01-04 Thread Jakub Jelinek
On Thu, Jan 05, 2012 at 12:38:17PM +1100, Richard Henderson wrote:
> +# Disable libitm if we're not building C++
> +case ,${enable_languages}, in
> +  *,c++) ;;

Shouldn't that be *,c++,* ?  C++ might not be the last in the list...

Jakub


[trans-mem] fix problem with TM clone aliases

2012-01-04 Thread Patrick Marlier

Hi,

(Initially from http://gcc.gnu.org/ml/gcc-patches/2011-12/msg00225.html)
PR51516 shows up a problem due to the TM IPA rework.
Indeed, an alias can get called but tm cg data is in the parent of the 
alias.
The fix consists to set and use information from the parent and not the 
alias itself.


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

Richard, ok?
(Don't have an account yet, thanks in advance for the committer)

Thanks.
--
Patrick Marlier.
ChangeLog
2012-01-05  Patrick Marlier  

PR middle-end/51516
* trans-mem.c (ipa_tm_scan_calls_block): Use parent node of aliases.
(ipa_tm_decrement_clone_counts): Likewise.

testsuite/ChangeLog
2012-01-05  Patrick Marlier  

PR middle-end/51516
* g++.dg/tm/ctor-used.C: New test.
Index: testsuite/g++.dg/tm/ctor-used.C
===
--- testsuite/g++.dg/tm/ctor-used.C	(revision 0)
+++ testsuite/g++.dg/tm/ctor-used.C	(revision 0)
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options "-fgnu-tm -fdump-tree-optimized" } */
+
+struct C {
+  long l;
+  C():l(0) {}
+};
+
+int main()
+{
+  C* alloc;
+  __transaction_atomic {
+alloc = new C;
+  }
+  alloc->l = 2;
+
+  return 0;
+}
+/* { dg-final { scan-assembler-not "_ITM_getTMCloneOrIrrevocable" } } */
+/* { dg-final { scan-tree-dump-times ";; Function C::C" 1 "optimized" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
Index: trans-mem.c
===
--- trans-mem.c	(revision 182899)
+++ trans-mem.c	(working copy)
@@ -3566,6 +3566,10 @@ ipa_tm_scan_calls_block (cgraph_node_queue *callee
 
 	  node = cgraph_get_node (fndecl);
 	  gcc_assert (node != NULL);
+
+	  if (node->alias)
+		node = cgraph_get_node (node->thunk.alias);
+
 	  d = get_cg_data (node);
 
 	  pcallers = (for_clone ? &d->tm_callers_clone
@@ -3853,13 +3857,20 @@ ipa_tm_decrement_clone_counts (basic_block bb, boo
 	{
 	  struct tm_ipa_cg_data *d;
 	  unsigned *pcallers;
+	  struct cgraph_node *node;
 
 	  if (is_tm_ending_fndecl (fndecl))
 		continue;
 	  if (find_tm_replacement_function (fndecl))
 		continue;
 
-	  d = get_cg_data (cgraph_get_node (fndecl));
+	  node = cgraph_get_node (fndecl);
+	  gcc_assert (node != NULL);
+
+	  if (node->alias)
+		node = cgraph_get_node (node->thunk.alias);
+
+	  d = get_cg_data (node);
 	  pcallers = (for_clone ? &d->tm_callers_clone
 			  : &d->tm_callers_normal);
 
@@ -4188,7 +4199,7 @@ struct create_version_alias_info
   tree new_decl;
 };
 
-/* A subrontine of ipa_tm_create_version, called via
+/* A subroutine of ipa_tm_create_version, called via
cgraph_for_node_and_aliases.  Create new tm clones for each of
the existing aliases.  */
 static bool


Re: Fix bootstrap/51072 -- libitm not disabled without c++

2012-01-04 Thread Richard Henderson
On 01/05/2012 12:53 PM, Jakub Jelinek wrote:
> On Thu, Jan 05, 2012 at 12:38:17PM +1100, Richard Henderson wrote:
>> +# Disable libitm if we're not building C++
>> +case ,${enable_languages}, in
>> +  *,c++) ;;
> 
> Shouldn't that be *,c++,* ?  C++ might not be the last in the list...

Gah, of course it should.  It's what I meant.
I guess you can tell exactly what I tested too...


r~


Re: Unreviewed libffi, libgfortran, libitm patches

2012-01-04 Thread Richard Henderson
On 01/04/2012 11:27 PM, Rainer Orth wrote:
>   [libgfortran, libitm] Link with -shared-libgcc
>   http://gcc.gnu.org/ml/gcc-patches/2011-12/msg01382.html
> 
> This will need a fortran resp. libitm maintainer.

Does the following alleviate the need for -shared-libgcc for libitm?


r~
diff --git a/libitm/eh_cpp.cc b/libitm/eh_cpp.cc
index 6f302cd..a6a1851 100644
--- a/libitm/eh_cpp.cc
+++ b/libitm/eh_cpp.cc
@@ -45,6 +45,7 @@ void __cxa_throw (void *, void *, void *) { return; }
 void *__cxa_begin_catch (void *) { return NULL; }
 void *__cxa_end_catch (void) { return NULL; }
 void __cxa_tm_cleanup (void *, void *, unsigned int) { return; }
+void _Unwind_DeleteException (_Unwind_Exception *) { return; }
 #endif /* HAVE_ELF_STYLE_WEAKREF */
 
 }
diff --git a/libitm/libitm_i.h b/libitm/libitm_i.h
index b53792a..959d802 100644
--- a/libitm/libitm_i.h
+++ b/libitm/libitm_i.h
@@ -39,6 +39,10 @@
 #include "local_type_traits"
 #include "local_atomic"
 
+/* Don't require libgcc_s.so for exceptions.  */
+extern void _Unwind_DeleteException (_Unwind_Exception*) __attribute__((weak));
+
+
 #include "common.h"
 
 namespace GTM HIDDEN {