Re: [PATCH] Support -m{cpu,tune}=native on Linux/Sparc

2011-09-05 Thread Eric Botcazou
> 2011-09-04  David S. Miller  
>
>   * config.host: Add driver-sparc.o and sparc/x-sparc on
>   native sparc*-*-linux* builds.
>   * config/sparc/driver-sparc.c: Correct Linux strings.
>   * gcc/config/sparc/linux.h: Add DRIVER_SELF_SPECS.
>   * gcc/config/sparc/linux64.h: Likewise.
>   * gcc/doc/invoke.texi: Document that Linux also supports
>   -mcpu=native and -mtune=native on sparc.

Nice, thanks (superfluous gcc/ in the last 3 ChangeLog entries though).

-- 
Eric Botcazou


Re: [PATCH] Add niagara3 and niagara4 cpu types.

2011-09-05 Thread Eric Botcazou
> For now I schedule Niagara3 like Niagara2, and that's pretty accurate.
> Niagara4 will be a different beast scheduling wise, so I've left it
> out of the chips niagara2.md matches.
>
> 2011-09-04  David S. Miller  
>
>   * gcc/config/sparc/sparc-opts.h (PROCESSOR_NIAGARA3,
>   PROCESSOR_NIAGARA4): New.
>   * gcc/config/sparc/sparc.opt: Handle new processor types.
>   * gcc/config/sparc/sparc.md: Add to "cpu" attribute.
>   * gcc/config/sparc/sparc.h (TARGET_CPU_niagara3,
>   TARGET_CPU_niagara4): New, treat as niagara2.
>   * gcc/config/sparc/linux64.h: Handle niagara3 and niagara4
>   like niagara2.
>   * gcc/config/sparc/sol2.h: Likewise.
>   * gcc/config/sparc/niagara2.md: Schedule niagara3 like
>   niagara2.
>   * gcc/config/sparc/sparc.c (sparc_option_override): Add
>   niagara3 and niagara4 handling.
>   (sparc32_initialize_trampoline): Likewise.
>   (sparc64_initialize_trampoline): Likewise.
>   (sparc_use_sched_lookahead): Likewise.
>   (sparc_issue_rate): Likewise.
>   (sparc_register_move_cost): Likewise.
>   * gcc/config/sparc/driver-sparc.c (cpu_names): Use niagara3
>   and niagara4 as appropriate.
>   * gcc/doc/invoke.texi: Document new processor types.

Great, thanks (superfluous gcc/ in the ChangeLog).  No improvements to the 
SPARC port have been documented in http://gcc.gnu.org/gcc-4.7/changes.html 
yet, so I'm going to write something down.

-- 
Eric Botcazou


Re: [PATCH] Better comparison of BINFOs in IPA-CP

2011-09-05 Thread Jan Hubicka
> Hi,
> 
> the patch below improves the comparisons of BINFOs in IPA-CP.  The
> problem is that we can read different BINFOs for the same type (or a
> base type component) from the LTO summaries because BINFOs coming from
> different compilation units are not unified.  Because we now have the
> BINFO_VTABLE available, we can compare those instead since the VMT
> variables are unified.

Hmm, I was quite sure this is happening.  Can't you get an extra credit for 
unifying
the binfos at stream in?

Honza
> 
> Bootstrapped and tested on x86_64-linux, also tested by LTO-building
> Firefox and 483.xalancbmk on the same platform (I lost the actual
> numbers but the new test returned true hundreds of times in both
> these cases).  OK for trunk?
> 
> Thanks,
> 
> Martin
> 
> 
> 2011-09-02  Martin Jambor  
> 
>   * ipa-cp.c (values_equal_for_ipcp_p): When comparing BINFOs, compare
>   their BINFO_VTABLE,
> 
> Index: src/gcc/ipa-cp.c
> ===
> --- src.orig/gcc/ipa-cp.c
> +++ src/gcc/ipa-cp.c
> @@ -800,6 +800,33 @@ values_equal_for_ipcp_p (tree x, tree y)
>if (x == y)
>  return true;
>  
> +  if (TREE_CODE (x) == TREE_BINFO && TREE_CODE (y) == TREE_BINFO)
> +{
> +  unsigned HOST_WIDE_INT ox, oy;
> +  tree vx = BINFO_VTABLE (x);
> +  tree vy = BINFO_VTABLE (y);
> +
> +  if (!vx || !vy
> +   || TREE_CODE (vx) != POINTER_PLUS_EXPR
> +   || TREE_CODE (vy) != POINTER_PLUS_EXPR)
> + return false;
> +
> +  ox = tree_low_cst (TREE_OPERAND (vx, 1), 1);
> +  oy = tree_low_cst (TREE_OPERAND (vx, 1), 1);
> +
> +  if (ox != oy)
> + return false;
> +
> +  vx = TREE_OPERAND (vx, 0);
> +  vy = TREE_OPERAND (vy, 0);
> +  if (TREE_CODE (vx) != ADDR_EXPR
> +   || TREE_CODE (vy) != ADDR_EXPR)
> + return false;
> +
> +  if (TREE_OPERAND (vx, 0) == TREE_OPERAND (vy, 0))
> + return true;
> +}
> +
>if (TREE_CODE (x) == TREE_BINFO || TREE_CODE (y) == TREE_BINFO)
>  return false;
>  


Re: [PATCH] Remove bogus TYPE_IS_SIZETYPE special-casing in extract_muldiv_1

2011-09-05 Thread Richard Guenther
On Sat, 3 Sep 2011, Eric Botcazou wrote:

> > Well, even when sign-extended there is a constant you can't negate
> > without overflow.  I would start digging for a testcase with
> > such case - but as said, testcases involving TYPE_IS_SIZETYPE are
> > very hard to generate for me.
> 
> We run thousands of Ada tests every night on many platforms and never 
> detected 
> a problem here, so finding a testcase with the unpatched compiler is probably 
> very hard - if there is really something to be found, which I doubt.
> 
> > Well, but I'd expect you can have a set of Ada types, a function that
> > returns just its size and some scan-tree-dumps that check those sizes
> > are folded to a constant.  Or to just N statements.
> 
> We probably should, but we don't have them (yet).  Like for the vast majority 
> of the transformations made by the folder I guess, so...
> 
> > If you insist I can revert the patch and apply it together with the
> > sign-extension change.
> 
> Yes, IMHO it should be part of the final patch.

Reverted now.

Richard.


Re: Propagate BB predicates in ipa-inline-analysis

2011-09-05 Thread Jan Hubicka
Hi,
this is patch I comitted fixing ipa-inline-analysis.  Stil I guess we should
fill in PR for missed optimization and solve the forwprop issue?

Honza

Index: ChangeLog
===
*** ChangeLog   (revision 178523)
--- ChangeLog   (working copy)
***
*** 1,3 
--- 1,8 
+ 2011-09-04  Jan Hubicka  
+ 
+   * ipa-inline-analysis.c (set_cond_stmt_execution_predicate): Check that
+   parameter is SSA name.
+ 
  2011-09-04  Richard Guenther  
  
Revert
Index: testsuite/gcc.c-torture/compile/20110902.c
===
*** testsuite/gcc.c-torture/compile/20110902.c  (revision 0)
--- testsuite/gcc.c-torture/compile/20110902.c  (revision 0)
***
*** 0 
--- 1,14 
+ static inline __attribute__((always_inline)) int f (unsigned int n, unsigned 
int size)
+ {
+  return (__builtin_constant_p (size != 0 && n > ~0 / size)
+  ? !!(size != 0 && n > ~0 / size)
+  : ({ static unsigned int count[2] = { 0, 0 };
+   int r = !!(size != 0 && n > ~0 / size);
+   count[r]++;
+   r; }));
+ }
+ 
+ int g (unsigned int size)
+ {
+  return f (size / 4096, 4);
+ }
Index: testsuite/ChangeLog
===
*** testsuite/ChangeLog (revision 178523)
--- testsuite/ChangeLog (working copy)
***
*** 1,3 
--- 1,7 
+ 2011-09-04  Jan Hubicka  
+ 
+   * gcc.c-torture/compile/20110902.c: new testcase.
+ 
  2011-09-04  Jason Merrill  
  
PR c++/49267
Index: ipa-inline-analysis.c
===
*** ipa-inline-analysis.c   (revision 178523)
--- ipa-inline-analysis.c   (working copy)
*** set_cond_stmt_execution_predicate (struc
*** 1187,1192 
--- 1187,1194 
|| gimple_call_num_args (set_stmt) != 1)
  return;
op2 = gimple_call_arg (set_stmt, 0);
+   if (TREE_CODE (op2) != SSA_NAME)
+ return;
if (!SSA_NAME_IS_DEFAULT_DEF (op2))
  return;
index = ipa_get_param_decl_index (info, SSA_NAME_VAR (op2));


Re: Propagate BB predicates in ipa-inline-analysis

2011-09-05 Thread Richard Guenther
On Mon, Sep 5, 2011 at 9:41 AM, Jan Hubicka  wrote:
> Hi,
> this is patch I comitted fixing ipa-inline-analysis.  Stil I guess we should
> fill in PR for missed optimization and solve the forwprop issue?

I'm looking at it, it seems to be cfgcleanups bug

Richard.

> Honza
>
> Index: ChangeLog
> ===
> *** ChangeLog   (revision 178523)
> --- ChangeLog   (working copy)
> ***
> *** 1,3 
> --- 1,8 
> + 2011-09-04  Jan Hubicka  
> +
> +       * ipa-inline-analysis.c (set_cond_stmt_execution_predicate): Check 
> that
> +       parameter is SSA name.
> +
>  2011-09-04  Richard Guenther  
>
>        Revert
> Index: testsuite/gcc.c-torture/compile/20110902.c
> ===
> *** testsuite/gcc.c-torture/compile/20110902.c  (revision 0)
> --- testsuite/gcc.c-torture/compile/20110902.c  (revision 0)
> ***
> *** 0 
> --- 1,14 
> + static inline __attribute__((always_inline)) int f (unsigned int n, 
> unsigned int size)
> + {
> +  return (__builtin_constant_p (size != 0 && n > ~0 / size)
> +          ? !!(size != 0 && n > ~0 / size)
> +          : ({ static unsigned int count[2] = { 0, 0 };
> +               int r = !!(size != 0 && n > ~0 / size);
> +               count[r]++;
> +               r; }));
> + }
> +
> + int g (unsigned int size)
> + {
> +  return f (size / 4096, 4);
> + }
> Index: testsuite/ChangeLog
> ===
> *** testsuite/ChangeLog (revision 178523)
> --- testsuite/ChangeLog (working copy)
> ***
> *** 1,3 
> --- 1,7 
> + 2011-09-04  Jan Hubicka  
> +
> +       * gcc.c-torture/compile/20110902.c: new testcase.
> +
>  2011-09-04  Jason Merrill  
>
>        PR c++/49267
> Index: ipa-inline-analysis.c
> ===
> *** ipa-inline-analysis.c       (revision 178523)
> --- ipa-inline-analysis.c       (working copy)
> *** set_cond_stmt_execution_predicate (struc
> *** 1187,1192 
> --- 1187,1194 
>        || gimple_call_num_args (set_stmt) != 1)
>      return;
>    op2 = gimple_call_arg (set_stmt, 0);
> +   if (TREE_CODE (op2) != SSA_NAME)
> +     return;
>    if (!SSA_NAME_IS_DEFAULT_DEF (op2))
>      return;
>    index = ipa_get_param_decl_index (info, SSA_NAME_VAR (op2));
>


Re: Add unwind information to mips epilogues

2011-09-05 Thread Richard Sandiford
Richard Henderson  writes:
> On 09/01/2011 12:13 AM, Richard Sandiford wrote:
>> Also, for the frame_pointer_required case, it looks like there's a
>> window between the restoration of the frame pointer and the deallocation
>> of the stack in which the CFA is still defined in terms of the frame
>> pointer register.  Is that significant?  If not (e.g. because we
>> should never need to unwind at that point) then why do we still
>> update the CFA here:
>
> What window are you referring to?
>
> Best I can tell from looking at the patch we restore the CFA to the
> stack pointer before anything else.

Well, I'm probably showing my ignorance here, but what I meant was:
we attach the DEF_CFA and the CFA_RESTORE notes to the final stack
deallocation.  I was just worried that, immediately before that
deallocation, the CFA is still defined in terms of the frame pointer,
even though the frame pointer has already been restored.  So it seemed
like someone trying to unwind at that point would get the wrong CFA.

So I just wasn't sure whether we expected anyone to try to unwind
at that point or not.  Or whether I'm missing something else...

Richard


rtl_verify_flow_info fix

2011-09-05 Thread Tom de Vries
Hi Eric,

During testing the approved-for-commit middle-end patch for bug 43864 on ARM, I
ran into a gcc.dg/torture/pr46068.c ICE.

An asm jump is not recognized as an unconditional jump, so its followed by a
fall-through block rather than a barrier.
...
(jump_insn 10 9 19 4 (asm_operands/v ("") ("") 0 []
 []
 [
(label_ref:SI 16)
] pr46068.c:16) pr46068.c:6 -1
 (nil)
 -> 16)
...

ce3 then turns the asm jump into an asm return, still without a barrier after 
it:
...
(jump_insn 10 9 19 4 (asm_operands/v ("") ("") 0 []
 []
 [
(return)
] pr46068.c:16) pr46068.c:6 -1
 (nil)
 -> return)
...

