Re: [PATCH] Fix up ppc64-linux profiledbootstrap - .toc section references in .debug_loc (PR target/51957)

2012-01-24 Thread Alan Modra
On Tue, Jan 24, 2012 at 08:36:11AM +0100, Jakub Jelinek wrote:
> If you relax the checking too much, don't you risk that something other than
> the TOC register value is being added to the UNSPEC_TOCREL?  Say, if you
> have an 8byte object in .toc, and some loop body uses
> ((char *) &object)[1 + iv];
> to access it, can't you end up with (r2 + 1), or (r2 + 1 + iv) being added
> to UNSPEC_TOCREL?  Certainly on i686 something like that happens and that
> is why the delegitimization needs to be strict about the pic register

I don't think so.  We only put addresses, int constants smaller than
Pmode, and FP constants in .toc.  Hmm, however with -mcmodel=medium we
do have UNSPEC_TOCREL refering to other local objects so you may be
correct.

> I've checked in my patch already

OK.  I was worried that we might be losing debug info, but if you take
a look you'll see that location list is quite bogus anyway.  At least
it looks that way to me..

-- 
Alan Modra
Australia Development Lab, IBM


Re: [PATCH] PR c++/50852 - loose template parameter comparison

2012-01-24 Thread Dodji Seketeli
> How about if we just store a pointer to the template parameter list
> and do comp_template_parms?

I tried a variation of this approach below.  My understanding is that
comp_template_parms wouldn't work as is, at least because it can lead to
an endless recursion:

Suppose we start comparing the first template parm P of a vector V of
parameters against another template parm P'.  We compare the kind,
level and position of P and P'.  Then we move on to comparing their
siblings, via comp_template_parms.  That will, at some point compare,
P and P' again.

So I have added a new COMPARE_NO_SIBLINGS flag to the other COMPARE_*
flag that are passed as a last argument (named STRICT) to
structural_comptypes and comptypes, to prevent that endless recursion.

A drawback with this is that all the comparisons that happen from
inside structural_comptypes must take the STRICT parameter to avoid
that recursion.  This makes quite a lot of changes, even if they are
almost mechanical.  I tried to think of a better way to handle this,
but alas.

Also, it occurred that storing a pointer to the full template
parameter list was not really appropriate e.g for cases where tsubst
reduces the level of a given template parameter.  A pointer to just
the innermost vector of siblings of the template parameter was enough.
I thus extracted a comp_template_parm_levels to compare just a level
(a vector) of template parameters against another one.

As for the possible performance regression, I couldn't notice any
slowdown in in full bootstrap time, or in compiling some local
templated c++ code here.

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

gcc/cp/

PR c++/50852
* cp-tree.h (struct template_parm_index_s): Remove.
(struct template_parm_index_s): New member.
(TEMPLATE_PARM_SIBLINGS): New accessor macro.
(process_template_parm): Change the integer num_siblings parm into
a tree siblings parm.
(comp_template_parms_siblings, comp_template_parm_levels)
(comp_template_parms_real, comp_template_args_real)
(same_type_ignoring_top_level_qualifiers_real_p): Declare new
functions.
(compare_trees): Declare new function.
* pt.c (build_template_parm_index, fixup_template_type_parm_type)
(fixup_template_parm_index, build_template_parm_index)
(fixup_template_parm_index, process_template_parm)
(fixup_template_type_parm_type, fixup_template_parm): Change the
integer num_siblings parm into a tree siblings parm.  Update
comments.
(comp_template_parm_levels): Define new function.
(comp_template_parms_real): Take an additional parm to control
comparison.  Factorize this out of ...
(comp_template_parms): ... this.
(reduce_template_parm_level): Use TEMPLATE_PARM_SIBLINGS instead
of TEMPLATE_PARM_NUM_SIBLINGS.
(template_args_equal_real): Take an additional parm to control
comparison.  Use template_args_equal_real instead of
template_args_equal.  Factorize this out of ...
(template_args_equal): ... this.
(comp_template_args_real): Take an additional parm to control
comparison.  Renamed from comp_template_args_with_info.  Make this
public.
(comp_template_args, unify_pack_expansion): Adjust.
* tree.c (compare_trees): Factorized this out of cp_tree_equal.
Take a comparison control parameter. Use tree comparison functions
that take a comparison control parm.
(cp_tree_equal): Use the factorized compare_trees.
* typeck.c (compparms_real): Take a comparison control parameter.
Split out of ...
(compparms): ... this.
(comp_template_parms_siblings): Define new function.
(comp_template_parms_position): Take an additional parameter to
control the comparison.  Use the new comp_template_parms_siblings.
(structural_comptypes): Use type comparison routines variants that
take the comparison control parm.
(same_type_ignoring_top_level_qualifiers_real_p): Take an
additional parm to control comparison.  USe comptypes instead of
comptypes.  Factorize out of ...
(same_type_ignoring_top_level_qualifiers_p): ... this.

gcc/testsuite/

PR c++/50852
* g++.dg/template/typedef39.C: New test.
* g++.dg/template/typedef40.C: Likewise.
* g++.dg/template/typedef41.C: Likewise.
---
 gcc/cp/cp-tree.h  |   25 +++-
 gcc/cp/pt.c   |  226 ++---
 gcc/cp/tree.c |  113 +--
 gcc/cp/typeck.c   |  174 +--
 gcc/testsuite/g++.dg/template/typedef39.C |   16 ++
 gcc/testsuite/g++.dg/template/typedef40.C |   22 +++
 gcc/testsuite/g++.dg/template/typedef41.C |   19 +++
 7 files changed, 416 insertions(+), 179 deletions(-)
 create mode 

Re: Fix regression on PR46590 (slow compile with -O0)

2012-01-24 Thread Richard Guenther
On Mon, Jan 23, 2012 at 6:01 PM, Michael Matz  wrote:
> Hi,
>
> On Sat, 21 Jan 2012, Eric Botcazou wrote:
>
>> > Trivially fixing the thinko (iterating over (work bit-and
>> > old_conflict) in the first inner loop) would fix the testcase but in
>> > general create too few conflicts, i.e. generate wrong code.  I need
>> > some time to think about this again.
>>
>> OK, thanks in advance.
>
> Sigh.  I can't come up with a way to generally speed up the conflict
> generation without sometimes adding artificial conflicts.  I.e. I'll have
> to revert r183305.  I can still fix the specific situation of PR46590 by
> making sure clobbers are added for all aggregates, not only the (at
> gimplification time) address takens.
>
> So, this is currently in regstrapping, x86_64-linux, all langs+Ada.  Okay
> for trunk (well, the revert is obvious, but the gimplify.c hunk)?
>
>
> Ciao,
> Michael.
>
>        PR tree-optimization/46590
>        * cfgexpand.c: Revert last change (r183305).
>        * gimplify.c (gimplify_bind_expr): Add clobbers for all non-gimple
>        regs.
>
> Index: gimplify.c
> ===
> --- gimplify.c  (revision 183303)
> +++ gimplify.c  (working copy)
> @@ -1226,12 +1226,11 @@ gimplify_bind_expr (tree *expr_p, gimple
>       if (TREE_CODE (t) == VAR_DECL
>          && !is_global_var (t)
>          && DECL_CONTEXT (t) == current_function_decl
> -         && !DECL_HARD_REGISTER (t)
> -         && !TREE_THIS_VOLATILE (t)
>          && !DECL_HAS_VALUE_EXPR_P (t)
>          /* Only care for variables that have to be in memory.  Others
>             will be rewritten into SSA names, hence moved to the top-level.  
> */
> -         && needs_to_live_in_memory (t))
> +         && !is_gimple_reg (t))
> +

Ok with the excessive vertical space removed.

Thanks,
Richard.

>        {
>          tree clobber = build_constructor (TREE_TYPE (t), NULL);
>          TREE_THIS_VOLATILE (clobber) = 1;
> Index: cfgexpand.c
> ===
> --- cfgexpand.c (revision 183305)
> +++ cfgexpand.c (working copy)
> @@ -441,12 +441,11 @@ visit_conflict (gimple stmt ATTRIBUTE_UN
>
>  /* Helper routine for add_scope_conflicts, calculating the active partitions
>    at the end of BB, leaving the result in WORK.  We're called to generate
> -   conflicts when OLD_CONFLICTS is non-null, otherwise we're just tracking
> -   liveness.  If we generate conflicts then OLD_CONFLICTS stores the bits
> -   for which we generated conflicts already.  */
> +   conflicts when FOR_CONFLICT is true, otherwise we're just tracking
> +   liveness.  */
>
>  static void
> -add_scope_conflicts_1 (basic_block bb, bitmap work, bitmap old_conflicts)
> +add_scope_conflicts_1 (basic_block bb, bitmap work, bool for_conflict)
>  {
>   edge e;
>   edge_iterator ei;
> @@ -483,7 +482,7 @@ add_scope_conflicts_1 (basic_block bb, b
>        }
>       else if (!is_gimple_debug (stmt))
>        {
> -         if (old_conflicts
> +         if (for_conflict
>              && visit == visit_op)
>            {
>              /* If this is the first real instruction in this BB we need
> @@ -491,27 +490,16 @@ add_scope_conflicts_1 (basic_block bb, b
>                 Unlike classical liveness for named objects we can't
>                 rely on seeing a def/use of the names we're interested in.
>                 There might merely be indirect loads/stores.  We'd not add any
> -                conflicts for such partitions.  We know that we generated
> -                conflicts between all partitions in old_conflicts already,
> -                so we need to generate only the new ones, avoiding to
> -                repeatedly pay the O(N^2) cost for each basic block.  */
> +                conflicts for such partitions.  */
>              bitmap_iterator bi;
>              unsigned i;
> -
> -             EXECUTE_IF_AND_COMPL_IN_BITMAP (work, old_conflicts, 0, i, bi)
> +             EXECUTE_IF_SET_IN_BITMAP (work, 0, i, bi)
>                {
>                  unsigned j;
>                  bitmap_iterator bj;
> -                 /* First the conflicts between new and old_conflicts.  */
> -                 EXECUTE_IF_SET_IN_BITMAP (old_conflicts, 0, j, bj)
> -                   add_stack_var_conflict (i, j);
> -                 /* Then the conflicts between only the new members.  */
> -                 EXECUTE_IF_AND_COMPL_IN_BITMAP (work, old_conflicts, i + 1,
> -                                                 j, bj)
> +                 EXECUTE_IF_SET_IN_BITMAP (work, i + 1, j, bj)
>                    add_stack_var_conflict (i, j);
>                }
> -             /* And remember for the next basic block.  */
> -             bitmap_ior_into (old_conflicts, work);
>              visit = visit_conflict;
>            }
>          walk_stmt_load_store_addr_ops (stmt, work, visit, visit, visit);
> @@ -528,7 +516,6 @@ add_scope_conflicts (void)
>   basic_block bb;
>  

Re: [ C frontend ] add support for builtins that take signed and unsigned md types

2012-01-24 Thread Richard Guenther
On Mon, Jan 23, 2012 at 6:12 PM, Mike Stump  wrote:
> On Jan 23, 2012, at 3:00 AM, Richard Guenther wrote:
>> So, yes, please have only one loop.
>
> Updated patch included.
>
> Ok?

Ok.

Thanks,
Richard.


Re: RFA: cgraph PATCH for c++/51812 (link failure with undefined/unneeded virtual function)

2012-01-24 Thread Richard Guenther
On Mon, Jan 23, 2012 at 7:03 PM, Jason Merrill  wrote:
> In this testcase, main doesn't call anything, so the inline functions in the
> classes can be optimized away, and we don't need the vtables or the virtual
> functions they refer to.  But cgraph_decide_is_function_needed wants to
> write out all static functions at -O0, which in this case was including the
> local thunk alias created by use_thunk.  Clearly we don't want to force such
> an alias out when it isn't needed, so I've added same-body aliases to the
> list of things that we don't need to emit.
>
> OK for trunk?

Ok.

Thanks,
Richard.


Patch ping

2012-01-24 Thread Jakub Jelinek
Hi!

I'd like to ping following patch:

- http://gcc.gnu.org/ml/gcc-patches/2012-01/msg00819.html
  P2 option handling ICE with -Wp,-pie or -Wp,-shared

Jakub


Re: RFA: fix PR 51649

2012-01-24 Thread Richard Guenther
On Mon, Jan 23, 2012 at 8:36 PM, Tom Tromey  wrote:
> This patch fixes some pretty-printer bugs pointed out in PR 51649.
>
> The bug in the PR is that the pretty-printers don't work if you build
> with --enable-symvers=gnu-versioned-namespace.
>
> This patch adds test cases for all the changes I made.
>
> I derived most of the information here from reading c++config, then
> going through the existing printers one-by-one to see how they are
> implemented in the various modes.
>
> Still missing are tests for parallel and profile modes.
>
> I wasn't sure whether we need a printer for the stuff in vstring.h.
> Anybody know?
>
> The old code referred to a __norm namespace.  I only found a single
> instance of this in the tree, which seemed to indicate it is a
> compatibility thing.  So, I ignored it.  (I think that if there is a
> problem here we should start with a test that shows it...)
>
> I built and tested this with --enable-symvers=gnu-versioned-namespace
> and with the default on x86-64 Fedora 15.
>
> I'm sufficiently out of the loop gcc-wise that I will need some advice
> as to whether this can go in immediately or whether it must wait for
> some other stage.

We're technically in regression-fixes-only mode.  We give target/language
maintainers some extra freedom though - while C++/libstdc++ are considered
release critical and thus should not regress at this point I'm less sure
about all the pretty-printing stuff - it can't possibly break anything
but debugging
experience.

Richard.

> Ok?
>
> Tom
>
> 2012-01-23  Tom Tromey  
>
>        PR libstdc++/51649:
>        * testsuite/libstdc++-prettyprinters/debug.cc: New file.
>        * testsuite/lib/gdb-test.exp (regexp-test): New proc.
>        (note-test): Update.
>        (gdb-test): Handle regexp tests.  Add some logging.
>        * testsuite/libstdc++-prettyprinters/simple.cc: Compile with -O0.
>        (placeholder, use): Remove.
>        (main): Add tests for deque, list, map, and set iterators.  Add
>        tests for slist and slist iterator.
>        * testsuite/libstdc++-prettyprinters/48362.cc (main): Handle __7
>        namespace.
>        * python/libstdcxx/v6/printers.py (StdListPrinter.children): Use
>        the type's _Node typedef.
>        (StdListIteratorPrinter.to_string): Change how node type is
>        computed.
>        (StdSlistPrinter.children): Use the type's _Node typedef.
>        (StdSlistIteratorPrinter.to_string): Likewise.
>        (StdRbtreeIteratorPrinter.to_string): Use the type's _Link_type
>        typedef.
>        (StdMapPrinter.children): Change how the node's type is computed.
>        (StdSetPrinter.children): Likewise.
>        (StdForwardListPrinter.children): Use the type's _Node typedef.
>        (Printer.add_version): New method.
>        (Printer.add_container): New method.
>        (build_libstdcxx_dictionary): Handle __7 and __cxx1998
>        namespaces.
>        (find_type): New function.
>
> Index: python/libstdcxx/v6/printers.py
> ===
> --- python/libstdcxx/v6/printers.py     (revision 183449)
> +++ python/libstdcxx/v6/printers.py     (working copy)
> @@ -1,6 +1,6 @@
>  # Pretty-printers for libstc++.
>
> -# Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
> +# Copyright (C) 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
>
>  # This program is free software; you can redistribute it and/or modify
>  # it under the terms of the GNU General Public License as published by
> @@ -26,6 +26,25 @@
>  except ImportError:
>     _use_gdb_pp = False
>
> +# Starting with the type ORIG, search for the member type NAME.  This
> +# handles searching upward through superclasses.  This is needed to
> +# work around http://sourceware.org/bugzilla/show_bug.cgi?id=13615.
> +def find_type(orig, name):
> +    typ = orig.strip_typedefs()
> +    while True:
> +        search = str(typ) + '::' + name
> +        try:
> +            return gdb.lookup_type(search)
> +        except RuntimeError:
> +            pass
> +        # The type was not found, so try the superclass.  We only need
> +        # to check the first superclass, so we don't bother with
> +        # anything fancier here.
> +        field = typ.fields()[0]
> +        if not field.is_base_class:
> +            raise ValueError, "Cannot find type %s::%s" % (str(orig), name)
> +        typ = field.type
> +
>  class StdPointerPrinter:
>     "Print a smart pointer of some kind"
>
> @@ -76,15 +95,8 @@
>         self.val = val
>
>     def children(self):
> -        itype = self.val.type.template_argument(0)
> -        # If the inferior program is compiled with -D_GLIBCXX_DEBUG
> -        # some of the internal implementation details change.
> -        if self.typename == "std::list":
> -            nodetype = gdb.lookup_type('std::_List_node<%s>' % 
> itype).pointer()
> -        elif self.typename == "std::__debug::list":
> -            nodetype = gdb.lookup_type('std::__norm

Re: RFA: fix PR 51649

2012-01-24 Thread Jakub Jelinek
On Tue, Jan 24, 2012 at 11:29:12AM +0100, Richard Guenther wrote:
> We're technically in regression-fixes-only mode.  We give target/language
> maintainers some extra freedom though - while C++/libstdc++ are considered
> release critical and thus should not regress at this point I'm less sure
> about all the pretty-printing stuff - it can't possibly break anything
> but debugging experience.

Well, even bad debugging experience problems would be very undesirable
if we generated wrong debug info and everybody compiled it into their
sources.  But pretty-printers stay on the side, it is just a matter of
updating the python scripts and there is no need to recompile already
compiled/linked programs/libraries.  So if properly tested, I think
this could go in.

Jakub


Re: [PATCH] Fix for PR51879 - Missed tail merging with non-const/pure calls

2012-01-24 Thread Richard Guenther
On Mon, Jan 23, 2012 at 10:27 PM, Tom de Vries  wrote:
> Richard,
> Jakub,
>
> the following patch fixes PR51879.
>
> Consider the following test-case:
> ...
> int bar (int);
> void baz (int);
>
> void
> foo (int y)
> {
>  int a;
>  if (y == 6)
>    a = bar (7);
>  else
>    a = bar (7);
>  baz (a);
> }
> ...
>
> after compiling at -02, the representation looks like this before 
> tail-merging:
> ...
>  # BLOCK 3 freq:1991
>  # PRED: 2 [19.9%]  (true,exec)
>  # .MEMD.1714_7 = VDEF <.MEMD.1714_6(D)>
>  # USE = nonlocal
>  # CLB = nonlocal
>  aD.1709_3 = barD.1703 (7);
>  goto ;
>  # SUCC: 5 [100.0%]  (fallthru,exec)
>
>  # BLOCK 4 freq:8009
>  # PRED: 2 [80.1%]  (false,exec)
>  # .MEMD.1714_8 = VDEF <.MEMD.1714_6(D)>
>  # USE = nonlocal
>  # CLB = nonlocal
>  aD.1709_4 = barD.1703 (7);
>  # SUCC: 5 [100.0%]  (fallthru,exec)
>
>  # BLOCK 5 freq:1
>  # PRED: 3 [100.0%]  (fallthru,exec) 4 [100.0%]  (fallthru,exec)
>  # aD.1709_1 = PHI 
>  # .MEMD.1714_5 = PHI <.MEMD.1714_7(3), .MEMD.1714_8(4)>
>  # .MEMD.1714_9 = VDEF <.MEMD.1714_5>
>  # USE = nonlocal
>  # CLB = nonlocal
>  bazD.1705 (aD.1709_1);
>  # VUSE <.MEMD.1714_9>
>  return;
> ...
>
> the patch allows aD.1709_4 to be value numbered to aD.1709_3, and .MEMD.1714_8
> to .MEMD.1714_7, which enables tail-merging of blocks 4 and 5.
>
> The patch makes sure non-const/pure call results (gimple_vdef and
> gimple_call_lhs) are properly value numbered.
>
> Bootstrapped and reg-tested on x86_64.
>
> ok for stage1?

The following cannot really work:

@@ -2600,7 +2601,11 @@ visit_reference_op_call (tree lhs, gimpl
   result = vn_reference_lookup_1 (&vr1, NULL);
   if (result)
 {
-  changed = set_ssa_val_to (lhs, result);
+  tree result_vdef = gimple_vdef (SSA_NAME_DEF_STMT (result));
+  if (vdef)
+   changed |= set_ssa_val_to (vdef, result_vdef);
+  changed |= set_ssa_val_to (lhs, result);

becase 'result' may be not an SSA name.  It might also not have
a proper definition statement (if VN_INFO (result)->needs_insertion
is true).  So you at least need to guard things properly.

(On a side-note - I _did_ want to remove value-numbering virtual operands
at some point ...)

@@ -3359,8 +3366,10 @@ visit_use (tree use)
  /* ???  We should handle stores from calls.  */
  else if (TREE_CODE (lhs) == SSA_NAME)
{
+ tree vuse = gimple_vuse (stmt);
  if (!gimple_call_internal_p (stmt)
- && gimple_call_flags (stmt) & (ECF_PURE | ECF_CONST))
+ && (gimple_call_flags (stmt) & (ECF_PURE | ECF_CONST)
+ || (vuse && SSA_VAL (vuse) != VN_TOP)))
changed = visit_reference_op_call (lhs, stmt);
  else
changed = defs_to_varying (stmt);

... exactly because of the issue that a stmt has multiple defs.  Btw,
vuse should have been visited here or be part of our SCC, so, why do
you need this check?

Thanks,
Richard.

> Thanks,
> - Tom
>
> 2012-01-23  Tom de Vries  
>
>        PR tree-optimization/51879
>        tree-ssa-sccvn.c (visit_reference_op_call): Handle gimple_vdef.
>        (visit_use): Handle non-pure/const calls using visit_reference_op_call.
>
>        gcc.dg/pr51879.c: New test.
>        gcc.dg/pr51879-2.c: Same.
>        gcc.dg/pr51879-3.c: Same.
>        gcc.dg/pr51879-4.c: Same.


Re: [patch] Fix mismatched #pragma GCC visibility

2012-01-24 Thread Paolo Carlini

Hi,

While trying to improve clang's handling of "#pragma GCC visibility" I
found out that libstdc++-v3/libsupc++/typeinfo looks like

#pragma GCC visibility push(default)
extern "C++" {
#pragma GCC visibility pop
}

Is that supposed to work or just happens to? If desired, the attached
patch moves the pop after the closing }.
Thanks for raising the issue. To me the above looks like a 
straightforward typo, which we should fix as soon as possible (not sure 
whether we could also diagnose it).


Jason, Jakub, can you confirm?

Thanks,
Paolo.


Re: [PATCH] Improve PHI-OPT when there are multiple phis

2012-01-24 Thread Richard Guenther
On Tue, Jan 24, 2012 at 7:34 AM, Andrew Pinski
 wrote:
> Hi,
>  Right now PHI-OPT does try to handle the case where we have multiple
> PHIs but the other PHIs have the same value for the edges we care
> about.
> This fixes the issue and allows PHI-OPT to handle a few more cases and
> it removes the TODO in the comments.
>
> OK For 4.8? Bootstrapped and tested on x86_64-linux-gnu with no regressions.
>
> Thanks,
> Andrew Pinski
>
> ChangeLog:
> * tree-ssa-phiopt.c (gimple_phi_singleton_for_edges): New function.

The name is confusing I think, because it returns the single non-singleton
PHI for the edge pair ... you can avoid choosing a better name by
inlining it to its single call site.  I'd maybe name it
single_non_singleton_phi_for_edges.

Otherwise ok.

Thanks,
Richard.

> (tree_ssa_phiopt_worker): Use gimple_phi_singleton_for_edges.
> (empty_block_p): Check also if the PHIs for the block are empty.
>
> testsuite/ChangeLog:
> * gcc.dg/tree-ssa/phi-opt-7.c: New testcase.


Re: [patch] Fix mismatched #pragma GCC visibility

2012-01-24 Thread Jakub Jelinek
On Tue, Jan 24, 2012 at 11:45:55AM +0100, Paolo Carlini wrote:
> Hi,
> >While trying to improve clang's handling of "#pragma GCC visibility" I
> >found out that libstdc++-v3/libsupc++/typeinfo looks like
> >
> >#pragma GCC visibility push(default)
> >extern "C++" {
> >#pragma GCC visibility pop
> >}
> >
> >Is that supposed to work or just happens to? If desired, the attached
> >patch moves the pop after the closing }.
> Thanks for raising the issue. To me the above looks like a
> straightforward typo, which we should fix as soon as possible (not
> sure whether we could also diagnose it).
> 
> Jason, Jakub, can you confirm?

While we can change it, it is certainly valid as is, #pragma GCC visibility
can happen in lots of places and just marks where the default visibility
is adjusted.  If clang errors on this, it is broken.

Jakub


Re: Patch ping

2012-01-24 Thread Richard Guenther
On Tue, Jan 24, 2012 at 11:28 AM, Jakub Jelinek  wrote:
> Hi!
>
> I'd like to ping following patch:
>
> - http://gcc.gnu.org/ml/gcc-patches/2012-01/msg00819.html
>  P2 option handling ICE with -Wp,-pie or -Wp,-shared

Ok.

Thanks,
Richard.

>        Jakub


Re: [patch] Fix mismatched #pragma GCC visibility

2012-01-24 Thread Paolo Carlini

Thanks for raising the issue. To me the above looks like a
straightforward typo, which we should fix as soon as possible (not
sure whether we could also diagnose it).

Jason, Jakub, can you confirm?

While we can change it, it is certainly valid as is, #pragma GCC visibility
can happen in lots of places and just marks where the default visibility
is adjusted.
Indeed, thanks for clarifying. In the specific case of libsupc++ I guess 
it's essentially a matter of style / consistency the exact line. We can 
schedule the change for Stage 1.

   If clang errors on this, it is broken.

Ehm, agreed.

Paolo.


Re: [build] Cleanup rs6000/t-ppccomm configurations (PR other/51022)

2012-01-24 Thread Alan Modra
On Mon, Dec 05, 2011 at 07:25:35PM -0500, David Edelsohn wrote:
> Is this fixed or is someone writing a follow-up patch?

This does the trick.  You could also use
case ${host}:${with_multisubdir} in
*:*32*)
;;
powerpc64-*:* | *:*64*)
tmake_file="$tmake_file rs6000/t-linux64"
;;
esac
in config.host, but that's unnecessarily complicated.  The t-linux64
bits can safely go in other config files.  Bootstrapped and regression
tested powerpc-linux and powerpc64-linux.

* config/rs6000/t-linux64: Delete.  Move..
* config/rs6000/t-ppc64-fp: .. softfp_wrap defines to here..
* config/rs6000/t-linux: ..and libgcc flags to here.

Index: libgcc/config/rs6000/t-linux64
===
--- libgcc/config/rs6000/t-linux64  (revision 183464)
+++ libgcc/config/rs6000/t-linux64  (working copy)
@@ -1,4 +0,0 @@
-HOST_LIBGCC2_CFLAGS += -mno-minimal-toc
-
-softfp_wrap_start := '\#ifndef __powerpc64__'
-softfp_wrap_end := '\#endif'
Index: libgcc/config/rs6000/t-ppc64-fp
===
--- libgcc/config/rs6000/t-ppc64-fp (revision 183464)
+++ libgcc/config/rs6000/t-ppc64-fp (working copy)
@@ -1,2 +1,5 @@
 # Can be used unconditionally, wrapped in __powerpc64__ || __64BIT__ __ppc64__.
 LIB2ADD += $(srcdir)/config/rs6000/ppc64-fp.c
+
+softfp_wrap_start := '\#ifndef __powerpc64__'
+softfp_wrap_end := '\#endif'
Index: libgcc/config/rs6000/t-linux
===
--- libgcc/config/rs6000/t-linux(revision 183464)
+++ libgcc/config/rs6000/t-linux(working copy)
@@ -1,3 +1,3 @@
 SHLIB_MAPFILES += $(srcdir)/config/rs6000/libgcc-glibc.ver
 
-HOST_LIBGCC2_CFLAGS += -mlong-double-128
+HOST_LIBGCC2_CFLAGS += -mlong-double-128 -mno-minimal-toc

-- 
Alan Modra
Australia Development Lab, IBM


Re: [build] Cleanup rs6000/t-ppccomm configurations (PR other/51022)

2012-01-24 Thread Paolo Bonzini

On 01/24/2012 12:20 PM, Alan Modra wrote:

On Mon, Dec 05, 2011 at 07:25:35PM -0500, David Edelsohn wrote:

Is this fixed or is someone writing a follow-up patch?


This does the trick.  You could also use
case ${host}:${with_multisubdir} in
*:*32*)
;;
powerpc64-*:* | *:*64*)
tmake_file="$tmake_file rs6000/t-linux64"
;;
esac
in config.host, but that's unnecessarily complicated.  The t-linux64
bits can safely go in other config files.  Bootstrapped and regression
tested powerpc-linux and powerpc64-linux.


Ok.

Paolo


[patch] remove empty directories (libgo, libstdc++-v3, libgomp)

2012-01-24 Thread Matthias Klose

Ok to remove these three empty directories?

libgo/go/exp/template
libstdc++-v3/testsuite/30_threads/condition_variable_any/requirements
libgomp/config/linux/arm


Re: [build] Cleanup rs6000/t-ppccomm configurations (PR other/51022)

2012-01-24 Thread Rainer Orth
Alan Modra  writes:

> On Mon, Dec 05, 2011 at 07:25:35PM -0500, David Edelsohn wrote:
>> Is this fixed or is someone writing a follow-up patch?
>
> This does the trick.  You could also use
>   case ${host}:${with_multisubdir} in
>   *:*32*)
>   ;;
>   powerpc64-*:* | *:*64*)
>   tmake_file="$tmake_file rs6000/t-linux64"
>   ;;
>   esac
> in config.host, but that's unnecessarily complicated.  The t-linux64
> bits can safely go in other config files.  Bootstrapped and regression
> tested powerpc-linux and powerpc64-linux.

