Re: [PATCH] PR50325 store_bit_field: Fix for big endian targets

2011-11-21 Thread Eric Botcazou
> Yeah, I don't think constants are any different here.  One fix might be
> to use simplify_expand_binop instead of extract_bit_field, as per the
> patch below.  The patch also restricts the shifting to forward walks,
> as discussed in the PR trail.

This looks fine to me, please apply (with a few words added to the comment, 
e.g. "...doesn't have full wordsize and we transfer in memory order...").

> The point of r8007 seems to be that WORDS_BIG_ENDIAN doesn't apply to
> BLKmode fieldmodes, but there must surely be some endianness involved
> somewhere, given that we're extracting words from a multiword value?

I think that BLKmode objects are treated as left-justified in memory order, 
i.e. left-justified on big-endian and right-justified on little-endian.

> So if possible, I'd prefer to revert the original patch for this PR
> and instead adjust the "backwards" test.  I'm just not sure whether
> it should be "WORDS_BIG_ENDIAN" (reverting r8007, which was obviously
> applied for a reason) or something like:
>
> (fieldmode == BLKmode ? BYTES_BIG_ENDIAN : WORDS_BIG_ENDIAN)

This seems to be a little risky for stage 3 though.

-- 
Eric Botcazou


Re: RFA: libgcc: move emutls.c from LIB2ADDEH et al to LIB2ADD

2011-11-21 Thread Paolo Bonzini

On 11/21/2011 01:53 AM, Hans-Peter Nilsson wrote:

Spotted while looking into
  (and
yes, I fixed the ChangeLog typo before commit) and also
mentioned at.

Emulating TLS has nothing to do with exception-handling, nor is
there something that might throw while calling one of its
functions, so no need to pass -fexceptions and thus lower
optimizations (which happens at least for targets with
delayed-slots) or carry around exception tables.  Tested cross
to cris-elf, no regressions.

Ok to commit?


Ok.

Paolo



Re: [Patch RFC Darwin] provide the crt stuff for tm.

2011-11-21 Thread Iain Sandoe

Hi Richard, Mike,

On 21 Nov 2011, at 00:12, Richard Henderson wrote:


On 11/20/2011 01:27 PM, Iain Sandoe wrote:

comments/OK for trunk?
Iain

gcc:

   * config/darwin.h (ENDFILE_SPEC): New.
   (DARWIN_CRT1_SPEC): Add crttms.o.

libgcc:

   * config/darwin-crt-tm.c: New file.
   * config.host (darwin): Build crttms.o crttme.o to provide
   startup and shutdown for tm clones.
   * config/t-darwin (crttms.o): New build rule.
   (crttme.o): New build rule.


Ok by me; Mike will want to look at the Darwin specifics.


Actually, two questions have come to mind overnight;

1. should I be applying this constructor/destructor pair to shared  
libraries as well?

 (the specs need minor amendment)

2. Mike: I think to append "regular,no_dead_strip" to the section  
text, OK to that addition?


thanks
Iain



CFT: Re: libgcc: why emutls.c in LIB2ADDEH instead of LIB2ADD?

2011-11-21 Thread Hans-Peter Nilsson
> From: Paolo Bonzini 
> Sender: Paolo Bonzini 
> Date: Mon, 21 Nov 2011 10:20:39 +0100

> H-P, can you try bootstrapping your patch on cygwin and/or mingw too 
> before applying it?

Sorry, I don't have that.  Dave?

brgds, H-P


Re: CFT: Re: libgcc: why emutls.c in LIB2ADDEH instead of LIB2ADD?

2011-11-21 Thread Iain Sandoe


On 21 Nov 2011, at 09:34, Hans-Peter Nilsson wrote:


From: Paolo Bonzini 
Sender: Paolo Bonzini 
Date: Mon, 21 Nov 2011 10:20:39 +0100



H-P, can you try bootstrapping your patch on cygwin and/or mingw too
before applying it?


Sorry, I don't have that.  Dave?


The reason it was in libgcc_eh (AFAIK, the original implementation pre- 
dates my GCC days) - is because there can only be one copy of the  
static emutls locking entities in a given exe.   I guess it was felt  
analogous to the "only one unwinder" rule.


note also: Darwin links libgcc.a even when using dynamic libs - it  
provides eprintf (and the out-of-line GPR/FPR save routines for  
powerpc).


(this is not a total show-stopper, we could provide those things some  
other way)


Iain



[Patch testsuite/darwin] adjust new gcov tests for darwin.

2011-11-21 Thread Iain Sandoe
Darwin uses ".private_extern" for hidden visibility, and also we have  
__USER_LABEL_PREFIX__ set to "_".


OK for trunk?
Iain

gcc/testsuite:

* gcc.misc-tests/gcov-16.c: Adjust scan-assembler for Darwin.
* gcc.misc-tests/gcov-17.c: Likewise.
* g++.dg/gcov/gcov-8.C: Likewise.
* g++.dg/gcov/gcov-9.C: Likewise.

Index: gcc/testsuite/gcc.misc-tests/gcov-16.c
===
--- gcc/testsuite/gcc.misc-tests/gcov-16.c  (revision 181539)
+++ gcc/testsuite/gcc.misc-tests/gcov-16.c  (working copy)
@@ -8,4 +8,5 @@ void Foo ()
 {
 }
 
- /* { dg-final { scan-assembler "\\.hidden\t__gcov__Foo" } } */
+ /* { dg-final { scan-assembler "\\.hidden\t__gcov__Foo" { target { ! 
*-*-darwin*  } } } } */
+ /* { dg-final { scan-assembler "\\.private_extern ___gcov__Foo" { target 
*-*-darwin* } } } */
Index: gcc/testsuite/gcc.misc-tests/gcov-17.c
===
--- gcc/testsuite/gcc.misc-tests/gcov-17.c  (revision 181539)
+++ gcc/testsuite/gcc.misc-tests/gcov-17.c  (working copy)
@@ -8,4 +8,5 @@ void __attribute__ ((visibility ("hidden"), weak))
 {
 }
 
-/* { dg-final { scan-assembler "\\.hidden\t__gcov__Foo" } } */
+/* { dg-final { scan-assembler "\\.hidden\t__gcov__Foo" { target { ! 
*-*-darwin*  } } } } */
+/* { dg-final { scan-assembler "\\.private_extern ___gcov__Foo" { target 
*-*-darwin* } } } */
Index: gcc/testsuite/g++.dg/gcov/gcov-8.C
===
--- gcc/testsuite/g++.dg/gcov/gcov-8.C  (revision 181539)
+++ gcc/testsuite/g++.dg/gcov/gcov-8.C  (working copy)
@@ -10,4 +10,5 @@ void X::Fink ()
 {
 }
 
-/* { dg-final { scan-assembler "\\.hidden\t__gcov___ZN1X4FinkEv" } } */
+/* { dg-final { scan-assembler "\\.hidden\t__gcov___ZN1X4FinkEv" { target { ! 
*-*-darwin*  } } } } */
+/* { dg-final { scan-assembler "\\.private_extern ___gcov___ZN1X4FinkEv" { 
target *-*-darwin* } } } */
Index: gcc/testsuite/g++.dg/gcov/gcov-9.C
===
--- gcc/testsuite/g++.dg/gcov/gcov-9.C  (revision 181539)
+++ gcc/testsuite/g++.dg/gcov/gcov-9.C  (working copy)
@@ -10,6 +10,8 @@ extern "C" void (*Foo ()) ()
   return Boo;
 }
 
-/* { dg-final { scan-assembler "\\.hidden\t__gcov___Z3Boov" } } */
+/* { dg-final { scan-assembler "\\.hidden\t__gcov___Z3Boov" { target { ! 
*-*-darwin*  } } } } */
+/* { dg-final { scan-assembler "\\.private_extern ___gcov___Z3Boov" { target 
*-*-darwin* } } } */
 /* { dg-final { scan-assembler "__gcov__Foo:" } } */
-/* { dg-final { scan-assembler-not "\\.hidden\t__gcov__Foo" } } */
+/* { dg-final { scan-assembler-not "\\.hidden\t__gcov__Foo" { target { ! 
*-*-darwin*  } } } } */
+/* { dg-final { scan-assembler-not "\\.private_extern ___gcov__Foo" { target 
*-*-darwin* } } } */






Re: C++ PATCH for c++/48322 (broken handling of variadic parms on multiple levels)

2011-11-21 Thread Paolo Carlini

On 11/21/2011 03:05 AM, Jason Merrill wrote:

On 11/20/2011 08:02 PM, Paolo Carlini wrote:

.. also, I was under the impression that c++/48322 was the only reason
we couldn't write something very simple, thus no __all_convertible, ie,
something using directly:

enable_if<__and_...>::value>::type


Yep, you can do that now.


That would be a great improvement, even if we need to SFINAE separately
for equal sizeofs.


You don't need to, you can just drop the sizeof check now.

Ah great. Thus I tested and committed the below.

Thanks again for the explanations to both of you,
Paolo.

///
2011-11-21  Paolo Carlini  

* include/std/tuple (__conv_types, __one_by_one_convertible,
__all_convertible): Remove.
(tuple<>::tuple(_UElements&&...),
tuple<>::tuple(const tuple<_UElements...>&),
tuple<>::tuple(tuple<_UElements...>&&)): Remove wa for c++/48322.
* testsuite/20_util/uses_allocator/cons_neg.cc: Adjust dg-error
line number.
Index: include/std/tuple
===
--- include/std/tuple   (revision 181554)
+++ include/std/tuple   (working copy)
@@ -69,35 +69,6 @@
 struct __add_r_ref<_Tp&>
 { typedef _Tp& type; };
 
-  // To work around c++/49225 aka c++/48322.
-  template
-struct __conv_types { };
-
-  template
-struct __one_by_one_convertible
-: public false_type { };
-
-  template
-struct __one_by_one_convertible<__conv_types<_Tp>, __conv_types<_Up>>
-: public is_convertible<_Tp, _Up>::type { };
-
-  template
-struct __one_by_one_convertible<__conv_types<_T1, _TR...>,
-__conv_types<_U1, _UR...>>
-: public __and_,
-__one_by_one_convertible<__conv_types<_TR...>,
- __conv_types<_UR...>>>::type
-{ };
-
-  template
-struct __all_convertible;
-
-  template
-struct __all_convertible<__conv_types<_TTypes...>,
- __conv_types<_UTypes...>>
-: public __one_by_one_convertible<__conv_types<_TTypes...>,
-  __conv_types<_UTypes...>>::type { };
-
   template
 struct _Head_base;
 
@@ -407,13 +378,9 @@
   constexpr tuple(const _Elements&... __elements)
   : _Inherited(__elements...) { }
 
-  template::type,
-  typename = typename
-enable_if<__all_convertible<__conv_types<_UElements...>,
-__conv_types<_Elements...> >::value
-  >::type>
+  template...>::value>::type>
explicit
 constexpr tuple(_UElements&&... __elements)
: _Inherited(std::forward<_UElements>(__elements)...) { }
@@ -423,21 +390,15 @@
   constexpr tuple(tuple&&) = default; 
 
   template,
-__all_convertible<__conv_types,
-  __conv_types<_Elements...>>
- >::value>::type>
+enable_if<__and_...>::value>::type>
 constexpr tuple(const tuple<_UElements...>& __in)
 : _Inherited(static_cast&>(__in))
 { }
 
   template,
-__all_convertible<__conv_types<_UElements...>,
-  __conv_types<_Elements...>>
->::value>::type>
+enable_if<__and_...>::value>::type>
 constexpr tuple(tuple<_UElements...>&& __in)
 : _Inherited(static_cast<_Tuple_impl<0, _UElements...>&&>(__in)) { }
 
Index: testsuite/20_util/uses_allocator/cons_neg.cc
===
--- testsuite/20_util/uses_allocator/cons_neg.cc(revision 181554)
+++ testsuite/20_util/uses_allocator/cons_neg.cc(working copy)
@@ -44,4 +44,4 @@
 
   tuple t(allocator_arg, a, 1);
 }
-// { dg-error "no matching function" "" { target *-*-* } 141 }
+// { dg-error "no matching function" "" { target *-*-* } 112 }


[Ada] Constraint checks on exit from function calls with out parameters

2011-11-21 Thread Arnaud Charlet
In Ada 2012, a function call with out parameters may generate assignments to
force constraint checks. These checks must be properly placed in the code after
the declaration or statement that contains the call.

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

2011-11-21  Ed Schonberg  

* exp_ch6.adb (Expand_Actuals): In Ada 2012, a function call
with out parameters may generate assignments to force constraint
checks. These checks must be properly placed in the code after the
declaration or statement that contains the call.

Index: exp_ch6.adb
===
--- exp_ch6.adb (revision 181556)
+++ exp_ch6.adb (working copy)
@@ -1750,24 +1750,50 @@
 
   if not Is_Empty_List (Post_Call) then
 
- --  If call is not a list member, it must be the triggering statement
- --  of a triggering alternative or an entry call alternative, and we
- --  can add the post call stuff to the corresponding statement list.
+ --  Cases where the call is not a member of a statement list
 
  if not Is_List_Member (N) then
 declare
-   P : constant Node_Id := Parent (N);
+   P :  Node_Id := Parent (N);
 
 begin
