[Ada] Lock-free implementation of protected objects
This patch implements a check in the runtime library that determines whether the current target supports the atomic primitives up to 64 bits. This should fix build failures on e.g. powerpc-darwin. Tested on x86_64-pc-linux-gnu, committed on trunk 2012-07-23 Vincent Pucci * system-aix64.ads, system-aix.ads, system-darwin-ppc.ads, system-hpux.ads, system-linux-alpha.ads, system-linux-hppa.ads, system-linux-ppc.ads, system-linux-s390.ads, system-linux-s390x.ads, system-linux-sh4.ads, system-linux-sparc.ads, system-lynxos-ppc.ads, system-mingw.ads, system-solaris-sparc.ads, system-solaris-sparcv9.ads, system-vms_64.ads, * system-vxworks-arm.ads, system-vxworks-m68k.ads, system-vxworks-mips.ads, system-vxworks-ppc.ads, system-vxworks-sparcv9.ads: Support_Atomic_Primitives set to False. * system-darwin-x86.ads, system-darwin-x86_64.ads, system-freebsd-x86.ads, system-freebsd-x86_64.ads, system-hpux-ia64.ads, system-linux-ia64.ads, system-linux-x86.ads, system-linux-x86_64.ads, system-lynxos-x86.ads, system-mingw-x86_64.ads, system-solaris-x86.ads, system-solaris-x86_64.ads, system-vms-ia64.ads, system-vxworks-x86.ads: Support_Atomic_Primitives set to True. * s-atopri.adb (Lock_Free_Read_X): New body. (Lock_Free_Try_Write_X): Support_Atomic_Primitives check added. (Lock_Free_Try_Write_64): New body. * s-atopri.ads: New type uint. (Sync_Compare_And_Swap_64): __sync_val_compare_and_swap_8 intrinsic import. (Lock_Free_Read_X): Body moved to s-atopri.adb. (Lock_Free_Try_Write_64): Similar to other Lock_Free_Try_Write_X routines. * targparm.adb: New enumeration literal SAP (Support_Atomic_Primitives) for type Targparm_Tags. New constant SAP_Str. New component SAP_Str'Access for array Targparm_Str. (Get_Target_Parameters): Parse Support_Atomic_Primitives_On_Target flag. * targparm.ads: New back-end code generation flag Support_Atomic_Primitives_On_Target Index: system-darwin-x86.ads === --- system-darwin-x86.ads (revision 189768) +++ system-darwin-x86.ads (working copy) @@ -7,7 +7,7 @@ -- S p e c -- -- (Darwin/x86 Version)-- -- -- --- Copyright (C) 1992-2011, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2012, Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- @@ -158,6 +158,7 @@ Stack_Check_Probes: constant Boolean := True; Stack_Check_Limits: constant Boolean := False; Support_Aggregates: constant Boolean := True; + Support_Atomic_Primitives : constant Boolean := True; Support_Composite_Assign : constant Boolean := True; Support_Composite_Compare : constant Boolean := True; Support_Long_Shifts : constant Boolean := True; Index: system-linux-s390x.ads === --- system-linux-s390x.ads (revision 189768) +++ system-linux-s390x.ads (working copy) @@ -7,7 +7,7 @@ -- S p e c -- -- (GNU-Linux/s390x Version) -- -- -- --- Copyright (C) 1992-2011, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2012, Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- @@ -130,6 +130,7 @@ Stack_Check_Probes: constant Boolean := False; Stack_Check_Limits: constant Boolean := False; Support_Aggregates: constant Boolean := True; + Support_Atomic_Primitives : constant Boolean := False; Support_Composite_Assign : constant Boolean := True; Support_Composite_Compare : constant Boolean := True; Support_Long_Shifts : constant Boolean := True; Index: system-linux-alpha.ads === --- system-linux-alpha.ads (revision 189768) +++ system-linux-alpha.ads (working copy) @@ -7,7 +7,7 @@ -- S p e c -- --
Re: [Ada] Lock-free implementation of protected objects
Hi Arnaud, --- s-atopri.adb(revision 189768) +++ s-atopri.adb(working copy) @@ -31,6 +31,58 @@ package body System.Atomic_Primitives is + -- + -- Lock_Free_Read_8 -- + -- ... + -- + -- Lock_Free_Read_16 -- + -- ... + -- + -- Lock_Free_Read_32 -- + -- There's a bunch or wrong comment formatting (notice how "" lines aren't always long enough except for the _8 case). Ciao, Duncan.
Re: [Ada] Lock-free implementation of protected objects
> Hi Arnaud, You removed Vincent who is the author of this patch, included here. >> --- s-atopri.adb (revision 189768) >> +++ s-atopri.adb (working copy) >> @@ -31,6 +31,58 @@ >> >> package body System.Atomic_Primitives is >> >> + -- >> + -- Lock_Free_Read_8 -- >> + -- > > ... > >> + -- >> + -- Lock_Free_Read_16 -- >> + -- > > ... > >> + -- >> + -- Lock_Free_Read_32 -- >> + -- > > There's a bunch or wrong comment formatting (notice how "" lines aren't > always long enough except for the _8 case).
[Ada] Aspect specifications in subprogram bodies
Aspect specification can appear in subprogram bodies. To handle them in the parser the aspects that follow a subprogram specification must be collected, and attached to the proper declaration or body only after the nature of the enclosing construct has been determined. The following must compile quietly in Ada_2012 mode: procedure P with Inline is begin null; end; Aspects are only allowed on a subprogram body if there is no previous spec for it. Compiling p2.adb must yield: p2.adb:4:05: aspect specifications must appear in subprogram declaration with Text_IO; use Text_IO; procedure P2 is function F return Integer; function F return Integer with Inline is begin return 15; end; begin null; end P2; Tested on x86_64-pc-linux-gnu, committed on trunk 2012-07-23 Ed Schonberg * par.adb: new subprogram Get_Aspect_Specifications. * par-ch6.adb (P_Subprogram): handle subprogram bodies with aspect specifications. * par-ch13.adb (Get_Aspect_Specifications): extracted from P_Aspect_Specifications. Collect aspect specifications in some legal context, but do not attach them to any declaration. Used when parsing subprogram declarations or bodies that include aspect specifications. * sem_ch6.adb (Analyze_Subprogram_Body_Helper): If aspects are present, analyze them, or reject them if the subprogram as a previous spec. Index: par-ch13.adb === --- par-ch13.adb(revision 189768) +++ par-ch13.adb(working copy) @@ -132,6 +132,251 @@ return Result; end Aspect_Specifications_Present; + --- + -- Get_Aspect_Specifications -- + --- + + function Get_Aspect_Specifications + (Semicolon : Boolean := True) return List_Id + is + Aspects : List_Id; + Aspect : Node_Id; + A_Id: Aspect_Id; + OK : Boolean; + + begin + Aspects := Empty_List; + + -- Check if aspect specification present + + if not Aspect_Specifications_Present then + if Semicolon then +TF_Semicolon; + end if; + + return Aspects; + end if; + + Scan; -- past WITH + Aspects := Empty_List; + + loop + OK := True; + + if Token /= Tok_Identifier then +Error_Msg_SC ("aspect identifier expected"); + +if Semicolon then + Resync_Past_Semicolon; +end if; + +return Aspects; + end if; + + -- We have an identifier (which should be an aspect identifier) + + A_Id := Get_Aspect_Id (Token_Name); + Aspect := + Make_Aspect_Specification (Token_Ptr, + Identifier => Token_Node); + + -- No valid aspect identifier present + + if A_Id = No_Aspect then +Error_Msg_SC ("aspect identifier expected"); + +-- Check bad spelling + +for J in Aspect_Id loop + if Is_Bad_Spelling_Of (Token_Name, Aspect_Names (J)) then + Error_Msg_Name_1 := Aspect_Names (J); + Error_Msg_SC -- CODEFIX +("\possible misspelling of%"); + exit; + end if; +end loop; + +Scan; -- past incorrect identifier + +if Token = Tok_Apostrophe then + Scan; -- past ' + Scan; -- past presumably CLASS +end if; + +if Token = Tok_Arrow then + Scan; -- Past arrow + Set_Expression (Aspect, P_Expression); + OK := False; + +elsif Token = Tok_Comma then + OK := False; + +else + if Semicolon then + Resync_Past_Semicolon; + end if; + + return Aspects; +end if; + + -- OK aspect scanned + + else +Scan; -- past identifier + +-- Check for 'Class present + +if Token = Tok_Apostrophe then + if not Class_Aspect_OK (A_Id) then + Error_Msg_Node_1 := Identifier (Aspect); + Error_Msg_SC ("aspect& does not permit attribute here"); + Scan; -- past apostrophe + Scan; -- past presumed CLASS + OK := False; + + else + Scan; -- past apostrophe + + if Token /= Tok_Identifier +or else Token_Name /= Name_Class + then + Error_Msg_SC ("Class attribute expected here"); + OK := False; + + if Token = Tok_Identifier then +Scan; -- past identifier not CLASS + end if; + + else + Scan; -- past CLASS +
[Ada] Fix to SCOs for SELECT alternatives with guard
This change fixes incorrect source location indications in SCOs for decisions corresponding to guard expressions in SELECT statements, which can cause a crash in coverage analysis tools. Tested on x86_64-pc-linux-gnu, committed on trunk 2012-07-23 Thomas Quinot * par_sco.adb (Process_Decisions.Output_Header): For the guard on an alternative in a SELECT statement, use the First_Sloc of the guard expression (not its topmost sloc) as the decision location, because this is what is referenced by dominance markers. Index: par_sco.adb === --- par_sco.adb (revision 189768) +++ par_sco.adb (working copy) @@ -25,6 +25,7 @@ with Atree;use Atree; with Debug;use Debug; +with Errout; use Errout; with Lib; use Lib; with Lib.Util; use Lib.Util; with Namet;use Namet; @@ -495,13 +496,15 @@ -- levels (through the pragma argument association) to get to -- the pragma node itself. For the guard on a select -- alternative, we do not have access to the token location - -- for the WHEN, so we use the sloc of the condition itself. + -- for the WHEN, so we use the first sloc of the condition + -- itself (note: we use First_Sloc, not Sloc, because this is + -- what is referenced by dominance markers). if Nkind_In (Parent (N), N_Accept_Alternative, N_Delay_Alternative, N_Terminate_Alternative) then - Loc := Sloc (N); + Loc := First_Sloc (N); else Loc := Sloc (Parent (Parent (N))); end if;
[Ada] Missing finalization of transient function result
This patch corrects the machinery which detects whether a particular transient context may raise an exception. Examine the original expression of an object declaration node because a function call that returns on the secondary stack may have been rewritten into something else and no longer appear as a call. Tested on x86_64-pc-linux-gnu, committed on trunk 2012-07-23 Hristian Kirtchev * exp_ch7.adb (Requires_Hooking): Examine the original expression of an object declaration node because a function call that returns on the secondary stack may have been rewritten into something else. Index: exp_ch7.adb === --- exp_ch7.adb (revision 189768) +++ exp_ch7.adb (working copy) @@ -4369,12 +4369,16 @@ function Requires_Hooking return Boolean is begin -- The context is either a procedure or function call or an object --- declaration initialized by a function call. In all these cases, --- the calls might raise an exception. +-- declaration initialized by a function call. Note that in the +-- latter case, a function call that returns on the secondary +-- stack is usually rewritten into something else. Its proper +-- detection requires examination of the original initialization +-- expression. return Nkind (N) in N_Subprogram_Call - or else (Nkind (N) = N_Object_Declaration - and then Nkind (Expression (N)) = N_Function_Call); + or else (Nkind (N) = N_Object_Declaration + and then Nkind (Original_Node (Expression (N))) = +N_Function_Call); end Requires_Hooking; -- Local variables
[Ada] Support for coverage analysis of ACCEPT alternatives in SELECT statement
This change ensures that the NULL statement generated for coverage analysis purposes in an otherwise empty ACCEPT alternative is not eliminated by GIGI or the code generator by setting its Comes_From_Source flag. Tested on x86_64-pc-linux-gnu, committed on trunk 2012-07-23 Thomas Quinot * exp_ch9.adb (Ensure_Statement_Present): Mark generated NULL statement as Comes_From_Source so that GIGI does not eliminate it. Index: exp_ch9.adb === --- exp_ch9.adb (revision 189768) +++ exp_ch9.adb (working copy) @@ -5484,11 +5484,19 @@ -- procedure Ensure_Statement_Present (Loc : Source_Ptr; Alt : Node_Id) is + Stmt : Node_Id; begin if Opt.Suppress_Control_Flow_Optimizations and then Is_Empty_List (Statements (Alt)) then - Set_Statements (Alt, New_List (Make_Null_Statement (Loc))); + Stmt := Make_Null_Statement (Loc); + + -- Mark NULL statement as coming from source so that it is not + -- eliminated by GIGI. + + Set_Comes_From_Source (Stmt, True); + + Set_Statements (Alt, New_List (Stmt)); end if; end Ensure_Statement_Present;
[Ada] Improve GNAT dimensionality checking system
For GNAT dimensionality checking system, accept constant declaration whose type is a dimensioned type when an initialization expression with dimension is present. The test presented below highlights this new patch: -- Source -- with System.Dim.Mks_IO; use System.Dim.Mks_IO; with System.Dim.Mks;use System.Dim.Mks; procedure Main is My_Cons : constant Mks_Type := cm * g**2; begin Put_Dim_Of (My_Cons); end Main; --- -- Compilation and Execution -- --- $ gnatmake -q -gnat12 main.adb $ ./main -- Output -- [L.M**2] Tested on x86_64-pc-linux-gnu, committed on trunk 2012-07-23 Vincent Pucci * sem_dim.adb (Analyze_Dimension_Has_Etype): For identifier, propagate dimension when entity is a non-dimensionless constant. (Analyze_Dimension_Object_Declaration): Propagate dimension from the expression to the entity when type is a dimensioned type and object is a constant. Index: sem_dim.adb === --- sem_dim.adb (revision 189768) +++ sem_dim.adb (working copy) @@ -1617,6 +1617,14 @@ if Exists (Dims_Of_Etyp) then Set_Dimensions (N, Dims_Of_Etyp); + + -- Propagation of the dimensions from the entity for identifier whose + -- entity is a non-dimensionless consant. + + elsif Nkind (N) = N_Identifier +and then Exists (Dimensions_Of (Entity (N))) + then + Set_Dimensions (N, Dimensions_Of (Entity (N))); end if; -- Removal of dimensions in expression @@ -1692,7 +1700,7 @@ if Present (Expr) then Dim_Of_Expr := Dimensions_Of (Expr); - -- case when expression is not a literal and when dimensions of the + -- Case when expression is not a literal and when dimensions of the -- expression and of the type mismatch if not Nkind_In (Original_Node (Expr), @@ -1700,7 +1708,20 @@ N_Integer_Literal) and then Dim_Of_Expr /= Dim_Of_Etyp then -Error_Dim_Msg_For_Object_Declaration (N, Etyp, Expr); +-- Propagate the dimension from the expression to the object +-- entity when the object is a constant whose type is a +-- dimensioned type. + +if Constant_Present (N) + and then not Exists (Dim_Of_Etyp) +then + Set_Dimensions (Id, Dim_Of_Expr); + +-- Otherwise, issue an error message + +else + Error_Dim_Msg_For_Object_Declaration (N, Etyp, Expr); +end if; end if; -- Removal of dimensions in expression
[Ada] User-defined indexing operations
A user-defined indexing operation can have more than one index, for example to describe user-defined matrix types. The following must compile quietly: gcc -c -gnat12 test_indexing.adb --- with Ada.Text_IO; use Ada.Text_IO; with Project; use Project; with Matrix_3x3s; use Matrix_3x3s; with Vector_3s; use Vector_3s; procedure Test_Indexing is procedure Display (X : Real) is begin Put_Line (Real'Image (X)); end Display; V : Vector_3 := Create (X => 12.34, Y => 123.4, Z => 1234.0); M : Matrix_3x3 := (Create (X => V, Y => V * 2.0, Z => V * 4.0)); begin V (1) := 1.0; Display (V (1)); Display (V (2)); Display (V (3)); M (1, 1) := 20.0; Display (M (1, 1)); end Test_Indexing; --- with Project; use Project; with Project.Real_Arrays; use Project.Real_Arrays; with Vector_3s; use Vector_3s; package Matrix_3x3s is pragma Pure (Matrix_3x3s); subtype An_Axis is Integer range 1 .. 3; type Matrix_3x3 is tagged private with Constant_Indexing => Matrix_3x3s.Constant_Reference, Variable_Indexing => Matrix_3x3s.Variable_Reference; function Create (X, Y, Z : Vector_3) return Matrix_3x3; type Constant_Reference_Type (Value : not null access constant Real) is private with Implicit_Dereference => Value; function Constant_Reference (This : Matrix_3x3; X, Y : An_Axis) return Constant_Reference_Type; type Reference_Type (Value : not null access Real) is private with Implicit_Dereference => Value; function Variable_Reference (This : Matrix_3x3; X, Y : An_Axis) return Reference_Type; private type Matrix_3x3 is tagged record M : Real_Matrix (An_Axis, An_Axis); end record; function Create (X, Y, Z : Vector_3) return Matrix_3x3 is (M => (1 => (X.Get_X, X.Get_Y, X.Get_Z), 2 => (Y.Get_X, Y.Get_Y, Y.Get_Z), 3 => (Z.Get_X, Z.Get_Y, Z.Get_Z))); type Constant_Reference_Type (Value : not null access constant Real) is null record; type Reference_Type (Value : not null access Real) is null record; function Constant_Reference (This : Matrix_3x3; X, Y : An_Axis) return Constant_Reference_Type is (Value => This.M (X, Y)'Unrestricted_Access); function Variable_Reference (This : Matrix_3x3; X, Y : An_Axis) return Reference_Type is (Value => This.M (X, Y)'Unrestricted_Access); end Matrix_3x3s; --- with Ada.Numerics.Long_Real_Arrays; package Project.Real_Arrays renames Ada.Numerics.Long_Real_Arrays; package Project is pragma Pure (Project); subtype Real is Long_Float; pragma Assert (Real'Size >= 64); subtype Non_Negative_Real is Real range 0.0 .. Real'Last; subtype Positive_Real is Real range Real'Succ (0.0) .. Real'Last; end Project; --- with Project; use Project; with Project.Real_Arrays; use Project.Real_Arrays; package Vector_3s is pragma Pure (Vector_3s); subtype An_Axis is Integer range 1 .. 3; type Vector_3 is tagged private with Constant_Indexing => Vector_3s.Constant_Reference, Variable_Indexing => Vector_3s.Variable_Reference; function Create (X, Y, Z : Real) return Vector_3; function Get_X (This : Vector_3) return Real; function Get_Y (This : Vector_3) return Real; function Get_Z (This : Vector_3) return Real; function "*" (Left : Vector_3; Right : Real'Base) return Vector_3; subtype Real_Vector_3 is Real_Vector (An_Axis); type Constant_Reference_Type (Value : not null access constant Real) is private with Implicit_Dereference => Value; function Constant_Reference (This : Vector_3; Axis : An_Axis) return Constant_Reference_Type; type Reference_Type (Value : not null access Real) is private with Implicit_Dereference => Value; function Variable_Reference (This : Vector_3; Axis : An_Axis) return Reference_Type; private type Vector_3 is tagged record V : Real_Vector (An_Axis); end record; function Create (X, Y, Z : Real) return Vector_3 is (V => (1 => X, 2 => Y, 3 => Z)); function Get_X (This : Vector_3) return Real is (This.V (1)); function Get_Y (This : Vector_3) return Real is (This.V (2)); function Get_Z (This : Vector_3) return Real is (This.V (3)); function "*" (Left : Vector_3; Right : Real'Base) return Vector_3 is (V => Left.V * Right); type Constant_Reference_Type (Value : not null access constant Real) is null record; type Reference_Type (Value : not null access Real) is null record; function Constant_Reference (Thi
[Ada] Clean up of heap objects in the context of accessibility failures
This patch reimplements the way accessibility checks are performed on heap- allocated class-wide objects. The checks now contain clean up code which finalizes (if applicable) and deallocates the object. Tested on x86_64-pc-linux-gnu, committed on trunk 2012-07-23 Hristian Kirtchev * exp_ch4.adb (Apply_Accessibility_Check): Reimplemented. The check is now more complex and contains optional finalization part and mandatory deallocation part. Index: exp_ch4.adb === --- exp_ch4.adb (revision 189768) +++ exp_ch4.adb (working copy) @@ -659,7 +659,7 @@ -- Ada 2005 (AI-344): For an allocator with a class-wide designated -- type, generate an accessibility check to verify that the level of the -- type of the created object is not deeper than the level of the access - -- type. If the type of the qualified expression is class- wide, then + -- type. If the type of the qualified expression is class-wide, then -- always generate the check (except in the case where it is known to be -- unnecessary, see comment below). Otherwise, only generate the check -- if the level of the qualified expression type is statically deeper @@ -690,7 +690,11 @@ (Ref: Node_Id; Built_In_Place : Boolean := False) is - New_Node : Node_Id; + Pool_Id : constant Entity_Id := Associated_Storage_Pool (PtrT); + Cond : Node_Id; + Free_Stmt : Node_Id; + Obj_Ref : Node_Id; + Stmts : List_Id; begin if Ada_Version >= Ada_2005 @@ -701,6 +705,8 @@ or else (Is_Class_Wide_Type (Etype (Exp)) and then Scope (PtrT) /= Current_Scope)) + and then + (Tagged_Type_Expansion or else VM_Target /= No_VM) then -- If the allocator was built in place, Ref is already a reference -- to the access object initialized to the result of the allocator @@ -712,39 +718,109 @@ if Built_In_Place then Remove_Side_Effects (Ref); - New_Node := New_Copy (Ref); + Obj_Ref := New_Copy (Ref); else - New_Node := New_Reference_To (Ref, Loc); + Obj_Ref := New_Reference_To (Ref, Loc); end if; -New_Node := +-- Step 1: Create the object clean up code + +Stmts := New_List; + +-- Create an explicit free statement to clean up the allocated +-- object in case the accessibility check fails. Generate: + +--Free (Obj_Ref); + +Free_Stmt := Make_Free_Statement (Loc, New_Copy (Obj_Ref)); +Set_Storage_Pool (Free_Stmt, Pool_Id); + +Append_To (Stmts, Free_Stmt); + +-- Finalize the object (if applicable), but wrap the call inside +-- a block to ensure that the object would still be deallocated in +-- case the finalization fails. Generate: + +--begin +-- [Deep_]Finalize (Obj_Ref.all); +--exception +-- when others => +-- Free (Obj_Ref); +-- raise; +--end; + +if Needs_Finalization (DesigT) then + Prepend_To (Stmts, + Make_Block_Statement (Loc, + Handled_Statement_Sequence => + Make_Handled_Sequence_Of_Statements (Loc, + Statements => New_List ( + Make_Final_Call ( + Obj_Ref => + Make_Explicit_Dereference (Loc, + Prefix => New_Copy (Obj_Ref)), + Typ => DesigT)), + + Exception_Handlers => New_List ( + Make_Exception_Handler (Loc, + Exception_Choices => New_List ( + Make_Others_Choice (Loc)), + Statements=> New_List ( + New_Copy_Tree (Free_Stmt), + Make_Raise_Statement (Loc))); +end if; + +-- Signal the accessibility failure through a Program_Error + +Append_To (Stmts, + Make_Raise_Program_Error (Loc, +Condition => New_Reference_To (Standard_True, Loc), +Reason=> PE_Accessibility_Check_Failed)); + +-- Step 2: Create the accessibility comparison + +-- Generate: +--Ref'Tag + +Obj_Ref := Make_Attribute_Reference (Loc, -Prefix => New_Node, +Prefix => Obj_Ref, Attribute_Name => Name_Tag); +-- For tagged types, deter
[Ada] Element allocators in indefinite containers need accessibility checks
Various operations in the indefinite containers perform initialized allocators for elements, and accessibility checks are required on those allocators which can fail when the actual type for Element_Type is a class-wide type and the operation is passed an element value of a type extension declared at a deeper level than the container instantiation (violating the check in 4.8(10.1)). Like other units in the GNAT library, the containers (and their instances) are compiled with checks suppressed, so the needed accessibility checks are not performed, which can result in accesses to dispatch tables that have gone out of scope. A similar problem can occur for element types with access discriminants. This is corrected by applying pragma Unsuppress in the various container operations that have allocators initialized by Element_Type formals. Note that AI12-0035 has been created to address the gap in the language rules, since these checks should be required. Tested on x86_64-pc-linux-gnu, committed on trunk 2012-07-23 Gary Dismukes * a-cihama.adb, a-cihase.adb, a-cimutr.adb, a-ciorma.adb, a-ciormu.adb, a-ciorse.adb, a-coinho.adb, a-coinve.adb, a-cidlli.adb: Unsuppress Accessibility_Check for Element_Type allocators. Index: a-cihama.adb === --- a-cihama.adb(revision 189768) +++ a-cihama.adb(working copy) @@ -694,6 +694,11 @@ Position.Node.Key := new Key_Type'(Key); + declare +pragma Unsuppress (Accessibility_Check); +-- The element allocator may need an accessibility check in the +-- case the actual type is class-wide or has access discriminants +-- (see RM 4.8(10.1) and AI12-0035). begin Position.Node.Element := new Element_Type'(New_Item); exception @@ -731,6 +736,11 @@ K : Key_Access := new Key_Type'(Key); E : Element_Access; + pragma Unsuppress (Accessibility_Check); + -- The element allocator may need an accessibility check in the case + -- the actual type is class-wide or has access discriminants (see + -- RM 4.8(10.1) and AI12-0035). + begin E := new Element_Type'(New_Item); return new Node_Type'(K, E, Next); @@ -1166,6 +1176,11 @@ Node.Key := new Key_Type'(Key); + declare + pragma Unsuppress (Accessibility_Check); + -- The element allocator may need an accessibility check in the case + -- the actual type is class-wide or has access discriminants (see + -- RM 4.8(10.1) and AI12-0035). begin Node.Element := new Element_Type'(New_Item); exception @@ -1215,6 +1230,10 @@ declare X : Element_Access := Position.Node.Element; + pragma Unsuppress (Accessibility_Check); + -- The element allocator may need an accessibility check in the case + -- the actual type is class-wide or has access discriminants (see + -- RM 4.8(10.1) and AI12-0035). begin Position.Node.Element := new Element_Type'(New_Item); Free_Element (X); Index: a-coinve.adb === --- a-coinve.adb(revision 189768) +++ a-coinve.adb(working copy) @@ -1698,7 +1698,14 @@ -- value, in case the allocation fails (either because there is no -- storage available, or because element initialization fails). -Container.Elements.EA (Idx) := new Element_Type'(New_Item); +declare + pragma Unsuppress (Accessibility_Check); + -- The element allocator may need an accessibility check in the + -- case actual type is class-wide or has access discriminants + -- (see RM 4.8(10.1) and AI12-0035). +begin + Container.Elements.EA (Idx) := new Element_Type'(New_Item); +end; -- The allocation of the element succeeded, so it is now safe to -- update the Last index, restoring container invariants. @@ -1744,7 +1751,14 @@ -- because there is no storage available, or because element -- initialization fails). - E (Idx) := new Element_Type'(New_Item); + declare + pragma Unsuppress (Accessibility_Check); + -- The element allocator may need an accessibility check + -- in case the actual type is class-wide or has access + -- discriminants (see RM 4.8(10.1) and AI12-0035). + begin + E (Idx) := new Element_Type'(New_Item); + end; -- The allocation of the element succeeded, so it is now -- safe to update the Last index, restoring container @@ -178
[Ada] Ambiguities with class-wide operations on synchronized types
This patch fixes the code that implements AI05-0090, a check for ambiguities in calls to primitive operations of tagged synchronized types. No small example available. Tested on x86_64-pc-linux-gnu, committed on trunk 2012-07-23 Ed Schonberg * sem_ch4.adb (Analyze_Selected_Component): When checking for potential ambiguities with class-wide operations on synchronized types, attach the copied node properly to the tree, to prevent errors during expansion. Index: sem_ch4.adb === --- sem_ch4.adb (revision 189774) +++ sem_ch4.adb (working copy) @@ -4222,13 +4222,21 @@ -- Duplicate the call. This is required to avoid problems with -- the tree transformations performed by Try_Object_Operation. + -- Set properly the parent of the copied call, because it is + -- about to be reanalyzed. - and then -Try_Object_Operation - (N=> Sinfo.Name (New_Copy_Tree (Parent (N))), - CW_Test_Only => True) then - return; + declare + Par : constant Node_Id := New_Copy_Tree (Parent (N)); + + begin + Set_Parent (Par, Parent (Parent (N))); + if Try_Object_Operation +(Sinfo.Name (Par), CW_Test_Only => True) + then + return; + end if; + end; end if; end if;
[Ada] Always analyze loop body during semantic analysis in Alfa mode
In Alfa mode for formal verification, the loop form with an iterator is not expanded, thus the analysis of the loop body should be done during semantic analysis. Tested on x86_64-pc-linux-gnu, committed on trunk 2012-07-23 Yannick Moy * sem_ch5.adb (Analyze_Loop_Statement): Make sure the loop body is analyzed in Alfa mode. Index: sem_ch5.adb === --- sem_ch5.adb (revision 189768) +++ sem_ch5.adb (working copy) @@ -2633,14 +2633,14 @@ -- types the actual subtype of the components will only be determined -- when the cursor declaration is analyzed. - -- If the expander is not active, then we want to analyze the loop body - -- now even in the Ada 2012 iterator case, since the rewriting will not - -- be done. Insert the loop variable in the current scope, if not done - -- when analysing the iteration scheme. + -- If the expander is not active, or in Alfa mode, then we want to + -- analyze the loop body now even in the Ada 2012 iterator case, since + -- the rewriting will not be done. Insert the loop variable in the + -- current scope, if not done when analysing the iteration scheme. if No (Iter) or else No (Iterator_Specification (Iter)) -or else not Expander_Active +or else not Full_Expander_Active then if Present (Iter) and then Present (Iterator_Specification (Iter))
[Ada] Crash on private enumeration type when compiling with -gnatVa
This patch corrects the retrieval of the base type of an enumeration subtype. In certain cases the base type may be a private type, therefore the compiler must inspect its full view. Tested on x86_64-pc-linux-gnu, committed on trunk 2012-07-23 Hristian Kirtchev * checks.adb (Determine_Range): Add local variable Btyp. Handle the case where the base type of an enumeration subtype is private. Replace all occurrences of Base_Type with Btyp. * exp_attr.adb (Attribute_Valid): Handle the case where the base type of an enumeration subtype is private. Replace all occurrences of Base_Type with Btyp. * sem_util.adb (Get_Enum_Lit_From_Pos): Add local variable Btyp. Handle the case where the base type of an enumeration subtype is private. Replace all occurrences of Base_Type with Btyp. Index: exp_attr.adb === --- exp_attr.adb(revision 189768) +++ exp_attr.adb(working copy) @@ -5372,6 +5372,13 @@ Validity_Checks_On := False; + -- Retrieve the base type. Handle the case where the base type is a + -- private enumeration type. + + if Is_Private_Type (Btyp) and then Present (Full_View (Btyp)) then +Btyp := Full_View (Btyp); + end if; + -- Floating-point case. This case is handled by the Valid attribute -- code in the floating-point attribute run-time library. @@ -5472,15 +5479,14 @@ -- (X >= type(X)'First and then type(X)'Last <= X) elsif Is_Enumeration_Type (Ptyp) - and then Present (Enum_Pos_To_Rep (Base_Type (Ptyp))) + and then Present (Enum_Pos_To_Rep (Btyp)) then Tst := Make_Op_Ge (Loc, Left_Opnd => Make_Function_Call (Loc, Name => - New_Reference_To -(TSS (Base_Type (Ptyp), TSS_Rep_To_Pos), Loc), + New_Reference_To (TSS (Btyp, TSS_Rep_To_Pos), Loc), Parameter_Associations => New_List ( Pref, New_Occurrence_Of (Standard_False, Loc))), Index: checks.adb === --- checks.adb (revision 189768) +++ checks.adb (working copy) @@ -3151,6 +3151,9 @@ Cindex : Cache_Index; -- Used to search cache + Btyp : Entity_Id; + -- Base type + function OK_Operands return Boolean; -- Used for binary operators. Determines the ranges of the left and -- right operands, and if they are both OK, returns True, and puts @@ -3267,6 +3270,15 @@ Typ := Underlying_Type (Base_Type (Typ)); end if; + -- Retrieve the base type. Handle the case where the base type is a + -- private enumeration type. + + Btyp := Base_Type (Typ); + + if Is_Private_Type (Btyp) and then Present (Full_View (Btyp)) then + Btyp := Full_View (Btyp); + end if; + -- We use the actual bound unless it is dynamic, in which case use the -- corresponding base type bound if possible. If we can't get a bound -- then we figure we can't determine the range (a peculiar case, that @@ -3280,8 +3292,8 @@ if Compile_Time_Known_Value (Bound) then Lo := Expr_Value (Bound); - elsif Compile_Time_Known_Value (Type_Low_Bound (Base_Type (Typ))) then - Lo := Expr_Value (Type_Low_Bound (Base_Type (Typ))); + elsif Compile_Time_Known_Value (Type_Low_Bound (Btyp)) then + Lo := Expr_Value (Type_Low_Bound (Btyp)); else OK := False; @@ -3296,8 +3308,8 @@ -- always be compile time known. Again, it is not clear that this -- can ever be false, but no point in bombing. - if Compile_Time_Known_Value (Type_High_Bound (Base_Type (Typ))) then - Hbound := Expr_Value (Type_High_Bound (Base_Type (Typ))); + if Compile_Time_Known_Value (Type_High_Bound (Btyp)) then + Hbound := Expr_Value (Type_High_Bound (Btyp)); Hi := Hbound; else @@ -4744,17 +4756,17 @@ -- associated subtype. Insert_Action (N, - Make_Raise_Constraint_Error (Loc, - Condition => -Make_Not_In (Loc, - Left_Opnd => -Convert_To (Base_Type (Etype (Sub)), - Duplicate_Subexpr_Move_Checks (Sub)), - Right_Opnd => -Make_Attribute_Reference (Loc, - Prefix => New_Reference_To (Etype (A), Loc), - Attribute_Name => Name_Range)), - Reason => CE_Index_Check_Failed)); + Make_Raise_Constraint_Error (Loc, +Condition => + Make_Not_In (L
[Ada] New restrictions for the lock-free implementation of protected objects
This patch updates the restrictions of the lock-free implementation. Furthermore, it also catches every error messages issued by the routine Allows_Lock_Free_Implementation. The test below illustrates some of the new restrictions: -- Source -- package Typ is protected Prot with Lock_Free is procedure Test; private Count : Integer := 0; L : Integer := 0; end Prot; end Typ; package body Typ is protected body Prot is procedure Test is type Rec is record I, J : Integer; end record; type Rec_Access is access Rec; IA : Rec_Access := new Rec'(1,2); begin delay 3.0; if Count = 0 then goto Continue; end if; loop Count := Count + IA.J; exit when Count = 10; end loop; <> L := Count + 1; end Test; end Prot; end Typ; --- -- Compilation and Execution -- --- $ gnatmake -q -gnat12 -gnatws typ.adb typ.adb:3:07: body not allowed when Lock_Free given typ.adb:9:29: allocator not allowed typ.adb:12:10: procedure call not allowed typ.adb:15:13: goto statement not allowed typ.adb:18:10: loop not allowed typ.adb:25:10: only one protected component allowed gnatmake: "typ.adb" compilation error Tested on x86_64-pc-linux-gnu, committed on trunk 2012-07-23 Vincent Pucci * sem_ch9.adb (Allows_Lock_Free_Implementation): Flag Lock_Free_Given renames previous flag Complain. Description updated. Henceforth, catch every error messages issued by this routine when Lock_Free_Given is True. Declaration restriction updated: No non-elementary parameter instead (even in parameter) New subprogram body restrictions implemented: No allocator, no address, import or export rep items, no delay statement, no goto statement, no quantified expression and no dereference of access value. Index: exp_ch9.adb === --- exp_ch9.adb (revision 189773) +++ exp_ch9.adb (working copy) @@ -3188,7 +3188,7 @@ Rewrite (Stmt, Make_Implicit_If_Statement (N, - Condition => + Condition => Make_Function_Call (Loc, Name => New_Reference_To (Try_Write, Loc), @@ -3379,9 +3379,9 @@ Make_Object_Renaming_Declaration (Loc, Defining_Identifier => Defining_Identifier (Comp_Decl), -Subtype_Mark => +Subtype_Mark=> New_Occurrence_Of (Comp_Type, Loc), -Name => +Name=> New_Reference_To (Desired_Comp, Loc))); -- Wrap any return or raise statements in Stmts in same the manner Index: sem_ch9.adb === --- sem_ch9.adb (revision 189768) +++ sem_ch9.adb (working copy) @@ -23,6 +23,7 @@ -- -- -- +with Aspects; use Aspects; with Atree;use Atree; with Checks; use Checks; with Debug;use Debug; @@ -68,24 +69,30 @@ function Allows_Lock_Free_Implementation (N: Node_Id; - Complain : Boolean := False) return Boolean; + Lock_Free_Given : Boolean := False) return Boolean; -- This routine returns True iff N satisfies the following list of lock- -- free restrictions for protected type declaration and protected body: -- --1) Protected type declaration -- May not contain entries - -- Component types must support atomic compare and exchange + -- Protected subprogram declarations may not have non-elementary + -- parameters. -- --2) Protected Body -- Each protected subprogram body within N must satisfy: --May reference only one protected component --May not reference non-constant entities outside the protected -- subprogram scope. - --May not reference non-elementary out parameters - --May not contain loop statements or procedure calls + --May not contain address representation items, allocators and + -- quantified expressions. + --May not contain delay, goto, loop and procedure call + -- statements. + --May not contain exported and imported entities + --May not dereference access values --Function calls and attribute references must be static -- - -- If Complain is
Re: [PATCH, frv-linux] Silence warning
Hi JBG, warning: implicit declaration of function ‘frv_ifcvt_machdep_init’ warning: no previous prototype for ‘frv_ifcvt_machdep_init’ oops! gcc/ 2012-07-21 Jan-Benedict Glaw * config/frv/frv-protos.h: Update copyright year, include basic-block.h (for ce_if_block_t). (frv_ifcvt_machdep_init): Declare. Approved - please apply. Cheers Nick
Re: [patch] Profiling infrastructure TLC (1/n)
On Sun, Jul 22, 2012 at 12:40 AM, Steven Bosscher wrote: > Hello, > > This patch cleans up some "interesting" things in GCC's profiling > support. The most significant changes are the removal of > BB_TO_GCOV_INDEX and after_tree_profile. Another visible cleanup is > that -profile-generate no longer sets > flag_value_profile_transformations. > > The rest is mostly just comment updates, because the comments (and the > code, see BB_TO_GCOV_INDEX ;-) have not been maintained very well for > everything that has changed since, oh, tree-ssa was merged? > > For example, in value-prof.c:"the flow graph is annotated with actual > execution counts, which are later propagated into the rtl for > optimization purposes." > > Or before profile.c:branch_prob(): > -/* Instrument and/or analyze program behavior based on program flow graph. > - In either case, this function builds a flow graph for the function being > - compiled. The flow graph is stored in BB_GRAPH. > ... > - (...) In this case, the flow graph is > - annotated with actual execution counts, which are later propagated into > the > - rtl for optimization purposes. > > But (a) branch_prob doesn't build a CFG; (b) the flow graph it doesn't > build is not stored in BB_GRAPH; and (c) the execution counts are not > "propagated into the rtl". > > The whole profiling infrastructure needs a lot of TLC before it looks > somewhat decent again. This is just the first step :-) > > Bootstrapped and tested on powerpc64-unknown-linux-gnu. > Profilebootstrapped and tested on x86_64-unknown-linux-gnu. > OK for trunk? Ok. Thanks, Richard. > Ciao! > Steven
Re: [patch][gcov] Clarify the internals a bit
On Sun, Jul 22, 2012 at 4:34 PM, Steven Bosscher wrote: > Hello, > > While reading up on how gcov/profiling works, I noticed that there are > a lot of places where the notes file is still referred to as the > "basic block graph" file. Also, the gcov manual has not been updated > for -fprofile-dir. The attached patch addresses these issues, so that > the next gcov newbie hopefully has an easier time understanding how > everything fits together. > > Bootstrapped&tested on x86_64-unknown-linux-gnu. OK? Ok. Thanks, Richard. > Ciao! > Steven
Re: [patch] PR53881 - again
On Mon, Jul 23, 2012 at 1:23 AM, Steven Bosscher wrote: > Hello, > > This patch fixes PR53881 by making group_case_labels_stmt look at the > CFG instead of relying on label equality. > > Bootstrapped&tested on powerpc64-unknown-linux-gnu. OK? Ok. Thanks, Richard. > Ciao! > Steven
Re: [PATCH, AArch64] Allow symbol+offset as symbolic constant expression
On 06/07/12 16:31, Ian Bolton wrote: Hi, This patch reduces codesize for cases such as this one: int arr[100]; int foo () { return arr[10]; } Before the patch, the code looked like this: adrp x0, arr add x0, x0, :lo12:arr ldr w0, [x0,40] Now, it looks like this: adrp x0, arr+40 ldr w0, [x0,#:lo12:arr+40] Some workloads have seen up to 1K reduction in code size. OK to commit? Cheers, Ian 2012-07-06 Ian Bolton * gcc/config/aarch64/aarch64.c (aarch64_print_operand): Use aarch64_classify_symbolic_expression for classifying operands. * gcc/config/aarch64/aarch64.c (aarch64_classify_symbolic_expression): New function. * gcc/config/aarch64/aarch64.c (aarch64_symbolic_constant_p): New function. * gcc/config/aarch64/predicates.md (aarch64_valid_symref): Symbol with constant offset is a valid symbol reference. OK
Re: [Test] Fix for PRPR53981
Anyone? Ping. 2012/7/20 Anna Tikhonova > > Hi all, > > I've fixed test which was failing on Android NDK > > testsuite/ChangeLog: > 2012-07-20 Anna Tikhonova > > * gcc.dg/20020201-1.c: Include . > > Patch attached. > > Ok for trunk & 4.7? >
Re: [PATCH, frv-linux] Silence warning
On Mon, 2012-07-23 08:28:53 +0100, nick clifton wrote: > Hi JBG, > > > warning: implicit declaration of function ‘frv_ifcvt_machdep_init’ > > warning: no previous prototype for ‘frv_ifcvt_machdep_init’ > > oops! > > >gcc/ > >2012-07-21 Jan-Benedict Glaw > > * config/frv/frv-protos.h: Update copyright year, > > include basic-block.h (for ce_if_block_t). > > (frv_ifcvt_machdep_init): Declare. > > Approved - please apply. My key isn't set-up for committing to GCC (only for binutils up to now.) Please commit it yourself and I'll apply for commit-after-approval rights for GCC. Thanks, JBG -- Jan-Benedict Glaw jbg...@lug-owl.de +49-172-7608481 Signature of: Warum ist Scheiße braun? ...weil braun schon immer scheiße ist! the second : signature.asc Description: Digital signature
[PATCH, ARM] Skip gcc.dg/torture/stackalign/builtin-apply-2.c for ARM hard-float ABI
Hi, The test case gcc.dg/torture/stackalign/builtin-apply-2.c makes assumptions which cannot be met for __builtin_apply for the ARM hard-float ABI variant. This patch simply skips the test in that case. Tested (stackalign.exp only) for ARMv4t -marm/-mthumb/-mfloat-abi=hard. The previously-failing test gets skipped as expected with the patch. (This is another one that we've had locally for a while.) OK to apply? Julian ChangeLog gcc/testsuite/ * gcc.dg/torture/stackalign/builtin-apply-2.c: Skip for hard-float ARM. Index: gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-2.c === --- gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-2.c (revision 189779) +++ gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-2.c (working copy) @@ -5,6 +5,8 @@ with pre-pushed arguments (e.g. SPARC). */ /* { dg-do run } */ + +/* { dg-skip-if "Variadic funcs use Base AAPCS. Normal funcs use VFP variant." { "arm*-*-*" } { "-mfloat-abi=hard" } { "" } } */ #define INTEGER_ARG 5
Re: [patch] More cleanups for CFG dumping
On Fri, Jul 20, 2012 at 11:28 AM, Richard Guenther wrote: > On Fri, Jul 20, 2012 at 11:02 AM, Steven Bosscher > wrote: >> On Thu, Jul 19, 2012 at 11:09 AM, Richard Guenther >> wrote: >>> Hmm, pp_flush looks like a lot more expensive compared to pp_newline >>> for example in >>> >>> @@ -74,7 +74,7 @@ maybe_init_pretty_print (FILE *file) >>> static void >>> newline_and_indent (pretty_printer *buffer, int spc) >>> { >>> - pp_newline (buffer); >>> + pp_flush (buffer); >>>INDENT (spc); >>> } >>> >>> And I'm pretty sure that newline_and_indent callers that after it directly >>> dump to the stream should be fixed instead. In fact, constant flushing >>> will just make things slow (yes, it's only dumping ...). >> >> Right, it's only dumping. I'm surprised one would care about its >> performance. And the patch actually helps in the debugger also: if for >> some reason a piece of invalid gimple is encountered then at least the >> part that was OK is still dumped. But oh well :-) >> >> I will need this additional patch to avoid test suite failures: >> >> Index: pretty-print.c >> === >> --- pretty-print.c (revision 189705) >> +++ pretty-print.c (working copy) >> @@ -759,6 +759,7 @@ void >> pp_base_newline (pretty_printer *pp) >> { >>obstack_1grow (pp->buffer->obstack, '\n'); >> + pp_needs_newline (pp) = false; >>pp->buffer->line_length = 0; >> } >> >> I suppose that's OK? > > Yes. I also need this one: -- 8< --- Index: gimple-pretty-print.c --- gimple-pretty-print.c (revision 189778) +++ gimple-pretty-print.c (working copy) @@ -2265,6 +2265,7 @@ gimple_dump_bb_buff (pretty_printer *buf } dump_implicit_edges (buffer, bb, indent, flags); + pp_flush (buffer); } -- 8< --- or you get nonsense dumps like: ... ;; basic block 4, loop depth 0 ;;pred: 2 : if (node_3(D) != node_20) ;;succ: 6 ;;5 ;; basic block 5, loop depth 0 ;;pred: 6 ;;4 : goto ; else goto ; ... Will commit as obvious. Ciao! Steven
[PATCH] Use local-decls in aliased vars dumping
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied. Richard. 2012-07-23 Richard Guenther * tree-ssa-alias.c (dump_alias_info): Walk over local decls instead of referenced vars. Index: gcc/tree-ssa-alias.c === --- gcc/tree-ssa-alias.c(revision 189718) +++ gcc/tree-ssa-alias.c(working copy) @@ -378,17 +378,16 @@ stmt_may_clobber_global_p (gimple stmt) void dump_alias_info (FILE *file) { - size_t i; + unsigned i; const char *funcname = lang_hooks.decl_printable_name (current_function_decl, 2); - referenced_var_iterator rvi; tree var; fprintf (file, "\n\nAlias information for %s\n\n", funcname); fprintf (file, "Aliased symbols\n\n"); - FOR_EACH_REFERENCED_VAR (cfun, var, rvi) + FOR_EACH_LOCAL_DECL (cfun, i, var) { if (may_be_aliased (var)) dump_variable (file, var);
Re: [PATCH, ARM] Skip gcc.dg/torture/stackalign/builtin-apply-2.c for ARM hard-float ABI
On 23/07/12 13:17, Julian Brown wrote: > Hi, > > The test case gcc.dg/torture/stackalign/builtin-apply-2.c makes > assumptions which cannot be met for __builtin_apply for the ARM > hard-float ABI variant. This patch simply skips the test in that case. > > Tested (stackalign.exp only) for ARMv4t -marm/-mthumb/-mfloat-abi=hard. > The previously-failing test gets skipped as expected with the patch. > (This is another one that we've had locally for a while.) > > OK to apply? > > Julian > > ChangeLog > > gcc/testsuite/ > * gcc.dg/torture/stackalign/builtin-apply-2.c: Skip for > hard-float ARM. > > > skip-builtin-apply-2-for-hardfloat-arm-2.diff > Hmm, I think this won't work for platforms like fedora/arm, where -mfloat-abi=hard is the default. R. > > Index: gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-2.c > === > --- gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-2.c (revision > 189779) > +++ gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-2.c (working copy) > @@ -5,6 +5,8 @@ > with pre-pushed arguments (e.g. SPARC). */ > > /* { dg-do run } */ > + > +/* { dg-skip-if "Variadic funcs use Base AAPCS. Normal funcs use VFP > variant." { "arm*-*-*" } { "-mfloat-abi=hard" } { "" } } */ > > > #define INTEGER_ARG 5 >
[PATCH, ARM] Split all insns before pool placement (Re: [PATCH, ARM] Fix length attributes for sync.md patterns)
Richard Earnshaw wrote: > >> Hmm, I wonder if we should just unconditionally call split_all_insns() > >> at the start of md_reorg when -O0. This would address your problem, but > >> have the added benefit that the length calculations would be more > >> accurate. We're going to have to split the insns anyway during output, > >> so why not get it over and done with... OK, here's a patch to implement this solution, which does indeed fix my original problem as well. Tested on arm-linux-gnueabi with no regressions. OK for mainline? Thanks, Ulrich ChangeLog: * config/arm/arm.c (arm_reorg): Ensure all insns are split. Index: gcc/config/arm/arm.c === *** gcc/config/arm/arm.c(revision 189459) --- gcc/config/arm/arm.c(working copy) *** arm_reorg (void) *** 13359,13364 --- 13359,13371 if (TARGET_THUMB2) thumb2_reorg (); + /* Ensure all insns that must be split have been split at this point. + Otherwise, the pool placement code below may compute incorrect + insn lengths. Note that when optimizing, all insns have already + been split at this point. */ + if (!optimize) + split_all_insns_noflow (); + minipool_fix_head = minipool_fix_tail = NULL; /* The first insn must always be a note, or the code below won't -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE ulrich.weig...@de.ibm.com
[patch] Move sbitmap dataflow functions from sbitmap.c to cfganal.c
Hello, $SUBJECT because it makes sbitmap.c independent of basic-block.h -- as it should be, given that sbitmap is just a very simple bitmap datatype. Bootstrapped (profiledbootstrapped, actually) and tested on x86_64-unknown-linux-gnu. OK for trunk? Ciao! Steven * sbitmap.h (sbitmap_intersect_of_predsucc, sbitmap_union_of_predsucc): Remove prototypes of non-existing function. (sbitmap_intersect_of_predecessors, sbitmap_intersect_of_successors, sbitmap_union_of_predecessors, sbitmap_union_of_successors): Remove unused defines. (sbitmap_intersection_of_succs, sbitmap_intersection_of_preds, sbitmap_union_of_succs, sbitmap_union_of_preds): Move prototypes to... * basic-block.h: ... here. * sbitmap.c: Do not include basic-block.h. (sbitmap_intersection_of_succs, sbitmap_intersection_of_preds, sbitmap_union_of_succs, sbitmap_union_of_preds): Move functions to... * cfganal.c: ... here. * bt-load.c (compute_out, link_btr_uses): Update for above changes. * gcse.c (compute_code_hoist_vbeinout): Likewise. * lcm.c (compute_antinout_edge, compute_available): Likewise. * Makefile.in: Fix sbitmap.o dependencies. Index: sbitmap.h === --- sbitmap.h (revision 189778) +++ sbitmap.h (working copy) @@ -241,24 +241,6 @@ extern bool sbitmap_a_subset_b_p (const_sbitmap, c extern int sbitmap_first_set_bit (const_sbitmap); extern int sbitmap_last_set_bit (const_sbitmap); -extern void sbitmap_intersect_of_predsucc (sbitmap, sbitmap *, int, - struct int_list **); -#define sbitmap_intersect_of_predecessors sbitmap_intersect_of_predsucc -#define sbitmap_intersect_of_successorssbitmap_intersect_of_predsucc - -extern void sbitmap_union_of_predsucc (sbitmap, sbitmap *, int, - struct int_list **); -#define sbitmap_union_of_predecessors sbitmap_union_of_predsucc -#define sbitmap_union_of_successorssbitmap_union_of_predsucc - -/* Intersection and Union of preds/succs using the new flow graph - structure instead of the pred/succ arrays. */ - -extern void sbitmap_intersection_of_succs (sbitmap, sbitmap *, int); -extern void sbitmap_intersection_of_preds (sbitmap, sbitmap *, int); -extern void sbitmap_union_of_succs (sbitmap, sbitmap *, int); -extern void sbitmap_union_of_preds (sbitmap, sbitmap *, int); - extern void debug_sbitmap (const_sbitmap); extern sbitmap sbitmap_realloc (sbitmap, unsigned int); extern unsigned long sbitmap_popcount(const_sbitmap, unsigned long); Index: basic-block.h === --- basic-block.h (revision 189778) +++ basic-block.h (working copy) @@ -674,6 +674,12 @@ ei_cond (edge_iterator ei, edge *p) #define CLEANUP_CFGLAYOUT 32 /* Do cleanup in cfglayout mode. */ #define CLEANUP_CFG_CHANGED64 /* The caller changed the CFG. */ +/* In cfganal.c */ +extern void sbitmap_intersection_of_succs (sbitmap, sbitmap *, basic_block); +extern void sbitmap_intersection_of_preds (sbitmap, sbitmap *, basic_block); +extern void sbitmap_union_of_succs (sbitmap, sbitmap *, basic_block); +extern void sbitmap_union_of_preds (sbitmap, sbitmap *, basic_block); + /* In lcm.c */ extern struct edge_list *pre_edge_lcm (int, sbitmap *, sbitmap *, sbitmap *, sbitmap *, sbitmap **, Index: sbitmap.c === --- sbitmap.c (revision 189778) +++ sbitmap.c (working copy) @@ -23,15 +23,6 @@ along with GCC; see the file COPYING3. If not see #include "coretypes.h" #include "sbitmap.h" -#ifdef IN_GCC -/* FIXME: sbitmap is just a data structure, but we define dataflow functions - here also. This is conditional on IN_GCC (see second #ifdef IN_GCC - further down). - For now, also only conditionally include basic-block.h, but we should - find a better place for the dataflow functions. Perhaps cfganal.c? */ -#include "basic-block.h" -#endif - #if GCC_VERSION >= 3400 # if HOST_BITS_PER_WIDEST_FAST_INT == HOST_BITS_PER_LONG #define do_popcount(x) __builtin_popcountl(x) @@ -744,184 +735,6 @@ sbitmap_a_and_b_or_c (sbitmap dst, const_sbitmap a *dstp++ = *ap++ & (*bp++ | *cp++); } -#ifdef IN_GCC -/* FIXME: depends on basic-block.h, see comment at start of this file. - - Ironically, the comments before the functions below suggest they do - dataflow using the "new flow graph structures", but that's the *old* - new data structures. The functions receive basic block numbers and - use BASIC_BLOCK(idx) to get the basic block. They should receive - the basic block directly, *sigh*. */ - -/* Set the bitmap DST to the intersection of SRC of successors of - block number BB, using the new flow graph structures. */ - -void -sbitmap_intersectio
Re: [PATCH, frv-linux] Silence warning
Hi JBG, 2012-07-21 Jan-Benedict Glaw * config/frv/frv-protos.h: Update copyright year, include basic-block.h (for ce_if_block_t). (frv_ifcvt_machdep_init): Declare. Approved - please apply. My key isn't set-up for committing to GCC (only for binutils up to now.) Please commit it yourself and I'll apply for commit-after-approval rights for GCC. Ok - I have applied a variant of your patch. I should have noted before that including other headers in *-protos.h is frowned upon. Plus in this case it is not necessary since the parameter to frv_ifcvt_machdep_init is not used. So I just made it a void * and updated frv.c. Cheers Nick gcc/ChangeLog 2012-07-23 Jan-Benedict Glaw Nick Clifton * config/frv/frv-protos.h (frv_ifcvt_machdep_init): Prototype. * config/frv/frv.c (frv_ifcvt_machdep_init): Change type of (unused) parameter to void *.
[PATCH] Fix PR53616
This should fix PR53616, loop distribution can change partition ordering when merging non-builtin partitions again, not honoring read-after-write dependences. The patch simply avoids any change in ordering. Bootstrapped on x86_64-unknown-linux-gnu, testing in progress. Richard. 2012-07-23 Richard Guenther PR tree-optimization/53616 * tree-loop-distribution.c (ldist_gen): Do not change partition ordering when merging partitions. Index: gcc/tree-loop-distribution.c === *** gcc/tree-loop-distribution.c(revision 189777) --- gcc/tree-loop-distribution.c(working copy) *** ldist_gen (struct loop *loop, struct gra *** 1289,1304 nbp = 0; goto ldist_done; } ! for (i = 0; VEC_iterate (partition_t, partitions, i, into); ++i) ! if (!partition_builtin_p (into)) ! break; ! for (++i; VEC_iterate (partition_t, partitions, i, partition); ++i) ! if (!partition_builtin_p (partition)) ! { ! bitmap_ior_into (into->stmts, partition->stmts); ! VEC_ordered_remove (partition_t, partitions, i); ! i--; ! } } else { --- 1289,1313 nbp = 0; goto ldist_done; } ! /* Only fuse adjacent non-builtin partitions, see PR53616. ! ??? Use dependence information to improve partition ordering. */ ! i = 0; ! do ! { ! for (; VEC_iterate (partition_t, partitions, i, into); ++i) ! if (!partition_builtin_p (into)) ! break; ! for (++i; VEC_iterate (partition_t, partitions, i, partition); ++i) ! if (!partition_builtin_p (partition)) ! { ! bitmap_ior_into (into->stmts, partition->stmts); ! VEC_ordered_remove (partition_t, partitions, i); ! i--; ! } ! else ! break; ! } ! while ((unsigned) i < VEC_length (partition_t, partitions)); } else {
Re: [patch] Move sbitmap dataflow functions from sbitmap.c to cfganal.c
On Mon, Jul 23, 2012 at 3:59 PM, Steven Bosscher wrote: > Hello, > > $SUBJECT because it makes sbitmap.c independent of basic-block.h -- as > it should be, given that sbitmap is just a very simple bitmap > datatype. > > Bootstrapped (profiledbootstrapped, actually) and tested on > x86_64-unknown-linux-gnu. OK for trunk? Ok! Thanks, Richard. > Ciao! > Steven
[PATCH, ARM] Add test for ARMv7-M interrupt function dynamic stack realignment
Hi, GCC has had a feature for many years to realign the stack for interrupt-handler functions (marked with "__attribute__((interrupt))") on Cortex-M-series devices (IIRC, this was a workaround for a hardware issue, or perhaps some unforeseen circumstance when the stack could become misaligned in user code): http://gcc.gnu.org/ml/gcc-patches/2006-03/msg00038.html The test case from the above patch unfortunately got mislaid at some point when branches were merged. It still passes on current mainline (using "-mthumb -march=armv7-m" when running tests). I will apply this one as obvious. Thanks, Julian ChangeLog Paul Brook gcc/testsuite/ * g++.dg/other/armv7m-1.c: New test.Index: gcc/testsuite/g++.dg/other/armv7m-1.C === --- gcc/testsuite/g++.dg/other/armv7m-1.C (revision 0) +++ gcc/testsuite/g++.dg/other/armv7m-1.C (revision 0) @@ -0,0 +1,69 @@ +/* { dg-do run { target arm*-*-* } } */ +/* Test Armv7m interrupt routines. */ +#include + +#ifdef __ARM_ARCH_7M__ +void __attribute__((interrupt)) +foo(void) +{ + long long n; + long p; + asm volatile ("" : "=r" (p) : "0" (&n)); + if (p & 4) +abort (); + return; +} + +void __attribute__((interrupt)) +bar(void) +{ + throw 42; +} + +int main() +{ + int a; + int before; + int after; + volatile register int sp asm("sp"); + + asm volatile ("mov %0, sp\n" + "blx %2\n" + "mov %1, sp\n" + : "=&r" (before), "=r" (after) : "r" (foo) + : "memory", "cc", "r0", "r1", "r2", "r3", "ip", "lr"); + if (before != after) +abort(); + asm volatile ("mov %0, sp\n" + "sub sp, sp, #4\n" + "blx %2\n" + "add sp, sp, #4\n" + "mov %1, sp\n" + : "=&r" (before), "=r" (after) : "r" (foo) + : "memory", "cc", "r0", "r1", "r2", "r3", "ip", "lr"); + if (before != after) +abort(); + before = sp; + try +{ + bar(); +} + catch (int i) +{ + if (i != 42) + abort(); +} + catch (...) +{ + abort(); +} + if (before != sp) +abort(); + exit(0); +} +#else +int main() +{ + exit (0); +} +#endif
Re: [Ada] Lock-free implementation of protected objects
Hi Arnaud, On 23 Jul 2012, at 09:02, Arnaud Charlet wrote: > This patch implements a check in the runtime library that determines whether > the current target supports the atomic primitives up to 64 bits. If I understand the name of the flag, it looks like an "all or nothing" for atomic primitives? is that a consequence of the language definition, or simply that it isn't worth spending a lot of effort on 32 bit machines? > This should fix build failures on e.g. powerpc-darwin. almost :-) On a 64-bit processor, the [32 bit] powerpc-darwin kernel is capable of launching 64bit processes. Thus, there is an m64 multi-lib for powerpc-darwin, which is built by default for GCC (and, for that multi-lib, the 64 bit locks are available). At present, bootstrap is failing while building this multi-lib. With the following, bootstrap completed on powerpc-apple-darwin9, and make check-ada shows no new fails. Should I apply it? Iain gcc/ada: * system-darwin-ppc64.ads: Add Support_Atomic_Primitives, set to True. Index: gcc/ada/system-darwin-ppc64.ads === --- gcc/ada/system-darwin-ppc64.ads (revision 189777) +++ gcc/ada/system-darwin-ppc64.ads (working copy) @@ -137,6 +137,7 @@ private Stack_Check_Limits: constant Boolean := False; Support_64_Bit_Divides: constant Boolean := True; Support_Aggregates: constant Boolean := True; + Support_Atomic_Primitives : constant Boolean := True; Support_Composite_Assign : constant Boolean := True; Support_Composite_Compare : constant Boolean := True; Support_Long_Shifts : constant Boolean := True;
Re: [Ada] Lock-free implementation of protected objects
> > This patch implements a check in the runtime library that determines > > whether > > the current target supports the atomic primitives up to 64 bits. > > If I understand the name of the flag, it looks like an "all or nothing" for > atomic primitives? Right. > is that a consequence of the language definition, or simply that it isn't > worth spending a lot of effort on 32 bit machines? The latter for now. > > This should fix build failures on e.g. powerpc-darwin. > > almost :-) > > On a 64-bit processor, the [32 bit] powerpc-darwin kernel is capable of > launching 64bit processes. > Thus, there is an m64 multi-lib for powerpc-darwin, which is built by > default for GCC (and, for that multi-lib, the 64 bit locks are available). At > present, bootstrap is failing while building this multi-lib. > > With the following, bootstrap completed on powerpc-apple-darwin9, and > make check-ada shows no new fails. > Should I apply it? Looks good to me, go ahead, although I'm a bit surprised that you got an error, can you clarify what error you got? > Iain > > gcc/ada: > > * system-darwin-ppc64.ads: Add Support_Atomic_Primitives, > set to True.
Re: [Ada] Lock-free implementation of protected objects
On 23 Jul 2012, at 15:27, Arnaud Charlet wrote: >> With the following, bootstrap completed on powerpc-apple-darwin9, and >> make check-ada shows no new fails. >> Should I apply it? > > Looks good to me, go ahead, although I'm a bit surprised that you got an > error, > can you clarify what error you got? IIRC, that the flag was undefined. If it's important I can revert the fix in my local tree and re-build. Iaim
Re: [Ada] Lock-free implementation of protected objects
On Jul 23, 2012, at 10:32, Iain Sandoe wrote: >> Looks good to me, go ahead, although I'm a bit surprised that you got an >> error, >> can you clarify what error you got? > > IIRC, that the flag was undefined. > If it's important I can revert the fix in my local tree and re-build. > Iaim No need to do that. Indeed, the flag must be defined for all versions of system.ads. Please apply the patch, it really seems to be just an oversight. I'd consider this could even have been fixed under the "obvious" rule. Thanks very much, Iain! -Geert
Re: [Ada] Lock-free implementation of protected objects
> >> With the following, bootstrap completed on powerpc-apple-darwin9, > >> and > >> make check-ada shows no new fails. > >> Should I apply it? > > > > Looks good to me, go ahead, although I'm a bit surprised that you got an > > error, > > can you clarify what error you got? > > IIRC, that the flag was undefined. The compiler should NOT generate an error in such case. Vincent, can you confirm that the compiler will default to False in case the value is not defined in system.ads? If not, then this needs to be fixed. > If it's important I can revert the fix in my local tree and re-build. Given that True is a proper value for darwin x64, your change is fine, but it shouldn't have been needed, since there should be a proper default. Arno
Re: [Ada] Lock-free implementation of protected objects
> >> Looks good to me, go ahead, although I'm a bit surprised that you got an > >> error, > >> can you clarify what error you got? > > > > IIRC, that the flag was undefined. > > If it's important I can revert the fix in my local tree and re-build. > > Iaim > No need to do that. Indeed, the flag must be defined for > all versions of system.ads. No, as we agreed and discussed, the flag does NOT have to be defined for all versions of system.ads, so this is a bug that needs to be fixed (precisely for the issue raised here: we don't want unknown or new ports to be broken by default). > Please apply the patch, it > really seems to be just an oversight. No, it's not just an oversight, and it's also not obvious as shown by this discussion. Arno
Re: [Ada] Lock-free implementation of protected objects
On 07/23/2012 10:43 AM, Arnaud Charlet wrote: With the following, bootstrap completed on powerpc-apple-darwin9, and make check-ada shows no new fails. Should I apply it? Looks good to me, go ahead, although I'm a bit surprised that you got an error, can you clarify what error you got? IIRC, that the flag was undefined. The compiler should NOT generate an error in such case. Vincent, can you confirm that the compiler will default to False in case the value is not defined in system.ads? The swicth is defaulted to be False in Targparm. However, as far as I understood in Targparm, the switch must be present in all system.ads packages but I may be wrong.
Re: [Ada] Lock-free implementation of protected objects
> The swicth is defaulted to be False in Targparm. > However, as far as I understood in Targparm, the switch must be present in > all system.ads packages but I may be wrong. That sounds wrong and isn't how other flags work. Vincent, can you please double check exactly what's happening, and in particular verify that a missing flag in system-.ads will NOT cause an error? Also, I would remove all the default values to False, since they mainly add noise (and create inconsistency for system files that do not have this value set). Arno
Re: [Ada] Lock-free implementation of protected objects
On 23 Jul 2012, at 15:57, Arnaud Charlet wrote: >> The swicth is defaulted to be False in Targparm. >> However, as far as I understood in Targparm, the switch must be present in >> all system.ads packages but I may be wrong. > > That sounds wrong and isn't how other flags work. > > Vincent, can you please double check exactly what's happening, and in > particular > verify that a missing flag in system-.ads will NOT cause an error? > > Also, I would remove all the default values to False, since they mainly add > noise (and create inconsistency for system files that do not have this > value set). FWIW, I checked the build transcript for the failed case: s-atopri.adb:40:10: "Support_Atomic_Primitives" is undefined (more references follow) make[8]: *** [s-atopri.o] Error 1 cheers Iain
Re: [Ada] Lock-free implementation of protected objects
On 07/23/2012 11:03 AM, Iain Sandoe wrote: On 23 Jul 2012, at 15:57, Arnaud Charlet wrote: That sounds wrong and isn't how other flags work. Vincent, can you please double check exactly what's happening, and in particular verify that a missing flag in system-.ads will NOT cause an error? Also, I would remove all the default values to False, since they mainly add noise (and create inconsistency for system files that do not have this value set). FWIW, I checked the build transcript for the failed case: s-atopri.adb:40:10: "Support_Atomic_Primitives" is undefined (more references follow) make[8]: *** [s-atopri.o] Error 1 cheers Iain Just got the same error... investigating
Re: [Ada] Lock-free implementation of protected objects
On Jul 23, 2012, at 10:24, Iain Sandoe wrote: >> This patch implements a check in the runtime library that determines whether >> the current target supports the atomic primitives up to 64 bits. > > If I understand the name of the flag, it looks like an "all or nothing" for > atomic primitives? > is that a consequence of the language definition, or simply that it isn't > worth spending a lot of effort on 32 bit machines? There is nothing related to the language definition here, as these are not standardized packages, but part of the implementation. Attempts to use them directly from user programs will result in warnings. There are a few issues. We really don't want to have different versions of the spec for different targets. Rather, we'd have functions that either raise an exception or use a lock-based implementation if the target lacks the required capabilities. The system-specific boolean is a mostly a method that allows us to "switch off" our use of lock-free protected types on a per system basis. This avoids unnecessary instability in less commonly used platforms while we're enhancing this new capability. IIUC, all ports are supposed to implement the atomic built-ins. If they are not supported in hardware, there should be a library function for it that uses locking. The problem we're trying to address is builds failing because of undefined references to __atomic_* functions. I could also have used __atomic_always_lock_free, which is better in many ways, but we also need to know in the front end what expansion to use for protected types. My initial thought was to just have the front end build some trees calling __atomic_always_lock_free and see if they fold to True. However, this was considered undesirable. The alternative would be to have the front end call can_compare_and_swap_p(), but that would have the front end depend on rtl.h, which even I understand is bad. Probably can_compare_and_swap_p() should be moved to a better place, so the front end can use it directly. As I felt it was important to address the failures quickly, we used the current approach. -Geert
Re: [Ada] Lock-free implementation of protected objects
>> FWIW, I checked the build transcript for the failed case: >> >> s-atopri.adb:40:10: "Support_Atomic_Primitives" is undefined (more >> references follow) >> make[8]: *** [s-atopri.o] Error 1 >> >> cheers >> Iain > > Just got the same error... investigating Ah, so the issue is not in the compiler/targpam, but in a direct use in the run-time, which is wrong as per previous discussions: we cannot rely on Support_Atomic_Primitives to be present in all system files. Arno
Re: [Ada] Lock-free implementation of protected objects
On Jul 23, 2012, at 10:45, Arnaud Charlet wrote: > No, as we agreed and discussed, the flag does NOT have to be defined for all > versions of system.ads, so this is a bug that needs to be fixed (precisely > for the issue raised here: we don't want unknown or new ports to be broken > by default). Having a default can't work, as s-atopri.adb needs access to the flag. Only the front end itself can use a default, not the run time. -Geert
Re: [Ada] Lock-free implementation of protected objects
> Having a default can't work, as s-atopri.adb needs access to the flag. > Only the front end itself can use a default, not the run time. Well, this means the current design is broken and s-atopri.adb needs to be modified. As we discussed, we cannot assume that System.Support_Atomic_Primitives exists, since there will always be some target system*.ads files around that don't have this flag (as shown by this discussion). For a run-time (as opposed to compiler) parameter, s-parame is probably a better place to start from, possibly using a separate. Arno
Re: [PATCH, ARM] Skip gcc.dg/torture/stackalign/builtin-apply-2.c for ARM hard-float ABI
On Mon, 23 Jul 2012 14:40:59 +0100 Richard Earnshaw wrote: > On 23/07/12 13:17, Julian Brown wrote: > > Hi, > > > > The test case gcc.dg/torture/stackalign/builtin-apply-2.c makes > > assumptions which cannot be met for __builtin_apply for the ARM > > hard-float ABI variant. This patch simply skips the test in that > > case. > > > > Tested (stackalign.exp only) for ARMv4t > > -marm/-mthumb/-mfloat-abi=hard. The previously-failing test gets > > skipped as expected with the patch. (This is another one that we've > > had locally for a while.) > > Hmm, I think this won't work for platforms like fedora/arm, where > -mfloat-abi=hard is the default. Yes, you're probably right. Here's a new version, which still seems to work for my test environment. I'm not prepared to test a compiler which has the hard-float ABI turned on by default, but I think this should work in theory. (I didn't find an existing check_effective_target_ function suitable for this purpose, so I had to add one.) OK? Julian ChangeLog gcc/testsuite/ * lib/target-supports.exp (check_effective_target_arm_hf_eabi): New. * gcc.dg/torture/stackalign/builtin-apply-2.c: Skip for hard-float ARM. Index: gcc/testsuite/lib/target-supports.exp === --- gcc/testsuite/lib/target-supports.exp (revision 189786) +++ gcc/testsuite/lib/target-supports.exp (working copy) @@ -2341,6 +2341,19 @@ proc check_effective_target_arm_eabi { } }] } +# Return 1 if this is an ARM target that adheres to the hard-float variant of +# the ABI for the ARM Architecture (e.g. -mfloat-abi=hard). + +proc check_effective_target_arm_hf_eabi { } { +return [check_no_compiler_messages arm_hf_eabi object { + #if !defined(__ARM_EABI__) || !defined(__ARM_PCS_VFP) + #error not hard-float EABI + #else + int dummy; + #endif +}] +} + # Return 1 if this is an ARM target supporting -mcpu=iwmmxt. # Some multilibs may be incompatible with this option. Index: gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-2.c === --- gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-2.c (revision 189786) +++ gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-2.c (working copy) @@ -5,6 +5,8 @@ with pre-pushed arguments (e.g. SPARC). */ /* { dg-do run } */ + +/* { dg-skip-if "Variadic funcs use Base AAPCS. Normal funcs use VFP variant." { arm_hf_eabi } } */ #define INTEGER_ARG 5
[PATCH, i386] Further improvements to PR 53961
Hello! Attached patch further improves ix86_decompose_address to allow (zero_extend:DI (subreg:SI (...))) addresses and prevent zero extended CONST_INT operands (as was previously the case with LEA operands only). This improvement allows us to put quite some asserts to strategic places, in order to detect invalid addresses before they generate invalid code. 2012-07-23 Uros Bizjak PR target/53961 * config/i386/i386.md (*lea): Add asserts to detect invalid addresses. * config/i386/i386.c (ix86_print_operand_address): Ditto. (ix86_decompose_address): Allow (zero_extend:DI (subreg:SI (...))) addresses. Prevent zero extensions of CONST_INT operands. Tested on x86_64-pc-linux-gnu {,-m32} and committed to mainline SVN. I will again watch x32 autotesters for possible breakage. Uros. Index: config/i386/i386.md === --- config/i386/i386.md (revision 189786) +++ config/i386/i386.md (working copy) @@ -5458,10 +5458,19 @@ rtx addr = operands[1]; if (GET_CODE (addr) == SUBREG) -return "lea{l}\t{%E1, %0|%0, %E1}"; +{ + gcc_assert (TARGET_64BIT); + gcc_assert (mode == SImode); + gcc_assert (GET_MODE (SUBREG_REG (addr)) == DImode); + return "lea{l}\t{%E1, %0|%0, %E1}"; +} else if (GET_CODE (addr) == ZERO_EXTEND || GET_CODE (addr) == AND) -return "lea{l}\t{%E1, %k0|%k0, %E1}"; +{ + gcc_assert (TARGET_64BIT); + gcc_assert (mode == DImode); + return "lea{l}\t{%E1, %k0|%k0, %E1}"; +} else return "lea{}\t{%E1, %0|%0, %E1}"; } Index: config/i386/i386.c === --- config/i386/i386.c (revision 189786) +++ config/i386/i386.c (working copy) @@ -11576,22 +11576,17 @@ ix86_decompose_address (rtx addr, struct ix86_addr int retval = 1; enum ix86_address_seg seg = SEG_DEFAULT; - /* Allow SImode subregs of DImode addresses, - they will be emitted with addr32 prefix. */ - if (TARGET_64BIT && GET_MODE (addr) == SImode) -{ - if (GET_CODE (addr) == SUBREG - && GET_MODE (XEXP (addr, 0)) == DImode) - addr = SUBREG_REG (addr); -} - /* Allow zero-extended SImode addresses, they will be emitted with addr32 prefix. */ - else if (TARGET_64BIT && GET_MODE (addr) == DImode) + if (TARGET_64BIT && GET_MODE (addr) == DImode) { if (GET_CODE (addr) == ZERO_EXTEND && GET_MODE (XEXP (addr, 0)) == SImode) - addr = XEXP (addr, 0); + { + addr = XEXP (addr, 0); + if (CONST_INT_P (addr)) + return 0; + } else if (GET_CODE (addr) == AND && const_32bit_mask (XEXP (addr, 1), DImode)) { @@ -11600,7 +11595,11 @@ ix86_decompose_address (rtx addr, struct ix86_addr /* Adjust SUBREGs. */ if (GET_CODE (addr) == SUBREG && GET_MODE (SUBREG_REG (addr)) == SImode) - addr = SUBREG_REG (addr); + { + addr = SUBREG_REG (addr); + if (CONST_INT_P (addr)) + return 0; + } else if (GET_MODE (addr) == DImode) addr = gen_rtx_SUBREG (SImode, addr, 0); else if (GET_MODE (addr) != VOIDmode) @@ -11608,6 +11607,19 @@ ix86_decompose_address (rtx addr, struct ix86_addr } } + /* Allow SImode subregs of DImode addresses, + they will be emitted with addr32 prefix. */ + if (TARGET_64BIT && GET_MODE (addr) == SImode) +{ + if (GET_CODE (addr) == SUBREG + && GET_MODE (SUBREG_REG (addr)) == DImode) + { + addr = SUBREG_REG (addr); + if (CONST_INT_P (addr)) + return 0; + } +} + if (REG_P (addr)) base = addr; else if (GET_CODE (addr) == SUBREG) @@ -14765,14 +14777,22 @@ ix86_print_operand_address (FILE *file, rtx addr) else { /* Print SImode register names to force addr32 prefix. */ - if (TARGET_64BIT - && (GET_CODE (addr) == SUBREG - || GET_CODE (addr) == ZERO_EXTEND - || GET_CODE (addr) == AND)) + if (GET_CODE (addr) == SUBREG) { + gcc_assert (TARGET_64BIT); + gcc_assert (GET_MODE (addr) == SImode); + gcc_assert (GET_MODE (SUBREG_REG (addr)) == DImode); gcc_assert (!code); code = 'l'; } + else if (GET_CODE (addr) == ZERO_EXTEND + || GET_CODE (addr) == AND) + { + gcc_assert (TARGET_64BIT); + gcc_assert (GET_MODE (addr) == DImode); + gcc_assert (!code); + code = 'l'; + } if (ASSEMBLER_DIALECT == ASM_ATT) {
[PATCH] PR target/53633; disable return value warnings for naked functions
This is a revised version of Paul Brook's patch from two years ago: http://gcc.gnu.org/ml/gcc-patches/2010-06/msg01088.html I've updated the patch per the review comments from that time, and also extended it to handle a similar warning from the C++ front end. I have so far only tested this on arm-none-eabi and by bootstrapping and regression-testing x86_64-linux-gnu native. I'm not set up to test on spu, rx, avr, or mcore, but I'm thinking that this needs at least an mcore build and hand-testing of the new compilation test cases due to the removal of the existing hack for this problem in that backend. Nick, you're listed as mcore port maintainer; can you help? -Sandra 2012-07-23 Sandra Loosemore Paul Brook PR target/53633 gcc/ * target.def (warn_func_return): New hook. * doc/tm.texi.in (TARGET_WARN_FUNC_RETURN): New hook. * doc/tm.texi: Regenerate. * target.h (gcc_target): Add warn_func_return. * ipa-pure-const.c (warn_function_noreturn): Check targetm.warn_func_return. * tree-cfg.h (execute_warn_function_return): Likewise. * config/spu/spu.c (spu_warn_func_return): New. (TARGET_WARN_FUNC_RETURN): Define. * config/rx/rx.c (rx_warn_func_return): New. (TARGET_WARN_FUNC_RETURN): Define. * config/avr/avr.c (avr_warn_func_return): New. (TARGET_WARN_FUNC_RETURN): Define. * config/arm/arm.c (arm_warn_func_return): New. (TARGET_WARN_FUNC_RETURN): Define. * config/mcore/mcore.c (mcore_warn_func_return): New. (TARGET_WARN_FUNC_RETURN): Define. (saved_warn_return_type, saved_warn_return_type_count): Remove. (mcore_reorg, mcore_handle_naked_attribute): Remove warn_return hack. gcc/cp/ * decl.c (finish_function): Check targetm.warn_func_return. gcc/testsuite/ * gcc.target/arm/naked-3.c: New test. * g++.dg/ext/attr-naked.C: New test. Index: gcc/target.def === --- gcc/target.def (revision 189734) +++ gcc/target.def (working copy) @@ -2710,6 +2710,15 @@ DEFHOOK void, (struct hard_reg_set_container *), NULL) +/* For targets that have attributes that can affect whether a + function's return statements need checking. For instance a 'naked' + function attribute. */ +DEFHOOK +(warn_func_return, + "True if a function's return statements should be checked for matching the function's return type. This includes checking for falling off the end of a non-void function. Return false if no such check should be made.", + bool, (tree), + hook_bool_tree_true) + /* Determine the type of unwind info to emit for debugging. */ DEFHOOK (debug_unwind_info, Index: gcc/doc/tm.texi.in === --- gcc/doc/tm.texi.in (revision 189734) +++ gcc/doc/tm.texi.in (working copy) @@ -4918,6 +4918,8 @@ FRAME_POINTER_REGNUM, ARG_POINTER_REGNUM @hook TARGET_SET_UP_BY_PROLOGUE +@hook TARGET_WARN_FUNC_RETURN + @node Stack Smashing Protection @subsection Stack smashing protection @cindex stack smashing protection Index: gcc/doc/tm.texi === --- gcc/doc/tm.texi (revision 189734) +++ gcc/doc/tm.texi (working copy) @@ -4977,6 +4977,10 @@ FRAME_POINTER_REGNUM, ARG_POINTER_REGNUM This hook should add additional registers that are computed by the prologue to the hard regset for shrink-wrapping optimization purposes. @end deftypefn +@deftypefn {Target Hook} bool TARGET_WARN_FUNC_RETURN (tree) +True if a function's return statements should be checked for matching the function's return type. This includes checking for falling off the end of a non-void function. Return false if no such check should be made. +@end deftypefn + @node Stack Smashing Protection @subsection Stack smashing protection @cindex stack smashing protection Index: gcc/ipa-pure-const.c === --- gcc/ipa-pure-const.c (revision 189734) +++ gcc/ipa-pure-const.c (working copy) @@ -186,7 +186,8 @@ void warn_function_noreturn (tree decl) { static struct pointer_set_t *warned_about; - if (!lang_hooks.missing_noreturn_ok_p (decl)) + if (!lang_hooks.missing_noreturn_ok_p (decl) + && targetm.warn_func_return (decl)) warned_about = suggest_attribute (OPT_Wsuggest_attribute_noreturn, decl, true, warned_about, "noreturn"); Index: gcc/tree-cfg.c === --- gcc/tree-cfg.c (revision 189734) +++ gcc/tree-cfg.c (working copy) @@ -40,6 +40,7 @@ along with GCC; see the file COPYING3. #include "value-prof.h" #include "pointer-set.h" #include "tree-inline.h" +#include "target.h" /* This file contains functions for building the Control Flow Graph (CFG) for a function tree. */ @@ -7613,6 +7614,9 @@ execute
Re: [PATCH, ARM] Skip gcc.dg/torture/stackalign/builtin-apply-2.c for ARM hard-float ABI
On 23 July 2012 16:41, Julian Brown wrote: > On Mon, 23 Jul 2012 14:40:59 +0100 > Richard Earnshaw wrote: > >> On 23/07/12 13:17, Julian Brown wrote: >> > Hi, >> > >> > The test case gcc.dg/torture/stackalign/builtin-apply-2.c makes >> > assumptions which cannot be met for __builtin_apply for the ARM >> > hard-float ABI variant. This patch simply skips the test in that >> > case. >> > >> > Tested (stackalign.exp only) for ARMv4t >> > -marm/-mthumb/-mfloat-abi=hard. The previously-failing test gets >> > skipped as expected with the patch. (This is another one that we've >> > had locally for a while.) >> >> Hmm, I think this won't work for platforms like fedora/arm, where >> -mfloat-abi=hard is the default. > > Yes, you're probably right. Here's a new version, which still seems to > work for my test environment. I'm not prepared to test a compiler which > has the hard-float ABI turned on by default, but I think this should > work in theory. > > (I didn't find an existing check_effective_target_ function > suitable for this purpose, so I had to add one.) Unfortunately arm_hard_vfp_ok doesn't serve this purpose. This should be documented in doc/sourcebuild.texi.( I will note that a number of new effective_targets for the ARM port haven't made it in there but that's a subject for a future patch but it would be better if we got this one right :) ) Ok with appropriate documentation to sourcebuild.texi and checking that the documentation builds fine. regards, Ramana > > OK? > > Julian > > ChangeLog > > gcc/testsuite/ > * lib/target-supports.exp (check_effective_target_arm_hf_eabi): New. > * gcc.dg/torture/stackalign/builtin-apply-2.c: Skip for > hard-float ARM.
RE: [PATCH] Decimal Floating-Point (libbid) for GNU/Hurd
Hello Thomas, Just a follow-up - have those changes been made? Thank you, Marius Cornea -Original Message- From: H.J. Lu [mailto:hjl.to...@gmail.com] Sent: Saturday, June 16, 2012 7:35 AM To: Thomas Schwinge Cc: decimalfp; gcc-patches@gcc.gnu.org Subject: Re: [PATCH] Decimal Floating-Point (libbid) for GNU/Hurd On Sat, Jun 16, 2012 at 7:32 AM, Thomas Schwinge wrote: > Hi! > > Intel folks, the bid_functions.h change is for you, that one plus the > other changes are for GCC. > > libgcc/config/libbid/ > * bid_functions.h: Check for __GLIBC__ additionally to LINUX > when > defining format specifiers. > Looks OK to me. Thanks. -- H.J.
Re: [PATCH, ARM] Split all insns before pool placement (Re: [PATCH, ARM] Fix length attributes for sync.md patterns)
On 23/07/12 14:57, Ulrich Weigand wrote: > Richard Earnshaw wrote: Hmm, I wonder if we should just unconditionally call split_all_insns() at the start of md_reorg when -O0. This would address your problem, but have the added benefit that the length calculations would be more accurate. We're going to have to split the insns anyway during output, so why not get it over and done with... > > OK, here's a patch to implement this solution, which does indeed fix my > original problem as well. > > Tested on arm-linux-gnueabi with no regressions. > > OK for mainline? > > Thanks, > Ulrich > > > ChangeLog: > > * config/arm/arm.c (arm_reorg): Ensure all insns are split. > > Index: gcc/config/arm/arm.c > === > *** gcc/config/arm/arm.c (revision 189459) > --- gcc/config/arm/arm.c (working copy) > *** arm_reorg (void) > *** 13359,13364 > --- 13359,13371 > if (TARGET_THUMB2) > thumb2_reorg (); > > + /* Ensure all insns that must be split have been split at this point. > + Otherwise, the pool placement code below may compute incorrect > + insn lengths. Note that when optimizing, all insns have already > + been split at this point. */ > + if (!optimize) > + split_all_insns_noflow (); > + > minipool_fix_head = minipool_fix_tail = NULL; > > /* The first insn must always be a note, or the code below won't > > OK. R.
Re: [PATCH, ARM] Split all insns before pool placement
Richard Earnshaw wrote: > On 23/07/12 14:57, Ulrich Weigand wrote: > > * config/arm/arm.c (arm_reorg): Ensure all insns are split. > OK. Checked in now. Is this OK for 4.7 as well? Bye, Ulrich -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE ulrich.weig...@de.ibm.com
[cxx-conversion] Update hash-table to new coding conventions. (issue6430066)
Change new C++ code to follow the new C++ coding conventions. This patch is part one, which changes to out-of-line method definitions and does other minor changes. Part two will fix the spacing problems. The two-part approach makes diffs sensible. Index: gcc/ChangeLog.cxx-conversion 2012-07-20 Lawrence Crowl * hash-table.h (xcallocator::control_alloc): Move definition out of class. (xcallocator::data_alloc): Likewise. (xcallocator::control_free): Likewise. (xcallocator::data_free): Likewise. (struct hash_table): Use class keyword. (hash_table::hash_table): Move definition out of line. (hash_table::is_created): Likewise. (hash_table::find): Likewise. (hash_table::find_slot): Likewise. (hash_table::remove_elt): Likewise. (hash_table::size): Likewise. (hash_table::elements): Likewise. (hash_table::collisions): Likewise. (hash_table::create): Put method name on same line as class qualifier. (hash_table::dispose): Likewise. (hash_table::expand): Likewise. (hash_table::empty): Likewise. Index: gcc/hash-table.h === --- gcc/hash-table.h(revision 189670) +++ gcc/hash-table.h(working copy) @@ -36,30 +36,43 @@ along with GCC; see the file COPYING3. template struct xcallocator { + static Type *control_alloc (size_t count); + static Type *data_alloc (size_t count); + static void control_free (Type *memory); + static void data_free (Type *memory); +}; + /* Allocate memory for COUNT control blocks. */ - static Type *control_alloc (size_t count) +template +inline Type * +xcallocator ::control_alloc (size_t count) { return static_cast (xcalloc (count, sizeof (Type))); } - + /* Allocate memory for COUNT data blocks. */ - static Type *data_alloc (size_t count) +template +inline Type * +xcallocator ::data_alloc (size_t count) { return static_cast (xcalloc (count, sizeof (Type))); } /* Free memory for control blocks. */ - static void control_free (Type *memory) +template +inline void +xcallocator ::control_free (Type *memory) { return ::free (memory); } + /* Free memory for data blocks. */ - static void data_free (Type *memory) +template +inline void +xcallocator ::data_free (Type *memory) { return ::free (memory); } - -}; /* A common function for hashing a CANDIDATE typed pointer. */ @@ -182,27 +195,34 @@ template class Allocator = xcallocator> -struct hash_table +class hash_table { private: hash_table_control *htab; - Element **find_empty_slot_for_expand (hashval_t hash); void expand (); public: + hash_table (); void create (size_t initial_slots); + bool is_created (); void dispose (); + Element *find (Element *comparable); Element *find_with_hash (Element *comparable, hashval_t hash); + Element **find_slot (Element *comparable, enum insert_option insert); Element **find_slot_with_hash (Element *comparable, hashval_t hash, enum insert_option insert); void empty (); void clear_slot (Element **slot); + void remove_elt (Element *comparable); void remove_elt_with_hash (Element *comparable, hashval_t hash); + size_t size(); + size_t elements(); + double collisions(); template @@ -211,11 +231,18 @@ public: template void traverse (Argument argument); +}; /* Construct the hash table. The only useful operation next is create. */ - hash_table () +template class Allocator> +inline +hash_table ::hash_table () : htab (NULL) { } @@ -223,7 +250,13 @@ public: /* See if the table has been created, as opposed to constructed. */ - bool is_created () +template class Allocator> +inline bool +hash_table ::is_created () { return htab != NULL; } @@ -231,7 +264,13 @@ public: /* Like find_with_hash, but compute the hash value from the element. */ - Element *find (Element *comparable) +template class Allocator> +inline Element * +hash_table ::find (Element *comparable) { return find_with_hash (comparable, Hash (comparable)); } @@ -239,7 +278,14 @@ public: /* Like find_slot_with_hash, but compute the hash value from the element. */ - Element **find_slot (Element *comparable, enum insert_option insert) +template class Allocator> +inline Element ** +hash_table +::find_slot (Element *comparable, enum insert_option insert) { return find_slot_with_hash (comparable, Hash (comparable), insert); } @@ -247,7 +293,14 @@ public: /* Like remove_elt_with_hash, but compute the hash value from the element. */ - void remove_elt (Element *comparable) +template class Allocator> +inline void +hash_table +::remove_elt (Element *comparable) { remove_elt_with_hash (comparable, Hash (comparable)); } @@ -256,7 +309,13 @@ public: /* Return the current size of this
Re: [Ada] Lock-free implementation of protected objects
On Jul 23, 2012, at 11:21, Geert Bosch wrote: > On Jul 23, 2012, at 10:45, Arnaud Charlet wrote: >> No, as we agreed and discussed, the flag does NOT have to be defined for all >> versions of system.ads, so this is a bug that needs to be fixed (precisely >> for the issue raised here: we don't want unknown or new ports to be broken >> by default). > > Having a default can't work, as s-atopri.adb needs access to the flag. > Only the front end itself can use a default, not the run time. While currently the flag is needed, I agree with you that this is undesirable. The only way to avoid this is to have a type attribute, such as T'Atomic_Always_Lock_Free that is statically True if T is known to be supported for atomic operations. This would be similar to the atomic built-in __atomic_always_lock_free function, but initially based on the value of the system constant (as well as size/alignment of the type). Eventually, we should be able to query this directly from the back end. Regardless, the situation as of now is that system.ads must define the flag, so right now Iain's patch is correct and fixes a build failure. As soon as the attribute is implemented, we can remove the system flags on systems where it is set to False. -Geert
Re: [PATCH, ARM] Split all insns before pool placement
On 23/07/12 18:29, Ulrich Weigand wrote: > Richard Earnshaw wrote: >> On 23/07/12 14:57, Ulrich Weigand wrote: >>> * config/arm/arm.c (arm_reorg): Ensure all insns are split. >> OK. > > Checked in now. Is this OK for 4.7 as well? > > Bye, > Ulrich > Leave it a couple of days, just in case something odd gets thrown up in testing. R.
[PATCH, i386]: Make ix86_lea_outperform static and cleanup LEA split helpers
Hello! No functional changes. 2012-07-23 Uros Bizjak * config/i386/i386-protos.c (ix86_lea_outperforms): Remove prototype. * config/i386/i386.c (ix86_lea_outperforms): Make static. Make split_cost argument signed. (ix86_avoid_lea_for_add): Cleanup. (ix86_use_lea_for_mov): Use INVALID_REGNUM instead of -1. (ix86_avoid_lea_for_addr): Ditto. Make split_cost signed. Use gen_lowpart instead of gen_rtx_SUBREG. Cleanup. Tested on x86_64-pc-linux-gnu {,-m32} configure with --with-arch=core2 --with-cpu=atom, committed to mainline SVN. Uros. Index: i386.c === --- i386.c (revision 189787) +++ i386.c (working copy) @@ -16805,9 +16805,9 @@ distance_agu_use (unsigned int regno0, rtx insn) over a sequence of instructions. Instructions sequence has SPLIT_COST cycles higher latency than lea latency. */ -bool +static bool ix86_lea_outperforms (rtx insn, unsigned int regno0, unsigned int regno1, - unsigned int regno2, unsigned int split_cost) + unsigned int regno2, int split_cost) { int dist_define, dist_use; @@ -16880,9 +16880,7 @@ ix86_ok_to_clobber_flags (rtx insn) bool ix86_avoid_lea_for_add (rtx insn, rtx operands[]) { - unsigned int regno0 = true_regnum (operands[0]); - unsigned int regno1 = true_regnum (operands[1]); - unsigned int regno2 = true_regnum (operands[2]); + unsigned int regno0, regno1, regno2; /* Check if we need to optimize. */ if (!TARGET_OPT_AGU || optimize_function_for_size_p (cfun)) @@ -16892,6 +16890,10 @@ ix86_avoid_lea_for_add (rtx insn, rtx operands[]) if (!ix86_ok_to_clobber_flags(insn)) return false; + regno0 = true_regnum (operands[0]); + regno1 = true_regnum (operands[1]); + regno2 = true_regnum (operands[2]); + /* We need to split only adds with non destructive destination operand. */ if (regno0 == regno1 || regno0 == regno2) @@ -16906,8 +16908,7 @@ ix86_avoid_lea_for_add (rtx insn, rtx operands[]) bool ix86_use_lea_for_mov (rtx insn, rtx operands[]) { - unsigned int regno0; - unsigned int regno1; + unsigned int regno0, regno1; /* Check if we need to optimize. */ if (!TARGET_OPT_AGU || optimize_function_for_size_p (cfun)) @@ -16920,7 +16921,7 @@ ix86_use_lea_for_mov (rtx insn, rtx operands[]) regno0 = true_regnum (operands[0]); regno1 = true_regnum (operands[1]); - return ix86_lea_outperforms (insn, regno0, regno1, -1, 0); + return ix86_lea_outperforms (insn, regno0, regno1, INVALID_REGNUM, 0); } /* Return true if we need to split lea into a sequence of @@ -16929,10 +16930,8 @@ ix86_use_lea_for_mov (rtx insn, rtx operands[]) bool ix86_avoid_lea_for_addr (rtx insn, rtx operands[]) { - unsigned int regno0 = true_regnum (operands[0]) ; - unsigned int regno1 = -1; - unsigned int regno2 = -1; - unsigned int split_cost = 0; + unsigned int regno0, regno1, regno2; + int split_cost; struct ix86_address parts; int ok; @@ -16957,11 +16956,17 @@ ix86_avoid_lea_for_addr (rtx insn, rtx operands[]) if (parts.disp && flag_pic && !LEGITIMATE_PIC_OPERAND_P (parts.disp)) return false; + regno0 = true_regnum (operands[0]) ; + regno1 = INVALID_REGNUM; + regno2 = INVALID_REGNUM; + if (parts.base) regno1 = true_regnum (parts.base); if (parts.index) regno2 = true_regnum (parts.index); + split_cost = 0; + /* Compute how many cycles we will add to execution time if split lea into a sequence of instructions. */ if (parts.base || parts.index) @@ -17021,27 +17026,31 @@ ix86_emit_binop (enum rtx_code code, enum machine_ extern void ix86_split_lea_for_addr (rtx operands[], enum machine_mode mode) { - unsigned int regno0 = true_regnum (operands[0]) ; - unsigned int regno1 = INVALID_REGNUM; - unsigned int regno2 = INVALID_REGNUM; + unsigned int regno0, regno1, regno2; struct ix86_address parts; - rtx tmp; + rtx target, tmp; int ok, adds; ok = ix86_decompose_address (operands[1], &parts); gcc_assert (ok); + target = operands[0]; + + regno0 = true_regnum (target); + regno1 = INVALID_REGNUM; + regno2 = INVALID_REGNUM; + if (parts.base) { if (GET_MODE (parts.base) != mode) - parts.base = gen_rtx_SUBREG (mode, parts.base, 0); + parts.base = gen_lowpart (mode, parts.base); regno1 = true_regnum (parts.base); } if (parts.index) { if (GET_MODE (parts.index) != mode) - parts.index = gen_rtx_SUBREG (mode, parts.index, 0); + parts.index = gen_lowpart (mode, parts.index); regno2 = true_regnum (parts.index); } @@ -17057,41 +17066,41 @@ ix86_split_lea_for_addr (rtx operands[], enum mach gcc_assert (regno2 != regno0); for (adds = parts.scale; adds > 0; adds--) - ix86_emit_binop (PLUS, mode, operands[0], parts.index); + ix86_emit_binop (PLUS, mode, target, parts.in
Re: [Patch, fortran] PR44354 implied-do-loop array constructors using the induction variable in the bounds
On 23/07/2012 07:58, Tobias Burnus wrote: > Mikael Morin wrote: >> Here is another attempt. >> I moved the diagnostic code from gfc_resolve_iterator to >> resolve_array_list, so that it doesn't trigger for do loops. >> Regression test in progress. OK? > > The patch looks OK: > > Though, I wonder why you only get a warning (which is fine); I thought > that -std=gnu (the default) – and, in particular, in combination with > -pedantic (test-suite default) – will give an error for > gfc_notify_standard, not a warning. > Well, no; it passed the test-suite. :-) options.c's set_default_std_flags explicitely allows legacy stuff: static void set_default_std_flags (void) { gfc_option.allow_std = GFC_STD_F95_OBS | GFC_STD_F95_DEL | GFC_STD_F2003 | GFC_STD_F2008 | GFC_STD_F95 | GFC_STD_F77 | GFC_STD_F2008_OBS | GFC_STD_F2008_TS | GFC_STD_GNU | GFC_STD_LEGACY; gfc_option.warn_std = GFC_STD_F95_DEL | GFC_STD_LEGACY; } and the references to pedantic in options.c only increase warnings (see gfc_post_options): /* If -pedantic, warn about the use of GNU extensions. */ if (pedantic && (gfc_option.allow_std & GFC_STD_GNU) != 0) gfc_option.warn_std |= GFC_STD_GNU; /* -std=legacy -pedantic is effectively -std=gnu. */ if (pedantic && (gfc_option.allow_std & GFC_STD_LEGACY) != 0) gfc_option.warn_std |= GFC_STD_F95_OBS | GFC_STD_F95_DEL | GFC_STD_LEGACY; Thanks for the review. Mikael
Re: [patch] Move lowering of switches to bit tests to GIMPLE
On Sun, Jul 1, 2012 at 11:58 AM, Richard Guenther wrote: > We have to think about the point in the pass pipeline where we want to do > this (and the rest of) lowering. At the moment switch-conversion runs before > profile-data is read and thus cannot do a very good job. I think lowering > somewhere early after IPA optimizations (inlining and then constant > propagation might affect the optimal lowering?) might be most sensible? I'd like to put switch lowering just before function splitting (the profile version and also the non-profile version), because I think (well, hope) that it will allow split-function to peel off the switch case with the highest probability. For instance it'd be possible to change: func (...) { switch (x) case many: ... case cases: ... case that: ... case are: ... case unlikely: ... case hot: ... } to: func (...) { if (x == hot) ... else func.part (...) // for the unlikely cases } For the same reason, I'd like to see Tom's branch-reorganization pass just before function splitting. So far, I've found this to be a common opportunity in GCC itself (with profile info on small switches only, the ones that expand to bit tests -- it's the only part I have working right now). In general: IMHO, the sooner switch lowering and/or branch reordering happens after reading back in profile information, the better, because (a) the value profile information for branches tends to deteriorate rather quickly (even cfg cleanups can invalidate it); (b) my branch profilers tend to be quite large (one counter per range -- I'm still trying to decide whether to make it a param or a magic number :-) and if we use the profile info soon then we can drop the histograms soon and save some memory; and (c) the switch lowering and branch reordering transformations do not destroy any profile information themselves. I'd like to hear Tom and Honza's opinions, too, please! :-) Ciao! Steven
[PATCH, Android] Runtime stack protector enabling for Android target
Hi! Since this change for stack-protector enabling hurts mingw compiler (see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53980 and http://gcc.gnu.org/ml/gcc-patches/2012-07/msg00638.html) we'd like to make change more general. Please see new patch in attachment. Tested in android environment(x86_64-*-linux-android), also bootstrapped and regtested on x86_64-unknown-linux-gnu and i686-linux. Also mingw bootstrap was checked. Ok for trunk? Thanks, Igor Changelog: 2012-07-23 Sergey Melnikov * config/i386/i386.md (stack_protect_set): Disable the pattern for Android since Android libc (bionic) does not provide random value for stack protection guard at gs:0x14. Guard value will be provided from external symbol (default implementation). (stack_protect_set_): Likewise. (stack_protect_test): Likewise. (stack_protect_test_): Likewise. * gcc/defaults.h: Define macro TARGET_HAS_BIONIC to 0 - target does not have Bionic by default * config/linux.h: Redefine macro TARGET_HAS_BIONIC to (OPTION_BIONIC) Macro OPTION_BIONIC is defined in this file and provides Bionic accessibility status patch-stack-protector-3_target_bionic.diff Description: Binary data
Re: [PATCH] Improve andq $0xffffffff, %reg handling (PR target/53110)
Resending in plain text mode so it goes through. Teresa On Mon, Jul 23, 2012 at 12:03 PM, Teresa Johnson wrote: > Any possibility of getting these patches (186979 and 186993), along with > r184891 (which added the and->zext splitter), backported to the 4_7 branch? > I found a performance issue where "andw $0xff, %reg" was not being converted > to movzbl when the source and target registers are the same, resulting in > LCP stalls, which is fixed by this series of patches. > > Thanks, > Teresa > > > On Mon, Apr 30, 2012 at 10:14 AM, Uros Bizjak wrote: >> >> On Mon, Apr 30, 2012 at 3:10 PM, Jakub Jelinek wrote: >> > On Mon, Apr 30, 2012 at 02:54:05PM +0200, Uros Bizjak wrote: >> >> > My recent changes to zero_extend expanders should handle this >> >> > automatically, and will undo generation of zero_extend pattern. >> >> > Please >> >> > see zero_extendsi2_and expander, and how it handles >> >> > TARGET_ZERO_EXTEND_WITH_AND targets. >> >> >> >> Attached patch implements this idea. In addition, it fixes the >> >> splitter to not change output mode of zero_extension from HImode and >> >> QImode from DImode to SImode. Although they generate the same >> >> instruction, I think we should better keep original mode here. >> > >> > Thanks. I was trying this morning slightly different patch for the >> > same, >> > but strangely it failed bootstrap, and didn't get around to analysing >> > why a mem store had (zero_extend (subreg (reg))) on a RHS. >> > >> >> + operands[1] = gen_lowpart (mode, operands[1]); >> >> + >> >> + if (GET_MODE (operands[0]) == DImode) >> >> +insn = (mode == SImode) >> >> +? gen_zero_extendsidi2 >> >> +: (mode == HImode) >> >> +? gen_zero_extendhidi2 >> >> +: gen_zero_extendqidi2; >> >> + else if (GET_MODE (operands[0]) == SImode) >> >> +insn = (mode == HImode) >> >> +? gen_zero_extendhisi2 >> >> +: gen_zero_extendqisi2; >> >> + else if (GET_MODE (operands[0]) == HImode) >> >> +insn = gen_zero_extendqihi2; >> >>else >> >> -ix86_expand_binary_operator (AND, mode, operands); >> >> +gcc_unreachable (); >> >> + >> >> + emit_insn (insn (operands[0], operands[1])); >> > >> > IMHO you should use mode instead of GET_MODE (operands[0]) >> > in all of the above, then the compiler can actually optimize >> > it at compile time. >> >> 2012-04-30 Uros Bizjak >> >> * config/i386/i386.md (and3): Change runtime operand mode >> checks >> to compile-time "mode == mode" checks. >> (and splitter): Ditto. >> >> Tested on x86_64-pc-linux-gnu, committed to mainline SVN. >> >> Uros. > > > > > -- > Teresa Johnson | Software Engineer | tejohn...@google.com | 408-460-2413 > -- Teresa Johnson | Software Engineer | tejohn...@google.com | 408-460-2413
Re: Updated to respond to various email comments from Jason, Diego and Cary (issue6197069)
>>> But if the consensus turns out to be that enumerators should be in >>> pubnames, wouldn't it also be fairly easy to change prune_unused_types >>> so that it doesn't mark enumerators, and change output_pubnames to >>> skip enumerators that have been pruned? >> >> This makes sense to me. > > Enclosed is a patch that does it this way. It requires special-casing > enumerators in two places. > > Personally, it seems cleaner to me just to put them in the pubtypes > table, but I am happy to do it whichever way you want. Sterling, I think you were right all along -- this fails with -fdebug-types-section. When we move an enumeration type out to a separate types section, the DIE isn't marked when we try to add the enumerators to the pubnames table, so the enumerators never get added to the pubnames table. I'm not sure if there's an easy way to get them added to pubnames in that case; it might be easier to go back to putting them in pubtypes. -cary
Re: [Patch] PR 51938: extend ifcombine
On Wed, 20 Jun 2012, Richard Guenther wrote: On Sun, Jun 10, 2012 at 4:16 PM, Marc Glisse wrote: Hello, currently, tree-ssa-ifcombine handles pairs of imbricated "if"s that share the same then branch, or the same else branch. There is no particular reason why it couldn't also handle the case where the then branch of one is the else branch of the other, which is what I do here. Any comments? The general idea looks good, but I think the patch is too invasive. As far as I can see the only callers with a non-zero 'inv' argument come from ifcombine_ifnotorif and ifcombine_ifnotandif (and both with inv == 2). I would rather see a more localized patch that makes use of invert_tree_comparison to perform the inversion on the call arguments of maybe_fold_and/or_comparisons. Hello, I finally went back to this version (which is where I started from, as shown in the PR). It is not very satisfying because: * some bit tests could also be optimized (more generally, grouping a&&b and !a&&b on one side and a||b and !a||b on the other side is rather arbitrary), * -ftrapping-math makes it useless for floating point, but I guess it is better than nothing. Handling traps correctly is complicated because the current code is already a bit bogus (see http://gcc.gnu.org/ml/gcc-patches/2012-07/msg00924.html for an example), and even the definition of -ftrapping-math is not clear ( http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53805 ). If defaults are ever reconsidered, my default flags include -frounding-math -fno-trapping-math. 2012-06-10 Marc Glisse gcc/ PR tree-optimization/51938 * tree-ssa-ifcombine.c (ifcombine_ifandif): New parameter for inverted outer condition. (ifcombine_iforif): Likewise. (tree_ssa_ifcombine_bb): Update calls to the above. Detect !a&&b and !a||b patterns. gcc/testsuite/ PR tree-optimization/51938 * gcc.dg/tree-ssa/ssa-ifcombine-8.c: New testcase. * gcc.dg/tree-ssa/ssa-ifcombine-9.c: New testcase. -- Marc GlisseIndex: tree-ssa-ifcombine.c === --- tree-ssa-ifcombine.c(revision 189779) +++ tree-ssa-ifcombine.c(working copy) @@ -288,45 +288,48 @@ recognize_bits_test (gimple cond, tree * || gimple_assign_rhs_code (stmt) != BIT_AND_EXPR) return false; *name = get_name_for_bit_test (gimple_assign_rhs1 (stmt)); *bits = gimple_assign_rhs2 (stmt); return true; } /* If-convert on a and pattern with a common else block. The inner - if is specified by its INNER_COND_BB, the outer by OUTER_COND_BB. + if is specified by its INNER_COND_BB, the outer by OUTER_COND_BB, + negated if outer_inv is true. Returns true if the edges to the common else basic-block were merged. */ static bool -ifcombine_ifandif (basic_block inner_cond_bb, basic_block outer_cond_bb) +ifcombine_ifandif (basic_block inner_cond_bb, basic_block outer_cond_bb, + bool outer_inv) { gimple_stmt_iterator gsi; gimple inner_cond, outer_cond; tree name1, name2, bit1, bit2; inner_cond = last_stmt (inner_cond_bb); if (!inner_cond || gimple_code (inner_cond) != GIMPLE_COND) return false; outer_cond = last_stmt (outer_cond_bb); if (!outer_cond || gimple_code (outer_cond) != GIMPLE_COND) return false; /* See if we test a single bit of the same name in both tests. In that case remove the outer test, merging both else edges, and change the inner one to test for name & (bit1 | bit2) == (bit1 | bit2). */ - if (recognize_single_bit_test (inner_cond, &name1, &bit1) + if (!outer_inv + && recognize_single_bit_test (inner_cond, &name1, &bit1) && recognize_single_bit_test (outer_cond, &name2, &bit2) && name1 == name2) { tree t, t2; /* Do it. */ gsi = gsi_for_stmt (inner_cond); t = fold_build2 (LSHIFT_EXPR, TREE_TYPE (name1), build_int_cst (TREE_TYPE (name1), 1), bit1); t2 = fold_build2 (LSHIFT_EXPR, TREE_TYPE (name1), @@ -360,76 +363,86 @@ ifcombine_ifandif (basic_block inner_con } return true; } /* See if we have two comparisons that we can merge into one. */ else if (TREE_CODE_CLASS (gimple_cond_code (inner_cond)) == tcc_comparison && TREE_CODE_CLASS (gimple_cond_code (outer_cond)) == tcc_comparison) { tree t; + enum tree_code outer_cond_code = gimple_cond_code (outer_cond); + if (outer_inv) + outer_cond_code = invert_tree_comparison (outer_cond_code, + HONOR_NANS (TYPE_MODE (TREE_TYPE (gimple_cond_lhs (outer_cond); + if (outer_cond_code == ERROR_MARK) + return false; if (!(t = maybe_fold_and_comparisons (gimple_cond_code (inner_cond), gimple_cond_lhs (inner_cond), gimple_cond_rhs (inne
[cxx-conversion] Update hash-table to new coding conventions. (Part 2) (issue6435049)
Change new C++ code to follow the new C++ coding conventions. This patch is part two, which changes the spacing for the bodies of methods formerly defined in-class. The two-part approach makes diffs sensible. Index: gcc/ChangeLog.cxx-conversion 2012-07-23 Lawrence Crowl * hash-table.h (xcallocator::control_alloc): Adjust spacing. (xcallocator::data_alloc): Likewise. (xcallocator::control_free): Likewise. (xcallocator::data_free): Likewise. (hash_table::hash_table): Likewise. (hash_table::is_created): Likewise. (hash_table::find): Likewise. (hash_table::find_slot): Likewise. (hash_table::remove_elt): Likewise. (hash_table::size): Likewise. (hash_table::elements): Likewise. (hash_table::collisions): Likewise. Index: gcc/hash-table.h === --- gcc/hash-table.h(revision 189791) +++ gcc/hash-table.h(working copy) @@ -43,36 +43,44 @@ struct xcallocator }; - /* Allocate memory for COUNT control blocks. */ +/* Allocate memory for COUNT control blocks. */ template inline Type * xcallocator ::control_alloc (size_t count) - { return static_cast (xcalloc (count, sizeof (Type))); } +{ + return static_cast (xcalloc (count, sizeof (Type))); +} - /* Allocate memory for COUNT data blocks. */ +/* Allocate memory for COUNT data blocks. */ template inline Type * xcallocator ::data_alloc (size_t count) - { return static_cast (xcalloc (count, sizeof (Type))); } +{ + return static_cast (xcalloc (count, sizeof (Type))); +} - /* Free memory for control blocks. */ +/* Free memory for control blocks. */ template inline void xcallocator ::control_free (Type *memory) - { return ::free (memory); } +{ + return ::free (memory); +} - /* Free memory for data blocks. */ +/* Free memory for data blocks. */ template inline void xcallocator ::data_free (Type *memory) - { return ::free (memory); } +{ + return ::free (memory); +} /* A common function for hashing a CANDIDATE typed pointer. */ @@ -234,7 +242,7 @@ public: }; - /* Construct the hash table. The only useful operation next is create. */ +/* Construct the hash table. The only useful operation next is create. */ template class Allocator> inline hash_table ::hash_table () - : htab (NULL) - { - } +: htab (NULL) +{ +} - /* See if the table has been created, as opposed to constructed. */ +/* See if the table has been created, as opposed to constructed. */ template class Allocator> inline bool hash_table ::is_created () - { -return htab != NULL; - } +{ + return htab != NULL; +} - /* Like find_with_hash, but compute the hash value from the element. */ +/* Like find_with_hash, but compute the hash value from the element. */ template class Allocator> inline Element * hash_table ::find (Element *comparable) - { -return find_with_hash (comparable, Hash (comparable)); - } +{ + return find_with_hash (comparable, Hash (comparable)); +} - /* Like find_slot_with_hash, but compute the hash value from the element. */ +/* Like find_slot_with_hash, but compute the hash value from the element. */ template ::find_slot (Element *comparable, enum insert_option insert) - { -return find_slot_with_hash (comparable, Hash (comparable), insert); - } +{ + return find_slot_with_hash (comparable, Hash (comparable), insert); +} - /* Like remove_elt_with_hash, but compute the hash value from the element. */ +/* Like remove_elt_with_hash, but compute the hash value from the element. */ template ::remove_elt (Element *comparable) - { -remove_elt_with_hash (comparable, Hash (comparable)); - } - +{ + remove_elt_with_hash (comparable, Hash (comparable)); +} - /* Return the current size of this hash table. */ +/* Return the current size of this hash table. */ template class Allocator> inline size_t hash_table ::size() - { -return htab->size; - } +{ + return htab->size; +} - /* Return the current number of elements in this hash table. */ +/* Return the current number of elements in this hash table. */ template class Allocator> inline size_t hash_table ::elements() - { -return htab->n_elements - htab->n_deleted; - } +{ + return htab->n_elements - htab->n_deleted; +} /* Return the fraction of fixed collisions during all work with given @@ -345,12 +352,12 @@ template class Allocator> inline double hash_table ::collisions() - { -if (htab->searches == 0) - return 0.0; +{ + if (htab->searches == 0) +return 0.0; -return static_cast (htab->collisions) / htab->searches; - } + return static_cast (htab->collisions) / htab->searches; +} /* Create a hash table with at least the given number of INITIAL_SLOTS. */ -- This patch is available for review at http://codereview.appspot.com/6435049
[google/gcc-4_7] Backport Fission patches from trunk (issue6405076)
This patch is for the google/gcc-4_7 branch. It backports five Fission patches from trunk, with two minor differences: - The DW_AT_GNU_pubnames and DW_AT_GNU_pubtypes attributes are both generated, and provide the offset to the corresponding pubnames/pubtypes section. This is done for compatibility with the gold linker, which does not yet support the flag form. - Enumerator names are placed in .debug_pubtypes instead of .debug_pubnames. In trunk with -fdebug_types_section enabled, enumerators were missing from the pubnames table. Tested by bootstrap and regression testing. 2012-07-23 Cary Coutant Backport Fission patches from trunk at r188195, r188857, r189084, r189094, and r189392. 2012-07-09 Sterling Augustine cp/ * error.c (lang_decl_name): Use TFF_UNQUALIFIED_NAME flag. testsuite/ * g++.dg/debug/dwarf2/pubnames-2.C: New. 2012-06-29 Cary Coutant * dwarf2out.c (add_pubname_string): Don't check for want_pubnames. (gen_subprogram_die): Don't add pubname if want_pubnames is false. (gen_variable_die): Likewise. (gen_namespace_die): Likewise. 2012-06-29 Sterling Augustine * dwarf2out.c (add_pubname): Add comment. (add_pubtype): Fix indentation. (gen_enumeration_type_die): Likewise. 2012-06-21 Sterling Augustine Cary Coutant * dwarf2out.c (is_cu_die, is_namespace_die, is_class_die, add_AT_pubnames, add_enumerator_pubname, want_pubnames): New functions. (comdat_type_struct): New field 'skeleton_die'. (breakout_comdat_types): Update it. (add_pubname): Rework logic. Call is_class_die, is_cu_die and is_namespace_die. Fix minor style violation. Call want_pubnames. (add_pubname_string): Call want_pubnames. (add_pubtype): Rework logic for calculating type name. Call is_namespace_die. Call want_pubnames. (output_pubnames): Move conditional logic deciding when to produce the section from dwarf2out_finish. Use new skeleton_die field. (base_type_die): Call add_pubtype. (gen_enumeration_type_die): Unconditionally call add_pubtype. (gen_subprogram_die): Adjust calls to add_pubname. (gen_namespace_die): Call add_pubname_string. (dwarf2out_finish): Call add_AT_pubnames; Move logic on when to produce pubnames and pubtypes sections to output_pubnames. (common.opt): New option '-gpubnames'. (invoke.texi): Document it. 2012-06-04 Sterling Augustine c-family/ * c-pretty-print.h (pp_c_flag_gnu_v3): New enumerator. * c-pretty-print.c (pp_c_specifier_qualifier_list): Check it at both the start and end of the function. cp/ * error.c (dump_decl): Check pp_c_flag_gnu_v3. (decl_as_dwarf_string, lang_decl_dwarf_name): New functions. (lang_decl_name): Handle namespace decls. * cp-tree.h: Declare decl_as_dwarf_string, lang_decl_dwarf_name. * cp-lang.c: Call them. diff --git a/gcc/c-family/c-pretty-print.c b/gcc/c-family/c-pretty-print.c index dc63f00..b596d3b 100644 --- a/gcc/c-family/c-pretty-print.c +++ b/gcc/c-family/c-pretty-print.c @@ -446,7 +446,7 @@ pp_c_specifier_qualifier_list (c_pretty_printer *pp, tree t) { const enum tree_code code = TREE_CODE (t); - if (TREE_CODE (t) != POINTER_TYPE) + if (!(pp->flags & pp_c_flag_gnu_v3) && code != POINTER_TYPE) pp_c_type_qualifier_list (pp, t); switch (code) { @@ -494,6 +494,8 @@ pp_c_specifier_qualifier_list (c_pretty_printer *pp, tree t) pp_simple_type_specifier (pp, t); break; } + if ((pp->flags & pp_c_flag_gnu_v3) && code != POINTER_TYPE) +pp_c_type_qualifier_list (pp, t); } /* parameter-type-list: diff --git a/gcc/c-family/c-pretty-print.h b/gcc/c-family/c-pretty-print.h index 8d399dd..2f9f94a 100644 --- a/gcc/c-family/c-pretty-print.h +++ b/gcc/c-family/c-pretty-print.h @@ -30,7 +30,8 @@ along with GCC; see the file COPYING3. If not see typedef enum { pp_c_flag_abstract = 1 << 1, - pp_c_flag_last_bit = 2 + pp_c_flag_gnu_v3 = 1 << 2, + pp_c_flag_last_bit = 3 } pp_c_pretty_print_flags; diff --git a/gcc/common.opt b/gcc/common.opt index 747dec9..ec94e86 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -2408,6 +2408,14 @@ gmlt Common RejectNegative Generate debug information at level 1 with minimal line table +gno-pubnames +Common RejectNegative Var(debug_generate_pub_sections, 0) Init(-1) +Don't generate DWARF pubnames and pubtypes sections. + +gpubnames +Common RejectNegative Var(debug_generate_pub_sections, 1) +Generate DWARF pubnames and pubtypes sections. + gno-record-gcc-switches Common RejectNegative Var(dwarf_record_gcc_switches,0) Init(0) Don't record gcc command line switches in DWARF DW_AT_producer. diff --git a/gcc/cp/cp-lang.
Re: [SH] PR 51244 - Remove T_REG alternatives from load/store patterns
Oleg Endo wrote: > This removes T_REG alternatives from various load/store patterns. > Tested with > > make -k check RUNTESTFLAGS="--target_board=sh-sim > \{-m2/-ml,-m2/-mb,-m2a/-mb,-m2a-single/-mb,-m4/-ml,-m4/-mb,-m4-single/-ml, > -m4-single/-mb,-m4a-single/-ml,-m4a-single/-mb}" > > and no new failures. > CSiBE shows no changes in result-size, except for -36 bytes in > flex-2.5.31/scan.c. > > OK? OK. Regards, kaz
Re: [SH] Remove addc1 and subc1
Oleg Endo wrote: > The attach patch replaces the use of the 'addc1' pattern with 'addc' and > the use of the 'subc1' pattern with 'subc'. > Tested with > > make -k check RUNTESTFLAGS="--target_board=sh-sim > \{-m2/-ml,-m2/-mb,-m2a/-mb,-m2a-single/-mb,-m4/-ml,-m4/-mb,-m4-single/-ml, > -m4-single/-mb,-m4a-single/-ml,-m4a-single/-mb}" > > and no new failures. CSiBE result-size also doesn't show any change for > '-O2 -m4-single -ml -mpretend-cmove'. > > OK? OK. Regards, kaz
Re: [SH] PR 53511 - Cleanup leftovers
Oleg Endo wrote: > This removes the fmac related combine helper construct that was used > before fma. > > Tested with > > make -k check RUNTESTFLAGS="--target_board=sh-sim > \{-m2/-ml,-m2/-mb,-m2a/-mb,-m2a-single/-mb,-m4/-ml,-m4/-mb,-m4-single/-ml, > -m4-single/-mb,-m4a-single/-ml,-m4a-single/-mb}" > > and no new failures. > CSiBE (-O2 -m4-single-ml -mpretend-cmove) shows no changes in > result-size. > > OK? OK. Regards, kaz
[PATCH] Improve ifcombine (PR 52005)
This patch improves ifcombine by doing two things. First tries to see if the then and else are swapped and handles that case. Also it handles the case where the else or then cases have an empty basic block instead of just fall through. OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. Thanks, Andrew Pinski ChangeLog: * tree-ssa-ifcombine.c (recognize_if_then_else): Handle the case where the the then and else are swapped. (tree_ssa_ifcombine_bb): Handle the case were we have an empty basic block for either then or else. * gcc.dg/tree-ssa/ssa-ifcombine-8.c: New testcase. * gcc.dg/tree-ssa/ssa-ifcombine-9.c: New testcase. Index: testsuite/gcc.dg/tree-ssa/ssa-ifcombine-8.c === --- testsuite/gcc.dg/tree-ssa/ssa-ifcombine-8.c (revision 0) +++ testsuite/gcc.dg/tree-ssa/ssa-ifcombine-8.c (revision 0) @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-optimized" } */ + +/* Testcase for PR31657. */ + +int f(int x, int a, int b) +{ + int t = 0; + int c = 1 << a; + if (!(x & 1)) +t = 0; + else +if (x & (1 << 2)) + t = 3; +else + t = 0; + return t; +} +/* { dg-final { scan-tree-dump "& 5" "optimized" } } */ +/* { dg-final { cleanup-tree-dump "optimized" } } */ Index: testsuite/gcc.dg/tree-ssa/ssa-ifcombine-9.c === --- testsuite/gcc.dg/tree-ssa/ssa-ifcombine-9.c (revision 0) +++ testsuite/gcc.dg/tree-ssa/ssa-ifcombine-9.c (revision 0) @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-optimized" } */ + +/* Testcase for PR31657. */ +int g(void); +int f(int x, int a, int b) +{ + int t = 0; + int c = 1 << a; + if (!(x & 1)) +t = 0; + else +if (x & (1 << 2)) + t = g(); +else + t = 0; + return t; +} + +/* { dg-final { scan-tree-dump "& 5" "optimized" } } */ +/* { dg-final { cleanup-tree-dump "optimized" } } */ Index: tree-ssa-ifcombine.c === --- tree-ssa-ifcombine.c(revision 189800) +++ tree-ssa-ifcombine.c(working copy) @@ -78,12 +78,34 @@ recognize_if_then_else (basic_block cond return false; /* Check if the edge destinations point to the required block. */ - if (*then_bb - && t->dest != *then_bb) -return false; - if (*else_bb - && e->dest != *else_bb) -return false; + if ((*then_bb + && t->dest != *then_bb) + || (*else_bb + && e->dest != *else_bb)) +{ + gimple stmt; + tree cond; + edge ee; + if ((*then_bb + && e->dest != *then_bb) + || (*else_bb + && t->dest != *else_bb)) + return false; + stmt = last_stmt (cond_bb); + cond = fold_build2 (gimple_cond_code (stmt), boolean_type_node, + gimple_cond_lhs (stmt), gimple_cond_rhs (stmt)); + cond = fold_build1 (TRUTH_NOT_EXPR, TREE_TYPE (cond), cond); + /* The opposite of the condition does not reduce so we cannot flip around the condition. */ + if (!is_gimple_condexpr (cond)) + return false; + e->flags ^= (EDGE_TRUE_VALUE|EDGE_FALSE_VALUE); + t->flags ^= (EDGE_TRUE_VALUE|EDGE_FALSE_VALUE); + gimple_cond_set_condition_from_tree (stmt, unshare_expr (cond)); + update_stmt (stmt); + ee = e; + e = t; + t = ee; +} if (!*then_bb) *then_bb = t->dest; @@ -590,6 +612,29 @@ tree_ssa_ifcombine_bb (basic_block inner return ifcombine_ifandif (inner_cond_bb, outer_cond_bb); } + /* The && form is characterized by a common else_bb with +the two edges leading to it mergable. The latter is +guaranteed by matching PHI arguments in the else_bb and +the inner cond_bb having no side-effects. */ + if (empty_block_p (else_bb) + && single_succ_p (else_bb) + && single_succ_edge (else_bb)->dest == then_bb + && recognize_if_then_else (outer_cond_bb, &inner_cond_bb, &then_bb) + && same_phi_args_p (outer_cond_bb, else_bb, then_bb) + && bb_no_side_effects_p (inner_cond_bb)) + { + /* We have + +if (q) goto inner_cond_bb; else goto else_bb; + +if (p) goto ...; else goto else_bb; +... + +... + */ + return ifcombine_ifandif (inner_cond_bb, outer_cond_bb); + } + /* The || form is characterized by a common then_bb with the two edges leading to it mergable. The latter is guaranteed by matching PHI arguments in the then_bb and the inner cond_bb @@ -599,6 +644,27 @@ tree_ssa_ifcombine_bb (basic_block inner && bb_no_side_effects_p (inner_cond_bb)) { /* We have + +if (q) goto then_bb; else goto inner_cond
Re: PR53914, rs6000 constraints and reload queries
On Mon, Jul 23, 2012 at 07:30:23PM -0400, David Edelsohn wrote: > This is okay Committed revision 189801. PR target/53914 PR target/54009 * config/rs6000/constraints.md (Y): Use mem_operand_gpr. * config/rs6000/predicates.md (word_offset_memref_operand): Delete. Adjust all rs6000_legitimate_offset_address_p calls. * config/rs6000/rs6000-protos.h (mem_operand_gpr): Declare. (rs6000_secondary_reload_gpr): Declare. (rs6000_legitimate_offset_address_p): Update prototype. (rs6000_offsettable_memref_p): Delete. (rs6000_secondary_reload_ppc64): Delete. * config/rs6000/rs6000.c (address_offset): New function. (mem_operand_gpr): Likewise. (rs6000_legitimate_offset_address_p): Add worst_case param. When not worst_case assume class of regs with least restrictive offsets. Adjust all calls. (legitimate_lo_sum_address_p): Simplify register mode tests. (rs6000_legitimize_address): Likewise. Assume best case offset addressing. Combine ELF and MACHO lo_sum code. (rs6000_mode_dependent_address): Correct offset addressing limits. (rs6000_offsettable_memref_p): Make static, add reg_mode param. Use reg_mode to help rs6000_legitimate_offset_address_p. (rs6000_secondary_reload): Use address_offset. Handle 32-bit multi gpr load/store when offset too large. (rs6000_secondary_reload_gpr): Renamed rs6000_secondary_reload_ppc64. (rs6000_split_multireg_move): Adjust rs6000_offsettable_memref_p calls. * config/rs6000/rs6000.md (movdf_hardfloat32): Use 'Y' constraint for gpr load/store. Order alternatives as r->Y,Y->r,r->r and d->m,m->d,d->d. Correct size of gpr load/store. (movdf_softfloat32): Use 'Y' constraint for gpr load/store. Order alternatives. (movti_ppc64): Likewise. (movdi_internal32): Likewise. Also disparage fprs. (movdi_mfpgpr, movdi_internal64): Likewise. (movtf_internal): Use 'm' for fpr load/store. Order alternatives. (movtf_softfloat): Order alternatives. (extenddftf2_internal): Use 'm' and 'Y' for store. (movti_power, movti_string): Use 'Y' for gpr load/store. Order. (stack_protect_setdi, stack_protect_testdi): Likewise. (movdf_hardfloat64_mfpgpr, movdf_hardfloat64): Order alternatives. (movdf_softfloat64): Likewise. (reload__store): Adjust reload_di_store to provide reload_si_store as well. (reload__load): Likewise. Index: gcc/config/rs6000/constraints.md === --- gcc/config/rs6000/constraints.md(revision 189800) +++ gcc/config/rs6000/constraints.md(working copy) @@ -150,8 +150,9 @@ to use @samp{m} or @samp{es} in @code{asm} stateme (match_test "GET_CODE (XEXP (op, 0)) == REG"))) (define_memory_constraint "Y" - "Indexed or word-aligned displacement memory operand" - (match_operand 0 "word_offset_memref_operand")) + "memory operand for 8 byte and 16 byte gpr load/store" + (and (match_code "mem") + (match_operand 0 "mem_operand_gpr"))) (define_memory_constraint "Z" "Memory operand that is an indexed or indirect from a register (it is Index: gcc/config/rs6000/predicates.md === --- gcc/config/rs6000/predicates.md (revision 189800) +++ gcc/config/rs6000/predicates.md (working copy) @@ -432,29 +432,6 @@ (and (match_operand 0 "memory_operand") (match_test "offsettable_nonstrict_memref_p (op)"))) -;; Return 1 if the operand is a memory operand with an address divisible by 4 -(define_predicate "word_offset_memref_operand" - (match_operand 0 "memory_operand") -{ - /* Address inside MEM. */ - op = XEXP (op, 0); - - /* Extract address from auto-inc/dec. */ - if (GET_CODE (op) == PRE_INC - || GET_CODE (op) == PRE_DEC) -op = XEXP (op, 0); - else if (GET_CODE (op) == PRE_MODIFY) -op = XEXP (op, 1); - else if (GET_CODE (op) == LO_SUM - && GET_CODE (XEXP (op, 0)) == REG - && GET_CODE (XEXP (op, 1)) == CONST) -op = XEXP (XEXP (op, 1), 0); - - return (GET_CODE (op) != PLUS - || GET_CODE (XEXP (op, 1)) != CONST_INT - || INTVAL (XEXP (op, 1)) % 4 == 0); -}) - ;; Return 1 if the operand is an indexed or indirect memory operand. (define_predicate "indexed_or_indirect_operand" (match_code "mem") @@ -892,7 +869,8 @@ return input_operand (op, mode); }) -;; Return true if OP is an invalid SUBREG operation on the e500. +;; Return true if OP is a non-immediate operand and not an invalid +;; SUBREG operation on the e500. (define_predicate "rs6000_nonimmediate_operand" (match_code "reg,subreg,mem") { @@ -1325,7 +1303,7 @@ if (base_regno == 0) return 0; } - else if (rs6000_legitimate_offset_address_p (SImode, src_addr, 0))