Thanks for doing this.  I still meant to get back to this, but didn't
have much time for GCC work lately.

Rainer

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


Re: [RFC] Fixing expansion of misaligned MEM_REFs on strict-alignment targets

2012-01-24 Thread Richard Guenther
On Fri, 6 Jan 2012, Martin Jambor wrote:

> Hi,
> 
> I'm trying to teach our expander how to deal with misaligned MEM_REFs
> on strict alignment targets.  We currently generate code which leads
> to bus error signals due to misaligned accesses.
> 
> I admit my motivation is not any target in particular but simply being
> able to produce misaligned MEM_REFs in SRA, currently we work-around
> that by producing COMPONENT_REFs which causes quite a few headaches.
> Nevertheless, I started by following Richi's advice and set out to fix
> the following two simple testcases on a strict-alignment platform, a
> sparc64 in the compile farm.  If I understood him correctly, Richi
> claimed they have been failing "since forever:"
> 
> - test case 1: -
> 
> extern void abort ();
> 
> typedef unsigned int myint __attribute__((aligned(1)));
> 
> /* even without the attributes we get bus error */
> unsigned int __attribute__((noinline, noclone))
> foo (myint *p)
> {
>   return *p;
> }
> 
> struct blah
> {
>   char c;
>   myint i;
> };
> 
> struct blah g;
> 
> #define cst 0xdeadbeef
> 
> int
> main (int argc, char **argv)
> {
>   int i;
>   g.i = cst;
>   i = foo (&g.i);
>   if (i != cst)
> abort ();
>   return 0;
> }
> 
> - test case 2: -
> 
> extern void abort ();
> 
> typedef unsigned int myint __attribute__((aligned(1)));
> 
> void __attribute__((noinline, noclone))
> foo (myint *p, unsigned int i)
> {
>   *p = i;
> }
> 
> struct blah
> {
>   char c;
>   myint i;
> };
> 
> struct blah g;
> 
> #define cst 0xdeadbeef
> 
> int
> main (int argc, char **argv)
> {
>   foo (&g.i, cst);
>   if (g.i != cst)
> abort ();
>   return 0;
> }
> 
> 
> 
> I dug in expr.c and found two places which handle misaligned MEM_REfs
> loads and stores respectively but only if there is a special
> movmisalign_optab operation available for the given mode.  My approach
> therefore was to append calls to extract_bit_field and store_bit_field
> which seem to be the part of expander capable of dealing with
> misaligned memory accesses.  The patch is below, it fixes both
> testcases on sparc64--linux-gnu.
> 
> Is this approach generally the right thing to do?  And of course,
> since my knowledge of RTL and expander is very limited I expect that
> there will by quite many suggestions about its various particular
> aspects.  I have run the c and c++ testsuite with the second hunk in
> place without any problems, the same test of the whole patch is under
> way right now but it takes quite a lot of time, therefore most
> probably I won't have the results today.  Of course I plan to do a
> bootstrap and at least Fortran checking on this platform too but that
> is really going to take some time and I'd like to hear any comments
> before that.
> 
> One more question: I'd like to be able to handle misaligned loads of
> stores of SSE vectors this way too but then of course I cannot use
> STRICT_ALIGNMENT as the guard but need a more elaborate predicate.  I
> assume it must already exist, which one is it?
> 
> Thanks a lot in advance for any feedback,

One issue that I am running into now is that we need to robustify/change
expand_assignment quite a bit.  I have a patch for SRA that makes sure
to create properly aligned MEM_REFs but then we have, for example

  MEM[p].m = ...

and in the handled_component_p path of expand_assignment we happily
expand MEM[p] via expand_normal ("for multiple use").  That of course
breaks, as doing so might go to the rvalue-producing movmisalign
path, miscompiling the store.  Even if we handle this case specially
in expand_normal, the UNSPEC x86 for example might produce most certainly
isn't safe for "reuse".  Similar for the path that would use
extract_bit_field (and would need to use store_bitfield).

Which means that, 1) we need to avoid to call expand_normal (tem)
in those cases, and we probably need to fall back to a stack
temporary for non-trivial cases?

Note that the SRA plus SSE-mode aggregate is probably a latent
pre-existing issue as get_object_or_type_alignment might
discover misalignment if we happen to know about an explicit
misalignment.

So, I am going to try to address this issue first.

Richard.


Re: [patch] remove empty directories (libgo, libstdc++-v3, libgomp)

2012-01-24 Thread Jonathan Wakely
On 24 January 2012 11:31, Matthias Klose wrote:
> Ok to remove these three empty directories?
>
> libgo/go/exp/template
> libstdc++-v3/testsuite/30_threads/condition_variable_any/requirements
> libgomp/config/linux/arm

OK for the libstdc++ dir, I should have removed it in rev 180454

Thanks.


Re: [RFC] Fixing expansion of misaligned MEM_REFs on strict-alignment targets

2012-01-24 Thread Richard Guenther
On Tue, 24 Jan 2012, Richard Guenther wrote:

> One issue that I am running into now is that we need to robustify/change
> expand_assignment quite a bit.  I have a patch for SRA that makes sure
> to create properly aligned MEM_REFs but then we have, for example
> 
>   MEM[p].m = ...
> 
> and in the handled_component_p path of expand_assignment we happily
> expand MEM[p] via expand_normal ("for multiple use").  That of course
> breaks, as doing so might go to the rvalue-producing movmisalign
> path, miscompiling the store.  Even if we handle this case specially
> in expand_normal, the UNSPEC x86 for example might produce most certainly
> isn't safe for "reuse".  Similar for the path that would use
> extract_bit_field (and would need to use store_bitfield).
> 
> Which means that, 1) we need to avoid to call expand_normal (tem)
> in those cases, and we probably need to fall back to a stack
> temporary for non-trivial cases?
> 
> Note that the SRA plus SSE-mode aggregate is probably a latent
> pre-existing issue as get_object_or_type_alignment might
> discover misalignment if we happen to know about an explicit
> misalignment.
> 
> So, I am going to try to address this issue first.

Like with the following, currently testing on x86_64-linux.  The
idea is to simply simulate a (piecewise) store into a pseudo
(which we hopefully can handle well enough - almost all cases
can happen right now, as we have MEM_REFs) and simply delay
the misaligned move until the rvalue is ready.  That fixes
my current issue, but it might not scale for a possible
store_bit_field path - I suppose that instead both
optimize_bitfield_assignment_op and store_field have to
handle the misalignment themselves (to_rtx is already a
MEM with MEM_ALIGN indicating the non-mode alignment).

Richard.

2012-01-24  Richard Guenther  

PR tree-optimization/50444
* expr.c (expand_assignment): Handle misaligned bases consistently,
even when wrapped inside component references.