-   pragma Assert (Nkind_In (P, N_Triggering_Alternative,
-   N_Entry_Call_Alternative));
+   --  In Ada 2012 the call may be a function call in an expression
+   --  (since OUT and IN OUT parameters are now allowed for such
+   --  calls. The write-back of (in)-out parameters is handled
+   --  by the back-end, but the constraint checks generated when
+   --  subtypes of formal and actual don't match must be inserted
+   --  in the form of assignments, at the nearest point after the
+   --  declaration or statement that contains the call.
 
-   if Is_Non_Empty_List (Statements (P)) then
-  Insert_List_Before_And_Analyze
-(First (Statements (P)), Post_Call);
+   if Ada_Version >= Ada_2012
+ and then Nkind (N) = N_Function_Call
+   then
+  while Nkind (P) not in N_Declaration
+and then
+  Nkind (P) not in N_Statement_Other_Than_Procedure_Call
+  loop
+ P := Parent (P);
+  end loop;
+
+  Insert_Actions_After (P, Post_Call);
+
+   --  If not the special Ada 2012 case of a function call, then
+   --  we must have the triggering statement of a triggering
+   --  alternative or an entry call alternative, and we can add
+   --  the post call stuff to the corresponding statement list.
+
else
-  Set_Statements (P, Post_Call);
+  pragma Assert (Nkind_In (P, N_Triggering_Alternative,
+  N_Entry_Call_Alternative));
+
+  if Is_Non_Empty_List (Statements (P)) then
+ Insert_List_Before_And_Analyze
+   (First (Statements (P)), Post_Call);
+  else
+ Set_Statements (P, Post_Call);
+  end if;
end if;
+
 end;
 
  --  Otherwise, normal case where N is in a statement sequence,
@@ -2764,7 +2790,7 @@
  Next_Formal (Formal);
   end loop;
 
-  --  If we are calling an Ada2012 function which needs to have the
+  --  If we are calling an Ada 2012 function which needs to have the
   --  "accessibility level determined by the point of call" (AI05-0234)
   --  passed in to it, then pass it in.
 
@@ -8506,8 +8532,8 @@
  return False;
 
   --  Handle a corner case, a cross-dialect subp renaming. For example,
-  --  an Ada2012 renaming of an Ada05 subprogram. This can occur when a
-  --  non-Ada2012 unit references predefined runtime units.
+  --  an Ada 2012 renaming of an Ada 05 subprogram. This can occur when a
+  --  non-Ada 2012 unit references predefined run-time units.
 
   elsif Present (Alias (Func_Id)) then
 


[v3] libstdc++/51185

2011-11-21 Thread Paolo Carlini

Hi,

I'm committing the below from Daniel. Thanks!

Tested x86_64-linux.

Paolo.

///
2011-11-21  Daniel Krugler  

PR libstdc++/51185
* include/std/type_traits (__is_base_to_derived_ref,
__is_lvalue_to_rvalue_ref): Fix.
* testsuite/20_util/is_constructible/51185.cc: New.
* testsuite/20_util/is_constructible/value-2.cc: Extend.
* testsuite/20_util/declval/requirements/1_neg.cc: Adjust dg-error
line number.
* testsuite/20_util/make_signed/requirements/typedefs_neg.cc:
Likewise.
* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc
Likewise.
Index: include/std/type_traits
===
--- include/std/type_traits (revision 181554)
+++ include/std/type_traits (working copy)
@@ -745,6 +745,8 @@
   // Implementation for non-reference types. To meet the proper
   // variable definition semantics, we also need to test for
   // is_destructible in this case.
+  // This form should be simplified by a single expression:
+  // ::delete ::new _Tp(declval<_Arg>()), see c++/51222.
   struct __do_is_direct_constructible_impl
   {
 template::value>
+   = __not_<__or_, 
+  is_function<_From>>>::value>
 struct __is_base_to_derived_ref;
 
+  // Detect whether we have a downcast situation during
+  // reference binding.
   template
 struct __is_base_to_derived_ref<_From, _To, true>
 {
@@ -803,6 +808,8 @@
 is_rvalue_reference<_To>>::value>
 struct __is_lvalue_to_rvalue_ref;
 
+  // Detect whether we have an lvalue of non-function type
+  // bound to a reference-compatible rvalue-reference.
   template
 struct __is_lvalue_to_rvalue_ref<_From, _To, true>
 {
@@ -810,8 +817,9 @@
 _From>::type>::type __src_t;
   typedef typename remove_cv::type>::type __dst_t;
-  typedef __or_,
-   is_base_of<__dst_t, __src_t>> type;
+  typedef __and_<__not_>, 
+__or_,
+   is_base_of<__dst_t, __src_t>>> type;
   static constexpr bool value = type::value;
 };
 
@@ -823,9 +831,9 @@
   // Here we handle direct-initialization to a reference type as 
   // equivalent to a static_cast modulo overshooting conversions.
   // These are restricted to the following conversions:
-  //a) A glvalue of a base class to a derived class reference
+  //a) A base class value to a derived class reference
   //b) An lvalue to an rvalue-reference of reference-compatible 
-  //   types
+  //   types that are not functions
   template
 struct __is_direct_constructible_ref_cast
 : public __and_<__is_static_castable<_Arg, _Tp>,
@@ -850,7 +858,9 @@
 
   // Since default-construction and binary direct-initialization have
   // been handled separately, the implementation of the remaining
-  // n-ary construction cases is rather straightforward.
+  // n-ary construction cases is rather straightforward. We can use
+  // here a functional cast, because array types are excluded anyway
+  // and this form is never interpreted as a C cast.
   struct __do_is_nary_constructible_impl
   {
 templatehttp://www.gnu.org/licenses/>.
 
-// { dg-error "static assertion failed" "" { target *-*-* } 1759 }
+// { dg-error "static assertion failed" "" { target *-*-* } 1769 }
 
 #include 
 
Index: testsuite/20_util/is_constructible/value-2.cc
===
--- testsuite/20_util/is_constructible/value-2.cc   (revision 181554)
+++ testsuite/20_util/is_constructible/value-2.cc   (working copy)
@@ -817,3 +817,5 @@
  "Error");
 static_assert(!std::is_constructible>::value,
  "Error");
+
+static_assert(std::is_constructible::value, "Error");
Index: testsuite/20_util/is_constructible/51185.cc
===
--- testsuite/20_util/is_constructible/51185.cc (revision 0)
+++ testsuite/20_util/is_constructible/51185.cc (revision 0)
@@ -0,0 +1,39 @@
+// { dg-options "-std=gnu++0x" }
+// { dg-do compile }
+
+// Copyright (C) 2011 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// .
+
+#include 
+
+struct A { };
+struct B : A { };
+
+// lib

[Ada] Conformance checks on partially parametrized formal packages

2011-11-21 Thread Arnaud Charlet
A formal subprogram of the formal package can be specified with a box default,
or can be covered by an others association with a box initialization. In either
case there is no need to check its conformance with the actual subprogram that
appears in the instantiation of the formal package. This patch covers the case
of an others association, whose representation is different from that of an
explicit box initialization for the formal subprogram.

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

2011-11-21  Ed Schonberg  

* sem_ch12.adb (Check_Formal_Package_Instance): If a formal
subprogram of the formal package is covered by an others
association with a box initialization, no check is needed
against the actual in the instantiation of the formal package.

Index: sem_ch12.adb
===
--- sem_ch12.adb(revision 181556)
+++ sem_ch12.adb(working copy)
@@ -5076,6 +5076,18 @@
 then
null;
 
+--  If the formal package has an "others"  box association that
+--  covers this formal, there is no need for a check either.
+
+elsif Nkind (Unit_Declaration_Node (E2)) in
+N_Formal_Subprogram_Declaration
+  and then Box_Present (Unit_Declaration_Node (E2))
+then
+   null;
+
+--  Otherwise the actual in the formal and the actual in the
+--  instantiation of the formal must match, up to renamings.
+
 else
Check_Mismatch
  (Ekind (E2) /= Ekind (E1) or else (Alias (E1)) /= Alias (E2));
@@ -12383,9 +12395,11 @@
   procedure Reset_Entity (N : Node_Id) is
 
  procedure Set_Global_Type (N : Node_Id; N2 : Node_Id);
- --  If the type of N2 is global to the generic unit. Save the type in
- --  the generic node.
- --  What does this comment mean???
+ --  If the type of N2 is global to the generic unit, save the type in
+ --  the generic node. Just as we perform name capture for explicit
+ --  references within the generic, we must capture the global types
+ --  of local entities because they may participate in resolution in
+ --  the instance.
 
  function Top_Ancestor (E : Entity_Id) return Entity_Id;
  --  Find the ultimate ancestor of the current unit. If it is not a


Re: [patch, ia64, libgcc] Patch to fix libunwind build on IA64

2011-11-21 Thread Michael Matz
Hi,

On Fri, 18 Nov 2011, Steve Ellcey wrote:

> > Oh, so you don't even need -fasynchronous-unwind-tables?  Even better 
> > then
> > :)
> 
> Didn't seem to.  Do you know of any special tests I should check and/or 
> run.

No.

> I didn't see any problems in the GCC test suite after the bootstrap.

Should be sufficient, there are enough exception related tests in the 
suite.


Ciao,
Michael.


Re: [PATCH] PR50325 store_bit_field: Fix for big endian targets

2011-11-21 Thread Richard Sandiford
Eric Botcazou  writes:
>> Yeah, I don't think constants are any different here.  One fix might be
>> to use simplify_expand_binop instead of extract_bit_field, as per the
>> patch below.  The patch also restricts the shifting to forward walks,
>> as discussed in the PR trail.
>
> This looks fine to me, please apply (with a few words added to the comment, 
> e.g. "...doesn't have full wordsize and we transfer in memory order...").
>
>> The point of r8007 seems to be that WORDS_BIG_ENDIAN doesn't apply to
>> BLKmode fieldmodes, but there must surely be some endianness involved
>> somewhere, given that we're extracting words from a multiword value?
>
> I think that BLKmode objects are treated as left-justified in memory order, 
> i.e. left-justified on big-endian and right-justified on little-endian.
>
>> So if possible, I'd prefer to revert the original patch for this PR
>> and instead adjust the "backwards" test.  I'm just not sure whether
>> it should be "WORDS_BIG_ENDIAN" (reverting r8007, which was obviously
>> applied for a reason) or something like:
>>
>> (fieldmode == BLKmode ? BYTES_BIG_ENDIAN : WORDS_BIG_ENDIAN)
>
> This seems to be a little risky for stage 3 though.

What's the main potential problem you see?  The backwards condition:

(fieldmode == BLKmode ? BYTES_BIG_ENDIAN : WORDS_BIG_ENDIAN)

should apply the same bit-for-bit mapping between source and target
as the patch applies.  The only difference should be in the order that
the reads and writes happen.  But does that matter?  If we were worried
about something like volatile MEMs here, I'd expect a check for that,
since volatile MEMs can be something like doubleword as well as BLKmode.

Richard


[Ada] Invariants must only apply to public subprograms

2011-11-21 Thread Arnaud Charlet
Previously, invariants were applied for IN OUT parameters and return
values on all subprograms. This is wrong, they should only be applied
for private subprograms. In the following test program, only the
exception marked OK should be raised, not the other two (before all
three exceptions were raised).

 1. with PrivInv; use PrivInv;
 2. with Text_IO; use Text_IO;
 3. procedure PrivInvM is
 4.X : T := Create;
 5. begin
 6.Pub (X);
 7. exception
 8.when others =>
 9.   Put_Line ("OK, exception raised for call to Pub");
10. end;

 1. package PrivInv is
 2.type T is private with Invariant => Valid (T);
 3.function Valid (X : T) return Boolean;
 4.procedure Pub (X : in out T);
 5.function Create return T;
 6. private
 7.type T is record
 8.   B : Boolean;
 9.end record;
10.function Valid (X : T) return Boolean is (X.B);
11.procedure Priv (X : in out T);
12.function Create return T is (T'(B => True));
13. end PrivInv;

 1. with Text_IO; use Text_IO;
 2. package body PrivInv is
 3.procedure Bod (X : in out T);
 4.procedure Bod (X : in out T) is
 5.begin
 6.   X.B := False;
 7.end;
 8.
 9.procedure Pub (X : in out T) is
10.begin
11.   begin
12.  Bod (X);
13.   exception
14.  when others =>
15. Put_Line ("ERROR: Exception raised for call to Bod");
16.   end;
17.
18.   begin
19.  Priv (X);
20.   exception
21.  when others =>
22. Put_Line ("ERROR: Exception raised for call to Priv");
23.   end;
24.
25.   X.B := False;
26.end;
27.
28.procedure Priv (X : in out T) is
29.begin
30.   X.B := False;
31.end;
32. end PrivInv;

The new correct output is the single line:

OK, exception raised for call to Pub

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

2011-11-21  Robert Dewar  

* sem_ch6.adb (Is_Public_Subprogram_For): New procedure
(Process_PPCs): Invariants only apply to public subprograms.

Index: sem_ch6.adb
===
--- sem_ch6.adb (revision 181556)
+++ sem_ch6.adb (working copy)
@@ -8536,19 +8536,19 @@
and then In_Private_Part (Current_Scope)
  then
 Priv_Decls :=
-  Private_Declarations (
-Specification (Unit_Declaration_Node (Current_Scope)));
+  Private_Declarations
+(Specification (Unit_Declaration_Node (Current_Scope)));
 
 return In_Package_Body (Current_Scope)
   or else
 (Is_List_Member (Decl)
-   and then List_Containing (Decl) = Priv_Decls)
+  and then List_Containing (Decl) = Priv_Decls)
   or else (Nkind (Parent (Decl)) = N_Package_Specification
- and then not
-   Is_Compilation_Unit
- (Defining_Entity (Parent (Decl)))
- and then List_Containing (Parent (Parent (Decl)))
-= Priv_Decls);
+and then not
+  Is_Compilation_Unit
+(Defining_Entity (Parent (Decl)))
+and then List_Containing (Parent (Parent (Decl))) =
+Priv_Decls);
  else
 return False;
  end if;
@@ -9562,6 +9562,15 @@
   --  or IN OUT parameters of the subprogram, or (for a function) if the
   --  return value has an invariant.
 
+  function Is_Public_Subprogram_For (T : Entity_Id) return Boolean;
+  --  T is the entity for a private type for which invariants are defined.
+  --  This function returns True if the procedure corresponding to the
+  --  value of Designator is a public procedure from the point of view of
+  --  this type (i.e. its spec is in the visible part of the package that
+  --  contains the declaration of the private type). A True value means
+  --  that an invariant check is required (for an IN OUT parameter, or
+  --  the returned value of a function.
+
   --
   -- Grab_PPC --
   --
@@ -9689,6 +9698,45 @@
  return False;
   end Invariants_Or_Predicates_Present;
 
+  --
+  -- Is_Public_Subprogram_For --
+  --
+
+  --  The type T is a private type, its declaration is therefore in
+  --  the list of public declarations of some package. The test for a
+  --  public subprogram is that its declaration is in this same list
+  --  of declarations for the same package (note that all the public
+   

[Ada] As we use the default behavior, no need to allocate a mutex attribute

2011-11-21 Thread Arnaud Charlet
Passing a null pointer to pthread_mutex_init for the attribute specify
that the default attribute should be used. This is exactly what was done
previously by using a mutex attribute with default value.

This is just a code clean-up, no change in behavior but we avoid some
system calls and furthermore the mutex attributes were not destroyed
properly which could cause resource/memory leaks.

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

2011-11-21  Pascal Obry  

* s-taprop-linux.adb (Initialize_Lock): Do not allocate a
mutex attribute as not needed.
(Initialize_TCB): Likewise.
(Initialize): Likewise.

Index: s-taprop-linux.adb
===
--- s-taprop-linux.adb  (revision 181556)
+++ s-taprop-linux.adb  (working copy)
@@ -291,15 +291,11 @@
 
   else
  declare
-Mutex_Attr : aliased pthread_mutexattr_t;
-Result : Interfaces.C.int;
+Result : Interfaces.C.int;
 
  begin
-Result := pthread_mutexattr_init (Mutex_Attr'Access);
-pragma Assert (Result = 0);
+Result := pthread_mutex_init (L.WO'Access, null);
 
-Result := pthread_mutex_init (L.WO'Access, Mutex_Attr'Access);
-
 pragma Assert (Result = 0 or else Result = ENOMEM);
 
 if Result = ENOMEM then
@@ -315,15 +311,11 @@
is
   pragma Unreferenced (Level);
 
-  Mutex_Attr : aliased pthread_mutexattr_t;
-  Result : Interfaces.C.int;
+  Result : Interfaces.C.int;
 
begin
-  Result := pthread_mutexattr_init (Mutex_Attr'Access);
-  pragma Assert (Result = 0);
+  Result := pthread_mutex_init (L, null);
 
-  Result := pthread_mutex_init (L, Mutex_Attr'Access);
-
   pragma Assert (Result = 0 or else Result = ENOMEM);
 
   if Result = ENOMEM then
@@ -817,9 +809,8 @@

 
procedure Initialize_TCB (Self_ID : Task_Id; Succeeded : out Boolean) is
-  Mutex_Attr : aliased pthread_mutexattr_t;
-  Cond_Attr  : aliased pthread_condattr_t;
-  Result : Interfaces.C.int;
+  Cond_Attr : aliased pthread_condattr_t;
+  Result: Interfaces.C.int;
 
begin
   --  Give the task a unique serial number
@@ -831,11 +822,8 @@
   Self_ID.Common.LL.Thread := Null_Thread_Id;
 
   if not Single_Lock then
- Result := pthread_mutexattr_init (Mutex_Attr'Access);
- pragma Assert (Result = 0);
-
  Result :=
-   pthread_mutex_init (Self_ID.Common.LL.L'Access, Mutex_Attr'Access);
+   pthread_mutex_init (Self_ID.Common.LL.L'Access, null);
  pragma Assert (Result = 0 or else Result = ENOMEM);
 
  if Result /= 0 then
@@ -1081,9 +1069,8 @@

 
procedure Initialize (S : in out Suspension_Object) is
-  Mutex_Attr : aliased pthread_mutexattr_t;
-  Cond_Attr  : aliased pthread_condattr_t;
-  Result : Interfaces.C.int;
+  Cond_Attr : aliased pthread_condattr_t;
+  Result: Interfaces.C.int;
 
begin
   --  Initialize internal state (always to False (RM D.10(6)))
@@ -1093,11 +1080,8 @@
 
   --  Initialize internal mutex
 
-  Result := pthread_mutexattr_init (Mutex_Attr'Access);
-  pragma Assert (Result = 0);
+  Result := pthread_mutex_init (S.L'Access, null);
 
-  Result := pthread_mutex_init (S.L'Access, Mutex_Attr'Access);
-
   pragma Assert (Result = 0 or else Result = ENOMEM);
 
   if Result = ENOMEM then


[Ada] A dispatching call cannot have a stdcall calling convention

2011-11-21 Thread Arnaud Charlet
Issue an error if a pragma convention stdcall is applied to a
dispatching subprogram. Such subprogram cannot be used to interface
to the Win32 API, so in fact this check does not impose any new
restrictions.

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

2011-11-21  Pascal Obry  

* sem_prag.adb (Process_Convention): A dispatching call cannot
have a stdcall calling convention.

Index: sem_prag.adb
===
--- sem_prag.adb(revision 181563)
+++ sem_prag.adb(working copy)
@@ -3527,8 +3527,9 @@
  --  For Stdcall, a subprogram, variable or subprogram type is required
 
  if C = Convention_Stdcall
-   and then not Is_Subprogram (E)
-   and then not Is_Generic_Subprogram (E)
+   and then
+ ((not Is_Subprogram (E) and then not Is_Generic_Subprogram (E))
+or else Is_Dispatching_Operation (E))
and then Ekind (E) /= E_Variable
and then not
  (Is_Access_Type (E)


[Ada] As we use the default behavior, no need to allocate a cond attribute

2011-11-21 Thread Arnaud Charlet
Passing a null pointer to pthread_cond_init for the attribute specify
that the default attribute should be used. This is exactly what was done
previously by using a cond attribute with default value.

This is just a code clean-up, no change in behavior but we avoid some
system calls and furthermore the cond attribute was not destroyed
properly which could cause resource/memory leaks.

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

2011-11-21  Pascal Obry  

* s-taprop-linux.adb (Initialize_Lock): Do not allocate a cond
attribute as not needed.

Index: s-taprop-linux.adb
===
--- s-taprop-linux.adb  (revision 181564)
+++ s-taprop-linux.adb  (working copy)
@@ -1069,8 +1069,7 @@

 
procedure Initialize (S : in out Suspension_Object) is
-  Cond_Attr : aliased pthread_condattr_t;
-  Result: Interfaces.C.int;
+  Result : Interfaces.C.int;
 
begin
   --  Initialize internal state (always to False (RM D.10(6)))
@@ -1090,11 +1089,8 @@
 
   --  Initialize internal condition variable
 
-  Result := pthread_condattr_init (Cond_Attr'Access);
-  pragma Assert (Result = 0);
+  Result := pthread_cond_init (S.CV'Access, null);
 
-  Result := pthread_cond_init (S.CV'Access, Cond_Attr'Access);
-
   pragma Assert (Result = 0 or else Result = ENOMEM);
 
   if Result /= 0 then


[Ada] Implement pragma Pure_12 and use it in Ada.Finalization

2011-11-21 Thread Arnaud Charlet
Ada_Finalization is Pure in Ada 2012, but not in earlier versions.
This is in accordance with AI05-0212. This patch implements a
pragma and apsect Pure_12, which is like Pure but effective
only in Ada 2012 mode (analogous to Pure_05 in Ada 2005 mode)

The following two test programs show the effect

 1. pragma Ada_2012;
 2. with Ada.Finalization;
 3. package pure1212 is
 4. pragma Pure;
 5. end;

the above compiles with no errors, but in Ada 95 mode, we have

 1. pragma Ada_95;
 2. with Ada.Finalization;
 |
>>> cannot depend on "Finalization" (wrong categorization)
>>> pure unit cannot depend on non-pure unit

 3. package pure1295 is
 4. pragma Pure;
 5. end;

this ensures portability with other Ada 95 and Ada 2005 compilers

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

2011-11-21  Robert Dewar  

* a-finali.ads: Use pragma Pure_12 for this unit
* aspects.adb: Add aspect Pure_12
* aspects.ads: Add aspect Pure_12
* opt.ads: Add note on Pure_12
* par-prag.adb: Add dummy entry for Pure_12
* sem_prag.adb: Implement Pure_12 pragma
* snames.ads-tmpl: Add Entry for Pure_12

Index: sem_prag.adb
===
--- sem_prag.adb(revision 181556)
+++ sem_prag.adb(working copy)
@@ -12647,6 +12647,47 @@
 end if;
  end Pure_05;
 
+ -
+ -- Pure_12 --
+ -
+
+ --  pragma Pure_12 [(library_unit_NAME)];
+
+ --  This pragma is useable only in GNAT_Mode, where it is used like
+ --  pragma Pure but it is only effective in Ada 2012 mode (otherwise
+ --  it is ignored). It may be used after a pragma Preelaborate, in
+ --  which case it overrides the effect of the pragma Preelaborate.
+ --  This is used to implement AI05-0212 which recategorizes some
+ --  run-time packages in Ada 2012 mode.
+
+ when Pragma_Pure_12 => Pure_12 : declare
+Ent : Entity_Id;
+
+ begin
+GNAT_Pragma;
+Check_Valid_Library_Unit_Pragma;
+
+if not GNAT_Mode then
+   Error_Pragma ("pragma% only available in GNAT mode");
+end if;
+
+if Nkind (N) = N_Null_Statement then
+   return;
+end if;
+
+--  This is one of the few cases where we need to test the value of
+--  Ada_Version_Explicit rather than Ada_Version (which is always
+--  set to Ada_2012 in a predefined unit), we need to know the
+--  explicit version set to know if this pragma is active.
+
+if Ada_Version_Explicit >= Ada_2012 then
+   Ent := Find_Lib_Unit_Name;
+   Set_Is_Preelaborated (Ent, False);
+   Set_Is_Pure (Ent);
+   Set_Suppress_Elaboration_Warnings (Ent);
+end if;
+ end Pure_12;
+
  ---
  -- Pure_Function --
  ---
@@ -14959,6 +15000,7 @@
   Pragma_Psect_Object   => -1,
   Pragma_Pure   => -1,
   Pragma_Pure_05=> -1,
+  Pragma_Pure_12=> -1,
   Pragma_Pure_Function  => -1,
   Pragma_Queuing_Policy => -1,
   Pragma_Ravenscar  => -1,
Index: aspects.adb
===
--- aspects.adb (revision 181556)
+++ aspects.adb (working copy)
@@ -255,6 +255,7 @@
 Aspect_Preelaborate_05  => Aspect_Preelaborate_05,
 Aspect_Pure => Aspect_Pure,
 Aspect_Pure_05  => Aspect_Pure_05,
+Aspect_Pure_12  => Aspect_Pure_12,
 Aspect_Remote_Call_Interface=> Aspect_Remote_Call_Interface,
 Aspect_Remote_Types => Aspect_Remote_Types,
 Aspect_Shared_Passive   => Aspect_Shared_Passive,
Index: aspects.ads
===
--- aspects.ads (revision 181556)
+++ aspects.ads (working copy)
@@ -96,6 +96,7 @@
   Aspect_Preelaborate_05,   -- GNAT
   Aspect_Pure,
   Aspect_Pure_05,   -- GNAT
+  Aspect_Pure_12,   -- GNAT
   Aspect_Remote_Call_Interface,
   Aspect_Remote_Types,
   Aspect_Shared_Passive,
@@ -154,6 +155,7 @@
  Aspect_Compiler_Unit=> True,
  Aspect_Preelaborate_05  => True,
  Aspect_Pure_05  => True,
+ Aspect_Pure_12  => True,
  Aspect_Universal_Data   => True,
  Aspect_Ada_2005 => True,
  

[Ada] Fix handling of local Restrictions pragmas

2011-11-21 Thread Arnaud Charlet
This patch completely redoes the handling of Restrictions pragmas that
occur locally to a unit as a configuration pragma (rather than as an
entrhy in a configuration pragma file).

The new handling is much more consistent, and fixes a number of problems
with inheriting restrictions from with'ed units and from package specs
in package bodies etc.

The new handling is as follows. For restrictions that are partition-wide,
there is no change, such restrictions are recognized wherever they appear
and can be freely inherited, e.g. from a with'ed unit to the with'ing
unit. This makes sense since the binder will in any case insist on seeing
consistent use, so any unit not conforming to any restrictions that are
anywhere in the partition will be rejected, and you might as well find
that out at compile time rather than at bind time.

For restrictions that do not require partition-wide consistency, e.g.
SPARK or No_Implementation_Attributes, in general the restriction applies
only to the unit in which the pragma appears, and not to any other units.

The exception is No_Elaboration_Code which always applies to the entire
object file from a compilation, i.e. to the body, spec, and all subunits.
This restriction can be specified in a configuration pragma file, or it
can be on the body and/or the spec (in eithe case it applies to all the
relevant units). It can appear on a subunit only if it has previously
appeared in the body of spec.

The following tests for improper inheriting of restrictions from spec
to body, and from with'ed units:

 1. pragma Restrictions (SPARK);
 2. pragma Restrictions (No_Wide_Characters);
 3. with RFHeader;
 4. package RFPkg is
 5.procedure Proc;
 6. end;
   |
>>> violation of restriction "SPARK" at rfheader.ads:1
>>>  "end Rfpkg" required

 1. package body RFPkg is
 2.procedure Proc is
 3.   W : Wide_Character := ' ';
 4.begin
 5.   RFHeader.G := 0;
 6.end;
 7. end;

 1. pragma Restrictions (SPARK);
 2. pragma Restrictions (No_Wide_Characters);
 3. package RFHeader is
 4.G : Integer;
 5. end RFHeader;

before this patch, the above program flagged the end of the body (a
case of improperly inheriting the pragma from the spec), and the
use of Wide_Character (improperly inheriting from a with'ed unit).

The following tests the new diagnostic for using an isolated pragma
Restrictions (No_Elaboration_Code) in a subunit (compiled with
-gnatld7 -gnatj60).

 1. package NoElabSub is
 2.procedure q;
 3. end;

 1. package body NoElabSub is
 2.procedure q is separate;
 3. end;

 1. pragma Restrictions (No_Elaboration_Code);
|
>>> invalid specification of "No_Elaboration_Code",
restriction cannot be specified in a subunit,
unless also specified in body or spec

 2. separate (NoElabSub)
 3. procedure q is begin null; end;

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

2011-11-21  Robert Dewar  

* frontend.adb (Frontend): Capture restrictions from config files
* lib-load.adb (Load_Unit): Save/set/restore restriction pragma
information
* lib-xref.adb (Generate_Reference): Fix handling of obsolescent
references. This was noticed during debugging, but it is not
known if it causes real bugs.
* restrict.ads, restrict.adb: New routines to save/set/restore
non-partition-wide restrictions.
* s-rident.ads: Comment changes for new handling of
No_Elaboration_Code
* sem.adb (Sem): Save/Set/Restore non-partition-wide restrictions
* sem_ch10.adb (Analyze_Compilation_Unit): Remove incomplete
attempt to save/restore non-partition-wide restrictions (now
this work is all done in Sem).
* sem_prag.adb (Process_Restrictions_Or_Restriction_Warnings):
Special handling for restriction No_Elaboration_Code.

Index: frontend.adb
===
--- frontend.adb(revision 181556)
+++ frontend.adb(working copy)
@@ -226,6 +226,12 @@
   Opt.Suppress_Options := Scope_Suppress;
end;
 
+   --  This is where we can capture the value of the compilation unit specific
+   --  restrictions that have been set by the config pragma files (or from
+   --  Targparm), for later restoration when processing e.g. subunits.
+
+   Save_Config_Cunit_Boolean_Restrictions;
+
--  If there was a -gnatem switch, initialize the mappings of unit names to
--  file names and of file names to path names from the mapping file.
 
Index: sem_ch10.adb
===
--- sem_ch10.adb(revision 181556)
+++ sem_ch10.adb(working copy)
@@ -467,7 +467,6 @@
--  generated with clauses or limited with clauses. Note that
--  we examine with clauses having pragmas Ela

Re: [Patch] make it possible for the target to rename ".tm_clone_table"

2011-11-21 Thread Pedro Alves
On Sunday 20 November 2011 15:34:54, Iain Sandoe wrote:
> +#undef  TARGET_ASM_TM_CLONE_TABLE_SECTION_NAME
> +#define TARGET_ASM_TM_CLONE_TABLE_SECTION darwin_tm_clone_table_section

#undef  TARGET_ASM_TM_CLONE_TABLE_SECTION

probably.

-- 
Pedro Alves


[Ada] Properly recognize NEL as end of line in UTF-8 encoding mode

2011-11-21 Thread Arnaud Charlet
The NEL (NEXT LINE) control code (16#85#) is now properly recognized as
a line terminator, and hence can be used to terminate a source line when
the source program is encoded in UTF-8 mode.

Note that NEL is not recognized as a line terminator in normal 8-bit
mode. For an extensive explanation of why this is, see the section in
the Sinput spec on "Handling of Source Line Terminators".

The first test program here is to be compiled in normal mode with
no wide character switch, so it is normal Latin-1, in which the
code NEL is not recognized as ending a line:

 1. with Ada.Text_IO; use Ada.Text_IO;
 2. procedure Test_NEL is
 3. begin
 4.-- Ends with VT so should print?   Put_Line("VT works");
 5.-- Ends with FF so should print?   Put_Line("FF works");
 6.-- Ends with NEL so should print?  Put_Line("NEL works");
 7. end Test_NEL;

In the above program
   ? in line 4 is the code 16#0B#, VT
   ? in line 5 is the code 16#0C#, FF
   ? in line 6 is the code 16#85#, NEL

Since NEL is not recognized as ending a line in this mode, the output
of this program is two lines:

VT works
FF works

The second program is to be compiled with the -gnatW8 mode specifying
that it is encoded in UTF-8, where the NEL code is recognized.

 1. with Ada.Text_IO; use Ada.Text_IO;
 2. procedure Test_NEL2 is
 3. begin
 4.-- Ends with VT so should print?   Put_Line("VT works");
 5.-- Ends with FF so should print?   Put_Line("FF works");
 6.-- Ends with NEL so should print?? Put_Line("NEL works");
 7. end Test_NEL2;

In the above program
   ? in line 4 is the code 16#0B#, VT
   ? in line 5 is the code 16#0C#, FF
   ?? in line 6 is the sequence 16#C2# 16#85# (UTF-8 for 16#85#/NEL)

Since NEL is recognized in UTF-8 mode, the output is three lines:

VT works
FF works
NEL works

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

2011-11-21  Robert Dewar  

* s-utf_32.adb (Is_UTF_32_Line_Terminator): Recognize NEL as
line terminator.
* sinput.ads: Add section on Handling of Source Line Terminators.
* types.ads (Line_Terminator): Adjust comments.

Index: types.ads
===
--- types.ads   (revision 181556)
+++ types.ads   (working copy)
@@ -102,12 +102,8 @@
--  Graphic characters, as defined in ARM
 
subtype Line_Terminator is Character range ASCII.LF .. ASCII.CR;
-   --  Line terminator characters (LF, VT, FF, CR)
-   --
-   --  This definition is dubious now that we have two more wide character
-   --  sequences that constitute a line terminator. Every reference to this
-   --  subtype needs checking to make sure the wide character case is handled
-   --  appropriately. ???
+   --  Line terminator characters (LF, VT, FF, CR). For further details,
+   --  see the extensive discussion of line termination in the Sinput spec.
 
subtype Upper_Half_Character is
  Character range Character'Val (16#80#) .. Character'Val (16#FF#);
Index: sinput.ads
===
--- sinput.ads  (revision 181556)
+++ sinput.ads  (working copy)
@@ -6,7 +6,7 @@
 --  --
 -- S p e c  --
 --  --
---  Copyright (C) 1992-2010, 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- --
@@ -43,7 +43,7 @@
 --described in RM 2.2 (13). Any of the characters FF, LF, CR or VT or any
 --wide character that is a Line or Paragraph Separator acts as an end of
 --logical line in this sense, and it is essentially irrelevant whether one
---or more appears in sequence (since if sequence of such characters is
+--or more appears in sequence (since if a sequence of such characters is
 --regarded as separate ends of line, then the intervening logical lines
 --are null in any case).
 
@@ -451,6 +451,75 @@
Internal_Source'Unrestricted_Access;
--  Pointer to internal source buffer
 
+   -
+   -- Handling of Source Line Terminators --
+   -
+
+   --  In this section we discuss in detail the issue of terminators used to
+   --  terminate source lines. The RM says that one or more format effectors
+   --  (other than horizontal tab) end a source line, and defines the set of
+   --  such format effectors, but does not talk about exactly how they are
+   --  represented in the source program (since in general the RM is no

Re: [PATCH] postreload: Invalidate reg_state info@barrier/volatile insns

2011-11-21 Thread Andreas Krebbel
> Let's be conservative instead and distinguish the two cases: in the barrier 
> case, we don't change anything and just add the missing comment, along the 
> lines of "Crossing a barrier resets all the use information".  In the 
> volatile 
> case, we unconditionally invalidate with a similar comment.

Ok.  Here is an updated version.

Bootstrapped and regtested on s390x and x86_64.

Ok for mainline?

Bye,

-Andreas-

2011-11-21  Andreas Krebbel  

* postreload.c (reload_combine): Mark reg_state as invalid at
volatile insns if there has been a use already.


Index: gcc/postreload.c
===
*** gcc/postreload.c.orig
--- gcc/postreload.c
*** reload_combine (void)
*** 1312,1322 
 is and then later disable any optimization that would cross it.  */
if (LABEL_P (insn))
last_label_ruid = reload_combine_ruid;
!   else if (BARRIER_P (insn)
!  || (INSN_P (insn) && volatile_insn_p (PATTERN (insn
!   for (r = 0; r < FIRST_PSEUDO_REGISTER; r++)
! if (! fixed_regs[r])
  reg_state[r].use_index = RELOAD_COMBINE_MAX_USES;
  
if (! NONDEBUG_INSN_P (insn))
continue;
--- 1312,1332 
 is and then later disable any optimization that would cross it.  */
if (LABEL_P (insn))
last_label_ruid = reload_combine_ruid;
!   else if (BARRIER_P (insn))
!   {
! /* Crossing a barrier resets all the use information.  */
! for (r = 0; r < FIRST_PSEUDO_REGISTER; r++)
!   if (! fixed_regs[r])
  reg_state[r].use_index = RELOAD_COMBINE_MAX_USES;
+   }
+   else if (INSN_P (insn) && volatile_insn_p (PATTERN (insn)))
+   /* Optimizations across insns being marked as volatile must be
+  prevented.  All the usage information is invalidated
+  here.  */
+   for (r = 0; r < FIRST_PSEUDO_REGISTER; r++)
+ if (! fixed_regs[r]
+ && reg_state[r].use_index != RELOAD_COMBINE_MAX_USES)
+   reg_state[r].use_index = -1;
  
if (! NONDEBUG_INSN_P (insn))
continue;


[Ada] Fix handling of position attributes in Ada 2005 mode

2011-11-21 Thread Arnaud Charlet
A special rule was introduced in Ada 2005 (RM 13.5.2(2/2-4/2)) that
specifies that if Position, First_Bit or Last_Bit are applied to
a component with a component clause, and the default record bit
ordering applies, then the results correspond to the exact values
given in the component clause, not normalized versions of them.
This patch implements this feature.

The following test program (compiled with -gnatws)

 1. pragma Ada_2005;
 2.
 3. with Ada.Streams;
 4. with Ada.Streams.Stream_Io;
 5. with Ada.Text_Io; use Ada.Text_IO;
 6. with system;
 7.
 8. procedure Bit_Test is
 9.
10.subtype Int_16 is Standard.Short_Integer;
11.type Int_10 is new Int_16 range 0 .. 9;
12.type Int_22 is new Int_16 range 10 .. 31;
13.
14.type A_Rec_Base is
15.   record
16.  Comp_A : Int_16;
17.  Comp_B : Int_16;
18.  Comp_C : Int_10;
19.  Comp_D : Int_22;
20.   end record;
21.
22.type B_Rec is new A_Rec_Base;
23.type C_Rec is new A_Rec_Base;
24.
25.for B_Rec use
26.   record
27.  Comp_A at 0 range  0 .. 15;
28.  Comp_B at 0 range 16 .. 31;
29.  Comp_C at 4 range  0 .. 9;
30.  Comp_D at 4 range 11 .. 31;
31.   end record;
32.
33.for C_Rec use
34.   record
35.  Comp_A at 0 range  0 .. 15;
36.  Comp_B at 0 range 16 .. 31;
37.  Comp_C at 4 range  0 ..  9;
38.  Comp_D at 4 range 11 .. 31;
39.   end record;
40.
41.for B_Rec'Bit_Order use
42.  System.Default_Bit_Order;
43.
44.for C_Rec'Bit_Order use
45.  System.Bit_Order'Val
46.(1 - System.Bit_Order'Pos
47.   (System.Default_Bit_Order));
48.
49.Obj_1 : B_Rec;
50.Obj_2 : C_Rec;
51.
52. begin
53.Obj_1.Comp_A := 1;
54.Obj_1.Comp_B := 2;
55.Obj_1.Comp_C := 3;
56.Obj_1.Comp_D := 11;
57.
58.Obj_2.Comp_A := 1;
59.Obj_2.Comp_B := 2;
60.Obj_2.Comp_C := 3;
61.Obj_2.Comp_D := 12;
62.
63.Put_Line ("B_Rec: ");
64.Put_Line ("Comp_A Pos: " &
65.  Integer'Image (Obj_1.Comp_A'Position));
66.Put_Line ("   FB: " &
67.  Integer'Image (Obj_1.Comp_A'First_Bit));
68.Put_Line ("   LB: " &
69.  Integer'Image (Obj_1.Comp_A'Last_Bit));
70.Put_Line ("Comp_B Pos: " &
71.  Integer'Image (Obj_1.Comp_B'Position));
72.Put_Line ("   FB: " &
73.  Integer'Image (Obj_1.Comp_B'First_Bit));
74.Put_Line ("   LB: " &
75.  Integer'Image (Obj_1.Comp_B'Last_Bit));
76.Put_Line ("Comp_C Pos: " &
77.  Integer'Image (Obj_1.Comp_C'Position));
78.Put_Line ("   FB: " &
79.  Integer'Image (Obj_1.Comp_C'First_Bit));
80.Put_Line ("   LB: " &
81.  Integer'Image (Obj_1.Comp_C'Last_Bit));
82.Put_Line ("Comp_D Pos: " &
83.  Integer'Image (Obj_1.Comp_D'Position));
84.Put_Line ("   FB: " &
85.  Integer'Image (Obj_1.Comp_D'First_Bit));
86.Put_Line ("   LB: " &
87.  Integer'Image (Obj_1.Comp_D'Last_Bit));
88.
89.Put_Line ("C_Rec: ");
90.Put_Line ("Comp_A Pos: " &
91.  Integer'Image (Obj_2.Comp_A'Position));
92.Put_Line ("   FB: " &
93.  Integer'Image (Obj_2.Comp_A'First_Bit));
94.Put_Line ("   LB: " &
95.  Integer'Image (Obj_2.Comp_A'Last_Bit));
96.Put_Line ("Comp_B Pos: " &
97.  Integer'Image (Obj_2.Comp_B'Position));
98.Put_Line ("   FB: " &
99.  Integer'Image (Obj_2.Comp_B'First_Bit));
   100.Put_Line ("   LB: " &
   101.  Integer'Image (Obj_2.Comp_B'Last_Bit));
   102.Put_Line ("Comp_C Pos: " &
   103.  Integer'Image (Obj_2.Comp_C'Position));
   104.Put_Line ("   FB: " &
   105.  Integer'Image (Obj_2.Comp_C'First_Bit));
   106.Put_Line ("   LB: " &
   107.  Integer'Image (Obj_2.Comp_C'Last_Bit));
   108.Put_Line ("Comp_D Pos: " &
   109.  Integer'Image (Obj_2.Comp_D'Position));
   110.Put_Line ("   FB: " &
   111.  Integer'Image (Obj_2.Comp_D'First_Bit));
   112.Put_Line ("   LB: " &
   113.  Integer'Image (Obj_2.Comp_D'Last_Bit));
   114.
   115. end Bit_Test;

 115 lines: No errors

Generates the output:

B_Rec:
Comp_A Pos:  0
   FB:  0
   LB:  15
Comp_B Pos:  0
   FB:  16
   LB:  31
Comp_C Pos:  4
   FB:  0
   LB:  9
Comp_D Pos:  4
   FB:  11
   LB:  31
C_Rec:
Comp_A Pos:  2
   FB:  0
   LB:  15
Comp_B Pos:  0
   FB:  0
   LB:  15
Comp_C Pos:  6
   FB:  6
   LB:  15
Comp_D Pos:  4
   FB:  0
   LB:  20

And as seen in these results, for B_Rec, which has the default
bit_ordering, the output matches exactly t

[Ada] Properly detect passing volatile A.B to non-volatile formal

2011-11-21 Thread Arnaud Charlet
This patch provides proper detection of the error of passing pointer
to volatile to pointer to non-volatile in the case of a component
reference A.B.

The following test program (compiled with -gnatld7 -gnatj60 -gnat2005)
shows detection of this error

 1. procedure Atomic_Test is
 2.
 3.type X32 is mod 2 ** 32;
 4.
 5.type X32_Array is array (1 .. 1) of aliased X32;
 6.pragma Atomic_Components (X32_Array);
 7.
 8.type Rec is record
 9.   A : X32_Array;