This triggers the cfgrtl.c assert:
...
  if (JUMP_P (x)
  && returnjump_p (x) && ! condjump_p (x)
  && ! (next_nonnote_insn (x) && BARRIER_P (next_nonnote_insn (x
fatal_insn ("return not followed by barrier", x);
...

The patch fixes the assert by replacing ! condjump_p with uncondjump_p.

Bootstrapped and reg-tested on arm and x86_64.

OK for trunk?

Thanks,
- Tom

2011-09-05  Tom de Vries  

* cfgrtl.c (rtl_verify_flow_info): Use any_uncondjump_p instead of
!condjump_p.

Index: gcc/cfgrtl.c
===
--- gcc/cfgrtl.c (revision 178056)
+++ gcc/cfgrtl.c (working copy)
@@ -2169,7 +2169,7 @@ rtl_verify_flow_info (void)
 	}
 
   if (JUMP_P (x)
-	  && returnjump_p (x) && ! condjump_p (x)
+	  && returnjump_p (x) && any_uncondjump_p (x)
 	  && ! (next_nonnote_insn (x) && BARRIER_P (next_nonnote_insn (x
 	fatal_insn ("return not followed by barrier", x);
   if (curr_bb && x == BB_END (curr_bb))


Re: rtl_verify_flow_info fix

2011-09-05 Thread Jakub Jelinek
On Mon, Sep 05, 2011 at 10:29:18AM +0200, Tom de Vries wrote:
> Hi Eric,
> 
> During testing the approved-for-commit middle-end patch for bug 43864 on ARM, 
> I
> ran into a gcc.dg/torture/pr46068.c ICE.
> 
> An asm jump is not recognized as an unconditional jump, so its followed by a
> fall-through block rather than a barrier.
> ...
> (jump_insn 10 9 19 4 (asm_operands/v ("") ("") 0 []
>  []
>  [
> (label_ref:SI 16)
> ] pr46068.c:16) pr46068.c:6 -1
>  (nil)
>  -> 16)
> ...
> 
> ce3 then turns the asm jump into an asm return, still without a barrier after 
> it:
> ...
> (jump_insn 10 9 19 4 (asm_operands/v ("") ("") 0 []
>  []
>  [
> (return)
> ] pr46068.c:16) pr46068.c:6 -1
>  (nil)
>  -> return)
> ...

I'd say the above transformation shouldn't be valid, asm goto is given some
possible labels it can jump to, but what will be emitted when the operand is
RETURN?  I think final.c does:
else if (letter == 'l')
  output_asm_label (operands[opnum]);
here and when operands[opnum] isn't a label or deleted label, that function
will
  output_operand_lossage ("'%%l' operand isn't a label");
You don't get it only because this testcase uses empty inline asm string
and thus doesn't use any of the labels.

Jakub


[PATCH] Use size_binop again in layout_type

2011-09-05 Thread Richard Guenther

This reverts parts of

2011-04-11  Richard Guenther  

* stor-layout.c (layout_type): Compute all array index size 
operations
in the original type.
(initialize_sizetypes): Add comment.
(set_sizetype): Do not set TREE_TYPE of a TREE_VEC.

and retains the use of size_binop in layout_type while still preserving
signedness.  We then just need to make sure to always use a
sizetype for domain types, the only case where we don't being
in complete_array_type for a[].

Bootstrapped and tested on x86_64-unknown-linux-gnu, committed
(c-common.c piece as obvious).

Richard.

2011-09-05  Richard Guenther  

* stor-layout.c (layout_type): Use size_binop for array size
calculations.

c-family/
* c-common.c (complete_array_type): Use ssize_int (-1) instead
of integer_minus_one_node for empty array upper bounds.

Index: gcc/stor-layout.c
===
--- gcc/stor-layout.c   (revision 178523)
+++ gcc/stor-layout.c   (working copy)
@@ -1959,16 +1959,15 @@ layout_type (tree type)
if (integer_zerop (element_size))
  length = size_zero_node;
 
-   /* The computation should happen in the original type so
-  that (possible) negative values are handled appropriately.  */
+   /* The computation should happen in the original signedness so
+  that (possible) negative values are handled appropriately
+  when determining overflow.  */
else
  length
= fold_convert (sizetype,
-   fold_build2 (PLUS_EXPR, TREE_TYPE (lb),
-build_int_cst (TREE_TYPE (lb), 1),
-fold_build2 (MINUS_EXPR,
- TREE_TYPE (lb),
- ub, lb)));
+   size_binop (PLUS_EXPR,
+   build_int_cst (TREE_TYPE (lb), 1),
+   size_binop (MINUS_EXPR, ub, lb)));
 
TYPE_SIZE (type) = size_binop (MULT_EXPR, element_size,
   fold_convert (bitsizetype,
Index: gcc/c-family/c-common.c
===
--- gcc/c-family/c-common.c (revision 178523)
+++ gcc/c-family/c-common.c (working copy)
@@ -8844,7 +8844,7 @@ complete_array_type (tree *ptype, tree i
{
  if (pedantic)
failure = 3;
- maxindex = integer_minus_one_node;
+ maxindex = ssize_int (-1);
}
  else
{


Re: Propagate BB predicates in ipa-inline-analysis

2011-09-05 Thread Ulrich Weigand
Jan Hubicka wrote:

> this is patch I comitted fixing ipa-inline-analysis.

Thanks for fixing this!

Richard Guenther wrote:

> Can you open a bugreport?

Sorry, I didn't see this until now.  Given that the fix is
already checked in (and the problem doesn't exist on any
release branch), I guess we don't really need any PR now ...

If you'd prefer to still have one, let me know and I'll
create it.

Thanks,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  ulrich.weig...@de.ibm.com


[PATCH] Make merge-blocks fold all statements propagated into

2011-09-05 Thread Richard Guenther

This makes merge-blocks fold all statements that have single-arg PHI
arguments propagated into them.  fold_stmt_inplace does not fold
calls, thus the following makes us use fold_stmt instead of
fold_stmt_inplace.

Bootstrap and regtest ongoing on x86_64-unknown-linux-gnu.

Richard.

2011-09-05  Richard Guenther  

* tree-cfg.c (replace_uses_by): Use fold_stmt, not fold_stmt_inplace.

Index: gcc/tree-cfg.c
===
--- gcc/tree-cfg.c  (revision 178523)
+++ gcc/tree-cfg.c  (working copy)
@@ -1566,9 +1570,11 @@ replace_uses_by (tree name, tree val)
 
   if (gimple_code (stmt) != GIMPLE_PHI)
{
+ gimple_stmt_iterator gsi = gsi_for_stmt (stmt);
  size_t i;
 
- fold_stmt_inplace (stmt);
+ fold_stmt (&gsi);
+ stmt = gsi_stmt (gsi);
  if (cfgcleanup_altered_bbs && !is_gimple_debug (stmt))
bitmap_set_bit (cfgcleanup_altered_bbs, gimple_bb (stmt)->index);
 



[arm-embedded] Backport r174965 from trunk to ARM/embedded-4_6-branch

2011-09-05 Thread Terry Guo
Hi,

The checkin at r174965 in trunk fixed vect-27.c failure for ARM EABI target.
Detailed information please refer to
http://gcc.gnu.org/ml/gcc-patches/2011-06/msg00927.html. 

Performed regression test on arm QEMU and no regression.

OK to ARM/embedded-4_6-branch?

BR,
Terry

2011-09-05  Terry Guo  

Backport r174965 from trunk.

2011-06-12  Ira Rosen  

* tree-vect-data-refs.c
(vect_peeling_hash_get_most_frequent):
Take number of iterations to peel into account for equally
frequent
misalignment values.

Index: gcc/tree-vect-data-refs.c
===
--- gcc/tree-vect-data-refs.c   (revision 178517)
+++ gcc/tree-vect-data-refs.c   (working copy)
@@ -1250,7 +1250,9 @@
   vect_peel_info elem = (vect_peel_info) *slot;
   vect_peel_extended_info max = (vect_peel_extended_info) data;
 
-  if (elem->count > max->peel_info.count)
+  if (elem->count > max->peel_info.count
+  || (elem->count == max->peel_info.count
+  && max->peel_info.npeel > elem->npeel))
 {
   max->peel_info.npeel = elem->npeel;
   max->peel_info.count = elem->count;




Re: [RFC, WIP] tree-ssa-strlen optimization pass

2011-09-05 Thread Jakub Jelinek
On Mon, Sep 05, 2011 at 10:54:47AM +0200, Richard Guenther wrote:
> > 2011-09-02  Jakub Jelinek  
> >
> >        * common.opt: Add -ftree-strlen option.
> 
> Maybe sth more generic?  -foptimize-string-ops?  Eventually guard
> the existing string op foldings with that flag as well.

I don't think other string op foldings should be dependent on that flag,
those are already guarded with -fbuiltin-strcpy etc.  I think we should have
a switch just for this pass, and IMHO -foptimize-string-ops is way too 
generic, but of course it can be -ftrack-string-lengths or
-foptimize-using-string-lengths or similar.

> > --- gcc/opts.c.jj       2011-06-30 17:58:03.0 +0200
> > +++ gcc/opts.c  2011-09-02 15:53:06.0 +0200
> > @@ -484,6 +484,7 @@ static const struct default_options defa
> >     { OPT_LEVELS_2_PLUS, OPT_falign_jumps, NULL, 1 },
> >     { OPT_LEVELS_2_PLUS, OPT_falign_labels, NULL, 1 },
> >     { OPT_LEVELS_2_PLUS, OPT_falign_functions, NULL, 1 },
> > +    { OPT_LEVELS_2_PLUS_SPEED_ONLY, OPT_ftree_strlen, NULL, 1 },
> 
> Why not -Os?  Doesn't it remove strlen calls?

Sometimes it does (though rarer than e.g. with -O2, because with -O2 we e.g.
fold strcat with constant literal as second argument to strlen plus memcpy,
but don't do that for -Os).  On the other side it transforms strcpy calls
into memcpy (where the latter is usually longer), etc.  And strcat is almost
always shorter too.  So, an alternative would be for -Os enable this pass,
but only do strlen removal in it (in addition to tracking lengths), nothing
else.  Even the strlen removal can grow the size if the string length
expression isn't constant, or variable, or arithmetic operation on two
operands.

> > +/* Array indexed by SSA_NAME_VERSION.  0 means unknown, positive value
> > +   is an index into strinfo vector, negative value stands for
> > +   string length of a string literal (~strlen).  */
> > +static int *ssa_ver_to_stridx;
> > +
> > +/* Number of currently active string indexes plus one.  */
> > +static int max_stridx;
> 
> USe a VEC?

For what?  ssa_ver_to_stridx isn't growing, we shouldn't use it on the
SSA_NAMEs added during the pass.  And max_stridx isn't the length of
the ssa_ver_to_stridx array, but how many string indexes are in use
(i.e. maximum current length of stridx_to_strinfo vector).

> > +/* Free a decl_stridxlist_map.  Callback for htab_delete.  */
> > +
> > +static void
> > +decl_to_stridxlist_free (void *item)
> > +{
> > +  struct stridxlist *next;
> > +  struct stridxlist *list = ((struct decl_stridxlist_map *) 
> > item)->list.next;
> > +
> > +  while (list)
> > +    {
> > +      next = list->next;
> > +      XDELETE (list);
> > +      list = next;
> > +    }
> > +  XDELETE (item);
> 
> Maybe use an obstack or alloc-pool dependent on re-use?

The number of those is limited by the string index limit, so it doesn't grow
without bounds.  It isn't reused, so yes, obstack could be used and avoid
the above routine.  If you prefer that, I'll change it.

> > +/* Create a new string index, or return 0 if reached limit.  */
> > +
> > +static int
> > +new_stridx (tree exp)
> > +{
> > +  int idx;
> > +  if (max_stridx == 1000)
> 
> I suppose make this a #define or --param

Yeah.  I guess this one could be a --param.

> > +static void
> > +find_equal_ptrs (tree ptr, int idx)
> > +{
> > +  if (TREE_CODE (ptr) != SSA_NAME)
> > +    return;
> > +  while (1)
> > +    {
> > +      gimple stmt = SSA_NAME_DEF_STMT (ptr);
> > +      if (!gimple_assign_single_p (stmt)
> > +         && (!gimple_assign_cast_p (stmt)
> > +             || !POINTER_TYPE_P (TREE_TYPE (gimple_assign_rhs1 (stmt)
> > +       return;
> 
> I'd prefer postive checks to guard code below.  So, you're handling
> SSA name copies, conversions from pointers and assignments from
> invariants.  You could simply do
> 
>  if (!is+gimple_assign (stmt))
>return;
>  switch (gimple_assign_rhs_code (stmt))
>   {
>case SSA_NAME:
>   ..
> case ADDR_EXPR:
>   ..
>   CASE_CONVERT:
>  ...
> default:
> return;
> }

Ok, will change that.

> > +             if (!update_call_from_tree (gsi, rhs))
> > +               {
> > +                 rhs = force_gimple_operand_gsi (gsi, rhs, true, NULL_TREE,
> > +                                                 true, GSI_SAME_STMT);
> > +                 if (!update_call_from_tree (gsi, rhs))
> 
> if update_call_from_tree fails then gimplify_and_update_call_from_tree
> will always succeed.  See gimple_fold_call.

I saw that call, I was worried that fold_all_builtins pass if
gimplify_and_update_call_from_tree is called forces
TODO_update_address_taken.  rhs will be just a sum of some constants and/or
SSA_NAMEs though, and the call here is a builtin that ought to be
non-throwing.  So do you think just
if (!update_call_from_tree
  gimplify_and_update_call_from_tree
is safe for that case?

> > +  len = fold_convert_loc (loc, type, si->length);
> > +  len = fold_build2_loc (loc, PLUS_EXPR, type, len, build_int_cst (type, 
> > 1));
>

Re: Ping: C-family stack check for threads

2011-09-05 Thread Ye Joey
On Mon, Sep 5, 2011 at 1:45 AM, Thomas Klein  wrote:

> +static int
> +stack_check_work_registers (rtx *workreg)
> +{
> +  int reg, i, k, n, nregs;
> +
> +  if (crtl->args.info.pcs_variant <= ARM_PCS_AAPCS_LOCAL)
> +{
> +  nregs = crtl->args.info.aapcs_next_ncrn;
> +}
> +  else
> +nregs = crtl->args.info.nregs;
Missing {} for else

> +  n = 0;
...
> +  /* check if we can use one of the argument registers r0..r3 as long as they
> +   * not holding data*/
> +  for (reg = 0; reg <= LAST_ARG_REGNUM && i < 2; reg++)
...
> +  n = (reg + 1) % 4;
Avoid immediate register number.
use ARG_REGISTER (1) to replace "reg 0"
use NUM_ARG_REGS to replace "4"

> +  if (is_non_opt_thumb2 || is_thumb2_hi_reg[0])
> + arm_emit_movpair(reg[0], stack_limit_rtx);
> +  else
> +emit_move_insn(reg[0], stack_limit_rtx);
and
> +   rtx lr = gen_rtx_REG (SImode, LR_REGNUM);
> +  emit_push_regs (1, &lr);
Wrong indent


[Patch,AVR]: Fix PR target/50289

2011-09-05 Thread Georg-Johann Lay
PR50289 is a minor issue with -mcall-prologues and global register variables
resp. fixed registers: Such registers shall be omitted in function
prologue/epilogue.

For test program

void bar (long long, long long, void*);

register char x asm ("7");

void foo (char a)
{
asm volatile ("":::"6");
bar (0, 0, &a);
}


however, avr.c:sequent_regs_live() generates a register sequence that covers
fixed R7, i.e. prologue saves R7...R17, Y and reads

foo:
ldi r26,lo8(1)
ldi r27,hi8(1)
ldi r30,lo8(gs(1f))
ldi r31,hi8(gs(1f))
rjmp __prologue_saves__+((18 - 13) * 2)
1:
/* prologue: function */

With the patch no sequences are generated that contain fixed regsisters, i.e.
prologue for the example reads now

foo:
push r6  ;  31  pushqi1/1   [length = 1]
push r8  ;  32  pushqi1/1   [length = 1]
push r9  ;  33  pushqi1/1   [length = 1]
push r10 ;  34  pushqi1/1   [length = 1]
push r11 ;  35  pushqi1/1   [length = 1]
push r12 ;  36  pushqi1/1   [length = 1]
push r13 ;  37  pushqi1/1   [length = 1]
push r14 ;  38  pushqi1/1   [length = 1]
push r15 ;  39  pushqi1/1   [length = 1]
push r16 ;  40  pushqi1/1   [length = 1]
push r17 ;  41  pushqi1/1   [length = 1]
push r28 ;  42  pushqi1/1   [length = 1]
push r29 ;  43  pushqi1/1   [length = 1]
push __tmp_reg__ ;  47  *addhi3_sp_R_pc2[length = 1]
in r28,__SP_L__  ;  48  *movhi_sp/2 [length = 2]
in r29,__SP_H__
/* prologue: function */

Ok to install?

Johann

PR target/50289
* config/avr/avr.c (sequent_regs_live): Don't recognize sequences
that contain global register variable.
Index: config/avr/avr.c
===
--- config/avr/avr.c	(revision 178525)
+++ config/avr/avr.c	(working copy)
@@ -522,6 +522,17 @@ sequent_regs_live (void)
 
   for (reg = 0; reg < 18; ++reg)
 {
+  if (fixed_regs[reg])
+{
+  /* Don't recognize sequences that contain global register
+ variables.  */
+  
+  if (live_seq != 0)
+return 0;
+  else
+continue;
+}
+  
   if (!call_used_regs[reg])
 	{
 	  if (df_regs_ever_live_p (reg))


Re: [RFC, WIP] tree-ssa-strlen optimization pass

2011-09-05 Thread Richard Guenther
On Mon, Sep 5, 2011 at 11:41 AM, Jakub Jelinek  wrote:
> On Mon, Sep 05, 2011 at 10:54:47AM +0200, Richard Guenther wrote:
>> > 2011-09-02  Jakub Jelinek  
>> >
>> >        * common.opt: Add -ftree-strlen option.
>>
>> Maybe sth more generic?  -foptimize-string-ops?  Eventually guard
>> the existing string op foldings with that flag as well.
>
> I don't think other string op foldings should be dependent on that flag,
> those are already guarded with -fbuiltin-strcpy etc.  I think we should have
> a switch just for this pass, and IMHO -foptimize-string-ops is way too
> generic, but of course it can be -ftrack-string-lengths or
> -foptimize-using-string-lengths or similar.

Ok, I guess we can bikeshed a bit about the flag ;)  -ftree-strlen
at least doesn't sound very informative (nor do I like the tree- prefix
too much). -foptimize-strlen would be fine with me.

>> > --- gcc/opts.c.jj       2011-06-30 17:58:03.0 +0200
>> > +++ gcc/opts.c  2011-09-02 15:53:06.0 +0200
>> > @@ -484,6 +484,7 @@ static const struct default_options defa
>> >     { OPT_LEVELS_2_PLUS, OPT_falign_jumps, NULL, 1 },
>> >     { OPT_LEVELS_2_PLUS, OPT_falign_labels, NULL, 1 },
>> >     { OPT_LEVELS_2_PLUS, OPT_falign_functions, NULL, 1 },
>> > +    { OPT_LEVELS_2_PLUS_SPEED_ONLY, OPT_ftree_strlen, NULL, 1 },
>>
>> Why not -Os?  Doesn't it remove strlen calls?
>
> Sometimes it does (though rarer than e.g. with -O2, because with -O2 we e.g.
> fold strcat with constant literal as second argument to strlen plus memcpy,
> but don't do that for -Os).  On the other side it transforms strcpy calls
> into memcpy (where the latter is usually longer), etc.  And strcat is almost
> always shorter too.  So, an alternative would be for -Os enable this pass,
> but only do strlen removal in it (in addition to tracking lengths), nothing
> else.  Even the strlen removal can grow the size if the string length
> expression isn't constant, or variable, or arithmetic operation on two
> operands.

Hm, ok.  I guess we can leave it for -O2+ for now.

>> > +/* Array indexed by SSA_NAME_VERSION.  0 means unknown, positive value
>> > +   is an index into strinfo vector, negative value stands for
>> > +   string length of a string literal (~strlen).  */
>> > +static int *ssa_ver_to_stridx;
>> > +
>> > +/* Number of currently active string indexes plus one.  */
>> > +static int max_stridx;
>>
>> USe a VEC?
>
> For what?  ssa_ver_to_stridx isn't growing, we shouldn't use it on the
> SSA_NAMEs added during the pass.  And max_stridx isn't the length of
> the ssa_ver_to_stridx array, but how many string indexes are in use
> (i.e. maximum current length of stridx_to_strinfo vector).

Just for consistency across the compiler - I have no strong preferences,
esp. if we don't grow it (but you'd get bounds checking, etc. for free ...)

>> > +/* Free a decl_stridxlist_map.  Callback for htab_delete.  */
>> > +
>> > +static void
>> > +decl_to_stridxlist_free (void *item)
>> > +{
>> > +  struct stridxlist *next;
>> > +  struct stridxlist *list = ((struct decl_stridxlist_map *) 
>> > item)->list.next;
>> > +
>> > +  while (list)
>> > +    {
>> > +      next = list->next;
>> > +      XDELETE (list);
>> > +      list = next;
>> > +    }
>> > +  XDELETE (item);
>>
>> Maybe use an obstack or alloc-pool dependent on re-use?
>
> The number of those is limited by the string index limit, so it doesn't grow
> without bounds.  It isn't reused, so yes, obstack could be used and avoid
> the above routine.  If you prefer that, I'll change it.

optimizing malloc/free calls is cheap, so yes, I think we should use
an obstack here.

>> > +/* Create a new string index, or return 0 if reached limit.  */
>> > +
>> > +static int
>> > +new_stridx (tree exp)
>> > +{
>> > +  int idx;
>> > +  if (max_stridx == 1000)
>>
>> I suppose make this a #define or --param
>
> Yeah.  I guess this one could be a --param.
>
>> > +static void
>> > +find_equal_ptrs (tree ptr, int idx)
>> > +{
>> > +  if (TREE_CODE (ptr) != SSA_NAME)
>> > +    return;
>> > +  while (1)
>> > +    {
>> > +      gimple stmt = SSA_NAME_DEF_STMT (ptr);
>> > +      if (!gimple_assign_single_p (stmt)
>> > +         && (!gimple_assign_cast_p (stmt)
>> > +             || !POINTER_TYPE_P (TREE_TYPE (gimple_assign_rhs1 (stmt)
>> > +       return;
>>
>> I'd prefer postive checks to guard code below.  So, you're handling
>> SSA name copies, conversions from pointers and assignments from
>> invariants.  You could simply do
>>
>>  if (!is+gimple_assign (stmt))
>>    return;
>>  switch (gimple_assign_rhs_code (stmt))
>>   {
>>    case SSA_NAME:
>>   ..
>> case ADDR_EXPR:
>>   ..
>>   CASE_CONVERT:
>>  ...
>> default:
>> return;
>> }
>
> Ok, will change that.
>
>> > +             if (!update_call_from_tree (gsi, rhs))
>> > +               {
>> > +                 rhs = force_gimple_operand_gsi (gsi, rhs, true, 
>> > NULL_TREE,
>> > +                                                 true, GSI_SAME_STMT);
>> > +                 if (!updat

RE: [PATCH, ARM, iWMMXt][4/5]: WMMX machine description

2011-09-05 Thread Xinyu Qi
At 2011-08-18 10:21:01,"Ramana Radhakrishnan"  
wrote:
> On 14 July 2011 08:45, Xinyu Qi  wrote:
> >> Hi,
> >>
> >> It is the fourth part of iWMMXt maintenance.
> >>
> 
> Can this be broken down further. ? I'll have to do this again but
> there are some initial comments below for some discussion.

> 
> >  (*iwmmxt_arm_movdi, *iwmmxt_movsi_insn, iwmmxt_uavgrndv8qi3,
> iwmmxt_uavgrndv4hi3, iwmmxt_uavgv8qi3, iwmmxt_uavgv4hi3, iwmmxt_tinsrb,
> iwmmxt_tinsrh, iwmmxt_tinsrw, eqv8qi3, eqv4hi3, eqv2si3, gtuv8qi3, gtuv4hi3,
> gtuv2si3, gtv8qi3, gtv4hi3, gtv2si3, iwmmxt_wunpckihb, iwmmxt_wunpckihh,
> iwmmxt_wunpckihw, iwmmxt_wunpckilb, iwmmxt_wunpckilh, iwmmxt_wunpckilw,
> iwmmxt_wunpckehub, iwmmxt_wunpckehuh, iwmmxt_wunpckehuw, iwmmxt_wunpckehsb,
> iwmmxt_wunpckehsh, iwmmxt_wunpckehsw, iwmmxt_wunpckelub, iwmmxt_wunpckeluh,
> iwmmxt_wunpckeluw, iwmmxt_wunpckelsb, iwmmxt_wunpckelsh, iwmmxt_wunpckelsw,
> iwmmxt_wmadds, iwmmxt_wmaddu, iwmmxt_wsadb, iwmmxt_wsadh, iwmmxt_wsadbz,
> iwmmxt_wsadhz): Revise.
> 
> Revise to do what ?

Sorry for late response.

Some of them have incorrect RTL templates. For example, see iwmmxt_uavgv8qi3
Its old RTL template is:
  [(set (match_operand:V8QI 0 "register_operand" "=y")
(ashiftrt:V8QI (plus:V8QI
(match_operand:V8QI 1 "register_operand" "y")
   (match_operand:V8QI 2 "register_operand" 
"y"))
  (const_int 1)))]

According to the assembly behavior of wavg2b, the correct one should be:
  [(set (match_operand:V8QI  0 "register_operand" "=y")
(truncate:V8QI
 (lshiftrt:V8HI
   (plus:V8HI (zero_extend:V8HI (match_operand:V8QI 1 
"register_operand" "y"))
  (zero_extend:V8HI (match_operand:V8QI 2 
"register_operand" "y")))
 (const_int 1]

Consider the case:
The Operation on element 0x01 and 0xff: gcc with old RTL template would 
optimize to the result 0x00.That is:
0x01 + 0xff => 0x00. 0x00 > 1 => 0x00
While the correct result should be 0x80. 
0x01 => 0x0001, 0xff => 0x00ff. 0x0001 + 0x00ff => 0x0100. 0x0100 > 1 => 
0x0080, 0x0080 => 0x80

iwmmxt_wmadds and iwmmxt_wmaddu are modified to use detailed RTL template 
instead of unspec.

For some of the wunpck patterns, change the order of zero_extend and vec_select 
in order to avoid a vec_select optimization internal error in old version gcc. 
Maybe this internal bug has been fixed, but such modification is harmless.

Rests of them are only revised for their format.

> 
> > (define_insn "*iwmmxt_movsi_insn"
> > -  [(set (match_operand:SI 0 "nonimmediate_operand" "=rk,r,r,rk,
> m,z,r,?z,Uy,z")
> >-(match_operand:SI 1 "general_operand"  "rk, I,K,mi,rk,r,z,Uy,z,
> z"))]
> >+  [(set (match_operand:SI 0 "nonimmediate_operand" "=rk,r,r,r,rk,
> m,z,r,?z,?Uy,?z,t,r,?t,?z,t")
> >+(match_operand:SI 1 "general_operand"  " rk,I,K,N,mi,rk,r,z,Uy,  z,
> z,r,t, z, t,t"))]
> >   "TARGET_REALLY_IWMMXT
> >-   && (   register_operand (operands[0], SImode)
> >-   || register_operand (operands[1], SImode))"
> >-  "*
> >-   switch (which_alternative)
> >+   && ((register_operand (operands[0], SImode)
> >+&& (!reload_completed
> >+|| REGNO_REG_CLASS (REGNO (operands[0])) == IWMMXT_GR_REGS))
> >+   || (register_operand (operands[1], SImode)
> >+   && (!reload_completed
> 
> 
> 
> >+   || REGNO_REG_CLASS (REGNO (operands[1])) == IWMMXT_GR_REGS)))"
> 
> I don't like this at all - what you are doing is assuming that after
> reg-alloc you are going to be able to rely on whether something has a
> particular register class and then turn on and off it's matching. So
> this matches before reload and doesn't do so after reload for the
> cases where *iwmmxt_movsi_insn is really in a core register. I don't
> think you can do it this way. If you really want to do this properly -
> have an arch field for iwmmxt as well in the arch attribute and then
> add these alternatives to existing patterns.
> 
> If I understand what you are trying to do here - you are trying to use
> *arm_movsi_insn and other patterns in the rest of the backend and let
> things like "predicable" kick in right after reload for all cases
> other than the ones you enumerate. In which case get rid of all the
> other constaints in this pattern other than the constraints that are
> valid for registers of class IWMMXT_REGS

This piece of code is added to make iwmmxt coexist with vfp when iwmmxt and vfp 
are enabled together. Agree, I don't think it is a good fix. 
Add adequate constrains to *iwmmxt_movsi_insn and *iwmmxt_arm_movdi so that 
don't need to change their conditions.

> 
> Also the definition of output_move_double has changed now and hence
> this needs some rework.

Done.

> Should there be a distinction between iwmmxt and iwmmxt2 ? Is it a
> user visible option ?

I don't think users need to know the distinction between iwmmxt and iwmmxt2 
though there are two options "-mcpu=i

[PATCH] Make sizetypes no longer sign-extended

2011-09-05 Thread Richard Guenther

This is the minimal patch that allows Ada to bootstrap (including
all the other frontend changes to make them regression-free).  It
doesn't need any Ada changes for this.

I will send out Ada changes separately, piecewise, indicating which
regressions they will fix - I'd appreciate help there though, as most
"fixes" rather fix the issues where symptoms occur which is not
necessarily the best place.

In the generic parts what changed compared to the last patch is
folding in of the reverted extract_muldiv_1 change, allowing
zero-size arrays in layout_type by ignoring overflow (with good
reasoning) and folding the host_integerp (.., 1) && tree_int_cst_sign_bit 
() && TREE_OVERFLOW check into a new valid_constant_size_p predicate.

Bootstrapped and tested on x86_64-unknown-linux-gnu with
--enable-languages=ada (which enables C and C++ as well, previous
versions bootstrapped and tested for all languages).

Ada fails from this patch:

=== acats tests ===
FAIL:   a71004a
FAIL:   c36204d
FAIL:   c36205l
FAIL:   c37404b
FAIL:   c41107a
FAIL:   c41204a
FAIL:   c43204c
FAIL:   c43204e
FAIL:   c43204f
FAIL:   c43204g
FAIL:   c43204h
FAIL:   c43204i
FAIL:   c52102a
FAIL:   c52102c
FAIL:   c64103c
FAIL:   c64103d
FAIL:   c64106a
FAIL:   c95087a
FAIL:   cc1224a
FAIL:   cc1311a
FAIL:   cc3106b
FAIL:   cc3224a
FAIL:   cd2a31a
FAIL:   cxb3009

=== acats Summary ===
# of expected passes2297
# of unexpected failures24

=== gnat tests ===


Running target unix/
FAIL: gnat.dg/align_max.adb execution test
FAIL: gnat.dg/array11.adb  (test for warnings, line 12)
FAIL: gnat.dg/loop_optimization3.adb (test for excess errors)
FAIL: gnat.dg/loop_optimization3.adb execution test
FAIL: gnat.dg/object_overflow.adb  (test for warnings, line 8)
FAIL: gnat.dg/test_8bitlong_overflow.adb (test for excess errors)
WARNING: gnat.dg/test_8bitlong_overflow.adb compilation failed to produce 
execut
able
FAIL: gnat.dg/thin_pointer2.adb execution test
FAIL: gnat.dg/unc_memfree.adb execution test

=== gnat Summary for unix/ ===

# of expected passes910
# of unexpected failures8
# of expected failures  11
# of unsupported tests  2

Running target unix//-m32
FAIL: gnat.dg/align_max.adb execution test
FAIL: gnat.dg/array11.adb  (test for warnings, line 12)
FAIL: gnat.dg/frame_overflow.adb  (test for errors, line 17)
FAIL: gnat.dg/frame_overflow.adb  (test for errors, line 24)
FAIL: gnat.dg/loop_optimization3.adb (test for excess errors)
FAIL: gnat.dg/loop_optimization3.adb execution test
FAIL: gnat.dg/object_overflow.adb  (test for warnings, line 8)
FAIL: gnat.dg/test_8bitlong_overflow.adb (test for excess errors)
WARNING: gnat.dg/test_8bitlong_overflow.adb compilation failed to produce 
execut
able
FAIL: gnat.dg/thin_pointer2.adb execution test
FAIL: gnat.dg/unc_memfree.adb execution test

=== gnat Summary for unix//-m32 ===

# of expected passes908
# of unexpected failures10
# of expected failures  11
# of unsupported tests  2

=== gnat Summary ===

# of expected passes1818
# of unexpected failures18
# of expected failures  22
# of unsupported tests  4

Richard.

2011-09-05  Richard Guenther  

* fold-const.c (div_if_zero_remainder): sizetypes no longer
sign-extend.
(int_const_binop_1): New worker for int_const_binop with
overflowable parameter.  Pass it through
to force_fit_type_double.
(int_const_binop): Wrap around int_const_binop_1 with overflowable
equal to one.
(size_binop_loc): Call int_const_binop_1 with overflowable equal
to minus one, forcing overflow detection for even unsigned types.
(extract_muldiv_1): Remove bogus TYPE_IS_SIZETYPE special-casing.
(fold_binary_loc): Call try_move_mult_to_index with signed offset.
* stor-layout.c (initialize_sizetypes): sizetypes no longer
sign-extend.
(layout_type): For zero-sized arrays ignore overflow on the
size calculations.
* tree-ssa-ccp.c (bit_value_unop_1): Likewise.
(bit_value_binop_1): Likewise.
* tree.c (double_int_to_tree): Likewise.
(double_int_fits_to_tree_p): Likewise.
(force_fit_type_double): Likewise.
(host_integerp): Likewise.
(int_fits_type_p): Likewise.
(valid_constant_size_p): New function.
* tree.h (valid_constant_size_p): Declare.
* cfgexpand.c (expand_one_var): Adjust check for too large
variables by using valid_constant_size_p.
* varasm.c (assemble_variable): Likewise.
(output_constructor_regular_field): Sign-extend the field-offset
to cater for negative offsets produced by the Ada frontend.
* omp-low.c (extract_omp_for_data): Convert the loop step to
signed for pointer adjustments.

c/
* c-decl.c (gro

[PATCH][Ada] Fix shift_unc_components_for_thin_pointers for sizetype changes

2011-09-05 Thread Richard Guenther

This avoids setting the TREE_OVERFLOW bit on DECL_FIELD_OFFSET for
the shifted bounds field.

If DECL_FIELD_OFFSET of array-field is always a constant we could
as well use

  DECL_FIELD_OFFSET (bounds_field)
= size_int (-int_byte_position (array_field));

also I notice that DECL_OFFSET_ALIGN is now bogus for bounds_field.
DECL_FIELD_OFFSET no longer has the desired zero bits.  Shouldn't we
instead set DECL_FIELD_OFFSET to -DECL_OFFSET_ALIGN and adjust
DECL_FIELD_BIT_OFFSET accordingly?

Well, with the above questions and suggestions I'd rather leave it
to you deciding whether you like the below hack or want to rework
the function a bit.

Fixes

   === gnat tests ===

Running target unix/
FAIL: gnat.dg/align_max.adb execution test
FAIL: gnat.dg/thin_pointer2.adb execution test
FAIL: gnat.dg/unc_memfree.adb execution test

Running target unix//-m32
FAIL: gnat.dg/align_max.adb execution test
FAIL: gnat.dg/thin_pointer2.adb execution test
FAIL: gnat.dg/unc_memfree.adb execution test

Richard.

2011-09-02  Richard Guenther  

ada/
* gcc-interface/utils.c (shift_unc_components_for_thin_pointers):
Drop overflow bit on negative offsets.

Index: trunk/gcc/ada/gcc-interface/utils.c
===
*** trunk.orig/gcc/ada/gcc-interface/utils.c2011-09-05 13:01:59.0 
+0200
--- trunk/gcc/ada/gcc-interface/utils.c 2011-09-05 13:56:37.0 +0200
*** shift_unc_components_for_thin_pointers (
*** 3411,3416 
--- 3414,3425 
  
DECL_FIELD_OFFSET (bounds_field)
  = size_binop (MINUS_EXPR, size_zero_node, byte_position (array_field));
+   if (TREE_CODE (DECL_FIELD_OFFSET (bounds_field)) == INTEGER_CST
+   && TREE_OVERFLOW (DECL_FIELD_OFFSET (bounds_field)))
+ DECL_FIELD_OFFSET (bounds_field)
+   = build_int_cst_wide (sizetype,
+   TREE_INT_CST_LOW (DECL_FIELD_OFFSET (bounds_field)),
+   TREE_INT_CST_HIGH (DECL_FIELD_OFFSET 
(bounds_field)));
  
DECL_FIELD_OFFSET (array_field) = size_zero_node;
DECL_FIELD_BIT_OFFSET (array_field) = bitsize_zero_node;



[testsuite]: Fix gcc.dg/ipa/ipcp-3.c

2011-09-05 Thread Georg-Johann Lay
This test case contains expression 1 << 18 which leads to FAIL for targets with
sizeof(int) < 4.

The mask seems not to be relevant for the test and can be set to, e.g. 14.

Ok?

testsuite/
* gcc.dg/ipa/ipcp-3.c (mark_cell): Use mask 1 << 14 instead of 1 << 18.



Index: gcc.dg/ipa/ipcp-3.c
===
--- gcc.dg/ipa/ipcp-3.c (revision 178527)
+++ gcc.dg/ipa/ipcp-3.c (working copy)
@@ -34,7 +34,7 @@ static void
 mark_cell(int * interp, Pcc_cell *c)
 {
   if (c && c->type == 4 && c->p
-  && !(c->p->flags & (1<<18)))
+  && !(c->p->flags & (1<<14)))
 never_ever(interp, c->p);
 }



Re: [PATCH] Fix Ada bootstrap failure

2011-09-05 Thread Michael Matz
Hi,

On Sat, 3 Sep 2011, Richard Guenther wrote:

> > your patch and apply mine entirely, as eliminating alloca (0) early 
> > looks a interesting simplification.  What do you think?
> 
> I'm not sure we want to create a the replacement decl with DECL_SIZE 
> zero though, so I suppose instead of making sure align is BITS_PER_UNIT 
> shouldn't we make sure that size is at least 1?  I fear we might run 
> into other odd problems with zero-size autos.
> 
> Thus, a variant of the patch that re-enables handling of size zero 
> allocas but adjusts the size to be at least 1 is ok.
> 
> Other opinions?

Yes.  Create zero-sized autos for alloca(0) as Eric proposes, and fix the 
fallout that might happen.  There's no reason to add work-arounds for bugs 
preemptively.


Ciao,
Michael.

Re: rtl_verify_flow_info fix

2011-09-05 Thread Tom de Vries
On 09/05/2011 10:53 AM, Jakub Jelinek wrote:
> On Mon, Sep 05, 2011 at 10:29:18AM +0200, Tom de Vries wrote:
>> Hi Eric,
>>
>> During testing the approved-for-commit middle-end patch for bug 43864 on 
>> ARM, I
>> ran into a gcc.dg/torture/pr46068.c ICE.
>>
>> An asm jump is not recognized as an unconditional jump, so its followed by a
>> fall-through block rather than a barrier.
>> ...
>> (jump_insn 10 9 19 4 (asm_operands/v ("") ("") 0 []
>>  []
>>  [
>> (label_ref:SI 16)
>> ] pr46068.c:16) pr46068.c:6 -1
>>  (nil)
>>  -> 16)
>> ...
>>
>> ce3 then turns the asm jump into an asm return, still without a barrier 
>> after it:
>> ...
>> (jump_insn 10 9 19 4 (asm_operands/v ("") ("") 0 []
>>  []
>>  [
>> (return)
>> ] pr46068.c:16) pr46068.c:6 -1
>>  (nil)
>>  -> return)
>> ...
> 
> I'd say the above transformation shouldn't be valid, asm goto is given some
> possible labels it can jump to, but what will be emitted when the operand is
> RETURN?  I think final.c does:
> else if (letter == 'l')
>   output_asm_label (operands[opnum]);
> here and when operands[opnum] isn't a label or deleted label, that function
> will
>   output_operand_lossage ("'%%l' operand isn't a label");
> You don't get it only because this testcase uses empty inline asm string
> and thus doesn't use any of the labels.

Right, if I use something like "b %l0", I hit the error you describe.

> 
>   Jakub

I managed to prevent the transformation using attached untested patch.

Is this the proper way to fix this?

Thanks,
- Tom
Index: gcc/recog.c
===
--- gcc/recog.c (revision 178145)
+++ gcc/recog.c (working copy)
@@ -118,6 +118,46 @@ init_recog (void)
 }
 
 
+/* Return true if labels in asm operands BODY are LABEL_REFs.  */
+
+static bool
+asm_labels_ok (rtx body)
+{
+  rtx first, asmop = NULL;
+  int i;
+
+  if (asm_noperands (body) <= 0)
+return true;
+
+  switch (GET_CODE (body))
+{
+case ASM_OPERANDS:
+  asmop = body;
+  break;
+
+case SET:
+  asmop = SET_SRC (body);
+  break;
+
+case PARALLEL:
+  first = XVECEXP (body, 0, 0);
+  if (GET_CODE (first) != SET)
+	return true;
+  asmop = SET_SRC (first);
+  break;
+default:
+  gcc_unreachable ();
+  break;
+}
+
+  gcc_assert (GET_CODE (asmop) == ASM_OPERANDS);
+
+  for (i = 0; i < ASM_OPERANDS_LABEL_LENGTH (asmop); i++)
+if (GET_CODE (ASM_OPERANDS_LABEL (asmop, i)) != LABEL_REF)
+  return false;
+  return true;
+}
+
 /* Check that X is an insn-body for an `asm' with operands
and that the operands mentioned in it are legitimate.  */
 
@@ -129,6 +169,9 @@ check_asm_operands (rtx x)
   const char **constraints;
   int i;
 
+  if (!asm_labels_ok (x))
+return 0;
+
   /* Post-reload, be more strict with things.  */
   if (reload_completed)
 {


Re: [testsuite]: Fix gcc.dg/ipa/ipcp-3.c

2011-09-05 Thread Martin Jambor
Hi,

On Mon, Sep 05, 2011 at 02:08:18PM +0200, Georg-Johann Lay wrote:
> This test case contains expression 1 << 18 which leads to FAIL for targets 
> with
> sizeof(int) < 4.
> 
> The mask seems not to be relevant for the test and can be set to, e.g. 14.
> 

I have created the testcase by modifying the one for PR 43835
(testsuite/gcc.c-torture/execute/pr43835.c), the shift could probably
be removed from the test altogether (but of course shift by 14 is also
fine with me, though I cannot approve anything).  I'm just wondering
what kind of failure this causes (a compile time one?) and why that
same failure does not take place with the aforementioned pr43835.c
testcase...

BTW, unfortunately I have recently also added a bunch of such shifts
in testsuite/gcc.c-torture/execute/pr49886.c, are they OK?

Thanks,

Martin


> Ok?
> 
> testsuite/
>   * gcc.dg/ipa/ipcp-3.c (mark_cell): Use mask 1 << 14 instead of 1 << 18.
> 
> 
> 
> Index: gcc.dg/ipa/ipcp-3.c
> ===
> --- gcc.dg/ipa/ipcp-3.c (revision 178527)
> +++ gcc.dg/ipa/ipcp-3.c (working copy)
> @@ -34,7 +34,7 @@ static void
>  mark_cell(int * interp, Pcc_cell *c)
>  {
>if (c && c->type == 4 && c->p
> -  && !(c->p->flags & (1<<18)))
> +  && !(c->p->flags & (1<<14)))
>  never_ever(interp, c->p);
>  }
> 


Re: rtl_verify_flow_info fix

2011-09-05 Thread Jakub Jelinek
On Mon, Sep 05, 2011 at 02:31:32PM +0200, Tom de Vries wrote:
> --- gcc/recog.c (revision 178145)
> +++ gcc/recog.c (working copy)
> @@ -118,6 +118,46 @@ init_recog (void)
>  }
>  
>  
> +/* Return true if labels in asm operands BODY are LABEL_REFs.  */
> +
> +static bool
> +asm_labels_ok (rtx body)
> +{
> +  rtx first, asmop = NULL;
> +  int i;

asmop = extract_asm_operands (body);

if (asmop == NULL)
  return true;
?

I'd say you don't need to call asm_noperands after it.

Jakub


[Ada] Do not mention objects of task or protected type in Alfa section

2011-09-05 Thread Arnaud Charlet
The Alfa section of ALI files mentioned objects of task type or protected type
in effects, but it should not, because we do not consider effects on such
objects. The present patch fixes this.

Tested on x86_64-pc-linux-gnu, committed on trunk

2011-09-05  Johannes Kanig  

* lib-xref-alfa.adb (Is_Alfa_Reference): Never declare effects on
objects of task type or protected type.

Index: lib-xref-alfa.adb
===
--- lib-xref-alfa.adb   (revision 178448)
+++ lib-xref-alfa.adb   (working copy)
@@ -620,7 +620,22 @@
   return False;
 
when others =>
+
+  --  Objects of Task type or protected type are not Alfa
+  --  references.
+
+  if Present (Etype (E)) then
+ case Ekind (Etype (E)) is
+when E_Task_Type | E_Protected_Type =>
+   return False;
+
+when others =>
+   null;
+ end case;
+  end if;
+
   return Typ = 'r' or else Typ = 'm';
+
 end case;
  end Is_Alfa_Reference;
 


[Ada] Overload resolution of intrinsic operators

2011-09-05 Thread Arnaud Charlet
This patch fixes a bug where the compiler would give an incorrect error message
when an intrinsic operator is called with operands of private type, but with a
result of a non-private type.
The following test should compile quietly.
package Test_Intrinsics is

  type T is private;

  X : constant T;

  function "*" (X, Y : T) return Float;

private

  type T is new Float;

  X : constant T := 0.0;

  pragma Import (Intrinsic, "*");

end Test_Intrinsics;


with Test_Intrinsics; use Test_Intrinsics;
procedure Test_Intrinsics_Main is

  Y : Float := X * X;

begin
   null;
end Test_Intrinsics_Main;

Tested on x86_64-pc-linux-gnu, committed on trunk

2011-09-05  Bob Duff  

* sem_res.adb (Resolve_Intrinsic_Operator): Use unchecked
conversions instead of normal type conversions in all cases where a
type conversion would be illegal. In particular, use unchecked
conversions when the operand types are private.

Index: sem_res.adb
===
--- sem_res.adb (revision 178460)
+++ sem_res.adb (working copy)
@@ -7145,6 +7145,8 @@
  return Res;
   end Convert_Operand;
 
+  --  Start of processing for Resolve_Intrinsic_Operator
+
begin
   --  We must preserve the original entity in a generic setting, so that
   --  the legality of the operation can be verified in an instance.
@@ -7162,11 +7164,14 @@
   Set_Entity (N, Op);
   Set_Is_Overloaded (N, False);
 
-  --  If the operand type is private, rewrite with suitable conversions on
-  --  the operands and the result, to expose the proper underlying numeric
-  --  type.
+  --  If the result or operand types are private, rewrite with unchecked
+  --  conversions on the operands and the result, to expose the proper
+  --  underlying numeric type.
 
-  if Is_Private_Type (Typ) then
+  if Is_Private_Type (Typ)
+or else Is_Private_Type (Etype (Left_Opnd (N)))
+or else Is_Private_Type (Etype (Right_Opnd (N)))
+  then
  Arg1 := Convert_Operand (Left_Opnd (N));
  --  Unchecked_Convert_To (Btyp, Left_Opnd  (N));
 


[Ada] Better error recovery for unparenthesized expression functions

2011-09-05 Thread Arnaud Charlet
In Ada2012, the expression that proides the body of an expression function must
be parenthesized. This patch improves the error recovery for what we expect to
be the common error of omitting those parentheses.

Compiling t.ads must yield:

   t.ads:21:06: expression function must be enclosed in parentheses

--
package T is
 Max_Length : constant Integer := 100;
 type Element_Type is range 0 .. 1_000_000;

 subtype Length_Range is Integer range 0 .. Max_Length;
 subtype Index_Range is Integer range 1..Max_Length;

 type Table is tagged private;

 procedure Insert (T : in out Table;
   E : in Element_Type)
 with
   Pre'Class  => Allows_Insert(T, E),
   Post'Class =>
 ( Length(T) >= Length(T'Old) ) and
 ( Is_In(T, E ) and
 ( for all J in 1 .. Length(T'Old) => Is_In(T, Element_At(T'Old, J)) ));

 function Allows_Insert( T : Table;
 E : Element_Type ) return Boolean is
 Length(T)

* par-ch6.adb (P_Subprogram): In Ada2012 mode, if the subprogram
appears within a package specification and the token after "IS"
is not a parenthesis, assume that this is an unparenthesized
expression function, even if the token appears in a line by
itself.
* par.adb: Clarify use of Labl field of scope stack in error
recovery.

Index: par.adb
===
--- par.adb (revision 178381)
+++ par.adb (working copy)
@@ -466,15 +466,22 @@
   --  control heuristic error recovery actions.
 
   Labl : Node_Id;
-  --  This field is used only for the LOOP and BEGIN cases, and is the
-  --  Node_Id value of the label name. For all cases except child units,
-  --  this value is an entity whose Chars field contains the name pointer
-  --  that identifies the label uniquely. For the child unit case the Labl
-  --  field references an N_Defining_Program_Unit_Name node for the name.
-  --  For cases other than LOOP or BEGIN, the Label field is set to Error,
-  --  indicating that it is an error to have a label on the end line.
+  --  This field is used to provide the name of the construct being parsed
+  --  and indirectly its kind. For loops and blocks, the field contains the
+  --  source name or the generated one. For package specifications, bodies,
+  --  subprogram specifications and bodies the field holds the correponding
+  --  program unit name. For task declarations and bodies, protected types
+  --  and bodies, and accept statements the field hold the name of the type
+  --  or operation. For if-statements, case-statements, and selects, the
+  --  field is initialized to Error, indicating that it is an error to have
+  --  a label on the end line.
   --  (this is really a misuse of Error since there is no Error ???)
 
+  --  Whenever the field is a name, it is attached to the parent node of
+  --  the construct being parsed. Thus the parent node indicates the kind
+  --  of construct whose parse tree is being built. This is used in error
+  --  recovery.
+
   Decl : List_Id;
   --  Points to the list of declarations (i.e. the declarative part)
   --  associated with this construct. It is set only in the END [name]
Index: par-ch6.adb
===
--- par-ch6.adb (revision 178401)
+++ par-ch6.adb (working copy)
@@ -675,11 +675,43 @@
   else
  --  If the identifier is the first token on its line, then
  --  let's assume that we have a missing begin and this is
- --  intended as a subprogram body.
+ --  intended as a subprogram body. However, if the context
+ --  is a function and the unit is a package declaration, a
+ --  body would be illegal, so try for an unparenthesized
+ --  expression function.
 
  if Token_Is_At_Start_Of_Line then
-return False;
+declare
 
+   --  The enclosing scope entry is a subprogram spec.
+
+   Spec_Node : constant Node_Id :=
+Parent (Scope.Table (Scope.Last).Labl);
+   Lib_Node : Node_Id := Spec_Node;
+
+begin
+
+   --  Check whether there is an enclosing scope that
+   --  is a package declaration.
+
+   if Scope.Last > 1 then
+  Lib_Node  :=
+Parent (Scope.Table (Scope.Last - 1).Labl);
+   end if;
+
+   if Ada_Version >= Ada_2012
+ and then
+   Nkind (Lib_Node) = N_Package_Specification
+

[Ada] Filter constants from effect information in ALI files

2011-09-05 Thread Arnaud Charlet
Constants cannot be modified, and so should never appear in the ALFA section
of ALI files as effects. This patch enforces this property.

Tested on x86_64-pc-linux-gnu, committed on trunk

2011-09-05  Johannes Kanig  

* lib-xref-alfa.adb (Is_Alfa_Reference): Filter constants from effect
information.

Index: lib-xref-alfa.adb
===
--- lib-xref-alfa.adb   (revision 178531)
+++ lib-xref-alfa.adb   (working copy)
@@ -616,7 +616,9 @@
--  section, as these will be translated as constants in the
--  intermediate language for formal verification.
 
-   when E_In_Parameter =>
+   --  Above comment is incomplete??? what about E_Constant case
+
+   when E_In_Parameter | E_Constant =>
   return False;
 
when others =>
@@ -624,18 +626,13 @@
   --  Objects of Task type or protected type are not Alfa
   --  references.
 
-  if Present (Etype (E)) then
- case Ekind (Etype (E)) is
-when E_Task_Type | E_Protected_Type =>
-   return False;
-
-when others =>
-   null;
- end case;
+  if Present (Etype (E))
+and then Ekind (Etype (E)) in Concurrent_Kind
+  then
+ return False;
   end if;
 
   return Typ = 'r' or else Typ = 'm';
-
 end case;
  end Is_Alfa_Reference;
 


[Ada] Cover all cases of constant objects for ALFA section in ALI files

2011-09-05 Thread Arnaud Charlet
The test which filters constants objects so that they do not appear in the
ALFA sections of ALI files did not cover all the cases. This patch corrects
the problem.

Tested on x86_64-pc-linux-gnu, committed on trunk

2011-09-05  Johannes Kanig  

* lib-xref-alfa.adb (Is_Alfa_Reference): Improve test for constant
objects and rewrite case statement as /if/elsif/endif.

Index: lib-xref-alfa.adb
===
--- lib-xref-alfa.adb   (revision 178536)
+++ lib-xref-alfa.adb   (working copy)
@@ -604,38 +604,36 @@
 Typ : Character) return Boolean
  is
  begin
---  The only references of interest on callable entities are calls.
---  On non-callable entities, the only references of interest are
---  reads and writes.
 
-case Ekind (E) is
-   when Overloadable_Kind =>
-  return Typ = 's';
+if Ekind (E) in Overloadable_Kind then
 
-   --  References to IN parameters and constants are not
-   --  considered in Alfa section, as these will be translated
-   --  as constants in the intermediate language for formal
-   --  verification, and should therefore never appear in frame
-   --  conditions.
+   --  The only references of interest on callable entities are
+   --  calls.  On non-callable entities, the only references of
+   --  interest are reads and writes.
 
-   --  What about E_Loop_Parameter???
+   return Typ = 's';
 
-   when E_In_Parameter | E_Constant =>
+elsif Is_Constant_Object (E) then
+
+   --  References to constant objects are not considered in Alfa
+   --  section, as these will be translated as constants in the
+   --  intermediate language for formal verification, and should
+   --  therefore never appear in frame conditions.
+
   return False;
 
-   when others =>
+elsif Present (Etype (E)) and then
+   Ekind (Etype (E)) in Concurrent_Kind then
 
-  --  Objects of Task type or protected type are not Alfa
-  --  references.
+   --  Objects of Task type or protected type are not Alfa
+   --  references.
 
-  if Present (Etype (E))
-and then Ekind (Etype (E)) in Concurrent_Kind
-  then
- return False;
-  end if;
+   return False;
 
-  return Typ = 'r' or else Typ = 'm';
-end case;
+else
+   return Typ = 'r' or else Typ = 'm';
+
+end if;
  end Is_Alfa_Reference;
 
  ---


[Ada] Detect illegal use of unconstrained string type in SPARK mode

2011-09-05 Thread Arnaud Charlet
When the SPARK restriction mode was set, check that a declaration of 
unconstrained type is allowed only for constants of type string.

compiling above string_type.ad(s|b) with SPARK mode 
gcc -c -gnat05 -gnatec=../spark.adc string_type.adb 
the following output must yield:
string_type.adb:1:19: violation of restriction "SPARK" at ../spark.adc:1
string_type.adb:1:19:  use clause is not allowed
string_type.adb:9:07: violation of restriction "SPARK" at ../spark.adc:1
string_type.adb:9:07:  declaration of object of unconstrained type not allowed
string_type.adb:9:12: unconstrained subtype not allowed (need initialization)
string_type.adb:9:12: provide initial value or explicit array bounds
string_type.adb:10:07: violation of restriction "SPARK" at ../spark.adc:1
string_type.adb:10:07:  declaration of object of unconstrained type not allowed
string_type.adb:10:22: violation of restriction "SPARK" at ../spark.adc:1
string_type.adb:10:22:  attribute "Image" is not allowed
string_type.adb:10:22: violation of restriction "SPARK" at ../spark.adc:1
string_type.adb:10:22:  initialization expression is not appropriate
string_type.adb:11:07: violation of restriction "SPARK" at ../spark.adc:1
string_type.adb:11:07:  declaration of object of unconstrained type not allowed
string_type.adb:12:07: violation of restriction "SPARK" at ../spark.adc:1
string_type.adb:12:07:  declaration of object of unconstrained type not allowed
string_type.adb:16:31: violation of restriction "SPARK" at ../spark.adc:1
string_type.adb:16:31:  initialization expression is not appropriate
string_type.adb:17:07: violation of restriction "SPARK" at ../spark.adc:1
string_type.adb:17:07:  declaration of object of unconstrained type not allowed
string_type.adb:17:22: violation of restriction "SPARK" at ../spark.adc:1
string_type.adb:17:22:  attribute "Image" is not allowed
string_type.adb:17:22: violation of restriction "SPARK" at ../spark.adc:1
string_type.adb:17:22:  initialization expression is not appropriate
string_type.adb:18:19: violation of restriction "SPARK" at ../spark.adc:1
string_type.adb:18:19:  subtype mark required
string_type.adb:18:27: violation of restriction "SPARK" at ../spark.adc:1
string_type.adb:18:27:  subtype mark required
string_type.ads:4:27: violation of restriction "SPARK" at ../spark.adc:1
string_type.ads:4:27:  subtype mark required

package String_Type is
  subtype Line_Index is Integer range 1 .. 100;
  subtype Line1 is String(Line_Index);
  subtype Line2 is String(Positive range 2 .. 100);
  procedure String_Eq (My_Line  : out String;
   My_Line1 : out Line1;
   My_Line2 : out Line2;
   X: Integer);
end String_Type;

with Ada.Text_IO; use Ada.Text_IO;
package body String_Type is
   --# main_program;
 procedure String_Eq (My_Line  : out String;
  My_Line1 : out Line1;
  My_Line2 : out Line2;
  X: Integer )
 is
  S1 : String;
  S2 : String := Integer'Image (X);
  S3 : String := "abc";
  S4 : String := "abc" & "def";
  S5 : constant String := "abc";
  S6 : constant String := "abc" & "def";
  S7 : constant String := S5 & S6;
  S8 : constant String := Get_Line;
  S9 : String := Integer'Image (X);
  Next_Line : String (1 .. 100);
  Next_Line1 : Line1;
  Next_Line2 : Line2;
   begin
  null;
   end String_Eq;
end String_Type;

Tested on x86_64-pc-linux-gnu, committed on trunk

2011-09-05  Marc Sango  

* sem_ch3.adb (Analyze_Object_Declaration): Remove
the wrong test and add the correct test to detect the violation
of illegal use of unconstrained string type in SPARK mode.

Index: sem_ch3.adb
===
--- sem_ch3.adb (revision 178537)
+++ sem_ch3.adb (working copy)
@@ -3267,6 +3267,16 @@
 
   if Is_Indefinite_Subtype (T) then
 
+ --  In SPARK, a declaration of unconstrained type is allowed
+ --  only for constants of type string.
+
+ if Is_String_Type (T)
+   and then not Constant_Present (Original_Node (N)) then
+Check_SPARK_Restriction
+  ("declaration of object of unconstrained type not allowed",
+   N);
+ end if;
+
  --  Nothing to do in deferred constant case
 
  if Constant_Present (N) and then No (E) then
@@ -3313,21 +3323,10 @@
  --  Case of initialization present
 
  else
---  Check restrictions in Ada 83 and SPARK modes
+--  Check restrictions in Ada 83
 
 if not Constant_Present (N) then
 
-   --  In SPARK, a declaration of unconstrained type is allowed
-   --  only for constants of type string.
-
-   --  Isn't following check the wrong way round???
-
-   if Nkind (E) = N_String_Literal then
-  Check_SPARK_Restriction
- 

[Ada] Illegal iterators over arrays

2011-09-05 Thread Arnaud Charlet
In early versions of Ada, an illegal iterator of the form "for X in S" where
S is an array, is most likely an attempt to iterate over the range of S, and
this is the appropriate error message to emit.  In Ada 2012, there is a new
iterator specification form "for E of S", and the error message must indicate
that the new form uses a different keyword.

Compiling the following program in Ada 2012 mode must yield:

main.adb:7:14: to iterate over the elements of an array, use "of"
main.adb:15:14: to iterate over the elements of an array, use "of"

Compiling with an earlier version of the language must yield;

main.adb:7:14: missing Range attribute in iteration over an array
main.adb:15:14: missing Range attribute in iteration over an array

---
with Ada.Text_IO;
with Tools;
with Type_Declarations;
package body Main is
   procedure Process is
   begin
 for Index in Tools.Result loop
Ada.Text_IO.Put_Line (Tools.Result (Index)'Img);
 end loop;
   end Process;

   procedure Process2 is
  Ct : constant Type_Declarations.Array_Type := Tools.Result;
   begin
 for Index in Ct loop
Ada.Text_IO.Put_Line (Tools.Result (Index)'Img);
 end loop;
   end Process2;
end Main;
--
with Type_Declarations;

package Tools is
   function Result
  return Type_Declarations.Array_Type;
end Tools;
---
package Type_Declarations is

   type Integer_Type is new Integer;
   Ct_Max : constant := 40;

   type Large_Index_Type is new Integer range 0 .. Ct_Max;
   subtype Index_Type is Large_Index_Type range 1 .. Large_Index_Type'Last;

   type Array_Type is array (Index_Type range <>) of Integer_Type;
end Type_Declarations;

Tested on x86_64-pc-linux-gnu, committed on trunk

2011-09-05  Ed Schonberg  

* sem_ch5.adb (Analyze_Iteration_Specification): Improve error
message on an iterator over an array.

Index: sem_ch5.adb
===
--- sem_ch5.adb (revision 178448)
+++ sem_ch5.adb (working copy)
@@ -2336,13 +2336,18 @@
   if Is_Array_Type (Typ) then
  if Of_Present (N) then
 Set_Etype (Def_Id, Component_Type (Typ));
+
+ elsif Ada_Version < Ada_2012 then
+Error_Msg_N
+  ("missing Range attribute in iteration over an array", N);
+
  else
 Error_Msg_N
   ("to iterate over the elements of an array, use OF", N);
 
 --  Prevent cascaded errors
 
-Set_Ekind (Def_Id, E_Constant);
+Set_Ekind (Def_Id, E_Loop_Parameter);
 Set_Etype (Def_Id, Etype (First_Index (Typ)));
  end if;
 


Re: [testsuite]: Fix gcc.dg/ipa/ipcp-3.c

2011-09-05 Thread Georg-Johann Lay
Martin Jambor schrieb:
> Hi,
> 
> On Mon, Sep 05, 2011 at 02:08:18PM +0200, Georg-Johann Lay wrote:
>> This test case contains expression 1 << 18 which leads to FAIL for targets 
>> with
>> sizeof(int) < 4.
>>
>> The mask seems not to be relevant for the test and can be set to, e.g. 14.
>>
> 
> I have created the testcase by modifying the one for PR 43835
> (testsuite/gcc.c-torture/execute/pr43835.c), the shift could probably
> be removed from the test altogether (but of course shift by 14 is also
> fine with me, though I cannot approve anything).  I'm just wondering
> what kind of failure this causes (a compile time one?) and why that

It's a warning that leads to test fail:

gcc/testsuite/gcc.dg/ipa/ipcp-3.c: In function 'mark_cell':
gcc/testsuite/gcc.dg/ipa/ipcp-3.c:37:7: warning: left shift count >= width of
type [enabled by default]
output is:
gcc/testsuite/gcc.dg/ipa/ipcp-3.c: In function 'mark_cell':
gcc/testsuite/gcc.dg/ipa/ipcp-3.c:37:7: warning: left shift count >= width of
type [enabled by default]

FAIL: gcc.dg/ipa/ipcp-3.c (test for excess errors)
Excess errors:
gcc/testsuite/gcc.dg/ipa/ipcp-3.c:37:7: warning: left shift count >= width of
type [enabled by default]

> same failure does not take place with the aforementioned pr43835.c
> testcase...

I had a look at the test results and there is no warning for shift >= width of
type for pr43835.c. Strange...

> BTW, unfortunately I have recently also added a bunch of such shifts
> in testsuite/gcc.c-torture/execute/pr49886.c, are they OK?

As mentioned above, such shifts lead to respective warning and the unexpected
output to test fail. So either the test case has to be flexible enough to treat
also small targets with sizeof(int) = 16 or add some gate like

/* { dg-require-effective-target int32plus } */

because if a test case actually uses a bit >= 16 on such a target it will very
likely show malfunction anyway which is not intended for these kind of tests.

> Thanks,
> 
> Martin
> 
> 
>> Ok?
>>
>> testsuite/
>>  * gcc.dg/ipa/ipcp-3.c (mark_cell): Use mask 1 << 14 instead of 1 << 18.
>>
>>
>>
>> Index: gcc.dg/ipa/ipcp-3.c
>> ===
>> --- gcc.dg/ipa/ipcp-3.c (revision 178527)
>> +++ gcc.dg/ipa/ipcp-3.c (working copy)
>> @@ -34,7 +34,7 @@ static void
>>  mark_cell(int * interp, Pcc_cell *c)
>>  {
>>if (c && c->type == 4 && c->p
>> -  && !(c->p->flags & (1<<18)))
>> +  && !(c->p->flags & (1<<14)))
>>  never_ever(interp, c->p);
>>  }
>>


[Ada] Anonymous access types in type declarations in child units

2011-09-05 Thread Arnaud Charlet
This patch sets properly the scope of an anonymous access type created for
an access to class-wide type declaration in a child unit. Previously the scope
was set to the parent unit, leading to anomalous behavior in the back end.

The following must compile quietly in Ada 2005 mode:

---
package Parent is end;
---
 package Parent.Child is 
type Employee is abstract tagged  private;
type myBosses_Type_Array is
  array (Integer range <>) of access Employee'Class;
type myBosses_Type is access all myBosses_Type_Array;
 private
type Employee is abstract tagged record 
   myBosses : myBosses_Type;
end record;
 end;
---

Tested on x86_64-pc-linux-gnu, committed on trunk

2011-09-05  Ed Schonberg  

* sem_ch3.adb (Access_Definition): If an access type declaration
appears in a child unit, the scope of whatever anonymous type
may be generated is the child unit itself.

Index: sem_ch3.adb
===
--- sem_ch3.adb (revision 178542)
+++ sem_ch3.adb (working copy)
@@ -772,10 +772,16 @@
 Anon_Scope := Scope (Defining_Entity (Related_Nod));
  end if;
 
+ --  For an access type definition, if the current scope is a child
+ --  unit it is the scope of the type.
+
+  elsif Is_Compilation_Unit (Current_Scope) then
+ Anon_Scope := Current_Scope;
+
+  --  For access formals, access components, and access discriminants, the
+  --  scope is that of the enclosing declaration,
+
   else
- --  For access formals, access components, and access discriminants,
- --  the scope is that of the enclosing declaration,
-
  Anon_Scope := Scope (Current_Scope);
   end if;
 


[testsuite,committed]: Fix gcc.dg/ipa/ipcp-3.c

2011-09-05 Thread Georg-Johann Lay
Committed as obvious.

http://gcc.gnu.org/viewcvs?view=revision&revision=178545


Martin Jambor schrieb:
> Hi,
> 
> On Mon, Sep 05, 2011 at 02:08:18PM +0200, Georg-Johann Lay wrote:
>> This test case contains expression 1 << 18 which leads to FAIL for targets 
>> with
>> sizeof(int) < 4.
>>
>> The mask seems not to be relevant for the test and can be set to, e.g. 14.
>>
> 
> I have created the testcase by modifying the one for PR 43835
> (testsuite/gcc.c-torture/execute/pr43835.c), the shift could probably
> be removed from the test altogether (but of course shift by 14 is also
> fine with me, though I cannot approve anything).  I'm just wondering
> what kind of failure this causes (a compile time one?) and why that
> same failure does not take place with the aforementioned pr43835.c
> testcase...
> 
> BTW, unfortunately I have recently also added a bunch of such shifts
> in testsuite/gcc.c-torture/execute/pr49886.c, are they OK?
> 
> Thanks,
> 
> Martin
> 
> 
>> Ok?
>>
>> testsuite/
>>  * gcc.dg/ipa/ipcp-3.c (mark_cell): Use mask 1 << 14 instead of 1 << 18.
>>
>>
>>
>> Index: gcc.dg/ipa/ipcp-3.c
>> ===
>> --- gcc.dg/ipa/ipcp-3.c (revision 178527)
>> +++ gcc.dg/ipa/ipcp-3.c (working copy)
>> @@ -34,7 +34,7 @@ static void
>>  mark_cell(int * interp, Pcc_cell *c)
>>  {
>>if (c && c->type == 4 && c->p
>> -  && !(c->p->flags & (1<<18)))
>> +  && !(c->p->flags & (1<<14)))
>>  never_ever(interp, c->p);
>>  }
>>



[Ada] in GNAT.Command_Line, allow user to replace the standard help message

2011-09-05 Thread Arnaud Charlet
GNAT.Command_Line automatically computes a help message showing all supported
switches. This patch allows to replace this automatic message by a user given
one, in case the automatic one does not fit.

Tested on x86_64-pc-linux-gnu, committed on trunk

2011-09-05  Johannes Kanig  

* g-comlin.adb (Set_Usage): Additional optional argument to set help
message.
(Display_Help): display the user given help message, if available.

Index: g-comlin.adb
===
--- g-comlin.adb(revision 178536)
+++ g-comlin.adb(working copy)
@@ -3026,9 +3026,10 @@
---
 
procedure Set_Usage
- (Config : in out Command_Line_Configuration;
-  Usage  : String := "[switches] [arguments]";
-  Help   : String := "")
+ (Config   : in out Command_Line_Configuration;
+  Usage: String := "[switches] [arguments]";
+  Help : String := "";
+  Help_Msg : String := "")
is
begin
   if Config = null then
@@ -3036,8 +3037,9 @@
   end if;
 
   Free (Config.Usage);
-  Config.Usage := new String'(Usage);
-  Config.Help  := new String'(Help);
+  Config.Usage:= new String'(Usage);
+  Config.Help := new String'(Help);
+  Config.Help_Msg := new String'(Help_Msg);
end Set_Usage;
 
--
@@ -3222,12 +3224,15 @@
& " [switches] [arguments]");
   end if;
 
-  Display_Section_Help ("");
-
-  if Config.Sections /= null and then Config.Switches /= null then
- for S in Config.Sections'Range loop
-Display_Section_Help (Config.Sections (S).all);
- end loop;
+  if Config.Help_Msg /= null and then Config.Help_Msg.all /= "" then
+ Put_Line (Config.Help_Msg.all);
+  else
+ Display_Section_Help ("");
+ if Config.Sections /= null and then Config.Switches /= null then
+for S in Config.Sections'Range loop
+   Display_Section_Help (Config.Sections (S).all);
+end loop;
+ end if;
   end if;
end Display_Help;
 
Index: g-comlin.ads
===
--- g-comlin.ads(revision 178438)
+++ g-comlin.ads(working copy)
@@ -664,11 +664,14 @@
--  Output is always initialized to the empty string.
 
procedure Set_Usage
- (Config : in out Command_Line_Configuration;
-  Usage  : String := "[switches] [arguments]";
-  Help   : String := "");
+ (Config   : in out Command_Line_Configuration;
+  Usage: String := "[switches] [arguments]";
+  Help : String := "";
+  Help_Msg : String := "");
--  Defines the general format of the call to the application, and a short
-   --  help text. These are both displayed by Display_Help
+   --  help text. These are both displayed by Display_Help. When a non-empty
+   --  Help_Msg is given, it is used by Display_Help instead of the
+   --  automatically generated list of supported switches.
 
procedure Display_Help (Config : Command_Line_Configuration);
--  Display the help for the tool (ie its usage, and its supported switches)
@@ -1134,6 +1137,7 @@
   Aliases  : Alias_Definitions_List;
   Usage: GNAT.OS_Lib.String_Access;
   Help : GNAT.OS_Lib.String_Access;
+  Help_Msg : GNAT.OS_Lib.String_Access;
   Switches : Switch_Definitions_List;
   --  List of expected switches (Used when expanding switch groups)
end record;


[Ada] Interface type conversions are not dynamically tagged

2011-09-05 Thread Arnaud Charlet
A view conversion to an interface type is expanded into a dereference of a
temporary that involves the class-wide interface type. Nevertheless such an
expression is not dynamically tagged, and is not a controlling argument in 
a call.

Compiling main.adb must be rejected with:

   main.adb:8:10: call to abstract procedure must be dispatching

---
with Types; use Types;
procedure Main is
V : R;
begin
I (V).P1;
I'Class (V).P1;
I (V).P2;
I'Class (V).P2;
end Main;
---
package Types  is
  type I is interface;

   procedure P1 (V : I)  is null;
   procedure P2 (V : I) is abstract;

   type R is new I with null record;

   procedure P2 (V : R) is null;
end Types;

Tested on x86_64-pc-linux-gnu, committed on trunk

2011-09-05  Ed Schonberg  

* sem_disp.adb (Find_Controlling_Arg): Add checks for
interface type conversions, that are expanded into dereferences.

Index: sem_disp.adb
===
--- sem_disp.adb(revision 178381)
+++ sem_disp.adb(working copy)
@@ -1616,6 +1616,32 @@
   then
  return Controlling_Argument (Orig_Node);
 
+  --  Type conversions are dynamically tagged if the target type, or its
+  --  designated type, are classwide. An interface conversion expands into
+  --  a dereference, so test must be performed on the original node.
+
+  elsif Nkind (Orig_Node) = N_Type_Conversion
+and then Nkind (N) = N_Explicit_Dereference
+and then Is_Controlling_Actual (N)
+  then
+ declare
+Target_Type : constant Entity_Id :=
+ Entity (Subtype_Mark (Orig_Node));
+
+ begin
+if Is_Class_Wide_Type (Target_Type) then
+   return N;
+
+elsif Is_Access_Type (Target_Type)
+  and then Is_Class_Wide_Type (Designated_Type (Target_Type))
+then
+   return N;
+
+else
+   return Empty;
+end if;
+ end;
+
   --  Normal case
 
   elsif Is_Controlling_Actual (N)


[Ada] Error recovery on subunits with serious syntax errors

2011-09-05 Thread Arnaud Charlet
This patch protects the compiler against cascaded errors and infinite loops
when analyzing a subunit that has serious syntax errors and an incomplete
context.

Compiling configurations.adb must yield:

   configurations.adb:1:01: spec of this package does not allow a body
   configurations-kernel-system_model.adb:7:05: misplaced "return" statement
   configurations-kernel-system_model.adb:8:02:
missing "begin" for function "Exists" at line 5
---
with text_IO;
 separate (Configurations.Kernel)
package body System_Model is
  --  syntactic  errors below 
  function Exists (NickNum: Integer) return Boolean  is
  --  begin
return False;
  end Exists;
end System_Model;
--
separate(Configurations)
package body Kernel is
  package System_Model is
  end System_Model;
  package body System_Model is separate;
end Kernel;
--
package body Configurations is
   --  actually proper body not allowed ...
   package body Kernel is separate;
begin
  null;
end Configurations;
--
generic
package Configurations is
   package Kernel is
   end Kernel;
end Configurations;
--

Tested on x86_64-pc-linux-gnu, committed on trunk

2011-09-05  Ed Schonberg  

* sem_ch10.adb (Analyze_Context): Apply simple fixup if context
of subunit is incomplete.
(Analyze_Proper_Body): If parent spec is not available, do not
attempt analysis.

Index: sem_ch10.adb
===
--- sem_ch10.adb(revision 178534)
+++ sem_ch10.adb(working copy)
@@ -1650,6 +1650,16 @@
 
  if Present (Library_Unit (N)) then
 Set_Corresponding_Stub (Unit (Library_Unit (N)), N);
+
+--  If the subunit has severe errors, the spec of the enclosing
+--  body may not be available, in which case do not try analysis.
+
+if Serious_Errors_Detected > 0
+  and then  No (Library_Unit (Library_Unit (N)))
+then
+   return;
+end if;
+
 Analyze_Subunit (Library_Unit (N));
 
  --  Otherwise we must load the subunit and link to it
@@ -1990,6 +2000,16 @@
  null;
 
   else
+ --  If a subunits has serious syntax errors, the context
+ --  may not have been loaded. Add a harmless unit name to
+ --  attempt processing.
+
+ if Serious_Errors_Detected > 0
+   and then  No (Entity (Name (Item)))
+ then
+Set_Entity (Name (Item), Standard_Standard);
+ end if;
+
  Unit_Name := Entity (Name (Item));
  while Is_Child_Unit (Unit_Name) loop
 Set_Is_Visible_Child_Unit (Unit_Name);


[Ada] Synchronization issues in Set_Finalize_Address

2011-09-05 Thread Arnaud Charlet
This patch adds task synchronization code to the mechanism which sets TSS
primitive Finalize_Address at run time. The following test should compile
and execute quietly.

-
-- Sources --
-

--  main.adb:

with Ada.Finalization; use Ada.Finalization;
with Ada.Text_IO;  use Ada.Text_IO;

procedure Main is
   Max_Tasks  : constant Natural := 200;
   Expected   : constant Natural := Max_Tasks / 2;
   Even_Count : Natural := 0;
   Odd_Count  : Natural := 0;

begin
   declare
  type Even_Tracker is new Controlled with null record;
  procedure Finalize (Obj : in out Even_Tracker);
  procedure Finalize (Obj : in out Even_Tracker) is
  begin
 Even_Count := Even_Count + 1;
  end Finalize;

  type Odd_Tracker is new Controlled with null record;
  procedure Finalize (Obj : in out Odd_Tracker);
  procedure Finalize (Obj : in out Odd_Tracker) is
  begin
 Odd_Count := Odd_Count + 1;
  end Finalize;

  type Root is tagged null record;
  subtype Any_Root is Root'Class;
  type Any_Root_Ptr is access all Any_Root;

  type Even_Container is new Root with record
 Tracker : Even_Tracker;
  end record;

  type Odd_Container is new Root with record
 Tracker : Odd_Tracker;
  end record;

  task type Allocator is
 entry Create (Even_Kind : Boolean);
  end Allocator;

  type Allocator_Array is array (1 .. Max_Tasks) of Allocator;

  task body Allocator is
  begin
 select
accept Create (Even_Kind : Boolean) do
   declare
  Temp : Any_Root_Ptr;
   begin
  if Even_Kind then
 Temp := Any_Root_Ptr'(new Even_Container);
  else
 Temp := Any_Root_Ptr'(new Odd_Container);
  end if;
   end;
end Create;
 or
terminate;
 end select;
  end Allocator;

  Allocators : Allocator_Array;

   begin
  for Index in 1 .. Max_Tasks loop
 Allocators (Index).Create (Index mod 2 = 0);
  end loop;
   end;

   if Even_Count /= Expected then
  Put_Line ("ERROR: even count is off");
  Put_Line ("  got:" & Even_Count'Img);
  Put_Line ("  exp:" & Expected'Img);
   end if;

   if Odd_Count /= Expected then
  Put_Line ("ERROR: odd count is off");
  Put_Line ("  got:" & Odd_Count'Img);
  Put_Line ("  exp:" & Expected'Img); 
   end if;
end Main;

---
-- Compilation and execution --
---

gnatmake -q -gnat05 main.adb
main

Tested on x86_64-pc-linux-gnu, committed on trunk

2011-09-05  Hristian Kirtchev  

* s-finmas.adb (Set_Finalize_Address): Explain the reason
for the synchronization. Move the test for null from
s-stposu.Allocate_Any_Controlled to this routine since the check
needs to be protected too.
(Set_Heterogeneous_Finalize_Address): Explain the reason for the
synchronization code.
* s-finmas.ads (Set_Heterogeneous_Finalize_Address): Add comment
explaining the context in which this routine is used.
* s-stposu.adb (Allocate_Any_Controlled): Move the test for null
to s-finmas.Set_Finalize_Address.

Index: s-stposu.adb
===
--- s-stposu.adb(revision 178550)
+++ s-stposu.adb(working copy)
@@ -276,9 +276,7 @@
  --3) Most cases of anonymous access types usage
 
  if Master.Is_Homogeneous then
-if Finalize_Address (Master.all) = null then
-   Set_Finalize_Address (Master.all, Fin_Address);
-end if;
+Set_Finalize_Address (Master.all, Fin_Address);
 
  --  Heterogeneous masters service the following:
 
Index: s-finmas.adb
===
--- s-finmas.adb(revision 178550)
+++ s-finmas.adb(working copy)
@@ -463,8 +463,17 @@
   Fin_Addr_Ptr : Finalize_Address_Ptr)
is
begin
+  --  TSS primitive Finalize_Address is set at the point of allocation,
+  --  either through Allocate_Any_Controlled or through this routine.
+  --  Since multiple tasks can allocate on the same finalization master,
+  --  access to this attribute must be protected.
+
   Lock_Task.all;
-  Master.Finalize_Address := Fin_Addr_Ptr;
+
+  if Master.Finalize_Address = null then
+ Master.Finalize_Address := Fin_Addr_Ptr;
+  end if;
+
   Unlock_Task.all;
end Set_Finalize_Address;
 
@@ -477,6 +486,9 @@
   Fin_Addr_Ptr : Finalize_Address_Ptr)
is
begin
+  --  Protected access is required in this case because
+  --  Finalize_Address_Table is a global data structure.
+
   Lock_Task.all;
   Finalize_Address_Table.Set (Obj, Fin_Addr_Ptr);
   Unlock_Task.all;
Index: s-finmas.ads
===

[Ada] Check that rtsfind entities are not overloaded

2011-09-05 Thread Arnaud Charlet
This patch properly documents the rule that rtsfind entities may not
be overloaded, and adds a check that this rule is met. This found
one violation of the rule in the run time which has been fixed. No
test is required, since this clean up has no external effect.

Tested on x86_64-pc-linux-gnu, committed on trunk

2011-09-05  Robert Dewar  

* rtsfind.adb (Check_CRT): Check for overloaded entity
* rtsfind.ads: Document that entities to be found by rtsfind
cannot be overloaded
* s-taenca.adb, s-tasren.adb, s-tpobop.adb, s-tpoben.ads, s-tpoben.adb
(Lock_Entries_With_Status): New name for Lock_Entries with two
arguments (changed to meet rtsfind no overloading rule).

Index: s-tpoben.adb
===
--- s-tpoben.adb(revision 178381)
+++ s-tpoben.adb(working copy)
@@ -6,7 +6,7 @@
 --  --
 --   B o d y--
 --  --
---  Copyright (C) 1998-2010, Free Software Foundation, Inc. --
+--  Copyright (C) 1998-2011, Free Software Foundation, Inc. --
 --  --
 -- GNARL is free software; you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -261,7 +261,22 @@
-- Lock_Entries --
--
 
-   procedure Lock_Entries
+   procedure Lock_Entries (Object : Protection_Entries_Access) is
+  Ceiling_Violation : Boolean;
+
+   begin
+  Lock_Entries_With_Status (Object, Ceiling_Violation);
+
+  if Ceiling_Violation then
+ raise Program_Error with "Ceiling Violation";
+  end if;
+   end Lock_Entries;
+
+   --
+   -- Lock_Entries_With_Status --
+   --
+
+   procedure Lock_Entries_With_Status
  (Object: Protection_Entries_Access;
   Ceiling_Violation : out Boolean)
is
@@ -316,20 +331,8 @@
   Self_Id.Common.Protected_Action_Nesting + 1;
  end;
   end if;
+   end Lock_Entries_With_Status;
 
-   end Lock_Entries;
-
-   procedure Lock_Entries (Object : Protection_Entries_Access) is
-  Ceiling_Violation : Boolean;
-
-   begin
-  Lock_Entries (Object, Ceiling_Violation);
-
-  if Ceiling_Violation then
- raise Program_Error with "Ceiling Violation";
-  end if;
-   end Lock_Entries;
-

-- Lock_Read_Only_Entries --

Index: s-tpoben.ads
===
--- s-tpoben.ads(revision 178381)
+++ s-tpoben.ads(working copy)
@@ -6,7 +6,7 @@
 --  --
 --  S p e c --
 --  --
---  Copyright (C) 1992-2009, Free Software Foundation, Inc. --
+--  Copyright (C) 1992-2011, Free Software Foundation, Inc. --
 --  --
 -- GNARL is free software; you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -183,7 +183,7 @@
--  Unlock has been made by the caller. Program_Error is raised in case of
--  ceiling violation.
 
-   procedure Lock_Entries
+   procedure Lock_Entries_With_Status
  (Object: Protection_Entries_Access;
   Ceiling_Violation : out Boolean);
--  Same as above, but return the ceiling violation status instead of
Index: s-tasren.adb
===
--- s-tasren.adb(revision 178381)
+++ s-tasren.adb(working copy)
@@ -628,7 +628,7 @@
--  Requeue to a protected entry
 
Called_PO := POE.To_Protection (Entry_Call.Called_PO);
-   STPE.Lock_Entries (Called_PO, Ceiling_Violation);
+   STPE.Lock_Entries_With_Status (Called_PO, Ceiling_Violation);
 
if Ceiling_Violation then
   pragma Assert (Ex = Ada.Exceptions.Null_Id);
Index: rtsfind.adb
===
--- rtsfind.adb (revision 178381)
+++ rtsfind.adb (working copy)
@@ -135,7 +135,7 @@
--  Check entity Eid to ensure that configurable run-time restrictions are
--  met. May generate an error message (if RTE_Available_Call is false) and
--  raise RE_Not_Available if entity E does not exist (e.g. Eid is Empty).
-   --  Above documentation not clear ???
+   --  Also check that entity is not

Re: [PATCH] Add niagara3 and niagara4 cpu types.

2011-09-05 Thread David Miller
From: Eric Botcazou 
Date: Mon, 5 Sep 2011 09:20:35 +0200

> Great, thanks (superfluous gcc/ in the ChangeLog).  No improvements to the 
> SPARC port have been documented in http://gcc.gnu.org/gcc-4.7/changes.html 
> yet, so I'm going to write something down.

Thanks Eric, and thanks also for finding my changelog thinkos :-)


Re: Rename across basic block boundaries

2011-09-05 Thread Bernd Schmidt
On 09/01/11 16:16, Richard Sandiford wrote:
> Bernd Schmidt  writes:
>> On 08/26/11 14:57, Richard Sandiford wrote:
>>> Wouldn't a reverse post-order (inverted_post_order_compute) allow even
>>> more pre-opening (as well as being less code)?
>>
>> I can't really tell from the comments what that function is supposed to
>> produce.
> 
> Sorry, I thought it was supposed to produce a reverse postorder, but...
> 
>> I've made a change to use it to order the bbs, but that made rr
>> visit basic blocks without seeing any of their predecessors first,
> 
> ...I guess not. :-)  pre_and_rev_post_order_compute should though.
> Could you try that instead?

That seems to work for me.


Bernd
* regrename.c (struct du_head): Make nregs signed.
(closed_chains): Remove.
(create_new_chain): Return the new chain.
(chain_from_id): New static function.
(dump_def_use_chain): Change argument to be an int, indicating
the first ID to print.  All callers changed.
(merge_overlapping_regs): Use chain_from_id.  Assert that
chains don't conflict with themselves.
(rename_chains): Take no argument.  Iterate over id_to_chain
rather to find chains to rename.  Clear tick before the main
loop.
(struct incoming_reg_info): New struct.
(struct bb_rename_info): New struct.
(init_rename_info, set_incoming_from_chain, merge_chains): New
static functions.
(regrename_analyze): New static function, broken out of
regrename_optimize.  Record and make use of open chain information
at basic block boundaries, and merge chains where possible.
(scan_rtx_reg): Make this_nregs signed.  Don't update
closed_chains.
(build_def_use): Return a bool to indicate success.  All callers
changed.  Don't initialize global data here.
(regrename_optimize): Move most code out of here into
regrename_analyze.
* regs.h (add_range_to_hard_reg_set, remove_range_from_hard_reg_set,
range_overlaps_hard_reg_set_p, range_in_hard_reg_set_p): New
static inline functions.
* vec.h (FOR_EACH_VEC_ELT_FROM): New macro.

Index: gcc/regrename.c
===
--- gcc/regrename.c (revision 178293)
+++ gcc/regrename.c (working copy)
@@ -47,18 +47,24 @@
 
  1. Local def/use chains are built: within each basic block, chains are
opened and closed; if a chain isn't closed at the end of the block,
-   it is dropped.
+   it is dropped.  We pre-open chains if we have already examined a
+   predecessor block and found chains live at the end which match
+   live registers at the start of the new block.
 
- 2. For each chain, the set of possible renaming registers is computed.
+ 2. We try to combine the local chains across basic block boundaries by
+comparing chains that were open at the start or end of a block to
+   those in successor/predecessor blocks.
+
+ 3. For each chain, the set of possible renaming registers is computed.
This takes into account the renaming of previously processed chains.
Optionally, a preferred class is computed for the renaming register.
 
- 3. The best renaming register is computed for the chain in the above set,
+ 4. The best renaming register is computed for the chain in the above set,
using a round-robin allocation.  If a preferred class exists, then the
round-robin allocation is done within the class first, if possible.
The round-robin allocation of renaming registers itself is global.
 
- 4. If a renaming register has been found, it is substituted in the chain.
+ 5. If a renaming register has been found, it is substituted in the chain.
 
   Targets can parameterize the pass by specifying a preferred class for the
   renaming register for a given (super)class of registers to be renamed.  */
@@ -75,8 +81,9 @@ struct du_head
   struct du_head *next_chain;
   /* The first and last elements of this chain.  */
   struct du_chain *first, *last;
-  /* Describes the register being tracked.  */
-  unsigned regno, nregs;
+  /* Describe the register being tracked, register number and count.  */
+  unsigned regno;
+  int nregs;
 
   /* A unique id to be used as an index into the conflicts bitmaps.  */
   unsigned id;
@@ -140,6 +147,7 @@ static struct obstack rename_obstack;
 static void do_replace (struct du_head *, int);
 static void scan_rtx (rtx, rtx *, enum reg_class, enum scan_actions,
  enum op_type);
+static bool build_def_use (basic_block);
 
 typedef struct du_head *du_head_p;
 DEF_VEC_P (du_head_p);
@@ -151,9 +159,8 @@ static unsigned current_id;
 /* A mapping of unique id numbers to chains.  */
 static VEC(du_head_p, heap) *id_to_chain;
 
-/* List of currently open chains, and closed chains that can be renamed.  */
+/* List of currently open chains.  */
 static struct 

rs6000 toc reference rtl

2011-09-05 Thread Alan Modra
This patch changes the rtl used by rs6000 for a TOC reference address.
The old rtl for -mcmodel=small is:
  (plus (reg tocreg) (const (unspec [(symbol_ref sym)] UNSPEC_TOCREL)))
while the old rtl for -mcmodel=medium/large is:
  (set (reg rn)
(const (plus (reg r2) (high (const (unspec [(symbol_ref sym)]
   UNSPEC_TOCREL))
  (lo_sum (reg rn) (const (unspec [(symbol_ref sym)] UNSPEC_TOCREL)))

These change to
  (unspec [(symbol_ref sym) (reg tocreg)] UNSPEC_TOCREL)
and
  (set (reg rn)
(high (unspec [(symbol_ref sym) (reg r2)] UNSPEC_TOCREL)))
  (lo_sum (reg rn) (unspec [(symbol_ref sym) (reg r2)] UNSPEC_TOCREL))
respectively.

Why do I want to do this, apart from simplifying the rtl?  Well,
df-scan.c and other parts of gcc don't look inside a CONST for regs
(arguably a bug), so we don't see r2 as being live for the high part
of a large-toc sequence.  Consequently, Mike's change to split rtl for
indirect calls sometimes sees the scheduler moving the r2 load in the
indirect call sequence before a toc reference.  While I could have
tackled the CONST problem, I reckon doing so would be more likely to
destabilize other targets than the changes to cselib.c and cprop.c
below.

Bootstrapped and regression tested powerpc-linux and powerpc64-linux,
and also with a -mcmodel=small default.  OK for mainline?  Further
comments/explanation interspersed with changelog.

* cselib.c (preserve_only_constants): Remove HIGH rtx containing
value references.
* cprop.c (cprop_constant_p): Return false for HIGH rtx containing
value references.

Regs inside a HIGH cause value refs to appear.

* config/rs6000/predicates.md (input_operand): Match unspec.  Remove
redundant tests.

legitimate_constant_pool_address_p true now implies
toc_relative_expr_p is true.

* rs6000-protos.h (toc_relative_expr_p): Update prototype.
* const/rs6000/rs6000.c (tocrel_base, tocrel_offset): Make const.

const_rtx is a pain.  mode_dependent_address forces a const_rtx down
to here, but we need to pass this on to output_addr_const.

(legitimate_constant_pool_address_p): Move TARGET_TOC test and
register checks to..
(toc_relative_expr_p): ..here.  Add "strict" param.  Match new rtl
generated by create_TOC_reference.

toc_relative_expr_p is needed in input_operand for 'R' constraint, but
we can't allow medium/large toc to match without ensuring reload
actually gives us a reg.

(rs6000_delegitimize_address): Handle new rtl for toc refs.

Simpler checks here should fix 50191 as a side-effect.

(rs6000_cannot_force_const_mem, rs6000_find_base_term): Likewise.
(use_toc_relative_ref): New function, split out from..
(rs6000_emit_move): ..here.  Remove redundant tests.
(rs6000_legitimize_reload_address): Formatting.  Remove redundant
code.  Use use_toc_relative_ref.

The existing lo_sum/high case handles new toc refs.

(print_operand): Formatting, style.  Adjust for toc changes.
(print_operand_address): Likewise.
(rs6000_output_addr_const_extra): Likewise.
(create_TOC_reference): Put TOC_REGISTER in UNSPEC_TOCREL rather
than a PLUS.  Use this formulation for both high and low part
of -mcmodel=medium/large toc reference too.

Making the low-part depend on r2 is deliberate and necessary in the
face of ld editing code to nop out the high part.

* config/rs6000/rs6000.md (tls_gd, tls_gd_high): Similarly avoid
a PLUS in high part of addresses here.
(tls_ld, tls_ld_high, tls_got_dtprel, tls_got_dtprel_high): Likewise.
(tls_got_tprel, tls_got_tprel_high, largetoc_high): Likewise.
(largetoc_high, largetoc_low): Move earlier.  Cope when no
base reg available.

Index: gcc/cselib.c
===
--- gcc/cselib.c(revision 178035)
+++ gcc/cselib.c(working copy)
@@ -325,8 +325,9 @@ preserve_only_constants (void **x, void 
   && v->locs->next == NULL)
 {
   if (CONSTANT_P (v->locs->loc)
- && (GET_CODE (v->locs->loc) != CONST
- || !references_value_p (v->locs->loc, 0)))
+ && !((GET_CODE (v->locs->loc) == CONST
+   || GET_CODE (v->locs->loc) == HIGH)
+  && references_value_p (v->locs->loc, 0)))
return 1;
   if (cfa_base_preserved_val)
{
Index: gcc/cprop.c
===
--- gcc/cprop.c (revision 178035)
+++ gcc/cprop.c (working copy)
@@ -253,7 +253,13 @@ insert_set_in_table (rtx dest, rtx src, 
 static bool
 cprop_constant_p (const_rtx x)
 {
-  return CONSTANT_P (x) && (GET_CODE (x) != CONST || shared_const_p (x));
+  if (!CONSTANT_P (x))
+return false;
+  if (GET_CODE (x) == CONST)
+return shared_const_p (x);
+  if (GET_CODE (x) == HIGH)
+return !references_value_p (x, false);
+

Re: [PATCH][Ada] Fix shift_unc_components_for_thin_pointers for sizetype changes

2011-09-05 Thread Eric Botcazou
> This avoids setting the TREE_OVERFLOW bit on DECL_FIELD_OFFSET for
> the shifted bounds field.
>
> If DECL_FIELD_OFFSET of array-field is always a constant we could
> as well use
>
>   DECL_FIELD_OFFSET (bounds_field)
> = size_int (-int_byte_position (array_field));
>
> also I notice that DECL_OFFSET_ALIGN is now bogus for bounds_field.

Yes, the offsets in the template record are fixed.

> DECL_FIELD_OFFSET no longer has the desired zero bits.  Shouldn't we
> instead set DECL_FIELD_OFFSET to -DECL_OFFSET_ALIGN and adjust
> DECL_FIELD_BIT_OFFSET accordingly?
>
> Well, with the above questions and suggestions I'd rather leave it
> to you deciding whether you like the below hack or want to rework
> the function a bit.

I guess that we have 3 solutions:
 - keep the negative offset hack and patch up,
 - make DECL_FIELD_OFFSET use ssizetype instead of sizetype,
 - remove the negative offset hack and devise a replacement mechanism.

We previously discussed 2 internally and agreed that it would be kind of an 
earthquake (feel free to differ though :-)  So it's probably about time to 
bite the bullet and tackle 3 seriously...

-- 
Eric Botcazou


Re: [Patch, Fortran] PR44646 - Add parser support for DO CONCURRENT

2011-09-05 Thread Tobias Burnus

On 09/03/2011 02:49 PM, Tobias Burnus wrote:
This patch implements the parsing/diagnostic for "DO[,] CONCURRENT 
for-all-header", e.g.

  do concurrent (i = 1:5)
A(i) = B(i)
  end do


(Side remark: do concurrent also supports a logical mask expression as 
FORALL does.)



I have attached an updated version, which actually implements do 
concurrent in trans-stmt.c. Additionally, "CYCLE" without a label did 
not work.



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


Tobias
2011-09-06  Tobias Burnus  

	PR fortran/44646
	* decl.c (gfc_match_entry, gfc_match_end): Handle COMP_DO_CONCURRENT.
	* dump-parse-tree.c (show_code_node): Handle EXEC_DO_CONCURRENT.
	* gfortran.h (gfc_exec_op): Add EXEC_DO_CONCURRENT.
	* match.c (gfc_match_critical, match_exit_cycle, gfc_match_stopcode,
	lock_unlock_statement, sync_statement, gfc_match_allocate,
	gfc_match_deallocate, gfc_match_return): Add DO CONCURRENT diagnostic.
	(gfc_match_do): Match DO CONCURRENT.
	(match_derived_type_spec, match_type_spec, gfc_free_forall_iterator,
	match_forall_iterator, match_forall_header, match_simple_forall,
	gfc_match_forall): Move up in the file.
	* parse.c (check_do_closure, parse_do_block): Handle do concurrent.
	* parse.h (gfc_compile_state): Add COMP_DO_CONCURRENT.
	* resolve.c (do_concurrent_flag): New global variable.
	(resolve_function, pure_subroutine, resolve_branch,
	gfc_resolve_blocks, resolve_code, resolve_types): Add do concurrent
	diagnostic.
	* st.c (gfc_free_statement): Handle EXEC_DO_CONCURRENT.
	* trans-stmt.c (gfc_trans_do_concurrent): New function.
	(gfc_trans_forall_1): Handle do concurrent.
	* trans-stmt.h (gfc_trans_do_concurrent): New function prototype.
	* trans.c (trans_code): Call it.

2011-09-06  Tobias Burnus  

	PR fortran/44646
	* gfortran.dg/do_concurrent_1.f90: New.
	* gfortran.dg/do_concurrent_2.f90: New.

diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index 18e2651..0ee2575 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -5248,6 +5248,7 @@ gfc_match_entry (void)
 		   "an IF-THEN block");
 	break;
 	  case COMP_DO:
+	  case COMP_DO_CONCURRENT:
 	gfc_error ("ENTRY statement at %C cannot appear within "
 		   "a DO block");
 	break;
@@ -5853,6 +5854,7 @@ gfc_match_end (gfc_statement *st)
   break;
 
 case COMP_DO:
+case COMP_DO_CONCURRENT:
   *st = ST_ENDDO;
   target = " do";
   eos_ok = 0;
diff --git a/gcc/fortran/dump-parse-tree.c b/gcc/fortran/dump-parse-tree.c
index ad8b554..af2cd85 100644
--- a/gcc/fortran/dump-parse-tree.c
+++ b/gcc/fortran/dump-parse-tree.c
@@ -1611,6 +1611,28 @@ show_code_node (int level, gfc_code *c)
   fputs ("END DO", dumpfile);
   break;
 
+case EXEC_DO_CONCURRENT:
+  fputs ("DO CONCURRENT ", dumpfile);
+  for (fa = c->ext.forall_iterator; fa; fa = fa->next)
+{
+  show_expr (fa->var);
+  fputc (' ', dumpfile);
+  show_expr (fa->start);
+  fputc (':', dumpfile);
+  show_expr (fa->end);
+  fputc (':', dumpfile);
+  show_expr (fa->stride);
+
+  if (fa->next != NULL)
+fputc (',', dumpfile);
+}
+  show_expr (c->expr1);
+
+  show_code (level + 1, c->block->next);
+  code_indent (level, c->label1);
+  fputs ("END DO", dumpfile);
+  break;
+
 case EXEC_DO_WHILE:
   fputs ("DO WHILE ", dumpfile);
   show_expr (c->expr1);
diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h
index ac36d24..54e0b20 100644
--- a/gcc/fortran/gfortran.h
+++ b/gcc/fortran/gfortran.h
@@ -2052,10 +2052,10 @@ typedef enum
   EXEC_LABEL_ASSIGN, EXEC_POINTER_ASSIGN, EXEC_CRITICAL, EXEC_ERROR_STOP,
   EXEC_GOTO, EXEC_CALL, EXEC_COMPCALL, EXEC_ASSIGN_CALL, EXEC_RETURN,
   EXEC_ENTRY, EXEC_PAUSE, EXEC_STOP, EXEC_CONTINUE, EXEC_INIT_ASSIGN,
-  EXEC_IF, EXEC_ARITHMETIC_IF, EXEC_DO, EXEC_DO_WHILE, EXEC_SELECT, EXEC_BLOCK,
-  EXEC_FORALL, EXEC_WHERE, EXEC_CYCLE, EXEC_EXIT, EXEC_CALL_PPC,
-  EXEC_ALLOCATE, EXEC_DEALLOCATE, EXEC_END_PROCEDURE, EXEC_SELECT_TYPE,
-  EXEC_SYNC_ALL, EXEC_SYNC_MEMORY, EXEC_SYNC_IMAGES,
+  EXEC_IF, EXEC_ARITHMETIC_IF, EXEC_DO, EXEC_DO_CONCURRENT, EXEC_DO_WHILE,
+  EXEC_SELECT, EXEC_BLOCK, EXEC_FORALL, EXEC_WHERE, EXEC_CYCLE, EXEC_EXIT,
+  EXEC_CALL_PPC, EXEC_ALLOCATE, EXEC_DEALLOCATE, EXEC_END_PROCEDURE,
+  EXEC_SELECT_TYPE, EXEC_SYNC_ALL, EXEC_SYNC_MEMORY, EXEC_SYNC_IMAGES,
   EXEC_OPEN, EXEC_CLOSE, EXEC_WAIT,
   EXEC_READ, EXEC_WRITE, EXEC_IOLENGTH, EXEC_TRANSFER, EXEC_DT_END,
   EXEC_BACKSPACE, EXEC_ENDFILE, EXEC_INQUIRE, EXEC_REWIND, EXEC_FLUSH,
diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c
index 43aeb19..4ea98b6 100644
--- a/gcc/fortran/match.c
+++ b/gcc/fortran/match.c
@@ -1748,6 +1748,13 @@ gfc_match_critical (void)
   return MATCH_ERROR;
 }
 
+  if (gfc_find_state (COMP_DO_CONCURRENT) == SUCCESS)
+{
+  gfc_error ("Image control statement CRITICAL at %C in DO CONCURRENT "
+		 "block");
+  return MATCH_ERROR;
+}
+
   if (gfc_implici

[Backport, AVR, 4.6]: PR50289

2011-09-05 Thread Georg-Johann Lay
Commited the following backport of PR50289 from mainline to 4.6:

http://gcc.gnu.org/viewcvs?view=revision&revision=178529

PR target/50289
Backport from mainline r178528
* config/avr/avr.c (sequent_regs_live): Don't recognize sequences
that contain global register variable.



Re: [PATCH] Add niagara3 and niagara4 cpu types.

2011-09-05 Thread David Miller
From: David Miller 
Date: Mon, 05 Sep 2011 11:24:10 -0400 (EDT)

> From: Eric Botcazou 
> Date: Mon, 5 Sep 2011 09:20:35 +0200
> 
>> Great, thanks (superfluous gcc/ in the ChangeLog).  No improvements to the 
>> SPARC port have been documented in http://gcc.gnu.org/gcc-4.7/changes.html 
>> yet, so I'm going to write something down.
> 
> Thanks Eric, and thanks also for finding my changelog thinkos :-)

While testing these changes I found that I forgot to hit config.gcc
so that it recognizes these new processor types.  Fixed as follows:

gcc/

* config.gcc: Recognize niagara3 and niagara4 in --with-cpu
and --with-tune options.

diff --git a/gcc/config.gcc b/gcc/config.gcc
index 81b542c..abc5d99 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -3482,7 +3482,8 @@ case "${target}" in
| v8 | supersparc | hypersparc | leon \
| sparclite | f930 | f934 | sparclite86x \
| sparclet | tsc701 \
-   | v9 | ultrasparc | ultrasparc3 | niagara | niagara2)
+   | v9 | ultrasparc | ultrasparc3 | niagara | niagara2 \
+   | niagara3 | niagara4)
# OK
;;
*)


Re: [PATCH][ARM] pr50193: ICE on a | (b << negative-constant)

2011-09-05 Thread Andrew Stubbs

On 01/09/11 17:21, Andrew Stubbs wrote:

I wasn't sure how to find the mode of shift operand in the predicate
though, so I've assumed they're always the same size. How would one find
the proper mode in a predicate?


OK, no reply, so I'm just going to assume we're dealing with 32-bit 
registers.


Additionally, Richard Sandiford has pointed out that changing the 
predicate such that it is more restrictive than the constraints is a 
problem because reload apparently ignores the predicates under certain 
circumstances. Setting aside that that seems broken and wrong (what's 
the point in a predicate if you're just going to ignore it), this patch 
also creates a new constraint "Pm" that limits the range to match the 
predicate.


Speaking of which, I've limited the constants to the range 1..31 
(inclusive) because a) allowing zero seems like it would be 
counter-productive - it would be better to keep a zero shift as a 
separate operation that can be optimized away (probably not an issue, 
but there it is); and b) allowing zero would produce non-canonical 
assembler (which is not a problem now, but is still best avoided).


I have a bootstrap test running now. Assuming that succeeds, is this ok?

Andrew

2011-09-05  Andrew Stubbs  

	gcc/
	* config/arm/arm.md (*not_shiftsi, *not_shiftsi_compare0,
	*not_shiftsi_compare0_scratch, *cmpsi_shiftsi,
	*cmpsi_shiftsi_swp, *arith_shiftsi, *arith_shiftsi_compare0,
	*arith_shiftsi_compare0_scratch, *sub_shiftsi,
	*sub_shiftsi_compare0, *sub_shiftsi_compare0_scratch): Change
	'M' constraint to 'Pm'.
	* config/arm/constraints.md (Pm): New constraint.
	* config/arm/predicates.md (shift_amount_operand): Ensure that all
	constants satisfy the Pm constraint.

	gcc/testsuite/
	* testsuite/gcc.dg/pr50193-1.c: New file.

--- a/gcc/config/arm/arm.md
+++ b/gcc/config/arm/arm.md
@@ -3669,7 +3669,7 @@
   [(set (match_operand:SI 0 "s_register_operand" "=r,r")
 	(not:SI (match_operator:SI 3 "shift_operator"
 		 [(match_operand:SI 1 "s_register_operand" "r,r")
-		  (match_operand:SI 2 "shift_amount_operand" "M,rM")])))]
+		  (match_operand:SI 2 "shift_amount_operand" "Pm,rPm")])))]
   "TARGET_32BIT"
   "mvn%?\\t%0, %1%S3"
   [(set_attr "predicable" "yes")
@@ -3683,7 +3683,7 @@
 	(compare:CC_NOOV
 	 (not:SI (match_operator:SI 3 "shift_operator"
 		  [(match_operand:SI 1 "s_register_operand" "r,r")
-		   (match_operand:SI 2 "shift_amount_operand" "M,rM")]))
+		   (match_operand:SI 2 "shift_amount_operand" "Pm,rPm")]))
 	 (const_int 0)))
(set (match_operand:SI 0 "s_register_operand" "=r,r")
 	(not:SI (match_op_dup 3 [(match_dup 1) (match_dup 2)])))]
@@ -3700,7 +3700,7 @@
 	(compare:CC_NOOV
 	 (not:SI (match_operator:SI 3 "shift_operator"
 		  [(match_operand:SI 1 "s_register_operand" "r,r")
-		   (match_operand:SI 2 "shift_amount_operand" "M,rM")]))
+		   (match_operand:SI 2 "shift_amount_operand" "Pm,rPm")]))
 	 (const_int 0)))
(clobber (match_scratch:SI 0 "=r,r"))]
   "TARGET_32BIT"
@@ -7247,7 +7247,7 @@
 	(compare:CC (match_operand:SI   0 "s_register_operand" "r,r")
 		(match_operator:SI  3 "shift_operator"
 		 [(match_operand:SI 1 "s_register_operand" "r,r")
-		  (match_operand:SI 2 "shift_amount_operand" "M,rM")])))]
+		  (match_operand:SI 2 "shift_amount_operand" "Pm,rPm")])))]
   "TARGET_32BIT"
   "cmp%?\\t%0, %1%S3"
   [(set_attr "conds" "set")
@@ -7259,7 +7259,7 @@
   [(set (reg:CC_SWP CC_REGNUM)
 	(compare:CC_SWP (match_operator:SI 3 "shift_operator"
 			 [(match_operand:SI 1 "s_register_operand" "r,r")
-			  (match_operand:SI 2 "shift_amount_operand" "M,rM")])
+			  (match_operand:SI 2 "shift_amount_operand" "Pm,rPm")])
 			(match_operand:SI 0 "s_register_operand" "r,r")))]
   "TARGET_32BIT"
   "cmp%?\\t%0, %1%S3"
@@ -8649,7 +8649,7 @@
 (match_operator:SI 1 "shiftable_operator"
   [(match_operator:SI 3 "shift_operator"
  [(match_operand:SI 4 "s_register_operand" "r,r,r,r")
-  (match_operand:SI 5 "shift_amount_operand" "M,M,M,r")])
+  (match_operand:SI 5 "shift_amount_operand" "Pm,Pm,Pm,r")])
(match_operand:SI 2 "s_register_operand" "rk,rk,r,rk")]))]
   "TARGET_32BIT"
   "%i1%?\\t%0, %2, %4%S3"
@@ -8700,7 +8700,7 @@
 	 (match_operator:SI 1 "shiftable_operator"
 	  [(match_operator:SI 3 "shift_operator"
 	[(match_operand:SI 4 "s_register_operand" "r,r")
-	 (match_operand:SI 5 "shift_amount_operand" "M,r")])
+	 (match_operand:SI 5 "shift_amount_operand" "Pm,r")])
 	   (match_operand:SI 2 "s_register_operand" "r,r")])
 	 (const_int 0)))
(set (match_operand:SI 0 "s_register_operand" "=r,r")
@@ -8719,7 +8719,7 @@
 	 (match_operator:SI 1 "shiftable_operator"
 	  [(match_operator:SI 3 "shift_operator"
 	[(match_operand:SI 4 "s_register_operand" "r,r")
-	 (match_operand:SI 5 "shift_amount_operand" "M,r")])
+	 (match_operand:SI 5 "shift_amount_operand" "Pm,r")])
 	   (match_operand:SI 2 "s_register_operand" "r,r")])
 	 (const_int 0)))
(clobber (match_scratch:SI 0 "=r,r"

Re: Ping: C-family stack check for threads

2011-09-05 Thread Thomas Klein

On 09/05/11 09:45, Ye Joey wrote:

+  /* check if we can use one of the argument registers r0..r3 as long as they
+   * not holding data*/
+  for (reg = 0; reg<= LAST_ARG_REGNUM&&  i<  2; reg++)
...

+  n = (reg + 1) % 4;

Avoid immediate register number.
use ARG_REGISTER (1) to replace "reg 0"
use NUM_ARG_REGS to replace "4"



The 4 is the number of argument registers so you are right to use 
NUM_ARG_REGS here.

The calculation should give the next possible argument register.
E.g. if the current register is r0, the next register is r1.
Except if the current register is r3, then the next register is r0.

I think the ARG_REGISTER macro will not reduce confusion.
  n = ( ARG_REGISTER(reg+1) + 1) % NUM_ARG_REGS;
identical to
  n = (reg + 1) % NUM_ARG_REGS;

regards
  Thomas Klein

gcc/ChangeLog

2011-09-05  Thomas Klein 
* opts.c (common_handle_option): introduce new parameters "direct" and
"indirect"
* flag-types.h (enum stack_check_type): Likewise

* explow.c (allocate_dynamic_stack_space):
- suppress stack probing if parameter "direct", "indirect" or if a
stack-limit is given
- do additional read of limit value if parameter "indirect" and a
stack-limit symbol is given
- emit a call to a stack_failure function [as an alternative to a trap
call]
(function probe_stack_range): if allowed to override the range porbe
emit generic_limit_check_stack

* config/arm/arm.c
(stack_check_work_registers): new function to find possible working
registers [only used by "stack check"]
(emit_push_regs): add push RTL instruction without keeping regnumber
and frame memory in mind.
(emit_pop_regs): add pop RTL instruction to revert the above push
(emit_stack_check_insns): new function to write RTL instructions for
stack check at prologue stage.
(arm_expand_prologue): stack check integration for ARM and Thumb-2
(thumb1_output_function_prologue): stack check integration for Thumb-1

* config/arm/arm.md
(cbranchsi4_insn): allow compare and branch using stack pointer
register [at thumb mode]
(arm_cmpsi_insn): allow comparing using stack pointer register [at arm]
(probe_stack): do not emit code when parameters "direct" or "indirect"
is given, emit move code way same as in gcc/explow.c [function
emit_stack_probe]
(probe_stack_done): dummy to make sure probe_stack insns are not
optimized away
(generic_limit_check_stack): if stack-limit and parameter "generic" is
given use the limit the same way as in function
allocate_dynamic_stack_space
(stack_failure): failure call used in stack check functions
emit_stack_check_insns, generic_limit_check_stack or
allocate_dynamic_stack_space [similar to a trap but avoid conflict with
builtin_trap]

Index: gcc/opts.c
===
--- gcc/opts.c  (revision 178554)
+++ gcc/opts.c  (working copy)
@@ -1644,6 +1644,12 @@ common_handle_option (struct gcc_options *opts,
   : STACK_CHECK_STATIC_BUILTIN
 ? STATIC_BUILTIN_STACK_CHECK
 : GENERIC_STACK_CHECK;
+  else if (!strcmp (arg, "indirect"))
+   /* This is an other stack checking method.  */
+   opts->x_flag_stack_check = INDIRECT_STACK_CHECK;
+  else if (!strcmp (arg, "direct"))
+   /* This is an other stack checking method.  */
+   opts->x_flag_stack_check = DIRECT_STACK_CHECK;
   else
warning_at (loc, 0, "unknown stack check parameter \"%s\"", arg);
   break;
Index: gcc/flag-types.h
===
--- gcc/flag-types.h(revision 178554)
+++ gcc/flag-types.h(working copy)
@@ -153,7 +153,15 @@ enum stack_check_type
 
   /* Check the stack and entirely rely on the target configuration
  files, i.e. do not use the generic mechanism at all.  */
-  FULL_BUILTIN_STACK_CHECK
+  FULL_BUILTIN_STACK_CHECK,
+
+  /* Check the stack (if possible) before allocation of local variables at
+ each function entry. The stack limit is directly given e.g. by address
+ of a symbol */
+  DIRECT_STACK_CHECK,
+  /* Check the stack (if possible) before allocation of local variables at
+ each function entry. The stack limit is given by global variable. */
+  INDIRECT_STACK_CHECK
 };
 
 /* Names for the different levels of -Wstrict-overflow=N.  The numeric
Index: gcc/explow.c
===
--- gcc/explow.c(revision 178554)
+++ gcc/explow.c(working copy)
@@ -1372,7 +1372,12 @@ allocate_dynamic_stack_space (rtx size, unsigned s
 
   /* If needed, check that we have the required amount of stack.  Take into
  account what has already been checked.  */
-  if (STACK_CHECK_MOVING_SP)
+  if (  STACK_CHECK_MOVING_SP 
+#ifdef HAVE_generic_limit_check_stack
+ || crtl->limit_stack
+#endif
+ || flag_stack_ch

Re: [RFC, WIP] tree-ssa-strlen optimization pass

2011-09-05 Thread Jakub Jelinek
On Mon, Sep 05, 2011 at 11:50:52AM +0200, Richard Guenther wrote:
> Yeah, I suppose update_call_from_tree could use a piecewise variant ...
> ok, let's defer this as a cleanup for whoever feels like updating some
> more code.

Attached are two patches, the first one contains two small changes,
one to make sure gimplify_and_update_call_from_tree doesn't need
TODO_update_ssa and another which adds a function similar to
update_call_from_tree, which just replaces one call with another one
from given fn, nargs and the arguments passed to ...
plus new functions this new function needs.  This patch can be applied
independently, has been bootstrapped/regtested on x86_64-linux and
i686-linux, ok for trunk?

The second patch is updated version of tree-ssa-strlen.c pass, with
incorporated feedback from you, but so far no further functional changes
(which I'd still like to work on).

Jakub
2011-09-05  Jakub Jelinek  

* gimple-fold.c (gimplify_and_update_call_from_tree): Set
gctx.into_ssa after push_gimplify_context.

* gimple.c (gimple_build_call_valist): New function.
* gimple.h (gimple_build_call_valist): New prototype.
* tree-ssa-propagate.c (finish_update_gimple_call): New function.
(update_gimple_call): Likewise.
(update_call_from_tree): Use finish_update_gimple_call.
* tree-ssa-propagate.h (update_gimple_call): New prototype.

--- gcc/gimple-fold.c.jj2011-09-02 16:29:39.0 +0200
+++ gcc/gimple-fold.c   2011-09-05 14:51:02.0 +0200
@@ -551,6 +551,7 @@ gimplify_and_update_call_from_tree (gimp
   reaching_vuse = gimple_vuse (stmt);
 
   push_gimplify_context (&gctx);
+  gctx.into_ssa = gimple_in_ssa_p (cfun);
 
   if (lhs == NULL_TREE)
 {
--- gcc/gimple.c.jj 2011-09-02 16:29:39.0 +0200
+++ gcc/gimple.c2011-09-05 14:55:34.0 +0200
@@ -215,9 +215,10 @@ gimple_call_reset_alias_info (gimple s)
 pt_solution_reset (gimple_call_clobber_set (s));
 }
 
-/* Helper for gimple_build_call, gimple_build_call_vec and
-   gimple_build_call_from_tree.  Build the basic components of a
-   GIMPLE_CALL statement to function FN with NARGS arguments.  */
+/* Helper for gimple_build_call, gimple_build_call_valist,
+   gimple_build_call_vec and gimple_build_call_from_tree.  Build the basic
+   components of a GIMPLE_CALL statement to function FN with NARGS
+   arguments.  */
 
 static inline gimple
 gimple_build_call_1 (tree fn, unsigned nargs)
@@ -272,6 +273,26 @@ gimple_build_call (tree fn, unsigned nar
 }
 
 
+/* Build a GIMPLE_CALL statement to function FN.  NARGS is the number of
+   arguments.  AP contains the arguments.  */
+
+gimple
+gimple_build_call_valist (tree fn, unsigned nargs, va_list ap)
+{
+  gimple call;
+  unsigned i;
+
+  gcc_assert (TREE_CODE (fn) == FUNCTION_DECL || is_gimple_call_addr (fn));
+
+  call = gimple_build_call_1 (fn, nargs);
+
+  for (i = 0; i < nargs; i++)
+gimple_call_set_arg (call, i, va_arg (ap, tree));
+
+  return call;
+}
+
+
 /* Helper for gimple_build_call_internal and gimple_build_call_internal_vec.
Build the basic components of a GIMPLE_CALL statement to internal
function FN with NARGS arguments.  */
--- gcc/gimple.h.jj 2011-09-02 16:29:39.0 +0200
+++ gcc/gimple.h2011-09-05 14:56:15.0 +0200
@@ -831,6 +831,7 @@ gimple gimple_build_debug_source_bind_st
 
 gimple gimple_build_call_vec (tree, VEC(tree, heap) *);
 gimple gimple_build_call (tree, unsigned, ...);
+gimple gimple_build_call_valist (tree, unsigned, va_list);
 gimple gimple_build_call_internal (enum internal_fn, unsigned, ...);
 gimple gimple_build_call_internal_vec (enum internal_fn, VEC(tree, heap) *);
 gimple gimple_build_call_from_tree (tree);
--- gcc/tree-ssa-propagate.c.jj 2011-07-22 22:15:02.0 +0200
+++ gcc/tree-ssa-propagate.c2011-09-05 15:08:45.0 +0200
@@ -1,5 +1,5 @@
 /* Generic SSA value propagation engine.
-   Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
+   Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
Free Software Foundation, Inc.
Contributed by Diego Novillo 
 
@@ -673,6 +673,38 @@ move_ssa_defining_stmt_for_defs (gimple 
 }
 }
 
+/* Helper function for update_gimple_call and update_call_from_tree.
+   A GIMPLE_CALL STMT is being replaced with GIMPLE_CALL NEW_STMT.  */
+
+static void
+finish_update_gimple_call (gimple_stmt_iterator *si_p, gimple new_stmt,
+  gimple stmt)
+{
+  gimple_call_set_lhs (new_stmt, gimple_call_lhs (stmt));
+  move_ssa_defining_stmt_for_defs (new_stmt, stmt);
+  gimple_set_vuse (new_stmt, gimple_vuse (stmt));
+  gimple_set_vdef (new_stmt, gimple_vdef (stmt));
+  gimple_set_location (new_stmt, gimple_location (stmt));
+  gsi_replace (si_p, new_stmt, false);
+}
+
+/* Update a GIMPLE_CALL statement at iterator *SI_P to call to FN
+   with number of arguments NARGS, where the arguments in GIMPLE form
+   follow NARGS argument.  */
+
+bool
+update_gimple_cal

[Patch, Ada, Darwin] fix-typos, restore x86-64-darwin10 multi-lib bootstrap.

2011-09-05 Thread Iain Sandoe
There are a couple of typos in ada/gcc-infterface/Makefile.in that  
result in many fails of x86_64-darwin10 bootstrap for the m32 lib  
variant (thus breaking bootstrap with default switches)..


the attached removes a duplicated section of text and corrects the  
target variants.


OK for trunk?
Iain

ada:

	* gcc-interface/Makefile.in (X86_TARGET_PAIRS): Remove duplicate  
definition.

(x86_64 darwin arch): Adjust LIBGNAT_TARGET_PAIRS for x86 and x86_64
variants.

diff --git a/gcc/ada/gcc-interface/Makefile.in b/gcc/ada/gcc-interface/ 
Makefile.in

index 1afe6c0..4be366e 100644
--- a/gcc/ada/gcc-interface/Makefile.in
+++ b/gcc/ada/gcc-interface/Makefile.in
@@ -434,14 +434,6 @@ X86_TARGET_PAIRS = \
   g-bytswa.adbdiff --git a/gcc/ada/gcc-interface/Makefile.in 
b/gcc/ada/gcc-interface/Makefile.in
index 1afe6c0..4be366e 100644
--- a/gcc/ada/gcc-interface/Makefile.in
+++ b/gcc/ada/gcc-interface/Makefile.in
@@ -434,14 +434,6 @@ X86_TARGET_PAIRS = \
   g-bytswa.adb

[Patch, Ada, Darwin] Adjust architecture for built shared libs.

2011-09-05 Thread Iain Sandoe

ld needs to be passed the correct arch flag when building shared libs.

This means that the multi-libs built for 4.6.x and trunk contain junk  
(essentially all the input objects are rejected as having the wrong  
arch).


The attached corrects this.

OK for trunk and 4.6 (since this is a wrong-code issue)?
Iain

P.S. Is there any salient justification for the use of the  
anachronistic  "-Wl, -flat_namespace"  in Ada ? ...

... if not then I'll forward a patch to remove this
...  IMO it causes more trouble than it solves ...
... and should be applied explicitly by the User in circumstances that  
require it.




ada:
	* gcc-interface/Makefile.in (darwin, SO_OPTS): Provide architecture  
size switches to the link

phase for shared libs.

diff --git a/gcc/ada/gcc-interface/Makefile.in b/gcc/ada/gcc-interface/ 
Makefile.in

index 4be366e..8974a99 100644
--- a/gcc/ada/gcc-interface/Makefile.in
+++ b/gcc/ada/gcc-interface/Makefile.in
@@ -2164,6 +2164,7 @@ ifeq ($(strip $(filter-out %x86_64 linux%,$ 
(arch) $(osys))),)

 endif

 ifeq ($(strip $(filter-out darwin%,$(osys))),)
+  SO_OPTS = -Wl,-flat_namespace -shared-libgcc
   ifeq ($(strip $(filter-out %86,$(arch))),)
 LIBGNAT_TARGET_PAIRS = \
 a-intnam.ads 		-Wl,-install_name,@rpath/libgnat$(hyphen)$(LIBRARY_VERSION)$ 
(soext) \

-   $(MISCLIB) -lm
+   $(MISCLIB)
cd $(RTSDIR); `echo "$(GCC_FOR_TARGET)" \
 | sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,- 
B../../,'` -dynamiclib $(PICFLAG_FOR_TARGET) \

-o libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \

diff --git a/gcc/ada/gcc-interface/Makefile.in 
b/gcc/ada/gcc-interface/Makefile.in
index 4be366e..8974a99 100644
--- a/gcc/ada/gcc-interface/Makefile.in
+++ b/gcc/ada/gcc-interface/Makefile.in
@@ -2164,6 +2164,7 @@ ifeq ($(strip $(filter-out %x86_64 linux%,$(arch) 
$(osys))),)
 endif
 
 ifeq ($(strip $(filter-out darwin%,$(osys))),)
+  SO_OPTS = -Wl,-flat_namespace -shared-libgcc
   ifeq ($(strip $(filter-out %86,$(arch))),)
 LIBGNAT_TARGET_PAIRS = \
 a-intnam.ads

[Patch, Ada, Darwin] Restore PowerPC Darwin Ada bootstrap (after a looong time, it seems).

2011-09-05 Thread Iain Sandoe

Well, this was two needles in a haystack ...

... AFAICT from googling, powerpc-darwin9 has never bootstrapped ADA  
(I see questions but no resolution).
Perhaps Adacore has a version ... but I was unable to find any  
starting point - so this was somewhat tough to debug.




Anyway, there are two issues for 4.6 and three for trunk:

1.  rs6000.c (WORLD_SAVE_P) decides on the use of the out-of-line  
prologue saves on the basis of cfun->calls_setjmp && flag_exceptions.
   of course, flag_exceptions is NOT set by Ada for SjLj - which is  
what's used for the compiler build.


   - it doesn't seem reasonable to force -fexceptions - until we can  
build ada with ZCE.


   - so, given that SjLj exceptions are in use w/out the flag - it  
seems that the check should be adjusted.


2. (TRUNK-only)

  ** Eric, you removed the setting of cfun->calls_setjmp from gcc/ 
builtins.c (in June).   This (re)breaks trunk c.f. 4.6 - given the fix  
to (1).

  Was there some reason to remove this?

 ... would there be some more appropriate test for rs6000.c to use?

 ... if not, my proposed solution is to re-insert the check in  
builtins.c to remove the regression w.r.t. to 4.6.


3. There is no multi-lib target set for powerpc64-darwin, thus  
bootstrap fails with a Bad Alignment error in building the target libs.


Since this is a long-standing regression (last bootstrap for powerpc- 
darwin was likely in the 4.2 era).


OK for 4.6 (1, 3) and trunk (1,2 & 3) ?

FTR, the rs6000 change is local to the Darwin port.

Iain

gcc:

	* builtins.c (expand_builtin_setjmp_setup):  Note that the function  
calls builtin setjmp.
	* config/rs6000/rs6000.c (compute_save_world_info): Do not require  
flag_exceptions

to be set when using SjLj.

ada:

	* gcc-interface/Makefile.in (darwin): Adjust LIBGNAT_TARGET_PAIRS for  
powerpc

darwin on the basis of the arch.
* system-darwin-ppc64.ads: New file.

Index: gcc/builtins.c
===
--- gcc/builtins.c  (revision 178554)
+++ gcc/builtins.c  (working copy)
@@ -815,6 +815,10 @@ expand_builtin_setjmp_setup (rtx buf_addr, rtx rec
 emit_insn (gen_builtin_setjmp_setup (buf_addr));
 #endif

+  /* This can be tested by a target to determine that the prologue  
may not use

+ register-saving functions.   */
+  cfun->calls_setjmp = 1;
+
   /* We have a nonlocal label.   */
   cfun->has_nonlocal_label = 1;
 }
Index: gcc/config/rs6000/rs6000.c
===
--- gcc/config/rs6000/rs6000.c  (revision 178554)
+++ gcc/config/rs6000/rs6000.c  (working copy)
@@ -17945,7 +17945,7 @@ compute_save_world_info (rs6000_stack_t  
*info_ptr)

   info_ptr->world_save_p
 = (WORLD_SAVE_P (info_ptr)
&& DEFAULT_ABI == ABI_DARWIN
-   && ! (cfun->calls_setjmp && flag_exceptions)
+   && !cfun->calls_setjmp
&& info_ptr->first_fp_reg_save == FIRST_SAVED_FP_REGNO
&& info_ptr->first_gp_reg_save == FIRST_SAVED_GP_REGNO
&& info_ptr->first_altivec_reg_save ==  
FIRST_SAVED_ALTIVEC_REGNO

Index: gcc/ada/gcc-interface/Makefile.in
===
--- gcc/ada/gcc-interface/Makefile.in   (revision 178554)
+++ gcc/ada/gcc-interface/Makefile.in   (working copy)
@@ -2240,8 +2240,15 @@ ifeq ($(strip $(filter-out darwin%,$(osys))),)
 a-numaux.ads+ 
--
+ 
--  --
+--GNAT RUN-TIME  
COMPONENTS  --
+ 
--  --
+--   S Y S T E  
M--
+ 
--  --
+-- S p e  
c  --
+-- (Darwin/PPC64  
Version)   --
+ 
--  --
+-- Copyright (C) 2011, Free Software Foundation,  
Inc.   --
+ 
--  --
+-- This specification is derived from the Ada Reference Manual for  
use with --
+-- GNAT. The copyright notice above, and the license provisions that  
follow --
+-- apply solely to the  contents of the part following the private  
keyword. --
+ 
--  --
+-- GNAT is free software;  you can  redistribute it  and/or modify it  
under --
+-- terms of the  GNU General Public License as published  by the Free  
Soft- --
+-- ware  Foundation;  either version 3,  or (at your option) any  
later ver- --
+-- sion.  GNAT is distributed in the hope that it will be useful, but  
WITH- --
+-- OUT ANY WA

[Patch, Ada, Darwin] Fix bootstrap issue on Darwin8.

2011-09-05 Thread Iain Sandoe

Darwin8 does not have _SC_NPROCESSORS_ONLN defined.

OK for trunk & 4.6?
Iain

Index: gcc/ada/adaint.c
===
--- gcc/ada/adaint.c(revision 178554)
+++ gcc/ada/adaint.c(working copy)
@@ -2460,7 +2460,10 @@ __gnat_number_of_cpus (void)
   int cores = 1;

 #if defined (linux) || defined (sun) || defined (AIX) \
-|| (defined (__alpha__)  && defined (_osf_)) || defined (__APPLE__)
+|| (defined (__alpha__)  && defined (_osf_)) \
+|| (defined (__APPLE__) \
+&& defined (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) \
+&& __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050)
   cores = (int) sysconf (_SC_NPROCESSORS_ONLN);

 #elif (defined (__mips) && defined (__sgi))

Index: gcc/ada/adaint.c
===
--- gcc/ada/adaint.c(revision 178554)
+++ gcc/ada/adaint.c(working copy)
@@ -2460,7 +2460,10 @@ __gnat_number_of_cpus (void)
   int cores = 1;
 
 #if defined (linux) || defined (sun) || defined (AIX) \
-|| (defined (__alpha__)  && defined (_osf_)) || defined (__APPLE__)
+|| (defined (__alpha__)  && defined (_osf_)) \
+|| (defined (__APPLE__) \
+&& defined (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) \
+&& __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050)
   cores = (int) sysconf (_SC_NPROCESSORS_ONLN);
 
 #elif (defined (__mips) && defined (__sgi))






[PATCH] For mem_loc_descriptor prefer avoid_constant_pool_reference (PR debug/50191)

2011-09-05 Thread Jakub Jelinek
Hi!

On PowerPC64 PR50191 testcase when linked together with other code
results in linker crash.  The problem is that a reference
to a constant pool stays in the .debug_loc section.  During var-tracking
adjust_insn doesn't successfully avoid_constant_pool_reference it
because instead of a REG it uses a DEBUG_EXPR (as the register is no
longer live at that point), and rs6000_delegitimize_address checks
only for REGs in that part of the TOCREL expression.  And in dwarf2out.c
we were prefering DW_OP_deref* over avoid_constant_pool_reference,
performed the latter only if mem_loc_descriptor on the address failed.

The following patch changes it to prefer avoid_constant_pool_reference.
I think we can do this in mem_loc_descriptor, because MEMs handled
by that routine are otherwise DW_OP_deref*, i.e. DWARF expression rvalues
anyway.  I'm not changing loc_descriptor, because there we want to
prefer getting a REG or MEM which can be changed.

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

2011-09-05  Jakub Jelinek  

PR debug/50191
* dwarf2out.c (mem_loc_descriptor) : Try
avoid_constant_pool_reference first instead of last.

--- gcc/dwarf2out.c.jj  2011-07-29 17:07:20.0 +0200
+++ gcc/dwarf2out.c 2011-09-05 09:59:41.0 +0200
@@ -11695,12 +11695,22 @@ mem_loc_descriptor (rtx rtl, enum machin
   break;
 
 case MEM:
+  {
+   rtx new_rtl = avoid_constant_pool_reference (rtl);
+   if (new_rtl != rtl)
+ {
+   mem_loc_result = mem_loc_descriptor (new_rtl, mode, mem_mode,
+initialized);
+   if (mem_loc_result != NULL)
+ return mem_loc_result;
+ }
+  }
   mem_loc_result = mem_loc_descriptor (XEXP (rtl, 0),
   get_address_mode (rtl), mode,
   VAR_INIT_STATUS_INITIALIZED);
   if (mem_loc_result == NULL)
mem_loc_result = tls_mem_loc_descriptor (rtl);
-  if (mem_loc_result != 0)
+  if (mem_loc_result != NULL)
{
  if (GET_MODE_SIZE (mode) > DWARF2_ADDR_SIZE
  || GET_MODE_CLASS (mode) != MODE_INT)
@@ -11728,12 +11738,6 @@ mem_loc_descriptor (rtx rtl, enum machin
   new_loc_descr (DW_OP_deref_size,
  GET_MODE_SIZE (mode), 0));
}
-  else
-   {
- rtx new_rtl = avoid_constant_pool_reference (rtl);
- if (new_rtl != rtl)
-   return mem_loc_descriptor (new_rtl, mode, mem_mode, initialized);
-   }
   break;
 
 case LO_SUM:

Jakub


Re: Propagate BB predicates in ipa-inline-analysis

2011-09-05 Thread Jan Hubicka
> Jan Hubicka wrote:
> 
> > this is patch I comitted fixing ipa-inline-analysis.
> 
> Thanks for fixing this!
> 
> Richard Guenther wrote:
> 
> > Can you open a bugreport?
> 
> Sorry, I didn't see this until now.  Given that the fix is
> already checked in (and the problem doesn't exist on any
> release branch), I guess we don't really need any PR now ...
> 
> If you'd prefer to still have one, let me know and I'll
> create it.

We should still have PR on the missing optimization in the testcase
(i.e. we really should not leak builtlin_constant_p (0) in the IL
after early cleanups. it is simply stupid).

Honza


Re: [Patch, Ada, Darwin] fix-typos, restore x86-64-darwin10 multi-lib bootstrap.

2011-09-05 Thread Arnaud Charlet
> the attached removes a duplicated section of text and corrects the target
> variants.
> 
> OK for trunk?
> 
> ada:
> 
>   * gcc-interface/Makefile.in (X86_TARGET_PAIRS): Remove duplicate
> definition.
>   (x86_64 darwin arch): Adjust LIBGNAT_TARGET_PAIRS for x86 and x86_64
>   variants.

OK, thanks (modulo too long lines in above ChangeLog).

Arno


Re: [Patch, Ada, Darwin] Adjust architecture for built shared libs.

2011-09-05 Thread Arnaud Charlet
> ld needs to be passed the correct arch flag when building shared libs.
> 
> This means that the multi-libs built for 4.6.x and trunk contain junk
> (essentially all the input objects are rejected as having the wrong arch).
> 
> The attached corrects this.
> 
> OK for trunk and 4.6 (since this is a wrong-code issue)?

Well, the patch attached is OK. The patch inline in your mail body is NOT
(contains unrelated hunks).

I'd recommend that you do not duplicate patches like that, in particular not
if both are different, since this is very confusing and error prone.

> ada:
>   * gcc-interface/Makefile.in (darwin, SO_OPTS): Provide architecture
>   size
> switches to the link
>   phase for shared libs.

Again, same problem with too longer lines in your changelog entry.

To clarify, the patch which is OK is the following:

> diff --git a/gcc/ada/gcc-interface/Makefile.in
> b/gcc/ada/gcc-interface/Makefile.in
> index 4be366e..8974a99 100644
> --- a/gcc/ada/gcc-interface/Makefile.in
> +++ b/gcc/ada/gcc-interface/Makefile.in
> @@ -2164,6 +2164,7 @@ ifeq ($(strip $(filter-out %x86_64 linux%,$(arch)
> $(osys))),)
>  endif
>  
>  ifeq ($(strip $(filter-out darwin%,$(osys))),)
> +  SO_OPTS = -Wl,-flat_namespace -shared-libgcc
>ifeq ($(strip $(filter-out %86,$(arch))),)
>  LIBGNAT_TARGET_PAIRS = \
>  a-intnam.ads @@ -2184,6 +2185,7 @@ ifeq ($(strip $(filter-out darwin%,$(osys))),)
>LIBGNAT_TARGET_PAIRS += \
>  $(X86_64_TARGET_PAIRS) \
>  system.ads +  SO_OPTS += -m64
>  else
>LIBGNAT_TARGET_PAIRS += \
>  $(X86_TARGET_PAIRS) \
> @@ -2211,6 +2213,7 @@ ifeq ($(strip $(filter-out darwin%,$(osys))),)
>LIBGNAT_TARGET_PAIRS += \
>  $(X86_TARGET_PAIRS) \
>  system.ads +  SO_OPTS += -m32
>  else
>LIBGNAT_TARGET_PAIRS += \
>  $(X86_64_TARGET_PAIRS) \
> @@ -2243,7 +2246,6 @@ ifeq ($(strip $(filter-out darwin%,$(osys))),)
>  
>EH_MECHANISM=-gcc
>GNATLIB_SHARED = gnatlib-shared-darwin
> -  SO_OPTS = -Wl,-flat_namespace -shared-libgcc
>RANLIB = ranlib -c
>GMEM_LIB = gmemlib
>LIBRARY_VERSION := $(LIB_VERSION)


Re: [Patch, Ada, Darwin] Fix bootstrap issue on Darwin8.

2011-09-05 Thread Arnaud Charlet
> Darwin8 does not have _SC_NPROCESSORS_ONLN defined.

Is Darwin8 still active/supported?

> OK for trunk & 4.6?

Not as submitted, you haven't provided a suitable changelog for review.

Also, when you repost your patch, can you please send a single version of
the patch (either inline or as an attachment)? TIA.

Arno


Re: C++ PATCHes for core 1358, 1360, c++/50248 (constexpr, templates, default constructor)

2011-09-05 Thread H.J. Lu
On Sun, Sep 4, 2011 at 9:29 PM, Jason Merrill  wrote:
> At the Bloomington C++ meeting we discussed some issues with the constexpr
> specification that the clang team encountered while trying to implement it.
>  Among the issues was a problem that also came up recently for us as BZ
> 50248: if the constexpr-ness of a template instantiation depends on its
> body, we need to instantiate it in order to decide whether or not an
> implicitly-declared function that uses it is constexpr.  The resolution of
> DR 1358 is that an instantiation of a constexpr template is constexpr even
> if it can never produce a constant expression.
>
> The second patch is related to DR 1360, where the clang team was complaining
> that deciding whether or not a class is literal requires the implicit
> declaration of the default constructor, which they would like to do lazily.
>  We seem to have agreed that it can be avoided in the cases where doing such
> is useful, but while looking at this I noticed a bug in our handling of this
> stuff: the function synthesized_default_constructor_is_constexpr was only
> right for trivial constructors.  So now I've renamed it accordingly, and
> force the implicit declaration for the non-trivial case.
>
> Tested x86_64-pc-linux-gnu, applying to trunk.
>

This caused:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50296

-- 
H.J.


Re: [Patch, Ada, Darwin] Fix bootstrap issue on Darwin8.

2011-09-05 Thread Iain Sandoe

Hi Arno,

On 5 Sep 2011, at 20:04, Arnaud Charlet wrote:


Darwin8 does not have _SC_NPROCESSORS_ONLN defined.


Is Darwin8 still active/supported?


it works - and I test from time to time.
.. feedback from fink in the form of bug reports suggests that it is  
still being used in the wild too.


In fact, the tortuous route I used to get to a working PPC ADA  
bootstrap was via a native-X darwin 8 compiler built on linux ;-)
(Now I know the problem with the PPC bootstrap it's easier to do a  
native X from i686-darwin, but I was debugging).




The policy we have adopted is not to break earlier Darwin if possible -
(bearing in mind that Darwin is volunteer-supported these days and we  
have scant resources).


However, FWIW, It is possible to build 4.6 even on Darwin 7 with some  
fiddling (odcctools) ...


[ However, I'm not going to nail my colors to the mast over this  
one ;-) ]


Not as submitted, you haven't provided a suitable changelog for  
review.


oops... apologies (and for the long lines in the other change logs)
... shouldn't type them directly into the mailer I suppose.

ada:

* adaint.c (__gnat_number_of_cpus): Don't try to check
_SC_NPROCESSORS_ONLN for early versions of Darwin.

Also, when you repost your patch, can you please send a single  
version of

the patch (either inline or as an attachment)? TIA.


The reason for duplication was that some people prefer one and some  
the other ..

.. plus mailers sometimes mangle in-line patches;

OK for trunk/4.6?
Iain

Index: gcc/ada/adaint.c
===
--- gcc/ada/adaint.c(revision 178554)
+++ gcc/ada/adaint.c(working copy)
@@ -2460,7 +2460,10 @@ __gnat_number_of_cpus (void)
   int cores = 1;
 
 #if defined (linux) || defined (sun) || defined (AIX) \
-|| (defined (__alpha__)  && defined (_osf_)) || defined (__APPLE__)
+|| (defined (__alpha__)  && defined (_osf_)) \
+|| (defined (__APPLE__) \
+&& defined (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) \
+&& __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050)
   cores = (int) sysconf (_SC_NPROCESSORS_ONLN);
 
 #elif (defined (__mips) && defined (__sgi))






[MIPS, committed] Fix mipsisa32-elf build

2011-09-05 Thread Richard Sandiford
As Bernd reported last week, mipsisa32-elf builds are broken in trunk.
The problem was a type error in the EABI part of mips_gimplify_va_arg_expr.

Tested on mipsisa32-elf and applied.  There are still some lto
builtins failures that I need to look at, but I ran out of time.

Richard


gcc/
* config/mips/mips.c (mips_gimplify_va_arg_expr): Unshare off.
Fix the type of the BIT_AND_EXPR.

Index: gcc/config/mips/mips.c
===
--- gcc/config/mips/mips.c  2011-09-03 11:05:52.0 +0100
+++ gcc/config/mips/mips.c  2011-09-04 12:41:38.0 +0100
@@ -5601,7 +5601,7 @@ mips_gimplify_va_arg_expr (tree valist,
}
 
   /* [2] Emit code to branch if off == 0.  */
-  t = build2 (NE_EXPR, boolean_type_node, off,
+  t = build2 (NE_EXPR, boolean_type_node, unshare_expr (off),
  build_int_cst (TREE_TYPE (off), 0));
   addr = build3 (COND_EXPR, ptr_type_node, t, NULL_TREE, NULL_TREE);
 
@@ -5624,7 +5624,7 @@ mips_gimplify_va_arg_expr (tree valist,
  /* [9] Emit: ovfl = ((intptr_t) ovfl + osize - 1) & -osize.  */
  t = fold_build_pointer_plus_hwi (unshare_expr (ovfl), osize - 1);
  u = build_int_cst (TREE_TYPE (t), -osize);
- t = build2 (BIT_AND_EXPR, sizetype, t, u);
+ t = build2 (BIT_AND_EXPR, TREE_TYPE (t), t, u);
  align = build2 (MODIFY_EXPR, TREE_TYPE (ovfl),
  unshare_expr (ovfl), t);
}


[MIPS, committed] Fix PR49606: ICE from -mabi=o64 -mlong64 -mabicalls

2011-09-05 Thread Richard Sandiford
PR 49606 is about an ICE when using the combination of -mabi=o64
-mlong64 -mabicalls.  In the PR I claimed that -mabi=o64 -mlong64
is an unsupported combination, and that this bug was therefore a
missing diagnostic bug.  However, it seems that in more naive days
I'd explicitly OKed the non-abicalls form:

http://gcc.gnu.org/ml/gcc-patches/2006-06/msg00609.html

That combination is also used by t-sr71k.  I think -mabi=o64 -mlong64
really doesn't make sense for abicalls though, because ELF32 produces
32-bit GOT entries.

This patch goes for a belt-and-braces fix.  It replaces all patterns
that assume Pmode == SImode with a :P version.  Although this might
not strictly be necessary, I think it makes the code more consistent.
The patch also adds a PMODE_INSN macro to make these Pmode insns easier
to handle.  But the patch also rejects ABI combinations that don't make
sense: they aren't defined, and even if they compile, they're likely to
be mishandled by the assembler, linker, or runtime.

I've added some smoke tests for every interesting ABI combination,
and error checks for the invalid combinations.

Tested on mipsisa32-elf and applied.

Richard


gcc/
PR target/49606
* config/mips/mips.h (ABI_HAS_64BIT_SYMBOLS): Check Pmode.
(PMODE_INSN): New macro.
* config/mips/mips.c (gen_load_const_gp): Use PMODE_INSN.
(mips_got_load, mips_expand_synci_loop): Likewise.
(mips_save_gp_to_cprestore_slot): Handle SImode and DImode
cprestore patterns.
(mips_emit_loadgp): Use PMODE_INSN.  Handle SImode and DImode
copygp_mips16 patterns.
(mips_expand_prologue): Handle SImode and DImode potential_cprestore
and use_cprestore patterns.
(mips_override_options): Check for incompatible -mabi and -mlong
combinations.
* config/mips/mips.md (unspec_got): Rename to...
(unspec_got_): ...this.
(copygp_mips16): Use the Pmode iterator.
(potential_cprestore, cprestore, use_cprestore): Likewise.
(clear_cache, indirect_jump): Use PMODE_INSN.
(indirect_jump): Rename to...
(indirect_jump_): ...this.
(tablejump): Use PMODE_INSN.
(tablejump): Rename to...
(tablejump_): ...this.
(exception_receiver): Handle restore_gp_si and restore_gp_di.
(restore_gp): Use the Pmode iterator.
* config/mips/mips-dsp.md (mips_lbux, mips_lhx, mips_lwx): Use
PMODE_INSN.

gcc/testsuite/
PR target/49606
* gcc.target/mips/abi-main.h: New file.
* gcc.target/mips/abi-o32-long32.c: New test.
* gcc.target/mips/abi-o32-long64.c: Likewise.
* gcc.target/mips/abi-o64-long32.c: Likewise.
* gcc.target/mips/abi-o64-long64.c: Likewise.
* gcc.target/mips/abi-n32-long32.c: Likewise.
* gcc.target/mips/abi-n32-long64.c: Likewise.
* gcc.target/mips/abi-n64-long32.c: Likewise.
* gcc.target/mips/abi-n64-long64.c: Likewise.
* gcc.target/mips/abi-o32-long32-no-shared.c: Likewise.
* gcc.target/mips/abi-o32-long64-no-shared.c: Likewise.
* gcc.target/mips/abi-o64-long32-no-shared.c: Likewise.
* gcc.target/mips/abi-o64-long64-no-shared.c: Likewise.
* gcc.target/mips/abi-n32-long32-no-shared.c: Likewise.
* gcc.target/mips/abi-n32-long64-no-shared.c: Likewise.
* gcc.target/mips/abi-n64-long32-no-shared.c: Likewise.
* gcc.target/mips/abi-n64-long64-no-shared.c: Likewise.
* gcc.target/mips/abi-o32-long32-pic.c: Likewise.
* gcc.target/mips/abi-o32-long64-pic.c: Likewise.
* gcc.target/mips/abi-o64-long32-pic.c: Likewise.
* gcc.target/mips/abi-o64-long64-pic.c: Likewise.
* gcc.target/mips/abi-n32-long32-pic.c: Likewise.
* gcc.target/mips/abi-n32-long64-pic.c: Likewise.
* gcc.target/mips/abi-n64-long32-pic.c: Likewise.
* gcc.target/mips/abi-n64-long64-pic.c: Likewise.
* gcc.target/mips/abi-eabi32-long32.c: Likewise.
* gcc.target/mips/abi-eabi32-long64.c: Likewise.
* gcc.target/mips/abi-eabi64-long32.c: Likewise.
* gcc.target/mips/abi-eabi64-long64.c: Likewise.
* gcc.target/mips/mips.exp: Make -mshared implied -mabicalls.
* gcc.target/mips/branch-2.c: Remove -mabicalls.
* gcc.target/mips/branch-3.c: Likewise.
* gcc.target/mips/branch-4.c: Likewise.
* gcc.target/mips/branch-5.c: Likewise.
* gcc.target/mips/branch-6.c: Likewise.
* gcc.target/mips/branch-7.c: Likewise.
* gcc.target/mips/branch-8.c: Likewise.
* gcc.target/mips/branch-9.c: Likewise.
* gcc.target/mips/branch-10.c: Likewise.
* gcc.target/mips/branch-11.c: Likewise.
* gcc.target/mips/branch-12.c: Likewise.
* gcc.target/mips/branch-13.c: Likewise.
* gcc.target/mips/lazy-binding-1.c: Likewise.

Index: gcc/config/mips/mips.h
===

Re: [Patch, Ada, Darwin] Fix bootstrap issue on Darwin8.

2011-09-05 Thread Jack Howarth
On Mon, Sep 05, 2011 at 08:26:49PM +0100, Iain Sandoe wrote:
> Hi Arno,
>
> On 5 Sep 2011, at 20:04, Arnaud Charlet wrote:
>
>>> Darwin8 does not have _SC_NPROCESSORS_ONLN defined.
>>
>> Is Darwin8 still active/supported?
>
> it works - and I test from time to time.
> .. feedback from fink in the form of bug reports suggests that it is  
> still being used in the wild too.

FYI, fink has moved darwin8 package support into a 10.4-EOL tree and developers
are no longer obligated to insure that fink packages build under darwin8.
Basically almost all of the fink developers just wish darwin8 would go away.
   Jack

>
> In fact, the tortuous route I used to get to a working PPC ADA bootstrap 
> was via a native-X darwin 8 compiler built on linux ;-)
> (Now I know the problem with the PPC bootstrap it's easier to do a  
> native X from i686-darwin, but I was debugging).
>
> 
>
> The policy we have adopted is not to break earlier Darwin if possible -
> (bearing in mind that Darwin is volunteer-supported these days and we  
> have scant resources).
>
> However, FWIW, It is possible to build 4.6 even on Darwin 7 with some  
> fiddling (odcctools) ...
>
> [ However, I'm not going to nail my colors to the mast over this one ;-) 
> ]
>
>> Not as submitted, you haven't provided a suitable changelog for  
>> review.
>
> oops... apologies (and for the long lines in the other change logs)
> ... shouldn't type them directly into the mailer I suppose.
>
> ada:
>   
>   * adaint.c (__gnat_number_of_cpus): Don't try to check
>   _SC_NPROCESSORS_ONLN for early versions of Darwin.
>
>> Also, when you repost your patch, can you please send a single version 
>> of
>> the patch (either inline or as an attachment)? TIA.
>
> The reason for duplication was that some people prefer one and some the 
> other ..
> .. plus mailers sometimes mangle in-line patches;
>
> OK for trunk/4.6?
> Iain
>

> Index: gcc/ada/adaint.c
> ===
> --- gcc/ada/adaint.c  (revision 178554)
> +++ gcc/ada/adaint.c  (working copy)
> @@ -2460,7 +2460,10 @@ __gnat_number_of_cpus (void)
>int cores = 1;
>  
>  #if defined (linux) || defined (sun) || defined (AIX) \
> -|| (defined (__alpha__)  && defined (_osf_)) || defined (__APPLE__)
> +|| (defined (__alpha__)  && defined (_osf_)) \
> +|| (defined (__APPLE__) \
> +&& defined (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) \
> +&& __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050)
>cores = (int) sysconf (_SC_NPROCESSORS_ONLN);
>  
>  #elif (defined (__mips) && defined (__sgi))

>
>
>



[PATCH] Fix target default on biarch Linux/Sparc

2011-09-05 Thread David Miller

If you configure a biarch Linux/Sparc compiler defaulting to
32-bit, but give --with-cpu= for a v9 cpu it erroneously
turns on 64-bit in TARGET_DEFAULT.

The right thing to do is what the Solaris/Sparc target does,
which is to key things off of a cpp macro (TARGET_64BIT_DEFAULT)
which is defined by a header that gets prepended to the target
header list based upon the target triplet.

Therefore I moved sol2-64.h to default-64.h and use it for Linux
biarch builds too when appropriate.

gcc/

* config/sparc/sol2-64.h: Move ...
* config/sparc/default-64.h: ... to here.  Update comment.
* config.gcc: Update Solaris sparc to use default-64.h, also
prefix this header into the list on sparc64-*-linux.
* config/sparc/linux64.h (TARGET_DEFAULT): Only override if
TARGET_64BIT_DEFAULT is defined.  Remove commented out reference
to MASK_HARD_QUAD.

Index: gcc/config.gcc
===
--- gcc/config.gcc  (revision 178557)
+++ gcc/config.gcc  (revision 178558)
@@ -2501,7 +2501,7 @@
tm_file="sparc/biarch64.h ${tm_file} ${sol2_tm_file} sol2-bi.h"
case ${target} in
sparc64-*-* | sparcv9-*-*)
-   tm_file="sparc/sol2-64.h ${tm_file}"
+   tm_file="sparc/default-64.h ${tm_file}"
;;
*)
test x$with_cpu != x || with_cpu=v9
@@ -2523,7 +2523,7 @@
tmake_file="${tmake_file} t-rtems"
;;
 sparc64-*-linux*)
-   tm_file="sparc/biarch64.h ${tm_file} dbxelf.h elfos.h sparc/sysv4.h 
gnu-user.h linux.h glibc-stdint.h sparc/linux64.h"
+   tm_file="sparc/biarch64.h ${tm_file} dbxelf.h elfos.h sparc/sysv4.h 
gnu-user.h linux.h glibc-stdint.h sparc/default-64.h sparc/linux64.h"
extra_options="${extra_options} sparc/long-double-switch.opt"
tmake_file="${tmake_file} sparc/t-linux sparc/t-linux64"
extra_parts="${extra_parts} crtfastmath.o"
Index: gcc/config/sparc/sol2-64.h
===
--- gcc/config/sparc/sol2-64.h  (revision 178557)
+++ gcc/config/sparc/sol2-64.h  (revision 178558)
@@ -1,22 +0,0 @@
-/* Definitions of target machine for GCC, for bi-arch SPARC
-   running Solaris 2, defaulting to 64-bit code generation.
-
-   Copyright (C) 1999, 2010, 2011 Free Software Foundation, Inc.
-
-This file is part of GCC.
-
-GCC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3, or (at your option)
-any later version.
-
-GCC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING3.  If not see
-.  */
-
-#define TARGET_64BIT_DEFAULT 1
Index: gcc/config/sparc/linux64.h
===
--- gcc/config/sparc/linux64.h  (revision 178557)
+++ gcc/config/sparc/linux64.h  (revision 178558)
@@ -31,20 +31,11 @@
 }  \
   while (0)
 
-#if TARGET_CPU_DEFAULT == TARGET_CPU_v9 \
-|| TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc \
-|| TARGET_CPU_DEFAULT == TARGET_CPU_ultrasparc3 \
-|| TARGET_CPU_DEFAULT == TARGET_CPU_niagara \
-|| TARGET_CPU_DEFAULT == TARGET_CPU_niagara2 \
-|| TARGET_CPU_DEFAULT == TARGET_CPU_niagara3 \
-|| TARGET_CPU_DEFAULT == TARGET_CPU_niagara4
-/* A 64 bit v9 compiler with stack-bias,
-   in a Medium/Low code model environment.  */
-
+#ifdef TARGET_64BIT_DEFAULT
 #undef TARGET_DEFAULT
 #define TARGET_DEFAULT \
-  (MASK_V9 + MASK_PTR64 + MASK_64BIT /* + MASK_HARD_QUAD */ \
-   + MASK_STACK_BIAS + MASK_APP_REGS + MASK_FPU + MASK_LONG_DOUBLE_128)
+  (MASK_V9 + MASK_PTR64 + MASK_64BIT + MASK_STACK_BIAS + \
+   MASK_APP_REGS + MASK_FPU + MASK_LONG_DOUBLE_128)
 #endif
 
 /* This must be v9a not just v9 because by default we enable
Index: gcc/config/sparc/default-64.h
===
--- gcc/config/sparc/default-64.h   (revision 0)
+++ gcc/config/sparc/default-64.h   (revision 178558)
@@ -0,0 +1,22 @@
+/* Definitions of target machine for GCC, for bi-arch SPARC,
+   defaulting to 64-bit code generation.
+
+   Copyright (C) 1999, 2010, 2011 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILI

Re: [PATCH] Support -m{cpu,tune}=native on Linux/Sparc

2011-09-05 Thread Gerald Pfeifer
On Sun, 4 Sep 2011, David Miller wrote:
>   * gcc/doc/invoke.texi: Document that Linux also supports
>   -mcpu=native and -mtune=native on sparc.
:
> -Native Solaris toolchains also support the value @samp{native},
> +Native Solaris and Linux toolchains also support the value @samp{native},
:
> +@samp{niagara}, and @samp{niagara2}.  With native Solaris and Linux
> +toolchains, @samp{native} can also be used.

Should we use GNU/Linux in those three cases per the standing request
from RMS?  I can make the change if so.

Gerald


Re: [PATCH] Support -m{cpu,tune}=native on Linux/Sparc

2011-09-05 Thread David Miller
From: Gerald Pfeifer 
Date: Tue, 6 Sep 2011 00:57:08 +0200 (CEST)

> Should we use GNU/Linux in those three cases per the standing request
> from RMS?  I can make the change if so.

I'm completely ambivalent, feel free to make the change.


Re: [Patch, Ada, Darwin] Restore PowerPC Darwin Ada bootstrap (after a looong time, it seems).

2011-09-05 Thread Mike Stump
On Sep 5, 2011, at 11:50 AM, Iain Sandoe  
wrote:
> 1.  rs6000.c (WORLD_SAVE_P) decides on the use of the out-of-line prologue 
> saves on the basis of cfun->calls_setjmp && flag_exceptions.
>   of course, flag_exceptions is NOT set by Ada for SjLj - which is what's 
> used for the compiler build.

Ick...  It seems wrong to me   15 years later and it still feels like there 
is too much chewing gum involved.  Unless someone has a better idea on how to 
press forward, I'll ok the Darwin only change to rs6000.  I think that the 
change to turn of fexceptions when doing exceptions is a better way forward, 
but that is like to be a way more destabilizing change and likely the Ada folks 
have their reasons why that won't work.
> 


RE: [PATCH, testsuite, ARM] change XFAIL to pass for ARM on a case testing tree-ssa-dom

2011-09-05 Thread Jiangning Liu
PING...

> -Original Message-
> From: gcc-patches-ow...@gcc.gnu.org [mailto:gcc-patches-
> ow...@gcc.gnu.org] On Behalf Of Jiangning Liu
> Sent: Friday, August 26, 2011 5:56 PM
> To: gcc-patches@gcc.gnu.org
> Subject: [PATCH, testsuite, ARM] change XFAIL to pass for ARM on a case
> testing tree-ssa-dom
> 
> Test case gcc.dg/tree-ssa/20040204-1.c can pass for -O1 after Richard
> Guenther  fixed something in tree-ssa-dom. The
> "link_error" should be optimized away for ARM targets as well.
> 
> The patch is:
> 
> diff --git a/gcc/testsuite/gcc.dg/tree-ssa/20040204-1.c
> b/gcc/testsuite/gcc.dg/tree-ssa/20040204-1.c
> index 45e44a1..470b585 100644
> --- a/gcc/testsuite/gcc.dg/tree-ssa/20040204-1.c
> +++ b/gcc/testsuite/gcc.dg/tree-ssa/20040204-1.c
> @@ -33,5 +33,5 @@ void test55 (int x, int y)
> that the && should be emitted (based on BRANCH_COST).  Fix this
> by teaching dom to look through && and register all components
> as true.  */
> -/* { dg-final { scan-tree-dump-times "link_error" 0 "optimized"
> { xfail { !
> "alpha*-*-* powerpc*-*-* cris-*-* crisv32-*-* hppa*-*-* i?86-*-* mmix-
> *-*
> mips*-*-* m68k*-*-* moxie-*-* sparc*-*-* spu-*-* x86_64-*-*" } } } } */
> +/* { dg-final { scan-tree-dump-times "link_error" 0 "optimized"
> { xfail { !
> "alpha*-*-* arm*-*-* powerpc*-*-* cris-*-* crisv32-*-* hppa*-*-* i?86-
> *-*
> mmix-*-* mips*-*-* m68k*-*-* moxie-*-* sparc*-*-* spu-*-* x86_64-*-
> *" } } }
> } */
>  /* { dg-final { cleanup-tree-dump "optimized" } } */
> 
> gcc/testsuite/ChangeLog:
> 
> 2011-08-26  Jiangning Liu  
> 
>PR tree-optimization/46021
>* gcc.dg/tree-ssa/20040204-1.c: Don't XFAIL on arm*-*-*.
> 
> Thanks,
> -Jiangning
> 
> 
> 





Re: [PATCH] Store jump functions in a VECtor

2011-09-05 Thread H.J. Lu
On Fri, Sep 2, 2011 at 8:24 AM, Martin Jambor  wrote:
> Hi,
>
> when I submitted the new IPA-CP a few months ago Honza requested that
> I store the jump_functions in a VECtor rather than an array in which
> they are now.  The patch below does exactly that.
>
> The last remaining such request is to rename
> ipa_check_create_node_params to "something else."  I guess I'll leave
> this to the next weekend when we'll see each other.
>
> I hope I got the ggc stuff right and a GTY marker does not need to be
> added somewhere.  On the other hand, the patch passes bootstrap and
> testsuite on x86_64-linux and I have successfully LTO-built Firefox
> with it (which was able to display some complicated pages).
>
> OK for trunk?
>
> Thanks,
>
> Martin
>
>
> 2011-09-02  Martin Jambor  
>
>        * ipa-prop.h (ipa_jump_func_t): New typedef.
>        (struct ipa_edge_args): Removed field argument_count, field
>        jump_functions turned into a vector.
>        (ipa_set_cs_argument_count): Removed.
>        (ipa_get_cs_argument_count): Updated to work on vectors.
>        (ipa_get_ith_jump_func): Likewise.
>        * ipa-prop.c (ipa_count_arguments): Removed.
>        (compute_scalar_jump_functions): Use ipa_get_ith_jump_func to access
>        jump functions.  Update caller.
>        (compute_pass_through_member_ptrs): Likewise.
>        (compute_cst_member_ptr_arguments): Likewise.
>        (ipa_compute_jump_functions_for_edge): Get number of arguments from
>        the statement, allocate vector.
>        (ipa_compute_jump_functions): Do not call ipa_count_arguments.
>        (duplicate_ipa_jump_func_array): Removed.
>        (ipa_edge_duplication_hook): Use VEC_copy, do not copy argument count.
>        (ipa_read_node_info): Allocate vector.
>
>

This caused:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50301

-- 
H.J.


Re: [Patch, Ada, Darwin] Restore PowerPC Darwin Ada bootstrap (after a looong time, it seems).

2011-09-05 Thread Geert Bosch

On Sep 5, 2011, at 14:50, Iain Sandoe wrote:
> ... AFAICT from googling, powerpc-darwin9 has never bootstrapped ADA (I see 
> questions but no resolution).
> Perhaps Adacore has a version ... but I was unable to find any starting point 
> - so this was somewhat tough to debug.

Nope, if we had supported any PPC-darwin versions, the required changes would 
have been checked in. Of course, it is hardly surprising that the platform 
isn't commercially viable anymore. So, Ada(*) support depends on volunteers 
like you... :-)

  -Geert

--
* Note capitalization


Re: Add unwind information to mips epilogues

2011-09-05 Thread Richard Henderson
On 09/05/2011 01:36 PM, Richard Sandiford wrote:
> Richard Henderson  writes:
>> On 09/01/2011 12:13 AM, Richard Sandiford wrote:
>>> Also, for the frame_pointer_required case, it looks like there's a
>>> window between the restoration of the frame pointer and the deallocation
>>> of the stack in which the CFA is still defined in terms of the frame
>>> pointer register.  Is that significant?  If not (e.g. because we
>>> should never need to unwind at that point) then why do we still
>>> update the CFA here:
>>
>> What window are you referring to?
>>
>> Best I can tell from looking at the patch we restore the CFA to the
>> stack pointer before anything else.
> 
> Well, I'm probably showing my ignorance here, but what I meant was:
> we attach the DEF_CFA and the CFA_RESTORE notes to the final stack
> deallocation.  I was just worried that, immediately before that
> deallocation, the CFA is still defined in terms of the frame pointer,
> even though the frame pointer has already been restored.  So it seemed
> like someone trying to unwind at that point would get the wrong CFA.

I don't see that.  I'm pasting from mainline but not the patch, but here:

>   /* Copy TARGET into the stack pointer.  */
>   if (target != stack_pointer_rtx)
> mips_emit_move (stack_pointer_rtx, target);

We restore the stack pointer from the frame pointer before restoring
the frame pointer.  The patch changes this spot with DEF_CFA.  So the
problem you're suggesting ought not be true.


r~


RE: [arm-embedded] Backport r174965 from trunk to ARM/embedded-4_6-branch

2011-09-05 Thread Joey Ye
> -Original Message-
> From: Terry Guo
> Sent: Monday, September 05, 2011 17:18
> To: Joey Ye; gcc-patches@gcc.gnu.org
> Subject: [arm-embedded] Backport r174965 from trunk to ARM/embedded-
> 4_6-branch
> 
> Hi,
> 
> The checkin at r174965 in trunk fixed vect-27.c failure for ARM EABI
> target.
> Detailed information please refer to
> http://gcc.gnu.org/ml/gcc-patches/2011-06/msg00927.html.
> 
> Performed regression test on arm QEMU and no regression.
> 
> OK to ARM/embedded-4_6-branch?
OK

> 
> BR,
> Terry
> 
> 2011-09-05  Terry Guo  
> 
>   Backport r174965 from trunk.
> 
>   2011-06-12  Ira Rosen  
> 
>   * tree-vect-data-refs.c
> (vect_peeling_hash_get_most_frequent):
>   Take number of iterations to peel into account for equally
> frequent
>   misalignment values.
> 
> Index: gcc/tree-vect-data-refs.c
> ===
> --- gcc/tree-vect-data-refs.c (revision 178517)
> +++ gcc/tree-vect-data-refs.c (working copy)
> @@ -1250,7 +1250,9 @@
>vect_peel_info elem = (vect_peel_info) *slot;
>vect_peel_extended_info max = (vect_peel_extended_info) data;
> 
> -  if (elem->count > max->peel_info.count)
> +  if (elem->count > max->peel_info.count
> +  || (elem->count == max->peel_info.count
> +  && max->peel_info.npeel > elem->npeel))
>  {
>max->peel_info.npeel = elem->npeel;
>max->peel_info.count = elem->count;
> 





[Patch][Cilkplus branch] Adding include directory path to testsuite script

2011-09-05 Thread Iyer, Balaji V
Hello Everyone,
This patch is for the Cilk Plus branch. It will add the include 
directory path it the testsuite script (cilk_plus.exp) in both gcc.dg/cilk-plus 
and g++.dg/cilk-plus directories.

Thanking You,

Yours sincerely,

Balaji V. Iyer.
diff --git a/gcc/testsuite/g++.dg/cilk-plus/cilk_plus.exp 
b/gcc/testsuite/g++.dg/cilk-plus/cilk_plus.exp
index 9f91b0c..8a9fdd4 100644
--- a/gcc/testsuite/g++.dg/cilk-plus/cilk_plus.exp
+++ b/gcc/testsuite/g++.dg/cilk-plus/cilk_plus.exp
@@ -18,6 +18,6 @@
 load_lib g++-dg.exp
 
 dg-init
-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.cpp]] "-fsyntax-only -w 
-lcilkrts -ldl " " "
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.cpp]] " -w -lcilkrts 
-ldl -I  $srcdir/../../libcilkrts/include " " "
 
 dg-finish
diff --git a/gcc/testsuite/gcc.dg/cilk-plus/cilk_plus.exp 
b/gcc/testsuite/gcc.dg/cilk-plus/cilk_plus.exp
index b228b65..dcf096e 100644
--- a/gcc/testsuite/gcc.dg/cilk-plus/cilk_plus.exp
+++ b/gcc/testsuite/gcc.dg/cilk-plus/cilk_plus.exp
@@ -18,6 +18,6 @@
 load_lib gcc-dg.exp
 
 dg-init
-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] "-fsyntax-only 
-lcilkrts -ldl -std=c99" " "
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] " -ldl 
-lcilkrts -I $srcdir/../../libcilkrts/include -std=c99 " " "
 
 dg-finish


Re: [patch] support for multiarch systems

2011-09-05 Thread Thomas Schwinge
Hi!

On Sun, 21 Aug 2011 02:14:10 +0200, Matthias Klose  wrote:
Non-text part: multipart/mixed
> On 08/20/2011 09:51 PM, Matthias Klose wrote:
> > Multiarch [1] is the term being used to refer to the capability of a system 
> > to
> > install and run applications of multiple different binary targets on the 
> > same
> > system.  The idea and name of multiarch dates back to 2004/2005 [2] (to be
> > confused with multiarch in glibc).
> 
> attached is an updated patch which includes feedback from Jakub and Joseph.

I can confirm that this restores out-of-the box GCC bootstrap on Debian
GNU/Linux testing 386 and Debian GNU/Hurd unstable i386.  Thanks!

A hint for the kids trying this patch at home: don't forget to regenerate
gcc/configure...  (Saves you some hours...)  ;-)


Matthias, please put the following patch on top, though.  (For preserving
the order of using i386/t-linux (which should be renamed i386/t-gnu-user,
but that's for another day) and i386/t-{gnu,kfreebsd}.

* gcc/config.gcc 
: Take care to put their configuration files after
the i386/t-linux one.
 
diff --git a/gcc/config.gcc b/gcc/config.gcc
index 784ddd7..7d0214f 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -1317,14 +1317,12 @@ i[34567]86-*-linux* | i[34567]86-*-kfreebsd*-gnu | 
i[34567]86-*-knetbsd*-gnu | i
;;
i[34567]86-*-kfreebsd*-gnu)
tm_file="${tm_file} i386/gnu-user.h kfreebsd-gnu.h 
i386/kfreebsd-gnu.h"
-   tmake_file="${tmake_file} i386/t-kfreebsd"
;;
i[34567]86-*-kopensolaris*-gnu)
tm_file="${tm_file} i386/gnu-user.h kopensolaris-gnu.h 
i386/kopensolaris-gnu.h"
;;
i[34567]86-*-gnu*)
tm_file="$tm_file i386/gnu-user.h gnu.h i386/gnu.h"
-   tmake_file="${tmake_file} i386/t-gnu"
;;
esac
tmake_file="${tmake_file} i386/t-crtstuff"
@@ -3587,11 +3585,15 @@ case ${target} in
 
i[34567]86-*-darwin* | x86_64-*-darwin*)
;;
-   i[34567]86-*-linux* | x86_64-*-linux* | \
- i[34567]86-*-kfreebsd*-gnu | x86_64-*-kfreebsd*-gnu | \
- i[34567]86-*-gnu*)
+   i[34567]86-*-linux* | x86_64-*-linux*)
tmake_file="${tmake_file} i386/t-linux"
;;
+   i[34567]86-*-kfreebsd*-gnu | x86_64-*-kfreebsd*-gnu)
+   tmake_file="${tmake_file} i386/t-linux i386/t-kfreebsd"
+   ;;
+   i[34567]86-*-gnu*)
+   tmake_file="${tmake_file} i386/t-linux i386/t-gnu"
+   ;;
i[34567]86-*-solaris2* | x86_64-*-solaris2.1[0-9]*)
;;
i[34567]86-*-cygwin* | i[34567]86-*-mingw* | x86_64-*-mingw*)


Grüße,
 Thomas


pgp84Dl6hIS8C.pgp
Description: PGP signature