Index: gcc/expr.c
===
*** gcc/expr.c  (revision 183470)
--- gcc/expr.c  (working copy)
*** expand_assignment (tree to, tree from, b
*** 4556,4564 
  {
rtx to_rtx = 0;
rtx result;
-   enum machine_mode mode;
-   unsigned int align;
-   enum insn_code icode;
  
/* Don't crash if the lhs of the assignment was erroneous.  */
if (TREE_CODE (to) == ERROR_MARK)
--- 4556,4561 
*** expand_assignment (tree to, tree from, b
*** 4571,4647 
if (operand_equal_p (to, from, 0))
  return;
  
-   mode = TYPE_MODE (TREE_TYPE (to));
-   if ((TREE_CODE (to) == MEM_REF
-|| TREE_CODE (to) == TARGET_MEM_REF)
-   && mode != BLKmode
-   && ((align = get_object_or_type_alignment (to))
- < GET_MODE_ALIGNMENT (mode))
-   && ((icode = optab_handler (movmisalign_optab, mode))
- != CODE_FOR_nothing))
- {
-   struct expand_operand ops[2];
-   enum machine_mode address_mode;
-   rtx reg, op0, mem;
- 
-   reg = expand_expr (from, NULL_RTX, VOIDmode, EXPAND_NORMAL);
-   reg = force_not_mem (reg);
- 
-   if (TREE_CODE (to) == MEM_REF)
-   {
- addr_space_t as
-   = TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (TREE_OPERAND (to, 0;
- tree base = TREE_OPERAND (to, 0);
- address_mode = targetm.addr_space.address_mode (as);
- op0 = expand_expr (base, NULL_RTX, VOIDmode, EXPAND_NORMAL);
- op0 = convert_memory_address_addr_space (address_mode, op0, as);
- if (!integer_zerop (TREE_OPERAND (to, 1)))
-   {
- rtx off
- = immed_double_int_const (mem_ref_offset (to), address_mode);
- op0 = simplify_gen_binary (PLUS, address_mode, op0, off);
-   }
- op0 = memory_address_addr_space (mode, op0, as);
- mem = gen_rtx_MEM (mode, op0);
- set_mem_attributes (mem, to, 0);
- set_mem_addr_space (mem, as);
-   }
-   else if (TREE_CODE (to) == TARGET_MEM_REF)
-   {
- addr_space_t as
-   = TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (TREE_OPERAND (to, 0;
- struct mem_address addr;
- 
- get_address_description (to, &addr);
- op0 = addr_for_mem_ref (&addr, as, true);
- op0 = memory_address_addr_space (mode, op0, as);
- mem = gen_rtx_MEM (mode, op0);
- set_mem_attributes (mem, to, 0);
- set_mem_addr_space (mem, as);
-   }
-   else
-   gcc_unreachable ();
-   if (TREE_THIS_VOLATILE (to))
-   MEM_VOLATILE_P (mem) = 1;
- 
-   create_fixed_operand (&ops[0], mem);
-   create_input_operand (&ops[1], reg, mode);
-   /* The movmisalign pattern cannot fail, else the assignment would
-  silently be omitted.  */
-   expand_insn (icode, 2, ops);
-   return;
- }
- 
/* Assignment of a structure component needs special treatment
   if the structure component's rtx is not

Re: [libitm] Link eh-1.exe with -shared-libgcc on Solaris (PR libitm/51822)

2012-01-24 Thread Rainer Orth
Richard Henderson  writes:

> On 01/17/2012 04:07 AM, Rainer Orth wrote:
>> * The 32-bit failures on Solaris 8 to 10 have a different root cause:
>>   _Unwind_Find_FDE returns NULL for an address in _ZGTtL2f1v (f1()).  It
>>   turns out that there are two copies of the unwinder in eh-1.exe: one
>>   from libgcc_s.so.1, and another one from libgcc_eh.a.  eh-1.o has a
>>   reference to _Unwind_Resume (don't yet know why), which is resolved
>>   from libgcc_eh.a.  This doesn't happen on Solaris 11, which uses the
>>   dl_iterate_phdr based unwinder, thus no __register_frame_info_bases.
>
> Er.. how did we get two copies?

The link line boils down to

ld -o eh-1.exe crt1.o crti.o crtbegin.o eh-1.o -litm -lstdc++ -lm -lgcc 
-lgcc_eh -lc -lgcc -lgcc_eh crtend.o crtn.o

The eh-1.o reference to _Unwind_Resume drags in one copy of the unwinder
from libgcc_eh.a, while libstdc++.so is linked against libgcc_s.so.1,
providing another copy.

> I don't think this change is correct, as it seems just as likely
> that we'd hit the same problem with real applications.  This just
> seems like it's papering over the real problem.

Quite possible.

Rainer

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


Re: [trans-mem,c++] PR51928

2012-01-24 Thread Aldy Hernandez

On 01/23/12 18:34, Patrick Marlier wrote:

Hi,

In this PR51928, it tries to look_for_tm_attr_overrides on a thunk but
there is no DECL_NAME for thunk. So it fails in
lookup_fnfields_idx_nolazy because name is NULL.

#0 0x00764b5a in lookup_fnfields_idx_nolazy
(type=0x769f77e0, name=0x0) at ../../trunk/gcc/cp/search.c:1384
#1 0x0076551a in lookup_fnfields_1 (type=0x769f77e0,
name=0x0) at ../../trunk/gcc/cp/search.c:1470
#2 0x0076886e in look_for_overrides_here (type=0x769f77e0,
fndecl=0x769f8800) at ../../trunk/gcc/cp/search.c:2026
#3 0x00635a94 in look_for_tm_attr_overrides
(type=0x76a091f8, fndecl=0x769f8800) at
../../trunk/gcc/cp/class.c:4337

I hope the good way to solve this is to use the THUNK_TARGET instead of
the thunk itself. (or just ignore when it is a thunk?)

Tested on x86_64-unknown-linux-gnu.
Thanks.
--
Patrick Marlier.


I can commit for you, but the testcase is missing, though the changelog 
entry for it is there.


Re: [trans-mem] Do not instrument thread locals

2012-01-24 Thread Aldy Hernandez

On 01/24/12 01:34, Richard Henderson wrote:

On 01/24/2012 09:59 AM, Patrick Marlier wrote:

2012-01-23  Patrick Marlier

* trans-mem.c (requires_barrier): Do not instrument thread local
variables and emit save/restore for them.

testsuite/ChangeLog
2012-01-23  Patrick Marlier

* gcc.dg/tm/threadlocal-1.c: New test.



Ok.


r~


Thank you Patrick.

Committed.


Re: [patch] remove empty directories (libgo, libstdc++-v3, libgomp)

2012-01-24 Thread Jakub Jelinek
On Tue, Jan 24, 2012 at 12:31:46PM +0100, Matthias Klose wrote:
> Ok to remove these three empty directories?
> 
> libgo/go/exp/template
> libstdc++-v3/testsuite/30_threads/condition_variable_any/requirements
> libgomp/config/linux/arm

The libgomp one only if you also remove linux/arm path from
libgomp/configure.tgt.  Patch preapproved.

Jakub


[PATCH][2/n] Fix PR50444, SRA and misaligned accesses

2012-01-24 Thread Richard Guenther

This creates a get_pointer_alignment_1 function, similar to
get_object_alignment_1 for use by SRA (and for consistency).

SRA needs to be conservative with its alignment assertions when
building MEM_REFs.  The following patch changes the single place
where we build them.  Together with the posted patch to fix
expanding of stores to unaligned accesses wrapped inside component-refs
this fixes this PR.

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

I'm queuing these patches to apply them in a useful order, but consider
this one quite obvious.  A followup (or rather a patch that I'd apply
before) will be to reduce the number of non-scalarized loads/stores
SRA rewrites (which it ideally should not do at all).

Richard.

2012-01-24  Richard Guenther  

PR tree-optimization/50444
* tree.h (get_pointer_alignment_1): Declare.
* builtins.c (get_pointer_alignment_1): New function.
(get_pointer_alignment): Use it.
* tree-sra.c (build_ref_for_offset): Properly adjust the
MEM_REF type for unaligned accesses.

* gcc.dg/torture/pr50444.c: New testcase.

Index: gcc/tree.h
===
*** gcc/tree.h  (revision 183470)
--- gcc/tree.h  (working copy)
*** extern bool is_builtin_fn (tree);
*** 5450,5455 
--- 5450,5456 
  extern unsigned int get_object_alignment_1 (tree, unsigned HOST_WIDE_INT *);
  extern unsigned int get_object_alignment (tree);
  extern unsigned int get_object_or_type_alignment (tree);
+ extern unsigned int get_pointer_alignment_1 (tree, unsigned HOST_WIDE_INT *);
  extern unsigned int get_pointer_alignment (tree);
  extern tree fold_call_stmt (gimple, bool);
  extern tree gimple_fold_builtin_snprintf_chk (gimple, tree, enum 
built_in_function);
Index: gcc/builtins.c
===
*** gcc/builtins.c  (revision 183470)
--- gcc/builtins.c  (working copy)
*** get_object_or_type_alignment (tree exp)
*** 477,513 
return align;
  }
  
! /* Return the alignment in bits of EXP, a pointer valued expression.
!The alignment returned is, by default, the alignment of the thing that
!EXP points to.  If it is not a POINTER_TYPE, 0 is returned.
  
!Otherwise, look at the expression to see if we can do better, i.e., if the
!expression is actually pointing at an object whose alignment is tighter.  
*/
  
  unsigned int
! get_pointer_alignment (tree exp)
  {
STRIP_NOPS (exp);
  
if (TREE_CODE (exp) == ADDR_EXPR)
! return get_object_alignment (TREE_OPERAND (exp, 0));
else if (TREE_CODE (exp) == SSA_NAME
   && POINTER_TYPE_P (TREE_TYPE (exp)))
  {
struct ptr_info_def *pi = SSA_NAME_PTR_INFO (exp);
-   unsigned align;
if (!pi)
!   return BITS_PER_UNIT;
!   if (pi->misalign != 0)
!   align = (pi->misalign & -pi->misalign);
!   else
!   align = pi->align;
!   return align * BITS_PER_UNIT;
  }
  
return POINTER_TYPE_P (TREE_TYPE (exp)) ? BITS_PER_UNIT : 0;
  }
  
  /* Compute the length of a C string.  TREE_STRING_LENGTH is not the right
 way, because it could contain a zero byte in the middle.
 TREE_STRING_LENGTH is the size of the character array, not the string.
--- 477,535 
return align;
  }
  
! /* For a pointer valued expression EXP compute values M and N such that
!M divides (EXP - N) and such that N < M.  Store N in *BITPOSP and return M.
  
!If EXP is not a pointer, 0 is returned.  */
  
  unsigned int
! get_pointer_alignment_1 (tree exp, unsigned HOST_WIDE_INT *bitposp)
  {
STRIP_NOPS (exp);
  
if (TREE_CODE (exp) == ADDR_EXPR)
! return get_object_alignment_1 (TREE_OPERAND (exp, 0), bitposp);
else if (TREE_CODE (exp) == SSA_NAME
   && POINTER_TYPE_P (TREE_TYPE (exp)))
  {
struct ptr_info_def *pi = SSA_NAME_PTR_INFO (exp);
if (!pi)
!   {
! *bitposp = 0;
! return BITS_PER_UNIT;
!   }
!   *bitposp = pi->misalign * BITS_PER_UNIT;
!   return pi->align * BITS_PER_UNIT;
  }
  
+   *bitposp = 0;
return POINTER_TYPE_P (TREE_TYPE (exp)) ? BITS_PER_UNIT : 0;
  }
  
+ /* Return the alignment in bits of EXP, a pointer valued expression.
+The alignment returned is, by default, the alignment of the thing that
+EXP points to.  If it is not a POINTER_TYPE, 0 is returned.
+ 
+Otherwise, look at the expression to see if we can do better, i.e., if the
+expression is actually pointing at an object whose alignment is tighter.  
*/
+ 
+ unsigned int
+ get_pointer_alignment (tree exp)
+ {
+   unsigned HOST_WIDE_INT bitpos = 0;
+   unsigned int align;
+   
+   align = get_pointer_alignment_1 (exp, &bitpos);
+ 
+   /* align and bitpos now specify known low bits of the pointer.
+  ptr & (align - 1) == bitpos.  */
+ 
+   if (bitpos != 0)
+ align = (bitpos & -bitpos);
+ 
+   return align;
+ }
+ 
  /* Compute t

Re: [trans-mem,c++] PR51928

2012-01-24 Thread Patrick Marlier

On 01/24/2012 08:32 AM, Aldy Hernandez wrote:

On 01/23/12 18:34, Patrick Marlier wrote:

Hi,

In this PR51928, it tries to look_for_tm_attr_overrides on a thunk but
there is no DECL_NAME for thunk. So it fails in
lookup_fnfields_idx_nolazy because name is NULL.

#0 0x00764b5a in lookup_fnfields_idx_nolazy
(type=0x769f77e0, name=0x0) at ../../trunk/gcc/cp/search.c:1384
#1 0x0076551a in lookup_fnfields_1 (type=0x769f77e0,
name=0x0) at ../../trunk/gcc/cp/search.c:1470
#2 0x0076886e in look_for_overrides_here (type=0x769f77e0,
fndecl=0x769f8800) at ../../trunk/gcc/cp/search.c:2026
#3 0x00635a94 in look_for_tm_attr_overrides
(type=0x76a091f8, fndecl=0x769f8800) at
../../trunk/gcc/cp/class.c:4337

I hope the good way to solve this is to use the THUNK_TARGET instead of
the thunk itself. (or just ignore when it is a thunk?)

Tested on x86_64-unknown-linux-gnu.
Thanks.
--
Patrick Marlier.


I can commit for you, but the testcase is missing, though the changelog
entry for it is there.


Sorry for the missing testcase. Here the full patch.
Thanks for taking care of the commit.
--
Patrick.



Index: testsuite/g++.dg/tm/pr51928.C
===
--- testsuite/g++.dg/tm/pr51928.C	(revision 0)
+++ testsuite/g++.dg/tm/pr51928.C	(revision 0)
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-fgnu-tm" } */
+
+struct A; // { dg-error "forward declaration of 'struct A'" }
+
+struct B
+{
+  virtual B* foo(A);
+};
+
+struct C : virtual B
+{
+  virtual C* foo(A) { return 0; } // { dg-error "'' has incomplete type" }
+};
+
+C c;
Index: cp/class.c
===
--- cp/class.c	(revision 183448)
+++ cp/class.c	(working copy)
@@ -4430,7 +4430,12 @@ set_method_tm_attributes (tree t)
   tree vchain;
   for (vchain = BINFO_VIRTUALS (TYPE_BINFO (t)); vchain;
 	   vchain = TREE_CHAIN (vchain))
-	set_one_vmethod_tm_attributes (t, BV_FN (vchain));
+	{
+	  fndecl = BV_FN (vchain);
+	  if (DECL_THUNK_P (fndecl))
+	fndecl = THUNK_TARGET (fndecl);
+	  set_one_vmethod_tm_attributes (t, fndecl);
+	}
 }
 
   /* If the class doesn't have an attribute, nothing more to do.  */


Re: [build] Cleanup rs6000/t-ppccomm configurations (PR other/51022)

2012-01-24 Thread David Edelsohn
On Tue, Jan 24, 2012 at 6:20 AM, Alan Modra  wrote:
> On Mon, Dec 05, 2011 at 07:25:35PM -0500, David Edelsohn wrote:
>> Is this fixed or is someone writing a follow-up patch?
>
> This does the trick.  You could also use
>        case ${host}:${with_multisubdir} in
>            *:*32*)
>                ;;
>            powerpc64-*:* | *:*64*)
>                tmake_file="$tmake_file rs6000/t-linux64"
>                ;;
>        esac
> in config.host, but that's unnecessarily complicated.  The t-linux64
> bits can safely go in other config files.  Bootstrapped and regression
> tested powerpc-linux and powerpc64-linux.
>
>        * config/rs6000/t-linux64: Delete.  Move..
>        * config/rs6000/t-ppc64-fp: .. softfp_wrap defines to here..
>        * config/rs6000/t-linux: ..and libgcc flags to here.

Okay.

Thanks, David


[PATCH][3/n] Fix PR50444, misalignment issues and SRA

2012-01-24 Thread Richard Guenther

This addresses a defect in handling movmisalign-handled stores
when they are wrapped in component-references (think of a
vector mode aggregate containing a single vector, wrapped with
a BIT_FIELD_REF to store a single vector element).  I ran into
this issue while trying to fix PR50444 (and made SRA create
such wrapped movmisalign-handled stores).  We cannot simply
use expand_normal on the inner reference if that possibly
goes through the movmisalign path as that would produce
an rvalue instead of a MEM we can re-use.  A simple fix is
to delay expanding the destination and instead build a pseudo
with the contents we can store via movmisalign.

That the MEM_REF path now goes the handled_component_p path
unconditionally unconvered an issue in store_field which
sets MEM_IN_STRUCT_P to any non-MEM_SCALAR_P destination.
But that's clearly wrong for MEMs where we have no idea
whether they are scalar or part of a struct (which is the
reason this is a tri-state flag combo).  Thus the 2nd patchlet
below.

Bootstrapped and tested on x86_64-unknown-linux-gnu, ok for trunk?

Thanks,
Richard.

2012-01-24  Richard Guenther  

PR tree-optimization/50444
* expr.c (expand_assignment): Handle misaligned bases consistently,
even when wrapped inside component references.

Index: gcc/expr.c
===
*** gcc/expr.c  (revision 183470)
--- gcc/expr.c  (working copy)
*** expand_assignment (tree to, tree from, b
*** 4556,4564 
  {
rtx to_rtx = 0;
rtx result;
-   enum machine_mode mode;
-   unsigned int align;
-   enum insn_code icode;
  
/* Don't crash if the lhs of the assignment was erroneous.  */
if (TREE_CODE (to) == ERROR_MARK)
--- 4556,4561 
*** expand_assignment (tree to, tree from, b
*** 4571,4647 
if (operand_equal_p (to, from, 0))
  return;
  
-   mode = TYPE_MODE (TREE_TYPE (to));
-   if ((TREE_CODE (to) == MEM_REF
-|| TREE_CODE (to) == TARGET_MEM_REF)
-   && mode != BLKmode
-   && ((align = get_object_or_type_alignment (to))
- < GET_MODE_ALIGNMENT (mode))
-   && ((icode = optab_handler (movmisalign_optab, mode))
- != CODE_FOR_nothing))
- {
-   struct expand_operand ops[2];
-   enum machine_mode address_mode;
-   rtx reg, op0, mem;
- 
-   reg = expand_expr (from, NULL_RTX, VOIDmode, EXPAND_NORMAL);
-   reg = force_not_mem (reg);
- 
-   if (TREE_CODE (to) == MEM_REF)
-   {
- addr_space_t as
-   = TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (TREE_OPERAND (to, 0;
- tree base = TREE_OPERAND (to, 0);
- address_mode = targetm.addr_space.address_mode (as);
- op0 = expand_expr (base, NULL_RTX, VOIDmode, EXPAND_NORMAL);
- op0 = convert_memory_address_addr_space (address_mode, op0, as);
- if (!integer_zerop (TREE_OPERAND (to, 1)))
-   {
- rtx off
- = immed_double_int_const (mem_ref_offset (to), address_mode);
- op0 = simplify_gen_binary (PLUS, address_mode, op0, off);
-   }
- op0 = memory_address_addr_space (mode, op0, as);
- mem = gen_rtx_MEM (mode, op0);
- set_mem_attributes (mem, to, 0);
- set_mem_addr_space (mem, as);
-   }
-   else if (TREE_CODE (to) == TARGET_MEM_REF)
-   {
- addr_space_t as
-   = TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (TREE_OPERAND (to, 0;
- struct mem_address addr;
- 
- get_address_description (to, &addr);
- op0 = addr_for_mem_ref (&addr, as, true);
- op0 = memory_address_addr_space (mode, op0, as);
- mem = gen_rtx_MEM (mode, op0);
- set_mem_attributes (mem, to, 0);
- set_mem_addr_space (mem, as);
-   }
-   else
-   gcc_unreachable ();
-   if (TREE_THIS_VOLATILE (to))
-   MEM_VOLATILE_P (mem) = 1;
- 
-   create_fixed_operand (&ops[0], mem);
-   create_input_operand (&ops[1], reg, mode);
-   /* The movmisalign pattern cannot fail, else the assignment would
-  silently be omitted.  */
-   expand_insn (icode, 2, ops);
-   return;
- }
- 
/* Assignment of a structure component needs special treatment
   if the structure component's rtx is not simply a MEM.
   Assignment of an array element at a constant index, and assignment of
   an array element in an unaligned packed structure field, has the same
   problem.  */
if (handled_component_p (to)
!   /* ???  We only need to handle MEM_REF here if the access is not
!  a full access of the base object.  */
!   || (TREE_CODE (to) == MEM_REF
! && TREE_CODE (TREE_OPERAND (to, 0)) == ADDR_EXPR)
|| TREE_CODE (TREE_TYPE (to)) == ARRAY_TYPE)
  {
enum machine_mode mode1;
--- 4568,4581 
if (operand_equal_p (to, from, 0))
  return;
  
/* Assignment of a structure component needs special treatment
   if the 

[patch, testsuite] fix test gcc.dg/pr50908-2.c

2012-01-24 Thread Greta Yorsh
The test gcc.dg/pr50908-2.c fails on arm and other targets where short enums
is the default. 

arm-none-eabi-gcc
/work/local-checkouts/main/gcc-fsf/gcc/testsuite/gcc.dg/pr50908-2.c
/work/local-checkouts/main/gcc-fsf/gcc/testsuite/gcc.dg/pr50908-2.c:39:8:
error: width of 'code' exceeds its type

The compile error has nothing to do with the intended functionality of this
test. The error is due to the use of a bitfield in the test: "enum rtx_code
code:16".

This patch adds the missing compiler option -fno-short-enums to the test.

gcc/testsuite/ChangeLog

2012-01-24  Greta Yorsh  

* gcc.dg/pr50908-2.c (dg-options): Add -fno-short-enums.

test-no-short-enums-v2.patch
Description: Binary data


[Patch ARM] Fix PR 49069.

2012-01-24 Thread Sameera Deshpande
Hi,

Please find attached the patch fixing bug 49069.

This patch is tested with check-gcc on trunk and 4.6 without regression.
OK for trunk?
Is it fine to backport to 4.6 branch?

ChangeLog:
2012-01-24  Sameera Deshpande  
PR target/49069
gcc/config/arm/arm.md (cstoredi4): Handle the case when both
operands are const_int.

gcc/testsuite/ChangeLog:
2012-01-24  Sameera Deshpande  
PR target/49069
gcc.target/arm/pr49069.c: New compile-only test.

- Thanks and regards,
  Sameera D.

diff --git a/gcc/config/arm/arm.md b/gcc/config/arm/arm.md
index 751997f..e3dc98f 100644
--- a/gcc/config/arm/arm.md
+++ b/gcc/config/arm/arm.md
@@ -7911,8 +7911,9 @@
  enum rtx_code code = GET_CODE (operands[1]);
 
  /* We should not have two constants.  */
- gcc_assert (GET_MODE (operands[2]) == DImode
-		 || GET_MODE (operands[3]) == DImode);
+ if (!(GET_MODE (operands[2]) == DImode || GET_MODE (operands[3]) == DImode)
+ && !(reload_in_progress || reload_completed))
+   operands[3] = force_reg (DImode, operands[3]);
 
 /* Flip unimplemented DImode comparisons to a form that
arm_gen_compare_reg can handle.  */
diff --git a/gcc/testsuite/gcc.target/arm/pr49069.c b/gcc/testsuite/gcc.target/arm/pr49069.c
new file mode 100644
index 000..3cc903e
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arm/pr49069.c
@@ -0,0 +1,24 @@
+/* { dg-do compile } */
+/* { dg-options "-Os -mfloat-abi=softfp -mfpu=vfpv3-d16" } */
+
+__extension__ typedef unsigned long long int uint64_t;
+
+static int
+func2 (int a, int b)
+{
+  return a == 0 ? a : a / b;
+}
+
+int array1[1];
+const uint64_t array2[1] = { 1 };
+
+void
+foo (void)
+{
+  for (array1[0] = 0; array1[0] == 1; array1[0]++)
+{
+}
+  if (bar (array2[0] == func2 (array1[0], 0)) == 0)
+{
+}
+}

Re: [v3] libstdc++/49829

2012-01-24 Thread Matthias Klose

On 24.01.2012 00:27, Benjamin Kosnik wrote:


This modularizes the libstdc++ sources such that the resulting library
binaries are now composed of three convenience libraries. In short:


this breaks builds configured with --enable-libstdcxx-debug. Tried the following 
(not yet working) fix.


  Matthias


Index: src/Makefile.am
===
--- src/Makefile.am (revision 183477)
+++ src/Makefile.am (working copy)
@@ -194,8 +194,9 @@
 # Take care to fix all possibly-relative paths.
 stamp-debug:
if test ! -d ${debugdir}; then \
- mkdir -p ${debugdir}; \
+ for d in $(SUBDIRS); do mkdir -p ${debugdir}/$$d; done; \
  (cd ${debugdir}; \
+ for d in . $(SUBDIRS); do \
  sed -e 's/top_builddir = \.\./top_builddir = ..\/../' \
  -e 's/top_build_prefix = \.\./top_build_prefix = ..\/../' \
  -e 's/srcdir = \.\./srcdir = ..\/../' \
@@ -204,7 +205,8 @@
  -e 's/MKDIR_P = \.\./MKDIR_P = ..\/../' \
  -e 's/all-local: build_debug/all-local:/' \
  -e 's/install-data-local: install_debug/install-data-local:/' \
- < ../Makefile > Makefile) ; \
+ < ../$$d/Makefile > $$d/Makefile; \
+ done); \
fi; \
echo `date` > stamp-debug;
 


C++ PATCH for c++/51973 (rejects-valid with explicit template args in call in function signature)

2012-01-24 Thread Jason Merrill
When we compare dependent names, we need to compare any explicit 
template args as well.


Tested x86_64-pc-linux-gnu, applying to trunk.
commit 7446bd5c430bab0ea5b496b93d92d298bb023572
Author: Jason Merrill 
Date:   Tue Jan 24 10:42:22 2012 -0500

	PR c++/51973
	* tree.c (called_fns_equal): Check template args.
	(cp_tree_equal): Call it.

diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index cf39800..b80b52a 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -2174,6 +2174,33 @@ decl_anon_ns_mem_p (const_tree decl)
 }
 }
 
+/* Subroutine of cp_tree_equal: t1 and t2 are the CALL_EXPR_FNs of two
+   CALL_EXPRS.  Return whether they are equivalent.  */
+
+static bool
+called_fns_equal (tree t1, tree t2)
+{
+  /* Core 1321: dependent names are equivalent even if the overload sets
+ are different.  But do compare explicit template arguments.  */
+  tree name1 = dependent_name (t1);
+  tree name2 = dependent_name (t2);
+  if (name1 || name2)
+{
+  tree targs1 = NULL_TREE, targs2 = NULL_TREE;
+
+  if (name1 != name2)
+	return false;
+
+  if (TREE_CODE (t1) == TEMPLATE_ID_EXPR)
+	targs1 = TREE_OPERAND (t1, 1);
+  if (TREE_CODE (t2) == TEMPLATE_ID_EXPR)
+	targs2 = TREE_OPERAND (t2, 1);
+  return cp_tree_equal (targs1, targs2);
+}
+  else
+return cp_tree_equal (t1, t2);
+}
+
 /* Return truthvalue of whether T1 is the same tree structure as T2.
Return 1 if they are the same. Return 0 if they are different.  */
 
@@ -2261,12 +2288,7 @@ cp_tree_equal (tree t1, tree t2)
   {
 	tree arg1, arg2;
 	call_expr_arg_iterator iter1, iter2;
-	/* Core 1321: dependent names are equivalent even if the
-	   overload sets are different.  */
-	tree name1 = dependent_name (CALL_EXPR_FN (t1));
-	tree name2 = dependent_name (CALL_EXPR_FN (t2));
-	if (!(name1 && name2 && name1 == name2)
-	&& !cp_tree_equal (CALL_EXPR_FN (t1), CALL_EXPR_FN (t2)))
+	if (!called_fns_equal (CALL_EXPR_FN (t1), CALL_EXPR_FN (t2)))
 	  return false;
 	for (arg1 = first_call_expr_arg (t1, &iter1),
 	   arg2 = first_call_expr_arg (t2, &iter2);
@@ -2354,26 +2376,18 @@ cp_tree_equal (tree t1, tree t2)
 			  TREE_TYPE (TEMPLATE_PARM_DECL (t2;
 
 case TEMPLATE_ID_EXPR:
+  return (cp_tree_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0))
+	  && cp_tree_equal (TREE_OPERAND (t1, 1), TREE_OPERAND (t2, 1)));
+
+case TREE_VEC:
   {
 	unsigned ix;
-	tree vec1, vec2;
-
-	if (!cp_tree_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0)))
+	if (TREE_VEC_LENGTH (t1) != TREE_VEC_LENGTH (t2))
 	  return false;
-	vec1 = TREE_OPERAND (t1, 1);
-	vec2 = TREE_OPERAND (t2, 1);
-
-	if (!vec1 || !vec2)
-	  return !vec1 && !vec2;
-
-	if (TREE_VEC_LENGTH (vec1) != TREE_VEC_LENGTH (vec2))
-	  return false;
-
-	for (ix = TREE_VEC_LENGTH (vec1); ix--;)
-	  if (!cp_tree_equal (TREE_VEC_ELT (vec1, ix),
-			  TREE_VEC_ELT (vec2, ix)))
+	for (ix = TREE_VEC_LENGTH (t1); ix--;)
+	  if (!cp_tree_equal (TREE_VEC_ELT (t1, ix),
+			  TREE_VEC_ELT (t2, ix)))
 	return false;
-
 	return true;
   }
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/sfinae31.C b/gcc/testsuite/g++.dg/cpp0x/sfinae31.C
new file mode 100644
index 000..ea151fe
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/sfinae31.C
@@ -0,0 +1,13 @@
+// PR c++/51973
+// { dg-options -std=c++0x }
+
+template 
+void f(T t) { };
+
+template  decltype(f(0)) g();
+template  decltype(f(0)) g();
+
+int main()
+{
+  g();
+}


Go patch committed: Better handling of erroneous functions

2012-01-24 Thread Ian Lance Taylor
This patch to the Go frontend improves the handling of erroneous
function signatures, avoiding knock-on errors in various different ways.
It has no effect on correct programs.  Bootstrapped and ran Go testsuite
on x86_64-unknown-linux-gnu.  Committed to mainline.

Ian

Index: gcc/go/gofrontend/gogo.cc
===
--- gcc/go/gofrontend/gogo.cc	(revision 183458)
+++ gcc/go/gofrontend/gogo.cc	(working copy)
@@ -626,8 +626,8 @@ Gogo::start_function(const std::string& 
   const Typed_identifier* receiver = type->receiver();
   Variable* this_param = new Variable(receiver->type(), NULL, false,
 	  true, true, location);
-  std::string name = receiver->name();
-  if (name.empty())
+  std::string rname = receiver->name();
+  if (rname.empty())
 	{
 	  // We need to give receivers a name since they wind up in
 	  // DECL_ARGUMENTS.  FIXME.
@@ -635,10 +635,10 @@ Gogo::start_function(const std::string& 
 	  char buf[50];
 	  snprintf(buf, sizeof buf, "r.%u", count);
 	  ++count;
-	  name = buf;
+	  rname = buf;
 	}
-  if (!Gogo::is_sink_name(name))
-	block->bindings()->add_variable(name, NULL, this_param);
+  if (!Gogo::is_sink_name(rname))
+	block->bindings()->add_variable(rname, NULL, this_param);
 }
 
   const Typed_identifier_list* parameters = type->parameters();
@@ -654,8 +654,8 @@ Gogo::start_function(const std::string& 
 	  if (is_varargs && p + 1 == parameters->end())
 	param->set_is_varargs_parameter();
 
-	  std::string name = p->name();
-	  if (name.empty() || Gogo::is_sink_name(name))
+	  std::string pname = p->name();
+	  if (pname.empty() || Gogo::is_sink_name(pname))
 	{
 	  // We need to give parameters a name since they wind up
 	  // in DECL_ARGUMENTS.  FIXME.
@@ -663,9 +663,9 @@ Gogo::start_function(const std::string& 
 	  char buf[50];
 	  snprintf(buf, sizeof buf, "p.%u", count);
 	  ++count;
-	  name = buf;
+	  pname = buf;
 	}
-	  block->bindings()->add_variable(name, NULL, param);
+	  block->bindings()->add_variable(pname, NULL, param);
 	}
 }
 
@@ -834,6 +834,14 @@ Gogo::finish_block(Location location)
   return block;
 }
 
+// Add an erroneous name.
+
+Named_object*
+Gogo::add_erroneous_name(const std::string& name)
+{
+  return this->package_->bindings()->add_erroneous_name(name);
+}
+
 // Add an unknown name.
 
 Named_object*
@@ -3522,6 +3530,7 @@ Block::traverse(Traverse* traverse)
 
 	case Named_object::NAMED_OBJECT_TYPE_DECLARATION:
 	case Named_object::NAMED_OBJECT_UNKNOWN:
+	case Named_object::NAMED_OBJECT_ERRONEOUS:
 	  break;
 
 	case Named_object::NAMED_OBJECT_PACKAGE:
@@ -4521,6 +4530,9 @@ Named_object::location() const
 case NAMED_OBJECT_UNINITIALIZED:
   go_unreachable();
 
+case NAMED_OBJECT_ERRONEOUS:
+  return Linemap::unknown_location();
+
 case NAMED_OBJECT_UNKNOWN:
   return this->unknown_value()->location();
 
@@ -4565,6 +4577,9 @@ Named_object::export_named_object(Export
 case NAMED_OBJECT_UNKNOWN:
   go_unreachable();
 
+case NAMED_OBJECT_ERRONEOUS:
+  break;
+
 case NAMED_OBJECT_CONST:
   this->const_value()->export_const(exp, this->name_);
   break;
@@ -4751,6 +4766,9 @@ Bindings::add_named_object_to_contour(Co
 Named_object*
 Bindings::new_definition(Named_object* old_object, Named_object* new_object)
 {
+  if (new_object->is_erroneous() && !old_object->is_erroneous())
+return new_object;
+
   std::string reason;
   switch (old_object->classification())
 {
@@ -4758,6 +4776,9 @@ Bindings::new_definition(Named_object* o
 case Named_object::NAMED_OBJECT_UNINITIALIZED:
   go_unreachable();
 
+case Named_object::NAMED_OBJECT_ERRONEOUS:
+  return old_object;
+
 case Named_object::NAMED_OBJECT_UNKNOWN:
   {
 	Named_object* real = old_object->unknown_value()->real_named_object();
@@ -5003,6 +5024,7 @@ Bindings::traverse(Traverse* traverse, b
 	case Named_object::NAMED_OBJECT_TYPE_DECLARATION:
 	case Named_object::NAMED_OBJECT_FUNC_DECLARATION:
 	case Named_object::NAMED_OBJECT_UNKNOWN:
+	case Named_object::NAMED_OBJECT_ERRONEOUS:
 	  break;
 
 	case Named_object::NAMED_OBJECT_SINK:
Index: gcc/go/gofrontend/gogo.h
===
--- gcc/go/gofrontend/gogo.h	(revision 183458)
+++ gcc/go/gofrontend/gogo.h	(working copy)
@@ -267,6 +267,11 @@ class Gogo
   Block*
   finish_block(Location);
 
+  // Declare an erroneous name.  This is used to avoid knock-on errors
+  // after a parsing error.
+  Named_object*
+  add_erroneous_name(const std::string& name);
+
   // Declare an unknown name.  This is used while parsing.  The name
   // must be resolved by the end of the parse.  Unknown names are
   // always added at the package level.
@@ -1688,6 +1693,9 @@ class Named_object
   {
 // An uninitialized Named_object.  We should never see this.
 NAMED_OBJECT_UNINITIALIZED,
+// An err

Fix target/51968: arm neon ice on vconcat

2012-01-24 Thread Richard Henderson
When I re-arranged the vconcat support for vec_perm, I forgot
that one must emit *something* in order to effect a split;
failure is equated with nothing being emitted.

Tested with qemu-arm, with more testing by the PR reporter.
Committed.


r~
PR target/51968
* config/arm/arm.c (neon_split_vcombine): Emit deleted note
to effect no-op split.


diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 8f1412a..4a94145 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -20928,7 +20928,11 @@ neon_split_vcombine (rtx operands[3])
   rtx destlo, desthi;
 
   if (src1 == dest && src2 == dest + halfregs)
-return;
+{
+  /* No-op move.  Can't split to nothing; emit something.  */
+  emit_note (NOTE_INSN_DELETED);
+  return;
+}
 
   /* Preserve register attributes for variable tracking.  */
   destlo = gen_rtx_REG_offset (operands[0], halfmode, dest, 0);
diff --git a/gcc/testsuite/gcc.target/arm/pr51968.c 
b/gcc/testsuite/gcc.target/arm/pr51968.c
new file mode 100644
index 000..f0506c2
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arm/pr51968.c
@@ -0,0 +1,32 @@
+/* PR target/51968 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -march=armv7-a -mfloat-abi=softfp -mfpu=neon" } */
+/* { dg-require-effective-target arm_neon_ok } */
+
+typedef __builtin_neon_qi int8x8_t __attribute__ ((__vector_size__ (8)));
+typedef __builtin_neon_uqi uint8x8_t __attribute__ ((__vector_size__ (8)));
+typedef __builtin_neon_qi int8x16_t __attribute__ ((__vector_size__ (16)));
+typedef __builtin_neon_hi int16x8_t __attribute__ ((__vector_size__ (16)));
+typedef __builtin_neon_si int32x4_t __attribute__ ((__vector_size__ (16)));
+struct T { int8x8_t val[2]; };
+int y;
+
+void
+foo (int8x8_t z, int8x8_t x, int16x8_t b, int8x8_t n)
+{
+  if (y)
+{
+  struct T m;
+  __builtin_neon_vuzpv8qi (&m.val[0], z, x);
+}
+  for (;;)
+{
+  int8x16_t g;
+  int8x8_t h, j, k;
+  struct T m;
+  j = __builtin_neon_vqmovunv8hi (b, 1);
+  g = __builtin_neon_vcombinev8qi (j, h);
+  k = __builtin_neon_vget_lowv16qi (g);
+  __builtin_neon_vuzpv8qi (&m.val[0], k, n);
+}
+}


[patch] libitm: Fix wake-up of readers in futex-based serial lock.

2012-01-24 Thread Torvald Riegel
This patch fixes a lost wake-up bug in the futex-based serial lock
implementation.  The previous code lacked some pieces of synchronization
(a seq_cst barrier and resetting a flag that is checked by the
respective futex_wait()), which led to those lost wake-ups when waking
and waiting were racing against each other.
Tested on ppc64 with microbenchmarks/STAMP and gl_wt.

OK for trunk?
commit a04fadca7c74f35d6d1d4f12d745c0ab44cc315a
Author: Torvald Riegel 
Date:   Tue Jan 24 15:05:42 2012 +0100

libitm: Fix wake-up of readers in futex-based serial lock.

libitm/
* config/linux/rwlock.cc (GTM::gtm_rwlock::write_unlock): Fix reader
wake-up.

diff --git a/libitm/config/linux/rwlock.cc b/libitm/config/linux/rwlock.cc
index 24e7042..ad1b042 100644
--- a/libitm/config/linux/rwlock.cc
+++ b/libitm/config/linux/rwlock.cc
@@ -231,10 +231,13 @@ gtm_rwlock::write_unlock ()
  // last writer (this can happen because write_lock_generic()
  // exchanges 0 or 1 to 2 and thus might go to contended mode even if
  // no other thread holds the write lock currently). Therefore, we
- // have to wake up readers here as well.
- futex_wake(&readers, INT_MAX);
+ // have to wake up readers here as well.  Execute a barrier after
+ // the previous relaxed reset of writers (Dekker-style), and fall
+ // through to the normal reader wake-up code.
+ atomic_thread_fence (memory_order_seq_cst);
}
-  return;
+  else
+   return;
 }
   // No waiting writers, so wake up all waiting readers.
   // Because the fetch_and_sub is a full barrier already, we don't need


sparc: fix v7 memory barrier handling

2012-01-24 Thread Richard Henderson
While investigating atomic-test-and-set problems, I found
that sparc v7 wasn't matching the memory barrier as desired.

The problem turned out to be that the lack of a match_code
containing const_int meant that genpreds generated the wrong
mode test within the predicate.  Which meant that no values
matched, instead of all values.

Tested along side patches to come.  Committed.


r~
* config/sparc/predicates.md (zero_or_v7_operand): Use match_code.



diff --git a/gcc/config/sparc/predicates.md b/gcc/config/sparc/predicates.md
index 81e5320..308fbd6 100644
--- a/gcc/config/sparc/predicates.md
+++ b/gcc/config/sparc/predicates.md
@@ -1,5 +1,5 @@
 ;; Predicate definitions for SPARC.
-;; Copyright (C) 2005, 2007, 2008, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 2005, 2007, 2008, 2010, 2012 Free Software Foundation, Inc.
 ;;
 ;; This file is part of GCC.
 ;;
@@ -113,8 +113,9 @@
 
 ;; Return true if OP is Zero, or if the target is V7.
 (define_predicate "zero_or_v7_operand"
-  (ior (match_test "op == const0_rtx")
-   (match_test "!TARGET_V8 && !TARGET_V9")))
+  (and (match_code "const_int")
+   (ior (match_test "INTVAL (op) == 0")
+   (match_test "!TARGET_V8 && !TARGET_V9"
 
 ;; Predicates for symbolic constants.
 


Go patch committed: Verify types of sink variables

2012-01-24 Thread Ian Lance Taylor
This patch makes gccgo verify the types of sink variables, so that we
issue an error as required for code like
var _ map[[]int]bool
Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
Committed to mainline.

Ian

diff -r 411e398e3e68 go/gogo.cc
--- a/go/gogo.cc	Tue Jan 24 09:20:57 2012 -0800
+++ b/go/gogo.cc	Tue Jan 24 09:40:18 2012 -0800
@@ -37,6 +37,7 @@
 imported_init_fns_(),
 unique_prefix_(),
 unique_prefix_specified_(false),
+verify_types_(),
 interface_types_(),
 specific_type_functions_(),
 specific_type_functions_are_written_(false),
@@ -1282,6 +1283,15 @@
 }
 }
 
+// Add a type to verify.  This is used for types of sink variables, in
+// order to give appropriate error messages.
+
+void
+Gogo::add_type_to_verify(Type* type)
+{
+  this->verify_types_.push_back(type);
+}
+
 // Traversal class used to verify types.
 
 class Verify_types : public Traverse
@@ -1312,6 +1322,12 @@
 {
   Verify_types traverse;
   this->traverse(&traverse);
+
+  for (std::vector::iterator p = this->verify_types_.begin();
+   p != this->verify_types_.end();
+   ++p)
+(*p)->verify();
+  this->verify_types_.clear();
 }
 
 // Traversal class used to lower parse tree.
diff -r 411e398e3e68 go/gogo.h
--- a/go/gogo.h	Tue Jan 24 09:20:57 2012 -0800
+++ b/go/gogo.h	Tue Jan 24 09:40:18 2012 -0800
@@ -344,6 +344,11 @@
   Named_object*
   add_sink();
 
+  // Add a type which needs to be verified.  This is used for sink
+  // types, just to give appropriate error messages.
+  void
+  add_type_to_verify(Type* type);
+
   // Add a named object to the current namespace.  This is used for
   // import . "package".
   void
@@ -683,6 +688,8 @@
   std::string unique_prefix_;
   // Whether an explicit unique prefix was set by -fgo-prefix.
   bool unique_prefix_specified_;
+  // A list of types to verify.
+  std::vector verify_types_;
   // A list of interface types defined while parsing.
   std::vector interface_types_;
   // Type specific functions to write out.
diff -r 411e398e3e68 go/parse.cc
--- a/go/parse.cc	Tue Jan 24 09:20:57 2012 -0800
+++ b/go/parse.cc	Tue Jan 24 09:40:18 2012 -0800
@@ -1911,6 +1911,8 @@
 	  return this->gogo_->add_variable(buf, var);
 	}
 	}
+  if (type != NULL)
+	this->gogo_->add_type_to_verify(type);
   return this->gogo_->add_sink();
 }
 


Re: [patch, testsuite] fix test gcc.dg/pr50908-2.c

2012-01-24 Thread Mike Stump
On Jan 24, 2012, at 7:55 AM, Greta Yorsh wrote:
> The test gcc.dg/pr50908-2.c fails on arm and other targets where short enums
> is the default. 

>   * gcc.dg/pr50908-2.c (dg-options): Add -fno-short-enums.

Ok.


[Patch, Fortran] PR 51966 - Fix struct constructor with character-parameter

2012-01-24 Thread Tobias Burnus

Hi all,

first: I am still looking for someone to review my patch at 
http://gcc.gnu.org/ml/fortran/2012-01/msg00197.html


 * * *

In PR 44857, a patch was added which changed:
   = dt_constructor ( character_parameter_array )
to
   = dt_constructor ( (/ character(len=n) :: character_parameter_array /) )
if the component had a different length that the PARAMETER of type 
character. (Without that change, either out of bound issues occurred or 
one the blank padding was missing.)


Unfortunately, the this change was also applied to scalar expressions 
such as

   = dt_constructor ( character_parameter_array(index) )
which causes an ICE.

The solution is simple: Only do this kind of optimization for arrays.

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

 * * *

Current regression status:
- 8 gfortran regressions (including this one) of which I only regard the 
front-end-optimization wong-code issue as serious. One 4.6-only 
ice-on-valid-code issue - and 5 other regressions which I regard as of 
lesser importance.
- 82 serious regression, 6 P1, 64 P2, 12 P3 - and 108 other regressions 
(64 P4 and 54 P5).


Tobias

PS: I think the patch is obvious enough that I will commit it tomorrow, 
unless I get an OK today or someone finds a reason why the patch is not 
the best solution.
2012-01-24  Tobias Burnus  

	PR fortran/51966
	* resolve.c (resolve_structure_cons): Only create an
	array constructors for nonscalars.

2012-01-24  Tobias Burnus  

	PR fortran/51966
	* gfortran.dg/derived_constructor_char_3.f90: New.

diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index c169b9e..b24399d 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -1051,6 +1051,7 @@ resolve_structure_cons (gfc_expr *expr, int init)
 	  && comp->ts.u.cl->length->expr_type == EXPR_CONSTANT
 	  && cons->expr->ts.u.cl && cons->expr->ts.u.cl->length
 	  && cons->expr->ts.u.cl->length->expr_type == EXPR_CONSTANT
+	  && cons->expr->rank != 0
 	  && mpz_cmp (cons->expr->ts.u.cl->length->value.integer,
 		  comp->ts.u.cl->length->value.integer) != 0)
 	{
--- /dev/null	2012-01-23 08:22:38.999666895 +0100
+++ gcc/gcc/testsuite/gfortran.dg/derived_constructor_char_3.f90	2012-01-24 18:25:51.0 +0100
@@ -0,0 +1,30 @@
+! { dg-do compile }
+!
+! PR fortran/51966
+!
+! Contributed by Peter Wind
+!
+
+  type :: Deriv
+character(len=10) :: name
+  end type
+  character(len=8), dimension(2), parameter :: &
+   DEF_ECOSYSTEMS = (/ "Grid", "StringYY" /)
+
+  type(Deriv), save :: DepEcoSystem = Deriv(DEF_ECOSYSTEMS(1))
+
+  if (DepEcoSystem%name /= "Grid" &
+  .or. DepEcoSystem%name(9:9) /= ' ' &
+  .or. DepEcoSystem%name(10:10) /= ' ') call abort()
+  DepEcoSystem%name = 'ABCDEFGHIJ'
+  call Init_EcoSystems()
+  if (DepEcoSystem%name /= "StringYY" &
+  .or. DepEcoSystem%name(9:9) /= ' ' &
+  .or. DepEcoSystem%name(10:10) /= ' ') call abort()
+
+contains
+  subroutine Init_EcoSystems()
+integer :: i =2
+DepEcoSystem = Deriv(DEF_ECOSYSTEMS(i))
+  end subroutine Init_EcoSystems
+end


Re: [libitm] Link eh-1.exe with -shared-libgcc on Solaris (PR libitm/51822)

2012-01-24 Thread Richard Henderson
On 01/25/2012 12:03 AM, Rainer Orth wrote:
>> Er.. how did we get two copies?
> 
> The link line boils down to
> 
> ld -o eh-1.exe crt1.o crti.o crtbegin.o eh-1.o -litm -lstdc++ -lm -lgcc 
> -lgcc_eh -lc -lgcc -lgcc_eh crtend.o crtn.o
> 
> The eh-1.o reference to _Unwind_Resume drags in one copy of the unwinder
> from libgcc_eh.a, while libstdc++.so is linked against libgcc_s.so.1,
> providing another copy.

So... are we linking with the gcc binary, not the g++ binary?
Because I thought -shared-libgcc is the default for C++.

If this goes too far down a rat-hole, your original patch is ok.


r~


Re: [patch] libitm: Fix wake-up of readers in futex-based serial lock.

2012-01-24 Thread Richard Henderson
On 01/25/2012 04:43 AM, Torvald Riegel wrote:
> libitm: Fix wake-up of readers in futex-based serial lock.
> 
>   libitm/
>   * config/linux/rwlock.cc (GTM::gtm_rwlock::write_unlock): Fix reader
>   wake-up.

Ok.


r~


Re: [PATCH] Fix PR33763

2012-01-24 Thread Joseph S. Myers
On Mon, 16 Jan 2012, Richard Guenther wrote:

> +   /* Do not merge an extern inline decl with any other decl either.  */
> +   if ((DECL_DECLARED_INLINE_P (newdecl)
> +&& DECL_EXTERNAL (newdecl))
> +   || (!flag_gnu89_inline
> +   && (DECL_DECLARED_INLINE_P (newdecl)
> +   || lookup_attribute ("gnu_inline",
> +DECL_ATTRIBUTES (newdecl)
> + return false;

That's not safe.  Consider the following test with -std=c99 
-pedantic-errors:

inline void h (void);
inline void h () {}

With your patch applied this gives an incorrect error "inline function 'h' 
declared but never defined".  The function was defined.  Another case:

inline void h (void);
inline void h ();
void i (void) { h (0); }
inline void h (void) {}

You get the same bogus error - but not the correct error you should get 
about "too many arguments to function 'h'".

For C99 inline functions, you only are allowed one body for the function - 
but do need to merge declarations to get the correct composite type, and 
correct diagnostics about whether the function was defined.

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


Re: [testsuite] Avoid assuming argc != 0

2012-01-24 Thread Richard Sandiford
Mike Stump  writes:
> On Jan 23, 2012, at 11:13 AM, Richard Sandiford wrote:
>> One fix is attached.  Another would be to read from a volatile variable
>> that has been initialised to 1.  Other possibilities exist too of course.
>> 
>> Tested on mipsisa64-elf.  OK to install?
>
> Ok.  I have a preference for volatile (clearer intent)...

Yeah, me too.  Here's what I installed after retesting.

Thanks,
Richard


gcc/testsuite/
* gcc.c-torture/execute/scal-to-vec1.c (one): New volatile variable.
(main): Use it instead of argc.

Index: gcc/testsuite/gcc.c-torture/execute/scal-to-vec1.c
===
--- gcc/testsuite/gcc.c-torture/execute/scal-to-vec1.c  2012-01-24 
18:57:39.0 +
+++ gcc/testsuite/gcc.c-torture/execute/scal-to-vec1.c  2012-01-24 
19:08:12.0 +
@@ -24,13 +24,14 @@ #define veccompare(type, count, v0, v1)
 } \
 } while (0)
 
+volatile int one = 1;
 
 int main (int argc, char *argv[]) {
 #define fvec_2 (vector(4, float)){2., 2., 2., 2.}
 #define dvec_2 (vector(2, double)){2., 2.}
 
 
-vector(8, short) v0 = {argc, 1,2,3,4,5,6,7};
+vector(8, short) v0 = {one, 1, 2, 3, 4, 5, 6, 7};
 vector(8, short) v1;
 
 vector(4, float) f0 = {1., 2., 3., 4.};


Go patch committed: Correct type of character expressions

2012-01-24 Thread Ian Lance Taylor
This patch to the Go compiler corrects the type of expressions involving
untyped character constants.  An expression like 'a' + 1 should take on
the type rune, not the type int.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian

diff -r cffcfa23a3b4 go/expressions.cc
--- a/go/expressions.cc	Tue Jan 24 09:51:15 2012 -0800
+++ b/go/expressions.cc	Tue Jan 24 11:10:00 2012 -0800
@@ -5556,7 +5556,9 @@
 	Expression* ret = NULL;
 	if (left_type != right_type
 	&& left_type != NULL
+	&& !left_type->is_abstract()
 	&& right_type != NULL
+	&& !right_type->is_abstract()
 	&& left_type->base() != right_type->base()
 	&& op != OPERATOR_LSHIFT
 	&& op != OPERATOR_RSHIFT)
@@ -5608,7 +5610,27 @@
 		  type = right_type;
 		else
 		  type = left_type;
-		ret = Expression::make_integer(&val, type, location);
+
+		bool is_character = false;
+		if (type == NULL)
+		  {
+		Type* t = this->left_->type();
+		if (t->integer_type() != NULL
+			&& t->integer_type()->is_rune())
+		  is_character = true;
+		else if (op != OPERATOR_LSHIFT && op != OPERATOR_RSHIFT)
+		  {
+			t = this->right_->type();
+			if (t->integer_type() != NULL
+			&& t->integer_type()->is_rune())
+			  is_character = true;
+		  }
+		  }
+
+		if (is_character)
+		  ret = Expression::make_character(&val, type, location);
+		else
+		  ret = Expression::make_integer(&val, type, location);
 	  }
 
 	mpz_clear(val);
@@ -6252,6 +6274,12 @@
 	  return left_type;
 	else if (right_type->float_type() != NULL)
 	  return right_type;
+	else if (left_type->integer_type() != NULL
+		 && left_type->integer_type()->is_rune())
+	  return left_type;
+	else if (right_type->integer_type() != NULL
+		 && right_type->integer_type()->is_rune())
+	  return right_type;
 	else
 	  return left_type;
   }


[MIPS, committed] Fix target conditions for MIPS3D instructions

2012-01-24 Thread Richard Sandiford
All the MIPS3D patterns were testing the wrong condition:
TARGET_PAIRED_SINGLE_FLOAT rather than TARGET_MIPS3D.  I think this
has been latent since the MIPS3D support was added, but it was shielded
by the definitions of the built-in functions, which require TARGET_MIPS3D.

We now use these patterns for the autovectoriser too, and various
vect.exp tests were failing on mipsisa64-elf because we were trying
to use addr.ps on a non-MIPS3D target.

Tested on mipsisa64-elf and mips64-linux-gnu.  Applied.

At some point we might want to run the vectoriser tests with -mips3d,
but this bug shows why running with plain -mpaired-single is useful too.

Richard


gcc/
* config/mips/mips-ps-3d.md (mips_addr_ps, reduc_splus_v2sf)
(mips_cvt_pw_ps, mips_cvt_ps_pw, mips_mulr_ps, mips_cabs_cond_)
(mips_cabs_cond_4s, mips_cabs_cond_ps, bc1any4t, bc1any4f, bc1any2t)
(bc1any2f, mips_rsqrt1_, mips_rsqrt2_, mips_recip1_)
(mips_recip2_): Require TARGET_MIPS3D rather than
TARGET_PAIRED_SINGLE_FLOAT.

Index: gcc/config/mips/mips-ps-3d.md
===
--- gcc/config/mips/mips-ps-3d.md   2012-01-24 19:20:28.0 +
+++ gcc/config/mips/mips-ps-3d.md   2012-01-24 19:26:46.0 +
@@ -366,7 +366,7 @@ (define_insn "mips_addr_ps"
(unspec:V2SF [(match_operand:V2SF 1 "register_operand" "f")
  (match_operand:V2SF 2 "register_operand" "f")]
 UNSPEC_ADDR_PS))]
-  "TARGET_HARD_FLOAT && TARGET_PAIRED_SINGLE_FLOAT"
+  "TARGET_HARD_FLOAT && TARGET_MIPS3D"
   "addr.ps\t%0,%1,%2"
   [(set_attr "type" "fadd")
(set_attr "mode" "SF")])
@@ -376,7 +376,7 @@ (define_insn "reduc_splus_v2sf"
(unspec:V2SF [(match_operand:V2SF 1 "register_operand" "f")
  (match_dup 1)]
 UNSPEC_ADDR_PS))]
-  "TARGET_HARD_FLOAT && TARGET_PAIRED_SINGLE_FLOAT"
+  "TARGET_HARD_FLOAT && TARGET_MIPS3D"
   "")
 
 ; cvt.pw.ps - Floating Point Convert Paired Single to Paired Word
@@ -384,7 +384,7 @@ (define_insn "mips_cvt_pw_ps"
   [(set (match_operand:V2SF 0 "register_operand" "=f")
(unspec:V2SF [(match_operand:V2SF 1 "register_operand" "f")]
 UNSPEC_CVT_PW_PS))]
-  "TARGET_HARD_FLOAT && TARGET_PAIRED_SINGLE_FLOAT"
+  "TARGET_HARD_FLOAT && TARGET_MIPS3D"
   "cvt.pw.ps\t%0,%1"
   [(set_attr "type" "fcvt")
(set_attr "mode" "SF")])
@@ -394,7 +394,7 @@ (define_insn "mips_cvt_ps_pw"
   [(set (match_operand:V2SF 0 "register_operand" "=f")
(unspec:V2SF [(match_operand:V2SF 1 "register_operand" "f")]
 UNSPEC_CVT_PS_PW))]
-  "TARGET_HARD_FLOAT && TARGET_PAIRED_SINGLE_FLOAT"
+  "TARGET_HARD_FLOAT && TARGET_MIPS3D"
   "cvt.ps.pw\t%0,%1"
   [(set_attr "type" "fcvt")
(set_attr "mode" "SF")])
@@ -405,7 +405,7 @@ (define_insn "mips_mulr_ps"
(unspec:V2SF [(match_operand:V2SF 1 "register_operand" "f")
  (match_operand:V2SF 2 "register_operand" "f")]
 UNSPEC_MULR_PS))]
-  "TARGET_HARD_FLOAT && TARGET_PAIRED_SINGLE_FLOAT"
+  "TARGET_HARD_FLOAT && TARGET_MIPS3D"
   "mulr.ps\t%0,%1,%2"
   [(set_attr "type" "fmul")
(set_attr "mode" "SF")])
@@ -445,7 +445,7 @@ (define_insn "mips_cabs_cond_"
(match_operand:SCALARF 2 "register_operand" "f")
(match_operand 3 "const_int_operand" "")]
   UNSPEC_CABS))]
-  "TARGET_HARD_FLOAT && TARGET_PAIRED_SINGLE_FLOAT"
+  "TARGET_HARD_FLOAT && TARGET_MIPS3D"
   "cabs.%Y3.\t%0,%1,%2"
   [(set_attr "type" "fcmp")
(set_attr "mode" "FPSW")])
@@ -492,7 +492,7 @@ (define_insn_and_split "mips_cabs_cond_4
  (match_operand:V2SF 4 "register_operand" "f")
  (match_operand 5 "const_int_operand" "")]
 UNSPEC_CABS))]
-  "TARGET_HARD_FLOAT && TARGET_PAIRED_SINGLE_FLOAT"
+  "TARGET_HARD_FLOAT && TARGET_MIPS3D"
   "#"
   "&& reload_completed"
   [(set (match_dup 6)
@@ -535,7 +535,7 @@ (define_insn "mips_cabs_cond_ps"
  (match_operand:V2SF 2 "register_operand" "f")
  (match_operand 3 "const_int_operand" "")]
 UNSPEC_CABS))]