10.   B : aliased X32;
11.   pragma Atomic (B);
12.end record;
13.
14.procedure Test (X : access X32) is null;
15.
16.C : aliased X32;
17.pragma Atomic (C);
18.
19.Object : Rec;
20. begin
21.Test (Object.A (1)'Access);
 |
>>> access to volatile object cannot yield
access-to-non-volatile type

22.Test (Object.B'Access);
 |
>>> access to volatile object cannot yield
access-to-non-volatile type

23.Test (C'Access);
 |
>>> access to volatile object cannot yield
access-to-non-volatile type

24. end Atomic_Test;

Before the patch not all these errors were caught.

This change necessitated fixes to two runtime files, namely
s-atocou-builtin.adb and s-taprop-linux.adb, which had this
error. These were both fixed by using Unrestricted_Access
instead of Access.

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

2011-11-21  Robert Dewar  

* s-atocou-builtin.adb (Decrement): Use Unrestricted_Access
to deal with fact that we properly detect the error if Access
is used.
(Increment): Same fix.
* s-taprop-linux.adb (Create_Task): Use Unrestricted_Access
to deal with fact that we properly detect the error if Access
is used.
* sem_util.adb (Is_Volatile_Object): Properly record that A.B is
volatile if the B component is volatile. This affects the check
for passing such a by reference volatile actual to a non-volatile
formal (which should be illegal)

Index: sem_util.adb
===
--- sem_util.adb(revision 181563)
+++ sem_util.adb(working copy)
@@ -8727,11 +8727,16 @@
   then
  return True;
 
-  elsif Nkind (N) = N_Indexed_Component
-or else Nkind (N) = N_Selected_Component
+  elsif Nkind_In (N, N_Indexed_Component, N_Selected_Component)
+and then Is_Volatile_Prefix (Prefix (N))
   then
- return Is_Volatile_Prefix (Prefix (N));
+ return True;
 
+  elsif Nkind (N) = N_Selected_Component
+and then Is_Volatile (Entity (Selector_Name (N)))
+  then
+ return True;
+
   else
  return False;
   end if;
@@ -10833,9 +10838,7 @@
--  source. This excludes, for example, calls to a dispatching
--  assignment operation when the left-hand side is tagged.
 
-   if Modification_Comes_From_Source
- or else Alfa_Mode
-   then
+   if Modification_Comes_From_Source or else Alfa_Mode then
   Generate_Reference (Ent, Exp, 'm');
 
   --  If the target of the assignment is the bound variable
Index: s-taprop-linux.adb
===
--- s-taprop-linux.adb  (revision 181565)
+++ s-taprop-linux.adb  (working copy)
@@ -990,12 +990,19 @@
   --  do not need to manipulate caller's signal mask at this point.
   --  All tasks in RTS will have All_Tasks_Mask initially.
 
-  Result := pthread_create
-(T.Common.LL.Thread'Access,
- Attributes'Access,
- Thread_Body_Access (Wrapper),
- To_Address (T));
+  --  Note: the use of Unrestricted_Access in the following call is needed
+  --  because otherwise we have an error of getting a access-to-volatile
+  --  value which points to a non-volatile object. But in this case it is
+  --  safe to do this, since we know we have no problems with aliasing and
+  --  Unrestricted_Access bypasses this check.
 
+  Result :=
+pthread_create
+  (T.Common.LL.Thread'Unrestricted_Access,
+   Attributes'Access,
+   Thread_Body_Access (Wrapper),
+   To_Address (T));
+
   pragma Assert
 (Result = 0 or else Result = EAGAIN or else Result = ENOMEM);
 
Index: s-atocou-builtin.adb
===
--- s-atocou-builtin.adb(revision 181556)
+++ s-atocou-builtin.adb(working copy)
@@ -50,7 +50,12 @@
 
function Decrement (Item : in out Atomic_Counter) return Boolean is
begin
-  return Sync_Sub_And_Fetch (Item.Value'Access, 1) = 0;
+  --  Note: the use of Unrestricted_Access here is required because we
+  --  are obt

[Ada] Adjustments to setting alignment when size is set

2011-11-21 Thread Arnaud Charlet
This patch reworks the handling when the alignment is not set
but the size is set. Basically in this case, we always set a
reasonable alignment from the size. This is true even if the
size is confirming (we really have no way of telling if a size
clause is or is not confirming in the general case).

And in the case where neither size nor alignment is set for
a subtype or derived type, we inherit both object size and
alignment from the parent type. This avoids some anomolies
that were previously showing up.

The following example:

 1.  package Pkg is
 2.type Time_Xtype is delta 0.1 range 0.0 .. 999_999.9;
 3.for Time_Xtype'Small use 0.1;
 4.for Time_Xtype'Size use 24;
 5.for Time_Xtype'Alignment use 1;
 6.
 7.subtype Ddc_Delay_Stype is Time_Xtype range 0.0 .. 51.1;
 8. end;

Was one of the anomolous cases, the result of -gnatR2 is

Representation information for unit Pkg (spec)

for Time_Xtype'Object_Size use 32;
for Time_Xtype'Value_Size use 24;
for Time_Xtype'Alignment use 1;
for Time_Xtype'Small use 0.1;
for Time_Xtype'Range use 0.0 .. 99.9;

for Ddc_Delay_Stype'Object_Size use 32;
for Ddc_Delay_Stype'Value_Size use 9;
for Ddc_Delay_Stype'Alignment use 1;
for Ddc_Delay_Stype'Small use 0.1;
for Ddc_Delay_Stype'Range use 0.0 .. 51.1;

Previously the subtype Ddc_Delay had an alignment of 4, which was
definitely strange. The impact of this change is small, it had no
visible effect on our entire test suite.

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

2011-11-21  Robert Dewar  

* freeze.adb (Freeze_Enumeration_Type): Make sure to set both
size and alignment for foreign convention enumeration types.
* layout.adb (Set_Elem_Alignment): Redo setting of alignment
when size is set.

Index: layout.adb
===
--- layout.adb  (revision 181556)
+++ layout.adb  (working copy)
@@ -3088,7 +3088,7 @@
   end if;
 
   --  Here we calculate the alignment as the largest power of two multiple
-  --  of System.Storage_Unit that does not exceed either the actual size of
+  --  of System.Storage_Unit that does not exceed either the object size of
   --  the type, or the maximum allowed alignment.
 
   declare
@@ -3126,21 +3126,101 @@
 A := 2 * A;
  end loop;
 
- --  Now we think we should set the alignment to A, but we skip this if
- --  an alignment is already set to a value greater than A (happens for
- --  derived types).
+ --  If alignment is currently not set, then we can safetly set it to
+ --  this new calculated value.
 
- --  However, if the alignment is known and too small it must be
- --  increased, this happens in a case like:
+ if Unknown_Alignment (E) then
+Init_Alignment (E, A);
 
- -- type R is new Character;
- -- for R'Size use 16;
+ --  Cases where we have inherited an alignment
 
- --  Here the alignment inherited from Character is 1, but it must be
- --  increased to 2 to reflect the increased size.
+ --  For constructed types, always reset the alignment, these are
+ --  Generally invisible to the user anyway, and that way we are
+ --  sure that no constructed types have weird alignments.
 
- if Unknown_Alignment (E) or else Alignment (E) < A then
+ elsif not Comes_From_Source (E) then
 Init_Alignment (E, A);
+
+ --  If this inherited alignment is the same as the one we computed,
+ --  then obviously everything is fine, and we do not need to reset it.
+
+ elsif Alignment (E) = A then
+null;
+
+ --  Now we come to the difficult cases where we have inherited an
+ --  alignment and size, but overridden the size but not the alignment.
+
+ elsif Has_Size_Clause (E) or else Has_Object_Size_Clause (E) then
+
+--  This is tricky, it might be thought that we should try to
+--  inherit the alignment, since that's what the RM implies, but
+--  that leads to complex rules and oddities. Consider for example:
+
+--type R is new Character;
+--for R'Size use 16;
+
+--  It seems quite bogus in this case to inherit an alignment of 1
+--  from the parent type Character. Furthermore, if that's what the
+--  programmer really wanted for some odd reason, then they could
+--  specify the alignment they wanted.
+
+--  Furthermore we really don't want to inherit the alignment in
+--  the case of a specified Object_Size for a subtype, since then
+--  there would be no way of overriding to give a reasonable value
+--  (we don't have an Object_Subtype attribute). Consider:
+
+--subtype R is new Character;
+--for R'Ob

[Ada] Do not expand checks in Alfa mode

2011-11-21 Thread Arnaud Charlet
In Alfa mode, formal verification backend takes care of checks, hence there is
no need for the frontend to insert checks.

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

2011-11-21  Yannick Moy  

* checks.adb (Apply_Access_Check, Apply_Arithmetic_Overflow_Check,
Apply_Discriminant_Check, Apply_Divide_Check,
Apply_Selected_Length_Checks, Apply_Selected_Range_Checks,
Build_Discriminant_Checks, Insert_Range_Checks, Selected_Length_Checks,
Selected_Range_Checks): Replace reference to Expander_Active
with reference to Full_Expander_Active, so that expansion of
checks is not performed in Alfa mode

Index: checks.adb
===
--- checks.adb  (revision 181556)
+++ checks.adb  (working copy)
@@ -442,7 +442,7 @@
   --  are cases (e.g. with pragma Debug) where generating the checks
   --  can cause real trouble).
 
-  if not Expander_Active then
+  if not Full_Expander_Active then
  return;
   end if;
 
@@ -878,7 +878,7 @@
 
  if Backend_Overflow_Checks_On_Target
or else not Do_Overflow_Check (N)
-   or else not Expander_Active
+   or else not Full_Expander_Active
or else (Present (Parent (N))
  and then Nkind (Parent (N)) = N_Type_Conversion
  and then Integer_Promotion_Possible (Parent (N)))
@@ -1178,7 +1178,7 @@
   --  Nothing to do if discriminant checks are suppressed or else no code
   --  is to be generated
 
-  if not Expander_Active
+  if not Full_Expander_Active
 or else Discriminant_Checks_Suppressed (T_Typ)
   then
  return;
@@ -1462,7 +1462,7 @@
   --  Don't actually use this value
 
begin
-  if Expander_Active
+  if Full_Expander_Active
 and then not Backend_Divide_Checks_On_Target
 and then Check_Needed (Right, Division_Check)
   then
@@ -2118,7 +2118,7 @@
   (not Length_Checks_Suppressed (Target_Typ));
 
begin
-  if not Expander_Active then
+  if not Full_Expander_Active then
  return;
   end if;
 
@@ -2226,7 +2226,7 @@
 (not Range_Checks_Suppressed (Target_Typ));
 
begin
-  if not Expander_Active or else not Checks_On then
+  if not Full_Expander_Active or else not Checks_On then
  return;
   end if;
 
@@ -5309,7 +5309,7 @@
   --  enhanced to check for an always True value in the condition and to
   --  generate a compilation warning???
 
-  if not Expander_Active or else not Checks_On then
+  if not Full_Expander_Active or else not Checks_On then
  return;
   end if;
 
@@ -6236,7 +6236,7 @@
--  Start of processing for Selected_Length_Checks
 
begin
-  if not Expander_Active then
+  if not Full_Expander_Active then
  return Ret_Result;
   end if;
 
@@ -6810,7 +6810,7 @@
--  Start of processing for Selected_Range_Checks
 
begin
-  if not Expander_Active then
+  if not Full_Expander_Active then
  return Ret_Result;
   end if;
 


[Ada] Access subprogram definitions as return types of access to subprograms

2011-11-21 Thread Arnaud Charlet
Ada 2005 allows the declaration of an  access to function whose return type is
itself an access to function, etc. Each anonymous access type generated for
this pathological construct has a scope which is the scope of the current
declaration.

The following must compile quietly in Ada 2005 mode, and output:

It works
It works
It works

---
with Text_IO; use Text_IO;
function G return Integer is
   procedure Proc is
   begin
  Put_Line ("It works");
   end Proc;

   function G0 return access procedure is
   begin
  return Proc'access;
   end;

   function G1 return access function return access procedure is
   begin
  return G0'access;
   end G1;

   function G2 return access function return
 access function return access procedure is
   begin
 return G1'access;
   end G2;

begin
   G0.all;
   G1.all.all;
   G2.all.all.all;
   return 0;
end;

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

2011-11-21  Ed Schonberg  

* sem_ch3.adb (Access_Definition): If the access definition
is itself the return type of an access to function definition
which is ultimately the return type of an access to subprogram
declaration, its scope is the enclosing scope of the ultimate
access to subprogram.

Index: sem_ch3.adb
===
--- sem_ch3.adb (revision 181567)
+++ sem_ch3.adb (working copy)
@@ -726,13 +726,33 @@
 
   --  If the access definition is the return type of another access to
   --  function, scope is the current one, because it is the one of the
-  --  current type declaration.
+  --  current type declaration, except for the pathological case below.
 
   if Nkind_In (Related_Nod, N_Object_Declaration,
 N_Access_Function_Definition)
   then
  Anon_Scope := Current_Scope;
 
+ --  A pathological case: function returning access functions that
+ --  return access functions, etc.  Each anonymous access type created
+ --  is in the enclosing scope of the outermost function.
+
+ declare
+Par : Node_Id;
+ begin
+Par := Related_Nod;
+while Nkind_In (Par,
+ N_Access_Function_Definition,
+ N_Access_Definition)
+loop
+   Par := Parent (Par);
+end loop;
+
+if Nkind (Par) = N_Function_Specification then
+   Anon_Scope := Scope (Defining_Entity (Par));
+end if;
+ end;
+
   --  For the anonymous function result case, retrieve the scope of the
   --  function specification's associated entity rather than using the
   --  current scope. The current scope will be the function itself if the


Re: [PATCH] PR50325 store_bit_field: Fix for big endian targets

2011-11-21 Thread Eric Botcazou
> What's the main potential problem you see?  The backwards condition:
>
> (fieldmode == BLKmode ? BYTES_BIG_ENDIAN : WORDS_BIG_ENDIAN)
>
> should apply the same bit-for-bit mapping between source and target
> as the patch applies.

Not if the objects don't have the same size.  In Ada we have BLKmode bitfields, 
i.e. fields whose type has BLKmode and whose DECL_SIZE is smaller than the 
TYPE_SIZE of the type; in this case, we want to drop the rightmost bytes in 
memory order, whatever the endianness.

-- 
Eric Botcazou


Re: [PATCH] postreload: Invalidate reg_state info@barrier/volatile insns

2011-11-21 Thread Eric Botcazou
> 2011-11-21  Andreas Krebbel  
>
>   * postreload.c (reload_combine): Mark reg_state as invalid at
>   volatile insns if there has been a use already.

What do we gain in practice by invalidating conditionally?  Probably nothing 
I'd say, so let's invalidate unconditionally like for CALL_P just below.

+   else if (INSN_P (insn) && volatile_insn_p (PATTERN (insn)))
+   /* Optimizations across insns being marked as volatile must be
+  prevented.  All the usage information is invalidated here.  */
+   for (r = 0; r < FIRST_PSEUDO_REGISTER; r++)
+   reg_state[r].use_index = -1;

OK with this change.

-- 
Eric Botcazou


[Ada] Fix libada build on cygwin

2011-11-21 Thread Eric Botcazou
This (presumably) fixes http://gcc.gnu.org/ml/gcc/2011-11/msg00404.html by 
always including the main GCC dir in INCLUDES_FOR_SUBDIR.

Tested on i586-suse-linux w/ and w/o --disable-libada, applied on the mainline.


2011-11-21  Eric Botcazou  

* gcc-interface/Makefile.in (INCLUDES_FOR_SUBDIR): Add $(fsrcdir) by
means of -iquote unconditionally.


-- 
Eric Botcazou
Index: gcc-interface/Makefile.in
===
--- gcc-interface/Makefile.in	(revision 181505)
+++ gcc-interface/Makefile.in	(working copy)
@@ -273,15 +273,9 @@ INCLUDES = -I- -I. -I.. -I$(srcdir)/ada
 
 ADA_INCLUDES = -I- -I. -I$(srcdir)/ada
 
-INCLUDES_FOR_SUBDIR = -iquote . -iquote .. -iquote ../.. -iquote $(fsrcdir)/ada \
-	-I$(fsrcdir)/../include
-
-ifeq ($(strip $(filter-out cygwin32% mingw32% pe,$(osys))),)
-  # On Windows native the tconfig.h files used by C runtime files needs to have
-  # the gcc source dir in its include dir list
-  INCLUDES_FOR_SUBDIR = -iquote . -iquote .. -iquote ../.. -iquote $(fsrcdir)/ada \
--I$(fsrcdir)/../include -I$(fsrcdir)
-endif
+INCLUDES_FOR_SUBDIR = -iquote . -iquote .. -iquote ../.. \
+		  -iquote $(fsrcdir)/ada -iquote $(fsrcdir) \
+		  -I$(fsrcdir)/../include
 
 ADA_INCLUDES_FOR_SUBDIR = -I. -I$(fsrcdir)/ada
 


Re: [Patch testsuite/darwin] adjust new gcov tests for darwin.

2011-11-21 Thread Nathan Sidwell

On 11/21/11 10:30, Iain Sandoe wrote:

Darwin uses ".private_extern" for hidden visibility, and also we have
__USER_LABEL_PREFIX__ set to "_".

OK for trunk?
Iain

gcc/testsuite:

* gcc.misc-tests/gcov-16.c: Adjust scan-assembler for Darwin.
* gcc.misc-tests/gcov-17.c: Likewise.
* g++.dg/gcov/gcov-8.C: Likewise.
* g++.dg/gcov/gcov-9.C: Likewise.


ok gcov-wise, thanks.

nathan


Re: [PATCH, take 2] Fix PR tree-optimization/49960 ,Fix self data dependence

2011-11-21 Thread Jakub Jelinek
On Tue, Nov 15, 2011 at 12:31:39PM +0200, Razya Ladelsky wrote:
> This patch fixes the failures described in 
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49960
> It also fixes bzips when run with autopar enabled.

Sorry, I've been away and couldn't react to this earlier, but the patch
looks wrong to me.  The reason why I've been calling compute_self_dependence
from the gather handling code is to do there what we did for normal data
references in compute_all_dependences, except for the affine stuff.
So, when compute_all_dependences no longer calls it, neither should
vect_analyze_data_refs.

Jakub


Re: [PATCH] PR50325 store_bit_field: Fix for big endian targets

2011-11-21 Thread Richard Sandiford
Eric Botcazou  writes:
>> What's the main potential problem you see?  The backwards condition:
>>
>> (fieldmode == BLKmode ? BYTES_BIG_ENDIAN : WORDS_BIG_ENDIAN)
>>
>> should apply the same bit-for-bit mapping between source and target
>> as the patch applies.
>
> Not if the objects don't have the same size.

Ugh.

> In Ada we have BLKmode bitfields, i.e. fields whose type has BLKmode
> and whose DECL_SIZE is smaller than the TYPE_SIZE of the type; in this
> case, we want to drop the rightmost bytes in memory order, whatever
> the endianness.

OK, I see how the two are different now, but I still don't get why the
current version is right.  If we say words are 16 bits for simplicity,
and we're storing VALUE == 0x0001_2345 into a 3-byte BLKmode bitfield,
surely we want to store 0x01_2345 rather than 0x00_0123?  It seems odd
for fieldmode (which I thought was a property of the target) to affect
the interpretation of VALUE (the source).

Richard


Re: [PATCH] postreload: Invalidate reg_state info@barrier/volatile insns

2011-11-21 Thread Andreas Krebbel
On 11/21/2011 01:12 PM, Eric Botcazou wrote:
>> 2011-11-21  Andreas Krebbel  
>>
>>  * postreload.c (reload_combine): Mark reg_state as invalid at
>>  volatile insns if there has been a use already.
> 
> What do we gain in practice by invalidating conditionally?  Probably nothing 
> I'd say, so let's invalidate unconditionally like for CALL_P just below.
> 
> +   else if (INSN_P (insn) && volatile_insn_p (PATTERN (insn)))
> +   /* Optimizations across insns being marked as volatile must be
> +  prevented.  All the usage information is invalidated here.  */
> +   for (r = 0; r < FIRST_PSEUDO_REGISTER; r++)
> +   reg_state[r].use_index = -1;

Wouldn't this prevent optimizations in cases like:

insn 1: r1 = r2 + r3
insn 2: r4 = r1, r1 dead
insn 3: unspec_volatile

With the proposal above we would mark r1 with an invalid use when passing insn 
3. But for
registers which are already dead we should not do this. They should just stay 
dead.

Bye,

-Andreas-



[Ada] In Alfa mode, do not force evaluation of expressions for checks

2011-11-21 Thread Arnaud Charlet
In Alfa mode, checks are not generated by the frontend, hence there is no need
to force the evaluation of expressions for checks. This avoids inserting
useless actions in expressions.

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

2011-11-21  Yannick Moy  

* sem_ch3.adb (Constrain_Index, Process_Range_Expr_In_Decl):
Use Full_Expander_Active instead of Expander_Active to control
the forced evaluation of expressions for the sake of generating
checks.

Index: sem_ch3.adb
===
--- sem_ch3.adb (revision 181572)
+++ sem_ch3.adb (working copy)
@@ -11786,7 +11786,7 @@
  --  needed, since checks may cause duplication of the expressions
  --  which must not be reevaluated.
 
- if Expander_Active then
+ if Full_Expander_Active then
 Force_Evaluation (Low_Bound (R));
 Force_Evaluation (High_Bound (R));
  end if;
@@ -18326,7 +18326,7 @@
 --  if needed, before applying checks, since checks may cause
 --  duplication of the expression without forcing evaluation.
 
-if Expander_Active then
+if Full_Expander_Active then
Force_Evaluation (Lo);
Force_Evaluation (Hi);
 end if;
@@ -18436,7 +18436,7 @@
 
   --  Case of other than an explicit N_Range node
 
-  elsif Expander_Active then
+  elsif Full_Expander_Active then
  Get_Index_Bounds (R, Lo, Hi);
  Force_Evaluation (Lo);
  Force_Evaluation (Hi);


[Ada] Special case dup2() on Windows

2011-11-21 Thread Arnaud Charlet
Special case when oldfd and newfd are identical and are the standard
input, output or error as this makes Windows XP hangs.

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

2011-11-21  Pascal Obry  

* adaint.c (__gnat_dup2): When fd are stdout, stdin or stderr and
identical, do nothing on Windows XP.

Index: adaint.c
===
--- adaint.c(revision 181556)
+++ adaint.c(working copy)
@@ -2449,6 +2449,14 @@
   /* Not supported on VxWorks 5.x, but supported on VxWorks 6.0 when using
  RTPs.  */
   return -1;
+#elif defined (_WIN32)
+  /* Special case when oldfd and newfd are identical and are the standard
+ input, output or error as this makes Windows XP hangs. Note that we
+ do that only for standard file descriptors that are known to be valid. */
+  if (oldfd == newfd && newfd >= 0 && newfd <= 2)
+return newfd;
+  else
+return dup2 (oldfd, newfd);
 #else
   return dup2 (oldfd, newfd);
 #endif


[Ada] Cleanup in sysdep.c: remove unused declaration

2011-11-21 Thread Arnaud Charlet
Tested on x86_64-pc-linux-gnu, committed on trunk

2011-11-21  Tristan Gingold  

* sysdep.c (mode_read_text, mode_write_text, mode_append_text,
mode_read_binary, mode_write_binary, mode_append_binary,
mode_read_text_plus, mode_write_text_plus, mode_append_text_plus,
mode_read_binary_plus, mode_write_binary_plus,
mode_append_binary_plus): Remove unused declarations.

Index: sysdep.c
===
--- sysdep.c(revision 181556)
+++ sysdep.c(working copy)
@@ -80,54 +80,6 @@
 #endif
 
 /*
-   mode_read_text
-   open text file for reading
-   rt for DOS and Windows NT, r for Unix
-
-   mode_write_text
-   truncate to zero length or create text file for writing
-   wt for DOS and Windows NT, w for Unix
-
-   mode_append_text
-   append; open or create text file for writing at end-of-file
-   at for DOS and Windows NT, a for Unix
-
-   mode_read_binary
-   open binary file for reading
-   rb for DOS and Windows NT, r for Unix
-
-   mode_write_binary
-   truncate to zero length or create binary file for writing
-   wb for DOS and Windows NT, w for Unix
-
-   mode_append_binary
-   append; open or create binary file for writing at end-of-file
-   ab for DOS and Windows NT, a for Unix
-
-   mode_read_text_plus
-   open text file for update (reading and writing)
-   r+t for DOS and Windows NT, r+ for Unix
-
-   mode_write_text_plus
-   truncate to zero length or create text file for update
-   w+t for DOS and Windows NT, w+ for Unix
-
-   mode_append_text_plus
-   append; open or create text file for update, writing at end-of-file
-   a+t for DOS and Windows NT, a+ for Unix
-
-   mode_read_binary_plus
-   open binary file for update (reading and writing)
-   r+b for DOS and Windows NT, r+ for Unix
-
-   mode_write_binary_plus
-   truncate to zero length or create binary file for update
-   w+b for DOS and Windows NT, w+ for Unix
-
-   mode_append_binary_plus
-   append; open or create binary file for update, writing at end-of-file
-   a+b for DOS and Windows NT, a+ for Unix
-
Notes:
 
(1) Opening a file with read mode fails if the file does not exist or
@@ -169,18 +121,7 @@
 */
 
 #if defined(WINNT)
-static const char *mode_read_text = "rt";
-static const char *mode_write_text = "wt";
-static const char *mode_append_text = "at";
-static const char *mode_read_binary = "rb";
-static const char *mode_write_binary = "wb";
-static const char *mode_append_binary = "ab";
-static const char *mode_read_text_plus = "r+t";
-static const char *mode_write_text_plus = "w+t";
-static const char *mode_append_text_plus = "a+t";
-static const char *mode_read_binary_plus = "r+b";
-static const char *mode_write_binary_plus = "w+b";
-static const char *mode_append_binary_plus = "a+b";
+
 const char __gnat_text_translation_required = 1;
 
 void
@@ -261,18 +202,6 @@
 
 #else
 
-static const char *mode_read_text = "r";
-static const char *mode_write_text = "w";
-static const char *mode_append_text = "a";
-static const char *mode_read_binary = "r";
-static const char *mode_write_binary = "w";
-static const char *mode_append_binary = "a";
-static const char *mode_read_text_plus = "r+";
-static const char *mode_write_text_plus = "w+";
-static const char *mode_append_text_plus = "a+";
-static const char *mode_read_binary_plus = "r+";
-static const char *mode_write_binary_plus = "w+";
-static const char *mode_append_binary_plus = "a+";
 const char __gnat_text_translation_required = 0;
 
 /* These functions do nothing in non-DOS systems. */


[Ada] Locate error message on the first character of an assertion

2011-11-21 Thread Arnaud Charlet
The source location of an expression may not be the best place to put a message,
in the case of a failed assertion. For example, it gets located on the last
"and" keyword in a chain of boolean expressiond and'ed together. It is best to
put the message on the first character of an assertion, which is done here.

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

2011-11-21  Yannick Moy  

* exp_prag.adb (Expand_Pragma_Check): Place error on first character
of expression.
* sem_res.adb (Resolve_Short_Circuit): Place error on first
character of expression.

Index: exp_prag.adb
===
--- exp_prag.adb(revision 181574)
+++ exp_prag.adb(working copy)
@@ -270,7 +270,7 @@
 
procedure Expand_Pragma_Check (N : Node_Id) is
   Cond : constant Node_Id:= Arg2 (N);
-  Loc  : constant Source_Ptr := Sloc (Cond);
+  Loc  : constant Source_Ptr := Sloc (First_Node (Cond));
   Nam  : constant Name_Id:= Chars (Arg1 (N));
   Msg  : Node_Id;
 
Index: sem_res.adb
===
--- sem_res.adb (revision 181574)
+++ sem_res.adb (working copy)
@@ -8668,7 +8668,7 @@
  --  this by making sure that the expanded code points to
  --  the Sloc of the expression, not the original pragma.
 
- Error_Msg_N
+ Error_Msg_F
("?assertion would fail at run time!",
 Expression
   (First (Pragma_Argument_Associations (Orig;
@@ -8694,7 +8694,7 @@
   then
  null;
   else
- Error_Msg_N
+ Error_Msg_F
("?check would fail at run time!",
 Expression
   (Last (Pragma_Argument_Associations (Orig;


[Ada] In Alfa mode, do not remove side-effects from expression

2011-11-21 Thread Arnaud Charlet
Formal verification constraints already ensure that expressions are free from
side-effects, so no need for removal of side-effects in Alfa mode.

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

2011-11-21  Yannick Moy  

* exp_util.adb (Remove_Side_Effects): Do nothing in Alfa mode.

Index: exp_util.adb
===
--- exp_util.adb(revision 181574)
+++ exp_util.adb(working copy)
@@ -6420,9 +6420,12 @@
--  Start of processing for Remove_Side_Effects
 
begin
-  --  Handle cases in which there is nothing to do
+  --  Handle cases in which there is nothing to do. In particular,
+  --  side-effects are not removed in Alfa mode for formal verification.
+  --  Instead, formal verification is performed only on those expressions
+  --  provably side-effect free.
 
-  if not Expander_Active then
+  if not Full_Expander_Active then
  return;
 
   --  Cannot generate temporaries if the invocation to remove side effects
@@ -6622,15 +6625,6 @@
   --  Otherwise we generate a reference to the value
 
   else
- --  An expression which is in Alfa mode is considered side effect free
- --  if the resulting value is captured by a variable or a constant.
-
- if Alfa_Mode
-   and then Nkind (Parent (Exp)) = N_Object_Declaration
- then
-return;
- end if;
-
  --  Special processing for function calls that return a limited type.
  --  We need to build a declaration that will enable build-in-place
  --  expansion of the call. This is not done if the context is already
@@ -6665,40 +6659,26 @@
  Def_Id := Make_Temporary (Loc, 'R', Exp);
  Set_Etype (Def_Id, Exp_Type);
 
- --  The regular expansion of functions with side effects involves the
- --  generation of an access type to capture the return value found on
- --  the secondary stack. Since Alfa (and why) cannot process access
- --  types, use a different approach which ignores the secondary stack
- --  and "copies" the returned object.
+ Res :=
+   Make_Explicit_Dereference (Loc,
+ Prefix => New_Reference_To (Def_Id, Loc));
 
- if Alfa_Mode then
-Res := New_Reference_To (Def_Id, Loc);
-Ref_Type := Exp_Type;
+ --  Generate:
+ --type Ann is access all ;
 
- --  Regular expansion utilizing an access type and 'reference
+ Ref_Type := Make_Temporary (Loc, 'A');
 
- else
-Res :=
-  Make_Explicit_Dereference (Loc,
-Prefix => New_Reference_To (Def_Id, Loc));
+ Ptr_Typ_Decl :=
+   Make_Full_Type_Declaration (Loc,
+ Defining_Identifier => Ref_Type,
+ Type_Definition =>
+   Make_Access_To_Object_Definition (Loc,
+ All_Present=> True,
+ Subtype_Indication =>
+   New_Reference_To (Exp_Type, Loc)));
 
---  Generate:
---type Ann is access all ;
+ Insert_Action (Exp, Ptr_Typ_Decl);
 
-Ref_Type := Make_Temporary (Loc, 'A');
-
-Ptr_Typ_Decl :=
-  Make_Full_Type_Declaration (Loc,
-Defining_Identifier => Ref_Type,
-Type_Definition =>
-  Make_Access_To_Object_Definition (Loc,
-All_Present=> True,
-Subtype_Indication =>
-  New_Reference_To (Exp_Type, Loc)));
-
-Insert_Action (Exp, Ptr_Typ_Decl);
- end if;
-
  E := Exp;
  if Nkind (E) = N_Explicit_Dereference then
 New_Exp := Relocate_Node (Prefix (E));


[Ada] Attribute 'Max_Size_In_Storage_Elements and controlled types

2011-11-21 Thread Arnaud Charlet
This patch modifies the way Max_Size_In_Storage_Elements operates when applied
to a controlled type. The attribute returns the size of the prefix plus the
size of the two hidden pointer which are added by the runtime support for
controlled objects on the heap.

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

2011-11-21  Hristian Kirtchev  

* exp_attr.adb (Expand_N_Attribute_Reference, case
Max_Size_In_Storage_Elements): Account for the size of the
hidden list header which precedes controlled objects allocated
on the heap.
* rtsfind.ads: Add RE_Header_Size_With_Padding to the runtime
tables.
* sinfo.adb (Header_Size_Added): New routine.
(Set_Header_Size_Added): New routine.
* sinfo.ads: Add flag Controlled_Header_Added along with
associated comment.
(Header_Size_Added): New inlined routine.
(Set_Header_Size_Added): New inlined routine.
* s-stposu.adb (Allocate_Any_Controlled): Use
Header_Size_With_Padding to calculate the proper
size of the header.
(Deallocate_Any_Controlled): Use
Header_Size_With_Padding to calculate the proper size
of the header.  (Header_Size_With_Padding): New routine.
(Nearest_Multiple_Rounded_Up): Removed along with its uses.
* s-stposu.ads (Header_Size_With_Padding): New routine.

Index: exp_attr.adb
===
--- exp_attr.adb(revision 181574)
+++ exp_attr.adb(working copy)
@@ -2989,6 +2989,52 @@
  Analyze_And_Resolve (N, Typ);
   end Mantissa;
 
+  --
+  -- Max_Size_In_Storage_Elements --
+  --
+
+  when Attribute_Max_Size_In_Storage_Elements =>
+ Apply_Universal_Integer_Attribute_Checks (N);
+
+ --  Heap-allocated controlled objects contain two extra pointers which
+ --  are not part of the actual type. Transform the attribute reference
+ --  into a runtime expression to add the size of the hidden header.
+
+ --  Do not perform this expansion on .NET/JVM targets because the
+ --  two pointers are already present in the type.
+
+ if VM_Target = No_VM
+   and then Nkind (N) = N_Attribute_Reference
+   and then Needs_Finalization (Ptyp)
+   and then not Header_Size_Added (N)
+ then
+Set_Header_Size_Added (N);
+
+--  Generate:
+--P'Max_Size_In_Storage_Elements +
+--  Universal_Integer
+--(Header_Size_With_Padding (Ptyp'Alignment))
+
+Rewrite (N,
+  Make_Op_Add (Loc,
+Left_Opnd  => Relocate_Node (N),
+Right_Opnd =>
+  Convert_To (Universal_Integer,
+Make_Function_Call (Loc,
+  Name   =>
+New_Reference_To
+  (RTE (RE_Header_Size_With_Padding), Loc),
+
+  Parameter_Associations => New_List (
+Make_Attribute_Reference (Loc,
+  Prefix =>
+New_Reference_To (Ptyp, Loc),
+  Attribute_Name => Name_Alignment));
+
+Analyze (N);
+return;
+ end if;
+
   
   -- Mechanism_Code --
   
@@ -5572,8 +5618,7 @@
   --  that the result is in range.
 
   when Attribute_Aft  |
-   Attribute_Max_Alignment_For_Allocation |
-   Attribute_Max_Size_In_Storage_Elements =>
+   Attribute_Max_Alignment_For_Allocation =>
  Apply_Universal_Integer_Attribute_Checks (N);
 
   --  The following attributes should not appear at this stage, since they
Index: sinfo.adb
===
--- sinfo.adb   (revision 181575)
+++ sinfo.adb   (working copy)
@@ -1573,6 +1573,14 @@
   return Flag13 (N);
end Has_Wide_Wide_Character;
 
+   function Header_Size_Added
+  (N : Node_Id) return Boolean is
+   begin
+  pragma Assert (False
+or else NT (N).Nkind = N_Attribute_Reference);
+  return Flag11 (N);
+   end Header_Size_Added;
+
function Hidden_By_Use_Clause
  (N : Node_Id) return Elist_Id is
begin
@@ -4637,6 +4645,14 @@
   Set_Flag13 (N, Val);
end Set_Has_Wide_Wide_Character;
 
+   procedure Set_Header_Size_Added
+  (N : Node_Id; Val : Boolean := True) is
+   begin
+  pragma Assert (False
+or else NT (N).Nkind = N_Attribute_Reference);
+  Set_Flag11 (N, Val);
+   end Set_Header_Size_Added;
+
procedure Set_Hidden_By_Use_Clause
  (N : Node_Id; Val : Elist_Id) is
begin
Index: sinfo.ads
===
--- sinfo.ads   (revisi

Re: [patch] update configury for FreeBSD 10 on gcc-4.6 branch

2011-11-21 Thread Joseph S. Myers
On Sun, 20 Nov 2011, Andreas Tobler wrote:

> Committed, thanks.
> 
> Results are here:
> 
> http://gcc.gnu.org/ml/gcc-testresults/2011-11/msg02050.html
> 
> And commit is this one:
> 
> http://gcc.gnu.org/ml/gcc-cvs/2011-11/msg00829.html

I don't see this on mainline, only 4.6 branch - am I missing something or 
is mainline now in a regressed state relative to 4.6?  A fix should always 
go on mainline before 4.6, 4.6 before 4.5, 4.5 before 4.4, and unless and 
until a full merge from libtool upstream happens that means this partial 
fix.

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


[wwwdocs] [RFA] Update gcc-4.7/changes.html to document -mcpu=cortex-a7

2011-11-21 Thread Matthew Gretton-Dann

All,

The attached patch updates gcc-4.7/changes.html to document the addition 
of support in the ARM backend for Cortex-A7 via the -mcpu=cortex-a7 
command line option.


The wording is based upon that used for Cortex-M4 in gcc-4.6/changes.html.

Can someone please review, and if appropriate apply the patch?

Thanks,

Matt

ChangeLog:

2011-11-21  Matthew Gretton-Dann  

* htdocs/gcc-4.7/changes.html: Document -mcpu=cortex-a7.

--
Matthew Gretton-Dann
Principal Engineer, PD Software - Tools, ARM LtdIndex: htdocs/gcc-4.7/changes.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-4.7/changes.html,v
retrieving revision 1.61
diff -u -p -r1.61 changes.html
--- htdocs/gcc-4.7/changes.html 19 Nov 2011 22:04:07 -  1.61
+++ htdocs/gcc-4.7/changes.html 21 Nov 2011 10:51:05 -
@@ -456,6 +456,8 @@ well.
 
 ARM
   
+GCC now supports the Cortex-A7 processor implementing the v7-a version
+  of the architecture using the option -mcpu=cortex-a7.
 The default vector size in auto-vectorization for NEON is now 128 bits.
   If vectorization fails thusly, the vectorizer tries again with
   64-bit vectors.

Re: [PATCH, take 2] Fix PR tree-optimization/49960 ,Fix self data dependence

2011-11-21 Thread Razya Ladelsky
gcc-patches-ow...@gcc.gnu.org wrote on 21/11/2011 02:57:07 PM:

> From: Jakub Jelinek 
> To: Razya Ladelsky/Haifa/IBM@IBMIL
> Cc: Richard Guenther , GCC Patches  patc...@gcc.gnu.org>
> Date: 21/11/2011 02:57 PM
> Subject: Re: [PATCH, take 2] Fix PR tree-optimization/49960 ,Fix 
> self data dependence
> Sent by: gcc-patches-ow...@gcc.gnu.org
> 
> On Tue, Nov 15, 2011 at 12:31:39PM +0200, Razya Ladelsky wrote:
> > This patch fixes the failures described in 
> > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49960
> > It also fixes bzips when run with autopar enabled.
> 
> Sorry, I've been away and couldn't react to this earlier, but the patch
> looks wrong to me.  The reason why I've been calling 
compute_self_dependence
> from the gather handling code is to do there what we did for normal data
> references in compute_all_dependences, except for the affine stuff.

Hi Jakub,
what do you mean by 'except for the affine stuff'?


Before having this patch, compute_self_depepndence just marked the 
distance zero 
and returned, while now it calls compute_affine_dependence.
So I think you do get the right outcome now.

> So, when compute_all_dependences no longer calls it, neither should
> vect_analyze_data_refs.

So do you want to replace it with the call to compute_affine_dependence?

Thanks,
Razya

> 
>Jakub
> 



[libitm, build] Clear hardware capabilities on libitm.so with Sun ld

2011-11-21 Thread Rainer Orth
The libitm execution tests are currently failing on Solaris 10 and up
with Sun as/ld:

ld.so.1: cancel.exe: fatal: 
/var/gcc/regression/trunk/11-gcc/build/i386-pc-solaris2.11/./libitm/.libs/libitm.so.0:
 hardware capability (CA_SUNW_HW_1) unsupported: 0x2000  [ AVX ]
FAIL: libitm.c/cancel.c execution test

This is the same issue solved by
gcc/testsuite/gcc.target/i386/clearcap.map, and the following patch
adresses it in the same way:

* Detect if the linker used supports -M .

* Use it when linking libitm.so.

Right now, it is only possible to clear the hardware capabilities
completely, while the new v2 mapfile syntax supports selectively adding
and removing capabilities.  It is only available in Solaris 11 and
Solaris 10 Update 10, though, so I'm restricting us to the v1 syntax for
now.

It may make sense to move the test to toplevel config/ld-hwcap.m4 later,
but for now libitm is the only user.

Bootstrapped on i386-pc-solaris2.11 with Sun as/ld, gas/Sun ld, and
gas/gld, on i386-pc-solaris2.8 to make sure it doesn't break the build
with the old linker there, and on x86_64-unknown-linux-gnu.

Ok for mainline?

Rainer


2011-11-18  Rainer Orth  

* clearcap.map: New file.
* acinclude.m4 (LIBITM_CHECK_LINKER_HWCAP): New test.
* configure.ac: Call it.
* Makefile.am (AM_LDFLAGS): Add $(HWCAP_LDFLAGS)
* configure: Regenerate.
* Makefile.in: Regenerate.
* testsuite/Makefile.in: Regenerate.

# HG changeset patch
# Parent fe631cce39f95ae2f718499a8e82260c18149752
Clear hardware capabilities on libitm.so with Sun ld

diff --git a/libitm/Makefile.am b/libitm/Makefile.am
--- a/libitm/Makefile.am
+++ b/libitm/Makefile.am
@@ -21,7 +21,7 @@ AM_CFLAGS = $(XCFLAGS)
 AM_CXXFLAGS = -std=gnu++0x -funwind-tables -fno-exceptions -fno-rtti \
 	$(XCFLAGS) $(abi_version)
 AM_CCASFLAGS = $(XCFLAGS)
-AM_LDFLAGS = $(XLDFLAGS) $(SECTION_LDFLAGS) $(OPT_LDFLAGS)
+AM_LDFLAGS = $(XLDFLAGS) $(SECTION_LDFLAGS) $(OPT_LDFLAGS) $(HWCAP_LDFLAGS)
 
 toolexeclib_LTLIBRARIES = libitm.la
 nodist_toolexeclib_HEADERS = libitm.spec
diff --git a/libitm/acinclude.m4 b/libitm/acinclude.m4
--- a/libitm/acinclude.m4
+++ b/libitm/acinclude.m4
@@ -256,6 +256,34 @@ AC_DEFUN([LIBITM_CHECK_LINKER_FEATURES],
 
 
 dnl
+dnl Check if the linker used supports linker maps to clear hardware
+dnl capabilities.  This is only supported by Sun ld at the moment.
+dnl
+dnl Defines:
+dnl  HWCAP_LDFLAGS='-Wl,-M,clearcap.map' if possible
+dnl  LD (as a side effect of testing)
+dnl
+AC_DEFUN([LIBITM_CHECK_LINKER_HWCAP], [
+  test -z "$HWCAP_LDFLAGS" && HWCAP_LDFLAGS=''
+  AC_REQUIRE([AC_PROG_LD])
+
+  ac_save_LDFLAGS="$LDFLAGS"
+  LDFLAGS="$LFLAGS -Wl,-M,$srcdir/clearcap.map"
+
+  AC_MSG_CHECKING([for ld that supports -Wl,-M,mapfile])
+  AC_TRY_LINK([], [return 0;], [ac_hwcap_ldflags=yes],[ac_hwcap_ldflags=no])
+  if test "$ac_hwcap_ldflags" = "yes"; then
+HWCAP_LDFLAGS="-Wl,-M,$srcdir/clearcap.map $HWCAP_LDFLAGS"
+  fi
+  AC_MSG_RESULT($ac_hwcap_ldflags)
+
+  LDFLAGS="$ac_save_LDFLAGS"
+
+  AC_SUBST(HWCAP_LDFLAGS)
+])
+
+
+dnl
 dnl Add version tags to symbols in shared library (or not), additionally
 dnl marking other symbols as private/local (or not).
 dnl
diff --git a/libitm/clearcap.map b/libitm/clearcap.map
new file mode 100644
--- /dev/null
+++ b/libitm/clearcap.map
@@ -0,0 +1,14 @@
+# Clear hardware capabilities emitted by Sun as: calls to the x86_avx.c
+# functions are only emitted with -mavx.
+#
+# The v1 mapfile syntax has no support for clearing specific capabilities,
+# so clear everything.
+#
+hwcap_1 = V0x0 OVERRIDE;
+#
+# If we can assume mapfile v2 syntax, we can specificially clear AVX.
+#
+#$mapfile_version 2
+#CAPABILITY {
+#	HW -= AVX;
+#};
diff --git a/libitm/configure.ac b/libitm/configure.ac
--- a/libitm/configure.ac
+++ b/libitm/configure.ac
@@ -208,10 +208,11 @@ GCC_LINUX_FUTEX(:)
 # See if we support thread-local storage.
 GCC_CHECK_TLS
 
-# See what sort of export controls are availible.
+# See what sort of export controls are available.
 LIBITM_CHECK_ATTRIBUTE_VISIBILITY
 LIBITM_CHECK_ATTRIBUTE_DLLEXPORT
 LIBITM_CHECK_ATTRIBUTE_ALIAS
+LIBITM_CHECK_LINKER_HWCAP
 LIBITM_ENABLE_SYMVERS
 
 if test $enable_symvers = gnu; then

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


Re: [PATCH, take 2] Fix PR tree-optimization/49960 ,Fix self data dependence

2011-11-21 Thread Jakub Jelinek
On Mon, Nov 21, 2011 at 03:50:10PM +0200, Razya Ladelsky wrote:
> what do you mean by 'except for the affine stuff'?

I mean that compute_affine_dependence must never be called on gather
data refs, that function can't do anything meaningful for them, they are
gather data refs exactly because dr_analyze_innermost failed on them
otherwise, as base and/or offset aren't simple IVs.

> > So, when compute_all_dependences no longer calls it, neither should
> > vect_analyze_data_refs.
> 
> So do you want to replace it with the call to compute_affine_dependence?

No.  With nothing at all.

Jakub


Re: [RFA/testsuite] Update gcc.dg/vshift-*.c tests to use rand and not random

2011-11-21 Thread Jakub Jelinek
On Mon, Nov 21, 2011 at 01:58:18PM +, Matthew Gretton-Dann wrote:
> gcc/testsuite/ChangeLog:
> 
> 2011-11-21  Matthew Gretton-Dann  
> 
>* gcc.dg/vshift-1.c (main): Call rand instead of random.
>* gcc.dg/vshift-3.c (main): Likewise.

This is ok for the trunk.

Jakub


[libitm, build] Support sun symbol versioning

2011-11-21 Thread Rainer Orth
Symbol versioning support in libitm is currently based on an old version
of the code in libgomp, which doesn't support sun style versioning.  The
following patch corrects this by merging the changes made to libgomp
versioning support since, with the exception of parts that aren't used
in libitm (symbol renaming).  This is yet another copy of that code, and
I still mean to unify all this in one place, but stage 3 isn't the right
time to do so.

I noticed a few issues while testing this patch: 

* libitm.so wasn't versioned even with gld, since libitm_la_LDFLAGS
  wasn't passed when linking it.

* The make_sunver.pl script didn't handle the '?' wildcard in version
  scripts, thus a few symbols in libitm.map were missing from the shared
  object.

* _ITM_getThreadnum is the only symbol in libitm.map that isn't present
  in the library.  It's documented as missing and should perhaps be
  removed from the map?

Bootstrapped without regressions on i386-pc-solaris2.11 with as/ld,
gas/ld, gas/gld, the version info in libitm.so is identical in all 3
cases.  Also bootstrapped on x86_64-unknown-linux-gnu,
i386-pc-solaris2.8 bootstrap in progress, but version info already
identical between S8 and S11.

Ok for mainline?

Rainer


2011-11-19  Rainer Orth  

libitm:
* acinclude.m4 (LIBITM_CHECK_LINKER_FEATURES): Handle gold.
(LIBITM_ENABLE_SYMVERS): Handle sun style.
* Makefile.am: Handle sun style versioning.
(libitm_la_LINK): Add $(libitm_la_LDFLAGS).
* configure: Regenerate.
* Makefile.in: Regenerate.

contrib:
* make_sunver.pl: Convert '?' in glob patterns to '.'.

# HG changeset patch
# Parent 71a5e39a12afc29fc0ed07ce5e822d817c788a49
Support sun symbol versioning

diff --git a/contrib/make_sunver.pl b/contrib/make_sunver.pl
--- a/contrib/make_sunver.pl
+++ b/contrib/make_sunver.pl
@@ -276,9 +276,10 @@ while () {
 if (/^([ \t]*)([^ \t;{}#]+);?[ \t]*$/) {
 	my $ws = $1;
 	my $ptn = $2;
-	# Turn the glob into a regex by replacing '*' with '.*'.
+	# Turn the glob into a regex by replacing '*' with '.*', '?' with '.'.
 	# Keep $ptn so we can still print the original form.
 	($pattern = $ptn) =~ s/\*/\.\*/g;
+	$pattern =~ s/\?/\./g;
 
 	if ($glob eq 'ign') {
 	# We're in a local: * section; just continue.
diff --git a/libitm/Makefile.am b/libitm/Makefile.am
--- a/libitm/Makefile.am
+++ b/libitm/Makefile.am
@@ -27,15 +27,33 @@ toolexeclib_LTLIBRARIES = libitm.la
 nodist_toolexeclib_HEADERS = libitm.spec
 
 if LIBITM_BUILD_VERSIONED_SHLIB
+if LIBITM_BUILD_VERSIONED_SHLIB_GNU
 libitm_version_script = -Wl,--version-script,$(top_srcdir)/libitm.map
+libitm_version_dep = $(top_srcdir)/libitm.map
+endif
+if LIBITM_BUILD_VERSIONED_SHLIB_SUN
+libitm_version_script = -Wl,-M,libitm.map-sun
+libitm_version_dep = libitm.map-sun
+libitm.map-sun : $(top_srcdir)/libitm.map \
+		$(top_srcdir)/../contrib/make_sunver.pl \
+		$(libitm_la_OBJECTS) $(libitm_la_LIBADD)
+	perl $(top_srcdir)/../contrib/make_sunver.pl \
+	  $(top_srcdir)/libitm.map \
+	  $(libitm_la_OBJECTS:%.lo=.libs/%.o) \
+	 `echo $(libitm_la_LIBADD) | \
+	sed 's,/\([^/.]*\)\.la,/.libs/\1.a,g'` \
+	 > $@ || (rm -f $@ ; exit 1)
+endif
 else
 libitm_version_script =
+libitm_version_dep =
 endif
 libitm_version_info = -version-info $(libtool_VERSION)
 
 # Force link with C, not C++.  For now, while we're using C++ we don't
 # want or need libstdc++.
-libitm_la_LINK = $(LINK)
+libitm_la_DEPENDENCIES = $(libitm_version_dep)
+libitm_la_LINK = $(LINK) $(libitm_la_LDFLAGS)
 libitm_la_LDFLAGS = $(libitm_version_info) $(libitm_version_script) \
 -no-undefined
 
diff --git a/libitm/acinclude.m4 b/libitm/acinclude.m4
--- a/libitm/acinclude.m4
+++ b/libitm/acinclude.m4
@@ -169,6 +169,7 @@ dnl  OPT_LDFLAGS='-Wl,-O1' if possible
 dnl  LD (as a side effect of testing)
 dnl Sets:
 dnl  with_gnu_ld
+dnl  libitm_ld_is_gold (possibly)
 dnl  libitm_gnu_ld_version (possibly)
 dnl
 dnl The last will be a single integer, e.g., version 1.23.45.0.67.89 will
@@ -200,9 +201,13 @@ AC_DEFUN([LIBITM_CHECK_LINKER_FEATURES],
 
   # Start by getting the version number.  I think the libtool test already
   # does some of this, but throws away the result.
+  libitm_ld_is_gold=no
+  if $LD --version 2>/dev/null | grep 'GNU gold'> /dev/null 2>&1; then
+libitm_ld_is_gold=yes
+  fi
   changequote(,)
-  ldver=`$LD --version 2>/dev/null | head -1 | \
- sed -e 's/GNU ld \(version \)\{0,1\}\(([^)]*) \)\{0,1\}\([0-9.][0-9.]*\).*/\3/'`
+  ldver=`$LD --version 2>/dev/null |
+ sed -e 's/GNU gold /GNU ld /;s/GNU ld version /GNU ld /;s/GNU ld ([^)]*) /GNU ld /;s/GNU ld \([0-9.][0-9.]*\).*/\1/; q'`
   changequote([,])
   libitm_gnu_ld_version=`echo $ldver | \
  $AWK -F. '{ if (NF<3) [$]3=0; print ([$]1*100+[$]2)*100+[$]3 }'`
@@ -300,16 +305,46 @@ AC_DEFUN([LIBITM_ENABLE_SYMVERS], [
 
 LIBITM_ENABLE(symvers,yes,[=STYLE],
   [enables symbol versioning of the shared library],
-  [permit yes|no|gnu])
+  [pe

[Patch,AVR]: Fix cc0 and loading const_int/const_double

2011-11-21 Thread Georg-Johann Lay
After updating my local copy I get new runtime FAILs in the test suite because
of the following sequence, e.g. from gcc.c-torture/execute/990527-1.c:

sbiw r28,1   ;  12  addhi3_clobber/1[length = 1]
ldi r24,lo8(9)   ;  24  *movhi/5[length = 2]
clr r25
brne .L3 ;  16  branch  [length = 1]

The trouble is that *movhi promises that it does not change cc0. Thus, the
correct code is:

sbiw r28,1   ;  12  addhi3_clobber/1[length = 1]
ldi r24,lo8(9)   ;  24  *movhi/5[length = 2]
ldi r25,0
brne .L3 ;  16  branch  [length = 1]

The patch fixes this and adjusts cc attribute of involved insns.

When loading 0, cc=none is more useful than cc=set_zn because the compiler
knows what it loads, and cc=none preserves cc0 from preceding code.

Tests pass fine again.

Ok to apply?

Johann

* config/avr/avr.c (output_reload_in_const): Loading a byte with 0
must not affect cc0.
* config/avr/avr.md (*movhi, *movpsi, *movsi, *movsf): Zero to any
register does not change cc0. Same for any constant to ld-register.

Index: config/avr/avr.md
===
--- config/avr/avr.md	(revision 181554)
+++ config/avr/avr.md	(working copy)
@@ -649,7 +649,7 @@ (define_insn "*movhi"
   }
   [(set_attr "length" "2,2,6,7,2,6,5,2")
(set_attr "adjust_len" "mov16")
-   (set_attr "cc" "none,clobber,clobber,clobber,none,clobber,none,none")])
+   (set_attr "cc" "none,none,clobber,clobber,none,clobber,none,none")])
 
 (define_peephole2 ; movw
   [(set (match_operand:QI 0 "even_register_operand" "")
@@ -752,7 +752,7 @@ (define_insn "*movpsi"
   }
   [(set_attr "length" "3,3,8,9,4,10")
(set_attr "adjust_len" "mov24")
-   (set_attr "cc" "none,set_zn,clobber,clobber,clobber,clobber")])
+   (set_attr "cc" "none,none,clobber,clobber,none,clobber")])
   
 ;;==
 ;; move double word (32 bit)
@@ -793,7 +793,7 @@ (define_insn "*movsi"
   }
   [(set_attr "length" "4,4,8,9,4,10")
(set_attr "adjust_len" "mov32")
-   (set_attr "cc" "none,set_zn,clobber,clobber,clobber,clobber")])
+   (set_attr "cc" "none,none,clobber,clobber,none,clobber")])
 
 ;; f
 ;; move floating point numbers (32 bit)
@@ -809,7 +809,7 @@ (define_insn "*movsf"
   }
   [(set_attr "length" "4,4,8,9,4,10")
(set_attr "adjust_len" "mov32")
-   (set_attr "cc" "none,set_zn,clobber,clobber,clobber,clobber")])
+   (set_attr "cc" "none,none,clobber,clobber,none,clobber")])
 
 (define_peephole2 ; *reload_insf
   [(match_scratch:QI 2 "d")
Index: config/avr/avr.c
===
--- config/avr/avr.c	(revision 181554)
+++ config/avr/avr.c	(working copy)
@@ -8836,7 +8836,13 @@ avr_regno_mode_code_ok_for_base_p (int r
LEN != NULL: set *LEN to the length of the instruction sequence
 (in words) printed with LEN = NULL.
If CLEAR_P is true, OP[0] had been cleard to Zero already.
-   If CLEAR_P is false, nothing is known about OP[0].  */
+   If CLEAR_P is false, nothing is known about OP[0].
+
+   The effect on cc0 is as follows:
+
+   Load 0 to any register  : NONE
+   Load ld register with any value : NONE
+   Anything else:  : CLOBBER  */
 
 static void
 output_reload_in_const (rtx *op, rtx clobber_reg, int *len, bool clear_p)
@@ -8914,7 +8920,7 @@ output_reload_in_const (rtx *op, rtx clo
   xop[2] = clobber_reg;
 
   if (n >= 2 + (avr_current_arch->n_segments > 1))
-avr_asm_len ("clr %0", xop, len, 1);
+avr_asm_len ("mov %0,__zero_reg__", xop, len, 1);
   else
 avr_asm_len (asm_code[n][ldreg_p], xop, len, ldreg_p ? 1 : 2);
   continue;
@@ -8946,14 +8952,13 @@ output_reload_in_const (rtx *op, rtx clo
 }
 }
 
-  /* Use CLR to zero a value so that cc0 is set as expected
- for zero.  */
+  /* Don't use CLR so that cc0 is set as expected.  */
   
   if (ival[n] == 0)
 {
   if (!clear_p)
-avr_asm_len ("clr %0", &xdest[n], len, 1);
-  
+avr_asm_len (ldreg_p ? "ldi %0,0" : "mov %0,__zero_reg__",
+ &xdest[n], len, 1);
   continue;
 }
 


[testsuite] Adapt c-c++-common/tm/malloc.c for Solaris headers with C++

2011-11-21 Thread Rainer Orth
This test fails on Solaris 2 when compiled as C++:

FAIL: c-c++-common/tm/malloc.c -std=gnu++98 scan-tree-dump-times tmmark " 
malloc .666" 1
FAIL: c-c++-common/tm/malloc.c -std=gnu++11 scan-tree-dump-times tmmark " 
malloc .666" 1

It scans for ' malloc', but the Solaris 2 headers are C++aware and
declare std::malloc, which also appears in the dump.

Fixed like this, bootstrapped on i386-pc-solaris2.11 and
x86_64-unknown-linux-gnu, installed on mainline.

Rainer


2011-11-20  Rainer Orth  

* c-c++-common/tm/malloc.c: Scan tree dumps for std::malloc if
*-*-solaris2* && c++.

# HG changeset patch
# Parent 14645d49968bcb44c9bae98bd2df933fc3253b3c
Adapt c-c++-common/tm/malloc.c for Solaris headers with C++

diff --git a/gcc/testsuite/c-c++-common/tm/malloc.c b/gcc/testsuite/c-c++-common/tm/malloc.c
--- a/gcc/testsuite/c-c++-common/tm/malloc.c
+++ b/gcc/testsuite/c-c++-common/tm/malloc.c
@@ -17,7 +17,9 @@ void foobar(void)
 z = (char *)malloc (666);
 }
 
-/* { dg-final { scan-tree-dump-times " malloc .666" 1 "tmmark" } } */
+/* { dg-final { scan-tree-dump-times " malloc .666" 1 "tmmark" { target { ! { *-*-solaris2* && c++ } } } } } */
+/* Solaris 2 headers are C++-aware and declare std::malloc.  */
+/* { dg-final { scan-tree-dump-times " std::malloc .666" 1 "tmmark" { target { *-*-solaris2* && c++ } } } } */
 /* { dg-final { scan-tree-dump-times "__builtin__ITM_malloc" 1 "tmmark" } } */
 /* { dg-final { scan-tree-dump-times "__builtin__ITM_calloc" 1 "tmmark" } } */
 /* { dg-final { scan-tree-dump-times "__builtin__ITM_free" 2 "tmmark" } } */

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


Re: [patch] update configury for FreeBSD 10 on gcc-4.6 branch

2011-11-21 Thread Gerald Pfeifer
On Mon, 21 Nov 2011, Joseph S. Myers wrote:
> I don't see this on mainline, only 4.6 branch - am I missing something 
> or is mainline now in a regressed state relative to 4.6?  A fix should 
> always go on mainline before 4.6, 4.6 before 4.5, 4.5 before 4.4, and 
> unless and until a full merge from libtool upstream happens that means 
> this partial fix.

Agreed, Joseph.  That's what we discussed.  We just wanted to give the 
build/configure guys a day or two for the libtool update, not making that 
one more tricky in case it finally happened, while not waiting longer 
before fixing the release branch.  So, technically you are absolutely 
right, and we'll close that window soon unless the wholesale libtool
update happens earlier.

Gerald


Re: [PATCH, take 2] Fix PR tree-optimization/49960 ,Fix self data dependence

2011-11-21 Thread Razya Ladelsky
Jakub Jelinek  wrote on 21/11/2011 03:59:15 PM:

> From: Jakub Jelinek 
> To: Razya Ladelsky/Haifa/IBM@IBMIL
> Cc: GCC Patches , Richard Guenther 
> 
> Date: 21/11/2011 03:59 PM
> Subject: Re: [PATCH, take 2] Fix PR tree-optimization/49960 ,Fix 
> self data dependence
> 
> On Mon, Nov 21, 2011 at 03:50:10PM +0200, Razya Ladelsky wrote:
> > what do you mean by 'except for the affine stuff'?
> 
> I mean that compute_affine_dependence must never be called on gather
> data refs, that function can't do anything meaningful for them, they are
> gather data refs exactly because dr_analyze_innermost failed on them
> otherwise, as base and/or offset aren't simple IVs.
> 

I understand.
I tried to follow the same paths that data refs (affine or not) go through 
in compute_all_depepndences.

According to compute_all_depepndences(), the path for computing any data 
dependence is:
call initialize_data_depepndence_relation(), and call 
compute_affine_dependence() if there's a loop nest.
I tried to keep the same semantics for self dependences.

Although compute_affine_dependence() can't do anything meaningful for the 
gather data refs,
it may still be assigning values to the dependence relation structure, if 
you need to use them. 
Therefore I did not skip the call to compute_self_dependence(), which 
indeed calls
compute_affine_depepndence().


If you think it's redundant, we can remove it.
Thanks,
Razya
 

> > > So, when compute_all_dependences no longer calls it, neither should
> > > vect_analyze_data_refs.
> > 
> > So do you want to replace it with the call to 
compute_affine_dependence?
> 
> No.  With nothing at all.
> 
>Jakub
> 



Re: libtool update

2011-11-21 Thread Andi Kleen
Markus Trippelsdorf  writes:
>
> I have deleted the tarballs because they don't apply cleanly anymore.
> But this is not rocket science and you can easily update to the new
> libtool yourself by just copying the new version to the gcc root dir
> and running "ACLOCAL='aclocal -I .. -I ../config' autoreconf -v" in the
> various subdirs.

It would be good if that could be done for 4.7. Then slim LTO
bootstrap has a chance to work. Are there any reasons left not to
update?

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


[RFA/testsuite] Update gcc.dg/vshift-*.c tests to use rand and not random

2011-11-21 Thread Matthew Gretton-Dann

All,

[Apologies to those getting this twice - used wrong account to send it 
initially].


The attached patch updates the gcc.dg/vshift-*.c tests to call the 
function rand and not random, as random is not available on all targets, 
but rand should be as it is in the Standard C Library.


Can someone please review the patch?

Thanks,

Matt

gcc/testsuite/ChangeLog:

2011-11-21  Matthew Gretton-Dann  

* gcc.dg/vshift-1.c (main): Call rand instead of random.
* gcc.dg/vshift-3.c (main): Likewise.

--
Matthew Gretton-Dann
Principal Engineer, PD Software - Tools, ARM Ltddiff --git a/gcc/testsuite/gcc.dg/vshift-1.c b/gcc/testsuite/gcc.dg/vshift-1.c
index 2a237aa..2220ad5 100644
--- a/gcc/testsuite/gcc.dg/vshift-1.c
+++ b/gcc/testsuite/gcc.dg/vshift-1.c
@@ -94,10 +94,10 @@ main ()
   for (i = 0; i < N; i++)
 {
   asm ("");
-  c[i] = (random () << 1) | (random () & 1);
+  c[i] = (rand () << 1) | (rand () & 1);
   b[i] = (i * 85) & (sizeof (TYPE1) * __CHAR_BIT__ - 1);
   a[i] = c[i];
-  d[i] = (random () << 1) | (random () & 1);
+  d[i] = (rand () << 1) | (rand () & 1);
   d[i] |= (unsigned long long) c[i] << 32;
   e[i] = (i * 85) & (sizeof (TYPE2) * __CHAR_BIT__ - 1);
   f[i] = d[i];
diff --git a/gcc/testsuite/gcc.dg/vshift-3.c b/gcc/testsuite/gcc.dg/vshift-3.c
index e62c76b..367e660 100644
--- a/gcc/testsuite/gcc.dg/vshift-3.c
+++ b/gcc/testsuite/gcc.dg/vshift-3.c
@@ -100,9 +100,9 @@ main ()
   for (i = 0; i < N; i++)
 {
   asm ("");
-  c[i] = (random () << 1) | (random () & 1);
+  c[i] = (rand () << 1) | (rand () & 1);
   a[i] = c[i];
-  d[i] = (random () << 1) | (random () & 1);
+  d[i] = (rand () << 1) | (rand () & 1);
   d[i] |= (unsigned long long) c[i] << 32;
   f[i] = d[i];
 }


[testsuite] Fix ultrasparc_vis[23]_hw tests

2011-11-21 Thread Rainer Orth
The new gcc.target/sparc/vec-init-[1-3]-vis3.c tests might fail on
Solaris 10 and 11 with Sun as on non-VIS3 capable hardware
(e.g. UltraSPARC T2 or UltraSPARC IV) like this:

ld.so.1: vec-init-1-vis3.exe: fatal: vec-init-1-vis3.exe: hardware capability (C
A_SUNW_HW_1) unsupported: 0x400  [ VIS3 ]
FAIL: gcc.target/sparc/vec-init-1-vis3.c execution test

This shouldn't happen, the tests should appear as UNSUPPORTED instead.  I
could trace this to the ultrasparc*_hw effective-target tests, which all
use the ultrasparc_hw keyword, so checking the wrong test.  By fixing
this, the test correctly appear as UNSUPPORTED in an
sparc-sun-solaris2.11 bootstrap.

Installed on mainline.

Rainer


2011-11-20  Rainer Orth  

* lib/target-supports.exp
(check_effective_target_ultrasparc_vis2_hw): Call check_runtime
with ultrasparc_vis2_hw.
(check_effective_target_ultrasparc_vis3_hw): Call check_runtime
with ultrasparc_vis3_hw.

# HG changeset patch
# Parent cbea07084d66f62d8e3d9405e9f5ca17d56ef97b
Fix ultrasparc_vis[23]_hw tests

diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -2476,7 +2476,7 @@ proc check_effective_target_ultrasparc_h
 # instructions.  We check this by attempting: "bmask %g0, %g0, %g0"
 
 proc check_effective_target_ultrasparc_vis2_hw { } {
-return [check_runtime ultrasparc_hw {
+return [check_runtime ultrasparc_vis2_hw {
 	int main() { __asm__(".word 0x81b00320"); return 0; }
 } "-mcpu=ultrasparc3"]
 }
@@ -2485,7 +2485,7 @@ proc check_effective_target_ultrasparc_v
 # instructions.  We check this by attempting: "addxc %g0, %g0, %g0"
 
 proc check_effective_target_ultrasparc_vis3_hw { } {
-return [check_runtime ultrasparc_hw {
+return [check_runtime ultrasparc_vis3_hw {
 	int main() { __asm__(".word 0x81b00220"); return 0; }
 } "-mcpu=niagara3"]
 }

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


Re: [PATCH, take 2] Fix PR tree-optimization/49960 ,Fix self data dependence

2011-11-21 Thread Jakub Jelinek
On Mon, Nov 21, 2011 at 04:54:09PM +0200, Razya Ladelsky wrote:
> Although compute_affine_dependence() can't do anything meaningful for the 
> gather data refs,
> it may still be assigning values to the dependence relation structure, if 
> you need to use them. 
> Therefore I did not skip the call to compute_self_dependence(), which 
> indeed calls
> compute_affine_depepndence().
> 
> 
> If you think it's redundant, we can remove it.

It is not just redundant, but harmful.  compute_affine_dependence assumes
that base and offset are simple IVs, that is not true for gather deps.
So please do remove it.

Jakub


[Patch libitm] [V2] config-based assessment of weakref capability

2011-11-21 Thread Iain Sandoe

Hello All,

This is the last piece needed to get libitm working on Darwin.

---

It is take 2 on auto-configury for weakrefs in libitm.

It takes into account the comments made by Rainer (and follow-up) on:
http://gcc.gnu.org/ml/gcc-patches/2011-11/msg01898.html

* moves the checking functions to config/weakref.m4

* tries to make it clear that we are checking for a specific weakref  
behavior.


-=-

If it is preferred that libitm should stand alone - then it would be  
easy to cut the relevant part of weakref.m4 back into libitm/ 
acinclude.m4.


This checked to DTRT on i686-darwin9 (weak ref doesn't behave like  
ELF's) and x86-64-darwin10/XCode 3.2.5 (weak ref behaves as per ELF).


It is my understanding from some off-list discussion reported with the  
ld64 engineer -
- that Darwin >= 10 should, in principle, support ELF-style weak refs  
(as well as the two-level and flat_namespace versions).


comments/OK for trunk?
Iain

config:

* weakref.m4: New file.

libitm:

* configure.ac: Use GCC_CHECK_ELF_STYLE_WEAKREF.
* alloc_cpp.cc: Generate dummy functions if we don't
HAVE_ELF_STYLE_WEAKREF.
* eh_cpp.cc: Likewise.
* configure: Regenerate.
* aclocal.m4:  Likewise.
* config.h.in: Likewise.

Index: config/weakref.m4
===
--- config/weakref.m4   (revision 0)
+++ config/weakref.m4   (revision 0)
@@ -0,0 +1,48 @@
+
+dnl Check if the target supports weak.
+AC_DEFUN([GCC_CHECK_ATTRIBUTE_WEAK], [
+  AC_CACHE_CHECK([whether the target supports weak],
+ac_cv_have_attribute_weak, [
+  weakref_m4_saved_CFLAGS="$CFLAGS"
+  CFLAGS="$CFLAGS -Werror"
+  AC_TRY_COMPILE([void __attribute__((weak)) foo(void) { }],
+[], ac_cv_have_attribute_weak=yes,
+ac_cv_have_attribute_weak=no)
+  CFLAGS="$weakref_m4_saved_CFLAGS"])
+  if test $ac_cv_have_attribute_weak = yes; then
+AC_DEFINE(HAVE_ATTRIBUTE_WEAK, 1,
+  [Define to 1 if the target supports __attribute__((weak)).])
+  fi])
+
+dnl Check whether weak refs work like the ELF ones.
+dnl This means that the weak reference works without having to satify 
+dnl linkage for the item.
+dnl There are targets (at least Darwin) where we have fully functional
+dnl weakrefs at runtime, but must supply the referenced item at link time.
+AC_DEFUN([GCC_CHECK_ELF_STYLE_WEAKREF], [
+  AC_CACHE_CHECK([whether weak refs work like ELF],
+  ac_cv_have_elf_style_weakref, [
+  weakref_m4_saved_CFLAGS="$CFLAGS"
+  case "${host}" in
+*-apple-darwin*) CFLAGS="$CFLAGS -Wl,-undefined,dynamic_lookup" ;;
+*) ;;
+  esac  
+  AC_RUN_IFELSE([AC_LANG_SOURCE([[
+extern void fNotToBeFound(void) __attribute__((weak));
+int main () 
+{
+  if (fNotToBeFound)
+return 1;
+  else
+return 0;
+}
+]])], ac_cv_have_elf_style_weakref=yes, ac_cv_have_elf_style_weakref=no, [
+case "${host}" in
+  alpha*-dec-osf*) ac_cv_have_elf_style_weakref=no ;;
+  *-apple-darwin[[89]]*) ac_cv_have_elf_style_weakref=no ;;
+  *) ac_cv_have_elf_style_weakref=yes;;
+esac])CFLAGS="$weakref_m4_saved_CFLAGS"])
+if test x"$ac_cv_have_elf_style_weakref" = xyes; then
+  AC_DEFINE(HAVE_ELF_STYLE_WEAKREF, 1, [Define to 1 if target has a weakref 
that works like the ELF one.])
+fi])
+
Index: libitm/configure.ac
===
--- libitm/configure.ac (revision 181573)
+++ libitm/configure.ac (working copy)
@@ -239,6 +239,8 @@ LIBITM_CHECK_SYNC_BUILTINS
 LIBITM_CHECK_64BIT_SYNC_BUILTINS
 LIBITM_CHECK_AS_AVX
 
+GCC_CHECK_ELF_STYLE_WEAKREF
+
 # Cleanup and exit.
 CFLAGS="$save_CFLAGS"
 AC_CACHE_SAVE
Index: libitm/alloc_cpp.cc
===
--- libitm/alloc_cpp.cc (revision 181573)
+++ libitm/alloc_cpp.cc (working copy)
@@ -60,7 +60,7 @@ extern void _ZdlPvRKSt9nothrow_t (void *, c_nothro
 extern void *_ZnaXRKSt9nothrow_t (size_t, c_nothrow_p) __attribute__((weak));
 extern void _ZdaPvRKSt9nothrow_t (void *, c_nothrow_p) __attribute__((weak));
 
-#ifdef __osf__ /* Really: !HAVE_WEAKDEF  */
+#if !defined (HAVE_ELF_STYLE_WEAKREF)
 void *_ZnwX (size_t) { return NULL; }
 void _ZdlPv (void *) { return; }
 void *_ZnaX (size_t) { return NULL; }
@@ -70,7 +70,7 @@ void *_ZnwXRKSt9nothrow_t (size_t, c_nothrow_p) {
 void _ZdlPvRKSt9nothrow_t (void *, c_nothrow_p) { return; }
 void *_ZnaXRKSt9nothrow_t (size_t, c_nothrow_p) { return NULL; }
 void _ZdaPvRKSt9nothrow_t (void *, c_nothrow_p) { return; }
-#endif /* __osf__ */
+#endif /* HAVE_ELF_STYLE_WEAKREF */
 
 /* Wrap the delete nothrow symbols for usage with a single argument.
Perhaps should have a configure type check for this, because the
Index: libitm/eh_cpp.cc
===
--- libitm/eh_cpp.cc(revision 181573)
+++ libitm/eh_cpp.cc(working copy)
@@ -39,13 +39,13 @@ extern void *__cxa_begin_catch (void *) WEAK;
 extern void *__cxa_e

Fix PR51125 (was: death@scope broke TM tests)

2011-11-21 Thread Michael Matz
Hi,

On Fri, 18 Nov 2011, Aldy Hernandez wrote:

> I just CC'ed you on a bug that I believe was caused by your patch.
> 
> I forgot to CC you on the bug before I wrote the comment on it.
> 
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51125#c4
> 
> Perhaps you can take a look?

The attached patch fixes the problem.  The TM machinery tried to deal with 
the death marker as if it was a real assignment leading to the trouble.  
The patch avoids this (leaving the clobber for expand to see).

As I'm not totally sure about semantics of TM I don't know if the 
occurrence of this problem doesn't also point to a missed optimization for 
the TM handling.  The situation after gimplification looks basically like 
so:

__transaction_atomic
  {
{
  struct shared_count sc;
  try
// ctor(&sc), dtor(&sc)
  finally
{
  sc = {CLOBBER};
}
}
  }

later lowered to:

:
  __transaction_atomic  // SUBCODE=[ GTMA_HAVE_STORE ]
:
  // ctor(&sc),dtor(&sc) [tm-clone]
  goto ;

:
  sc ={v} {CLOBBER};
  __builtin__ITM_commitTransaction ();

:
  return 0;

:
  landing-pad

The object 'sc' is constructed on the stack.  Is it necessary to make it 
transact?  If not, then you can possibly improve code quality somewhat by 
ignoring the clobbers also in requires_barrier (which then would need 
changes to receive the whole statement, not just the lhs/rhs to determine 
if this is an ignorable statement).  I haven't tried this, though.  The 
patch below would be necessary anyway.

In any case, patch fixes the testcases again, regstrapping on x86_64-linux 
in progress.  Okay for trunk?


Ciao,
Michael.

PR other/51125
* trans-mem.c (expand_block_tm): Ignore clobbers.

Index: trans-mem.c
===
--- trans-mem.c (revision 181582)
+++ trans-mem.c (working copy)
@@ -2319,7 +2319,8 @@ expand_block_tm (struct tm_region *regio
{
case GIMPLE_ASSIGN:
  /* Only memory reads/writes need to be instrumented.  */
- if (gimple_assign_single_p (stmt))
+ if (gimple_assign_single_p (stmt)
+ && !gimple_clobber_p (stmt))
{
  expand_assign_tm (region, &gsi);
  continue;


Re: Massive breakage with your libgcc patches

2011-11-21 Thread Rainer Orth
Paolo Bonzini  writes:

> On 11/07/2011 07:15 PM, Rainer Orth wrote:
>> Bernd Schmidt  writes:
>> 
>>> On 11/03/11 20:20, Rainer Orth wrote:

* config/c6x/t-elf (LIB2ADDEH): Set.
* config/c6x/t-c6x-elf: Remove.
>>>
>>> It builds now, but parts of libgcc are missing. There's no sign of
>>> muldf3, for examples.
>> 
>> I found the problem: before, LIB2ADD was passed in from gcc/config via
>> libgcc.mvars, and added to in t-softfp.  Now the order of the t-*
>> fragments has been kept the same, with the assignment to LIB2ADD in
>> c6x/t-elf overriding what has been constructed by t-softfp before.
>> 
>> The following patch did the trick for me, could you give it a try?
>
> Looks ok, but these look like they could also be broken.

Sorry it took me so long, but this weekend I finally had a close look
at both the explicit settings of LIB2ADD and LIB2FUNCS_EXCLUDE.  The
latter are unproblematic since the files affected are disjunct.  For
LIB2ADD, here are the problematic cases.  All others explicitly setting
LIB2ADD have no issues since there are no t-* fragments setting LIB2ADD
before.

i386/t-darwin64:LIB2ADD = $(srcdir)/config/darwin-64.c

  The file is currently unused, was lost in the migration for
  x86_64-*-darwin*.  The same settings are already in i386/t-darwin, so
  the file is superfluous and can be removed.

iq2000/t-iq2000:LIB2ADD = $(srcdir)/udivmod.c \

  This file is unused, now restored, otherwise no problem.

pa/t-pa64:LIB2ADD = $(srcdir)/config/pa/quadlib.c

  This overrides pa/t-hpux, originally we had pa/t-pa64 pa/t-pa-hpux
  without overrides, but the result is ok.

rs6000/t-darwin64:LIB2ADD = $(srcdir)/config/rs6000/darwin-tramp.S \

  Overrides rs6000/t-darwin, as it did before the move.

rs6000/t-lynx:LIB2ADD = $(srcdir)/config/rs6000/tramp.S

  This file is currently unused, but necessary.  t-lynx is also missing,
  but no settings left.

rs6000/t-netbsd:LIB2ADD = $(srcdir)/config/rs6000/tramp.S

  unused, necessary

sh/t-netbsd:LIB2ADD =

  The override poses no problem, but is unnecessary since nothing sets
  LIB2ADD before.

t-vxworks:LIB2ADD = $(srcdir)/config/vxlib.c $(srcdir)/config/vxlib-tls.c

  Ok, but missing from powerpc-wrs-vxworks which didn't add to tmake_file.

The following patch implements those observations.

Ok for mainline?

Rainer


2011-11-20  Rainer Orth  

libgcc:
* config.host (iq2000*-*-elf*): Add iq2000/t-iq2000 to tmake_file.
(powerpc-*-netbsd*): Add rs6000/t-netbsd to tmake_file.
(powerpc-wrs-vxworks, powerpc-wrs-vxworksae): Add to tmake_file.
(powerpc-*-lynxos*): Add rs6000/t-lynx to tmake_file.
* config/i386/t-darwin64: Remove.
* config/sh/t-netbsd (LIB2ADD): Remove.

# HG changeset patch
# Parent 5acb7cf614f2b6be2dd842aa54595488a6283198
Fix LIB2ADD overrides in libgcc

diff --git a/libgcc/config.host b/libgcc/config.host
--- a/libgcc/config.host
+++ b/libgcc/config.host
@@ -672,7 +672,7 @@ ia64-hp-*vms*)
 	md_unwind_header=ia64/vms-unwind.h
 	;;
 iq2000*-*-elf*)
-	tmake_file=t-fdpbit
+	tmake_file="iq2000/t-iq2000 t-fdpbit"
 	# Don't use default.
 	extra_parts=
 ;;
@@ -856,7 +856,7 @@ powerpc-*-freebsd*)
 	extra_parts="$extra_parts crtbeginT.o ecrti.o ecrtn.o ncrti.o ncrtn.o"
 	;;
 powerpc-*-netbsd*)
-	tmake_file="$tmake_file rs6000/t-crtstuff"
+	tmake_file="$tmake_file rs6000/t-netbsd rs6000/t-crtstuff"
 	;;
 powerpc-*-eabispe*)
 	tmake_file="${tmake_file} rs6000/t-ppccomm rs6000/t-crtstuff t-crtstuff-pic"
@@ -896,10 +896,10 @@ powerpc-*-linux* | powerpc64-*-linux*)
 	md_unwind_header=rs6000/linux-unwind.h
 	;;
 powerpc-wrs-vxworks|powerpc-wrs-vxworksae)
-	tmake_file="rs6000/t-ppccomm-ldbl t-fdpbit"
+	tmake_file="$tmake_file rs6000/t-ppccomm-ldbl t-fdpbit"
 	;;
 powerpc-*-lynxos*)
-	tmake_file="$tmake_file t-fdpbit"
+	tmake_file="$tmake_file rs6000/t-lynx t-fdpbit"
 	;;
 powerpcle-*-elf*)
 	tmake_file="${tmake_file} rs6000/t-ppccomm rs6000/t-ppccomm-ldbl rs6000/t-crtstuff t-crtstuff-pic t-fdpbit"
diff --git a/libgcc/config/i386/t-darwin64 b/libgcc/config/i386/t-darwin64
deleted file mode 100644
--- a/libgcc/config/i386/t-darwin64
+++ /dev/null
@@ -1,2 +0,0 @@
-LIB2_SIDITI_CONV_FUNCS = yes
-LIB2ADD = $(srcdir)/config/darwin-64.c
diff --git a/libgcc/config/sh/t-netbsd b/libgcc/config/sh/t-netbsd
--- a/libgcc/config/sh/t-netbsd
+++ b/libgcc/config/sh/t-netbsd
@@ -1,5 +1,3 @@
 LIB1ASMFUNCS_CACHE = _ic_invalidate
 
-LIB2ADD =
-
 HOST_LIBGCC2_CFLAGS += -mieee


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


Re: Massive breakage with your libgcc patches

2011-11-21 Thread Paolo Bonzini

On 11/21/2011 04:43 PM, Rainer Orth wrote:

Paolo Bonzini  writes:


On 11/07/2011 07:15 PM, Rainer Orth wrote:

Bernd Schmidt   writes:


On 11/03/11 20:20, Rainer Orth wrote:


* config/c6x/t-elf (LIB2ADDEH): Set.
* config/c6x/t-c6x-elf: Remove.


It builds now, but parts of libgcc are missing. There's no sign of
muldf3, for examples.


I found the problem: before, LIB2ADD was passed in from gcc/config via
libgcc.mvars, and added to in t-softfp.  Now the order of the t-*
fragments has been kept the same, with the assignment to LIB2ADD in
c6x/t-elf overriding what has been constructed by t-softfp before.

The following patch did the trick for me, could you give it a try?


Looks ok, but these look like they could also be broken.


Sorry it took me so long, but this weekend I finally had a close look
at both the explicit settings of LIB2ADD and LIB2FUNCS_EXCLUDE.  The
latter are unproblematic since the files affected are disjunct.  For
LIB2ADD, here are the problematic cases.  All others explicitly setting
LIB2ADD have no issues since there are no t-* fragments setting LIB2ADD
before.

i386/t-darwin64:LIB2ADD = $(srcdir)/config/darwin-64.c

   The file is currently unused, was lost in the migration for
   x86_64-*-darwin*.  The same settings are already in i386/t-darwin, so
   the file is superfluous and can be removed.

iq2000/t-iq2000:LIB2ADD = $(srcdir)/udivmod.c \

   This file is unused, now restored, otherwise no problem.

pa/t-pa64:LIB2ADD = $(srcdir)/config/pa/quadlib.c

   This overrides pa/t-hpux, originally we had pa/t-pa64 pa/t-pa-hpux
   without overrides, but the result is ok.

rs6000/t-darwin64:LIB2ADD = $(srcdir)/config/rs6000/darwin-tramp.S \

   Overrides rs6000/t-darwin, as it did before the move.

rs6000/t-lynx:LIB2ADD = $(srcdir)/config/rs6000/tramp.S

   This file is currently unused, but necessary.  t-lynx is also missing,
   but no settings left.

rs6000/t-netbsd:LIB2ADD = $(srcdir)/config/rs6000/tramp.S

   unused, necessary

sh/t-netbsd:LIB2ADD =

   The override poses no problem, but is unnecessary since nothing sets
   LIB2ADD before.

t-vxworks:LIB2ADD = $(srcdir)/config/vxlib.c $(srcdir)/config/vxlib-tls.c

   Ok, but missing from powerpc-wrs-vxworks which didn't add to tmake_file.

The following patch implements those observations.

Ok for mainline?

Rainer


2011-11-20  Rainer Orth

libgcc:
* config.host (iq2000*-*-elf*): Add iq2000/t-iq2000 to tmake_file.
(powerpc-*-netbsd*): Add rs6000/t-netbsd to tmake_file.
(powerpc-wrs-vxworks, powerpc-wrs-vxworksae): Add to tmake_file.
(powerpc-*-lynxos*): Add rs6000/t-lynx to tmake_file.
* config/i386/t-darwin64: Remove.
* config/sh/t-netbsd (LIB2ADD): Remove.








Ok.

Paolo


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

2011-11-21 Thread Rainer Orth
As reported in the PR, powerpc-rtems bootstrap (and certainly several
other powerpc targets) is currently broken since rs6000/ibm-ldouble.c
appears twice in LIB2ADD, once from rs6000/t-ppccomm and
rs6000/t-ppccomm-ldbl, which confuses make.

It took me a while to understand how we got into that situation.  Here's
what I found: before the toplevel libgcc move started, we had both
gcc/config/rs6000/t-ppccomm and libgcc/config/rs6000/t-ppccomm.  The
second is a superset of the first, in that it contains LIB2ADD_ST +=
crtsavfpr.S crtresfpr.S and many other similar files.

The set of targets using the gcc and libgcc files differs:

gcc/config/rs6000/t-ppccomm libgcc/config/rs6000/t-ppccomm

  powerpc-*-freebsd*powerpc-*-freebsd*
  powerpc-*-eabispe*powerpc-*-eabispe*
  powerpc-*-eabisimaltivec*
  powerpc-*-eabisim*
  powerpc-*-elf*
  powerpc-*-eabialtivec*
  powerpc-xilinx-eabi*
  powerpc-*-eabi*   powerpc-*-eabi*
  powerpc-*-rtems*
  powerpc-*-linux*  powerpc-*-linux*
| powerpc64-*-linux*  | powerpc64-*-linux*
  powerpc-*-gnu-gnualtivec*
  powerpc-*-gnu*
  powerpc-wrs-vxworks
| powerpc-wrs-vxworksae
  powerpcle-*-elf*
  powerpcle-*-eabisim*
  powerpcle-*-eabi*

When I started the move, I introduced
libgcc/config/rs6000/t-ppccomm-ldbl since I couldn't simply use the
existing t-ppccomm file which is used on a far smaller set of targets.

To reach an end state matching what we had before the move, I propose to
instead create a separate t-savresfgpr (for {sav,res}{fpr,gpr,gprctr})
that only contains the additional files and add that to the targets that
had it before, and remove t-ppccomm-ldbl to avoid the duplication.

When checking this, I noticed that powerpc-vxworks had lost
rs6000/t-ppccomm, which the patch adds back.

I'd really appreciate if some affected targets could fully test the
patch.

Thanks.
Rainer


2011-11-20  Rainer Orth  

PR other/51022
* config/rs6000/t-savresfgpr: New file.
* config/rs6000/t-ppccomm (LIB2ADD_ST): Remove all but
$(srcdir)/config/rs6000/eabi.S.
* config/rs6000/t-ppccomm-ldbl: Remove.
* config.host (powerpc-*-freebsd*): Add rs6000/t-savresfgpr to
tmake_file.
(powerpc-*-eabispe*): Likewise.
(powerpc-*-eabi*): Likewise.
(powerpc-*-linux*, powerpc64-*-linux*): Likewise.
(powerpc-wrs-vxworks, powerpc-wrs-vxworksae): Add rs6000/t-ppccomm
to tmake_file, remove rs6000/t-ppccomm-ldbl.
(powerpc-*-eabisimaltivec*): Remove rs6000/t-ppccomm-ldbl from
tmake_file.
(powerpc-*-eabisim*): Likewise.
(powerpc-*-elf*): Likewise.
(powerpc-*-eabialtivec*): Likewise.
(powerpc-xilinx-eabi*): Likewise.
(powerpc-*-rtems*): Likewise.
(powerpcle-*-elf*): Likewise.
(powerpcle-*-eabisim*): Likewise.
(powerpcle-*-eabi*): Likewise.

# HG changeset patch
# Parent 4ec0f566a9a8795dbe0d67024a347bd0ecd41e7a
Fix t-ppccomm bootstrap

diff --git a/libgcc/config/rs6000/t-ppccomm b/libgcc/config/rs6000/t-ppccomm
--- a/libgcc/config/rs6000/t-ppccomm
+++ b/libgcc/config/rs6000/t-ppccomm
@@ -29,13 +29,13 @@ LIB2ADD_ST += \
 
 # Assemble startup files.
 ecrti$(objext): $(srcdir)/config/rs6000/eabi-ci.S
-	$(crt_compile) -c ecrti.S
+	$(crt_compile) -c $<
 
 ecrtn$(objext): $(srcdir)/config/rs6000/eabi-cn.S
-	$(crt_compile) -c ecrtn.S
+	$(crt_compile) -c $<
 
 ncrti$(objext): $(srcdir)/config/rs6000/sol-ci.S
-	$(crt_compile) -c ncrti.S
+	$(crt_compile) -c $<
 
 ncrtn$(objext): $(srcdir)/config/rs6000/sol-cn.S
-	$(crt_compile) -c ncrtn.S
+	$(crt_compile) -c $<


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


Re: [PATCH] Remove dead labels to increase superblock scope

2011-11-21 Thread Michael Matz
Hi,

On Sat, 19 Nov 2011, Tom de Vries wrote:

> On 11/18/2011 10:29 PM, Eric Botcazou wrote:
> >> For the test-case of PR50764, a dead label is introduced by
> >> fixup_reorder_chain in cfg_layout_finalize, called from
> >> pass_reorder_blocks.
> > 
> > I presume that there is no reasonable way of preventing fixup_reorder_chain 
> > from introducing it or of teaching fixup_reorder_chain to remove it?
> > 
> 
> This (untested) patch also removes the dead label for the PR, and I 
> think it is safe. ...

cfgrtl.c has already code to delete labels (delete_insn) when appropriate 
(can_delete_label_p).  Perhaps that can be reused somehow.

> Index: cfglayout.c 
> === --- 
> cfglayout.c (revision 181377) +++ cfglayout.c (working copy) @@ -702,6 
> +702,21 @@ relink_block_chain (bool stay_in_cfglayo
>  }
>  
> 
> +static bool
> +forced_label_p (rtx label)
> +{
> +  rtx insn, forced_label;
> +  for (insn = forced_labels; insn; insn = XEXP (insn, 1))
> +{
> +  forced_label = XEXP (insn, 0);
> +  if (!LABEL_P (forced_label))
> + continue;
> +  if (forced_label == label)
> + return true;
> +}
> +  return false;
> +}

That's in_expr_list_p().

> @@ -857,6 +872,12 @@ fixup_reorder_chain (void)
>  (e_taken->src, e_taken->dest));
> e_taken->flags |= EDGE_FALLTHRU;
> update_br_prob_note (bb);
> +   if (LABEL_NUSES (ret_label) == 0

> +   && !LABEL_PRESERVE_P (ret_label)
> +   && LABEL_NAME (ret_label) == NULL
> +   && !forced_label_p (ret_label)

And this is cfgrtl.c:can_delete_label_p.  Note that you actually 
can remove labels also if they are !can_delete_label_p, if you use 
delete_insn (which you do).  It will replace such undeletable labels by a 
DELETED_LABEL note.


Ciao,
Michael.


Re: [Patch libitm] [V2] config-based assessment of weakref capability

2011-11-21 Thread Richard Henderson
On 11/21/2011 07:17 AM, Iain Sandoe wrote:
> config:
> 
> * weakref.m4: New file.
> 
> libitm:
> 
> * configure.ac: Use GCC_CHECK_ELF_STYLE_WEAKREF.
> * alloc_cpp.cc: Generate dummy functions if we don't
> HAVE_ELF_STYLE_WEAKREF.
> * eh_cpp.cc: Likewise.
> * configure: Regenerate.
> * aclocal.m4:  Likewise.
> * config.h.in: Likewise.

Ok.


r~


Re: Memset/memcpy patch

2011-11-21 Thread Michael Zolotukhin
Hi,

Continuing investigation of fails on bootstrap I found next problem
(besides the problem with unknown alignment described above): there is
a mess with size_needed and epilogue_size_needed when we generate
epilogue loop which also use SSE-moves, but no unrolled - that's
probably the reason of the fails we saw.

Please check the attached patch - though the full testing isn't over
yet. bootstraps seem to be ok as well as arrayarg.f90-test (with
sse_loop enabled).

On 19 November 2011 05:38, Jan Hubicka  wrote:
>> Given that x86 memset/memcpy is still broken, I think we should revert
>> it for now.
>
> Well, looking into the code, the SSE alignment issues needs work - the
> alignment test merely tests whether some alignmnet is known not whether 16 
> byte
> alignment is known that is the cause of failures in 32bit bootstrap.  I 
> originally
> convinced myself that this is safe since we soot for unaligned load/stores 
> anyway.
>
>
> I've commited the following patch that disabled SSE codegen and unbreaks atom
> bootstrap.  This seems more sensible to me given that the patch cumulated some
> good improvements on the non-SSE path as well and we could return into the SSE
> alignment issues incremntally.  There is still falure in the fortran testcase
> that I am convinced is previously latent issue.
>
> I will be offline tomorrow.  If there are futher serious problems, just fell
> free to revert the changes and we could look into them for next stage1.
>
> Honza
>
>        * i386.c (atom_cost): Disable SSE loop until alignment issues are 
> fixed.
> Index: i386.c
> ===
> --- i386.c      (revision 181479)
> +++ i386.c      (working copy)
> @@ -1783,18 +1783,18 @@ struct processor_costs atom_cost = {
>   /* stringop_algs for memcpy.
>      SSE loops works best on Atom, but fall back into non-SSE unrolled loop 
> variant
>      if that fails.  */
> -  {{{libcall, {{4096, sse_loop}, {4096, unrolled_loop}, {-1, libcall}}}, /* 
> Known alignment.  */
> -    {libcall, {{4096, sse_loop}, {4096, unrolled_loop}, {-1, libcall,
> -   {{libcall, {{2048, sse_loop}, {2048, unrolled_loop}, {-1, libcall}}}, /* 
> Unknown alignment.  */
> -    {libcall, {{2048, sse_loop}, {2048, unrolled_loop},
> +  {{{libcall, {{4096, unrolled_loop}, {-1, libcall}}}, /* Known alignment.  
> */
> +    {libcall, {{4096, unrolled_loop}, {-1, libcall,
> +   {{libcall, {{2048, unrolled_loop}, {-1, libcall}}}, /* Unknown alignment. 
>  */
> +    {libcall, {{2048, unrolled_loop},
>               {-1, libcall},
>
>   /* stringop_algs for memset.  */
> -  {{{libcall, {{4096, sse_loop}, {4096, unrolled_loop}, {-1, libcall}}}, /* 
> Known alignment.  */
> -    {libcall, {{4096, sse_loop}, {4096, unrolled_loop}, {-1, libcall,
> -   {{libcall, {{1024, sse_loop}, {1024, unrolled_loop},         /* Unknown 
> alignment.  */
> +  {{{libcall, {{4096, unrolled_loop}, {-1, libcall}}}, /* Known alignment.  
> */
> +    {libcall, {{4096, unrolled_loop}, {-1, libcall,
> +   {{libcall, {{1024, unrolled_loop},   /* Unknown alignment.  */
>               {-1, libcall}}},
> -    {libcall, {{2048, sse_loop}, {2048, unrolled_loop},
> +    {libcall, {{2048, unrolled_loop},
>               {-1, libcall},
>   1,                                   /* scalar_stmt_cost.  */
>   1,                                   /* scalar load_cost.  */



-- 
---
Best regards,
Michael V. Zolotukhin,
Software Engineer
Intel Corporation.


memfunc_epilogue_loops.patch
Description: Binary data


Support enforcing use of libgcc_s even with LINK_EH_SPEC

2011-11-21 Thread Rainer Orth
For the last two weeks, testsuite results on Solaris 11/x86 with gld
2.21.1 have been terrible, which hundreds of link failures.  One example
is

spawn /var/gcc/regression/trunk/11-gcc-gas-gld/build/gcc/xgcc 
-B/var/gcc/regression/trunk/11-gcc-gas-gld/build/gcc/ 
/vol/gcc/src/hg/trunk/local/libffi/testsuite/libffi.call/closure_fn0.c -O0 -W 
-Wall 
-I/var/gcc/regression/trunk/11-gcc-gas-gld/build/i386-pc-solaris2.11/./libffi/include
 -I/vol/gcc/src/hg/trunk/local/libffi/testsuite/../include 
-I/var/gcc/regression/trunk/11-gcc-gas-gld/build/i386-pc-solaris2.11/./libffi/include/..
 
-L/var/gcc/regression/trunk/11-gcc-gas-gld/build/i386-pc-solaris2.11/./libffi/.libs
 
-L/var/gcc/regression/trunk/11-gcc-gas-gld/build/i386-pc-solaris2.11/./libstdc++-v3/src/.libs
 -lffi -lm -o ./closure_fn0.exe
/vol/gcc/bin/gld-2.21.1: .compiler exited with status 1
output is:
/vol/gcc/bin/gld-2.21.1: .
FAIL: libffi.call/closure_fn0.c -O0 -W -Wall (test for excess errors)
Excess errors:
/vol/gcc/bin/gld-2.21.1: .
WARNING: libffi.call/closure_fn0.c -O0 -W -Wall compilation failed to produce 
executable

Executing this manually gives:

/vol/gcc/bin/gld-2.21.1: ./closure_fn0.exe: hidden symbol 
`__gcc_personality_v0' in 
/var/gcc/regression/trunk/11-gcc-gas-gld/build/gcc/libgcc_eh.a(unwind-c.o) is 
referenced by DSO
/vol/gcc/bin/gld-2.21.1: final link failed: Bad value
collect2: error: ld returned 1 exit status

The message could certainly be improved here!  (It turns out the DSO in
question is libffi.so.)

I've still to investigate where this bad pruning stems from, but the
problem boils down to the following: since this patch

2011-11-08  Michael Matz  

* gengtype.c (write_field_root): Avoid out-of-scope access of newv.

* tree-stdarg.c (execute_optimize_stdarg): Accept clobbers.
[...]

several of the target libraries developed references to
__gcc_personality_v0, which weren't there before.  The executable is
linked like this:

 /var/gcc/regression/trunk/11-gcc-gas-gld/build/gcc/collect2 --eh-frame-hdr -V 
-m elf_i386_sol2 -Y P,/usr/ccs/lib:/lib:/usr/lib -Qy -o ./closure_fn0.exe 
/usr/lib/crt1.o /usr/lib/crti.o /usr/lib/values-Xa.o 
/var/gcc/regression/trunk/11-gcc-gas-gld/build/gcc/crtbegin.o 
-L/var/gcc/regression/trunk/11-gcc-gas-gld/build/i386-pc-solaris2.11/./libffi/.libs
 
-L/var/gcc/regression/trunk/11-gcc-gas-gld/build/i386-pc-solaris2.11/./libstdc++-v3/src/.libs
 -L/var/gcc/regression/trunk/11-gcc-gas-gld/build/gcc closure_fn0.o -lffi -lm 
-lgcc -lgcc_eh -lc -lgcc -lgcc_eh 
/var/gcc/regression/trunk/11-gcc-gas-gld/build/gcc/crtend.o /usr/lib/crtn.o

i.e. only with libgcc_eh.a, where __gcc_personality_v0 is hidden.

The problem is that (unlike with ld), libffi.so isn't linked with
libgcc_s.so.1 because gcc.c (init_spec) decides that if LINK_EH_SPEC is
defined, this mustn't/needn't be done.  I've no idea why this should be
so, but hacked around it by forcing to always use libgcc_s with -shared
as in the patch below.  This brought testsuite results with gld much
more in line with Sun ld results, but most likely isn't appropriate, or
at the very least needs the FIXME comment filled in and documentation in
tm.texi.

One could of course also link all affected target libraries with an
explicit -shared-libgcc (as is already done for e.g. libobjc and
libstdc++).

Suggestions?

Rainer


2011-11-20  Rainer Orth  

* gcc.c (init_gcc_specs) [USE_SHARED_LIBGCC_FOR_EH]: Always use
libgcc_s.
* config/sol2.h [USE_GLD] (USE_SHARED_LIBGCC_FOR_EH): Define.

# HG changeset patch
# Parent 0f811d11987fd90895cf6fda7698d876e59f39a5
Support enforcing use of libgcc_s even with LINK_EH_SPEC

diff --git a/gcc/config/sol2.h b/gcc/config/sol2.h
--- a/gcc/config/sol2.h
+++ b/gcc/config/sol2.h
@@ -182,6 +182,8 @@ along with GCC; see the file COPYING3.  
--eh-frame-hdr to create the required .eh_frame_hdr sections.  */
 #if defined(HAVE_LD_EH_FRAME_HDR) && defined(TARGET_DL_ITERATE_PHDR)
 #define LINK_EH_SPEC "%{!static:--eh-frame-hdr} "
+/* Always use libgcc_s.  FIXME: Why?  */
+#define USE_SHARED_LIBGCC_FOR_EH 1
 #endif /* HAVE_LD_EH_FRAME && TARGET_DL_ITERATE_PHDR */
 #endif
 
diff --git a/gcc/gcc.c b/gcc/gcc.c
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -1291,7 +1291,7 @@ init_gcc_specs (struct obstack *obstack,
 		"%{!shared-libgcc:", static_name, " ", eh_name, "}"
 		"%{shared-libgcc:", shared_name, " ", static_name, "}"
 		"}"
-#ifdef LINK_EH_SPEC
+#if defined(LINK_EH_SPEC) && !USE_SHARED_LIBGCC_FOR_EH
 		"%{shared:"
 		"%{shared-libgcc:", shared_name, "}"
 		"%{!shared-libgcc:", static_name, "}"


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


Re: Minor contrib.texi update

2011-11-21 Thread Jeff Law
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 11/18/11 19:47, Gerald Pfeifer wrote:

> 
> Just mind the long line
Do we wrap earlier in the texi file (first line is 79chars I think)?
Or are you referring to an output file?

and it's Rawhide (uppercase), I think.
Yea, fixed.
jeff
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJOyoA/AAoJEBRtltQi2kC7iusH/1M5ilJkiWECEcj0NVdGVueS
XOKxXTXn3tmTnpR0wH7rcldF1fS47Dobfs/lbv8+/HAWH/W6W1S2dBTR4Q//YDRX
wUfkbj6V70diAVAntmw00A/duZIBIJC4+AuMY+jkjfMo8n0+KwDyYYZpK9G/SJV3
tjwy8ie0xiPj38BLwMPourF5ysDZ2W6lPgbCTDl/RfP7abpfpoJw4UwxIH5f+EsU
3K8ofAk4+xRoIp3f6/VUByfsiokx6p44YQRXS/JWk8nVoW/ooLcr0eip5QAtbtRo
YpRGZ1ZoPeuoRfBbH845wVR2bcwntC1v2iUAW1hs++dkGUIHus8+e+gBoE+IV+g=
=nlsH
-END PGP SIGNATURE-


Re: [PATCH, take 2] Fix PR tree-optimization/49960 ,Fix self data dependence

2011-11-21 Thread Razya Ladelsky
Jakub Jelinek  wrote on 21/11/2011 05:07:54 PM:

> From: Jakub Jelinek 
> To: Razya Ladelsky/Haifa/IBM@IBMIL
> Cc: GCC Patches , Richard Guenther 
> 
> Date: 21/11/2011 05:08 PM
> Subject: Re: [PATCH, take 2] Fix PR tree-optimization/49960 ,Fix 
> self data dependence
> 
> On Mon, Nov 21, 2011 at 04:54:09PM +0200, Razya Ladelsky wrote:
> > Although compute_affine_dependence() can't do anything meaningful for 
the 
> > gather data refs,
> > it may still be assigning values to the dependence relation structure, 
if 
> > you need to use them. 
> > Therefore I did not skip the call to compute_self_dependence(), which 
> > indeed calls
> > compute_affine_depepndence().
> > 
> > 
> > If you think it's redundant, we can remove it.
> 
> It is not just redundant, but harmful.  compute_affine_dependence 
assumes
> that base and offset are simple IVs, that is not true for gather deps.
> So please do remove it.
> 
>Jakub
> 

Jakub,

I have some non-affine cases for which compute_affine_dependence is called 
(as it is called for 
ALL dependences from compte_all_depepndences()), and no harm is done.
I looked a little bit closer into the code, and this is what happens for 
non affine accesses:

initialize_data_dependence_relation() assigns 
DDR_ARE_DEPENDENT (res) = chrec_dont_know for the dr.

Then, compute_affine_depepndence()
tests if (DDR_ARE_DEPENDENT (ddr) == NULL_TREE), and does nothing 
otherwise.
Since the dr was initialized with chrec_dont_know, no harm is done.

Anyway, since it is useless for your gather case, I'll just remove it, 
along with compute_self_dependence().

OK?

Thanks,
Razya



Re: [libitm, build] Support sun symbol versioning

2011-11-21 Thread Richard Henderson
On 11/21/2011 06:06 AM, Rainer Orth wrote:
> * libitm.so wasn't versioned even with gld, since libitm_la_LDFLAGS
>   wasn't passed when linking it.

foo_LDFLAGS is supposed to be one of those auto variables that gets used when 
linking foo.  I know that the library was successfully versioned when I put all 
that stuff in on the branch...  But, whatever, autotomfoolery is disgustingly 
fragile.

> * _ITM_getThreadnum is the only symbol in libitm.map that isn't present
>   in the library.  It's documented as missing and should perhaps be
>   removed from the map?

Probably.

>   libitm:
>   * acinclude.m4 (LIBITM_CHECK_LINKER_FEATURES): Handle gold.
>   (LIBITM_ENABLE_SYMVERS): Handle sun style.
>   * Makefile.am: Handle sun style versioning.
>   (libitm_la_LINK): Add $(libitm_la_LDFLAGS).
>   * configure: Regenerate.
>   * Makefile.in: Regenerate.
> 
>   contrib:
>   * make_sunver.pl: Convert '?' in glob patterns to '.'.

Ok.


r~


Re: [libitm, build] Support sun symbol versioning

2011-11-21 Thread Michael Matz
Hi,

On Mon, 21 Nov 2011, Richard Henderson wrote:

> On 11/21/2011 06:06 AM, Rainer Orth wrote:
> > * libitm.so wasn't versioned even with gld, since libitm_la_LDFLAGS
> >   wasn't passed when linking it.
> 
> foo_LDFLAGS is supposed to be one of those auto variables that gets used 
> when linking foo.

Only if you don't override foo_LINK at the same time, which ...

> I know that the library was successfully versioned when I put all that 
> stuff in on the branch...

... seems to be done after your tests to "Force link with C, not C++."
;-)


Ciao,
Michael.


Re: [libitm, build] Clear hardware capabilities on libitm.so with Sun ld

2011-11-21 Thread Richard Henderson
On 11/21/2011 05:53 AM, Rainer Orth wrote:
> The libitm execution tests are currently failing on Solaris 10 and up
> with Sun as/ld:
> 
> ld.so.1: cancel.exe: fatal: 
> /var/gcc/regression/trunk/11-gcc/build/i386-pc-solaris2.11/./libitm/.libs/libitm.so.0:
>  hardware capability (CA_SUNW_HW_1) unsupported: 0x2000  [ AVX ]
> FAIL: libitm.c/cancel.c execution test
> 
> This is the same issue solved by
> gcc/testsuite/gcc.target/i386/clearcap.map, and the following patch
> adresses it in the same way:
> 
> * Detect if the linker used supports -M .
> 
> * Use it when linking libitm.so.
> 
> Right now, it is only possible to clear the hardware capabilities
> completely, while the new v2 mapfile syntax supports selectively adding
> and removing capabilities.  It is only available in Solaris 11 and
> Solaris 10 Update 10, though, so I'm restricting us to the v1 syntax for
> now.

This is only ok if the compiler and library are build with default options.
If you use --with-arch=corei7-avx then we may well use AVX insns all through
the library, not just in the one interface that will only be used if the 
user of the library is using avx.

Can you auto-foo this based on CC+CFLAGS?  E.g.  compile-time tests for the
various __SSE__ / __AVX__ macros?


r~


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

2011-11-21 Thread Paolo Bonzini

On 11/21/2011 05:01 PM, Rainer Orth wrote:

As reported in the PR, powerpc-rtems bootstrap (and certainly several
other powerpc targets) is currently broken since rs6000/ibm-ldouble.c
appears twice in LIB2ADD, once from rs6000/t-ppccomm and
rs6000/t-ppccomm-ldbl, which confuses make.

It took me a while to understand how we got into that situation.  Here's
what I found: before the toplevel libgcc move started, we had both
gcc/config/rs6000/t-ppccomm and libgcc/config/rs6000/t-ppccomm.  The
second is a superset of the first, in that it contains LIB2ADD_ST +=
crtsavfpr.S crtresfpr.S and many other similar files.

The set of targets using the gcc and libgcc files differs:

gcc/config/rs6000/t-ppccomm libgcc/config/rs6000/t-ppccomm

  powerpc-*-freebsd*powerpc-*-freebsd*
  powerpc-*-eabispe*powerpc-*-eabispe*
  powerpc-*-eabisimaltivec*
  powerpc-*-eabisim*
  powerpc-*-elf*
  powerpc-*-eabialtivec*
  powerpc-xilinx-eabi*
  powerpc-*-eabi*   powerpc-*-eabi*
  powerpc-*-rtems*
  powerpc-*-linux*  powerpc-*-linux*
| powerpc64-*-linux*  | powerpc64-*-linux*
  powerpc-*-gnu-gnualtivec*
  powerpc-*-gnu*
  powerpc-wrs-vxworks
| powerpc-wrs-vxworksae
  powerpcle-*-elf*
  powerpcle-*-eabisim*
  powerpcle-*-eabi*

When I started the move, I introduced
libgcc/config/rs6000/t-ppccomm-ldbl since I couldn't simply use the
existing t-ppccomm file which is used on a far smaller set of targets.

To reach an end state matching what we had before the move, I propose to
instead create a separate t-savresfgpr (for {sav,res}{fpr,gpr,gprctr})
that only contains the additional files and add that to the targets that
had it before, and remove t-ppccomm-ldbl to avoid the duplication.

When checking this, I noticed that powerpc-vxworks had lost
rs6000/t-ppccomm, which the patch adds back.

I'd really appreciate if some affected targets could fully test the
patch.


Wrong patch attached.

Paolo



Re: [libitm, build] Clear hardware capabilities on libitm.so with Sun ld

2011-11-21 Thread Rainer Orth
Richard Henderson  writes:

> This is only ok if the compiler and library are build with default options.
> If you use --with-arch=corei7-avx then we may well use AVX insns all through
> the library, not just in the one interface that will only be used if the 
> user of the library is using avx.
>
> Can you auto-foo this based on CC+CFLAGS?  E.g.  compile-time tests for the
> various __SSE__ / __AVX__ macros?

Probably, but it occured to me that it might be easier to just apply the
mapfile to x86_avx.o unconditionally before linking libitm.la.

Rainer

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


Re: [PATCH, take 2] Fix PR tree-optimization/49960 ,Fix self data dependence

2011-11-21 Thread Jakub Jelinek
On Mon, Nov 21, 2011 at 06:56:55PM +0200, Razya Ladelsky wrote:
> I have some non-affine cases for which compute_affine_dependence is called 
> (as it is called for 
> ALL dependences from compte_all_depepndences()), and no harm is done.
> I looked a little bit closer into the code, and this is what happens for 
> non affine accesses:
> 
> initialize_data_dependence_relation() assigns 
> DDR_ARE_DEPENDENT (res) = chrec_dont_know for the dr.

It can be chrec_known too (that's actually the only interesting case for us
unless it is a read-read ddr), but you're right that likely
object_address_invariant_in_loop_p should be false.

> Then, compute_affine_depepndence()
> tests if (DDR_ARE_DEPENDENT (ddr) == NULL_TREE), and does nothing 
> otherwise.
> Since the dr was initialized with chrec_dont_know, no harm is done.
> 
> Anyway, since it is useless for your gather case, I'll just remove it, 
> along with compute_self_dependence().
> 
> OK?

Yes, patch preapproved.

Jakub


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

2011-11-21 Thread Rainer Orth
Paolo Bonzini  writes:

> Wrong patch attached.

Indeed ;-)

# HG changeset patch
# Parent e270cbe9e8641882fbcae2c23e927cdfd2be182f
Cleanup rs6000/t-ppccomm configurations (PR other/51022)

diff --git a/libgcc/config.host b/libgcc/config.host
--- a/libgcc/config.host
+++ b/libgcc/config.host
@@ -852,65 +852,65 @@ powerpc64-*-darwin*)
 	extra_parts="$extra_parts crt2.o"
 	;;
 powerpc-*-freebsd*)
-	tmake_file="${tmake_file} rs6000/t-ppccomm rs6000/t-crtstuff rs6000/t-freebsd t-softfp-sfdf t-softfp-excl t-softfp t-slibgcc-libgcc"
+	tmake_file="${tmake_file} rs6000/t-ppccomm rs6000/t-savresfgpr rs6000/t-crtstuff rs6000/t-freebsd t-softfp-sfdf t-softfp-excl t-softfp t-slibgcc-libgcc"
 	extra_parts="$extra_parts crtbeginT.o ecrti.o ecrtn.o ncrti.o ncrtn.o"
 	;;
 powerpc-*-netbsd*)
 	tmake_file="$tmake_file rs6000/t-netbsd rs6000/t-crtstuff"
 	;;
 powerpc-*-eabispe*)
-	tmake_file="${tmake_file} rs6000/t-ppccomm rs6000/t-crtstuff t-crtstuff-pic"
+	tmake_file="${tmake_file} rs6000/t-ppccomm rs6000/t-savresfgpr rs6000/t-crtstuff t-crtstuff-pic"
 	extra_parts="$extra_parts crtbegin.o crtend.o crtbeginS.o crtendS.o crtbeginT.o ecrti.o ecrtn.o ncrti.o ncrtn.o"
 	;;
 powerpc-*-eabisimaltivec*)
-	tmake_file="${tmake_file} rs6000/t-ppccomm rs6000/t-ppccomm-ldbl rs6000/t-crtstuff t-crtstuff-pic t-fdpbit"
+	tmake_file="${tmake_file} rs6000/t-ppccomm rs6000/t-crtstuff t-crtstuff-pic t-fdpbit"
 	extra_parts="$extra_parts crtbegin.o crtend.o crtbeginS.o crtendS.o crtbeginT.o ecrti.o ecrtn.o ncrti.o ncrtn.o"
 	;;
 powerpc-*-eabisim*)
-	tmake_file="${tmake_file} rs6000/t-ppccomm rs6000/t-ppccomm-ldbl rs6000/t-crtstuff t-crtstuff-pic t-fdpbit"
+	tmake_file="${tmake_file} rs6000/t-ppccomm rs6000/t-crtstuff t-crtstuff-pic t-fdpbit"
 	extra_parts="$extra_parts crtbegin.o crtend.o crtbeginS.o crtendS.o crtbeginT.o ecrti.o ecrtn.o ncrti.o ncrtn.o"
 	;;
 powerpc-*-elf*)
-	tmake_file="${tmake_file} rs6000/t-ppccomm rs6000/t-ppccomm-ldbl rs6000/t-crtstuff t-crtstuff-pic t-fdpbit"
+	tmake_file="${tmake_file} rs6000/t-ppccomm rs6000/t-crtstuff t-crtstuff-pic t-fdpbit"
 	extra_parts="$extra_parts crtbeginS.o crtendS.o crtbeginT.o ecrti.o ecrtn.o ncrti.o ncrtn.o"
 	;;
 powerpc-*-eabialtivec*)
-	tmake_file="${tmake_file} rs6000/t-ppccomm rs6000/t-ppccomm-ldbl rs6000/t-crtstuff t-crtstuff-pic t-fdpbit"
+	tmake_file="${tmake_file} rs6000/t-ppccomm rs6000/t-crtstuff t-crtstuff-pic t-fdpbit"
 	extra_parts="$extra_parts crtbegin.o crtend.o crtbeginS.o crtendS.o crtbeginT.o ecrti.o ecrtn.o ncrti.o ncrtn.o"
 	;;
 powerpc-xilinx-eabi*)
-	tmake_file="${tmake_file} rs6000/t-ppccomm rs6000/t-ppccomm-ldbl rs6000/t-crtstuff t-crtstuff-pic t-fdpbit"
+	tmake_file="${tmake_file} rs6000/t-ppccomm rs6000/t-crtstuff t-crtstuff-pic t-fdpbit"
 	extra_parts="$extra_parts crtbegin.o crtend.o crtbeginS.o crtendS.o crtbeginT.o ecrti.o ecrtn.o ncrti.o ncrtn.o"
 	;;
 powerpc-*-eabi*)
-	tmake_file="${tmake_file} rs6000/t-ppccomm rs6000/t-crtstuff t-crtstuff-pic t-fdpbit"
+	tmake_file="${tmake_file} rs6000/t-ppccomm rs6000/t-savresfgpr rs6000/t-crtstuff t-crtstuff-pic t-fdpbit"
 	extra_parts="$extra_parts crtbegin.o crtend.o crtbeginS.o crtendS.o crtbeginT.o ecrti.o ecrtn.o ncrti.o ncrtn.o"
 	;;
 powerpc-*-rtems*)
-	tmake_file="${tmake_file} rs6000/t-ppccomm rs6000/t-ppccomm-ldbl rs6000/t-crtstuff t-crtstuff-pic t-fdpbit"
+	tmake_file="${tmake_file} rs6000/t-ppccomm rs6000/t-crtstuff t-crtstuff-pic t-fdpbit"
 	extra_parts="$extra_parts crtbeginS.o crtendS.o crtbeginT.o ecrti.o ecrtn.o ncrti.o ncrtn.o"
 	;;
 powerpc-*-linux* | powerpc64-*-linux*)
-	tmake_file="${tmake_file} rs6000/t-ppccomm rs6000/t-crtstuff rs6000/t-linux t-softfp-sfdf t-softfp-excl t-dfprules rs6000/t-ppc64-fp t-softfp t-slibgcc-libgcc"
+	tmake_file="${tmake_file} rs6000/t-ppccomm rs6000/t-savresfgpr rs6000/t-crtstuff rs6000/t-linux t-softfp-sfdf t-softfp-excl t-dfprules rs6000/t-ppc64-fp t-softfp t-slibgcc-libgcc"
 	extra_parts="$extra_parts ecrti.o ecrtn.o ncrti.o ncrtn.o"
 	md_unwind_header=rs6000/linux-unwind.h
 	;;
 powerpc-wrs-vxworks|powerpc-wrs-vxworksae)
-	tmake_file="$tmake_file rs6000/t-ppccomm-ldbl t-fdpbit"
+	tmake_file="$tmake_file rs6000/t-ppccomm t-fdpbit"
 	;;
 powerpc-*-lynxos*)
 	tmake_file="$tmake_file rs6000/t-lynx t-fdpbit"
 	;;
 powerpcle-*-elf*)
-	tmake_file="${tmake_file} rs6000/t-ppccomm rs6000/t-ppccomm-ldbl rs6000/t-crtstuff t-crtstuff-pic t-fdpbit"
+	tmake_file="${tmake_file} rs6000/t-ppccomm rs6000/t-crtstuff t-crtstuff-pic t-fdpbit"
 	extra_parts="$extra_parts crtbeginS.o crtendS.o crtbeginT.o ecrti.o ecrtn.o ncrti.o ncrtn.o"
 	;;
 powerpcle-*-eabisim*)
-	tmake_file="${tmake_file} rs6000/t-ppccomm rs6000/t-ppccomm-ldbl rs6000/t-crtstuff t-crtstuff-pic t-fdpbit"
+	tmake_file="${tmake_file} rs6000/t-ppccomm rs6000/t-crtstuff t-crtstuff-pic t-fdpbit"
 	extra_parts="$extra_parts crtbegin.o crtend.o crtbeginS.o crtendS.o crtbeginT.o ecrti.o ecrtn.o ncrti.o ncrtn.o"
 	;;
 powerpcle-*-eabi*)
-	tmake_file="${tmake_file} rs6000/t-ppccomm rs6000/t-ppccomm-ldbl rs6000/t-crtstuff t-cr

Re: [Patch,AVR]: Fix cc0 and loading const_int/const_double

2011-11-21 Thread Denis Chertykov
2011/11/21 Georg-Johann Lay :
> After updating my local copy I get new runtime FAILs in the test suite because
> of the following sequence, e.g. from gcc.c-torture/execute/990527-1.c:
>
>        sbiw r28,1       ;  12  addhi3_clobber/1        [length = 1]
>        ldi r24,lo8(9)   ;  24  *movhi/5        [length = 2]
>        clr r25
>        brne .L3         ;  16  branch  [length = 1]
>
> The trouble is that *movhi promises that it does not change cc0. Thus, the
> correct code is:
>
>        sbiw r28,1       ;  12  addhi3_clobber/1        [length = 1]
>        ldi r24,lo8(9)   ;  24  *movhi/5        [length = 2]
>        ldi r25,0
>        brne .L3         ;  16  branch  [length = 1]
>
> The patch fixes this and adjusts cc attribute of involved insns.
>
> When loading 0, cc=none is more useful than cc=set_zn because the compiler
> knows what it loads, and cc=none preserves cc0 from preceding code.
>
> Tests pass fine again.
>
> Ok to apply?
>
> Johann
>
>        * config/avr/avr.c (output_reload_in_const): Loading a byte with 0
>        must not affect cc0.
>        * config/avr/avr.md (*movhi, *movpsi, *movsi, *movsf): Zero to any
>        register does not change cc0. Same for any constant to ld-register.
>
>

Approved.

Denis.


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

2011-11-21 Thread Joel Sherrill

On 11/21/2011 11:25 AM, Rainer Orth wrote:

Paolo Bonzini  writes:


Wrong patch attached.

Indeed ;-)


Does this patch apply OK for others?

Ranier.. you can just send me the impacted files if you like.  I have
no local changes to libgcc.

$ cat /tmp/libgcc-t-savresfgpr.patch | patch -p1
patching file libgcc/config.host
Hunk #1 succeeded at 843 (offset -9 lines).
patching file libgcc/config/rs6000/t-ppccomm
patching file libgcc/config/rs6000/t-ppccomm-ldbl
patching file libgcc/config/rs6000/t-ppccomm
Hunk #1 FAILED at 1.
Hunk #2 FAILED at 21.
2 out of 2 hunks FAILED -- saving rejects to file 
libgcc/config/rs6000/t-ppccomm.rej



--
Joel Sherrill, Ph.D. Director of Research&  Development
joel.sherr...@oarcorp.comOn-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
   Support Available (256) 722-9985




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

2011-11-21 Thread Rainer Orth
Joel Sherrill  writes:

> Does this patch apply OK for others?
>
> Ranier.. you can just send me the impacted files if you like.  I have
> no local changes to libgcc.
>
> $ cat /tmp/libgcc-t-savresfgpr.patch | patch -p1
> patching file libgcc/config.host
> Hunk #1 succeeded at 843 (offset -9 lines).
> patching file libgcc/config/rs6000/t-ppccomm
> patching file libgcc/config/rs6000/t-ppccomm-ldbl
> patching file libgcc/config/rs6000/t-ppccomm
> Hunk #1 FAILED at 1.
> Hunk #2 FAILED at 21.
> 2 out of 2 hunks FAILED -- saving rejects to file
> libgcc/config/rs6000/t-ppccomm.rej

Released versions of patch cannot deal with git-style patches (a copy in
this case), it seems.  git patch (or a snapshot from alpha.gnu.org)
should be ok.

I'm including libgcc/config/rs6000/t-savresfgpr for your convenience.

Rainer


# These can't end up in shared libgcc
LIB2ADD_ST += \
   $(srcdir)/config/rs6000/crtsavfpr.S \
   $(srcdir)/config/rs6000/crtresfpr.S \
   $(srcdir)/config/rs6000/crtsavgpr.S \
   $(srcdir)/config/rs6000/crtresgpr.S \
   $(srcdir)/config/rs6000/crtresxfpr.S \
   $(srcdir)/config/rs6000/crtresxgpr.S \
   $(srcdir)/config/rs6000/e500crtres32gpr.S \
   $(srcdir)/config/rs6000/e500crtres64gpr.S \
   $(srcdir)/config/rs6000/e500crtres64gprctr.S \
   $(srcdir)/config/rs6000/e500crtrest32gpr.S \
   $(srcdir)/config/rs6000/e500crtrest64gpr.S \
   $(srcdir)/config/rs6000/e500crtresx32gpr.S \
   $(srcdir)/config/rs6000/e500crtresx64gpr.S \
   $(srcdir)/config/rs6000/e500crtsav32gpr.S \
   $(srcdir)/config/rs6000/e500crtsav64gpr.S \
   $(srcdir)/config/rs6000/e500crtsav64gprctr.S \
   $(srcdir)/config/rs6000/e500crtsavg32gpr.S \
   $(srcdir)/config/rs6000/e500crtsavg64gpr.S \
   $(srcdir)/config/rs6000/e500crtsavg64gprctr.S


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


[PATCH, i386]: Move unspec/unspecv constants around

2011-11-21 Thread Uros Bizjak
Hello!

This patch moves unspec/unspecv constants to their new homes. The
patch also moves a couple of fence patterns from sse.md to sync.md.

No functional changes.

2011-11-21  Uros Bizjak  

* config/i386/mmx.md (unspec) :
Move from config/i386/i386.md
(unspecv) : Ditto.
* config/i386/sse.md (unspec) : Ditto.
(unspecv) :
Ditto.
* config/i386/sync.md (unspec) : Ditto.
(unspecv) : Ditto.
(sse2_lfence): Move from config/i386/sse.md.
(*sse2_lfence): Ditto.
(sse_sfence): Ditto.
(*sse_sfence): Ditto.
(sse2_mfence): Ditto.
(mfence_sse2): Ditto.  Rename from *sse2_mfence.  Enable also for 
TARGET_64BIT.
(mem_thread_fence): Use mfence_sse2.

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

Uros.
Index: i386.md
===
--- i386.md (revision 181585)
+++ i386.md (working copy)
@@ -62,8 +62,6 @@
 ;; ; -- print a semicolon (after prefixes due to bug in older gas).
 ;; @ -- print a segment register of thread base pointer load
 
-;; UNSPEC usage:
-
 (define_c_enum "unspec" [
   ;; Relocation specifiers
   UNSPEC_GOT
@@ -108,6 +106,7 @@
   UNSPEC_LD_MPIC   ; load_macho_picbase
   UNSPEC_TRUNC_NOOP
   UNSPEC_DIV_ALREADY_SPLIT
+  UNSPEC_MS_TO_SYSV_CALL
   UNSPEC_CALL_NEEDS_VZEROUPPER
   UNSPEC_PAUSE
 
@@ -115,22 +114,9 @@
   UNSPEC_FIX_NOTRUNC
   UNSPEC_MASKMOV
   UNSPEC_MOVMSK
-  UNSPEC_MOVNTQ
-  UNSPEC_MOVNT
-  UNSPEC_MOVU
   UNSPEC_RCP
   UNSPEC_RSQRT
-  UNSPEC_SFENCE
-  UNSPEC_PFRCP
-  UNSPEC_PFRCPIT1
-  UNSPEC_PFRCPIT2
-  UNSPEC_PFRSQRT
-  UNSPEC_PFRSQIT1
-  UNSPEC_MFENCE
-  UNSPEC_LFENCE
   UNSPEC_PSADBW
-  UNSPEC_LDDQU
-  UNSPEC_MS_TO_SYSV_CALL
 
   ;; Generic math support
   UNSPEC_COPYSIGN
@@ -178,105 +164,32 @@
   UNSPEC_SP_TLS_SET
   UNSPEC_SP_TLS_TEST
 
-  ;; SSSE3
-  UNSPEC_PSHUFB
-  UNSPEC_PSIGN
-  UNSPEC_PALIGNR
-
-  ;; For SSE4A support
-  UNSPEC_EXTRQI
-  UNSPEC_EXTRQ
-  UNSPEC_INSERTQI
-  UNSPEC_INSERTQ
-
-  ;; For SSE4.1 support
-  UNSPEC_BLENDV
-  UNSPEC_INSERTPS
-  UNSPEC_DP
-  UNSPEC_MOVNTDQA
-  UNSPEC_MPSADBW
-  UNSPEC_PHMINPOSUW
-  UNSPEC_PTEST
+  ;; For ROUND support
   UNSPEC_ROUND
 
-  ;; For SSE4.2 support
+  ;; For CRC32 support
   UNSPEC_CRC32
-  UNSPEC_PCMPESTR
-  UNSPEC_PCMPISTR
 
-  ;; For FMA4 support
-  UNSPEC_FMADDSUB
-  UNSPEC_XOP_UNSIGNED_CMP
-  UNSPEC_XOP_TRUEFALSE
-  UNSPEC_XOP_PERMUTE
-  UNSPEC_FRCZ
+  ;; For RDRAND support
+  UNSPEC_RDRAND
 
-  ;; For AES support
-  UNSPEC_AESENC
-  UNSPEC_AESENCLAST
-  UNSPEC_AESDEC
-  UNSPEC_AESDECLAST
-  UNSPEC_AESIMC
-  UNSPEC_AESKEYGENASSIST
-
-  ;; For PCLMUL support
-  UNSPEC_PCLMUL
-
-  ;; For AVX support
-  UNSPEC_PCMP
-  UNSPEC_VPERMIL
-  UNSPEC_VPERMIL2
-  UNSPEC_VPERMIL2F128
-  UNSPEC_CAST
-  UNSPEC_VTESTP
-  UNSPEC_VCVTPH2PS
-  UNSPEC_VCVTPS2PH
-
-  ;; For AVX2 support
-  UNSPEC_VPERMSI
-  UNSPEC_VPERMDF
-  UNSPEC_VPERMSF
-  UNSPEC_VPERMTI
-  UNSPEC_GATHER
-  UNSPEC_VSIBADDR
-
   ;; For BMI support
   UNSPEC_BEXTR
 
-  ;; For RDRAND support
-  UNSPEC_RDRAND
-
   ;; For BMI2 support
   UNSPEC_PDEP
   UNSPEC_PEXT
-
-  ;; For __atomic support
-  UNSPEC_MOVA
 ])
 
 (define_c_enum "unspecv" [
   UNSPECV_BLOCKAGE
   UNSPECV_STACK_PROBE
   UNSPECV_PROBE_STACK_RANGE
-  UNSPECV_EMMS
-  UNSPECV_LDMXCSR
-  UNSPECV_STMXCSR
-  UNSPECV_FEMMS
-  UNSPECV_CLFLUSH
   UNSPECV_ALIGN
-  UNSPECV_MONITOR
-  UNSPECV_MWAIT
-  UNSPECV_CMPXCHG_1
-  UNSPECV_CMPXCHG_2
-  UNSPECV_CMPXCHG_3
-  UNSPECV_CMPXCHG_4
-  UNSPECV_XCHG
-  UNSPECV_LOCK
   UNSPECV_PROLOGUE_USE
+  UNSPECV_SPLIT_STACK_RETURN
   UNSPECV_CLD
   UNSPECV_NOPS
-  UNSPECV_VZEROALL
-  UNSPECV_VZEROUPPER
   UNSPECV_RDTSC
   UNSPECV_RDTSCP
   UNSPECV_RDPMC
@@ -288,7 +201,6 @@
   UNSPECV_RDGSBASE
   UNSPECV_WRFSBASE
   UNSPECV_WRGSBASE
-  UNSPECV_SPLIT_STACK_RETURN
 ])
 
 ;; Constants to represent rounding modes in the ROUND instruction
Index: mmx.md
===
--- mmx.md  (revision 181585)
+++ mmx.md  (working copy)
@@ -30,6 +30,20 @@
 ;; means that we should never use any of these patterns except at the
 ;; direction of the user via a builtin.
 
+(define_c_enum "unspec" [
+  UNSPEC_MOVNTQ
+  UNSPEC_PFRCP
+  UNSPEC_PFRCPIT1
+  UNSPEC_PFRCPIT2
+  UNSPEC_PFRSQRT
+  UNSPEC_PFRSQIT1
+])
+
+(define_c_enum "unspecv" [
+  UNSPECV_EMMS
+  UNSPECV_FEMMS
+])
+
 ;; 8 byte integral modes handled by MMX (and by extension, SSE)
 (define_mode_iterator MMXMODEI [V8QI V4HI V2SI])
 (define_mode_iterator MMXMODEI8 [V8QI V4HI V2SI V1DI])
Index: sse.md
===
--- sse.md  (revision 181585)
+++ sse.md  (working copy)
@@ -18,6 +18,85 @@
 ;; along with GCC; see the file COPYING3.  If not see
 ;; .
 
+(define_c_enum "unspec" [
+  ;; SSE
+  UNSPEC_MOVNT
+  UNSPEC_MOVU
+
+  ;; SSE3
+  UNSPEC_LDDQU
+
+  ;; SSSE3
+  UNSPEC_PSHUFB
+  UNSPEC_PSIGN
+  UNSPEC_PALIGNR

Re: [libitm, build] Clear hardware capabilities on libitm.so with Sun ld

2011-11-21 Thread David Miller
From: Rainer Orth 
Date: Mon, 21 Nov 2011 14:53:33 +0100

> Right now, it is only possible to clear the hardware capabilities
> completely, while the new v2 mapfile syntax supports selectively adding
> and removing capabilities.  It is only available in Solaris 11 and
> Solaris 10 Update 10, though, so I'm restricting us to the v1 syntax for
> now.

I really wish Sun had never added this hwcap checking, 99 times out of
100 it's a nuisance rather than a help in any way.


Re: [testsuite] Fix ultrasparc_vis[23]_hw tests

2011-11-21 Thread David Miller
From: Rainer Orth 
Date: Mon, 21 Nov 2011 16:07:04 +0100

> The new gcc.target/sparc/vec-init-[1-3]-vis3.c tests might fail on
> Solaris 10 and 11 with Sun as on non-VIS3 capable hardware
> (e.g. UltraSPARC T2 or UltraSPARC IV) like this:
> 
> ld.so.1: vec-init-1-vis3.exe: fatal: vec-init-1-vis3.exe: hardware capability 
> (C
> A_SUNW_HW_1) unsupported: 0x400  [ VIS3 ]
> FAIL: gcc.target/sparc/vec-init-1-vis3.c execution test
> 
> This shouldn't happen, the tests should appear as UNSUPPORTED instead.  I
> could trace this to the ultrasparc*_hw effective-target tests, which all
> use the ultrasparc_hw keyword, so checking the wrong test.  By fixing
> this, the test correctly appear as UNSUPPORTED in an
> sparc-sun-solaris2.11 bootstrap.
> 
> Installed on mainline.

Thanks for fixing this.


Re: [PATCH] PR c++/51145 - Alias template in elaborated-type-specifier

2011-11-21 Thread Dodji Seketeli
Jason Merrill  writes:

> See my comment in the PR.

Yes, sorry I have missed it.

Here is an updated patch hopefully addressing that comment.  I have also
updated a bunch of tests as a result of the change from error to note.

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

From: Dodji Seketeli 
Date: Fri, 18 Nov 2011 00:50:21 +0100
Subject: [PATCH] PR c++/51145 - Alias template in elaborated-type-specifier
 accepted

gcc/cp/

PR c++/51145
* decl.c (check_elaborated_type_specifier): Gracefully handle
error_mark_node.  Accept bound template template parameters.
Update diagnostics for alias template specializations.  Update
comment.
* parser.c (cp_parser_elaborated_type_specifier): Use
check_elaborated_type_specifier for simple-template-ids as well.

gcc/testsuite/

PR c++/51145
* g++.dg/cpp0x/alias-decl-14.C: New test.
* g++.dg/cpp0x/alias-decl-2.C: Adjust for tests that were wrongly
passing before.
* g++.dg/cpp0x/alias-decl-10.C: Likewise and adjust for diagnostic
change.
* g++.dg/ext/attrib27.C: Adjust for diagnostic change.
* g++.dg/lookup/struct1.C: Likewise.
* g++.dg/parse/elab1.C: Likewise.
* g++.dg/parse/elab2.C: Likewise.
* g++.dg/parse/int-as-enum1.C: Likewise.
* g++.dg/parse/typedef1.C: Likewise.
* g++.dg/parse/typedef3.C: Likewise.
* g++.dg/parse/typedef4.C: Likewise.
* g++.dg/parse/typedef5.C: Likewise.
* g++.dg/template/crash26.C: Likewise.
* g++.dg/template/nontype4.C: Likewise.
* g++.old-deja/g++.benjamin/typedef01.C: Likewise.
* g++.old-deja/g++.brendan/line1.C: Likewise.
* g++.old-deja/g++.other/elab1.C: Likewise.
* g++.old-deja/g++.other/syntax4.C: Likewise.
---
 gcc/cp/decl.c  |   21 ---
 gcc/cp/parser.c|3 +-
 gcc/testsuite/g++.dg/cpp0x/alias-decl-10.C |   16 +++---
 gcc/testsuite/g++.dg/cpp0x/alias-decl-14.C |   14 +
 gcc/testsuite/g++.dg/cpp0x/alias-decl-2.C  |2 +-
 gcc/testsuite/g++.dg/ext/attrib27.C|2 +-
 gcc/testsuite/g++.dg/lookup/struct1.C  |4 +-
 gcc/testsuite/g++.dg/parse/elab1.C |2 +-
 gcc/testsuite/g++.dg/parse/elab2.C |2 +-
 gcc/testsuite/g++.dg/parse/int-as-enum1.C  |2 +-
 gcc/testsuite/g++.dg/parse/typedef1.C  |2 +-
 gcc/testsuite/g++.dg/parse/typedef3.C  |2 +-
 gcc/testsuite/g++.dg/parse/typedef4.C  |2 +-
 gcc/testsuite/g++.dg/parse/typedef5.C  |2 +-
 gcc/testsuite/g++.dg/template/crash26.C|2 +-
 gcc/testsuite/g++.dg/template/nontype4.C   |2 +-
 .../g++.old-deja/g++.benjamin/typedef01.C  |4 +-
 gcc/testsuite/g++.old-deja/g++.brendan/line1.C |2 +-
 gcc/testsuite/g++.old-deja/g++.other/elab1.C   |2 +-
 gcc/testsuite/g++.old-deja/g++.other/syntax4.C |2 +-
 20 files changed, 63 insertions(+), 27 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/cpp0x/alias-decl-14.C

diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index b77963b..8406432 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -11342,6 +11342,9 @@ check_elaborated_type_specifier (enum tag_types 
tag_code,
 {
   tree type;
 
+  if (decl == error_mark_node)
+return error_mark_node;
+
   /* In the case of:
 
struct S { struct S *p; };
@@ -11361,10 +11364,15 @@ check_elaborated_type_specifier (enum tag_types 
tag_code,
 type, tag_name (tag_code));
   return error_mark_node;
 }
+  /* Accept bound template template parameters.  */
+  else if (allow_template_p
+  && TREE_CODE (type) == BOUND_TEMPLATE_TEMPLATE_PARM)
+;
   /*   [dcl.type.elab]
 
-   If the identifier resolves to a typedef-name or a template
-   type-parameter, the elaborated-type-specifier is ill-formed.
+   If the identifier resolves to a typedef-name or the
+   simple-template-id resolves to an alias template
+   specialization, the elaborated-type-specifier is ill-formed.
 
  In other words, the only legitimate declaration to use in the
  elaborated type specifier is the implicit typedef created when
@@ -11373,8 +11381,13 @@ check_elaborated_type_specifier (enum tag_types 
tag_code,
   && !DECL_SELF_REFERENCE_P (decl)
   && tag_code != typename_type)
 {
-  error ("using typedef-name %qD after %qs", decl, tag_name (tag_code));
-  error ("%q+D has a previous declaration here", decl);
+  if (alias_template_specialization_p (type))
+   error ("using alias template specialization %qT after %qs",
+  type, tag_name (tag_code));
+  else
+   error ("using typedef-name %qD after %qs", decl, tag_name (tag_code));
+  inform (DECL_SOURCE_LOCATION (decl)

Re: [Patch RFC Darwin] provide the crt stuff for tm.

2011-11-21 Thread Richard Henderson
On 11/21/2011 01:17 AM, Iain Sandoe wrote:
> 1. should I be applying this constructor/destructor pair to shared libraries 
> as well?
>  (the specs need minor amendment)

Yes.


r~


Re: [libitm, build] Clear hardware capabilities on libitm.so with Sun ld

2011-11-21 Thread Richard Henderson
On 11/21/2011 09:23 AM, Rainer Orth wrote:
> Richard Henderson  writes:
> 
>> This is only ok if the compiler and library are build with default options.
>> If you use --with-arch=corei7-avx then we may well use AVX insns all through
>> the library, not just in the one interface that will only be used if the 
>> user of the library is using avx.
>>
>> Can you auto-foo this based on CC+CFLAGS?  E.g.  compile-time tests for the
>> various __SSE__ / __AVX__ macros?
> 
> Probably, but it occured to me that it might be easier to just apply the
> mapfile to x86_avx.o unconditionally before linking libitm.la.

Possibly.  Though you'd want to do the same thing for x86_sse.o too.
Again, that file is only used if the main program uses SSE.


r~


Re: Support enforcing use of libgcc_s even with LINK_EH_SPEC

2011-11-21 Thread Jakub Jelinek
On Mon, Nov 21, 2011 at 05:40:26PM +0100, Rainer Orth wrote:
> 2011-11-20  Rainer Orth  
> 
>   * gcc.c (init_gcc_specs) [USE_SHARED_LIBGCC_FOR_EH]: Always use
>   libgcc_s.
>   * config/sol2.h [USE_GLD] (USE_SHARED_LIBGCC_FOR_EH): Define.

That's an ugly hack.  IMHO we just want to do what has been discussed
earlier, ensure that generated EH info and code generation isn't actually
pessimized because of the clobbers, at least not in the common cases.

Jakub


[patch, committed] update configury for FreeBSD 10 on trunk

2011-11-21 Thread Andreas Tobler

Here the pointer to the patch I just committed.

Test results:

http://gcc.gnu.org/ml/gcc-testresults/2011-11/msg02168.html

Commit:

http://gcc.gnu.org/ml/gcc-cvs/2011-11/msg00886.html


And sorry for the inconsistency.

Thanks,
Andreas


Re: CFT: Re: libgcc: why emutls.c in LIB2ADDEH instead of LIB2ADD?

2011-11-21 Thread Richard Henderson
On 11/21/2011 02:04 AM, Iain Sandoe wrote:
> The reason it was in libgcc_eh (AFAIK, the original implementation
> pre-dates my GCC days) - is because there can only be one copy of the
> static emutls locking entities in a given exe.   I guess it was felt
> analogous to the "only one unwinder" rule.

Yes, that was it.  That puts the stuff in libgcc_s.so, but not libgcc.a.


r~


[patch] support LTO of transactional memory

2011-11-21 Thread Aldy Hernandez

No sense not supporting LTO in the first TM release, if we can avoid it.

OK for trunk, or should I queue for 4.8?  This only affects the TM code 
path.


Tested on x86-64 Linux.  The testcase only tests for assembly, since I 
see no way of testing linkage and depending on libitm as well.  Plus, we 
only support a handful of targets anyhow.  I also tested by setting 
"dg-lto-do link" and checking that the only error was a link error 
against the relevant _ITM_* symbols (no additional LTO related  errors).


p.s. See, Andrew?  I didn't forget :).

* opts.c (finish_options): Do not fail for -fgnu-tm.
* gimple-streamer-out.c (output_gimple_stmt): Handle GIMPLE_TRANSACTION.
* gimple-streamer-in.c (input_gimple_stmt): Same.
(ipa_tm_create_version): Same.
lto/
* lto-lang.c (lto_attribute_table): Handle transaction_pure.
(handle_transaction_pure_attribute): New.

Index: gimple-streamer-out.c
===
--- gimple-streamer-out.c   (revision 181588)
+++ gimple-streamer-out.c   (working copy)
@@ -111,6 +111,7 @@ output_gimple_stmt (struct output_block
 case GIMPLE_COND:
 case GIMPLE_GOTO:
 case GIMPLE_DEBUG:
+case GIMPLE_TRANSACTION:
   for (i = 0; i < gimple_num_ops (stmt); i++)
{
  tree op = gimple_op (stmt, i);
@@ -145,6 +146,8 @@ output_gimple_stmt (struct output_block
  else
stream_write_tree (ob, gimple_call_fntype (stmt), true);
}
+  if (gimple_code (stmt) == GIMPLE_TRANSACTION)
+   stream_write_tree (ob, gimple_transaction_label (stmt), true);
   break;

 case GIMPLE_NOP:
Index: testsuite/gcc.dg/lto/trans-mem-1_0.c
===
--- testsuite/gcc.dg/lto/trans-mem-1_0.c(revision 0)
+++ testsuite/gcc.dg/lto/trans-mem-1_0.c(revision 0)
@@ -0,0 +1,12 @@
+/* { dg-lto-do assemble } */
+/* { dg-lto-options {{-flto -fgnu-tm}} } */
+
+int i;
+
+main()
+{
+  __transaction_atomic
+{
+  i = 0;
+}
+}
Index: opts.c
===
--- opts.c  (revision 181588)
+++ opts.c  (working copy)
@@ -784,8 +784,6 @@ finish_options (struct gcc_options *opts
 #endif
   if (!opts->x_flag_fat_lto_objects && !HAVE_LTO_PLUGIN)
 error_at (loc, "-fno-fat-lto-objects are supported only with 
linker plugin.");

-  if (opts->x_flag_tm)
-	error_at (loc, "LTO is currently not supported with transactional 
memory");

 }
   if ((opts->x_flag_lto_partition_balanced != 0) + 
(opts->x_flag_lto_partition_1to1 != 0)

+ (opts->x_flag_lto_partition_none != 0) >= 1)
Index: lto/lto-lang.c
===
--- lto/lto-lang.c  (revision 181588)
+++ lto/lto-lang.c  (working copy)
@@ -46,6 +46,7 @@ static tree handle_nonnull_attribute (tr
 static tree handle_nothrow_attribute (tree *, tree, tree, int, bool *);
 static tree handle_sentinel_attribute (tree *, tree, tree, int, bool *);
 static tree handle_type_generic_attribute (tree *, tree, tree, int, 
bool *);
+static tree handle_transaction_pure_attribute (tree *, tree, tree, int, 
bool *);

 static tree handle_format_attribute (tree *, tree, tree, int, bool *);
 static tree handle_format_arg_attribute (tree *, tree, tree, int, bool *);

@@ -75,6 +76,8 @@ const struct attribute_spec lto_attribut
  handle_sentinel_attribute, false },
   { "type generic",   0, 0, false, true, true,
  handle_type_generic_attribute, false },
+  { "transaction_pure",0, 0, false, true, true,
+ handle_transaction_pure_attribute, false },
   { NULL, 0, 0, false, false, false, NULL, false }
 };

@@ -401,6 +404,20 @@ handle_type_generic_attribute (tree *nod

   return NULL_TREE;
 }
+
+/* Handle a "transaction_pure" attribute.  */
+
+static tree
+handle_transaction_pure_attribute (tree *node, tree ARG_UNUSED (name),
+  tree ARG_UNUSED (args),
+  int ARG_UNUSED (flags),
+  bool * ARG_UNUSED (no_add_attrs))
+{
+  /* Ensure we have a function type.  */
+  gcc_assert (TREE_CODE (*node) == FUNCTION_TYPE);
+
+  return NULL_TREE;
+}

 /* Handle a "format" attribute; arguments as in
struct attribute_spec.handler.  */
Index: gimple-streamer-in.c
===
--- gimple-streamer-in.c(revision 181588)
+++ gimple-streamer-in.c(working copy)
@@ -141,6 +141,7 @@ input_gimple_stmt (struct lto_input_bloc
 case GIMPLE_COND:
 case GIMPLE_GOTO:
 case GIMPLE_DEBUG:
+case GIMPLE_TRANSACTION:
   for (i = 0; i < num_ops; i++)
{
  tree op = stream_read_tree (ib, data_in);
@@ -232,6 +233,8 @@ input_gimple_stmt (struct lto_in

[Patch,AVR] Light-weight DImode implementation.

2011-11-21 Thread Georg-Johann Lay
This adds support for DImode insns that don't operate byte-wise like NEG,
COMPARE, PLUS, MINUS, ASHIFT, LSHIFTRT, ASHIFTRT, ROTATE.

The crucial point is that there is no movdi, with the following reasoning as
cited from new avr-dimode.md:

;; The purpose of this file is to provide a light-weight DImode
;; implementation for AVR.  The trouble with DImode is that tree -> RTL
;; lowering leads to really unpleasant code for operations that don't
;; work byte-wise like NEG, PLUS, MINUS, etc.  Defining optabs entries for
;; them won't help because the optab machinery assumes these operations
;; are cheap and does not check if a libgcc implementation is available.
;;
;; The DImode insns are all straight forward -- except movdi.  The approach
;; of this implementation is to provide DImode insns without the burden of
;; introducing movdi.
;;
;; The caveat is that if there are insns for some mode, there must also be a
;; respective move insn that describes reloads.  Therefore, this
;; implementation uses an accumulator-based model with two hard-coded,
;; accumulator-like registers
;;
;;A[] = reg:DI 18
;;B[] = reg:DI 10
;;
;; so that no DImode insn contains pseudos or needs reloading.

Comments are welcome whether this is reasonable or bullshit ;-)

The implementation is just some 300 lines and works smooth with the test suite
and libgcc and avr-libc generated with -m64, of course.

All insns/expanders in the new avr-dimode.md are triggered by -m64 which is off
per default.

The new option is because I excepted problems with the patch, but it runs
smooth since the first line so that the option can be dropped if the
explanation above holds.

The changes to the rest of the backend are just hand-full of lines :-)

As said above, test suite passes fine both woth -m64 off and with -m64 turn on
and with libgcc/libc built with that switch.

Ok?

Johann

gcc/
* config/avr/avr.opt (-m64): New option.
* config/avr/avr-dimode.md: New file.
* config/avr/avr.md: Include it.
(adjust_len): Add plus64, compare64.
(HIDI): Remove code iterator.
(code_stdname): New code attribute.
(rotx, rotsmode): Remove DI.
(rotl3, *rotw, *rotb): Use HISI instead of HIDI
as code iterator.
* config/avr/avr-protos.h (avr_out_plus64, avr_out_compare64): New.
* config/avr/avr.c (avr_out_compare): Handle DImode.
(avr_out_compare64, avr_out_plus64): New functions.
(avr_out_plus_1): Use simplify_unary_operation to negate xval.
(adjust_insn_length): Handle ADJUST_LEN_COMPARE64, ADJUST_LEN_PLUS64.
(avr_compare_pattern): Skip DImode comparisons.

libgcc/
* config/avr/t-avr (LIB1ASMFUNCS): Add _adddi3, _adddi3_s8,
_subdi3, _cmpdi2, _cmpdi2_s8, _rotldi3.
* config/avr/lib1funcs.S (__adddi3, __adddi3_s8, __subdi3,
__cmpdi2, __cmpdi2_s8, __rotldi3): New functions.

Index: gcc/config/avr/avr-dimode.md
===
--- gcc/config/avr/avr-dimode.md	(revision 0)
+++ gcc/config/avr/avr-dimode.md	(revision 0)
@@ -0,0 +1,283 @@
+;;   Machine description for GNU compiler,
+;;   for Atmel AVR micro controllers.
+;;   Copyright (C) 1998 - 2011
+;;   Free Software Foundation, Inc.
+;;   Contributed by Georg Lay (a...@gjlay.de)
+;;
+;; This file is part of GCC.
+;;
+;; GCC is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3, or (at your option)
+;; any later version.
+;;
+;; GCC is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with GCC; see the file COPYING3.  If not see
+;; .
+
+;;
+
+;; The purpose of this file is to provide a light-weight DImode
+;; implementation for AVR.  The trouble with DImode is that tree -> RTL
+;; lowering leads to really unpleasant code for operations that don't
+;; work byte-wise like NEG, PLUS, MINUS, etc.  Defining optabs entries for
+;; them won't help because the optab machinery assumes these operations
+;; are cheap and does not check if a libgcc implementation is available.
+;;
+;; The DImode insns are all straight forward -- except movdi.  The approach
+;; of this implementation is to provide DImode insns without the burden of
+;; introducing movdi.
+;; 
+;; The caveat is that if there are insns for some mode, there must also be a
+;; respective move insn that describes reloads.  Therefore, this
+;; implementation uses an accumulator-based model with two hard-coded,
+;; accumulator-like registers
+;;
+;;A[] = reg:DI 18
+;;B[] = r

Re: [libitm, build] Support sun symbol versioning

2011-11-21 Thread Torvald Riegel
On Mon, 2011-11-21 at 15:06 +0100, Rainer Orth wrote:
> * _ITM_getThreadnum is the only symbol in libitm.map that isn't present
>   in the library.  It's documented as missing and should perhaps be
>   removed from the map?

Yes, this is not supported anymore.

Thanks,
Torvald



Re: [C++11] Ping on PR50958

2011-11-21 Thread Jason Merrill

On 11/20/2011 05:24 PM, Ed Smith-Rowland wrote:

Ping.

There's a patch that should do the literal operator resolution correctly
and resolve PR50958:

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


Ah, I didn't realize you had attached a patch there.  Next time please 
also send patches to gcc-patches.


Applied with minor tweaks.

Thanks,
Jason


Re: [patch] support LTO of transactional memory

2011-11-21 Thread Richard Henderson
On 11/21/2011 11:31 AM, Aldy Hernandez wrote:
> Tested on x86-64 Linux.  The testcase only tests for assembly, since I see no 
> way of testing linkage and depending on libitm as well.

All these tests support multi-file linkage (otherwise LTO is moot).
You could supply dummy implementations of the libitm functions,
with __attribute__((noinline,noclone)) and with a body containing
at least asm("").


r~


Re: [patch] support LTO of transactional memory

2011-11-21 Thread Richard Henderson
On 11/21/2011 11:31 AM, Aldy Hernandez wrote:
>  case GIMPLE_DEBUG:
> +case GIMPLE_TRANSACTION:
>for (i = 0; i < gimple_num_ops (stmt); i++)
>  {
>tree op = gimple_op (stmt, i);
> @@ -145,6 +146,8 @@ output_gimple_stmt (struct output_block
>else
>  stream_write_tree (ob, gimple_call_fntype (stmt), true);
>  }
> +  if (gimple_code (stmt) == GIMPLE_TRANSACTION)
> +stream_write_tree (ob, gimple_transaction_label (stmt), true); 


No point merging GIMPLE_TRANSACTION with those cases.  There are only two 
operands, BODY and LABEL, and BODY should have been lowered already.  Make this 
a separate case with an assert BODY == NULL, and writing the label.

> +  if (gimple_code (stmt) == GIMPLE_TRANSACTION)
> +gimple_transaction_set_label (stmt, stream_read_tree (ib, data_in)); 

Similarly separate, although obviously no assert for BODY here.

Otherwise ok.


r~


Re: [libitm, build] Support sun symbol versioning

2011-11-21 Thread Jack Howarth
On Mon, Nov 21, 2011 at 08:35:39PM +0100, Torvald Riegel wrote:
> On Mon, 2011-11-21 at 15:06 +0100, Rainer Orth wrote:
> > * _ITM_getThreadnum is the only symbol in libitm.map that isn't present
> >   in the library.  It's documented as missing and should perhaps be
> >   removed from the map?
> 
> Yes, this is not supported anymore.
> 
> Thanks,
> Torvald

  I'm not sure if this patch is the cause, but we seem to have soversion bumped 
libitm
from 0 to 1 (at least x86_64-apple-darwin11). Is this occuring on other targets 
and
was it intentional?
   Jack


Re: Eric Botcazou to join our Ada maintainer team

2011-11-21 Thread Eric Botcazou
> It's my pleasure to announce that Eric Botcazou is joining Arnaud,
> Geert and Robert as maintainer for Ada.
>
> (Turns out that when discussing this many were actually suprised
> he was not already. :-)
>
> Eric, you know the procedure, MAINTAINERS and such.

Thanks, file updated thusly.


* MAINTAINERS: Add self as co-maintainer of the Ada front end.


-- 
Eric Botcazou
Index: MAINTAINERS
===
--- MAINTAINERS	(revision 181595)
+++ MAINTAINERS	(working copy)
@@ -139,6 +139,7 @@ C front end/ISO C99	Richard Henderson	rt
 Ada front end		Geert Bosch		bo...@gnat.com
 Ada front end		Robert Dewar		de...@gnat.com
 Ada front end		Arnaud Charlet		char...@act-europe.fr
+Ada front end		Eric Botcazou		ebotca...@libertysurf.fr
 Fortran			Paul Brook		p...@codesourcery.com
 c++			Jason Merrill		ja...@redhat.com
 c++			Mark Mitchell		m...@codesourcery.com


Re: [libitm, build] Support sun symbol versioning

2011-11-21 Thread Richard Henderson
On 11/21/2011 11:50 AM, Jack Howarth wrote:
> On Mon, Nov 21, 2011 at 08:35:39PM +0100, Torvald Riegel wrote:
>> On Mon, 2011-11-21 at 15:06 +0100, Rainer Orth wrote:
>>> * _ITM_getThreadnum is the only symbol in libitm.map that isn't present
>>>   in the library.  It's documented as missing and should perhaps be
>>>   removed from the map?
>>
>> Yes, this is not supported anymore.
>>
>> Thanks,
>> Torvald
> 
>   I'm not sure if this patch is the cause, but we seem to have soversion 
> bumped libitm
> from 0 to 1 (at least x86_64-apple-darwin11). Is this occuring on other 
> targets and
> was it intentional?

It was probably due to the version number not being applied previously.


r~


Re: [libitm, build] Support sun symbol versioning

2011-11-21 Thread Jack Howarth
On Mon, Nov 21, 2011 at 11:55:00AM -0800, Richard Henderson wrote:
> On 11/21/2011 11:50 AM, Jack Howarth wrote:
> > On Mon, Nov 21, 2011 at 08:35:39PM +0100, Torvald Riegel wrote:
> >> On Mon, 2011-11-21 at 15:06 +0100, Rainer Orth wrote:
> >>> * _ITM_getThreadnum is the only symbol in libitm.map that isn't present
> >>>   in the library.  It's documented as missing and should perhaps be
> >>>   removed from the map?
> >>
> >> Yes, this is not supported anymore.
> >>
> >> Thanks,
> >> Torvald
> > 
> >   I'm not sure if this patch is the cause, but we seem to have soversion 
> > bumped libitm
> > from 0 to 1 (at least x86_64-apple-darwin11). Is this occuring on other 
> > targets and
> > was it intentional?
> 
> It was probably due to the version number not being applied previously.

Richard,
   I asked because we have libssp and libquadmath at 0 so I thought that the 
initial release of
libitm would soversioned the same way.
  Jack

> 
> 
> r~


Re: [libitm, build] Support sun symbol versioning

2011-11-21 Thread Richard Henderson
On 11/21/2011 11:58 AM, Jack Howarth wrote:
>> > It was probably due to the version number not being applied previously.
> Richard,
>I asked because we have libssp and libquadmath at 0 so I thought that the 
> initial release of
> libitm would soversioned the same way.

Those simply don't seem to define a version number properly:

 ./libitm/configure.ac:libtool_VERSION=1:0:0
 ./libitm/configure.ac:AC_SUBST(libtool_VERSION)
 ./libgo/configure.ac:libtool_VERSION=1:0:0
 ./libgo/configure.ac:AC_SUBST(libtool_VERSION)
 ./libgomp/configure.ac:libtool_VERSION=1:0:0
 ./libgomp/configure.ac:AC_SUBST(libtool_VERSION)



r~


[patch] Fix instantiation of transaction expressions.

2011-11-21 Thread Torvald Riegel
This patch fixes the instantiation of transaction expressions.
Transaction statements were correctly before via tsubst_expr, so just
use this code for expressions in tsubst_copy_and_build too.

OK for trunk?
commit 08726d496492d5a0fc2b0310983b04689ba17a48
Author: Torvald Riegel 
Date:   Sat Nov 19 13:44:27 2011 +0100

Fix instantiation of transaction expressions.

gcc/cp/
* pt.c (tsubst_copy_and_build): Handle TRANSACTION_EXPR.

gcc/testsuite/
* g++.dg/tm/template-2.C: New test.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 2ba26b2..f817b6f 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -14290,6 +14290,10 @@ tsubst_copy_and_build (tree t,
return r;
   }
 
+case TRANSACTION_EXPR:
+  return tsubst_expr(t, args, complain, in_decl,
+integral_constant_expression_p);
+
 default:
   /* Handle Objective-C++ constructs, if appropriate.  */
   {
diff --git a/gcc/testsuite/g++.dg/tm/template-2.C 
b/gcc/testsuite/g++.dg/tm/template-2.C
new file mode 100644
index 000..a05793d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tm/template-2.C
@@ -0,0 +1,22 @@
+// { dg-do compile }
+// { dg-options "-fgnu-tm -O -std=c++0x -fdump-tree-tmmark" }
+
+struct TrueFalse
+{
+};
+
+int global;
+
+template int foo()
+{
+  return __transaction_atomic (global + 2)
+ + __transaction_atomic (global + 3);
+}
+
+int f1()
+{
+  return foo();
+}
+
+/* { dg-final { scan-tree-dump-times "ITM_RU4\\s*\\(&global" 2 "tmmark" } } */
+/* { dg-final { cleanup-tree-dump "tmmark" } } */


[patch] Handle MUST_NOT_THROW_EXPR in voidify_wrapper_expr.

2011-11-21 Thread Torvald Riegel
voidify_wrapper_expr didn't handle MUST_NOT_THROW_EXPR before, but was
used by the C++ side gimplify function for MUST_NOT_THROW_EXPR.  Handle
it like other wrappers which have the inner part in operand 0.

OK for trunk?
commit 9cb965d2a5cf9ca6708ee85929784982253ded7a
Author: Torvald Riegel 
Date:   Mon Nov 21 00:25:08 2011 +0100

Handle MUST_NOT_THROW_EXPR in voidify_wrapper_expr.

gcc/
* gimplify.c (voidify_wrapper_expr): Handle MUST_NOT_THROW_EXPR.

diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index cfe6696..2cd48de 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -1050,6 +1050,7 @@ voidify_wrapper_expr (tree wrapper, tree temp)
case CLEANUP_POINT_EXPR:
case TRY_FINALLY_EXPR:
case TRY_CATCH_EXPR:
+   case MUST_NOT_THROW_EXPR:
  TREE_SIDE_EFFECTS (*p) = 1;
  TREE_TYPE (*p) = void_type_node;
  p = &TREE_OPERAND (*p, 0);


Re: [patch] Fix instantiation of transaction expressions.

2011-11-21 Thread Richard Henderson
On 11/21/2011 12:25 PM, Torvald Riegel wrote:
>   gcc/cp/
>   * pt.c (tsubst_copy_and_build): Handle TRANSACTION_EXPR.

Ok.

> +/* { dg-final { scan-tree-dump-times "ITM_RU4\\s*\\(&global" 2 "tmmark" } } 
> */

This needs to cater to sizeof(int) != 4.
Why not just match "ITM_RU" and leave it at that?


r~


Re: [patch] Handle MUST_NOT_THROW_EXPR in voidify_wrapper_expr.

2011-11-21 Thread Richard Henderson
On 11/21/2011 12:27 PM, Torvald Riegel wrote:
> voidify_wrapper_expr didn't handle MUST_NOT_THROW_EXPR before, but was
> used by the C++ side gimplify function for MUST_NOT_THROW_EXPR.  Handle
> it like other wrappers which have the inner part in operand 0.
> 
> OK for trunk?

Not ok.  This is a c++ specific name used in a non-c++ file.
You should have seen a bootstrap failure.


r~


[patch] Support noexcept-specifications for transaction statements and expressions.

2011-11-21 Thread Torvald Riegel
This revision of the patch is now complete and passes all the tests I
could come up with.  Compared to previous iterations, I added parsing of
noexcept without explicit true/false.  This makes
cp_parser_noexcept_specification_opt a bit more complex, but we can now
reuse it.
The other two patches I posted recently (fixing instantiations, handling
MUST_NOT_THROW_EXPR in voidify_wrapper_expr) are required for noexcept
support to work.

OK for trunk?
commit 0d82e90a50631296a67813605b7aeebd586064d6
Author: Torvald Riegel 
Date:   Tue Nov 15 15:00:48 2011 +0100

Support noexcept-specifications for transaction statements and expressions.

gcc/
* tree.h (TRANSACTION_EXPR_NOEX): New.
* tree.def (TRANSACTION_EXPR): Add noexcept spec as 2nd operand.
* c-parser.c (c_parser_transaction_expression): Adapt to this.
* c-typeck.c (c_finish_transaction): Same.

gcc/cp/
* semantics.c (finish_transaction_stmt, build_transaction_expr):
Accept new noexcept parameter and handle it.
(begin_transaction_stmt): Adapt to additional noexcept operand.
* cp-tree.h (finish_transaction_stmt, build_transaction_expr): Adapt
declarations.
* parser.c (cp_parser_exception_specification_opt): Extract
noexcept-specification parsing to ...
(cp_parser_noexcept_specification_opt): ...here.  Allow for parsing
non-constexpr noexcept arguments.
(cp_parser_transaction, cp_parser_transaction_expression): Parse
and handle noexcept-specifications.
(cp_parser_function_transaction): Adapt to finish_transaction_stmt
change.
* pt.c (tsubst_expr): Handle noexcept specs when instantiating
transactions.

gcc/testsuite/
* g++.dg/tm/noexcept-1.C: New test.
* g++.dg/tm/noexcept-2.C: New test.
* g++.dg/tm/noexcept-3.C: New test.
* g++.dg/tm/noexcept-4.C: New test.
* g++.dg/tm/noexcept-5.C: New test.

diff --git a/gcc/c-parser.c b/gcc/c-parser.c
index b88b11f..e1ce35f 100644
--- a/gcc/c-parser.c
+++ b/gcc/c-parser.c
@@ -10703,7 +10703,8 @@ c_parser_transaction_expression (c_parser *parser, enum 
rid keyword)
 {
   tree expr = c_parser_expression (parser).value;
   ret.original_type = TREE_TYPE (expr);
-  ret.value = build1 (TRANSACTION_EXPR, ret.original_type, expr);
+  ret.value = build2 (TRANSACTION_EXPR, ret.original_type, expr,
+ NULL_TREE);
   if (this_in & TM_STMT_ATTR_RELAXED)
TRANSACTION_EXPR_RELAXED (ret.value) = 1;
   SET_EXPR_LOCATION (ret.value, loc);
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index 4a134b0..f015ff6 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -10930,7 +10930,7 @@ c_finish_omp_clauses (tree clauses)
 tree
 c_finish_transaction (location_t loc, tree block, int flags)
 {
-  tree stmt = build_stmt (loc, TRANSACTION_EXPR, block);
+  tree stmt = build_stmt (loc, TRANSACTION_EXPR, block, NULL_TREE);
   if (flags & TM_STMT_ATTR_OUTER)
 TRANSACTION_EXPR_OUTER (stmt) = 1;
   if (flags & TM_STMT_ATTR_RELAXED)
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 3f4f408..ba124cf 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -5571,8 +5571,8 @@ extern void finish_omp_barrier(void);
 extern void finish_omp_flush   (void);
 extern void finish_omp_taskwait(void);
 extern tree begin_transaction_stmt (location_t, tree *, int);
-extern void finish_transaction_stmt(tree, tree, int);
-extern tree build_transaction_expr (location_t, tree, int);
+extern void finish_transaction_stmt(tree, tree, int, tree);
+extern tree build_transaction_expr (location_t, tree, int, tree);
 extern void finish_omp_taskyield   (void);
 extern bool cxx_omp_create_clause_info (tree, tree, bool, bool, bool);
 extern tree baselink_for_fns(tree);
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 4a2b2a9..dea59f1 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -19509,19 +19509,23 @@ cp_parser_base_specifier (cp_parser* parser)
 
 /* Exception handling [gram.exception] */
 
-/* Parse an (optional) exception-specification.
+/* Parse an (optional) noexcept-specification.
 
-   exception-specification:
- throw ( type-id-list [opt] )
+   noexcept-specification:
+ noexcept ( constant-expression ) [opt]
 
-   Returns a TREE_LIST representing the exception-specification.  The
-   TREE_VALUE of each node is a type.  */
+   If no noexcept-specification is present, returns NULL_TREE.
+   Otherwise, if REQUIRE_CONSTEXPR is false, then either parse and return any
+   expression if parentheses follow noexcept, or return BOOLEAN_TRUE_NODE if
+   there are no parentheses.  CONSUMED_EXPR will be set accordingly.
+   Otherwise, returns a noexcept specification.  */
 
 static tree
-cp_parser_exception_specification_opt (c

  1   2   >