cfg fixup bug fix
The attached patch fixed a minor bug in cfg fixup -- the outgoing edge profile count is not scaled after inlining leading to warnings printed in IR dump -- 'Invalid sum of ...'. Bootstrap and tested on x86-64/linux, ok for trunk? Thanks, David p2 Description: Binary data
Re: [Patch, i386, testsuite] Fix for PR49547, new tescases for lzcnt instruction
Ping. -- K On Wed, Jul 27, 2011 at 10:23 PM, Kirill Yukhin kirill.yuk...@gmail.com wrote: Okay, then here is an updated patch updated ChangeLog entry: 2011-07-26 Kirill Yukhin kirill.yuk...@intel.com PR target/49547 * config.gcc (i[34567]86-*-*): Replace abmintrin.h with lzcntintrin.h. (x86_64-*-*): Likewise. * config/i386/i386.opt (mlzcnt): New. * config/i386/abmintrin.h: File removed. (__lzcnt_u16, __lzcnt, __lzcnt_u64): Moved to ... * config/i386/lzcntintrin.h: ... here. New file. (__lzcnt): Rename to ... (__lzcnt32): ... this. * config/i386/bmiintrin.h (head): Update copyright year. (__lzcnt_u16): Removed. (__lzcnt_u32): Likewise. (__lzcnt_u64): Likewise. * config/i386/x86intrin.h: Include lzcntintrin.h when __LZCNT__ is defined, remove abmintrin.h. * config/i386/cpuid.h: New define. * config/i386/driver-i386.c (host_detect_local_cpu): Detect LZCNT feature. * config/i386/i386-c.c (ix86_target_macros_internal): Define __LZCNT__ if needed. * config/i386/i386.c (ix86_target_string): New option -mlzcnt. (ix86_option_override_internal): Handle LZCNT option. (ix86_valid_target_attribute_inner_p): Likewise. (struct builtin_description bdesc_args) IX86_BUILTIN_CLZS: Update. * config/i386/i386.h (TARGET_LZCNT): New. (CLZ_DEFINED_VALUE_AT_ZERO): Update. * config/i386/i386.md (clzmode2): Update insn constraint. (clzmode2_lzcnt): Likewise. * doc/invoke.texi: Mention -mlzcnt option. * doc/extend.texi: Likewise. Bootstrapped successfully. Ok? K On Wed, Jul 27, 2011 at 8:51 PM, H.J. Lu hjl.to...@gmail.com wrote: On Wed, Jul 27, 2011 at 9:49 AM, Uros Bizjak ubiz...@gmail.com wrote: On Wed, Jul 27, 2011 at 6:12 PM, Kirill Yukhin kirill.yuk...@gmail.com wrote: Than as it is ABM header, it should include two headers: lzcntinrin.h and popcntintrin.h But again, it seems useless to me. If we cannot remove empty header, let it stay empty... K On Wed, Jul 27, 2011 at 7:53 PM, H.J. Lu hjl.to...@gmail.com wrote: On Wed, Jul 27, 2011 at 8:45 AM, Kirill Yukhin kirill.yuk...@gmail.com wrote: Just have a closer look to ABM intrinsics support in GCC Seems, we have popcnt support in separate file: popcntintrin.h So, after I move lzcnt intrinsics to lzcntintrin.h, abmintrin will become useless and have to be removed at all We can't remove an installed header file. It should just include other header files. ambintrin.h has: #ifndef _X86INTRIN_H_INCLUDED # error Never use abmintrin.h directly; include x86intrin.h instead. #endif I see no problem in removing this header. It is not possible to #include it directly. Sounds good to me. -- H.J.
Re: [Patch, i386, testsuite] Fix for PR49547, new tescases for lzcnt instruction
On Mon, Aug 1, 2011 at 10:21 AM, Kirill Yukhin kirill.yuk...@gmail.com wrote: Okay, then here is an updated patch updated ChangeLog entry: 2011-07-26 Kirill Yukhin kirill.yuk...@intel.com PR target/49547 * config.gcc (i[34567]86-*-*): Replace abmintrin.h with lzcntintrin.h. (x86_64-*-*): Likewise. * config/i386/i386.opt (mlzcnt): New. * config/i386/abmintrin.h: File removed. (__lzcnt_u16, __lzcnt, __lzcnt_u64): Moved to ... * config/i386/lzcntintrin.h: ... here. New file. (__lzcnt): Rename to ... (__lzcnt32): ... this. * config/i386/bmiintrin.h (head): Update copyright year. (__lzcnt_u16): Removed. (__lzcnt_u32): Likewise. (__lzcnt_u64): Likewise. * config/i386/x86intrin.h: Include lzcntintrin.h when __LZCNT__ is defined, remove abmintrin.h. * config/i386/cpuid.h: New define. * config/i386/driver-i386.c (host_detect_local_cpu): Detect LZCNT feature. * config/i386/i386-c.c (ix86_target_macros_internal): Define __LZCNT__ if needed. * config/i386/i386.c (ix86_target_string): New option -mlzcnt. (ix86_option_override_internal): Handle LZCNT option. (ix86_valid_target_attribute_inner_p): Likewise. (struct builtin_description bdesc_args) IX86_BUILTIN_CLZS: Update. * config/i386/i386.h (TARGET_LZCNT): New. (CLZ_DEFINED_VALUE_AT_ZERO): Update. * config/i386/i386.md (clzmode2): Update insn constraint. (clzmode2_lzcnt): Likewise. * doc/invoke.texi: Mention -mlzcnt option. * doc/extend.texi: Likewise. Bootstrapped successfully. OK for mainline. Uros.
Re: Patches ping
Hi, Thanks for the review! Changelog: (sms_schedule_by_order): Update call to get_sched_window. all set_must_precede_follow. ^^^ call Done. +/* Set bitmaps TMP_FOLLOW and TMP_PRECEDE to MUST_FOLLOW and MUST_PRECEDE + respectively only if cycle C falls in the scheduling window boundaries ^^ on the border of Done. sbitmap tmp_precede = NULL; sbitmap tmp_follow = NULL; are redundantly reset in set_must_precede_follow(). Done. I removed the setting of tmp_precede and tmp_follow before calling set_must_precede_follow. (they are reset in set_must_precede_follow) +/* Update the sched_params for node U using the II, ^ (time, row and stage) + the CYCLE of U and MIN_CYCLE. */ Please also clarify that we're not simply taking SCHED_STAGE (u) = CALC_STAGE_COUNT (SCHED_TIME (u), min_cycle, ii); because the stages are aligned on cycle 0. Done. I assume it should be because the stages may not be aligned on cycle 0. + /* First, normailize the partial schedualing. */ ^ ^ + /* Try to achieve optimized SC by normalizing the partial + schedule (having the cycles start from cycle zero). The branch ^ + location must be placed in row ii-1 in the final scheduling. + If that's not the case after the normalization then try to ^^ + move the branch to that row if possible. */ ^ If failed, shift all instructions to position the branch in row ii-1. Done. For consistency and clarity, may be instead of: + /* Bring the branch to cycle -1. */ + int amount = SCHED_TIME (g-closing_branch) + 1; it would be better to have: + /* Bring the branch to cycle ii-1. */ + int amount = SCHED_TIME (g-closing_branch) - (ii - 1); OK, the attached patch contains this fix in other places as well where we bring the branch to cycle -1. Some thoughts on possible improvements (not mandatory; especially given the delay in approval, sorry..thanks for the ping): o Have optimize_sc() take care of all possible rotations doing the best it can, without returning an indication which leaves subsequent (suboptimal) processing to the caller. o Instead of removing the branch and then trying to get it back into the same cycle if you can't place it in row ii-1, consider keeping it in its place and removing it only if you succeed to schedule it (also..) in row ii-1. o May be worthwhile to apply more refactoring, so that the code to reschedule the branch in row ii-1 reuses more of the general code for scheduling an instruction (possibly setting end = start + end), but avoid splitting a row. o Would be interesting to learn of loops that still have suboptimal SC's, to see if it's still an issue. Thanks for the suggestions, will try to address them. I'm now re-testing the attached patch on PowerPC and will commit it if there will be no further comments. Thanks, Revital (See attached file: patch_opt_sc_1_8.txt) Index: ChangeLog === --- ChangeLog (revision 176998) +++ ChangeLog (working copy) @@ -1,3 +1,18 @@ +2011-08-01 Revital Eres revital.e...@linaro.org + + * modulo-sched.c (calculate_stage_count, + calculate_must_precede_follow, get_sched_window, + try_scheduling_node_in_cycle, remove_node_from_ps): Add + declaration. + (update_node_sched_params, set_must_precede_follow, optimize_sc): + New functions. + (reset_sched_times): Call update_node_sched_params. + (sms_schedule): Call optimize_sc. + (get_sched_window): Change function arguments. + (sms_schedule_by_order): Update call to get_sched_window. + Call set_must_precede_follow. + (calculate_stage_count): Add function argument. + 2011-07-31 Richard Henderson r...@redhat.com * config/h8300/crti.asm: Add flags to .section directive. Index: modulo-sched.c === --- modulo-sched.c (revision 176998) +++ modulo-sched.c (working copy) @@ -203,7 +203,16 @@ static void generate_prolog_epilog (part rtx, rtx); static void duplicate_insns_of_cycles (partial_schedule_ptr, int, int, int, rtx); -static int calculate_stage_count (partial_schedule_ptr ps); +static int calculate_stage_count (partial_schedule_ptr, int); +static void calculate_must_precede_follow (ddg_node_ptr, int, int, + int, int, sbitmap, sbitmap, sbitmap); +static int get_sched_window
[Ada] Legality checks on 'Result in the presence of quantified expression
The expansion of quantified expressions into loops introduces new scopes that must be taken into account when validating the use of the attribute 'Result. The following must compile quietly: gcc -c -gnat12 -gnata test_astrium_2.adb -- with Ada.Containers.Ordered_Sets; package Test_Astrium_2 is package OS is new Ada.Containers.Ordered_Sets (Element_Type = Integer); use OS; function Test_Recovery_Highest (S : Set) return Integer with Post = (for all Cu in S = not (Test_Recovery_Highest'Result Element (Cu))); end Test_Astrium_2; --- package body Test_Astrium_2 is function Test_Recovery_Highest (S : Set) return Integer is Res : Integer; begin Res := Integer'First; for Int of S loop if Int Res then Res := Int; end if; end loop; return Res; end; end Test_Astrium_2; Tested on x86_64-pc-linux-gnu, committed on trunk 2011-08-01 Ed Schonberg schonb...@adacore.com * sem_attr.adb (Analyze_Attribute, case 'Result): Handle properly a quantified expression that appears within a postcondition and uses the Ada2012 'Result attribute. Index: sem_attr.adb === --- sem_attr.adb(revision 176998) +++ sem_attr.adb(working copy) @@ -3947,14 +3947,29 @@ package body Sem_Attr is when Attribute_Result = Result : declare - CS : Entity_Id := Current_Scope; - PS : Entity_Id := Scope (CS); + CS : Entity_Id; + -- The enclosing scope, excluding loops for quantified expressions + + PS : Entity_Id; + -- During analysis, CS is the postcondition subprogram and PS the + -- source subprogram to which the postcondition applies. During + -- pre-analysis, CS is the scope of the subprogram declaration. begin + -- Find enclosing scopes, excluding loops + + CS := Current_Scope; + while Ekind (CS) = E_Loop loop +CS := Scope (CS); + end loop; + + PS := Scope (CS); + -- If the enclosing subprogram is always inlined, the enclosing -- postcondition will not be propagated to the expanded call. - if Has_Pragma_Inline_Always (PS) + if not In_Spec_Expression + and then Has_Pragma_Inline_Always (PS) and then Warn_On_Redundant_Constructs then Error_Msg_N @@ -3994,9 +4009,7 @@ package body Sem_Attr is -- current one. else -while Present (CS) - and then CS /= Standard_Standard -loop +while Present (CS) and then CS /= Standard_Standard loop if Chars (CS) = Name_uPostconditions then exit; else @@ -4038,7 +4051,7 @@ package body Sem_Attr is else Error_Attr (% attribute can only appear - in function Postcondition pragma, P); +in function Postcondition pragma, P); end if; end if; end Result;
Re: [Patch, i386, testsuite] Fix for PR49547, new tescases for lzcnt instruction
Thanks! Guys with waa rights, could anybody commit my fix? Thanks, K OK for mainline. Uros.
[PATCH] Fix libquadmath on FLT_EVAL_METHOD != 0 targets
Hi! As #include quadmath.h #include stdio.h void printq(__float128 x) { char buf[100]; quadmath_snprintf(buf, 100, %40.30Qa, x); printf(%s\n, buf); } int main() { __float128 twopi = 6.28318530717958647692528676655900576839433879875021164194989Q; __float128 three = 3.0Q; __float128 two = 2.0Q; __float128 ang = two * twopi / three; __float128 c = cosq(ang); __float128 correctc = -.5; __float128 s = sinq(ang); __float128 corrects = 0.866025403784438646763723170752936183471402626905190314027903Q; printq(twopi); printq(three); printq(two); printq(ang); printq(c); printq(correctc); printq(s); printq(corrects); return 0; } shows, the following two loops (at least the first one matters a lot) in __quadmath_kernel_rem_pio2 rely on FLT_EVAL_METHOD 0, so sinq is giving a result within 1ulp or so on x86_64, but a number that is far off on i686. If libquadmath is recompiled with -O0, it works even on i686. Fixed by forced rounding into double precision (don't want to rely on -fexcess-precision=* setting used to compile the library, so added a - volatile), committed to trunk/4.6. 2011-08-01 Jakub Jelinek ja...@redhat.com * math/rem_pio2q.c (__quadmath_kernel_rem_pio2): Fix up fq to y conversion for prec 3 and __FLT_EVAL_METHOD__ != 0. --- libquadmath/math/rem_pio2q.c.jj 2010-12-14 08:11:24.0 +0100 +++ libquadmath/math/rem_pio2q.c2011-08-01 10:45:27.0 +0200 @@ -282,14 +282,20 @@ recompute: break; case 3: /* painful */ for (i=jz;i0;i--) { - fw = fq[i-1]+fq[i]; - fq[i] += fq[i-1]-fw; - fq[i-1] = fw; +#if __FLT_EVAL_METHOD__ != 0 + volatile +#endif + double fv = (double)(fq[i-1]+fq[i]); + fq[i] += fq[i-1]-fv; + fq[i-1] = fv; } for (i=jz;i1;i--) { - fw = fq[i-1]+fq[i]; - fq[i] += fq[i-1]-fw; - fq[i-1] = fw; +#if __FLT_EVAL_METHOD__ != 0 + volatile +#endif + double fv = (double)(fq[i-1]+fq[i]); + fq[i] += fq[i-1]-fv; + fq[i-1] = fv; } for (fw=0.0,i=jz;i=2;i--) fw += fq[i]; if(ih==0) { Jakub
[Ada] Access to protected subprograms in generic bodies
This patch fixes two bugs in the handling of 'access applied to a protected subprogram, when the attribute reference appears within a generic body, and the access type is declared outside of the body. This is now properly rejected. The patch also fixes a bug in the legality check for convention, and removes a spurious error. Compiling proc.adb must yield the following error messages: proc.odb:15:31: 'Access attribute not allowed in generic body proc.adb:15:31: because access type Ptr is declared outside generic unit (RM 3.10.2(32)) proc.adb:15:31: move 'Access to private part, or (Ada 2005) use anonymous access type instead of Ptr --- procedure Proc is type Ptr is access protected procedure (P : Integer); generic package Gen is procedure Register (Link : Ptr); protected type Prot is procedure Transmit (X : Integer); end Prot; end; package body Gen is procedure Register (Link : Ptr) is begin null; end; protected body Prot is procedure Transmit (X : Integer) is begin Register (Transmit'access); -- ERROR end; end; end; begin null; end; Tested on x86_64-pc-linux-gnu, committed on trunk 2011-08-01 Ed Schonberg schonb...@adacore.com * sem_attr.adb (Analyze_Attribute, case 'Access): handle properly named access to protected subprograms in generic bodies. * sem_ch6.adb (Analyze_Subprogram_Declaration): If the context is a protected type, indicate that the convention of the subprogram is Convention_Protected, because it may be used in subsequent declarations within the protected declaration. Index: sem_attr.adb === --- sem_attr.adb(revision 177001) +++ sem_attr.adb(working copy) @@ -7837,14 +7837,16 @@ package body Sem_Attr is if Ekind_In (Btyp, E_Access_Subprogram_Type, E_Anonymous_Access_Subprogram_Type, + E_Access_Protected_Subprogram_Type, E_Anonymous_Access_Protected_Subprogram_Type) then -- Deal with convention mismatch - if Convention (Btyp) /= Convention (Entity (P)) then + if Convention (Designated_Type (Btyp)) /= + Convention (Entity (P)) + then Error_Msg_FE (subprogram has wrong convention, P, Entity (P)); - Error_Msg_FE (\does not match convention of access type , P, Btyp); Index: sem_ch6.adb === --- sem_ch6.adb (revision 176998) +++ sem_ch6.adb (working copy) @@ -2929,6 +2929,14 @@ package body Sem_Ch6 is Write_Eol; end if; + if Is_Protected_Type (Current_Scope) then + + -- Indicate that this is a protected operation, because it may be + -- used in subsequent declarations within the protected type. + + Set_Convention (Designator, Convention_Protected); + end if; + List_Inherited_Pre_Post_Aspects (Designator); Analyze_Aspect_Specifications (N, Designator, Aspect_Specifications (N)); end Analyze_Subprogram_Declaration;
[Ada] No adainit/adafinal procedures in Stand-Alone Libraries
This patch set the names of the init and final procedures of Stand-Alone Libraries to ada_init and ada_final if the name of the library is ada, to avoid duplicate symbols adainit and adafinal in executables. The test for this is to build an executable using a shared SAL with the name ada. It should behave as if the name of the SAL was different from ada. Tested on x86_64-pc-linux-gnu, committed on trunk 2011-08-01 Vincent Celier cel...@adacore.com * mlib-prj.adb (Build_Library): Use ada_ as the prefix for the init and final procedures when the name of the library is ada, to avoid duplicate symbols adainit and adafinal in executables. Index: mlib-prj.adb === --- mlib-prj.adb(revision 176998) +++ mlib-prj.adb(working copy) @@ -862,7 +862,7 @@ package body MLib.Prj is Arguments := new String_List (1 .. Initial_Argument_Max); end if; --- Add -n -o b~lib.adb (b__lib.adb on VMS) -Llib +-- Add -n -o b~lib.adb (b__lib.adb on VMS) -Llib_ Argument_Number := 2; Arguments (1) := No_Main; @@ -875,7 +875,17 @@ package body MLib.Prj is Add_Argument (B_Start.all Get_Name_String (For_Project.Library_Name) .adb); -Add_Argument (-L Get_Name_String (For_Project.Library_Name)); + +-- Make sure that the init procedure is never adainit + +Get_Name_String (For_Project.Library_Name); + +if Name_Buffer (1 .. Name_Len) = ada then + Add_Argument (-Lada_); +else + Add_Argument + (-L Get_Name_String (For_Project.Library_Name)); +end if; if For_Project.Lib_Auto_Init and then SALs_Use_Constructors then Add_Argument (Auto_Initialize); @@ -950,16 +960,15 @@ package body MLib.Prj is then if Check_Project (Unit.File_Names (Impl).Project) then if Unit.File_Names (Spec) = null then -declare - Src_Ind : Source_File_Index; - -begin - Src_Ind := Sinput.P.Load_Project_File -(Get_Name_String - (Unit.File_Names (Impl).Path.Name)); - -- Add the ALI file only if it is not a subunit +-- Add the ALI file only if it is not a subunit +declare + Src_Ind : constant Source_File_Index := + Sinput.P.Load_Project_File + (Get_Name_String + (Unit.File_Names (Impl).Path.Name)); +begin if not Sinput.P.Source_File_Is_Subunit (Src_Ind) then
Re: [RFC] Add middle end hook for stack red zone size
On Mon, Aug 01, 2011 at 11:44:04AM +0800, Jiangning Liu wrote: It's quite necessary to solve the general problem in middle-end rather than in back-end. That's what we disagree on. All back-ends but ARM are able to handle it right, why can't ARM too? The ABI rules for stack handling in the epilogues are simply too diverse and complex to be handled easily in the scheduler. Jakub
[Ada] Incorrect assignment when deleting node
When a node was being removed from the tree, the node itself was being assigned to the child of its parent, which was incorrect. The correct assignment value is the left child of the deleted node. Tested on x86_64-pc-linux-gnu, committed on trunk 2011-08-01 Matthew Heaney hea...@adacore.com * a-rbtgbo.adb (Delete_Node_Sans_Free): Fixed assignment to left child of node. Index: a-rbtgbo.adb === --- a-rbtgbo.adb(revision 176998) +++ a-rbtgbo.adb(working copy) @@ -330,7 +330,7 @@ Set_Right (N (Parent (N (Z))), Y); end if; - Set_Left (N (Y), Z); + Set_Left (N (Y), Left (N (Z))); Set_Parent (N (Left (N (Y))), Y); Set_Right (N (Y), Z); Set_Parent (N (Z), Y);
[Ada] Delay all aspects
This patch implements delay of all aspects till the freeze point as finally decided in the Ada 2012 design. It also corrects a couple of errors in handling delayed aspects (now that we have many more of them, these errors showed up). Here is a test program (compiled with -gnatws) 1. pragma Ada_2012; 2. with Ada.Text_IO; use Ada.Text_IO; 3. procedure DelayAllAspect is 4.Outer_X : constant Integer := 8; 5.Outer_Y : constant Integer := 8; 6. 7.package X1 is 8. type X1T is range 1 .. 2 with 9. Size = Outer_X; 10. Outer_X : constant Integer := 16; 11.end; 12. 13.package X2 is 14. type X2T is range 1 .. 2 with 15. Size = Outer_X; 16. V2T : X2T; -- freezes 17. Outer_X : constant Integer := 16; 18. -- Should give error! 19.end X2; 20. 21.package X3 is 22. type X3T is range 1 .. 2 with 23. Size = Outer_X + Outer_Y; 24. Outer_Y : constant Integer := 24; 25. V3T : X3T; -- freezes 26. Outer_X : constant Integer := 40; 27. -- Should give error! 28.end X3; 29. 30. begin 31.Put_Line (X1.X1T'Size'Img should be 16); 32.Put_Line (X2.X2T'Size'Imgshould be 8); 33.Put_Line (X3.X3T'Size'Img should be 32); 34. end DelayAllAspect; The output with this patch is: 16 should be 16 8 should be 8 32 should be 32 Note the two lines marked Should give error, These reflect the requirement under discussion that if the freeze point is before the end of the declarative region, and the visibility changes between the freeze point and the end of this region, the program is illegal. This seems very hard to do, and we will wait on this till (a) the final decision is to go in this direction and (b) we figure out how the heck to implement this (sees awfully difficult). Tested on x86_64-pc-linux-gnu, committed on trunk 2011-08-01 Robert Dewar de...@adacore.com * aspects.ads (Boolean_Aspects): New subtype. * exp_ch13.adb (Expand_Freeze_Entity): Fix errors in handling aspects for derived types in cases where the parent type and derived type have aspects. * freeze.adb (Freeze_Entity): Fix problems in handling derived type with aspects when parent type also has aspects. (Freeze_Entity): Deal with delay of boolean aspects (must evaluate boolean expression at this point). * sem_ch13.adb (Analyze_Aspect_Specifications): Delay all aspects in accordance with final decision on the Ada 2012 feature. * sinfo.ads, sinfo.adb (Is_Boolean_Aspect): New flag. Index: sinfo.adb === --- sinfo.adb (revision 176998) +++ sinfo.adb (working copy) @@ -1696,6 +1696,14 @@ return Flag7 (N); end Is_Asynchronous_Call_Block; + function Is_Boolean_Aspect + (N : Node_Id) return Boolean is + begin + pragma Assert (False +or else NT (N).Nkind = N_Aspect_Specification); + return Flag16 (N); + end Is_Boolean_Aspect; + function Is_Component_Left_Opnd (N : Node_Id) return Boolean is begin @@ -4716,6 +4724,14 @@ Set_Flag7 (N, Val); end Set_Is_Asynchronous_Call_Block; + procedure Set_Is_Boolean_Aspect + (N : Node_Id; Val : Boolean := True) is + begin + pragma Assert (False +or else NT (N).Nkind = N_Aspect_Specification); + Set_Flag16 (N, Val); + end Set_Is_Boolean_Aspect; + procedure Set_Is_Component_Left_Opnd (N : Node_Id; Val : Boolean := True) is begin Index: sinfo.ads === --- sinfo.ads (revision 176998) +++ sinfo.ads (working copy) @@ -1252,6 +1252,10 @@ --expansion of an asynchronous entry call. Such a block needs cleanup --handler to assure that the call is cancelled. + -- Is_Boolean_Aspect (Flag16-Sem) + --Present in N_Aspect_Specification node. Set if the aspect is for a + --boolean aspect (i.e. Aspect_Id is in Boolean_Aspect subtype). + -- Is_Component_Left_Opnd (Flag13-Sem) -- Is_Component_Right_Opnd (Flag14-Sem) --Present in concatenation nodes, to indicate that the corresponding @@ -6543,6 +6547,7 @@ -- Class_Present (Flag6) Set if 'Class present -- Next_Rep_Item (Node5-Sem) -- Split_PPC (Flag17) Set if split pre/post attribute + -- Is_Boolean_Aspect (Flag16-Sem) -- Note: Aspect_Specification is an Ada 2012 feature @@ -8487,6 +8492,9 @@ function Is_Asynchronous_Call_Block (N : Node_Id) return Boolean;-- Flag7 + function Is_Boolean_Aspect + (N : Node_Id) return Boolean;-- Flag16 + function Is_Component_Left_Opnd (N : Node_Id) return Boolean;-- Flag13 @@ -9450,6 +9458,9 @@ procedure
[Ada] Incorrect use of iterator when selector was intended
When navigating over the nodes in the same bucket of a hash table, one only needs the next pointer of the current node in order to move to the next node (in the same bucket). The delete operation was using the container-wide iterator to get the pointer to the next node, but this was incorrect, as that iterator operation will navigate across buckets. The (incorrect) use of the iterator was replaced with the (correct) use of the Next selector operation, which returns the value of the Next component of the current node. Tested on x86_64-pc-linux-gnu, committed on trunk 2011-08-01 Matthew Heaney hea...@adacore.com * a-chtgbo.adb (Delete_Node_Sans_Free): Replace iterator with selector. Index: a-chtgbo.adb === --- a-chtgbo.adb(revision 176998) +++ a-chtgbo.adb(working copy) @@ -78,7 +78,7 @@ end if; if Prev = X then - HT.Buckets (Indx) := Next (HT, Prev); + HT.Buckets (Indx) := Next (HT.Nodes (Prev)); HT.Length := HT.Length - 1; return; end if; @@ -89,7 +89,7 @@ end if; loop - Curr := Next (HT, Prev); + Curr := Next (HT.Nodes (Prev)); if Curr = 0 then raise Program_Error with @@ -97,7 +97,7 @@ end if; if Curr = X then -Set_Next (HT.Nodes (Prev), Next = Next (HT, Curr)); +Set_Next (HT.Nodes (Prev), Next = Next (HT.Nodes (Curr))); HT.Length := HT.Length - 1; return; end if;
Re: [RFC] Add middle end hook for stack red zone size
On Mon, 1 Aug 2011, Jakub Jelinek wrote: On Mon, Aug 01, 2011 at 11:44:04AM +0800, Jiangning Liu wrote: It's quite necessary to solve the general problem in middle-end rather than in back-end. That's what we disagree on. All back-ends but ARM are able to handle it right, why can't ARM too? The ABI rules for stack handling in the epilogues are simply too diverse and complex to be handled easily in the scheduler. Given that the long-standing open bugs relating to scheduling and stack adjustments (30282, 38644) include issues for Power that do not yet appear to have been fixed, even if other back ends are able to handle it right they don't seem to do so at present. -- Joseph S. Myers jos...@codesourcery.com
RE: [RFC] Add middle end hook for stack red zone size
The answer is ARM can. However, if you look into the bugs PR30282 and PR38644, PR44199, you may find in history, there are several different cases in different ports reporting the similar failures, covering x86, PowerPC and ARM. You are right, they were all fixed in back-ends in the past, but we should fix the bug in a general way to make GCC infrastructure stronger, rather than fixing the problem target-by-target and case-by-case! If you further look into the back-end fixes in x86 and PowerPC, you may find they looks quite similar in back-ends. Thanks, -Jiangning -Original Message- From: gcc-patches-ow...@gcc.gnu.org [mailto:gcc-patches-ow...@gcc.gnu.org] On Behalf Of Jakub Jelinek Sent: Monday, August 01, 2011 5:12 PM To: Jiangning Liu Cc: 'Joern Rennecke'; g...@gcc.gnu.org; gcc-patches@gcc.gnu.org; vmaka...@redhat.com; dje@gmail.com; Richard Henderson; Ramana Radhakrishnan; 'Ramana Radhakrishnan' Subject: Re: [RFC] Add middle end hook for stack red zone size On Mon, Aug 01, 2011 at 11:44:04AM +0800, Jiangning Liu wrote: It's quite necessary to solve the general problem in middle-end rather than in back-end. That's what we disagree on. All back-ends but ARM are able to handle it right, why can't ARM too? The ABI rules for stack handling in the epilogues are simply too diverse and complex to be handled easily in the scheduler. Jakub
Re: [RFC] Add middle end hook for stack red zone size
On 01/08/11 10:11, Jakub Jelinek wrote: On Mon, Aug 01, 2011 at 11:44:04AM +0800, Jiangning Liu wrote: It's quite necessary to solve the general problem in middle-end rather than in back-end. That's what we disagree on. All back-ends but ARM are able to handle it right, why can't ARM too? The ABI rules for stack handling in the epilogues are simply too diverse and complex to be handled easily in the scheduler. Because the vast majority of back-ends (ie those without red zones) shouldn't have to deal with this mess. This is something the MI code should be able to work out and deal with itself. Then the compiler will at least generate safe code, rather than randomly moving things about and allowing potentially unsafe writes/reads from beyond the allocated stack region. We should build the compiler defensively, but then allow for more aggressive optimizations to disable the defences when the back-end wants to take on the responsibility. Not the other way around. R.
[Ada] Visibility check for aspects, part 1
This patch implements the consistent visibility check for enties with delayed aspects that are frozen early, as shown by the tests below. This step covers all aspects except Invariant and Predicate, which will be taken care of separately. 1. pragma Ada_2012; 2. package AspectVis is 3.R_Size : constant Integer := 32; 4. 5.package Inner is 6. type R is new Integer with 7. Size = R_Size; | visibility of aspect for R changes after freeze point 8. F : R; -- freezes | info: R is frozen here, aspects evaluated at this point 9. R_Size : constant Integer := 64; 10. S : constant Integer := R'Size; -- 32 not 64 11.end Inner; 12. end AspectVis; 1. pragma Ada_2012; 2. package AspectVis2 is 3.R_Size : constant Integer := 32; 4. 5.package Inner is 6. type R is new Integer with 7. Size = R_Size; 1 2 visibility of aspect for R changes after freeze point expected type Standard.Integer found type Standard.Float 8. F : R; -- freezes | info: R is frozen here, aspects evaluated at this point 9. R_Size : constant Float := 64.0; 10. S : constant Integer := R'Size; -- 32 not 64 11.end Inner; 12. end AspectVis2; Tested on x86_64-pc-linux-gnu, committed on trunk 2011-08-01 Robert Dewar de...@adacore.com * freeze.adb (Freeze_Entity): Call Check_Aspect_At_Freeze_Point (Freeze_All): Call Check_Aspect_At_End_Of_Declarations * sem_ch13.ads, sem_ch13.adb (Check_Aspect_At_Freeze_Point): New procedure. (Check_Aspect_At_End_Of_Declarations): New procedure (Analye_Aspect_Specification): Minor changes for above procedures * sinfo.ads, sinfo.adb (Is_Delayed_Aspect): Now set in aspect specification node as well. Index: sinfo.adb === --- sinfo.adb (revision 177005) +++ sinfo.adb (working copy) @@ -1732,6 +1732,7 @@ (N : Node_Id) return Boolean is begin pragma Assert (False +or else NT (N).Nkind = N_Aspect_Specification or else NT (N).Nkind = N_Attribute_Definition_Clause or else NT (N).Nkind = N_Pragma); return Flag14 (N); @@ -4760,6 +4761,7 @@ (N : Node_Id; Val : Boolean := True) is begin pragma Assert (False +or else NT (N).Nkind = N_Aspect_Specification or else NT (N).Nkind = N_Attribute_Definition_Clause or else NT (N).Nkind = N_Pragma); Set_Flag14 (N, Val); Index: sinfo.ads === --- sinfo.ads (revision 177005) +++ sinfo.ads (working copy) @@ -1265,7 +1265,8 @@ -- Is_Delayed_Aspect (Flag14-Sem) --Present in N_Pragma and N_Attribute_Definition_Clause nodes which --come from aspect specifications, where the evaluation of the aspect - --must be delayed to the freeze point. + --must be delayed to the freeze point. This flag is also set True in + --the corresponding N_Aspect_Specification node. -- Is_Controlling_Actual (Flag16-Sem) --This flag is set on in an expression that is a controlling argument in @@ -6548,9 +6549,17 @@ -- Next_Rep_Item (Node5-Sem) -- Split_PPC (Flag17) Set if split pre/post attribute -- Is_Boolean_Aspect (Flag16-Sem) + -- Is_Delayed_Aspect (Flag14-Sem) -- Note: Aspect_Specification is an Ada 2012 feature + -- Note: The Identifier serves to identify the aspect involved (it + -- is the aspect whose name corresponds to the Chars field). This + -- means that the other fields of this identifier are unused, and + -- in particular we use the Entity field of this identifier to save + -- a copy of the expression for visibility analysis, see spec of + -- Sem_Ch13 for full details of this usage. + -- Note: When a Pre or Post aspect specification is processed, it is -- broken into AND THEN sections. The left most section has Split_PPC -- set to False, indicating that it is the original specification (e.g. Index: freeze.adb === --- freeze.adb (revision 177005) +++ freeze.adb (working copy) @@ -1323,6 +1323,27 @@ if not Is_Frozen (E) then Flist := Freeze_Entity (E, After); Process_Flist; + +-- If already frozen, and there are delayed aspects, this is where +-- we do the visibility check for these aspects (see Sem_Ch13 spec +-- for a description of how we handle aspect visibility). + +elsif Has_Delayed_Aspects (E) then + declare + Ritem : Node_Id; + + begin +
Re: [RFC] Add middle end hook for stack red zone size
On Mon, Aug 01, 2011 at 06:14:27PM +0800, Jiangning Liu wrote: ARM. You are right, they were all fixed in back-ends in the past, but we should fix the bug in a general way to make GCC infrastructure stronger, rather than fixing the problem target-by-target and case-by-case! If you further look into the back-end fixes in x86 and PowerPC, you may find they looks quite similar in back-ends. Red zone is only one difficulty, your patch is e.g. completely ignoring existence of biased stack pointers (e.g. SPARC -m64 has them). Some targets have stack growing in opposite direction, etc. We have really a huge amount of very diverse ABIs and making the middle-end grok what is an invalid stack access is difficult. Jakub
[Ada] Implement new aspects Dynamic_Predicate and Static_Predicate
This patch introduces two new aspects. Dynamic_Predicate provides a subtype predicate which can have any form, but the result cannot be used in loops and case statements. Static_Predicate limits the form of expressions to be static in the sense previously implemented for the static case of Predicate previously, and the subtype can be used in case and loop constructs. The previously implemented plain Predicate aspect, which is implicitly static if the expression meets the static requirements is retained as an impl-defined aspect. The following test shows the diagnosis of errors: 1. pragma Ada_2012; 2. procedure statdynampred1 (A : Integer) is 3.subtype R1 is Integer with 4. Static_Predicate = R1 A; -- not static | expression does not have required form for static predicate 5. 6.subtype R2 is Integer with 7. Dynamic_Predicate = R2 in 3 .. 7; 8. 9. begin 10.for J in R2 loop -- not a static predicate | cannot use subtype R2 with non-static predicate for loop iteration 11. null; 12.end loop; 13. end; The following test compiles clean: 1. pragma Ada_2012; 2. with Text_IO; use Text_IO; 3. procedure statdynampred2 is 4.procedure SD (A : Integer) is 5. subtype R1 is Integer with 6. Dynamic_Predicate = R1 A; -- not static 7. 8. subtype R2 is Integer with 9. Static_Predicate = R2 in 3 .. 7; 10. 11.begin 12. for J in R2 loop -- not a static predicate 13. Put_Line (J'Img); 14. end loop; 15. 16. Put_Line (Boolean'Image (100 in R1)); 17. Put_Line (Boolean'Image (10 in R1)); 18.end; 19. 20. begin 21.SD (23); 22. end; And generates output: 3 4 5 6 7 TRUE FALSE Tested on x86_64-pc-linux-gnu, committed on trunk 2011-08-01 Robert Dewar de...@adacore.com * aspects.ads, aspects.adb: Add Static_Predicate and Dynamic_Predicate. * sem_ch13.adb (Analyze_Aspect_Specification): Add processing for Static_Predicate and Dynamic_Predicate. (Build_Predicate_Function): Add processing for Static_Predicate and Dynamic_Predicate. * sinfo.ads, sinfo.adb (From_Dynamic_Predicate): New flag (From_Static_Predicate): New flag * snames.ads-tmpl: Add Name_Static_Predicate and Name_Dynamic_Predicate Index: sinfo.adb === --- sinfo.adb (revision 177008) +++ sinfo.adb (working copy) @@ -1360,6 +1360,22 @@ return Flag6 (N); end From_Default; + function From_Dynamic_Predicate + (N : Node_Id) return Boolean is + begin + pragma Assert (False +or else NT (N).Nkind = N_Pragma); + return Flag7 (N); + end From_Dynamic_Predicate; + + function From_Static_Predicate + (N : Node_Id) return Boolean is + begin + pragma Assert (False +or else NT (N).Nkind = N_Pragma); + return Flag8 (N); + end From_Static_Predicate; + function Generic_Associations (N : Node_Id) return List_Id is begin @@ -4388,6 +4404,22 @@ Set_Flag6 (N, Val); end Set_From_Default; + procedure Set_From_Dynamic_Predicate + (N : Node_Id; Val : Boolean := True) is + begin + pragma Assert (False +or else NT (N).Nkind = N_Pragma); + Set_Flag7 (N, Val); + end Set_From_Dynamic_Predicate; + + procedure Set_From_Static_Predicate + (N : Node_Id; Val : Boolean := True) is + begin + pragma Assert (False +or else NT (N).Nkind = N_Pragma); + Set_Flag8 (N, Val); + end Set_From_Static_Predicate; + procedure Set_Generic_Associations (N : Node_Id; Val : List_Id) is begin Index: sinfo.ads === --- sinfo.ads (revision 177008) +++ sinfo.ads (working copy) @@ -497,13 +497,6 @@ --has been inserted at the flagged node. This is used to avoid the --generation of duplicate checks. - -- Has_Local_Raise (Flag8-Sem) - --Present in exception handler nodes. Set if the handler can be entered - --via a local raise that gets transformed to a goto statement. This will - --always be set if Local_Raise_Statements is non-empty, but can also be - --set as a result of generation of N_Raise_xxx nodes, or flags set in - --nodes requiring generation of back end checks. - -- Description of Semantic Fields -- @@ -1108,6 +1101,14 @@ --declaration is treated as an implicit reference to the formal in the --ali file. + -- From_Dynamic_Predicate (Flag7-Sem) + --Set for generated pragma Predicate node if this is generated by a + --
[Ada] Invariant aspect now called Type_Invariant
This patch implements the latest version of invariants, in which the aspect is called Type_Invariant, the old name Invariant is retained as an implementation-specific aspect. A general mechanism for dealing with synonyms is also implemented (so that e.g. you cannot specify both Invariant and Type_Invariant for the same entity). Synonyms Precondition and Postcondition have been added for Pre and Post aspects. The names of pragmas are not affected. The first test shows synonym checking in effect (compiled with -gnatj60ld7 -gnata12) 1. package sameaspect is 2.type R1 is new Integer with 3. Atomic = True, 4. Shared = True; | aspect shared for R1 previously given at line 3 5. 6.type R2 is private with 7. Invariant = True, 8. Type_Invariant = False; | aspect type_invariant for R2 previously given at line 7 9. 10. private 11.type R2 is new Integer; 12. end sameaspect; The second test shows the new aspect name Type_Invariant being properly recognized (compiles clean with above switches and executes silently). 1. with Ada.Assertions; use Ada.Assertions; 2. procedure typeinvariant is 3.package P is 4. type R is private with 5. Type_Invariant = False; 6.private 7. type R is record 8. X : Integer := 3; 9. end record; 10.end; 11. 12. begin 13.declare 14. V : P.R; 15.begin 16. raise Program_Error; 17.end; 18. 19. exception 20.when Assertion_Error = 21. null; 22. end; Tested on x86_64-pc-linux-gnu, committed on trunk 2011-08-01 Robert Dewar de...@adacore.com * aspects.ads, aspects.adb: Add aspect Type_Invariant, Precondition, Postcondition. (Same_Aspect): New function. * sem_ch13.adb (Analyze_Aspect_Specifications): Add aspect Type_Invariant, Precondition, Postcondition. * snames.ads-tmpl: Add Name_Type_Invariant. Index: aspects.adb === --- aspects.adb (revision 177009) +++ aspects.adb (working copy) @@ -72,8 +72,8 @@ Asp : Aspect_Id; end record; - Aspect_Names : constant array (Integer range ) of Aspect_Entry := ( - (Name_Ada_2005, Aspect_Ada_2005), + Aspect_Names : constant array (Integer range ) of Aspect_Entry := +((Name_Ada_2005, Aspect_Ada_2005), (Name_Ada_2012, Aspect_Ada_2012), (Name_Address, Aspect_Address), (Name_Alignment,Aspect_Alignment), @@ -95,7 +95,9 @@ (Name_Pack, Aspect_Pack), (Name_Persistent_BSS, Aspect_Persistent_BSS), (Name_Post, Aspect_Post), + (Name_Postcondition,Aspect_Postcondition), (Name_Pre, Aspect_Pre), + (Name_Precondition, Aspect_Precondition), (Name_Predicate,Aspect_Predicate), (Name_Preelaborable_Initialization, Aspect_Preelaborable_Initialization), (Name_Pure_Function,Aspect_Pure_Function), @@ -108,6 +110,7 @@ (Name_Stream_Size, Aspect_Stream_Size), (Name_Suppress, Aspect_Suppress), (Name_Suppress_Debug_Info, Aspect_Suppress_Debug_Info), + (Name_Type_Invariant, Aspect_Type_Invariant), (Name_Unchecked_Union, Aspect_Unchecked_Union), (Name_Universal_Aliasing, Aspect_Universal_Aliasing), (Name_Unmodified, Aspect_Unmodified), @@ -217,6 +220,70 @@ return Has_Aspect_Specifications_Flag (Nkind (N)); end Permits_Aspect_Specifications; + - + -- Same_Aspect -- + - + + -- Table used for Same_Aspect, maps aspect to canonical aspect + + Canonical_Aspect : constant array (Aspect_Id) of Aspect_Id := ( +No_Aspect = No_Aspect, +Aspect_Ada_2005 = Aspect_Ada_2005, +Aspect_Ada_2012 = Aspect_Ada_2005, +Aspect_Address = Aspect_Address, +Aspect_Alignment= Aspect_Alignment, +Aspect_Atomic = Aspect_Atomic, +Aspect_Atomic_Components= Aspect_Atomic_Components, +Aspect_Bit_Order= Aspect_Bit_Order, +Aspect_Component_Size = Aspect_Component_Size, +Aspect_Discard_Names= Aspect_Discard_Names, +Aspect_Dynamic_Predicate= Aspect_Predicate, +Aspect_External_Tag = Aspect_External_Tag, +Aspect_Favor_Top_Level = Aspect_Favor_Top_Level, +Aspect_Inline
[gomp3.1] Handle OMP_PROC_BIND env var
Hi! This patch handles OMP_PROC_BIND=true roughly as GOMP_CPU_AFFINITY=0-65535 if GOMP_CPU_AFFINITY isn't present in the environment, just slightly more efficiently during startup. Tested on x86_64-linux, committed to gomp-3_1-branch. 2011-08-01 Jakub Jelinek ja...@redhat.com * env.c (initialize_env): Call parse_boolean with OMP_PROC_BIND. If OMP_PROC_BIND=true, call gomp_init_affinity even if parse_affinity returned false. * config/linux/affinity.c (gomp_init_affinity): Handle gomp_cpu_affinity_len == 0. --- libgomp/env.c.jj2011-07-11 17:32:52.0 +0200 +++ libgomp/env.c 2011-08-01 13:31:01.0 +0200 @@ -571,6 +571,7 @@ initialize_env (void) { unsigned long stacksize; int wait_policy; + bool bind_var = false; /* Do a compile time check that mkomp_h.pl did good job. */ omp_check_defines (); @@ -578,6 +579,7 @@ initialize_env (void) parse_schedule (); parse_boolean (OMP_DYNAMIC, gomp_global_icv.dyn_var); parse_boolean (OMP_NESTED, gomp_global_icv.nest_var); + parse_boolean (OMP_PROC_BIND, bind_var); parse_unsigned_long (OMP_MAX_ACTIVE_LEVELS, gomp_max_active_levels_var, true); parse_unsigned_long (OMP_THREAD_LIMIT, gomp_thread_limit_var, false); @@ -593,7 +595,7 @@ initialize_env (void) gomp_nthreads_var_list, gomp_nthreads_var_list_len)) gomp_global_icv.nthreads_var = gomp_available_cpus; - if (parse_affinity ()) + if (parse_affinity () || bind_var) gomp_init_affinity (); wait_policy = parse_wait_policy (); if (!parse_spincount (GOMP_SPINCOUNT, gomp_spin_count_var)) --- libgomp/config/linux/affinity.c.jj 2011-02-24 14:11:10.0 +0100 +++ libgomp/config/linux/affinity.c 2011-08-01 13:16:55.0 +0200 @@ -1,4 +1,5 @@ -/* Copyright (C) 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +/* Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 + Free Software Foundation, Inc. Contributed by Jakub Jelinek ja...@redhat.com. This file is part of the GNU OpenMP Library (libgomp). @@ -53,17 +54,36 @@ gomp_init_affinity (void) } CPU_ZERO (cpusetnew); - for (widx = idx = 0; idx gomp_cpu_affinity_len; idx++) -if (gomp_cpu_affinity[idx] CPU_SETSIZE - CPU_ISSET (gomp_cpu_affinity[idx], cpuset)) - { - if (! CPU_ISSET (gomp_cpu_affinity[idx], cpusetnew)) + if (gomp_cpu_affinity_len == 0) +{ + unsigned long count = CPU_COUNT (cpuset); + if (count = 65536) + count = 65536; + gomp_cpu_affinity = malloc (count * sizeof (unsigned short)); + if (gomp_cpu_affinity == NULL) + { + gomp_error (not enough memory to store CPU affinity list); + return; + } + for (widx = idx = 0; widx count idx 65536; idx++) + if (CPU_ISSET (idx, cpuset)) { cpus++; - CPU_SET (gomp_cpu_affinity[idx], cpusetnew); + gomp_cpu_affinity[widx++] = idx; } - gomp_cpu_affinity[widx++] = gomp_cpu_affinity[idx]; - } +} + else +for (widx = idx = 0; idx gomp_cpu_affinity_len; idx++) + if (gomp_cpu_affinity[idx] CPU_SETSIZE + CPU_ISSET (gomp_cpu_affinity[idx], cpuset)) + { + if (! CPU_ISSET (gomp_cpu_affinity[idx], cpusetnew)) + { + cpus++; + CPU_SET (gomp_cpu_affinity[idx], cpusetnew); + } + gomp_cpu_affinity[widx++] = gomp_cpu_affinity[idx]; + } if (widx == 0) { Jakub
[PATCH] Fix bitsizetype TYPE_MAX_VALUE
This sign-extends it, similar to how we treat TYPE_MAX_VALUE of sizetype. Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk. Richard. 2011-08-01 Richard Guenther rguent...@suse.de * stor-layout.c (initialize_sizetypes): Properly sign-extend bitsiztype TYPE_MAX_VALUE. Index: gcc/stor-layout.c === --- gcc/stor-layout.c (revision 176998) +++ gcc/stor-layout.c (working copy) @@ -2247,7 +2247,11 @@ initialize_sizetypes (void) = size_int (GET_MODE_SIZE (TYPE_MODE (bitsizetype))); set_min_and_max_values_for_integral_type (bitsizetype, bprecision, /*is_unsigned=*/true); - /* ??? TYPE_MAX_VALUE is not properly sign-extended. */ + /* bitsizetype is unsigned but we need to fix TYPE_MAX_VALUE so that it is + sign-extended in a way consistent with force_fit_type. */ + TYPE_MAX_VALUE (bitsizetype) += double_int_to_tree (bitsizetype, + tree_to_double_int (TYPE_MAX_VALUE (bitsizetype))); /* Create the signed variants of *sizetype. */ ssizetype = make_signed_type (TYPE_PRECISION (sizetype));
Support .debug_macro with Sun as (PR debug/49887)
As described in the PR, many gcc.dg/debug and g++.dg/debug tests were failing on Solaris/SPARC with -gdwarf-2 -g3 and Sun as. This happens because the signature symbols Sun as requires for the COMDAT groups are emitted in TARGET_ASM_CODE_END, before *debug_hooks-finish runs which creates new ones for .debug_macro. Fixed by moving the emission to TARGET_ASM_FILE_END instead. Bootstrapped without regressions on i386-pc-solaris2.11 and sparc-sun-solaris2.11, installed on mainline. Rainer 2011-07-29 Rainer Orth r...@cebitec.uni-bielefeld.de PR debug/49887 * config/sol2.c (solaris_code_end): Rename to solaris_file_end. * config/sol2-protos.h: Likewise. * config/i386/i386.c (ix86_code_end) [TARGET_SOLARIS]: Don't call solaris_code_end. * config/i386/sol2.h [!USE_GAS] (TARGET_ASM_FILE_END): Redefine. * config/sparc/sparc.c (sparc_file_end) [TARGET_SOLARIS]: Call solaris_file_end. * config/sparc/sol2.h (TARGET_ASM_CODE_END): Remove. diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -8321,10 +8321,6 @@ ix86_code_end (void) rtx xops[2]; int regno; -#ifdef TARGET_SOLARIS - solaris_code_end (); -#endif - for (regno = AX_REG; regno = SP_REG; regno++) { char name[32]; diff --git a/gcc/config/i386/sol2.h b/gcc/config/i386/sol2.h --- a/gcc/config/i386/sol2.h +++ b/gcc/config/i386/sol2.h @@ -160,6 +160,12 @@ along with GCC; see the file COPYING3. #undef TARGET_ASM_NAMED_SECTION #define TARGET_ASM_NAMED_SECTION i386_solaris_elf_named_section +#ifndef USE_GAS +/* Emit COMDAT group signature symbols for Sun as. */ +#undef TARGET_ASM_FILE_END +#define TARGET_ASM_FILE_END solaris_file_end +#endif + /* Unlike GNU ld, Sun ld doesn't coalesce .ctors.N/.dtors.N sections, so inhibit their creation. Also cf. sparc/sysv4.h. */ #ifndef USE_GLD diff --git a/gcc/config/sol2-protos.h b/gcc/config/sol2-protos.h --- a/gcc/config/sol2-protos.h +++ b/gcc/config/sol2-protos.h @@ -1,6 +1,6 @@ /* Operating system specific prototypes to be used when targeting GCC for any Solaris 2 system. - Copyright 2004, 2007, 2010 Free Software Foundation, Inc. + Copyright 2004, 2007, 2010, 2011 Free Software Foundation, Inc. This file is part of GCC. @@ -23,4 +23,4 @@ extern void solaris_register_pragmas (vo extern void solaris_output_init_fini (FILE *, tree); extern void solaris_assemble_visibility (tree, int); extern void solaris_elf_asm_comdat_section (const char *, unsigned int, tree); -extern void solaris_code_end (void); +extern void solaris_file_end (void); diff --git a/gcc/config/sol2.c b/gcc/config/sol2.c --- a/gcc/config/sol2.c +++ b/gcc/config/sol2.c @@ -228,7 +228,7 @@ solaris_elf_asm_comdat_section (const ch for Sun as. With a few exceptions, this is already the case. To identify the missing ones without changing the affected frontents, remember the signature symbols and emit those not marked - TREE_SYMBOL_REFERENCED in solaris_code_end. */ + TREE_SYMBOL_REFERENCED in solaris_file_end. */ if (solaris_comdat_htab == NULL) solaris_comdat_htab = htab_create_alloc (37, comdat_hash, comdat_eq, NULL, xcalloc, free); @@ -275,7 +275,7 @@ solaris_define_comdat_signature (void ** /* Emit unreferenced COMDAT group signature symbols for Sun as. */ void -solaris_code_end (void) +solaris_file_end (void) { if (solaris_comdat_htab == NULL) return; diff --git a/gcc/config/sparc/sol2.h b/gcc/config/sparc/sol2.h --- a/gcc/config/sparc/sol2.h +++ b/gcc/config/sparc/sol2.h @@ -314,10 +314,6 @@ along with GCC; see the file COPYING3. #undef TARGET_ASM_NAMED_SECTION #define TARGET_ASM_NAMED_SECTION sparc_solaris_elf_asm_named_section -/* Emit COMDAT group signature symbols for Sun as. */ -#undef TARGET_ASM_CODE_END -#define TARGET_ASM_CODE_END solaris_code_end - /* Sun as requires doublequoted section names on SPARC. While GNU as supports that, too, we prefer the standard variant. */ #undef SECTION_NAME_FORMAT diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c --- a/gcc/config/sparc/sparc.c +++ b/gcc/config/sparc/sparc.c @@ -10019,6 +10019,10 @@ sparc_file_end (void) if (NEED_INDICATE_EXEC_STACK) file_end_indicate_exec_stack (); + +#ifdef TARGET_SOLARIS + solaris_file_end (); +#endif } #ifdef TARGET_ALTERNATE_LONG_DOUBLE_MANGLING -- - Rainer Orth, Center for Biotechnology, Bielefeld University
Re: [patch tree-optimization]: Fix for PR/49806
On Fri, Jul 29, 2011 at 2:07 PM, Kai Tietz kti...@redhat.com wrote: Hello, this patch fixes regression of bug report PR middle-end/49806, which was caused due unhandled type-cast patterns reasoned by boolification of compares and type-cast preserving from/to boolean types. ChangeLog 2011-07-29 Kai Tietz kti...@redhat.com PR middle-end/49806 * tree-vrp.c (has_operand_boolean_range): Helper function. (simplify_truth_ops_using_ranges): Factored out code pattern into new has_operand_boolean_range function and use it. (simplify_converted_bool_expr_using_ranges): New function. (simplify_stmt_using_ranges): Add new simplification function call. * gcc.dg/tree-ssa/vrp47.c: Remove dom-dump and adjusted scan test for vrp result. Bootstrapped and regression tested for all languages (+ Ada, Obj-C++) on host x86_64-pc-linux-gnu. Ok for apply? Regards, Kai Index: gcc-head/gcc/tree-vrp.c === --- gcc-head.orig/gcc/tree-vrp.c +++ gcc-head/gcc/tree-vrp.c @@ -6747,15 +6747,46 @@ varying: return SSA_PROP_VARYING; } +/* Returns true, if operand OP has either a one-bit type precision, + or if value-range of OP is between zero and one. Otherwise false + is returned. The destination of PSOP will be set to true, if a sign- + overflow on range-check occures. PSOP might be NULL. */ +static bool +has_operand_boolean_range (tree op, bool *psop) +{ + tree val = NULL; + value_range_t *vr; + bool sop = false; + + if (TYPE_PRECISION (TREE_TYPE (op)) == 1) + { + if (psop) + *psop = false; + return true; + } + if (TREE_CODE (op) != SSA_NAME) + return false; + vr = get_value_range (op); + + val = compare_range_with_value (GE_EXPR, vr, integer_zero_node, sop); + if (!val || !integer_onep (val)) + return false; + + val = compare_range_with_value (LE_EXPR, vr, integer_one_node, sop); + if (!val || !integer_onep (val)) + return false; There is a much simpler and cheaper way to detect these cases. return vr-type == VR_RANGE integer_zerop (vr-min) integer_onep (vr-max); and all the strict-overflow stuff with *psop is not necessary. + if (psop) + *psop = sop; + return true; +} + /* Simplify boolean operations if the source is known to be already a boolean. */ static bool simplify_truth_ops_using_ranges (gimple_stmt_iterator *gsi, gimple stmt) { enum tree_code rhs_code = gimple_assign_rhs_code (stmt); - tree val = NULL; tree op0, op1; - value_range_t *vr; bool sop = false; bool need_conversion; @@ -6763,20 +6794,8 @@ simplify_truth_ops_using_ranges (gimple_ gcc_assert (rhs_code == EQ_EXPR || rhs_code == NE_EXPR); op0 = gimple_assign_rhs1 (stmt); - if (TYPE_PRECISION (TREE_TYPE (op0)) != 1) - { - if (TREE_CODE (op0) != SSA_NAME) - return false; - vr = get_value_range (op0); - - val = compare_range_with_value (GE_EXPR, vr, integer_zero_node, sop); - if (!val || !integer_onep (val)) - return false; - - val = compare_range_with_value (LE_EXPR, vr, integer_one_node, sop); - if (!val || !integer_onep (val)) - return false; - } + if (!has_operand_boolean_range (op0, sop)) sounds backward. We have op_with_constant_singledon_value_range, so why not op_with_boolean_range_p instead? + return false; op1 = gimple_assign_rhs2 (stmt); @@ -6802,17 +6821,8 @@ simplify_truth_ops_using_ranges (gimple_ if (rhs_code == EQ_EXPR) return false; - if (TYPE_PRECISION (TREE_TYPE (op1)) != 1) - { - vr = get_value_range (op1); - val = compare_range_with_value (GE_EXPR, vr, integer_zero_node, sop); - if (!val || !integer_onep (val)) - return false; - - val = compare_range_with_value (LE_EXPR, vr, integer_one_node, sop); - if (!val || !integer_onep (val)) - return false; - } + if (!has_operand_boolean_range (op1, sop)) + return false; } if (sop issue_strict_overflow_warning (WARN_STRICT_OVERFLOW_MISC)) @@ -7320,6 +7330,126 @@ simplify_switch_using_ranges (gimple stm return false; } +/* Simplify an integeral boolean-typed casted expression for the + following cases: + 1) (type) ~ (bool) op1 - op1 ^ 1 + 2) (type) ((bool)op1[0..1] (bool)op2[0..1]) - op1 op2 + 3) (type) ((bool)op1[0..1] | (bool)op2[0..1]) - op1 | op2 + 4) (type) ((bool)op1[0..1] ^ (bool)op2[0..1]) - op2 ^ op2 + 5) (type) (val[0..1] == 0) - val ^ 1 + 6) (type) (val[0..1] != 0) - val 2) to 4) don't look in any way special for 'bool' but should treat all kinds of intermediate types. The description does suggest that (type) ~(bool) op1 - op1 ^ 1 is always valid - it is not, unless op1 has a (sub-)range of [0..1]. + + Assuming op1 and op2 hav\EDng type TYPE. */ +
[Patch,AVR]: PR46278 (fake X addressing)
This is Denis' work from http://codereview.appspot.com/4674046/ updated to current trunk in order to resume work on that PR. I removed some changes from the patch (which originated in my original patch) that are avr backend cleanups and don't deal with this fake X addressing PR. Likewise the fix for PR46779 is no more included because that PR is already fixed. There are still many test fails like gcc.c-torture/execute/20021120-1.c:45:1: error: unrecognizable insn: (insn 4063 4062 918 3 (set (reg:SF 24 r24) (mem/c:SF (plus:HI (reg:HI 30 r30) (const_int 62 [0x3e])) [5 %sfp+254 S4 A8])) FAIL: gcc.c-torture/execute/20021120-1.c compilation, -Os gcc.c-torture/compile/20071207-1.c:14:1: error: unrecognizable insn: (insn 306 291 86 4 (set (reg:HI 30 r30) (mem/c:HI (plus:HI (reg/f:HI 28 r28) (const_int 1101 [0x44d])) [3 %sfp+1101 S2 A8])) FAIL: gcc.c-torture/compile/20071207-1.c -O3 -fomit-frame-pointer -funroll-loops gcc.c-torture/compile/pr27907.c:23:1: internal compiler error: in cselib_record_set, at cselib.c:2241 FAIL: gcc.c-torture/compile/pr27907.c -O3 -fomit-frame-pointer -funroll-loops There are also new execution fails. The first kind of unrecognizable fails are like (set (reg: mode QI) (mem (plus:HI (Z + offset ca. 63 The second kind looks like (set (X or Z) (mem:HI (plus:HI (Y + big offset Appears that the second ICEs are triggered by LRA. Regards. Johann Index: config/avr/avr.md === --- config/avr/avr.md (revision 177011) +++ config/avr/avr.md (working copy) @@ -862,10 +862,10 @@ (define_insn *addhi3_sp_R_pc3 (const_int 0)))]) (define_insn *addhi3 - [(set (match_operand:HI 0 register_operand =r,!w,!w,d,r,r) + [(set (match_operand:HI 0 register_operand =r,!w,!w,d,r,r,!d) (plus:HI - (match_operand:HI 1 register_operand %0,0,0,0,0,0) - (match_operand:HI 2 nonmemory_operand r,I,J,i,P,N)))] + (match_operand:HI 1 register_operand %0,0,0,0,0,0,r) + (match_operand:HI 2 nonmemory_operand r,I,J,i,P,N,rn)))] @ add %A0,%A2\;adc %B0,%B2 @@ -873,9 +873,26 @@ (define_insn *addhi3 sbiw %A0,%n2 subi %A0,lo8(-(%2))\;sbci %B0,hi8(-(%2)) sec\;adc %A0,__zero_reg__\;adc %B0,__zero_reg__ - sec\;sbc %A0,__zero_reg__\;sbc %B0,__zero_reg__ - [(set_attr length 2,1,1,2,3,3) - (set_attr cc set_n,set_czn,set_czn,set_czn,set_n,set_n)]) + sec\;sbc %A0,__zero_reg__\;sbc %B0,__zero_reg__ +# + [(set_attr length 2,1,1,2,3,3,4) + (set_attr cc set_n,set_czn,set_czn,set_czn,set_n,set_n,set_n)]) + +;; Special split for three addressing addhi3 +;; to make postreload optimization possible +(define_split ; addhi3 !d,r,rn + [(set (match_operand:HI 0 d_register_operand ) + (plus:HI (match_operand:HI 1 register_operand ) + (match_operand:HI 2 nonmemory_operand )))] + reload_completed +REGNO (operands[0]) != REGNO (operands[1]) + [(set (match_dup 0) +(match_dup 1)) + (set (match_dup 0) +(plus:HI (match_dup 0) + (match_dup 2)))] + ) + (define_insn addsi3 [(set (match_operand:SI 0 register_operand =r,!w,!w,d,r,r) @@ -2755,54 +2772,6 @@ (define_insn_and_split zero_extendhisi2 operands[3] = simplify_gen_subreg (HImode, operands[0], SImode, high_off); }) -(define_insn_and_split zero_extendqidi2 - [(set (match_operand:DI 0 register_operand =r) -(zero_extend:DI (match_operand:QI 1 register_operand r)))] - - # - reload_completed - [(set (match_dup 2) (zero_extend:SI (match_dup 1))) - (set (match_dup 3) (const_int 0))] -{ - unsigned int low_off = subreg_lowpart_offset (SImode, DImode); - unsigned int high_off = subreg_highpart_offset (SImode, DImode); - - operands[2] = simplify_gen_subreg (SImode, operands[0], DImode, low_off); - operands[3] = simplify_gen_subreg (SImode, operands[0], DImode, high_off); -}) - -(define_insn_and_split zero_extendhidi2 - [(set (match_operand:DI 0 register_operand =r) -(zero_extend:DI (match_operand:HI 1 register_operand r)))] - - # - reload_completed - [(set (match_dup 2) (zero_extend:SI (match_dup 1))) - (set (match_dup 3) (const_int 0))] -{ - unsigned int low_off = subreg_lowpart_offset (SImode, DImode); - unsigned int high_off = subreg_highpart_offset (SImode, DImode); - - operands[2] = simplify_gen_subreg (SImode, operands[0], DImode, low_off); - operands[3] = simplify_gen_subreg (SImode, operands[0], DImode, high_off); -}) - -(define_insn_and_split zero_extendsidi2 - [(set (match_operand:DI 0 register_operand =r) -(zero_extend:DI (match_operand:SI 1 register_operand r)))] - - # - reload_completed - [(set (match_dup 2) (match_dup 1)) - (set (match_dup 3) (const_int 0))] -{ - unsigned int low_off = subreg_lowpart_offset (SImode, DImode); - unsigned int high_off = subreg_highpart_offset (SImode, DImode); - - operands[2] = simplify_gen_subreg (SImode, operands[0],
Re: [Patch, i386, testsuite] Fix for PR49547, new tescases for lzcnt instruction
I've merged my changes with trunk (there was a conflict) and fixed typo. Updated patch is attached. Waiting for commit... Thanks, K On Mon, Aug 1, 2011 at 1:03 PM, Kirill Yukhin kirill.yuk...@gmail.com wrote: Thanks! Guys with waa rights, could anybody commit my fix? Thanks, K OK for mainline. Uros. lzcnt-5.gcc.patch Description: Binary data
Re: [Patch, i386, testsuite] Fix for PR49547, new tescases for lzcnt instruction
On Mon, Aug 1, 2011 at 5:20 AM, Kirill Yukhin kirill.yuk...@gmail.com wrote: I've merged my changes with trunk (there was a conflict) and fixed typo. Updated patch is attached. Waiting for commit... Thanks, K On Mon, Aug 1, 2011 at 1:03 PM, Kirill Yukhin kirill.yuk...@gmail.com wrote: Thanks! Guys with waa rights, could anybody commit my fix? Thanks, K OK for mainline. Uros. +# Return 1 if lzcnt instruction can be compiled. +proc check_effective_target_lzcnt { } { +return [check_no_compiler_messages lzcnt object { + void _lzcnt (void) + { + __builtin_clzs (0); + } +} -O2 -mlzcnt ] +} GCC may optimize this away. Please fix it similar to: http://gcc.gnu.org/ml/gcc-patches/2011-07/msg02463.html -- H.J.
Re: [PLUGIN] compile and install gengtype, install gtype.state
ping 2011/7/26 Romain Geissler romain.geiss...@gmail.com: 2011/7/25 Jakub Jelinek ja...@redhat.com: On Mon, Jul 25, 2011 at 09:10:55PM +0200, Romain Geissler wrote: 2011-07-18 Romain Geissler romain.geiss...@gmail.com * gengtype-state.c (#include bconfig.h): Include bconfig.h if GENERATOR_FILE is defined, config.h otherwise. Still not right, this should have been * gengtype-state.c: Include bconfig.h if GENERATOR_FILE is define, config.h otherwise. * gengtype.c: Likewise. * gengtype-lex.l: Likewise. * gengtype-parse.c: Likewise. * Makefile.in (gengtype): Compile and install for host when $enable_plugins is set to yes. (gtype.state): Install when $enable_plugins is set to yes. And this should list all the Makefile.in goals you've changed, added etc. Ok with those changes. Jakub Is it OK with this changelog ? If yes, can someone apply the patch, as i don't have write access. Romain Geissler. 2011-07-18 Romain Geissler romain.geiss...@gmail.com * gengtype-state.c: Include bconfig.h if GENERATOR_FILE is defined, config.h otherwise. * gengtype.c: Likewise. * gengtype-lex.l: Likewise. * gengtype-parse.c: Likewise. * Makefile.in (gengtype-lex.o-warn): New variable. (plugindir): Likewise. (plugin_bindir): Likewise. (plugin_includedir): Use $(plugindir) as prefix base. (MOSTLYCLEANFILES): Add gengtype$(exeext). (native): Depend on gengtype$(exeext) is $enable_plugin is set to yes. (gtype.state): Depend on s-gtype. Use temporary file. (gengtype-lex.o): New rule. (gengtype-parse.o): Likewise. (gengtype-state.o): Likewise. (gengtype$(exeext)): Likewise. (install-gengtype): Likewise. (gengtype.o): Likewise. (build/gengtype.o): Depend on version.h. (build/gengtype-state): Depend on double-int.h, version.h, $(HASHTAB_H), $(OBSTACK_H), $(XREGEX_H) and build/errors.o. (install-plugin): Depend on install-gengtype. Index: gcc/gengtype-state.c === --- gcc/gengtype-state.c (revision 175907) +++ gcc/gengtype-state.c (working copy) @@ -23,7 +23,11 @@ and Basile Starynkevitch bas...@starynkevitch.net */ +#ifdef GENERATOR_FILE #include bconfig.h +#else +#include config.h +#endif #include system.h #include errors.h /* For fatal. */ #include double-int.h Index: gcc/gengtype.c === --- gcc/gengtype.c (revision 175907) +++ gcc/gengtype.c (working copy) @@ -18,7 +18,11 @@ along with GCC; see the file COPYING3. If not see http://www.gnu.org/licenses/. */ +#ifdef GENERATOR_FILE #include bconfig.h +#else +#include config.h +#endif #include system.h #include errors.h /* for fatal */ #include getopt.h Index: gcc/gengtype-lex.l === --- gcc/gengtype-lex.l (revision 175907) +++ gcc/gengtype-lex.l (working copy) @@ -22,7 +22,11 @@ along with GCC; see the file COPYING3. %option noinput %{ +#ifdef GENERATOR_FILE #include bconfig.h +#else +#include config.h +#endif #include system.h #define malloc xmalloc Index: gcc/gengtype-parse.c === --- gcc/gengtype-parse.c (revision 175907) +++ gcc/gengtype-parse.c (working copy) @@ -17,7 +17,11 @@ along with GCC; see the file COPYING3. If not see http://www.gnu.org/licenses/. */ +#ifdef GENERATOR_FILE #include bconfig.h +#else +#include config.h +#endif #include system.h #include gengtype.h Index: gcc/Makefile.in === --- gcc/Makefile.in (revision 175907) +++ gcc/Makefile.in (working copy) @@ -192,6 +192,7 @@ GCC_WARN_CXXFLAGS = $(LOOSE_WARN) $($(@D # be subject to -Werror: # flex output may yield harmless no previous prototype warnings build/gengtype-lex.o-warn = -Wno-error +gengtype-lex.o-warn = -Wno-error # mips-tfile.c contains -Wcast-qual warnings. mips-tfile.o-warn = -Wno-error expmed.o-warn = -Wno-error @@ -566,8 +567,12 @@ libexecdir = @libexecdir@ libsubdir = $(libdir)/gcc/$(target_noncanonical)/$(version) # Directory in which the compiler finds executables libexecsubdir = $(libexecdir)/gcc/$(target_noncanonical)/$(version) -# Directory in which plugin headers are installed -plugin_includedir = $(libsubdir)/plugin/include +# Directory in which all plugin resources are installed +plugindir = $(libsubdir)/plugin + # Directory in which plugin headers are installed +plugin_includedir = $(plugindir)/include +# Directory in which plugin specific executables are installed +plugin_bindir = $(plugindir)/bin # Used to
[Ada] Fixes to preelaborable initialization handling
This change updates the circuitry that handles the preelaborable initialization property for controlled types. It fixes several bugs whereby some types would erroneously be treated as not having preelaborable initialization. It also implements one of the changes in AI05-028 for Ada 2012, to the effect that a controlled type with an overriding Initialize primitive that is a null subprogram does have preelaborable initialization. The following compilations must produce the indicated results: $ gcc -c -gnat05 q4_good_05.ads quiet acceptance $ gcc -c -gnat05 q4_bad_05.ads q4_bad_05.ads:4:43: actual for T must have preelaborable initialization q4_bad_05.ads:5:43: actual for T must have preelaborable initialization q4_bad_05.ads:6:43: actual for T must have preelaborable initialization $ gcc -c -gnat12 q4_good_12.ads quiet acceptance $ gcc -c -gnat12 q4_bad_12.ads q4_bad_12.ads:4:43: actual for T must have preelaborable initialization q4_bad_12.ads:5:43: actual for T must have preelaborable initialization with Q4_Types; with Q4_Gen; package Q4_Bad_05 is package I1 is new Q4_Gen (T = Q4_Types.T1_No_Preelab); package I2 is new Q4_Gen (T = Q4_Types.T2_No_Preelab); package I3 is new Q4_Gen (T = Q4_Types.T1_Preelab12); end Q4_Bad_05; with Q4_Types; with Q4_Gen; package Q4_Bad_12 is package I1 is new Q4_Gen (T = Q4_Types.T1_No_Preelab); package I2 is new Q4_Gen (T = Q4_Types.T2_No_Preelab); end Q4_Bad_12; with Q4_Types; with Q4_Gen; package Q4_Bad_Inst is new Q4_Gen (T = Q4_Types.T99); generic type T () is private; pragma Preelaborable_Initialization (T); package Q4_Gen is end Q4_Gen; with Q4_Types; with Q4_Gen; package Q4_Good_05 is package I1 is new Q4_Gen (T = Q4_Types.T1_Preelab05); package I2 is new Q4_Gen (T = Q4_Types.T2_Preelab05); package I3 is new Q4_Gen (T = Q4_Types.T3_Preelab05); end Q4_Good_05; with Q4_Types; with Q4_Gen; package Q4_Good_12 is package I1 is new Q4_Gen (T = Q4_Types.T1_Preelab12); end Q4_Good_12; package body Q4_Types is procedure Initialize (X : in out T2) is begin null; end Initialize; end Q4_Types; with Ada.Finalization; package Q4_Types is -- The following types have preelaborable initialization in Ada 2005: type T1_Preelab05 is new Ada.Finalization.Controlled with null record; procedure Initialize (X : in out T1_Preelab05; Y : Integer); -- Non overriding Initialize procedure type T2_Preelab05 is new T1_Preelab05 with null record; procedure Initialize (X : in out T2_Preelab05; Y : Integer); -- Overriding Initialize procedure, but not for the predefined Initialize?? type T3_Preelab05 is new Ada.Finalization.Controlled with null record; function Initialize (X : T3_Preelab05) return Integer; -- The following type has never preelaborable initialization type T1_No_Preelab is new Ada.Finalization.Controlled with null record; procedure Initialize (X : in out T1_No_Preelab); type T2_No_Preelab is new T1_No_Preelab with null record; procedure Initialize (X : in out T2_No_Preelab) is null; -- Null Initialize procedure, but ancestor type does not have preelab -- initialization anyway. -- The following type has preelaborable initialization in Ada 2012 -- but not in Ada 2005: type T1_Preelab12 is new Ada.Finalization.Controlled with null record; procedure Initialize (X : in out T1_Preelab12) is null; end Q4_Types; Tested on x86_64-pc-linux-gnu, committed on trunk 2011-08-01 Thomas Quinot qui...@adacore.com * sem_util.adb, sem_util.ads (Has_Overriding_Initialize): Make function conformant with its spec (return True only for types that have an overriding Initialize primitive operation that prevents them from having preelaborable initialization). * sem_cat.adb (Validate_Object_Declaration): Fix test for preelaborable initialization for controlled types in Ada 2005 or later mode. Index: sem_util.adb === --- sem_util.adb(revision 176998) +++ sem_util.adb(working copy) @@ -4889,51 +4889,48 @@ function Has_Overriding_Initialize (T : Entity_Id) return Boolean is BT : constant Entity_Id := Base_Type (T); - Comp : Entity_Id; P: Elmt_Id; begin if Is_Controlled (BT) then + if Is_RTU (Scope (BT), Ada_Finalization) then +return False; - -- For derived types, check immediate ancestor, excluding - -- Controlled itself. - - if Is_Derived_Type (BT) - and then not In_Predefined_Unit (Etype (BT)) - and then Has_Overriding_Initialize (Etype (BT)) - then -return True; - elsif Present (Primitive_Operations (BT)) then P := First_Elmt (Primitive_Operations (BT)); while Present (P) loop - if Chars (Node (P)) = Name_Initialize - and then Comes_From_Source (Node (P)) -
Re: [Patch, i386, testsuite] Fix for PR49547, new tescases for lzcnt instruction
Hi HJ, Thanks for input. I've missed it. Done. Updated patch is attached. Thanks, K On Mon, Aug 1, 2011 at 4:26 PM, H.J. Lu hjl.to...@gmail.com wrote: On Mon, Aug 1, 2011 at 5:20 AM, Kirill Yukhin kirill.yuk...@gmail.com wrote: I've merged my changes with trunk (there was a conflict) and fixed typo. Updated patch is attached. Waiting for commit... Thanks, K On Mon, Aug 1, 2011 at 1:03 PM, Kirill Yukhin kirill.yuk...@gmail.com wrote: Thanks! Guys with waa rights, could anybody commit my fix? Thanks, K OK for mainline. Uros. +# Return 1 if lzcnt instruction can be compiled. +proc check_effective_target_lzcnt { } { + return [check_no_compiler_messages lzcnt object { + void _lzcnt (void) + { + __builtin_clzs (0); + } + } -O2 -mlzcnt ] +} GCC may optimize this away. Please fix it similar to: http://gcc.gnu.org/ml/gcc-patches/2011-07/msg02463.html -- H.J. lzcnt-5.gcc.patch Description: Binary data
Re: [Patch, i386, testsuite] Fix for PR49547, new tescases for lzcnt instruction
On Mon, Aug 1, 2011 at 5:36 AM, Kirill Yukhin kirill.yuk...@gmail.com wrote: Hi HJ, Thanks for input. I've missed it. Done. Updated patch is attached. Compiler may still optimize it away. You need to replace 0 with a function parameter. Please see: http://gcc.gnu.org/ml/gcc-patches/2011-07/msg02463.html H.J. --- Thanks, K On Mon, Aug 1, 2011 at 4:26 PM, H.J. Lu hjl.to...@gmail.com wrote: On Mon, Aug 1, 2011 at 5:20 AM, Kirill Yukhin kirill.yuk...@gmail.com wrote: I've merged my changes with trunk (there was a conflict) and fixed typo. Updated patch is attached. Waiting for commit... Thanks, K On Mon, Aug 1, 2011 at 1:03 PM, Kirill Yukhin kirill.yuk...@gmail.com wrote: Thanks! Guys with waa rights, could anybody commit my fix? Thanks, K OK for mainline. Uros. +# Return 1 if lzcnt instruction can be compiled. +proc check_effective_target_lzcnt { } { + return [check_no_compiler_messages lzcnt object { + void _lzcnt (void) + { + __builtin_clzs (0); + } + } -O2 -mlzcnt ] +} GCC may optimize this away. Please fix it similar to: http://gcc.gnu.org/ml/gcc-patches/2011-07/msg02463.html
[Ada] New syntax for aspects in packages, add library unit aspects
This patch adds aspects for library unit pragmas, e.g. in packages, and implements the new syntax (aspects before IS keyword), as shown in these tests: 1. pragma Ada_2012; 2. package aspectpu with Pure is 3. X : Integer; | declaration of variable not allowed in pure unit 4. end; 1. pragma Ada_2012; 2. package AspectPuerr is 3.package X with Pure is | incorrect context for library unit aspect Pure 4.end X; 5. end AspectPuerr; 1. pragma Ada_2012; 2. procedure Aspectsubp with 3. Pure = True; (the last test needs -gnatc) Tested on x86_64-pc-linux-gnu, committed on trunk 2011-08-01 Robert Dewar de...@adacore.com * aspects.ads, aspects.adb: Add aspects for library unit pragmas (Pre_Post_Aspects): New subtype. * par-ch12.adb (P_Generic): New syntax for aspects in packages * par-ch13.adb (P_Aspect_Specifications): Add Semicolon parameter * par-ch7.adb (P_Package): Remove Decl parameter (P_Package): Handle new syntax for aspects (before IS) * par-ch9.adb (P_Protected_Definition): Remove Decl parameter, handle new aspect syntax (P_Task_Definition): Remove Decl parameter, handle new aspect syntax * par.adb (P_Aspect_Specifications): Add Semicolon parameter (P_Package): Remove Decl parameter * sem_ch13.adb (Analyze_Aspect_Specifications): Handle library unit aspects * sem_ch7.adb (Analyze_Package_Declaration): Analyze new format aspect specs * sem_util.ads, sem_util.adb (Static_Boolean): New function * sinfo.ads: Document new syntax for aspects in packages etc. * sprint.adb: Handle new syntax of aspects before IS in package Index: sinfo.ads === --- sinfo.ads (revision 169935) +++ sinfo.ads (working copy) @@ -1158,7 +1158,7 @@ -- Has_Pragma_Suppress_All (Flag14-Sem) --This flag is set in an N_Compilation_Unit node if the Suppress_All - --pragma appears anywhere in the unit. This accomodates the rather + --pragma appears anywhere in the unit. This accommodates the rather --strange placement rules of other compilers (DEC permits it at the --end of a unit, and Rational allows it as a program unit pragma). We --allow it anywhere at all, and consider it equivalent to a pragma @@ -1468,7 +1468,7 @@ -- Next_Exit_Statement (Node3-Sem) --Present in N_Exit_Statement nodes. The exit statements for a loop are - --chained (in reverse order of appearence) from the First_Exit_Statement + --chained (in reverse order of appearance) from the First_Exit_Statement --field of the E_Loop entity for the loop. Next_Exit_Statement points to --the next entry on this chain (Empty = end of list). @@ -1479,7 +1479,7 @@ --A postorder traversal of the tree whose nodes are units and whose --links are with_clauses defines the order in which Inspector must --examine a compiled unit and its full context. This ordering ensures - --that any subprogram call is examined after the subprogram declartion + --that any subprogram call is examined after the subprogram declaration --has been seen. -- Next_Named_Actual (Node4-Sem) @@ -1747,9 +1747,9 @@ --secondary stack. -- Suppress_Assignment_Checks (Flag18-Sem) - --Used in genererated N_Assignment_Statement nodes to suppress predicate + --Used in generated N_Assignment_Statement nodes to suppress predicate --and range checks in cases where the generated code knows that the - --value being assigned is in range and satisifies any predicate. Also + --value being assigned is in range and satisfies any predicate. Also --can be set in N_Object_Declaration nodes, to similarly suppress any --checks on the initializing value. @@ -4078,7 +4078,7 @@ -- Suppress_Assignment_Checks (Flag18-Sem) -- Note: if a range check is required, then the Do_Range_Check flag - -- is set in the Expression (right hand side), with the check b6ing + -- is set in the Expression (right hand side), with the check being -- done against the type of the Name (left hand side). -- Note: the back end places some restrictions on the form of the @@ -4203,7 +4203,7 @@ -- explicit loop identifier. Otherwise the parser leaves this field -- set to Empty, and then the semantic processing for a loop statement -- creates an identifier, setting the Has_Created_Identifier flag to - -- True. So after semantic anlaysis, the Identifier is always set, + -- True. So after semantic analysis, the Identifier is always set, -- referencing an identifier whose entity has an Ekind of E_Loop. -- @@
Re: [Patch, i386, testsuite] Fix for PR49547, new tescases for lzcnt instruction
Done. Updated patch is attached. Thanks, K On Mon, Aug 1, 2011 at 4:49 PM, H.J. Lu hjl.to...@gmail.com wrote: On Mon, Aug 1, 2011 at 5:36 AM, Kirill Yukhin kirill.yuk...@gmail.com wrote: Hi HJ, Thanks for input. I've missed it. Done. Updated patch is attached. Compiler may still optimize it away. You need to replace 0 with a function parameter. Please see: http://gcc.gnu.org/ml/gcc-patches/2011-07/msg02463.html H.J. --- Thanks, K On Mon, Aug 1, 2011 at 4:26 PM, H.J. Lu hjl.to...@gmail.com wrote: On Mon, Aug 1, 2011 at 5:20 AM, Kirill Yukhin kirill.yuk...@gmail.com wrote: I've merged my changes with trunk (there was a conflict) and fixed typo. Updated patch is attached. Waiting for commit... Thanks, K On Mon, Aug 1, 2011 at 1:03 PM, Kirill Yukhin kirill.yuk...@gmail.com wrote: Thanks! Guys with waa rights, could anybody commit my fix? Thanks, K OK for mainline. Uros. +# Return 1 if lzcnt instruction can be compiled. +proc check_effective_target_lzcnt { } { + return [check_no_compiler_messages lzcnt object { + void _lzcnt (void) + { + __builtin_clzs (0); + } + } -O2 -mlzcnt ] +} GCC may optimize this away. Please fix it similar to: http://gcc.gnu.org/ml/gcc-patches/2011-07/msg02463.html lzcnt-6.gcc.patch Description: Binary data
[Ada] Add procedure to print out the predefined floating point types
This new procedure is a clean up that replaces explicit references of constants such as Standard_Long_Float_Size by calls to attribute functions in Einfo. This will allow eventual removal of explicit constants for each predefined type. No functional change. Tested on x86_64-pc-linux-gnu, committed on trunk 2011-08-01 Geert Bosch bo...@adacore.com * cstand.adb (P_Float_Type): New procedure to print the definition of predefined fpt types. (P_Mixed_Name): New procedure to print a name using mixed case (Print_Standard): Use P_Float_Type for printing floating point types * einfo.adb (Machine_Emax_Value): Add preliminary support for quad precision IEEE float. Index: cstand.adb === --- cstand.adb (revision 177026) +++ cstand.adb (working copy) @@ -1673,6 +1673,12 @@ procedure P_Float_Range (Id : Entity_Id); -- Prints the bounds range for the given float type entity + procedure P_Float_Type (Id : Entity_Id); + -- Prints the type declaration of the given float type entity + + procedure P_Mixed_Name (Id : Name_Id); + -- Prints Id in mixed case + --- -- P_Float_Range -- --- @@ -1687,6 +1693,26 @@ Write_Eol; end P_Float_Range; + -- + -- P_Float_Type -- + -- + + procedure P_Float_Type (Id : Entity_Id) is + begin + Write_Str ( type ); + P_Mixed_Name (Chars (Id)); + Write_Str ( is digits ); + Write_Int (UI_To_Int (Digits_Value (Id))); + Write_Eol; + P_Float_Range (Id); + Write_Str ( for ); + P_Mixed_Name (Chars (Id)); + Write_Str ('Size use ); + Write_Int (UI_To_Int (RM_Size (Id))); + Write_Line (;); + Write_Eol; + end P_Float_Type; + - -- P_Int_Range -- - @@ -1702,6 +1728,23 @@ Write_Eol; end P_Int_Range; + -- + -- P_Mixed_Name -- + -- + + procedure P_Mixed_Name (Id : Name_Id) is + begin + Get_Name_String (Id); + + for J in 1 .. Name_Len loop +if J = 1 or else Name_Buffer (J - 1) = '_' then + Name_Buffer (J) := Fold_Upper (Name_Buffer (J)); +end if; + end loop; + + Write_Str (Name_Buffer (1 .. Name_Len)); + end P_Mixed_Name; + -- Start of processing for Print_Standard begin @@ -1764,42 +1807,11 @@ -- Floating point types - Write_Str ( type Short_Float is digits ); - Write_Int (Standard_Short_Float_Digits); - Write_Eol; - P_Float_Range (Standard_Short_Float); - Write_Str ( for Short_Float'Size use ); - Write_Int (Standard_Short_Float_Size); - P (;); - Write_Eol; + P_Float_Type (Standard_Short_Float); + P_Float_Type (Standard_Float); + P_Float_Type (Standard_Long_Float); + P_Float_Type (Standard_Long_Long_Float); - Write_Str ( type Float is digits ); - Write_Int (Standard_Float_Digits); - Write_Eol; - P_Float_Range (Standard_Float); - Write_Str ( for Float'Size use ); - Write_Int (Standard_Float_Size); - P (;); - Write_Eol; - - Write_Str ( type Long_Float is digits ); - Write_Int (Standard_Long_Float_Digits); - Write_Eol; - P_Float_Range (Standard_Long_Float); - Write_Str ( for Long_Float'Size use ); - Write_Int (Standard_Long_Float_Size); - P (;); - Write_Eol; - - Write_Str ( type Long_Long_Float is digits ); - Write_Int (Standard_Long_Long_Float_Digits); - Write_Eol; - P_Float_Range (Standard_Long_Long_Float); - Write_Str ( for Long_Long_Float'Size use ); - Write_Int (Standard_Long_Long_Float_Size); - P (;); - Write_Eol; - P ( type Character is (...)); Write_Str ( for Character'Size use ); Write_Int (Standard_Character_Size); Index: einfo.adb === --- einfo.adb (revision 177026) +++ einfo.adb (working copy) @@ -6518,7 +6518,7 @@ case Digs is when 1 .. 6 = return Uint_128; when 7 .. 15 = return 2**10; - when 16 .. 18 = return 2**14; + when 16 .. 33 = return 2**14; when others = return No_Uint; end case;
[Ada] Improve error message for extra , in choice list
The new error messages should be: c.adb:4:16: extra , ignored c.adb:9:16: , should be | for the following test case: procedure c (X : Boolean) is begin case X is when True, | False = null; end case; case X is when True, False = null; end case; end c; Tested on x86_64-pc-linux-gnu, committed on trunk 2011-08-01 Geert Bosch bo...@adacore.com * par-ch3.adb (P_Discrete_Choice_List): Improve error message for extra , in choice list. Index: par-ch3.adb === --- par-ch3.adb (revision 176998) +++ par-ch3.adb (working copy) @@ -3714,13 +3714,23 @@ end if; if Token = Tok_Comma then -Error_Msg_SC -- CODEFIX - (, should be '|); +Scan; -- past comma + +if Token = Tok_Vertical_Bar then + Error_Msg_SP -- CODEFIX + (|extra , ignored); + Scan; -- past | + +else + Error_Msg_SP -- CODEFIX + (, should be '|); +end if; + else exit when Token /= Tok_Vertical_Bar; +Scan; -- past | end if; - Scan; -- past | or comma end loop; return Choices;
[Ada] Better reference information for in out params
The ali file not includes both a read and modify reference for an entity that is an actual for an in-out parameter. The following commands: gcc -c gp.adb grep G{integer} gp.ali must yield: 2i4*G{integer} 2|9m14 9r14 --- package GP is G : Integer; procedure Indirect_Read_Write; end GP; --- package body GP is procedure Indirect_Read_Write is procedure Local (Proxy : in out Integer) is pragma Precondition (Proxy Integer'Last); begin Proxy := Proxy + 1; end Local; begin Local (G); end Indirect_Read_Write; end GP; Tested on x86_64-pc-linux-gnu, committed on trunk 2011-08-01 Ed Schonberg schonb...@adacore.com * sem_ch8.adb (Find_Direct_Name, Analyze_Expanded_Name): use Is_LHS to better determine whether an entity reference is a write. * sem_util.adb (Is_LHS): refine predicate to handle assignment to a subcomponent. * lib-xref.adb (Output_References): Do no suppress a read reference at the same location as an immediately preceeding modify-reference, to handle properly in-out actuals. Index: sem_util.adb === --- sem_util.adb(revision 177027) +++ sem_util.adb(working copy) @@ -6663,8 +6663,17 @@ function Is_LHS (N : Node_Id) return Boolean is P : constant Node_Id := Parent (N); begin - return Nkind (P) = N_Assignment_Statement -and then Name (P) = N; + if Nkind (P) = N_Assignment_Statement then + return Name (P) = N; + + elsif +Nkind_In (P, N_Indexed_Component, N_Selected_Component, N_Slice) + then + return N = Prefix (P) and then Is_LHS (P); + + else + return False; + end if; end Is_LHS; Index: sem_ch8.adb === --- sem_ch8.adb (revision 176998) +++ sem_ch8.adb (working copy) @@ -4574,10 +4574,21 @@ -- --The Is_Actual_Parameter routine takes care of one of these --cases but there are others probably ??? +-- +--If the entity is the LHS of an assignment, and is a variable +--(rather than a package prefix), we can mark it as a +--modification right away, to avoid duplicate references. else if not Is_Actual_Parameter then - Generate_Reference (E, N); + if Is_LHS (N) +and then Ekind (E) /= E_Package +and then Ekind (E) /= E_Generic_Package + then + Generate_Reference (E, N, 'm'); + else + Generate_Reference (E, N); + end if; end if; Check_Nested_Access (E); @@ -4980,7 +4991,12 @@ Set_Entity (N, Id); else Set_Entity_Or_Discriminal (N, Id); - Generate_Reference (Id, N); + + if Is_LHS (N) then +Generate_Reference (Id, N, 'm'); + else +Generate_Reference (Id, N); + end if; end if; if Is_Type (Id) then Index: lib-xref.adb === --- lib-xref.adb(revision 176998) +++ lib-xref.adb(working copy) @@ -1377,6 +1377,9 @@ Ctyp : Character; -- Entity type character + Prevt : Character; + -- reference kind of previous reference + Tref : Entity_Id; -- Type reference @@ -1519,6 +1522,7 @@ Curdef := No_Location; Curru := No_Unit; Crloc := No_Location; + Prevt := 'm'; -- Loop to output references @@ -2193,12 +2197,17 @@ Crloc := No_Location; end if; - -- Output the reference + -- Output the reference if it is not as the same location + -- as the previous one, or it is a read-reference that + -- indicates that the entity is an in-out actual in a call. if XE.Loc /= No_Location - and then XE.Loc /= Crloc +and then + (XE.Loc /= Crloc + or else (Prevt = 'm' and then XE.Typ = 'r')) then Crloc := XE.Loc; + Prevt := XE.Typ; -- Start continuation if line full, else blank
[Ada] Improved error message on invisible operator
A common programming error is to assume that a predefined operator is visible when its operand type is in scope. The compiler in that case indicates that a use clause would make the operation legal. However, the type maybe only in scope indirectly, through other visible units, in which case the error message is incomplete, because a use_clause will not be sufficient to make the operator visible. THis patch recognizes this case, and specializes the error message accordingly. Compiling user.adb below must yield: user.adb:5:11: operator for type E defined at typ.ads:2 is not directly visible user.adb:5:11: add with_clause and use_clause for Typ --- with Cst; use Cst; procedure User is begin if Get = C then null; end if; end; --- package Typ is type E is range 0 .. 10; end; --- with Typ; use Typ; package Cst is C : constant E := 0; function Get return E; end; Tested on x86_64-pc-linux-gnu, committed on trunk 2011-08-01 Ed Schonberg schonb...@adacore.com * sem_ch4.adb (Operator_Check): improve error message when both a with_clause and a use_clause are needed to make operator usage legal. * sem_util.ads, sem_util.adb (Unit_Is_Visible): new predicate to determine whether a compilation unit is visible within an other, either through a with_clause in the current unit, or a with_clause in its library unit or one one of its parents. Index: sem_util.adb === --- sem_util.adb(revision 177030) +++ sem_util.adb(working copy) @@ -11533,6 +11533,109 @@ package body Sem_Util is return N; end Unit_Declaration_Node; + - + -- Unit_Is_Visible -- + - + + function Unit_Is_Visible (U : Entity_Id) return Boolean is + Curr: constant Node_Id := Cunit (Current_Sem_Unit); + Curr_Entity : constant Entity_Id := Cunit_Entity (Current_Sem_Unit); + + function Unit_In_Parent_Context (Par_Unit : Node_Id) return Boolean; + -- For a child unit, check whether unit appears in a with_clause + -- of a parent. + + function Unit_In_Context (Comp_Unit : Node_Id) return Boolean; + -- Scan the context clause of one compilation unit looking for a + -- with_clause for the unit in question. + + + -- Unit_In_Parent_Context -- + + + function Unit_In_Parent_Context (Par_Unit : Node_Id) return Boolean + is + begin + if Unit_In_Context (Par_Unit) then +return True; + + elsif Is_Child_Unit (Defining_Entity (Unit (Par_Unit))) then +return Unit_In_Parent_Context (Parent_Spec (Unit (Par_Unit))); + + else +return False; + end if; + end Unit_In_Parent_Context; + + - + -- Unit_In_Context -- + - + + function Unit_In_Context (Comp_Unit : Node_Id) return Boolean is + Clause : Node_Id; + + begin + Clause := First (Context_Items (Comp_Unit)); + while Present (Clause) loop +if Nkind (Clause) = N_With_Clause then + if Library_Unit (Clause) = U then + return True; + + -- The with_clause may denote a renaming of the unit we are + -- looking for, eg. Text_IO which renames Ada.Text_IO. + + elsif + Renamed_Entity (Entity (Name (Clause))) + = Defining_Entity (Unit (U)) + then + return True; + end if; +end if; + +Next (Clause); + end loop; + return False; + end Unit_In_Context; + + begin + + -- The currrent unit is directly visible. + + if Curr = U then + return True; + + elsif Unit_In_Context (Curr) then + return True; + + -- If the current unit is a body, check the context of the spec. + + elsif Nkind (Unit (Curr)) = N_Package_Body +or else + (Nkind (Unit (Curr)) = N_Subprogram_Body +and then not Acts_As_Spec (Unit (Curr))) + then + + if Unit_In_Context (Library_Unit (Curr)) then +return True; + end if; + end if; + + -- If the spec is a child unit, examine the parents. + + if Is_Child_Unit (Curr_Entity) then + if Nkind (Unit (Curr)) in N_Unit_Body then +return + Unit_In_Parent_Context +(Parent_Spec (Unit (Library_Unit (Curr; + else +return Unit_In_Parent_Context (Parent_Spec (Unit (Curr))); + end if; + + else + return False; + end if; + end Unit_Is_Visible; + -- -- Universal_Interpretation -- -- Index: sem_util.ads
Re: [PATCH] ARM fixed-point support [5.5/6]: argument return padding for libcalls
On Thu, May 26, 2011 at 9:56 AM, Julian Brown jul...@codesourcery.com wrote: This patch allows padding to be specified per-target for libcalls. This hasn't been traditionally important, because libcalls haven't accepted quantities which might need padding, but that's no longer true with the new(-ish) fixed-point support helper functions. Tested (alongside other fixed-point support patches) with cross to ARM EABI in both big little-endian mode (the target-specific part is to avoid a behaviour change for half-float types on ARM). OK to apply? Thanks, Julian ChangeLog gcc/ * calls.c (emit_library_call_value_1): Support padding for libcall arguments and return values. * config/arm/arm.c (arm_pad_arg_upward): Pad half-float values downwards in big-endian mode. This breaks bootstrap on Linux/x86: http://gcc.gnu.org/ml/gcc-regression/2011-08/msg7.html ../../src-trunk/gcc/calls.c: In function 'rtx_def* emit_library_call_value_1(int, rtx, rtx, libcall_type, machine_mode, int, __va_list_tag*)': ../../src-trunk/gcc/calls.c:3832:11: error: unused variable 'size' [-Werror=unused-variable] cc1plus: all warnings being treated as errors make[6]: *** [calls.o] Error 1 -- H.J.
Re: [C++0x] contiguous bitfields race implementation
On Fri, Jul 29, 2011 at 11:37 AM, Richard Guenther richard.guent...@gmail.com wrote: On Fri, Jul 29, 2011 at 4:12 AM, Aldy Hernandez al...@redhat.com wrote: On 07/28/11 06:40, Richard Guenther wrote: Looking at the C++ memory model what you need is indeed simple enough to recover here. Still this loop does quadratic work for a struct with N bitfield members and a function which stores into all of them. And that with a big constant factor as you build a component-ref and even unshare trees (which isn't necessary here anyway). In fact you could easily manually keep track of bitpos when walking adjacent bitfield members. An initial call to get_inner_reference on TREE_OPERAND (exp, 0) would give you the starting position of the record. That would still be quadratic of course. Actually, we don't need to call get_inner_reference at all. It seems DECL_FIELD_BIT_OFFSET has all the information we need. How about we simplify things further as in the attached patch? Tested on x86-64 Linux. OK for mainline? Well ... byte pieces of the offset can be in the tree offset (DECL_FIELD_OFFSET). Only up to DECL_OFFSET_ALIGN bits are tracked in DECL_FIELD_BIT_OFFSET (and DECL_FIELD_OFFSET can be a non-constant - at least for Ada, not sure about C++). But - can you please expand a bit on the desired semantics of get_bit_range? Especially, relative to what is *bitstart / *bitend supposed to be? Why do you pass in bitpos and bitsize - they seem to be used as local variables only. Why is the check for thread-local storage in this function and not in the caller (and what's the magic [0,0] bit-range relative to?)? The existing get_inner_reference calls give you a bitpos relative to the start of the containing object - but /* If this is the last element in the structure, include the padding at the end of structure. */ *bitend = TREE_INT_CST_LOW (TYPE_SIZE (record_type)) - 1; will set *bitend to the size of the direct parent structure size, not the size of the underlying object. Your proposed patch changes bitpos to be relative to the direct parent structure. Using TYPE_SIZE can also run into issues with C++ tail packing, you need to use DECL_SIZE of the respective field instead. Consider struct A { int : 17; }; struct B : public A { char c; }; where I'm not sure we are not allowed to pack c into the tail padding in A. Also neither TYPE_SIZE nor DECL_SIZE have to be constant, at least in Ada you can have a variable-sized array before, and in C you can have a trailing one. Richard. So - I guess you need to play with some testcases like struct { int some_padding; struct { int bitfield :1; } x; }; and split / clarify some of get_bit_range comments. Thanks, Richard.
Re: [PATCH] ARM fixed-point support [5.5/6]: argument return padding for libcalls
On Mon, Aug 1, 2011 at 6:38 AM, H.J. Lu hjl.to...@gmail.com wrote: On Thu, May 26, 2011 at 9:56 AM, Julian Brown jul...@codesourcery.com wrote: This patch allows padding to be specified per-target for libcalls. This hasn't been traditionally important, because libcalls haven't accepted quantities which might need padding, but that's no longer true with the new(-ish) fixed-point support helper functions. Tested (alongside other fixed-point support patches) with cross to ARM EABI in both big little-endian mode (the target-specific part is to avoid a behaviour change for half-float types on ARM). OK to apply? Thanks, Julian ChangeLog gcc/ * calls.c (emit_library_call_value_1): Support padding for libcall arguments and return values. * config/arm/arm.c (arm_pad_arg_upward): Pad half-float values downwards in big-endian mode. This breaks bootstrap on Linux/x86: http://gcc.gnu.org/ml/gcc-regression/2011-08/msg7.html ../../src-trunk/gcc/calls.c: In function 'rtx_def* emit_library_call_value_1(int, rtx, rtx, libcall_type, machine_mode, int, __va_list_tag*)': ../../src-trunk/gcc/calls.c:3832:11: error: unused variable 'size' [-Werror=unused-variable] cc1plus: all warnings being treated as errors make[6]: *** [calls.o] Error 1 I am testing this patch. -- H.J. --- diff --git a/gcc/calls.c b/gcc/calls.c index 7ad30b4..c4f8b46 100644 --- a/gcc/calls.c +++ b/gcc/calls.c @@ -3829,7 +3829,9 @@ emit_library_call_value_1 (int retval, rtx orgfun, rtx val ue, rtx val = argvec[argnum].value; rtx reg = argvec[argnum].reg; int partial = argvec[argnum].partial; +#ifdef BLOCK_REG_PADDING int size = 0; +#endif /* Handle calls that pass values in multiple non-contiguous locations. The PA64 has examples of this for library calls. */
Re: Support -mcpu=native on Solaris/SPARC
Rainer Orth r...@cebitec.uni-bielefeld.de writes: This is a first cut at supporting -mcpu=native/-mtune=native on Solaris/SPARC. Unlike it's Tru64 UNIX/Alpha and IRIX/MIPS (to be submitted soon) counterparts, it's a bit more involved: * There's no support for -mcpu=native in the SPARC port yet. * Access to the %ver register is privileged, so we need OS interfaces to access the information. I couldn't find anything in libc. While the AT_SUN_CPU file from sys/auxv.h might fill the bill, it isn't actually set according to pargs -x. There seem to be two options: libkstat and libpicl. The former has the advantage that it's a tad better documented and talks directly to the kernel, while the latter needs picld, which seems overkill. Both are present in Solaris 8, though. I prefer the cpu_info:::brand kstat over cpu_info:::implementation: The former looks like (from kstat -p cpu_info:::brand): cpu_info:0:cpu_info0:brand UltraSPARC-T2 compared to cpu_info:0:cpu_info0:implementation UltraSPARC-T2 (chipid 0, clock 1165 MHz) but brand was only introduced in Solaris 10. Before that, only implementation existed with this contents: cpu_info:0:cpu_info0:implementation UltraSPARC-IIIi * Unlike IRIX and Tru64 UNIX, where the respective interfaces return a numeric identifier for the cpu type from a finite range, on SPARC we get string names, and I'm having some trouble determining the complete set. The patch below is based on what I've found so far, but certainly needs to be augmented for sun4m cpus which I don't have any longer. * The requirement to link the drivers with an additional library (-lkstat) prompted me to introduce GCC_EXTRA_LIBS. I didn't want to link the backends with -lkstat since they don't need it. The build maintainers may not like the way this was done, though. * Right now, this is Solaris-only since I have no idea what /proc/cpuinfo on Linux/SPARC contains. With all those caveats, the patch has been run through a C-only non-bootstrap build on sparc-sun-solaris2.11 so far. -mcpu=native/-mtune=native seem to work as expected, though I'll have to broaden the range of OS versions tested. I'm seeing tons of testsuite Here's an updated version of the patch, containing two changes: * Solaris 8 doesn't support KSTAT_DATA_STRING. * I've updated the list of known cpu types, based on the /platform/sun4?/kernel/cpu{, /sparcv9} entries found in Solaris 8, 9, 10 and 11. It seems that the vendor field sometimes present there (SUNW, TI, Ross, ...) is consistently absent in the kstat output. While I could confirm this on all sun4u/sun4v system we have, I don't have access to sun4m machines any longer, so it's just a guess. Bootstrapped without regressions no sparc-sun-solaris2.{8, 9, 10, 11} without regressions (Solaris 8 bootstrap still running), -mcpu is correctly detected everywhere. Ok for mainline? Thanks. Rainer 2011-07-27 Rainer Orth r...@cebitec.uni-bielefeld.de gcc: * config/sparc/driver-sparc.c: New file. * config/sparc/x-sparc: New file. * config.host: Use driver-sparc.o, sparc/x-sparc on sparc*-*-solaris2*. * config/sparc/sparc.opt (native): New value for enum processor_type. * config/sparc/sparc-opts.h (PROCESSOR_NATIVE): Declare. * config/sparc/sparc.c (sparc_option_override): Abort if PROCESSOR_NATIVE gets here. * config/sparc/sol2.h [__sparc__] (host_detect_local_cpu): Declare. (EXTRA_SPEC_FUNCTIONS, MCPU_MTUNE_NATIVE_SPECS, DRIVER_SELF_SPECS): Define. * configure.ac (EXTRA_GCC_LIBS): Check for libkstat. Substitute result. * configure: Regenerate. * Makefile.in (EXTRA_GCC_LIBS): Set. (xgcc$(exeext)): Add $(EXTRA_GCC_LIBS). (cpp$(exeext)): Likewise. gcc/cp: * Make-lang.in (g++$(exeext)): Add $(EXTRA_GCC_LIBS). gcc/fortran: * Make-lang.in (gfortran$(exeext)): Add $(EXTRA_GCC_LIBS). gcc/go: * Make-lang.in (gccgo$(exeext)): Add $(EXTRA_GCC_LIBS). gcc/java: * Make-lang.in ($(XGCJ)$(exeext)): Add $(EXTRA_GCC_LIBS). diff --git a/gcc/Makefile.in b/gcc/Makefile.in --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -723,6 +723,9 @@ EXTRA_OBJS = @extra_objs@ # the gcc driver. EXTRA_GCC_OBJS =@extra_gcc_objs@ +# List of extra libraries that should be linked with the gcc driver. +EXTRA_GCC_LIBS = @EXTRA_GCC_LIBS@ + # List of additional header files to install. EXTRA_HEADERS =@extra_headers_list@ @@ -1828,7 +1831,8 @@ libcommon.a: $(OBJS-libcommon) xgcc$(exeext): $(GCC_OBJS) gccspec.o libcommon-target.a $(LIBDEPS) \ $(EXTRA_GCC_OBJS) +$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ $(GCC_OBJS) \ - gccspec.o $(EXTRA_GCC_OBJS) libcommon-target.a $(LIBS) + gccspec.o $(EXTRA_GCC_OBJS) libcommon-target.a \ +
Re: [PATCH] ARM fixed-point support [5.5/6]: argument return padding for libcalls
On Mon, Aug 1, 2011 at 6:51 AM, H.J. Lu hjl.to...@gmail.com wrote: On Mon, Aug 1, 2011 at 6:38 AM, H.J. Lu hjl.to...@gmail.com wrote: On Thu, May 26, 2011 at 9:56 AM, Julian Brown jul...@codesourcery.com wrote: This patch allows padding to be specified per-target for libcalls. This hasn't been traditionally important, because libcalls haven't accepted quantities which might need padding, but that's no longer true with the new(-ish) fixed-point support helper functions. Tested (alongside other fixed-point support patches) with cross to ARM EABI in both big little-endian mode (the target-specific part is to avoid a behaviour change for half-float types on ARM). OK to apply? Thanks, Julian ChangeLog gcc/ * calls.c (emit_library_call_value_1): Support padding for libcall arguments and return values. * config/arm/arm.c (arm_pad_arg_upward): Pad half-float values downwards in big-endian mode. This breaks bootstrap on Linux/x86: http://gcc.gnu.org/ml/gcc-regression/2011-08/msg7.html ../../src-trunk/gcc/calls.c: In function 'rtx_def* emit_library_call_value_1(int, rtx, rtx, libcall_type, machine_mode, int, __va_list_tag*)': ../../src-trunk/gcc/calls.c:3832:11: error: unused variable 'size' [-Werror=unused-variable] cc1plus: all warnings being treated as errors make[6]: *** [calls.o] Error 1 I am testing this patch. -- H.J. --- diff --git a/gcc/calls.c b/gcc/calls.c index 7ad30b4..c4f8b46 100644 --- a/gcc/calls.c +++ b/gcc/calls.c @@ -3829,7 +3829,9 @@ emit_library_call_value_1 (int retval, rtx orgfun, rtx val ue, rtx val = argvec[argnum].value; rtx reg = argvec[argnum].reg; int partial = argvec[argnum].partial; +#ifdef BLOCK_REG_PADDING int size = 0; +#endif /* Handle calls that pass values in multiple non-contiguous locations. The PA64 has examples of this for library calls. */ I checked it in as an obvious fix. -- H.J.
Re: Support -mcpu=native on Solaris/SPARC
On 08/01/2011 03:51 PM, Rainer Orth wrote: Here's an updated version of the patch, containing two changes: * Solaris 8 doesn't support KSTAT_DATA_STRING. * I've updated the list of known cpu types, based on the /platform/sun4?/kernel/cpu{, /sparcv9} entries found in Solaris 8, 9, 10 and 11. It seems that the vendor field sometimes present there (SUNW, TI, Ross, ...) is consistently absent in the kstat output. While I could confirm this on all sun4u/sun4v system we have, I don't have access to sun4m machines any longer, so it's just a guess. Bootstrapped without regressions no sparc-sun-solaris2.{8, 9, 10, 11} without regressions (Solaris 8 bootstrap still running), -mcpu is correctly detected everywhere. Ok for mainline? Build parts are ok. Paolo
Re: Patch for C++ build on HP-UX and to implement -static-libstdc++
On 29-Jul-11, at 2:11 PM, Steve Ellcey wrote: On Fri, 2011-07-29 at 20:00 +0200, Rainer Orth wrote: Steve, Index: gcc/configure.ac === --- gcc/configure.ac(revision 176899) +++ gcc/configure.ac(working copy) @@ -3240,6 +3240,13 @@ *-*-solaris2*) gcc_cv_ld_static_dynamic=yes ;; + *-*-hpux*) + if test x$gnu_ld = xno; then + gcc_cv_ld_static_dynamic=yes + gcc_cv_ld_static_option=-aarchive + gcc_cv_ld_dynamic_option=-adefault + fi + ;; esac fi fi just a nit, but could you keep the cases sorted alphabetically? Thanks. Rainer I can do that. And add a comment line like the other entries have. The patch fixes the C++ build on HP-UX 11.11 for both 32 and 64-bit targets. The HP-UX parts are ok with above revision. Dave -- John David Anglin dave.ang...@bell.net
[PATCH] Fix PR49907
This fixes PR49907 - ok for trunk? Thanks, Richard. 2011-08-01 Richard Guenther rguent...@suse.de PR bootstrap/49907 lto-plugin/ * configure.ac: Use ACX_PROG_CC_WARNING_OPTS to detect -Wall presence. * Makefile.am (AM_CFLAGS): Adjust. Do not build with -Werror. * configure: Regenerate. * Makefile.in: Likewise. * aclocal.m4: Likewise. Index: configure.ac === --- configure.ac(revision 177016) +++ configure.ac(working copy) @@ -6,6 +6,7 @@ AM_INIT_AUTOMAKE([foreign no-dist]) AM_MAINTAINER_MODE AC_PROG_CC AC_SYS_LARGEFILE +ACX_PROG_CC_WARNING_OPTS([-Wall], [ac_lto_plugin_warn_cflags]) AM_PROG_LIBTOOL ACX_LT_HOST_FLAGS AC_SUBST(target_noncanonical) Index: Makefile.am === --- Makefile.am (revision 177016) +++ Makefile.am (working copy) @@ -8,7 +8,7 @@ target_noncanonical := @target_noncanoni libexecsubdir := $(libexecdir)/gcc/$(target_noncanonical)/$(gcc_version) AM_CPPFLAGS = -I$(top_srcdir)/../include $(DEFS) -AM_CFLAGS = -Wall -Werror +AM_CFLAGS = @ac_lto_plugin_warn_cflags@ AM_LIBTOOLFLAGS = --tag=disable-static libexecsub_LTLIBRARIES = liblto_plugin.la
Re: [PATCH] ARM fixed-point support [5.5/6]: argument return padding for libcalls
On Mon, 1 Aug 2011 06:54:54 -0700 H.J. Lu hjl.to...@gmail.com wrote: This breaks bootstrap on Linux/x86: I checked it in as an obvious fix. Sorry about that, and thank you! Cheers, Julian
[Ada] Avoid FE crash processing wrong sources
This patch avoids the frontend crash when generated with assertions enabled and it process the following wrong sources in which partial view is not a synchronized tagged type as requested by RM 7.3 (7.2/2). package RT is type I is protected interface; type T is tagged limited private; private protected type T is new I with -- ERROR end T; end RT; Tested on x86_64-pc-linux-gnu, committed on trunk 2011-08-01 Javier Miranda mira...@adacore.com * sem_util.adb (Abstract_Interface_List): Complete condition when processing private type declarations to avoid reading unavailable attribute. (Is_Synchronized_Tagged_Type): Complete condition when processing private extension declaration nodes to avoid reading unavailable attribute. Index: sem_util.adb === --- sem_util.adb(revision 177035) +++ sem_util.adb(working copy) @@ -165,7 +165,10 @@ Nod := Type_Definition (Parent (Typ)); elsif Nkind (Parent (Typ)) = N_Private_Type_Declaration then -if Present (Full_View (Typ)) then +if Present (Full_View (Typ)) + and then Nkind (Parent (Full_View (Typ))) + = N_Full_Type_Declaration +then Nod := Type_Definition (Parent (Full_View (Typ))); -- If the full-view is not available we cannot do anything else @@ -7335,6 +7338,7 @@ and then Is_Synchronized_Interface (E)) or else (Ekind (E) = E_Record_Type_With_Private +and then Nkind (Parent (E)) = N_Private_Extension_Declaration and then (Synchronized_Present (Parent (E)) or else Is_Synchronized_Interface (Etype (E; end Is_Synchronized_Tagged_Type;
[Ada] Remove duplicated units
This code reorganization reduces the amount of code duplication in the GNAT runtime library. No behaviour change, no test. Tested on x86_64-pc-linux-gnu, committed on trunk 2011-08-01 Thomas Quinot qui...@adacore.com * s-parame-ae653.ads, s-parame-vms-alpha.ads, s-parame-hpux.ads, i-cpoint.adb, i-cstrin.adb, i-cpoint.ads, i-cstrin.ads, s-parame-vms-ia64.ads, s-parame.ads, i-c.ads, s-parame-vxworks.ads, s-parame-vms-restrict.ads: Remove duplicated Interfaces.C.* packages for VMS, instead parametrize the common implementation with System.Parameters declarations. Index: s-parame-ae653.ads === --- s-parame-ae653.ads (revision 176998) +++ s-parame-ae653.ads (working copy) @@ -112,6 +112,15 @@ -- is that this is the same as type Long_Integer, but this is not true -- of all targets. For example, in OpenVMS long /= Long_Integer. + ptr_bits : constant := Standard'Address_Size; + subtype C_Address is System.Address; + -- Number of bits in Interaces.C pointers, normally a standard address, + -- except on 64-bit VMS where they are 32-bit addresses, for compatibility + -- with legacy code. + + C_Malloc_Linkname : constant String := __gnat_malloc; + -- Name of runtime function used to allocate such a pointer + -- -- Behavior of Pragma Finalize_Storage_Only -- -- Index: s-parame-vms-alpha.ads === --- s-parame-vms-alpha.ads (revision 176998) +++ s-parame-vms-alpha.ads (working copy) @@ -46,6 +46,8 @@ -- Note: do not introduce any pragma Inline statements into this unit, since -- otherwise the relinking and rebinding capability would be deactivated. +with System.Aux_DEC; + package System.Parameters is pragma Pure; @@ -110,6 +112,15 @@ -- is that this is the same as type Long_Integer, but this is not true -- of all targets. For example, in OpenVMS long /= Long_Integer. + ptr_bits : constant := 32; + subtype C_Address is System.Short_Address; + -- Number of bits in Interaces.C pointers, normally a standard address, + -- except on 64-bit VMS where they are 32-bit addresses, for compatibility + -- with legacy code. + + C_Malloc_Linkname : constant String := __gnat_malloc32; + -- Name of runtime function used to allocate such a pointer + -- -- Behavior of Pragma Finalize_Storage_Only -- -- Index: s-parame-hpux.ads === --- s-parame-hpux.ads (revision 176998) +++ s-parame-hpux.ads (working copy) @@ -110,6 +110,15 @@ -- is that this is the same as type Long_Integer, but this is not true -- of all targets. For example, in OpenVMS long /= Long_Integer. + ptr_bits : constant := Standard'Address_Size; + subtype C_Address is System.Address; + -- Number of bits in Interaces.C pointers, normally a standard address, + -- except on 64-bit VMS where they are 32-bit addresses, for compatibility + -- with legacy code. + + C_Malloc_Linkname : constant String := __gnat_malloc; + -- Name of runtime function used to allocate such a pointer + -- -- Behavior of Pragma Finalize_Storage_Only -- -- Index: i-cpoint.adb === --- i-cpoint.adb(revision 176998) +++ i-cpoint.adb(working copy) @@ -36,7 +36,7 @@ package body Interfaces.C.Pointers is - type Addr is mod Memory_Size; + type Addr is mod 2 ** System.Parameters.ptr_bits; function To_Pointer is new Ada.Unchecked_Conversion (Addr, Pointer); function To_Addris new Ada.Unchecked_Conversion (Pointer, Addr); @@ -195,6 +195,7 @@ subtype A is Element_Array (L .. H); type PA is access A; +for PA'Size use System.Parameters.ptr_bits; function To_PA is new Ada.Unchecked_Conversion (Pointer, PA); begin @@ -238,6 +239,7 @@ subtype A is Element_Array (L .. H); type PA is access A; +for PA'Size use System.Parameters.ptr_bits; function To_PA is new Ada.Unchecked_Conversion (Pointer, PA); begin Index: i-cstrin.adb === --- i-cstrin.adb(revision 177030) +++ i-cstrin.adb(working copy) @@ -42,10 +42,10 @@ -- this type will in fact be used for aliasing values of other types. function To_chars_ptr is - new Ada.Unchecked_Conversion (Address, chars_ptr); + new Ada.Unchecked_Conversion (System.Parameters.C_Address, chars_ptr);
[Patch,AVR]: Supply and use information on skip core bug
Some AVR devices have the skip bug, i.e. they must not use any skip instruction to bypass a 2-word instruction. Affected devices are AT90S8515 (core avr2) and ATmega103 (core avr31). For information see the new file errata.txt. This patch supplies new built-in macros so that a user can test if that erratum might be active. Moreover, libgcc.S uses the new built-in macros because they allow for more exact test for the bug. struct mcu_type_s has a new field errata_bug which is set to one for the following devices: * avr2 and none (as avr2 is default if no -mmcu is given) * avr31 * at90s8515 * atmega103 avr-tables.opt does not change and needs not to be regenerated. Ok to install? Johann * config/avr/errata.txt: New text file. * config/avr/avr.h (mcu_type_s): Add errata_skip field. * config/avr/avr-devices.c (avr_mcu_types): Use it. * config/avr/avr-mcus.def (AVR_MCU): Use it. * config/avr/avr-c.c (avr_cpu_cpp_builtins): Use it to builtin define __AVR_ERRATA_SKIP__ and __AVR_ERRATA_SKIP_JMP_CALL__. * config/avr/libgcc.S (__mulshisi3, __ffshi2, __fmulsu_exit): Use __AVR_ERRATA_SKIP_JMP_CALL__ instead of __AVR_HAVE_JMP_CALL__ to detect if XJMP must not be skipped. Index: config/avr/libgcc.S === --- config/avr/libgcc.S (revision 177011) +++ config/avr/libgcc.S (working copy) @@ -361,7 +361,7 @@ ENDF __umulhisi3 ;;; (C3:C0) = (signed long) A1:A0 * B3:B0 ;;; Clobbers: __tmp_reg__ DEFUN __mulshisi3 -#ifdef __AVR_HAVE_JMP_CALL__ +#ifdef __AVR_ERRATA_SKIP_JMP_CALL__ ;; Some cores have problem skipping 2-word instruction tst A1 brmi__mulohisi3 @@ -1074,7 +1074,7 @@ ENDF __ffssi2 ;; clobbers: r26 DEFUN __ffshi2 clr r26 -#ifdef __AVR_HAVE_JMP_CALL__ +#ifdef __AVR_ERRATA_SKIP_JMP_CALL__ ;; Some cores have problem skipping 2-word instruction tst r24 breq 2f @@ -1480,7 +1480,7 @@ DEFUN __fmulsu_exit ;; A1 = |A1| sbrc A1, 7 neg A1 -#ifdef __AVR_HAVE_JMP_CALL__ +#ifdef __AVR_ERRATA_SKIP_JMP_CALL__ ;; Some cores have problem skipping 2-word instruction tst A0 brmi 1f Index: config/avr/avr-c.c === --- config/avr/avr-c.c (revision 177011) +++ config/avr/avr-c.c (working copy) @@ -82,6 +82,14 @@ avr_cpu_cpp_builtins (struct cpp_reader if (TARGET_NO_INTERRUPTS) cpp_define (pfile, __NO_INTERRUPTS__); + if (avr_current_device-errata_skip) +{ + cpp_define (pfile, __AVR_ERRATA_SKIP__); + + if (avr_current_arch-have_jmp_call) +cpp_define (pfile, __AVR_ERRATA_SKIP_JMP_CALL__); +} + /* Define builtin macros so that the user can easily query if or if not a specific builtin is available. */ Index: config/avr/avr-devices.c === --- config/avr/avr-devices.c (revision 177011) +++ config/avr/avr-devices.c (working copy) @@ -40,11 +40,11 @@ const struct base_arch_s avr_arch_types[ }; const struct mcu_type_s avr_mcu_types[] = { -#define AVR_MCU(NAME, ARCH, MACRO, SHORT_SP, DATA_SEC, LIBRARY_NAME) \ - { NAME, ARCH, MACRO, SHORT_SP, DATA_SEC, LIBRARY_NAME }, +#define AVR_MCU(NAME, ARCH, MACRO, SHORT_SP, ERRATA_SKIP, DATA_SEC, LIBRARY_NAME) \ + { NAME, ARCH, MACRO, SHORT_SP, ERRATA_SKIP, DATA_SEC, LIBRARY_NAME }, #include avr-mcus.def #undef AVR_MCU /* End of list. */ - { NULL, ARCH_UNKNOWN, NULL, 0, 0, NULL } + { NULL, ARCH_UNKNOWN, NULL, 0, 0, 0, NULL } }; Index: config/avr/avr-mcus.def === --- config/avr/avr-mcus.def (revision 177011) +++ config/avr/avr-mcus.def (working copy) @@ -27,185 +27,185 @@ Before including this file, define a macro: - AVR_MCU (NAME, ARCH, MACRO, SHORT_SP, DATA_SEC, LIBRARY_NAME) + AVR_MCU (NAME, ARCH, MACRO, SHORT_SP, ERRATA_SKIP, DATA_SEC, LIBRARY_NAME) where the arguments are the fields of struct mcu_type_s. */ /* avr2 must be first for the 0 default to work as intended. */ /* Classic, = 8K. */ -AVR_MCU (avr2, ARCH_AVR2, NULL,0, 0x0060, s8515) -AVR_MCU (at90s2313,ARCH_AVR2, __AVR_AT90S2313__, 1, 0x0060, s2313) -AVR_MCU (at90s2323,ARCH_AVR2, __AVR_AT90S2323__, 1, 0x0060, s2323) -AVR_MCU (at90s2333,ARCH_AVR2, __AVR_AT90S2333__, 1, 0x0060, s2333) -AVR_MCU (at90s2343,ARCH_AVR2, __AVR_AT90S2343__, 1, 0x0060, s2343) -AVR_MCU (attiny22, ARCH_AVR2, __AVR_ATtiny22__, 1, 0x0060, tn22) -AVR_MCU (attiny26, ARCH_AVR2, __AVR_ATtiny26__, 1, 0x0060, tn26) -AVR_MCU (at90s4414,ARCH_AVR2, __AVR_AT90S4414__, 0, 0x0060, s4414) -AVR_MCU (at90s4433,ARCH_AVR2, __AVR_AT90S4433__, 1,
[Committed,AVR]: Fix SVN properties svn:executable
Some files had wrong svn:executable property, I fixed that. http://gcc.gnu.org/viewcvs?view=revisionrevision=177039 Johann * config/avr/avr-devices.c: Delete SVN property svn:executable. * config/avr/predicates.md: Ditto. * config/avr/driver-avr.c: Ditto. * config/avr/genopt.sh: Set SVN property svn:executable to *.
RE: [Patch,AVR]: Supply and use information on skip core bug
-Original Message- From: Georg-Johann Lay [mailto:a...@gjlay.de] Sent: Monday, August 01, 2011 8:38 AM To: gcc-patches@gcc.gnu.org Cc: Anatoly Sokolov; Denis Chertykov; Weddington, Eric Subject: [Patch,AVR]: Supply and use information on skip core bug Some AVR devices have the skip bug, i.e. they must not use any skip instruction to bypass a 2-word instruction. Affected devices are AT90S8515 (core avr2) and ATmega103 (core avr31). For information see the new file errata.txt. This patch supplies new built-in macros so that a user can test if that erratum might be active. Moreover, libgcc.S uses the new built-in macros because they allow for more exact test for the bug. struct mcu_type_s has a new field errata_bug which is set to one for the following devices: * avr2 and none (as avr2 is default if no -mmcu is given) * avr31 * at90s8515 * atmega103 avr-tables.opt does not change and needs not to be regenerated. Ok to install? Hi Johann, It all looks fine to me, except that I don't think we really need to have a separate errata.txt file, do we? The information in errata.txt could be condensed (we don't need the full email response back from Atmel, just the information that it is the 2 devices that have this errata) and put it in a comment in avr-devices.c or avr-mcus.def. Approved with that small change. Thanks for doing this. Eric Weddington
Re: [RS6000] asynch exceptions and unwind info
On Fri, Jul 29, 2011 at 10:28:28PM +0930, Alan Modra wrote: libgcc/ * config/rs6000/linux-unwind.h (frob_update_context __powerpc64__): Restore for indirect call bcrtl from correct stack slot, and only if cfa+40 isn't valid. gcc/ * config/rs6000/rs6000-protos.h (rs6000_save_toc_in_prologue_p): Delete. * config/rs6000/rs6000.c (rs6000_save_toc_in_prologue_p): Make static. (rs6000_emit_prologue): Don't prematurely return when TARGET_SINGLE_PIC_BASE. Don't emit eh_frame info in save_toc_in_prologue case. (rs6000_call_indirect_aix): Only disallow save_toc_in_prologue for calls_alloca. Approved offline and applied with a comment change. -- Alan Modra Australia Development Lab, IBM
[Ada] Update run-time files to GPLv3
This patch moves most remaining GNAT run-time files to GPLv3 run-time license, and also gradually remove the old name GNARL which is no longer used, in favor of simply GNAT. Tested on x86_64-pc-linux-gnu, committed on trunk 2011-08-01 Arnaud Charlet char...@adacore.com * g-socket-dummy.adb, s-osinte-linux.ads, g-socket-dummy.ads, g-debuti.adb, g-tasloc.adb, g-debuti.ads, g-tasloc.ads, s-osinte-hpux.ads, g-sercom.adb, g-soliop-solaris.ads, g-sercom.ads, g-sptain.ads, g-curexc.ads, s-tasloc.adb, s-tasloc.ads, s-tataat.adb, g-ctrl_c.adb, a-reatim.adb, s-tataat.ads, g-dirope.adb, g-ctrl_c.ads, g-dirope.ads, g-boubuf.adb, g-calend.adb, g-boubuf.ads, g-souinf.ads, g-table.adb, g-bytswa-x86.adb, g-wispch.adb, g-io.adb, g-table.ads, g-wispch.ads, g-io.ads, g-memdum.adb, g-memdum.ads, g-busorg.adb, g-busorg.ads, g-regpat.adb, g-sothco-dummy.adb, g-encstr.adb, g-regpat.ads, g-sothco-dummy.ads, s-osinte-aix.ads, g-encstr.ads, g-sercom-mingw.adb, s-mastop-vms.adb, g-diopit.adb, g-diopit.ads, s-vxwext.adb, g-dyntab.adb, g-dyntab.ads, g-crc32.adb, g-sercom-linux.adb, g-crc32.ads, s-regpat.adb, g-flocon.ads, s-regpat.ads, g-stheme.adb, g-sestin.ads, s-taspri-posix-noaltstack.ads, g-soliop.ads, s-inmaop-posix.adb, g-locfil.ads, g-enblsp-vms-alpha.adb, g-socthi-dummy.adb, g-socthi-dummy.ads, gnat.ads, g-moreex.adb, g-moreex.ads, g-dynhta.adb, g-dynhta.ads, g-deutst.ads, g-htable.adb, g-cgicoo.adb, g-htable.ads, g-cgicoo.ads, a-interr.adb, g-socthi-vms.adb, g-socthi-vms.ads, g-hesora.adb, g-bubsor.adb, g-hesora.ads, g-bubsor.ads, g-md5.adb, g-md5.ads, s-intman-irix.adb, s-htable.adb, s-osinte-vms.adb, s-htable.ads, s-osinte-vms.ads, s-taprob.adb, g-bytswa.adb, g-bytswa.ads, s-osinte-solaris-posix.ads, a-suenco.adb, g-comver.adb, g-comver.ads, g-exctra.adb, s-osinte-solaris.adb, g-exctra.ads, s-osinte-irix.ads, s-osinte-solaris.ads, a-caldel-vms.adb, g-socthi-vxworks.adb, g-expect.adb, g-socthi-vxworks.ads, g-expect.ads, g-comlin.ads, g-heasor.adb, g-heasor.ads, g-traceb.adb, g-traceb.ads, g-decstr.adb, g-spipat.adb, g-decstr.ads, g-spipat.ads, s-mastop-tru64.adb, g-except.ads, g-thread.adb, g-hesorg.adb, g-thread.ads, g-hesorg.ads, g-expect-vms.adb, a-stuten.ads, g-spchge.adb, g-spchge.ads, g-u3spch.adb, g-u3spch.ads, g-spitbo.adb, g-spitbo.ads, s-osinte-dummy.ads, s-osinte-posix.adb, g-pehage.adb, g-pehage.ads, s-gloloc-mingw.adb, g-sha1.ads, s-traceb-hpux.adb, g-trasym-unimplemented.adb, g-trasym-unimplemented.ads, g-io_aux.adb, g-regexp.adb, g-io_aux.ads, g-socthi-mingw.adb, g-regexp.ads, s-osinte-hpux-dce.adb, g-socthi-mingw.ads, g-cgi.adb, s-osinte-hpux-dce.ads, g-cgi.ads, g-byorma.adb, g-boumai.ads, g-byorma.ads, a-caldel.adb, s-regexp.adb, s-regexp.ads, g-soliop-mingw.ads, g-sptavs.ads, s-osinte-tru64.ads, g-speche.adb, g-speche.ads, g-socthi.adb, g-stsifd-sockets.adb, g-socthi.ads, s-osinte-darwin.ads, i-vxwork-x86.ads, g-awk.adb, i-vxwork.ads, g-awk.ads, g-zspche.adb, g-zspche.ads, g-socket.adb, g-sptabo.ads, g-socket.ads, g-semaph.adb, g-semaph.ads, s-taspri-posix.ads, g-enblsp-vms-ia64.adb, g-cgideb.adb, g-cgideb.ads, g-sothco.adb, s-osinte-freebsd.ads, g-sothco.ads, g-catiio.adb, g-casuti.adb, g-catiio.ads, g-casuti.ads, g-trasym.adb, g-trasym.ads, s-casuti.adb, g-os_lib.adb, s-traceb-mastop.adb, g-busora.adb, s-interr-dummy.adb, g-busora.ads, g-enutst.ads, s-os_lib.adb, a-tasatt.adb, s-osinte-mingw.ads: Update to GPLv3 run-time license. Use GNAT instead of GNARL. difs.bz2 Description: application/bzip
[Ada] Frontend cleanup
This patch does not change the behavior of the compiler. It removes useless code and enforces the assertions associated with attributes Access_Disp_Table and Dispatch_Table_Wrappers to follow their documentation and thus ensure that these attributes are always read from the entity associated with the full view of private types. No test required. Tested on x86_64-pc-linux-gnu, committed on trunk 2011-08-01 Javier Miranda mira...@adacore.com * sem_ch7.adb (Uninstall_Declarations): Remove useless code. * einfo.ads (Access_Disp_Table): Fix documentation. (Dispatch_Table_Wrappers): Fix documentation. * einfo.adb (Access_Disp_Table, Dispatch_Table_Wrappers, Set_Access_Disp_Table, Set_Dispatch_Table_Wrappers): Fix the assertions to enforce the documentation of this attribute. (Set_Is_Interface): Cleanup the assertion. * exp_ch4.adb (Expand_Allocator_Expression, Tagged_Membership): Locate the Underlying_Type entity before reading attribute Access_Disp_Table. * exp_disp.adb (Expand_Dispatching_Call, Expand_Interface_Conversion): Locate the Underlying_Type before reading attribute Access_Disp_Table. * exp_aggr.adb (Build_Array_Aggr_Code, Build_Record_Aggr_Code): Locate the Underlying_Type entity before reading attribute Access_Disp_Table. * exp_ch3.adb (Build_Record_Init_Proc, Expand_N_Object_Declaration): Locate the Underlying_Type entity before reading attribute Access_Disp_Table. Index: sem_ch7.adb === --- sem_ch7.adb (revision 177027) +++ sem_ch7.adb (working copy) @@ -2069,39 +2069,6 @@ and then Is_Tagged_Type (Full) and then not Error_Posted (Full) then -if Priv_Is_Base_Type then - - -- Ada 2005 (AI-345): The full view of a type implementing an - -- interface can be a task type. - - --type T is new I with private; - -- private - --task type T is new I with ... - - if Is_Interface (Etype (Priv)) - and then Is_Concurrent_Type (Base_Type (Full)) - then - -- Protect the frontend against previous errors - - if Present (Corresponding_Record_Type - (Base_Type (Full))) - then - Set_Access_Disp_Table - (Priv, Access_Disp_Table - (Corresponding_Record_Type (Base_Type (Full; - - -- Generic context, or previous errors - - else - null; - end if; - - else - Set_Access_Disp_Table -(Priv, Access_Disp_Table (Base_Type (Full))); - end if; -end if; - if Is_Tagged_Type (Priv) then -- If the type is tagged, the tag itself must be available on Index: einfo.adb === --- einfo.adb (revision 177028) +++ einfo.adb (working copy) @@ -573,7 +573,8 @@ function Access_Disp_Table (Id : E) return L is begin - pragma Assert (Is_Tagged_Type (Id)); + pragma Assert (Ekind_In (Id, E_Record_Type, + E_Record_Subtype)); return Elist16 (Implementation_Base_Type (Id)); end Access_Disp_Table; @@ -882,7 +883,8 @@ function Dispatch_Table_Wrappers (Id : E) return L is begin - pragma Assert (Is_Tagged_Type (Id)); + pragma Assert (Ekind_In (Id, E_Record_Type, + E_Record_Subtype)); return Elist26 (Implementation_Base_Type (Id)); end Dispatch_Table_Wrappers; @@ -2996,7 +2998,9 @@ procedure Set_Access_Disp_Table (Id : E; V : L) is begin - pragma Assert (Is_Tagged_Type (Id) and then Is_Base_Type (Id)); + pragma Assert (Ekind (Id) = E_Record_Type +and then Id = Implementation_Base_Type (Id)); + pragma Assert (V = No_Elist or else Is_Tagged_Type (Id)); Set_Elist16 (Id, V); end Set_Access_Disp_Table; @@ -3302,12 +3306,9 @@ procedure Set_Dispatch_Table_Wrappers (Id : E; V : L) is begin - pragma Assert (Is_Tagged_Type (Id) -and then Is_Base_Type (Id) -and then Ekind_In (Id, E_Record_Type, - E_Record_Subtype, - E_Record_Type_With_Private, - E_Record_Subtype_With_Private)); + pragma Assert (Ekind (Id) = E_Record_Type +and then Id = Implementation_Base_Type (Id)); + pragma Assert (V = No_Elist or else Is_Tagged_Type (Id)); Set_Elist26 (Id, V); end Set_Dispatch_Table_Wrappers; @@ -4312,13 +4313,7 @@ procedure Set_Is_Interface (Id : E; V : B := True) is begin - pragma
[Ada] Conformance for quantified expressions
Ada2012 Quantified expressions can appear in default expressions, and must be checked for conformance. The following compilation: gcc -c -gnat12 -gnata conf.adb must yield: conf.adb:16:14: not fully conformant with declaration at line 4 conf.adb:16:14: default expression for X does not match conf.adb:22:14: not fully conformant with declaration at line 6 conf.adb:22:14: default expression for X does not match conf.adb:29:14: not fully conformant with declaration at line 9 conf.adb:29:14: default expression for X does not match conf.adb:37:14: not fully conformant with declaration at line 12 conf.adb:37:14: default expression for X does not match --- procedure Conf is table : array (1..10) of integer := (others = 1); procedure Maybe (X : Boolean := (for all E of table = E = 1)); procedure Peut_Etre (X : Boolean := (for all I in table'range = Table (I) = 1)); procedure Quizas (X : Boolean := (for all I in table'range = Table (I) = 1)); procedure Qui_Sait (X : Boolean := (for all I of table = Table (I) = 1)); -- Expression doesn't match procedure Maybe (X : Boolean := (for all E of table = E = 2)) is begin null; end; -- loop parameter doesn't match procedure Peut_Etre (X : Boolean := (for all J in table'range = Table (J) = 1)) is begin null; end; -- discrete range doesn't match procedure Quizas (X : Boolean := (for all I in table'first .. table'last = Table (I) = 1)) is begin null; end; -- discrete range doesn't match procedure Qui_Sait (X : Boolean := (for all I in reverse table'range = Table (I) = 1)) is begin null; end; begin Table (5) := 0; Maybe; Qui_Sait; Quizas; end; Tested on x86_64-pc-linux-gnu, committed on trunk 2011-08-01 Ed Schonberg schonb...@adacore.com * sem_ch6.adb (Fully_Conformant_Expressions): handle quantified expressions. Index: sem_ch6.adb === --- sem_ch6.adb (revision 177048) +++ sem_ch6.adb (working copy) @@ -6685,6 +6685,50 @@ and then FCE (Expression (E1), Expression (E2)); +when N_Quantified_Expression = + if not FCE (Condition (E1), Condition (E2)) then + return False; + end if; + + if Present (Loop_Parameter_Specification (E1)) + and then Present (Loop_Parameter_Specification (E2)) + then + declare + L1 : constant Node_Id := + Loop_Parameter_Specification (E1); + L2 : constant Node_Id := + Loop_Parameter_Specification (E2); + + begin + return + Reverse_Present (L1) = Reverse_Present (L2) + and then + FCE (Defining_Identifier (L1), +Defining_Identifier (L2)) + and then + FCE (Discrete_Subtype_Definition (L1), +Discrete_Subtype_Definition (L2)); + end; + + else -- quantified expression with an iterator + declare + I1 : constant Node_Id := Iterator_Specification (E1); + I2 : constant Node_Id := Iterator_Specification (E2); + + begin + return + FCE (Defining_Identifier (I1), +Defining_Identifier (I2)) + and then + Of_Present (I1) = Of_Present (I2) + and then + Reverse_Present (I1) = Reverse_Present (I2) + and then FCE (Name (I1), Name (I2)) + and then FCE (Subtype_Indication (I1), + Subtype_Indication (I2)); + end; + end if; + when N_Range = return FCE (Low_Bound (E1), Low_Bound (E2))
Re: [Patch 4/4] ARM 64 bit sync atomic operations [V2]
On 26 July 2011 10:02, Dr. David Alan Gilbert david.gilb...@linaro.org wrote: gcc/ * config/arm/arm.c (TARGET_HAVE_DMB_MCR) MCR Not available in Thumb1 but is available on armv6 `:' after (TARGET_HAVE_DMB_MCR) and something like `Disable for Thumb1.' instead of what's on there. /* Nonzero if this chip implements a memory barrier via CP15. */ -#define TARGET_HAVE_DMB_MCR (arm_arch6k ! TARGET_HAVE_DMB) +#define TARGET_HAVE_DMB_MCR (arm_arch6 ! TARGET_HAVE_DMB \ + ! TARGET_THUMB1) Otherwise OK for trunk and afflicted release branches since this really is a bug fix. cheers Ramana
Re: [Patch,AVR]: Supply and use information on skip core bug
Weddington, Eric wrote: -Original Message- From: Georg-Johann Lay [mailto:a...@gjlay.de] Sent: Monday, August 01, 2011 8:38 AM To: gcc-patches@gcc.gnu.org Cc: Anatoly Sokolov; Denis Chertykov; Weddington, Eric Subject: [Patch,AVR]: Supply and use information on skip core bug Some AVR devices have the skip bug, i.e. they must not use any skip instruction to bypass a 2-word instruction. Affected devices are AT90S8515 (core avr2) and ATmega103 (core avr31). For information see the new file errata.txt. This patch supplies new built-in macros so that a user can test if that erratum might be active. Moreover, libgcc.S uses the new built-in macros because they allow for more exact test for the bug. struct mcu_type_s has a new field errata_bug which is set to one for the following devices: * avr2 and none (as avr2 is default if no -mmcu is given) * avr31 * at90s8515 * atmega103 avr-tables.opt does not change and needs not to be regenerated. Ok to install? Hi Johann, It all looks fine to me, except that I don't think we really need to have a separate errata.txt file, do we? The information in errata.txt could be condensed (we don't need the full email response back from Atmel, just the information that it is the 2 devices that have this errata) and put it in a comment in avr-devices.c or avr-mcus.def. Approved with that small change. Thanks for doing this. Eric Weddington Ok, I removed the separate file. Luckily AVRs have very little core bugs and I hope we will never need such a file... The original mail was much longer, I now added the relevant parts at the place where I would expect them: the structure definition in avr.h. I added parts from the mail header, too, in particular the subject so that someone else can refer to it. Applied with that change: http://gcc.gnu.org/viewcvs?view=revisionrevision=177049 Johann * config/avr/avr.h (mcu_type_s): Add errata_skip field. * config/avr/avr-devices.c (avr_mcu_types): Use it. * config/avr/avr-mcus.def (AVR_MCU): Use it. * config/avr/avr-c.c (avr_cpu_cpp_builtins): Use it to builtin define __AVR_ERRATA_SKIP__ and __AVR_ERRATA_SKIP_JMP_CALL__. * config/avr/libgcc.S (__mulshisi3, __ffshi2, __fmulsu_exit): Use __AVR_ERRATA_SKIP_JMP_CALL__ instead of __AVR_HAVE_JMP_CALL__ to detect if XJMP must not be skipped.
Re: [RFC] hard-reg-set.h refactoring
On Sun, 31 Jul 2011, Paolo Bonzini wrote: On Sat, Jul 30, 2011 at 19:21, Dimitrios Apostolou ji...@gmx.net wrote: Nevertheless I'd appreciate comments on whether any part of this patch is worth keeping. FWIW I've profiled this on i386 to be about 4 M instr slower out of ~1.5 G inst. I'll be now checking the profiler to see where exactly the overhead is. I suggest -fdump-tree-all too, to check if unrolling is happening and if not why. I don't fully understand the output from -fdump-tree-all, but my conclusion based also on profiler output and objdump, is that both unrolling and inlining is happening in both versions. Nevertheless I can see that assembly output is a bit different in the two cases (I can post specific disassembly output if you are interested). My opinion is that code cleanup is worth the minor overhead, given that there should be no regressions. Thanks, Dimitris
Re: [RFC] hard-reg-set.h refactoring
On 08/01/2011 05:57 PM, Dimitrios Apostolou wrote: I don't fully understand the output from -fdump-tree-all, but my conclusion based also on profiler output and objdump, is that both unrolling and inlining is happening in both versions. Nevertheless I can see that assembly output is a bit different in the two cases (I can post specific disassembly output if you are interested). Thanks for checking. Have you tried the idea of passing an unsigned HOST_WIDEST_FAST_INT * (or whatever the name) to the target hook? Paolo
RE: [Patch,AVR]: Supply and use information on skip core bug
-Original Message- From: Georg-Johann Lay [mailto:a...@gjlay.de] Sent: Monday, August 01, 2011 9:45 AM To: Weddington, Eric Cc: gcc-patches@gcc.gnu.org; Anatoly Sokolov; Denis Chertykov Subject: Re: [Patch,AVR]: Supply and use information on skip core bug Ok, I removed the separate file. Thanks! Luckily AVRs have very little core bugs and I hope we will never need such a file... Well, we've been lucky so far. ;-) When we add the xmega support to gcc (IIRC, it should be in binutils), then we may have to revisit the errata list. Eric Weddington
[Ada] Wrong dispatching on private type that covers interface
If the parent of a private type is an interface type, the parent of its full type declaration is an abstract type that covers such interface, and the order of declaration of the tagged type primitives differs from their order of declaration in the parent (or if not explicitly declared in the parent, their declaration differs from their order of declaration in the interface type) then the compiler assigns erroneous slots in the dispatch table to its primitives. After this patch the following test compiles and executes without errors. package Pkg1 is type I1 is interface; function F1 (Self : I1) return Natural is abstract; function F2 (Self : I1) return Natural is abstract; function F3 (Self : I1) return Natural is abstract; end; with Pkg1; use Pkg1; package Pkg2 is type A_Root is abstract tagged null record; type A_DT1 is abstract new A_Root and I1 with null record; end; with Pkg1; use Pkg1; with Pkg2; use Pkg2; package Pkg3 is type A_DT2 is new I1 with private; private type A_DT2 is new A_DT1 with null record;-- Test function F3 (Self : A_DT2) return Natural; function F1 (Self : A_DT2) return Natural; function F2 (Self : A_DT2) return Natural; end; with Pkg1; use Pkg1; with Pkg2; use Pkg2; with Pkg3; use Pkg3; procedure Main is M : A_DT2; begin pragma Assert (A_DT2'Class (M).F1 = 1); pragma Assert (A_DT1'Class (I1'Class (M)).F1 = 1); pragma Assert (A_DT2'Class (M).F2 = 2); pragma Assert (A_DT1'Class (I1'Class (M)).F2 = 2); pragma Assert (A_DT2'Class (M).F3 = 3); pragma Assert (A_DT1'Class (I1'Class (M)).F3 = 3); null; end Main; with Text_IO; use Text_IO; package body Pkg3 is function F3 (Self : A_DT2) return Natural is begin return 3; end; function F1 (Self : A_DT2) return Natural is begin return 1; end; function F2 (Self : A_DT2) return Natural is begin return 2; end; end; Command: gnatmake -gnat05 -gnata main; ./main Tested on x86_64-pc-linux-gnu, committed on trunk 2011-08-01 Javier Miranda mira...@adacore.com * sem_disp.adb (Override_Dispatching_Operation): Enforce strictness of condition that detects if the overridden operation must replace an existing entity. Index: sem_disp.adb === --- sem_disp.adb(revision 176998) +++ sem_disp.adb(working copy) @@ -2078,15 +2078,19 @@ -- The location of entities that come from source in the list of -- primitives of the tagged type must follow their order of occurrence -- in the sources to fulfill the C++ ABI. If the overridden entity is a - -- primitive of an interface that is not an ancestor of this tagged - -- type (that is, it is an entity added to the list of primitives by - -- Derive_Interface_Progenitors), then we must append the new entity - -- at the end of the list of primitives. + -- primitive of an interface that is not implemented by the parents of + -- this tagged type (that is, it is an alias of an interface primitive + -- generated by Derive_Interface_Progenitors), then we must append the + -- new entity at the end of the list of primitives. if Present (Alias (Prev_Op)) +and then Etype (Tagged_Type) /= Tagged_Type and then Is_Interface (Find_Dispatching_Type (Alias (Prev_Op))) and then not Is_Ancestor (Find_Dispatching_Type (Alias (Prev_Op)), Tagged_Type) +and then not Implements_Interface + (Etype (Tagged_Type), +Find_Dispatching_Type (Alias (Prev_Op))) then Remove_Elmt (Primitive_Operations (Tagged_Type), Elmt); Append_Elmt (New_Op, Primitive_Operations (Tagged_Type));
[Ada] Compiler crash processing postcondition
The compiler crashed processing Ada 2012 pre/post conditions because internally generated declarations associated with the evaluation of the preconditions located in a package spec were not propagated to the corresponding routine in the body of the package. After this patch the following program compiles without errors: package Pack is type Node_Id is new Integer; type Node_Kind is (Case_1, Case_2); type Node (Kind : Node_Kind := Case_1) is record case Kind is when Case_1 = null; when Case_2 = Case_2_Data : Node_Id; end case; end record; end Pack; with Ada.Containers.Vectors; package Pack.Tables is function Get_Node (Id : Node_Id) return Node; function Get_Kind (Id : Node_Id) return Node_Kind; private package Node_Tables is new Ada.Containers.Vectors (Index_Type = Node_Id, Element_Type = Node, = = =); Node_Table : Node_Tables.Vector; function Get_Node (Id : Node_Id) return Node is (Node_Tables.Element (Node_Table, Id)); function Get_Kind (Id : Node_Id) return Node_Kind is (Get_Node (Id).Kind); end Pack.Tables; with Pack.Tables; use Pack.Tables; package Pack.Fields is function Get_External (Id : Node_Id) return Node_Id; pragma Postcondition (case Get_Kind (Id) is when Case_2 = Get_External'Result = Get_Node (Id).Case_2_Data, when others = False); end Pack.Fields; package body Pack.Fields is function Get_External (Id : Node_Id) return Node_Id is N : Node_Id; begin return N; end; end Pack.Fields; Command: gcc -c -gnat12 -gnatws pack-fields.adb Tested on x86_64-pc-linux-gnu, committed on trunk 2011-08-01 Javier Miranda mira...@adacore.com * exp_ch4.adb (Expand_N_Case_Expression): Propagate to the expanded code declarations inserted by Insert_Actions in each alternative of the N_Case_Expression node. Index: exp_ch4.adb === --- exp_ch4.adb (revision 177053) +++ exp_ch4.adb (working copy) @@ -4018,6 +4018,11 @@ Aloc : constant Source_Ptr := Sloc (Aexp); begin +-- Propagate declarations inserted in the node by Insert_Actions +-- (for example, temporaries generated to remove side effects). + +Append_List_To (Actions, Sinfo.Actions (Alt)); + if not Is_Scalar_Type (Typ) then Aexp := Make_Attribute_Reference (Aloc,
Re: PATCH: PR target/47766: [x32] -fstack-protector doesn't work
On Fri, Jul 29, 2011 at 3:14 PM, H.J. Lu hjl.to...@gmail.com wrote: On Thu, Jul 28, 2011 at 1:03 PM, Uros Bizjak ubiz...@gmail.com wrote: On Thu, Jul 28, 2011 at 9:03 PM, H.J. Lu hjl.to...@gmail.com wrote: This patch adds x32 support to UNSPEC_SP_XXX patterns. OK for trunk? http://gcc.gnu.org/contribute.html#patches Sorry. I should have mentioned testcase in: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47766 Actually, they are in gcc testsuite. I noticed them when I run gcc testsuite on x32. This looks like a middle-end problem to me. According to the documentation: --quote-- `stack_protect_set' This pattern, if defined, moves a `Pmode' value from the memory in operand 1 to the memory in operand 0 without leaving the value in a register afterward. This is to avoid leaking the value some place that an attacker might use to rewrite the stack guard slot after having clobbered it. If this pattern is not defined, then a plain move pattern is generated. `stack_protect_test' This pattern, if defined, compares a `Pmode' value from the memory in operand 1 with the memory in operand 0 without leaving the value in a register afterward and branches to operand 2 if the values weren't equal. If this pattern is not defined, then a plain compare pattern and conditional branch pattern is used. --quote-- According to the documentation, x86 patterns are correct. However, middle-end fails to extend ptr_mode value to Pmode, and in function.c, stack_protect_prologue/stack_protect_epilogue, we already have ptr_mode (SImode) operand: (mem/v/f/c/i:SI (plus:DI (reg/f:DI 54 virtual-stack-vars) (const_int -4 [0xfffc])) [2 D.2704+0 S4 A32]) (mem/v/f/c/i:SI (symbol_ref:DI (__stack_chk_guard) [flags 0x40] var_decl 0x7ffc35aa0be0 __stack_chk_guard) [2 __stack_chk_guard+0 S4 A32]) An opinion of a RTL maintainer (CC'd) is needed here. Target definition is OK in its current form. When -fstack-protector was added, there are tree default_stack_protect_guard (void) { tree t = stack_chk_guard_decl; if (t == NULL) { rtx x; t = build_decl (UNKNOWN_LOCATION, VAR_DECL, get_identifier (__stack_chk_guard), ptr_type_node); ^ I think ptr_mode is intended and Pmode is just a typo. Jakub, Richard, what are your thoughts on this? Stack protector does use ptr_mode. We have /* i386 glibc provides __stack_chk_guard in %gs:0x14, x32 glibc provides it in %fs:0x18. x86_64 glibc provides it in %fs:0x28. */ #define TARGET_THREAD_SSP_OFFSET \ (TARGET_64BIT ? (TARGET_X32 ? 0x18 : 0x28) : 0x14) in gnu-user64.h and typedef struct { void *tcb;/* Pointer to the TCB. Not necessarily the thread descriptor used by libpthread. */ dtv_t *dtv; void *self; /* Pointer to the thread descriptor. */ int multiple_threads; int gscope_flag; uintptr_t sysinfo; uintptr_t stack_guard; uintptr_t pointer_guard; in sysdeps/x86_64/tls.h. I believe it is a mistake to use Pmode in the stack protector documentation. -- H.J.
[patch] Fix PR tree-optimization/49926
Hi, This patch adds another missing check for SLP reduction detection: we should check that a statement in a reduction chain has either one use inside the loop, or two uses: in the reduction phi node and the loop exit phi node. Bootstrapped and tested on powerpc64-suse-linux. Applied to trunk. Ira ChangeLog: PR tree-optimization/49926 * tree-vect-loop.c (vect_is_slp_reduction): Check that a statement in a chain doesn't have uses both inside and outside the loop. testsuite/ChangeLog: PR tree-optimization/49926 * gcc.dg/vect/pr49926.c: New test. Index: tree-vect-loop.c === --- tree-vect-loop.c(revision 177062) +++ tree-vect-loop.c(working copy) @@ -1730,7 +1730,7 @@ vect_is_slp_reduction (loop_vec_info loop_info, gi tree lhs; imm_use_iterator imm_iter; use_operand_p use_p; - int nloop_uses, size = 0; + int nloop_uses, size = 0, n_out_of_loop_uses; bool found = false; if (loop != vect_loop) @@ -1741,6 +1741,7 @@ vect_is_slp_reduction (loop_vec_info loop_info, gi while (1) { nloop_uses = 0; + n_out_of_loop_uses = 0; FOR_EACH_IMM_USE_FAST (use_p, imm_iter, lhs) { gimple use_stmt = USE_STMT (use_p); @@ -1757,16 +1758,22 @@ vect_is_slp_reduction (loop_vec_info loop_info, gi break; } - if (flow_bb_inside_loop_p (loop, gimple_bb (use_stmt)) - vinfo_for_stmt (use_stmt) - !STMT_VINFO_IN_PATTERN_P (vinfo_for_stmt (use_stmt))) - { - loop_use_stmt = use_stmt; - nloop_uses++; - } + if (flow_bb_inside_loop_p (loop, gimple_bb (use_stmt))) +{ + if (vinfo_for_stmt (use_stmt) + !STMT_VINFO_IN_PATTERN_P (vinfo_for_stmt (use_stmt))) +{ + loop_use_stmt = use_stmt; + nloop_uses++; +} +} + else + n_out_of_loop_uses++; - if (nloop_uses 1) -return false; + /* There are can be either a single use in the loop or two uses in + phi nodes. */ + if (nloop_uses 1 || (n_out_of_loop_uses nloop_uses)) + return false; } if (found) Index: testsuite/gcc.dg/vect/pr49926.c === --- testsuite/gcc.dg/vect/pr49926.c (revision 0) +++ testsuite/gcc.dg/vect/pr49926.c (revision 0) @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +int a, b, c[10]; + +void +foo (unsigned int x, int y, int z, int *w) +{ + do +{ + *w = z; + y = x; + if (y) +for (b = -4; b; b++) + { +z = y = a = 1; +y = c[b + 4]; + } +} + while (1); +} + +/* { dg-final { cleanup-tree-dump vect } } */
Re: [google] Backport r175347 from trunk to google/gcc-4_6 (issue4835041)
ok http://codereview.appspot.com/4835041/
[MMIX] Hookize PREFERRED_RELOAD_CLASS and PREFERRED_OUTPUT_RELOAD_CLASS
Hi. This patch removes obsolete PREFERRED_RELOAD_CLASS and PREFERRED_OUTPUT_RELOAD_CLASS macros from MMIX back end in the GCC and introduces equivalent TARGET_PREFERRED_RELOAD_CLASS and TARGET_PREFERRED_OUTPUT_RELOAD_CLASS target hooks. Regression tested on mmix-knuth-mmixware. OK to install? * config/mmix/mmix.h (PREFERRED_RELOAD_CLASS, PREFERRED_OUTPUT_RELOAD_CLASS): Remove macro. * config/mmix/mmix-protos.h (mmix_preferred_reload_class, mmix_preferred_output_reload_class): Remove. * config/mmix/mmix.c (mmix_preferred_reload_class, mmix_preferred_output_reload_class): Make static. Change rclass argument and return type to reg_class_t. (TARGET_PREFERRED_RELOAD_CLASS, TARGET_PREFERRED_OUTPUT_RELOAD_CLASS): Define. Index: gcc/config/mmix/mmix.h === --- gcc/config/mmix/mmix.h (revision 176858) +++ gcc/config/mmix/mmix.h (working copy) @@ -452,12 +452,6 @@ #define REGNO_OK_FOR_INDEX_P(REGNO) REGNO_OK_FOR_BASE_P (REGNO) -#define PREFERRED_RELOAD_CLASS(X, CLASS) \ - mmix_preferred_reload_class (X, CLASS) - -#define PREFERRED_OUTPUT_RELOAD_CLASS(X, CLASS) \ - mmix_preferred_output_reload_class (X, CLASS) - #define SECONDARY_INPUT_RELOAD_CLASS(CLASS, MODE, X) \ mmix_secondary_reload_class (CLASS, MODE, X, 1) Index: gcc/config/mmix/mmix-protos.h === --- gcc/config/mmix/mmix-protos.h (revision 176858) +++ gcc/config/mmix/mmix-protos.h (working copy) @@ -59,9 +59,6 @@ (FILE *, tree, int, const char *); extern void mmix_asm_output_addr_diff_elt (FILE *, rtx, int, int); extern void mmix_asm_output_addr_vec_elt (FILE *, int); -extern enum reg_class mmix_preferred_reload_class (rtx, enum reg_class); -extern enum reg_class mmix_preferred_output_reload_class - (rtx, enum reg_class); extern enum reg_class mmix_secondary_reload_class (enum reg_class, enum machine_mode, rtx, int); extern int mmix_const_ok_for_letter_p (HOST_WIDE_INT, int); Index: gcc/config/mmix/mmix.c === --- gcc/config/mmix/mmix.c (revision 176858) +++ gcc/config/mmix/mmix.c (working copy) @@ -129,6 +129,8 @@ static void mmix_target_asm_function_prologue (FILE *, HOST_WIDE_INT); static void mmix_target_asm_function_end_prologue (FILE *); static void mmix_target_asm_function_epilogue (FILE *, HOST_WIDE_INT); +static reg_class_t mmix_preferred_reload_class (rtx, reg_class_t); +static reg_class_t mmix_preferred_output_reload_class (rtx, reg_class_t); static bool mmix_legitimate_address_p (enum machine_mode, rtx, bool); static bool mmix_legitimate_constant_p (enum machine_mode, rtx); static void mmix_reorg (void); @@ -250,6 +252,11 @@ #undef TARGET_CALLEE_COPIES #define TARGET_CALLEE_COPIES hook_bool_CUMULATIVE_ARGS_mode_tree_bool_true +#undef TARGET_PREFERRED_RELOAD_CLASS +#define TARGET_PREFERRED_RELOAD_CLASS mmix_preferred_reload_class +#undef TARGET_PREFERRED_OUTPUT_RELOAD_CLASS +#define TARGET_PREFERRED_OUTPUT_RELOAD_CLASS mmix_preferred_reload_class + #undef TARGET_LEGITIMATE_ADDRESS_P #define TARGET_LEGITIMATE_ADDRESS_Pmmix_legitimate_address_p #undef TARGET_LEGITIMATE_CONSTANT_P @@ -409,23 +416,22 @@ return regno = MMIX_LAST_STACK_REGISTER_REGNUM !call_used_regs[regno]; } -/* PREFERRED_RELOAD_CLASS. +/* TARGET_PREFERRED_RELOAD_CLASS. We need to extend the reload class of REMAINDER_REG and HIMULT_REG. */ -enum reg_class -mmix_preferred_reload_class (rtx x ATTRIBUTE_UNUSED, enum reg_class rclass) +static reg_class_t +mmix_preferred_reload_class (rtx x, reg_class_t rclass) { /* FIXME: Revisit. */ return GET_CODE (x) == MOD GET_MODE (x) == DImode ? REMAINDER_REG : rclass; } -/* PREFERRED_OUTPUT_RELOAD_CLASS. +/* TARGET_PREFERRED_OUTPUT_RELOAD_CLASS. We need to extend the reload class of REMAINDER_REG and HIMULT_REG. */ -enum reg_class -mmix_preferred_output_reload_class (rtx x ATTRIBUTE_UNUSED, - enum reg_class rclass) +static reg_class_t +mmix_preferred_output_reload_class (rtx x, reg_class_t rclass) { /* FIXME: Revisit. */ return GET_CODE (x) == MOD GET_MODE (x) == DImode Anatoly.
[PATCH, i386]: Fix PR49927, ice in spill_failure, at reload1.c:2120
Hello! On a register starved i686, the relaxation that we allow DImode values in addresses can lead to register shortages and spill failures. Attached patch puts back the requirement that we allow subregs up to and including WORD_MODE width, nicely packed in a new function. 2011-08-01 Uros Bizjak ubiz...@gmail.com PR target/49927 * config/i386/i386.c (ix86_address_subreg_operand): New. (ix86_decompose_address): Use ix86_address_subreg_operand. (ix86_legitimate_address_p): Do not assert that subregs satisfy register_no_elim_operand in DImode. testsuite/ChangeLog: 2011-08-01 Uros Bizjak ubiz...@gmail.com PR target/49927 * gcc.target/i386/pr49927.c: New test. Tested on x86_64-pc-linux-gnu {,-m32}, committed to mainline SVN. Uros. Index: config/i386/i386.c === --- config/i386/i386.c (revision 177036) +++ config/i386/i386.c (working copy) @@ -11096,6 +11096,30 @@ ix86_live_on_entry (bitmap regs) } } +/* Determine if op is suitable SUBREG RTX for address. */ + +static bool +ix86_address_subreg_operand (rtx op) +{ + enum machine_mode mode; + + if (!REG_P (op)) +return false; + + mode = GET_MODE (op); + + if (GET_MODE_CLASS (mode) != MODE_INT) +return false; + + /* Don't allow SUBREGs that span more than a word. It can lead to spill + failures when the register is one word out of a two word structure. */ + if (GET_MODE_SIZE (mode) UNITS_PER_WORD) +return false; + + /* Allow only SUBREGs of non-eliminable hard registers. */ + return register_no_elim_operand (op, mode); +} + /* Extract the parts of an RTL expression that is a valid memory address for an instruction. Return 0 if the structure of the address is grossly off. Return -1 if the address contains ASHIFT, so it is not @@ -6,8 +11140,7 @@ ix86_decompose_address (rtx addr, struct base = addr; else if (GET_CODE (addr) == SUBREG) { - /* Allow only subregs of DImode hard regs. */ - if (register_no_elim_operand (SUBREG_REG (addr), DImode)) + if (ix86_address_subreg_operand (SUBREG_REG (addr))) base = addr; else return 0; @@ -11175,8 +11198,7 @@ ix86_decompose_address (rtx addr, struct break; case SUBREG: - /* Allow only subregs of DImode hard regs in PLUS chains. */ - if (!register_no_elim_operand (SUBREG_REG (op), DImode)) + if (!ix86_address_subreg_operand (SUBREG_REG (op))) return 0; /* FALLTHRU */ @@ -11228,9 +11250,8 @@ ix86_decompose_address (rtx addr, struct { if (REG_P (index)) ; - /* Allow only subregs of DImode hard regs. */ else if (GET_CODE (index) == SUBREG - register_no_elim_operand (SUBREG_REG (index), DImode)) + ix86_address_subreg_operand (SUBREG_REG (index))) ; else return 0; @@ -11677,10 +11698,7 @@ ix86_legitimate_address_p (enum machine_ if (REG_P (base)) reg = base; else if (GET_CODE (base) == SUBREG REG_P (SUBREG_REG (base))) - { - reg = SUBREG_REG (base); - gcc_assert (register_no_elim_operand (reg, DImode)); - } + reg = SUBREG_REG (base); else /* Base is not a register. */ return false; @@ -11702,10 +11720,7 @@ ix86_legitimate_address_p (enum machine_ if (REG_P (index)) reg = index; else if (GET_CODE (index) == SUBREG REG_P (SUBREG_REG (index))) - { - reg = SUBREG_REG (index); - gcc_assert (register_no_elim_operand (reg, DImode)); - } + reg = SUBREG_REG (index); else /* Index is not a register. */ return false; Index: testsuite/gcc.target/i386/pr49927.c === --- testsuite/gcc.target/i386/pr49927.c (revision 0) +++ testsuite/gcc.target/i386/pr49927.c (revision 0) @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options -O0 } */ + +char a[1][1]; +long long b; + +void +foo (void) +{ + --a[b][b]; +}
Re: [MMIX] Hookize PREFERRED_RELOAD_CLASS and PREFERRED_OUTPUT_RELOAD_CLASS
On 08/01/2011 10:08 AM, Anatoly Sokolov wrote: * config/mmix/mmix.h (PREFERRED_RELOAD_CLASS, PREFERRED_OUTPUT_RELOAD_CLASS): Remove macro. * config/mmix/mmix-protos.h (mmix_preferred_reload_class, mmix_preferred_output_reload_class): Remove. * config/mmix/mmix.c (mmix_preferred_reload_class, mmix_preferred_output_reload_class): Make static. Change rclass argument and return type to reg_class_t. (TARGET_PREFERRED_RELOAD_CLASS, TARGET_PREFERRED_OUTPUT_RELOAD_CLASS): Define. Ok. r~
Re: Ping: RFA: Fix bug in optimize_mode_switching
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 07/31/11 03:25, Joern Rennecke wrote: This patch has not been reviewed in more than two weeks: http://gcc.gnu.org/ml/gcc-patches/2011-07/msg00786.html OK. jeff -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/ iQEcBAEBAgAGBQJONtkgAAoJEBRtltQi2kC7qG8IAK2zUbQ2p+MxXyBh41SSB/E1 uJz+FlPWb6hmLC0DLjdF9xTOymwxlc4F81E4f3l/5PTvFv03KOP5txJ+jnJ/e4RP +QSwJyTAgaIHfrlP4uidIeYt55Cvaq0Py3x8hgW6vT2e8OkRiEVOiDqvP+W8SeeM EBZUw3B6dqWsm6TGCiRoGQTy626ZcxENOHzsE+QgWOLzqsc1B5j2HR8dJFdJ5kLV Qd0VoFgD+auWWT5lyjTAZ8UcFBdFpMyyqhmkTGf21i0R3Sj7GewrxwVLYBl4hT1K LUYlWmjL1ZuweetWb4JWR2QtQeFTDJ+LvztUi2b/FdNGRBQUPmYd4cPmvt7kLjo= =u/Qn -END PGP SIGNATURE-
Re: C++ PATCH for c++/49813 (__builtin_isinf in constant expression)
Another issue raised in 49813 is that morally_constexpr_builtin_function_p was rejecting __builtin_isinf because it has a variadic signature. I'm changing potential_constant_expression_1 to just allow any built-in function in a constexpr function; if it doesn't expand to a constant, we'll deal with that when we actually expand it. Tested x86_64-pc-linux-gnu, applying to trunk. commit e2a2b30a8008b9f2d21e19bb2fd73776dbf89576 Author: Jason Merrill ja...@redhat.com Date: Mon Aug 1 11:49:09 2011 -0400 PR c++/49813 * semantics.c (potential_constant_expression_1): Allow any builtin. (morally_constexpr_builtin_function_p): Remove. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index c44c0ef..47b714f 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -7523,32 +7523,6 @@ check_automatic_or_tls (tree ref) } #endif -/* Return true if the DECL designates a builtin function that is - morally constexpr, in the sense that its parameter types and - return type are literal types and the compiler is allowed to - fold its invocations. */ - -static bool -morally_constexpr_builtin_function_p (tree decl) -{ - tree funtype = TREE_TYPE (decl); - tree t; - - if (!is_builtin_fn (decl)) -return false; - if (!literal_type_p (TREE_TYPE (funtype))) -return false; - for (t = TYPE_ARG_TYPES (funtype); t != NULL ; t = TREE_CHAIN (t)) -{ - if (t == void_list_node) -return true; - if (!literal_type_p (TREE_VALUE (t))) -return false; -} - /* We assume no varargs builtins are suitable. */ - return t != NULL; -} - /* Return true if T denotes a potentially constant expression. Issue diagnostic as appropriate under control of FLAGS. If WANT_RVAL is true, an lvalue-rvalue conversion is implied. @@ -7656,7 +7630,9 @@ potential_constant_expression_1 (tree t, bool want_rval, tsubst_flags_t flags) if (builtin_valid_in_constant_expr_p (fun)) return true; if (!DECL_DECLARED_CONSTEXPR_P (fun) - !morally_constexpr_builtin_function_p (fun)) + /* Allow any built-in function; if the expansion + isn't constant, we'll deal with that then. */ + !is_builtin_fn (fun)) { if (flags tf_error) { diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-builtin1.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-builtin1.C new file mode 100644 index 000..b3f5576 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-builtin1.C @@ -0,0 +1,25 @@ +// PR c++/49813 +// { dg-options -std=c++0x } + +inline constexpr bool +isinf(long double __x) +{ return __builtin_isinf(__x); } + +inline constexpr bool +isinf(double __x) +{ return __builtin_isinf(__x); } + +inline constexpr bool +isnan(long double __x) +{ return __builtin_isnan(__x); } + +int main() +{ + constexpr long double num1 = __builtin_isinf(1.l); // Ok. + + constexpr long double num2 = isinf(1.l); // Error. + + constexpr double num3 = isinf(1.);// Ok. + + constexpr long double num4 = isnan(1.l); // Ok. +}
Re: PATCH: PR target/47766: [x32] -fstack-protector doesn't work
PR target/47766 * config/i386/i386.md (PTR): New. (stack_protect_set: Check TARGET_LP64 instead of TARGET_64BIT. (stack_protect_test): Likewise. (stack_protect_set_mode): Replace :P with :PTR. (stack_tls_protect_set_mode): Likewise. (stack_tls_protect_test_mode): Likewise. Ok. r~
[PATCH] OpenMP 3.1 branch merge
Hi! Now that OpenMP 3.1 has been released for a few weeks and what we have on gomp-3_1-branch should be feature complete (though in the future could benefit from various optimizations, in particular: 1) avoid atomic insns for atomic reads and stores if aligned and hw/backend can guarantee atomicity of the store/load - use volatile loads/stores instead - here I hope some interaction with Andrew's C++0x stuff will be useful 2) taskyield - currently stubbed, I think especially if we have a different task scheduler it will be useful to implement it 3) mergeable task clonning), I'd like to merge this to trunk. Bootstrapped/regtested on x86_64-linux and i686-linux, will commit unless I hear objections in the next day or so. 2011-08-01 Jakub Jelinek ja...@redhat.com gcc/ * c-parser.c (enum c_parser_prec): New enum, moved from within c_parser_binary_expression. (c_parser_binary_expression): Add PREC argument. Stop parsing if operator has lower or equal precedence than PREC. (c_parser_conditional_expression, c_parser_omp_for_loop): Adjust callers. (c_parser_omp_atomic): Handle parsing OpenMP 3.1 atomics. Adjust c_finish_omp_atomic caller. (c_parser_omp_taskyield): New function. (c_parser_pragma): Handle PRAGMA_OMP_TASKYIELD. (c_parser_omp_clause_name): Handle final and mergeable clauses. (c_parser_omp_clause_final, c_parser_omp_clause_mergeable): New functions. (c_parser_omp_all_clauses): Handle PRAGMA_OMP_CLAUSE_FINAL and PRAGMA_OMP_CLAUSE_MERGEABLE. (OMP_TASK_CLAUSE_MASK): Allow final and mergeable clauses. (c_parser_omp_clause_reduction): Handle min and max. * c-typeck.c (c_finish_omp_clauses): Don't complain about const qualified predetermined vars in firstprivate clause. andle OMP_CLAUSE_FINAL and OMP_CLAUSE_MERGEABLE. Handle MIN_EXPR and MAX_EXPR. * tree-pretty-print.c (dump_omp_clause): Handle OMP_CLAUSE_FINAL and OMP_CLAUSE_MERGEABLE. (dump_generic_node): Handle OMP_ATOMIC_READ, OMP_ATOMIC_CAPTURE_OLD and OMP_ATOMIC_CAPTURE_NEW. * tree.c (omp_clause_num_ops): Add OMP_CLAUSE_FINAL and OMP_CLAUSE_MERGEABLE. (omp_clause_code_name): Likewise. (walk_tree_1): Handle OMP_CLAUSE_FINAL and OMP_CLAUSE_MERGEABLE. * tree.h (enum omp_clause_code): Add OMP_CLAUSE_FINAL and OMP_CLAUSE_MERGEABLE. (OMP_CLAUSE_FINAL_EXPR): Define. * omp-low.c (scan_sharing_clauses): Handle OMP_CLAUSE_FINAL and OMP_CLAUSE_MERGEABLE. (expand_task_call): Likewise. (expand_omp_atomic_load, expand_omp_atomic_store): New functions. (expand_omp_atomic_fetch_op): Handle cases where old or new value is needed afterwards. (expand_omp_atomic): Call expand_omp_atomic_load resp. expand_omp_atomic_store. * gimplify.c (gimplify_omp_atomic, gimplify_expr): Handle OMP_ATOMIC_READ, OMP_ATOMIC_CAPTURE_OLD and OMP_ATOMIC_CAPTURE_NEW. (gimplify_scan_omp_clauses, gimplify_adjust_omp_clauses): Handle OMP_CLAUSE_FINAL and OMP_CLAUSE_MERGEABLE. * tree-nested.c (convert_nonlocal_omp_clauses, convert_local_omp_clauses): Likewise. * tree.def (OMP_ATOMIC_READ, OMP_ATOMIC_CAPTURE_OLD, OMP_ATOMIC_CAPTURE_NEW): New. * gimple.h (GF_OMP_ATOMIC_NEED_VALUE): New. (gimple_omp_atomic_need_value_p, gimple_omp_atomic_set_need_value): New inlines. * omp-builtins.def (BUILT_IN_GOMP_TASKYIELD): New builtin. * doc/generic.texi: Mention OMP_CLAUSE_COLLAPSE, OMP_CLAUSE_UNTIED, OMP_CLAUSE_FINAL and OMP_CLAUSE_MERGEABLE. gcc/c-family/ * c-common.h (c_finish_omp_atomic): Adjust prototype. (c_finish_omp_taskyield): New prototype. * c-omp.c (c_finish_omp_atomic): Add OPCODE, V, LHS1 and RHS1 arguments. Handle OMP_ATOMIC_READ, OMP_ATOMIC_CAPTURE_OLD and OMP_ATOMIC_CAPTURE_NEW in addition to OMP_ATOMIC. If LHS1 or RHS1 have side-effects, evaluate those too in the right spot, if it is a decl and LHS is also a decl, error out if they aren't the same. (c_finish_omp_taskyield): New function. * c-cppbuiltin.c (c_cpp_builtins): Change _OPENMP to 201107. * c-pragma.c (omp_pragmas): Add taskyield. * c-pragma.h (enum pragma_kind): Add PRAGMA_OMP_TASKYIELD. (enum pragma_omp_clause): Add PRAGMA_OMP_CLAUSE_FINAL and PRAGMA_OMP_CLAUSE_MERGEABLE. gcc/cp/ * cp-tree.h (finish_omp_atomic): Adjust prototype. (cxx_omp_const_qual_no_mutable): New prototype. (finish_omp_taskyield): New prototype. * parser.c (cp_parser_omp_atomic): (cp_parser_omp_atomic): Handle parsing OpenMP 3.1 atomics. Adjust finish_omp_atomic caller. (cp_parser_omp_clause_name): Handle final and mergeable clauses.
Re: [RFC] Cleanup DW_CFA_GNU_args_size handling
Richard Henderson schrieb: This is related primarily to PR49864 but also to PR49879. The fundamental problem in the first test case is that the AVR target cannot perform (set (stack-pointer-rtx) (plus (stack-pointer-rtx) (const_int large))) where large is in fact really quite small. This gets dutifully reloaded to (set (reg temp) (stack-pointer-rtx)) (set (reg temp) (plus (reg temp) (const_int large))) (set (stack-pointer-rtx) (reg temp)) which, we have to admit, is perfectly reasonable. The code that we had in stack_adjust_offset would not properly handle anything except immediate addends to the stack pointer. Indeed, if it saw any other sort of stack pointer adjustment, it gave up and assumed that we'd reset the args_size level to 0. This exact problem hasn't shown up on other targets either (1) because they ACCUMULATE_OUTGOING_ARGS, or (2) while they may not be able to handle very large addends to the stack pointer, we usually don't let the pushed arguments grow to very large numbers; we regularly reduce stack_pointer_delta. AVR is special in that it can't *really* perform any direct addition to the stack pointer at all; large is non-zero only because of a peephole pattern to use pop insns into a scratch register for small adjustments. In CCing Denis. http://gcc.gnu.org/ml/gcc-patches/2011-08/msg00075.html Is there a specific reason not to define ACCUMULATE_OUTGOING_ARGS on AVR? Addind/subtracting to SP is very expensive on AVR, even IRQs have to be disabled. Johann I briefly considered adding an insn pattern that would handle the entire mov/add/mov thing with a scratch, so that we wouldn't have to do anything special. It seemed relatively unlikely that any other port would be this severely limited. However, then came a look at the second PR, where we performed cross-jumping between two blocks with different args_size values. For the specific case of the PR, this merely resulted in wrong-debug, because we would in fact generate invalid unwind info for one of the two paths. That said, I see no reason why this same cross-jump could not occur with a real throw as opposed to an abort. And in that case we would have wrong-code. I consulted the IRC oracle, and Ian didn't have any objections in principal to a new reg-note. Comments? r~
Re: [RFC] Cleanup DW_CFA_GNU_args_size handling
On 08/01/2011 11:42 AM, Georg-Johann Lay wrote: Is there a specific reason not to define ACCUMULATE_OUTGOING_ARGS on AVR? Yes. So that you can use PUSH. But as I said in PR49881, you probably want to provide -maccumulate-outgoing-args. I have a follow-up patch to the last one in that PR... r~
Re: [PATCH 1/7] Linemap infrastructure for virtual locations
Jason Merrill ja...@redhat.com writes: On 07/16/2011 07:37 AM, Dodji Seketeli wrote: +/* Returns the highest location [of a token resulting from macro + expansion] encoded in this line table. */ +#define LINEMAPS_MACRO_HIGHEST_LOCATION(SET) \ + LINEMAPS_HIGHEST_LOCATION(SET, true) + +/* Returns the location of the begining of the highest line + -- containing a token resulting from macro expansion -- encoded + in the line table SET. */ +#define LINEMAPS_MACRO_HIGHEST_LINE(SET) \ + LINEMAPS_HIGHEST_LINE(SET, true) What is the use of these? The ordinary highest line/location are used for various things, but I can't think of a reason you would want the above, nor are they used in any of the patches. The former is necessary because locations yielded by original macro maps grow from zero to upward while locations yielded by macro maps grow from a MAX_SOURCE_LOCATION downward. As locations of macro locations decrease monotonically we need LINEMAPS_MACRO_HIGHEST_LOCATION (used in linemap_enter_macro) for reasons that are similar to why we need LINEMAPS_ORDINARY_HIGHEST_LOCATION. I added LINEMAPS_MACRO_HIGHEST_LINE for symmetry, as we had LINEMAPS_ORDINARY_HIGHEST_LINE. It's also because at some point I thought that I'd need a function like linemap_position_for_column, but for macro locations. This could be useful to e.g, create source locations for macro tokens that we are re-constructing. E.g, to support macro locations with -fpreprocessed. I stepped my ambitions down for this first batch of patches and I forgot to remove this macro. I'll remove it from my local updated version of the patch. Maybe these should be in line_maps instead of maps_info? I think the former should stay in maps_info as each type of map (macro and ordinary) need its own highest location. Jason Merrill ja...@redhat.com writes: On 07/16/2011 07:37 AM, Dodji Seketeli wrote: Apart from the added declaration, these changes seem like unnecessary churn; let's avoid reformatting unchanged comments and removing extern from declarations that are correct as they are. I am cleaning up this in my local version of the patch. Thanks. -- Dodji
Fwd: [AVR] Fix PR49881
Dang, forgot to add gcc-patches... Original Message Subject: [AVR] Fix PR49881 Date: Mon, 01 Aug 2011 11:58:32 -0700 From: Richard Henderson r...@redhat.com To: Denis Chertykov cherty...@gmail.com, eric.wedding...@atmel.com CC: a...@gjlay.de The following iteration fixes the two regressions reported in comment 7 of the PR. These were ICEs due to emit_push_insn_single being helpful with pushing complex numbers. Instead of recursing for the components of a complex number, it simply generated raw pre_dec patterns. This is arguably a middle-end bug, but it's easier to fix in the backend by listing complex modes in the macro for the push expander. Ok? r~ * config/avr/avr.h (PUSH_ROUNDING): New. * config/avr/avr.md (pushqi1): Rename from *pushqi. (*pushhi, *pushsi, *pushsf): Remove. (MPUSH): New mode iterator. (pushMPUSH1): New expander. diff --git a/gcc/config/avr/avr.h b/gcc/config/avr/avr.h index ddd30d6..6a80693 100644 --- a/gcc/config/avr/avr.h +++ b/gcc/config/avr/avr.h @@ -665,3 +665,7 @@ struct GTY(()) machine_function /* 'true' if a callee might be tail called */ int sibcall_fails; }; + +/* AVR does not round pushes, but the existance of this macro is + required in order for pushes to be generated. */ +#define PUSH_ROUNDING(X) (X) diff --git a/gcc/config/avr/avr.md b/gcc/config/avr/avr.md index 55a883e..f60f9f0 100644 --- a/gcc/config/avr/avr.md +++ b/gcc/config/avr/avr.md @@ -202,8 +202,7 @@ DONE; }) - -(define_insn *pushqi +(define_insn pushqi1 [(set (mem:QI (post_dec:HI (reg:HI REG_SP))) (match_operand:QI 0 reg_or_0_operand r,L))] @@ -212,33 +211,29 @@ push __zero_reg__ [(set_attr length 1,1)]) -(define_insn *pushhi - [(set (mem:HI (post_dec:HI (reg:HI REG_SP))) -(match_operand:HI 0 reg_or_0_operand r,L))] - - @ - push %B0\;push %A0 - push __zero_reg__\;push __zero_reg__ - [(set_attr length 2,2)]) +;; All modes for a multi-byte push. We must include complex modes here too, +;; lest emit_single_push_insn helpfully create the auto-inc itself. +(define_mode_iterator MPUSH + [(CQI ) + (HI ) (CHI ) + (SI ) (CSI ) + (DI ) (CDI ) + (SF ) (SC )]) -(define_insn *pushsi - [(set (mem:SI (post_dec:HI (reg:HI REG_SP))) -(match_operand:SI 0 reg_or_0_operand r,L))] +(define_expand pushmode1 + [(match_operand:MPUSH 0 general_operand )] - @ - push %D0\;push %C0\;push %B0\;push %A0 - push __zero_reg__\;push __zero_reg__\;push __zero_reg__\;push __zero_reg__ - [(set_attr length 4,4)]) - -(define_insn *pushsf - [(set (mem:SF (post_dec:HI (reg:HI REG_SP))) -(match_operand:SF 0 register_operand r))] - - push %D0 - push %C0 - push %B0 - push %A0 - [(set_attr length 4)]) +{ + int i; + for (i = GET_MODE_SIZE (MODEmode) - 1; i = 0; --i) +{ + rtx part = simplify_gen_subreg (QImode, operands[0], MODEmode, i); + if (part != const0_rtx) + part = force_reg (QImode, part); + emit_insn (gen_pushqi1 (part)); +} + DONE; +}) ;; ;; move byte
Re: [RFC] hard-reg-set.h refactoring
On Mon, 1 Aug 2011, Paolo Bonzini wrote: On 08/01/2011 05:57 PM, Dimitrios Apostolou wrote: I don't fully understand the output from -fdump-tree-all, but my conclusion based also on profiler output and objdump, is that both unrolling and inlining is happening in both versions. Nevertheless I can see that assembly output is a bit different in the two cases (I can post specific disassembly output if you are interested). Thanks for checking. Have you tried the idea of passing an unsigned HOST_WIDEST_FAST_INT * (or whatever the name) to the target hook? Keeping my patch exactly the same, just changing the hook_void_hard_reg_set to receive a (HOST_WIDEST_FAST_INT *) arg and doing the necessary typecasts, added an extra 3 M instructions. But the ix86_live_on_entry is only called 1233x times from df-scan.c. This isn't enough to explain all this overhead. Dimitris
Re: C++ PATCH for c++/49813 (__builtin_isinf in constant expression)
Thanks a lot, Jason. I applied the below, tested x86_64-linux multilib. Paolo. // 2011-08-01 Paolo Carlini paolo.carl...@oracle.com PR c++/49813 * include/c_global/cmath (isinf): Remove workaround. Index: include/c_global/cmath === --- include/c_global/cmath (revision 177068) +++ include/c_global/cmath (working copy) @@ -547,18 +547,17 @@ isfinite(_Tp __x) { return true; } - // Workaround the isinf issue discussed in PR 49813. constexpr bool isinf(float __x) - { return fpclassify(__x) == FP_INFINITE; } + { return __builtin_isinf(__x); } constexpr bool isinf(double __x) - { return fpclassify(__x) == FP_INFINITE; } + { return __builtin_isinf(__x); } constexpr bool isinf(long double __x) - { return fpclassify(__x) == FP_INFINITE; } + { return __builtin_isinf(__x); } templatetypename _Tp constexpr typename __gnu_cxx::__enable_if__is_integer_Tp::__value,
Re: [RFC] Cleanup DW_CFA_GNU_args_size handling
2011/8/1 Richard Henderson r...@redhat.com: On 08/01/2011 11:42 AM, Georg-Johann Lay wrote: Is there a specific reason not to define ACCUMULATE_OUTGOING_ARGS on AVR? I havn't define ACCUMULATE_OUTGOING_ARGS because AVR have a very small displacement for memory addressing (63 bytes) and I think that better to have a minimal possible frame size (because of difficult addressing of a local variables outside of fp+63 boundary). Generally, ACCUMULATE_OUTGOING_ARGS enlarge the frame size. Denis. PS: I didn't try ACCUMULATE_OUTGOING_ARGS for AVR. May be results will be better than I think.
Re: [PATCH] Propagate source locations from function_decls to their template_decls
Thanks. Committed to gcc-4_6-branch in r176851 and the google/gcc-4_6 branch in r177072. On Wed, Jul 27, 2011 at 11:46 AM, Jason Merrill ja...@redhat.com wrote: Yes. Jeffrey Yasskin jyass...@google.com wrote: Thanks. I'll commit to trunk in the morning when I can be around to watch for breakage. Is this also ok for gcc-4_6-branch? On Tue, Jul 26, 2011 at 7:16 PM, Jason Merrill ja...@redhat.com wrote: Ok. Jeffrey Yasskin jyass...@google.com wrote: Hi Jason. Paolo suggested I ping you directly about this patch for the C++ parser. Thanks in advance for taking a look. On Tue, Jul 26, 2011 at 2:20 PM, Jeffrey Yasskin jyass...@google.com wrote: This patch copies the source location of a FUNCTION_DECL to the TEMPLATE_DECL that build_template_decl() builds out of it. Otherwise, the TEMPLATE_DECL's location becomes input_location, which is the end of the parameter list, while the FUNCTION_DECL's location is the location of the name of the function. Depending on what order templates are defined and used, gcc may emit either the FUNCTION_DECL's or TEMPLATE_DECL's location into the debug location, which causes gold's ODR checker to emit false positives. Tested with a bootstrap+`make -k check-c++` on x86_64-unknown-linux-gnu. I'm looking to check it in to trunk, and will propagate it to the gcc-4_6-branch if you think that's the right thing to do. No more tests fail than in http://gcc.gnu.org/ml/gcc-testresults/2011-07/msg02995.html. gcc/cp/ChangeLog: 2011-07-26 ? Jeffrey Yasskin ?jyass...@google.com ? ? ? ?* pt.c (build_template_decl): Copy the function_decl's source ? ? ? ?location to the new template_decl. gcc/testsuite/ChangeLog: 2011-07-26 ? Jeffrey Yasskin ?jyass...@google.com ? ? ? ?* g++.old-deja/g++.pt/crash60.C: Updated. libstdc++-v3/ChangeLog: 2011-07-26 ? Jeffrey Yasskin ?jyass...@google.com ? ? ? ?* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Updated.
C++ PATCH for c++/49924 (constexpr rejects-valid with array member)
cxx_eval_vec_init_1 was assuming that any CONSTRUCTOR would be for the element type, which is silly in this context because an array initializer is also a CONSTRUCTOR. Oops. While I was fixing this I also changed value-initialization to be pre-evaluated like default-initialization. Tested x86_64-pc-linux-gnu, applying to trunk. commit e421970c44311cf24389f8281f0e635523f9eea3 Author: Jason Merrill ja...@redhat.com Date: Mon Aug 1 14:44:01 2011 -0400 PR c++/49924 * semantics.c (cxx_eval_vec_init_1): Fix logic. diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 47b714f..0b2a96f 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -6651,6 +6651,7 @@ cxx_eval_vec_init_1 (const constexpr_call *call, tree atype, tree init, tree elttype = TREE_TYPE (atype); int max = tree_low_cst (array_type_nelts (atype), 0); VEC(constructor_elt,gc) *n = VEC_alloc (constructor_elt, gc, max + 1); + bool pre_init = false; int i; /* For the default constructor, build up a call to the default @@ -6658,8 +6659,15 @@ cxx_eval_vec_init_1 (const constexpr_call *call, tree atype, tree init, here, as for a constructor to be constexpr, all members must be initialized, which for a defaulted default constructor means they must be of a class type with a constexpr default constructor. */ - if (value_init) -gcc_assert (!init); + if (TREE_CODE (elttype) == ARRAY_TYPE) +/* We only do this at the lowest level. */; + else if (value_init) +{ + init = build_value_init (elttype, tf_warning_or_error); + init = cxx_eval_constant_expression + (call, init, allow_non_constant, addr, non_constant_p); + pre_init = true; +} else if (!init) { VEC(tree,gc) *argvec = make_tree_vector (); @@ -6669,6 +6677,7 @@ cxx_eval_vec_init_1 (const constexpr_call *call, tree atype, tree init, release_tree_vector (argvec); init = cxx_eval_constant_expression (call, init, allow_non_constant, addr, non_constant_p); + pre_init = true; } if (*non_constant_p !allow_non_constant) @@ -6690,17 +6699,14 @@ cxx_eval_vec_init_1 (const constexpr_call *call, tree atype, tree init, allow_non_constant, addr, non_constant_p); } - else if (value_init) + else if (pre_init) { - eltinit = build_value_init (elttype, tf_warning_or_error); - eltinit = cxx_eval_constant_expression - (call, eltinit, allow_non_constant, addr, non_constant_p); - } - else if (TREE_CODE (init) == CONSTRUCTOR) - { - /* Initializing an element using the call to the default - constructor we just built above. */ - eltinit = unshare_expr (init); + /* Initializing an element using value or default initialization + we just pre-built above. */ + if (i == 0) + eltinit = init; + else + eltinit = unshare_expr (init); } else { diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-array4.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-array4.C new file mode 100644 index 000..9aeb75d --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-array4.C @@ -0,0 +1,14 @@ +// PR c++/49924 +// { dg-options -std=c++0x } + +struct A { constexpr A() { } }; + +struct B { + A array[1]; //non-static member array of a literal type w constexpr ctor + constexpr B() : array{} { } // here is the problem +}; + +int main() +{ + constexpr B b{}; // won't compile +}
Re: PATCH: Add x32 libstdc++-v3 symbols
Hi, Hi, This patch adds x32 libstdc++-v3 symbols. OK for trunk? I can't really check this but OK. Paolo.
[PATCH] bootstrap/49914
Hi, I bootstrapped and I'm currently finishing testing on x86_64-linux the below. Is it Ok for mainline? Thanks, Paolo. /// 2011-08-02 Paolo Carlini paolo.carl...@oracle.com PR bootstrap/49914 * fold-const.c (fold_plusminus_mult_expr): Use abs_hwi instead of abs. * tree-ssa-math-opts.c (gimple_expand_builtin_pow): Likewise. * tree-ssa-loop-prefetch.c (prune_ref_by_group_reuse): Likewise. Index: fold-const.c === --- fold-const.c(revision 177075) +++ fold-const.c(working copy) @@ -7037,8 +7037,7 @@ fold_plusminus_mult_expr (location_t loc, enum tre int11 = TREE_INT_CST_LOW (arg11); /* Move min of absolute values to int11. */ - if ((int01 = 0 ? int01 : -int01) - (int11 = 0 ? int11 : -int11)) + if (abs_hwi (int01) abs_hwi (int11)) { tmp = int01, int01 = int11, int11 = tmp; alt0 = arg00, arg00 = arg10, arg10 = alt0; @@ -7048,7 +7047,7 @@ fold_plusminus_mult_expr (location_t loc, enum tre else maybe_same = arg11; - if (exact_log2 (abs (int11)) 0 int01 % int11 == 0 + if (exact_log2 (abs_hwi (int11)) 0 int01 % int11 == 0 /* The remainder should not be a constant, otherwise we end up folding i * 4 + 2 to (i * 2 + 1) * 2 which has increased the number of multiplications necessary. */ Index: tree-ssa-math-opts.c === --- tree-ssa-math-opts.c(revision 177075) +++ tree-ssa-math-opts.c(working copy) @@ -1231,7 +1231,7 @@ gimple_expand_builtin_pow (gimple_stmt_iterator *g /* Attempt to fold powi(arg0, abs(n/2)) into multiplies. If not possible or profitable, give up. Skip the degenerate case when n is 1 or -1, where the result is always 1. */ - if (abs (n) != 1) + if (abs_hwi (n) != 1) { powi_x_ndiv2 = gimple_expand_builtin_powi (gsi, loc, arg0, abs(n/2)); if (!powi_x_ndiv2) @@ -1242,7 +1242,7 @@ gimple_expand_builtin_pow (gimple_stmt_iterator *g result of the optimal multiply sequence just calculated. */ sqrt_arg0 = build_and_insert_call (gsi, loc, target, sqrtfn, arg0); - if (abs (n) == 1) + if (abs_hwi (n) == 1) result = sqrt_arg0; else result = build_and_insert_binop (gsi, loc, target, MULT_EXPR, @@ -1284,10 +1284,10 @@ gimple_expand_builtin_pow (gimple_stmt_iterator *g /* Attempt to fold powi(arg0, abs(n/3)) into multiplies. If not possible or profitable, give up. Skip the degenerate case when abs(n) 3, where the result is always 1. */ - if (abs (n) = 3) + if (abs_hwi (n) = 3) { powi_x_ndiv3 = gimple_expand_builtin_powi (gsi, loc, arg0, -abs (n / 3)); +abs_hwi (n / 3)); if (!powi_x_ndiv3) return NULL_TREE; } @@ -1297,14 +1297,14 @@ gimple_expand_builtin_pow (gimple_stmt_iterator *g either cbrt(x) or cbrt(x) * cbrt(x). */ cbrt_x = build_and_insert_call (gsi, loc, target, cbrtfn, arg0); - if (abs (n) % 3 == 1) + if (abs_hwi (n) % 3 == 1) powi_cbrt_x = cbrt_x; else powi_cbrt_x = build_and_insert_binop (gsi, loc, target, MULT_EXPR, cbrt_x, cbrt_x); /* Multiply the two subexpressions, unless powi(x,abs(n)/3) = 1. */ - if (abs (n) 3) + if (abs_hwi (n) 3) result = powi_cbrt_x; else result = build_and_insert_binop (gsi, loc, target, MULT_EXPR, Index: tree-ssa-loop-prefetch.c === --- tree-ssa-loop-prefetch.c(revision 177075) +++ tree-ssa-loop-prefetch.c(working copy) @@ -1,5 +1,6 @@ /* Array prefetching. - Copyright (C) 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 2005, 2007, 2008, 2009, 2010, 2011 + Free Software Foundation, Inc. This file is part of GCC. @@ -794,7 +795,7 @@ prune_ref_by_group_reuse (struct mem_ref *ref, str prefetch_before = (hit_from - delta_r + step - 1) / step; /* Do not reduce prefetch_before if we meet beyond cache size. */ - if (prefetch_before (unsigned) abs (L2_CACHE_SIZE_BYTES / step)) + if (prefetch_before (unsigned) abs_hwi (L2_CACHE_SIZE_BYTES / step)) prefetch_before = PREFETCH_ALL; if (prefetch_before ref-prefetch_before) ref-prefetch_before = prefetch_before;
Re: [PATCH] bootstrap/49914
... oops, due to a missing space I missed an occurrence of abs in gimple_expand_builtin_pow. I'm restarting bootstrap and test with the below. Paolo. /// Index: fold-const.c === --- fold-const.c(revision 177075) +++ fold-const.c(working copy) @@ -7037,8 +7037,7 @@ fold_plusminus_mult_expr (location_t loc, enum tre int11 = TREE_INT_CST_LOW (arg11); /* Move min of absolute values to int11. */ - if ((int01 = 0 ? int01 : -int01) - (int11 = 0 ? int11 : -int11)) + if (abs_hwi (int01) abs_hwi (int11)) { tmp = int01, int01 = int11, int11 = tmp; alt0 = arg00, arg00 = arg10, arg10 = alt0; @@ -7048,7 +7047,7 @@ fold_plusminus_mult_expr (location_t loc, enum tre else maybe_same = arg11; - if (exact_log2 (abs (int11)) 0 int01 % int11 == 0 + if (exact_log2 (abs_hwi (int11)) 0 int01 % int11 == 0 /* The remainder should not be a constant, otherwise we end up folding i * 4 + 2 to (i * 2 + 1) * 2 which has increased the number of multiplications necessary. */ Index: tree-ssa-math-opts.c === --- tree-ssa-math-opts.c(revision 177075) +++ tree-ssa-math-opts.c(working copy) @@ -1231,9 +1231,10 @@ gimple_expand_builtin_pow (gimple_stmt_iterator *g /* Attempt to fold powi(arg0, abs(n/2)) into multiplies. If not possible or profitable, give up. Skip the degenerate case when n is 1 or -1, where the result is always 1. */ - if (abs (n) != 1) + if (abs_hwi (n) != 1) { - powi_x_ndiv2 = gimple_expand_builtin_powi (gsi, loc, arg0, abs(n/2)); + powi_x_ndiv2 = gimple_expand_builtin_powi (gsi, loc, arg0, +abs_hwi (n / 2)); if (!powi_x_ndiv2) return NULL_TREE; } @@ -1242,7 +1243,7 @@ gimple_expand_builtin_pow (gimple_stmt_iterator *g result of the optimal multiply sequence just calculated. */ sqrt_arg0 = build_and_insert_call (gsi, loc, target, sqrtfn, arg0); - if (abs (n) == 1) + if (abs_hwi (n) == 1) result = sqrt_arg0; else result = build_and_insert_binop (gsi, loc, target, MULT_EXPR, @@ -1284,10 +1285,10 @@ gimple_expand_builtin_pow (gimple_stmt_iterator *g /* Attempt to fold powi(arg0, abs(n/3)) into multiplies. If not possible or profitable, give up. Skip the degenerate case when abs(n) 3, where the result is always 1. */ - if (abs (n) = 3) + if (abs_hwi (n) = 3) { powi_x_ndiv3 = gimple_expand_builtin_powi (gsi, loc, arg0, -abs (n / 3)); +abs_hwi (n / 3)); if (!powi_x_ndiv3) return NULL_TREE; } @@ -1297,14 +1298,14 @@ gimple_expand_builtin_pow (gimple_stmt_iterator *g either cbrt(x) or cbrt(x) * cbrt(x). */ cbrt_x = build_and_insert_call (gsi, loc, target, cbrtfn, arg0); - if (abs (n) % 3 == 1) + if (abs_hwi (n) % 3 == 1) powi_cbrt_x = cbrt_x; else powi_cbrt_x = build_and_insert_binop (gsi, loc, target, MULT_EXPR, cbrt_x, cbrt_x); /* Multiply the two subexpressions, unless powi(x,abs(n)/3) = 1. */ - if (abs (n) 3) + if (abs_hwi (n) 3) result = powi_cbrt_x; else result = build_and_insert_binop (gsi, loc, target, MULT_EXPR, Index: tree-ssa-loop-prefetch.c === --- tree-ssa-loop-prefetch.c(revision 177075) +++ tree-ssa-loop-prefetch.c(working copy) @@ -1,5 +1,6 @@ /* Array prefetching. - Copyright (C) 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 2005, 2007, 2008, 2009, 2010, 2011 + Free Software Foundation, Inc. This file is part of GCC. @@ -794,7 +795,7 @@ prune_ref_by_group_reuse (struct mem_ref *ref, str prefetch_before = (hit_from - delta_r + step - 1) / step; /* Do not reduce prefetch_before if we meet beyond cache size. */ - if (prefetch_before (unsigned) abs (L2_CACHE_SIZE_BYTES / step)) + if (prefetch_before (unsigned) abs_hwi (L2_CACHE_SIZE_BYTES / step)) prefetch_before = PREFETCH_ALL; if (prefetch_before ref-prefetch_before) ref-prefetch_before = prefetch_before;
Re: [Patch, i386, testsuite] Fix for PR49547, new tescases for lzcnt instruction
On Mon, Aug 1, 2011 at 6:13 AM, Kirill Yukhin kirill.yuk...@gmail.com wrote: Done. Updated patch is attached. Thanks, K On Mon, Aug 1, 2011 at 4:49 PM, H.J. Lu hjl.to...@gmail.com wrote: On Mon, Aug 1, 2011 at 5:36 AM, Kirill Yukhin kirill.yuk...@gmail.com wrote: Hi HJ, Thanks for input. I've missed it. Done. Updated patch is attached. Compiler may still optimize it away. You need to replace 0 with a function parameter. Please see: http://gcc.gnu.org/ml/gcc-patches/2011-07/msg02463.html H.J. --- Thanks, K On Mon, Aug 1, 2011 at 4:26 PM, H.J. Lu hjl.to...@gmail.com wrote: On Mon, Aug 1, 2011 at 5:20 AM, Kirill Yukhin kirill.yuk...@gmail.com wrote: I've merged my changes with trunk (there was a conflict) and fixed typo. Updated patch is attached. Waiting for commit... Thanks, K On Mon, Aug 1, 2011 at 1:03 PM, Kirill Yukhin kirill.yuk...@gmail.com wrote: Thanks! Guys with waa rights, could anybody commit my fix? Thanks, K OK for mainline. Uros. +# Return 1 if lzcnt instruction can be compiled. +proc check_effective_target_lzcnt { } { + return [check_no_compiler_messages lzcnt object { + void _lzcnt (void) + { + __builtin_clzs (0); + } + } -O2 -mlzcnt ] +} GCC may optimize this away. Please fix it similar to: http://gcc.gnu.org/ml/gcc-patches/2011-07/msg02463.html We should use long long on 64bit intrinsic. I checked in this as an obvious fix. -- H.J. --- Index: ChangeLog === --- ChangeLog (revision 177080) +++ ChangeLog (working copy) @@ -1,3 +1,8 @@ +2011-08-01 H.J. Lu hongjiu...@intel.com + + * config/i386/lzcntintrin.h (__lzcnt64): Replace long with + long long. + 2011-08-01 Sebastian Pop sebastian@amd.com Joseph Myers jos...@codesourcery.com Index: config/i386/lzcntintrin.h === --- config/i386/lzcntintrin.h (revision 177080) +++ config/i386/lzcntintrin.h (working copy) @@ -45,10 +45,10 @@ __lzcnt32 (unsigned int __X) } #ifdef __x86_64__ -extern __inline unsigned long __attribute__((__gnu_inline__, __always_inline__, __artificial__)) -__lzcnt64 (unsigned long __X) +extern __inline unsigned long long __attribute__((__gnu_inline__, __always_inli ne__, __artificial__)) +__lzcnt64 (unsigned long long __X) { - return __builtin_clzl (__X); + return __builtin_clzll (__X); } #endif
Re: [RFC] Cleanup DW_CFA_GNU_args_size handling
Testing on h8300, newlib/libm/math/ef_j0.c revealed a crash. The problem is that PREV turned out to be unlinked when we came to fixup_args_size_notes (prev, PREV_INSN (next), INTVAL (XEXP (p, 0))); I'm not sure how this didn't previously crash at fixup_eh_region_note (insn, prev, next); Thanks to reload inheritance deleting insns out from under, I can't think of any other mechanism than to have a marker note before INSN that won't get deleted. Comments? r~ commit 90060c3e9508d3bd0c930ba13cbe3230c7ea0b8f Author: Richard Henderson r...@redhat.com Date: Mon Aug 1 18:47:04 2011 -0700 reload: Work around reload inheritence deleting insns. diff --git a/gcc/reload1.c b/gcc/reload1.c index 3233580..ba6ce37 100644 --- a/gcc/reload1.c +++ b/gcc/reload1.c @@ -4548,7 +4548,7 @@ reload_as_needed (int live_known) #if defined (AUTO_INC_DEC) int i; #endif - rtx x; + rtx x, marker; memset (spill_reg_rtx, 0, sizeof spill_reg_rtx); memset (spill_reg_store, 0, sizeof spill_reg_store); @@ -4559,6 +4559,10 @@ reload_as_needed (int live_known) set_initial_elim_offsets (); + /* Generate a marker insn that we will move around. */ + marker = emit_note (NOTE_INSN_DELETED); + unlink_insn_chain (marker, marker); + for (chain = reload_insn_chain; chain; chain = chain-next) { rtx prev = 0; @@ -4631,7 +4635,10 @@ reload_as_needed (int live_known) rtx next = NEXT_INSN (insn); rtx p; + /* ??? PREV can get deleted by reload inheritance. +Work around this by emitting a marker note. */ prev = PREV_INSN (insn); + reorder_insns_nobb (marker, marker, prev); /* Now compute which reload regs to reload them into. Perhaps reusing reload regs from previous insns, or else output @@ -4649,6 +4656,9 @@ reload_as_needed (int live_known) and that we moved the structure into). */ subst_reloads (insn); + prev = PREV_INSN (marker); + unlink_insn_chain (marker, marker); + /* Adjust the exception region notes for loads and stores. */ if (cfun-can_throw_non_call_exceptions !CALL_P (insn)) fixup_eh_region_note (insn, prev, next);
Remove line 0 hack in cp/decl.c (issue4835047)
This hack, has described in more details in the email labeled Line 0 Hack??, was now causing problem when serializing the line_table in pph. According to the revision history: this was introduced by steven in 2005: commit ba821eb102fc1a654c0542fcba73898340a9a02d Author: steven steven@138bc75d-0d04-0410-961f-82ee72b054a4 Date: Sat Jan 1 16:15:23 2005 + * emit-rtl.c (add_insn_before): Fix comment typo. PR middle-end/17544 * c-decl.c (finish_function): If compiling C99, annotate the compiler generated return with the current file name and line 0. * tree-cfg.c (remove_useless_stmts_warn_notreached): Only warn if the source line is greater than 0. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@92784 138bc75d-0d04-0410-961f-82ee72b054a4 The function remove_useless_stmts_warn_notreached refered to by steven in his 2005 commit has been removed on 2009-10-08 by m...@suse.de according to ChangeLog-2009. This patch removes this hack which appears to be no longer necessary. Tested with a full bootstrap build and regression testing on x64. Gabriel 2011-08-01 Gabriel Charette gch...@google.com * decl.c (finish_function): Remove unecessary line 0 hack. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 2000bd4..9ee3c6d 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -13220,22 +13220,13 @@ finish_function (int flags) { if (DECL_MAIN_P (current_function_decl)) { - tree stmt; - /* Make it so that `main' always returns 0 by default (or 1 for VMS). */ #if VMS_TARGET - stmt = finish_return_stmt (integer_one_node); + finish_return_stmt (integer_one_node); #else - stmt = finish_return_stmt (integer_zero_node); + finish_return_stmt (integer_zero_node); #endif - /* Hack. We don't want the middle-end to warn that this -return is unreachable, so put the statement on the -special line 0. */ - { - location_t linezero = linemap_line_start (line_table, 0, 1); - SET_EXPR_LOCATION (stmt, linezero); - } } if (use_eh_spec_block (current_function_decl)) -- This patch is available for review at http://codereview.appspot.com/4835047
Re: [google][patch] Put make_heap's declaration on a single line to work around inconsistent debug locations
And reverted in r177083 because I fixed the underlying problem. On Fri, Jul 22, 2011 at 11:06 PM, Ollie Wild a...@google.com wrote: Ok for inclusion in google/gcc-4_6. Ollie On Fri, Jul 22, 2011 at 5:46 PM, Jeffrey Yasskin jyass...@google.com wrote: For the google/gcc-4_6 branch _only_. I'll fix the inconsistency in debug locations later for trunk and google/main. In some translation units the debug location of make_heap is the location of its name; in other TUs it's the location of the closing ')'. This causes false positives in gold's ODR checker. Until I can find why the locations are inconsistent, we can work around the problem by putting the name and closing ')' on the same line. libstdc++-v3/ChangeLog 2011-07-22 Jeffrey Yasskin jyass...@google.com * include/bits/stl_heap.h(make_heap): Remove a newline.
RE: [RFC] Add middle end hook for stack red zone size
Hi Jakub, Appreciate for your valuable comments! I think SPARC V9 ABI doesn't have red zone defined, right? So stack_red_zone_size should be defined as zero by default, the scheduler would block moving memory accesses across stack adjustment no matter what the offset is. I don't see any risk here. Also, in my patch function *abs* is being used to avoid the opposite stack direction issue as you mentioned. Some people like you insist on the ABI diversity, and actually I agree with you on this. But part of the ABI definition is general for all targets. The point here is memory access beyond stack red zone should be avoided, which is the general part of ABI that compiler should guarantee. For this general part, middle end should take the responsibility. Thanks, -Jiangning -Original Message- From: Jakub Jelinek [mailto:ja...@redhat.com] Sent: Monday, August 01, 2011 6:31 PM To: Jiangning Liu Cc: 'Joern Rennecke'; g...@gcc.gnu.org; gcc-patches@gcc.gnu.org; vmaka...@redhat.com; dje@gmail.com; Richard Henderson; Ramana Radhakrishnan; 'Ramana Radhakrishnan' Subject: Re: [RFC] Add middle end hook for stack red zone size On Mon, Aug 01, 2011 at 06:14:27PM +0800, Jiangning Liu wrote: ARM. You are right, they were all fixed in back-ends in the past, but we should fix the bug in a general way to make GCC infrastructure stronger, rather than fixing the problem target-by-target and case-by-case! If you further look into the back-end fixes in x86 and PowerPC, you may find they looks quite similar in back-ends. Red zone is only one difficulty, your patch is e.g. completely ignoring existence of biased stack pointers (e.g. SPARC -m64 has them). Some targets have stack growing in opposite direction, etc. We have really a huge amount of very diverse ABIs and making the middle-end grok what is an invalid stack access is difficult. Jakub
[PATCH 0/2] Fix PR47594
Hi Richi, These two patches passed regstrap on amd64-linux: Use build_zero_cst or build_one_cst. Fix PR47594: Build signed niter expressions Ok for trunk? Thanks, Sebastian
[PATCH 1/2] Use build_zero_cst or build_one_cst.
--- gcc/tree-ssa-loop-niter.c | 32 1 files changed, 16 insertions(+), 16 deletions(-) diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c index 4acfc67..2ee3f6e 100644 --- a/gcc/tree-ssa-loop-niter.c +++ b/gcc/tree-ssa-loop-niter.c @@ -101,7 +101,7 @@ split_to_var_and_offset (tree expr, tree *var, mpz_t offset) break; case INTEGER_CST: - *var = build_int_cst_type (type, 0); + *var = build_zero_cst (type); off = tree_to_double_int (expr); mpz_set_double_int (offset, off, TYPE_UNSIGNED (type)); break; @@ -522,7 +522,7 @@ inverse (tree x, tree mask) } else { - rslt = build_int_cst (type, 1); + rslt = build_one_cst (type); for (; ctr; ctr--) { rslt = int_const_binop (MULT_EXPR, rslt, x); @@ -670,7 +670,7 @@ number_of_iterations_ne (tree type, affine_iv *iv, tree final, - tree_low_cst (bits, 1))); d = fold_binary_to_constant (LSHIFT_EXPR, niter_type, - build_int_cst (niter_type, 1), bits); + build_one_cst (niter_type), bits); s = fold_binary_to_constant (RSHIFT_EXPR, niter_type, s, bits); if (!exit_must_be_taken) @@ -679,7 +679,7 @@ number_of_iterations_ne (tree type, affine_iv *iv, tree final, assumptions for divisibility of c. */ assumption = fold_build2 (FLOOR_MOD_EXPR, niter_type, c, d); assumption = fold_build2 (EQ_EXPR, boolean_type_node, - assumption, build_int_cst (niter_type, 0)); + assumption, build_zero_cst (niter_type)); if (!integer_nonzerop (assumption)) niter-assumptions = fold_build2 (TRUTH_AND_EXPR, boolean_type_node, niter-assumptions, assumption); @@ -846,7 +846,7 @@ assert_no_overflow_lt (tree type, affine_iv *iv0, affine_iv *iv1, } else diff = fold_build2 (MINUS_EXPR, niter_type, step, - build_int_cst (niter_type, 1)); + build_one_cst (niter_type)); bound = fold_build2 (MINUS_EXPR, type, TYPE_MAX_VALUE (type), fold_convert (type, diff)); assumption = fold_build2 (LE_EXPR, boolean_type_node, @@ -867,7 +867,7 @@ assert_no_overflow_lt (tree type, affine_iv *iv0, affine_iv *iv1, } else diff = fold_build2 (MINUS_EXPR, niter_type, step, - build_int_cst (niter_type, 1)); + build_one_cst (niter_type)); bound = fold_build2 (PLUS_EXPR, type, TYPE_MIN_VALUE (type), fold_convert (type, diff)); assumption = fold_build2 (GE_EXPR, boolean_type_node, @@ -963,7 +963,7 @@ assert_loop_rolls_lt (tree type, affine_iv *iv0, affine_iv *iv1, if (integer_nonzerop (iv0-step)) { diff = fold_build2 (MINUS_EXPR, type1, - iv0-step, build_int_cst (type1, 1)); + iv0-step, build_one_cst (type1)); /* We need to know that iv0-base = MIN + iv0-step - 1. Since 0 address never belongs to any object, we can assume this for @@ -985,7 +985,7 @@ assert_loop_rolls_lt (tree type, affine_iv *iv0, affine_iv *iv1, else { diff = fold_build2 (PLUS_EXPR, type1, - iv1-step, build_int_cst (type1, 1)); + iv1-step, build_one_cst (type1)); if (!POINTER_TYPE_P (type)) { @@ -1083,7 +1083,7 @@ number_of_iterations_lt (tree type, affine_iv *iv0, affine_iv *iv1, { affine_iv zps; - zps.base = build_int_cst (niter_type, 0); + zps.base = build_zero_cst (niter_type); zps.step = step; /* number_of_iterations_lt_to_ne will add assumptions that ensure that zps does not overflow. */ @@ -1102,7 +1102,7 @@ number_of_iterations_lt (tree type, affine_iv *iv0, affine_iv *iv1, assert_loop_rolls_lt (type, iv0, iv1, niter, bnds); s = fold_build2 (MINUS_EXPR, niter_type, - step, build_int_cst (niter_type, 1)); + step, build_one_cst (niter_type)); delta = fold_build2 (PLUS_EXPR, niter_type, delta, s); niter-niter = fold_build2 (FLOOR_DIV_EXPR, niter_type, delta, step); @@ -1167,13 +1167,13 @@ number_of_iterations_le (tree type, affine_iv *iv0, affine_iv *iv1, iv1-base = fold_build_pointer_plus_hwi (iv1-base, 1); else iv1-base = fold_build2 (PLUS_EXPR, type1, iv1-base, -build_int_cst (type1, 1)); +build_one_cst (type1)); } else if (POINTER_TYPE_P (type)) iv0-base = fold_build_pointer_plus_hwi (iv0-base, -1); else iv0-base = fold_build2 (MINUS_EXPR, type1, -iv0-base, build_int_cst (type1, 1)); +iv0-base, build_one_cst (type1));
[PATCH 2/2] Fix PR47594: Build signed niter expressions
2011-07-23 Sebastian Pop sebastian@amd.com PR middle-end/47594 * graphite-scop-detection.c (graphite_can_represent_scev): Return false on TYPE_UNSIGNED. * graphite-sese-to-poly.c (scan_tree_for_params_int): Do not call double_int_sext. * tree-ssa-loop-niter.c (number_of_iterations_ne): Use the signed types for the trivial case, then convert to unsigned. (number_of_iterations_lt): Use the original signed types. (number_of_iterations_cond): Same. (find_loop_niter): Build signed integer constant. (loop_niter_by_eval): Same. --- gcc/ChangeLog | 14 gcc/graphite-scop-detection.c |6 ++ gcc/graphite-sese-to-poly.c|7 +-- gcc/testsuite/ChangeLog|5 ++ .../gfortran.dg/graphite/run-id-pr47594.f90| 35 +++ gcc/tree-ssa-loop-niter.c | 63 6 files changed, 113 insertions(+), 17 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/graphite/run-id-pr47594.f90 diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 580c12f..33bd7b4 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,17 @@ +2011-07-23 Sebastian Pop sebastian@amd.com + + PR middle-end/47594 + * graphite-scop-detection.c (graphite_can_represent_scev): Return false + on TYPE_UNSIGNED. + * graphite-sese-to-poly.c (scan_tree_for_params_int): Do not call + double_int_sext. + * tree-ssa-loop-niter.c (number_of_iterations_ne): Use the signed types + for the trivial case, then convert to unsigned. + (number_of_iterations_lt): Use the original signed types. + (number_of_iterations_cond): Same. + (find_loop_niter): Build signed integer constant. + (loop_niter_by_eval): Same. + 2011-08-01 Richard Henderson r...@redhat.com PR target/49881 diff --git a/gcc/graphite-scop-detection.c b/gcc/graphite-scop-detection.c index 3460568..403ff23 100644 --- a/gcc/graphite-scop-detection.c +++ b/gcc/graphite-scop-detection.c @@ -196,6 +196,12 @@ graphite_can_represent_scev (tree scev) if (chrec_contains_undetermined (scev)) return false; + /* FIXME: As long as Graphite cannot handle wrap around effects of + induction variables, we discard them. */ + if (TYPE_UNSIGNED (TREE_TYPE (scev)) + !POINTER_TYPE_P (TREE_TYPE (scev))) +return false; + switch (TREE_CODE (scev)) { case PLUS_EXPR: diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c index 7e23c9d..d15f0b3 100644 --- a/gcc/graphite-sese-to-poly.c +++ b/gcc/graphite-sese-to-poly.c @@ -647,14 +647,9 @@ scan_tree_for_params_int (tree cst, ppl_Linear_Expression_t expr, mpz_t k) { mpz_t val; ppl_Coefficient_t coef; - tree type = TREE_TYPE (cst); mpz_init (val); - - /* Necessary to not get -1 = 2^n - 1. */ - mpz_set_double_int (val, double_int_sext (tree_to_double_int (cst), - TYPE_PRECISION (type)), false); - + tree_int_to_gmp (cst, val); mpz_mul (val, val, k); ppl_new_Coefficient (coef); ppl_assign_Coefficient_from_mpz_t (coef, val); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4ff8a10..1f8d049 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-07-23 Sebastian Pop sebastian@amd.com + + PR middle-end/47594 + * gfortran.dg/graphite/run-id-pr47594.f90: New. + 2011-08-01 Jason Merrill ja...@redhat.com PR c++/49932 diff --git a/gcc/testsuite/gfortran.dg/graphite/run-id-pr47594.f90 b/gcc/testsuite/gfortran.dg/graphite/run-id-pr47594.f90 new file mode 100644 index 000..7f36fc6 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/graphite/run-id-pr47594.f90 @@ -0,0 +1,35 @@ +! { dg-options -O2 -fgraphite-identity } + +Subroutine foo (N, M) +Integer N +Integer M +integer A(8,16) +integer B(8) + +B = (/ 2, 3, 5, 7, 11, 13, 17, 23 /) + +do I = 1, N + do J = I, M +A(J,2) = B(J) + end do +end do + +do I = 1, N + do J = I, M +if (A(J,2) /= B(J)) then + call abort () + endif + end do +end do + +Return +end + + +program main + +Call foo (16, 8) + +stop +end + diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c index 2ee3f6e..3bd9511 100644 --- a/gcc/tree-ssa-loop-niter.c +++ b/gcc/tree-ssa-loop-niter.c @@ -618,7 +618,7 @@ number_of_iterations_ne (tree type, affine_iv *iv, tree final, struct tree_niter_desc *niter, bool exit_must_be_taken, bounds *bnds) { - tree niter_type = unsigned_type_for (type); + tree niter_type = POINTER_TYPE_P (type) ? unsigned_type_for (type) : type; tree
[RS6000] Fix ICE in reg_save
Seen when running binutils testsuite on powerpc-linux. .../ld-elfvers/vers24b.c: In function 'foo': .../ld-elfvers/vers24b.c:5:1: internal compiler error: in reg_save, at dwarf2cfi.c:827 Bootstrapped and regression tested powerpc-linux. Committed as obvious. * config/rs6000/rs6000.c (rs6000_emit_prologue): Add REG_CFA_RESTORE note for save_LR_around_toc_setup sequence. Index: gcc/config/rs6000/rs6000.c === --- gcc/config/rs6000/rs6000.c (revision 177041) +++ gcc/config/rs6000/rs6000.c (working copy) @@ -20505,6 +20505,7 @@ rs6000_emit_prologue (void) rs6000_emit_load_toc_table (TRUE); insn = emit_move_insn (lr, frame_ptr_rtx); + add_reg_note (insn, REG_CFA_RESTORE, lr); RTX_FRAME_RELATED_P (insn) = 1; } else -- Alan Modra Australia Development Lab, IBM