-  "TARGET_HARD_FLOAT && TARGET_PAIRED_SINGLE_FLOAT"
+  "TARGET_HARD_FLOAT && TARGET_MIPS3D"
   "cabs.%Y3.ps\t%0,%1,%2"
   [(set_attr "type" "fcmp")
(set_attr "mode" "FPSW")])
@@ -578,7 +578,7 @@ (define_insn "bc1any4t"
  (const_int 0))
  (label_ref (match_operand 0 "" ""))
  (pc)))]
-  "TARGET_HARD_FLOAT && TARGET_PAIRED_SINGLE_FLOAT"
+  "TARGET_HARD_FLOAT && TARGET_MIPS3D"
   "%*bc1any4t\t%1,%0%/"
   [(set_attr "type" "branch")])
 
@@ -589,7 +589,7 @@ (define_insn "bc1any4f"
  (const_int -1))
  (label_ref (match_operand 0 "" ""))
  (pc)))]
-  "TARGET_HARD_FLOAT && TARGET_PAIRED_SINGLE_FLOAT"
+  "TARGET_HARD_FLOAT && TARGET_MIPS3D"

[ping 4] [patch] attribute to reverse bitfield allocations

2012-01-24 Thread DJ Delorie

Ping 4...

> Ping 3?  It's been months with no feedback...
> 
> > Ping 2 ?
> > 
> > http://gcc.gnu.org/ml/gcc-patches/2011-07/msg01889.html
> > http://gcc.gnu.org/ml/gcc-patches/2011-07/msg02555.html
http://gcc.gnu.org/ml/gcc-patches/2012-01/msg00529.html


