Re: [v3] constexpr tuple

2011-09-06 Thread Daniel Krügler
2011/9/7 Benjamin Kosnik :
>
> Here's the tuple additions for constexpr now that it's ok to return
> this.

Btw.: I would have expected that you can make
__tuple_compare<>::__eq/__less also constexpr.

These are static functions, thus __tuple_compare
itself need not to be a literal type (Disclaimer: I did
not check all __tuple_compare specializations).

> Is tuple_cat now considered conforming?

No, see:

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

> If so, certain signatures can be constexpr.

Yes.

- Daniel


[google][main]Fix broken test cases in google/main branch (issue4961065)

2011-09-06 Thread Sriraman Tallam
This patches fixes bugs that caused the multi-version tests to fail.

* mversn-dispatch.c (specialize_call): Rebuild cgraph edges after
specialization.
(clone_and_dispatch_function): Rebuild cgraph edges to compute
inline parameters.
(do_convert_builtin_dispatch): Ditto.
(convert_builtin_dispatch): Remove call to mark_syms_for_renaming
for phi nodes.
* passes.c (init_optimization_passes): Remove pass to rebuild
cgraph edges after converting __builtin_dispatch.


Index: mversn-dispatch.c
===
--- mversn-dispatch.c   (revision 178618)
+++ mversn-dispatch.c   (working copy)
@@ -1166,6 +1166,10 @@ specialize_call (tree clone_decl, int side)
   gsi = gsi_for_stmt (specialized_call_stmt);
}
 }
+
+  /* Rebuild cgraph edges for the clone. */
+  rebuild_cgraph_edges ();
+
   current_function_decl = old_current_function_decl;
   pop_cfun ();
 }
@@ -1282,6 +1286,8 @@ clone_and_dispatch_function (struct cgraph_node *o
  global. */
   update_ssa (TODO_update_ssa);
 
+  /* cgraph edges need to be updated before computing inline parameters. */
+  rebuild_cgraph_edges ();
   compute_inline_parameters (cgraph_get_create_node (orig_fndecl), false);
   DECL_DECLARED_INLINE_P (orig_fndecl) = 1;
   DECL_UNINLINABLE (orig_fndecl) = 0;
@@ -1623,7 +1629,6 @@ convert_builtin_dispatch (gimple stmt)
   phinode = create_phi_node (tmp_var, bb4);
   add_phi_arg (phinode, ssa_if_name, e24, UNKNOWN_LOCATION);
   add_phi_arg (phinode, ssa_else_name, e34, UNKNOWN_LOCATION);
-  mark_symbols_for_renaming (phinode);
   gcc_assert (lhs_result);
   assign_stmt
 = gimple_build_assign (lhs_result, gimple_phi_result (phinode));
@@ -1732,6 +1737,8 @@ do_convert_builtin_dispatch (void)
++ix)
 convert_builtin_dispatch (builtin_stmt);
 
+  /* cgraph edges need to be updated before computing inline parameters. */
+  rebuild_cgraph_edges ();
   compute_inline_parameters (cgraph_get_create_node (current_function_decl),
 false);
  
Index: passes.c
===
--- passes.c(revision 178618)
+++ passes.c(working copy)
@@ -1254,10 +1254,6 @@ init_optimization_passes (void)
 {
   struct opt_pass **p = &pass_ipa_multiversion_dispatch.pass.sub;
   NEXT_PASS (pass_tree_convert_builtin_dispatch);
-  /* Rebuilding cgraph edges is necessary as the above passes change
- the call graph.  Otherwise, future optimizations use the old
-call graph and make wrong decisions sometimes.*/
-  NEXT_PASS (pass_rebuild_cgraph_edges);
 }
   NEXT_PASS (pass_ipa_lower_emutls);
   *p = NULL;

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


Fix a cfgcleanup head-merge issue on cc0 targets

2011-09-06 Thread Bernd Schmidt
This showed up with a coldfire-linux toolchain. get_condition can return
NULL in some cases when the condition is reversed and there are float
modes involved; in that case we will move instructions in between a cc0
user and setter.

This patch fixes it. Tested on cris-elf, since I currently have no way
of testing m68k. Will commit as obvious tomorrow if no objections.


Bernd
* cfgcleanup.c (try_head_merge_bb): If get_condition returns
NULL for a jump that is a cc0 insn, pick the previous insn for
move_before.

* gcc.c-torture/compile/20110907.c: New file.

Index: gcc/cfgcleanup.c
===
--- gcc/cfgcleanup.c(revision 178596)
+++ gcc/cfgcleanup.c(working copy)
@@ -2214,7 +2214,14 @@ try_head_merge_bb (basic_block bb)
 
   cond = get_condition (jump, &move_before, true, false);
   if (cond == NULL_RTX)
-move_before = jump;
+{
+#ifdef HAVE_cc0
+  if (reg_mentioned_p (cc0_rtx, jump))
+   move_before = prev_nonnote_nondebug_insn (jump);
+  else
+#endif
+   move_before = jump;
+}
 
   for (ix = 0; ix < nedges; ix++)
 if (EDGE_SUCC (bb, ix)->dest == EXIT_BLOCK_PTR)
@@ -2376,7 +2383,14 @@ try_head_merge_bb (basic_block bb)
   jump = BB_END (final_dest_bb);
   cond = get_condition (jump, &move_before, true, false);
   if (cond == NULL_RTX)
-   move_before = jump;
+   {
+#ifdef HAVE_cc0
+ if (reg_mentioned_p (cc0_rtx, jump))
+   move_before = prev_nonnote_nondebug_insn (jump);
+ else
+#endif
+   move_before = jump;
+   }
 }
 
   do
Index: gcc/testsuite/gcc.c-torture/compile/20110907.c
===
--- gcc/testsuite/gcc.c-torture/compile/20110907.c  (revision 0)
+++ gcc/testsuite/gcc.c-torture/compile/20110907.c  (revision 0)
@@ -0,0 +1,26 @@
+struct ieee754_double {
+  double d;
+};
+extern const float __exp_deltatable[178];
+float __ieee754_expf (float x)
+{
+  static const float himark = 88.72283935546875;
+  static const float lomark = -103.972084045410;
+  if (__builtin_isless(x, himark) && __builtin_isgreater(x, lomark))
+{
+  int tval;
+  double x22, t, result, dx;
+  float delta;
+  struct ieee754_double ex2_u;
+  dx -= t;
+  tval = (int) (t * 512.0);
+  if (t >= 0)
+   delta = - __exp_deltatable[tval];
+  else
+   delta = __exp_deltatable[-tval];
+  x22 = (0.500496709180453 * dx + 1.001192102037084) * dx + delta;
+  result = x22 * ex2_u.d + ex2_u.d;
+  return (float) result;
+}
+  return x;
+}


[v3] constexpr tuple

2011-09-06 Thread Benjamin Kosnik

Here's the tuple additions for constexpr now that it's ok to return
this. 

I'm not quite sure what to do with the get, tie, tuple_cat functions
given the current signatures. Is tuple_cat now considered conforming?
If so, certain signatures can be constexpr. 

tested x86/linux

benjamin2011-09-06  Benjamin Kosnik  

	* include/std/tuple (_Tuple_impl::_M_head, _M_tail): Mark constexpr.
	(tuple(tuple&&)): Same.
	(tuple(const tuple<_UElements...>& __in)): Same.
	(tuple(tuple<_UElements...>&& __in)): Same.
	(tuple_cat(const tuple<_TElements...>&, const tuple<_UElements...>&)):
	Same.
	(get): Same.
	* include/std/array: Consolidate array::data usage.
	* testsuite/23_containers/array/requirements/constexpr_functions.cc: 
	Remove extra include.
	* testsuite/20_util/tuple/creation_functions/constexpr.cc: New.
	* testsuite/20_util/tuple/cons/constexpr-2.cc: Add tests.
	* testsuite/20_util/tuple/cons/constexpr-3.cc: Same.
	* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Adjust line numbers.

Index: include/std/tuple
===
--- include/std/tuple	(revision 178557)
+++ include/std/tuple	(working copy)
@@ -143,7 +143,7 @@
   _Head&   
   _M_head() noexcept { return *this; }
 
-  const _Head& 
+  constexpr const _Head& 
   _M_head() const noexcept { return *this; }
 };
 
@@ -189,7 +189,7 @@
   _Head&   
   _M_head() noexcept { return _M_head_impl; }
 
-  const _Head& 
+  constexpr const _Head& 
   _M_head() const noexcept { return _M_head_impl; }
 
   _Head _M_head_impl; 
@@ -248,13 +248,13 @@
   _Head&
   _M_head() noexcept { return _Base::_M_head(); }
 
-  const _Head&  
+  constexpr const _Head&  
   _M_head() const noexcept { return _Base::_M_head(); }
 
   _Inherited&   
   _M_tail() noexcept { return *this; }
 
-  const _Inherited& 
+  constexpr const _Inherited& 
   _M_tail() const noexcept { return *this; }
 
   constexpr _Tuple_impl()
@@ -280,7 +280,7 @@
 	_Base(std::forward<_Head>(__in._M_head())) { }
 
   template
-_Tuple_impl(const _Tuple_impl<_Idx, _UElements...>& __in)
+constexpr _Tuple_impl(const _Tuple_impl<_Idx, _UElements...>& __in)
 	: _Inherited(__in._M_tail()), _Base(__in._M_head()) { }
 
   template
@@ -409,7 +409,7 @@
 
   constexpr tuple(const tuple&) = default;
 
-  tuple(tuple&&) = default;
+  constexpr tuple(tuple&&) = default; 
 
   template,
 	   __conv_types<_Elements...>>
  >::value>::type>
-tuple(const tuple<_UElements...>& __in)
+constexpr tuple(const tuple<_UElements...>& __in)
 : _Inherited(static_cast&>(__in))
 { }
 
@@ -427,7 +427,7 @@
 			 __all_convertible<__conv_types<_UElements...>,
 	   __conv_types<_Elements...>>
 			 >::value>::type>
-tuple(tuple<_UElements...>&& __in)
+constexpr tuple(tuple<_UElements...>&& __in)
 : _Inherited(static_cast<_Tuple_impl<0, _UElements...>&&>(__in)) { }
 
   // Allocator-extended constructors.
@@ -548,18 +548,18 @@
 
   constexpr tuple(const tuple&) = default;
 
-  tuple(tuple&&) = default;
+  constexpr tuple(tuple&&) = default;
 
   template,
 			 is_convertible>::value>::type>
-tuple(const tuple<_U1, _U2>& __in)
+constexpr tuple(const tuple<_U1, _U2>& __in)
 	: _Inherited(static_cast&>(__in)) { }
 
   template,
 is_convertible<_U2, _T2>>::value>::type>
-tuple(tuple<_U1, _U2>&& __in)
+constexpr tuple(tuple<_U1, _U2>&& __in)
 	: _Inherited(static_cast<_Tuple_impl<0, _U1, _U2>&&>(__in)) { }
 
   template,
 is_convertible<_U2, _T2>>::value>::type>
- tuple(pair<_U1, _U2>&& __in)
+ constexpr tuple(pair<_U1, _U2>&& __in)
 	: _Inherited(std::forward<_U1>(__in.first),
 		 std::forward<_U2>(__in.second)) { }
 
@@ -752,7 +752,7 @@
 { return __t._M_head(); }
 
   template
-inline typename __add_c_ref<_Head>::type
+inline constexpr typename __add_c_ref<_Head>::type
 __get_helper(const _Tuple_impl<__i, _Head, _Tail...>& __t) noexcept
 { return __t._M_head(); }
 
@@ -767,7 +767,7 @@
 { return __get_helper<__i>(__t); }
 
   template
-inline typename __add_c_ref<
+inline constexpr typename __add_c_ref<
   typename tuple_element<__i, tuple<_Elements...>>::type
 >::type
 get(const tuple<_Elements...>& __t) noexcept
@@ -789,13 +789,15 @@
   template
 struct __tuple_compare<0, __i, __j, _Tp, _Up>
 {
-  static bool __eq(const _Tp& __t, const _Up& __u)
+  static bool 
+  __eq(const _Tp& __t, const _Up& __u)
   {
 	return (get<__i>(__t) == get<__i>(__u) &&
 		__tuple_compare<0, __i + 1, __j, _Tp, _Up>::__eq(__t, __u));
   }
  
-  static bool __less(const _Tp& __t, const _Up& __u)
+  static bool 
+  __less(const _Tp& __t, const _Up& __u)
   {

[PATCH, committed] Fix up documentation about tm_p.h

2011-09-06 Thread Michael Meissner
I checked in the following patch to update the documentation for tm_p.h.  I
noticed the FIXME comment in the texi source when I was working on my previous
patch for combining the standard and machine dependent builtin indexes.  While
that patch did not go in, I figured I could improve the documentation for
tm_p.h.

2011-09-06  Michael Meissner  

* doc/configfiles.texi (Configuration Files): Update documentation
about tm_p.h and remove FIXME comment.

Index: gcc/doc/configfiles.texi
===
--- gcc/doc/configfiles.texi(revision 178609)
+++ gcc/doc/configfiles.texi(working copy)
@@ -59,6 +59,14 @@ these include the autoconfigured headers
 machine.
 @item
 @file{tm_p.h}, which includes the header @file{@var{machine}-protos.h}
-that contains prototypes for functions in the target @file{.c} file.
-FIXME: why is such a separate header necessary?
+that contains prototypes for functions in the target
+@file{@var{machine}.c} file.  The header @file{@var{machine}-protos.h}
+can include prototypes of functions that use rtl and tree data
+structures inside appropriate @code{#ifdef RTX_CODE} and @code{#ifdef
+TREE_CODE} conditional code segements.  The
+@file{@var{machine}-protos.h} is included after the @file{rtl.h}
+and/or @file{tree.h} would have been included.  The @file{tm_p.h} also
+includes the header @file{tm-preds.h} which is generated by
+@file{genpreds} program during the build to define the declarations
+and inline functions for the predicate functions.
 @end itemize

-- 
Michael Meissner, IBM
5 Technology Place Drive, M/S 2757, Westford, MA 01886-3141, USA
meiss...@linux.vnet.ibm.com fax +1 (978) 399-6899


Re: [patch][google/integration] Add lightweight checks to vector::begin et. al. (issue4973065)

2011-09-06 Thread Jonathan Wakely
On 6 September 2011 22:58, Paul Pluzhnikov wrote:
> On Tue, Sep 6, 2011 at 2:51 PM, Jonathan Wakely  wrote:
>
>> I don't mean for vector::begin and the other functions in that patch,
>> I mean in general for member functions of any type. There are plenty
>> of functions that wouldn't crash when called through a null pointer.
>> But even std:vector has member functions like that, such as max_size.
>
> Right. (We might tweak the compiler to automagically insert that assert
> in non-omitimized builds ;-)

Heh :-)

Have you considered a compiler option to make 'delete v' zero out the
pointer, so that any following use of it gives an immediate segfault?
That would be conforming (the value of delete's operand is unspecified
after the operation), but would only help if the same pointer is used,
rather than another object with the same value.  I don't know of any
compiler that does that, but have wondered if it would be useful for
debugging some cases.


[PATCH, committed] Fix C++ altivec test case

2011-09-06 Thread Michael Meissner
I committed the following patch as obvious to make the dg-error test match the
current compiler's error message (the current compiler now lists the type which
broke the regexp).

2011-09-06  Michael Meissner  

* g++.dg/ext/altivec-17.C: Fix dg-error to match current compiler.

Index: gcc/testsuite/g++.dg/ext/altivec-17.C
===
--- gcc/testsuite/g++.dg/ext/altivec-17.C   (revision 178613)
+++ gcc/testsuite/g++.dg/ext/altivec-17.C   (working copy)
@@ -12,5 +12,5 @@ typedef vector__ bool__ int bool_simd_ty
 
 void Foo (bool_simd_type const &a)
 {
-  simd_type const &v = a; // { dg-error "'const simd_type&' from expression of 
type 'const bool_simd_type'" }
+  simd_type const &v = a; // { dg-error "invalid initialization of reference 
of type" }
 }

-- 
Michael Meissner, IBM
5 Technology Place Drive, M/S 2757, Westford, MA 01886-3141, USA
meiss...@linux.vnet.ibm.com fax +1 (978) 399-6899


Re: [patch][google/integration] Add lightweight checks to vector::begin et. al. (issue4973065)

2011-09-06 Thread Paul Pluzhnikov
On Tue, Sep 6, 2011 at 2:51 PM, Jonathan Wakely  wrote:

> I don't mean for vector::begin and the other functions in that patch,
> I mean in general for member functions of any type. There are plenty
> of functions that wouldn't crash when called through a null pointer.
> But even std:vector has member functions like that, such as max_size.

Right. (We might tweak the compiler to automagically insert that assert
in non-omitimized builds ;-)

> Anyway, I think we've concluded the patch is not suitable for general
> use, as it has limited value without a debugging allocator that makes
> pages dirty after free.

Agreed. I'll rename __is_valid to _M_is_valid to match the rest of the file,
and submit to google/integration only.

Thanks for your comments,
-- 
Paul Pluzhnikov


Re: [PATCH] check_cfg assert fix

2011-09-06 Thread Maxim Kuvyrkov
On 7/09/2011, at 9:32 AM, Steven Bosscher wrote:

