Re: [google/integration] Support arm-grtev2-linux-*eabi (issue4628043)

2011-09-12 Thread Chris Demetriou
On Mon, Sep 12, 2011 at 15:24, Gerald Pfeifer  wrote:
> Should this be added to the GCC 4.7 release notes at
> http://gcc.gnu.org/gcc-4.7/changes.html ?  If you need help doing
> so, propose a text and I'll be happy to care of it.

I absolutely need help (just ask Diego)... but not with that...  8-)

This was a change that was made on the google/integration branch, and
is not appropriate for trunk.
So, no NEWS (or changes.html) here.

Thanks, though.  8-)


-c


Re: [2/4] SMS: Use ids to represent ps_insns

2011-09-12 Thread Ayal Zaks
Richard Sandiford  wrote on 30/08/2011
03:03:59 PM:

> From: Richard Sandiford 

> To: gcc-patches@gcc.gnu.org

> Cc: Ayal Zaks/Haifa/IBM@IBMIL

> Date: 30/08/2011 03:05 PM

> Subject: [2/4] SMS: Use ids to represent ps_insns

>
> Instructions in a partial schedule are currently represented as a
> ddg node. This patch uses a more abstract id instead. At the moment,
> the ids map directly to ddg nodes, but the next patch will add register
> moves to the end.
>
> One slight advantage of using ids is that we can leave the ASAP value
> on the node; we don't need to copy it across to the scheduling info.
>
> (Later patches use the same scheduling info for moves, for which an ASAP
> value would be wasted space.)
>
> Richard
>

OK.

So instead of navigating directly from
ps_insn->ddg_node->node_sched_params, we now use indices and lookup
pointees in ddg_node and node_sched_params arrays. A bit of a
nuisance, but it's ok with me. A couple of thoughts:

o One could still achieve the goal of having ps_insn's with
node_sched_params but free of ddg_node's, w/o penalizing the existing
direct access from ddg_node->node_sched_params, and w/o replicating
the interface. If you add an (insn field and an) aux union to ps_insn,
whose info points to your node_sched_params, you could reuse the same
set of macros. Admittedly, it's a space-time tradeoff, where the space
is probably not a major concern, and there are other places to look
for first in sms to save time.

o first_reg_move and nreg_moves will be redundant for regmoves, right?
No refactoring is perfect...

o it could be useful to have a debug version which checks array
bounds, in case one feeds a bad index.

o and a minor comment below:

> /* The scheduling parameters held for each node. */
> typedef struct node_sched_params
> {
> - int asap; /* A lower-bound on the absolute scheduling cycle. */
> int time; /* The absolute scheduling cycle (time >= asap). */

Please fix/remove the "(time >= asap)" comment, as there's no asap
there any more.

Thanks,
Ayal.


[v3] Declare std::tuple_cat constexpr (+ all std::get)

2011-09-12 Thread Paolo Carlini

Hi,

Daniel kindly helped adjusting  to enable constexpr for 
std::tuple_cat. At the same time all the std::get overloads, for 
std::pair and std::array too.


Tested x86_64-linux, committed.

Thanks,
Paolo.


2011-09-12  Daniel Krugler  
Paolo Carlini  

* include/std/tuple (_Head_base<>::_M_head, _Head_base<>::_M_tail,
_Tuple_impl<>::_M_head, _Tuple_impl<>::_M_tail): Change to static
constexpr functions; adjust everywhere.
(__get_helper, get): Declare constexpr all three overloads.
(tuple_cat): Declare constexpr; use late return type to improve
error messages.
* include/std/utility (__pair_get<>::__get, __pair_get<>::__move_get,
__pair_get<>::__const_get, get): Declare all constexpr.
* include/std/array (get): Likewise.
* testsuite/20_util/tuple/creation_functions/constexpr.cc: Re-enable
tuple_cat test.
* testsuite/23_containers/array/constexpr_get.cc: New.
* testsuite/20_util/tuple/element_access/constexpr_get.cc: Likewise.
* testsuite/20_util/pair/constexpr_get.cc: Likewise.
* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Adjust dg-error
line number.
Index: include/std/tuple
===
--- include/std/tuple   (revision 178791)
+++ include/std/tuple   (working copy)
@@ -140,11 +140,11 @@
_Head_base(__uses_alloc2<_Alloc> __a, _UHead&& __uhead)
: _Head(std::forward<_UHead>(__uhead), *__a._M_a) { }
 
-  _Head&   
-  _M_head() noexcept { return *this; }
+  static constexpr _Head&
+  _M_head(_Head_base& __b) noexcept { return __b; }
 
-  constexpr const _Head& 
-  _M_head() const noexcept { return *this; }
+  static constexpr const _Head&
+  _M_head(const _Head_base& __b) noexcept { return __b; }
 };
 
   template
@@ -186,13 +186,13 @@
_Head_base(__uses_alloc2<_Alloc> __a, _UHead&& __uhead)
: _M_head_impl(std::forward<_UHead>(__uhead), *__a._M_a) { }
 
-  _Head&   
-  _M_head() noexcept { return _M_head_impl; }
+  static constexpr _Head&
+  _M_head(_Head_base& __b) noexcept { return __b._M_head_impl; }
 
-  constexpr const _Head& 
-  _M_head() const noexcept { return _M_head_impl; }
+  static constexpr const _Head&
+  _M_head(const _Head_base& __b) noexcept { return __b._M_head_impl; }
 