[MIPS, committed] Clean up vect.exp results

2012-01-24 Thread Richard Sandiford
...for -mpaired-single at least.  Although the patch shows the intention
of making this specific to -mpaired-single, we don't distinguish between
integer and float capabilities, so the condition effectively triggers
for Loongson integer vectors too.

The patch is still correct for floats on Loongson, and the Loongson
results are messy even without this patch, so I'm afraid I'm going
to punt on them for now and concentrate on getting the standard ISA
results clean.  The lack of feedback to Richard's autovectorisation
patches makes me wonder how much interest there is in Loongson these
days anyway.

Tested on mipsisa64-elf and mips64-linux-gnu.  Applied.

Richard


gcc/testsuite/
* lib/target-supports.exp (proc check_effective_target_vect_perm)
(check_effective_target_vect_extract_even_odd)
(check_effective_target_vect_interleave): Return true for MIPS
paired-single.

Index: gcc/testsuite/lib/target-supports.exp
===
--- gcc/testsuite/lib/target-supports.exp   2012-01-24 19:20:28.0 
+
+++ gcc/testsuite/lib/target-supports.exp   2012-01-24 19:40:13.0 
+
@@ -2759,7 +2759,9 @@ proc check_effective_target_vect_perm {
 || [istarget powerpc*-*-*]
  || [istarget spu-*-*]
 || [istarget i?86-*-*]
-|| [istarget x86_64-*-*] } {
+|| [istarget x86_64-*-*]
+|| ([istarget mips*-*-*]
+&& [check_effective_target_mpaired_single]) } {
 set et_vect_perm_saved 1
 }
 }
@@ -3484,8 +3486,10 @@ proc check_effective_target_vect_extract
  || [istarget i?86-*-*]
  || [istarget x86_64-*-*]
  || [istarget ia64-*-*]
- || [istarget spu-*-*] } {
-   set et_vect_extract_even_odd_saved 1
+ || [istarget spu-*-*]
+|| ([istarget mips*-*-*]
+&& [check_effective_target_mpaired_single]) } {
+   set et_vect_extract_even_odd_saved 1
 }
 }
 
@@ -3507,7 +3511,9 @@ proc check_effective_target_vect_interle
  || [istarget i?86-*-*]
  || [istarget x86_64-*-*]
  || [istarget ia64-*-*]
- || [istarget spu-*-*] } {
+ || [istarget spu-*-*]
+|| ([istarget mips*-*-*]
+&& [check_effective_target_mpaired_single]) } {
set et_vect_interleave_saved 1
 }
 }


[committed] Avoid optabs.c warning

2012-01-24 Thread Richard Sandiford
If the target doesn't have an atomic_test_and_set pattern, we'd warn
about "mode" being unused.

Tested on mips64-linux-gnu and applied as obvious.

Richard


gcc/
* optabs.c (gen_atomic_test_and_set): Use each argument.

Index: gcc/optabs.c
===
--- gcc/optabs.c2012-01-24 19:48:11.0 +
+++ gcc/optabs.c2012-01-24 19:48:11.0 +
@@ -7311,7 +7311,8 @@ maybe_emit_compare_and_swap_exchange_loo
 #ifndef HAVE_atomic_test_and_set
 #define HAVE_atomic_test_and_set 0
 #define CODE_FOR_atomic_test_and_set CODE_FOR_nothing
-#define gen_atomic_test_and_set(x,y,z)  (gcc_unreachable (), NULL_RTX)
+#define gen_atomic_test_and_set(x,y,z) \
+  (gcc_unreachable (), (void) (0 && (x) && (y) && (z)), NULL_RTX)
 #endif
 
 static rtx


[pph] Factor out some tree header reading code (issue5575050)

2012-01-24 Thread Diego Novillo

This patch factors out some code, which was making debugging
unnecessarily confusing.

When we read the header of a tree, we first read an LTO tag marker to
identify what kind of tree we are reading.  However, we were doing
this *outside* of pph_in_tree_header, which resulted in code
duplication in the several callers we have for it.

The patch also removes some unnecessary code:

- In pph_out_tree, we will never have an IDENTIFIER_NODE when writing
  a builtin.  Similarly, in pph_in_tree.

- There was some code commented out in
  pph_in_merge_body_namespace_decl that is really not needed anymore.
  We are now treating mutated trees as XREFs, instead of trying to add
  them on the internal cache.


2012-01-24   Diego Novillo  

* pph-in.c (pph_in_tree_header): Add argument FULLY_READ_P.
Remove argument TAG.  Update all callers.
Move LTO tag reading code from ...
(pph_in_tree): ... here.
(pph_in_merge_body_namespace_decl): Remove unused code.
* pph-out.c (pph_out_tree): Remove check for IDENTIFIER_NODE.

diff --git a/gcc/cp/pph-in.c b/gcc/cp/pph-in.c
index 5ee6458..ec65a4f 100644
--- a/gcc/cp/pph-in.c
+++ b/gcc/cp/pph-in.c
@@ -2243,16 +2243,41 @@ pph_unpack_value_fields (struct bitpack_d *bp, tree 
expr)
 
 
 /* Read a tree header from STREAM and allocate a memory instance for it.
-   Return the new tree.  */
+   Return the new tree.  If the whole tree fits in the header, the
+   caller does not need to read anything else.  In that case,
+   *FULLY_READ_P will be set to true on return from this function.
+   Otherwise, it will be set to false.  */
 
 static tree
-pph_in_tree_header (pph_stream *stream, enum LTO_tags tag)
+pph_in_tree_header (pph_stream *stream, bool *fully_read_p)
 {
   struct lto_input_block *ib = stream->encoder.r.ib;
   struct data_in *data_in = stream->encoder.r.data_in;
   struct bitpack_d bp;
   tree expr;
   enum tree_code code;
+  enum LTO_tags tag;
+
+  tag = streamer_read_record_start (ib);
+  gcc_assert ((unsigned) tag < (unsigned) LTO_NUM_TAGS);
+
+  /* Some trees are completely contained in the header,
+ deal with them first.  */
+  if (tag == LTO_builtin_decl)
+{
+  /* If we are going to read a built-in function, all we need is
+ the code and class.  */
+  expr = streamer_get_builtin_tree (ib, data_in);
+  *fully_read_p = true;
+  return expr;
+}
+  else if (tag == lto_tree_code_to_tag (INTEGER_CST))
+{
+  /* For integer constants we only need the type and its hi/low
+ words.  */
+  *fully_read_p = true;
+  return streamer_read_integer_cst (ib, data_in);
+}
 
   /* Allocate the tree.  Handle C++-specific codes first.  */
   code = lto_tag_to_tree_code (tag);
@@ -2270,6 +2295,9 @@ pph_in_tree_header (pph_stream *stream, enum LTO_tags tag)
   /* Unpack all language-dependent bitfields.  */
   pph_unpack_value_fields (&bp, expr);
 
+  /* The reader should continue reading the body of EXPR.  */
+  *fully_read_p = false;
+
   return expr;
 }
 