> On Tue, Sep 6, 2011 at 11:31 PM, Steven Bosscher  
> wrote:
>> Index: haifa-sched.c
>> ===
>> --- haifa-sched.c   (revision 178601)
>> +++ haifa-sched.c   (working copy)
>> @@ -6071,7 +6071,10 @@ check_cfg (rtx head, rtx tail)
>> /* Or jump to the next instruction.  */
>> || (EDGE_COUNT (bb->succs) == 1
>> && (BB_HEAD (EDGE_I (bb->succs, 0)->dest)
>> -== JUMP_LABEL (head;
>> +== JUMP_LABEL (head)))
>> +   /* Or the jump is not just a jump.  */
>> +   || (!onlyjump_p (head)
>> +   || returnjump_p (head)));
>>}
>>  if (BB_END (bb) == head)
>>{
>> 
> 
> BTW that's one ugly gcc_assert. Candidate for gcc_checking_assert?

I agree.  I would rather remove the entirety of haifa-sched.c: check_cfg(); 
scheduler is not the right place for checking consistency of CFG.  Check_cfg() 
was useful for debugging scheduler patches, but now it is more of maintainance 
overhead.

Do I have a second vote for removal of check_cfg()?

--
Maxim Kuvyrkov
CodeSourcery / Mentor Graphics




Re: [PATCH, PR 50301] Missing checks of number of actual arguments in IPA-CP

2011-09-06 Thread Jan Hubicka
> Hi,
> 
> somehow I lost two hunks in the patch allowing IPA-CP to process
> functions with variable number of arguments and one of these omissions
> caused PR 50301 (416.gamess LTO miscompilation).  The two hunks check
> the number of actual arguments in two places of IPA-CP which are not
> executed so often and where we currently can get an out-of-bounds
> VECtor failure.
> 
> Bootstrapped and tested on x86_64-linux, I have verified gmaess
> LTO-builds with it.  OK for trunk?

OK,
thanks
Honza
> 
> Thanks,
> 
> Martin
> 
> 
> 2011-09-06  Martin Jambor  
> 
>   PR middle-end/50301
>   * ipa-cp.c (find_more_values_for_callers_subset): Check jump
>   function index bounds.
>   (perhaps_add_new_callers): Likewise.
> 
> Index: src/gcc/ipa-cp.c
> ===
> --- src.orig/gcc/ipa-cp.c
> +++ src/gcc/ipa-cp.c
> @@ -2052,8 +2052,12 @@ find_more_values_for_callers_subset (str
> struct ipa_jump_func *jump_func;
> tree t;
>  
> +  if (i >= ipa_get_cs_argument_count (IPA_EDGE_REF (cs)))
> +{
> +  newval = NULL_TREE;
> +  break;
> +}
> jump_func = ipa_get_ith_jump_func (IPA_EDGE_REF (cs), i);
> -
> t = ipa_value_from_jfunc (IPA_NODE_REF (cs->caller), jump_func);
> if (!t
> || (newval
> @@ -2123,6 +2127,11 @@ perhaps_add_new_callers (struct cgraph_n
> if (!val)
>   continue;
>  
> +   if (i >= ipa_get_cs_argument_count (args))
> + {
> +   insufficient = true;
> +   break;
> + }
> jump_func = ipa_get_ith_jump_func (args, i);
> t = ipa_value_from_jfunc (caller_info, jump_func);
> if (!t || !values_equal_for_ipcp_p (val, t))


Re: [patch][google/integration] Add lightweight checks to vector::begin et. al. (issue4973065)

2011-09-06 Thread Jonathan Wakely
On 6 September 2011 21:52, Paul Pluzhnikov wrote:
> On Tue, Sep 6, 2011 at 1:33 PM, Jonathan Wakely  wrote:
>
>>>  for (it = v->begin(); it != v->end(); ++it)  // Oops!
>>
>> Eurgh, the occurrence of "delete" in anything except a destructor is a
>> code smell that should have led someone to find those bugs anyway!
>> Obviously the code above is a trivial example, but it's unforgivable
>> to write that
>
> I can assure you that the actual code that exhibited these bugs was much
> subtler than that, and the bugs were not immediately obvious.
>
> Sometimes they were not immediately obvious even after running Valgrind
> on the buggy code and getting allocation/deletion/access stack traces with
> source corrdinates.
>
>>> We can't (easily) catch the general problem. This patch allows us to easily
>>> catch this particular instance of it.
>>
>> Sure, but so does adding "assert(this);" at the top of every member
>
> Sorry, no. Adding "assert(this);" does not catch any new bugs (at least
> not on Linux) -- the code would have immediately crashed on zero-page
> dereference anyway.

I don't mean for vector::begin and the other functions in that patch,
I mean in general for member functions of any type. There are plenty
of functions that wouldn't crash when called through a null pointer.
But even std:vector has member functions like that, such as max_size.

Anyway, I think we've concluded the patch is not suitable for general
use, as it has limited value without a debugging allocator that makes
pages dirty after free.


Re: [PATCH] check_cfg assert fix

2011-09-06 Thread Steven Bosscher
On Tue, Sep 6, 2011 at 11:31 PM, Steven Bosscher  wrote:
> Index: haifa-sched.c
> ===
> --- haifa-sched.c       (revision 178601)
> +++ haifa-sched.c       (working copy)
> @@ -6071,7 +6071,10 @@ check_cfg (rtx head, rtx tail)
>                                 /* Or jump to the next instruction.  */
>                                 || (EDGE_COUNT (bb->succs) == 1
>                                     && (BB_HEAD (EDGE_I (bb->succs, 0)->dest)
> -                                        == JUMP_LABEL (head;
> +                                        == JUMP_LABEL (head)))
> +                               /* Or the jump is not just a jump.  */
> +                               || (!onlyjump_p (head)
> +                                   || returnjump_p (head)));
>                }
>              if (BB_END (bb) == head)
>                {
>

BTW that's one ugly gcc_assert. Candidate for gcc_checking_assert?

Ciao!
Steven


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

2011-09-06 Thread Jason Merrill

On 09/06/2011 04:21 PM, Dodji Seketeli wrote:

Jason Merrill  a écrit:


A followup: non-literal argument types shouldn't change the constexpr
flag either, and we shouldn't crash when a constructor initializes
bases as well as members (50296).  I'm not sure how my testing missed
that bug...

Tested x86_64-pc-linux-gnu, applying to trunk.
commit 26e458d541a3b04512ab88cfab866703e868e728
Author: Jason Merrill
Date:   Thu Jul 14 23:56:59 2011 -0400

 zadditional_options


I fail to see what the patch below has to do with the cover letter you
wrote above.  Am I missing something?


Hmm, Thunderbird has wanted to attach that patch for a while and finally 
managed to sneak it past me.  Here's the proper patch.


commit b7cc1c044d3a529340dc17599d58bef1dac8333a
Author: Jason Merrill 
Date:   Mon Sep 5 12:24:44 2011 -0400

	PR c++/50296
	* semantics.c (register_constexpr_fundef): Call is_valid_constexpr_fn.
	(cx_check_missing_mem_inits): Handle bases and empty trivial members.
	(validate_constexpr_fundecl): Remove.
	* decl.c (start_preparsed_function): Don't call it.
	* cp-tree.h: Don't declare it.

diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index cf6c056..ae4cd07 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -5367,7 +5367,6 @@ extern void finish_handler_parms		(tree, tree);
 extern void finish_handler			(tree);
 extern void finish_cleanup			(tree, tree);
 extern bool literal_type_p (tree);
-extern tree validate_constexpr_fundecl (tree);
 extern tree register_constexpr_fundef (tree, tree);
 extern bool check_constexpr_ctor_body (tree, tree);
 extern tree ensure_literal_type_for_constexpr_object (tree);
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 39a0b0e..eed4535 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -12659,10 +12659,6 @@ start_preparsed_function (tree decl1, tree attrs, int flags)
 	maybe_apply_pragma_weak (decl1);
 }
 
-  /* constexpr functions must have literal argument types and
- literal return type.  */
-  validate_constexpr_fundecl (decl1);
-
   /* Reset this in case the call to pushdecl changed it.  */
   current_function_decl = decl1;
 
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index bdc4cf2..f782df9 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -5485,7 +5485,6 @@ is_valid_constexpr_fn (tree fun, bool complain)
 	}
 	}
 
-  /* Check this again here for cxx_eval_call_expression.  */
   if (DECL_NONSTATIC_MEMBER_FUNCTION_P (fun)
 	  && !CLASSTYPE_LITERAL_P (DECL_CONTEXT (fun)))
 	{
@@ -5502,29 +5501,6 @@ is_valid_constexpr_fn (tree fun, bool complain)
   return ret;
 }
 
-/* Return non-null if FUN certainly designates a valid constexpr function
-   declaration.  Otherwise return NULL.  Issue appropriate diagnostics
-   if necessary.  Note that we only check the declaration, not the body
-   of the function.  */
-
-tree
-validate_constexpr_fundecl (tree fun)
-{
-  if (processing_template_decl || !DECL_DECLARED_CONSTEXPR_P (fun))
-return NULL;
-  else if (DECL_CLONED_FUNCTION_P (fun))
-/* We already checked the original function.  */
-return fun;
-
-  if (!is_valid_constexpr_fn (fun, !DECL_TEMPLATE_INFO (fun)))
-{
-  DECL_DECLARED_CONSTEXPR_P (fun) = false;
-  return NULL;
-}
-
-  return fun;
-}
-
 /* Subroutine of  build_constexpr_constructor_member_initializers.
The expression tree T represents a data member initialization
in a (constexpr) constructor definition.  Build a pairing of
@@ -5799,17 +5775,27 @@ cx_check_missing_mem_inits (tree fun, tree body, bool complain)
   else
 	{
 	  index = CONSTRUCTOR_ELT (body, i)->index;
-	  /* Skip base vtable inits.  */
-	  if (TREE_CODE (index) == COMPONENT_REF)
+	  /* Skip base and vtable inits.  */
+	  if (TREE_CODE (index) != FIELD_DECL)
 	continue;
 	}
   for (; field != index; field = DECL_CHAIN (field))
 	{
+	  tree ftype;
 	  if (TREE_CODE (field) != FIELD_DECL
 	  || (DECL_C_BIT_FIELD (field) && !DECL_NAME (field)))
 	continue;
 	  if (!complain)
 	return true;
+	  ftype = strip_array_types (TREE_TYPE (field));
+	  if (type_has_constexpr_default_constructor (ftype))
+	{
+	  /* It's OK to skip a member with a trivial constexpr ctor.
+	 A constexpr ctor that isn't trivial should have been
+	 added in by now.  */
+	  gcc_checking_assert (!TYPE_HAS_COMPLEX_DFLT (ftype));
+	  continue;
+	}
 	  error ("uninitialized member %qD in % constructor",
 		 field);
 	  bad = true;
@@ -5834,6 +5820,9 @@ register_constexpr_fundef (tree fun, tree body)
   constexpr_fundef entry;
   constexpr_fundef **slot;
 
+  if (!is_valid_constexpr_fn (fun, !DECL_TEMPLATE_INFO (fun)))
+return NULL;
+
   body = massage_constexpr_body (fun, body);
   if (body == NULL_TREE || body == error_mark_node)
 {
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-diag1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-diag1.C
index 44e6bc7..cbd4983 100644
--- a/gcc/testsuite/g++.dg/cpp0x/constexpr-diag1.C
+

Re: [PATCH] check_cfg assert fix

2011-09-06 Thread Steven Bosscher
On Tue, Sep 6, 2011 at 8:00 PM, Maxim Kuvyrkov  wrote:
>
> On 7/09/2011, at 3:13 AM, Steven Bosscher wrote:
>
>> On Tue, Sep 6, 2011 at 11:14 AM, Tom de Vries  wrote:
>>> Hi,
>>>
>>> During testing the approved-for-commit middle-end patch for bug 43864 on 
>>> ARM, I
>>> ran into a gcc.dg/torture/pr46068.c ICE.
>>>
>>> The following assert in haifa-sched.c:check_cfg triggered:
>>> ...
>>>                  else if (any_condjump_p (head))
>>>                    gcc_assert (/* Usual case.  */
>>>                                (EDGE_COUNT (bb->succs) > 1
>>>                                 && !BARRIER_P (NEXT_INSN (head)))
>>>                                /* Or jump to the next instruction.  */
>>>                                || (EDGE_COUNT (bb->succs) == 1
>>>                                    && (BB_HEAD (EDGE_I (bb->succs, 0)->dest)
>>>                                        == JUMP_LABEL (head;
>>>
> ...
>>> Bootstrapped and reg-tested on x86_64 and build and reg-tested on arm.
>>>
>>> OK for trunk?
>>
>> No. If the conditional return is not taken, you should not fall into a
>> barrier. It looks like the CFG somehow got corrupted, and if that's
>> indeed the case then your patch just papers over the problem. That
>> follows after the barrier?
>
> Initially, I thought so too, that is why I wrote the above assert in the 
> first place.  However, __builtin_unreachable() adds a whole new spin on where 
> a BARRIER can occur; after all, this built-in expands directly to BARRIER.
>
> Before Tom's optimization the fall-through path of conditional jump was 
> followed by an unconditional jump to a label directly followed by a barrier.  
> Tom's patch removed the middle-man in the face of unconditional jump so that 
> the barrier now follows a conditional jump.  This is very odd, but, given the 
> initial test case, is a valid case.

Well, shouldn't the assert be changed then to handle !onlyjump_p and
returnjump_p cases separately? Tom's patch removes a valid check for
all but these corner cases. Perhaps something like this:

Index: haifa-sched.c
===
--- haifa-sched.c   (revision 178601)
+++ haifa-sched.c   (working copy)
@@ -6071,7 +6071,10 @@ check_cfg (rtx head, rtx tail)
 /* Or jump to the next instruction.  */
 || (EDGE_COUNT (bb->succs) == 1
 && (BB_HEAD (EDGE_I (bb->succs, 0)->dest)
-== JUMP_LABEL (head;
+== JUMP_LABEL (head)))
+   /* Or the jump is not just a jump.  */
+   || (!onlyjump_p (head)
+   || returnjump_p (head)));
}
  if (BB_END (bb) == head)
{


Ciao!
Steven


[PATCH, i386]: Fix XPASS: gcc.target/i386/builtin-apply-mmx.c execution test + some cleanups

2011-09-06 Thread Uros Bizjak
Hello!

x32 follows x86_64 ABI, so no MMX regs are saved/restored in
__builtin_apply_args/__builtin_return, even with -mmmx. The patch also
includes some cleanups in this area.

2011-09-06  Uros Bizjak  

* config/i386/i386.c (ix86_function_value_regno_p): Use AX_REG.
(function_value_32): Do not check TARGET_MMX, TARGET_SSE or TARGET_AVX.

testsuite/ChangeLog:

2011-09-06  Uros Bizjak  

* gcc.target/i386/builtin-apply-mmx.c: Require ia32 effective target.

Tested on x86_64-pc-linux-gnu {,-m32}, committed to mainline SVN.

Uros.
Index: config/i386/i386.c
===
--- config/i386/i386.c  (revision 178608)
+++ config/i386/i386.c  (working copy)
@@ -7015,7 +7015,7 @@ ix86_function_value_regno_p (const unsigned int re
 {
   switch (regno)
 {
-case 0:
+case AX_REG:
   return true;
 
 case FIRST_FLOAT_REG:
@@ -7053,18 +7053,18 @@ function_value_32 (enum machine_mode orig_mode, en
  we normally prevent this case when mmx is not available.  However
  some ABIs may require the result to be returned like DImode.  */
   if (VECTOR_MODE_P (mode) && GET_MODE_SIZE (mode) == 8)
-regno = TARGET_MMX ? FIRST_MMX_REG : 0;
+regno = FIRST_MMX_REG;
 
   /* 16-byte vector modes in %xmm0.  See ix86_return_in_memory for where
  we prevent this case when sse is not available.  However some ABIs
  may require the result to be returned like integer TImode.  */
   else if (mode == TImode
   || (VECTOR_MODE_P (mode) && GET_MODE_SIZE (mode) == 16))
-regno = TARGET_SSE ? FIRST_SSE_REG : 0;
+regno = FIRST_SSE_REG;
 
   /* 32-byte vector modes in %ymm0.   */
   else if (VECTOR_MODE_P (mode) && GET_MODE_SIZE (mode) == 32)
-regno = TARGET_AVX ? FIRST_SSE_REG : 0;
+regno = FIRST_SSE_REG;
 
   /* Floating point return values in %st(0) (unless -mno-fp-ret-in-387).  */
   else if (X87_FLOAT_MODE_P (mode) && TARGET_FLOAT_RETURNS_IN_80387)
@@ -7098,6 +7098,8 @@ function_value_64 (enum machine_mode orig_mode, en
   /* Handle libcalls, which don't provide a type node.  */
   if (valtype == NULL)
 {
+  unsigned int regno;
+
   switch (mode)
{
case SFmode:
@@ -7108,15 +7110,19 @@ function_value_64 (enum machine_mode orig_mode, en
case SDmode:
case DDmode:
case TDmode:
- return gen_rtx_REG (mode, FIRST_SSE_REG);
+ regno = FIRST_SSE_REG;
+ break;
case XFmode:
case XCmode:
- return gen_rtx_REG (mode, FIRST_FLOAT_REG);
+ regno = FIRST_FLOAT_REG;
+ break;
case TCmode:
  return NULL;
default:
- return gen_rtx_REG (mode, AX_REG);
+ regno = AX_REG;
}
+
+  return gen_rtx_REG (mode, regno);
 }
   else if (POINTER_TYPE_P (valtype))
 {
Index: testsuite/gcc.target/i386/builtin-apply-mmx.c
===
--- testsuite/gcc.target/i386/builtin-apply-mmx.c   (revision 178608)
+++ testsuite/gcc.target/i386/builtin-apply-mmx.c   (working copy)
@@ -11,7 +11,7 @@
  
 /* { dg-do run { xfail { ! *-*-darwin* } } } */
 /* { dg-options "-O2 -mmmx" } */
-/* { dg-require-effective-target ilp32 } */
+/* { dg-require-effective-target ia32 } */
 
 #include "mmx-check.h"
 


Re: [patch][google/integration] Add lightweight checks to vector::begin et. al. (issue4973065)

2011-09-06 Thread Paul Pluzhnikov
On Tue, Sep 6, 2011 at 1:33 PM, Jonathan Wakely  wrote:

>>  for (it = v->begin(); it != v->end(); ++it)  // Oops!
>
> Eurgh, the occurrence of "delete" in anything except a destructor is a
> code smell that should have led someone to find those bugs anyway!
> Obviously the code above is a trivial example, but it's unforgivable
> to write that

I can assure you that the actual code that exhibited these bugs was much
subtler than that, and the bugs were not immediately obvious.

Sometimes they were not immediately obvious even after running Valgrind
on the buggy code and getting allocation/deletion/access stack traces with
source corrdinates.

>> We can't (easily) catch the general problem. This patch allows us to easily
>> catch this particular instance of it.
>
> Sure, but so does adding "assert(this);" at the top of every member

Sorry, no. Adding "assert(this);" does not catch any new bugs (at least
not on Linux) -- the code would have immediately crashed on zero-page
dereference anyway.

Thanks,
-- 
Paul Pluzhnikov


Re: [patch][google/integration] Add lightweight checks to vector::begin et. al. (issue4973065)

2011-09-06 Thread Jonathan Wakely
On 6 September 2011 21:19, Paul Pluzhnikov wrote:
> On Tue, Sep 6, 2011 at 12:44 PM, Jonathan Wakely  
> wrote:
>> On 6 September 2011 20:23, Jonathan Wakely wrote:
>>>
>>> What's a dangling vector anyway?  One that has been moved from?
>>
>> Apparently not, since a moved-from vector would pass __valid() (as
>> indeed it should)
>>
>> So I'm quite curious what bugs this catches.
>
> The garden variety "use after free":
>
>  vector<> *v = new vector<>;
> ...
>  delete v;
> ...
>
>  for (it = v->begin(); it != v->end(); ++it)  // Oops!

Eurgh, the occurrence of "delete" in anything except a destructor is a
code smell that should have led someone to find those bugs anyway!
Obviously the code above is a trivial example, but it's unforgivable
to write that - patching vector to catch it is definitely solving the
wrong problem in the wrong place!

>> The existing debug mode
>> catches some fairly subtle cases of user error such as comparing
>> iterators from different containers, or dereferencing past-the-end
>> iterators.  This patch seems to catch user errors related to ... what?
>>  Heap corruption?  Using a vector after its destructor runs?  Those
>> are pretty serious, un-subtle errors and not specific to vector, so
>> why add code to vector (code which isn't 100% reliable if it only
>> catches corruption after the memory is reused and new data written to
>> it)
>
> It is 100% percent reliable for us, due to use of a debugging allocator
> which scribbles on all free()d memory.

Aha.

> But yes, that's one more reason why this patch is not really good for
> upstream.
>
>> to detect more general problems that can happen to any type?
>
> We can't (easily) catch the general problem. This patch allows us to easily
> catch this particular instance of it.

Sure, but so does adding "assert(this);" at the top of every member
function to check you don't call through a null pointer, but that
doesn't make it a good idea :-)

I'm not 100% against a lighter weight debug mode, but it would have to
offer some pretty convincing benefits and I don't see this patch being
widely useful enough to warrant a separate mode.  Especially as the
existing debug mode is *much* faster than it used to be for some
workloads.


>> The fact the patch did catch real bugs doesn't mean it's a good idea,
>> as you say, those bugs probably could have been caught in other ways.
>
> Sure -- we have other ways to catch the these bugs. They are not very
> practical at the moment due to their runtime overhead.
>
> As for your other suggestion: enabling _GLIBCXX_DEBUG just for vector,
> that didn't occur to me and is something I'd like to explore.

It's something I do quite often, so that specific types can be
switched to use debug mode during some builds, or for some unit tests,
without having to turn on the extra checks for every use of vector (or
other std containers) in the entire app.

Also, if your code uses a typedef like:

typedef v::vector vector_type;

and you consistently use that typedef (rather than referring to
std::vector directly) then it can be relatively painless to turn
debug mode on and off for specific pieces of code.  Even the
unconventional-looking "v::vector" (or "my_debug_switch_123::vector")
only gets mentioned in one place.


Re: [patch][google/integration] Add lightweight checks to vector::begin et. al. (issue4973065)

2011-09-06 Thread Christopher Jefferson

On 6 Sep 2011, at 21:19, Paul Pluzhnikov wrote:

> On Tue, Sep 6, 2011 at 12:44 PM, Jonathan Wakely  
> wrote:
>> On 6 September 2011 20:23, Jonathan Wakely wrote:
>>> 
>>> What's a dangling vector anyway?  One that has been moved from?
>> 
>> Apparently not, since a moved-from vector would pass __valid() (as
>> indeed it should)
>> 
>> So I'm quite curious what bugs this catches.
> 
> The garden variety "use after free":
> 
>  vector<> *v = new vector<>;
> ...
>  delete v;
> ...
> 
>  for (it = v->begin(); it != v->end(); ++it)  // Oops!
> 
>> The existing debug mode
>> catches some fairly subtle cases of user error such as comparing
>> iterators from different containers, or dereferencing past-the-end
>> iterators.  This patch seems to catch user errors related to ... what?
>>  Heap corruption?  Using a vector after its destructor runs?  Those
>> are pretty serious, un-subtle errors and not specific to vector, so
>> why add code to vector (code which isn't 100% reliable if it only
>> catches corruption after the memory is reused and new data written to
>> it)
> 
> It is 100% percent reliable for us, due to use of a debugging allocator
> which scribbles on all free()d memory.
> 
> But yes, that's one more reason why this patch is not really good for
> upstream.
> 
>> to detect more general problems that can happen to any type?
> 
> We can't (easily) catch the general problem. This patch allows us to easily
> catch this particular instance of it.
> 
>> The fact the patch did catch real bugs doesn't mean it's a good idea,
>> as you say, those bugs probably could have been caught in other ways.
> 
> Sure -- we have other ways to catch the these bugs. They are not very
> practical at the moment due to their runtime overhead.
> 
> As for your other suggestion: enabling _GLIBCXX_DEBUG just for vector,
> that didn't occur to me and is something I'd like to explore.

It might be interesting to profile your app under _GLIBCXX_DEBUG, and see where 
the high costs are.

I previously found that stable_sort had a stupidly high cost, and it turned out 
with some tweaking we could get just as much protection with a lower cost. 

Chris


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

2011-09-06 Thread Dodji Seketeli
Jason Merrill  a écrit:

> A followup: non-literal argument types shouldn't change the constexpr
> flag either, and we shouldn't crash when a constructor initializes
> bases as well as members (50296).  I'm not sure how my testing missed
> that bug...
>
> Tested x86_64-pc-linux-gnu, applying to trunk.
> commit 26e458d541a3b04512ab88cfab866703e868e728
> Author: Jason Merrill 
> Date:   Thu Jul 14 23:56:59 2011 -0400
>
> zadditional_options

I fail to see what the patch below has to do with the cover letter you
wrote above.  Am I missing something?

>
> diff --git a/gcc/Makefile.in b/gcc/Makefile.in
> index 0fded4e..e12791d 100644
> --- a/gcc/Makefile.in
> +++ b/gcc/Makefile.in
> @@ -5019,7 +5019,7 @@ check_p_subdirs=$(wordlist 1,$(words 
> $(check_$*_parallelize)),$(check_p_numbers)
>  
>  # For parallelized check-% targets, this decides whether parallelization
>  # is desirable (if -jN is used and RUNTESTFLAGS doesn't contain anything
> -# but optional --target_board or --tool_opts arguments).  If it is desirable,
> +# but optional --target_board or --zadditional_options arguments).  If 
> desirable,
>  # recursive make is run with check-parallel-$lang{,1,2,3,4,5} etc. goals,
>  # which can be executed in parallel, as they are run in separate directories.
>  # check-parallel-$lang{1,2,3,4,5} etc. goals invoke runtest with the longest
> @@ -5036,7 +5036,7 @@ check_p_subdirs=$(wordlist 1,$(words 
> $(check_$*_parallelize)),$(check_p_numbers)
>  # to lang_checks_parallelized variable and define check_$lang_parallelize
>  # variable (see above check_gcc_parallelize description).
>  $(lang_checks_parallelized): check-% : site.exp
> - @if [ -z "$(filter-out --target_board=%,$(filter-out 
> --tool_opts%,$(RUNTESTFLAGS)))" ] \
> + @if [ -z "$(filter-out --target_board=%,$(filter-out 
> --zadditional_options%,$(RUNTESTFLAGS)))" ] \
>   && [ "$(filter -j, $(MFLAGS))" = "-j" ]; then \
> $(MAKE) TESTSUITEDIR="$(TESTSUITEDIR)" RUNTESTFLAGS="$(RUNTESTFLAGS)" 
> \
>   check-parallel-$* \
> diff --git a/gcc/cp/Make-lang.in b/gcc/cp/Make-lang.in
> index b9251a4..8353376 100644
> --- a/gcc/cp/Make-lang.in
> +++ b/gcc/cp/Make-lang.in
> @@ -151,7 +151,7 @@ c++.srcman: doc/g++.1
>  check-c++ : check-g++
>  # Run the testsute in C++0x mode.
>  check-c++0x:
> - $(MAKE) RUNTESTFLAGS="$(RUNTESTFLAGS) --tool_opts=-std=gnu++0x" \
> + $(MAKE) RUNTESTFLAGS="$(RUNTESTFLAGS) 
> --zadditional_options,-std=gnu++0x" \
> TESTSUITEDIR="$(TESTSUITEDIR).c++0x" check-g++
>  check-c++-subtargets : check-g++-subtargets
>  # List of targets that can use the generic check- rule and its // variant.
> diff --git a/gcc/testsuite/lib/g++.exp b/gcc/testsuite/lib/g++.exp
> index 81c4398..562f6f0 100644
> --- a/gcc/testsuite/lib/g++.exp
> +++ b/gcc/testsuite/lib/g++.exp
> @@ -307,3 +307,33 @@ proc g++_target_compile { source dest type options } {
>  
>  return $result
>  }
> +
> +#
> +# ${tool}_option_help
> +#
> +# The initial 'z' is there because runtest.exp treats --a* as --all.
> +# This shouldn't be necessary at all; it should be entirely redundant with
> +# --tool_opts, except that --tool_opts currently breaks multilib.  Patch at
> +# http://lists.gnu.org/archive/html/dejagnu/2002-10/msg7.html
> +
> +proc ${tool}_option_help { } {
> +send_user " --zadditional_options,OPTIONS\t\tUse OPTIONS to compile the 
> testcase files. OPTIONS should be comma-separated.\n"
> +}
> +
> +#
> +# ${tool}_option_proc
> +#
> +
> +proc ${tool}_option_proc { option } {
> +if [regexp "^--zadditional_options," $option] {
> + global gpp_compile_options
> + regsub "^--zadditional_options," $option "" option
> + foreach x [split $option ","] {
> + lappend gpp_compile_options "additional_flags=$x"
> + }
> + verbose -log "gpp_compile_options set to $gpp_compile_options"
> + return 1
> +} else {
> + return 0
> +}
> +}

-- 
Dodji


Re: [patch][google/integration] Add lightweight checks to vector::begin et. al. (issue4973065)

2011-09-06 Thread Paul Pluzhnikov
On Tue, Sep 6, 2011 at 12:44 PM, Jonathan Wakely  wrote:
> On 6 September 2011 20:23, Jonathan Wakely wrote:
>>
>> What's a dangling vector anyway?  One that has been moved from?
>
> Apparently not, since a moved-from vector would pass __valid() (as
> indeed it should)
>
> So I'm quite curious what bugs this catches.

The garden variety "use after free":

  vector<> *v = new vector<>;
...
  delete v;
...

  for (it = v->begin(); it != v->end(); ++it)  // Oops!

> The existing debug mode
> catches some fairly subtle cases of user error such as comparing
> iterators from different containers, or dereferencing past-the-end
> iterators.  This patch seems to catch user errors related to ... what?
>  Heap corruption?  Using a vector after its destructor runs?  Those
> are pretty serious, un-subtle errors and not specific to vector, so
> why add code to vector (code which isn't 100% reliable if it only
> catches corruption after the memory is reused and new data written to
> it)

It is 100% percent reliable for us, due to use of a debugging allocator
which scribbles on all free()d memory.

But yes, that's one more reason why this patch is not really good for
upstream.

> to detect more general problems that can happen to any type?

We can't (easily) catch the general problem. This patch allows us to easily
catch this particular instance of it.

> The fact the patch did catch real bugs doesn't mean it's a good idea,
> as you say, those bugs probably could have been caught in other ways.

Sure -- we have other ways to catch the these bugs. They are not very
practical at the moment due to their runtime overhead.

As for your other suggestion: enabling _GLIBCXX_DEBUG just for vector,
that didn't occur to me and is something I'd like to explore.

Thanks,
-- 
Paul Pluzhnikov


[Patch, Darwin, Committed] remove duplicate LIBSPEC from darwin10.h

2011-09-06 Thread Iain Sandoe

I applied the following under the 'obvious' rule.
config/darwin10.h no longer modifies LIB_SPEC and thus the one in it  
was just a duplicate of the one in darwin.h.

tidied.
cheers,
Iain

gcc:

* config/darwin10.h Remove duplicate LIB_SPEC.

Index: gcc/config/darwin10.h
===
--- gcc/config/darwin10.h   (revision 178608)
+++ gcc/config/darwin10.h   (working copy)
@@ -18,9 +18,6 @@ You should have received a copy of the GNU General
 along with GCC; see the file COPYING3.  If not see
 .  */

-#undef LIB_SPEC
-#define LIB_SPEC "%{!static: -lSystem }"
-
 /* Fix PR41260 by passing -no_compact_unwind on darwin10 and later  
until
unwinder in libSystem is fixed to digest new epilog unwinding  
notes.





Re: [patch][google/integration] Add lightweight checks to vector::begin et. al. (issue4973065)

2011-09-06 Thread Jonathan Wakely
On 6 September 2011 20:23, Jonathan Wakely wrote:
>
> What's a dangling vector anyway?  One that has been moved from?

Apparently not, since a moved-from vector would pass __valid() (as
indeed it should)

So I'm quite curious what bugs this catches.  The existing debug mode
catches some fairly subtle cases of user error such as comparing
iterators from different containers, or dereferencing past-the-end
iterators.  This patch seems to catch user errors related to ... what?
 Heap corruption?  Using a vector after its destructor runs?  Those
are pretty serious, un-subtle errors and not specific to vector, so
why add code to vector (code which isn't 100% reliable if it only
catches corruption after the memory is reused and new data written to
it) to detect more general problems that can happen to any type?

The fact the patch did catch real bugs doesn't mean it's a good idea,
as you say, those bugs probably could have been caught in other ways.


Re: [patch][google/integration] Add lightweight checks to vector::begin et. al. (issue4973065)

2011-09-06 Thread Jonathan Wakely
On 6 September 2011 19:01, Paul Pluzhnikov wrote:
>
>> But this is something to discuss with libstdc++ (CC'd).
>
> Sure. If the "parallel" debug mode is more tenable now, I am all for it.

I don't think anything has changed.  I'm not excited by the idea of
another debug mode, especially not this patch, which would never get
into mainline.

It is always valid to call vector::begin(), it's 'noexcept' so the
patch will cause immediate calls to std::terminate, so why throw
instead of just aborting?  Why is __valid not named consistently with
the v3 naming style?


What's a dangling vector anyway?  One that has been moved from?


> To give some context, in a large code base (> 1e6 lines of C++ code),
> the checks added in this patch found 20 bugs.
>
> Most (though not all) of these bugs could also have been found with Valgrind
> and (probably) with _GLIBCXX_DEBUG, but the runtime cost of running such
> heavy-weight checks over the entire code base is prohibitive.

You can do:

#ifdef MY_DEBUG_FLAG
#include 
namespace v = __gnu_debug;
#else
#include 
namespace v = std;
#

Then use v::vector in specific places to only enable the checks in some places.


Re: [PATCH] PR c++/33255 - Support -Wunused-local-typedefs warning

2011-09-06 Thread Jason Merrill

On 08/08/2011 03:52 PM, Dodji Seketeli wrote:

+  cfun->language = NULL;


Might as well ggc_free it first.


+  /* We want T to be either a type or a TYPE_DECL.   */


Comment is out of date.

Does __attribute ((used)) on the typedef prevent the warning?

Jason



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

2011-09-06 Thread Jason Merrill

OK.

Jason


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

2011-09-06 Thread Jason Merrill
A followup: non-literal argument types shouldn't change the constexpr 
flag either, and we shouldn't crash when a constructor initializes bases 
as well as members (50296).  I'm not sure how my testing missed that bug...


Tested x86_64-pc-linux-gnu, applying to trunk.
commit 26e458d541a3b04512ab88cfab866703e868e728
Author: Jason Merrill 
Date:   Thu Jul 14 23:56:59 2011 -0400

zadditional_options

diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 0fded4e..e12791d 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -5019,7 +5019,7 @@ check_p_subdirs=$(wordlist 1,$(words $(check_$*_parallelize)),$(check_p_numbers)
 
 # For parallelized check-% targets, this decides whether parallelization
 # is desirable (if -jN is used and RUNTESTFLAGS doesn't contain anything
-# but optional --target_board or --tool_opts arguments).  If it is desirable,
+# but optional --target_board or --zadditional_options arguments).  If desirable,
 # recursive make is run with check-parallel-$lang{,1,2,3,4,5} etc. goals,
 # which can be executed in parallel, as they are run in separate directories.
 # check-parallel-$lang{1,2,3,4,5} etc. goals invoke runtest with the longest
@@ -5036,7 +5036,7 @@ check_p_subdirs=$(wordlist 1,$(words $(check_$*_parallelize)),$(check_p_numbers)
 # to lang_checks_parallelized variable and define check_$lang_parallelize
 # variable (see above check_gcc_parallelize description).
 $(lang_checks_parallelized): check-% : site.exp
-	@if [ -z "$(filter-out --target_board=%,$(filter-out --tool_opts%,$(RUNTESTFLAGS)))" ] \
+	@if [ -z "$(filter-out --target_board=%,$(filter-out --zadditional_options%,$(RUNTESTFLAGS)))" ] \
 	&& [ "$(filter -j, $(MFLAGS))" = "-j" ]; then \
 	  $(MAKE) TESTSUITEDIR="$(TESTSUITEDIR)" RUNTESTFLAGS="$(RUNTESTFLAGS)" \
 	check-parallel-$* \
diff --git a/gcc/cp/Make-lang.in b/gcc/cp/Make-lang.in
index b9251a4..8353376 100644
--- a/gcc/cp/Make-lang.in
+++ b/gcc/cp/Make-lang.in
@@ -151,7 +151,7 @@ c++.srcman: doc/g++.1
 check-c++ : check-g++
 # Run the testsute in C++0x mode.
 check-c++0x:
-	$(MAKE) RUNTESTFLAGS="$(RUNTESTFLAGS) --tool_opts=-std=gnu++0x" \
+	$(MAKE) RUNTESTFLAGS="$(RUNTESTFLAGS) --zadditional_options,-std=gnu++0x" \
 	  TESTSUITEDIR="$(TESTSUITEDIR).c++0x" check-g++
 check-c++-subtargets : check-g++-subtargets
 # List of targets that can use the generic check- rule and its // variant.
diff --git a/gcc/testsuite/lib/g++.exp b/gcc/testsuite/lib/g++.exp
index 81c4398..562f6f0 100644
--- a/gcc/testsuite/lib/g++.exp
+++ b/gcc/testsuite/lib/g++.exp
@@ -307,3 +307,33 @@ proc g++_target_compile { source dest type options } {
 
 return $result
 }
+
+#
+# ${tool}_option_help
+#
+# The initial 'z' is there because runtest.exp treats --a* as --all.
+# This shouldn't be necessary at all; it should be entirely redundant with
+# --tool_opts, except that --tool_opts currently breaks multilib.  Patch at
+# http://lists.gnu.org/archive/html/dejagnu/2002-10/msg7.html
+
+proc ${tool}_option_help { } {
+send_user " --zadditional_options,OPTIONS\t\tUse OPTIONS to compile the testcase files. OPTIONS should be comma-separated.\n"
+}
+
+#
+# ${tool}_option_proc
+#
+
+proc ${tool}_option_proc { option } {
+if [regexp "^--zadditional_options," $option] {
+	global gpp_compile_options
+	regsub "^--zadditional_options," $option "" option
+	foreach x [split $option ","] {
+	lappend gpp_compile_options "additional_flags=$x"
+	}
+	verbose -log "gpp_compile_options set to $gpp_compile_options"
+	return 1
+} else {
+	return 0
+}
+}


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

2011-09-06 Thread H.J. Lu
I checked it into cilkplus branch.

Thanks.

On Tue, Sep 6, 2011 at 10:38 AM, Iyer, Balaji V  wrote:
> OK..fixed. Please try it now.
>
> Thanks,
>
> Balaji V. Iyer.
> 
> From: H.J. Lu [hjl.to...@gmail.com]
> Sent: Tuesday, September 06, 2011 1:35 PM
> To: Iyer, Balaji V
> Cc: gcc-patches@gcc.gnu.org
> Subject: Re: [Patch][Cilkplus branch] Adding include directory path to 
> testsuite script
>
> diff --git a/gcc/testsuite/ChangeLog.cilk b/gcc/testsuite/ChangeLog.cilk
> index c9eac87..a602b88 100644
> --- a/gcc/testsuite/ChangeLog.cilk
> +++ b/gcc/testsuite/ChangeLog.cilk
> @@ -1,3 +1,9 @@
> +2011-09-05  Balaji V. Iyer. 
>                                     ^^ Your name should be
> followed by 2 spaces, not a period.
>
> +
> +       * gcc.dg/cilk-plus/cilk_plus.exp: Added -I
> +       $(src_dir)../../libcilkrts/include.  Also removed -fsyntax-only
> +       * g++.dg/cilk-plus/cilk_plus.exp: Likewise
> +
>
>
> On Tue, Sep 6, 2011 at 10:22 AM, Iyer, Balaji V  
> wrote:
>> Ok..try it now.. I did git diff origin/cilkplus.
>>
>> Thanks,
>>
>> Balaji V. Iyer.
>>
>> -Original Message-
>> From: H.J. Lu [mailto:hjl.to...@gmail.com]
>> Sent: Tuesday, September 06, 2011 12:37 PM
>> To: Iyer, Balaji V
>> Subject: Re: [Patch][Cilkplus branch] Adding include directory path to 
>> testsuite script
>>
>> Please use "git diff origin/cilkplus" to generate patch.
>>
>> On Tue, Sep 6, 2011 at 9:36 AM, H.J. Lu  wrote:
>>> On Tue, Sep 6, 2011 at 8:01 AM, Iyer, Balaji V  
>>> wrote:
 Sure! Here is the fixed patch.
>>>
>>> It won't apply.  Please make sure that it is against cilkplus branch.
>>>
>>> H.J.
 Thanks,

 Balaji V. Iyer.

 -Original Message-
 From: H.J. Lu [mailto:hjl.to...@gmail.com]
 Sent: Tuesday, September 06, 2011 10:57 AM
 To: Iyer, Balaji V
 Cc: gcc-patches@gcc.gnu.org
 Subject: Re: [Patch][Cilkplus branch] Adding include directory path
 to testsuite script

 You should just say "* g++.dg/cilk-plus/cilk_plus.exp: Likewise" since the 
 change is the same as above.

 H.J.
 On Tue, Sep 6, 2011 at 7:45 AM, Iyer, Balaji V  
 wrote:
> I fixed all the changed you have requested. Here is an updated patch.
>
> Thanks,
>
> Balaji V. Iyer.
>
>
> -Original Message-
> From: H.J. Lu [mailto:hjl.to...@gmail.com]
> Sent: Tuesday, September 06, 2011 10:41 AM
> To: Iyer, Balaji V
> Cc: gcc-patches@gcc.gnu.org
> Subject: Re: [Patch][Cilkplus branch] Adding include directory path
> to testsuite script
>
> On Tue, Sep 6, 2011 at 7:30 AM, Iyer, Balaji V  
> wrote:
>> Attached, please find a patch with the modifications you have suggested 
>> (adding the info in Changelog.cilk).
>
> Please remove the extra blank line in ChangLog.  ChangeLog should simply 
> say what you did, not why.
>
> H.J.
> 
>> Sorry for the mistake.
>>
>> Thanks,
>>
>> Balaji V. Iyer.
>>
>>
>> -Original Message-
>> From: H.J. Lu [mailto:hjl.to...@gmail.com]
>> Sent: Tuesday, September 06, 2011 10:22 AM
>> To: Iyer, Balaji V
>> Cc: gcc-patches@gcc.gnu.org
>> Subject: Re: [Patch][Cilkplus branch] Adding include directory path
>> to testsuite script
>>
>> On Mon, Sep 5, 2011 at 9:52 PM, Iyer, Balaji V  
>> wrote:
>>> 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,
>>>
>>
>> ChangeLog entries are missing.
>>
>>>
>>
>>
>>
>> --
>> H.J.
>>
>
>
>
> --
> H.J.
>



-- 
H.J.


Re: [patch][google/integration] Add lightweight checks to vector::begin et. al. (issue4973065)

2011-09-06 Thread Paul Pluzhnikov
On Tue, Sep 6, 2011 at 10:46 AM, Diego Novillo  wrote:
> On Tue, Sep 6, 2011 at 12:54, Paul Pluzhnikov  wrote:
>> On Tue, Sep 6, 2011 at 9:44 AM, Diego Novillo  wrote:
>>
>>> OK.  Any reason not to send this (or a variant) to mainline?
>>
>> AFAIU, mainline is not interested -- there is already a debug mode (enabled
>> by _GLIBCXX_DEBUG), which catches many of the same bugs (and more), and
>> introduction of "parallel" debug modes is undesirable.
>>
>> Unfortunately, _GLIBCXX_DEBUG makes no performance guarantees (making some
>> normally constant-time operations O(N), etc.) and so we can't just turn
>> it on in Google.
>
> Right.  That's why I thought of a variant.  Maybe we want to have
> levels of checking, or a _GLBICXX_DEBUG_FAST.

Which would introduce a "parallel" debug mode ... which has been rejected
in the past.

> But this is something to discuss with libstdc++ (CC'd).

Sure. If the "parallel" debug mode is more tenable now, I am all for it.

To give some context, in a large code base (> 1e6 lines of C++ code),
the checks added in this patch found 20 bugs.

Most (though not all) of these bugs could also have been found with Valgrind
and (probably) with _GLIBCXX_DEBUG, but the runtime cost of running such
heavy-weight checks over the entire code base is prohibitive.

Thanks,
-- 
Paul Pluzhnikov


Re: [PATCH] check_cfg assert fix

2011-09-06 Thread Maxim Kuvyrkov

On 7/09/2011, at 3:13 AM, Steven Bosscher wrote:

> On Tue, Sep 6, 2011 at 11:14 AM, Tom de Vries  wrote:
>> Hi,
>> 
>> During testing the approved-for-commit middle-end patch for bug 43864 on 
>> ARM, I
>> ran into a gcc.dg/torture/pr46068.c ICE.
>> 
>> The following assert in haifa-sched.c:check_cfg triggered:
>> ...
>>  else if (any_condjump_p (head))
>>gcc_assert (/* Usual case.  */
>>(EDGE_COUNT (bb->succs) > 1
>> && !BARRIER_P (NEXT_INSN (head)))
>>/* Or jump to the next instruction.  */
>>|| (EDGE_COUNT (bb->succs) == 1
>>&& (BB_HEAD (EDGE_I (bb->succs, 0)->dest)
>>== JUMP_LABEL (head;
>> 
...
>> Bootstrapped and reg-tested on x86_64 and build and reg-tested on arm.
>> 
>> OK for trunk?
> 
> No. If the conditional return is not taken, you should not fall into a
> barrier. It looks like the CFG somehow got corrupted, and if that's
> indeed the case then your patch just papers over the problem. That
> follows after the barrier?

Initially, I thought so too, that is why I wrote the above assert in the first 
place.  However, __builtin_unreachable() adds a whole new spin on where a 
BARRIER can occur; after all, this built-in expands directly to BARRIER.

Before Tom's optimization the fall-through path of conditional jump was 
followed by an unconditional jump to a label directly followed by a barrier.  
Tom's patch removed the middle-man in the face of unconditional jump so that 
the barrier now follows a conditional jump.  This is very odd, but, given the 
initial test case, is a valid case.

For reference, the test case in question:

/* { dg-do compile } */

void
foo ()
{
  asm goto (""l1);
  __builtin_unreachable ();
l1:;
}

void
bar ()
{
  foo ();
  foo ();
}

--
Maxim Kuvyrkov
CodeSourcery / Mentor Graphics




smime.p7s
Description: S/MIME cryptographic signature


[PATCH, PR 50301] Missing checks of number of actual arguments in IPA-CP

2011-09-06 Thread Martin Jambor
Hi,

somehow I lost two hunks in the patch allowing IPA-CP to process
functions with variable number of arguments and one of these omissions
caused PR 50301 (416.gamess LTO miscompilation).  The two hunks check
the number of actual arguments in two places of IPA-CP which are not
executed so often and where we currently can get an out-of-bounds
VECtor failure.

Bootstrapped and tested on x86_64-linux, I have verified gmaess
LTO-builds with it.  OK for trunk?

Thanks,

Martin


2011-09-06  Martin Jambor  

PR middle-end/50301
* ipa-cp.c (find_more_values_for_callers_subset): Check jump
function index bounds.
(perhaps_add_new_callers): Likewise.

Index: src/gcc/ipa-cp.c
===
--- src.orig/gcc/ipa-cp.c
+++ src/gcc/ipa-cp.c
@@ -2052,8 +2052,12 @@ find_more_values_for_callers_subset (str
  struct ipa_jump_func *jump_func;
  tree t;
 
+  if (i >= ipa_get_cs_argument_count (IPA_EDGE_REF (cs)))
+{
+  newval = NULL_TREE;
+  break;
+}
  jump_func = ipa_get_ith_jump_func (IPA_EDGE_REF (cs), i);
-
  t = ipa_value_from_jfunc (IPA_NODE_REF (cs->caller), jump_func);
  if (!t
  || (newval
@@ -2123,6 +2127,11 @@ perhaps_add_new_callers (struct cgraph_n
  if (!val)
continue;
 
+ if (i >= ipa_get_cs_argument_count (args))
+   {
+ insufficient = true;
+ break;
+   }
  jump_func = ipa_get_ith_jump_func (args, i);
  t = ipa_value_from_jfunc (caller_info, jump_func);
  if (!t || !values_equal_for_ipcp_p (val, t))


Re: [PATCH, Atom] Improve AGU stalls avoidance optimization

2011-09-06 Thread Ilya Enkovich
2011/9/6 Uros Bizjak :
>
> Please merge your new splitters with corresponding LEA patterns.
>
> OK with this change.
>
> Thanks,
> Uros.
>

Fixed. Could please someone check it in if it's OK now?

Thanks,
Ilya
---
gcc/

2011-09-06  Enkovich Ilya  

* config/i386/i386-protos.h (ix86_lea_outperforms): New.
(ix86_avoid_lea_for_add): Likewise.
(ix86_avoid_lea_for_addr): Likewise.
(ix86_split_lea_for_addr): Likewise.

* config/i386/i386.c (LEA_MAX_STALL): New.
(increase_distance): Likewise.
(insn_defines_reg): Likewise.
(insn_uses_reg_mem): Likewise.
(distance_non_agu_define_in_bb): Likewise.
(distance_agu_use_in_bb): Likewise.
(ix86_lea_outperforms): Likewise.
(ix86_ok_to_clobber_flags): Likewise.
(ix86_avoid_lea_for_add): Likewise.
(ix86_avoid_lea_for_addr): Likewise.
(ix86_split_lea_for_addr): Likewise.
(distance_non_agu_define): Search in pred BBs added.
(distance_agu_use): Search in succ BBs added.
(IX86_LEA_PRIORITY): Value changed from 2 to 0.
(LEA_SEARCH_THRESHOLD): Now depends on LEA_MAX_STALL.
(ix86_lea_for_add_ok): Use ix86_lea_outperforms to make decision.

* config/i386/i386.md: Split added to transform non destructive
add into move and add.
(lea_1): transformed into insn_and_split to avoid AGU stalls.
(lea_2): Likewise.


lea.diff
Description: Binary data


Re: [patch][google/integration] Add lightweight checks to vector::begin et. al. (issue4973065)

2011-09-06 Thread Diego Novillo
On Tue, Sep 6, 2011 at 12:54, Paul Pluzhnikov  wrote:
> On Tue, Sep 6, 2011 at 9:44 AM, Diego Novillo  wrote:
>
>> OK.  Any reason not to send this (or a variant) to mainline?
>
> AFAIU, mainline is not interested -- there is already a debug mode (enabled
> by _GLIBCXX_DEBUG), which catches many of the same bugs (and more), and
> introduction of "parallel" debug modes is undesirable.
>
> Unfortunately, _GLIBCXX_DEBUG makes no performance guarantees (making some
> normally constant-time operations O(N), etc.) and so we can't just turn
> it on in Google.

Right.  That's why I thought of a variant.  Maybe we want to have
levels of checking, or a _GLBICXX_DEBUG_FAST.  But this is something
to discuss with libstdc++ (CC'd).


Diego.
>
> Thanks,
> --
> Paul Pluzhnikov
>


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

2011-09-06 Thread Iyer, Balaji V
OK..fixed. Please try it now.

Thanks,

Balaji V. Iyer.

From: H.J. Lu [hjl.to...@gmail.com]
Sent: Tuesday, September 06, 2011 1:35 PM
To: Iyer, Balaji V
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [Patch][Cilkplus branch] Adding include directory path to 
testsuite script

diff --git a/gcc/testsuite/ChangeLog.cilk b/gcc/testsuite/ChangeLog.cilk
index c9eac87..a602b88 100644
--- a/gcc/testsuite/ChangeLog.cilk
+++ b/gcc/testsuite/ChangeLog.cilk
@@ -1,3 +1,9 @@
+2011-09-05  Balaji V. Iyer. 
 ^^ Your name should be
followed by 2 spaces, not a period.

+
+   * gcc.dg/cilk-plus/cilk_plus.exp: Added -I
+   $(src_dir)../../libcilkrts/include.  Also removed -fsyntax-only
+   * g++.dg/cilk-plus/cilk_plus.exp: Likewise
+


On Tue, Sep 6, 2011 at 10:22 AM, Iyer, Balaji V  wrote:
> Ok..try it now.. I did git diff origin/cilkplus.
>
> Thanks,
>
> Balaji V. Iyer.
>
> -Original Message-
> From: H.J. Lu [mailto:hjl.to...@gmail.com]
> Sent: Tuesday, September 06, 2011 12:37 PM
> To: Iyer, Balaji V
> Subject: Re: [Patch][Cilkplus branch] Adding include directory path to 
> testsuite script
>
> Please use "git diff origin/cilkplus" to generate patch.
>
> On Tue, Sep 6, 2011 at 9:36 AM, H.J. Lu  wrote:
>> On Tue, Sep 6, 2011 at 8:01 AM, Iyer, Balaji V  
>> wrote:
>>> Sure! Here is the fixed patch.
>>
>> It won't apply.  Please make sure that it is against cilkplus branch.
>>
>> H.J.
>>> Thanks,
>>>
>>> Balaji V. Iyer.
>>>
>>> -Original Message-
>>> From: H.J. Lu [mailto:hjl.to...@gmail.com]
>>> Sent: Tuesday, September 06, 2011 10:57 AM
>>> To: Iyer, Balaji V
>>> Cc: gcc-patches@gcc.gnu.org
>>> Subject: Re: [Patch][Cilkplus branch] Adding include directory path
>>> to testsuite script
>>>
>>> You should just say "* g++.dg/cilk-plus/cilk_plus.exp: Likewise" since the 
>>> change is the same as above.
>>>
>>> H.J.
>>> On Tue, Sep 6, 2011 at 7:45 AM, Iyer, Balaji V  
>>> wrote:
 I fixed all the changed you have requested. Here is an updated patch.

 Thanks,

 Balaji V. Iyer.


 -Original Message-
 From: H.J. Lu [mailto:hjl.to...@gmail.com]
 Sent: Tuesday, September 06, 2011 10:41 AM
 To: Iyer, Balaji V
 Cc: gcc-patches@gcc.gnu.org
 Subject: Re: [Patch][Cilkplus branch] Adding include directory path
 to testsuite script

 On Tue, Sep 6, 2011 at 7:30 AM, Iyer, Balaji V  
 wrote:
> Attached, please find a patch with the modifications you have suggested 
> (adding the info in Changelog.cilk).

 Please remove the extra blank line in ChangLog.  ChangeLog should simply 
 say what you did, not why.

 H.J.
 
> Sorry for the mistake.
>
> Thanks,
>
> Balaji V. Iyer.
>
>
> -Original Message-
> From: H.J. Lu [mailto:hjl.to...@gmail.com]
> Sent: Tuesday, September 06, 2011 10:22 AM
> To: Iyer, Balaji V
> Cc: gcc-patches@gcc.gnu.org
> Subject: Re: [Patch][Cilkplus branch] Adding include directory path
> to testsuite script
>
> On Mon, Sep 5, 2011 at 9:52 PM, Iyer, Balaji V  
> wrote:
>> 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,
>>
>
> ChangeLog entries are missing.
>
>>
>
>
>
> --
> H.J.
>



--
H.J.
diff --git a/gcc/testsuite/ChangeLog.cilk b/gcc/testsuite/ChangeLog.cilk
index c9eac87..e45add2 100644
--- a/gcc/testsuite/ChangeLog.cilk
+++ b/gcc/testsuite/ChangeLog.cilk
@@ -1,4 +1,10 @@
-2011-08-15  Balaji V. Iyer. 
+2011-09-05  Balaji V. Iyer  
+
+   * gcc.dg/cilk-plus/cilk_plus.exp: Added -I 
+   $(src_dir)../../libcilkrts/include.  Also removed -fsyntax-only
+   * g++.dg/cilk-plus/cilk_plus.exp: Likewise
+
+2011-08-15  Balaji V. Iyer  
 
* gcc.dg/cilk-plus/cilk-for.c: New
* gcc.dg/cilk-plus/fib.c: New
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=c

[PATCH] Make SRA produce integer replacements for enumeration types

2011-09-06 Thread Martin Jambor
Hi,

the patch below makes SRA produce intere type replacements when it
currently produces enumeration type ones because this then may cause
VRP to assume wrong bounds (PR 49911).

I do not know how to create a testcase for the PR this should solve
because I could not reproduce it on yesterday's trunk checkout.

The patch is against trunk, where it successfully passes bootstrap and
testing on x86_64-linux, but applies well also to 4.6 and 4.5 branches
and there has been a request to commit them there as well so I'd like
to do so (after testing it on them which I have not done yet).

OK?

Thanks,

Martin


2011-09-05  Martin Jambor  

PR tree-optimization/49911
* tree-sra.c (analyze_access_subtree): Change type of to-be-replaced
enumerations to the corresponding plain integer type.

Index: src/gcc/tree-sra.c
===
--- src.orig/gcc/tree-sra.c
+++ src/gcc/tree-sra.c
@@ -2075,13 +2075,25 @@ analyze_access_subtree (struct access *r
  || ((root->grp_scalar_read || root->grp_assignment_read)
  && (root->grp_scalar_write || root->grp_assignment_write
 {
+  bool new_integer_type;
+  if (TREE_CODE (root->type) == ENUMERAL_TYPE)
+   {
+ tree rt = root->type;
+ root->type = build_nonstandard_integer_type (TYPE_PRECISION (rt),
+  TYPE_UNSIGNED (rt));
+ new_integer_type = true;
+   }
+  else
+   new_integer_type = false;
+
   if (dump_file && (dump_flags & TDF_DETAILS))
{
  fprintf (dump_file, "Marking ");
  print_generic_expr (dump_file, root->base, 0);
- fprintf (dump_file, " offset: %u, size: %u: ",
+ fprintf (dump_file, " offset: %u, size: %u ",
   (unsigned) root->offset, (unsigned) root->size);
- fprintf (dump_file, " to be replaced.\n");
+ fprintf (dump_file, " to be replaced%s.\n",
+  new_integer_type ? " with an integer": "");
}
 
   root->grp_to_be_replaced = 1;



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

2011-09-06 Thread H.J. Lu
diff --git a/gcc/testsuite/ChangeLog.cilk b/gcc/testsuite/ChangeLog.cilk
index c9eac87..a602b88 100644
--- a/gcc/testsuite/ChangeLog.cilk
+++ b/gcc/testsuite/ChangeLog.cilk
@@ -1,3 +1,9 @@
+2011-09-05  Balaji V. Iyer. 
 ^^ Your name should be
followed by 2 spaces, not a period.

+
+   * gcc.dg/cilk-plus/cilk_plus.exp: Added -I
+   $(src_dir)../../libcilkrts/include.  Also removed -fsyntax-only
+   * g++.dg/cilk-plus/cilk_plus.exp: Likewise
+


On Tue, Sep 6, 2011 at 10:22 AM, Iyer, Balaji V  wrote:
> Ok..try it now.. I did git diff origin/cilkplus.
>
> Thanks,
>
> Balaji V. Iyer.
>
> -Original Message-
> From: H.J. Lu [mailto:hjl.to...@gmail.com]
> Sent: Tuesday, September 06, 2011 12:37 PM
> To: Iyer, Balaji V
> Subject: Re: [Patch][Cilkplus branch] Adding include directory path to 
> testsuite script
>
> Please use "git diff origin/cilkplus" to generate patch.
>
> On Tue, Sep 6, 2011 at 9:36 AM, H.J. Lu  wrote:
>> On Tue, Sep 6, 2011 at 8:01 AM, Iyer, Balaji V  
>> wrote:
>>> Sure! Here is the fixed patch.
>>
>> It won't apply.  Please make sure that it is against cilkplus branch.
>>
>> H.J.
>>> Thanks,
>>>
>>> Balaji V. Iyer.
>>>
>>> -Original Message-
>>> From: H.J. Lu [mailto:hjl.to...@gmail.com]
>>> Sent: Tuesday, September 06, 2011 10:57 AM
>>> To: Iyer, Balaji V
>>> Cc: gcc-patches@gcc.gnu.org
>>> Subject: Re: [Patch][Cilkplus branch] Adding include directory path
>>> to testsuite script
>>>
>>> You should just say "* g++.dg/cilk-plus/cilk_plus.exp: Likewise" since the 
>>> change is the same as above.
>>>
>>> H.J.
>>> On Tue, Sep 6, 2011 at 7:45 AM, Iyer, Balaji V  
>>> wrote:
 I fixed all the changed you have requested. Here is an updated patch.

 Thanks,

 Balaji V. Iyer.


 -Original Message-
 From: H.J. Lu [mailto:hjl.to...@gmail.com]
 Sent: Tuesday, September 06, 2011 10:41 AM
 To: Iyer, Balaji V
 Cc: gcc-patches@gcc.gnu.org
 Subject: Re: [Patch][Cilkplus branch] Adding include directory path
 to testsuite script

 On Tue, Sep 6, 2011 at 7:30 AM, Iyer, Balaji V  
 wrote:
> Attached, please find a patch with the modifications you have suggested 
> (adding the info in Changelog.cilk).

 Please remove the extra blank line in ChangLog.  ChangeLog should simply 
 say what you did, not why.

 H.J.
 
> Sorry for the mistake.
>
> Thanks,
>
> Balaji V. Iyer.
>
>
> -Original Message-
> From: H.J. Lu [mailto:hjl.to...@gmail.com]
> Sent: Tuesday, September 06, 2011 10:22 AM
> To: Iyer, Balaji V
> Cc: gcc-patches@gcc.gnu.org
> Subject: Re: [Patch][Cilkplus branch] Adding include directory path
> to testsuite script
>
> On Mon, Sep 5, 2011 at 9:52 PM, Iyer, Balaji V  
> wrote:
>> 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,
>>
>
> ChangeLog entries are missing.
>
>>
>
>
>
> --
> H.J.
>



-- 
H.J.


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

2011-09-06 Thread Iyer, Balaji V
Ok..try it now.. I did git diff origin/cilkplus.

Thanks,

Balaji V. Iyer.

-Original Message-
From: H.J. Lu [mailto:hjl.to...@gmail.com] 
Sent: Tuesday, September 06, 2011 12:37 PM
To: Iyer, Balaji V
Subject: Re: [Patch][Cilkplus branch] Adding include directory path to 
testsuite script

Please use "git diff origin/cilkplus" to generate patch.

On Tue, Sep 6, 2011 at 9:36 AM, H.J. Lu  wrote:
> On Tue, Sep 6, 2011 at 8:01 AM, Iyer, Balaji V  
> wrote:
>> Sure! Here is the fixed patch.
>
> It won't apply.  Please make sure that it is against cilkplus branch.
>
> H.J.
>> Thanks,
>>
>> Balaji V. Iyer.
>>
>> -Original Message-
>> From: H.J. Lu [mailto:hjl.to...@gmail.com]
>> Sent: Tuesday, September 06, 2011 10:57 AM
>> To: Iyer, Balaji V
>> Cc: gcc-patches@gcc.gnu.org
>> Subject: Re: [Patch][Cilkplus branch] Adding include directory path 
>> to testsuite script
>>
>> You should just say "* g++.dg/cilk-plus/cilk_plus.exp: Likewise" since the 
>> change is the same as above.
>>
>> H.J.
>> On Tue, Sep 6, 2011 at 7:45 AM, Iyer, Balaji V  
>> wrote:
>>> I fixed all the changed you have requested. Here is an updated patch.
>>>
>>> Thanks,
>>>
>>> Balaji V. Iyer.
>>>
>>>
>>> -Original Message-
>>> From: H.J. Lu [mailto:hjl.to...@gmail.com]
>>> Sent: Tuesday, September 06, 2011 10:41 AM
>>> To: Iyer, Balaji V
>>> Cc: gcc-patches@gcc.gnu.org
>>> Subject: Re: [Patch][Cilkplus branch] Adding include directory path 
>>> to testsuite script
>>>
>>> On Tue, Sep 6, 2011 at 7:30 AM, Iyer, Balaji V  
>>> wrote:
 Attached, please find a patch with the modifications you have suggested 
 (adding the info in Changelog.cilk).
>>>
>>> Please remove the extra blank line in ChangLog.  ChangeLog should simply 
>>> say what you did, not why.
>>>
>>> H.J.
>>> 
 Sorry for the mistake.

 Thanks,

 Balaji V. Iyer.


 -Original Message-
 From: H.J. Lu [mailto:hjl.to...@gmail.com]
 Sent: Tuesday, September 06, 2011 10:22 AM
 To: Iyer, Balaji V
 Cc: gcc-patches@gcc.gnu.org
 Subject: Re: [Patch][Cilkplus branch] Adding include directory path 
 to testsuite script

 On Mon, Sep 5, 2011 at 9:52 PM, Iyer, Balaji V  
 wrote:
> 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,
>

 ChangeLog entries are missing.

>



--
H.J.
diff --git a/gcc/testsuite/ChangeLog.cilk b/gcc/testsuite/ChangeLog.cilk
index c9eac87..a602b88 100644
--- a/gcc/testsuite/ChangeLog.cilk
+++ b/gcc/testsuite/ChangeLog.cilk
@@ -1,3 +1,9 @@
+2011-09-05  Balaji V. Iyer. 
+
+   * gcc.dg/cilk-plus/cilk_plus.exp: Added -I 
+   $(src_dir)../../libcilkrts/include.  Also removed -fsyntax-only
+   * g++.dg/cilk-plus/cilk_plus.exp: Likewise
+
 2011-08-15  Balaji V. Iyer. 
 
* gcc.dg/cilk-plus/cilk-for.c: New
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][google/integration] Add lightweight checks to vector::begin et. al. (issue4973065)

2011-09-06 Thread Paul Pluzhnikov
On Tue, Sep 6, 2011 at 9:44 AM, Diego Novillo  wrote:

> OK.  Any reason not to send this (or a variant) to mainline?

AFAIU, mainline is not interested -- there is already a debug mode (enabled
by _GLIBCXX_DEBUG), which catches many of the same bugs (and more), and
introduction of "parallel" debug modes is undesirable.

Unfortunately, _GLIBCXX_DEBUG makes no performance guarantees (making some
normally constant-time operations O(N), etc.) and so we can't just turn
it on in Google.

Thanks,
-- 
Paul Pluzhnikov


Re: [patch][google/integration] Add lightweight checks to vector::begin et. al. (issue4973065)

2011-09-06 Thread Diego Novillo
On Tue, Sep 6, 2011 at 12:28, Paul Pluzhnikov  wrote:
> Greetings,
>
> This patch adds a lightweight self-consistency check to many vector
> operations. Google issue 5246356.
>
> Ok for google/integration branch?
>
> Thanks,
> --
>
>
> 2011-09-06  Paul Pluzhnikov  
>
>        * include/bits/stl_vector.h (__is_valid): New function.
>        (begin, end, size, capacity, swap, clear): Call it.
>        * include/bits/vector.tcc (operator=): Likewise.

OK.  Any reason not to send this (or a variant) to mainline?


Diego.


Re: [PATCH Atom][PR middle-end/44382] Tree reassociation improvement

2011-09-06 Thread H.J. Lu
On Tue, Sep 6, 2011 at 9:07 AM, Ilya Enkovich  wrote:
> 2011/9/6 Uros Bizjak :
>>
>> OK.
>>
>> Thanks,
>> Uros.
>>
>
> Could please someone check it in for me?
>

I checked it in for you.

-- 
H.J.


Re: [patch][google/integration] Add lightweight checks to vector::begin et. al. (issue4973065)

2011-09-06 Thread Paul Pluzhnikov
On Tue, Sep 6, 2011 at 9:28 AM, Paul Pluzhnikov  wrote:

> This patch adds a lightweight self-consistency check to many vector
> operations. Google issue 5246356.

Sorry, forgot to mention: tested by doing bootstrap and make check on
Linux/x86_64.

-- 
Paul Pluzhnikov


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

2011-09-06 Thread H.J. Lu
On Tue, Sep 6, 2011 at 8:01 AM, Iyer, Balaji V  wrote:
> Sure! Here is the fixed patch.

It won't apply.  Please make sure that it is against cilkplus branch.

H.J.
> Thanks,
>
> Balaji V. Iyer.
>
> -Original Message-
> From: H.J. Lu [mailto:hjl.to...@gmail.com]
> Sent: Tuesday, September 06, 2011 10:57 AM
> To: Iyer, Balaji V
> Cc: gcc-patches@gcc.gnu.org
> Subject: Re: [Patch][Cilkplus branch] Adding include directory path to 
> testsuite script
>
> You should just say "* g++.dg/cilk-plus/cilk_plus.exp: Likewise" since the 
> change is the same as above.
>
> H.J.
> On Tue, Sep 6, 2011 at 7:45 AM, Iyer, Balaji V  
> wrote:
>> I fixed all the changed you have requested. Here is an updated patch.
>>
>> Thanks,
>>
>> Balaji V. Iyer.
>>
>>
>> -Original Message-
>> From: H.J. Lu [mailto:hjl.to...@gmail.com]
>> Sent: Tuesday, September 06, 2011 10:41 AM
>> To: Iyer, Balaji V
>> Cc: gcc-patches@gcc.gnu.org
>> Subject: Re: [Patch][Cilkplus branch] Adding include directory path to
>> testsuite script
>>
>> On Tue, Sep 6, 2011 at 7:30 AM, Iyer, Balaji V  
>> wrote:
>>> Attached, please find a patch with the modifications you have suggested 
>>> (adding the info in Changelog.cilk).
>>
>> Please remove the extra blank line in ChangLog.  ChangeLog should simply say 
>> what you did, not why.
>>
>> H.J.
>> 
>>> Sorry for the mistake.
>>>
>>> Thanks,
>>>
>>> Balaji V. Iyer.
>>>
>>>
>>> -Original Message-
>>> From: H.J. Lu [mailto:hjl.to...@gmail.com]
>>> Sent: Tuesday, September 06, 2011 10:22 AM
>>> To: Iyer, Balaji V
>>> Cc: gcc-patches@gcc.gnu.org
>>> Subject: Re: [Patch][Cilkplus branch] Adding include directory path
>>> to testsuite script
>>>
>>> On Mon, Sep 5, 2011 at 9:52 PM, Iyer, Balaji V  
>>> wrote:
 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,

>>>
>>> ChangeLog entries are missing.
>>>


[patch][google/integration] Add lightweight checks to vector::begin et. al. (issue4973065)

2011-09-06 Thread Paul Pluzhnikov
Greetings,

This patch adds a lightweight self-consistency check to many vector
operations. Google issue 5246356.

Ok for google/integration branch?

Thanks,
--


2011-09-06  Paul Pluzhnikov  

* include/bits/stl_vector.h (__is_valid): New function.
(begin, end, size, capacity, swap, clear): Call it.
* include/bits/vector.tcc (operator=): Likewise.



Index: include/bits/stl_vector.h
===
--- include/bits/stl_vector.h   (revision 178493)
+++ include/bits/stl_vector.h   (working copy)
@@ -234,6 +234,16 @@
   using _Base::_M_impl;
   using _Base::_M_get_Tp_allocator;
 
+  bool __is_valid() const
+  {
+return (this->_M_impl._M_end_of_storage == 0
+   && this->_M_impl._M_start == 0
+   && this->_M_impl._M_finish == 0)
+ || (this->_M_impl._M_start <= this->_M_impl._M_finish
+ && this->_M_impl._M_finish <= this->_M_impl._M_end_of_storage
+ && this->_M_impl._M_start < this->_M_impl._M_end_of_storage);
+  }
+
 public:
   // [23.2.4.1] construct/copy/destroy
   // (assign() and get_allocator() are also listed in this section)
@@ -531,7 +541,13 @@
*/
   iterator
   begin() _GLIBCXX_NOEXCEPT
-  { return iterator(this->_M_impl._M_start); }
+  {
+#if __google_stl_debug_dangling_vector
+if (!this->__is_valid())
+  __throw_logic_error("begin() on corrupt (dangling?) vector");
+#endif
+   return iterator(this->_M_impl._M_start);
+  }
 
   /**
*  Returns a read-only (constant) iterator that points to the
@@ -540,7 +556,13 @@
*/
   const_iterator
   begin() const _GLIBCXX_NOEXCEPT
-  { return const_iterator(this->_M_impl._M_start); }
+  {
+#if __google_stl_debug_dangling_vector
+if (!this->__is_valid())
+  __throw_logic_error("begin() on corrupt (dangling?) vector");
+#endif
+   return const_iterator(this->_M_impl._M_start);
+  }
 
   /**
*  Returns a read/write iterator that points one past the last
@@ -549,7 +571,13 @@
*/
   iterator
   end() _GLIBCXX_NOEXCEPT
-  { return iterator(this->_M_impl._M_finish); }
+  {
+#if __google_stl_debug_dangling_vector
+if (!this->__is_valid())
+  __throw_logic_error("end() on corrupt (dangling?) vector");
+#endif
+   return iterator(this->_M_impl._M_finish);
+  }
 
   /**
*  Returns a read-only (constant) iterator that points one past
@@ -558,7 +586,13 @@
*/
   const_iterator
   end() const _GLIBCXX_NOEXCEPT
-  { return const_iterator(this->_M_impl._M_finish); }
+  {
+#if __google_stl_debug_dangling_vector
+if (!this->__is_valid())
+  __throw_logic_error("end() on corrupt (dangling?) vector");
+#endif
+   return const_iterator(this->_M_impl._M_finish);
+  }
 
   /**
*  Returns a read/write reverse iterator that points to the
@@ -638,7 +672,13 @@
   /**  Returns the number of elements in the %vector.  */
   size_type
   size() const _GLIBCXX_NOEXCEPT
-  { return size_type(this->_M_impl._M_finish - this->_M_impl._M_start); }
+  {
+#if __google_stl_debug_dangling_vector
+if (!this->__is_valid())
+  __throw_logic_error("size() on corrupt (dangling?) vector");
+#endif
+   return size_type(this->_M_impl._M_finish - this->_M_impl._M_start);
+  }
 
   /**  Returns the size() of the largest possible %vector.  */
   size_type
@@ -718,7 +758,12 @@
*/
   size_type
   capacity() const _GLIBCXX_NOEXCEPT
-  { return size_type(this->_M_impl._M_end_of_storage
+  {
+#if __google_stl_debug_dangling_vector
+if (!this->__is_valid())
+  __throw_logic_error("capacity() on corrupt (dangling?) vector");
+#endif
+   return size_type(this->_M_impl._M_end_of_storage
 - this->_M_impl._M_start); }
 
   /**
@@ -1112,6 +1157,10 @@
noexcept(_Alloc_traits::_S_nothrow_swap())
 #endif
   {
+#if __google_stl_debug_dangling_vector
+if (!this->__is_valid() || !__x.__is_valid())
+  __throw_logic_error("swap() on corrupt (dangling?) vector");
+#endif
this->_M_impl._M_swap_data(__x._M_impl);
_Alloc_traits::_S_on_swap(_M_get_Tp_allocator(),
  __x._M_get_Tp_allocator());
@@ -1125,7 +1174,13 @@
*/
   void
   clear() _GLIBCXX_NOEXCEPT
-  { _M_erase_at_end(this->_M_impl._M_start); }
+  {
+#if __google_stl_debug_dangling_vector
+if (!this->__is_valid())
+  __throw_logic_error("clear() on corrupt (dangling?) vector");
+#endif
+   _M_erase_at_end(this->_M_impl._M_start);
+  }
 
 protected:
   /**
Index: include/bits/vector.tcc
===
--- include/bits/vector.tcc (revision 178493)

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

2011-09-06 Thread Mike Stump
On Sep 6, 2011, at 1:12 AM, Eric Botcazou wrote:
>> That's a good question, and one that I haven't got to the bottom of -
>> but the exclusion was there in the original code-base [still in the
>> vendor's tree too].
>> (also, the rs6000 pro/epilogue code is not the easiest to navigate).
> 
> Assuming that this is because the non-local goto handler needs to find a 
> register saved at a canonical place, you can try !cfun->has_nonlocal_label.

> This will subsume the original check !(cfun->calls_setjmp && flag_exceptions)
> as both the regular SJLJ scheme and the GNAT SJLJ scheme use it.

I can't confirm the assumption, but, if it holds, sounds nicer to me, thanks.


Re: [PATCH Atom][PR middle-end/44382] Tree reassociation improvement

2011-09-06 Thread Ilya Enkovich
2011/9/6 Uros Bizjak :
>
> OK.
>
> Thanks,
> Uros.
>

Could please someone check it in for me?

Thanks,
Ilya


[PATCH] Fix PR47025

2011-09-06 Thread Richard Guenther

This fixes PR47025, __builtin_va_end is preventing dead store
elimination and __builtin_va_start is an escape point for the
valist.

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

Richard.

2011-09-06  Richard Guenther  

PR tree-optimization/47025
* tree-ssa-alias.c (ref_maybe_used_by_call_p_1): BUILT_IN_VA_END
uses nothing.
(call_may_clobber_ref_p_1): BUILT_IN_VA_END is a barrier like
BUILT_IN_FREE.
(stmt_kills_ref_p_1): BUILT_IN_VA_END kills what its argument
definitely points to.
* tree-ssa-structalias.c (find_func_aliases_for_builtin_call):
BUILT_IN_VA_START doesn't let its va_list argument escape.
* tree-ssa-dce.c (propagate_necessity): BUILT_IN_VA_END does
not make any previous stores necessary.

Index: gcc/tree-ssa-alias.c
===
*** gcc/tree-ssa-alias.c.orig   2011-09-06 16:24:16.0 +0200
--- gcc/tree-ssa-alias.c2011-09-06 16:28:48.0 +0200
*** ref_maybe_used_by_call_p_1 (gimple call,
*** 1254,1259 
--- 1254,1260 
case BUILT_IN_SINCOSF:
case BUILT_IN_SINCOSL:
case BUILT_IN_ASSUME_ALIGNED:
+   case BUILT_IN_VA_END:
  return false;
/* __sync_* builtins and some OpenMP builtins act as threading
   barriers.  */
*** call_may_clobber_ref_p_1 (gimple call, a
*** 1518,1523 
--- 1519,1525 
   the call has to serve as a barrier for moving loads and stores
   across it.  */
case BUILT_IN_FREE:
+   case BUILT_IN_VA_END:
  {
tree ptr = gimple_call_arg (call, 0);
return ptr_deref_may_alias_ref_p_1 (ptr, ref);
*** stmt_kills_ref_p_1 (gimple stmt, ao_ref
*** 1763,1772 
  / BITS_PER_UNIT)))
return true;
}
}
  default:;
  }
- 
  }
return false;
  }
--- 1765,1787 
  / BITS_PER_UNIT)))
return true;
}
+ break;
+   }
+ 
+ case BUILT_IN_VA_END:
+   {
+ tree ptr = gimple_call_arg (stmt, 0);
+ if (TREE_CODE (ptr) == ADDR_EXPR)
+   {
+ tree base = ao_ref_base (ref);
+ if (TREE_OPERAND (ptr, 0) == base)
+   return true;
+   }
+ break;
}
+ 
  default:;
  }
  }
return false;
  }
Index: gcc/tree-ssa-structalias.c
===
*** gcc/tree-ssa-structalias.c.orig 2011-09-06 16:23:29.0 +0200
--- gcc/tree-ssa-structalias.c  2011-09-06 16:24:18.0 +0200
*** find_func_aliases_for_builtin_call (gimp
*** 4187,4213 
 mode as well.  */
case BUILT_IN_VA_START:
{
  if (in_ipa_mode)
{
- tree valist = gimple_call_arg (t, 0);
- struct constraint_expr rhs, *lhsp;
- unsigned i;
- /* The va_list gets access to pointers in variadic
-arguments.  */
  fi = lookup_vi_for_tree (cfun->decl);
- gcc_assert (fi != NULL);
- get_constraint_for (valist, &lhsc);
- do_deref (&lhsc);
  rhs = get_function_part_constraint (fi, ~0);
  rhs.type = ADDRESSOF;
- FOR_EACH_VEC_ELT (ce_s, lhsc, i, lhsp)
- process_constraint (new_constraint (*lhsp, rhs));
- VEC_free (ce_s, heap, lhsc);
- /* va_list is clobbered.  */
- make_constraint_to (get_call_clobber_vi (t)->id, valist);
- return true;
}
! break;
}
/* va_end doesn't have any effect that matters.  */
case BUILT_IN_VA_END:
--- 4187,4218 
 mode as well.  */
case BUILT_IN_VA_START:
{
+ tree valist = gimple_call_arg (t, 0);
+ struct constraint_expr rhs, *lhsp;
+ unsigned i;
+ get_constraint_for (valist, &lhsc);
+ do_deref (&lhsc);
+ /* The va_list gets access to pointers in variadic
+arguments.  Which we know in the case of IPA analysis
+and otherwise are just all nonlocal variables.  */
  if (in_ipa_mode)
{
  fi = lookup_vi_for_tree (cfun->decl);
  rhs = get_function_part_constraint (fi, ~0);
  rhs.type = ADDRESSOF;
}
! else
!   {
! rhs.var = nonlocal_id;
! rhs.type = ADDRESSOF;
! rhs.offset = 0;
!   }
! FOR_EACH_VEC_ELT (ce_s, lhsc, i, lhsp)
!   process_constraint (new_constraint (*lhsp, rhs));
! VEC_free (ce_s, heap, lhsc);
! /* va_list is clobbered.  */
! make_constraint_

Re: [PATCH Atom][PR middle-end/44382] Tree reassociation improvement

2011-09-06 Thread Uros Bizjak
On Tue, Sep 6, 2011 at 2:39 PM, Ilya Enkovich  wrote:

>> I assume that you need to split tune attribute to int and FP part to
>> handle reassociation for other targets, since Atom handles both in the
>> same way.
>>
>> Please also describe function return value in the comment (and perhaps
>> in documentation, too).
>>
>> OK with this addition.
>>
>> Thanks,
>> Uros.
>>
>
> Here is patch with added comment for hook implementation. Is it OK?
>
> Thanks,
> Ilya
> ---
> gcc/
>
> 2011-09-06  Enkovich Ilya  
>
>        PR middle-end/44382
>        * target.def (reassociation_width): New hook.
>
>        * doc/tm.texi.in (reassociation_width): Likewise.
>
>        * doc/tm.texi (reassociation_width): Likewise.
>
>        * doc/invoke.texi (tree-reassoc-width): New param documented.
>
>        * hooks.h (hook_int_uint_mode_1): New default hook.
>
>        * hooks.c (hook_int_uint_mode_1): Likewise.
>
>        * config/i386/i386.h (ix86_tune_indices): Add
>        X86_TUNE_REASSOC_INT_TO_PARALLEL and
>        X86_TUNE_REASSOC_FP_TO_PARALLEL.
>
>        (TARGET_REASSOC_INT_TO_PARALLEL): New.
>        (TARGET_REASSOC_FP_TO_PARALLEL): Likewise.
>
>        * config/i386/i386.c (initial_ix86_tune_features): Add
>        X86_TUNE_REASSOC_INT_TO_PARALLEL and
>        X86_TUNE_REASSOC_FP_TO_PARALLEL.
>
>        (ix86_reassociation_width) implementation of
>        new hook for i386 target.
>
>        * params.def (PARAM_TREE_REASSOC_WIDTH): New param added.
>
>        * tree-ssa-reassoc.c (get_required_cycles): New function.
>        (get_reassociation_width): Likewise.
>        (swap_ops_for_binary_stmt): Likewise.
>        (rewrite_expr_tree_parallel): Likewise.
>
>        (rewrite_expr_tree): Refactored. Part of code moved into
>        swap_ops_for_binary_stmt.
>
>        (reassociate_bb): Now checks reassociation width to be used
>        and call rewrite_expr_tree_parallel instead of rewrite_expr_tree
>        if needed.
>
> gcc/testsuite/
>
> 2011-09-06  Enkovich Ilya  
>
>        * gcc.dg/tree-ssa/pr38533.c (dg-options): Added option
>        --param tree-reassoc-width=1.
>
>        * gcc.dg/tree-ssa/reassoc-24.c: New test.
>        * gcc.dg/tree-ssa/reassoc-25.c: Likewise.
>

OK.

Thanks,
Uros.


Re: [PATCH, Atom] Improve AGU stalls avoidance optimization

2011-09-06 Thread Uros Bizjak
On Tue, Sep 6, 2011 at 2:26 PM, Ilya Enkovich  wrote:


> Is fixed version OK?
>
> Thanks,
> Ilya
> ---
> gcc/
>
> 2011-09-06  Enkovich Ilya  
>
>        * config/i386/i386-protos.h (ix86_lea_outperforms): New.
>        (ix86_avoid_lea_for_add): Likewise.
>        (ix86_avoid_lea_for_addr): Likewise.
>        (ix86_split_lea_for_addr): Likewise.
>
>        * config/i386/i386.c (LEA_MAX_STALL): New.
>        (increase_distance): Likewise.
>        (insn_defines_reg): Likewise.
>        (insn_uses_reg_mem): Likewise.
>        (distance_non_agu_define_in_bb): Likewise.
>        (distance_agu_use_in_bb): Likewise.
>        (ix86_lea_outperforms): Likewise.
>        (ix86_ok_to_clobber_flags): Likewise.
>        (ix86_avoid_lea_for_add): Likewise.
>        (ix86_avoid_lea_for_addr): Likewise.
>        (ix86_split_lea_for_addr): Likewise.
>        (distance_non_agu_define): Search in pred BBs added.
>        (distance_agu_use): Search in succ BBs added.
>        (IX86_LEA_PRIORITY): Value changed from 2 to 0.
>        (LEA_SEARCH_THRESHOLD): Now depends on LEA_MAX_STALL.
>        (ix86_lea_for_add_ok): Use ix86_lea_outperforms to make decision.
>
>        * config/i386/i386.md: Splits added to transform lea into a
>        sequence of instructions.

Please merge your new splitters with corresponding LEA patterns.

OK with this change.

Thanks,
Uros.


Re: Vector shuffling

2011-09-06 Thread Richard Guenther
On Sat, Sep 3, 2011 at 5:52 PM, Artem Shinkarov
 wrote:
> On Fri, Sep 2, 2011 at 8:52 PM, Joseph S. Myers  
> wrote:
>> On Fri, 2 Sep 2011, Artem Shinkarov wrote:
>>
>>> Joseph, I don't understand this comment. I have 2 or 3 arguments in
>>> the VEC_SHUFFLE_EXPR and any of them can be C_MAYBE_CONST_EXPR,
>>
>> Yes.
>>
>>> so I
>>> need to wrap mask (the last argument) to avoid the following failure:
>>
>> No.  You need to fold it (c_fully_fold) to eliminate any
>> C_MAYBE_CONST_EXPR it contains, but you shouldn't need to wrap the result
>> of folding in a SAVE_EXPR.
>
> Ok, Now I get it, thanks.
>
> In the attachment there is a new version of the patch that removes save-exprs.

You are missing a ChangeLog entry

+
+res = __builtin_shuffle (a, mask1);   /* res is @{1,2,2,4@}  */
+res = __builtin_shuffle2 (a, b, mask2);   /* res is @{1,5,3,6@}  */

should be __builtin_shuffle (a, b, mask2);

+bool
+expand_vec_shuffle_expr_p (enum machine_mode mode, tree v0,
+  tree v1, tree mask)
+{
+  int v0_mode_s = GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (TREE_TYPE (v0;
+  int mask_mode_s = GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (TREE_TYPE
(mask;
+
+  if (TREE_CODE (mask) == VECTOR_CST
+  && targetm.vectorize.builtin_vec_perm_ok (TREE_TYPE (v0), mask))
+return true;
+
+  if (v0 != v1 || v0_mode_s != mask_mode_s)
+return false;

the mask size check constrains the size of the vector elements but not
their count.  It looks like you should instead verify the vector modes
are equal?  At least that would match the fact that you have an expander
that distinguishes one operand mode only.

At some point we definitely want to merge the builtin_vec_perm_*
target hooks with the optab.

+  fn = copy_node (fn);

You shouldn't need to copy fn

+  call = fold_build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (fn)), fn);
+  call = build_call_nary (type /* ? */, call, 3, v0, v1, mask);
+
+  t = expand_normal (call);
+  target = gen_reg_rtx (mode);
+  emit_insn (gen_rtx_SET (VOIDmode, target, t));

why can't you simply use

  return expand_expr_real_1 (call, target, VOIDmode, EXPAND_NORMAL, NULL);

here?

+   case VEC_SHUFFLE_EXPR:
+ {
+   enum gimplify_status r0, r1, r2;
+
+   if (TREE_OPERAND (*expr_p, 0) == TREE_OPERAND (*expr_p, 1))
+ {
+   r0 = r1 = gimplify_expr (&TREE_OPERAND (*expr_p, 0), pre_p,
+post_p, is_gimple_val, fb_rvalue);
+   TREE_OPERAND (*expr_p, 1) = TREE_OPERAND (*expr_p, 0);
+ }
+   else
+ {
+r0 = gimplify_expr (&TREE_OPERAND (*expr_p, 0), pre_p,
+post_p, is_gimple_val, fb_rvalue);
+r1 = gimplify_expr (&TREE_OPERAND (*expr_p, 1), pre_p,
+post_p, is_gimple_val, fb_rvalue);
+ }

please avoid the above tree sharing (I realize it's probably for constants,
but we don't share those).  Thus, unconditionally gimplify both
operands.  The equality check in expanding should probably use
operand_equal_p (..., ..., 0) instead of a pointer comparison.

Thus, the above should simply use the expr_3: code, like FMA_EXPR.

+/* Vector shuffle expression. A = VEC_SHUFFLE_EXPR
+   means
+
+   freach i in length (mask):

foreach

+   number of elements in V0 and V1. The size of the inner type
+   of the MASK and of the V0 and V1 must be the same.

Index: gcc/tree-cfg.c
===
--- gcc/tree-cfg.c  (revision 178354)
+++ gcc/tree-cfg.c  (working copy)
@@ -3713,6 +3713,7 @@ verify_gimple_assign_ternary (gimple stm

 case DOT_PROD_EXPR:
 case REALIGN_LOAD_EXPR:
+case VEC_SHUFFLE_EXPR:
   /* FIXME.  */
   return false;

can you do some basic verification here?  At least what you document
in tree.def should be verified here.

Index: gcc/tree-vect-generic.c
===
--- gcc/tree-vect-generic.c (revision 178354)
+++ gcc/tree-vect-generic.c (working copy)
@@ -30,6 +30,7 @@ along with GCC; see the file COPYING3.
 #include "tree-pass.h"
 #include "flags.h"
 #include "ggc.h"
+#include "diagnostic.h"

I don't see where you need this, nor a Makefile.in change.

+/* Build a reference to the element of the vector VECT. Function

two spaces after a '.'

+  if (TREE_CODE (vect) == VECTOR_CST)
+{
+unsigned i;
+tree vals = TREE_VECTOR_CST_ELTS (vect);
+for (i = 0; vals; vals = TREE_CHAIN (vals), ++i)
+  if (i == index)

operand_equal_p

+  else if (TREE_CODE (vect) == SSA_NAME)
+{
+  tree el;
+  gimple vectdef = SSA_NAME_DEF_STMT (vect);
+  if (gimple_assign_single_p (vectdef)
+  && (el = vector_element (gsi, gimple_assign_rhs1 (vectdef),
+   idx, ptmp

Re: RFA: MN10300: Add jump label to Lcc insn

2011-09-06 Thread Jeff Law
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 09/06/11 07:01, Nick Clifton wrote:
> Hi Jeff, Hi Alex,
> 
> The MN10300 target is currently failing to build in the mainline FSF 
> sources because of this error when creating libgcc:
> 
> gcc/libgcc2.c: In function '__popcountsi2': gcc/libgcc2.c:834:1:
> internal compiler error: in create_trace_edges, at dwarf2cfi.c:2325
> 
> This turns out to be because the code in create_trace_edges does not 
> handle jumps inside parallel insns, like this:
> 
> (jump_insn 72 52 31 3 (parallel [ (set (pc) (if_then_else (ne (reg:CC
> 51 EPSW) (const_int 0 [0])) (label_ref 29) (pc))) (unspec [ 
> (const_int 1 [0x1]) ] 9) ]) gcc/libgcc2.c:830 -1 
> (insn_list:REG_LABEL_OPERAND 29 (nil)))
> 
> I am not sure if create_trace_edges should handle this, but I felt 
> that the easiest thing to do was to fix the MN10300 backend so that 
> when it was creating this insn, it would also set the label on the 
> parallel container.  That is what the patch below does and with this 
> applied I can build the toolchain again.
> 
> OK to apply, or is there a better way to fix the problem ?
> 
> Cheers Nick
> 
> gcc/ChangeLog 2011-09-06  Nick Clifton  
> 
> * config/mn10300/mn10300.c (mn10300_insert_setlb_lcc): Set the jump
> label on the parallel part of the insn.
Normally the JUMP_LABEL is set by the generic parts of the compiler;
however, jumps created via the md_reorg hook need explicitly have their
JUMP_LABEL set by the backend.

OK.

jeff

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

iQEcBAEBAgAGBQJOZjs5AAoJEBRtltQi2kC7jJkH/0XQmZiche6+zgwdkq9rxLAs
BBILnHF4cHsj8lb12lL3r7CY32JrXVE+jl1o2xz5uR1gWUd4Hnf3EVQ0z7feNfda
CQLUJUHTbCVTIOLZqLtMuwB4IVQFiRKFSdNxTE/ZYUG3gvHuN6vVEjbJW/+rzPei
MMhc0jq2uFUvazdnHJQ9rW6mQuk51Y66CWOTft21mrOnm2SzeKZ+tKM0TiTOYOOT
xSkT3Ni6wMPQe9sey1Bub+r4S0LWo2ER2aV2/Owg6j5k/ChDFYYcKCci+pLBSKGe
J4QdG4LdJjzLIvFf4YB4OQo9NGFVvlD5+lRXYW+QgYNmsM+nrqmFpC4C2eW04fk=
=jpY2
-END PGP SIGNATURE-


Re: [Ada] Speed up build of gnatools

2011-09-06 Thread Paolo Bonzini

On 09/06/2011 01:56 PM, Arnaud Charlet wrote:

this means using as many processes as there are CPUs, right?  It seems pretty


Right, but only for gnattools, which is a relatively short time, and
which always occurs at the end of the build (so with nothing else
running at the same time).


dubious to me to use more processes than the user maybe asked for.  For example
I have to restrict the number of CPUs used when building GCC to less than I have
since otherwise my machine overheats and turns itself off.  Is there some way
to get at the -j level the user passed to the top-level make and use that?


No, I'm not aware of a way to get this information.


The solution would be to support running gnatmake as a client of make's 
job server.  In short:


1) gnatmake should look for the MAKEFLAGS environment variable, and look 
for the --jobserver-fds= option found inside it.  The option receives a 
comma-separated list of two file descriptors.  The first is an "input" 
pipe, the second is an "output" pipe.


2) before invoking any child process, gnatmake should ensure the child 
doesn't see the two pipes (unless the child were also an instance of 
make/gnatmake).


3) *after* invoking any child process, gnatmake should perform a 
blocking 1-byte read from the "input" pipe.


4) after reaping any child process, gnatmake should perform a blocking 
1-byte write to the "output" pipe.


5) you should add a + in front of rules that use gnatmake.

Paolo


[Ada] clean ups in Makefiles

2011-09-06 Thread Arnaud Charlet
As discussed recently, this patch reintroduces some Makefile hunks
that had been removed in the past. These hunks allow (at least partially)
to use gnattools/gnatlib targets to be used individually when using
--disable-libada and alos reduce differences between FSF and AdaCore
repositories, thus making it easier to merge changes in the future and
avoid conflicts.

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

* gcc-interface/Makefile.in, gcc-interface/Make-lang.in
(gnattools, regnattools, cross-gnattools, canadian-gnattools,
gnatlib, gnatlib-sjlj, gnatlib-zcx, gnatlib-shared, gnatlib_and_tools):
New targets.
(TOOLS_FLAGS_TO_PASS): New.
(../stamp-tools): Reintroduce, to avoid merge conflicts.
--
Index: gcc-interface/Makefile.in
===
--- gcc-interface/Makefile.in   (revision 178592)
+++ gcc-interface/Makefile.in   (working copy)
@@ -2315,8 +2315,32 @@
 
 LIBGNAT=../$(RTSDIR)/libgnat.a
 
+TOOLS_FLAGS_TO_PASS=   \
+   "CC=$(CC)"  \
+   "CFLAGS=$(CFLAGS)"  \
+   "LDFLAGS=$(LDFLAGS)"\
+   "ADAFLAGS=$(ADAFLAGS)"  \
+   "INCLUDES=$(INCLUDES_FOR_SUBDIR)"\
+   "ADA_INCLUDES=$(ADA_INCLUDES) $(ADA_INCLUDES_FOR_SUBDIR)"\
+   "libsubdir=$(libsubdir)"\
+   "exeext=$(exeext)"  \
+   "fsrcdir=$(fsrcdir)"\
+   "srcdir=$(fsrcdir)" \
+   "TOOLS_LIBS=$(TOOLS_LIBS) $(TGT_LIB)"   \
+   "GNATMAKE=$(GNATMAKE)"  \
+   "GNATLINK=$(GNATLINK)"  \
+   "GNATBIND=$(GNATBIND)"
+
 GCC_LINK=$(CC) $(GCC_LINK_FLAGS) $(ADA_INCLUDES)
 
+# Build directory for the tools. Let's copy the target-dependent
+# sources using the same mechanism as for gnatlib. The other sources are
+# accessed using the vpath directive below
+# Note: dummy target, stamp-tools is mainly handled by gnattools.
+
+../stamp-tools:
+   touch ../stamp-tools
+
 # when compiling the tools, the runtime has to be first on the path so that
 # it hides the runtime files lying with the rest of the sources
 ifeq ($(TOOLSCASE),native)
@@ -2335,7 +2359,38 @@
   vpath %.h   ../
 endif
 
-common-tools:
+# gnatmake/link tools cannot always be built with gnatmake/link for bootstrap
+# reasons: gnatmake should be built with a recent compiler, a recent compiler
+# may not generate ALI files compatible with an old gnatmake so it is important
+# to be able to build gnatmake without a version of gnatmake around. Once
+# everything has been compiled once, gnatmake can be recompiled with itself
+# (see target gnattools1-re)
+gnattools1: ../stamp-tools ../stamp-gnatlib-$(RTSDIR)
+   $(MAKE) -C tools -f ../Makefile $(TOOLS_FLAGS_TO_PASS) \
+ TOOLSCASE=native \
+ ../../gnatmake$(exeext) ../../gnatlink$(exeext)
+
+# gnatmake/link can be built with recent gnatmake/link if they are available.
+# This is especially convenient for building cross tools or for rebuilding
+# the tools when the original bootstrap has already be done.
+gnattools1-re: ../stamp-tools
+   $(MAKE) -C tools -f ../Makefile $(TOOLS_FLAGS_TO_PASS) \
+ TOOLSCASE=cross INCLUDES="" gnatmake-re gnatlink-re
+
+# these tools are built with gnatmake & are common to native and cross
+gnattools2: ../stamp-tools
+   $(MAKE) -C tools -f ../Makefile $(TOOLS_FLAGS_TO_PASS) \
+ TOOLSCASE=native common-tools $(EXTRA_GNATTOOLS)
+
+# those tools are only built for the cross version
+gnattools4: ../stamp-tools
+ifeq ($(ENABLE_VXADDR2LINE),true)
+   $(MAKE) -C tools -f ../Makefile $(TOOLS_FLAGS_TO_PASS) \
+ TOOLSCASE=cross top_buildir=../../.. \
+ ../../vxaddr2line$(exeext)
+endif
+
+common-tools: ../stamp-tools
$(GNATMAKE) -j0 -c -b $(ADA_INCLUDES) \
  --GNATBIND="$(GNATBIND)" --GCC="$(CC) $(ALL_ADAFLAGS)" \
  gnatchop gnatcmd gnatkr gnatls gnatprep gnatxref gnatfind gnatname \
@@ -2359,22 +2414,22 @@
$(GNATLINK) -v gnatclean -o ../../gnatclean$(exeext) \
--GCC="$(GCC_LINK)" $(TOOLS_LIBS)
 
-../../gnatsym$(exeext): 
+../../gnatsym$(exeext): ../stamp-tools
$(GNATMAKE) -c $(ADA_INCLUDES) gnatsym --GCC="$(CC) $(ALL_ADAFLAGS)"
$(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) gnatsym
$(GNATLINK) -v gnatsym -o $@ --GCC="$(GCC_LINK)" $(TOOLS_LIBS)
 
-../../gnatdll$(exeext): 
+../../gnatdll$(exeext): ../stamp-tools
$(GNATMAKE) -c $(ADA_INCLUDES) gnatdll --GCC="$(CC) $(ALL_ADAFLAGS)"
$(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) gnatdll
$(GNATLINK) -v gnatdll -o $@ --GCC="$(GCC_LINK)" $(TOOLS_LIBS)
 
-../../vxaddr2line$(exeext): targext.o
+../../vxaddr2line$(exeext): ../stamp-tools targext.o
$(GNATMAKE) -c  $(ADA_INCLUDES) vxaddr2line --GCC="$(CC) 
$(ALL_ADAFLAGS)"
$(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) vxaddr2line
$(GNATLINK) -v vxaddr2line -o $@ --GCC="$(GCC_LINK)" targext.o $(CLIB)
 
-gnatmake-re:  link.o targext.o
+gnatmake-re: ../stamp-tools link.o ta

Re: [PATCH] check_cfg assert fix

2011-09-06 Thread Steven Bosscher
On Tue, Sep 6, 2011 at 11:14 AM, Tom de Vries  wrote:
> Hi,
>
> During testing the approved-for-commit middle-end patch for bug 43864 on ARM, 
> I
> ran into a gcc.dg/torture/pr46068.c ICE.
>
> The following assert in haifa-sched.c:check_cfg triggered:
> ...
>                  else if (any_condjump_p (head))
>                    gcc_assert (/* Usual case.  */
>                                (EDGE_COUNT (bb->succs) > 1
>                                 && !BARRIER_P (NEXT_INSN (head)))
>                                /* Or jump to the next instruction.  */
>                                || (EDGE_COUNT (bb->succs) == 1
>                                    && (BB_HEAD (EDGE_I (bb->succs, 0)->dest)
>                                        == JUMP_LABEL (head;
> ...
>
> It triggered on this rtl, a conditional return followed by a barrier:
> ...
> (jump_insn 44 43 93 7 (set (pc)
>        (if_then_else (ne (reg:CC 24 cc)
>                (const_int 0 [0]))
>            (return)
>            (pc))) gcc/testsuite/gcc.dg/builtin-unreachable-4.c:13 249
> {*cond_return}
>     (expr_list:REG_DEAD (reg:CC 24 cc)
>        (expr_list:REG_BR_PROB (const_int 9996 [0x270c])
>            (nil)))
>  -> return)
>
> (barrier 93 44 92)
> ...
>
> Although this insn sequence is non-optimal (the conditional return can be
> optimized to an unconditional one, given that it's followed by a barrier), 
> it's
> not incorrect. The patch fixes this ICE by removing the check for the
> 'EDGE_COUNT (bb->succs) == 1' case.
>
> Bootstrapped and reg-tested on x86_64 and build and reg-tested on arm.
>
> OK for trunk?

No. If the conditional return is not taken, you should not fall into a
barrier. It looks like the CFG somehow got corrupted, and if that's
indeed the case then your patch just papers over the problem. That
follows after the barrier?

Ciao!
Steven


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

2011-09-06 Thread Iyer, Balaji V
Sure! Here is the fixed patch.

Thanks,

Balaji V. Iyer.

-Original Message-
From: H.J. Lu [mailto:hjl.to...@gmail.com] 
Sent: Tuesday, September 06, 2011 10:57 AM
To: Iyer, Balaji V
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [Patch][Cilkplus branch] Adding include directory path to 
testsuite script

You should just say "* g++.dg/cilk-plus/cilk_plus.exp: Likewise" since the 
change is the same as above.

H.J.
On Tue, Sep 6, 2011 at 7:45 AM, Iyer, Balaji V  wrote:
> I fixed all the changed you have requested. Here is an updated patch.
>
> Thanks,
>
> Balaji V. Iyer.
>
>
> -Original Message-
> From: H.J. Lu [mailto:hjl.to...@gmail.com]
> Sent: Tuesday, September 06, 2011 10:41 AM
> To: Iyer, Balaji V
> Cc: gcc-patches@gcc.gnu.org
> Subject: Re: [Patch][Cilkplus branch] Adding include directory path to 
> testsuite script
>
> On Tue, Sep 6, 2011 at 7:30 AM, Iyer, Balaji V  
> wrote:
>> Attached, please find a patch with the modifications you have suggested 
>> (adding the info in Changelog.cilk).
>
> Please remove the extra blank line in ChangLog.  ChangeLog should simply say 
> what you did, not why.
>
> H.J.
> 
>> Sorry for the mistake.
>>
>> Thanks,
>>
>> Balaji V. Iyer.
>>
>>
>> -Original Message-
>> From: H.J. Lu [mailto:hjl.to...@gmail.com]
>> Sent: Tuesday, September 06, 2011 10:22 AM
>> To: Iyer, Balaji V
>> Cc: gcc-patches@gcc.gnu.org
>> Subject: Re: [Patch][Cilkplus branch] Adding include directory path 
>> to testsuite script
>>
>> On Mon, Sep 5, 2011 at 9:52 PM, Iyer, Balaji V  
>> wrote:
>>> 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,
>>>
>>
>> ChangeLog entries are missing.
>>
>> --
>> H.J.
>>
>
>
>
> --
> H.J.
>



--
H.J.
diff --git a/gcc/testsuite/ChangeLog.cilk b/gcc/testsuite/ChangeLog.cilk
index a311052..a602b88 100644
--- a/gcc/testsuite/ChangeLog.cilk
+++ b/gcc/testsuite/ChangeLog.cilk
@@ -1,3 +1,8 @@
+2011-09-05  Balaji V. Iyer. 
+
+   * gcc.dg/cilk-plus/cilk_plus.exp: Added -I 
+   $(src_dir)../../libcilkrts/include.  Also removed -fsyntax-only
+   * g++.dg/cilk-plus/cilk_plus.exp: Likewise
 
 2011-08-15  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][Cilkplus branch] Adding include directory path to testsuite script

2011-09-06 Thread H.J. Lu
You should just say "* g++.dg/cilk-plus/cilk_plus.exp: Likewise" since
the change is the same as above.

H.J.
On Tue, Sep 6, 2011 at 7:45 AM, Iyer, Balaji V  wrote:
> I fixed all the changed you have requested. Here is an updated patch.
>
> Thanks,
>
> Balaji V. Iyer.
>
>
> -Original Message-
> From: H.J. Lu [mailto:hjl.to...@gmail.com]
> Sent: Tuesday, September 06, 2011 10:41 AM
> To: Iyer, Balaji V
> Cc: gcc-patches@gcc.gnu.org
> Subject: Re: [Patch][Cilkplus branch] Adding include directory path to 
> testsuite script
>
> On Tue, Sep 6, 2011 at 7:30 AM, Iyer, Balaji V  
> wrote:
>> Attached, please find a patch with the modifications you have suggested 
>> (adding the info in Changelog.cilk).
>
> Please remove the extra blank line in ChangLog.  ChangeLog should simply say 
> what you did, not why.
>
> H.J.
> 
>> Sorry for the mistake.
>>
>> Thanks,
>>
>> Balaji V. Iyer.
>>
>>
>> -Original Message-
>> From: H.J. Lu [mailto:hjl.to...@gmail.com]
>> Sent: Tuesday, September 06, 2011 10:22 AM
>> To: Iyer, Balaji V
>> Cc: gcc-patches@gcc.gnu.org
>> Subject: Re: [Patch][Cilkplus branch] Adding include directory path to
>> testsuite script
>>
>> On Mon, Sep 5, 2011 at 9:52 PM, Iyer, Balaji V  
>> wrote:
>>> 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,
>>>
>>
>> ChangeLog entries are missing.
>>
>> --
>> H.J.
>>
>
>
>
> --
> H.J.
>



-- 
H.J.


Re: Vector Comparison patch

2011-09-06 Thread Richard Guenther
On Tue, Sep 6, 2011 at 4:50 PM, Artem Shinkarov
 wrote:
> Here is a new version of the patch which considers the changes from
> 2011-09-02  Richard Guenther
>
>
> ChangeLog
>
> 20011-09-06 Artjoms Sinkarovs 
>
>       gcc/
>       * fold-const.c (constant_boolean_node): Adjust the meaning
>       of boolean for vector types: true = {-1,..}, false = {0,..}.
>       (fold_unary_loc): Avoid conversion of vector comparison to
>       boolean type.

Both changes have already been done.

>       * expr.c (expand_expr_real_2): Expand vector comparison by
>       building an appropriate VEC_COND_EXPR.

I prefer

Index: gcc/expr.c
===
*** gcc/expr.c.orig 2011-08-29 11:48:23.0 +0200
--- gcc/expr.c  2011-08-29 12:58:59.0 +0200
*** do_store_flag (sepops ops, rtx target, e
*** 10309,10314 
--- 10309,10325 
STRIP_NOPS (arg0);
STRIP_NOPS (arg1);

+   /* For vector typed comparisons emit code to generate the desired
+  all-ones or all-zeros mask.  Conveniently use the VEC_COND_EXPR
+  expander for this.  */
+   if (TREE_CODE (ops->type) == VECTOR_TYPE)
+ {
+   tree ifexp = build2 (ops->code, ops->type, arg0, arg1);
+   tree if_true = constant_boolean_node (true, ops->type);
+   tree if_false = constant_boolean_node (false, ops->type);
+   return expand_vec_cond_expr (ops->type, ifexp, if_true,
if_false, target);
+ }
+
/* Get the rtx comparison code to use.  We know that EXP is a comparison

as I said multiple times.

>       * c-typeck.c (build_binary_op): Typecheck vector comparisons.
>       (c_objc_common_truthvalue_conversion): Adjust.
>       * tree-vect-generic.c (do_compare): Helper function.
>       (expand_vector_comparison): Check if hardware supports
>       vector comparison of the given type or expand vector
>       piecewise.
>       (expand_vector_operation): Treat comparison as binary
>       operation of vector type.
>       (expand_vector_operations_1): Adjust.
>       * tree-cfg.c (verify_gimple_comparison): Adjust.

The tree-cfg.c change has already been done.

Richard.

>
>       gcc/config/i386
>       * i386.c (ix86_expand_sse_movcc): Consider a case when
>       vcond operators are {-1,..} and {0,..}.
>
>       gcc/doc
>       * extend.texi: Adjust.
>
>       gcc/testsuite
>       * gcc.c-torture/execute/vector-compare-1.c: New test.
>       * gcc.c-torture/execute/vector-compare-2.c: New test.
>       * gcc.dg/vector-compare-1.c: New test.
>       * gcc.dg/vector-compare-2.c: New test.
>
> bootstrapped and tested on x86_64-unknown-linux-gnu.
>
>
> Thanks,
> Artem.
>


Re: Vector Comparison patch

2011-09-06 Thread Artem Shinkarov
Here is a new version of the patch which considers the changes from
2011-09-02  Richard Guenther


ChangeLog

20011-09-06 Artjoms Sinkarovs 

   gcc/
   * fold-const.c (constant_boolean_node): Adjust the meaning
   of boolean for vector types: true = {-1,..}, false = {0,..}.
   (fold_unary_loc): Avoid conversion of vector comparison to
   boolean type.
   * expr.c (expand_expr_real_2): Expand vector comparison by
   building an appropriate VEC_COND_EXPR.
   * c-typeck.c (build_binary_op): Typecheck vector comparisons.
   (c_objc_common_truthvalue_conversion): Adjust.
   * tree-vect-generic.c (do_compare): Helper function.
   (expand_vector_comparison): Check if hardware supports
   vector comparison of the given type or expand vector
   piecewise.
   (expand_vector_operation): Treat comparison as binary
   operation of vector type.
   (expand_vector_operations_1): Adjust.
   * tree-cfg.c (verify_gimple_comparison): Adjust.

   gcc/config/i386
   * i386.c (ix86_expand_sse_movcc): Consider a case when
   vcond operators are {-1,..} and {0,..}.

   gcc/doc
   * extend.texi: Adjust.

   gcc/testsuite
   * gcc.c-torture/execute/vector-compare-1.c: New test.
   * gcc.c-torture/execute/vector-compare-2.c: New test.
   * gcc.dg/vector-compare-1.c: New test.
   * gcc.dg/vector-compare-2.c: New test.

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


Thanks,
Artem.
Index: gcc/doc/extend.texi
===
--- gcc/doc/extend.texi (revision 178579)
+++ gcc/doc/extend.texi (working copy)
@@ -6561,6 +6561,29 @@ invoke undefined behavior at runtime.  W
 accesses for vector subscription can be enabled with
 @option{-Warray-bounds}.
 
+In GNU C vector comparison is supported within standard comparison
+operators: @code{==, !=, <, <=, >, >=}. Comparison operands can be
+vector expressions of integer-type or real-type. Comparison between
+integer-type vectors and real-type vectors are not supported.  The
+result of the comparison is a vector of the same width and number of
+elements as the comparison operands with a signed integral element
+type.
+
+Vectors are compared element-wise producing 0 when comparison is false
+and -1 (constant of the appropriate type where all bits are set)
+otherwise. Consider the following example.
+
+@smallexample
+typedef int v4si __attribute__ ((vector_size (16)));
+
+v4si a = @{1,2,3,4@};
+v4si b = @{3,2,1,4@};
+v4si c;
+
+c = a >  b; /* The result would be @{0, 0,-1, 0@}  */
+c = a == b; /* The result would be @{0,-1, 0,-1@}  */
+@end smallexample
+
 You can declare variables and use them in function calls and returns, as
 well as in assignments and some casts.  You can specify a vector type as
 a return type for a function.  Vector types can also be used as function
Index: gcc/fold-const.c
===
--- gcc/fold-const.c(revision 178579)
+++ gcc/fold-const.c(working copy)
@@ -5934,7 +5934,15 @@ extract_muldiv_1 (tree t, tree c, enum t
 tree
 constant_boolean_node (bool value, tree type)
 {
-  if (type == integer_type_node)
+  if (TREE_CODE (type) == VECTOR_TYPE)
+{
+  tree tval;
+  
+  gcc_assert (TREE_CODE (TREE_TYPE (type)) == INTEGER_TYPE);
+  tval = build_int_cst (TREE_TYPE (type), value ? -1 : 0);
+  return build_vector_from_val (type, tval);
+}
+  else if (type == integer_type_node)
 return value ? integer_one_node : integer_zero_node;
   else if (type == boolean_type_node)
 return value ? boolean_true_node : boolean_false_node;
@@ -7670,6 +7678,16 @@ fold_unary_loc (location_t loc, enum tre
return build2_loc (loc, TREE_CODE (op0), type,
   TREE_OPERAND (op0, 0),
   TREE_OPERAND (op0, 1));
+ else if (TREE_CODE (type) == VECTOR_TYPE)
+   {
+ tree el_type = TREE_TYPE (type);
+ tree op_el_type = TREE_TYPE (TREE_TYPE (op0));
+
+ if (el_type == op_el_type)
+   return op0;
+ else
+   build1_loc (loc, VIEW_CONVERT_EXPR, type, op0);
+   }
  else if (!INTEGRAL_TYPE_P (type))
return build3_loc (loc, COND_EXPR, type, op0,
   constant_boolean_node (true, type),
Index: gcc/testsuite/gcc.c-torture/execute/vector-compare-1.c
===
--- gcc/testsuite/gcc.c-torture/execute/vector-compare-1.c  (revision 0)
+++ gcc/testsuite/gcc.c-torture/execute/vector-compare-1.c  (revision 0)
@@ -0,0 +1,123 @@
+#define vector(elcount, type)  \
+__attribute__((vector_size((elcount)*sizeof(type type
+
+#define check_compare(count, res, i0, i1, op, fmt) \
+do { \
+int __i; \
+for (__i = 0; __i < count; __i ++) { \
+  if ((res)[__i] != ((i0)[__i] op (i1)[__i]

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

2011-09-06 Thread Iyer, Balaji V
I fixed all the changed you have requested. Here is an updated patch.

Thanks,

Balaji V. Iyer.


-Original Message-
From: H.J. Lu [mailto:hjl.to...@gmail.com] 
Sent: Tuesday, September 06, 2011 10:41 AM
To: Iyer, Balaji V
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [Patch][Cilkplus branch] Adding include directory path to 
testsuite script

On Tue, Sep 6, 2011 at 7:30 AM, Iyer, Balaji V  wrote:
> Attached, please find a patch with the modifications you have suggested 
> (adding the info in Changelog.cilk).

Please remove the extra blank line in ChangLog.  ChangeLog should simply say 
what you did, not why.

H.J.

> Sorry for the mistake.
>
> Thanks,
>
> Balaji V. Iyer.
>
>
> -Original Message-
> From: H.J. Lu [mailto:hjl.to...@gmail.com]
> Sent: Tuesday, September 06, 2011 10:22 AM
> To: Iyer, Balaji V
> Cc: gcc-patches@gcc.gnu.org
> Subject: Re: [Patch][Cilkplus branch] Adding include directory path to 
> testsuite script
>
> On Mon, Sep 5, 2011 at 9:52 PM, Iyer, Balaji V  
> wrote:
>> 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,
>>
>
> ChangeLog entries are missing.
>
> --
> H.J.
>



--
H.J.
diff --git a/gcc/testsuite/ChangeLog.cilk b/gcc/testsuite/ChangeLog.cilk
index a311052..b018232 100644
--- a/gcc/testsuite/ChangeLog.cilk
+++ b/gcc/testsuite/ChangeLog.cilk
@@ -1,3 +1,9 @@
+2011-09-05  Balaji V. Iyer. 
+
+   * gcc.dg/cilk-plus/cilk_plus.exp: Added -I 
+   $(src_dir)../../libcilkrts/include.  Also removed -fsyntax-only
+   * g++.dg/cilk-plus/cilk_plus.exp: Added -I 
+   $(src_dir)../../libcilkrts/include. Also removed -fsyntax-only
 
 2011-08-15  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][Cilkplus branch] Adding include directory path to testsuite script

2011-09-06 Thread H.J. Lu
On Tue, Sep 6, 2011 at 7:30 AM, Iyer, Balaji V  wrote:
> Attached, please find a patch with the modifications you have suggested 
> (adding the info in Changelog.cilk).

Please remove the extra blank line in ChangLog.  ChangeLog
should simply say what you did, not why.

H.J.

> Sorry for the mistake.
>
> Thanks,
>
> Balaji V. Iyer.
>
>
> -Original Message-
> From: H.J. Lu [mailto:hjl.to...@gmail.com]
> Sent: Tuesday, September 06, 2011 10:22 AM
> To: Iyer, Balaji V
> Cc: gcc-patches@gcc.gnu.org
> Subject: Re: [Patch][Cilkplus branch] Adding include directory path to 
> testsuite script
>
> On Mon, Sep 5, 2011 at 9:52 PM, Iyer, Balaji V  
> wrote:
>> 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,
>>
>
> ChangeLog entries are missing.
>
> --
> H.J.
>



-- 
H.J.


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

2011-09-06 Thread Martin Jambor
Hi,

On Mon, Sep 05, 2011 at 09:24:36AM +0200, Jan Hubicka wrote:
> > 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?
> 

Unifying them (especially BASE_BINFOs) in a way that we end up with an
appropriate BINFO attached to the prevailing type is not trivial and I
really would like to avoid writing that.

On the other hand, we basically use BINFOs as a mapping from the
encapsulating type and offset into virtual table expressions and so
what we can do is stream the encapsulating type and offset in jump
functions and at the WPA stage use the two to get the BINFO (now
unique because of type unification) and work with that.

So I decided to implement the above and not to commit this patch
(I'd only consider it if I did not manage to have the proper solution
ready by the end of stage1).

Thanks,

Martin



> 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][Cilkplus branch] Adding include directory path to testsuite script

2011-09-06 Thread Iyer, Balaji V
Attached, please find a patch with the modifications you have suggested (adding 
the info in Changelog.cilk).

Sorry for the mistake.

Thanks,

Balaji V. Iyer.


-Original Message-
From: H.J. Lu [mailto:hjl.to...@gmail.com] 
Sent: Tuesday, September 06, 2011 10:22 AM
To: Iyer, Balaji V
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [Patch][Cilkplus branch] Adding include directory path to 
testsuite script

On Mon, Sep 5, 2011 at 9:52 PM, Iyer, Balaji V  wrote:
> 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,
>

ChangeLog entries are missing.

-- 
H.J.
diff --git a/gcc/testsuite/ChangeLog.cilk b/gcc/testsuite/ChangeLog.cilk
index a311052..cc2a973 100644
--- a/gcc/testsuite/ChangeLog.cilk
+++ b/gcc/testsuite/ChangeLog.cilk
@@ -1,3 +1,12 @@
+2011-09-05  Balaji V. Iyer. 
+
+   * gcc.dg/cilk-plus/cilk_plus.exp: Added -I 
+   $(src_dir)../../libcilkrts/include so that the compiler can find cilk.h
+   and cilk_api.h file correctly. Also removed -fsyntax-only
+   * g++.dg/cilk-plus/cilk_plus.exp: Added -I 
+   $(src_dir)../../libcilkrts/include so that the compiler can find cilk.h
+   and cilk_api.h file correctly. Also removed -fsyntax-only
+
 
 2011-08-15  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][Cilkplus branch] Adding include directory path to testsuite script

2011-09-06 Thread H.J. Lu
On Mon, Sep 5, 2011 at 9:52 PM, Iyer, Balaji V  wrote:
> 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,
>

ChangeLog entries are missing.

-- 
H.J.


[PATCH ARM] Fix PR50099

2011-09-06 Thread Ramana Radhakrishnan
Hi,

PR target/50099 is a case where we are using the wrong predicate for
the sign_extend from QI to DImode values. ldrsb has a lower range than
the other ldrb instructions in ARM state and hence one has to be
careful about generating the right addresses when splitting it.

Attached is a patch to fix this. I will commit this if there are no
regressions. A backport to 4.6 branch will be done after suitable
regression testing.

cheers
Ramana


2011-09-06  Ramana Radhakrishnan  

PR target/50099
* config/arm/iterators.md (qhs_zextenddi_cstr): New.
(qhs_zextenddi_op): New.
* config/arm/arm.md ("zero_extenddi2"): Use them.
* config/arm/predicates.md ("arm_extendqisi_mem_op"):
Distinguish between ARM and Thumb2 states.

PR target/50099
* gcc.target/arm/pr50099.c: New test.
commit 9c268f1a74578ae082ea52dfcc655804b8319190
Author: Ramana Radhakrishnan 
Date:   Tue Sep 6 15:14:14 2011 +0100

Fix PR target/50099

diff --git a/gcc/config/arm/arm.md b/gcc/config/arm/arm.md
index 40341bd..388254f 100644
--- a/gcc/config/arm/arm.md
+++ b/gcc/config/arm/arm.md
@@ -4163,8 +4163,8 @@
 
 (define_insn "zero_extenddi2"
   [(set (match_operand:DI 0 "s_register_operand" "=r")
-(zero_extend:DI (match_operand:QHSI 1 ""
-   "")))]
+(zero_extend:DI (match_operand:QHSI 1 ""
+   "")))]
   "TARGET_32BIT "
   "#"
   [(set_attr "length" "8")
diff --git a/gcc/config/arm/iterators.md b/gcc/config/arm/iterators.md
index 219918c..da1f7af 100644
--- a/gcc/config/arm/iterators.md
+++ b/gcc/config/arm/iterators.md
@@ -390,10 +390,14 @@
 (define_mode_attr qhs_zextenddi_cond [(SI "") (HI "&& arm_arch6") (QI "")])
 (define_mode_attr qhs_sextenddi_cond [(SI "") (HI "&& arm_arch6")
  (QI "&& arm_arch6")])
-(define_mode_attr qhs_extenddi_op [(SI "s_register_operand")
+(define_mode_attr qhs_zextenddi_op [(SI "s_register_operand")
   (HI "nonimmediate_operand")
   (QI "nonimmediate_operand")])
-(define_mode_attr qhs_extenddi_cstr [(SI "r") (HI "rm") (QI "rm")])
+(define_mode_attr qhs_extenddi_op [(SI "s_register_operand")
+  (HI "nonimmediate_operand")
+  (QI "arm_reg_or_extendqisi_mem_op")])
+(define_mode_attr qhs_extenddi_cstr [(SI "r") (HI "rm") (QI "rUq")])
+(define_mode_attr qhs_zextenddi_cstr [(SI "r") (HI "rm") (QI "rm")])
 
 ;; Mode attributes used for fixed-point support.
 (define_mode_attr qaddsub_suf [(V4UQQ "8") (V2UHQ "16") (UQQ "8") (UHQ "16")
diff --git a/gcc/config/arm/predicates.md b/gcc/config/arm/predicates.md
index cfe8d33..50c1b43 100644
--- a/gcc/config/arm/predicates.md
+++ b/gcc/config/arm/predicates.md
@@ -296,8 +296,11 @@
 
 (define_special_predicate "arm_extendqisi_mem_op"
   (and (match_operand 0 "memory_operand")
-   (match_test "arm_legitimate_address_outer_p (mode, XEXP (op, 0),
-   SIGN_EXTEND, 0)")))
+   (match_test "TARGET_ARM ? arm_legitimate_address_outer_p (mode,
+ XEXP (op, 0),
+SIGN_EXTEND,
+0)
+   : memory_address_p (QImode, XEXP (op, 0))")))
 
 (define_special_predicate "arm_reg_or_extendqisi_mem_op"
   (ior (match_operand 0 "arm_extendqisi_mem_op")
diff --git a/gcc/testsuite/gcc.target/arm/pr50099.c 
b/gcc/testsuite/gcc.target/arm/pr50099.c
new file mode 100644
index 000..e767423
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arm/pr50099.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+
+typedef signed char int8_t ;
+typedef signed short int16_t;
+typedef signed long int32_t;
+typedef signed long long int64_t;
+
+int64_t foo (int8_t * arg)
+{
+  int64_t temp_1;
+
+  temp_1 = arg[256]; // index must be > 255 to ice!
+  return temp_1;
+}


Re: [PATCH][ARM] -m{cpu,tune,arch}=native

2011-09-06 Thread Andrew Stubbs
This update adds many more "magic numbers" for various ARM CPUs, and 
also ensures that the implementer is ARM (as opposed to Marvell, etc.). 
The list is far from comprehensive, but it should cover many (but by no 
means all) of the cores in current use and it would not be hard to add 
support for other implementers and CPU names in future.


It has been suggested that this patch should use auxv rather than 
/proc/cpuinfo. Does anybody here have any insight/preferences?


Is the patch OK?

Andrew
2011-08-27  Andrew Stubbs  

	gcc/
	* config.host (arm*-*-linux*): Add driver-arm.o and x-arm.
	* config/arm/arm.opt: Add 'native' processor_type and
	arm_arch enum values.
	* config/arm/arm.h (host_detect_local_cpu): New prototype.
	(EXTRA_SPEC_FUNCTIONS): New define.
	(MCPU_MTUNE_NATIVE_SPECS): New define.
	(DRIVER_SELF_SPECS): New define.
	* config/arm/driver-arm.c: New file.
	* config/arm/x-arm: New file.
	* doc/invoke.texi (ARM Options): Document -mcpu=native,
	-mtune=native and -march=native.

--- a/gcc/config.host
+++ b/gcc/config.host
@@ -100,6 +100,14 @@ case ${host} in
 esac
 
 case ${host} in
+  arm*-*-linux*)
+case ${target} in
+  arm*-*-*)
+	host_extra_gcc_objs="driver-arm.o"
+	host_xmake_file="${host_xmake_file} arm/x-arm"
+	;;
+esac
+;;
   alpha*-*-linux* | alpha*-dec-osf*)
 case ${target} in
   alpha*-*-linux* | alpha*-dec-osf*)
--- a/gcc/config/arm/arm.h
+++ b/gcc/config/arm/arm.h
@@ -2223,4 +2223,21 @@ extern int making_const_table;
instruction.  */
 #define MAX_LDM_STM_OPS 4
 
+/* -mcpu=native handling only makes sense with compiler running on
+   an ARM chip.  */
+#if defined(__arm__)
+extern const char *host_detect_local_cpu (int argc, const char **argv);
+# define EXTRA_SPEC_FUNCTIONS		\
+  { "local_cpu_detect", host_detect_local_cpu },
+
+# define MCPU_MTUNE_NATIVE_SPECS	\
+   " %{march=native:%http://www.gnu.org/licenses/>.  */
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "tm.h"
+
+static struct {
+  const char *part_no;
+  const char *arch_name;
+  const char *cpu_name;
+} cpu_table[] = {
+{"0x926", "armv5te", "arm926ej-s"},
+{"0xa26", "armv5te", "arm1026ej-s"},
+{"0xb02", "armv6k", "mpcore"},
+{"0xb36", "armv6j", "arm1136j-s"},
+{"0xb56", "armv6t2", "arm1156t2-s"},
+{"0xb76", "armv6zk", "arm1176jz-s"},
+{"0xc05", "armv7-a", "cortex-a5"},
+{"0xc08", "armv7-a", "cortex-a8"},
+{"0xc09", "armv7-a", "cortex-a9"},
+{"0xc0f", "armv7-a", "cortex-a15"},
+{"0xc14", "armv7-r", "cortex-r4"},
+{"0xc15", "armv7-r", "cortex-r5"},
+{"0xc20", "armv6-m", "cortex-m0"},
+{"0xc21", "armv6-m", "cortex-m1"},
+{"0xc23", "armv7-m", "cortex-m3"},
+{"0xc24", "armv7e-m", "cortex-m4"},
+{NULL, NULL, NULL}
+};
+
+/* This will be called by the spec parser in gcc.c when it sees
+   a %:local_cpu_detect(args) construct.  Currently it will be called
+   with either "arch", "cpu" or "tune" as argument depending on if
+   -march=native, -mcpu=native or -mtune=native is to be substituted.
+
+   It returns a string containing new command line parameters to be
+   put at the place of the above two options, depending on what CPU
+   this is executed.  E.g. "-march=armv7-a" on a Cortex-A8 for
+   -march=native.  If the routine can't detect a known processor,
+   the -march or -mtune option is discarded.
+
+   ARGC and ARGV are set depending on the actual arguments given
+   in the spec.  */
+const char *
+host_detect_local_cpu (int argc, const char **argv)
+{
+  const char *val = NULL;
+  char buf[128];
+  FILE *f;
+  bool arch;
+
+  if (argc < 1)
+return NULL;
+
+  arch = strcmp (argv[0], "arch") == 0;
+  if (!arch && strcmp (argv[0], "cpu") != 0 && strcmp (argv[0], "tune"))
+return NULL;
+
+  f = fopen ("/proc/cpuinfo", "r");
+  if (f == NULL)
+return NULL;
+
+  while (fgets (buf, sizeof (buf), f) != NULL)
+{
+  /* Ensure that CPU implementer is ARM (0x41).  */
+  if (strncmp (buf, "CPU implementer", sizeof ("CPU implementer") - 1) == 0
+	  && strstr (buf, "0x41") == NULL)
+	return NULL;
+
+  /* Detect arch/cpu.  */
+  if (strncmp (buf, "CPU part", sizeof ("CPU part") - 1) == 0)
+	{
+	  int i;
+	  for (i = 0; cpu_table[i].part_no != NULL; i++)
+	if (strstr (buf, cpu_table[i].part_no) != NULL)
+	  {
+		val = arch ? cpu_table[i].arch_name : cpu_table[i].cpu_name;
+		break;
+	  }
+	  break;
+	}
+}
+
+  fclose (f);
+
+  if (val == NULL)
+return NULL;
+
+  return concat ("-m", argv[0], "=", val, NULL);
+}
--- /dev/null
+++ b/gcc/config/arm/x-arm
@@ -0,0 +1,3 @@
+driver-arm.o: $(srcdir)/config/arm/driver-arm.c \
+  $(CONFIG_H) $(SYSTEM_H)
+	$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $<
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -10319,6 +10319,11 @@ assembly code.  Permissible names are: @samp{arm2}, @samp{arm250},
 @samp{fa526}, @samp{fa626},
 @samp{fa606te}, @samp{fa626te}, @samp{fmp626}, @samp{fa726te}.
 
+@opt

[PATCH] Fix PR48149

2011-09-06 Thread Richard Guenther

This makes SCCVN combine COMPLEX_EXPR arguments with its operands,
allowing to optimize piecewise pass-thru of a complex value.

The meat of the patch is the tuplification fix

! && TREE_CODE (gimple_assign_rhs1 (def_stmt)) == SSA_NAME)
---
! && TREE_CODE (TREE_OPERAND (gimple_assign_rhs1 (def_stmt),
! 0)) == SSA_NAME)

and special-casing of COMPLEX_EXPR in simplify_binary_expression.
The rest is some TLC in the functions.

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

Richard.

2011-09-06  Richard Guenther  

PR tree-optimization/48149
* tree-ssa-sccvn.c (vn_get_expr_for): Simplify.  Fix tuplification bug.
(vn_valueize): Move earlier.
(valueize_expr): Use vn_valueize.
(simplify_binary_expression): Simplify, also combine COMPLEX_EXPR
operands.
(simplify_unary_expression): Simplify.

* gcc.dg/tree-ssa/ssa-fre-32.c: New testcase.

Index: trunk/gcc/tree-ssa-sccvn.c
===
*** trunk.orig/gcc/tree-ssa-sccvn.c 2011-09-06 14:58:32.0 +0200
--- trunk/gcc/tree-ssa-sccvn.c  2011-09-06 14:58:53.0 +0200
*** vn_get_expr_for (tree name)
*** 217,222 
--- 217,223 
vn_ssa_aux_t vn = VN_INFO (name);
gimple def_stmt;
tree expr = NULL_TREE;
+   enum tree_code code;
  
if (vn->valnum == VN_TOP)
  return name;
*** vn_get_expr_for (tree name)
*** 241,277 
/* Otherwise use the defining statement to build the expression.  */
def_stmt = SSA_NAME_DEF_STMT (vn->valnum);
  
!   /* If the value number is a default-definition or a PHI result
!  use it directly.  */
!   if (gimple_nop_p (def_stmt)
!   || gimple_code (def_stmt) == GIMPLE_PHI)
! return vn->valnum;
! 
if (!is_gimple_assign (def_stmt))
  return vn->valnum;
  
/* FIXME tuples.  This is incomplete and likely will miss some
   simplifications.  */
!   switch (TREE_CODE_CLASS (gimple_assign_rhs_code (def_stmt)))
  {
  case tcc_reference:
!   if ((gimple_assign_rhs_code (def_stmt) == VIEW_CONVERT_EXPR
!  || gimple_assign_rhs_code (def_stmt) == REALPART_EXPR
!  || gimple_assign_rhs_code (def_stmt) == IMAGPART_EXPR)
! && TREE_CODE (gimple_assign_rhs1 (def_stmt)) == SSA_NAME)
!   expr = fold_build1 (gimple_assign_rhs_code (def_stmt),
gimple_expr_type (def_stmt),
TREE_OPERAND (gimple_assign_rhs1 (def_stmt), 0));
break;
  
  case tcc_unary:
!   expr = fold_build1 (gimple_assign_rhs_code (def_stmt),
  gimple_expr_type (def_stmt),
  gimple_assign_rhs1 (def_stmt));
break;
  
  case tcc_binary:
!   expr = fold_build2 (gimple_assign_rhs_code (def_stmt),
  gimple_expr_type (def_stmt),
  gimple_assign_rhs1 (def_stmt),
  gimple_assign_rhs2 (def_stmt));
--- 242,275 
/* Otherwise use the defining statement to build the expression.  */
def_stmt = SSA_NAME_DEF_STMT (vn->valnum);
  
!   /* If the value number is not an assignment use it directly.  */
if (!is_gimple_assign (def_stmt))
  return vn->valnum;
  
/* FIXME tuples.  This is incomplete and likely will miss some
   simplifications.  */
!   code = gimple_assign_rhs_code (def_stmt);
!   switch (TREE_CODE_CLASS (code))
  {
  case tcc_reference:
!   if ((code == REALPART_EXPR
!  || code == IMAGPART_EXPR
!  || code == VIEW_CONVERT_EXPR)
! && TREE_CODE (TREE_OPERAND (gimple_assign_rhs1 (def_stmt),
! 0)) == SSA_NAME)
!   expr = fold_build1 (code,
gimple_expr_type (def_stmt),
TREE_OPERAND (gimple_assign_rhs1 (def_stmt), 0));
break;
  
  case tcc_unary:
!   expr = fold_build1 (code,
  gimple_expr_type (def_stmt),
  gimple_assign_rhs1 (def_stmt));
break;
  
  case tcc_binary:
!   expr = fold_build2 (code,
  gimple_expr_type (def_stmt),
  gimple_assign_rhs1 (def_stmt),
  gimple_assign_rhs2 (def_stmt));
*** stmt_has_constants (gimple stmt)
*** 2822,2827 
--- 2820,2838 
return false;
  }
  
+ /* Valueize NAME if it is an SSA name, otherwise just return it.  */
+ 
+ static inline tree
+ vn_valueize (tree name)
+ {
+   if (TREE_CODE (name) == SSA_NAME)
+ {
+   tree tem = SSA_VAL (name);
+   return tem == VN_TOP ? name : tem;
+ }
+   return name;
+ }
+ 
  /* Replace SSA_NAMES in expr with their value numbers, and return the
 result.
 This is performed in place. */
*** valueize_expr (tree expr)
*** 2831,2851 
  {
switch (TREE_CODE_CLASS (TREE_

[Ada] Fixes to No_Implementation_Units restriction

2011-09-06 Thread Arnaud Charlet
This patch fixes some errors in the previous initial checkin of this
new feature.

 1. package noimpunit4 is end;

 1. pragma Restrictions (No_Implementation_Units);
 2. with noimpunit4;
 3. with GNAT.IO;
 |
>>> violation of restriction
"no_implementation_units" at line 1

 4. package noimpunit3 is end;

Prior to this fix, the line with'ing noimpunit4 was flagged (along
with all user defined units), and the with of the gnat unit was not
flagged and it should be (even if perhaps this is not 100% legally
conforming).

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

2011-09-06  Robert Dewar  

* sem_ch10.adb, impunit.ads, impunit.adb (Not_Impl_Defined_Unit): New
name for Is_RM_Defined_Unit. Also several fixes to this unit.

Index: impunit.adb
===
--- impunit.adb (revision 178594)
+++ impunit.adb (working copy)
@@ -826,11 +826,11 @@
  return False;
end Is_Known_Unit;
 
-   
-   -- Is_RM_Defined_Unit --
-   
+   ---
+   -- Not_Impl_Defined_Unit --
+   ---
 
-   function Is_RM_Defined_Unit (U : Unit_Number_Type) return Boolean is
+   function Not_Impl_Defined_Unit (U : Unit_Number_Type) return Boolean is
   Fname : constant File_Name_Type := Unit_File_Name (U);
 
begin
@@ -848,21 +848,22 @@
  return True;
   end if;
 
-  --  If length of file name is greater than 12, not RM-defined. The value
-  --  12 here is an 8 char name with extension .ads.
+  --  If length of file name is greater than 12, then it's a user unit
+  --  and not a GNAT implementation defined unit.
 
   if Name_Len > 12 then
- return False;
+ return True;
   end if;
 
-  --  Not RM-defined if length of name greater than 12 (12 is 8 characters
-  --  plus 4 for ".ads" appended at the end).
+  --  Implementation defined if unit in the gnat hierarchy
 
-  if Length_Of_Name (Fname) > 12 then
+  if (Name_Len = 8 and then Name_Buffer (1 .. 8) = "gnat.ads")
+or else (Name_Len > 2 and then Name_Buffer (1 .. 2) = "g-")
+  then
  return False;
   end if;
 
-  --  Not RM defined if file name does not start with a- s- i-
+  --  Not implementation defined if file name does not start with a- s- i-
 
   if Name_Len < 3
 or else Name_Buffer (2) /= '-'
@@ -872,14 +873,14 @@
and then
  Name_Buffer (1) /= 's')
   then
- return False;
+ return True;
   end if;
 
-  --  Not RM defined if file name does not end in .ads. This can happen
+  --  Not impl-defined if file name does not end in .ads. This can happen
   --  when non-standard file names are being used.
 
   if Name_Buffer (Name_Len - 3 .. Name_Len) /= ".ads" then
- return False;
+ return True;
   end if;
 
   --  Otherwise normalize file name to 8 characters
@@ -891,7 +892,8 @@
   end loop;
 
   --  Check our lists of names, if we find a match, return corresponding
-  --  indication of whether the file is RM defined.
+  --  indication of whether the file is RM defined, respecting the RM
+  --  version in which it is defined.
 
   for J in Non_Imp_File_Names_95'Range loop
  if Name_Buffer (1 .. 8) = Non_Imp_File_Names_95 (J).Fname then
@@ -913,9 +915,11 @@
  end if;
   end loop;
 
-  --  If no match in any of the lists, not RM defined
+  --  If unit is in System, Ada or Interfaces hierarchies and did not match
+  --  any entry in the list, means it is an internal implementation defined
+  --  unit which the restriction should definition forbid.
 
-  return False;
-   end Is_RM_Defined_Unit;
+  return True;
+   end Not_Impl_Defined_Unit;
 
 end Impunit;
Index: impunit.ads
===
--- impunit.ads (revision 178594)
+++ impunit.ads (working copy)
@@ -72,10 +72,14 @@
--  the known library units, and if so, returns True. If the name does not
--  match any known library unit, False is returned.
 
-   function Is_RM_Defined_Unit (U : Unit_Number_Type) return Boolean;
-   --  This function returns True if U represents a unit that is defined in
-   --  the RM, as defined by the No_Implementation_Units restriction rules.
-   --  It is used to implement this restriction, so if False is returned, it
-   --  means that with'ing the unit violates the restriction.
+   function Not_Impl_Defined_Unit (U : Unit_Number_Type) return Boolean;
+   --  This function returns True if U represents a unit that is permitted by
+   --  the restriction No_Implementation_Units (i.e. a unit in the Ada, System,
+   --  and Interfaces hierarchies that is defined in the RM, or a user defined
+   --  unit. It returns False if U represents a unit that

Re: [Ada] Speed up build of gnatools

2011-09-06 Thread Robert Dewar

On 9/6/2011 7:14 AM, Duncan Sands wrote:


this means using as many processes as there are CPUs, right?  It
seems pretty dubious to me to use more processes than the user maybe
asked for.


We often find that the optimum number of processes is a little bit more
than the number of physical processes (not surprising when there is
mixed I/O computation going on.


For example I have to restrict the number of CPUs used when building
GCC to less than I have since otherwise my machine overheats and
turns itself off.


That seems a (pretty disastrous) engineering error in the design of
your machine. In a properly designed machine, extra fans should come
on to counteract the extra heating (that's certainly what happens on
my Toshiba R700 with is the new core i7-2620M with four cores.


Is there some way to get at the -j level the user passed to the
top-level make and use that?


I am pretty sure you can specify any -j value you like, but will
let Arno clarify that.


[PATCH] Make SCCVN handle vector CONSTRUCTORs

2011-09-06 Thread Richard Guenther

We currently lack support for vector CONSTRUCTORs in value-numbering
(yes, and vector component selection as well, but that's a different 
story...).

The following implements this by treating vector CONSTRUCTOR as nary
ops.  With quite some infrastructure adjustments to support
(sort-of arbitrary) sized narys instead of a maximum number of 4
ops as it is now.

Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.

Richard.

2011-09-06  Richard Guenther  

PR tree-optimization/48317
* tree-ssa-sccvn.h (struct vn_nary_op_s): Make op a true
trailing array.
(sizeof_vn_nary_op): New inline function.
(vn_nary_op_lookup_pieces): Adjust.
(vn_nary_op_insert_pieces): Likewise.
* tree-ssa-sccvn.c (vn_nary_op_eq): Also compare the length.
(init_vn_nary_op_from_pieces): Adjust signature.  Deal with
any number of operands.
(vn_nary_length_from_stmt): New function.
(init_vn_nary_op_from_stmt): Adjust for CONSTRUCTOR handling.
(vn_nary_op_lookup_pieces): Adjust signature and allocate properly
sized temporary.
(vn_nary_op_lookup): Likewise.
(vn_nary_op_lookup_stmt): Likewise.
(vn_nary_op_insert_into): Likewise.
(vn_nary_op_insert_stmt): Likewise.
(visit_use): Handle CONSTRUCTOR as nary.
* tree-ssa-pre.c (phi_translate_1): Adjust.
(create_expression_by_pieces): Likewise.
(compute_avail): Likewise.

* gcc.dg/tree-ssa/ssa-fre-31.c: New testcase.

Index: trunk/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-31.c
===
*** /dev/null   1970-01-01 00:00:00.0 +
--- trunk/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-31.c2011-09-06 
12:55:03.0 +0200
***
*** 0 
--- 1,46 
+ /* { dg-do compile } */
+ /* { dg-options "-O -fdump-tree-fre1-details" } */
+ 
+ typedef double d128 __attribute__((vector_size(16)));
+ typedef float f128 __attribute__((vector_size(16)));
+ typedef short s128 __attribute__((vector_size(16)));
+ typedef char c256 __attribute__((vector_size(32)));
+ 
+ d128 d;
+ f128 f;
+ s128 s;
+ c256 c;
+ 
+ void test1 (double x)
+ {
+   d = (d128){x + x, x + x};
+   d = (d128){x + x, x + x};
+ }
+ 
+ void test2 (float x)
+ {
+   f = (f128){x + x, x + x, x + x, x + x};
+   f = (f128){x + x, x + x, x + x, x + x};
+ }
+ 
+ void test3 (short x)
+ {
+   s = (s128){x + x, x + x, x + x, x + x, x + x, x + x, x + x, x + x};
+   s = (s128){x + x, x + x, x + x, x + x, x + x, x + x, x + x, x + x};
+ }
+ 
+ void test4 (unsigned char x)
+ {
+   c = (c256){x + x, x + x, x + x, x + x, x + x, x + x, x + x, x + x,
+   x + x, x + x, x + x, x + x, x + x, x + x, x + x, x + x,
+   x + x, x + x, x + x, x + x, x + x, x + x, x + x, x + x,
+   x + x, x + x, x + x, x + x, x + x, x + x, x + x, x + x};
+   c = (c256){x + x, x + x, x + x, x + x, x + x, x + x, x + x, x + x,
+   x + x, x + x, x + x, x + x, x + x, x + x, x + x, x + x,
+   x + x, x + x, x + x, x + x, x + x, x + x, x + x, x + x,
+   x + x, x + x, x + x, x + x, x + x, x + x, x + x, x + x};
+ }
+ 
+ /* { dg-final { scan-tree-dump-times "Replaced \{" 4 "fre1" } } */
+ /* { dg-final { scan-tree-dump-times "Deleted redundant store" 4 "fre1" } } */
+ /* { dg-final { cleanup-tree-dump "fre1" } } */
Index: trunk/gcc/tree-ssa-pre.c
===
*** trunk.orig/gcc/tree-ssa-pre.c   2011-09-06 12:28:12.0 +0200
--- trunk/gcc/tree-ssa-pre.c2011-09-06 13:32:35.0 +0200
*** phi_translate_1 (pre_expr expr, bitmap_s
*** 1443,1462 
unsigned int i;
bool changed = false;
vn_nary_op_t nary = PRE_EXPR_NARY (expr);
!   struct vn_nary_op_s newnary;
!   /* The NARY structure is only guaranteed to have been
!  allocated to the nary->length operands.  */
!   memcpy (&newnary, nary, (sizeof (struct vn_nary_op_s)
!- sizeof (tree) * (4 - nary->length)));
  
!   for (i = 0; i < newnary.length; i++)
  {
!   if (TREE_CODE (newnary.op[i]) != SSA_NAME)
  continue;
else
  {
  pre_expr leader, result;
!   unsigned int op_val_id = VN_INFO (newnary.op[i])->value_id;
leader = find_leader_in_sets (op_val_id, set1, set2);
  result = phi_translate (leader, set1, set2, pred, phiblock);
if (result && result != leader)
--- 1443,1460 
unsigned int i;
bool changed = false;
vn_nary_op_t nary = PRE_EXPR_NARY (expr);
!   vn_nary_op_t newnary = XALLOCAVAR (struct vn_nary_op_s,
!  sizeof_vn_nary_op (nary->length));
!   memcpy (newnary, nary, sizeof_vn_nary_op (nary->length));
  
!   for (i = 0; i < newnary->length; i++)
  {
!   if (TREE_CODE (newnary->op[i]) != S

[Ada] Implement new Ada 2012 restriction No_Implementation_Units

2011-09-06 Thread Arnaud Charlet
This patch implements the new restriction No_Implementation_Units, as
defined in AI 242. This restriction is also part of the new Ada 2012
profile No_Implementation_Extensions.

Here is a test of the new restriction (compiled with -gnatld7 -gnatj60)

 1. pragma Ada_2005;
 2. pragma Restrictions (No_Implementation_Units);
 3. with Ada.Command_Line.Remove; -- ERROR
 |
>>> violation of restriction
"No_Implementation_Units" at line 2

 4. with Ada.Iterator_Interfaces; -- ERROR
|
>>> violation of restriction
"No_Implementation_Units" at line 2

 5. with Ada.Wide_Wide_Text_IO.C_Streams; -- ERROR
  |
>>> violation of restriction
"No_Implementation_Units" at line 2

 6. with Ada.Directories; -- OK
 7. with Ada.Text_IO; -- OK
 8. with Ada; -- OK
 9. with Interfaces;  -- OK
10. with System;  -- OK
11. with GNAT;-- ERROR
 |
>>> violation of restriction
"No_Implementation_Units" at line 2

12. package NoImpUnits is
13. end NoImpUnits;

and here is the same test using the profile

 1. pragma Ada_2005;
 2. pragma Profile (No_Implementation_Extensions);
 3. with Ada.Command_Line.Remove; -- ERROR
 |
>>> violation of restriction
"No_Implementation_Units", from profile
"No_Implementation_Extensions" at line 2

 4. with Ada.Iterator_Interfaces; -- ERROR
|
>>> violation of restriction
"No_Implementation_Units", from profile
"No_Implementation_Extensions" at line 2

 5. with Ada.Wide_Wide_Text_IO.C_Streams; -- ERROR
  |
>>> violation of restriction
"No_Implementation_Units", from profile
"No_Implementation_Extensions" at line 2

 6. with Ada.Directories; -- OK
 7. with Ada.Text_IO; -- OK
 8. with Ada; -- OK
 9. with Interfaces;  -- OK
10. with System;  -- OK
11. with GNAT;-- ERROR
 |
>>> violation of restriction
"No_Implementation_Units", from profile
"No_Implementation_Extensions" at line 2

12. package NoImpUnits2 is
13. end NoImpUnits2;

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

2011-09-06  Robert Dewar  

* impunit.ads, impunit.adb (Is_RM_Defined_Unit): New function.
* s-rident.ads: New restriction No_Implementation_Units
(this restriction is also part of the profile
No_Implementation_Extensions)
* sem_ch10.adb (Analyze_With_Clause): Add check for
No_Implementation_Units restriction.

Index: impunit.adb
===
--- impunit.adb (revision 178593)
+++ impunit.adb (working copy)
@@ -29,6 +29,7 @@
 with Fname.UF; use Fname.UF;
 with Lib;  use Lib;
 with Namet;use Namet;
+with Opt;  use Opt;
 with Uname;use Uname;
 
 --  Note: this package body is used by GPS and GNATBench to supply a list of
@@ -37,8 +38,22 @@
 package body Impunit is
 
subtype File_Name_8 is String (1 .. 8);
-   type File_List is array (Nat range <>) of File_Name_8;
 
+   type File_Name_Record is record
+  Fname : File_Name_8;
+  --  8 character name of unit
+
+  RMdef : Boolean;
+  --  True if unit is RM defined. False for any unit that is implementation
+  --  defined (and thus not with'able in No_Implementation_Units mode).
+   end record;
+
+   type File_List is array (Nat range <>) of File_Name_Record;
+
+   T : constant Boolean := True;
+   F : constant Boolean := False;
+   --  Short hand for RM_Defined values in lists below
+
--
-- Ada 95 Units --
--
@@ -58,130 +73,133 @@
-- Ada Hierarchy Units from Ada-95 Reference Manual --
--
 
- "a-astaco",-- Ada.Asynchronous_Task_Control
- "a-calend",-- Ada.Calendar
- "a-chahan",-- Ada.Characters.Handling
- "a-charac",-- Ada.Characters
- "a-chlat1",-- Ada.Characters.Latin_1
- "a-comlin",-- Ada.Command_Line
- "a-decima",-- Ada.Decimal
- "a-direio",-- Ada.Direct_IO
- "a-dynpri",-- Ada.Dynamic_Priorities
- "a-except",-- Ada.Exceptions
- "a-finali",-- Ada.Finalization
- "a-flteio",-- Ada.Float_Text_IO
- "a-fwteio",-- Ada.Float_Wide_Text_IO
- "a-inteio",-- Ada.Integer_Text_IO
- "a-interr",-- Ada.Interrupts
- "a-intnam",-- Ada.Interrupts.Names
- "a-ioexce", 

[Ada] Freezing and Ada2012 expression functions

2011-09-06 Thread Arnaud Charlet
The body that is a rewriting of an expression function does not freeze previous
entities.

The following must compile quietly in Ada2012 mode:

---
package Ada12 is
type T is tagged null record;function Template (Self : T) return String 
is ("foo.thtml");

type T2 is new T with null record;
overriding function Template (Self : T2) return String is ("bar.thtml");

end Ada12;

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

2011-09-06  Ed Schonberg  

* sem_ch6.adb (Analyze_Subprogram_Body_Helper): The body that
is a rewriting of an expression function does not freeze previous
entities.

Index: sem_ch6.adb
===
--- sem_ch6.adb (revision 178567)
+++ sem_ch6.adb (working copy)
@@ -2346,7 +2346,12 @@
 --  expansion has generated an equivalent type that is used when
 --  elaborating the body.
 
-if No (Spec_Id) then
+--  An exception in the case of Ada2012, AI05-177: The bodies
+--  created for expression functions do not freeze.
+
+if No (Spec_Id)
+  and then Nkind (Original_Node (N)) /= N_Expression_Function
+then
Freeze_Before (N, Body_Id);
 
 elsif Nkind (Parent (N)) = N_Compilation_Unit then


RFA: MN10300: Add jump label to Lcc insn

2011-09-06 Thread Nick Clifton
Hi Jeff, Hi Alex,

  The MN10300 target is currently failing to build in the mainline FSF
  sources because of this error when creating libgcc:

gcc/libgcc2.c: In function '__popcountsi2':
gcc/libgcc2.c:834:1: internal compiler error: in create_trace_edges, at 
dwarf2cfi.c:2325

  This turns out to be because the code in create_trace_edges does not
  handle jumps inside parallel insns, like this:

(jump_insn 72 52 31 3 (parallel [
(set (pc)
(if_then_else (ne (reg:CC 51 EPSW)
(const_int 0 [0]))
(label_ref 29)
(pc)))
(unspec [
(const_int 1 [0x1])
] 9)
]) gcc/libgcc2.c:830 -1
 (insn_list:REG_LABEL_OPERAND 29 (nil)))

  I am not sure if create_trace_edges should handle this, but I felt
  that the easiest thing to do was to fix the MN10300 backend so that
  when it was creating this insn, it would also set the label on the
  parallel container.  That is what the patch below does and with this
  applied I can build the toolchain again.

  OK to apply, or is there a better way to fix the problem ?

Cheers
  Nick

gcc/ChangeLog
2011-09-06  Nick Clifton  

* config/mn10300/mn10300.c (mn10300_insert_setlb_lcc): Set the
jump label on the parallel part of the insn.

Index: gcc/config/mn10300/mn10300.c
===
--- gcc/config/mn10300/mn10300.c(revision 178566)
+++ gcc/config/mn10300/mn10300.c(working copy)
@@ -3150,6 +3150,7 @@
 
   lcc = emit_jump_insn_before (lcc, branch);
   mark_jump_label (XVECEXP (PATTERN (lcc), 0, 0), lcc, 0);
+  JUMP_LABEL (lcc) = label;
   DUMP ("Replacing branch insn...", branch);
   DUMP ("... with Lcc insn:", lcc);  
   delete_insn (branch);

   


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

2011-09-06 Thread Jakub Jelinek
Hi!

CALL_INSN_FUNCTION_USAGE contains for each (use (reg:M)) or (use (mem:M))
the mode of the promoted argument, not the original mode, which is needed
for RTL optimizations, but prepare_call_arguments would like to know
the original non-promoted argument mode (i.e. TYPE_MODE of the argument's
type).  While sometimes prepare_call_arguments can get at the tree type
of the callee, for e.g. indirect calls that information is simply not
available.  And without that information, e.g. if on a big-endian
64-bit hosts an argument is passed on the stack promoted from SImode to
DImode, we store the address of the whole 64-bit slot instead of adding
+4 to it to get at the 32-bit slot where the actual int argument is passed.

The following patch fixes it by not storing just one mode - the promoted
mode - in C_I_F_U, but also storing there the original mode as well.
The advantage of that is that various non-argument USEs in C_I_F_U will
no longer be tracked as DW_TAG_call_site_parameter - e.g. x86_64 %al
for var-arg functions which is passed the number of SSE arguments.
The original mode is stored in EXPR_LIST's mode.

I've adjusted just the single register arguments (which on various targets
includes even multi-word arguments, as long as the registers are consecutive
etc.) and memory slots, not sure what to do with multi-register arguments,
so I've left them with VOIDmode (this could be changed by adjusting
use_group_regs and/or use_regs).  We do a terribly bad job debug-info wise
for testcases like
struct S { long a, b; };
void baz (void);

__attribute__((noinline, noclone))
int foo (struct S s)
{
  long a = s.a;
  long b = s.b;
  baz ();
  return 2;
}

int bar (void)
{
  struct S s = { 1, 2 };
  foo (s);
  return 0;
}
on x86_64-linux anyway - var-tracking doesn't track those, RTL DSE removes
the argument stores (so debug_insns for e.g. a and b above reference
uninitialized memory) and DECL_RTL of the parameter is used too (so again,
the same uninitialized memory).  Maybe we could for small arguments (say up
to 4 or 8 words) attempt to track them by pieces during var-tracking, as
if SRA split them up, if their DECL_RTL isn't the memory slot in which they
have been passed.

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

2011-09-06  Jakub Jelinek  

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

--- gcc/calls.c.jj  2011-08-22 08:17:07.0 +0200
+++ gcc/calls.c 2011-09-05 19:47:47.0 +0200
@@ -1756,7 +1756,8 @@ load_register_parameters (struct arg_dat
  if (GET_CODE (reg) == PARALLEL)
use_group_regs (call_fusage, reg);
  else if (nregs == -1)
-   use_reg (call_fusage, reg);
+   use_reg_mode (call_fusage, reg,
+ TYPE_MODE (TREE_TYPE (args[i].tree_value)));
  else if (nregs > 0)
use_regs (call_fusage, REGNO (reg), nregs);
}
@@ -2815,10 +2816,10 @@ expand_call (tree exp, rtx target, int i
  }
 
  if (args[i].stack)
-   call_fusage = gen_rtx_EXPR_LIST (VOIDmode,
-gen_rtx_USE (VOIDmode,
- args[i].stack),
-call_fusage);
+   call_fusage
+ = gen_rtx_EXPR_LIST (TYPE_MODE (TREE_TYPE (args[i].tree_value)),
+  gen_rtx_USE (VOIDmode, args[i].stack),
+  call_fusage);
}
 
   /* If we have a parm that is passed in registers but not in memory
--- gcc/expr.h.jj   2011-07-27 23:25:36.0 +0200
+++ gcc/expr.h  2011-09-05 18:05:31.0 +0200
@@ -321,8 +321,16 @@ extern void emit_group_store (rtx, rtx, 
 /* Copy BLKmode object from a set of registers.  */
 extern rtx copy_blkmode_from_reg (rtx, rtx, tree);
 
+/* Mark REG as holding a parameter for the next CALL_INSN.
+   Mode is TYPE_MODE of the non-promoted parameter, or VOIDmode.  */
+extern void use_reg_mode (rtx *, rtx, enum machine_mode);
+
 /* Mark REG as holding a parameter for the next CALL_INSN.  */
-extern void use_reg (rtx *, rtx);
+static inline void
+use_reg (rtx *fusage, rtx reg)
+{
+  use_reg_mode (fusage, reg

Re: [PATCH Atom][PR middle-end/44382] Tree reassociation improvement

2011-09-06 Thread Ilya Enkovich
Hello,

2011/9/2 Uros Bizjak :
> I assume that you need to split tune attribute to int and FP part to
> handle reassociation for other targets, since Atom handles both in the
> same way.
>
> Please also describe function return value in the comment (and perhaps
> in documentation, too).
>
> OK with this addition.
>
> Thanks,
> Uros.
>

Here is patch with added comment for hook implementation. Is it OK?

Thanks,
Ilya
---
gcc/

2011-09-06  Enkovich Ilya  

PR middle-end/44382
* target.def (reassociation_width): New hook.

* doc/tm.texi.in (reassociation_width): Likewise.

* doc/tm.texi (reassociation_width): Likewise.

* doc/invoke.texi (tree-reassoc-width): New param documented.

* hooks.h (hook_int_uint_mode_1): New default hook.

* hooks.c (hook_int_uint_mode_1): Likewise.

* config/i386/i386.h (ix86_tune_indices): Add
X86_TUNE_REASSOC_INT_TO_PARALLEL and
X86_TUNE_REASSOC_FP_TO_PARALLEL.

(TARGET_REASSOC_INT_TO_PARALLEL): New.
(TARGET_REASSOC_FP_TO_PARALLEL): Likewise.

* config/i386/i386.c (initial_ix86_tune_features): Add
X86_TUNE_REASSOC_INT_TO_PARALLEL and
X86_TUNE_REASSOC_FP_TO_PARALLEL.

(ix86_reassociation_width) implementation of
new hook for i386 target.

* params.def (PARAM_TREE_REASSOC_WIDTH): New param added.

* tree-ssa-reassoc.c (get_required_cycles): New function.
(get_reassociation_width): Likewise.
(swap_ops_for_binary_stmt): Likewise.
(rewrite_expr_tree_parallel): Likewise.

(rewrite_expr_tree): Refactored. Part of code moved into
swap_ops_for_binary_stmt.

(reassociate_bb): Now checks reassociation width to be used
and call rewrite_expr_tree_parallel instead of rewrite_expr_tree
if needed.

gcc/testsuite/

2011-09-06  Enkovich Ilya  

* gcc.dg/tree-ssa/pr38533.c (dg-options): Added option
--param tree-reassoc-width=1.

* gcc.dg/tree-ssa/reassoc-24.c: New test.
* gcc.dg/tree-ssa/reassoc-25.c: Likewise.


PR44382.diff
Description: Binary data


[PATCH, 4.6] Revert fix for PR 49886

2011-09-06 Thread Martin Jambor
Hi,

I'm going to apply this after a quick c-only bootstrap and test on the
4.6 branch to revert my previous fix for PR 49886 because it causes PR
50295 (and probably also PR 50287 though I do not know whether that is
against trunk or 4.6 too).

I'm not reverting this on trunk because I know there is at least one
another patch depending on it (the IPA-CP fro unchangeable
signatures).  I'm going to look into ways to fix it there right now
(and Honza promised the same) and after it is done we'll backport the
correct fix here too.

The execution part of the testcase for PR 49886 is XFAILed by this
patch but that means it XPASSes with LTO.  This is the best I could do
in reasonable time though, it has taken me quite a lot of time
already.

Thanks,

Martin


2011-09-06  Martin Jambor  

Revert
2011-09-02  Martin Jambor  
PR middle-end/49886
* ipa-split.c (split_function): Do not skip any arguments if
can_change_signature is set or there are function type attributes.

testsuite/
* gcc.c-torture/execute/pr49886.c: Move to...
* gcc.dg/torture/pr49886.c: ...here. Xfail run test for -O2 and above.

Index: gcc/testsuite/gcc.c-torture/execute/pr49886.c
===
--- gcc/testsuite/gcc.c-torture/execute/pr49886.c   (revision 178572)
+++ gcc/testsuite/gcc.c-torture/execute/pr49886.c   (working copy)
@@ -1,100 +0,0 @@
-struct PMC {
-unsigned flags;
-};
-
-typedef struct Pcc_cell
-{
-struct PMC *p;
-long bla;
-long type;
-} Pcc_cell;
-
-int gi;
-int cond;
-
-extern void abort ();
-extern void never_ever(int interp, struct PMC *pmc)
-  __attribute__((noinline,noclone));
-
-void never_ever (int interp, struct PMC *pmc)
-{
-  abort ();
-}
-
-static void mark_cell(int * interp, Pcc_cell *c)
-  __attribute__((__nonnull__(1)));
-
-static void
-mark_cell(int * interp, Pcc_cell *c)
-{
-  if (!cond)
-return;
-
-  if (c && c->type == 4 && c->p
-  && !(c->p->flags & (1<<18)))
-never_ever(gi + 1, c->p);
-  if (c && c->type == 4 && c->p
-  && !(c->p->flags & (1<<17)))
-never_ever(gi + 2, c->p);
-  if (c && c->type == 4 && c->p
-  && !(c->p->flags & (1<<16)))
-never_ever(gi + 3, c->p);
-  if (c && c->type == 4 && c->p
-  && !(c->p->flags & (1<<15)))
-never_ever(gi + 4, c->p);
-  if (c && c->type == 4 && c->p
-  && !(c->p->flags & (1<<14)))
-never_ever(gi + 5, c->p);
-  if (c && c->type == 4 && c->p
-  && !(c->p->flags & (1<<13)))
-never_ever(gi + 6, c->p);
-  if (c && c->type == 4 && c->p
-  && !(c->p->flags & (1<<12)))
-never_ever(gi + 7, c->p);
-  if (c && c->type == 4 && c->p
-  && !(c->p->flags & (1<<11)))
-never_ever(gi + 8, c->p);
-  if (c && c->type == 4 && c->p
-  && !(c->p->flags & (1<<10)))
-never_ever(gi + 9, c->p);
-}
-
-static void
-foo(int * interp, Pcc_cell *c)
-{
-  mark_cell(interp, c);
-}
-
-static struct Pcc_cell *
-__attribute__((noinline,noclone))
-getnull(void)
-{
-  return (struct Pcc_cell *) 0;
-}
-
-
-int main()
-{
-  int i;
-
-  cond = 1;
-  for (i = 0; i < 100; i++)
-foo (&gi, getnull ());
-  return 0;
-}
-
-
-void
-bar_1 (int * interp, Pcc_cell *c)
-{
-  c->bla += 1;
-  mark_cell(interp, c);
-}
-
-void
-bar_2 (int * interp, Pcc_cell *c)
-{
-  c->bla += 2;
-  mark_cell(interp, c);
-}
-
Index: gcc/testsuite/gcc.dg/torture/pr49886.c
===
--- gcc/testsuite/gcc.dg/torture/pr49886.c  (revision 178572)
+++ gcc/testsuite/gcc.dg/torture/pr49886.c  (working copy)
@@ -1,3 +1,6 @@
+/* { dg-do run } */
+/* { dg-xfail-run-if "" { "*-*-*" } { "-O2" "-O3" "-Os" } } */
+
 struct PMC {
 unsigned flags;
 };
Index: gcc/ipa-split.c
===
--- gcc/ipa-split.c (revision 178572)
+++ gcc/ipa-split.c (working copy)
@@ -943,10 +943,10 @@ static void
 split_function (struct split_point *split_point)
 {
   VEC (tree, heap) *args_to_pass = NULL;
-  bitmap args_to_skip;
+  bitmap args_to_skip = BITMAP_ALLOC (NULL);
   tree parm;
   int num = 0;
-  struct cgraph_node *node, *cur_node = cgraph_node (current_function_decl);
+  struct cgraph_node *node;
   basic_block return_bb = find_return_bb ();
   basic_block call_bb;
   gimple_stmt_iterator gsi;
@@ -966,34 +966,17 @@ split_function (struct split_point *spli
   dump_split_point (dump_file, split_point);
 }
 
-  if (cur_node->local.can_change_signature
-  && !TYPE_ATTRIBUTES (TREE_TYPE (cur_node->decl)))
-args_to_skip = BITMAP_ALLOC (NULL);
-  else
-args_to_skip = NULL;
-
   /* Collect the parameters of new function and args_to_skip bitmap.  */
   for (parm = DECL_ARGUMENTS (current_function_decl);
parm; parm = DECL_CHAIN (parm), num++)
-if (args_to_skip
-   && (!is_gimple_reg (parm)
-   || !gimple_default_def (cfun, parm)
-   || !bitmap_bit_p (split_point->ssa_names_to_pass,
-   

Re: [PATCH, Atom] Improve AGU stalls avoidance optimization

2011-09-06 Thread Ilya Enkovich
Hello,

Thanks for review!

2011/9/3 Uros Bizjak :
> Did you also test on x32 ? H.J.'s x32 page [1] currently says that
> Atom LEA optimization is disabled on x32 for some reason.
No. I did not try to cover x32. It will be a separate work.

> +bool
> +ix86_avoid_lea_for_addr (rtx insn, rtx operands[])
> +{
> +  unsigned int regno0 = true_regnum (operands[0]) ;
> +  unsigned int regno1 = -1;
> +  unsigned int regno2 = -1;
>
> Use INVALID_REGNUM here.
Fixed. Also used  INVALID_REGNUM in other places where -1 was used as
invalid register number.

>
> +extern void
> +ix86_split_lea_for_addr (rtx operands[], enum machine_mode mode)
> +{
>
> Missing comment.
Fixed

> +;; Split non destructive adds if we cannot use lea.
> +(define_split
> +  [(set (match_operand:SWI48 0 "register_operand" "")
> +       (plus:SWI48 (match_operand:SWI48 1 "register_operand" "")
> +              (match_operand:SWI48 2 "nonmemory_operand" "")))
> +   (clobber (reg:CC FLAGS_REG))]
> +  "reload_completed && ix86_avoid_lea_for_add (insn, operands)"
> +  [(set (match_dup 0) (match_dup 1))
> +   (parallel [(set (match_dup 0) (plus: (match_dup 0) (match_dup 2)))
> +             (clobber (reg:CC FLAGS_REG))])
> +  ]
> +)
>
> Put all closing braces on one line:
Fixed.

> +;; Split lea into one or more ALU instructions if profitable.
> +(define_split
> +  [(set (match_operand:SI 0 "register_operand" "")
> +       (subreg:SI (match_operand:DI 1 "lea_address_operand" "") 0))]
> +  "reload_completed && ix86_avoid_lea_for_addr (insn, operands)"
> +  [(const_int 0)]
> +{
> +  ix86_split_lea_for_addr (operands, SImode);
> +  DONE;
> +})
>
> This is valid only for TARGET_64BIT.
Fixed.

> Please note that x32 adds quite some different LEA patterns (see
> i386.md, line 5466+). I suggest you merge your splitters with these
> define_insn patterns into define_insn_and_split, adding "&&
> reload_completed && ix86_avoid_lea_for_addr (insn, operands)" as a
> split condition.
Thanks for the note. I'll look at new patterns when we enable lea
optimization for x32.

>
> Uros.
>

Is fixed version OK?

Thanks,
Ilya
---
gcc/

2011-09-06  Enkovich Ilya  

* config/i386/i386-protos.h (ix86_lea_outperforms): New.
(ix86_avoid_lea_for_add): Likewise.
(ix86_avoid_lea_for_addr): Likewise.
(ix86_split_lea_for_addr): Likewise.

* config/i386/i386.c (LEA_MAX_STALL): New.
(increase_distance): Likewise.
(insn_defines_reg): Likewise.
(insn_uses_reg_mem): Likewise.
(distance_non_agu_define_in_bb): Likewise.
(distance_agu_use_in_bb): Likewise.
(ix86_lea_outperforms): Likewise.
(ix86_ok_to_clobber_flags): Likewise.
(ix86_avoid_lea_for_add): Likewise.
(ix86_avoid_lea_for_addr): Likewise.
(ix86_split_lea_for_addr): Likewise.
(distance_non_agu_define): Search in pred BBs added.
(distance_agu_use): Search in succ BBs added.
(IX86_LEA_PRIORITY): Value changed from 2 to 0.
(LEA_SEARCH_THRESHOLD): Now depends on LEA_MAX_STALL.
(ix86_lea_for_add_ok): Use ix86_lea_outperforms to make decision.

* config/i386/i386.md: Splits added to transform lea into a
sequence of instructions.


lea.diff
Description: Binary data


Re: [c-family] Fix PR middle-end/50266

2011-09-06 Thread Joseph S. Myers
On Tue, 6 Sep 2011, Eric Botcazou wrote:

> Hi,
> 
> this is a regression present on the mainline and 4.6 branch caused by the 
> constructor uniquization patch.  The tree_output_constant_def routine rejects 
> offsetof-like computations that can be written in the C family of languages.
> While the C compiler folds most of them early, it doesn't if an intermediate 
> folding step is required.
> 
> The proposed fix is to make c_fully_fold also do the offsetof folding.
> 
> Tested on x86_64-suse-linux, OK for mainline and 4.6 branch?

OK with a comment explaining the need to fold in this case and with the 
testcase moved to gcc.c-torture/compile rather than having dg-options 
specifying particular options from the set that would be passed in 
gcc.c-torture/compile.  But in general we want to *reduce* the amount of 
folding done in the front ends and move more of it to gimplification time 
or later, except where required for the front end to meet standard 
requirements for diagnostics relating to constant expressions or avoid 
unnecessary warnings in various cases relating to conversions etc. (and 
there may be better ways to avoid those warnings without early 
optimization).

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


[Ada] Remove hack for Win95 which is not needed anymore

2011-09-06 Thread Arnaud Charlet
No change in behavior, this patch just removes code that is not
used since a long time.

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

2011-09-06  Pascal Obry  

* sysdep.c (winflush_nt): Removed as not needed anymore.
(winflush_95): Likewise.
(winflush_init): Likewise.
(winflush_function): Likewise.
(getc_immediate_common): Remove call to winflush_function.

Index: sysdep.c
===
--- sysdep.c(revision 178565)
+++ sysdep.c(working copy)
@@ -211,84 +211,10 @@
 return NULL;
 }
 
-/* This function is needed to fix a bug under Win95/98. Under these platforms
-   doing :
-ch1 = getch();
-   ch2 = fgetc (stdin);
+#ifndef RTX
 
-   will put the same character into ch1 and ch2. It seem that the character
-   read by getch() is not correctly removed from the buffer. Even a
-   fflush(stdin) does not fix the bug. This bug does not appear under Window
-   NT. So we have two version of this routine below one for 95/98 and one for
-   NT/2000 version of Windows. There is also a special routine (winflushinit)
-   that will be called only the first time to check which version of Windows
-   we are running running on to set the right routine to use.
-
-   This problem occurs when using Text_IO.Get_Line after Text_IO.Get_Immediate
-   for example.
-
-   Calling FlushConsoleInputBuffer just after getch() fix the bug under
-   95/98. */
-
-#ifdef RTX
-
-static void winflush_nt (void);
-
-/* winflush_function will do nothing since we only have problems with Windows
-   95/98 which are not supported by RTX. */
-
-static void (*winflush_function) (void) = winflush_nt;
-
-static void
-winflush_nt (void)
-{
-  /* Does nothing as there is no problem under NT.  */
-}
-
-#else /* !RTX */
-
-static void winflush_init (void);
-
-static void winflush_95 (void);
-
-static void winflush_nt (void);
-
 int __gnat_is_windows_xp (void);
 
-/* winflusfunction is set first to the winflushinit function which will check
-   the OS version 95/98 or NT/2000 */
-
-static void (*winflush_function) (void) = winflush_init;
-
-/* This function does the runtime check of the OS version and then sets
-   winflush_function to the appropriate function and then call it. */
-
-static void
-winflush_init (void)
-{
-  DWORD dwVersion = GetVersion();
-
-  if (dwVersion < 0x8000)/* Windows NT/2000 */
-winflush_function = winflush_nt;
-  else   /* Windows 95/98   */
-winflush_function = winflush_95;
-
-  (*winflush_function)();  /* Perform the 'flush' */
-
-}
-
-static void
-winflush_95 (void)
-{
-  FlushConsoleInputBuffer (GetStdHandle (STD_INPUT_HANDLE));
-}
-
-static void
-winflush_nt (void)
-{
-  /* Does nothing as there is no problem under NT.  */
-}
-
 int
 __gnat_is_windows_xp (void)
 {
@@ -311,7 +237,7 @@
   return is_win_xp;
 }
 
-#endif /* !RTX */
+#endif
 
 /* Get the bounds of the stack.  The stack pointer is supposed to be
initialized to BASE when a thread is created and the stack can be extended
@@ -542,7 +468,6 @@
   if (waiting)
{
  *ch = getch ();
- (*winflush_function) ();
 
  if (*ch == eot_ch)
*end_of_file = 1;
@@ -559,7 +484,6 @@
{
  *avail = 1;
  *ch = getch ();
- (*winflush_function) ();
 
  if (*ch == eot_ch)
*end_of_file = 1;


[Ada] Freezing rules and expression functions

2011-09-06 Thread Arnaud Charlet
Ada2012 Expression functions behave like default expressions in regards to
freezing rules: their declaration does not freeze, only a use of them (in a
call) freezes.
The following must compile quietly in Ada2012 mode:

---
with Interfaces; use Interfaces;
package Images is
   type RGBQUAD is record
  rgbBlue : Unsigned_8;
  rgbGreen: Unsigned_8;
  rgbRed  : Unsigned_8;
  rgbReserved : Unsigned_8;
   end record;

   type Color_Type is new Unsigned_32;

   type Image_Types is (Grey, RGB, RGBa);

   subtype Colornr_Range is Integer range 0 .. 255;
   type Color_Data_Header is array (Colornr_Range) of RGBQUAD;
   type Color_Data_Header_Ptr is access all Color_Data_Header;

   subtype Image_Byte is Unsigned_8;
   type Image_Data is array (Positive range <>,
 Positive range <>) of Unsigned_8;
   for Image_Data'Alignment use 4;
   type Image_Data_Ptr is access all Image_Data;

   type Line_Type is
  record
 X_From, Y_From, X_Upto, Y_Upto : Integer;
 Color : Color_Type;
  end record;
   type Line_Array is array (Positive range <>) of Line_Type;
   subtype Linenr_Range is Integer range 1 .. 256;

   type Visual_Itec_Common_Header is
   record
  SequenceNr : Integer;
  Xaxis_Mirror : Boolean;
  Yaxis_Mirror : Boolean;
  Lines : Line_Array (Linenr_Range);
   end record;
   type Visual_Itec_Common_Header_Ptr is
 access constant Visual_Itec_Common_Header;

   type Image_Read_Properties is
 (Image_Width, Image_Height, Image_VerticalPitch, Image_BitsPerPixel,
  Image_XPelsPerMeter, Image_YPelsPerMeter);
   type Image_Write_Properties is (Image_XPelsPerMeter, Image_YPelsPerMeter);

   type Image_Header is private;

   type Image_Type (Height, Width, VerticalPitch : Positive) is
   limited record
  Header : Image_Header;
  Data : Image_Data (1 .. Height, 1 .. VerticalPitch);
   end record;
   type Image_Object is access all Image_Type;
   pragma No_Strict_Aliasing (Image_Object);
   Null_Image : constant Image_Object;

   type Image_Objects is array (Integer range <>) of Image_Object;

   procedure Set_Default_PixelsPerMeter (X, Y : Integer);
private
   type Image_Header is
  record
 ImageNr : Integer;
 Common : aliased Visual_Itec_Common_Header;
 Color_Data : aliased Color_Data_Header;
  end record;
   Null_Image : constant Image_Object := null;

   function Get_Color (Image : Image_Object;
   Colornr : Colornr_Range) return RGBQUAD is
(Image.Header.Color_Data (Colornr));
end Images;
---
package body Images is
   XPelsPerMeter : Integer := 5000;
   YPelsPerMeter : Integer := 5000;

   procedure Set_Default_PixelsPerMeter (X, Y : Integer) is
   begin
  XPelsPerMeter := X;
  YPelsPerMeter := Y;
   end Set_Default_PixelsPerMeter;
end Images;

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

2011-09-06  Ed Schonberg  

* sem_res.adb (Resolve): An expression that is the body of an
expression function does not freeze.

Index: sem_res.adb
===
--- sem_res.adb (revision 178565)
+++ sem_res.adb (working copy)
@@ -2810,8 +2810,17 @@
  --  default expression mode (the Freeze_Expression routine tests this
  --  flag and only freezes static types if it is set).
 
- Freeze_Expression (N);
+ --  AI05-177 (Ada2012): Expression functions do not freeze. Only
+ --  their use (in an expanded call) freezes.
 
+ if Ekind (Current_Scope) /= E_Function
+   or else
+ Nkind (Original_Node (Unit_Declaration_Node (Current_Scope))) /=
+N_Expression_Function
+ then
+Freeze_Expression (N);
+ end if;
+
  --  Now we can do the expansion
 
  Expand (N);


[Ada] Initialization calls with access discriminants

2011-09-06 Thread Arnaud Charlet
If a record component is constrained with a current instance, that is to say
an access to the enclosing type, an initialization call for the component must
use a reference to the target object. Previously this was done when generating
the code for the initialization procedure for the encloing record, but such
a call can also be generated for an aggregate.

The following must compile quietly in Ada2005 mode:

---
package Small_Class is
   type Instance is limited private;
   type Instance_P is access all Instance;
   function Create (Index : Integer) return Instance_P;
   procedure Start (This : Instance_P);
private
   task type T (This : not null access Instance) is
  entry Start;
   end T;
   type Instance is limited record
  The_T : T (This => Instance'Access);
  Index : Integer := 0;
   end record;
end Small_Class;
---
with Ada.Text_IO; use Ada.Text_IO;

package body Small_Class is

   task body T is
   begin
  accept Start;
  Put_Line ("T (" & Integer'Image (This.Index) & " ) started.");
   end T;

   function Create (Index : Integer) return Instance_P
   is
  --   Result : Instance_P := new Instance;
   begin
   --  Result.Index := Index;
   --  return Result;
  return new Instance'(Index => Index, others => <>);
   end Create;

   procedure Start (This : Instance_P) is
   begin
  This.The_T.Start;
   end Start;

end Small_Class;

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

2011-09-06  Ed Schonberg  

* exp_ch3.adb (Build_Initialization_Call): If the target is a
selected component discriminated by a current instance, replace
the constraint with a reference to the target object, regardless
of whether the context is an init_proc.

Index: exp_ch3.adb
===
--- exp_ch3.adb (revision 178565)
+++ exp_ch3.adb (working copy)
@@ -1563,8 +1563,22 @@
Discriminant_Constraint (Full_Type));
 end;
 
-if In_Init_Proc then
+--  If the target has access discriminants, and is constrained by
+--  an access to the enclosing construct, i.e. a current instance,
+--  replace the reference to the type by a reference to the object.
 
+if Nkind (Arg) = N_Attribute_Reference
+  and then Is_Access_Type (Etype (Arg))
+  and then Is_Entity_Name (Prefix (Arg))
+  and then Is_Type (Entity (Prefix (Arg)))
+then
+   Arg :=
+ Make_Attribute_Reference (Loc,
+   Prefix => New_Copy (Prefix (Id_Ref)),
+   Attribute_Name => Name_Unrestricted_Access);
+
+elsif In_Init_Proc then
+
--  Replace any possible references to the discriminant in the
--  call to the record initialization procedure with references
--  to the appropriate formal parameter.
@@ -1574,19 +1588,6 @@
then
   Arg := New_Reference_To (Discriminal (Entity (Arg)), Loc);
 
-   --  Case of access discriminants. We replace the reference
-   --  to the type by a reference to the actual object
-
-   elsif Nkind (Arg) = N_Attribute_Reference
- and then Is_Access_Type (Etype (Arg))
- and then Is_Entity_Name (Prefix (Arg))
- and then Is_Type (Entity (Prefix (Arg)))
-   then
-  Arg :=
-Make_Attribute_Reference (Loc,
-  Prefix => New_Copy (Prefix (Id_Ref)),
-  Attribute_Name => Name_Unrestricted_Access);
-
--  Otherwise make a copy of the default expression. Note that
--  we use the current Sloc for this, because we do not want the
--  call to appear to be at the declaration point. Within the


[c-family] Fix PR middle-end/50266

2011-09-06 Thread Eric Botcazou
Hi,

this is a regression present on the mainline and 4.6 branch caused by the 
constructor uniquization patch.  The tree_output_constant_def routine rejects 
offsetof-like computations that can be written in the C family of languages.
While the C compiler folds most of them early, it doesn't if an intermediate 
folding step is required.

The proposed fix is to make c_fully_fold also do the offsetof folding.

Tested on x86_64-suse-linux, OK for mainline and 4.6 branch?


2011-09-06  Eric Botcazou  

PR middle-end/50266
* c-common.c (c_fully_fold_internal) : Fold offsetof-like
computations.


2011-09-06  Eric Botcazou  

* gcc.dg/init-offsetof-1.c: New test.


-- 
Eric Botcazou
Index: c-common.c
===
--- c-common.c	(revision 178488)
+++ c-common.c	(working copy)
@@ -1264,7 +1264,18 @@ c_fully_fold_internal (tree expr, bool i
   STRIP_TYPE_NOPS (op0);
   if (code != ADDR_EXPR && code != REALPART_EXPR && code != IMAGPART_EXPR)
 	op0 = decl_constant_value_for_optimization (op0);
-  if (op0 != orig_op0 || in_init)
+  if (op0 != orig_op0
+	  && code == ADDR_EXPR
+	  && (op1 = get_base_address (op0)) != NULL_TREE
+	  && TREE_CODE (op1) == INDIRECT_REF
+	  && TREE_CONSTANT (TREE_OPERAND (op1, 0)))
+	{
+	  tree offset = fold_offsetof (op0, op1);
+	  op1
+	= fold_convert_loc (loc, TREE_TYPE (expr), TREE_OPERAND (op1, 0));
+	  ret = fold_build_pointer_plus_loc (loc, op1, offset);
+	}
+  else if (op0 != orig_op0 || in_init)
 	ret = in_init
 	  ? fold_build1_initializer_loc (loc, code, TREE_TYPE (expr), op0)
 	  : fold_build1_loc (loc, code, TREE_TYPE (expr), op0);
/* PR middle-end/50266 */
/* Testcase by  */

/* { dg-do compile } */
/* { dg-options "-Os" } */

struct a {
 unsigned int a;
 unsigned int b;
};

struct a *const p = (struct a *)0x4A004100;

void foo(void)
{
 unsigned int i = 0;
 unsigned int *const x[] = {
  &p->a,
  &p->b,
  0
 };

 (*(volatile unsigned int *)((x[i]))
   = (unsigned int)((unsigned int)((*(volatile unsigned int *)(x[i]);
}


Re: [Ada] Speed up build of gnatools

2011-09-06 Thread Arnaud Charlet
> this means using as many processes as there are CPUs, right?  It seems pretty

Right, but only for gnattools, which is a relatively short time, and
which always occurs at the end of the build (so with nothing else
running at the same time).

> dubious to me to use more processes than the user maybe asked for.  For 
> example
> I have to restrict the number of CPUs used when building GCC to less than I 
> have
> since otherwise my machine overheats and turns itself off.  Is there some way
> to get at the -j level the user passed to the top-level make and use that?

No, I'm not aware of a way to get this information.

I'd suggest playing/experimenting with this change for a while.

If people (e.g. you) report troubles with this change, reverting it is
very easy in any case. I'll be happy to do that.

Arno


Re: [patch, ARM] Change default vector size to 128 bits - take 3

2011-09-06 Thread Ira Rosen
On 17 August 2011 15:49, Richard Earnshaw  wrote:
> On 16/08/11 10:28, Ira Rosen wrote:
>> Hi,
>>
>> This patch changes the default vector size for auto-vectorization on
>> ARM NEON to 128 bits. This new version is a result of a discussion
>> with Richard and Ramana.
>>
>> wwwdocs changes will follow shortly.
>>
>> Bootstrapped and tested on arm-linux-gnueabi. The testsuite changes
>> were also checked on powerpc64-suse-linux and x86_64-suse-linux.
>>
>> There is one new failure:
>> gcc.c-torture/execute/mode-dependent-address.c fails with -O3
>> -funroll-loops with this patch or with -mvectorize-with-neon-quad.
>> Ramana has a patch to fix this
>> http://gcc.gnu.org/ml/gcc/2011-08/msg00284.html. I will wait with
>> committing my patch until this issue is resolved.
>>
>> OK for mainline?
>>
>> Thanks,
>> Ira
>>
>> ChangeLog:
>>
>>    * config/arm/arm.c (arm_preferred_simd_mode): Check
>>    TARGET_NEON_VECTORIZE_DOUBLE instead of
>>    TARGET_NEON_VECTORIZE_QUAD.
>>    (arm_expand_sync): Likewise.
>>    * config/arm/arm.opt (mvectorize-with-neon-quad): Make inverse
>>    mask of mvectorize-with-neon-double.  Add RejectNegative.
>>    (mvectorize-with-neon-double): New.
>>
>> testsuite/ChangeLog:
>>
>>    * lib/target-supports.exp (check_effective_target_vect_multiple_sizes):
>>    New procedure.
>>    (add_options_for_quad_vectors): Replace with ...
>>    (add_options_for_double_vectors): ... this.
>>    * gfortran.dg/vect/pr19049.f90: Expect more printings on targets that
>>     support multiple vector sizes since the vectorizer attempts to
>>     vectorize with both vector sizes.
>>    * gcc.dg/vect/no-vfa-vect-79.c,
>>     gcc.dg/vect/no-vfa-vect-102a.c, gcc.dg/vect/vect-outer-1a.c,
>>     gcc.dg/vect/vect-outer-1b.c, gcc.dg/vect/vect-outer-2b.c,
>>     gcc.dg/vect/vect-outer-3a.c, gcc.dg/vect/no-vfa-vect-37.c,
>>     gcc.dg/vect/vect-outer-3b.c, gcc.dg/vect/no-vfa-vect-101.c,
>>     gcc.dg/vect/no-vfa-vect-102.c, gcc.dg/vect/vect-reduc-dot-s8b.c,
>>     gcc.dg/vect/vect-outer-1.c, gcc.dg/vect/vect-104.c: Likewise.
>>    * gcc.dg/vect/vect-42.c: Run with 64 bit vectors if applicable.
>>    * gcc.dg/vect/vect-multitypes-6.c, gcc.dg/vect/vect-52.c,
>>    gcc.dg/vect/vect-54.c, gcc.dg/vect/vect-46.c, gcc.dg/vect/vect-48.c,
>>    gcc.dg/vect/vect-96.c, gcc.dg/vect/vect-multitypes-3.c,
>>    gcc.dg/vect/vect-40.c: Likewise.
>>   * gcc.dg/vect/vect-outer-5.c: Remove quad-vectors option as
>>    redundant.
>>   * gcc.dg/vect/vect-109.c, gcc.dg/vect/vect-peel-1.c,
>>    gcc.dg/vect/vect-peel-2.c, gcc.dg/vect/slp-25.c,
>>    gcc.dg/vect/vect-multitypes-1.c, gcc.dg/vect/slp-3.c,
>>    gcc.dg/vect/no-vfa-pr29145.c, gcc.dg/vect/vect-multitypes-4.c:
>>    Likewise.
>>  * gcc.dg/vect/vect-peel-4.c: Make ia global.
>>
>
> Ok with the following change:
>
>>  static unsigned int
>>  arm_autovectorize_vector_sizes (void)
>>  {
>> -  return TARGET_NEON_VECTORIZE_QUAD ? 16 | 8 : 0;
>> +  return TARGET_NEON_VECTORIZE_DOUBLE ? 0 : 16 | 8;
>>  }
>
>
> Please put parentheses round the expression to make the precedence explicit.

I added parentheses and committed the patch.

Thanks,
Ira

>
> R.
>
>


Re: [ARM] PR target/49030: ICE in get_arm_condition_code

2011-09-06 Thread Richard Sandiford
Chung-Lin Tang  writes:
> Hi Richard, this looks very similar to this patch, originally for LP:689887:
> http://gcc.gnu.org/ml/gcc-patches/2011-01/msg00794.html
> Apart from your additional handling in the dominance modes cases.

Indeed.  Sorry about that.  It must look odd that I've posted such
a similar patch to a bug that I'd also assigned to myself.  The reason
is that this problem was reported more recently as two other Launchpad
bugs, and I only found the old one when submitting the patch (I linked the
new bugs to the bugzilla PR, and Launchpad told me about the old one also
being linked to that PR).  I didn't even notice there was a patch attached.

My patch has now survived a Thumb-2 bootstrap, and it sounds like Ramana
has also successfully bootstrapped your original patch.

Richard


Re: [Ada] Speed up build of gnatools

2011-09-06 Thread Duncan Sands

Hi Arnaud,


Now that gnatmake supports -j0, it's possible to speed up the build of
gnattools during GNAT build by using gnatmake -j0 instead of gnatmake.

This is useful since gnattools is the only target which isn't parallelized
in the Makefile before this change.


this means using as many processes as there are CPUs, right?  It seems pretty
dubious to me to use more processes than the user maybe asked for.  For example
I have to restrict the number of CPUs used when building GCC to less than I have
since otherwise my machine overheats and turns itself off.  Is there some way
to get at the -j level the user passed to the top-level make and use that?

Ciao, Duncan.



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

2011-09-06  Arnaud Charlet

* gcc-interface/Makefile.in (common-tools, gnatmake-re,
gnatlink-re): Speed up by using -j0.

--
Index: gcc-interface/Makefile.in
===
--- gcc-interface/Makefile.in   (revision 178566)
+++ gcc-interface/Makefile.in   (working copy)
@@ -2336,7 +2336,7 @@
  endif

  common-tools:
-   $(GNATMAKE) -c -b $(ADA_INCLUDES) \
+   $(GNATMAKE) -j0 -c -b $(ADA_INCLUDES) \
  --GNATBIND="$(GNATBIND)" --GCC="$(CC) $(ALL_ADAFLAGS)" \
  gnatchop gnatcmd gnatkr gnatls gnatprep gnatxref gnatfind gnatname \
  gnatclean -bargs $(ADA_INCLUDES) $(GNATBIND_FLAGS)
@@ -2375,16 +2375,18 @@
$(GNATLINK) -v vxaddr2line -o $@ --GCC="$(GCC_LINK)" targext.o $(CLIB)

  gnatmake-re:  link.o targext.o
-   $(GNATMAKE) $(ADA_INCLUDES) -u sdefault --GCC="$(CC) $(MOST_ADA_FLAGS)"
-   $(GNATMAKE) -c $(ADA_INCLUDES) gnatmake --GCC="$(CC) $(ALL_ADAFLAGS)"
+   $(GNATMAKE) -j0 $(ADA_INCLUDES) -u sdefault --GCC="$(CC) 
$(MOST_ADA_FLAGS)"
+   $(GNATMAKE) -j0 -c $(ADA_INCLUDES) gnatmake --GCC="$(CC) 
$(ALL_ADAFLAGS)"
$(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) gnatmake
$(GNATLINK) -v gnatmake -o ../../gnatmake$(exeext) \
--GCC="$(GCC_LINK)" $(TOOLS_LIBS)

  # Note the use of the "mv" command in order to allow gnatlink to be linked 
with
  # with the former version of gnatlink itself which cannot override itself.
-gnatlink-re:  link.o targext.o
-   $(GNATMAKE) -c $(ADA_INCLUDES) gnatlink --GCC="$(CC) $(ALL_ADAFLAGS)"
+# gnatlink-re cannot be run at the same time as gnatmake-re, hence the
+# dependency
+gnatlink-re: link.o targext.o gnatmake-re
+   $(GNATMAKE) -j0 -c $(ADA_INCLUDES) gnatlink --GCC="$(CC) 
$(ALL_ADAFLAGS)"
$(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) gnatlink
$(GNATLINK) -v gnatlink -o ../../gnatlinknew$(exeext) \
--GCC="$(GCC_LINK)" $(TOOLS_LIBS)




[Ada] Improved warnings on useless formals in subprograms

2011-09-06 Thread Arnaud Charlet
This patch allows a better detection of unused formals in subprogram bodies.
Previously the use of a formal as the selector in a parameter association was
treated as a proper reference, thus missing otherwise unused entities.

The following command :

   gcc -c -gnatwa k.adb

must yield:

   k.adb:2:22: warning: formal parameter "X" is not referenced

---
procedure K is
  procedure Suspect (X : Integer) is
   begin
  for I in 1 .. 10 loop null; end loop;
   end;

begin
   Suspect (X => 15);
   Suspect (X => 15);
   Suspect (X => 15);
end;

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

2011-09-06  Ed Schonberg  

* lib-xref.adb (OK_To_Set_Referenced): A reference to a formal
in a parameter association must not set the Referenced flag on
the formal.
* prj-nmsc.adb (Check_File_Naming_Schemes): Remove useless formal

Index: prj-nmsc.adb
===
--- prj-nmsc.adb(revision 178585)
+++ prj-nmsc.adb(working copy)
@@ -376,8 +376,7 @@
--  otherwise only those currently set in the Source_Names hash table.
 
procedure Check_File_Naming_Schemes
- (In_Tree   : Project_Tree_Ref;
-  Project   : Project_Processing_Data;
+ (Project   : Project_Processing_Data;
   File_Name : File_Name_Type;
   Alternate_Languages   : out Language_List;
   Language  : out Language_Ptr;
@@ -6619,8 +6618,7 @@
---
 
procedure Check_File_Naming_Schemes
- (In_Tree   : Project_Tree_Ref;
-  Project   : Project_Processing_Data;
+ (Project   : Project_Processing_Data;
   File_Name : File_Name_Type;
   Alternate_Languages   : out Language_List;
   Language  : out Language_Ptr;
@@ -6923,8 +6921,7 @@
 
   if Check_Name then
  Check_File_Naming_Schemes
-   (In_Tree   => Data.Tree,
-Project   => Project,
+   (Project   => Project,
 File_Name => File_Name,
 Alternate_Languages   => Alternate_Languages,
 Language  => Language,
Index: lib-xref.adb
===
--- lib-xref.adb(revision 178578)
+++ lib-xref.adb(working copy)
@@ -512,6 +512,16 @@
  return False;
   end if;
end if;
+
+--  A reference to a formal in a named parameter association does
+--  not make the formal referenced. Formals that are unused in the
+--  subprogram body are properly flagged as such, even if calls
+--  elsewhere use named notation.
+
+elsif Nkind (P) = N_Parameter_Association
+  and then N = Selector_Name (P)
+then
+   return False;
 end if;
  end if;
 


[Ada] Speed up build of gnatools

2011-09-06 Thread Arnaud Charlet
Now that gnatmake supports -j0, it's possible to speed up the build of
gnattools during GNAT build by using gnatmake -j0 instead of gnatmake.

This is useful since gnattools is the only target which isn't parallelized
in the Makefile before this change.

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

2011-09-06  Arnaud Charlet  

* gcc-interface/Makefile.in (common-tools, gnatmake-re, 
gnatlink-re): Speed up by using -j0.

--
Index: gcc-interface/Makefile.in
===
--- gcc-interface/Makefile.in   (revision 178566)
+++ gcc-interface/Makefile.in   (working copy)
@@ -2336,7 +2336,7 @@
 endif
 
 common-tools:
-   $(GNATMAKE) -c -b $(ADA_INCLUDES) \
+   $(GNATMAKE) -j0 -c -b $(ADA_INCLUDES) \
  --GNATBIND="$(GNATBIND)" --GCC="$(CC) $(ALL_ADAFLAGS)" \
  gnatchop gnatcmd gnatkr gnatls gnatprep gnatxref gnatfind gnatname \
  gnatclean -bargs $(ADA_INCLUDES) $(GNATBIND_FLAGS)
@@ -2375,16 +2375,18 @@
$(GNATLINK) -v vxaddr2line -o $@ --GCC="$(GCC_LINK)" targext.o $(CLIB)
 
 gnatmake-re:  link.o targext.o
-   $(GNATMAKE) $(ADA_INCLUDES) -u sdefault --GCC="$(CC) $(MOST_ADA_FLAGS)"
-   $(GNATMAKE) -c $(ADA_INCLUDES) gnatmake --GCC="$(CC) $(ALL_ADAFLAGS)"
+   $(GNATMAKE) -j0 $(ADA_INCLUDES) -u sdefault --GCC="$(CC) 
$(MOST_ADA_FLAGS)"
+   $(GNATMAKE) -j0 -c $(ADA_INCLUDES) gnatmake --GCC="$(CC) 
$(ALL_ADAFLAGS)"
$(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) gnatmake
$(GNATLINK) -v gnatmake -o ../../gnatmake$(exeext) \
--GCC="$(GCC_LINK)" $(TOOLS_LIBS)
 
 # Note the use of the "mv" command in order to allow gnatlink to be linked with
 # with the former version of gnatlink itself which cannot override itself.
-gnatlink-re:  link.o targext.o
-   $(GNATMAKE) -c $(ADA_INCLUDES) gnatlink --GCC="$(CC) $(ALL_ADAFLAGS)"
+# gnatlink-re cannot be run at the same time as gnatmake-re, hence the
+# dependency
+gnatlink-re: link.o targext.o gnatmake-re
+   $(GNATMAKE) -j0 -c $(ADA_INCLUDES) gnatlink --GCC="$(CC) 
$(ALL_ADAFLAGS)"
$(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) gnatlink
$(GNATLINK) -v gnatlink -o ../../gnatlinknew$(exeext) \
--GCC="$(GCC_LINK)" $(TOOLS_LIBS)


[Ada] Implement attribute Descriptor_Size

2011-09-06 Thread Arnaud Charlet
This patch provides support for attribute Descriptor_Size. Currently the
attribute is applicable only to unconstrained arrays types and returns the
size of the dope vector plus any additional padding due to alignment issues
in bits.

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

2011-09-06  Hristian Kirtchev  

* gcc-interface/trans.c (Attribute_to_gnu): New case for
attribute Descriptor_Size.
* exp_attr.adb (Expand_N_Attribute_Reference): Add processing
for attribute Descriptor_Size.
* exp_ch7.adb (Double_Size_Of): Removed.
(Make_Finalize_Address_Stmts): Remove the code which generates
an expression to calculate the dope vector of an unconstrained
array. Instead use attribute Descriptor_Size and leave the
calculation to the back end.
(Nearest_Multiple_Rounded_Up): Removed.
(Size_Of): Removed.
* sem_attr.adb (Analyze_Attribute): Add processing for attribute
Descriptor_Size. Currently the attribute is applicable only
to unconstrained arrays.
(Eval_Attribute): Add processing for
attribute Descriptor_Size.
* snames.ads-tmpl: Add a predefined name and an Attribute_Id
for Descriptor_Size.

Index: exp_ch7.adb
===
--- exp_ch7.adb (revision 178572)
+++ exp_ch7.adb (working copy)
@@ -7023,99 +7023,6 @@
   Desg_Typ : Entity_Id;
   Obj_Expr : Node_Id;
 
-  function Double_Size_Of (Typ : Entity_Id) return Node_Id;
-  --  Subsidiary routine, produces an expression which calculates double
-  --  the size of Typ as the nearest multiple of its alignment rounded up.
-
-  function Nearest_Multiple_Rounded_Up
-(Size_Expr : Node_Id;
- Typ   : Entity_Id) return Node_Id;
-  --  Subsidiary routine, generate the following expression:
-  --((Size_Expr + Typ'Alignment - 1) / Typ'Alignment) * Typ'Alignment
-
-  function Size_Of (Typ : Entity_Id) return Node_Id;
-  --  Subsidiary routine, produces an expression which calculates the size
-  --  of Typ as the nearest multiple of its alignment rounded up.
-
-  
-  -- Double_Size_Of --
-  
-
-  function Double_Size_Of (Typ : Entity_Id) return Node_Id is
-  begin
- return
-   Make_Op_Multiply (Loc,
- Left_Opnd  => Make_Integer_Literal (Loc, 2),
- Right_Opnd => Size_Of (Typ));
-  end Double_Size_Of;
-
-  -
-  -- Nearest_Multiple_Rounded_Up --
-  -
-
-  function Nearest_Multiple_Rounded_Up
-(Size_Expr : Node_Id;
- Typ   : Entity_Id) return Node_Id
-  is
- function Alignment_Of (Typ : Entity_Id) return Node_Id;
- --  Subsidiary routine, generate the following attribute reference:
- --Typ'Alignment
-
- --
- -- Alignment_Of --
- --
-
- function Alignment_Of (Typ : Entity_Id) return Node_Id is
- begin
-return
-  Make_Attribute_Reference (Loc,
-Prefix => New_Reference_To (Typ, Loc),
-Attribute_Name => Name_Alignment);
- end Alignment_Of;
-
-  --  Start of processing for Nearest_Multiple_Rounded_Up
-
-  begin
- --  Generate:
- --((Size_Expr + Typ'Alignment - 1) / Typ'Alignment) *
- --   Typ'Alignment
-
- return
-   Make_Op_Multiply (Loc,
- Left_Opnd  =>
-   Make_Op_Divide (Loc,
- Left_Opnd  =>
-   Make_Op_Add (Loc,
- Left_Opnd  => Size_Expr,
- Right_Opnd =>
-   Make_Op_Subtract (Loc,
- Left_Opnd  => Alignment_Of (Typ),
- Right_Opnd => Make_Integer_Literal (Loc, 1))),
- Right_Opnd => Alignment_Of (Typ)),
- Right_Opnd => Alignment_Of (Typ));
-  end Nearest_Multiple_Rounded_Up;
-
-  -
-  -- Size_Of --
-  -
-
-  function Size_Of (Typ : Entity_Id) return Node_Id is
-  begin
- return
-   Nearest_Multiple_Rounded_Up
- (Size_Expr =>
-Make_Op_Divide (Loc,
-  Left_Opnd  =>
-Make_Attribute_Reference (Loc,
-  Prefix => New_Reference_To (Typ, Loc),
-  Attribute_Name => Name_Size),
-  Right_Opnd =>
-Make_Integer_Literal (Loc, System_Storage_Unit)),
-  Typ => Typ);
-  end Size_Of;
-
-   --  Start of processing for Make_Finalize_Address_Stmts
-
begin
   if Is_Array_Type (Typ) then
  if Is_Constrained (First_Subtype (Typ)) then
@@ -7190,11 +7097,7

Re: Rename across basic block boundaries

2011-09-06 Thread Richard Sandiford
Bernd Schmidt  writes:
> 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.

Looks good to me.  Maybe here:

> +  /* The order in which we visit blocks ensures that whenever
> + possible, we only process a block after at least one of its
> + predecessors, which provides a "seeding" effect to make the logic
> + in set_incoming_from_chain and init_rename_info useful.  */
> +
> +  for (i = 0; i < n_bbs; i++)
> +{
> +  basic_block bb1 = BASIC_BLOCK (inverse_postorder[i]);
> +  struct bb_rename_info *this_info = rename_info + i;
> [...]
> +  if (bb1->aux == NULL)
> + continue;

it would be better to use:

  this_info = (struct bb_rename_info *) bb1->aux;

  if (this_info == NULL)
continue;

so that we don't care which order the rename_info array is.  You could
then keep the original form of the first loop:

  /* Gather some information about the blocks in this function.  */
  rename_info = XCNEWVEC (struct bb_rename_info, n_basic_blocks);
  ri_index = 0;
  FOR_EACH_BB (bb)
{
  struct bb_rename_info *ri = rename_info + ri_index;
  ri->bb = bb;
  ri->n_preds = EDGE_COUNT (bb->preds);
  bb->aux = ri;
  ri_index++;
}

OK with me whichever.

Richard


[Ada] Erroneous memory access when destroying a task's own ATCB

2011-09-06 Thread Arnaud Charlet
This change fixes a defect in the tasking runtime library whereby a
task freeing its own Ada Task Control Block would reference it after it
had been deallocated, because the deallocation is made with abortion deferred,
and Abort_Undefer needs access to the ATCB.

In particular this happens when a foreign thread unregisters using
GNAT.Threads.Unregister_Thread.

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

2011-09-06  Thomas Quinot  

* s-taprop-vxworks.adb, s-taprop-tru64.adb, s-taprop-vms.adb,
s-tpoaal.adb, s-taprop-mingw.adb, s-taprop-linux.adb,
s-taprop-solaris.adb, s-taprop-irix.adb, s-taprop.ads,
s-taprop-hpux-dce.adb, s-taprop-dummy.adb, s-taprop-posix.adb
(ATCB_Allocation): New subpackage of
System.Tasking.Primitive_Operations, shared across all targets
with full tasking runtime.
(ATCB_Allocation.New_ATCB): Moved there (from target specific
s-taprop bodies).
(ATCB_Allocation.Free_ATCB): New subprogram. Deallocate an ATCB,
taking care of establishing a local temporary ATCB if the one
being deallocated is Self, to avoid a reference to the freed
ATCB in Abort_Undefer.

Index: s-taprop-vxworks.adb
===
--- s-taprop-vxworks.adb(revision 178565)
+++ s-taprop-vxworks.adb(working copy)
@@ -39,7 +39,6 @@
 --  operations. It causes infinite loops and other problems.
 
 with Ada.Unchecked_Conversion;
-with Ada.Unchecked_Deallocation;
 
 with Interfaces.C;
 
@@ -140,6 +139,13 @@
package body Specific is separate;
--  The body of this package is target specific
 
+   --
+   -- ATCB allocation/deallocation --
+   --
+
+   package body ATCB_Allocation is separate;
+   --  The body of this package is shared across several targets
+
-
-- Support for foreign threads --
-
@@ -828,15 +834,6 @@
   end if;
end Enter_Task;
 
-   --
-   -- New_ATCB --
-   --
-
-   function New_ATCB (Entry_Num : Task_Entry_Index) return Task_Id is
-   begin
-  return new Ada_Task_Control_Block (Entry_Num);
-   end New_ATCB;
-
---
-- Is_Valid_Task --
---
@@ -986,13 +983,8 @@
--
 
procedure Finalize_TCB (T : Task_Id) is
-  Result  : int;
-  Tmp : Task_Id  := T;
-  Is_Self : constant Boolean := (T = Self);
+  Result : int;
 
-  procedure Free is new
-Ada.Unchecked_Deallocation (Ada_Task_Control_Block, Task_Id);
-
begin
   if not Single_Lock then
  Result := semDelete (T.Common.LL.L.Mutex);
@@ -1008,11 +1000,7 @@
  Known_Tasks (T.Known_Tasks_Index) := null;
   end if;
 
-  Free (Tmp);
-
-  if Is_Self then
- Specific.Delete;
-  end if;
+  ATCB_Allocation.Free_ATCB (T);
end Finalize_TCB;
 
---
Index: s-taprop-tru64.adb
===
--- s-taprop-tru64.adb  (revision 178565)
+++ s-taprop-tru64.adb  (working copy)
@@ -38,8 +38,6 @@
 --  Turn off polling, we do not want ATC polling to take place during tasking
 --  operations. It causes infinite loops and other problems.
 
-with Ada.Unchecked_Deallocation;
-
 with Interfaces;
 with Interfaces.C;
 
@@ -127,6 +125,13 @@
package body Specific is separate;
--  The body of this package is target specific
 
+   --
+   -- ATCB allocation/deallocation --
+   --
+
+   package body ATCB_Allocation is separate;
+   --  The body of this package is shared across several targets
+
-
-- Support for foreign threads --
-
@@ -695,15 +700,6 @@
   Specific.Set (Self_ID);
end Enter_Task;
 
-   --
-   -- New_ATCB --
-   --
-
-   function New_ATCB (Entry_Num : Task_Entry_Index) return Task_Id is
-   begin
-  return new Ada_Task_Control_Block (Entry_Num);
-   end New_ATCB;
-
---
-- Is_Valid_Task --
---
@@ -930,13 +926,8 @@
--
 
procedure Finalize_TCB (T : Task_Id) is
-  Result  : Interfaces.C.int;
-  Tmp : Task_Id := T;
-  Is_Self : constant Boolean := T = Self;
+  Result : Interfaces.C.int;
 
-  procedure Free is new
-Ada.Unchecked_Deallocation (Ada_Task_Control_Block, Task_Id);
-
begin
   if not Single_Lock then
  Result := pthread_mutex_destroy (T.Common.LL.L'Access);
@@ -950,11 +941,7 @@
  Known_Tasks (T.Known_Tasks_Index) := null;
   end if;
 
-  Free (Tmp);
-
-  if Is_Self then
- Specific.Set (null);
-  end if;
+  ATCB_Allocation.Free_ATCB (T);
end Finalize_TCB;
 
---
Inde

[Ada] Automatic deallocation of task upon termination

2011-09-06 Thread Arnaud Charlet
This change implements a new feature in the tasking runtime library: if
Unchecked_Deallocation is called on a non-terminated task (which was
previously a no-op), the task is now marked to be freed automatically when
it terminates.

The following test case demonstrates the feature:

$ gnatmake -q -z free_nonterm_task

When executing free_nonterm_task under valgrind, no memory leak corresponding
to the creation of task T (in System.Tasking.Stages.Create_Task) shall be
reported.

package Free_Nonterm_Task is
   pragma Elaborate_Body;
end Free_Nonterm_Task;

with Ada.Unchecked_Deallocation;
with Ada.Text_IO; use Ada.Text_IO;

package body Free_Nonterm_Task is

   type T;
   type A is access T;

   task type T is
  entry Term (Self : in out A);
   end T;

   procedure Free is new Ada.Unchecked_Deallocation (T, A);

   task body T is
   begin
  Put_Line ("T: enter");

  accept Term (Self : in out A) do
 Free (Self);
  end Term;
  Put_Line ("T: exit");
   end T;
   My_Task : A;
begin
   Put_Line ("Create task");
   My_Task := new T;
   Put_Line ("Call Term");
   My_Task.Term (My_Task);
end Free_Nonterm_Task;

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

2011-09-06  Thomas Quinot  

* s-tassta.adb, s-taskin.ads (Free_Task): If the task is not
terminated, mark it for deallocation upon termination.
(Terminate_Task): Call Free_Task again if the task is marked
for automatic deallocation upon termination.

Index: s-tassta.adb
===
--- s-tassta.adb(revision 178565)
+++ s-tassta.adb(working copy)
@@ -969,12 +969,11 @@
  Free_Entry_Names (T);
  System.Task_Primitives.Operations.Finalize_TCB (T);
 
-  --  If the task is not terminated, then we simply ignore the call. This
-  --  happens when a user program attempts an unchecked deallocation on
-  --  a non-terminated task.
+  else
+ --  If the task is not terminated, then mark the task as to be freed
+ --  upon termination.
 
-  else
- null;
+ T.Free_On_Termination := True;
   end if;
end Free_Task;
 
@@ -1429,6 +1428,7 @@
procedure Terminate_Task (Self_ID : Task_Id) is
   Environment_Task : constant Task_Id := STPO.Environment_Task;
   Master_of_Task   : Integer;
+  Deallocate   : Boolean;
 
begin
   Debug.Task_Termination_Hook;
@@ -1474,6 +1474,7 @@
   Stack_Guard (Self_ID, False);
 
   Utilities.Make_Passive (Self_ID, Task_Completed => True);
+  Deallocate := Self_ID.Free_On_Termination;
 
   if Single_Lock then
  Unlock_RTS;
@@ -1485,8 +1486,13 @@
   Initialization.Final_Task_Unlock (Self_ID);
 
   --  WARNING: past this point, this thread must assume that the ATCB has
-  --  been deallocated. It should not be accessed again.
+  --  been deallocated, and can't access it anymore (which is why we have
+  --  saved the Free_On_Termination flag in a temporary variable).
 
+  if Deallocate then
+ Free_Task (Self_ID);
+  end if;
+
   if Master_of_Task > 0 then
  STPO.Exit_Task;
   end if;
Index: s-taskin.ads
===
--- s-taskin.ads(revision 178565)
+++ s-taskin.ads(working copy)
@@ -1150,6 +1150,12 @@
   --
   --  Protection: Self.L. Once a task has set Self.Stage to Completing, it
   --  has exclusive access to this field.
+
+  Free_On_Termination : Boolean := False;
+  --  Deallocate the ATCB when the task terminates. This flag is normally
+  --  False, and is set True when Unchecked_Deallocation is called on a
+  --  non-terminated task so that the associated storage is automatically
+  --  reclaimed when the task terminates.
end record;
 



[Ada] Refine error messages for illegal placement of [Type_]Invariant aspect

2011-09-06 Thread Arnaud Charlet
Aspect/pragma [Type_]Invariant may be placed illegally on a public type or
a private type without public declaration. This patch gives a different error
message for each case. Now, compiling the following code generates 4 different
messages:

$ gcc -c -gnat12 inv.ads
inv.ads:5:11: aspect "Type_Invariant" only allowed for private type
inv.ads:9:11: aspect "Invariant" only allowed for private type
inv.ads:14:11: aspect "Type_Invariant" only allowed for private type declared 
in visible part
inv.ads:18:11: aspect "Invariant" only allowed for private type declared in 
visible part
---
 1  package Inv is
 2 type Wrap is record
 3X : Integer;
 4 end record
 5   with Type_Invariant => X mod 2 = 1;
 6 type Wrap2 is record
 7X : Integer;
 8 end record
 9   with Invariant => X mod 2 = 1;
10  private
11 type Wrap3 is record
12X : Integer;
13 end record
14   with Type_Invariant => X mod 2 = 1;
15 type Wrap4 is record
16X : Integer;
17 end record
18   with Invariant => X mod 2 = 1;
19  end Inv;

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

2011-09-06  Yannick Moy  

* sem_ch13.adb (Analyze_Aspect_Specifications, case
Aspect_Invariant): Do not issue error at this point on illegal
pragma placement, as this is checked later on when analyzing
the corresponding pragma.
* sem_prag.adb (Error_Pragma_Arg_Alternate_Name): New procedure
similar to Error_Pragma_Arg, except the source name of the
aspect/pragma to use in warnings may be equal to parameter
Alt_Name (Analyze_Pragma, case Pragma_Invariant): refine error
message to distinguish source name of pragma/aspect, and whether
the illegality resides in the type being public, or being private
without a public declaration

Index: sem_prag.adb
===
--- sem_prag.adb(revision 178579)
+++ sem_prag.adb(working copy)
@@ -29,63 +29,65 @@
 --  to complete the syntax checks. Certain pragmas are handled partially or
 --  completely by the parser (see Par.Prag for further details).
 
-with Atree;use Atree;
-with Casing;   use Casing;
-with Checks;   use Checks;
-with Csets;use Csets;
-with Debug;use Debug;
-with Einfo;use Einfo;
-with Elists;   use Elists;
-with Errout;   use Errout;
-with Exp_Dist; use Exp_Dist;
-with Exp_Util; use Exp_Util;
-with Freeze;   use Freeze;
-with Lib;  use Lib;
-with Lib.Writ; use Lib.Writ;
-with Lib.Xref; use Lib.Xref;
-with Namet.Sp; use Namet.Sp;
-with Nlists;   use Nlists;
-with Nmake;use Nmake;
-with Opt;  use Opt;
-with Output;   use Output;
-with Par_SCO;  use Par_SCO;
-with Restrict; use Restrict;
-with Rident;   use Rident;
-with Rtsfind;  use Rtsfind;
-with Sem;  use Sem;
-with Sem_Aux;  use Sem_Aux;
-with Sem_Ch3;  use Sem_Ch3;
-with Sem_Ch6;  use Sem_Ch6;
-with Sem_Ch8;  use Sem_Ch8;
-with Sem_Ch12; use Sem_Ch12;
-with Sem_Ch13; use Sem_Ch13;
-with Sem_Disp; use Sem_Disp;
-with Sem_Dist; use Sem_Dist;
-with Sem_Elim; use Sem_Elim;
-with Sem_Eval; use Sem_Eval;
-with Sem_Intr; use Sem_Intr;
-with Sem_Mech; use Sem_Mech;
-with Sem_Res;  use Sem_Res;
-with Sem_Type; use Sem_Type;
-with Sem_Util; use Sem_Util;
-with Sem_VFpt; use Sem_VFpt;
-with Sem_Warn; use Sem_Warn;
-with Stand;use Stand;
-with Sinfo;use Sinfo;
-with Sinfo.CN; use Sinfo.CN;
-with Sinput;   use Sinput;
-with Snames;   use Snames;
-with Stringt;  use Stringt;
-with Stylesw;  use Stylesw;
+with System.Case_Util;
+
+with Atree;use Atree;
+with Casing;   use Casing;
+with Checks;   use Checks;
+with Csets;use Csets;
+with Debug;use Debug;
+with Einfo;use Einfo;
+with Elists;   use Elists;
+with Errout;   use Errout;
+with Exp_Dist; use Exp_Dist;
+with Exp_Util; use Exp_Util;
+with Freeze;   use Freeze;
+with Lib;  use Lib;
+with Lib.Writ; use Lib.Writ;
+with Lib.Xref; use Lib.Xref;
+with Namet.Sp; use Namet.Sp;
+with Nlists;   use Nlists;
+with Nmake;use Nmake;
+with Opt;  use Opt;
+with Output;   use Output;
+with Par_SCO;  use Par_SCO;
+with Restrict; use Restrict;
+with Rident;   use Rident;
+with Rtsfind;  use Rtsfind;
+with Sem;  use Sem;
+with Sem_Aux;  use Sem_Aux;
+with Sem_Ch3;  use Sem_Ch3;
+with Sem_Ch6;  use Sem_Ch6;
+with Sem_Ch8;  use Sem_Ch8;
+with Sem_Ch12; use Sem_Ch12;
+with Sem_Ch13; use Sem_Ch13;
+with Sem_Disp; use Sem_Disp;
+with Sem_Dist; use Sem_Dist;
+with Sem_Elim; use Sem_Elim;
+with Sem_Eval; use Sem_Eval;
+with Sem_Intr; use Sem_Intr;
+with Sem_Mech; use Sem_Mech;
+with Sem_Res;  

[Ada] Optimize out index check for dynamic arrays in indirect case

2011-09-06 Thread Arnaud Charlet
This small change brings the indirect case on par with the direct case when it
comes to eliminating an index check for dynamic arrays.  No index check will
be generated for the following procedure in default mode:

   type Darray is array (1 .. Q.N) of Long_Float;

   procedure Add (X, Y : access Darray; R : access Darray) is
   begin
  for I in Darray'Range loop
 R(I) := X(I) + Y(I);
  end loop;
   end;

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

2011-09-06  Eric Botcazou  

* checks.adb (Apply_Scalar_Range_Check): Deal with access
type prefix.

Index: checks.adb
===
--- checks.adb  (revision 178565)
+++ checks.adb  (working copy)
@@ -1877,6 +1877,9 @@
   if Is_Subscr_Ref then
  Arr := Prefix (Parnt);
  Arr_Typ := Get_Actual_Subtype_If_Available (Arr);
+ if Is_Access_Type (Arr_Typ) then
+Arr_Typ := Directly_Designated_Type (Arr_Typ);
+ end if;
   end if;
 
   if not Do_Range_Check (Expr) then


[Ada] Class-wide operations in instantations

2011-09-06 Thread Arnaud Charlet
AI05-0071 stipulates that: In an instance, if the actual for a formal type FT
with unknown discriminants is a class-wide type CT, and the generic has a
formal subprogram with a box for a primitive operation of FT, the corresponding
actual subprogram denoted by the default is a class-wide operation whose body
is a dispatching call. This body is analyzed when the operation is frozen, and
is attached to the Freeze_Actions of the corresponding entity. Freeze actions
are not processed when expansion is disabled, so the body should not be placed
in the tree in that case, to prevent problems in the back-end when compiling
with -gnatct.

The following must compile quietly:

   gcc -c -gnat05 -gnatct pck.ads

---
with Ada.Containers.Indefinite_Doubly_Linked_Lists;
with Ada.Finalization; use Ada.Finalization;

package Pck is

   type Editor_Buffer is abstract new Controlled with null record;

   overriding function "="
 (This : Editor_Buffer; Buffer : Editor_Buffer) return Boolean;

   package Buffer_Lists is new Ada.Containers.Indefinite_Doubly_Linked_Lists
 (Editor_Buffer'Class);

end Pck;

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

2011-09-06  Ed Schonberg  

* sem_ch8.adb (Check_Class_Wide_Actual): Do not generate body of
class-wide operation if expansion is not enabled.

Index: sem_ch8.adb
===
--- sem_ch8.adb (revision 178565)
+++ sem_ch8.adb (working copy)
@@ -1859,9 +1859,12 @@
   Statements (Handled_Statement_Sequence (New_Body)));
 
 --  The generated body does not freeze. It is analyzed when the
---  generated operation is frozen.
+--  generated operation is frozen. This body is only needed if
+--  expansion is enabled.
 
-Append_Freeze_Action (Defining_Entity (New_Decl), New_Body);
+if Expander_Active then
+   Append_Freeze_Action (Defining_Entity (New_Decl), New_Body);
+end if;
 
 Result := Defining_Entity (New_Decl);
  end if;


[PATCH] SCCVN TLC

2011-09-06 Thread Richard Guenther

Some cleanups before I touch this code.

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

Richard.

2011-09-06  Richard Guenther  

* tree-ssa-sccvn.c (visit_use): CSE stmt pieces and simplify
matching.

Index: gcc/tree-ssa-sccvn.c
===
--- gcc/tree-ssa-sccvn.c(revision 178570)
+++ gcc/tree-ssa-sccvn.c(working copy)
@@ -3043,16 +3043,17 @@ visit_use (tree use)
changed = defs_to_varying (stmt);
   else if (is_gimple_assign (stmt))
{
+ enum tree_code code = gimple_assign_rhs_code (stmt);
  tree lhs = gimple_assign_lhs (stmt);
+ tree rhs1 = gimple_assign_rhs1 (stmt);
  tree simplified;
 
  /* Shortcut for copies. Simplifying copies is pointless,
 since we copy the expression and value they represent.  */
- if (gimple_assign_copy_p (stmt)
- && TREE_CODE (gimple_assign_rhs1 (stmt)) == SSA_NAME
+ if (code == SSA_NAME
  && TREE_CODE (lhs) == SSA_NAME)
{
- changed = visit_copy (lhs, gimple_assign_rhs1 (stmt));
+ changed = visit_copy (lhs, rhs1);
  goto done;
}
  simplified = try_to_simplify (stmt);
@@ -3119,24 +3120,22 @@ visit_use (tree use)
   /* We can substitute SSA_NAMEs that are live over
  abnormal edges with their constant value.  */
   && !(gimple_assign_copy_p (stmt)
-   && is_gimple_min_invariant (gimple_assign_rhs1 (stmt)))
+   && is_gimple_min_invariant (rhs1))
   && !(simplified
&& is_gimple_min_invariant (simplified))
   && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (lhs))
  /* Stores or copies from SSA_NAMEs that are live over
 abnormal edges are a problem.  */
- || (gimple_assign_single_p (stmt)
- && TREE_CODE (gimple_assign_rhs1 (stmt)) == SSA_NAME
- && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (gimple_assign_rhs1 
(stmt
+ || (code == SSA_NAME
+ && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rhs1)))
changed = defs_to_varying (stmt);
- else if (REFERENCE_CLASS_P (lhs) || DECL_P (lhs))
-   {
- changed = visit_reference_op_store (lhs, gimple_assign_rhs1 
(stmt), stmt);
-   }
+ else if (REFERENCE_CLASS_P (lhs)
+  || DECL_P (lhs))
+   changed = visit_reference_op_store (lhs, rhs1, stmt);
  else if (TREE_CODE (lhs) == SSA_NAME)
{
  if ((gimple_assign_copy_p (stmt)
-  && is_gimple_min_invariant (gimple_assign_rhs1 (stmt)))
+  && is_gimple_min_invariant (rhs1))
  || (simplified
  && is_gimple_min_invariant (simplified)))
{
@@ -3144,11 +3143,11 @@ visit_use (tree use)
  if (simplified)
changed = set_ssa_val_to (lhs, simplified);
  else
-   changed = set_ssa_val_to (lhs, gimple_assign_rhs1 (stmt));
+   changed = set_ssa_val_to (lhs, rhs1);
}
  else
{
- switch (get_gimple_rhs_class (gimple_assign_rhs_code (stmt)))
+ switch (get_gimple_rhs_class (code))
{
case GIMPLE_UNARY_RHS:
case GIMPLE_BINARY_RHS:
@@ -3156,25 +3155,24 @@ visit_use (tree use)
  changed = visit_nary_op (lhs, stmt);
  break;
case GIMPLE_SINGLE_RHS:
- switch (TREE_CODE_CLASS (gimple_assign_rhs_code (stmt)))
+ switch (TREE_CODE_CLASS (code))
{
case tcc_reference:
  /* VOP-less references can go through unary case.  */
- if ((gimple_assign_rhs_code (stmt) == REALPART_EXPR
-  || gimple_assign_rhs_code (stmt) == IMAGPART_EXPR
-  || gimple_assign_rhs_code (stmt) == 
VIEW_CONVERT_EXPR)
- && TREE_CODE (TREE_OPERAND (gimple_assign_rhs1 
(stmt), 0)) == SSA_NAME)
+ if ((code == REALPART_EXPR
+  || code == IMAGPART_EXPR
+  || code == VIEW_CONVERT_EXPR)
+ && TREE_CODE (TREE_OPERAND (rhs1, 0)) == SSA_NAME)
{
  changed = visit_nary_op (lhs, stmt);
  break;
}
  /* Fallthrough.  */
case tcc_declaration:
- changed = visit_reference_op_load
- (lhs, gimple_assign_rhs1 (stmt), stmt);
+  

[v3] libstdc++/50257

2011-09-06 Thread Paolo Carlini

Hi,

tested x86_64-linux, committed to mainline. See audit trail for details...

Thanks,
Paolo.

/
2011-09-06  Paolo Carlini  

PR libstdc++/50257
* include/bits/hashtable_policy.h (_Prime_rehash_policy::
_M_next_bkt): Optimize for small argument.
Index: include/bits/hashtable_policy.h
===
--- include/bits/hashtable_policy.h (revision 178574)
+++ include/bits/hashtable_policy.h (working copy)
@@ -427,8 +427,15 @@
   _Prime_rehash_policy::
   _M_next_bkt(std::size_t __n) const
   {
-const unsigned long __p = *std::lower_bound(__prime_list, __prime_list
-   + _S_n_primes, __n);
+// Optimize lookups involving the first elements of __prime_list.
+// (useful to speed-up, eg, constructors)
+static const unsigned char __fastbkt[12]
+  = { 2, 2, 2, 3, 5, 5, 7, 7, 11, 11, 11, 11 };
+
+const unsigned long __p
+  = __n <= 11 ? __fastbkt[__n]
+  : *std::lower_bound(__prime_list + 5,
+ __prime_list + _S_n_primes, __n);
 _M_next_resize =
   static_cast(__builtin_floor(__p * _M_max_load_factor));
 return __p;


[Ada] Implement No_Implementation_Identifiers/Extensions

2011-09-06 Thread Arnaud Charlet
This patch implements AI 246, restriction No_Implemention_Identifiers
and the related profile No_Implementation_Extensions. The restriction
disallows references to implementation defined identifiers (such as the
ones in package Interfaces). The profile activates the full set of
restrictions with names No_Implementation_*.

It also implements pragma Implementation_Defined, which is used
in the run-time to flag implenentation defined entities.

The following two tests show these new features in action:

 1. pragma Restrictions (No_Implementation_Identifiers);
 2. with Interfaces; use Interfaces;
 3. package UserID is
 4.X : Long_Long_Integer;
   |
>>> violation of restriction
"No_Implementation_Identifiers" at line 1

 5.Y : Integer_32;
   |
>>> violation of restriction
"No_Implementation_Identifiers" at line 1

 6.Z : Long_Float;
 7.U : Unsigned_32 := 187;
   |
>>> violation of restriction
"No_Implementation_Identifiers" at line 1

 8.P : Unsigned_32 := Shift_Right (U, 3);
   1  2
>>> violation of restriction
"No_Implementation_Identifiers" at line 1
>>> violation of restriction
"No_Implementation_Identifiers" at line 1

 9. end UserId;

 1. pragma Profile (No_Implementation_Extensions);
 2. with Interfaces; use Interfaces;
 3. package UserID2 is
 4.X : Long_Long_Integer;
   |
>>> violation of restriction
"No_Implementation_Identifiers", from profile
"No_Implementation_Extensions" at line 1

 5.Y : Integer_32;
   |
>>> violation of restriction
"No_Implementation_Identifiers", from profile
"No_Implementation_Extensions" at line 1

 6.Z : Long_Float;
 7.U : Unsigned_32 := 187;
   |
>>> violation of restriction
"No_Implementation_Identifiers", from profile
"No_Implementation_Extensions" at line 1

 8.P : Unsigned_32 := Shift_Right (U, 3);
   1  2
>>> violation of restriction
"No_Implementation_Identifiers", from profile
"No_Implementation_Extensions" at line 1
>>> violation of restriction
"No_Implementation_Identifiers", from profile
"No_Implementation_Extensions" at line 1

 9. end UserId2;

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

2011-09-06  Robert Dewar  

* a-cbprqu.ads, a-cbsyqu.ads, a-cuprqu.ads, a-cusyqu.ads,
a-intnam-aix.ads, a-intnam-darwin.ads, a-intnam-dummy.ads,
a-intnam-freebsd.ads, a-intnam-hpux.ads, a-intnam-irix.ads,
a-intnam-linux.ads, a-intnam-lynxos.ads, a-intnam-mingw.ads,
a-intnam-ppc.ads, a-intnam-solaris.ads, a-intnam-tru64.ads,
a-intnam-vms.ads, a-intnam-vxworks.ads, a-intnam.ads, interfac.ads,
cstand.adb, s-maccod.ads: Mark all entities as Implementation_Defined
* einfo.ads, einfo.adb (Is_Implementation_Defined): New flag
* par-prag.adb: Add dummy entry for pragma Implementation_Defined
* s-rident.ads: Add new restriction No_Implementation_Identifiers
Add new profile No_Implementation_Extensions
* sem_prag.adb: Implement pragma Implementation_Defined Implement
profile No_Implementation_Extensions
* sem_util.adb: Minor reformatting (Set_Entity_With_Style_Check):
Check violation of restriction No_Implementation_Identifiers
* snames.ads-tmpl: Add entries for pragma Implementation_Defined
Add entry for Name_No_Implementation_Extensions

Index: s-maccod.ads
===
--- s-maccod.ads(revision 178565)
+++ s-maccod.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. --
 --  --
 -- 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- --
@@ -36,6 +36,10 @@
 package System.Machine_Code is
pragma Pure;
 
+   --  All identifiers in this unit are implementation defined
+
+   pragma Implementation_Defined;
+
type Asm_Input_Operand  is private;
type Asm_Output_Operand is private;
--  These types are never used directly, they are declared only so that
Index: a-intnam-dummy.ads
===
--

[rs6000] Fix PR target/50091

2011-09-06 Thread Eric Botcazou
Hi,

this is a regression present on the mainline/4.6/4.5 branches.  I overlooked 
the -mregnames business when I changed the probe_stack pattern and, while 
this silently works on most platforms, this breaks on Darwin because of the 
awkward assembler.

Tested on PowerPC/Darwin by Iain and on PowerPC/Linux by me.  OK for mainline 
and the 4.6/4.5 branches?


2011-09-06  Eric Botcazou  
Iain Sandoe  

PR target/50091
* config/rs6000/rs6000.md (probe_stack): Use explicit operand.
* config/rs6000/rs6000.c (output_probe_stack_range): Likewise.


-- 
Eric Botcazou
Index: config/rs6000/rs6000.c
===
--- config/rs6000/rs6000.c	(revision 178488)
+++ config/rs6000/rs6000.c	(working copy)
@@ -19303,7 +19303,8 @@ output_probe_stack_range (rtx reg1, rtx
   output_asm_insn ("{cal %0,%1(%0)|addi %0,%0,%1}", xops);
 
   /* Probe at TEST_ADDR and branch.  */
-  output_asm_insn ("{st|stw} 0,0(%0)", xops);
+  xops[1] = gen_rtx_REG (Pmode, 0);
+  output_asm_insn ("{st|stw} %1,0(%0)", xops);
   fprintf (asm_out_file, "\tb ");
   assemble_name_raw (asm_out_file, loop_lab);
   fputc ('\n', asm_out_file);
Index: config/rs6000/rs6000.md
===
--- config/rs6000/rs6000.md	(revision 178488)
+++ config/rs6000/rs6000.md	(working copy)
@@ -13049,7 +13049,11 @@ (define_insn "probe_stack"
   [(set (match_operand 0 "memory_operand" "=m")
 (unspec [(const_int 0)] UNSPEC_PROBE_STACK))]
   ""
-  "{st%U0%X0|stw%U0%X0} 0,%0"
+  "*
+{
+  operands[1] = gen_rtx_REG (Pmode, 0);
+  return \"{st%U0%X0|stw%U0%X0} %1,%0\";
+}"
   [(set_attr "type" "store")
(set_attr "length" "4")])
 


[Ada] Implementation of Ada 2012 type invariants

2011-09-06 Thread Arnaud Charlet
The final version of the Ada 2012 RM specifies that a type invariant can be
given in the private part of a package, on the completion of a private type
declaration.
The following must compile quietly:

package Inv is
   type List is private;
private
   type Length_T is new Integer;
   type Array_T is array (Length_T range <>) of Integer;
   type Array_Ptr_T is access Array_T;
   type List is record
  Length : Length_T;
  Item   : Array_Ptr_T;
   end record
 with Type_Invariant =>
   List.Item'First = 1 and List.Item'Last = List.Length;
end Inv;

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

2011-09-06  Ed Schonberg  

* sem_prag.adb (Analyze_Pragma, case Type_Invariant): A type invariant
is allowed on a full type declaration if it is the completion of
a private declarations.
* sem_ch13.adb (Analyze_Aspect_Specifications): An invariant
aspect is allowed on a full type declaration in the private part
of a package.

Index: sem_prag.adb
===
--- sem_prag.adb(revision 178565)
+++ sem_prag.adb(working copy)
@@ -10088,10 +10088,21 @@
 if Typ = Any_Type then
return;
 
-elsif not Ekind_In (Typ, E_Private_Type,
+--  An invariant must apply to a private type, or appear in the
+--  private part of a package spec and apply to a completion.
+
+elsif Ekind_In (Typ, E_Private_Type,
  E_Record_Type_With_Private,
  E_Limited_Private_Type)
 then
+   null;
+
+elsif In_Private_Part (Current_Scope)
+  and then Has_Private_Declaration (Typ)
+then
+   null;
+
+else
Error_Pragma_Arg
  ("pragma% only allowed for private type", Arg1);
 end if;
Index: sem_ch13.adb
===
--- sem_ch13.adb(revision 178565)
+++ sem_ch13.adb(working copy)
@@ -1289,11 +1289,22 @@
when Aspect_Invariant  |
 Aspect_Type_Invariant =>
 
-  --  Check placement legality
+  --  Check placement legality: An invariant must apply to a
+  --  private type, or appear in the private part of a spec.
+  --  Analysis of the pragma will verify that in the private
+  --  part it applies to a completion.
 
-  if not Nkind_In (N, N_Private_Type_Declaration,
+  if Nkind_In (N, N_Private_Type_Declaration,
   N_Private_Extension_Declaration)
   then
+ null;
+
+  elsif Nkind (N) = N_Full_Type_Declaration
+and then In_Private_Part (Current_Scope)
+  then
+ null;
+
+  else
  Error_Msg_N
("invariant aspect must apply to a private type", N);
   end if;


[Ada] Add support to load references of imported entities

2011-09-06 Thread Arnaud Charlet
This patch adds the support needed to load references of entities
imported from other languages. This functionality is required by
tools processing ALI files (for example GPS).

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

2011-09-06  Javier Miranda  

* ali.adb (Scan_ALI): Add missing support to load references of
entities imported from other languages.
* ali.ads (Xref_Record): Adding new fields to store the language and
name of an imported entity.
* lib-xref.adb (Output_Import_Export_Info): Fix typo
in comment.

Index: ali.adb
===
--- ali.adb (revision 178565)
+++ ali.adb (working copy)
@@ -504,6 +504,10 @@
 or else Nextc = '<' or else Nextc = '>'
 or else Nextc = '=';
 
+  --  Terminate on comma
+
+  exit when Nextc = ',';
+
   --  Terminate if left bracket not part of wide char sequence
   --  Note that we only recognize brackets notation so far ???
 
@@ -2389,12 +2393,21 @@
 
 --  Imported entities reference as in:
 --494b25
---  ??? Simply skipped for now
 
 if Nextc = '<' then
-   while Getc /= '>' loop
-  null;
-   end loop;
+   Skipc;
+   XR.Imported_Lang := Get_Name;
+
+   pragma Assert (Nextc = ',');
+   Skipc;
+
+   XR.Imported_Name := Get_Name;
+
+   pragma Assert (Nextc = '>');
+   Skipc;
+else
+   XR.Imported_Lang := No_Name;
+   XR.Imported_Name := No_Name;
 end if;
 
 XR.Col   := Get_Nat;
Index: ali.ads
===
--- ali.ads (revision 178565)
+++ ali.ads (working copy)
@@ -975,6 +975,10 @@
   -- ref1 is a reference to an entity that was instantied at ref2.
   -- ref2 itself is also the result of an instantiation, that took
   -- place at ref3
+
+  Imported_Lang : Name_Id := No_Name;
+  Imported_Name : Name_Id := No_Name;
+  --  Language and name of imported entity reference
end record;
 
package Xref is new Table.Table (
Index: lib-xref.adb
===
--- lib-xref.adb(revision 178565)
+++ lib-xref.adb(working copy)
@@ -1163,7 +1163,7 @@
 
   procedure Output_Import_Export_Info (Ent : Entity_Id);
   --  Output language and external name information for an interfaced
-  --  entity, using the format ,
+  --  entity, using the format 
 
   
   -- Get_Type_Reference --


[Ada] Use oscons circuitry to define pthread types on GNU/Linux

2011-09-06 Thread Arnaud Charlet
Simplify s-linux*.ads files by using s-oscons-tmplt.c to generate proper
definition of pthread_mutex_t.

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

2011-09-06  Pascal Obry  

* s-linux.ads, s-linux-alpha.ads, s-linux-hppa.ads, s-linux-mipsel.ads,
s-linux-sparc.ads: Remove hard coded and now wrong definitions.
* s-oscons-tmplt.c: Add support for generating pthread related
types size on GNU/Linux as done for Darwin.
* s-osinte-linux.ads: Use s-oscons to define the pthread types.

Index: s-osinte-linux.ads
===
--- s-osinte-linux.ads  (revision 178565)
+++ s-osinte-linux.ads  (working copy)
@@ -41,6 +41,7 @@
 with Ada.Unchecked_Conversion;
 with Interfaces.C;
 with System.Linux;
+with System.OS_Constants;
 
 package System.OS_Interface is
pragma Preelaborate;
@@ -557,35 +558,31 @@
end record;
pragma Convention (C, timespec);
 
-   type pthread_attr_t is record
-  detachstate   : int;
-  schedpolicy   : int;
-  schedparam: struct_sched_param;
-  inheritsched  : int;
-  scope : int;
-  guardsize : size_t;
-  stackaddr_set : int;
-  stackaddr : System.Address;
-  stacksize : size_t;
-   end record;
+   type unsigned_long_long_t is mod 2 ** 64;
+   --  Local type only used to get it's 'Alignment below
+
+   type pthread_attr_t is
+ array (1 .. OS_Constants.PTHREAD_ATTR_SIZE) of unsigned_char;
pragma Convention (C, pthread_attr_t);
+   for pthread_attr_t'Alignment use Interfaces.C.unsigned_long'Alignment;
 
-   type pthread_condattr_t is record
-  dummy : int;
-   end record;
+   type pthread_condattr_t is
+ array (1 .. OS_Constants.PTHREAD_CONDATTR_SIZE) of unsigned_char;
pragma Convention (C, pthread_condattr_t);
+   for pthread_condattr_t'Alignment use Interfaces.C.int'Alignment;
 
-   type pthread_mutexattr_t is record
-  mutexkind : int;
-   end record;
+   type pthread_mutexattr_t is
+ array (1 .. OS_Constants.PTHREAD_MUTEXATTR_SIZE) of unsigned_char;
pragma Convention (C, pthread_mutexattr_t);
+   for pthread_mutexattr_t'Alignment use Interfaces.C.int'Alignment;
 
-   type pthread_mutex_t is new System.Linux.pthread_mutex_t;
+   type pthread_mutex_t is
+ array (1 .. OS_Constants.PTHREAD_MUTEX_SIZE) of unsigned_char;
+   pragma Convention (C, pthread_mutex_t);
+   for pthread_mutex_t'Alignment use Interfaces.C.unsigned_long'Alignment;
 
-   type unsigned_long_long_t is mod 2 ** 64;
-   --  Local type only used to get it's 'Alignment below
-
-   type pthread_cond_t is array (0 .. 47) of unsigned_char;
+   type pthread_cond_t is
+ array (1 .. OS_Constants.PTHREAD_COND_SIZE) of unsigned_char;
pragma Convention (C, pthread_cond_t);
for pthread_cond_t'Alignment use unsigned_long_long_t'Alignment;
 
Index: s-linux.ads
===
--- s-linux.ads (revision 178565)
+++ s-linux.ads (working copy)
@@ -6,7 +6,7 @@
 --  --
 --  S p e c --
 --  --
---  Copyright (C) 2008-2009, Free Software Foundation, Inc. --
+--  Copyright (C) 2008-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- --
@@ -101,19 +101,4 @@
SA_SIGINFO  : constant := 16#04#;
SA_ONSTACK  : constant := 16#0800#;
 
-   type struct_pthread_fast_lock is record
-  status   : Long_Integer;
-  spinlock : Integer;
-   end record;
-   pragma Convention (C, struct_pthread_fast_lock);
-
-   type pthread_mutex_t is record
-  m_reserved : Integer;
-  m_count: Integer;
-  m_owner: System.Address;
-  m_kind : Integer;
-  m_lock : struct_pthread_fast_lock;
-   end record;
-   pragma Convention (C, pthread_mutex_t);
-
 end System.Linux;
Index: s-linux-alpha.ads
===
--- s-linux-alpha.ads   (revision 178565)
+++ s-linux-alpha.ads   (working copy)
@@ -6,7 +6,7 @@
 --  --
 --  S p e c --
 --  --
--- Copyright (C) 2009, Free Software Foundation, Inc.   --
+-- Copyright (C) 2009-2011, Free Software Foundation, Inc.  --
 --  --
 -- GNARL is free software; you can  redistribute it  and/or modify it under --
 -- ter

[Ada] Inlining calls that return unconstrained arrays

2011-09-06 Thread Arnaud Charlet
This patch fixes a crash in the compiler when inlining a function call that
returns an unconstrained array in the context of an assignment created for an
extended return statement. The patch also optimizes the case where the target
of the assignment is a selected component, and avoid the use of an intermediate
temporary in the expansion.

The following must compile quietly:

with Types; use Types;

package body My_Simulink_Model is

   procedure Compute (Input  : Input_Type;
  Output : out Output_Type) is
   begin
  Output.O := Sum (Input.M1, Input.M2);
   end Compute;

   procedure Compute_Ext_Return (Input  : Input_Type;
 Output : out Output_Type) is
   begin
  Output.O := Sum_Ext_Return (Input.M1, Input.M2);
   end Compute_Ext_Return;

   procedure Compute_Inline (Input  : Input_Type;
 Output : out Output_Type) is
   begin
  for I in Output.O'Range (1) loop
 for J in Output.O'Range (2) loop
Output.O (I, J) := Input.M1 (I, J) + Input.M2 (I, J);
 end loop;
  end loop;
   end Compute_Inline;
end My_Simulink_Model;
---
with Types;
package My_Simulink_Model is
   subtype Range_1 is Integer range 1 .. 2;
   subtype Range_2 is Integer range 1 .. 3;

   subtype My_Matrix is Types.Integer_Matrix_2D
 (Range_1, Range_2);

   type Input_Type is record
  M1 : My_Matrix;
  M2 : My_Matrix;
   end record;

   type Output_Type is record
  O : My_Matrix;
   end record;

   procedure Compute (Input  : Input_Type;
  Output : out Output_Type);

   procedure Compute_Ext_Return (Input  : Input_Type;
 Output : out Output_Type);

   procedure Compute_Inline (Input  : Input_Type;
 Output : out Output_Type);

end My_Simulink_Model;
---
package Types is
   type Integer_Matrix_2D is array (Integer range <>, Integer range <>)
 of Integer;

   function Sum (Left, Right : Integer_Matrix_2D) return Integer_Matrix_2D;
   pragma Precondition (Left'Length (1) = Right'Length (1)
and Left'Length (2) = Right'Length (2));
   pragma Inline_Always (Sum);
   function Sum_Ext_Return (Left, Right : Integer_Matrix_2D)
return Integer_Matrix_2D;
   pragma Precondition (Left'Length (1) = Right'Length (1)
and Left'Length (2) = Right'Length (2));
   pragma Inline_Always (Sum_Ext_Return);
end Types;
---
package body Types is
   function Sum (Left, Right : Integer_Matrix_2D) return Integer_Matrix_2D is
  Res : Integer_Matrix_2D (Left'Range (1), Left'Range (2));
   begin
  for I in Res'Range (1) loop
 for J in Res'Range (2) loop
Res (I, J) := Left (I, J) + Right (I, J);
 end loop;
  end loop;
  return Res;
   end Sum;

   function Sum_Ext_Return
 (Left, Right : Integer_Matrix_2D)
  return Integer_Matrix_2D
   is
   begin
  return Res : Integer_Matrix_2D (Left'Range (1), Left'Range (2)) do
 for I in Res'Range (1) loop
for J in Res'Range (2) loop
   Res (I, J) := Left (I, J) + Right (I, J);
end loop;
 end loop;
  end return;
   end Sum_Ext_Return;
end Types;

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

2011-09-06  Ed Schonberg  

* exp_ch6.adb (Expand_Inlined_Call): Handle properly the case
where the return type is an unconstrained array and the context
is an assignment. Optimize the case when the target of the
assignment is a selected component.

Index: exp_ch6.adb
===
--- exp_ch6.adb (revision 178572)
+++ exp_ch6.adb (working copy)
@@ -4031,12 +4031,20 @@
 
 Insert_After (Parent (Entity (N)), Blk);
 
+ --  If the context is an assignment, and the left-hand side is
+ --  free of side-effects, the replacement is also safe.
+ --  Can this be generalized further???
+
  elsif Nkind (Parent (N)) = N_Assignment_Statement
and then
 (Is_Entity_Name (Name (Parent (N)))
or else
   (Nkind (Name (Parent (N))) = N_Explicit_Dereference
-and then Is_Entity_Name (Prefix (Name (Parent (N))
+   and then Is_Entity_Name (Prefix (Name (Parent (N)
+
+   or else
+   (Nkind (Name (Parent (N))) = N_Selected_Component
+   and then Is_Entity_Name (Prefix (Name (Parent (N))
  then
 --  Replace assignment with the block
 
@@ -4201,14 +4209,19 @@
  Set_Declarations (Blk, New_List);
   end if;
 
-  --  For the unconstrained case, capture the name of the local
-  --  variable that holds the result. This must be the first declaration
+  --  For the unconstrained case, capture the name of the local variable
+  --  that holds the r

  1   2   >