-  _Head _M_head_impl; 
+  _Head _M_head_impl;
 };
 
   /**
@@ -245,17 +245,17 @@
   typedef _Tuple_impl<_Idx + 1, _Tail...> _Inherited;
   typedef _Head_base<_Idx, _Head, std::is_empty<_Head>::value> _Base;
 
-  _Head&
-  _M_head() noexcept { return _Base::_M_head(); }
+  static constexpr _Head&  
+  _M_head(_Tuple_impl& __t) noexcept { return _Base::_M_head(__t); }
 
-  constexpr const _Head&  
-  _M_head() const noexcept { return _Base::_M_head(); }
+  static constexpr const _Head&
+  _M_head(const _Tuple_impl& __t) noexcept { return _Base::_M_head(__t); }
 
-  _Inherited&   
-  _M_tail() noexcept { return *this; }
+  static constexpr _Inherited&
+  _M_tail(_Tuple_impl& __t) noexcept { return __t; }
 
-  constexpr const _Inherited& 
-  _M_tail() const noexcept { return *this; }
+  static constexpr const _Inherited&
+  _M_tail(const _Tuple_impl& __t) noexcept { return __t; }
 
   constexpr _Tuple_impl()
   : _Inherited(), _Base() { }
@@ -276,17 +276,20 @@
   _Tuple_impl(_Tuple_impl&& __in)
   noexcept(__and_,
  is_nothrow_move_constructible<_Inherited>>::value)
-  : _Inherited(std::move(__in._M_tail())), 
-   _Base(std::forward<_Head>(__in._M_head())) { }
+  : _Inherited(std::move(_M_tail(__in))), 
+   _Base(std::forward<_Head>(_M_head(__in))) { }
 
   template
 constexpr _Tuple_impl(const _Tuple_impl<_Idx, _UElements...>& __in)
-   : _Inherited(__in._M_tail()), _Base(__in._M_head()) { }
+   : _Inherited(_Tuple_impl<_Idx, _UElements...>::_M_tail(__in)),
+ _Base(_Tuple_impl<_Idx, _UElements...>::_M_head(__in)) { }
 
   template
 _Tuple_impl(_Tuple_impl<_Idx, _UHead, _UTails...>&& __in)
-   : _Inherited(std::move(__in._M_tail())),
- _Base(std::forward<_UHead>(__in._M_head())) { }
+ : _Inherited(std::move
+  (_Tuple_impl<_Idx, _UHead, _UTails...>::_M_tail(__in))),
+ _Base(std::forward<_UHead>
+   (_Tuple_impl<_Idx, _UHead, _UTails...>::_M_head(__in))) { }
 
   template
_Tuple_impl(allocator_arg_t __tag, const _Alloc& __a)
@@ -311,34 +314,38 @@
   template
 _Tuple_impl(allocator_arg_t __tag, const _Alloc& __a,
const _Tuple_impl& __in)
-   : _Inherited(__tag, __a, __in._M_tail()), 
-  _Base(__use_alloc<_Head, _Alloc, _Head>(__a), __in._M_head()) { }
+   : _Inherited(__tag, __a, 

Re: Initial shrink-wrapping patch

2011-09-12 Thread Bernd Schmidt
On 09/01/11 15:57, Richard Sandiford wrote:
> add_to_hard_reg_set (pused, GET_MODE (x), REGNO (x));

Done.

> Strange line break, and comment doesn't match code (no "changed" variable).

Fixed.

>> +/* Return true if INSN requires the stack frame to be set up.
>> +   PROLOGUE_USED contains the hard registers used in the function
>> +   prologue.  */
>> +static bool
>> +requires_stack_frame_p (rtx insn, HARD_REG_SET prologue_used)
>> +{
>> [...]
>> +  if (for_each_rtx (&PATTERN (insn), frame_required_for_rtx, NULL))
>> +return true;
>> +  CLEAR_HARD_REG_SET (hardregs);
>> +  note_stores (PATTERN (insn), record_hard_reg_sets, &hardregs);
>> +  if (hard_reg_set_intersect_p (hardregs, prologue_used))
>> +return true;
>> +  AND_COMPL_HARD_REG_SET (hardregs, call_used_reg_set);
>> +  for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
>> +if (TEST_HARD_REG_BIT (hardregs, regno)
>> +&& df_regs_ever_live_p (regno))
>> +  return true;
> 
> ...I suppose this ought to use DF instead.

Here, I kind of disagree. Most of the new code works on unemitted
sequences, and df doesn't work for that, so we rely on note_stores and
such quite a lot. I've changed the one note_stores call in this function
to use df, but IMO it's not an improvement. As for
frame_required_for_rtx, I'd much rather test for equality with
hard_frame_pointer_rtx than muck about with register numbers and
frame_pointer_needed tests.

Also, it turns out I need to pretend that trap_if requires the prologue
due to the testcase you also ran across, so a for_each_rtx walk is
required anyway.

> Does something guarantee that non-local gotos are marked as
> needing a frame?

There are (use fp) (use sp) and such insns before nonlocal gotos. There
aren't any testsuite failures related to nonlocal gotos, so I assume
that's sufficient.

> Why do we need to check specifically for pic_offset_table_rtx?  Isn't it
> handled by the generic "live registers set by the prologue" test?

There is no such test, really - other than this code. There is a "live
registers clobbered by the prologue" test which disables the
optimization at a late stage. However, the prologue may set some
registers simply as scratch regs, and things would be more complicated
if we tried to identify which ones are scratch and which ones are really
set up for the rest of the function.

> Reason for asking is that pic_offset_table_rtx can be a global value,
> such as for mips*-elf.

Can we shelve this as a potential improvement for later?

>> +static rtx
>> +gen_return_pattern (bool simple_p)
> 
> Missing function comment.

Fixed.

> Pedantic, but the comment should reference SIMPLE_P.

Fixed.

> 
>> +#ifdef HAVE_simple_return
>> +  /* Try to perform a kind of shrink-wrapping, making sure the
>> + prologue/epilogue is emitted only around those parts of the
>> + function that require it.  */
>> +
>> +  if (flag_shrink_wrap && HAVE_simple_return && !flag_non_call_exceptions
>> +  && HAVE_prologue && !crtl->calls_eh_return)
>> +{
> 
> Maybe it should be obvious, but could you add a comment explaining why
> flag_non_call_exceptions and crtl->calls_eh_return need to be checked
> explicitly?

Primarily because I think it's a waste of time to worry about them. I've
removed the flag_non_call_exceptions check, but eh_return is handled
elsewhere in this function, and there's really no reason to try to think
of the possible interactions. It's only used in one function in libgcc...

> Would checking prologue_seq != NULL be better than HAVE_prologue?

I was going to say no, but a look at the i386 expand_prologue suggests
we don't really want to try to duplicate the logic for HAVE_prologue.
"prologue_seq != NULL" isn't sufficient due to extra stuff being emitted
into the sequence, but I've added some code to check if the prologue has
nontrivial insns.

> Should this iterate over split_prologue_seq as well?

and

> Seems like we should be able to reuse the insn walk from the beginning
> of the enclosing if statement.

That seems to be a problem with merging multiple versions of this code.
Rearranged.

> Could we combine prologue_seq and split_prologue_seq into a single sequence?

Not in this patch, please.

> Excess { and } in for loop.

Fixed.

> if (e->dest != EXIT_BLOCK_PTR
> && bitmap_set_bit (&bb_flags, e->dest->index))
>   VEC_quick_push (basic_block, vec, e->dest);
> 
> should be a little more efficient.

Changed (three similar changes which you pointed out).

>> +#ifdef HAVE_simple_return
>> +  simple_p = (entry_edge != orig_entry_edge
>> +  ? !bitmap_bit_p (&bb_flags, bb->index) : false);
>> +#else
>> +  simple_p = false;
>> +#endif
> 
> Why is this bb_flags rather than bb_antic_flags?

Doesn't really matter. (bb_antic_flags & ~bb_flags) only contains blocks
which don't need a prologue, but for which all subsequent paths lead to
something that requires a prologue. That's never going to be a block
that needs an epilogue or a return 

[pph] Restore -fno-dwarf2-cfi-asm. (issue4992051)

2011-09-12 Thread Lawrence Crowl
Restore compiling the tests with -fno-dwarf2-cfi-asm.  Failure to do
so results in different assembly output on different platforms due to
different assembler support for exceptions.


Index: gcc/testsuite/ChangeLog.pph

2011-09-12   Lawrence Crowl  

* lib/dg-pph.exp: Restore -fno-dwarf2-cfi-asm option for
stability across platforms.


Index: gcc/testsuite/lib/dg-pph.exp
===
--- gcc/testsuite/lib/dg-pph.exp(revision 178792)
+++ gcc/testsuite/lib/dg-pph.exp(working copy)
@@ -19,10 +19,13 @@
 
 load_lib copy-file.exp
 
+# Options needed for assembly stability across platforms.
+set stable "-fno-dwarf2-cfi-asm"
+
 # Generate a PPH image from a header file.
 proc dg-pph-hdr { subdir test options mapflag suffix } {
 
-global runtests dg-do-what-default
+global runtests dg-do-what-default stable
 
 # If we're only testing specific files and this isn't one of them, skip it.
 if { ![runtest_file_p $runtests $test] } {
@@ -34,7 +37,7 @@ proc dg-pph-hdr { subdir test options ma
 verbose -log "\nTesting $nshort, $options"
 
 set dg-do-what-default preparse
-dg-test -keep-output $test "-fpph-gen $options $mapflag -I." ""
+dg-test -keep-output $test "-fpph-gen $options $mapflag $stable" ""
 
 if { [file_on_host exists "$bname.s"] } {
file_on_host delete "$bname.s"
@@ -45,7 +48,7 @@ proc dg-pph-hdr { subdir test options ma
 # as they represent files that are not compatible with PPH.
 proc dg-pph-neg { subdir test options mapflag suffix } {
 
-global runtests dg-do-what-default
+global runtests dg-do-what-default stable
 
 # If we're only testing specific files and this isn't one of them, skip it.
 if { ![runtest_file_p $runtests $test] } {
@@ -57,7 +60,7 @@ proc dg-pph-neg { subdir test options ma
 verbose -log "\nTesting $nshort, $options"
 
 set dg-do-what-default compile
-dg-test -keep-output $test "$options $mapflag -I. -fno-dwarf2-cfi-asm" ""
+dg-test -keep-output $test "$options $mapflag $stable" ""
 
 if { [file_on_host exists "$bname.s"] } {
file_on_host delete "$bname.s"
@@ -71,7 +74,7 @@ proc dg-pph-neg { subdir test options ma
 # assembly outputs are identical.
 proc dg-pph-pos { subdir test options mapflag suffix } {
 
-global runtests dg-do-what-default
+global runtests dg-do-what-default stable
 
 # If we're only testing specific files and this isn't one of them, skip it.
 if { ![runtest_file_p $runtests $test] } {
@@ -109,7 +112,8 @@ proc dg-pph-pos { subdir test options ma
# Now, compile the file but prune the result to avoid considering
# it part of the testsuite.  We just want to compile it to provide
# a base assembly output to compare against.
-   set comp_output [g++-dg-test $test compile "$options $other_options"]
+set full_options "$options $other_options $stable"
+   set comp_output [g++-dg-test $test compile "$full_options"]
set comp_output [g++-dg-prune $target_triplet $comp_output]
 
# Wanted assembly, so quit if it did not compile successfully.
@@ -127,7 +131,7 @@ proc dg-pph-pos { subdir test options ma
 verbose -log ""
 
 # Compile a second time using the PPH files.
-dg-test -keep-output $test "$options $mapflag" ""
+dg-test -keep-output $test "$options $mapflag $stable" ""
 
 if { !$is_asm } {
# No assembly means we cannot compare them,

--
This patch is available for review at http://codereview.appspot.com/4992051


Re: [google/integration] Support arm-grtev2-linux-*eabi (issue4628043)

2011-09-12 Thread Gerald Pfeifer
On Thu, 16 Jun 2011, Chris Demetriou wrote:
> This patch adds support for the arm-grtev2-linux-gnueabi configuration.
> This is like the x86 linux config of similar 'vendor':
>  * it plays some spec games to support easier use of static NSS
>configuration, and
>  * it adds RUNTIME_ROOT_PREFIX support to the dynamic loader path.

Should this be added to the GCC 4.7 release notes at 
http://gcc.gnu.org/gcc-4.7/changes.html ?  If you need help doing
so, propose a text and I'll be happy to care of it.

Gerald


Re: [PATCH] c++/48320 - Template parameter packs cannot be expanded in

2011-09-12 Thread Jason Merrill

OK.

Jason


Re: [pph] Remove XPASS noise from pph testsuite (issue4967063)

2011-09-12 Thread Lawrence Crowl
And I have confirmed the problem is still here.  I'll be reinserting
the option.

On 9/12/11, Gabriel Charette  wrote:
> Oops forgot to reply all...
>
> On Mon, Sep 12, 2011 at 7:40 AM, Diego Novillo  wrote:
>> This patch removes all the XPASS noise from pph.exp runs by pruning
>> the output from the base compiles (thanks Ian for the pointer).  It
>> add some comments as well.
>>
>> Lawrence, I noticed that we do not seem to need -I. -fno-dwarf2-cfi-asm
>> anymore.  So, I removed them.  I'm not sure I remember exactly why you
>> had added them, but since removing them produces no changes to the
>> results, I just took them out.
>
> This was a hack because Lawrence was getting different asm checksums
> for the pph asm xdiff because his configuration would output some
> additional dwarf2-cfi assembly. Thus, no single expected diff checksum
> would work for both of us.
>
> Cheers,
> Gab
>


-- 
Lawrence Crowl


Re: [PATCH 7/7] Reduce memory waste due to non-power-of-2 allocs

2011-09-12 Thread Jason Merrill

On 07/16/2011 10:37 AM, Dodji Seketeli wrote:

Ideally, I'd prefer some parts of this patch to be integrated into the
memory allocator.  That is, I'd like to see the memory allocator have
an interface that returns the actual size of memory it has allocated.
This would help client code like this one to avoid requesting memory
unnecessarily.


This sounds good to me.  Or, it would probably be simpler to just 
provide a separate function for rounding up the allocated size using the 
same code as the allocator.


Jason


Re: [PATCH 6/7] Kill pedantic warnings on system headers macros

2011-09-12 Thread Jason Merrill

On 07/16/2011 10:37 AM, Dodji Seketeli wrote:

+  location_t here = c_parser_peek_token (parser)->location;


Perhaps "first_token_loc"?  It's unfortunate that we don't retain the 
locations of the individual declspecs, but I don't expect you to fix that.



+   SYNTAX_ERROR2_AT (prev_virtual_location,
+ "missing binary operator before token \"%s\"",
+ cpp_token_as_text (pfile, op.token));


It seems to me that the "missing X before" errors should point to the 
current token, not the previous one.  So you can drop prev_virtual_location.


Jason


Re: [PATCH 5/7] Add line map statistics to -fmem-report output

2011-09-12 Thread Jason Merrill

On 07/16/2011 10:37 AM, Dodji Seketeli wrote:

+#define ONE_M ONE_K * ONE_K


Parenthesize this so that users don't need to.


+  macro_maps_used_size =
+LINEMAPS_MACRO_USED (set) * sizeof (struct line_map)
++ macro_maps_locations_size;


It seems odd to add in the locations size here since it's also printed 
separately.



+  fprintf (stderr, "Total allocated maps size:   %5lu%c\n",
+  SCALE (s.total_allocated_map_size),
+  STAT_LABEL (s.total_allocated_map_size));
+  fprintf (stderr, "Total used maps size:%5lu%c\n",
+  SCALE (s.total_used_map_size),
+  STAT_LABEL (s.total_used_map_size));
+  fprintf (stderr, "Ordinary map used size:  %5lu%c\n",
+  SCALE (s.ordinary_maps_used_size),
+  STAT_LABEL (s.ordinary_maps_used_size));
+  fprintf (stderr, "Macro maps used size:%5lu%c\n",
+  SCALE (s.macro_maps_used_size),
+  STAT_LABEL (s.macro_maps_used_size));
+  fprintf (stderr, "Number of ordinary maps allocated:   %5lu%c\n",
+  SCALE (s.num_ordinary_maps_allocated),
+  STAT_LABEL (s.num_ordinary_maps_allocated));
+  fprintf (stderr, "Number of ordinary maps used:%5lu%c\n",
+  SCALE (s.num_ordinary_maps_used),
+  STAT_LABEL (s.num_ordinary_maps_used));
+  fprintf (stderr, "Number of macro maps used:   %5lu%c\n",
+  SCALE (s.num_macro_maps_used),
+  STAT_LABEL (s.num_macro_maps_used));
+  fprintf (stderr, "Ordinary maps allocated size:%5lu%c\n",
+  SCALE (s.ordinary_maps_allocated_size),
+  STAT_LABEL (s.ordinary_maps_allocated_size));
+  fprintf (stderr, "Macro maps locations size:   %5lu%c\n",
+  SCALE (s.macro_maps_locations_size),
+  STAT_LABEL (s.macro_maps_locations_size));
+  fprintf (stderr, "Duplicated maps locations size:  %5lu%c\n",
+  SCALE (s.duplicated_macro_maps_locations_size),
+  STAT_LABEL (s.duplicated_macro_maps_locations_size));


This seems oddly sorted.  And why the difference between ordinary and 
macro maps in terms of what is printed?



+/* Counters defined in libcpp's macro.c.  */
+extern unsigned num_expanded_macros_counter;
+extern unsigned num_macro_tokens_counter;


These should be part of struct linemap_stats.

Jason


Re: [PATCH 4/7] Support -fdebug-cpp option

2011-09-12 Thread Jason Merrill

On 08/24/2011 10:06 AM, Tom Tromey wrote:

Dodji> Would it be acceptable to just change the output of -fdirective to fit?
Dodji> Or are we bound to not breaking existing consumers?

I think changing it would be fine.


I agree.

On 07/16/2011 10:37 AM, Dodji Seketeli wrote:

 }
+
+void
+linemap_dump_location (struct line_maps *set,


Comment.


+@item -fdebug-cpp
+@opindex fdebug-cpp


Please add something to clarify that this is only useful for debugging GCC.

Jason


Re: [PATCH 3/7] Emit macro expansion related diagnostics

2011-09-12 Thread Jason Merrill

On 08/04/2011 11:32 AM, Dodji Seketeli wrote:

+++ b/gcc/diagnostic.c
@@ -30,6 +30,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "input.h"
 #include "intl.h"
 #include "diagnostic.h"
+#include "vec.h"


Do you still need this?


 // Just discard errors pointing at header files
 // { dg-prune-output "include" }
+// { dg-prune-output "from" }


These should be pruned by testsuite/lib/prune.exp.  I'm surprised they 
aren't already.



+#define APPEND_LOC_TO_VEC(LOC) \
+  if (num_locs >=3D loc_vec_capacity)  \
+{  \
+  loc_vec_capacity +=3D 4; \
+  loc_vec =3D XRESIZEVEC (loc_t, loc_vec, loc_vec_capacity);
\
+}  \
+  loc_vec[num_locs++] =3D LOC;


Why not use VEC since we're in gcc/ here?


+/* Unwind the different macro expansions that lead to the token which
+   location is WHERE and emit diagnostics showing the resulting
+   unwound macro expansion stack.  If TOPMOST_EXP_POINT_MAP is
+   non-null, *TOPMOST_EXP_POINT_MAP is set to the map of the expansion
+   point of the top most macro of the stack.  This must be an ordinary
+   map.  */


I find the use of "top" here confusing.  You mean the place in the 
source that first triggered the macro expansion, right?  Can we avoid 
talking about stacks here?



+  /* Walk the map_vec and print the macro expansion stack, unless the
+ topmost macro which expansion triggered this stack [assuming the
+ stack grows downwards] was expanded inside a system header.  */


Abstract stacks are said to grow upwards; only the representation of a 
call stack on certain architectures can grow downwards.  The top of the 
stack is the most recently pushed element, which in the case of macro 
expansion would be the innermost macro expanded.



+  while (unwind)
+{

...

+  if (!linemap_macro_expansion_map_p (map))
+   unwind =3D false;
+}


This seems like a job for do/while.


+   diagnostic->location =3D resolved_def_loc;
+   pp_base_set_prefix (context->printer,
+   diagnostic_build_prefix (context,
+diagnostic));


Using pp_verbatim like in maybe_print_constexpr_context seems simpler to 
me, but if you prefer this approach that's fine.


Jason


[PATCH] c++/48320 - Template parameter packs cannot be expanded in

2011-09-12 Thread Dodji Seketeli
Hello,

fixup_template_parms fixes up template parameters by substituting the
result of current_template_args into each template parameter, from
left to right.

In the example the patch, when the compiler comes to the point of
substituting into the default argument of template parameter Result,
it is exposed to a subtlety that is twofold.

1/ The parameter pack Indices is now represented by a
TEMPLATE_PARM_INDEX, as a result of substituting into the PARM_DECL that
was representing it prior to going through fixup_template_parm.

2/ The non-type template parameter Indices, when passed to
template_parm_to_arg (indirectly called by current_template_args) is
wrapped into an argument pack containing the pack expansion of
Indices.

Normally, the wrapped form of Indices shouldn't escape
tsubst_pack_expansion; this function should detect it, figure out that
we are basically substituting the parameter pack Indices into itself
and do the right thing.

The problem in this PR is that 1/ makes it so that what the
representation of Indices that is wrapped in 2/ is not a PARM_DECL but
rather a TEMPLATE_PARM_INDEX.  But the code of tsubst_pack_expansion
was expecting a PARM_DECL in that wrapped form.

The patch below factorizes out the code (that detects the wrapped
form) from tsubst_pack_expansion, and expands it a little bit to make
it be aware of 1/ and 2/ combined.

Bootstrapped and tested on x86_64-unknown-linux-gnu against trunk.
I'll launch a bootstrap & test on 4.6 as well.

From: Dodji Seketeli   
Date: Mon, 12 Sep 2011 20:17:33 +0200
Subject: [PATCH] c++/48320 - Template parameter packs cannot be expanded in
 default template arguments

gcc/cp/

PR c++/48320
* pt.c (template_parameter_pack_p):  Support TEMPLATE_PARM_INDEX
nodes.  Add a comment.
(arg_from_parm_pack_p):  New static function, factorized out from
tsubst_pack_expansion and extended to support non-type parameter
packs represented with TEMPLATE_PARM_INDEX nodes.
(tsubst_pack_expansion): Use arg_from_parm_pack_p.

gcc/testsuite/

PR c++/48320
* g++.dg/cpp0x/variadic116.C: New test case.
---
 gcc/cp/pt.c  |  115 ++
 gcc/testsuite/g++.dg/cpp0x/variadic116.C |   32 
 2 files changed, 100 insertions(+), 47 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic116.C

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 9a5e3dd..1407364 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -203,6 +203,7 @@ static void append_type_to_template_for_access_check_1 
(tree, tree, tree,
 static tree listify (tree);
 static tree listify_autos (tree, tree);
 static tree template_parm_to_arg (tree t);
+static bool arg_from_parm_pack_p (tree, tree);
 static tree current_template_args (void);
 static tree fixup_template_type_parm_type (tree, int);
 static tree fixup_template_parm_index (tree, tree, int);
@@ -2741,12 +2742,15 @@ template_parameter_pack_p (const_tree parm)
   if (TREE_CODE (parm) == PARM_DECL)
 return (DECL_TEMPLATE_PARM_P (parm) 
 && TEMPLATE_PARM_PARAMETER_PACK (DECL_INITIAL (parm)));
+  if (TREE_CODE (parm) == TEMPLATE_PARM_INDEX)
+return TEMPLATE_PARM_PARAMETER_PACK (parm);
 
   /* If this is a list of template parameters, we could get a
  TYPE_DECL or a TEMPLATE_DECL.  */ 
   if (TREE_CODE (parm) == TYPE_DECL || TREE_CODE (parm) == TEMPLATE_DECL)
 parm = TREE_TYPE (parm);
 
+  /* Otherwise it must be a type template parameter.  */
   return ((TREE_CODE (parm) == TEMPLATE_TYPE_PARM
   || TREE_CODE (parm) == TEMPLATE_TEMPLATE_PARM)
  && TEMPLATE_TYPE_PARAMETER_PACK (parm));
@@ -4005,6 +4009,63 @@ template_parm_to_arg (tree t)
   return t;
 }
 
+/* This function returns TRUE if PARM_PACK is a template parameter
+   pack and if ARG_PACK is what template_parm_to_arg returned when
+   passed PARM_PACK.  */
+
+static bool
+arg_from_parm_pack_p (tree arg_pack, tree parm_pack)
+{
+  /* For clarity in the comments below let's use the representation
+ argument_pack' to denote an argument pack and its
+ elements.
+
+ In the 'if' block below, we want to detect cases where
+ ARG_PACK is argument_pack.  I.e, we want to
+ check if ARG_PACK is an argument pack which sole element is
+ the expansion of PARM_PACK.  That argument pack is typically
+ created by template_parm_to_arg when passed a parameter
+ pack.  */
+
+  if (arg_pack
+  && TREE_VEC_LENGTH (ARGUMENT_PACK_ARGS (arg_pack)) == 1
+  && PACK_EXPANSION_P (TREE_VEC_ELT (ARGUMENT_PACK_ARGS (arg_pack), 0)))
+{
+  tree expansion = TREE_VEC_ELT (ARGUMENT_PACK_ARGS (arg_pack), 0);
+  tree pattern = PACK_EXPANSION_PATTERN (expansion);
+  /* So we have an argument_pack.  We want to test if P
+is actually PARM_PACK.  We will not use cp_tree_equal to
+test P and PARM_PACK because during type fixup (by
+fixup_template_parm) P can be a pre-fixup version of a
+type

Re: [PATCH 2/7] Generate virtual locations for tokens

2011-09-12 Thread Jason Merrill

On 08/09/2011 10:54 AM, Dodji Seketeli wrote:

+  goto ftrack_macro_expansion_with_arg;
+
+case OPT_ftrack_macro_expansion_:
+ftrack_macro_expansion_with_arg:


Instead of the goto, just write /* Fall through.  */


+consumption if necessary. Value @samp{0} of @var{level} de-activates
+this option just as if no @option{-ftrack-macro-expansion} was present
+on the command line. Value @samp{1} tracks tokens locations in a
+degraded mode for the sake of minimal memory overhead. In this mode
+all tokens resulting from the expansion of an argument of a
+function-like macro have the same location. Value @samp{2} tracks
+tokens locations completely. This value is the most memory hungry. It
+is the default value.


"It is the default value" sounds to me like no -ftrack-macro-expansion 
option is equivalent to -ftrack-macro-expansion=2, rather than =0.



+ expansion of arguments of function-like macro. all macro
+ expansion. 2 Means we do track all macro expansions. This last


Seems like the "all macro expansion" is left over from a previous 
version of this sentence.



+/* This describes some additional data that is added to the macro
+   token context of type cpp_context, when -ftrack-macro-expansion is
+   on.  */
+typedef struct
+{
+  /* The node of the macro we are referring to.  */
+  cpp_hashnode *macro_node;
+  /* This buffer contains an array of virtual locations.  The virtual
+ location at index 0 is the virtual location of the token at index
+ 0 in the current instance of cpp_context; similarly for all the
+ other virtual locations.  */
+  source_location *virt_locs;
+  /* This is a pointer to the current virtual location.  This is used
+ to iterate over the virtual locations while we iterate over the
+ tokens they belong to.  */
+  source_location *cur_virt_loc;
+} macro_context;


Why track virtual locations separately rather than use them directly as 
the src_loc of the tokens?


Jason


[Patch,AVR]: Fix PR 50358

2011-09-12 Thread Georg-Johann Lay
This patch introduces patterns for multiply-add and multiply-sub.

On the enhanced core, these operations can be performed with the product in R0;
there is no need to MOVW it out of that register.  The code is smaller and
faster and has lower register pressure.

Tested without regressions.

Ok to commit?

Johann

PR target/50358
* config/avr/predicates.md (const_1_to_6_operand): New predicate.
* config/avr/avr.md: (extend_s): New code attribute.
(mul_r_d): New code attribute.
(*maddqihi4, *umaddqihi4): New insns.
(*msubqihi4, *umsubqihi4): New insns.
(*usmaddqihi4, *sumaddqihi4): New insns.
(*usmsubqihi4, *susubdqihi4): New insns.
(*umaddqihi4.uconst, *maddqihi4.sconst): New insn-and-splits.
(*umsubqihi4.uconst, *msubqihi4.sconst): New insn-and-splits.
(*umsubqihi4.uconst.ashift): New insn-and-split.
(*msubqihi4.sconst.ashift): New insn-and-split.
(*sumaddqihi4.uconst): New insn-and-split.
(*sumsubqihi4.uconst): New insn-and-split.
* config/avr/avr.c (avr_rtx_costs): Report costs of above in cases
PLUS:HI and MINUS:HI.
Index: config/avr/predicates.md
===
--- config/avr/predicates.md	(revision 178734)
+++ config/avr/predicates.md	(working copy)
@@ -78,6 +78,11 @@ (define_predicate "const_2_to_7_operand"
   (and (match_code "const_int")
(match_test "IN_RANGE (INTVAL (op), 2, 7)")))
 
+;; Return 1 if OP is constant integer 1..6 for MODE.
+(define_predicate "const_1_to_6_operand"
+  (and (match_code "const_int")
+   (match_test "IN_RANGE (INTVAL (op), 1, 6)")))
+
 ;; Return 1 if OP is constant integer 2..6 for MODE.
 (define_predicate "const_2_to_6_operand"
   (and (match_code "const_int")
Index: config/avr/avr.md
===
--- config/avr/avr.md	(revision 178734)
+++ config/avr/avr.md	(working copy)
@@ -150,6 +150,15 @@ (define_code_attr extend_u
   [(sign_extend "")
(zero_extend "u")])
 
+(define_code_attr extend_s
+  [(sign_extend "s")
+   (zero_extend "")])
+
+;; Constrain input operand of widening multiply, i.e. MUL resp. MULS.
+(define_code_attr mul_r_d
+  [(zero_extend "r")
+   (sign_extend "d")])
+
 
 ;;
 ;; The following is used by nonlocal_goto and setjmp.
@@ -1128,6 +1137,267 @@ (define_insn "*oumulqihi3"
   [(set_attr "length" "4")
(set_attr "cc" "clobber")])
 
+;**
+; multiply-add/sub HI: $0 = $3 +/- $1*$2  with 8-bit values $1, $2
+;**
+
+;; We don't use standard insns/expanders as they lead to cumbersome code for,
+;; e.g,
+;;
+;; int foo (unsigned char z)
+;; {
+;;   extern int aInt[];
+;;   return aInt[3*z+2];
+;; }
+;;
+;; because the constant +4 then is added explicitely instead of consuming it
+;; with the aInt symbol.  Therefore, we rely on insn combine which takes costs
+;; into account more accurately and doesn't do burte-force multiply-add/sub.
+;; The implementational effort is the same so we are fine with that approach.
+
+
+;; "*maddqihi4"
+;; "*umaddqihi4"
+(define_insn "*maddqihi4"
+  [(set (match_operand:HI 0 "register_operand"  "=r")
+(plus:HI (mult:HI (any_extend:HI (match_operand:QI 1 "register_operand" ""))
+  (any_extend:HI (match_operand:QI 2 "register_operand" "")))
+ (match_operand:HI 3 "register_operand" "0")))]
+  
+  "AVR_HAVE_MUL"
+  "mul %1,%2
+	add %A0,r0
+	adc %B0,r1
+	clr __zero_reg__"
+  [(set_attr "length" "4")
+   (set_attr "cc" "clobber")])
+
+;; "*msubqihi4"
+;; "*umsubqihi4"
+(define_insn "*msubqihi4"
+  [(set (match_operand:HI 0 "register_operand"  "=r")
+(minus:HI (match_operand:HI 3 "register_operand" "0")
+  (mult:HI (any_extend:HI (match_operand:QI 1 "register_operand" ""))
+   (any_extend:HI (match_operand:QI 2 "register_operand" "")]
+  "AVR_HAVE_MUL"
+  "mul %1,%2
+	sub %A0,r0
+	sbc %B0,r1
+	clr __zero_reg__"
+  [(set_attr "length" "4")
+   (set_attr "cc" "clobber")])
+
+;; "*usmaddqihi4"
+;; "*sumaddqihi4"
+(define_insn "*msubqihi4"
+  [(set (match_operand:HI 0 "register_operand"  "=r")
+(plus:HI (mult:HI (any_extend:HI  (match_operand:QI 1 "register_operand" "a"))
+  (any_extend2:HI (match_operand:QI 2 "register_operand" "a")))
+ (match_operand:HI 3 "register_operand"  "0")))]
+  "AVR_HAVE_MUL
+   && reload_completed
+   &&  != "
+  {
+output_asm_insn ( == SIGN_EXTEND
+ ? "mulsu %1,%2" : "mulsu %2,%1", operands);

Re: [PATCH, rs6000] Preserve link stack for 476 cpus

2011-09-12 Thread David Edelsohn
On Mon, Sep 12, 2011 at 12:07 PM, Peter Bergner  wrote:
> The Power ISA declares the "bcl 20,31,..." instruction as the preferred
> idiom for obtaining the next instruction address (NIA), which we use for
> computing the address of the GOT.  This special branch and link is *not*
> a subroutine call, meaning it won't be paired with a blr (subroutine return).
> Processors therefore are not supposed to update their internal link stack
> when executing one of this instructions, otherwise we'll mispredict the
> following blrs.
>
> The 476 processor has an bug where it doesn't ignore these "bcl 20,31,..."
> instructions, so we end up getting lots of mispredicts for -fPIC code.
> The following patch adds a -mpreserve-link-stack option that is enabled
> automatically for -mtune={476,476fp}, that changes the two types of GOT
> access code GCC produces.  The new code replaces the "bcl 20,31,..." with
> a "bl..., b..., blr" triplet.  I've included some old versus new code
> snipits for both types of GOT access code to illustrate how the code
> has changed.
>
>
> 1)      Normal Code:                            New 476 Code:
> ==
>
>        bcl 20,31,$+4                           bl $+8
> .L3:                                    .L3:
>                                                b $+8
>                                                blr
>        mflr 9                                  mflr 9
>        addis 9,9,.LCTOC1-.L3@ha                addis 9,9,.LCTOC1-.L3@ha
>        addi 9,9,.LCTOC1-.L3@l                  addi 9,9,.LCTOC1-.L3@l
>
>
>
> 2)      Normal Code:                            New 476 Code:
> ==
>
>        bcl 20,31,$+8                           bl $+12
>        .long _GLOBAL_OFFSET_TABLE_-$           b $+12
>                                                .long _GLOBAL_OFFSET_TABLE_-$
>                                                blr
>        mflr 9                                  mflr 9
>                                                addi 9,9,4
>        lwz 3,0(9)                              lwz 3,0(9)
>
>
> I have bootstrapped and regtested the following patch with no regressiosn.
> To test the code even more, I modified the patch so that we default to always
> using -mpreserve-link-stack and that bootstrapped and regtested with no
> regressions too.
>
> Ok for mainline?
>
> Peter
>
>
>        * config/rs6000/rs6000.opt (mpreserve-link-stack): New option.
>        * config/rs6000/rs6000.c (rs6000_option_override_internal): Enable
>        TARGET_LINK_STACK for -mtune=476 and -mtune=476fp.
>        (rs6000_legitimize_tls_address): Emit the link stack preserving GOT
>        code if TARGET_LINK_STACK.
>        (rs6000_emit_load_toc_table): Likewise.
>        (output_function_profiler): Likewise
>        (macho_branch_islands): Likewise
>        (machopic_output_stub): Likewise
>        * config/rs6000/rs6000.md (load_toc_v4_PIC_1, load_toc_v4_PIC_1b):
>        Convert to a define_expand.
>        (load_toc_v4_PIC_1_normal): New define_insn.
>        (load_toc_v4_PIC_1_476): Likewise.
>        (load_toc_v4_PIC_1b_normal): Likewise.
>        (load_toc_v4_PIC_1b_476): Likewise.

First, please choose a more informative option name.
-mpreserve-link-stack seems like something generally useful for all
processors and someone may randomly add the option.  It always is
useful to preserve the link stack -- that's why you're jumping through
hoops to fix this bug.  Maybe -mpreserve-ppc476-link-stack .

I would prefer that this patch were maintained by the chip vendors
distributing SDKs for PPC476 instead of complicating the FSF codebase.

Otherwise, please implement this like Xilinx FPU in rs6000.opt,
rs6000.h, ppc476.h and config.gcc where TARGET_LINK_STACK is defined
as 0 unless GCC explicitly is configured for powerpc476.

Thanks, David


Re: Add unwind information to mips epilogues

2011-09-12 Thread Richard Sandiford
Bernd Schmidt  writes:
> On 09/11/11 11:03, Richard Sandiford wrote:
>> Richard Sandiford  writes:
>>> I think I need to play around with it a bit before I understand enough
>>> to review.  I'll try to find time this weekend.
>> 
>> Does the attached patch look OK?  It should fix a couple of things.
>
> Sure!

Thanks, applied, along with the fix for mips16e argument saves.

Richard


Re: [PATCH] Fix -fno-dwarf2-cfi-asm bootstrap (PR bootstrap/50010)

2011-09-12 Thread Bernd Schmidt
On 09/12/11 17:13, Jakub Jelinek wrote:
> dwarf2cfi.c generates sometimes different .eh_frame with/without
> -fvar-tracking-assignments.  The problem is that in add_cfis_to_fde
> when adding NOTE_INSN_CFI_LABEL notes there is a scan to find consecutive
> NOTE_INSN_CFI notes, but if there are any var-tracking notes in between,
> more labels are emitted.  And apparently the assembler doesn't optimize
> zero length DW_CFA_advance_loc* ops away.
> While only skipping NOTE_INSN_VAR_LOCATION and NOTE_INSN_CALL_ARG_LOCATION
> would be enough to fix the comparison failures, I think we can skip any
> non-active_insn_p's (except for NOTE_INSN_SWTICH_TEXT_SECTION which we need
> to handle earlier in the loop).

> 2011-09-12  Jakub Jelinek  
> 
>   PR bootstrap/50010
>   * dwarf2cfi.c (add_cfis_to_fde): Ignore non-active insns in between
>   NOTE_INSN_CFI notes, with the exception of
>   NOTE_INSN_SWITCH_TEXT_SECTIONS.

Ok.


Bernd


C++ PATCH to handling of template conversion functions

2011-09-12 Thread Jason Merrill
This was another change that I needed to make to fix the deduction issue 
mentioned in my previous mail, and brought my attention to an existing 
bug.  When considering a template conversion function we don't want to 
allow derived-to-base conversions, but we should still allow 
qualification conversions.  This patch fixes the latter, and gives a 
more helpful diagnostic for the former.


Tested x86_64-pc-linux-gnu, applying to trunk.
commit eeb8627ed5d62c93d015c58e6e0e2958fe833f47
Author: Jason Merrill 
Date:   Fri Sep 9 15:14:54 2011 -0400

	* pt.c (type_unification_real): Fix handling of DEDUCE_CONV
	with no deducible template parameters.
	* call.c (rejection_reason_code): Add rr_template_conversion.
	(print_z_candidate): Handle it.
	(template_conversion_rejection): New.
	(build_user_type_conversion_1): Use it.

diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index a97e8c7..81df80e 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -432,6 +432,7 @@ enum rejection_reason_code {
   rr_none,
   rr_arity,
   rr_explicit_conversion,
+  rr_template_conversion,
   rr_arg_conversion,
   rr_bad_arg_conversion,
   rr_template_unification,
@@ -654,6 +655,16 @@ explicit_conversion_rejection (tree from, tree to)
 }
 
 static struct rejection_reason *
+template_conversion_rejection (tree from, tree to)
+{
+  struct rejection_reason *r = alloc_rejection (rr_template_conversion);
+  r->u.conversion.n_arg = 0;
+  r->u.conversion.from_type = from;
+  r->u.conversion.to_type = to;
+  return r;
+}
+
+static struct rejection_reason *
 template_unification_rejection (tree tmpl, tree explicit_targs, tree targs,
 const tree *args, unsigned int nargs,
 tree return_type, unification_kind_t strict,
@@ -3135,6 +3146,12 @@ print_z_candidate (const char *msgstr, struct z_candidate *candidate)
 		  "conversion", r->u.conversion.from_type,
 		  r->u.conversion.to_type);
 	  break;
+	case rr_template_conversion:
+	  inform (loc, "  conversion from return type %qT of template "
+		  "conversion function specialization to %qT is not an "
+		  "exact match", r->u.conversion.from_type,
+		  r->u.conversion.to_type);
+	  break;
 	case rr_template_unification:
 	  /* We use template_unification_error_rejection if unification caused
 	 actual non-SFINAE errors, in which case we don't need to repeat
@@ -3495,6 +3512,16 @@ build_user_type_conversion_1 (tree totype, tree expr, int flags)
 		= bad_arg_conversion_rejection (NULL_TREE, -1,
 		rettype, totype);
 	}
+	  else if (primary_template_instantiation_p (cand->fn)
+		   && ics->rank > cr_exact)
+	{
+	  /* 13.3.3.1.2: If the user-defined conversion is specified by
+		 a specialization of a conversion function template, the
+		 second standard conversion sequence shall have exact match
+		 rank.  */
+	  cand->viable = -1;
+	  cand->reason = template_conversion_rejection (rettype, totype);
+	}
 	}
 }
 
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index d326c84..9a5e3dd 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -14709,10 +14709,18 @@ type_unification_real (tree tparms,
 
 	  if (same_type_p (parm, type))
 	continue;
-	  if (strict != DEDUCE_EXACT
-	  && can_convert_arg (parm, type, TYPE_P (arg) ? NULL_TREE : arg,
-  flags))
-	continue;
+	  if (strict == DEDUCE_CONV)
+	{
+	  if (can_convert_arg (type, parm, NULL_TREE, flags))
+		continue;
+	}
+	  else if (strict != DEDUCE_EXACT)
+	{
+	  if (can_convert_arg (parm, type,
+   TYPE_P (arg) ? NULL_TREE : arg,
+   flags))
+		continue;
+	}
 
 	  if (strict == DEDUCE_EXACT)
 	return unify_type_mismatch (explain_p, parm, arg);
diff --git a/gcc/testsuite/g++.dg/cpp0x/fntmpdefarg2.C b/gcc/testsuite/g++.dg/cpp0x/fntmpdefarg2.C
index 12cc836..d94843c 100644
--- a/gcc/testsuite/g++.dg/cpp0x/fntmpdefarg2.C
+++ b/gcc/testsuite/g++.dg/cpp0x/fntmpdefarg2.C
@@ -4,11 +4,21 @@
 struct B { };
 struct D : B { };
 struct A {
-  template operator D&();
+  template operator D&(); // { dg-message "template conversion" }
   operator long();
 };
 
 void f(long);
 void f(B&);
 
-int main() { f(A()); }
+struct A2 {
+  template operator B&();
+};
+
+void f2(const B&);
+
+int main() {
+  f(A());
+  f2(A2());
+  f2(A());			// { dg-error "" }
+}


Sequence of C++ PATCHes to C++11 reference semantics

2011-09-12 Thread Jason Merrill
While debugging a template deduction change that I didn't end up making, 
I fell down a rabbit hole into issues with our handling of C++11 
reference semantics.  Most of these changes are less necessary without 
the deduction change, but there is still a minor bug fix here, and I've 
been meaning to clean up this stuff for a while now.


1) reference_binding wasn't handling xvalues (what you get from e.g. a 
function returning an rvalue reference) properly.  I fixed 
LOOKUP_NO_TEMP_BIND to not apply to xvalues, and fixed rvalue reference 
binding to respect it.  Then I realized that the rules for ?: 
conversions are stricter, requiring actual lvalue/lvalue match rather 
than just direct binding, so I had to add LOOKUP_NO_RVAL_BIND as well.


2) For some reason we weren't passing the LOOKUP flags down through the 
reference binding functions.  This change isn't necessary without the 
deduction change, but seems correct.


3) We had two separate functions doing the same thing: 
build_user_type_conversion_1 and convert_class_to_reference_1.  This led 
to bugs from changes being made in one place and not the other.  I've 
fixed this by discarding the reference-specific function.  This change 
required change #1 above.


4) As a result of #3 we started rejecting explicit conversion functions 
that would require a further conversion of greater than exact match rank 
to the reference type being initialized.  This seems correct to me even 
though the standard doesn't say that yet.  I had to change some things 
around a bit to get a helpful error message for this case.


Tested x86_64-pc-linux-gnu, applying to trunk.
commit 68b5d5b940586209465340a1a6f20d80db2f1c8a
Author: Jason Merrill 
Date:   Fri Sep 9 15:12:59 2011 -0400

	* cp-tree.h (LOOKUP_NO_RVAL_BIND): New.
	* call.c (conditional_conversion): Use it.
	(reference_binding): Fix handling of xvalues.

diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 62bee2d..81c8a90 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -1564,7 +1564,8 @@ reference_binding (tree rto, tree rfrom, tree expr, bool c_cast_p, int flags)
   tree tfrom;
   bool related_p;
   bool compatible_p;
-  cp_lvalue_kind is_lvalue = clk_none;
+  cp_lvalue_kind gl_kind;
+  bool is_lvalue;
 
   if (TREE_CODE (to) == FUNCTION_TYPE && expr && type_unknown_p (expr))
 {
@@ -1574,14 +1575,6 @@ reference_binding (tree rto, tree rfrom, tree expr, bool c_cast_p, int flags)
   from = TREE_TYPE (expr);
 }
 
-  if (TREE_CODE (from) == REFERENCE_TYPE)
-{
-  from = TREE_TYPE (from);
-  if (!TYPE_REF_IS_RVALUE (rfrom)
-	  || TREE_CODE (from) == FUNCTION_TYPE)
-	is_lvalue = clk_ordinary;
-}
-
   if (expr && BRACE_ENCLOSED_INITIALIZER_P (expr))
 {
   maybe_warn_cpp0x (CPP0X_INITIALIZER_LISTS);
@@ -1597,11 +1590,28 @@ reference_binding (tree rto, tree rfrom, tree expr, bool c_cast_p, int flags)
 	}
 }
 
-  if (is_lvalue == clk_none && expr)
-is_lvalue = real_lvalue_p (expr);
+  if (TREE_CODE (from) == REFERENCE_TYPE)
+{
+  from = TREE_TYPE (from);
+  if (!TYPE_REF_IS_RVALUE (rfrom)
+	  || TREE_CODE (from) == FUNCTION_TYPE)
+	gl_kind = clk_ordinary;
+  else
+	gl_kind = clk_rvalueref;
+}
+  else if (expr)
+{
+  gl_kind = lvalue_kind (expr);
+  if (gl_kind & clk_class)
+	/* A class prvalue is not a glvalue.  */
+	gl_kind = clk_none;
+}
+  else
+gl_kind = clk_none;
+  is_lvalue = gl_kind && !(gl_kind & clk_rvalueref);
 
   tfrom = from;
-  if ((is_lvalue & clk_bitfield) != 0)
+  if ((gl_kind & clk_bitfield) != 0)
 tfrom = unlowered_expr_type (expr);
 
   /* Figure out whether or not the types are reference-related and
@@ -1619,16 +1629,16 @@ reference_binding (tree rto, tree rfrom, tree expr, bool c_cast_p, int flags)
  the reference and expression is an lvalue. In DR391, the wording in
  [8.5.3/5 dcl.init.ref] is changed to also require direct bindings for
  const and rvalue references to rvalues of compatible class type.
- We should also do direct bindings for non-class "rvalues" derived from
- rvalue references.  */
+ We should also do direct bindings for non-class xvalues.  */
   if (compatible_p
   && (is_lvalue
 	  || (((CP_TYPE_CONST_NON_VOLATILE_P (to)
-		&& !(flags & LOOKUP_NO_TEMP_BIND))
+		&& !(flags & LOOKUP_NO_RVAL_BIND))
 	   || TYPE_REF_IS_RVALUE (rto))
-	  && (CLASS_TYPE_P (from)
-		  || TREE_CODE (from) == ARRAY_TYPE
-		  || (expr && lvalue_p (expr))
+	  && (gl_kind
+		  || (!(flags & LOOKUP_NO_TEMP_BIND)
+		  && (CLASS_TYPE_P (from)
+			  || TREE_CODE (from) == ARRAY_TYPE))
 {
   /* [dcl.init.ref]
 
@@ -1661,8 +1671,8 @@ reference_binding (tree rto, tree rfrom, tree expr, bool c_cast_p, int flags)
 	conv->rvaluedness_matches_p 
   = (TYPE_REF_IS_RVALUE (rto) == !is_lvalue);
 
-  if ((is_lvalue & clk_bitfield) != 0
-	  || ((is_lvalue & clk_packed) != 0 && !TYPE_PACKED (to)))
+  if ((gl_kind & clk_bitfield) != 0
+	  || ((gl_kind & cl

Trivial C++ PATCH to implicit_conversion

2011-09-12 Thread Jason Merrill
While looking at something else I noticed that the middle test here can 
be much more expensive than the third if the type isn't complete yet, so 
I reordered them.  This shouldn't have a significant effect on any code, 
but seemed like an improvement.


Tested x86_64-pc-linux-gnu, applying to trunk.
commit 540cc1799744041f96fb15b9eea9ec9793725d1d
Author: Jason Merrill 
Date:   Thu Sep 8 10:52:03 2011 -0400

	* call.c (implicit_conversion): Check BRACE_ENCLOSED_INITIALIZER_P
	before forcing instantiation.

diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index c707d66..62bee2d 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -1848,8 +1848,8 @@ implicit_conversion (tree to, tree from, tree expr, bool c_cast_p,
 |LOOKUP_NO_NARROWING));
 
   if (CLASS_TYPE_P (to)
-	  && !CLASSTYPE_NON_AGGREGATE (complete_type (to))
-	  && BRACE_ENCLOSED_INITIALIZER_P (expr))
+	  && BRACE_ENCLOSED_INITIALIZER_P (expr)
+	  && !CLASSTYPE_NON_AGGREGATE (complete_type (to)))
 	return build_aggr_conv (to, expr, flags);
 
   cand = build_user_type_conversion_1 (to, expr, convflags);


Re: [PATCH, ARM] Support NEON's VABD with combine pass

2011-09-12 Thread Ramana Radhakrishnan
On 12 September 2011 17:11, Dmitry Melnik  wrote:
>
>> Interesting but I would be a bit defensive and make sure that this
>> matches only if -ffast-math in the FP case. You are sort of relying on
>> the fact that vsub wouldn't be generated without ffast-math but I'd
>> rather be defensive about it . (This is in case it's not clear in the
>> non-intrinsics case).
>
> Fixed.
>>
>> BTW was SPEC2k built with -Ofast ? Maybe then you'll see a bit of
>> vectorization.
>
> Yes, I built it with -Ofast. I think it's because SPEC2K tests mostly use
> doubles, which are not supported by vabd.

OK.

cheers
Ramana


Re: [PLUGIN] Fix PLUGIN_FINISH_TYPE

2011-09-12 Thread Dodji Seketeli
Romain Geissler  a écrit:

> I just checked again, and PLUGIN_FINISH_DECL is triggered for a
> typedef in C mode, but not in C++ mode. I'll patch that.

Correct.  This is because the event is emitted at the end of
cp_finish_decl, but that function has many return points.  Maybe
unifying all the those return points by replacing them with "goto out;"
and adding an "out" label right at the end, before emitting the event.

> When i recontributed the PLUGIN_FINISH_DECL patch from the original
> Brian Hackett, i didn't exactly checked  what may or may not trigger
> this new event. I know for example that declaring a function triggers
> this event, but defining it does not.
>
> I don't really know when those event should be triggered, we should
> clarify the meaning of those.
>
> According to me:
> PLUGIN_FINISH_DECL should be triggered anytime the parser parse a
> declaration (which includes declaration + definition of function,
> typedef definition, namespaces, ..., all DECL_P trees built by the
> parser).

The general idea sounds sensible, IMHO.  However, we must keep in mind
that there are cases like, e.g, 'struct C;' where G++ creates a typedef
'typedef struct C C;' so that you can name that type 'C' instead of
having to type "struct C' all the time.  For these cases, I don't think
the PLUGIN_FINISH_DECL event should be emitted.

> For, PLUGIN_FINISH_TYPE i don't really know it means a new type
> declaration (or declaration + definition) or if it means usage of a
> type (in a function prototype, the type of a local variable.

I'd say it's a definition of a new type, IMHO.

> I would rather vote for new type definition (including typedefs)

My understanding is that a typedef declaration doesn't define a new
type.  Rather, it declares an alias for an existing type.  As such, I
would think that notifying typedef declarations via PLUGIN_FINISH_DECL
would be the way to go.

> but for special cases of struct, you can declare and use them at the
> same time:

Just to be sure I understand, do you need to be notified about *uses* of
types and decls as well?  If so, maybe a new kind of event should
probably be defined, because PLUGIN_FINISH_DECL and PLUGIN_FINISH_TYPE
seem to have more to do with declaring/defining decls and types than
using them.

> So, what the real meaning of all those events ?

From plugin.def, I read:

 /* After finishing parsing a type.  */
 DEFEVENT (PLUGIN_FINISH_TYPE)

 /* After finishing parsing a declaration. */
 DEFEVENT (PLUGIN_FINISH_DECL)

I agree that's rather terse, but it doesn't seem to be related to the
use of the type/decls.

-- 
Dodji


Re: [PATCH, ARM] Support NEON's VABD with combine pass

2011-09-12 Thread Dmitry Melnik



Interesting but I would be a bit defensive and make sure that this
matches only if -ffast-math in the FP case. You are sort of relying on
the fact that vsub wouldn't be generated without ffast-math but I'd
rather be defensive about it . (This is in case it's not clear in the
non-intrinsics case).

Fixed.

BTW was SPEC2k built with -Ofast ? Maybe then you'll see a bit of vectorization.
Yes, I built it with -Ofast. I think it's because SPEC2K tests mostly 
use doubles, which are not supported by vabd.


--
Best regards,
   Dmitry
diff --git a/gcc/config/arm/neon.md b/gcc/config/arm/neon.md
index a8c1b87..aceb564 100644
--- a/gcc/config/arm/neon.md
+++ b/gcc/config/arm/neon.md
@@ -5607,3 +5607,32 @@
   emit_insn (gen_neon_vec_pack_trunc_ (operands[0], tempreg));
   DONE;
 })
+
+(define_insn "neon_vabd_2"
+ [(set (match_operand:VDQ 0 "s_register_operand" "=w")
+   (abs:VDQ (minus:VDQ (match_operand:VDQ 1 "s_register_operand" "w")
+   (match_operand:VDQ 2 "s_register_operand" "w"]
+ "TARGET_NEON && (! || flag_unsafe_math_optimizations)"
+ "vabd. %0, %1, %2"
+ [(set (attr "neon_type")
+   (if_then_else (ne (symbol_ref "") (const_int 0))
+ (if_then_else (ne (symbol_ref "") (const_int 0))
+   (const_string "neon_fp_vadd_ddd_vabs_dd")
+   (const_string "neon_fp_vadd_qqq_vabs_qq"))
+ (const_string "neon_int_5")))]
+)
+
+(define_insn "neon_vabd_3"
+ [(set (match_operand:VDQ 0 "s_register_operand" "=w")
+   (abs:VDQ (unspec:VDQ [(match_operand:VDQ 1 "s_register_operand" "w")
+ (match_operand:VDQ 2 "s_register_operand" "w")]
+ UNSPEC_VSUB)))]
+ "TARGET_NEON && (! || flag_unsafe_math_optimizations)"
+ "vabd. %0, %1, %2"
+ [(set (attr "neon_type")
+   (if_then_else (ne (symbol_ref "") (const_int 0))
+ (if_then_else (ne (symbol_ref "") (const_int 0))
+   (const_string "neon_fp_vadd_ddd_vabs_dd")
+   (const_string "neon_fp_vadd_qqq_vabs_qq"))
+ (const_string "neon_int_5")))]
+)
diff --git a/gcc/testsuite/gcc.target/arm/neon-combine-sub-abs-into-vabd.c b/gcc/testsuite/gcc.target/arm/neon-combine-sub-abs-into-vabd.c
new file mode 100644
index 000..ad6ba75
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arm/neon-combine-sub-abs-into-vabd.c
@@ -0,0 +1,50 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target arm_neon_ok } */
+/* { dg-options "-O2 -funsafe-math-optimizations" } */
+/* { dg-add-options arm_neon } */
+
+#include 
+float32x2_t f_sub_abs_to_vabd_32()
+{
+  float32x2_t val1 = vdup_n_f32 (10);
+  float32x2_t val2 = vdup_n_f32 (30);
+  float32x2_t sres = vsub_f32(val1, val2);
+  float32x2_t res = vabs_f32 (sres);
+
+  return res;
+}
+/* { dg-final { scan-assembler "vabd\.f32" } }*/
+
+#include 
+int8x8_t sub_abs_to_vabd_8()
+{
+  int8x8_t val1 = vdup_n_s8 (10);
+  int8x8_t val2 = vdup_n_s8 (30);
+  int8x8_t sres = vsub_s8(val1, val2);
+  int8x8_t res = vabs_s8 (sres);
+
+  return res;
+}
+/* { dg-final { scan-assembler "vabd\.s8" } }*/
+
+int16x4_t sub_abs_to_vabd_16()
+{
+  int16x4_t val1 = vdup_n_s16 (10);
+  int16x4_t val2 = vdup_n_s16 (30);
+  int16x4_t sres = vsub_s16(val1, val2);
+  int16x4_t res = vabs_s16 (sres);
+
+  return res;
+}
+/* { dg-final { scan-assembler "vabd\.s16" } }*/
+
+int32x2_t sub_abs_to_vabd_32()
+{
+  int32x2_t val1 = vdup_n_s32 (10);
+  int32x2_t val2 = vdup_n_s32 (30);
+  int32x2_t sres = vsub_s32(val1, val2);
+  int32x2_t res = vabs_s32 (sres);
+
+   return res;
+}
+/* { dg-final { scan-assembler "vabd\.s32" } }*/


[PATCH, rs6000] Preserve link stack for 476 cpus

2011-09-12 Thread Peter Bergner
The Power ISA declares the "bcl 20,31,..." instruction as the preferred
idiom for obtaining the next instruction address (NIA), which we use for
computing the address of the GOT.  This special branch and link is *not*
a subroutine call, meaning it won't be paired with a blr (subroutine return).  
Processors therefore are not supposed to update their internal link stack
when executing one of this instructions, otherwise we'll mispredict the
following blrs.

The 476 processor has an bug where it doesn't ignore these "bcl 20,31,..."
instructions, so we end up getting lots of mispredicts for -fPIC code.
The following patch adds a -mpreserve-link-stack option that is enabled
automatically for -mtune={476,476fp}, that changes the two types of GOT
access code GCC produces.  The new code replaces the "bcl 20,31,..." with
a "bl..., b..., blr" triplet.  I've included some old versus new code
snipits for both types of GOT access code to illustrate how the code
has changed.


1)  Normal Code:New 476 Code:
==

bcl 20,31,$+4   bl $+8
.L3:.L3:
b $+8
blr
mflr 9  mflr 9
addis 9,9,.LCTOC1-.L3@haaddis 9,9,.LCTOC1-.L3@ha
addi 9,9,.LCTOC1-.L3@l  addi 9,9,.LCTOC1-.L3@l



2)  Normal Code:New 476 Code:
==

bcl 20,31,$+8   bl $+12
.long _GLOBAL_OFFSET_TABLE_-$   b $+12
.long _GLOBAL_OFFSET_TABLE_-$
blr
mflr 9  mflr 9
addi 9,9,4
lwz 3,0(9)  lwz 3,0(9)


I have bootstrapped and regtested the following patch with no regressiosn.
To test the code even more, I modified the patch so that we default to always
using -mpreserve-link-stack and that bootstrapped and regtested with no
regressions too.

Ok for mainline?

Peter


* config/rs6000/rs6000.opt (mpreserve-link-stack): New option.
* config/rs6000/rs6000.c (rs6000_option_override_internal): Enable
TARGET_LINK_STACK for -mtune=476 and -mtune=476fp.
(rs6000_legitimize_tls_address): Emit the link stack preserving GOT
code if TARGET_LINK_STACK.
(rs6000_emit_load_toc_table): Likewise.
(output_function_profiler): Likewise
(macho_branch_islands): Likewise
(machopic_output_stub): Likewise
* config/rs6000/rs6000.md (load_toc_v4_PIC_1, load_toc_v4_PIC_1b):
Convert to a define_expand.
(load_toc_v4_PIC_1_normal): New define_insn.
(load_toc_v4_PIC_1_476): Likewise.
(load_toc_v4_PIC_1b_normal): Likewise.
(load_toc_v4_PIC_1b_476): Likewise.


Index: gcc/config/rs6000/rs6000.opt
===
--- gcc/config/rs6000/rs6000.opt(revision 176007)
+++ gcc/config/rs6000/rs6000.opt(working copy)
@@ -528,3 +528,7 @@ Use/do not use r11 to hold the static li
 msave-toc-indirect
 Target Undocumented Var(TARGET_SAVE_TOC_INDIRECT) Save Init(1)
 ; Control whether we save the TOC in the prologue for indirect calls or 
generate the save inline
+
+mpreserve-link-stack
+Target Report Var(TARGET_LINK_STACK) Init(-1) Save
+Preserve the link stack on some cpus (eg, 476) by matching up a blr with the 
bcl/bl insns used for GOT accesses
Index: gcc/config/rs6000/rs6000.c
===
--- gcc/config/rs6000/rs6000.c  (revision 176007)
+++ gcc/config/rs6000/rs6000.c  (working copy)
@@ -3246,6 +3246,11 @@ rs6000_option_override_internal (bool gl
 target_option_default_node = target_option_current_node
   = build_target_option_node ();
 
+  /* If not explicitly specified via option, decide whether to generate the
+ extra blr's required to preserve the link stack on some cpus (eg, 476).  
*/
+  if (TARGET_LINK_STACK == -1)
+TARGET_LINK_STACK = (rs6000_cpu == PROCESSOR_PPC476);
+
   return ret;
 }
 
@@ -5930,6 +5935,8 @@ rs6000_legitimize_tls_address (rtx addr,
  lab = gen_label_rtx ();
  emit_insn (gen_load_toc_v4_PIC_1b (gsym, lab));
  emit_move_insn (tmp1, gen_rtx_REG (Pmode, LR_REGNO));
+ if (TARGET_LINK_STACK)
+   emit_insn (gen_addsi3 (tmp1, tmp1, GEN_INT (4)));
  emit_move_insn (tmp2, mem);
  last = emit_insn (gen_addsi3 (got, tmp1, tmp2));
  set_unique_reg_note (last, REG_EQUAL, gsym);
@@ -18927,6 +18934,8 @@ rs6000_emi

Re: Patch ping

2011-09-12 Thread Jeff Law

On 09/12/2011 09:18 AM, Jakub Jelinek wrote:

Hi!

I'd like to ping two patches of mine:

http://gcc.gnu.org/ml/gcc-patches/2011-08/msg02385.html
   - PR rtl-optimization/50212
 fix EH ICE with -freorder-blocks-and-partition
Seems OK.  Though I did wonder why we were deleting the label and 
whether or not that was an indication that there was another suitable 
label in the insn stream that should be used instead.  Assuming you 
verified that is not the case, then this patch is OK.





http://gcc.gnu.org/ml/gcc-patches/2011-09/msg00386.html
   - PR debug/50299
 addition original argument mode to
 CALL_INSN_FUNCTION_USAGE to fix up call site debug info

OK
jeff


Re: [PLUGIN] Fix PLUGIN_FINISH_TYPE

2011-09-12 Thread Romain Geissler
Hi,

2011/9/12 Dodji Seketeli :
> Hello Romain,
>
> Romain Geissler  a écrit:
>
>> This patch solves some lacks with the PLUGIN_FINISH_TYPE event
>> triggering. For now, both C and C++ parser won't trigger it for enums or
>> for typedef.
>
> AFAICT, typedef declarations are reported by the PLUGIN_FINISH_DECL
> event.  The predicate is_typedef_decl then returns TRUE when passed the
> decl carried by the event.  Maybe the plugin's documentation could use
> an addendum for this.

I just checked again, and PLUGIN_FINISH_DECL is triggered for a
typedef in C mode, but not in C++ mode. I'll patch that.
When i recontributed the PLUGIN_FINISH_DECL patch from the original
Brian Hackett, i didn't exactly checked  what may or may not trigger
this new event. I know for example that declaring a function triggers
this event, but defining it does not.

I don't really know when those event should be triggered, we should
clarify the meaning of those.

According to me:
PLUGIN_FINISH_DECL should be triggered anytime the parser parse a
declaration (which includes declaration + definition of function,
typedef definition, namespaces, ..., all DECL_P trees built by the
parser).
For, PLUGIN_FINISH_TYPE i don't really know it means a new type
declaration (or declaration + definition) or if it means usage of a
type (in a function prototype, the type of a local variable. I would
rather vote for new type definition (including typedefs) but for
special cases of struct, you can declare and use them at the same
time:

#include 

struct my_struct x;
struct my_struct *my_function ();

struct my_struct {
  int field_1;
  int field_2;
};

struct my_struct *my_function () {
>---return NULL;
}

which GCC accepts even with -pedantic.

That's why in this patch i launch a PLUGIN_FINISH_TYPE event every
time the parser meet the "struct" keyword.


So, what the real meaning of all those events ?

>
> [...]
>
>> gcc/cp/
>> 2011-09-12  Romain Geissler  
>>
>>       * decl.c (grokdeclarator): Trigger PLUGIN_FINISH_TYPE for typedefs.
>
> [...]
>
>> Index: gcc/cp/decl.c
>> ===
>> --- gcc/cp/decl.c     (revision 178252)
>> +++ gcc/cp/decl.c     (working copy)
>> @@ -9682,6 +9682,9 @@ grokdeclarator (const cp_declarator *dec
>>                     memfn_quals != TYPE_UNQUALIFIED,
>>                     inlinep, friendp, raises != NULL_TREE);
>>
>> +      if (TREE_TYPE (decl) != error_mark_node && !DECL_ARTIFICIAL (decl))
>> +        invoke_plugin_callbacks (PLUGIN_FINISH_TYPE, decl);
>> +
>>        return decl;
>>      }
>>
>
> So I think this change is not necessary.
>
> [...]
>
>
>> Index: gcc/testsuite/gcc.dg/plugin/dumb-plugin-test-1.c
>> ===
>> --- gcc/testsuite/gcc.dg/plugin/dumb-plugin-test-1.c  (revision 0)
>> +++ gcc/testsuite/gcc.dg/plugin/dumb-plugin-test-1.c  (revision 0)
>> @@ -0,0 +1,56 @@
>> +// Test case for the dumb plugin.
>> +// { dg-do compile }
>> +// { dg-options "-O -fplugin-arg-dumb_plugin-ref-pass-name=ccp 
>> -fplugin-arg-dumb_plugin-ref-pass-instance-num=1" }
>> +
>
> Here, it would be nice to add a comment saying which plugin acts on this
> plugin's test and what the plugin does (what the output is supposed to
> be).  That redundant information eases the review, at very least.

Ok

>
> Thanks.
>
> --
>                Dodji
>


[lra] patch to solve code size regression on ppc32 SPEC2000

2011-09-12 Thread Vladimir Makarov
The following patch fixes ppc32 code size regression on SPEC2000.  I 
already posted an analogous patch


http://gcc.gnu.org/ml/gcc-patches/2011-08/msg02208.html

but it resulted in wrong code generation on x86.  The original patch was 
reworked to fix the x86 code generation.  To do this, classes with 
constraints '*' are made more costly.  This is different from reload 
approach which ignores such constraint.  I believe taking the constraint 
into account will help to make LRA more stable to order of alternatives 
in the insn descriptions making them more descriptive.


The patch was successfully bootstrapped on x86/x86-64 and ppc32.

2011-09-12  Vladimir Makarov 

* lra-constraints.c (best_reload_nregs): New variable.
(process_alt_operands): Add heuristics based on number regs
involved in relaods and based on '*' constraints.  Increase reject
for all failed non registers.
(curr_insn_transform, lra_inheritance): Formatting.

* lra-eliminations.c (mark_not_eliminable): Add check on hard
register before looping on eliminations.

Index: lra-constraints.c
===
--- lra-constraints.c   (revision 178737)
+++ lra-constraints.c   (working copy)
@@ -270,7 +270,8 @@ init_curr_insn_input_reloads (void)
NEW_CLASS.  Print info about it using TITLE.  Output a new line if
NL_P.  */
 static void
-change_class (int regno, enum reg_class new_class, const char *title, bool 
nl_p)
+change_class (int regno, enum reg_class new_class,
+ const char *title, bool nl_p)
 {
   int curr_regno;
 
@@ -1143,6 +1144,10 @@ static int best_losers, best_overall;
 /* Number of small register classes used for operands of the best
alternative.  */
 static int best_small_class_operands_num;
+/* Overall number hard registers used for reloads.  For example, on
+   some targets we need 2 general registers to reload DFmode and only
+   one floating point register.  */
+static int best_reload_nregs;
 /* Overall number reflecting distances of previous reloading the same
value.  It is used to improve inheritance chances.  */
 static int best_reload_sum;
@@ -1415,7 +1420,9 @@ process_alt_operands (int only_alternati
   rtx no_subreg_operand[MAX_RECOG_OPERANDS], operand_reg[MAX_RECOG_OPERANDS];
   int hard_regno[MAX_RECOG_OPERANDS];
   enum machine_mode biggest_mode[MAX_RECOG_OPERANDS];
-  int reload_sum;
+  int reload_nregs, reload_sum;
+  bool costly_p;
+  enum reg_class cl;
 
   /* Calculate some data common for all alternatives to speed up the
  function.  */
@@ -1460,7 +1467,7 @@ process_alt_operands (int only_alternati
  (only_alternative >= 0 && nalt != only_alternative))
continue;
 
-  overall = losers = reject = reload_sum = 0;
+  overall = losers = reject = reload_nregs = reload_sum = 0;
   for (nop = 0; nop < n_operands; nop++)
reject += (curr_static_id
   ->operand_alternative[nalt * n_operands + nop].reject);
@@ -1481,8 +1488,8 @@ process_alt_operands (int only_alternati
  /* False if a constant forced into memory would be OK for
 this operand.  */
  bool constmemok;
- enum reg_class this_alternative;
- HARD_REG_SET this_alternative_set;
+ enum reg_class this_alternative, this_costly_alternative;
+ HARD_REG_SET this_alternative_set, this_costly_alternative_set;
  bool this_alternative_match_win, this_alternative_win;
  bool this_alternative_offmemok;
  int invalidate_m;
@@ -1510,13 +1517,14 @@ process_alt_operands (int only_alternati
  early_clobber_p = false;
  p = curr_static_id->operand_alternative[opalt_num].constraint;
   
- this_alternative = NO_REGS;
+ this_costly_alternative = this_alternative = NO_REGS;
  /* We update set of possible hard regs besides its class
 because reg class might be inaccurate.  For example,
 union of LO_REGS (l), HI_REGS(h), and STACK_REG(k) in ARM
 is translated in HI_REGS because classes are merged by
 pairs and there is no accurate intermediate class.  */
  CLEAR_HARD_REG_SET (this_alternative_set);
+ CLEAR_HARD_REG_SET (this_costly_alternative_set);
  this_alternative_win = false;
  this_alternative_match_win = false;
  this_alternative_offmemok = false;
@@ -1534,349 +1542,378 @@ process_alt_operands (int only_alternati
 letter after reloads, or set WINREG if this operand could
 fit after reloads provided the constraint allows some
 registers.  */
-  
+ costly_p = false;
  do
-   switch ((c = *p, len = CONSTRAINT_LEN (c, p)), c)
- {
- case '\0':
-   len = 0;
-   break;
- case ',':
-   c = '\0';
-   break;
-   
- case '=':  case '+':  ca

Patch ping

2011-09-12 Thread Jakub Jelinek
Hi!

I'd like to ping two patches of mine:

http://gcc.gnu.org/ml/gcc-patches/2011-08/msg02385.html
  - PR rtl-optimization/50212
fix EH ICE with -freorder-blocks-and-partition

http://gcc.gnu.org/ml/gcc-patches/2011-09/msg00386.html
  - PR debug/50299
addition original argument mode to
CALL_INSN_FUNCTION_USAGE to fix up call site debug info

Jakub


[PATCH] Fix -fno-dwarf2-cfi-asm bootstrap (PR bootstrap/50010)

2011-09-12 Thread Jakub Jelinek
Hi!

dwarf2cfi.c generates sometimes different .eh_frame with/without
-fvar-tracking-assignments.  The problem is that in add_cfis_to_fde
when adding NOTE_INSN_CFI_LABEL notes there is a scan to find consecutive
NOTE_INSN_CFI notes, but if there are any var-tracking notes in between,
more labels are emitted.  And apparently the assembler doesn't optimize
zero length DW_CFA_advance_loc* ops away.
While only skipping NOTE_INSN_VAR_LOCATION and NOTE_INSN_CALL_ARG_LOCATION
would be enough to fix the comparison failures, I think we can skip any
non-active_insn_p's (except for NOTE_INSN_SWTICH_TEXT_SECTION which we need
to handle earlier in the loop).

Bootstrapped/regtested on x86_64-linux and i686-linux, additionally tested
with bootstrap/regtest on i586-linux with -fno-dwarf2-asm-cfi in *C*FLAGS
during bootstrapping (which before this patch failed for me).
Ok for trunk?

2011-09-12  Jakub Jelinek  

PR bootstrap/50010
* dwarf2cfi.c (add_cfis_to_fde): Ignore non-active insns in between
NOTE_INSN_CFI notes, with the exception of
NOTE_INSN_SWITCH_TEXT_SECTIONS.

--- gcc/dwarf2cfi.c.jj  2011-08-22 08:17:08.0 +0200
+++ gcc/dwarf2cfi.c 2011-09-12 10:32:46.0 +0200
@@ -2153,11 +2153,18 @@ add_cfis_to_fde (void)
   if (NOTE_P (insn) && NOTE_KIND (insn) == NOTE_INSN_CFI)
{
  bool required = cfi_label_required_p (NOTE_CFI (insn));
- while (next && NOTE_P (next) && NOTE_KIND (next) == NOTE_INSN_CFI)
-   {
- required |= cfi_label_required_p (NOTE_CFI (next));
+ while (next)
+   if (NOTE_P (next) && NOTE_KIND (next) == NOTE_INSN_CFI)
+ {
+   required |= cfi_label_required_p (NOTE_CFI (next));
+   next = NEXT_INSN (next);
+ }
+   else if (active_insn_p (next)
+|| (NOTE_P (next) && (NOTE_KIND (next)
+  == NOTE_INSN_SWITCH_TEXT_SECTIONS)))
+ break;
+   else
  next = NEXT_INSN (next);
-   }
  if (required)
{
  int num = dwarf2out_cfi_label_num;
@@ -2178,7 +2185,9 @@ add_cfis_to_fde (void)
 
  do
{
- VEC_safe_push (dw_cfi_ref, gc, fde->dw_fde_cfi, NOTE_CFI (insn));
+ if (NOTE_P (insn) && NOTE_KIND (insn) == NOTE_INSN_CFI)
+   VEC_safe_push (dw_cfi_ref, gc, fde->dw_fde_cfi,
+  NOTE_CFI (insn));
  insn = NEXT_INSN (insn);
}
  while (insn != next);

Jakub


Re: [PLUGIN] Fix PLUGIN_FINISH_TYPE

2011-09-12 Thread Dodji Seketeli
Hello Romain,

Romain Geissler  a écrit:

> This patch solves some lacks with the PLUGIN_FINISH_TYPE event
> triggering. For now, both C and C++ parser won't trigger it for enums or
> for typedef.

AFAICT, typedef declarations are reported by the PLUGIN_FINISH_DECL
event.  The predicate is_typedef_decl then returns TRUE when passed the
decl carried by the event.  Maybe the plugin's documentation could use
an addendum for this.

[...]

> gcc/cp/
> 2011-09-12  Romain Geissler  
>
>   * decl.c (grokdeclarator): Trigger PLUGIN_FINISH_TYPE for typedefs.

[...]

> Index: gcc/cp/decl.c
> ===
> --- gcc/cp/decl.c (revision 178252)
> +++ gcc/cp/decl.c (working copy)
> @@ -9682,6 +9682,9 @@ grokdeclarator (const cp_declarator *dec
> memfn_quals != TYPE_UNQUALIFIED,
> inlinep, friendp, raises != NULL_TREE);
>  
> +  if (TREE_TYPE (decl) != error_mark_node && !DECL_ARTIFICIAL (decl))
> +invoke_plugin_callbacks (PLUGIN_FINISH_TYPE, decl);
> +
>return decl;
>  }
>  

So I think this change is not necessary.

[...]


> Index: gcc/testsuite/gcc.dg/plugin/dumb-plugin-test-1.c
> ===
> --- gcc/testsuite/gcc.dg/plugin/dumb-plugin-test-1.c  (revision 0)
> +++ gcc/testsuite/gcc.dg/plugin/dumb-plugin-test-1.c  (revision 0)
> @@ -0,0 +1,56 @@
> +// Test case for the dumb plugin.
> +// { dg-do compile }
> +// { dg-options "-O -fplugin-arg-dumb_plugin-ref-pass-name=ccp 
> -fplugin-arg-dumb_plugin-ref-pass-instance-num=1" }
> +

Here, it would be nice to add a comment saying which plugin acts on this
plugin's test and what the plugin does (what the output is supposed to
be).  That redundant information eases the review, at very least.

Thanks.

-- 
Dodji


Re: [pph] Remove XPASS noise from pph testsuite (issue4967063)

2011-09-12 Thread Gabriel Charette
Oops forgot to reply all...

On Mon, Sep 12, 2011 at 7:40 AM, Diego Novillo  wrote:
> This patch removes all the XPASS noise from pph.exp runs by pruning
> the output from the base compiles (thanks Ian for the pointer).  It
> add some comments as well.
>
> Lawrence, I noticed that we do not seem to need -I. -fno-dwarf2-cfi-asm
> anymore.  So, I removed them.  I'm not sure I remember exactly why you
> had added them, but since removing them produces no changes to the
> results, I just took them out.

This was a hack because Lawrence was getting different asm checksums
for the pph asm xdiff because his configuration would output some
additional dwarf2-cfi assembly. Thus, no single expected diff checksum
would work for both of us.

Cheers,
Gab


Re: [pph] Do not read pph files more than once (issue4983055)

2011-09-12 Thread Gabriel Charette
Oops forgot to reply all the first time...

On Fri, Sep 9, 2011 at 4:54 PM, Diego Novillo  wrote:
> This was not causing any failures, but it is pretty wasteful to read
> the same PPH more than once.
>
> We cannot just skip them, however.  We need to read the line table to
> properly modify the line table for the current translation unit.

I don't think that's right. If the header is not re-read (i.e. ifdef
guarded out), it should not show in the line_table either. I think you
simply want to do this check at the top of pph_read_file itself.

>
>  /* Read PPH file FILENAME.  Return the in-memory pph_stream instance.  */
>
> -pph_stream *
> +void
>  pph_read_file (const char *filename)
>  {
>   pph_stream *stream;
> @@ -1667,7 +1696,7 @@ pph_read_file (const char *filename)
>   else
> error ("Cannot open PPH file for reading: %s: %m", filename);
>
> -  return stream;
> +  pph_add_read_image (stream);
>  }

This needs to be after the check for an already read image I think
(having it here wouldn't create test failures, but would create
duplicate entries for skipped headers (as right now they are still
added to pph_read_images when skipped I think)).

Cheers!,
Gab

On Fri, Sep 9, 2011 at 4:54 PM, Diego Novillo  wrote:
> This was not causing any failures, but it is pretty wasteful to read
> the same PPH more than once.
>
> We cannot just skip them, however.  We need to read the line table to
> properly modify the line table for the current translation unit.
>
> Tested on x86_64.  Committed to branch.
>
>
> Diego.
>
>
>        * pph-streamer-in.c (pph_image_already_read): New.
>        (pph_read_file_1): Call pph_image_already_read.  If it returns
>        true, return after reading the line table.
>        (pph_add_read_image): New.
>        (pph_read_file): Change return value to void.  Update all callers.
>        Call pph_add_read_image.
>        * pph-streamer-out.c (pph_add_include): Remove second argument.
>        Update all callers.
>        Do not add INCLUDE to pph_read_images.
>        * pph-streamer.h (pph_add_include): Update prototype.
>
> diff --git a/gcc/cp/pph-streamer-in.c b/gcc/cp/pph-streamer-in.c
> index b111850..ea44460 100644
> --- a/gcc/cp/pph-streamer-in.c
> +++ b/gcc/cp/pph-streamer-in.c
> @@ -1462,7 +1462,6 @@ pph_in_include (pph_stream *stream)
>  {
>   int old_loc_offset;
>   const char *include_name;
> -  pph_stream *include;
>   source_location prev_start_loc = pph_in_source_location (stream);
>
>   /* Simulate highest_location to be as it would be at this point in a non-pph
> @@ -1475,8 +1474,7 @@ pph_in_include (pph_stream *stream)
>   old_loc_offset = pph_loc_offset;
>
>   include_name = pph_in_string (stream);
> -  include = pph_read_file (include_name);
> -  pph_add_include (include, false);
> +  pph_read_file (include_name);
>
>   pph_loc_offset = old_loc_offset;
>  }
> @@ -1583,6 +1581,23 @@ pph_in_line_table_and_includes (pph_stream *stream)
>  }
>
>
> +/* If FILENAME has already been read, return the stream associated with it.  
> */
> +
> +static pph_stream *
> +pph_image_already_read (const char *filename)
> +{
> +  pph_stream *include;
> +  unsigned i;
> +
> +  /* FIXME pph, implement a hash map to avoid this linear search.  */
> +  FOR_EACH_VEC_ELT (pph_stream_ptr, pph_read_images, i, include)
> +    if (strcmp (include->name, filename) == 0)
> +      return include;
> +
> +  return NULL;
> +}
> +
> +
>  /* Helper for pph_read_file.  Read contents of PPH file in STREAM.  */
>
>  static void
> @@ -1605,6 +1620,11 @@ pph_read_file_1 (pph_stream *stream)
>      read.  */
>   cpp_token_replay_loc = pph_in_line_table_and_includes (stream);
>
> +  /* If we have read STREAM before, we do not need to re-read the rest
> +     of its body.  We only needed to read its line table.  */
> +  if (pph_image_already_read (stream->name))
> +    return;
> +
>   /* Read all the identifiers and pre-processor symbols in the global
>      namespace.  */
>   pph_in_identifiers (stream, &idents_used);
> @@ -1650,13 +1670,22 @@ pph_read_file_1 (pph_stream *stream)
>      STREAM will need to be read again the next time we want to read
>      the image we are now generating.  */
>   if (pph_out_file && !pph_reading_includes)
> -    pph_add_include (stream, true);
> +    pph_add_include (stream);
> +}
> +
> +
> +/* Add STREAM to the list of read images.  */
> +
> +static void
> +pph_add_read_image (pph_stream *stream)
> +{
> +  VEC_safe_push (pph_stream_ptr, heap, pph_read_images, stream);
>  }
>
>
>  /* Read PPH file FILENAME.  Return the in-memory pph_stream instance.  */
>
> -pph_stream *
> +void
>  pph_read_file (const char *filename)
>  {
>   pph_stream *stream;
> @@ -1667,7 +1696,7 @@ pph_read_file (const char *filename)
>   else
>     error ("Cannot open PPH file for reading: %s: %m", filename);
>
> -  return stream;
> +  pph_add_read_image (stream);
>  }
>
>
> diff --git a/gcc/cp/pph-streamer-out.c b/gcc/cp/pph-streamer-out.c
> index 264294c..1a32814 100644
> --- a/gcc/cp/pph-streamer

Re: Add unwind information to mips epilogues

2011-09-12 Thread Bernd Schmidt
On 09/11/11 11:03, Richard Sandiford wrote:
> Richard Sandiford  writes:
>> I think I need to play around with it a bit before I understand enough
>> to review.  I'll try to find time this weekend.
> 
> Does the attached patch look OK?  It should fix a couple of things.

Sure!


Bernd



Re: [pph] Fix method lookups (part 1) (issue4997042)

2011-09-12 Thread Diego Novillo
On Sat, Sep 10, 2011 at 11:30, Gabriel Charette  wrote:
> On Fri, Sep 9, 2011 at 4:37 PM, Diego Novillo  wrote:
>>
>> The main problem fixed here is that name lookups for class methods
>> uses a binary search that assumes that the methods in
>> CLASSTYPE_METHOD_VEC are sorted by pointer value.
>>
>> Since the reader typically allocates trees in a different pattern than
>> the writer, it is common for the symbols in the vector to have
>> different pointer values, so the order used by the writer is different
>> than the reader.
>>
>> This was causing us to fail name lookups when generating the pph image
>> for x6dynarray5.h and x6dynarray6.h.
>>
>> To fix this, I am making finish_struct_methods an extern function and
>> calling it after reading a type that has a CLASSTYPE_METHOD_VEC.
>>
>> This exposed another failure that was simple enough to roll in
>> together with this patch.  We should not emit preloaded symbols when
>> writing the names in the global namespace.  This was causing a
>> DECL_CHAIN cycle.  I added a new filter PPHF_NO_PREFS to skip the
>> preloaded symbols when needed.
>>
>
> The loop in the DECL_CHAIN in x6dynarray5 was already there before.
> This is why I had introduced the preloaded cache to do something along
> those lines.
>
> However I don't think simply filtering it out is sufficient in this
> case.

It is for this case.  But you are right that it isn't for state
mutations like the one you describe later.  I'm trying to fix this by
detecting state changes between read-time and write-time.  I'm
thinking of checksumming the input tree and create a merge record when
we notice that the tree has mutated during write.  We would only
checksum the input when generating PPH images, so this would never
slow down the reader.

> Anyways, just can't help it, but keep reading all the patches coming in :)!

Heh.  I can send you the copyright assignments for you to fill out.
Don't think you can escape so easily ;)


Diego.


Re: [PATCH] Fix up call_site_parameter (PR debug/50299)

2011-09-12 Thread Richard Sandiford
Jakub Jelinek  writes:
> 2011-09-06  Jakub Jelinek  
>
>   PR debug/50299
>   * calls.c (load_register_parameters): Use use_reg_mode instead
>   of use_reg when adding a single register CALL_INSN_FUNCTION_USAGE
>   entry.
>   (expand_call): Set EXPR_LIST mode to TYPE_MODE of the argument
>   for stack CALL_INSN_FUNCTION_USAGE uses.
>   * expr.h (use_reg_mode): New prototype.
>   (use_reg): Changed into inline around use_reg_mode.
>   * expr.c (use_reg): Renamed to...
>   (use_reg_mode): ... this.  Added MODE argument, set EXPR_LIST
>   mode to that mode instead of VOIDmode.
>   * var-tracking.c (prepare_call_arguments): Don't track parameters
>   whose EXPR_LIST mode is VOIDmode, BLKmode or X mode isn't convertible
>   to it using lowpart_subreg.  Convert VALUE and REG/MEM to the
>   EXPR_LIST mode.

Looks good to me FWIW, but I can't approve it.

Richard


Re: [PATCH, SMS] Minor misc. fixes

2011-09-12 Thread Revital Eres
Hello,

> OK.
> While we're at it, an alternative would be to have
> remove_node_from_ps() assert its own (parameters and) return value.
> That is, replace "if (c) return false" by "assert (!c)" and have it
> return void if successful. There's not much you can do if it returns
> false. That would check its other invocation too.

OK, that's indeed seems reasonable.
The attached patch implements it.
Will commit it after re-testing completes if there is not objection.

Thanks,
Revital

Changelog:

   modulo-sched.c (remove_node_from_ps): Return void instead of bool.
(optimize_sc): Adjust call to remove_node_from_ps.
(sms_schedule): Add print info.
Index: modulo-sched.c
===
--- modulo-sched.c  (revision 178755)
+++ modulo-sched.c  (working copy)
@@ -211,7 +211,7 @@ static int get_sched_window (partial_sch
 static bool try_scheduling_node_in_cycle (partial_schedule_ptr, ddg_node_ptr,
  int, int, sbitmap, int *, sbitmap,
  sbitmap);
-static bool remove_node_from_ps (partial_schedule_ptr, ps_insn_ptr);
+static void remove_node_from_ps (partial_schedule_ptr, ps_insn_ptr);
 
 #define SCHED_ASAP(x) (((node_sched_params_ptr)(x)->aux.info)->asap)
 #define SCHED_TIME(x) (((node_sched_params_ptr)(x)->aux.info)->time)
@@ -834,8 +834,7 @@ optimize_sc (partial_schedule_ptr ps, dd
if (next_ps_i->node->cuid == g->closing_branch->cuid)
  break;
 
-  gcc_assert (next_ps_i);
-  gcc_assert (remove_node_from_ps (ps, next_ps_i));
+  remove_node_from_ps (ps, next_ps_i);
   success =
try_scheduling_node_in_cycle (ps, g->closing_branch,
  g->closing_branch->cuid, c,
@@ -1485,8 +1484,8 @@ sms_schedule (void)
   if (dump_file)
 {
  fprintf (dump_file,
-  "SMS succeeded %d %d (with ii, sc)\n", ps->ii,
-  stage_count);
+  "%s:%d SMS succeeded %d %d (with ii, sc)\n",
+  insn_file (tail), insn_line (tail), ps->ii, stage_count);
  print_partial_schedule (ps, dump_file);
}
  
@@ -2719,22 +2718,18 @@ create_ps_insn (ddg_node_ptr node, int c
 }
 
 
-/* Removes the given PS_INSN from the partial schedule.  Returns false if the
-   node is not found in the partial schedule, else returns true.  */
-static bool
+/* Removes the given PS_INSN from the partial schedule.  */  
+static void 
 remove_node_from_ps (partial_schedule_ptr ps, ps_insn_ptr ps_i)
 {
   int row;
 
-  if (!ps || !ps_i)
-return false;
-
+  gcc_assert (ps && ps_i);
+  
   row = SMODULO (ps_i->cycle, ps->ii);
   if (! ps_i->prev_in_row)
 {
-  if (ps_i != ps->rows[row])
-   return false;
-
+  gcc_assert (ps_i == ps->rows[row]);
   ps->rows[row] = ps_i->next_in_row;
   if (ps->rows[row])
ps->rows[row]->prev_in_row = NULL;
@@ -2748,7 +2743,7 @@ remove_node_from_ps (partial_schedule_pt

   ps->rows_length[row] -= 1; 
   free (ps_i);
-  return true;
+  return;
 }
 
 /* Unlike what literature describes for modulo scheduling (which focuses


[pph] Remove XPASS noise from pph testsuite (issue4967063)

2011-09-12 Thread Diego Novillo
This patch removes all the XPASS noise from pph.exp runs by pruning
the output from the base compiles (thanks Ian for the pointer).  It
add some comments as well.

Lawrence, I noticed that we do not seem to need -I. -fno-dwarf2-cfi-asm 
anymore.  So, I removed them.  I'm not sure I remember exactly why you
had added them, but since removing them produces no changes to the
results, I just took them out.

No need for filtering out results anymore; make check should produce
no extraneous XPASS output anymore.

Tested on x86_64.  Committed to branch.


Diego.

* lib/dg-pph.exp (dg-pph-pos): Do not compile base cases with
dg-test.  Use g++-dg-test and g++-dg-prune to build base cases.

diff --git a/gcc/testsuite/lib/dg-pph.exp b/gcc/testsuite/lib/dg-pph.exp
index 08c01da..3573fba 100644
--- a/gcc/testsuite/lib/dg-pph.exp
+++ b/gcc/testsuite/lib/dg-pph.exp
@@ -19,6 +19,7 @@
 
 load_lib copy-file.exp
 
+# Generate a PPH image from a header file.
 proc dg-pph-hdr { subdir test options mapflag suffix } {
 
 global runtests dg-do-what-default
@@ -40,6 +41,8 @@ proc dg-pph-hdr { subdir test options mapflag suffix } {
 }
 }
 
+# Run a negative PPH test.  These tests are expected to produce an error
+# as they represent files that are not compatible with PPH.
 proc dg-pph-neg { subdir test options mapflag suffix } {
 
 global runtests dg-do-what-default
@@ -61,6 +64,11 @@ proc dg-pph-neg { subdir test options mapflag suffix } {
 }
 }
 
+# Run a positive PPH test (a test expected to work with PPH).  Tests not
+# marked 'dg-do run' or 'dg-do link' are compiled twice.  The first time
+# with PPH disabled, the second time with PPH enabled.  The assembly
+# output from both compiles is then compared.  The test succeeds if both
+# assembly outputs are identical.
 proc dg-pph-pos { subdir test options mapflag suffix } {
 
 global runtests dg-do-what-default
@@ -70,14 +78,11 @@ proc dg-pph-pos { subdir test options mapflag suffix } {
return
 }
 
+set dg-do-what-default compile
 set nshort "$subdir/[file tail $test]"
 set bname "[file rootname [file tail $nshort]]"
 verbose -log "\nTesting $nshort, $options"
 
-# Compile the file the first time for a base case.
-set dg-do-what-default compile
-dg-test -keep-output $test "$options -I. -fno-dwarf2-cfi-asm" ""
-
 # Determine whether this is an assembly comparison test
 set is_exec [llength [grep $test "dg-do run"]]
 set is_link [llength [grep $test "dg-do link"]]
@@ -88,11 +93,31 @@ proc dg-pph-pos { subdir test options mapflag suffix } {
 }
 
 if { $is_asm } {
+   # Compile the file the first time for a base case.
+   global target_triplet
+
+   # First, gather additional options specified by the test.
+   set all_dg_options [dg-get-options $test]
+   set other_options ""
+   foreach dg_option $all_dg_options {
+   set cmd [lindex $dg_option 0]
+   if { [string match "dg-options" $cmd] } {
+   set other_options "$other_options [lindex $dg_option 2]"
+   }
+   }
+
+   # Now, compile the file but prune the result to avoid considering
+   # it part of the testsuite.  We just want to compile it to provide
+   # a base assembly output to compare against.
+   set comp_output [g++-dg-test $test compile "$options $other_options"]
+   set comp_output [g++-dg-prune $target_triplet $comp_output]
+
# Wanted assembly, so quit if it did not compile successfully.
if { ![file_on_host exists "$bname.s"] } {
fail "$nshort $options (regular assembly missing)"
return
}
+
# Rename the .s file into .s-pph to compare it after the second build.
remote_upload host "$bname.s" "$bname.s-pph"
remote_download host "$bname.s-pph"
@@ -101,8 +126,8 @@ proc dg-pph-pos { subdir test options mapflag suffix } {
 
 verbose -log ""
 
-# Compile a second time using the pph files.
-dg-test -keep-output $test "$options $mapflag -I. -fno-dwarf2-cfi-asm" ""
+# Compile a second time using the PPH files.
+dg-test -keep-output $test "$options $mapflag" ""
 
 if { !$is_asm } {
# No assembly means we cannot compare them,
@@ -131,6 +156,7 @@ proc dg-pph-pos { subdir test options mapflag suffix } {
 # In most tests, they should be identical.
 # Tests involving overload injection and such will have different assembly.
 set adiff [catch {exec diff "$bname.s-pph" "$bname.s+pph"} diff_result]
+
 # The sources mark when they expect the comparison to differ.
 # When marked with xdiff, the difference is a problem.
 # When marked with xwant, the difference is what we want.

--
This patch is available for review at http://codereview.appspot.com/4967063


Re: [wwwdocs] Revamp the news section on our title page

2011-09-12 Thread Gerald Pfeifer
This patchlet did not make it from my test environment to the patch
I committed for production for some reason.  Fixed thusly.

Gerald

Index: gcc.css
===
RCS file: /cvs/gcc/wwwdocs/htdocs/gcc.css,v
retrieving revision 1.24
diff -u -r1.24 gcc.css
--- gcc.css 12 Sep 2011 00:08:49 -  1.24
+++ gcc.css 12 Sep 2011 09:41:05 -
@@ -17,7 +17,7 @@
 dl.news  { margin-top:0; }
 dl.news dt   { color:darkslategrey; font-weight:bold; margin-top:0.3em; }
 dl.news dd   { margin-left:3ex; margin-top:0.1em; margin-bottom:0.1em; }
-dl.news .date { color:darkslategrey; margin-left:0.1ex; }
+dl.news .date { color:darkslategrey; font-size:90%; margin-left:0.1ex; }
 
 dl.status{ margin-top:0; }
 dl.status .version { font-weight:bold; }


Re: ARM: Emit conditions in push_multi

2011-09-12 Thread Jakub Jelinek
Hi!

This last hunk is wrong, for sprintf you need to use %% instead of %.

On Wed, Sep 07, 2011 at 09:23:36PM +0200, Bernd Schmidt wrote:
> @@ -10631,7 +10633,7 @@ (define_insn "*push_fp_multi"
>{
>  char pattern[100];
>  
> -sprintf (pattern, \"sfmfd\\t%%1, %d, [%%m0]!\", XVECLEN (operands[2], 
> 0));
> +sprintf (pattern, \"sfm%(fd%)\\t%%1, %d, [%%m0]!\", XVECLEN 
> (operands[2], 0));
>  output_asm_insn (pattern, operands);
>  return \"\";
>}"

Committed as obvious:

2011-09-12  Jakub Jelinek  

PR bootstrap/50352
* config/arm/arm.md (*push_fp_multi): Add % before %( and %) in the
sprintf format string.

--- gcc/config/arm/arm.md   (revision 178777)
+++ gcc/config/arm/arm.md   (revision 178778)
@@ -10633,7 +10633,7 @@ (define_insn "*push_fp_multi"
   {
 char pattern[100];
 
-sprintf (pattern, \"sfm%(fd%)\\t%%1, %d, [%%m0]!\", XVECLEN (operands[2], 
0));
+sprintf (pattern, \"sfm%%(fd%%)\\t%%1, %d, [%%m0]!\", XVECLEN 
(operands[2], 0));
 output_asm_insn (pattern, operands);
 return \"\";
   }"

Jakub


[PLUGIN] Fix PLUGIN_FINISH_TYPE

2011-09-12 Thread Romain Geissler

Hi,

This patch solves some lacks with the PLUGIN_FINISH_TYPE event
triggering. For now, both C and C++ parser won't trigger it for enums or
for typedef. In C++, when a struct, class or union declaration is parsed
(without definition), the given event data is an error mark instead of
the parsed type node.

Bootstrapped and tested on x86_64.

Romain Geissler

gcc/
2011-09-12  Romain Geissler  

* c-decl.c (grokdeclarator): Trigger PLUGIN_FINISH_TYPE for typedefs.
* c-parser.c (cp_parser_type_specifier: Trigger PLUGIN_FINISH_TYPE for
enums.


gcc/cp/
2011-09-12  Romain Geissler  

* decl.c (grokdeclarator): Trigger PLUGIN_FINISH_TYPE for typedefs.
* parser.c (cp_parser_type_specifier: Trigger PLUGIN_FINISH_TYPE for
enums.
Correctly trigger PLUGIN_FINISH_TYPE for unions, structs or classes.


gcc/testsuite/
2011-09-12  Romain Geissler  

* gcc.dg/plugin/dumb-plugin-test-1.c: New File.
* gcc.dg/plugin/dumb_plugin.c: Likewise.
* gcc.dg/plugin/plugin.exp: Add above testcase.
* g++.dg/plugin/dumb-plugin-test-1.C: New tests.
* g++.dg/plugin/dumb_plugin.c (handle_type): Renamed from handle_struct.
Add warnings for all kind of types.
Index: gcc/testsuite/gcc.dg/plugin/dumb-plugin-test-1.c
===
--- gcc/testsuite/gcc.dg/plugin/dumb-plugin-test-1.c(revision 0)
+++ gcc/testsuite/gcc.dg/plugin/dumb-plugin-test-1.c(revision 0)
@@ -0,0 +1,56 @@
+// Test case for the dumb plugin.
+// { dg-do compile }
+// { dg-options "-O -fplugin-arg-dumb_plugin-ref-pass-name=ccp 
-fplugin-arg-dumb_plugin-ref-pass-instance-num=1" }
+
+struct my_struct {
+  int a_;
+  char b_;
+}; // { dg-warning "Process struct my_struct" }
+
+struct Bar; // { dg-warning "Process struct Bar" }
+struct Bar; // { dg-warning "Process struct Bar" }
+struct Bar {
+  int c_;
+  int d_;
+  struct my_struct e_; // { dg-warning "Process struct my_struct" }
+}; // { dg-warning "Process struct Bar" }
+
+union my_union; // { dg-warning "Process union my_union" }
+union my_union; // { dg-warning "Process union my_union" }
+union my_union {
+  int g_;
+  char h_;
+}; // { dg-warning "Process union my_union" }
+
+enum my_enum; // { dg-warning "Process enum my_enum" }
+enum my_enum; // { dg-warning "Process enum my_enum" }
+enum my_enum {
+  i_,
+  j_
+}; // { dg-warning "Process enum my_enum" }
+
+typedef int* my_typedef; // { dg-warning "Process typedef my_typedef" }
+
+int g = 2;
+
+int func()
+{
+  struct Bar *bar1, bar2; // { dg-warning "Process struct Bar" }
+  int x = x;
+  static int y = 6;
+  float *f;
+  struct Bar bar_array[5];  // { dg-warning "Process struct Bar" }
+  char n;
+  int overflow;
+
+  *f = *f;
+  bar1->c_ = bar1->c_;
+  bar2.d_ = bar2.d_;
+  bar_array[3].e_ = bar_array[3].e_;
+  bar_array[x+g].d_ = bar_array[x+g].d_;
+  y = x;
+  x = y;
+} // { dg-warning "Before genericizing function" }
+
+// { dg-warning "Analyze function" "" { target *-*-* } 53 }
+// {  dg-warning "End of compilation unit" "" { target *-*-* } 53 }
Index: gcc/testsuite/gcc.dg/plugin/dumb_plugin.c
===
--- gcc/testsuite/gcc.dg/plugin/dumb_plugin.c   (revision 0)
+++ gcc/testsuite/gcc.dg/plugin/dumb_plugin.c   (revision 0)
@@ -0,0 +1,160 @@
+/* A trivial (dumb) plugin example that shows how to use the GCC plugin
+   mechanism.  */
+
+#include "gcc-plugin.h"
+#include 
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "tree.h"
+#include "tree-pass.h"
+#include "intl.h"
+#include "toplev.h"
+#include "diagnostic.h"
+
+int plugin_is_GPL_compatible;
+
+/* Callback function to invoke after GCC finishes parsing a type.  */
+
+void
+handle_type (void *event_data, void *data)
+{
+  tree type = (tree) event_data;
+
+  switch (TREE_CODE (type)) {
+case RECORD_TYPE:
+  warning (0, G_("Process struct %s"),
+ IDENTIFIER_POINTER (TYPE_NAME (type)));
+  break;
+case UNION_TYPE:
+  warning (0, G_("Process union %s"),
+ IDENTIFIER_POINTER (TYPE_NAME (type)));
+  break;
+case ENUMERAL_TYPE:
+  warning (0, G_("Process enum %s"),
+ IDENTIFIER_POINTER (TYPE_NAME (type)));
+  break;
+case TYPE_DECL:
+  warning (0, G_("Process typedef %s"),
+ IDENTIFIER_POINTER (DECL_NAME (type)));
+  break;
+default:
+  error (G_("Unexpected tree node in PLUGIN_FINISH_TYPE %s\n"), 
tree_code_name [TREE_CODE (type)]);
+  }
+}
+
+/* Callback function to invoke before the function body is genericized.  */ 
+
+void
+handle_pre_generic (void *event_data, void *data)
+{
+  tree fndecl = (tree) event_data;
+  warning (0, G_("Before genericizing function %s"),
+   IDENTIFIER_POINTER (DECL_NAME (fndecl)));
+}
+
+/* Callback function to invoke after GCC finishes the compilation unit.  */
+
+void
+handle_end_of_compilation_unit (void *event_data, void *data)

Re: [wwwdocs] Document recent (and less recent) SPARC changes

2011-09-12 Thread Eric Botcazou
> (Well, to live up to my reviewer's reputation :-) and provide a
> nanonit, perhaps omit "and later"?)

Installed with this change, thanks.

-- 
Eric Botcazou