@@ -2293,12 +2321,10 @@ pph_ensure_namespace_binding_level (tree decl)
 static void
 pph_in_merge_key_namespace_decl (pph_stream *stream, tree *chain)
 {
-  struct lto_input_block *ib = stream->encoder.r.ib;
-  bool is_namespace_alias;
+  bool is_namespace_alias, fully_read_p;
   unsigned image_ix, ix;
   enum pph_record_marker marker;
   tree read_decl = NULL, decl = NULL;
-  enum LTO_tags tag;
   const char *name;
   tree name_id;
 
@@ -2309,10 +2335,10 @@ pph_in_merge_key_namespace_decl (pph_stream *stream, 
tree *chain)
   else
 gcc_assert (marker == PPH_RECORD_START_MERGE_KEY);
 
-  tag = streamer_read_record_start (ib);
+  gcc_assert (decl == NULL || TREE_CODE (decl) == NAMESPACE_DECL);
 
-  read_decl = pph_in_tree_header (stream, tag);
-  gcc_assert (pph_tree_is_mergeable (read_decl));
+  read_decl = pph_in_tree_header (stream, &fully_read_p);
+  gcc_assert (!fully_read_p && pph_tree_is_mergeable (read_decl));
   name = pph_in_string (stream);
 
   gcc_assert (TREE_CODE (read_decl) == NAMESPACE_DECL);
@@ -2375,31 +2401,24 @@ pph_in_merge_key_namespace_decl (pph_stream *stream, 
tree *chain)
 static void
 pph_in_merge_body_namespace_decl (pph_stream *stream)
 {
-  bool is_namespace_alias;
+  bool is_namespace_alias, fully_read_p;
   unsigned image_ix, ix;
-  /* FIXME pph: remove internal cache duplication of external
-  unsigned local_ix;
-  */
   enum pph_record_marker marker;
   tree read_decl = NULL, decl = NULL;
-  enum LTO_tags tag;
-  struct lto_input_block *ib = stream->encoder.r.ib;
 
   marker = pph_in_start_record (stream, &image_ix, &ix, PPH_any_tree);
   gcc_assert (marker != PPH_RECORD_END);
   if (pph_is_reference_marker (marker))
 decl = (tree) pph_cache_find (stream, marker, image_ix, ix, PPH_any_tree);
-  else if (marker == PPH_RECORD_START_MUTATED)
-/* FIXME pph: remove internal cache duplication of external
-local_ix = pph_in_uint (stream);
-*/
-;
   else
-gcc_assert (marker == P

Fix several atomic_test_and_set problems

2012-01-24 Thread Richard Henderson
I thought there was a PR for this, but I can't find it.

A report about problems using the atomic_test_and_set pattern for SH
showed that we weren't being completely sane with the mode handling
of the boolean output.  Further investigation showed that the docs
didn't match the implementation (or vice-versa), and that the Sparc
implementation didn't match either (to be fixed in another patch).

The need to store an arbitrary non-zero value in the byte means that
the documentation that we take a bool* can't be strictly correct.
I thought about changing it to char* or making it a fully variable
type, as with the other atomic builtins.  But in the end I left the
existing implementation using void*.  As long as the user is using
any integral type we'll still get an (endian dependent) arbitrary
non-zero result.  Which should be fine.

Fortunately, all of the targets that need to use atomic_test_and_set
(because they don't have atomic_exchange or better) of which I am
aware use a test-and-set insn that is byte based.  Which means that
so far we don't need to receive more information from the builtin
about space available, or handle any mode besides QImode when
expanding the operation.

Irritatingly, I made a mistake while moving this patch around and
committed a slightly broken version.  Thus what should have been
one commit is split up into the two patches below.

Bootstrapped on powerpc64 (where we merely check for Werror's),
and sparc64 (where we actually make use of ldstub).

Committed.


r~


PS. I'd been hoping to be able to use bts on x86, so that we have a
major platform using this code, but I'd forgotten there's no byte
variant of that instruction.  Ah well.

* optabs.c (CODE_FOR_atomic_test_and_set): Provide default.
(maybe_emit_atomic_test_and_set): New.
(expand_sync_lock_test_and_set): Use it.
(expand_atomic_test_and_set): Likewise.
* doc/extend.texi (__atomic_test_and_set): Adjust the docs to match
the implementation; clarify implementation defined details.
* doc/md.texi (atomic_test_and_set): Document.


diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index 229e87c..e159736 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -7202,11 +7202,12 @@ All memory models are valid.
 
 @end deftypefn
 
-@deftypefn {Built-in Function} bool __atomic_test_and_set (bool *ptr, int 
memmodel)
+@deftypefn {Built-in Function} bool __atomic_test_and_set (void *ptr, int 
memmodel)
 
 This built-in function performs an atomic test-and-set operation on
-@code{*@var{ptr}}.  @code{*@var{ptr}} is set to the value 1 and
-the previous contents are returned.
+the byte at @code{*@var{ptr}}.  The byte is set to some implementation
+defined non-zero "set" value and the return value is @code{true} if and only
+if the previous contents were "set".
 
 All memory models are valid.
 
diff --git a/gcc/doc/md.texi b/gcc/doc/md.texi
index bcfd420..afdc3e3 100644
--- a/gcc/doc/md.texi
+++ b/gcc/doc/md.texi
@@ -5893,6 +5893,19 @@ the operation followed by the arithmetic operation 
required to produce the
 result.  If none of these are available a compare-and-swap loop will be
 used.
 
+@cindex @code{atomic_test_and_set} instruction pattern
+@item @samp{atomic_test_and_set}
+
+This pattern emits code for @code{__builtin_atomic_test_and_set}.
+Operand 0 is an output operand which is set to true if the previous
+previous contents of the byte was "set", and false otherwise.  Operand 1
+is the @code{QImode} memory to be modified.  Operand 2 is the memory
+model to be used.
+
+The specific value that defines "set" is implementation defined, and
+is normally based on what is performed by the native atomic test and set
+instruction.
+
 @cindex @code{mem_thread_fence@var{mode}} instruction pattern
 @item @samp{mem_thread_fence@var{mode}}
 This pattern emits code required to implement a thread fence with
diff --git a/gcc/optabs.c b/gcc/optabs.c
index a532ba3..0f6d763 100644
--- a/gcc/optabs.c
+++ b/gcc/optabs.c
@@ -7304,11 +7304,41 @@ maybe_emit_compare_and_swap_exchange_loop (rtx target, 
rtx mem, rtx val)
   return NULL_RTX;
 }
 
+/* This function tries to implement an atomic test-and-set operation
+   using the atomic_test_and_set instruction pattern.  A boolean value
+   is returned from the operation, using TARGET if possible.  */
+
 #ifndef HAVE_atomic_test_and_set
 #define HAVE_atomic_test_and_set 0
+#define CODE_FOR_atomic_test_and_set CODE_FOR_nothing
 #define gen_atomic_test_and_set(x,y,z)  (gcc_unreachable (), NULL_RTX)
 #endif
 
+static rtx
+maybe_emit_atomic_test_and_set (rtx target, rtx mem, enum memmodel model)
+{
+  enum machine_mode pat_bool_mode;
+  const struct insn_data_d *id;
+
+  if (!HAVE_atomic_test_and_set)
+return NULL_RTX;
+
+  id = &insn_data[CODE_FOR_atomic_test_and_set];
+  pat_bool_mode = id->operand[0].mode;
+
+  /* ??? We only support test-and-set on single bytes at the moment.
+ We'd have to change the builtin to allow wider memories. 

Go patch committed: Fix type switch block

2012-01-24 Thread Ian Lance Taylor
In Go, in a type switch like
switch t := 0; t := x.(type)
the two variables named 't' are in different blocks; they are not a
redefinition.  This patch implements that in gccgo.  Bootstrapped and
ran Go testsuite on x86_64-unknown-linux-gnu.  Committed to mainline.

Ian

diff -r 725daf468f17 go/parse.cc
--- a/go/parse.cc	Tue Jan 24 11:31:26 2012 -0800
+++ b/go/parse.cc	Tue Jan 24 12:49:40 2012 -0800
@@ -4057,6 +4057,7 @@
   Expression* switch_val = NULL;
   bool saw_send_stmt;
   Type_switch type_switch;
+  bool have_type_switch_block = false;
   if (this->simple_stat_may_start_here())
 {
   switch_val = this->simple_stat(false, &saw_send_stmt, NULL,
@@ -4099,7 +4100,14 @@
 			 id_loc));
 	  if (is_coloneq)
 		{
-		  // This must be a TypeSwitchGuard.
+		  // This must be a TypeSwitchGuard.  It is in a
+		  // different block from any initial SimpleStat.
+		  if (saw_simple_stat)
+		{
+		  this->gogo_->start_block(id_loc);
+		  have_type_switch_block = true;
+		}
+
 		  switch_val = this->simple_stat(false, &saw_send_stmt, NULL,
 		 &type_switch);
 		  if (!type_switch.found)
@@ -4142,13 +4150,23 @@
 	  if (this->peek_token()->is_op(OPERATOR_SEMICOLON))
 	this->advance_token();
 	  if (!this->peek_token()->is_op(OPERATOR_LCURLY))
-	return;
+	{
+	  if (have_type_switch_block)
+		this->gogo_->add_block(this->gogo_->finish_block(location),
+   location);
+	  this->gogo_->add_block(this->gogo_->finish_block(location),
+ location);
+	  return;
+	}
 	  if (type_switch.found)
 	type_switch.expr = Expression::make_error(location);
 	}
   else
 	{
 	  error_at(this->location(), "expected %<{%>");
+	  if (have_type_switch_block)
+	this->gogo_->add_block(this->gogo_->finish_block(this->location()),
+   location);
 	  this->gogo_->add_block(this->gogo_->finish_block(this->location()),
  location);
 	  return;
@@ -4165,6 +4183,10 @@
   if (statement != NULL)
 this->gogo_->add_statement(statement);
 
+  if (have_type_switch_block)
+this->gogo_->add_block(this->gogo_->finish_block(this->location()),
+			   location);
+
   this->gogo_->add_block(this->gogo_->finish_block(this->location()),
 			 location);
 }


Re: C++ PATCH for c++/51889 (problem overloading function using in template)

2012-01-24 Thread Fabien Chêne
2012/1/19 Jason Merrill :
> When we have a class-scope using-declaration that nominates functions, we
> want to insert those functions into the derived class' CLASSTYPE_METHOD_VEC.
>  In non-template code we do this in handle_using_decl, which is called from
> check_bases_and_members.  But we don't call that function for a class
> template definition.  Previously, for templates we were inserting them from
> finish_member_declaration, but that leads to name collisions if a function
> with the same signature is declared after the using-declaration, as in this
> testcase.  So this patch delays inserting the used function until
> finish_struct time, to match the non-template case.

Thanks for fixing it !

-- 
Fabien


[RFC] Disable FWPROP on pathological cases

2012-01-24 Thread Eric Botcazou
Starting with the 4.5.x series, we have pathological cases (Ada code generated 
by a code generator from a model) where FWPROP takes 80% of the compilation 
time at -O1 (for essentially no benefits).  There are very few basic blocks 
(typically 1) and tens of thousands of uses registered with DF, so processing 
them takes a while (top function in the profile: local_ref_killed_between_p).

The attached patch is an attempt (modelled on gcse.c) at disabling the pass for 
these pathological cases.  Thoughts?


* Makefile.in (fwprop.o): Add intl.h.
* fwprop.c: Include intl.h.
(is_too_expensive): New function.
(fwprop): Call it and return early if it returns true.
(fwprop_addr): Likewise.


-- 
Eric Botcazou
Index: Makefile.in
===
--- Makefile.in	(revision 183423)
+++ Makefile.in	(working copy)
@@ -3023,9 +3023,10 @@ dse.o : dse.c $(CONFIG_H) $(SYSTEM_H) co
$(TREE_PASS_H) alloc-pool.h $(ALIAS_H) dse.h $(OPTABS_H) $(TARGET_H) \
$(BITMAP_H) $(PARAMS_H)
 fwprop.o : fwprop.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \
-   $(DIAGNOSTIC_CORE_H) insn-config.h $(RECOG_H) $(FLAGS_H) $(OBSTACK_H) $(BASIC_BLOCK_H) \
-   output.h $(DF_H) alloc-pool.h $(TIMEVAR_H) $(TREE_PASS_H) $(TARGET_H) \
-   $(TM_P_H) $(CFGLOOP_H) $(EMIT_RTL_H) domwalk.h sparseset.h
+   $(DIAGNOSTIC_CORE_H) insn-config.h $(RECOG_H) $(FLAGS_H) $(OBSTACK_H) \
+   intl.h $(BASIC_BLOCK_H) output.h $(DF_H) alloc-pool.h $(TIMEVAR_H) \
+   $(TREE_PASS_H) $(TARGET_H) $(TM_P_H) $(CFGLOOP_H) $(EMIT_RTL_H) \
+   domwalk.h sparseset.h
 web.o : web.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \
hard-reg-set.h $(FLAGS_H) $(BASIC_BLOCK_H) $(FUNCTION_H) output.h $(DIAGNOSTIC_CORE_H) \
insn-config.h $(RECOG_H) $(DF_H) $(OBSTACK_H) $(TIMEVAR_H) $(TREE_PASS_H)
Index: fwprop.c
===
--- fwprop.c	(revision 183423)
+++ fwprop.c	(working copy)
@@ -32,6 +32,7 @@ along with GCC; see the file COPYING3.
 #include "insn-config.h"
 #include "recog.h"
 #include "flags.h"
+#include "intl.h"
 #include "obstack.h"
 #include "basic-block.h"
 #include "output.h"
@@ -1435,6 +1436,28 @@ fwprop_done (void)
 }
 
 
+/* Return true if the function is too expensive to optimize.  PASS is the
+   optimization about to be performed.  */
+
+static bool
+is_too_expensive (const char *pass)
+{
+  int ratio = DF_USES_TABLE_SIZE () / (n_basic_blocks - NUM_FIXED_BLOCKS);
+
+  /* Trying to propagate into uses in functions with gigantic basic blocks
+ will take a long time and is unlikely to be particularly useful.  */
+  if (ratio > 2)
+{
+  warning (OPT_Wdisabled_optimization,
+	   "%s: %d basic blocks and %d uses/basic block",
+	   pass, n_basic_blocks - NUM_FIXED_BLOCKS, ratio);
+
+  return true;
+}
+
+  return false;
+}
+
 /* Main entry point.  */
 
 static bool
@@ -1451,6 +1474,12 @@ fwprop (void)
 
   fwprop_init ();
 
+  if (is_too_expensive (_("FWPROP1 disabled")))
+{
+  fwprop_done ();
+  return 0;
+}
+
   /* Go through all the uses.  df_uses_create will create new ones at the
  end, and we'll go through them as well.
 
@@ -1469,8 +1498,10 @@ fwprop (void)
 }
 
   fwprop_done ();
+
   if (need_cleanup)
 cleanup_cfg (0);
+
   return 0;
 }
 
@@ -1503,6 +1534,12 @@ fwprop_addr (void)
 
   fwprop_init ();
 
+  if (is_too_expensive (_("FWPROP2 disabled")))
+{
+  fwprop_done ();
+  return 0;
+}
+
   /* Go through all the uses.  df_uses_create will create new ones at the
  end, and we'll go through them as well.  */
   for (i = 0; i < DF_USES_TABLE_SIZE (); i++)
@@ -1520,6 +1557,7 @@ fwprop_addr (void)
 
   if (need_cleanup)
 cleanup_cfg (0);
+
   return 0;
 }
 


Re: [RFC] Disable FWPROP on pathological cases

2012-01-24 Thread Jakub Jelinek
On Tue, Jan 24, 2012 at 10:26:28PM +0100, Eric Botcazou wrote:
> +static bool
> +is_too_expensive (const char *pass)
> +{
> +  int ratio = DF_USES_TABLE_SIZE () / (n_basic_blocks - NUM_FIXED_BLOCKS);
> +
> +  /* Trying to propagate into uses in functions with gigantic basic blocks
> + will take a long time and is unlikely to be particularly useful.  */
> +  if (ratio > 2)

Use a param for this instead of constant?

Jakub


Re: [4.7][google] Adding a new option "-fstack-protector-strong". (issue 5461043)

2012-01-24 Thread xur

OK for google branches.


http://codereview.appspot.com/5461043/diff/16001/gcc/cfgexpand.c
File gcc/cfgexpand.c (right):

http://codereview.appspot.com/5461043/diff/16001/gcc/cfgexpand.c#newcode1597
gcc/cfgexpand.c:1597: contain an array or are arrays. */
"," before "or", and
two spaces before "*/".

http://codereview.appspot.com/5461043/diff/16001/gcc/cfgexpand.c#newcode1709
gcc/cfgexpand.c:1709: create_stack_guard ();
it's better to merge to the earlier if statement. something like:
  if (flag_stack_protect == 2
  || (flag_stack_protect == 3 && gen_stack_protect_signal)
  || (flag_stack_protect
  && (cfun->calls_alloca || has_protected_decls)))
 create_stack_guard ();

http://codereview.appspot.com/5461043/


Re: [4.7][google] Adding a new option "-fstack-protector-strong". (issue 5461043)

2012-01-24 Thread davidxl


Also need to update doc/invoke.texi file for the new option.




http://codereview.appspot.com/5461043/diff/16001/gcc/cfgexpand.c
File gcc/cfgexpand.c (right):

http://codereview.appspot.com/5461043/diff/16001/gcc/cfgexpand.c#newcode1531
gcc/cfgexpand.c:1531: record_or_union_type_has_array (const_tree
tree_type)
Better add '_p' suffix to the predicate function name.

http://codereview.appspot.com/5461043/diff/16001/gcc/cfgexpand.c#newcode1535
gcc/cfgexpand.c:1535: for (f = fields; f; f = DECL_CHAIN (f))
Add an empty line after declarations.

http://codereview.appspot.com/5461043/diff/16001/gcc/cfgexpand.c#newcode1702
gcc/cfgexpand.c:1702: if (flag_stack_protect == 2
Add more descriptions. Better yet, fix the flag value mapping --
protect_all-> 3, protect --> 2, and protect_strong-->1

http://codereview.appspot.com/5461043/


Go patch committed: Do not allow slice of array literal

2012-01-24 Thread Ian Lance Taylor
Go does not permit taking a slice of an array literal.  This patch
implements that in the gccgo frontend, and cleans up a bit of the
surrounding code.  One now-obsolete test case is removed.  Bootstrapped
and ran Go testsuite on x86_64-unknown-linux-gnu.  Committed to
mainline.

Ian

Index: gcc/go/gofrontend/expressions.cc
===
--- gcc/go/gofrontend/expressions.cc	(revision 183490)
+++ gcc/go/gofrontend/expressions.cc	(working copy)
@@ -10593,7 +10593,7 @@ Array_index_expression::do_check_types(G
   if (this->end_ != NULL && !array_type->is_slice_type())
 {
   if (!this->array_->is_addressable())
-	this->report_error(_("array is not addressable"));
+	this->report_error(_("slice of unaddressable value"));
   else
 	this->array_->address_taken(true);
 }
@@ -10834,13 +10834,6 @@ Expression*
 Expression::make_array_index(Expression* array, Expression* start,
 			 Expression* end, Location location)
 {
-  // Taking a slice of a composite literal requires moving the literal
-  // onto the heap.
-  if (end != NULL && array->is_composite_literal())
-{
-  array = Expression::make_heap_composite(array, location);
-  array = Expression::make_unary(OPERATOR_MULT, array, location);
-}
   return new Array_index_expression(array, start, end, location);
 }
 
@@ -11954,10 +11947,6 @@ class Struct_construction_expression : p
 	  this->location());
   }
 
-  bool
-  do_is_addressable() const
-  { return true; }
-
   tree
   do_get_tree(Translate_context*);
 
@@ -12239,10 +12228,6 @@ protected:
   void
   do_check_types(Gogo*);
 
-  bool
-  do_is_addressable() const
-  { return true; }
-
   void
   do_export(Export*) const;
 
Index: gcc/testsuite/go.test/test/fixedbugs/bug268.go
===
--- gcc/testsuite/go.test/test/fixedbugs/bug268.go	(revision 183280)
+++ gcc/testsuite/go.test/test/fixedbugs/bug268.go	(working copy)
@@ -1,53 +0,0 @@
-// $G $D/$F.go && $L $F.$A && ./$A.out
-
-// Copyright 2010 The Go Authors.  All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// http://code.google.com/p/go/issues/detail?id=745
-
-package main
-
-type T1 struct {
-	T2 *T2
-}
-
-type T2 struct {
-	T3 *T3
-}
-
-type T3 struct {
-	T4 []*T4
-}
-
-type T4 struct {
-	X int
-}
-
-func f() *T1 {
-	x := &T1{
-		&T2{
-			&T3{
-[1]*T4{
-	&T4{5},
-}[0:],
-			},
-		},
-	}
-	return x
-}
-
-func g(x int) {
-	if x == 0 {
-		return
-	}
-	g(x-1)
-}
-
-func main() {
-	x := f()
-	g(100) // smash temporaries left over on stack
-	if x.T2.T3.T4[0].X != 5 {
-		println("BUG", x.T2.T3.T4[0].X)
-	}
-}


PR lto/51698 and the state of LTO + transactional memory

2012-01-24 Thread Aldy Hernandez
The problem here is that -flto cannot equate the instrumentation 
functions being generated with a user supplied version of the library 
functions.  This would happen if the user tried to link a transactional 
program with libitm with -flto (as in -fwhole-program, etc).


This is an easy problem to fix, just by changing DEF_TM_BUILTIN to set 
BOTH_P so the __builtin_ITM_* variants and _ITM_* are considered the same.


In doing so, I noticed that there are a myriad of _ITM_* builtins that 
have incorrect prototypes as defined in the builtins*.def files.  So 
using libitm/libitm.h fails miserably because of mismatches.  The 
attached patch fixes all problems, and the PR.


However...

Looking at the generated code, I've noticed that LTO isn't inlining the 
TM builtins as one would expect.  This is a two-fold problem:


First, LTO streaming happens before the final TM lowering (tmmark pass), 
so there is nothing to inline.  The instrumented function calls 
(_ITM_RU4, et al), aren't generated until after LTO.


Second, it seems that by design, LTO prefers builtins to user-provided 
versions of them.  In particular, lto_symtab_prevailing_decl() 
stipulates that builtins are their own prevailing decl.  So even if we 
lowered TM before LTO streaming, user provided builtins wouldn't be 
preferred (and thus inlined) as we would expect into application code.


Though I don't think fixing LTO of instrumented TM code is 4.7 material, 
I thought I'd write this up for the record.


With regards to the first problem, the reason we lower TM so late (in 
contrast to openmp) is because we were hoping to get good optimization 
of the memory operations before fudging them all up.  So at some point 
we should decide what's the biggest gain, deeper optimization of the 
memory operations or the ability to inline the instrumentation.  Or 
perhaps, whether we can simply move the LTO streaming point under 
certain conditions and get both.


With regards to the second problem, I suppose I should tackle #1 first, 
but I would be curious if the LTO experts could weigh in here.


The attached patch fixes the ICE in the PR, though it won't do what the 
user ultimately wants to do, given the limitations described.  Perhaps 
we could create another PR and tag it with an enhancement request.


OK pending tests?

Aldy

p.s. Oh, and btw, does this all make sense?
PR lto/51698
* builtin-types.def: (BT_CONST_DOUBLE_PTR): New.
(BT_FN_VOID_PTR_CONST_PTR_SIZE): New.
(BT_FN_VOID_PTR_INT_SIZE): New.
(BT_FN_DOUBLE_VPTR): Remove.
(BT_FN_DOUBLE_CONST_DOUBLE_PTR): New.
* gtm-builtins.def (_ITM_abortTransaction): Set return type to
void.
(_ITM_changeTransactionMode): Same.
(_ITM_memmoveRtWt): Change return type to void.
(_ITM_memcpyRtWt): Same.
(_ITM_memsetW): Same.
(_ITM_RaRD): Change types to double.
(_ITM_RD): Same.
(_ITM_RaWD): Same.
(_ITM_RfWD): Same.
* builtins.def (DEF_TM_BUILTIN): Set BOTH_P to true.

Index: testsuite/gcc.dg/lto/trans-mem-4_0.c
===
--- testsuite/gcc.dg/lto/trans-mem-4_0.c(revision 0)
+++ testsuite/gcc.dg/lto/trans-mem-4_0.c(revision 0)
@@ -0,0 +1,11 @@
+/* { dg-lto-options {{-flto -fgnu-tm}} } */
+/* { dg-lto-do link } */
+
+extern void foo() __attribute__((transaction_safe));
+
+int main()
+{
+  __transaction_atomic {
+  foo();
+  }
+}
Index: testsuite/gcc.dg/lto/trans-mem-4_1.c
===
--- testsuite/gcc.dg/lto/trans-mem-4_1.c(revision 0)
+++ testsuite/gcc.dg/lto/trans-mem-4_1.c(revision 0)
@@ -0,0 +1,12 @@
+__attribute__((transaction_safe))
+void foo() 
+{
+}
+
+unsigned int _ITM_beginTransaction(unsigned int prop, ...)
+{
+}
+
+void __builtin__ITM_commitTransaction (void)
+{
+}
Index: builtin-types.def
===
--- builtin-types.def   (revision 183474)
+++ builtin-types.def   (working copy)
@@ -103,6 +103,10 @@ DEF_PRIMITIVE_TYPE (BT_PTRMODE, (*lang_h
 DEF_PRIMITIVE_TYPE (BT_INT_PTR, integer_ptr_type_node)
 DEF_PRIMITIVE_TYPE (BT_FLOAT_PTR, float_ptr_type_node)
 DEF_PRIMITIVE_TYPE (BT_DOUBLE_PTR, double_ptr_type_node)
+DEF_PRIMITIVE_TYPE (BT_CONST_DOUBLE_PTR,
+   build_pointer_type
+(build_qualified_type (double_type_node,
+   TYPE_QUAL_CONST)))
 DEF_PRIMITIVE_TYPE (BT_LONGDOUBLE_PTR, long_double_ptr_type_node)
 DEF_PRIMITIVE_TYPE (BT_PID, pid_type_node)
 DEF_PRIMITIVE_TYPE (BT_SIZE, size_type_node)
@@ -342,10 +346,14 @@ DEF_FUNCTION_TYPE_3 (BT_FN_INT_CONST_STR
 BT_INT, BT_CONST_STRING, BT_CONST_STRING, BT_SIZE)
 DEF_FUNCTION_TYPE_3 (BT_FN_PTR_PTR_CONST_PTR_SIZE,
 BT_PTR, BT_PTR, BT_CONST_PTR, BT_SIZE)
+DEF_FUNCTION_TYPE_3 (BT_FN_VOID_PTR_CONST_PTR_SIZE,
+

Re: [RFC] Disable FWPROP on pathological cases

2012-01-24 Thread Steven Bosscher
On Tue, Jan 24, 2012 at 10:26 PM, Eric Botcazou  wrote:
> Starting with the 4.5.x series, we have pathological cases (Ada code generated
> by a code generator from a model) where FWPROP takes 80% of the compilation
> time at -O1 (for essentially no benefits).  There are very few basic blocks
> (typically 1) and tens of thousands of uses registered with DF, so processing
> them takes a while (top function in the profile: local_ref_killed_between_p).

Would it work to punt in local_ref_killed_between_p if
(DF_INSN_LUID(to) - DF_INSN_LUID(from)) is greater than some value?

Ciao!
Steven


Re: PR lto/51698 and the state of LTO + transactional memory

2012-01-24 Thread Richard Henderson
On 01/25/2012 10:16 AM, Aldy Hernandez wrote:
> The attached patch fixes the ICE in the PR, though it won't do what
> the user ultimately wants to do, given the limitations described.
> Perhaps we could create another PR and tag it with an enhancement
> request.

An enhancement request pr sounds good.

>   PR lto/51698
>   * builtin-types.def: (BT_CONST_DOUBLE_PTR): New.
>   (BT_FN_VOID_PTR_CONST_PTR_SIZE): New.
>   (BT_FN_VOID_PTR_INT_SIZE): New.
>   (BT_FN_DOUBLE_VPTR): Remove.
>   (BT_FN_DOUBLE_CONST_DOUBLE_PTR): New.
>   * gtm-builtins.def (_ITM_abortTransaction): Set return type to
>   void.
>   (_ITM_changeTransactionMode): Same.
>   (_ITM_memmoveRtWt): Change return type to void.
>   (_ITM_memcpyRtWt): Same.
>   (_ITM_memsetW): Same.
>   (_ITM_RaRD): Change types to double.
>   (_ITM_RD): Same.
>   (_ITM_RaWD): Same.
>   (_ITM_RfWD): Same.
>   * builtins.def (DEF_TM_BUILTIN): Set BOTH_P to true.

Ok.


r~


Go patch committed: Error if type switch case can not match

2012-01-24 Thread Ian Lance Taylor
This patch to the Go frontend adds in an error if a case in a type
switch can not match the type of the switch value, because the case type
does not implement methods of the switch value.  Bootstrapped and ran Go
testsuite on x86_64-unknown-linux-gnu.  Committed to mainline.

Ian

diff -r b4d67f01b439 go/statements.cc
--- a/go/statements.cc	Tue Jan 24 14:32:07 2012 -0800
+++ b/go/statements.cc	Tue Jan 24 15:22:44 2012 -0800
@@ -3940,7 +3940,8 @@
 // statements.
 
 void
-Type_case_clauses::Type_case_clause::lower(Block* b,
+Type_case_clauses::Type_case_clause::lower(Type* switch_val_type,
+	   Block* b,
 	   Temporary_statement* descriptor_temp,
 	   Unnamed_label* break_label,
 	   Unnamed_label** stmts_label) const
@@ -3952,6 +3953,20 @@
 {
   Type* type = this->type_;
 
+  std::string reason;
+  if (switch_val_type->interface_type() != NULL
+	  && !type->is_nil_constant_as_type()
+	  && type->interface_type() == NULL
+	  && !switch_val_type->interface_type()->implements_interface(type,
+  &reason))
+	{
+	  if (reason.empty())
+	error_at(this->location_, "impossible type switch case");
+	  else
+	error_at(this->location_, "impossible type switch case (%s)",
+		 reason.c_str());
+	}
+
   Expression* ref = Expression::make_temporary_reference(descriptor_temp,
 			 loc);
 
@@ -4102,7 +4117,8 @@
 // BREAK_LABEL is the label at the end of the type switch.
 
 void
-Type_case_clauses::lower(Block* b, Temporary_statement* descriptor_temp,
+Type_case_clauses::lower(Type* switch_val_type, Block* b,
+			 Temporary_statement* descriptor_temp,
 			 Unnamed_label* break_label) const
 {
   const Type_case_clause* default_case = NULL;
@@ -4113,7 +4129,8 @@
++p)
 {
   if (!p->is_default())
-	p->lower(b, descriptor_temp, break_label, &stmts_label);
+	p->lower(switch_val_type, b, descriptor_temp, break_label,
+		 &stmts_label);
   else
 	{
 	  // We are generating a series of tests, which means that we
@@ -4124,7 +4141,8 @@
   go_assert(stmts_label == NULL);
 
   if (default_case != NULL)
-default_case->lower(b, descriptor_temp, break_label, NULL);
+default_case->lower(switch_val_type, b, descriptor_temp, break_label,
+			NULL);
 }
 
 // Dump the AST representation for case clauses (from a switch statement)
@@ -4222,7 +4240,7 @@
 }
 
   if (this->clauses_ != NULL)
-this->clauses_->lower(b, descriptor_temp, this->break_label());
+this->clauses_->lower(val_type, b, descriptor_temp, this->break_label());
 
   Statement* s = Statement::make_unnamed_label_statement(this->break_label_);
   b->add_statement(s);
diff -r b4d67f01b439 go/statements.h
--- a/go/statements.h	Tue Jan 24 14:32:07 2012 -0800
+++ b/go/statements.h	Tue Jan 24 15:22:44 2012 -0800
@@ -1441,7 +1441,7 @@
 
   // Lower to if and goto statements.
   void
-  lower(Block*, Temporary_statement* descriptor_temp,
+  lower(Type*, Block*, Temporary_statement* descriptor_temp,
 	Unnamed_label* break_label) const;
 
   // Dump the AST representation to a dump context.
@@ -1485,7 +1485,7 @@
 
 // Lower to if and goto statements.
 void
-lower(Block*, Temporary_statement* descriptor_temp,
+lower(Type*, Block*, Temporary_statement* descriptor_temp,
 	  Unnamed_label* break_label, Unnamed_label** stmts_label) const;
 
 // Dump the AST representation to a dump context.


[pph] Merge unemitted_tinfo_decls and keyed_classes (issue5575053)

2012-01-24 Thread Lawrence Crowl
Merge unemitted_tinfo_decls and keyed_classes.  We do not have a test
case failing for keyed_classes, so the latter is anticipatory.

Add a 'pph asm xokay' test marker for assembly differences that are
benign.  We would rather have identical assembly, but it is just not
important right now.  These will be treated as passes.

Clarify a few other failures.

Make various debug/trace dump changes.


Index: gcc/testsuite/ChangeLog.pph

2012-01-24   Lawrence Crowl  

* lib/dg-pph.exp: Add an asm 'xokay' for benign assembly differences.
* g++.dg/pph/x4keyno.cc: Bug fixed, now xokay.
* g++.dg/pph/x4keyed.cc: Bug fixed, now xokay.
* g++.dg/pph/x4keyex.cc: Mark xokay.
* g++.dg/pph/x4tmplclass1.cc: Mark xokay.
* g++.dg/pph/x1tmplclass2.cc: Clarify failure.
* g++.dg/pph/x4tmplclass2.cc: Clarify failure.

Index: gcc/cp/ChangeLog.pph

2012-01-24   Lawrence Crowl  

* pph-streamer.h (pph_dump_global_state): New.
(pph_dump_namespace): Removed; callers now use pph_dump_global_state.
* pph-core.c (pph_dump_tree_name): Add tree pointer.
(pph_dump_vec_tree): New.
(pph_dump_namespace): Remove message parameter.
(pph_dump_global_state): New.
(pph_loaded): Call pph_dump_global_state instead of pph_dump_namespace.
* pph-out.c (pph_write_file): Call pph_dump_global_state instead of
pph_dump_namespace.
* error.c (dump_decl): Protect against null pointers.
* name-lookup.c (pph_debug_binding_action): Add PPH: output label.
(pph_debug_binding_inaction): Add PPH: output label.
(pph_set_identifier_bindings): Modify debug label.
(pph_debug_overload_binding_action): New.
(pph_set_namespace_bindings): Call pph_debug_overload_binding_action
instead of pph_debug_binding_action.
(pph_add_overload): Remove unused.
* pph-in.c (pph_is_on_chain): New.
(pph_union_into_chain): New.
(pph_read_file_1): Call pph_union_into_chain for keyed_classes.
Call pph_union_into_tree_vec for unemitted_tinfo_decls.
Call pph_dump_global_state instead of pph_dump_namespace.


Index: gcc/testsuite/lib/dg-pph.exp
===
--- gcc/testsuite/lib/dg-pph.exp(revision 183499)
+++ gcc/testsuite/lib/dg-pph.exp(working copy)
@@ -166,9 +166,14 @@ proc dg-pph-pos { subdir test options ma
 
 # The sources mark when they expect the comparison to differ.
 # When marked with xdiff, the difference is a problem.
+# When marked with xokay, the difference is not causing a problem.
 # When marked with xwant, the difference is what we want.
 set xdiff_entry [grep $test "pph asm xdiff( )*\[0-9\]*"]
+set xokay_entry [grep $test "pph asm xokay( )*\[0-9\]*"]
 set xwant_entry [grep $test "pph asm xwant( )*\[0-9\]*"]
+if { $xokay_entry != ""} {
+   set xwant_entry $xokay_entry
+}
 set xdiff [llength $xdiff_entry]
 set xwant [llength $xwant_entry]
 if { $adiff == 0 } {
Index: gcc/testsuite/g++.dg/pph/x4keyno.cc
===
--- gcc/testsuite/g++.dg/pph/x4keyno.cc (revision 183499)
+++ gcc/testsuite/g++.dg/pph/x4keyno.cc (working copy)
@@ -1,5 +1,4 @@
-// { dg-xfail-if "redefinition problems" { *-*-* } { "-fpph-map=pph.map" } }
-// { dg-excess-errors "The variable for the typeinfo name for 'keyno' is 
duplicated." }
+// pph asm xokay 32642
 
 #include "x0keyno1.h"
 #include "x0keyno2.h"
Index: gcc/testsuite/g++.dg/pph/x1tmplclass2.cc
===
--- gcc/testsuite/g++.dg/pph/x1tmplclass2.cc(revision 183499)
+++ gcc/testsuite/g++.dg/pph/x1tmplclass2.cc(working copy)
@@ -1,4 +1,7 @@
 // pph asm xdiff 37711
-// Soft failure.  Symbols are emitted in different order in pph compile.
+// xfail BOGUS MISSVAR
+// The assembly is missing a template class static member variable
+// base::variable instantiated in a prior pph file.
+// Others symbols are emitted in a different order.
 #include "x0tmplclass23.h"
 #include "a0tmplclass2_u.h"
Index: gcc/testsuite/g++.dg/pph/x4keyex.cc
===
--- gcc/testsuite/g++.dg/pph/x4keyex.cc (revision 183499)
+++ gcc/testsuite/g++.dg/pph/x4keyex.cc (working copy)
@@ -1,4 +1,4 @@
-// pph asm xdiff 32642
+// pph asm xokay 32642
 //
 // This test case fails to compare because LFB/LFE labels are different.
 //
Index: gcc/testsuite/g++.dg/pph/x4tmplclass1.cc
===
--- gcc/testsuite/g++.dg/pph/x4tmplclass1.cc(revision 183499)
+++ gcc/testsuite/g++.dg/pph/x4tmplclass1.cc(working copy)
@@ -1,4 +1,4 @@
-// pph asm xdiff 63957
+// pph asm xokay 63957
 // Assembly differences seem to be due to the order in which the
 // symbols in the template hash tables are emitted.
 #include "x0tmplc

Go patch committed: Update to current Go testsuite

2012-01-24 Thread Ian Lance Taylor
I have committed a patch to update the testsuite under
gcc/testsuite/go.test/test to the current Go testsuite.  This overall
patch is too large to include in this e-mail message.  There were some
changes to the testsuite driver, which I have included here.  Ran Go
testsuite on x86_64-unknown-linux-gnu.  Committed to mainline.

Ian


2012-01-24  Ian Lance Taylor  

* go.test/go-test.exp (filecmp): New procedure.
(errchk): Handle quoted square brackets.
(go-gc-tests): Set go_compile_args. Handle various new test
lines.  Skip a few new tests.
* lib/go-torture.exp (go-torture-execute): Use go_compile_args.


Index: go.test/go-test.exp
===
--- go.test/go-test.exp	(revision 183501)
+++ go.test/go-test.exp	(working copy)
@@ -34,6 +34,38 @@
 load_lib go-dg.exp
 load_lib go-torture.exp
 
+# Compare two files
+proc filecmp { file1 file2 testname } {
+set f1 [open $file1 r]
+set f2 [open $file2 r]
+set ok 1
+while { [gets $f1 line1] >= 0 } {
+	if { [gets $f2 line2] < 0 } {
+	verbose -log "output mismatch: $file2 shorter than $file1"
+	set ok 0
+	break
+	}
+	if { $line1 != $line2 } {
+	verbose -log "output mismatch comparing $file1 and $file2"
+	verbose -log "expected \"$line1\""
+	verbose -log "got  \"$line2\""
+	set ok 0
+	break
+	}
+}
+if { [gets $f2 line2] >= 0 } {
+	verbose -log "output mismatch: $file1 shorter than $file2"
+	set ok 0
+}
+close $f1
+close $f2
+if { ! $ok } {
+	fail $testname
+} else {
+	pass $testname
+}
+}
+
 # Implement errchk
 proc errchk { test opts } {
 global dg-do-what-default
@@ -56,6 +88,14 @@ proc errchk { test opts } {
 	continue
 	}
 	regsub "// \(GCCGO_\)?ERROR \"\(\[^\"\]*\)\".*$" $copy_line "// \{ dg-error \"\\2\" \}" out_line
+	if [string match "*dg-error*\\\[*" $out_line] {
+	set index [string first "dg-error" $out_line]
+	regsub -start $index -all "\\\[" $out_line "\\\[" out_line
+	}
+	if [string match "*dg-error*\\\]*" $out_line] {
+	set index [string first "dg-error" $out_line]
+	regsub -start $index -all "\\\]" $out_line "\\\]" out_line
+	}
 	if [string match "*dg-error*.\**" $out_line] {
 	# I worked out the right number of backslashes by
 	# experimentation, not analysis.
@@ -199,6 +239,7 @@ proc go-gc-tests { } {
 global TOOL_OPTIONS
 global TORTURE_OPTIONS
 global dg-do-what-default
+global go_compile_args
 global go_execute_args
 global target_triplet
 
@@ -230,13 +271,10 @@ proc go-gc-tests { } {
 	continue
 	}
 
-	# Skip the files in bench and garbage; they are not tests.
+	# Skip the files in bench; they are not tests.
 	if [string match "*go.test/test/bench/*" $test] {
 	continue
 	}
-	if [string match "*go.test/test/garbage/*" $test] {
-	continue
-	}
 
 	# Skip files in sub-subdirectories: they are components of
 	# other tests.
@@ -274,6 +312,20 @@ proc go-gc-tests { } {
 	continue
 	}
 
+	if { [file tail $test] == "init1.go" } {
+	# This tests whether GC runs during init, which for gccgo
+	# it currently does not.
+	untested $name
+	continue
+	}
+
+	if { [file tail $test] == "closure.go" } {
+	# This tests whether function closures do any memory
+	# allocation, which for gccgo they currently do.
+	untested $name
+	continue
+	}
+
 	set fd [open $test r]
 
 	set lines_ok 1
@@ -290,7 +342,8 @@ proc go-gc-tests { } {
 	if { [ string match "*nacl*exit 0*" $test_line ] \
 		 || [ string match "*exit 0*nacl*" $test_line ] \
 		 || [ string match "*Android*exit 0*" $test_line ] \
-		 || [ string match "*exit 0*Android*" $test_line ] } {
+		 || [ string match "*exit 0*Android*" $test_line ] \
+		 || [ string match "*\"\$GOOS\" == windows*" $test_line ] } {
 		continue
 	}
 
@@ -320,8 +373,9 @@ proc go-gc-tests { } {
 
 	close $fd
 
+	set go_compile_args ""
 	set go_execute_args ""
-	if { [regexp ".*\\\$A.out (\[^|&>\].*)\$" $test_line match progargs] } {
+	if { [regexp ".*\\\$A.out (\[^|&>2\].*)\$" $test_line match progargs] } {
 	set go_execute_args $progargs
 	verbose -log "$test: go_execute_args is $go_execute_args"
 	set index [string last " $progargs" $test_line]
@@ -393,6 +447,33 @@ proc go-gc-tests { } {
 	# This is a vanilla execution test.
 	go-torture-execute $test
 	file delete core [glob -nocomplain core.*]
+	} elseif { $test_line == "// \$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out 2>&1 | cmp - \$D/\$F.out" \
+		   || $test_line == "// (\$G \$D/\$F.go && \$L \$F.\$A && ./\$A.out 2>&1 | cmp - \$D/\$F.out)" } {
+	# This is an execution test for which we need to check the
+	# program output.
+	set hold_runtests $runtests
+	set runtests "go-test.exp"
+	set dg-do-what-default "link"
+	dg-test -keep-output $test "-O" "-w $DEFAULT_GOCFLAGS"
+	set output_file "./[file rootname [

[libitm] Minor changes to libitm.h

2012-01-24 Thread Patrick Marlier

Hi,

I propose some minor modifications to libitm.h:
* Add a link to current TM-ABI document.
* Remove ITM_REGPARM from _ITM_beginTransaction since on x86-32, a 
variadic function ignores regparm.
* Add ITM_PURE to _ITM_addUserCommitAction and _ITM_addUserUndoAction to 
be usable inside transactions.

* Cosmetic changes to match GCC coding rules.

By the way, is it on purpose that libitm.h is not installed?

Tested on x86_64-unknown-linux-gnu. Ok for trunk?
(Aldy, I am really sorry to bother you one more time. I owe you one)

Thanks.
--
Patrick.

libitm/
2012-01-24  Patrick Marlier  

* libitm.h (_ITM_beginTransaction): Remove ITM_REGPARM.
(_ITM_addUserCommitAction): Add ITM_PURE attribute.
(_ITM_addUserUndoAction): Likewise.
Index: libitm.h
===
--- libitm.h	(revision 183497)
+++ libitm.h	(working copy)
@@ -23,7 +23,7 @@
.  */
 
 /* The external interface of this library follows the specification described
-   in version 1 of http://www.intel.com/some/path/here.pdf.  */
+   in version 1 of http://software.intel.com/file/8097.pdf.  */
 
 #ifndef LIBITM_H
 #define LIBITM_H 1
@@ -117,7 +117,7 @@ typedef struct
 const char *psource;
 } _ITM_srcLocation;
 
-typedef void (* _ITM_userUndoFunction)(void *);
+typedef void (* _ITM_userUndoFunction) (void *);
 typedef void (* _ITM_userCommitFunction) (void *);
 
 #define _ITM_VERSION "0.90 (Feb 29 2008)"
@@ -126,28 +126,31 @@ typedef void (* _ITM_userCommitFunction) (void *);
 extern int _ITM_versionCompatible (int) ITM_REGPARM;
 extern const char * _ITM_libraryVersion (void) ITM_REGPARM;
 
-void _ITM_error(const _ITM_srcLocation *, int errorCode)
+void _ITM_error (const _ITM_srcLocation *, int errorCode)
   ITM_REGPARM ITM_NORETURN;
 
-extern _ITM_howExecuting _ITM_inTransaction(void) ITM_REGPARM;
+extern _ITM_howExecuting _ITM_inTransaction (void) ITM_REGPARM;
 
 typedef uint64_t _ITM_transactionId_t;	/* Transaction identifier */
 #define _ITM_noTransactionId 1		/* Id for non-transactional code. */
 
-extern _ITM_transactionId_t _ITM_getTransactionId(void) ITM_REGPARM;
+extern _ITM_transactionId_t _ITM_getTransactionId (void) ITM_REGPARM;
 
-extern uint32_t _ITM_beginTransaction(uint32_t, ...) ITM_REGPARM;
+/* ITM_REGPARM is ignored with variadic function on x86-32. */
+extern uint32_t _ITM_beginTransaction (uint32_t, ...);
 
-extern void _ITM_abortTransaction(_ITM_abortReason) ITM_REGPARM ITM_NORETURN;
+extern void _ITM_abortTransaction (_ITM_abortReason) ITM_REGPARM ITM_NORETURN;
 
 extern void _ITM_commitTransaction (void) ITM_REGPARM;
 
 extern void _ITM_changeTransactionMode (_ITM_transactionState) ITM_REGPARM;
 
-extern void _ITM_addUserCommitAction(_ITM_userCommitFunction,
- _ITM_transactionId_t, void *) ITM_REGPARM;
+extern void _ITM_addUserCommitAction (_ITM_userCommitFunction,
+  _ITM_transactionId_t, void *)
+		ITM_REGPARM ITM_PURE;
 
-extern void _ITM_addUserUndoAction(_ITM_userUndoFunction, void *) ITM_REGPARM;
+extern void _ITM_addUserUndoAction (_ITM_userUndoFunction, void *)
+		ITM_REGPARM ITM_PURE;
 
 extern void _ITM_dropReferences (void *, size_t) ITM_REGPARM ITM_PURE;
 
@@ -230,41 +233,41 @@ ITM_LOG(CE)
 
 extern void _ITM_LB (const void *, size_t) ITM_REGPARM;
 
-extern void _ITM_memcpyRnWt(void *, const void *, size_t) ITM_REGPARM;
-extern void _ITM_memcpyRnWtaR(void *, const void *, size_t) ITM_REGPARM;
-extern void _ITM_memcpyRnWtaW(void *, const void *, size_t) ITM_REGPARM;
-extern void _ITM_memcpyRtWn(void *, const void *, size_t) ITM_REGPARM;
-extern void _ITM_memcpyRtWt(void *, const void *, size_t) ITM_REGPARM;
-extern void _ITM_memcpyRtWtaR(void *, const void *, size_t) ITM_REGPARM;
-extern void _ITM_memcpyRtWtaW(void *, const void *, size_t) ITM_REGPARM;
-extern void _ITM_memcpyRtaRWn(void *, const void *, size_t) ITM_REGPARM;
-extern void _ITM_memcpyRtaRWt(void *, const void *, size_t) ITM_REGPARM;
-extern void _ITM_memcpyRtaRWtaR(void *, const void *, size_t) ITM_REGPARM;
-extern void _ITM_memcpyRtaRWtaW(void *, const void *, size_t) ITM_REGPARM;
-extern void _ITM_memcpyRtaWWn(void *, const void *, size_t) ITM_REGPARM;
-extern void _ITM_memcpyRtaWWt(void *, const void *, size_t) ITM_REGPARM;
-extern void _ITM_memcpyRtaWWtaR(void *, const void *, size_t) ITM_REGPARM;
-extern void _ITM_memcpyRtaWWtaW(void *, const void *, size_t) ITM_REGPARM;
+extern void _ITM_memcpyRnWt (void *, const void *, size_t) ITM_REGPARM;
+extern void _ITM_memcpyRnWtaR (void *, const void *, size_t) ITM_REGPARM;
+extern void _ITM_memcpyRnWtaW (void *, const void *, size_t) ITM_REGPARM;
+extern void _ITM_memcpyRtWn (void *, const void *, size_t) ITM_REGPARM;
+extern void _ITM_memcpyRtWt (void *, const void *, size_t) ITM_REGPARM;
+extern void _ITM_memcpyRtWtaR (void *, const void *, size_t) ITM_REGPARM;
+extern void _ITM_memcpyRtWtaW (void *, const void *, size_t) ITM_REGPARM;
+extern void _ITM_memcpyRtaRWn (void *, con

Re: [libitm] Minor changes to libitm.h

2012-01-24 Thread Torvald Riegel
On Tue, 2012-01-24 at 19:12 -0500, Patrick Marlier wrote:
> I propose some minor modifications to libitm.h:
> * Add a link to current TM-ABI document.

We should link to libitm.texi instead because this describes the
interface that we implement.

> * Remove ITM_REGPARM from _ITM_beginTransaction since on x86-32, a 
> variadic function ignores regparm.
> * Add ITM_PURE to _ITM_addUserCommitAction and _ITM_addUserUndoAction to 
> be usable inside transactions.

Those should be called from transaction_pure code only, or from wrapper
functions linked to using transaction_wrapper.  Thus, they don't need to
be pure.  Alternatively, why should they be?




Re: [trans-mem] Do not instrument thread locals

2012-01-24 Thread Andi Kleen
Patrick Marlier  writes:

> Hi,
>
> I found that all thread local variables are instrumented with
> _ITM_W/R* calls whereas they should not be shared with other
> threads. This patch takes care of thread locals into requires_barrier
> and also adds the local save/restore for them. This patch also
> includes a testcase.

What happens when the address of the thread local escapes?
It could well be written by another thread then.

I guess you have to check for escapes here.

-Andi

-- 
a...@linux.intel.com -- Speaking for myself only


Re: [libitm] Minor changes to libitm.h

2012-01-24 Thread Patrick Marlier

On 01/24/2012 07:32 PM, Torvald Riegel wrote:

* Remove ITM_REGPARM from _ITM_beginTransaction since on x86-32, a
>  variadic function ignores regparm.
>  * Add ITM_PURE to _ITM_addUserCommitAction and _ITM_addUserUndoAction to
>  be usable inside transactions.

Those should be called from transaction_pure code only, or from wrapper
functions linked to using transaction_wrapper.  Thus, they don't need to
be pure.  Alternatively, why should they be?


I though it was also allowed to be called inside transaction_safe code. 
This way, the developer has some callbacks on transactions events.

example:

void ucommit(void *arg)
{
  printf("Committed. now we can do undoable action (as printf) or ...\n");
}

__transaction_atomic {
  _ITM_addUserCommitAction(ucommit, _ITM_noTransactionId, NULL);
  ...
}

I read the ABI and right they seem to focus on the case of tm_wrap. In 
fact, I found those calls quite convenient sometimes but definitely not 
a problem for me.


Note that GCC does not annotate wrapped function automatically as 
transaction_pure. So the wrapper has to be transaction_pure too. I don't 
know if we should consider as a bug (Intel STM compiler adds the 
transaction_pure attribute automatically) or a feature of GCC.
In fact, I found this also quite cool to be able to propose an 
alternative and transactified function when used in transaction.


Thanks.
--
Patrick.


[RFC] libstdc++ atomic_flag changes

2012-01-24 Thread Richard Henderson
The issue that I'm trying to solve is that we will have at least two targets 
whose test-and-set insn does not define "set" as 1, as a variable of type 
"bool" would expect.  In the case of Sparc we *could* make the test-and-set 
implementation test for any non-zero value, but in the case of m68k the hw will 
only test-and-set the msb of the byte.

This compiles on x86_64, and is still undergoing testing, but I wanted to get 
this out before Ben quits for the day.  ;-)

Notes:
  * I try to leave _M_i as bool if at all possible,
as this gives the best information to the debugger.

  * The suggestion on IRC to derive private from __atomic_flag_base
falls afoul of src/c++11/compatibility-atomic-c++0x.cc.
I'll leave any possible cleanup here to libstdc++ maintainers.  ;-)

  * The changes to the target files actually depend on outstanding patches
in my tree.  But at least show where the problems would lie.

Did I miss anything?

r~

diff --git a/gcc/c-family/c-cppbuiltin.c b/gcc/c-family/c-cppbuiltin.c
index 7e7b9c1..608dba6 100644
--- a/gcc/c-family/c-cppbuiltin.c
+++ b/gcc/c-family/c-cppbuiltin.c
@@ -670,6 +670,11 @@ cpp_atomic_builtins (cpp_reader *pfile)
   builtin_define_with_int_value ("__GCC_ATOMIC_LLONG_LOCK_FREE", 
(have_swap[SWAP_INDEX (long_long_integer_type_node)]? 2 : 1));
 
+  /* If we're dealing with a "set" value that doesn't exactly correspond
+ to a boolean truth value, let the library work around that.  */
+  builtin_define_with_int_value ("__GCC_ATOMIC_TEST_AND_SET_TRUEVAL",
+targetm.atomic_test_and_set_trueval);
+
   /* ptr_type_node can't be used here since ptr_mode is only set when
  toplev calls backend_init which is not done with -E  or pch.  */
   psize = POINTER_SIZE / BITS_PER_UNIT;
diff --git a/gcc/config/m68k/m68k.c b/gcc/config/m68k/m68k.c
index e0edd5b..d3ed82b 100644
--- a/gcc/config/m68k/m68k.c
+++ b/gcc/config/m68k/m68k.c
@@ -303,6 +303,10 @@ static void m68k_init_sync_libfuncs (void) 
ATTRIBUTE_UNUSED;
 #undef TARGET_ASM_OUTPUT_ADDR_CONST_EXTRA
 #define TARGET_ASM_OUTPUT_ADDR_CONST_EXTRA m68k_output_addr_const_extra
 
+/* The value stored by TAS.  */
+#undef TARGET_ATOMIC_TEST_AND_SET_TRUEVAL
+#define TARGET_ATOMIC_TEST_AND_SET_TRUEVAL 128
+
 static const struct attribute_spec m68k_attribute_table[] =
 {
   /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler,
diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c
index 19ab54a..1b3b4c8 100644
--- a/gcc/config/sparc/sparc.c
+++ b/gcc/config/sparc/sparc.c
@@ -779,6 +779,10 @@ char sparc_hard_reg_printed[8];
 #undef TARGET_PRINT_OPERAND_ADDRESS
 #define TARGET_PRINT_OPERAND_ADDRESS sparc_print_operand_address
 
+/* The value stored by LDSTUB.  */
+#undef TARGET_ATOMIC_TEST_AND_SET_TRUEVAL
+#define TARGET_ATOMIC_TEST_AND_SET_TRUEVAL 0xff
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 static void
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index ceb0d1e..91e4b04 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -11359,3 +11359,7 @@ value of @code{TARGET_CONST_ANCHOR} is a power of 2.  
For example, on
 MIPS, where add-immediate takes a 16-bit signed value,
 @code{TARGET_CONST_ANCHOR} is set to @samp{0x8000}.  The default value
 is zero, which disables this optimization.  @end deftypevr
+
+@deftypevr {Target Hook} {unsigned char} TARGET_ATOMIC_TEST_AND_SET_TRUEVAL
+This value should be set if the result written by @code{atomic_test_and_set} 
is not exactly 1, i.e. the @code{bool} @code{true}.
+@end deftypevr
diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
index 55c8432..0ebc15d 100644
--- a/gcc/doc/tm.texi.in
+++ b/gcc/doc/tm.texi.in
@@ -11237,3 +11237,5 @@ value of @code{TARGET_CONST_ANCHOR} is a power of 2.  
For example, on
 MIPS, where add-immediate takes a 16-bit signed value,
 @code{TARGET_CONST_ANCHOR} is set to @samp{0x8000}.  The default value
 is zero, which disables this optimization.  @end deftypevr
+
+@hook TARGET_ATOMIC_TEST_AND_SET_TRUEVAL
diff --git a/gcc/target.def b/gcc/target.def
index f86f782..6084b21 100644
--- a/gcc/target.def
+++ b/gcc/target.def
@@ -2667,6 +2667,13 @@ DEFHOOK
  enum unwind_info_type, (void),
  default_debug_unwind_info)
 
+DEFHOOKPOD
+(atomic_test_and_set_trueval,
+ "This value should be set if the result written by\
+ @code{atomic_test_and_set} is not exactly 1, i.e. the\
+ @code{bool} @code{true}.",
+ unsigned char, 1)
+ 
 /* Leave the boolean fields at the end.  */
 
 /* True if we can create zeroed data by switching to a BSS section
diff --git a/libstdc++-v3/include/bits/atomic_base.h 
b/libstdc++-v3/include/bits/atomic_base.h
index ef17b7e..aa43bcc 100644
--- a/libstdc++-v3/include/bits/atomic_base.h
+++ b/libstdc++-v3/include/bits/atomic_base.h
@@ -227,12 +227,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   struct __atomic_flag_base
   {
+/* The target's "set" value for test-and-set may not be exactly 1.  */
+#if __GCC_ATOMIC_TEST_AND_SET_TRUEVAL == 1
 bool _M_i;

Re: [RFC] libstdc++ atomic_flag changes

2012-01-24 Thread Benjamin Kosnik

> The issue that I'm trying to solve is that we will have at least two
> targets whose test-and-set insn does not define "set" as 1, as a
> variable of type "bool" would expect.  In the case of Sparc we
> *could* make the test-and-set implementation test for any non-zero
> value, but in the case of m68k the hw will only test-and-set the msb
> of the byte.
> 
> This compiles on x86_64, and is still undergoing testing, but I
> wanted to get this out before Ben quits for the day.  ;-)

Looks fine to me.

-benjamin


Re: [trans-mem] Do not instrument thread locals

2012-01-24 Thread Patrick Marlier

On 01/24/2012 08:32 PM, Andi Kleen wrote:

Hi,
>
>  I found that all thread local variables are instrumented with
>  _ITM_W/R* calls whereas they should not be shared with other
>  threads. This patch takes care of thread locals into requires_barrier
>  and also adds the local save/restore for them. This patch also
>  includes a testcase.

What happens when the address of the thread local escapes?
It could well be written by another thread then.

I guess you have to check for escapes here.


Thanks to raise the question and I hope I understand your point.

Did you mean something like this?

__thread int myvalue;
void bar()
{
  foo(&myvalue);
  __transaction_atomic {
myvalue++;
  }
}

where foo shares the pointer to other threads?

From my point of view, no. When it is a thread local, it should not be 
shared to someone else. If the thread dies, what happens to the thread 
local variable? Should it be discarded completely and this piece of 
memory never reallocated? Even if the programmer take care of this 
situation, does it make sense to share a thread local to other threads?


Anyway, you are probably right but I would prefer let the knowledgeable 
people answer instead of me, the little jedi...

--
Patrick.




Re: [patch] Fix mismatched #pragma GCC visibility

2012-01-24 Thread Rafael Ávila de Espíndola
> While we can change it, it is certainly valid as is, #pragma GCC visibility
> can happen in lots of places and just marks where the default visibility
> is adjusted.  If clang errors on this, it is broken.

It doesn't. As far as I can tell, in the absence of templates clang
produces the same results as gcc on any valid case. I was trying to
improve the error messages and found this.

Just to make sure I get the more fun corner cases right. This is invalid:

-
#pragma GCC visibility push(default)

namespace foo __attribute__((visibility("hidden"))) {
  int a;
#pragma GCC visibility pop
  int b;
}
--

But removing the attribute makes it valid. Correct?

>   Jakub

Cheers,
Rafael


Re: [patch] Fix mismatched #pragma GCC visibility

2012-01-24 Thread Rafael Ávila de Espíndola
> While we can change it, it is certainly valid as is, #pragma GCC visibility
> can happen in lots of places and just marks where the default visibility
> is adjusted.  If clang errors on this, it is broken.

Sorry, one more case that gcc accepts where it is not clear what the
result should be:

-
#pragma GCC visibility push(protected)

int x;
class  __attribute__((visibility("hidden"))) foo {
  static int a;
#pragma GCC visibility pop
  static int b;
};
int y;

int foo::a;
int foo::b;
-

Should this be reject (as happens with namespaces)? If not what is the
expected result? Currently we get

x -> protected
y -> default
a -> hidden
b -> hidden

>   Jakub

Cheers,
Rafael


C++ PATCH for c++/51917 (wrong tinfo hints on some targets)

2012-01-24 Thread Jason Merrill
As it turns out, this bug depended on vector allocation size. 
xref_basetypes asks for space for a certain number of bases, then fills 
up the vector, and assumes that if there's any space left we must have 
hit a shared virtual base, i.e. diamond-shaped inheritance.  But since 
my vec.c patch for PR 14179, when we allocate a vector we get back a 
vector with the number of slots that fill the memory we get from the 
allocator, rather than the exact number of slots we asked for.  So if 
those don't match, the compiler thinks that we're sharing.


Fixed by directly comparing the number of slots filled to the number of 
slots expected.  Tested x86_64-pc-linux-gnu, applying to trunk.
commit 8860243111f961b8f1d37238cd28ed82516b1927
Author: Jason Merrill 
Date:   Tue Jan 24 22:05:52 2012 -0500

	PR c++/51917
	* decl.c (xref_basetypes): Check VEC_length instead of VEC_space.

diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index ef43dbf..7fba04a 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -11916,8 +11916,8 @@ xref_basetypes (tree ref, tree base_list)
   BINFO_BASE_ACCESS_APPEND (binfo, access);
 }
 
-  if (VEC_space (tree, CLASSTYPE_VBASECLASSES (ref), 1))
-/* If we have space in the vbase vector, we must have shared at
+  if (VEC_length (tree, CLASSTYPE_VBASECLASSES (ref)) < max_vbases)
+/* If we didn't get max_vbases vbases, we must have shared at
least one of them, and are therefore diamond shaped.  */
 CLASSTYPE_DIAMOND_SHAPED_P (ref) = 1;
 


Re: [v3] libstdc++/49829

2012-01-24 Thread Benjamin Kosnik


> this breaks builds configured with --enable-libstdcxx-debug.

confirmed

>  Tried
> the following (not yet working) fix.

OK. The attached is closer, but still not quite there.

-benjamindiff --git a/libstdc++-v3/src/Makefile.am b/libstdc++-v3/src/Makefile.am
index 87b2a16..59cc57d 100644
--- a/libstdc++-v3/src/Makefile.am
+++ b/libstdc++-v3/src/Makefile.am
@@ -172,13 +172,23 @@ endif
 # 1 debug library
 # 2 supra-convenience library
 if GLIBCXX_BUILD_DEBUG
-all-local: libstdc++convenience.la build_debug
-install-data-local: install_debug
+STAMP_DEBUG = build-debug
+STAMP_INSTALL_DEBUG = install-debug
+CLEAN_DEBUG = debug
 else
-all-local: libstdc++convenience.la
-install-data-local:
+STAMP_DEBUG =
+STAMP_INSTALL_DEBUG =
+CLEAN_DEBUG =
 endif
 
+all-local-once: libstdc++convenience.la $(STAMP_DEBUG)
+install-data-local-once: $(STAMP_INSTALL_DEBUG)
+
+all-local: all-local-once
+install-data-local: install-data-local-once
+clean-local:
+	rm -rf libstdc++convenience.la stamp* $(CLEAN_DEBUG)
+
 # Make a non-installed convenience library, so that --disable-static
 # may work.
 libstdc++convenience.la: $(toolexeclib_LTLIBRARIES)
@@ -188,13 +198,13 @@ libstdc++convenience.la: $(toolexeclib_LTLIBRARIES)
 	fi; \
 	echo `date` > stamp-libstdc++convenience;
 
-debugdir = debug
-
-# Build a set of debug objects here.
+# Build a debug variant.
 # Take care to fix all possibly-relative paths.
+debugdir = ${glibcxx_builddir}/src/debug
 stamp-debug:
 	if test ! -d ${debugdir}; then \
 	  mkdir -p ${debugdir}; \
+	  for d in $(SUBDIRS); do mkdir -p  ${debugdir}/$$d; done; \
 	  (cd ${debugdir}; \
 	  sed -e 's/top_builddir = \.\./top_builddir = ..\/../' \
 	  -e 's/top_build_prefix = \.\./top_build_prefix = ..\/../' \
@@ -202,16 +212,25 @@ stamp-debug:
 	  -e 's/VPATH = \.\./VPATH = ..\/../' \
 	  -e 's/glibcxx_basedir = \.\./glibcxx_basedir = ..\/../' \
 	  -e 's/MKDIR_P = \.\./MKDIR_P = ..\/../' \
-	  -e 's/all-local: build_debug/all-local:/' \
-	  -e 's/install-data-local: install_debug/install-data-local:/' \
-	  < ../Makefile > Makefile) ; \
+	  -e 's/all-local: all-local-once/all-local:/' \
+	  -e 's/install-data-local: install-data-local-once/install-data-local:/' \
+	  < ../Makefile > Makefile ; \
+	  for d in . $(SUBDIRS); do \
+	  sed -e 's/top_builddir = \.\./top_builddir = ..\/../' \
+	  -e 's/top_build_prefix = \.\./top_build_prefix = ..\/../' \
+	  -e 's/srcdir = \.\./srcdir = ..\/../' \
+	  -e 's/VPATH = \.\./VPATH = ..\/../' \
+	  -e 's/glibcxx_basedir = \.\./glibcxx_basedir = ..\/../' \
+	  -e 's/MKDIR_P = \.\./MKDIR_P = ..\/../' \
+	  < ../$$d/Makefile > $$d/Makefile ; \
+	  done) ; \
 	fi; \
 	echo `date` > stamp-debug;
 
-build_debug: stamp-debug
-	(cd ${debugdir} && $(MAKE) CXXFLAGS='$(DEBUG_FLAGS)' all)
+build-debug: stamp-debug
+	(cd ${debugdir} && $(MAKE) CXXFLAGS='$(DEBUG_FLAGS)' libstdc++.la)
 
-# Install debug library here.
-install_debug:
+# Install debug library.
+install-debug: stamp-debug
 	(cd ${debugdir} && $(MAKE) \
 	toolexeclibdir=$(glibcxx_toolexeclibdir)/debug install)


[PATCH] Partially fix 51988: value_replacement in PHIOPT should handle even the cases where there are other PHIs even with non equal value

2012-01-24 Thread Andrew Pinski
Hi,
  value_replacement in PHIOPT currently works only when there is one
PHI (which is non virtual).
http://gcc.gnu.org/ml/gcc-patches/2012-01/msg01195.html improves the
situation but we can improve it even more as replacing a PHI argument
with a SSA_NAME is almost always a benefit.

This patch improves the situation even more for value replacement
(though it does not fix all the cases I wanted to fix but that would
require much more rewrite of phiopt that I was willing to take on
right now, see the bug report for the two testcases where we miss
still).  We improve the situation by just going through all the PHIs
and seeing if we want to do value replacement and only remove the
middle basic block if it is empty or we used the only assignment in
the PHI (for if(p)a=&p->a;else a= 0; case).

OK for 4.8? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

Note I have two improvements when both this and
http://gcc.gnu.org/ml/gcc-patches/2012-01/msg01195.html are applied;
remove the xfail and instead of gimple_seq_singleton_p use the new
single_non_singleton_phi_for_edges (I will test that patch after both
are applied).  Currently these patches are independent and I want to
keep it that way.

Thanks,
Andrew Pinski

ChangeLog:
* tree-ssa-phiopt.c: Include tree-pretty-print.h for print_generic_expr.
(tree_ssa_phiopt_worker): Go through all the PHIs for
value_replacement instead of just the singleton one.
(value_replacement): Change return type to int.  Return 0 instead of false.
Allow the middle basic block to contain more than just the defining statement.
Handle non empty middle basic blocks.
* Makefile.in (tree-ssa-phiopt.o): Add tree-pretty-print.h

testsuite/ChangeLog:
* gcc.dg/tree-ssa/phi-opt-8.c: New testcase.
* gcc.dg/tree-ssa/phi-opt-9.c: New testcase.
Index: testsuite/gcc.dg/tree-ssa/phi-opt-8.c
===
--- testsuite/gcc.dg/tree-ssa/phi-opt-8.c   (revision 0)
+++ testsuite/gcc.dg/tree-ssa/phi-opt-8.c   (revision 0)
@@ -0,0 +1,26 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fdump-tree-optimized -fdump-tree-phiopt1" } */
+
+int g(int,int);
+int f(int t, int c)
+{
+  int d = 0;
+  int e = 0;
+  if (t)
+{
+  d = 1;
+  e = t;
+}
+  else d = 0, e = 0;
+  return g(e,d);
+}
+
+/* This testcase should be reduced to e = t; d = t != 0; in phiopt1
+   but currently is not as PHI-OPT does not reduce the t PHI as we have
+   two phis.  Note this is fixed with
+   http://gcc.gnu.org/ml/gcc-patches/2012-01/msg01195.html .  */
+/* { dg-final { scan-tree-dump-not "if" "phiopt1" { xfail *-*-* } } } */
+/* { dg-final { scan-tree-dump "g .t_\[0-9\]*.D.," "optimized" } } */
+/* { dg-final { scan-tree-dump-times 0 "PHI" "optimized" } } */
+/* { dg-final { cleanup-tree-dump "phiopt1" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
Index: testsuite/gcc.dg/tree-ssa/phi-opt-9.c
===
--- testsuite/gcc.dg/tree-ssa/phi-opt-9.c   (revision 0)
+++ testsuite/gcc.dg/tree-ssa/phi-opt-9.c   (revision 0)
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fdump-tree-optimized" } */
+
+int g(int,int);
+int f(int t, int c)
+{
+  int d = 0;
+  int e = 0;
+  if (t)
+{
+  d = c+1;
+  e = t;
+}
+  else d = 0, e = 0;
+  return g(e,d);
+}
+
+/* The value e should have been replaced with t and there should be only one 
PHI. */
+/* { dg-final { scan-tree-dump "g .t_\[0-9\]*.D.," "optimized" } } */
+/* { dg-final { scan-tree-dump-times 1 "PHI" "optimized" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
Index: tree-ssa-phiopt.c
===
--- tree-ssa-phiopt.c   (revision 183507)
+++ tree-ssa-phiopt.c   (working copy)
@@ -36,13 +36,14 @@ along with GCC; see the file COPYING3.
 #include "domwalk.h"
 #include "cfgloop.h"
 #include "tree-data-ref.h"
+#include "tree-pretty-print.h"
 
 static unsigned int tree_ssa_phiopt (void);
 static unsigned int tree_ssa_phiopt_worker (bool);
 static bool conditional_replacement (basic_block, basic_block,
 edge, edge, gimple, tree, tree);
-static bool value_replacement (basic_block, basic_block,
-  edge, edge, gimple, tree, tree);
+static int value_replacement (basic_block, basic_block,
+ edge, edge, gimple, tree, tree);
 static bool minmax_replacement (basic_block, basic_block,
edge, edge, gimple, tree, tree);
 static bool abs_replacement (basic_block, basic_block,
@@ -314,7 +315,24 @@ tree_ssa_phiopt_worker (bool do_store_el
{
  gimple_seq phis = phi_nodes (bb2);
  gimple_stmt_iterator gsi;
+ bool candorest = true;
+ /* Value replacement can work with more than one PHI
+so try that first. */
+ for (gsi = gsi_start (phis); !gsi_end_p (gsi); gsi_next (&gsi))
+