Re: [Test] Fix for PRPR53981
> Yes, you can put it on the 4.6 branch. Hi, Thanks! Checked into 4.6 branch. http://gcc.gnu.org/ml/gcc-cvs/2012-08/msg00130.html Thanks, K
[Ada] Missing Constraint_Error in illegal conversion to C type
This patch removes an old range check optimization which incorrectly assumes that the type of an arbitrary expression can always fit in the target type of a conversion. -- Source -- -- main.adb with Interfaces; use Interfaces; procedure Main is subtype Small_Positive is Integer_16 range 1 .. Integer_16'Last; type Target_Typ is array (Small_Positive range <>) of Boolean; pragma Convention (C, Target_Typ); subtype Large_Positive is Integer_32 range 1 .. 60_000; type Expr_Typ is array (Large_Positive range <>) of Boolean; type Expr_Typ_Ptr is access Expr_Typ; Expr : constant Expr_Typ := (1 .. 60_000 => True); Expr_Ptr : constant Expr_Typ_Ptr := new Expr_Typ'(Expr); Target : constant Target_Typ := Target_Typ (Expr_Ptr.all); begin null; end Main; -- Compilation and output -- $ gnatmake -q main.adb $ ./main.adb raised CONSTRAINT_ERROR : main.adb:16 range check failed Tested on x86_64-pc-linux-gnu, committed on trunk 2012-08-06 Hristian Kirtchev * checks.adb (Discrete_Range_Cond): Do not try to optimize on the assumption that the type of an expression can always fit in the target type of a conversion. Index: checks.adb === --- checks.adb (revision 190155) +++ checks.adb (working copy) @@ -6660,12 +6660,6 @@ LB := New_Occurrence_Of (Discriminal (Entity (LB)), Loc); end if; - if Nkind (HB) = N_Identifier - and then Ekind (Entity (HB)) = E_Discriminant - then -HB := New_Occurrence_Of (Discriminal (Entity (HB)), Loc); - end if; - Left_Opnd := Make_Op_Lt (Loc, Left_Opnd => @@ -6677,28 +6671,10 @@ (Base_Type (Typ), Get_E_First_Or_Last (Loc, Typ, 0, Name_First))); - if Base_Type (Typ) = Typ then -return Left_Opnd; - - elsif Compile_Time_Known_Value (High_Bound (Scalar_Range (Typ))) -and then - Compile_Time_Known_Value (High_Bound (Scalar_Range - (Base_Type (Typ + if Nkind (HB) = N_Identifier + and then Ekind (Entity (HB)) = E_Discriminant then -if Is_Floating_Point_Type (Typ) then - if Expr_Value_R (High_Bound (Scalar_Range (Typ))) = - Expr_Value_R (High_Bound (Scalar_Range (Base_Type (Typ - then - return Left_Opnd; - end if; - -else - if Expr_Value (High_Bound (Scalar_Range (Typ))) = - Expr_Value (High_Bound (Scalar_Range (Base_Type (Typ - then - return Left_Opnd; - end if; -end if; +HB := New_Occurrence_Of (Discriminal (Entity (HB)), Loc); end if; Right_Opnd :=
[Ada] Skip unneeded expansion for Alfa mode
In Alfa mode for formal verification, a special expansion done in the frontend turns out to be both harmful and unneeded, because the formal verification backend relies on the types of nodes (hence is not robust w.r.t. a change to base type here), and does not suffer from the out-of-order issue targetted by the special expansion. Thus, this expansion is skipped in Alfa mode. Tested on x86_64-pc-linux-gnu, committed on trunk 2012-08-06 Yannick Moy * sem_attr.adb (Analyze_Attribute): In the case for 'Old, skip a special expansion which is not needed in Alfa mode. Index: sem_attr.adb === --- sem_attr.adb(revision 190155) +++ sem_attr.adb(working copy) @@ -4034,7 +4034,13 @@ -- enclosing subprogram. This is properly an expansion activity -- but it has to be performed now to prevent out-of-order issues. - if not Is_Entity_Name (P) then + -- This expansion is both harmful and not needed in Alfa mode, since + -- the formal verification backend relies on the types of nodes + -- (hence is not robust w.r.t. a change to base type here), and does + -- not suffer from the out-of-order issue described above. Thus, this + -- expansion is skipped in Alfa mode. + + if not Is_Entity_Name (P) and then not Alfa_Mode then P_Type := Base_Type (P_Type); Set_Etype (N, P_Type); Set_Etype (P, P_Type);
[Ada] Skip special expansion in Alfa mode
In Alfa mode for formal verification, a special expansion of the iterator is not needed, as the formal verification backend directly deals with the source form of the iterator. Thus, skip this expansion. Tested on x86_64-pc-linux-gnu, committed on trunk 2012-08-06 Yannick Moy * sem_ch5.adb (Analyze_Iterator_Specification): Do not perform an expansion of the iterator in Alfa mode. Index: sem_ch5.adb === --- sem_ch5.adb (revision 190158) +++ sem_ch5.adb (working copy) @@ -1665,16 +1665,21 @@ -- If the domain of iteration is an expression, create a declaration for -- it, so that finalization actions are introduced outside of the loop. -- The declaration must be a renaming because the body of the loop may - -- assign to elements. When the context is a quantified expression, the - -- renaming declaration is delayed until the expansion phase. + -- assign to elements. if not Is_Entity_Name (Iter_Name) + +-- When the context is a quantified expression, the renaming +-- declaration is delayed until the expansion phase if we are +-- doing expansion. + and then (Nkind (Parent (N)) /= N_Quantified_Expression + or else Operating_Mode = Check_Semantics) - -- The following two tests need comments ??? +-- Do not perform this expansion in Alfa mode, since the formal +-- verification directly deals with the source form of the iterator. - or else Operating_Mode = Check_Semantics - or else Alfa_Mode) +and then not Alfa_Mode then declare Id : constant Entity_Id := Make_Temporary (Loc, 'R', Iter_Name); @@ -1711,7 +1716,7 @@ -- Container is an entity or an array with uncontrolled components, or -- else it is a container iterator given by a function call, typically -- called Iterate in the case of predefined containers, even though - -- Iterate is not a reserved name. What matter is that the return type + -- Iterate is not a reserved name. What matters is that the return type -- of the function is an iterator type. elsif Is_Entity_Name (Iter_Name) then
[Ada] Redundant finalization of controlled function result
This patch removes obsolete code related to array initialization. When an array is initialized by an aggregate, the compiler may generate a loop to initialize all elements. If the aggregate contains controlled function calls, the loop statements are wrapped in a block for finalization purposes. The block already handles proper finalization of transient objects so it no longer needs the specialized processing performed in Process_Transient_Objects. -- Source -- -- types.ads with Ada.Finalization; use Ada.Finalization; package Types is type Ctrl is new Controlled with record Id : Natural; end record; procedure Adjust (Obj : in out Ctrl); procedure Finalize (Obj : in out Ctrl); procedure Initialize (Obj : in out Ctrl); end Types; -- types.adb with Ada.Text_IO; use Ada.Text_IO; package body Types is Id_Gen : Natural := 0; procedure Adjust (Obj : in out Ctrl) is New_Id : constant Natural := Obj.Id * 100; begin Put_Line (" adj" & Obj.Id'Img & " ->" & New_Id'Img); Obj.Id := New_Id; end Adjust; procedure Finalize (Obj : in out Ctrl) is begin Put_Line (" fin" & Obj.Id'Img); end Finalize; procedure Initialize (Obj : in out Ctrl) is begin Id_Gen := Id_Gen + 1; Obj.Id := Id_Gen; Put_Line (" ini" & Obj.Id'Img); end Initialize; end Types; -- main.adb with Types; use Types; procedure Main is function Create return Ctrl is begin return Obj : Ctrl; end Create; Container : array (1 .. 2) of Ctrl := (others => Create); begin null; end Main; -- Compilation and output -- $ gnatmake -q -gnat05 main.adb $ ./main ini 1 adj 1 -> 100 fin 1 adj 100 -> 1 fin 100 ini 2 adj 2 -> 200 fin 2 adj 200 -> 2 fin 200 fin 2 fin 1 Tested on x86_64-pc-linux-gnu, committed on trunk 2012-08-06 Hristian Kirtchev * exp_ch7.adb (Process_Transient_Objects): Remove obsolete loop processing related to array initialization. The expansion of loops already contains a mechanism to detect controlled objects generated by expansion and introduce a block around the loop statements for finalization purposes. Index: exp_ch7.adb === --- exp_ch7.adb (revision 190155) +++ exp_ch7.adb (working copy) @@ -4585,48 +4585,12 @@ end if; Prev_Fin := Fin_Block; +end if; --- When the associated node is an array object, the expander may --- sometimes generate a loop and create transient objects inside --- the loop. +-- Terminate the scan after the last object has been processed to +-- avoid touching unrelated code. -elsif Nkind (Related_Node) = N_Object_Declaration - and then Is_Array_Type - (Base_Type - (Etype (Defining_Identifier (Related_Node - and then Nkind (Stmt) = N_Loop_Statement -then - declare - Block_HSS : Node_Id := First (Statements (Stmt)); - - begin - -- The loop statements may have been wrapped in a block by - -- Process_Statements_For_Controlled_Objects, inspect the - -- handled sequence of statements. - - if Nkind (Block_HSS) = N_Block_Statement -and then No (Next (Block_HSS)) - then - Block_HSS := Handled_Statement_Sequence (Block_HSS); - - Process_Transient_Objects - (First_Object => First (Statements (Block_HSS)), -Last_Object => Last (Statements (Block_HSS)), -Related_Node => Related_Node); - - -- Inspect the statements of the loop - - else - Process_Transient_Objects - (First_Object => First (Statements (Stmt)), -Last_Object => Last (Statements (Stmt)), -Related_Node => Related_Node); - end if; - end; - --- Terminate the scan after the last object has been processed - -elsif Stmt = Last_Object then +if Stmt = Last_Object then exit; end if;
[Ada] Fix delayed analysis of aspect specification when scopes differ
This patch properly analyses aspects in cases when scopes differ such as protected types, tasks, etc. The test illustrates the analysis of aspects at freeze point specified for a protected object. -- Source -- package T is type Typ is new Integer with Size => 128; protected type Prot with Lock_Free => True is procedure Reset; private Counter : Typ := 0; end Prot; end T; package body T is protected body Prot is procedure Reset is begin Counter := 0; end Reset; end Prot; end T; - -- Compilation -- - $ gnatmake -q -gnat12 t.adb t.adb:3:07: illegal body when Lock_Free given t.adb:5:10: type of "Counter" must support atomic operations gnatmake: "t.adb" compilation error Tested on x86_64-pc-linux-gnu, committed on trunk 2012-08-06 Vincent Pucci * sem_ch13.adb: Current scope must be within or same as the scope of the entity while analysing aspect specifications at freeze point. Index: sem_ch13.adb === --- sem_ch13.adb(revision 190155) +++ sem_ch13.adb(working copy) @@ -856,10 +856,11 @@ -- Start of processing for Analyze_Aspects_At_Freeze_Point begin - -- Must be declared in current scope. This is need for a generic - -- context. + -- Must be visible in current scope. Note that this is needed for + -- entities that creates their own scope such as protected objects, + -- tasks, etc. - if Scope (E) /= Current_Scope then + if not Scope_Within_Or_Same (Current_Scope, Scope (E)) then return; end if; @@ -2434,11 +2435,12 @@ return; -- Must be declared in current scope or in case of an aspect - -- specification, must be the current scope. + -- specification, must be visible in current scope. elsif Scope (Ent) /= Current_Scope -and then (not From_Aspect_Specification (N) - or else Ent /= Current_Scope) +and then + not (From_Aspect_Specification (N) +and then Scope_Within_Or_Same (Current_Scope, Scope (Ent))) then Error_Msg_N ("entity must be declared in this scope", Nam); return;
[Ada] Guard against cascaded error when processing deferred config pragmas
Some configuration pragmas require the presence of a compilation unit context to be processed. Their analysis is deferred until after the main unit has been analyzed. However, if that analysis fails for any reason, then the context may not be correctly established, and the deferred config pragmas must not be analyzed, because this could cause a compiler crash. Using a compiler with assertions enabled, the following compilation must produce the indicated error message (and no bug box): $ gcc -c illeg.adb illeg.adb:2:04: declaration expected package Illeg is procedure Proc; end Illeg; package body Illeg is illegal; end Illeg; -- gnat.adc: pragma Initialize_Scalars; pragma Restrictions (No_Abort_Statements); pragma Restrictions (Max_Asynchronous_Select_Nesting => 0); pragma Restrictions (No_Asynchronous_Control); pragma Restrictions (No_Dynamic_Priorities); pragma Interrupt_State (Name => SIGABRT, State => SYSTEM); pragma Interrupt_State (Name => SIGTERM, State => SYSTEM); pragma Interrupt_State (Name => SIGPIPE, State => SYSTEM); Tested on x86_64-pc-linux-gnu, committed on trunk 2012-08-06 Thomas Quinot * frontend.adb: Do not attempt to process deferred configuration pragmas if the main unit failed to load, to avoid cascaded inconsistencies that can lead to a compiler crash. Index: frontend.adb === --- frontend.adb(revision 190155) +++ frontend.adb(working copy) @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2011, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-2012, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -282,6 +282,7 @@ -- a context for their semantic processing. if Config_Pragmas /= Error_List + and then not Fatal_Error (Main_Unit) and then Operating_Mode /= Check_Syntax then -- Pragmas that require some semantic activity, such as
[Ada] Incorrect parameter mechanism due to convention C_Pass_By_Copy
This patch corrects the Ada-C parameter passing mechanism for record types. OUT and IN OUT parameters are now unconditionally passed by reference regardless of whether C_Pass_By_Copy is in effect. IN parameters subject to the convention are passed by copy, otherwise they are passed by reference. -- Source -- -- utils.ads with Interfaces.C; package Utils is type Record_Type is record A : Interfaces.C.int; end record; pragma Convention (C_Pass_By_Copy, Record_Type); procedure Get_Data (Result: out Interfaces.C.int; In_Param : Record_Type; Out_Param : out Record_Type); pragma Export (C, Get_Data, "get_data"); pragma Export_Valued_Procedure (Get_Data); end Utils; -- utils.adb with Ada.Text_IO; use Ada.Text_IO; package body Utils is procedure Get_Data (Result: out Interfaces.C.int; In_Param : Record_Type; Out_Param : out Record_Type) is begin Put_Line (" In data:"); Put_Line (" record field :" & In_Param.A'Img); Result := 0; Out_Param.A := 42; Put_Line (" Returning data:"); Put_Line (" return code :" & Result'Img); Put_Line (" record field :" & Out_Param.A'Img); end Get_Data; end Utils; -- driver.c #include #include struct record_t { int a; }; extern int get_data(struct record_t in_param, struct record_t *out_param); int main() { int ret; struct record_t in_data, out_data; printf("Initializing Ada Runtime\n"); adainit(); in_data.a = 4; printf("Passing data\n"); printf(" record field : %d\n", in_data.a); ret = get_data(in_data,&out_data); printf("Returned data\n"); printf(" return code : %d\n", ret); printf(" record field : %d\n", out_data.a); printf("Expected value: 42\n"); printf("Finalizing Ada Runtime\n"); adafinal(); } -- Compilation and output -- $ gcc -c driver.c $ gnatmake -q -z utils -o driver -bargs -n -largs driver.o $ ./driver Initializing Ada Runtime Passing data record field : 4 In data: record field : 4 Returning data: return code : 0 record field : 42 Returned data return code : 0 record field : 42 Expected value: 42 Finalizing Ada Runtime Tested on x86_64-pc-linux-gnu, committed on trunk 2012-08-06 Hristian Kirtchev * sem_mech.adb (Set_Mechanisms): OUT and IN OUT parameters are now unconditionally passed by reference. IN parameters subject to convention C_Pass_By_Copy are passed by copy, otherwise they are passed by reference. Index: sem_mech.adb === --- sem_mech.adb(revision 190155) +++ sem_mech.adb(working copy) @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1996-2011, Free Software Foundation, Inc. -- +-- Copyright (C) 1996-2012, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -352,13 +352,13 @@ --Access parameters (RM B.3(68)) --Access to subprogram types (RM B.3(71)) - -- Note: in the case of access parameters, it is the - -- pointer that is passed by value. In GNAT access - -- parameters are treated as IN parameters of an - -- anonymous access type, so this falls out free. + -- Note: in the case of access parameters, it is the pointer + -- that is passed by value. In GNAT access parameters are + -- treated as IN parameters of an anonymous access type, so + -- this falls out free. - -- The bottom line is that all IN elementary types - -- are passed by copy in GNAT. + -- The bottom line is that all IN elementary types are + -- passed by copy in GNAT. if Is_Elementary_Type (Typ) then if Ekind (Formal) = E_In_Parameter then @@ -385,10 +385,21 @@ if Convention (Typ) /= Convention_C then Set_Mechanism (Formal, By_Reference); - -- If convention C_Pass_By_Copy was specified for - -- the record type, then we pass by copy. + -- OUT and IN OUT parameters of record types are passed +
[Ada] Protected objects with interrupt handlers are legal in nested scopes
AI95-0303 removes the rule that protected objects with handlers must be declared at the library level. The AI is a binding interpretation, and thus applies to earlier versions of the language as well. The new rule is tested in ACATS test BXC3002. Tested on x86_64-pc-linux-gnu, committed on trunk 2012-08-06 Ed Schonberg * sem_ch3.adb (Analyze_Object_Declaration): According to AI95-0303, protected objects with interrupt handlers can be declared in nested scopes. This is a binding interpretation, and thus applies to all versions of the compiler. Index: sem_ch3.adb === --- sem_ch3.adb (revision 190155) +++ sem_ch3.adb (working copy) @@ -3078,8 +3078,11 @@ -- in the RM is removed) because accessibility checks are sufficient -- to make handlers not at the library level illegal. + -- AI05-0303: the AI is in fact a binding interpretation, and thus + -- applies to the '95 version of the language as well. + if Has_Interrupt_Handler (T) - and then Ada_Version < Ada_2005 + and then Ada_Version < Ada_95 then Error_Msg_N ("interrupt object can only be declared at library level", Id);
[Ada] Lock-free implementation of protected objects (PR ada/54125)
This patch removes dependency on Support_Atomic_Primitives in the run-time package System.Atomic_Primitives by introducing a new attribute Atomic_Always_Lock_Free. This changes allow us to remove all the Support_Atomic_Primitives defaulted values in the corresponding system packages and fixes build failures on platform that didn't have the flag Support_Atomic_Primitives defined in the target system.ads (PR ada/54125) Tested on x86_64-pc-linux-gnu, committed on trunk 2012-08-06 Vincent Pucci PR ada/54125 * exp_attr.adb (Expand_N_Attribute_Reference): Expand new Atomic_Always_Lock_Free attribute. * sem_attr.adb (Analyze_Attribute): Analyze new Atomic_Always_Lock_Free attribute. (Eval_Attribute): Nothing to do with new Atomic_Always_Lock_Free attribute. * sem_ch9.adb (Allows_Lock_Free_Implementation): Support_Atomic_Primitives check replaces previous erroneous size check. * sem_util.adb, sem_util.ads (Support_Atomic_Primitives): New routine. * snames.ads-tmpl: New name Name_Atomic_Always_Lock_Free and new attribute Attribute_Atomic_Always_Lock_Free defined. * s-atopri.adb: Support_Atomic_Primitives checks replaced by Atomic_Always_Lock_Free queries. * 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-lynxos178-ppc.ads, system-lynxos-ppc.ads, system-mingw.ads, system-vxworks-arm.ads, system-solaris-sparc.ads, system-solaris-sparcv9.ads, system-vms_64.ads, system-vxworks-m68k.ads, system-vxworks-mips.ads, system-vxworks-ppc.ads, system-vxworks-sparcv9.ads: Flag Support_Atomic_Primitives removed. Index: system-linux-s390x.ads === --- system-linux-s390x.ads (revision 190155) +++ system-linux-s390x.ads (working copy) @@ -130,7 +130,6 @@ 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 190155) +++ system-linux-alpha.ads (working copy) @@ -130,7 +130,6 @@ Stack_Check_Probes: constant Boolean := True; 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: exp_attr.adb === --- exp_attr.adb(revision 190155) +++ exp_attr.adb(working copy) @@ -3100,19 +3100,6 @@ end if; end; - --- - -- Lock_Free -- - --- - - -- Rewrite the attribute reference with the value of Uses_Lock_Free - - when Attribute_Lock_Free => Lock_Free : declare - V : constant Entity_Id := Boolean_Literals (Uses_Lock_Free (Ptyp)); - begin - Rewrite (N, New_Occurrence_Of (V, Loc)); - Analyze_And_Resolve (N, Standard_Boolean); - end Lock_Free; - - -- Machine -- - @@ -6018,6 +6005,7 @@ when Attribute_Abort_Signal | Attribute_Address_Size | + Attribute_Atomic_Always_Lock_Free | Attribute_Base | Attribute_Class| Attribute_Compiler_Version | @@ -6035,6 +6023,7 @@ Attribute_Has_Tagged_Values| Attribute_Large| Attribute_Last_Valid | + Attribute_Lock_Free| Attribute_Machine_Emax | Attribute_Machine_Emin | Attribute_Machine_Mantissa | Index: system-vxworks-arm.ads === --- system-vxworks-arm.ads (revision 190155) +++ system-vxworks-arm.ads (working copy) @@ -145,7 +145,6 @@ Stack_Check_Probes: constant Boolean := False; Stack_Check_Limits: constant Boolean := True; Support_Aggregates: constant Boolean :=
Re: [PATCH] Remove introduction of undefined overflow in emit_case_bit_test.
On Mon, Aug 6, 2012 at 1:31 AM, Tom de Vries wrote: > Richard, > > the code in emit_case_bit_tests currently introduces a MINUS_EXPR in signed > type > (without checking if signed types wrap or not), which could mean introduction > of > undefined overflow. > > This patch fixes this problem by performing the MINUS_EXPR in an unsigned > type. > > Doing so also enables the vrp optimization for the test-case. > > Bootstrapped and reg-tested (ada inclusive) on x86_64. > > OK for trunk? Ok. Thanks, Richard. > Thanks, > - Tom > > > 2012-08-06 Tom de Vries > > * tree-switch-conversion.c (emit_case_bit_tests): Generate MINUS_EXPR > in > unsigned type. > > * gcc.dg/tree-ssa/vrp78.c: New test.
Re: [PATCH] Improve ifcombine (PR 52005)
On Mon, Aug 6, 2012 at 8:27 AM, Marc Glisse wrote: > > Hello, > > do you have an opinion on this patch (available here: > http://gcc.gnu.org/ml/gcc-patches/2012-07/msg01352.html > ) ? I like it. Thus, the referenced patch is ok for trunk. Thanks, Richard. > Or should we go back to my old patch, or Andrew's patch? > > > On Thu, 26 Jul 2012, Marc Glisse wrote: > >> Hello, >> >> here is a new version of the ifcombine patch, which handles Andrew's >> examples (though only with -O2 for one of them, same_phi_args_p returns >> false otherwise). >> >> Note that the new patch never calls maybe_fold_or_comparisons, only >> maybe_fold_and_comparisons. It would be possible to call >> maybe_fold_or_comparisons, when maybe_fold_and_comparisons fails, but I >> don't know if there are optimizations that one does and not the other, >> except for the odd trapping-math case. >> >> Bootstrap and testsuite are fine. >> >> 2012-07-26 Marc Glisse >> >> gcc/ >> PR tree-optimization/51938 >> PR tree-optimization/52005 >> * tree-ssa-ifcombine.c (ifcombine_ifandif): New parameters for >> inverted conditions. >> (ifcombine_iforif): Remove, merge code into ifcombine_ifandif. >> (tree_ssa_ifcombine_bb): Update calls to the above. Detect !a&&b >> and !a||b patterns. >> >> >> gcc/testsuite/ >> PR tree-optimization/51938 >> PR tree-optimization/52005 >> * gcc.dg/tree-ssa/ssa-ifcombine-8.c: New testcase. >> * gcc.dg/tree-ssa/ssa-ifcombine-9.c: Likewise. >> * gcc.dg/tree-ssa/ssa-ifcombine-10.c: Likewise. >> * gcc.dg/tree-ssa/ssa-ifcombine-11.c: Likewise. > > > -- > Marc Glisse
Re: [patch] speed up ifcvt:cond_move_convert_if_block
On Mon, Aug 6, 2012 at 8:54 AM, Steven Bosscher wrote: > Hello, > > In PR54146, ifcvt spends a lot of time just clearing memory. This > patch changes the value maps to pointer-maps to fix this issue. > > Bootstrapped&tested on x86_64-unknown-linux-gnu. OK? Ok! Thanks, Richard. > Ciao! > Steven
[Ada] Implement extended overflow checks, step 1
This patch extends the type Suppress_Array in types.ads to include the switches to control extended overflow checking. The new type is called Suppress_Record, and all uses elsewhere of Suppress_Array are changed to be Suppress_Record. So far, the only settings for the new overflow checking modes are Suppress and Check_All, which are equivalent to the previous Suppress and check modes, so there is no functional change so far, so no test is required. Tested on x86_64-pc-linux-gnu, committed on trunk 2012-08-06 Robert Dewar * exp_util.adb, switch-c.adb, inline.ads, sem_ch10.adb, types.ads, checks.adb, sem_prag.adb, sem.adb, sem.ads, sem_res.adb, sem_attr.adb, gnat1drv.adb, exp_ch4.adb, exp_ch6.adb, opt.ads, osint.adb: Implement extended overflow checks (step 1). (Suppress_Array): extended to include switches to control extended overflow checking. Update all uses of Suppress_Array. Index: exp_util.adb === --- exp_util.adb(revision 190155) +++ exp_util.adb(working copy) @@ -3818,20 +3818,20 @@ begin if Suppress = All_Checks then declare -Svg : constant Suppress_Array := Scope_Suppress; +Svg : constant Suppress_Record := Scope_Suppress; begin -Scope_Suppress := (others => True); +Scope_Suppress := Suppress_All; Insert_Actions (Assoc_Node, Ins_Actions); Scope_Suppress := Svg; end; else declare -Svg : constant Boolean := Scope_Suppress (Suppress); +Svg : constant Boolean := Scope_Suppress.Suppress (Suppress); begin -Scope_Suppress (Suppress) := True; +Scope_Suppress.Suppress (Suppress) := True; Insert_Actions (Assoc_Node, Ins_Actions); -Scope_Suppress (Suppress) := Svg; +Scope_Suppress.Suppress (Suppress) := Svg; end; end if; end Insert_Actions; @@ -6272,9 +6272,9 @@ Name_Req : Boolean := False; Variable_Ref : Boolean := False) is - Loc : constant Source_Ptr := Sloc (Exp); - Exp_Type : constant Entity_Id := Etype (Exp); - Svg_Suppress : constant Suppress_Array := Scope_Suppress; + Loc : constant Source_Ptr := Sloc (Exp); + Exp_Type : constant Entity_Id := Etype (Exp); + Svg_Suppress : constant Suppress_Record := Scope_Suppress; Def_Id : Entity_Id; E: Node_Id; New_Exp : Node_Id; @@ -6705,7 +6705,7 @@ -- All this must not have any checks - Scope_Suppress := (others => True); + Scope_Suppress := Suppress_All; -- If it is a scalar type and we need to capture the value, just make -- a copy. Likewise for a function call, an attribute reference, an Index: switch-c.adb === --- switch-c.adb(revision 190155) +++ switch-c.adb(working copy) @@ -443,7 +443,8 @@ -- -gnated switch (disable atomic synchronization) when 'd' => - Suppress_Options (Atomic_Synchronization) := True; + Suppress_Options.Suppress (Atomic_Synchronization) := + True; -- -gnateD switch (preprocessing symbol definition) @@ -754,7 +755,9 @@ when 'o' => Ptr := Ptr + 1; - Suppress_Options (Overflow_Check) := False; + Suppress_Options.Suppress (Overflow_Check) := False; + Suppress_Options.Overflow_Checks_General := Check_All; + Suppress_Options.Overflow_Checks_Assertions := Check_All; Opt.Enable_Overflow_Checks := True; -- Processing for O switch @@ -782,12 +785,16 @@ -- exclude Atomic_Synchronization, since this is not a real -- check. - for J in Suppress_Options'Range loop + for J in Suppress_Options.Suppress'Range loop if J /= Elaboration_Check - and then J /= Atomic_Synchronization + and then +J /= Atomic_Synchronization then -Suppress_Options (J) := True; +Suppress_Options.Suppress (J) := True; end if; + + Suppress_Options.Overflow_Checks_General:= Suppress; + Suppress_Options.Overflow_Checks_Assertions := Suppress; end loop; Validity_Checks_On := False; Index: inline.ads === --- inline.ads (revision 190155) +++ inline.ads (working copy) @@ -70,7 +70,7 @@
[Ada] In Alfa mode, issue an error instead of a warning on a missing component
In Alfa mode, there is no use in applying formal verification to a codebase with a blatant error such as an access to a component not present in the type, so make the default warning an error in this mode. Tested on x86_64-pc-linux-gnu, committed on trunk 2012-08-06 Yannick Moy * sem_ch4.adb (Analyze_Selected_Component): Issue an error in Alfa mode for component not present. Index: sem_ch4.adb === --- sem_ch4.adb (revision 190155) +++ sem_ch4.adb (working copy) @@ -4343,10 +4343,22 @@ -- Emit appropriate message. Gigi will replace the -- node subsequently with the appropriate Raise. - Apply_Compile_Time_Constraint_Error - (N, "component not present in }?", -CE_Discriminant_Check_Failed, -Ent => Prefix_Type, Rep => False); + -- In Alfa mode, this is an made into an error to + -- simplify the treatment of the formal verification + -- backend. + + if Alfa_Mode then +Apply_Compile_Time_Constraint_Error + (N, "component not present in }", + CE_Discriminant_Check_Failed, + Ent => Prefix_Type, Rep => False); + else +Apply_Compile_Time_Constraint_Error + (N, "component not present in }?", + CE_Discriminant_Check_Failed, + Ent => Prefix_Type, Rep => False); + end if; + Set_Raises_Constraint_Error (N); return; end if;
[Ada] Portability improvement for constants related to serial ports
This change improves the process that generates s-oscons.ads so that the proper unisgned values for serial ports related constants are generated. Tested on x86_64-pc-linux-gnu, committed on trunk 2012-08-06 Thomas Quinot * s-oscons-tmplt.c, xoscons.adb: Per the Single UNIX Specification, types cc_t, speed_t, and tcflag_t defined in all are unsigned types. Add required special handling to have their correct unsigned values in s-oscons.ads. Index: s-oscons-tmplt.c === --- s-oscons-tmplt.c(revision 190158) +++ s-oscons-tmplt.c(working copy) @@ -169,6 +169,9 @@ #define CND(name,comment) \ printf ("\n->CND:$%d:" #name ":$%d:" comment, __LINE__, ((int) _VAL (name))); +#define CNU(name,comment) \ + printf ("\n->CNU:$%d:" #name ":$%u:" comment, __LINE__, ((unsigned int) _VAL (name))); + #define CNS(name,comment) \ printf ("\n->CNS:$%d:" #name ":" name ":" comment, __LINE__); @@ -185,6 +188,13 @@ : : "i" (__LINE__), "i" ((int) name)); /* Decimal constant in the range of type "int" */ +#define CNU(name, comment) \ + asm volatile("\n->CNU:%0:" #name ":%1:" comment \ + : : "i" (__LINE__), "i" ((int) name)); +/* Decimal constant in the range of type "unsigned int" (note, assembler + * always wants a signed int, we convert back in xoscons). + */ + #define CNS(name, comment) \ asm volatile("\n->CNS:%0:" #name ":" name ":" comment \ : : "i" (__LINE__)); @@ -250,9 +260,9 @@ /* - - - -- Platform identification -- - - + - + -- General platform parameters -- + - type OS_Type is (Windows, VMS, Other_OS); */ @@ -273,6 +283,10 @@ */ #define Target_Name TARGET CST(Target_Name, "") + +#define sizeof_unsigned_int sizeof (unsigned int) +CND(sizeof_unsigned_int, "Size of unsigned int") + /* --- @@ -630,210 +644,215 @@ #endif CND(TCIFLUSH, "Flush input") +#ifndef IXON +# define IXON -1 +#endif +CNU(IXON, "Output sw flow control") + #ifndef CLOCAL # define CLOCAL -1 #endif -CND(CLOCAL, "Local") +CNU(CLOCAL, "Local") #ifndef CRTSCTS # define CRTSCTS -1 #endif -CND(CRTSCTS, "Hardware flow control") +CNU(CRTSCTS, "Output hw flow control") #ifndef CREAD # define CREAD -1 #endif -CND(CREAD, "Read") +CNU(CREAD, "Read") #ifndef CS5 # define CS5 -1 #endif -CND(CS5, "5 data bits") +CNU(CS5, "5 data bits") #ifndef CS6 # define CS6 -1 #endif -CND(CS6, "6 data bits") +CNU(CS6, "6 data bits") #ifndef CS7 # define CS7 -1 #endif -CND(CS7, "7 data bits") +CNU(CS7, "7 data bits") #ifndef CS8 # define CS8 -1 #endif -CND(CS8, "8 data bits") +CNU(CS8, "8 data bits") #ifndef CSTOPB # define CSTOPB -1 #endif -CND(CSTOPB, "2 stop bits") +CNU(CSTOPB, "2 stop bits") #ifndef PARENB # define PARENB -1 #endif -CND(PARENB, "Parity enable") +CNU(PARENB, "Parity enable") #ifndef PARODD # define PARODD -1 #endif -CND(PARODD, "Parity odd") +CNU(PARODD, "Parity odd") #ifndef B0 # define B0 -1 #endif -CND(B0, "0 bps") +CNU(B0, "0 bps") #ifndef B50 # define B50 -1 #endif -CND(B50, "50 bps") +CNU(B50, "50 bps") #ifndef B75 # define B75 -1 #endif -CND(B75, "75 bps") +CNU(B75, "75 bps") #ifndef B110 # define B110 -1 #endif -CND(B110, "110 bps") +CNU(B110, "110 bps") #ifndef B134 # define B134 -1 #endif -CND(B134, "134 bps") +CNU(B134, "134 bps") #ifndef B150 # define B150 -1 #endif -CND(B150, "150 bps") +CNU(B150, "150 bps") #ifndef B200 # define B200 -1 #endif -CND(B200, "200 bps") +CNU(B200, "200 bps") #ifndef B300 # define B300 -1 #endif -CND(B300, "300 bps") +CNU(B300, "300 bps") #ifndef B600 # define B600 -1 #endif -CND(B600, "600 bps") +CNU(B600, "600 bps") #ifndef B1200 # define B1200 -1 #endif -CND(B1200, "1200 bps") +CNU(B1200, "1200 bps") #ifndef B1800 # define B1800 -1 #endif -CND(B1800, "1800 bps") +CNU(B1800, "1800 bps") #ifndef B2400 # define B2400 -1 #endif -CND(B2400, "2400 bps") +CNU(B2400, "2400 bps") #ifndef B4800 # define B4800 -1 #endif -CND(B4800, "4800 bps") +CNU(B4800, "4800 bps") #ifndef B9600 # define B9600 -1 #endif -CND(B9600, "9600 bps") +CNU(B9600, "9600 bps") #ifndef B19200 # define B19200 -1 #endif -CND(B19200, "19200 bps") +CNU(B19200, "19200 bps") #ifndef B38400 # define B38400 -1 #endif -CND(B38400, "38400 bps") +CNU(B38400, "38400 bps") #ifndef B57600 # define B57600 -1 #endif -CND(B57600, "57600 bps") +CNU(B57600, "57600 bps") #ifndef B115200 # define B115200 -1 #endif -CND(B115200, "115200 bps") +CNU(B115200, "115200 bps") #ifndef B230400 # define B230400 -1 #endif -CND(B230400, "230400 bps") +CNU(B230400, "230400 bps") #ifndef B460800 # define B460800 -1 #endif -CND(B460800, "460800 bps") +CNU(B460800, "460800 bps") #ifndef B50 # define B50 -1 #endif -CND(B50, "500
[Ada] Serial port flow control support
This change adds two new optional parameters to GNAT.Serial_Comminications.Set to allow the user to specify a local port (no modem control lines), and to choose a flow control method (none, hardware, software). Note that the default behaviour is now consistently no flow control on all platforms. Previously it was the case on Windows only; on Linux, RTS/CTS flow control was always enabled. Tested on x86_64-pc-linux-gnu, committed on trunk 2012-08-06 Thomas Quinot * g-sercom.adb, g-sercom.ads, g-sercom-mingw.adb, g-sercom-linux.adb (Set): Add Local and Flow_Control settings. Index: g-sercom.adb === --- g-sercom.adb(revision 190155) +++ g-sercom.adb(working copy) @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 2007-2010, AdaCore -- +-- Copyright (C) 2007-2012, AdaCore -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -82,6 +82,8 @@ Stop_Bits : Stop_Bits_Number := One; Parity: Parity_Check := None; Block : Boolean := True; + Local : Boolean := True; + Flow : Flow_Control := None; Timeout : Duration := 10.0) is begin Index: g-sercom.ads === --- g-sercom.ads(revision 190155) +++ g-sercom.ads(working copy) @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- ---Copyright (C) 2007-2010, AdaCore -- +--Copyright (C) 2007-2012, AdaCore -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -62,6 +62,9 @@ type Parity_Check is (None, Even, Odd); -- Either no parity check or an even or odd parity + type Flow_Control is (None, RTS_CTS, Xon_Xoff); + -- No flow control, hardware flow control, software flow control + type Serial_Port is new Ada.Streams.Root_Stream_Type with private; procedure Open @@ -77,13 +80,18 @@ Stop_Bits : Stop_Bits_Number := One; Parity: Parity_Check := None; Block : Boolean := True; + Local : Boolean := True; + Flow : Flow_Control := None; Timeout : Duration := 10.0); -- The communication port settings. If Block is set then a read call -- will wait for the whole buffer to be filed. If Block is not set then - -- the given Timeout (in seconds) is used. Note that the timeout precision - -- may be limited on some implementation (e.g. on GNU/Linux the maximum - -- precision is a tenth of seconds). + -- the given Timeout (in seconds) is used. If Local is set then modem + -- control lines (in particular DCD) are ignored (not supported on + -- Windows). + -- Note that the timeout precision may be limited on some implementation + -- (e.g. on GNU/Linux the maximum precision is a tenth of seconds). + overriding procedure Read (Port : in out Serial_Port; Buffer : out Ada.Streams.Stream_Element_Array; Index: g-sercom-mingw.adb === --- g-sercom-mingw.adb (revision 190155) +++ g-sercom-mingw.adb (working copy) @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- ---Copyright (C) 2007-2010, AdaCore -- +--Copyright (C) 2007-2012, AdaCore -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -175,8 +175,12 @@ Stop_Bits : Stop_Bits_Number := One; Parity: Parity_Check := None; Block : Boolean := True; + Local : Boolean := T
[Ada] Reject exponent of dimensioned operand that is unknown at compile-time
The test presented below illustrates the current patch. -- Source -- with System.Dim.Mks;use System.Dim.Mks; with System.Dim.Mks_IO; use System.Dim.Mks_IO; procedure Main is begin for N in -3 .. +3 loop Put (m**N , Aft => 2, Exp => 0); end loop; end Main; - -- Compilation -- - $ gcc -c -gnat12 main.adb main.adb:7:13: exponent of dimensioned operand must be known at compile-time compilation abandoned due to previous error Tested on x86_64-pc-linux-gnu, committed on trunk 2012-08-06 Vincent Pucci * sem_dim.adb (Analyze_Dimension_Binary_Op): Issue an error message for unknown exponent at compile-time. Index: sem_dim.adb === --- sem_dim.adb (revision 190155) +++ sem_dim.adb (working copy) @@ -1322,9 +1322,12 @@ -- value of the exponent must be known compile time. Otherwise, -- the exponentiation evaluation will return an error message. - if L_Has_Dimensions - and then Compile_Time_Known_Value (R) - then + if L_Has_Dimensions then + if not Compile_Time_Known_Value (R) then + Error_Msg_N ("exponent of dimensioned operand must be " & + "known at compile-time", N); + end if; + declare Exponent_Value : Rational := Zero;
[Ada] Inheritance of representation aspects at freezing point
The test presented below deals with the aspect Volatile. Indeed it's illegal to instantiate non-volatile formal object with volatile actual. -- Source -- package Volatile is type Volatile is tagged record R : Integer; end record with Volatile; -- Volatile type Der_Volatile is new Volatile with record R2 : Integer; end record; -- Volatile by inheritance generic Non_Formal_Object : in out Integer; package Non_Volatile_Formal is end; DerVol : Der_Volatile; package Error is new Non_Volatile_Formal (DerVol.R2); -- instantiation error since the actual DerVol.R2 is volatile whereas the -- formal Non_Formal_Object is non-volatile. end Volatile; - -- Compilation -- - $ gcc -c -gnat12 volatile.ads volatile.ads:16:52: cannot instantiate non-volatile formal object with volatile actual Tested on x86_64-pc-linux-gnu, committed on trunk 2012-08-06 Vincent Pucci * freeze.adb (Freeze_Entity): Inherit_Aspects_At_Freeze_Point calls added for derived types and subtypes. * sem_aux.adb, sem_aux.ads (Get_Rep_Item, Get_Rep_Pragma, Has_Rep_Pragma): New routines. * sem_ch13.ads (Inherit_Aspects_At_Freeze_Point): New routine. * sem_ch13.adb (Analyze_Aspect_Specifications): Error message for aspect Lock_Free fixed. (Inherits_Aspects_At_Freeze_Point): New routine. * sem_ch3.adb: Several flag settings removed since inheritance of aspects must be performed at freeze point. Index: sem_ch3.adb === --- sem_ch3.adb (revision 190171) +++ sem_ch3.adb (working copy) @@ -4048,12 +4048,9 @@ -- Inherit common attributes - Set_Is_Generic_Type (Id, Is_Generic_Type (Base_Type (T))); Set_Is_Volatile (Id, Is_Volatile (T)); Set_Treat_As_Volatile (Id, Treat_As_Volatile (T)); - Set_Is_Atomic (Id, Is_Atomic (T)); - Set_Is_Ada_2005_Only (Id, Is_Ada_2005_Only (T)); - Set_Is_Ada_2012_Only (Id, Is_Ada_2012_Only (T)); + Set_Is_Generic_Type (Id, Is_Generic_Type (Base_Type (T))); Set_Convention(Id, Convention(T)); -- If ancestor has predicates then so does the subtype, and in addition @@ -5855,13 +5852,6 @@ Analyze (N); - -- If pragma Discard_Names applies on the first subtype of the parent - -- type, then it must be applied on this subtype as well. - - if Einfo.Discard_Names (First_Subtype (Parent_Type)) then -Set_Discard_Names (Derived_Type); - end if; - -- Apply a range check. Since this range expression doesn't have an -- Etype, we have to specifically pass the Source_Typ parameter. Is -- this right??? @@ -7666,8 +7656,6 @@ -- Fields inherited from the Parent_Type - Set_Discard_Names -(Derived_Type, Einfo.Discard_Names (Parent_Type)); Set_Has_Specified_Layout (Derived_Type, Has_Specified_Layout (Parent_Type)); Set_Is_Limited_Composite @@ -7711,20 +7699,9 @@ Set_OK_To_Reorder_Components (Derived_Type, OK_To_Reorder_Components (Parent_Full)); -Set_Reverse_Bit_Order - (Derived_Type, Reverse_Bit_Order (Parent_Full)); -Set_Reverse_Storage_Order - (Derived_Type, Reverse_Storage_Order (Parent_Full)); end; end if; - -- Direct controlled types do not inherit Finalize_Storage_Only flag - - if not Is_Controlled (Parent_Type) then - Set_Finalize_Storage_Only - (Derived_Type, Finalize_Storage_Only (Parent_Type)); - end if; - -- Set fields for private derived types if Is_Private_Type (Derived_Type) then @@ -8043,11 +8020,6 @@ -- they are inherited from the parent type, and these invariants can -- be further inherited, so both flags are set. - if Has_Inheritable_Invariants (Parent_Type) then - Set_Has_Inheritable_Invariants (Derived_Type); - Set_Has_Invariants (Derived_Type); - end if; - -- We similarly inherit predicates if Has_Predicates (Parent_Type) then @@ -12218,7 +12190,6 @@ Set_Component_Type (T1, Component_Type (T2)); Set_Component_Size (T1, Component_Size (T2)); Set_Has_Controlled_Component (T1, Has_Controlled_Component (T2)); - Set_Finalize_Storage_Only(T1, Finalize_Storage_Only(T2)); Set_Has_Non_Standard_Rep (T1, Has_Non_Standard_Rep (T2)); Set_Has_Task (T1, Has_Task (T2)); Set_Is_Packed(T1, Is_Packed(T2)); @@ -12237,7 +12208,6 @@ Set_First_Index (T1, First_Index (T2)); Set_Is_Aliased (T1, Is_Aliased(T2));
Re: [Patch, Fortran] PR 35831: checking for dummy procedures
On 08/05/2012 11:12 PM, Janus Weil wrote: here is a patch for a rather old PR, which deals with correctness checking for several cases, such as: 1) dummy procedures 2) proc-ptr assignments 3) type-bound procedure overloading The patch adds a new function 'check_result_characteristics' to do various checks on function results. This is largely analogous to 'check_dummy_characteristics'. In both of them, there are still a few attributes left to check, which I may add in a follow-up patch. Also I had to disable the warning for cases where we can not finally determine whether the string length or shape expressions are equal. The treatment for those cases should be improved at some point, or one should think about re-enabling the warnings. Regtested on x86_64-unknown-linux-gnu. Ok for trunk? Thanks for the patch. However, I wonder about: + /* Check ALLOCATABLE attribute. */ + if (r1->attr.allocatable != r2->attr.allocatable) +{ + snprintf (errmsg, err_len, "ALLOCATABLE mismatch in function result"); + return FAILURE; +} Shouldn't one check whether errmsg != NULL? That should only occur with generic resolution, but my impression is that that code is reached. Additionally, I find "ALLOCATABLE mismatch" a bit unclear and would prefer something like "ALLOCATABLE attribute mismatch". (Ditto for some other cases.) Other items to check for: CONTIGUOUS, type-length parameter (string length), procedure-pointer results. For strings, one can have deferred ("len=:", ts.deferred) and explicit size (len=n, len=3 etc.). I think you should at least add CONTIGUOUS as it is simple - and mention the string length in the FIXME. With those changes, I am fine with the patch. Tobias PS: Some remarks, triggered by your patch but only remotely related. Though, I wouldn't mind if you (or someone else) could work on one of those ;-) Side remark 1: Talking about generic resolution: I think we should at some point implement diagnostic for generic calls as well. If the interface matches (according to ambiguity rules), it makes sense to also print an error if there is a mismatch. Currently, gfortran just prints that no specific proc to the a generic name has been found, which requires extensive digging until one find the "correct" specific function and sees that, e.g., the dummy procedure has an argument with intent(inout) and the one of the acutal argument has no intent specified. [PR40276.] Side remark 1a: F2008 has relaxed some ambiguity rules; at some point we have to implement them. (PR 45521) Side remark 2: I think we should split the type-rank mismatch diagnostic and print the gfc_typename() and, respectively, rank in the error message; one probably should pass on the errmsg as one also needs to check the kind and not only the type. (I recently run into the issues of side remark 1 and 2: First the no-specific-proc-found error; then, calling the specific function, the type/rank error; it took us a while to see that the type was okay about not the rank.) Side remark 3: I probably introduced a bug with my recent assumed-type/assumed-rank patches: It regards assumed-type/assumed-rank compatible to any other type/rank. That makes sense for checking dummy arguments - but not to check the interface of dummy procedures. For assumed-rank, an as->type check might catch it (untested), but I fear that type(*) is mishandled. Side remark 4: The following program ICEs in check_assumed_size_reference's 1386 if ((e->ref->u.ar.end[e->ref->u.ar.as->rank - 1] == NULL) as e->ref == NULL. implicit none contains function g() integer :: g(*) end function g subroutine test() procedure(g), pointer :: x x => g end subroutine test end 2012-08-05 Janus Weil PR fortran/35831 * interface.c (check_result_characteristics): New function, which checks the characteristics of function results. (gfc_compare_interfaces,gfc_check_typebound_override): Call it. 2012-08-05 Janus Weil PR fortran/35831 * gfortran.dg/dummy_procedure_5.f90: Modified. * gfortran.dg/dummy_procedure_8.f90: New. * gfortran.dg/interface_26.f90: Modified. * gfortran.dg/proc_ptr_11.f90: Modified. * gfortran.dg/proc_ptr_15.f90: Modified. * gfortran.dg/proc_ptr_result_5.f90: Modified. * gfortran.dg/typebound_override_1.f90: Modified. * gfortran.dg/typebound_proc_6.f03: Modified.
RFA: MN10300: Add support for -fstack-usage
Hi Jeff, Hi Alex, Please may I apply the small patch below to add support for reporting stack usage to the MN10300 port ? Cheers Nick gcc/ChangeLog 2012-08-06 Nick Clifton * config/mn10300/mn10300.c (mn10300_expand_prologue): Report stack usage if requested. Index: gcc/config/mn10300/mn10300.c === --- gcc/config/mn10300/mn10300.c(revision 190157) +++ gcc/config/mn10300/mn10300.c(working copy) @@ -744,6 +744,9 @@ { HOST_WIDE_INT size = mn10300_frame_size (); + if (flag_stack_usage_info) +current_function_static_stack_size = size; + /* If we use any of the callee-saved registers, save them now. */ mn10300_gen_multiple_store (mn10300_get_live_callee_saved_regs (NULL));
Re: [patch] speed up ifcvt:cond_move_convert_if_block
Il 06/08/2012 08:54, Steven Bosscher ha scritto: > Hello, > > In PR54146, ifcvt spends a lot of time just clearing memory. This > patch changes the value maps to pointer-maps to fix this issue. > > Bootstrapped&tested on x86_64-unknown-linux-gnu. OK? Nice, but perhaps we need a sparsemap to do even better? Paolo
Re: [patch] one more sched-vis fix
Hi Steven, On 03.08.2012 12:02, Steven Bosscher wrote: Hello, I also need to handle SEQUENCE, of course, or slim dumping fails in targets with branch delay slots. But who knew SEQUENCE can also appear as a REG_NOTE value?! The cfgrtl.c fix is purely cosmetic and obvious. Bootstrapped&tested on powerpc64-unknown-linux-gnu. Committed as obvious. You can even close PR 47489 as fixed then :) Andrey Ciao! Steven * sched-vis (print_pattern): Handle SEQUENCE also. * cfgrtl.c (print_rtl_with_bb): Do not print a newline between insns. Index: sched-vis.c === --- sched-vis.c (revision 190016) +++ sched-vis.c (working copy) @@ -610,8 +610,19 @@ print_pattern (char *buf, const_rtx x, int verbose } break; case SEQUENCE: - /* Should never see SEQUENCE codes until after reorg. */ - gcc_unreachable (); + { + int i; + + sprintf (t1, "sequence{"); + for (i = 0; i < XVECLEN (x, 0); i++) + { + print_pattern (t2, XVECEXP (x, 0, i), verbose); + sprintf (t3, "%s%s;", t1, t2); + strcpy (t1, t3); + } + sprintf (buf, "%s}", t1); + } + break; case ASM_INPUT: sprintf (buf, "asm {%s}", XSTR (x, 0)); break; Index: cfgrtl.c === --- cfgrtl.c(revision 190112) +++ cfgrtl.c(working copy) @@ -1958,10 +1958,9 @@ print_rtl_with_bb (FILE *outf, const_rtx rtx_first dump_bb_info (outf, bb, 0, dump_flags | TDF_COMMENT, false, true); if (df && (flags & TDF_DETAILS)) df_dump_bottom (bb, outf); + putc ('\n', outf); } } - - putc ('\n', outf); } free (start);
Re: [patch] speed up ifcvt:cond_move_convert_if_block
On Mon, Aug 6, 2012 at 1:07 PM, Paolo Bonzini wrote: > Il 06/08/2012 08:54, Steven Bosscher ha scritto: >> Hello, >> >> In PR54146, ifcvt spends a lot of time just clearing memory. This >> patch changes the value maps to pointer-maps to fix this issue. >> >> Bootstrapped&tested on x86_64-unknown-linux-gnu. OK? > > Nice, but perhaps we need a sparsemap to do even better? If you mean sparseset: no, it won't do any better. My first idea was to use a sparseset, but: 1. The amount of memory allocated is simply too big. In fact, it'd be even worse than before: 4*max_regno*sizeof(rtx) instead of "only" 2*max_regno*sizeof(rtx). 2. sparseset has the same problem of memory clearing (for valgrind, see sparseset_alloc). Remember, we can call this function cond_move_convert_if_block O(n_basic_block) times: On a CFG with mostly regular control flow, i.e. no or few computed jumps, jump tables, and exception handlers, the number of IF-THEN-{,ELSE_}-JOIN blocks will be O(n_basic_blocks) and cond_move_convert_if_block is called on almost all of them. What could work, is to allocate a sparseset once at the beginning of if_convert, but I don't see any good reason to add a pair of global variables for this. My patch reduces the time spent in ifcvt to almost nothing (down from ~250s, which is still not so bad, considering we're looking at a function with >26 basic blocks!). Ciao! Steven
Re: [patch] one more sched-vis fix
On Mon, Aug 6, 2012 at 1:16 PM, Andrey Belevantsev wrote: > Hi Steven, > > > On 03.08.2012 12:02, Steven Bosscher wrote: >> >> Hello, >> >> I also need to handle SEQUENCE, of course, or slim dumping fails in >> targets with branch delay slots. But who knew SEQUENCE can also appear >> as a REG_NOTE value?! >> >> The cfgrtl.c fix is purely cosmetic and obvious. >> >> Bootstrapped&tested on powerpc64-unknown-linux-gnu. Committed as obvious. > > > You can even close PR 47489 as fixed then :) Heh, nice :-) Thus, closed as fixed. Thanks! Ciao! Steven
Re: [patch] speed up ifcvt:cond_move_convert_if_block
Il 06/08/2012 13:15, Steven Bosscher ha scritto: > On Mon, Aug 6, 2012 at 1:07 PM, Paolo Bonzini wrote: >> Il 06/08/2012 08:54, Steven Bosscher ha scritto: >>> Hello, >>> >>> In PR54146, ifcvt spends a lot of time just clearing memory. This >>> patch changes the value maps to pointer-maps to fix this issue. >>> >>> Bootstrapped&tested on x86_64-unknown-linux-gnu. OK? >> >> Nice, but perhaps we need a sparsemap to do even better? > > If you mean sparseset: no, it won't do any better. No, I mean "inventing" a sparseset that cannot do boolean operations, but can store an associative value in a second dense array. That is sparsemap_insert(m, k, v) { if (!sparsemap_contains(m, k)) { s->sparse[k] = s->members++; s->dense_keys[i] = k; } i = s->sparse[k]; s->dense_values[i] = v; } sparsemap_contains(m, k) { if (!sparsemap_contains(m, k)) { return -1; } else { return s->dense_values[i]; } > My first idea was to use a sparseset, but: > > 1. The amount of memory allocated is simply too big. In fact, it'd be > even worse than before: 4*max_regno*sizeof(rtx) instead of "only" > 2*max_regno*sizeof(rtx). Yeah, sparseset wastes some memory. I wonder if the dense array should be allocated separately and even made dynamically resizable, also because... > 2. sparseset has the same problem of memory clearing (for valgrind, > see sparseset_alloc). ... only the sparse array needs this clearing, but currently we do it for both. > What could work, is to allocate a sparseset once at the beginning of > if_convert, but I don't see any good reason to add a pair of global > variables for this. Yes, this is what I meant. Fast clearing is where sparsesets behave well, so it makes sense to make them global in that case. What I missed was that the maps remain small. Otherwise they would also need clearing. Paolo
Re: cosmetic change - simplify cse.c:preferable()
On Sat, 4 Aug 2012, Dimitrios Apostolou wrote: > On Thu, 19 Jul 2012, Richard Guenther wrote: > > > > I don't think it's any good or clearer to understand. > > Hi Richi, I had forgotten I prepared this for PR #19832, maybe you want to > take a look. FWIW, with my patch applied there is a difference of ~3 M instr, > which is almost unmeasurable in time. But we can close the PR even with the > simple patch Cristophe posted, since mine does not make things clearer. Christophes patch is ok. We still want to if-convert this in the compiler though. Thanks, Richard.
Re: [PATCH] Follow-up to the last gengtype patch: handle DEF_VEC_A in gengtype
Ping? 2012/7/30 Laurynas Biveinis : > I only remembered to add DEF_VEC_A handlgin to gengtype.c a second after > committing the previous patch [1]. > > Here it is, done as a follow up. With some luck, this will be short-lived > code because of the C++ conversion. > > Bootstrapped and regtested on x86_64 linux. OK for trunk? > > 2012-07-30 Laurynas Biveinis > > * gengtype.h (enum gc_vec_type_kind): New. > List individual vector kinds in the token codes. > * gengtype-lex.l: Handle DEF_VEC_A, DEF_VEC_O, DEF_VEC_P, > DEF_VEC_I individually. > * gengtype-parse.c (token_names): Replace "DEF_VEC_[OP]" with > individual vector token names. > (def_vec): handle vector token types separately. > (parse_file): handle the new vector token types. > * gengtype.c (note_def_vec): remove is_scalar argument, introduce > vec_type_argument instead. Create GTY option and resolve the > vector element type according to vec_type_argument value. > -- Laurynas
Re: [Patch, Fortran] PR 35831: checking for dummy procedures
Hi Tobias, thanks for the review! >> here is a patch for a rather old PR, which deals with correctness >> checking for several cases, such as: >> 1) dummy procedures >> 2) proc-ptr assignments >> 3) type-bound procedure overloading >> >> The patch adds a new function 'check_result_characteristics' to do >> various checks on function results. This is largely analogous to >> 'check_dummy_characteristics'. In both of them, there are still a few >> attributes left to check, which I may add in a follow-up patch. Also I >> had to disable the warning for cases where we can not finally >> determine whether the string length or shape expressions are equal. >> The treatment for those cases should be improved at some point, or one >> should think about re-enabling the warnings. >> >> Regtested on x86_64-unknown-linux-gnu. Ok for trunk? > > > Thanks for the patch. However, I wonder about: > > + /* Check ALLOCATABLE attribute. */ > + if (r1->attr.allocatable != r2->attr.allocatable) > +{ > + snprintf (errmsg, err_len, "ALLOCATABLE mismatch in function > result"); > + return FAILURE; > +} > > Shouldn't one check whether errmsg != NULL? That should only occur with > generic resolution, but my impression is that that code is reached. I have to admit that I did not properly think about this point. Now that I do, I actually conclude that 'check_result_characteristics' is apparently never called without errmsg. 'gfc_compare_interfaces' only calls it when 'strict_flag' is set, and it is never called with strict_flag and without errmsg. > Additionally, I find "ALLOCATABLE mismatch" a bit unclear and would prefer > something like "ALLOCATABLE attribute mismatch". Ok, I have done so for this one and the other attribute checks. > Other items to check for: CONTIGUOUS, type-length parameter (string length), > procedure-pointer results. The string length checking I already had, and the other two I added now. > For strings, one can have deferred ("len=:", > ts.deferred) and explicit size (len=n, len=3 etc.). The deferred checking was still missing for the string length, but I have added it now. > With those changes, I am fine with the patch. Thanks. I will commit the attached version after another regtest - unless there are further complaints in the meantime. [Your further remarks I will ignore for now. For some of them, one should maybe open a PR to keep track.] Cheers, Janus > PS: Some remarks, triggered by your patch but only remotely related. Though, > I wouldn't mind if you (or someone else) could work on one of those ;-) > > Side remark 1: Talking about generic resolution: I think we should at some > point implement diagnostic for generic calls as well. If the interface > matches (according to ambiguity rules), it makes sense to also print an > error if there is a mismatch. Currently, gfortran just prints that no > specific proc to the a generic name has been found, which requires extensive > digging until one find the "correct" specific function and sees that, e.g., > the dummy procedure has an argument with intent(inout) and the one of the > acutal > argument has no intent specified. [PR40276.] > > Side remark 1a: F2008 has relaxed some ambiguity rules; at some point we > have to implement them. (PR 45521) > > Side remark 2: I think we should split the type-rank mismatch diagnostic and > print the gfc_typename() and, respectively, rank in the error message; one > probably should pass on the errmsg as one also needs to check the kind and > not only the type. > > (I recently run into the issues of side remark 1 and 2: First the > no-specific-proc-found error; then, calling the specific function, the > type/rank error; it took us a while to see that the type was okay about not > the rank.) > > Side remark 3: I probably introduced a bug with my recent > assumed-type/assumed-rank patches: It regards assumed-type/assumed-rank > compatible to any other type/rank. That makes sense for checking dummy > arguments - but not to check the interface of dummy procedures. For > assumed-rank, an as->type check might catch it (untested), but I fear that > type(*) is mishandled. > > Side remark 4: The following program ICEs in check_assumed_size_reference's > 1386 if ((e->ref->u.ar.end[e->ref->u.ar.as->rank - 1] == NULL) > as e->ref == NULL. > > implicit none > contains > function g() > integer :: g(*) > end function g > > subroutine test() > procedure(g), pointer :: x > x => g > end subroutine test > end > > >> 2012-08-05 Janus Weil >> >> PR fortran/35831 >> * interface.c (check_result_characteristics): New function, which >> checks >> the characteristics of function results. >> (gfc_compare_interfaces,gfc_check_typebound_override): Call it. >> >> 2012-08-05 Janus Weil >> >> PR fortran/35831 >> * gfortran.dg/dummy_procedure_5.f90: Modified. >> * gfortran.dg/dummy_procedure_8.f90: New. >> * gfortran.dg/interface_26.f90: Mod
Huge change on 4.7 branch
Hi Nick, You checked a huge change into 4,7 branch: http://gcc.gnu.org/ml/gcc-cvs/2012-08/msg00149.html Is this an accident? -- H.J.
Re: Huge change on 4.7 branch
On Mon, Aug 6, 2012 at 3:25 PM, H.J. Lu wrote: > Hi Nick, > > You checked a huge change into 4,7 branch: > > http://gcc.gnu.org/ml/gcc-cvs/2012-08/msg00149.html > > Is this an accident? I hope so. Please revert. Thanks, Richard. > -- > H.J.
Re: Huge change on 4.7 branch
Hi H.J.., Hi Richard, Change reverted. Sorry about the mess-up. I was trying to perform a local merge but I had my cached svn control directories the wrong way around. Doh. Cheers Nick
[PATCH - C++] Avoid crashing on erroneous static_assert usage
When working on something else, I noticed that failing to provide the second argument to the static_assert operator would lead to an ICE. Fixed thus, and tested against trunk on x86_64-unknown-linux-gnu. gcc/cp/ * semantics.c (finish_static_assert): Don't crash on erroneous message or condition. gcc/testsuite/ * g++.dg/cpp0x/static_assert8.C: New test. --- gcc/cp/semantics.c |6 ++ gcc/testsuite/g++.dg/cpp0x/static_assert8.C |7 +++ 2 files changed, 13 insertions(+), 0 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/static_assert8.C diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index b27e8ab..230e967 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -5099,6 +5099,12 @@ void finish_static_assert (tree condition, tree message, location_t location, bool member_p) { + if (message == NULL_TREE + || message == error_mark_node + || condition == NULL_TREE + || condition == error_mark_node) +return; + if (check_for_bare_parameter_packs (condition)) condition = error_mark_node; diff --git a/gcc/testsuite/g++.dg/cpp0x/static_assert8.C b/gcc/testsuite/g++.dg/cpp0x/static_assert8.C new file mode 100644 index 000..ea23afb --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/static_assert8.C @@ -0,0 +1,7 @@ +// { dg-do compile { target c++11 } } + +static_assert (1 == 0); // { dg-error "expected (string-literal|',') before" } + +static_assert (1 == 0,); // { dg-error "expected string-literal before '\\)'" } + +static_assert (1 == 0, "oops"); // { dg-error "static assertion failed" } -- Dodji
Re: [google/main] Add powerpc-grtev3-linux-gnu.xfail to contrib/testsuite-management (issue6447087)
OK. Don't forget to add xfail files for google/trunk and google/gcc-4_7, too. Ollie On Fri, Aug 3, 2012 at 9:14 AM, Simon Baldwin wrote: > > Add powerpc-grtev3-linux-gnu.xfail to contrib/testsuite-management. > > Tested with build followed by validate_failures.py. > > 2012-08-03 Simon Baldwin > > * testsuite-management/powerpc-grtev3-linux-gnu.xfail: New. > > > Index: contrib/testsuite-management/powerpc-grtev3-linux-gnu.xfail > === > --- contrib/testsuite-management/powerpc-grtev3-linux-gnu.xfail (revision > 0) > +++ contrib/testsuite-management/powerpc-grtev3-linux-gnu.xfail (revision > 0) > @@ -0,0 +1,172 @@ > +# Temporarily ignore gcc pr54127. > +expire=20121031 | FAIL: gcc.dg/torture/pr53589.c -O3 -g (test for excess > errors) > +expire=20121031 | FAIL: gcc.dg/torture/pr53589.c -O3 -g (internal > compiler error) > + > +FAIL: gfortran.dg/bessel_6.f90 -O0 execution test > +FAIL: gfortran.dg/bessel_6.f90 -O1 execution test > +FAIL: gfortran.dg/bessel_6.f90 -O2 execution test > +FAIL: gfortran.dg/bessel_6.f90 -O3 -fomit-frame-pointer execution test > +FAIL: gfortran.dg/bessel_6.f90 -O3 -fomit-frame-pointer -funroll-loops > execution test > +FAIL: gfortran.dg/bessel_6.f90 -O3 -fomit-frame-pointer > -funroll-all-loops -finline-functions execution test > +FAIL: gfortran.dg/bessel_6.f90 -O3 -g execution test > +FAIL: gfortran.dg/bessel_6.f90 -Os execution test > +XPASS: gfortran.dg/nint_2.f90 -O0 execution test > +FAIL: gfortran.dg/unf_io_convert_3.f90 -O0 execution test > +FAIL: gfortran.dg/unf_io_convert_3.f90 -O1 execution test > +FAIL: gfortran.dg/unf_io_convert_3.f90 -O2 execution test > +FAIL: gfortran.dg/unf_io_convert_3.f90 -O3 -fomit-frame-pointer > execution test > +FAIL: gfortran.dg/unf_io_convert_3.f90 -O3 -fomit-frame-pointer > -funroll-loops execution test > +FAIL: gfortran.dg/unf_io_convert_3.f90 -O3 -fomit-frame-pointer > -funroll-all-loops -finline-functions execution test > +FAIL: gfortran.dg/unf_io_convert_3.f90 -O3 -g execution test > +FAIL: gfortran.dg/unf_io_convert_3.f90 -Os execution test > +FAIL: gfortran.dg/x_slash_2.f -O0 execution test > +FAIL: g++.dg/abi/forced.C -std=gnu++98 execution test > +FAIL: g++.dg/abi/forced.C -std=gnu++11 execution test > +FAIL: g++.dg/ext/cleanup-10.C -std=gnu++98 execution test > +FAIL: g++.dg/ext/cleanup-10.C -std=gnu++11 execution test > +FAIL: g++.dg/ext/cleanup-11.C -std=gnu++98 execution test > +FAIL: g++.dg/ext/cleanup-11.C -std=gnu++11 execution test > +FAIL: g++.dg/ext/cleanup-8.C -std=gnu++98 execution test > +FAIL: g++.dg/ext/cleanup-8.C -std=gnu++11 execution test > +FAIL: g++.dg/ext/cleanup-9.C -std=gnu++98 execution test > +FAIL: g++.dg/ext/cleanup-9.C -std=gnu++11 execution test > +FAIL: g++.dg/warn/Wself-assign-2.C -std=gnu++11 (test for warnings, line > 12) > +FAIL: g++.dg/tree-prof/lipo/vcall1_0.C scan-ipa-dump-times profile > "Indirect call -> direct call" 2 > +FAIL: g++.dg/tree-prof/lipo/vcall1_0.C scan-ipa-dump-times profile > "Indirect call -> direct call" 2 > +FAIL: g++.dg/tree-prof/lipo/vcall1_0.C scan-ipa-dump-times profile > "Indirect call -> direct call" 2 > +FAIL: g++.dg/tree-prof/lipo/vcall1_0.C scan-ipa-dump-times profile > "Indirect call -> direct call" 2 > +FAIL: g++.dg/tree-prof/lipo/vcall1_0.C scan-ipa-dump-times profile > "Indirect call -> direct call" 2 > +FAIL: g++.dg/tree-prof/lipo/vcall1_0.C scan-ipa-dump-times profile > "Indirect call -> direct call" 2 > +FAIL: g++.dg/tree-prof/lipo/vcall1_0.C scan-ipa-dump-times profile > "Indirect call -> direct call" 2 > +UNRESOLVED: g++.dg/tree-prof/callgraph-profiles.C scan-file Callgraph > group : main _Z3barv _Z3foov\n > +UNRESOLVED: g++.dg/tree-prof/callgraph-profiles.C scan-file > .text.*.main\n.text.*._Z3barv\n.text.*._Z3foov\n.text.*._Z9notcalledv > +UNRESOLVED: g++.dg/tree-prof/callgraph-profiles.C scan-file Callgraph > group : main _Z3barv _Z3foov\n > +UNRESOLVED: g++.dg/tree-prof/callgraph-profiles.C scan-file > .text.*.main\n.text.*._Z3barv\n.text.*._Z3foov\n.text.*._Z9notcalledv > +UNRESOLVED: g++.dg/tree-prof/callgraph-profiles.C scan-file Callgraph > group : main _Z3barv _Z3foov\n > +UNRESOLVED: g++.dg/tree-prof/callgraph-profiles.C scan-file > .text.*.main\n.text.*._Z3barv\n.text.*._Z3foov\n.text.*._Z9notcalledv > +UNRESOLVED: g++.dg/tree-prof/callgraph-profiles.C scan-file Callgraph > group : main _Z3barv _Z3foov\n > +UNRESOLVED: g++.dg/tree-prof/callgraph-profiles.C scan-file > .text.*.main\n.text.*._Z3barv\n.text.*._Z3foov\n.text.*._Z9notcalledv > +UNRESOLVED: g++.dg/tree-prof/callgraph-profiles.C scan-file Callgraph > group : main _Z3barv _Z3foov\n > +UNRESOLVED: g++.dg/tree-prof/callgraph-profiles.C scan-file > .text.*.main\n.text.*._Z3barv\n.text.*._Z3foov\n.text.*._Z9notcalledv > +UNRESOLVED: g++.dg/tree-prof/callgraph-profiles.C scan-file Callgraph > group : main _Z3barv _Z3foov\n > +UNRESOLVED: g++.dg/tree-prof/callgraph-profiles.C scan-
Re: fix thinko in tree-emutls, breaking tls support on vxworks
On Jul 16, 2012, at 19:48 , Richard Henderson wrote: >>* tree-emutls.c (new_emutls_decl): When a var_section is requested by >>the target, attach the new decl to that, not to the template section. > > Ok. rev 190179, after a couple of weeks off. Thanks :)
Re: RFA: MN10300: Add support for -fstack-usage
On 08/06/2012 03:48 AM, Nick Clifton wrote: Hi Jeff, Hi Alex, Please may I apply the small patch below to add support for reporting stack usage to the MN10300 port ? Cheers Nick gcc/ChangeLog 2012-08-06 Nick Clifton * config/mn10300/mn10300.c (mn10300_expand_prologue): Report stack usage if requested. This is fine. Thanks. jeff
RE: [PATCH - C++] Avoid crashing on erroneous static_assert usage
Ok. Original Message From: Dodji Seketeli Sent: Mon, Aug 6, 2012 10:49 AM To: Jason Merrill CC: GCC Patches Subject: [PATCH - C++] Avoid crashing on erroneous static_assert usage When working on something else, I noticed that failing to provide the second argument to the static_assert operator would lead to an ICE. Fixed thus, and tested against trunk on x86_64-unknown-linux-gnu. gcc/cp/ * semantics.c (finish_static_assert): Don't crash on erroneous message or condition. gcc/testsuite/ * g++.dg/cpp0x/static_assert8.C: New test. --- gcc/cp/semantics.c |6 ++ gcc/testsuite/g++.dg/cpp0x/static_assert8.C |7 +++ 2 files changed, 13 insertions(+), 0 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/static_assert8.C diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index b27e8ab..230e967 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -5099,6 +5099,12 @@ void finish_static_assert (tree condition, tree message, location_t location, bool member_p) { + if (message == NULL_TREE + || message == error_mark_node + || condition == NULL_TREE + || condition == error_mark_node) +return; + if (check_for_bare_parameter_packs (condition)) condition = error_mark_node; diff --git a/gcc/testsuite/g++.dg/cpp0x/static_assert8.C b/gcc/testsuite/g++.dg/cpp0x/static_assert8.C new file mode 100644 index 000..ea23afb --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/static_assert8.C @@ -0,0 +1,7 @@ +// { dg-do compile { target c++11 } } + +static_assert (1 == 0); // { dg-error "expected (string-literal|',') before" } + +static_assert (1 == 0,); // { dg-error "expected string-literal before '\\)'" } + +static_assert (1 == 0, "oops"); // { dg-error "static assertion failed" } -- Dodji
Changed strucs to structs. (issue6442086)
This patch removes functions and structs necessary for gathering pmu info with pfmon, which is now a deprecated tool. For google/main. Tested with bootstrap. 2012-08-03 Chris Manghane * libgcc/pmu-profile.c (enum pmu_tool_type): Remove pfmon-specific functions/structs. (enum pmu_event_type): Ditto. (enum pmu_state): Ditto. (enum cpu_vendor_signature): Ditto. (struct pmu_tool_info): Ditto. (void gcov_write_branch_mispredict_infos): Ditto. (get_x86cpu_vendor): Ditto. (parse_pmu_profile_options): Ditto. (start_addr2line_symbolizer): Ditto. (reset_symbolizer_parent_pipes): Ditto. (reset_symbolizer_child_pipes): Ditto. (end_addr2line_symbolizer): Ditto. (symbolize_addr2line): Ditto. (start_pfmon_module): Ditto. (convert_pct_to_unsigned): Ditto. (parse_load_latency_line): Ditto. (parse_branch_mispredict_line): Ditto. (parse_pfmon_load_latency): Ditto. (parse_pfmon_tool_header): Ditto. (parse_pfmon_branch_mispredicts): Ditto. (pmu_start): Ditto. (init_pmu_branch_mispredict): Ditto. (init_pmu_tool): Ditto. (__gcov_init_pmu_profiler): Ditto. (__gcov_start_pmu_profiler): Ditto. (__gcov_stop_pmu_profiler): Ditto. (gcov_write_branch_mispredict_line): Ditto. (gcov_write_load_latency_infos): Ditto. (gcov_write_branch_mispredict_infos): Ditto. (gcov_write_tool_header): Ditto. (__gcov_end_pmu_profiler): Ditto. Index: libgcc/pmu-profile.c === --- libgcc/pmu-profile.c(revision 190103) +++ libgcc/pmu-profile.c(working copy) @@ -67,169 +67,11 @@ see the files COPYING3 and COPYING.RUNTIME respect #define XDELETEVEC(p) free(p) #define XDELETE(p) free(p) -#define PFMON_CMD "/usr/bin/pfmon" -#define ADDR2LINE_CMD "/usr/bin/addr2line" -#define PMU_TOOL_MAX_ARGS (20) -static char default_addr2line[] = "??:0"; -static const char pfmon_ll_header[] = "# counts %self%cum " -"<10 <32 <64<256 <1024 >=1024 %wself " -"code addr symbol\n"; -static const char pfmon_bm_header[] = -"# counts %self%cum code addr symbol\n"; - -const char *pfmon_intel_ll_args[PMU_TOOL_MAX_ARGS] = { - PFMON_CMD, - "--aggregate-results", - "--follow-all", - "--with-header", - "--smpl-module=pebs-ll", - "--ld-lat-threshold=4", - "--pebs-ll-dcmiss-code", - "--resolve-addresses", - "-emem_inst_retired:LATENCY_ABOVE_THRESHOLD", - "--long-smpl-periods=1", - 0 /* terminating NULL must be present */ -}; - -const char *pfmon_amd_ll_args[PMU_TOOL_MAX_ARGS] = { - PFMON_CMD, - "--aggregate-results", - "--follow-all", - "-uk", - "--with-header", - "--smpl-module=ibs", - "--resolve-addresses", - "-eibsop_event:uops", - "--ibs-dcmiss-code", - "--long-smpl-periods=0x0", - 0 /* terminating NULL must be present */ -}; - -const char *pfmon_intel_brm_args[PMU_TOOL_MAX_ARGS] = { - PFMON_CMD, - "--aggregate-results", - "--follow-all", - "--with-header", - "--resolve-addresses", - "-eMISPREDICTED_BRANCH_RETIRED", - "--long-smpl-periods=1", - 0 /* terminating NULL must be present */ -}; - -const char *pfmon_amd_brm_args[PMU_TOOL_MAX_ARGS] = { - PFMON_CMD, - "--aggregate-results", - "--follow-all", - "--with-header", - "--resolve-addresses", - "-eRETIRED_MISPREDICTED_BRANCH_INSTRUCTIONS", - "--long-smpl-periods=1", - 0 /* terminating NULL must be present */ -}; - -const char *addr2line_args[PMU_TOOL_MAX_ARGS] = { - ADDR2LINE_CMD, - "-e", - 0 /* terminating NULL must be present */ -}; - - -enum pmu_tool_type -{ - PTT_PFMON, - PTT_LAST -}; - -enum pmu_event_type -{ - PET_INTEL_LOAD_LATENCY, - PET_AMD_LOAD_LATENCY, - PET_INTEL_BRANCH_MISPREDICT, - PET_AMD_BRANCH_MISPREDICT, - PET_LAST -}; - -typedef struct pmu_tool_fns { - const char *name; /* name of the pmu tool */ - /* pmu tool commandline argument. */ - const char **arg_array; - /* Initialize pmu module. */ - void *(*init_pmu_module) (void); - /* Start profililing. */ - void (*start_pmu_module) (pid_t ppid, char *tmpfile, const char **args); - /* Stop profililing. */ - void (*stop_pmu_module) (void); - /* How to parse the output generated by the PMU tool. */ - int (*parse_pmu_output) (char *filename, void *pmu_data); - /* How to write parsed pmu data into gcda file. */ - void (*gcov_write_pmu_data) (void *data); - /* How to cleanup any data structure created during parsing. */ - void (*cleanup_pmu_data) (void *data); - /* How to initialize symbolizer for the PPID. */ - int (*start_symbolizer) (pid_t ppid); - void (*end_symbolizer) (void); - char *(*symbolize) (void *addr); -} pmu_tool_fns; - -enum pmu_state -{ - PMU_NONE, /* Not configurated at all. */ - PMU_INITIALIZED, /* Configured and initialized. */ - PM
Re: [google] Remove deprecated pfmon-specific functions/structs from pmu-profile.c (was: Changed strucs to structs) (issue6442086)
Revised the subject to add [google] tag and add original patch description. Chris, you can use the same subject as the original patch and just describe the revisions to the patch in the email body. Thanks, Teresa On Mon, Aug 6, 2012 at 8:51 AM, Chris Manghane wrote: > This patch removes functions and structs necessary for gathering pmu info with > pfmon, which is now a deprecated tool. > > For google/main. Tested with bootstrap. > > 2012-08-03 Chris Manghane > > * libgcc/pmu-profile.c > (enum pmu_tool_type): Remove pfmon-specific functions/structs. > (enum pmu_event_type): Ditto. > (enum pmu_state): Ditto. > (enum cpu_vendor_signature): Ditto. > (struct pmu_tool_info): Ditto. > (void gcov_write_branch_mispredict_infos): Ditto. > (get_x86cpu_vendor): Ditto. > (parse_pmu_profile_options): Ditto. > (start_addr2line_symbolizer): Ditto. > (reset_symbolizer_parent_pipes): Ditto. > (reset_symbolizer_child_pipes): Ditto. > (end_addr2line_symbolizer): Ditto. > (symbolize_addr2line): Ditto. > (start_pfmon_module): Ditto. > (convert_pct_to_unsigned): Ditto. > (parse_load_latency_line): Ditto. > (parse_branch_mispredict_line): Ditto. > (parse_pfmon_load_latency): Ditto. > (parse_pfmon_tool_header): Ditto. > (parse_pfmon_branch_mispredicts): Ditto. > (pmu_start): Ditto. > (init_pmu_branch_mispredict): Ditto. > (init_pmu_tool): Ditto. > (__gcov_init_pmu_profiler): Ditto. > (__gcov_start_pmu_profiler): Ditto. > (__gcov_stop_pmu_profiler): Ditto. > (gcov_write_branch_mispredict_line): Ditto. > (gcov_write_load_latency_infos): Ditto. > (gcov_write_branch_mispredict_infos): Ditto. > (gcov_write_tool_header): Ditto. > (__gcov_end_pmu_profiler): Ditto. > > Index: libgcc/pmu-profile.c > === > --- libgcc/pmu-profile.c(revision 190103) > +++ libgcc/pmu-profile.c(working copy) > @@ -67,169 +67,11 @@ see the files COPYING3 and COPYING.RUNTIME respect > #define XDELETEVEC(p) free(p) > #define XDELETE(p) free(p) > > -#define PFMON_CMD "/usr/bin/pfmon" > -#define ADDR2LINE_CMD "/usr/bin/addr2line" > -#define PMU_TOOL_MAX_ARGS (20) > -static char default_addr2line[] = "??:0"; > -static const char pfmon_ll_header[] = "# counts %self%cum " > -"<10 <32 <64<256 <1024 >=1024 %wself " > -"code addr symbol\n"; > -static const char pfmon_bm_header[] = > -"# counts %self%cum code addr symbol\n"; > - > -const char *pfmon_intel_ll_args[PMU_TOOL_MAX_ARGS] = { > - PFMON_CMD, > - "--aggregate-results", > - "--follow-all", > - "--with-header", > - "--smpl-module=pebs-ll", > - "--ld-lat-threshold=4", > - "--pebs-ll-dcmiss-code", > - "--resolve-addresses", > - "-emem_inst_retired:LATENCY_ABOVE_THRESHOLD", > - "--long-smpl-periods=1", > - 0 /* terminating NULL must be present */ > -}; > - > -const char *pfmon_amd_ll_args[PMU_TOOL_MAX_ARGS] = { > - PFMON_CMD, > - "--aggregate-results", > - "--follow-all", > - "-uk", > - "--with-header", > - "--smpl-module=ibs", > - "--resolve-addresses", > - "-eibsop_event:uops", > - "--ibs-dcmiss-code", > - "--long-smpl-periods=0x0", > - 0 /* terminating NULL must be present */ > -}; > - > -const char *pfmon_intel_brm_args[PMU_TOOL_MAX_ARGS] = { > - PFMON_CMD, > - "--aggregate-results", > - "--follow-all", > - "--with-header", > - "--resolve-addresses", > - "-eMISPREDICTED_BRANCH_RETIRED", > - "--long-smpl-periods=1", > - 0 /* terminating NULL must be present */ > -}; > - > -const char *pfmon_amd_brm_args[PMU_TOOL_MAX_ARGS] = { > - PFMON_CMD, > - "--aggregate-results", > - "--follow-all", > - "--with-header", > - "--resolve-addresses", > - "-eRETIRED_MISPREDICTED_BRANCH_INSTRUCTIONS", > - "--long-smpl-periods=1", > - 0 /* terminating NULL must be present */ > -}; > - > -const char *addr2line_args[PMU_TOOL_MAX_ARGS] = { > - ADDR2LINE_CMD, > - "-e", > - 0 /* terminating NULL must be present */ > -}; > - > - > -enum pmu_tool_type > -{ > - PTT_PFMON, > - PTT_LAST > -}; > - > -enum pmu_event_type > -{ > - PET_INTEL_LOAD_LATENCY, > - PET_AMD_LOAD_LATENCY, > - PET_INTEL_BRANCH_MISPREDICT, > - PET_AMD_BRANCH_MISPREDICT, > - PET_LAST > -}; > - > -typedef struct pmu_tool_fns { > - const char *name; /* name of the pmu tool */ > - /* pmu tool commandline argument. */ > - const char **arg_array; > - /* Initialize pmu module. */ > - void *(*init_pmu_module) (void); > - /* Start profililing. */ > - void (*start_pmu_module) (pid_t ppid, char *tmpfile, const char **args); > - /* Stop profililing. */ > - void (*stop_pmu_module) (void); > - /* How to parse the output generated by the PMU tool. */ > - int (*parse_pmu_output) (char *filename, vo
Re: [google] Remove deprecated pfmon-specific functions/structs from pmu-profile.c (was: Changed strucs to structs) (issue6442086)
The upload script asks for a subject, even when updating a previous issue number. Usually I just re-enter the original patch subject line, and describe the changes from the original in the patch description that I am uploading. You don't need to reload it again, it should all be tracked properly using Rietveld under the issue number. Thanks, Teresa On Mon, Aug 6, 2012 at 9:37 AM, Chris Manghane wrote: > Sorry, I'm confused. I didn't think updating the issue would change the > subject. Do I need to upload the updated patch again with the correct > subject using the upload-gcc-patch.py script or is there something I'm > missing? > > Thanks, > Chris > > > On Mon, Aug 6, 2012 at 9:13 AM, Teresa Johnson wrote: >> >> >> Revised the subject to add [google] tag and add original patch >> description. >> >> Chris, you can use the same subject as the original patch and just >> describe the revisions to the patch in the email body. >> >> Thanks, >> Teresa >> >> On Mon, Aug 6, 2012 at 8:51 AM, Chris Manghane wrote: >> > This patch removes functions and structs necessary for gathering pmu >> > info with >> > pfmon, which is now a deprecated tool. >> > >> > For google/main. Tested with bootstrap. >> > >> > 2012-08-03 Chris Manghane >> > >> > * libgcc/pmu-profile.c >> > (enum pmu_tool_type): Remove pfmon-specific functions/structs. >> > (enum pmu_event_type): Ditto. >> > (enum pmu_state): Ditto. >> > (enum cpu_vendor_signature): Ditto. >> > (struct pmu_tool_info): Ditto. >> > (void gcov_write_branch_mispredict_infos): Ditto. >> > (get_x86cpu_vendor): Ditto. >> > (parse_pmu_profile_options): Ditto. >> > (start_addr2line_symbolizer): Ditto. >> > (reset_symbolizer_parent_pipes): Ditto. >> > (reset_symbolizer_child_pipes): Ditto. >> > (end_addr2line_symbolizer): Ditto. >> > (symbolize_addr2line): Ditto. >> > (start_pfmon_module): Ditto. >> > (convert_pct_to_unsigned): Ditto. >> > (parse_load_latency_line): Ditto. >> > (parse_branch_mispredict_line): Ditto. >> > (parse_pfmon_load_latency): Ditto. >> > (parse_pfmon_tool_header): Ditto. >> > (parse_pfmon_branch_mispredicts): Ditto. >> > (pmu_start): Ditto. >> > (init_pmu_branch_mispredict): Ditto. >> > (init_pmu_tool): Ditto. >> > (__gcov_init_pmu_profiler): Ditto. >> > (__gcov_start_pmu_profiler): Ditto. >> > (__gcov_stop_pmu_profiler): Ditto. >> > (gcov_write_branch_mispredict_line): Ditto. >> > (gcov_write_load_latency_infos): Ditto. >> > (gcov_write_branch_mispredict_infos): Ditto. >> > (gcov_write_tool_header): Ditto. >> > (__gcov_end_pmu_profiler): Ditto. >> > >> > Index: libgcc/pmu-profile.c >> > === >> > --- libgcc/pmu-profile.c(revision 190103) >> > +++ libgcc/pmu-profile.c(working copy) >> > @@ -67,169 +67,11 @@ see the files COPYING3 and COPYING.RUNTIME respect >> > #define XDELETEVEC(p) free(p) >> > #define XDELETE(p) free(p) >> > >> > -#define PFMON_CMD "/usr/bin/pfmon" >> > -#define ADDR2LINE_CMD "/usr/bin/addr2line" >> > -#define PMU_TOOL_MAX_ARGS (20) >> > -static char default_addr2line[] = "??:0"; >> > -static const char pfmon_ll_header[] = "# counts %self%cum >> > " >> > -"<10 <32 <64<256 <1024 >=1024 %wself " >> > -"code addr symbol\n"; >> > -static const char pfmon_bm_header[] = >> > -"# counts %self%cum code addr symbol\n"; >> > - >> > -const char *pfmon_intel_ll_args[PMU_TOOL_MAX_ARGS] = { >> > - PFMON_CMD, >> > - "--aggregate-results", >> > - "--follow-all", >> > - "--with-header", >> > - "--smpl-module=pebs-ll", >> > - "--ld-lat-threshold=4", >> > - "--pebs-ll-dcmiss-code", >> > - "--resolve-addresses", >> > - "-emem_inst_retired:LATENCY_ABOVE_THRESHOLD", >> > - "--long-smpl-periods=1", >> > - 0 /* terminating NULL must be present */ >> > -}; >> > - >> > -const char *pfmon_amd_ll_args[PMU_TOOL_MAX_ARGS] = { >> > - PFMON_CMD, >> > - "--aggregate-results", >> > - "--follow-all", >> > - "-uk", >> > - "--with-header", >> > - "--smpl-module=ibs", >> > - "--resolve-addresses", >> > - "-eibsop_event:uops", >> > - "--ibs-dcmiss-code", >> > - "--long-smpl-periods=0x0", >> > - 0 /* terminating NULL must be present */ >> > -}; >> > - >> > -const char *pfmon_intel_brm_args[PMU_TOOL_MAX_ARGS] = { >> > - PFMON_CMD, >> > - "--aggregate-results", >> > - "--follow-all", >> > - "--with-header", >> > - "--resolve-addresses", >> > - "-eMISPREDICTED_BRANCH_RETIRED", >> > - "--long-smpl-periods=1", >> > - 0 /* terminating NULL must be present */ >> > -}; >> > - >> > -const char *pfmon_amd_brm_args[PMU_TOOL_MAX_ARGS] = { >> > - PFMON_CMD, >> > - "--aggregate-results", >> > - "--follow-all", >> > - "--with-header", >> > - "-
Re: [PATCH 0/2] Convert s390 to atomic optabs, v2
Richard Henderson wrote: While the first set of changes looks good to me, I don't understand those: > @@ -4728,7 +4733,12 @@ init_alignment_context (struct alignment_context *ac, > rtx mem, >ac->aligned = (MEM_ALIGN (mem) >= GET_MODE_BITSIZE (SImode)); > >if (ac->aligned) > -ac->memsi = adjust_address (mem, SImode, 0); /* Memory is aligned. */ > +{ > + ac->memsi = adjust_address (mem, SImode, 0); /* Memory is aligned. */ > + ac->shift = const0_rtx; > + ac->modemask = GEN_INT (GET_MODE_MASK (mode)); > + ac->modemaski = GEN_INT (~GET_MODE_MASK (mode)); > +} >else > { >/* Alignment is unknown. */ > @@ -4755,15 +4765,17 @@ init_alignment_context (struct alignment_context *ac, > rtx mem, >ac->shift = expand_simple_binop (SImode, MINUS, ac->shift, byteoffset, > NULL_RTX, 1, OPTAB_DIRECT); > > + /* Shift is the byte count, but we need the bitcount. */ > + ac->shift = expand_simple_binop (SImode, ASHIFT, ac->shift, GEN_INT > (3), > +NULL_RTX, 1, OPTAB_DIRECT); > + > + /* Calculate masks. */ > + ac->modemask = expand_simple_binop (SImode, ASHIFT, > + GEN_INT (GET_MODE_MASK (mode)), > + ac->shift, NULL_RTX, 1, OPTAB_DIRECT); > + ac->modemaski = expand_simple_unop (SImode, NOT, ac->modemask, > + NULL_RTX, 1); > } > - /* Shift is the byte count, but we need the bitcount. */ > - ac->shift = expand_simple_binop (SImode, MULT, ac->shift, GEN_INT > (BITS_PER_UNIT), > - NULL_RTX, 1, OPTAB_DIRECT); > - /* Calculate masks. */ > - ac->modemask = expand_simple_binop (SImode, ASHIFT, > - GEN_INT (GET_MODE_MASK (mode)), ac->shift, > - NULL_RTX, 1, OPTAB_DIRECT); > - ac->modemaski = expand_simple_unop (SImode, NOT, ac->modemask, NULL_RTX, > 1); > } > > /* A subroutine of s390_expand_cs_hqi. Insert INS into VAL. If possible, > @@ -4781,7 +4793,7 @@ s390_two_part_insv (struct alignment_context *ac, rtx > *seq1, rtx *seq2, >start_sequence (); >tmp = copy_to_mode_reg (SImode, val); >if (s390_expand_insv (tmp, GEN_INT (GET_MODE_BITSIZE (mode)), > - const0_rtx, ins)) > + GEN_INT (32 - GET_MODE_BITSIZE (mode)), ins)) > { > *seq1 = NULL; > *seq2 = get_insns (); "aligned" accesses do involve the *most significant* part of the word (on a big-endian machine), which means ac->shift has to be set to modesize (outer) - modesize (inner), and expand_insv needs to be called with bitpos 0 (due to bits-big-endian). When reverting this part of your patch (and together with the EQ/NE fix pointed out here: http://gcc.gnu.org/ml/gcc-patches/2012-08/msg00170.html), I can complete a bootstrap/testing cycle without regressions. (There's still code being generated that looks a bit inefficient, but that's a different story.) Bye, Ulrich -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE ulrich.weig...@de.ibm.com
Re: [RFA, patch] Add missing source location info to thunks
On 08/03/2012 04:38 PM, Cary Coutant wrote: > 2012-08-03 Cary Coutant > > * gcc/cgraphunit.c (assemble_thunk): Add source line info. > * gcc/final.c (final): Check for non-null cfg pointer. I'm uncomfortable with just the one call into the debug generator, outside of the other debug_hooks begin/end calls. It'll obviously work for stabs, and probably work for sdb, due to how the debug info is represented. But for dwarf2 it probably only works for selected targets. For instance, !DWARF2_ASM_LINE_DEBUG_INFO requires a call to dwarf2out_finish in order to get anything emitted at all. Some targets, like x86, use final_start_function + final_end_function in the output_mi_thunk hook, and that would take care of it. However, x86-linux is also going to define DWARF2_ASM_LINE_DEBUG_INFO making both cases work. And I'm guessing that's all you tested. Try a target like arm-linux (which doesn't use final_end_function), and hack the generated auto-host.h so that HAVE_AS_DWARF2_DEBUG_LINE is undefined. r~ PS: Yet Another Reason thunks should be represented as first-class citizens with a decl and other assorted paths through code emission done "properly".
Re: [PATCH 2/2] s390: Convert from sync to atomic optabs
Richard Henderson wrote: Some more comments on this patch. > +; Different from movdi_31 in that we have no splitters. > +(define_insn "atomic_loaddi_1" > + [(set (match_operand:DI 0 "register_operand" "=d,d,!*f,!*f") > + (unspec:DI [(match_operand:DI 1 "s_operand" "Q,S,Q,m")] The constraint line doesn't look right. ld(y) accept base+index, so they should get R and T constraints, respectively. In fact, I wouldn't use "s_operand" as a predicate, since this excludes valid addresses for those cases, and since in general I've found it to be preferable to have reload fix up addresses. So I'd just use "memory_operand" here, and actually in all the other patterns as well ... (This also simplifes the expander.) > +UNSPEC_MOVA))] > + "!TARGET_ZARCH" > + "@ > + lm\t%0,%M0,%S1 > + lmy\t%0,%M0,%S1 > + ld\t%0,%1 > + ldy\t%0,%1" > + [(set_attr "op_type" "RS,RSY,RS,RSY") > + (set_attr "type" "lm,lm,floaddf,floaddf")]) > + > +(define_insn "atomic_loadti_1" > + [(set (match_operand:TI 0 "register_operand" "=r") > + (unspec:TI [(match_operand:TI 1 "memory_operand" "m")] "m" is wrong here (and basically everywhere), since it includes SYMBOL_REFs for lrl etc. on z10. For lpq we need "RT". > + "lpq\t%0,%1" > + [(set_attr "op_type" "RXY")]) LPQ and STPQ probably should get a "type" of "other". This may not model the pipeline exactly, but it's better than just assuming "integer" by default. These instructions are special (and slow). > +(define_expand "atomic_compare_and_swap" > + [(match_operand:SI 0 "register_operand") ;; bool success output > + (match_operand:DGPR 1 "register_operand") ;; oldval output > + (match_operand:DGPR 2 "s_operand");; memory memory_operand probably better again. > + (match_operand:DGPR 3 "register_operand") ;; expected intput > + (match_operand:DGPR 4 "register_operand") ;; newval intput > + (match_operand:SI 5 "const_int_operand") ;; is_weak > + (match_operand:SI 6 "const_int_operand") ;; success model > + (match_operand:SI 7 "const_int_operand")] ;; failure model > + "" > +{ > + rtx cc, cmp; > + emit_insn (gen_atomic_compare_and_swap_internal > + (operands[1], operands[2], operands[3], operands[4])); > + cc = gen_rtx_REG (CCZ1mode, CC_REGNUM); > + cmp = gen_rtx_NE (SImode, cc, const0_rtx); As already pointed out, this needs to be EQ. > - "" > - "cds\t%0,%3,%S1" > - [(set_attr "op_type" "RS") > + "TARGET_ZARCH" > + "csg\t%0,%3,%S1" > + [(set_attr "op_type" "RXY") Should be "RSY" > + "@ > + cds\t%0,%3,%S1 > + cdsy\t%0,%3,%S1" > + [(set_attr "op_type" "RX,RXY") Should be "RS, RSY" > + "@ > + cs\t%0,%3,%S1 > + csy\t%0,%3,%S1" > + [(set_attr "op_type" "RX,RXY") Likewise. > +(define_insn "atomic_fetch__iaf" > + [(set (match_operand:GPR 0 "register_operand" "=d") > + (match_operand:GPR 1 "s_operand" "+S")) > + (set (match_dup 1) > + (unspec_volatile:GPR > + [(ATOMIC_Z196:GPR (match_dup 1) > +(match_operand:GPR 2 "general_operand" "d"))] > + UNSPECV_ATOMIC_OP)) > + (clobber (reg:CC CC_REGNUM))] >"TARGET_Z196" > - "la\t%0,%2,%1") > + "la\t%0,%2,%1" > + [(set_attr "op_type" "RXY") Again RSY. There is one particular inefficiency I have noticed. This code: if (!__atomic_compare_exchange_n (&v, &expected, max, 0 , 0, 0)) abort (); from atomic-compare-exchange-3.c gets compiled into: l %r3,0(%r2) larl%r1,v cs %r3,%r4,0(%r1) ipm %r1 sra %r1,28 st %r3,0(%r2) ltr %r1,%r1 jne .L3 which is extremely inefficient; it converts the condition code into an integer using the slow ipm, sra sequence, just so that it can convert the integer back into a condition code via ltr and branch on it ... Now, with the old code this sequence used to be optimized away by combine and we'd just have the cs followed by a branch. This is not done any more because we have the store to "expected" in between. This is because of this code in combine: /* Make sure that the value that is to be substituted for the register does not use any registers whose values alter in between. However, If the insns are adjacent, a use can't cross a set even though we think it might (this can happen for a sequence of insns each setting the same destination; last_set of that register might point to a NOTE). If INSN has a REG_EQUIV note, the register is always equivalent to the memory so the substitution is valid even if there are intervening stores. Also, don't move a volatile asm or UNSPEC_VOLATILE across any other insns. */ || (! all_adjacent && (((!MEM_P (src) || ! find_reg_note (insn, REG_EQUIV, src)) && use_crosses_set_p (src, DF_INSN_LUID (insn))) || (GET_CODE (src) == ASM_OPERANDS && MEM_VOLATILE_P (src))
Re: [PATCH] put exception tables for comdat functions in comdat, too
On 08/05/2012 08:40 PM, Sandra Loosemore wrote: > 2012-08-04 Paul Brook > Sandra Loosemore > > gcc/ > * except.c (switch_to_exception_section): Place tables for > DECL_ONE_ONLY functions in comdat groups. Mostly ok. > - s = get_section (section_name, flags, NULL); > + s = get_section (section_name, flags, current_function_decl); Not correct, since we're not putting the function in that section. We have no decl for the actual eh data. Though that might be a good cleanup for except.c... r~
Re: [PATCH 2/2] s390: Convert from sync to atomic optabs
On 08/06/2012 11:34 AM, Ulrich Weigand wrote: > Richard Henderson wrote: > > > Some more comments on this patch. > >> +; Different from movdi_31 in that we have no splitters. >> +(define_insn "atomic_loaddi_1" >> + [(set (match_operand:DI 0 "register_operand" "=d,d,!*f,!*f") >> +(unspec:DI [(match_operand:DI 1 "s_operand" "Q,S,Q,m")] > > The constraint line doesn't look right. ld(y) accept base+index, > so they should get R and T constraints, respectively. Yes, but since I'd limited to s_operand, R seemed weird. > In fact, I wouldn't use "s_operand" as a predicate, since this > excludes valid addresses for those cases, and since in general > I've found it to be preferable to have reload fix up addresses. > So I'd just use "memory_operand" here, and actually in all the > other patterns as well ... (This also simplifes the expander.) In the first patch I did, I had memory_operand and QS, but that ran into reload failures. I assumed I'd just made a mistake. I'll see if I can replicate this for your debugging enjoyment... > "m" is wrong here (and basically everywhere), since it includes > SYMBOL_REFs for lrl etc. on z10. For lpq we need "RT". Ah right. > LPQ and STPQ probably should get a "type" of "other". This may not > model the pipeline exactly, but it's better than just assuming > "integer" by default. These instructions are special (and slow). Noted. > There is one particular inefficiency I have noticed. This code: > > if (!__atomic_compare_exchange_n (&v, &expected, max, 0 , 0, 0)) > abort (); > > from atomic-compare-exchange-3.c gets compiled into: > > l %r3,0(%r2) > larl%r1,v > cs %r3,%r4,0(%r1) > ipm %r1 > sra %r1,28 > st %r3,0(%r2) > ltr %r1,%r1 > jne .L3 > > which is extremely inefficient; it converts the condition code into > an integer using the slow ipm, sra sequence, just so that it can > convert the integer back into a condition code via ltr and branch > on it ... ... > Is there a way of structuring the atomic optabs/expander so that the store > gets done either before or after all the CC operations? No. But I'm a bit confused since a store doesn't affect the flags, so I'm not sure why the EQ can't be combined with the branch. I'll give that another look. All that said, one of the things that MacLeod's gimple_atomic will achieve is allowing two register outputs, which (for the common case) will eliminate the store entirely. r~
Re: [PATCH 2/2] s390: Convert from sync to atomic optabs
On 08/06/2012 11:50 AM, Richard Henderson wrote: > In the first patch I did, I had memory_operand and QS, but that > ran into reload failures. I assumed I'd just made a mistake. > > I'll see if I can replicate this for your debugging enjoyment... I think I had written =S instead of =QS, which of course fails for old 31-bit. I can't reproduce the problem now... r~
Re: [RFA, patch] Add missing source location info to thunks
> I'm uncomfortable with just the one call into the debug generator, outside of > the other debug_hooks begin/end calls. > > It'll obviously work for stabs, and probably work for sdb, due to how the > debug info is represented. > > But for dwarf2 it probably only works for selected targets. > > For instance, !DWARF2_ASM_LINE_DEBUG_INFO requires a call to dwarf2out_finish > in order to get anything emitted at all. Some targets, like x86, use > final_start_function + final_end_function in the output_mi_thunk hook, and > that would take care of it. However, x86-linux is also going to define > DWARF2_ASM_LINE_DEBUG_INFO making both cases work. And I'm guessing that's > all you tested. Yep, that's all I tested. But even where output_mi_thunk doesn't call final_start_function or final_end_function, dwarf2out_finish will still be called, won't it? > Try a target like arm-linux (which doesn't use final_end_function), and hack > the generated auto-host.h so that HAVE_AS_DWARF2_DEBUG_LINE is undefined. Trying arm-unknown-linux-gnueabi now... -cary
Re: [Patch, Fortran] PR 35831: checking for dummy procedures
>> With those changes, I am fine with the patch. > > Thanks. I will commit the attached version after another regtest - > unless there are further complaints in the meantime. Committed as r190187 with some minor adjustments. Cheers, Janus >>> 2012-08-05 Janus Weil >>> >>> PR fortran/35831 >>> * interface.c (check_result_characteristics): New function, which >>> checks >>> the characteristics of function results. >>> (gfc_compare_interfaces,gfc_check_typebound_override): Call it. >>> >>> 2012-08-05 Janus Weil >>> >>> PR fortran/35831 >>> * gfortran.dg/dummy_procedure_5.f90: Modified. >>> * gfortran.dg/dummy_procedure_8.f90: New. >>> * gfortran.dg/interface_26.f90: Modified. >>> * gfortran.dg/proc_ptr_11.f90: Modified. >>> * gfortran.dg/proc_ptr_15.f90: Modified. >>> * gfortran.dg/proc_ptr_result_5.f90: Modified. >>> * gfortran.dg/typebound_override_1.f90: Modified. >>> * gfortran.dg/typebound_proc_6.f03: Modified.
Re: [RFA, patch] Add missing source location info to thunks
Richard, >> Try a target like arm-linux (which doesn't use final_end_function), and hack >> the generated auto-host.h so that HAVE_AS_DWARF2_DEBUG_LINE is undefined. > > Trying arm-unknown-linux-gnueabi now... I just built an ARM compiler and tried it out on my testcase. It generated this code for one of the thunks: .section.text._ZThn8_N1CD1Ev,"ax",%progbits .align 2 .global _ZThn8_N1CD1Ev .type _ZThn8_N1CD1Ev, %function _ZThn8_N1CD1Ev: .fnstart @ thunk.cc:25 .LM21: sub r0, r0, #8 b .LTHUNK0 .fnend .size _ZThn8_N1CD1Ev, .-_ZThn8_N1CD1Ev and further down, in the .debug_line section, this: .byte 0 @ set address *.LM21 .uleb128 0x5 .byte 0x2 .4byte .LM21 .byte 0x2f@ line 25 Same for the other thunk. I think that's all good. Do you still have concerns about the patch? -cary
Re: [RFA, patch] Add missing source location info to thunks
Here's a revised patch, with testcase added, and with Steven's suggested change... -cary 2012-08-06 Cary Coutant gcc/ * cgraphunit.c (assemble_thunk): Add source line info. * final.c (final): Check for non-null cfg pointer. * testsuite/g++.dg/debug/dwarf2/non-virtual-thunk.C: New test case. commit db557f2dabd9658e59a5111dd156aa39d691bf22 Author: Cary Coutant Date: Mon Aug 6 12:48:31 2012 -0700 Add line number info for thunks; fix an ICE when -dA used with thunks. gcc/ * cgraphunit.c (assemble_thunk): Add source line info. * final.c (final): Check for non-null cfg pointer. * testsuite/g++.dg/debug/dwarf2/non-virtual-thunk.C: New test case. diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c index a6591b5..2dd0871 100644 --- a/gcc/cgraphunit.c +++ b/gcc/cgraphunit.c @@ -1381,6 +1381,10 @@ assemble_thunk (struct cgraph_node *node) init_function_start (thunk_fndecl); cfun->is_thunk = 1; assemble_start_function (thunk_fndecl, fnname); + (*debug_hooks->source_line) (DECL_SOURCE_LINE (thunk_fndecl), + DECL_SOURCE_FILE (thunk_fndecl), + /* discriminator */ 0, + /* is_stmt */ 1); targetm.asm_out.output_mi_thunk (asm_out_file, thunk_fndecl, fixed_offset, virtual_value, alias); diff --git a/gcc/final.c b/gcc/final.c index cdae011..30890b3 100644 --- a/gcc/final.c +++ b/gcc/final.c @@ -1863,11 +1863,13 @@ final (rtx first, FILE *file, int optimize_p) start_to_bb = XCNEWVEC (basic_block, bb_map_size); end_to_bb = XCNEWVEC (basic_block, bb_map_size); - FOR_EACH_BB_REVERSE (bb) - { - start_to_bb[INSN_UID (BB_HEAD (bb))] = bb; - end_to_bb[INSN_UID (BB_END (bb))] = bb; - } + /* There is no cfg for a thunk. */ + if (!cfun->is_thunk) + FOR_EACH_BB_REVERSE (bb) + { + start_to_bb[INSN_UID (BB_HEAD (bb))] = bb; + end_to_bb[INSN_UID (BB_END (bb))] = bb; + } } /* Output the insns. */ diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/non-virtual-thunk.C b/gcc/testsuite/g++.dg/debug/dwar new file mode 100644 index 000..8ad347a --- /dev/null +++ b/gcc/testsuite/g++.dg/debug/dwarf2/non-virtual-thunk.C @@ -0,0 +1,39 @@ +// { dg-do compile } +// { dg-options "-g2 -dA" } + +// Verify that line number info is output for the non-virtual +// thunks for C::~C(). +// { dg-final { scan-assembler "thunk.C:30" } } + +class A +{ + public: + A(); + virtual ~A(); + private: + int i; +}; + +class B +{ + public: + B(); + virtual ~B(); + private: + int i; +}; + +class C : public A, public B +{ + public: + C(); + virtual ~C(); // line 30 +}; + +C::C() +{ +} + +C::~C() +{ +}
Re: [RFA, patch] Add missing source location info to thunks
On 08/06/2012 02:45 PM, Cary Coutant wrote: > Do you still have concerns about the patch? Nope. I'd mis-remembered from whence things get finalized. Revised patch is ok. r~
Re: [PATCH] Set correct source location for deallocator calls
Ping... Richard, could you shed some lights on this? Thanks, Dehao On Mon, Jul 30, 2012 at 8:29 PM, Dehao Chen wrote: > Hi, > > This patch fixes the source location for automatically generated calls > to deallocator. For example: > > 19 void foo(int i) > 20 { > 21 for (int j = 0; j < 10; j++) > 22 { > 23 t test; > 24 test.foo(); > 25 if (i + j) > 26 { > 27 test.bar(); > 28 return; > 29 } > 30 } > 31 return; > 32 } > > The deallocator for "23 t test" is called in two places: Line 28 and > line 30. However, gcc attributes both callsites to line 30. > > Bootstrapped and passed gcc regression tests. > > Is it ok for trunk? > > Thanks, > Dehao > > gcc/ChangeLog > > 2012-07-31 Dehao Chen > > * tree-eh.c (goto_queue_node): New field. > (record_in_goto_queue): New parameter. > (record_in_goto_queue_label): New parameter. > (lower_try_finally_copy): Update source location. > > gcc/testsuite/ChangeLog > > 2012-07-31 Dehao Chen > > * g++.dg/guality/deallocator.C: New test. > > Index: gcc/testsuite/g++.dg/guality/deallocator.C > === > --- gcc/testsuite/g++.dg/guality/deallocator.C (revision 0) > +++ gcc/testsuite/g++.dg/guality/deallocator.C (revision 0) > @@ -0,0 +1,33 @@ > +// Test that debug info generated for auto-inserted deallocator is > +// correctly attributed. > +// This patch scans for the lineno directly from assembly, which may > +// differ between different architectures. Because it mainly tests > +// FE generated debug info, without losing generality, only x86 > +// assembly is scanned in this test. > +// { dg-do compile { target { i?86-*-* x86_64-*-* } } } > +// { dg-options "-O2 -fno-exceptions -g" } > + > +struct t { > + t (); > + ~t (); > + void foo(); > + void bar(); > +}; > + > +int bar(); > + > +void foo(int i) > +{ > + for (int j = 0; j < 10; j++) > +{ > + t test; > + test.foo(); > + if (i + j) > + { > + test.bar(); > + return; > + } > +} > + return; > +} > +// { dg-final { scan-assembler "1 28 0" } } > Index: gcc/tree-eh.c > === > --- gcc/tree-eh.c (revision 189835) > +++ gcc/tree-eh.c (working copy) > @@ -321,6 +321,7 @@ > struct goto_queue_node > { >treemple stmt; > + enum gimple_code code; >gimple_seq repl_stmt; >gimple cont_stmt; >int index; > @@ -560,7 +561,8 @@ > record_in_goto_queue (struct leh_tf_state *tf, >treemple new_stmt, >int index, > - bool is_label) > + bool is_label, > + enum gimple_code code) > { >size_t active, size; >struct goto_queue_node *q; > @@ -583,6 +585,7 @@ >memset (q, 0, sizeof (*q)); >q->stmt = new_stmt; >q->index = index; > + q->code = code; >q->is_label = is_label; > } > > @@ -590,7 +593,8 @@ > TF is not null. */ > > static void > -record_in_goto_queue_label (struct leh_tf_state *tf, treemple stmt, tree > label) > +record_in_goto_queue_label (struct leh_tf_state *tf, treemple stmt, tree > label, > + enum gimple_code code) > { >int index; >treemple temp, new_stmt; > @@ -629,7 +633,7 @@ > since with a GIMPLE_COND we have an easy access to the then/else > labels. */ >new_stmt = stmt; > - record_in_goto_queue (tf, new_stmt, index, true); > + record_in_goto_queue (tf, new_stmt, index, true, code); > } > > /* For any GIMPLE_GOTO or GIMPLE_RETURN, decide whether it leaves a > try_finally > @@ -649,19 +653,22 @@ > { > case GIMPLE_COND: >new_stmt.tp = gimple_op_ptr (stmt, 2); > - record_in_goto_queue_label (tf, new_stmt, gimple_cond_true_label > (stmt)); > + record_in_goto_queue_label (tf, new_stmt, gimple_cond_true_label > (stmt), > + gimple_code (stmt)); >new_stmt.tp = gimple_op_ptr (stmt, 3); > - record_in_goto_queue_label (tf, new_stmt, > gimple_cond_false_label (stmt)); > + record_in_goto_queue_label (tf, new_stmt, gimple_cond_false_label > (stmt), > + gimple_code (stmt)); >break; > case GIMPLE_GOTO: >new_stmt.g = stmt; > - record_in_goto_queue_label (tf, new_stmt, gimple_goto_dest (stmt)); > + record_in_goto_queue_label (tf, new_stmt, gimple_goto_dest (stmt), > + gimple_code (stmt)); >break; > > case GIMPLE_RETURN: >tf->may_return = true; >new_stmt.g = stmt; > - record_in_goto_queue (tf, new_stmt, -1, false); > + record_in_goto_queue (tf, new_stmt, -1, false, gimple_code (stmt)); >break; > > default: > @@ -1234,6 +1241,7 @@ >for (index = 0; index < return_index + 1; index++) > { >
s390: Avoid CAS boolean output inefficiency
On 08/06/2012 11:34 AM, Ulrich Weigand wrote: > There is one particular inefficiency I have noticed. This code: > > if (!__atomic_compare_exchange_n (&v, &expected, max, 0 , 0, 0)) > abort (); > > from atomic-compare-exchange-3.c gets compiled into: > > l %r3,0(%r2) > larl%r1,v > cs %r3,%r4,0(%r1) > ipm %r1 > sra %r1,28 > st %r3,0(%r2) > ltr %r1,%r1 > jne .L3 > > which is extremely inefficient; it converts the condition code into > an integer using the slow ipm, sra sequence, just so that it can > convert the integer back into a condition code via ltr and branch > on it ... This was caused (or perhaps abetted by) the representation of EQ as NE ^ 1. With the subsequent truncation and zero-extend, I think combine reached its insn limit of 3 before seeing everything it needed to see. I'm able to fix this problem by representing EQ as EQ before reload. For extimm targets this results in identical code; for older targets it requires avoidance of the constant pool, i.e. LHI+XR instead of X. l %r2,0(%r3) larl%r1,v cs %r2,%r5,0(%r1) st %r2,0(%r3) jne .L3 That fixed, we see the second CAS in that file: .loc 1 27 0 cs %r2,%r2,0(%r1) ipm %r5 sll %r5,28 lhi %r0,1 xr %r5,%r0 st %r2,0(%r3) ltr %r5,%r5 je .L20 This happens because CSE notices the cbranch vs 0, and sets r116 to zero along the path to 32 if (!__atomic_compare_exchange_n (&v, &expected, 0, STRONG, __ATOMIC_RELEASE, __ATOMIC_ACQUIRE)) at which point CSE decides that it would be cheaper to "re-use" the zero already in r116 instead of load another constant 0 here. After that, combine is ham-strung because r116 is not dead. I'm not quite sure the best way to fix this, since rtx_costs already has all constants cost 0. CSE ought not believe that r116 is better than a plain constant. CSE also shouldn't be extending the life of pseudos this way. A short-term possibility is to have the CAS insns accept general_operand, so that the 0 gets merged. With reload inheritance and post-reload cse, that might produce code that is "good enough". Certainly it's effective for the atomic-compare-exchange-3.c testcase. I'm less than happy with that, since the non-optimization of CAS depends on following code that is totally unrelated. This patch ought to be independent of any other patch so far. r~ diff --git a/gcc/config/s390/s390.md b/gcc/config/s390/s390.md index 0e43e51..bed6b79 100644 --- a/gcc/config/s390/s390.md +++ b/gcc/config/s390/s390.md @@ -5325,12 +5325,15 @@ (match_operand 3 "const0_operand")])) (clobber (reg:CC CC_REGNUM))])] "" - "emit_insn (gen_sne (operands[0], operands[2])); - if (GET_CODE (operands[1]) == EQ) - emit_insn (gen_xorsi3 (operands[0], operands[0], const1_rtx)); - DONE;") +{ + if (!TARGET_EXTIMM && GET_CODE (operands[1]) == EQ) +{ + emit_insn (gen_seq_neimm (operands[0], operands[2])); + DONE; +} +}) -(define_insn_and_split "sne" +(define_insn_and_split "*sne" [(set (match_operand:SI 0 "register_operand" "=d") (ne:SI (match_operand:CCZ1 1 "register_operand" "0") (const_int 0))) @@ -5342,6 +5345,48 @@ [(set (match_dup 0) (ashiftrt:SI (match_dup 0) (const_int 28))) (clobber (reg:CC CC_REGNUM))])]) +(define_insn_and_split "*seq" + [(set (match_operand:SI 0 "register_operand" "=d") + (eq:SI (match_operand:CCZ1 1 "register_operand" "0") + (const_int 0))) + (clobber (reg:CC CC_REGNUM))] + "TARGET_EXTIMM" + "#" + "&& reload_completed" + [(const_int 0)] +{ + rtx op0 = operands[0]; + emit_insn (gen_lshrsi3 (op0, op0, GEN_INT (28))); + emit_insn (gen_xorsi3 (op0, op0, const1_rtx)); + DONE; +}) + +;; ??? Ideally we'd USE a const1_rtx, properly reloaded, but that makes +;; things more difficult for combine (which can only insert clobbers). +;; But perhaps it would be better still to have simply used a branch around +;; constant load instead of beginning with the IPM? +;; +;; What about LOCR for Z196? That's a more general question about cstore +;; being decomposed into movcc... + +(define_insn_and_split "seq_neimm" + [(set (match_operand:SI 0 "register_operand" "=d") + (eq:SI (match_operand:CCZ1 1 "register_operand" "0") + (const_int 0))) + (clobber (match_scratch:SI 2 "=&d")) + (clobber (reg:CC CC_REGNUM))] + "!TARGET_EXTIMM" + "#" + "&& reload_completed" + [(const_int 0)] +{ + rtx op0 = operands[0]; + rtx op2 = operands[2]; + emit_insn (gen_ashlsi3 (op0, op0, GEN_INT (28))); + emit_move_insn (op2, const1_rtx); + emit_insn (gen_xorsi3 (op0, op0, op2)); + DONE; +}) ;; ;; - Conditional move instructions (introduced with z196)
Re: [RFA, patch] Add missing source location info to thunks
> Revised patch is ok. Thanks! Committed at r190190. -cary
[PATCH v3] s390: Convert from sync to atomic optabs
[ This ought to be exactly the patch you bootstrapped. It does not include the SEQ follow-up. ] Split out s390_two_part_insv from s390_expand_cs_hqi to try harder to use bit insertion instructions in the CAS loop. Reorg s390_expand_insv to aid that. Try RISBG last, after other mechanisms have failed; don't require operands in registers for it but force them there instead. Try a limited form of ICM. -- gcc/config/s390/s390-protos.h |3 +- gcc/config/s390/s390.c| 302 gcc/config/s390/s390.md | 389 + 3 files changed, 471 insertions(+), 223 deletions(-) diff --git a/gcc/config/s390/s390-protos.h b/gcc/config/s390/s390-protos.h index 4f1eb42..79673d6 100644 --- a/gcc/config/s390/s390-protos.h +++ b/gcc/config/s390/s390-protos.h @@ -85,7 +85,8 @@ extern void s390_expand_setmem (rtx, rtx, rtx); extern bool s390_expand_cmpmem (rtx, rtx, rtx, rtx); extern bool s390_expand_addcc (enum rtx_code, rtx, rtx, rtx, rtx, rtx); extern bool s390_expand_insv (rtx, rtx, rtx, rtx); -extern void s390_expand_cs_hqi (enum machine_mode, rtx, rtx, rtx, rtx); +extern void s390_expand_cs_hqi (enum machine_mode, rtx, rtx, rtx, + rtx, rtx, bool); extern void s390_expand_atomic (enum machine_mode, enum rtx_code, rtx, rtx, rtx, bool); extern rtx s390_return_addr_rtx (int, rtx); diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c index 3a87291..20a2db6 100644 --- a/gcc/config/s390/s390.c +++ b/gcc/config/s390/s390.c @@ -896,10 +896,12 @@ s390_emit_compare (enum rtx_code code, rtx op0, rtx op1) conditional branch testing the result. */ static rtx -s390_emit_compare_and_swap (enum rtx_code code, rtx old, rtx mem, rtx cmp, rtx new_rtx) +s390_emit_compare_and_swap (enum rtx_code code, rtx old, rtx mem, + rtx cmp, rtx new_rtx) { - emit_insn (gen_sync_compare_and_swapsi (old, mem, cmp, new_rtx)); - return s390_emit_compare (code, gen_rtx_REG (CCZ1mode, CC_REGNUM), const0_rtx); + emit_insn (gen_atomic_compare_and_swapsi_internal (old, mem, cmp, new_rtx)); + return s390_emit_compare (code, gen_rtx_REG (CCZ1mode, CC_REGNUM), + const0_rtx); } /* Emit a jump instruction to TARGET. If COND is NULL_RTX, emit an @@ -4548,106 +4550,146 @@ s390_expand_insv (rtx dest, rtx op1, rtx op2, rtx src) { int bitsize = INTVAL (op1); int bitpos = INTVAL (op2); + enum machine_mode mode = GET_MODE (dest); + enum machine_mode smode; + int smode_bsize, mode_bsize; + rtx op, clobber; - /* On z10 we can use the risbg instruction to implement insv. */ - if (TARGET_Z10 - && ((GET_MODE (dest) == DImode && GET_MODE (src) == DImode) - || (GET_MODE (dest) == SImode && GET_MODE (src) == SImode))) + /* Generate INSERT IMMEDIATE (IILL et al). */ + /* (set (ze (reg)) (const_int)). */ + if (TARGET_ZARCH + && register_operand (dest, word_mode) + && (bitpos % 16) == 0 + && (bitsize % 16) == 0 + && const_int_operand (src, VOIDmode)) { - rtx op; - rtx clobber; + HOST_WIDE_INT val = INTVAL (src); + int regpos = bitpos + bitsize; - op = gen_rtx_SET (GET_MODE(src), - gen_rtx_ZERO_EXTRACT (GET_MODE (dest), dest, op1, op2), - src); - clobber = gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (CCmode, CC_REGNUM)); - emit_insn (gen_rtx_PARALLEL (VOIDmode, gen_rtvec (2, op, clobber))); + while (regpos > bitpos) + { + enum machine_mode putmode; + int putsize; + if (TARGET_EXTIMM && (regpos % 32 == 0) && (regpos >= bitpos + 32)) + putmode = SImode; + else + putmode = HImode; + + putsize = GET_MODE_BITSIZE (putmode); + regpos -= putsize; + emit_move_insn (gen_rtx_ZERO_EXTRACT (word_mode, dest, + GEN_INT (putsize), + GEN_INT (regpos)), + gen_int_mode (val, putmode)); + val >>= putsize; + } + gcc_assert (regpos == bitpos); return true; } - /* We need byte alignment. */ - if (bitsize % BITS_PER_UNIT) -return false; + smode = smallest_mode_for_size (bitsize, MODE_INT); + smode_bsize = GET_MODE_BITSIZE (smode); + mode_bsize = GET_MODE_BITSIZE (mode); + /* Generate STORE CHARACTERS UNDER MASK (STCM et al). */ if (bitpos == 0 - && memory_operand (dest, VOIDmode) + && (bitsize % BITS_PER_UNIT) == 0 + && MEM_P (dest) && (register_operand (src, word_mode) || const_int_operand (src, VOIDmode))) { /* Emit standard pattern if possible. */ - enum machine_mode mode = smallest_mode_for_size (bitsize, MODE_INT); - if (GET_MODE_BITSIZE (mode) == bitsize) - emit_move_insn (adjust_address (dest, mode, 0), gen_lowpart (mode, src));
[google/gcc-4_7] Backport patch to add line info to non-virtual thunks
This patch is for the google/gcc-4_7 branch. It backports the following patch from trunk at r190190: http://gcc.gnu.org/ml/gcc-patches/2012-08/msg00321.html GCC generates non-virtual thunks directly to assembly code, which causes a couple of problems. First, it doesn't add source location information to the thunk, so the thunk simply inherits the random location from the end of the function in front of it (the function it's a thunk for). In two different compilation units compiled with different options, this could result in two different locations for the same thunk, and gold will give a false positive ODR violation warning. Second, if you try to compile with -S -dA, GCC crashes in final(), where it's trying to build a mapping from insn to bb, because the function has no cfg, and FOR_EACH_BB_REVERSE tries to dereference cfun->cfg without checking for non-NULL. Bootstrapped and ran testsuite with no regressions. Google ref b/6891766. 2012-08-06 Cary Coutant gcc/ * cgraphunit.c (assemble_thunk): Add source line info. * final.c (final): Check for non-null cfg pointer. gcc/testsuite/ * g++.dg/debug/dwarf2/non-virtual-thunk.C: New test case. Index: gcc/final.c === --- gcc/final.c (revision 190189) +++ gcc/final.c (working copy) @@ -1761,11 +1761,13 @@ final (rtx first, FILE *file, int optimi start_to_bb = XCNEWVEC (basic_block, bb_map_size); end_to_bb = XCNEWVEC (basic_block, bb_map_size); - FOR_EACH_BB_REVERSE (bb) - { - start_to_bb[INSN_UID (BB_HEAD (bb))] = bb; - end_to_bb[INSN_UID (BB_END (bb))] = bb; - } + /* There is no cfg for a thunk. */ + if (!cfun->is_thunk) + FOR_EACH_BB_REVERSE (bb) + { + start_to_bb[INSN_UID (BB_HEAD (bb))] = bb; + end_to_bb[INSN_UID (BB_END (bb))] = bb; + } } /* Output the insns. */ Index: gcc/cgraphunit.c === --- gcc/cgraphunit.c(revision 190189) +++ gcc/cgraphunit.c(working copy) @@ -1799,6 +1799,10 @@ assemble_thunk (struct cgraph_node *node init_function_start (thunk_fndecl); cfun->is_thunk = 1; assemble_start_function (thunk_fndecl, fnname); + (*debug_hooks->source_line) (DECL_SOURCE_LINE (thunk_fndecl), + DECL_SOURCE_FILE (thunk_fndecl), + /* discriminator */ 0, + /* is_stmt */ 1); targetm.asm_out.output_mi_thunk (asm_out_file, thunk_fndecl, fixed_offset, virtual_value, alias); Index: gcc/testsuite/g++.dg/debug/dwarf2/non-virtual-thunk.C === --- gcc/testsuite/g++.dg/debug/dwarf2/non-virtual-thunk.C (revision 0) +++ gcc/testsuite/g++.dg/debug/dwarf2/non-virtual-thunk.C (revision 0) @@ -0,0 +1,39 @@ +// { dg-do compile } +// { dg-options "-g2 -dA" } + +// Verify that line number info is output for the non-virtual +// thunks for C::~C(). +// { dg-final { scan-assembler "thunk.C:30" } } + +class A +{ + public: + A(); + virtual ~A(); + private: + int i; +}; + +class B +{ + public: + B(); + virtual ~B(); + private: + int i; +}; + +class C : public A, public B +{ + public: + C(); + virtual ~C(); // line 30 +}; + +C::C() +{ +} + +C::~C() +{ +}
Assembly output optimisations (was: PR 51094 - fprint_w() in output_addr_const() reinstated)
Hello list, these clean-ups and minor speedups complete some TODOs and semi-finished changes I have gathered in the ELF backend. In a nutshell: Fixed comment style, used INT_BITS_STRLEN_BOUND from gnulib to be future proof on integer representation string length, replaced long arguments in fast printing functions with HOST_WIDE_INT that is always a larger type (also asserted that), converted some never-negative ints to unsigned. Guarded the output.h:default_elf_asm_output_* declarations, mimicking varasm.c (I'm not exactly sure why this is guarded in the first place). Changed default_elf_asm_output_* to be clearer and faster, they now fwrite() line by line instead of putting char by char. Implemented fast octal output in default_elf_asm_output_*, this should give a good boost to -flto, but I haven't measured a big testcase for this one. All in all I get a speed-up of ~30 M instr out of ~2 G instr, for -g3 compilation of reload.c. Actually saving all the putc() calls gives more significant gain, but I lost a tiny bit because of converting [sf]print_* functions to HOST_WIDE_INT from long, for PR 51094. So on i586 which has HOST_WIDE_INT 8 byte wide, I can see slow calls to __u{div,mod}di3 taking place. I don't know whether there is a meaning in writing LEB128 values greater than 2^31 but I could change all that to HOST_WIDEST_FAST_INT if you think so. Time savings are minor too, about 10 ms out of 0.85 s. Memory usage is the same. Bootstrapped on x86, no regressions for C,C++ testsuite. Thanks Andreas, hp, Mike, for your comments. Mike I'd appreciate if you elaborated on how to speed-up sprint_uw_rev(), I don't think I understood what you have in mind. Thanks, Dimitris2012-08-07 Dimitrios Apostolou * final.c: Assert that HOST_WIDE_INT is at least as wide as long. (output_addr_const): Use fprint_w() instead of fprintf() when CONST_INT or CONST_FIXED. (_sprint_uw): New static function. (sprint_ul_rev): Change to: (_sprint_uw_rev): Accept HOST_WIDE_INT arg instead of long. Changed i to unsigned. (INT_BITS_STRLEN_BOUND): Copied from gnulib. (HOST_WIDE_INT_STRING_LEN): Define. (fprint_ul, sprint_ul): Change to: (fprint_uw, sprint_uw): Accept HOST_WIDE_INT arg instead of long. Changed counter variables to unsigned. (fprint_uw_hex): Renamed from fprint_whex * output.h (fprint_ul, sprint_ul): Remove declarations. (fprint_w, fprint_uw, sprint_uw): Declare. (default_elf_asm_output_limited_string) (default_elf_asm_output_ascii): wrap in #ifdef ELF_ASCII_ESCAPES (fprint_uw_hex): Renamed from fprint_whex * elfos.h (ASM_GENERATE_INTERNAL_LABEL): Use sprint_uw() instead of sprint_ul(). (ASM_OUTPUT_ASCII): Removed questionmark at the end of macro. * i386.c (print_reg): Use fprint_uw() instead of fprint_ul(). * dwarf2asm.c (asm_output_data_sleb128): Change fprintf() to fputs() plus fprint_w(). Change fputc() to putc() in hot path. (dw2_assemble_integer, dw2_asm_output_data) (dw2_asm_output_data_uleb128): fprint_whex() renamed to fprint_uw_hex(). * dwarf2out.c (dwarf2out_source_line): Changed comment. Use fprint_uw() instead of fprint_ul(). * varasm.c (_elf_escape_char): New static function that writes a char to a string according to ELF_ASCII_ESCAPES. (_elf_output_ascii_line): New static function that writes to file a single .ascii assembler declaration. (default_elf_asm_output_limited_string) (default_elf_asm_output_ascii): Rewrote functions so that they fwrite() a full assembler line instead of putting char by char. === modified file 'gcc/config/elfos.h' --- gcc/config/elfos.h 2012-06-19 19:55:33 + +++ gcc/config/elfos.h 2012-08-06 03:19:16 + @@ -119,7 +119,7 @@ see the files COPYING3 and COPYING.RUNTI (LABEL)[0] = '*';\ (LABEL)[1] = '.';\ __p = stpcpy (&(LABEL)[2], PREFIX); \ - sprint_ul (__p, (unsigned long) (NUM)); \ + sprint_uw (__p, (unsigned HOST_WIDE_INT) (NUM)); \ } \ while (0) @@ -418,7 +418,7 @@ see the files COPYING3 and COPYING.RUNTI #undef ASM_OUTPUT_ASCII #define ASM_OUTPUT_ASCII(FILE, STR, LENGTH)\ - default_elf_asm_output_ascii ((FILE), (STR), (LENGTH)); + default_elf_asm_output_ascii ((FILE), (STR), (LENGTH)) /* Allow the use of the -frecord-gcc-switches switch via the elf_record_gcc_switches function defined in varasm.c. */ === modified file 'gcc/config/i386/i386.c' --- gcc/config/i386/i386.c 2012-07-28 09:16:52 + +++ gcc/config/i386/i386.c 2012-08-04 16:47:01 + @@ -13995,7 +13995,7 @@ prin
Re: [PATCH] put exception tables for comdat functions in comdat, too
On 08/06/2012 11:45 AM, Richard Henderson wrote: On 08/05/2012 08:40 PM, Sandra Loosemore wrote: 2012-08-04 Paul Brook Sandra Loosemore gcc/ * except.c (switch_to_exception_section): Place tables for DECL_ONE_ONLY functions in comdat groups. Mostly ok. - s = get_section (section_name, flags, NULL); + s = get_section (section_name, flags, current_function_decl); Not correct, since we're not putting the function in that section. We have no decl for the actual eh data. This use of the function decl doesn't indicate that we're putting the function in this section; it represents the group symbol for the comdat group the section belongs in. Without this part of the patch, there is nothing to tie the section being used for the eh tables for fnname to the comdat group for fnname, and default_elf_asm_named_section segfaults on the assumption that all comdat sections have a non-null decl for the purposes of the GroupName,comdat assembler syntax. Compare to default_function_rodata_section in varasm.c for an existing similar call to get_section. OK to commit the patch as originally posted? -Sandra
Re: Assembly output optimisations (was: PR 51094 - fprint_w() in output_addr_const() reinstated)
On Tue, 7 Aug 2012, Dimitrios Apostolou wrote: > Thanks Andreas, hp, Mike, for your comments. Mike I'd appreciate if you > elaborated on how to speed-up sprint_uw_rev(), I don't think I understood what > you have in mind. I just commented on comments and just above the nit-level; formatting and contents. Still, I believe such nits affects reviewer interest. Formatting: two spaces after punctuation at end of sentence, see other comments. You got it right in most places. Some of the comments you changed were actually wrong *before*, some of those you actually corrected. I can't quote the non-inlined patch, so I'll copy-paste some lines, adding quote-style: > +/* Return a statically allocated string with the decimal representation of > + VALUE. String IS NOT null-terminated. */ Write as: +/* Return a statically allocated string with the decimal representation of + VALUE. String IS NOT null-terminated. */ Avoid comments that look like commented out code. Add a word or two to avoid that. > + /* Emit the .loc directive understood by GNU as. Equivalent: */ > + /* printf ("\t.loc %u %u 0 is_stmt %u discriminator %u", > + file_num, line, is_stmt, discriminator); */ Write as: + /* Emit the .loc directive understood by GNU as. The following is + equivalent to printf ("\t.loc %u %u 0 is_stmt %u discriminator %u", + file_num, line, file_num, line, is_stmt, discriminator); */ Most of the new comments in default_elf_asm_output_ascii are wrongly formatted. Most are missing end-of-sentence punctuation and two spaces. Some look odd; complete the sentences or add ellipsis to continue in the next comment. There's also wrong terminology both in comments and code, in several places: a '\0' is NIL, not NULL. Better write as \0 for clarity in comments. > + /* If short enough */ > + if (((unsigned long) (next_null - s) < ELF_STRING_LIMIT) > + /* and if it starts with NULL and it is only a > +single NULL (empty string) */ > + && ((*s != '\0') || (s == next_null))) > + /* then output as .string */ > + s = default_elf_asm_output_limited_string (f, s); > + else > + /* long string or many NULLs, output as .ascii */ Write as (note also the s/next_null/next_nil/): + /* If short enough... */ + if (((unsigned long) (next_nil - s) < ELF_STRING_LIMIT) + /* ... and if it starts with \0 and it is only +single \0 (an empty string) ... */ + && ((*s != '\0') || (s == next_null))) + /* ... then output as .string. */ + s = default_elf_asm_output_limited_string (f, s); + else + /* A long string or many \0, output as .ascii. */ Contents: I missed a note on relative speedups. You need to guard the changes, or else a valid future cleanup could be to simplify the code, using library functions, possibly slowing it down. There's just the word "fast" added in a comment, reminding of self-adhesive go-fast-stripes for cars and computer cases. :) > /* Write a signed HOST_WIDE_INT as decimal to a file, fast. */ But *how* much faster? Something like: /* Write a signed HOST_WIDE_INT as decimal to a file. At some time, this was X times faster than fprintf ("%lld", l); */ Right, not the most important review bits. Still, you asked for elaboration. Oh right, I see that was just for Mike's comments. Well, anyway, since my comments still apply. :P brgds, H-P
add strnlen to libiberty (was Re: Assembly output optimisations)
As an addendum to my previous patch, I made an attempt to properly add strnlen() to libiberty, with the code copied from gnulib. Unfortunately it seems I've messed it up somewhere since defining HAVE_STRNLEN to 0 doesn't seem to build strnlen.o for me. Any ideas? Thanks, Dimitris === modified file 'libiberty/Makefile.in' --- libiberty/Makefile.in 2012-04-27 14:14:14 + +++ libiberty/Makefile.in 2012-08-07 03:52:53 + @@ -151,7 +151,7 @@ CFILES = alloca.c argv.c asprintf.c atex spaces.c splay-tree.c stack-limit.c stpcpy.c stpncpy.c \ strcasecmp.c strchr.c strdup.c strerror.c strncasecmp.c\ strncmp.c strrchr.c strsignal.c strstr.c strtod.c strtol.c \ -strtoul.c strndup.c strverscmp.c \ +strtoul.c strndup.c strnlen.c strverscmp.c \ timeval-utils.c tmpnam.c\ unlink-if-ordinary.c\ vasprintf.c vfork.c vfprintf.c vprintf.c vsnprintf.c vsprintf.c \ @@ -218,6 +218,7 @@ CONFIGURED_OFILES = ./asprintf.$(objext) ./strncmp.$(objext) ./strndup.$(objext) ./strrchr.$(objext)\ ./strstr.$(objext) ./strtod.$(objext) ./strtol.$(objext) \ ./strtoul.$(objext) ./strverscmp.$(objext) \ + ./strnlen.$(objext) \ ./tmpnam.$(objext) \ ./vasprintf.$(objext) ./vfork.$(objext) ./vfprintf.$(objext)\ ./vprintf.$(objext) ./vsnprintf.$(objext) ./vsprintf.$(objext) \ @@ -622,8 +623,7 @@ $(CONFIGURED_OFILES): stamp-picdir else true; fi $(COMPILE.c) $(srcdir)/crc32.c $(OUTPUT_OPTION) -./dwarfnames.$(objext): $(srcdir)/dwarfnames.c $(INCDIR)/dwarf2.h \ - $(INCDIR)/dwarf2.def +./dwarfnames.$(objext): $(srcdir)/dwarfnames.c $(INCDIR)/dwarf2.h if [ x"$(PICFLAG)" != x ]; then \ $(COMPILE.c) $(PICFLAG) $(srcdir)/dwarfnames.c -o pic/$@; \ else true; fi @@ -656,7 +656,8 @@ $(CONFIGURED_OFILES): stamp-picdir else true; fi $(COMPILE.c) $(srcdir)/fibheap.c $(OUTPUT_OPTION) -./filename_cmp.$(objext): $(srcdir)/filename_cmp.c config.h $(INCDIR)/filenames.h \ +./filename_cmp.$(objext): $(srcdir)/filename_cmp.c config.h $(INCDIR)/ansidecl.h \ + $(INCDIR)/filenames.h $(INCDIR)/hashtab.h \ $(INCDIR)/safe-ctype.h if [ x"$(PICFLAG)" != x ]; then \ $(COMPILE.c) $(PICFLAG) $(srcdir)/filename_cmp.c -o pic/$@; \ @@ -757,7 +758,7 @@ $(CONFIGURED_OFILES): stamp-picdir $(COMPILE.c) $(srcdir)/insque.c $(OUTPUT_OPTION) ./lbasename.$(objext): $(srcdir)/lbasename.c config.h $(INCDIR)/ansidecl.h \ - $(INCDIR)/filenames.h $(INCDIR)/libiberty.h \ + $(INCDIR)/filenames.h $(INCDIR)/hashtab.h $(INCDIR)/libiberty.h \ $(INCDIR)/safe-ctype.h if [ x"$(PICFLAG)" != x ]; then \ $(COMPILE.c) $(PICFLAG) $(srcdir)/lbasename.c -o pic/$@; \ @@ -1043,7 +1044,7 @@ $(CONFIGURED_OFILES): stamp-picdir else true; fi $(COMPILE.c) $(srcdir)/splay-tree.c $(OUTPUT_OPTION) -./stack-limit.$(objext): $(srcdir)/stack-limit.c config.h +./stack-limit.$(objext): $(srcdir)/stack-limit.c config.h $(INCDIR)/ansidecl.h if [ x"$(PICFLAG)" != x ]; then \ $(COMPILE.c) $(PICFLAG) $(srcdir)/stack-limit.c -o pic/$@; \ else true; fi @@ -1104,6 +1105,12 @@ $(CONFIGURED_OFILES): stamp-picdir else true; fi $(COMPILE.c) $(srcdir)/strndup.c $(OUTPUT_OPTION) +./strnlen.$(objext): $(srcdir)/strnlen.c + if [ x"$(PICFLAG)" != x ]; then \ + $(COMPILE.c) $(PICFLAG) $(srcdir)/strnlen.c -o pic/$@; \ + else true; fi + $(COMPILE.c) $(srcdir)/strnlen.c $(OUTPUT_OPTION) + ./strrchr.$(objext): $(srcdir)/strrchr.c $(INCDIR)/ansidecl.h if [ x"$(PICFLAG)" != x ]; then \ $(COMPILE.c) $(PICFLAG) $(srcdir)/strrchr.c -o pic/$@; \ === modified file 'libiberty/config.in' --- libiberty/config.in 2011-07-22 08:33:37 + +++ libiberty/config.in 2012-08-07 03:29:18 + @@ -262,6 +262,9 @@ /* Define to 1 if you have the `strndup' function. */ #undef HAVE_STRNDUP +/* Define to 1 if you have the `strnlen' function. */ +#undef HAVE_STRNLEN + /* Define to 1 if you have the `strrchr' function. */ #undef HAVE_STRRCHR === modified file 'libiberty/configure' --- libiberty/configure 2012-01-23 06:25:28 + +++ libiberty/configure 2012-08-07 03:10:54 + @@ -5340,6 +5340,7 @@ funcs="$funcs strchr" funcs="$funcs strdup" funcs="$funcs strncasecmp" funcs="$funcs strndup" +funcs="$funcs strnlen" funcs="$funcs strrchr" funcs="$funcs strstr" funcs="$funcs strtod" @@ -5380,8 +5381,8 @@ if test "x" = "y"; then random realpath rename rindex \ sbrk setenv setproctitle setrlimit sigsetmask snprintf spawnve spawnvpe \ stpcpy stpncpy strcasecmp strchr strdup \ -
libgo patch committed: Support NumCPU on more platforms
This patch to libgo, from Shenghou Ma, adds support for NumCPU on additional platforms: Solaris, Irix, *BSD, Darwin. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline. Ian diff -r 12a361bc53d0 libgo/Makefile.am --- a/libgo/Makefile.am Mon Aug 06 21:39:47 2012 -0700 +++ b/libgo/Makefile.am Mon Aug 06 21:40:21 2012 -0700 @@ -390,6 +390,32 @@ runtime_lock_files = runtime/lock_sema.c runtime/thread-sema.c endif +if LIBGO_IS_LINUX +runtime_getncpu_file = runtime/getncpu-linux.c +else +if LIBGO_IS_DARWIN +runtime_getncpu_file = runtime/getncpu-bsd.c +else +if LIBGO_IS_IRIX +runtime_getncpu_file = runtime/getncpu-irix.c +else +if LIBGO_IS_SOLARIS +runtime_getncpu_file = runtime/getncpu-solaris.c +else +if LIBGO_IS_FREEBSD +runtime_getncpu_file = runtime/getncpu-bsd.c +else +if LIBGO_IS_NETBSD +runtime_getncpu_file = runtime/getncpu-bsd.c +else +runtime_getncpu_file = runtime/getncpu-none.c +endif +endif +endif +endif +endif +endif + runtime_files = \ runtime/go-append.c \ runtime/go-assert.c \ @@ -481,7 +507,8 @@ sema.c \ sigqueue.c \ string.c \ - time.c + time.c \ + $(runtime_getncpu_file) goc2c.$(OBJEXT): runtime/goc2c.c $(CC_FOR_BUILD) -c $(CFLAGS_FOR_BUILD) $< diff -r 12a361bc53d0 libgo/runtime/getncpu-bsd.c --- /dev/null Thu Jan 01 00:00:00 1970 + +++ b/libgo/runtime/getncpu-bsd.c Mon Aug 06 21:40:21 2012 -0700 @@ -0,0 +1,24 @@ +// Copyright 2012 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +#include +#include + +#include "runtime.h" +#include "defs.h" + +int32 +getproccount(void) +{ + int mib[2], out; + size_t len; + + mib[0] = CTL_HW; + mib[1] = HW_NCPU; + len = sizeof(out); + if(sysctl(mib, 2, &out, &len, NULL, 0) >= 0) + return (int32)out; + else + return 0; +} diff -r 12a361bc53d0 libgo/runtime/getncpu-irix.c --- /dev/null Thu Jan 01 00:00:00 1970 + +++ b/libgo/runtime/getncpu-irix.c Mon Aug 06 21:40:21 2012 -0700 @@ -0,0 +1,16 @@ +// Copyright 2012 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +#include + +#include "runtime.h" +#include "defs.h" + +int32 +getproccount(void) +{ + int32 n; + n = (int32)sysconf(_SC_NPROC_ONLN); + return n > 1 ? n : 1; +} diff -r 12a361bc53d0 libgo/runtime/getncpu-linux.c --- /dev/null Thu Jan 01 00:00:00 1970 + +++ b/libgo/runtime/getncpu-linux.c Mon Aug 06 21:40:21 2012 -0700 @@ -0,0 +1,47 @@ +// Copyright 2012 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +#include +#include +#include +#include + +#include "runtime.h" +#include "defs.h" + +#ifndef O_CLOEXEC +#define O_CLOEXEC 0 +#endif + +int32 +getproccount(void) +{ + int32 fd, rd, cnt, cpustrlen; + const char *cpustr; + const byte *pos; + byte *bufpos; + byte buf[256]; + + fd = open("/proc/stat", O_RDONLY|O_CLOEXEC, 0); + if(fd == -1) + return 1; + cnt = 0; + bufpos = buf; + cpustr = "\ncpu"; + cpustrlen = strlen(cpustr); + for(;;) { + rd = read(fd, bufpos, sizeof(buf)-cpustrlen); + if(rd == -1) + break; + bufpos[rd] = 0; + for(pos=buf; (pos=(const byte*)strstr((const char*)pos, cpustr)) != nil; cnt++, pos++) { + } + if(rd < cpustrlen) + break; + memmove(buf, bufpos+rd-cpustrlen+1, cpustrlen-1); + bufpos = buf+cpustrlen-1; + } + close(fd); + return cnt ? cnt : 1; +} diff -r 12a361bc53d0 libgo/runtime/getncpu-none.c --- /dev/null Thu Jan 01 00:00:00 1970 + +++ b/libgo/runtime/getncpu-none.c Mon Aug 06 21:40:21 2012 -0700 @@ -0,0 +1,12 @@ +// Copyright 2012 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +#include "runtime.h" +#include "defs.h" + +int32 +getproccount(void) +{ + return 0; +} diff -r 12a361bc53d0 libgo/runtime/getncpu-solaris.c --- /dev/null Thu Jan 01 00:00:00 1970 + +++ b/libgo/runtime/getncpu-solaris.c Mon Aug 06 21:40:21 2012 -0700 @@ -0,0 +1,16 @@ +// Copyright 2012 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +#include + +#include "runtime.h" +#include "defs.h" + +int32 +getproccount(void) +{ + int32 n; + n = (int32)sysconf(_SC_NPROCESSORS_ONLN); + return n > 1 ? n : 1; +} diff -r 12a361bc53d0 libgo/runtime/runtime.h --- a/libgo/runtime/runtime.h Mon Aug 06 21:39:47 2012 -0700 +++ b/libgo/runtime/runtime.h Mon Aug 06 21:40:21 2012 -0700 @@ -518,3 +518,5 @@ extern uintptr runtime_stacks_sys; extern _Bool __go_file_line (uintptr, String*, String*, int *); + +int32 getproccount(void); diff -r 12a361bc53d0 libgo/runtime/thread-linux.c --- a/libgo/runtime/thread-linux.c Mon Aug 06 21:39:47 2012 -0700 +++ b/libgo/runtime/thread-linux.c Mon Aug 06 21:40:21 2012 -0700 @@ -72,42 +72,6 @@ *(int32*)0x1006 = 0x1006; }
Re: add strnlen to libiberty (was Re: Assembly output optimisations)
On Mon, Aug 6, 2012 at 9:34 PM, Dimitrios Apostolou wrote: > As an addendum to my previous patch, I made an attempt to properly add > strnlen() to libiberty, with the code copied from gnulib. Unfortunately it > seems I've messed it up somewhere since defining HAVE_STRNLEN to 0 doesn't > seem to build strnlen.o for me. Any ideas? What do you mean by "defining HAVE_STRNLEN to 0"? The thing that will control building strnlen.o is having AC_REPLACE_FUNCS in libiberty/configure.in fail to find strlen. One way you can test this is by adding this to libiberty/config.cache: ac_cv_func_strnlen=${ac_cv_func_strnlen=yes} before invoking configure. Ian
Re: add strnlen to libiberty (was Re: Assembly output optimisations)
On Mon, 6 Aug 2012, Ian Lance Taylor wrote: On Mon, Aug 6, 2012 at 9:34 PM, Dimitrios Apostolou wrote: As an addendum to my previous patch, I made an attempt to properly add strnlen() to libiberty, with the code copied from gnulib. Unfortunately it seems I've messed it up somewhere since defining HAVE_STRNLEN to 0 doesn't seem to build strnlen.o for me. Any ideas? What do you mean by "defining HAVE_STRNLEN to 0"? The thing that will control building strnlen.o is having AC_REPLACE_FUNCS in libiberty/configure.in fail to find strlen. One way you can test this is by adding this to libiberty/config.cache: ac_cv_func_strnlen=${ac_cv_func_strnlen=yes} before invoking configure. Thanks Ian, that helped a lot. I changed ac_cv_func_strnlen=no and reconfigured with -C, and strnlen.o was built. :-) What else is missing to make this patch appropriate for libiberty? Should I change the prolog in strnlen.c, since I only copied it intact from gnulib? Thanks, Dimitris
[patch] Reduce memory overhead for build_insn_chain
Hello, In the test case for PR54146, build_insn_chain spends almost all its time in this loop: FOR_EACH_BB_REVERSE (bb) { bitmap_iterator bi; rtx insn; CLEAR_REG_SET (live_relevant_regs); --> memset (live_subregs_used, 0, max_regno * sizeof (int)); The test case has >400,000 basic blocks and >1,000,000 regs... Fortunately this can be done much more efficiently if one realizes that an sbitmap knows its own size (using SBITMAP_SIZE that I introduced recently). With that, live_subregs_used can be a sparse bitmap. Bootstrapped&tested on x86_64-unknown-linux-gnu. OK for trunk? Ciao! Steven PR54146_reload.diff Description: Binary data
[patch] Use a smaller, dynamic worklist in compute_global_livein
Hello, In the test case for PR54146, compute_global_livein allocates/frees a worklist for >400,000 basic blocks on each invocation. And it's called a lot, for rewrite_into_loop_closed_ssa. But the maximum number of basic blocks ever on the work list was only ~6500. So the work list can be much smaller most of the time. Bootstrapped&tested on x86_64-unknown-linux-gnu. OK for trunk? Ciao! Steven PR54146_cgli.diff Description: Binary data
Re: add strnlen to libiberty (was Re: Assembly output optimisations)
On Mon, Aug 6, 2012 at 10:44 PM, Dimitrios Apostolou wrote: > > What else is missing to make this patch appropriate for libiberty? Should I > change the prolog in strnlen.c, since I only copied it intact from gnulib? We generally try to avoid straight GPL source code without runtime exception in libiberty, and I don't see a reason to bend that rule for this trivial function. I recommend that you write your own version rather than copying it from elsewhere. Ian