[gcc r16-1342] powerpc: testsuite: Fix powerpc FMV symbol tests [PR 120519]
https://gcc.gnu.org/g:ef938108b8d141a251783cbf123248f30319d211 commit r16-1342-gef938108b8d141a251783cbf123248f30319d211 Author: Alfie Richards Date: Wed Jun 4 15:24:36 2025 + powerpc: testsuite: Fix powerpc FMV symbol tests [PR 120519] As discussed on the BZ page, this removes the overly specific resolver tests which proved overly specific, and modifies the jump instructions. gcc/testsuite/ChangeLog: PR testsuite/120519 * g++.target/powerpc/mvc-symbols1.C: Modify tests. * g++.target/powerpc/mvc-symbols2.C: Ditto. * g++.target/powerpc/mvc-symbols3.C: Ditto. * g++.target/powerpc/mvc-symbols4.C: Ditto. Diff: --- gcc/testsuite/g++.target/powerpc/mvc-symbols1.C | 10 ++ gcc/testsuite/g++.target/powerpc/mvc-symbols2.C | 6 -- gcc/testsuite/g++.target/powerpc/mvc-symbols3.C | 10 ++ gcc/testsuite/g++.target/powerpc/mvc-symbols4.C | 6 -- 4 files changed, 4 insertions(+), 28 deletions(-) diff --git a/gcc/testsuite/g++.target/powerpc/mvc-symbols1.C b/gcc/testsuite/g++.target/powerpc/mvc-symbols1.C index 9424382bf141..ba5492ab451a 100644 --- a/gcc/testsuite/g++.target/powerpc/mvc-symbols1.C +++ b/gcc/testsuite/g++.target/powerpc/mvc-symbols1.C @@ -28,20 +28,14 @@ int bar(int x) /* { dg-final { scan-assembler-times "\n_Z3foov\.cpu_power6:\n" 1 } } */ /* { dg-final { scan-assembler-times "\n_Z3foov\.cpu_power6x:\n" 1 } } */ /* { dg-final { scan-assembler-times "\n_Z3foov\.resolver:\n" 1 } } */ -/* { dg-final { scan-assembler-times "\n\tbl _Z3foov\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n\tbl _Z3foov(\n|@)" 1 } } */ /* { dg-final { scan-assembler-times "\n\t\.type\t_Z3foov, @gnu_indirect_function\n" 1 } } */ /* { dg-final { scan-assembler-times "\n\t\.set\t_Z3foov,_Z3foov\.resolver\n" 1 } } */ -/* { dg-final { scan-assembler-times "\n\t\.quad\t_Z3foov\.default\n" 1 } } */ -/* { dg-final { scan-assembler-times "\n\t\.quad\t_Z3foov\.cpu_power6\n" 1 } } */ -/* { dg-final { scan-assembler-times "\n\t\.quad\t_Z3foov\.cpu_power6x\n" 0 } } */ /* { dg-final { scan-assembler-times "\n_Z3fooi\.default:\n" 1 } } */ /* { dg-final { scan-assembler-times "\n_Z3fooi\.cpu_power6:\n" 1 } } */ /* { dg-final { scan-assembler-times "\n_Z3fooi\.cpu_power6x:\n" 1 } } */ /* { dg-final { scan-assembler-times "\n_Z3fooi\.resolver:\n" 1 } } */ -/* { dg-final { scan-assembler-times "\n\tbl _Z3fooi\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n\tbl _Z3fooi(\n|@)" 1 } } */ /* { dg-final { scan-assembler-times "\n\t\.type\t_Z3fooi, @gnu_indirect_function\n" 1 } } */ /* { dg-final { scan-assembler-times "\n\t\.set\t_Z3fooi,_Z3fooi\.resolver\n" 1 } } */ -/* { dg-final { scan-assembler-times "\n\t\.quad\t_Z3fooi\.default\n" 1 } } */ -/* { dg-final { scan-assembler-times "\n\t\.quad\t_Z3fooi\.cpu_power6\n" 0 } } */ -/* { dg-final { scan-assembler-times "\n\t\.quad\t_Z3fooi\.cpu_power6x\n" 1 } } */ diff --git a/gcc/testsuite/g++.target/powerpc/mvc-symbols2.C b/gcc/testsuite/g++.target/powerpc/mvc-symbols2.C index edf54480efd1..fe96dc4a7a35 100644 --- a/gcc/testsuite/g++.target/powerpc/mvc-symbols2.C +++ b/gcc/testsuite/g++.target/powerpc/mvc-symbols2.C @@ -20,9 +20,6 @@ int foo (int) /* { dg-final { scan-assembler-times "\n_Z3foov\.resolver:\n" 1 } } */ /* { dg-final { scan-assembler-times "\n\t\.type\t_Z3foov, @gnu_indirect_function\n" 1 } } */ /* { dg-final { scan-assembler-times "\n\t\.set\t_Z3foov,_Z3foov\.resolver\n" 1 } } */ -/* { dg-final { scan-assembler-times "\n\t\.quad\t_Z3foov\.default\n" 1 } } */ -/* { dg-final { scan-assembler-times "\n\t\.quad\t_Z3foov\.cpu_power6\n" 1 } } */ -/* { dg-final { scan-assembler-times "\n\t\.quad\t_Z3foov\.cpu_power6x\n" 0 } } */ /* { dg-final { scan-assembler-times "\n_Z3fooi\.default:\n" 1 } } */ /* { dg-final { scan-assembler-times "\n_Z3fooi\.cpu_power6:\n" 1 } } */ @@ -30,6 +27,3 @@ int foo (int) /* { dg-final { scan-assembler-times "\n_Z3fooi\.resolver:\n" 1 } } */ /* { dg-final { scan-assembler-times "\n\t\.type\t_Z3fooi, @gnu_indirect_function\n" 1 } } */ /* { dg-final { scan-assembler-times "\n\t\.set\t_Z3fooi,_Z3fooi\.resolver\n" 1 } } */ -/* { dg-final { scan-assembler-times "\n\t\.quad\t_Z3fooi\.default\n" 1 } } */ -/* { dg-final { scan-assembler-times "\n\t\.quad\t_Z3fooi\.cpu_power6\n" 0 } } */ -/* { dg-final { scan-assembler-times "\n\t\.quad\t_Z3fooi\.cpu_power6x\n" 1 } } */ diff --git a/gcc/testsuite/g++.target/powerpc/mvc-symbols3.C b/gcc/testsuite/g++.target/powerpc/mvc-symbols3.C index ca79c7f979ce..c44acafb8e3f 100644 --- a/gcc/testsuite/g++.target/powerpc/mvc-symbols3.C +++ b/gcc/testsuite/g++.target/powerpc/mvc-symbols3.C @@ -22,20 +22,14 @@ int bar(int x) /* { dg-final { scan-assembler-times "\n_Z3foov\.cpu_power6:\n" 0 } } */ /* { dg-final { scan-assembler-times "\n_Z3foov\.cpu_power6x:\n" 0 } } */ /* { dg-final { scan-assembler-times "\n_Z3foov\.resolver:\n" 1 } } */ -/* { dg-final { scan-assem
[gcc r15-9800] ada: Fix spurious error on anonymous array initialized by conditional expression
https://gcc.gnu.org/g:823e9733520536cf1fc427d6a128f5a7a48cc3b5 commit r15-9800-g823e9733520536cf1fc427d6a128f5a7a48cc3b5 Author: Eric Botcazou Date: Thu Feb 27 20:43:04 2025 +0100 ada: Fix spurious error on anonymous array initialized by conditional expression Even though the actual subtype of the anonymous array is not yet set on the object itself by the time Insert_Conditional_Object_Declaration is called, it is set on its initialization expression, so it can simply be forwarded to Insert_Conditional_Object_Declaration from there, which avoids creating a new one for each new object and triggering a subtype mismatch later. gcc/ada/ChangeLog: * exp_ch4.adb (Insert_Conditional_Object_Declaration): Remove Decl formal parameter, add Typ and Const formal parameters. (Expand_N_Case_Expression): Fix pasto in comment. Adjust call to Insert_Conditional_Object_Declaration and tidy up surrounding code. (Expand_N_If_Expression): Adjust couple of calls to Insert_Conditional_Object_Declaration. Diff: --- gcc/ada/exp_ch4.adb | 43 +-- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb index 793e468a0a3c..161bcee073a0 100644 --- a/gcc/ada/exp_ch4.adb +++ b/gcc/ada/exp_ch4.adb @@ -193,12 +193,12 @@ package body Exp_Ch4 is procedure Insert_Conditional_Object_Declaration (Obj_Id : Entity_Id; + Typ: Entity_Id; Expr : Node_Id; - Decl : Node_Id); - -- Expr is the dependent expression of a conditional expression and Decl - -- is the declaration of an object whose initialization expression is the - -- conditional expression. Insert in the actions of Expr the declaration - -- of Obj_Id modeled on Decl and with Expr as initialization expression. + Const : Boolean); + -- Expr is the dependent expression of a conditional expression. Insert in + -- the actions of Expr the declaration of Obj_Id with type Typ and Expr as + -- initialization expression. Const is True when Obj_Id is a constant. procedure Insert_Dereference_Action (N : Node_Id); -- N is an expression whose type is an access. When the type of the @@ -5304,7 +5304,7 @@ package body Exp_Ch4 is -- 'Unrestricted_Access. -- Generate: - --type Ptr_Typ is not null access all [constant] Typ; + --type Target_Typ is not null access all [constant] Typ; else Target_Typ := Make_Temporary (Loc, 'P'); @@ -5402,20 +5402,16 @@ package body Exp_Ch4 is elsif Optimize_Object_Decl then Obj := Make_Temporary (Loc, 'C', Alt_Expr); - Insert_Conditional_Object_Declaration (Obj, Alt_Expr, Par); - - Alt_Expr := - Make_Attribute_Reference (Alt_Loc, - Prefix => New_Occurrence_Of (Obj, Alt_Loc), - Attribute_Name => Name_Unrestricted_Access); - - LHS := New_Occurrence_Of (Target, Loc); - Set_Assignment_OK (LHS); + Insert_Conditional_Object_Declaration + (Obj, Typ, Alt_Expr, Const => Constant_Present (Par)); Stmts := New_List ( Make_Assignment_Statement (Alt_Loc, - Name => LHS, - Expression => Alt_Expr)); + Name => New_Occurrence_Of (Target, Loc), + Expression => + Make_Attribute_Reference (Alt_Loc, + Prefix => New_Occurrence_Of (Obj, Alt_Loc), + Attribute_Name => Name_Unrestricted_Access))); -- Take the unrestricted access of the expression value for non- -- scalar types. This approach avoids big copies and covers the @@ -6013,8 +6009,10 @@ package body Exp_Ch4 is Target : constant Entity_Id := Make_Temporary (Loc, 'C', N); begin -Insert_Conditional_Object_Declaration (Then_Obj, Thenx, Par); -Insert_Conditional_Object_Declaration (Else_Obj, Elsex, Par); +Insert_Conditional_Object_Declaration + (Then_Obj, Typ, Thenx, Const => Constant_Present (Par)); +Insert_Conditional_Object_Declaration + (Else_Obj, Typ, Elsex, Const => Constant_Present (Par)); -- Generate: --type Ptr_Typ is not null access all [constant] Typ; @@ -13285,16 +13283,17 @@ package body Exp_Ch4 is procedure Insert_Conditional_Object_Declaration (Obj_Id : Entity_Id; + Typ: Entity_Id; Expr : Node_Id; - Decl : Node_Id) + Const : Boolean) is Loc : constant Source_Ptr := Sloc (Expr); Obj_Decl : constant Node_Id := Make_Object_Declaration (Loc, Defining_Identifier => Obj_Id, Aliased_Pre
[gcc r15-9801] ada: Incorrect creation of corresponding expression of class-wide contracts
https://gcc.gnu.org/g:8a63f6bd618decc974a46c50894f3b450e025f95 commit r15-9801-g8a63f6bd618decc974a46c50894f3b450e025f95 Author: Gary Dismukes Date: Fri Feb 28 00:08:19 2025 + ada: Incorrect creation of corresponding expression of class-wide contracts GNAT was incorrectly implementing the Ada rules for resolving calls to primitive functions within inherited class-wide pre- and postconditions, as specified in RM22 6.1.1 (relating to AI12-0113). Only function calls that involve formals of the associated primitive subprogram should be treated using the "(notional) formal derived type" rules. In particular, calls that are tag-indeterminate (for example, "F(G)") should not be mapped to call the corresponding primitives of the derived type (they should still call the primitives of the ancestor type). The fix for this involves a new predicate function that recursively traverses calls to determine the calls that satisfy the criteria for mapping. These changes also completely remove the mapping of formals that was done in Contracts.Merge_Class_Conditions (in Inherit_Condition), since the mapping will be done later anyway by Build_Class_Wide_Expression, and the earlier mapping interferes with that. Note: The utility function Sem_Util.Check_Parents is no longer called after removal of the single call to it from contracts.adb, but it's being retained (along with the generic subprograms in Atree that it depends on) for possible use in VAST. gcc/ada/ChangeLog: * contracts.adb (Inherit_Condition): Remove Assoc_List and its uses along with function Check_Condition, since mapping of formals will effectively be done in Build_Class_Wide_Expression (by Replace_Entity). * exp_util.adb (Replace_Entity): Only rewrite entity references in function calls that qualify according to the result of calling the new function Call_To_Parent_Dispatching_Op_Must_Be_Mapped. (Call_To_Parent_Dispatching_Op_Must_Be_Mapped): New function that determines whether a function call to a primitive of Par_Subp associated tagged type needs to be mapped (according to whether it has any actuals that reference controlling formals of the primitive). Diff: --- gcc/ada/contracts.adb | 103 - gcc/ada/exp_util.adb | 113 +- 2 files changed, 121 insertions(+), 95 deletions(-) diff --git a/gcc/ada/contracts.adb b/gcc/ada/contracts.adb index 8b94a67639f2..e0eb26ec971e 100644 --- a/gcc/ada/contracts.adb +++ b/gcc/ada/contracts.adb @@ -4389,10 +4389,10 @@ package body Contracts is Seen: Subprogram_List (Subps'Range) := (others => Empty); function Inherit_Condition - (Par_Subp : Entity_Id; -Subp : Entity_Id) return Node_Id; - -- Inherit the class-wide condition from Par_Subp to Subp and adjust - -- all the references to formals in the inherited condition. + (Par_Subp : Entity_Id) return Node_Id; + -- Inherit the class-wide condition from Par_Subp. Simply makes + -- a copy of the condition in preparation for later mapping of + -- referenced formals and functions by Build_Class_Wide_Expression. procedure Merge_Conditions (From : Node_Id; Into : Node_Id); -- Merge two class-wide preconditions or postconditions (the former @@ -4407,92 +4407,11 @@ package body Contracts is --- function Inherit_Condition - (Par_Subp : Entity_Id; -Subp : Entity_Id) return Node_Id - is -function Check_Condition (Expr : Node_Id) return Boolean; --- Used in assertion to check that Expr has no reference to the --- formals of Par_Subp. - -- --- Check_Condition -- -- - -function Check_Condition (Expr : Node_Id) return Boolean is - Par_Formal_Id : Entity_Id; - - function Check_Entity (N : Node_Id) return Traverse_Result; - -- Check occurrence of Par_Formal_Id - - -- - -- Check_Entity -- - -- - - function Check_Entity (N : Node_Id) return Traverse_Result is - begin - if Nkind (N) = N_Identifier -and then Present (Entity (N)) -and then Entity (N) = Par_Formal_Id - then - return Abandon; - end if; - - return OK; - end Check_Entity; - - function Check_Expression is new Traverse_Func (Check_Entity); - --- Start of processing for Check_Co
[gcc r15-9806] ada: Support fixed-lower-bound array types as generic actual parameters
https://gcc.gnu.org/g:d96603a48d338a92b78628016d00cbf11576621e commit r15-9806-gd96603a48d338a92b78628016d00cbf11576621e Author: Gary Dismukes Date: Mon Mar 17 18:30:00 2025 + ada: Support fixed-lower-bound array types as generic actual parameters Attempting to use a fixed-lower-bound array type (or subtype) as an actual parameter for a formal unconstrained array type was being rejected by the compiler (complaining about the index type of the actual not matching the index type of the formal type). The compiler was improperly testing the actual's FLB range and finding that it didn't statically match the index type of the formal array type; it should instead test the underlying index type of the FLB type or subtype. gcc/ada/ChangeLog: * sem_ch3.adb (Constrain_Index): In the case of a fixed-lower-bound index, set Etype of the newly created itype's Scalar_Range from the index's Etype. * sem_ch12.adb (Validate_Array_Type_Instance): If the actual subtype is a fixed-lower-bound type, then check again the Etype of its Scalar_Range. Diff: --- gcc/ada/sem_ch12.adb | 10 ++ gcc/ada/sem_ch3.adb | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb index 5768e28e90fc..d93788b779e9 100644 --- a/gcc/ada/sem_ch12.adb +++ b/gcc/ada/sem_ch12.adb @@ -14132,6 +14132,16 @@ package body Sem_Ch12 is T2 := Etype (I2); end if; +-- In the case of a fixed-lower-bound subtype, we want to check +-- against the index type's range rather than the range of the +-- subtype (which will be seen as unconstrained, and whose bounds +-- won't generally match those of the formal unconstrained array +-- type's corresponding index type). + +if Is_Fixed_Lower_Bound_Index_Subtype (T2) then + T2 := Etype (Scalar_Range (T2)); +end if; + if not Subtypes_Match (Find_Actual_Type (Etype (I1), A_Gen_T), T2) then diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index 4b5c5b1a41ee..9a25ff7b6405 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -15092,7 +15092,8 @@ package body Sem_Ch3 is -- If this is a range for a fixed-lower-bound subtype, then set the -- index itype's low bound to the FLB and the index itype's upper bound -- to the high bound of the parent array type's index subtype. Also, - -- mark the itype as an FLB index subtype. + -- set the Etype of the new scalar range and mark the itype as an FLB + -- index subtype. if Nkind (S) = N_Range and then Is_FLB_Index then Set_Scalar_Range @@ -15100,6 +15101,7 @@ package body Sem_Ch3 is Make_Range (Sloc (S), Low_Bound => Low_Bound (S), High_Bound => Type_High_Bound (T))); + Set_Etype (Scalar_Range (Def_Id), Etype (Index)); Set_Is_Fixed_Lower_Bound_Index_Subtype (Def_Id); else
[gcc r15-9805] ada: Reject component-related aspects on formal non-array types
https://gcc.gnu.org/g:6cc5c01aa77a1f01057a963cc5061bad4b0cc270 commit r15-9805-g6cc5c01aa77a1f01057a963cc5061bad4b0cc270 Author: Piotr Trojanek Date: Mon Mar 17 13:20:53 2025 +0100 ada: Reject component-related aspects on formal non-array types In Ada 2022 aspects Atomic_Components and Volatile_Components can be specified for a formal array type, but they were wrongly accepted on any formal type. Also, we don't need to check if the corresponding pragmas appear in Ada 2022 mode, because generic formal parameters can't have explicit representation pragmas in any Ada version and can only have aspects since Ada 2022. gcc/ada/ChangeLog: * sem_prag.adb (Analyze_Pragma): Fix conditions for legality checks on formal type declarations. Diff: --- gcc/ada/sem_prag.adb | 11 --- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index 17805c96fed3..19e72ab6f38f 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -14696,21 +14696,18 @@ package body Sem_Prag is D := Declaration_Node (E); -if (Nkind (D) = N_Full_Type_Declaration and then Is_Array_Type (E)) +if (Nkind (D) in N_Full_Type_Declaration + | N_Formal_Type_Declaration + and then Is_Array_Type (E)) or else (Nkind (D) = N_Object_Declaration and then Ekind (E) in E_Constant | E_Variable and then Nkind (Object_Definition (D)) = N_Constrained_Array_Definition) - or else - (Ada_Version >= Ada_2022 - and then Nkind (D) = N_Formal_Type_Declaration) then -- The flag is set on the base type, or on the object - if Nkind (D) in N_Full_Type_Declaration - | N_Formal_Type_Declaration - then + if Is_Array_Type (E) then E := Base_Type (E); end if;
[gcc r15-9804] ada: Fix glitch in handling of Atomic_Components on generic formal type
https://gcc.gnu.org/g:2fd267be72dfb0dbaa422c21888a40e69173defa commit r15-9804-g2fd267be72dfb0dbaa422c21888a40e69173defa Author: Piotr Trojanek Date: Mon Mar 17 12:57:26 2025 +0100 ada: Fix glitch in handling of Atomic_Components on generic formal type In Ada 2022 aspects Atomic_Components and Volatile_Components can be specified for a formal array type, but then they need to be set on the base type entity. Otherwise we get an assertion failure in debug build and wrong legality errors in production builds. gcc/ada/ChangeLog: * sem_prag.adb (Analyze_Pragma): If pragmas apply to a formal array type, then set the flags on the base type. Diff: --- gcc/ada/sem_prag.adb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index 621edc7725d8..17805c96fed3 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -14708,7 +14708,9 @@ package body Sem_Prag is then -- The flag is set on the base type, or on the object - if Nkind (D) = N_Full_Type_Declaration then + if Nkind (D) in N_Full_Type_Declaration + | N_Formal_Type_Declaration + then E := Base_Type (E); end if;
[gcc r15-9803] ada: Missing discriminant check on assignment of Bounded_Vector aggregate
https://gcc.gnu.org/g:f59c4d4a6a30c655afb53236eee2bda9e2d2cbb2 commit r15-9803-gf59c4d4a6a30c655afb53236eee2bda9e2d2cbb2 Author: Gary Dismukes Date: Sat Mar 8 01:05:35 2025 + ada: Missing discriminant check on assignment of Bounded_Vector aggregate When a container aggregate for a Bounded_Vector type involves an iterated association that is assigned to a vector object whose capacity (as defined by the Capacity discriminant) is less than the number of elements of the aggregate, Constraint_Error should be raised due to failing a discriminant check on the assignment. But the compiler fails to do proper expansion, plus omits the check, and instead creates a temporary whose capacity is bounded by that of the target vector of the assignment. It attempts to assign all elements of the aggregate to the temporary, resulting in a failure on a call to the Replace_Element operation that assigns past the length of the temporary vector (which can result in a Storage_Error due to a segment violation). This is fixed by ensuring that the temporary object is declared with an unconstrained base subtype rather than the assignment target's constrained subtype. gcc/ada/ChangeLog: * exp_aggr.adb (Expand_Container_Aggregate): Use the Base_Type of the subtype provided by the context as the subtype of the temporary object initialized by the aggregate. Diff: --- gcc/ada/exp_aggr.adb | 11 ++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb index 8f1869cc7091..f4674f565e65 100644 --- a/gcc/ada/exp_aggr.adb +++ b/gcc/ada/exp_aggr.adb @@ -7496,10 +7496,19 @@ package body Exp_Aggr is Set_Assignment_OK (Lhs); Aggr_Code := Build_Container_Aggr_Code (N, Typ, Lhs, Init); + + -- Use the unconstrained base subtype of the subtype provided by + -- the context for declaring the temporary object (which may come + -- from a constrained assignment target), to ensure that the + -- aggregate can be successfully expanded and assigned to the + -- temporary without exceeding its capacity. (Later assignment + -- of the temporary to a target object may result in failing + -- a discriminant check.) + Prepend_To (Aggr_Code, Make_Object_Declaration (Loc, Defining_Identifier => Obj_Id, - Object_Definition => New_Occurrence_Of (Typ, Loc), + Object_Definition => New_Occurrence_Of (Base_Type (Typ), Loc), Expression => Init)); Insert_Actions (N, Aggr_Code);
[gcc r15-9802] ada: Check validity using signedness from the type and not its base type
https://gcc.gnu.org/g:e68026cd01d87a89d52c74238d4c1bff8764f9fc commit r15-9802-ge68026cd01d87a89d52c74238d4c1bff8764f9fc Author: Piotr Trojanek Date: Tue Mar 4 12:33:34 2025 +0100 ada: Check validity using signedness from the type and not its base type When attribute Valid is applied to a private type, we used the signedness of its implementation base type which wrongly included negative values. gcc/ada/ChangeLog: * exp_attr.adb (Expand_N_Attribute_Reference): When expanding attribute Valid, use signedness from the validated view, not from its base type. Diff: --- gcc/ada/exp_attr.adb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/gcc/ada/exp_attr.adb b/gcc/ada/exp_attr.adb index 455cc226bbfb..18179d3a4e97 100644 --- a/gcc/ada/exp_attr.adb +++ b/gcc/ada/exp_attr.adb @@ -7872,9 +7872,8 @@ package body Exp_Attr is else declare Uns : constant Boolean := -Is_Unsigned_Type (Ptyp) - or else (Is_Private_Type (Ptyp) -and then Is_Unsigned_Type (PBtyp)); + Is_Unsigned_Type (Validated_View (Ptyp)); + Size : Uint; P: Node_Id := Pref;
[gcc r16-1343] [RISC-V] Enable more if-conversion on RISC-V
https://gcc.gnu.org/g:af3de9e20968c8fb0f5b950e4b0753a28a1d1dc3 commit r16-1343-gaf3de9e20968c8fb0f5b950e4b0753a28a1d1dc3 Author: Jeff Law Date: Mon Jun 9 06:55:21 2025 -0600 [RISC-V] Enable more if-conversion on RISC-V Another czero related adjustment. This time in costing of conditional move sequences. Essentially a copy from a promoted subreg can and should be ignored from a costing standpoint. We had some code to do this, but its conditions were too strict. No real surprises evaluating spec. This should be a minor, but probably not measurable improvement in x264 and xz. It is if-converting more in some particular harm to hot routines, but not necessarily in the hot parts of those routines. It's been tested on riscv32-elf and riscv64-elf. Versions of this have bootstrapped and regression tested as well, though perhaps not this exact version. Waiting on pre-commit testing. gcc/ * config/riscv/riscv.cc (riscv_noce_conversion_profitable_p): Relax condition for adjustments due to copies from promoted SUBREGs. Diff: --- gcc/config/riscv/riscv.cc | 12 +--- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index f98072cca7ce..14ac2f3cdbc1 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -4609,16 +4609,14 @@ riscv_noce_conversion_profitable_p (rtx_insn *seq, rtx dest = SET_DEST (x); - /* Do something similar for the moves that are likely to + /* Do something similar for the moves that are likely to turn into NOP moves by the time the register allocator is -done. These are also side effects of how our sCC expanders -work. We'll want to check and update LAST_DEST here too. */ - if (last_dest - && REG_P (dest) +done. We don't require src to be something set in this +sequence, just a promoted SUBREG. */ + if (REG_P (dest) && GET_MODE (dest) == SImode && SUBREG_P (src) - && SUBREG_PROMOTED_VAR_P (src) - && REGNO (SUBREG_REG (src)) == REGNO (last_dest)) + && SUBREG_PROMOTED_VAR_P (src)) { riscv_if_info.original_cost += COSTS_N_INSNS (1); riscv_if_info.max_seq_cost += COSTS_N_INSNS (1);
[gcc r15-9807] c++: constexpr prvalues vs genericize [PR120502]
https://gcc.gnu.org/g:4e4684ca6a79b22fe91acaa81af2d4a00d6e1345 commit r15-9807-g4e4684ca6a79b22fe91acaa81af2d4a00d6e1345 Author: Jason Merrill Date: Wed Jun 4 13:31:02 2025 -0400 c++: constexpr prvalues vs genericize [PR120502] Here constexpr evaluation was getting confused by the result of split_nonconstant_init, which leaves an INIT_EXPR from an empty CONSTRUCTOR to be followed by member initialization. As a result CONSTRUCTOR_NO_CLEARING was set for the time_zone, and cxx_eval_store_expression didn't set it again for the initial clobber in the basic_string constructor, so when cxx_fold_indirect_ref wants to check whether the anonymous union active member had type non_trivial_if, we see that we don't currently have a value for the anonymous union, try to add one, and fail. So let's do constexpr evaluation before split_nonconstant_init. PR c++/120502 gcc/cp/ChangeLog: * cp-gimplify.cc (cp_fold_r) [TARGET_EXPR]: Do constexpr evaluation before genericize. * constexpr.cc (cxx_eval_store_expression): Add comment. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/constexpr-prvalue2.C: New test. Diff: --- gcc/cp/constexpr.cc | 3 ++- gcc/cp/cp-gimplify.cc | 21 gcc/testsuite/g++.dg/cpp2a/constexpr-prvalue2.C | 26 + 3 files changed, 41 insertions(+), 9 deletions(-) diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc index d647a09269d3..1ed3aba0b0f8 100644 --- a/gcc/cp/constexpr.cc +++ b/gcc/cp/constexpr.cc @@ -6421,7 +6421,8 @@ cxx_eval_store_expression (const constexpr_ctx *ctx, tree t, if (TREE_CLOBBER_P (init) && CLOBBER_KIND (init) < CLOBBER_OBJECT_END) -/* Only handle clobbers ending the lifetime of objects. */ +/* Only handle clobbers ending the lifetime of objects. + ??? We should probably set CONSTRUCTOR_NO_CLEARING. */ return void_node; /* First we figure out where we're storing to. */ diff --git a/gcc/cp/cp-gimplify.cc b/gcc/cp/cp-gimplify.cc index d2423fd1848a..5363ec83ff41 100644 --- a/gcc/cp/cp-gimplify.cc +++ b/gcc/cp/cp-gimplify.cc @@ -1473,6 +1473,19 @@ cp_fold_r (tree *stmt_p, int *walk_subtrees, void *data_) break; case TARGET_EXPR: + if (!flag_no_inline) + if (tree &init = TARGET_EXPR_INITIAL (stmt)) + { + tree folded = maybe_constant_init (init, TARGET_EXPR_SLOT (stmt), + (data->flags & ff_mce_false + ? mce_false : mce_unknown)); + if (folded != init && TREE_CONSTANT (folded)) + init = folded; + } + + /* This needs to happen between the constexpr evaluation (which wants +pre-generic trees) and fold (which wants the cp_genericize_init +transformations). */ if (data->flags & ff_genericize) cp_genericize_target_expr (stmt_p); @@ -1481,14 +1494,6 @@ cp_fold_r (tree *stmt_p, int *walk_subtrees, void *data_) cp_walk_tree (&init, cp_fold_r, data, NULL); cp_walk_tree (&TARGET_EXPR_CLEANUP (stmt), cp_fold_r, data, NULL); *walk_subtrees = 0; - if (!flag_no_inline) - { - tree folded = maybe_constant_init (init, TARGET_EXPR_SLOT (stmt), -(data->flags & ff_mce_false - ? mce_false : mce_unknown)); - if (folded != init && TREE_CONSTANT (folded)) - init = folded; - } /* Folding might replace e.g. a COND_EXPR with a TARGET_EXPR; in that case, strip it in favor of this one. */ if (TREE_CODE (init) == TARGET_EXPR) diff --git a/gcc/testsuite/g++.dg/cpp2a/constexpr-prvalue2.C b/gcc/testsuite/g++.dg/cpp2a/constexpr-prvalue2.C new file mode 100644 index ..c2dc7cd49456 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/constexpr-prvalue2.C @@ -0,0 +1,26 @@ +// PR c++/120502 +// { dg-do compile { target c++20 } } +// { dg-additional-options -O } + +struct non_trivial_if { + constexpr non_trivial_if() {} +}; +struct allocator : non_trivial_if {}; +struct padding {}; +struct __short { + [[no_unique_address]] padding p; +}; +struct basic_string { + union { +__short s; +int l; + }; + [[no_unique_address]] allocator a; + constexpr basic_string() {} + ~basic_string() {} +}; +struct time_zone { + basic_string __abbrev; + long __offset; +}; +time_zone convert_to_time_zone() { return {}; }
[gcc r15-9808] c++: recursive template with deduced return [PR120555]
https://gcc.gnu.org/g:e4940c042b753457748e2257a8b13ca3738b4fac commit r15-9808-ge4940c042b753457748e2257a8b13ca3738b4fac Author: Jason Merrill Date: Fri Jun 6 10:26:28 2025 -0400 c++: recursive template with deduced return [PR120555] Here since r15-4120 we were prematurely complaining about the use of func within its own definiton, which is fine at instantiation time. So don't require this for function templates that are currently being defined. But keep the error for instantiations of templates that are not currently being defined, which we similarly did not diagnose before r15-4120 but other implementations do. Both of these follow the general principle from [temp.res.general]/6 that we only error in a template body if no instatiation could be well-formed. Also remove a redundant call to require_deduced_type. PR c++/120555 gcc/cp/ChangeLog: * decl2.cc (fn_being_defined, fn_template_being_defined): New. (mark_used): Check fn_template_being_defined. gcc/testsuite/ChangeLog: * g++.dg/cpp1z/constexpr-if39.C: New test. (cherry picked from commit 8d204f2a536f7253e4251aca7bc12af524800b4c) Diff: --- gcc/cp/decl2.cc | 33 ++--- gcc/testsuite/g++.dg/cpp1z/constexpr-if39.C | 30 ++ 2 files changed, 60 insertions(+), 3 deletions(-) diff --git a/gcc/cp/decl2.cc b/gcc/cp/decl2.cc index bceaf78b8c45..63a5a21511df 100644 --- a/gcc/cp/decl2.cc +++ b/gcc/cp/decl2.cc @@ -6267,6 +6267,33 @@ mark_single_function (tree expr, tsubst_flags_t complain) return true; } +/* True iff we have started, but not finished, defining FUNCTION_DECL DECL. */ + +bool +fn_being_defined (tree decl) +{ + /* DECL_INITIAL is set to error_mark_node in grokfndecl for a definition, and + changed to BLOCK by poplevel at the end of the function. */ + return (TREE_CODE (decl) == FUNCTION_DECL + && DECL_INITIAL (decl) == error_mark_node); +} + +/* True if DECL is an instantiation of a function template currently being + defined. */ + +bool +fn_template_being_defined (tree decl) +{ + if (TREE_CODE (decl) != FUNCTION_DECL + || !DECL_LANG_SPECIFIC (decl) + || !DECL_TEMPLOID_INSTANTIATION (decl) + || DECL_TEMPLATE_INSTANTIATED (decl)) +return false; + tree tinfo = DECL_TEMPLATE_INFO (decl); + tree pattern = DECL_TEMPLATE_RESULT (TI_TEMPLATE (tinfo)); + return fn_being_defined (pattern); +} + /* Mark DECL (either a _DECL or a BASELINK) as "used" in the program. If DECL is a specialization or implicitly declared class member, generate the actual definition. Return false if something goes @@ -6415,6 +6442,9 @@ mark_used (tree decl, tsubst_flags_t complain /* = tf_warning_or_error */) maybe_instantiate_decl (decl); if (!decl_dependent_p (decl) + /* Don't require this yet for an instantiation of a function template +we're currently defining (c++/120555). */ + && !fn_template_being_defined (decl) && !require_deduced_type (decl, complain)) return false; @@ -6429,9 +6459,6 @@ mark_used (tree decl, tsubst_flags_t complain /* = tf_warning_or_error */) && uses_template_parms (DECL_TI_ARGS (decl))) return true; - if (!require_deduced_type (decl, complain)) -return false; - if (builtin_pack_fn_p (decl)) { error ("use of built-in parameter pack %qD outside of a template", diff --git a/gcc/testsuite/g++.dg/cpp1z/constexpr-if39.C b/gcc/testsuite/g++.dg/cpp1z/constexpr-if39.C new file mode 100644 index ..38ae7a0c0e10 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/constexpr-if39.C @@ -0,0 +1,30 @@ +// PR c++/120555 +// { dg-do compile { target c++17 } } + +struct A { int m; }; + +template +constexpr auto f() { + if constexpr (sizeof(T) == sizeof(int)) +return 1; + else +return A{f()}; +} + +static_assert(f().m == 1); +static_assert(f() == 1); + +template constexpr auto g(); + +template +constexpr auto f2() { + if constexpr (sizeof(T) == sizeof(int)) +return 1; + else +return A{g()};// { dg-error "auto" } +} + +template constexpr auto g() { return A{1}; } + +static_assert(f2().m == 1); +static_assert(f2() == 1);
[gcc r16-1344] diagnostics: fix of experimental-html output [PR116792]
https://gcc.gnu.org/g:82de4cada8669639a8474808db48d63ffade2bcb commit r16-1344-g82de4cada8669639a8474808db48d63ffade2bcb Author: David Malcolm Date: Mon Jun 9 09:40:06 2025 -0400 diagnostics: fix of experimental-html output [PR116792] Add a new vfunc diagnostic_output_format::set_main_input_filename so that we can separate setting the of HTML output and the diagnostic_artifact_role::analysis_target of SARIF output from creation of the sinks. Calling it is done by the various creators of the sinks. gcc/ChangeLog: PR other/116792 * diagnostic-format-html.cc (html_builder::m_title_element): New field. (html_builder::html_builder): Initialize it. Don't add placeholder text. (html_builder::set_main_input_filename): New. (html_output_format::set_main_input_filename): New. (test_html_diagnostic_context::test_html_diagnostic_context): Call set_main_input_filename on the new sink. (seldtest::test_simple_log): Update expected text. * diagnostic-format-json.cc (diagnostic_output_format_init_json): Return a reference to the new sink. (diagnostic_output_format_init_json_stderr): Likewise. (diagnostic_output_format_init_json_file): Likewise. * diagnostic-format-sarif.cc (sarif_builder::sarif_builder): Drop "main_input_filename_" param, and move adding an artifact for it with diagnostic_artifact_role::analysis_target to... (sarif_builder::set_main_input_filename): ...this new function. (sarif_output_format::set_main_input_filename): New. (sarif_output_format::sarif_output_format): Drop "main_input_filename_" param. (sarif_stream_output_format::sarif_stream_output_format): Likewise. (sarif_file_output_format::sarif_file_output_format): Likewise. (diagnostic_output_format_init_sarif): Return a reference to *FMT. (diagnostic_output_format_init_sarif_stderr): Return a refererence to the new sink. Drop "main_input_filename_" param. (diagnostic_output_format_init_sarif_file): Likewise. (diagnostic_output_format_init_sarif_stream): Likewise. (make_sarif_sink): Drop "main_input_filename_" param. (selftest::test_sarif_diagnostic_context::test_sarif_diagnostic_context): Likewise. Call set_main_input_filename on the new format. (selftest::test_sarif_diagnostic_context::buffered_output_format::buffered_output_format): Drop "main_input_filename_" param. (selftest::test_make_location_object): Likewise. * diagnostic-format-sarif.h (diagnostic_output_format_init_sarif_stderr): Return a refererence to the new sink. Drop "main_input_filename_" param. (diagnostic_output_format_init_sarif_file): Likewise. (diagnostic_output_format_init_sarif_stream): Likewise. (make_sarif_sink): Drop "main_input_filename_" param. * diagnostic-format.h (diagnostic_output_format::set_main_input_filename): New vfunc. (diagnostic_output_format_init_json_stderr): Return a refererence to the new sink. (diagnostic_output_format_init_json_file): Likewise. * diagnostic.cc (diagnostic_output_format_init): Likewise. Call set_main_input_filename on the new sink. * libgdiagnostics.cc (sarif_sink::sarif_sink): Update for above changes. * opts-diagnostic.cc (sarif_scheme_handler::make_sink): Likewise. (handle_OPT_fdiagnostics_add_output_): Likewise. (handle_OPT_fdiagnostics_set_output_): Likewise. gcc/testsuite/ChangeLog: PR other/116792 * gcc.dg/html-output/missing-semicolon.py: Update expected text. Drop out-of-date comment. Signed-off-by: David Malcolm Diff: --- gcc/diagnostic-format-html.cc | 27 ++- gcc/diagnostic-format-json.cc | 23 -- gcc/diagnostic-format-sarif.cc | 91 -- gcc/diagnostic-format-sarif.h | 10 +-- gcc/diagnostic-format.h| 9 ++- gcc/diagnostic.cc | 29 +++ gcc/libgdiagnostics.cc | 2 +- gcc/opts-diagnostic.cc | 3 +- .../gcc.dg/html-output/missing-semicolon.py| 25 +- 9 files changed, 118 insertions(+), 101 deletions(-) diff --git a/gcc/diagnostic-format-html.cc b/gcc/diagnostic-format-html.cc index ea2dbbba9293..ddf6ba0f4cfc 100644 --- a/gcc/diagnostic-format-html.cc +++ b/gcc/diagnostic-format-html.cc @@ -104,6 +104,9 @@ public: const line_maps *line_ma
[gcc r16-1360] RISC-V: Regen riscv-ext.texi [NFC]
https://gcc.gnu.org/g:fce42e15063e76d2535586a25d560e2340ca8ac9 commit r16-1360-gfce42e15063e76d2535586a25d560e2340ca8ac9 Author: Kito Cheng Date: Tue Jun 10 10:32:37 2025 +0800 RISC-V: Regen riscv-ext.texi [NFC] Regenerates the `riscv-ext.texi` file in the GCC documentation. gcc/ChangeLog: * doc/riscv-ext.texi: Regen. Diff: --- gcc/doc/riscv-ext.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/doc/riscv-ext.texi b/gcc/doc/riscv-ext.texi index e69a2df768d4..c3ed1bfb5936 100644 --- a/gcc/doc/riscv-ext.texi +++ b/gcc/doc/riscv-ext.texi @@ -520,7 +520,7 @@ @item smrnmi @tab 1.0 -@tab Resumable Non-Maskable Interrupts +@tab Resumable non-maskable interrupts @item smstateen @tab 1.0
[gcc r15-9810] ext-dce: Don't refine live width with SUBREG mode if !TRULY_NOOP_TRUNCATION_MODES_P [PR 120050]
https://gcc.gnu.org/g:ba729e217add91ac919c06a51f00145249fbeb4b commit r15-9810-gba729e217add91ac919c06a51f00145249fbeb4b Author: Xi Ruoyao Date: Sun May 11 16:44:31 2025 +0800 ext-dce: Don't refine live width with SUBREG mode if !TRULY_NOOP_TRUNCATION_MODES_P [PR 120050] If we see a promoted subreg and TRULY_NOOP_TRUNCATION says the truncation is not a noop, then all bits of the inner reg are live. We cannot reduce the live mask to that of the mode of the subreg. gcc/ChangeLog: PR rtl-optimization/120050 * ext-dce.cc (ext_dce_process_uses): Break early if a SUBREG in rhs is promoted and the truncation from the inner mode to the outer mode is not a noop when handling SETs. (cherry picked from commit 65f3a439c4f76fe780a30ac66969f51035c4bf98) Diff: --- gcc/ext-dce.cc | 17 +++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/gcc/ext-dce.cc b/gcc/ext-dce.cc index a03439501419..aa80c0483d61 100644 --- a/gcc/ext-dce.cc +++ b/gcc/ext-dce.cc @@ -35,6 +35,7 @@ along with GCC; see the file COPYING3. If not see #include "print-rtl.h" #include "dbgcnt.h" #include "diagnostic-core.h" +#include "target.h" /* These should probably move into a C++ class. */ static vec livein; @@ -764,13 +765,25 @@ ext_dce_process_uses (rtx_insn *insn, rtx obj, We don't want to mark those bits live unnecessarily as that inhibits extension elimination in important cases such as those in Coremark. So we need that -outer code. */ +outer code. + +But if !TRULY_NOOP_TRUNCATION_MODES_P, the mode +change performed by Y would normally need to be a +TRUNCATE rather than a SUBREG. It is probably the +guarantee provided by SUBREG_PROMOTED_VAR_P that +allows the SUBREG in Y as an exception. We must +therefore preserve that guarantee and treat the +upper bits of the inner register as live +regardless of the outer code. See PR 120050. */ if (!REG_P (SUBREG_REG (y)) || (SUBREG_PROMOTED_VAR_P (y) && ((GET_CODE (SET_SRC (x)) == SIGN_EXTEND && SUBREG_PROMOTED_SIGNED_P (y)) || (GET_CODE (SET_SRC (x)) == ZERO_EXTEND - && SUBREG_PROMOTED_UNSIGNED_P (y) + && SUBREG_PROMOTED_UNSIGNED_P (y)) + || !TRULY_NOOP_TRUNCATION_MODES_P ( + GET_MODE (y), + GET_MODE (SUBREG_REG (y)) break; bit = subreg_lsb (y).to_constant ();
[gcc r16-1357] RISC-V: Reconcile the existing test for vremu.vx combine
https://gcc.gnu.org/g:b59354cf309052de6a1c297f06411691c03bfd24 commit r16-1357-gb59354cf309052de6a1c297f06411691c03bfd24 Author: Pan Li Date: Mon Jun 9 16:28:50 2025 +0800 RISC-V: Reconcile the existing test for vremu.vx combine Some existing vrem related test need some adjust for the asm check due to cost model. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/binop/vrem-rv32gcv.c: Adjust the asm check for vremu. * gcc.target/riscv/rvv/autovec/binop/vrem-rv64gcv.c: Ditto. Signed-off-by: Pan Li Diff: --- gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vrem-rv32gcv.c | 4 ++-- gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vrem-rv64gcv.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vrem-rv32gcv.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vrem-rv32gcv.c index ad918a9b800a..10de7c268e5e 100644 --- a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vrem-rv32gcv.c +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vrem-rv32gcv.c @@ -4,8 +4,8 @@ /* { dg-final { scan-assembler-times {\tvrem\.vv} 8 } } */ /* { dg-final { scan-assembler-not {\tvrem\.vx} } } */ -/* { dg-final { scan-assembler-times {\tvremu\.vv} 5 } } */ -/* { dg-final { scan-assembler-times {\tvremu\.vx} 3 } } */ +/* { dg-final { scan-assembler-times {\tvremu\.vv} 8 } } */ +/* { dg-final { scan-assembler-not {\tvremu\.vx} } } */ /* { dg-final { scan-tree-dump-times "\.COND_LEN_MOD" 16 "optimized" } } */ /* { dg-final { scan-assembler-not {\tvmv1r\.v} } } */ /* { dg-final { scan-assembler-not {\tvmv2r\.v} } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vrem-rv64gcv.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vrem-rv64gcv.c index 4e28f99e2886..cf187a2bde7c 100644 --- a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vrem-rv64gcv.c +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vrem-rv64gcv.c @@ -5,8 +5,8 @@ /* { dg-final { scan-assembler-times {\tvrem\.vv} 8 } } */ /* { dg-final { scan-assembler-not {\tvrem\.vx} } } */ -/* { dg-final { scan-assembler-times {\tvremu\.vv} 4 } } */ -/* { dg-final { scan-assembler-times {\tvremu\.vx} 4 } } */ +/* { dg-final { scan-assembler-times {\tvremu\.vv} 8 } } */ +/* { dg-final { scan-assembler-not {\tvremu\.vx} } } */ /* { dg-final { scan-tree-dump-times "\.COND_LEN_MOD" 16 "optimized" } } */ /* { dg-final { scan-assembler-not {\tvmv1r\.v} } } */ /* { dg-final { scan-assembler-not {\tvmv2r\.v} } } */
[gcc r16-1358] RISC-V: Add test for vec_duplicate + vremu.vv combine case 0 with GR2VR cost 0, 2 and 15
https://gcc.gnu.org/g:0bdea31036e8268edd1b4ea3ed07478c07c96ad1 commit r16-1358-g0bdea31036e8268edd1b4ea3ed07478c07c96ad1 Author: Pan Li Date: Mon Jun 9 16:33:52 2025 +0800 RISC-V: Add test for vec_duplicate + vremu.vv combine case 0 with GR2VR cost 0, 2 and 15 Add asm dump check test for vec_duplicate + vrem.vv combine to vrem.vx, with the GR2VR cost is 0, 2 and 15. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/vx_vf/vx-1-u16.c: Add asm check for vremu.vx combine. * gcc.target/riscv/rvv/autovec/vx_vf/vx-1-u32.c: Ditto. * gcc.target/riscv/rvv/autovec/vx_vf/vx-1-u64.c: Ditto. * gcc.target/riscv/rvv/autovec/vx_vf/vx-1-u8.c: Ditto. * gcc.target/riscv/rvv/autovec/vx_vf/vx-2-u16.c: Ditto. * gcc.target/riscv/rvv/autovec/vx_vf/vx-2-u32.c: Ditto. * gcc.target/riscv/rvv/autovec/vx_vf/vx-2-u64.c: Ditto. * gcc.target/riscv/rvv/autovec/vx_vf/vx-2-u8.c: Ditto. * gcc.target/riscv/rvv/autovec/vx_vf/vx-3-u16.c: Ditto. * gcc.target/riscv/rvv/autovec/vx_vf/vx-3-u32.c: Ditto. * gcc.target/riscv/rvv/autovec/vx_vf/vx-3-u64.c: Ditto. * gcc.target/riscv/rvv/autovec/vx_vf/vx-3-u8.c: Ditto. * gcc.target/riscv/rvv/autovec/vx_vf/vx_binary_data.h: Add test data for run test. * gcc.target/riscv/rvv/autovec/vx_vf/vx_vrem-run-1-u16.c: New test. * gcc.target/riscv/rvv/autovec/vx_vf/vx_vrem-run-1-u32.c: New test. * gcc.target/riscv/rvv/autovec/vx_vf/vx_vrem-run-1-u64.c: New test. * gcc.target/riscv/rvv/autovec/vx_vf/vx_vrem-run-1-u8.c: New test. Signed-off-by: Pan Li Diff: --- .../gcc.target/riscv/rvv/autovec/vx_vf/vx-1-u16.c | 2 + .../gcc.target/riscv/rvv/autovec/vx_vf/vx-1-u32.c | 2 + .../gcc.target/riscv/rvv/autovec/vx_vf/vx-1-u64.c | 2 + .../gcc.target/riscv/rvv/autovec/vx_vf/vx-1-u8.c | 2 + .../gcc.target/riscv/rvv/autovec/vx_vf/vx-2-u16.c | 2 + .../gcc.target/riscv/rvv/autovec/vx_vf/vx-2-u32.c | 2 + .../gcc.target/riscv/rvv/autovec/vx_vf/vx-2-u64.c | 2 + .../gcc.target/riscv/rvv/autovec/vx_vf/vx-2-u8.c | 2 + .../gcc.target/riscv/rvv/autovec/vx_vf/vx-3-u16.c | 2 + .../gcc.target/riscv/rvv/autovec/vx_vf/vx-3-u32.c | 2 + .../gcc.target/riscv/rvv/autovec/vx_vf/vx-3-u64.c | 2 + .../gcc.target/riscv/rvv/autovec/vx_vf/vx-3-u8.c | 2 + .../riscv/rvv/autovec/vx_vf/vx_binary_data.h | 196 + .../riscv/rvv/autovec/vx_vf/vx_vrem-run-1-u16.c| 15 ++ .../riscv/rvv/autovec/vx_vf/vx_vrem-run-1-u32.c| 15 ++ .../riscv/rvv/autovec/vx_vf/vx_vrem-run-1-u64.c| 15 ++ .../riscv/rvv/autovec/vx_vf/vx_vrem-run-1-u8.c | 15 ++ 17 files changed, 280 insertions(+) diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx-1-u16.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx-1-u16.c index 92fbf227d563..474fed2be15d 100644 --- a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx-1-u16.c +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx-1-u16.c @@ -12,6 +12,7 @@ DEF_VX_BINARY_CASE_0_WRAP(T, &, and) DEF_VX_BINARY_CASE_0_WRAP(T, |, or) DEF_VX_BINARY_CASE_0_WRAP(T, ^, xor) DEF_VX_BINARY_CASE_0_WRAP(T, /, div) +DEF_VX_BINARY_CASE_0_WRAP(T, %, rem) /* { dg-final { scan-assembler-times {vadd.vx} 1 } } */ /* { dg-final { scan-assembler-times {vsub.vx} 1 } } */ @@ -20,3 +21,4 @@ DEF_VX_BINARY_CASE_0_WRAP(T, /, div) /* { dg-final { scan-assembler-times {vor.vx} 1 } } */ /* { dg-final { scan-assembler-times {vxor.vx} 1 } } */ /* { dg-final { scan-assembler-times {vdivu.vx} 1 } } */ +/* { dg-final { scan-assembler-times {vremu.vx} 1 } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx-1-u32.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx-1-u32.c index f487b42820ee..28c0524c9934 100644 --- a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx-1-u32.c +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx-1-u32.c @@ -12,6 +12,7 @@ DEF_VX_BINARY_CASE_0_WRAP(T, &, and) DEF_VX_BINARY_CASE_0_WRAP(T, |, or) DEF_VX_BINARY_CASE_0_WRAP(T, ^, xor) DEF_VX_BINARY_CASE_0_WRAP(T, /, div) +DEF_VX_BINARY_CASE_0_WRAP(T, %, rem) /* { dg-final { scan-assembler-times {vadd.vx} 1 } } */ /* { dg-final { scan-assembler-times {vsub.vx} 1 } } */ @@ -20,3 +21,4 @@ DEF_VX_BINARY_CASE_0_WRAP(T, /, div) /* { dg-final { scan-assembler-times {vor.vx} 1 } } */ /* { dg-final { scan-assembler-times {vxor.vx} 1 } } */ /* { dg-final { scan-assembler-times {vdivu.vx} 1 } } */ +/* { dg-final { scan-assembler-times {vremu.vx} 1 } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx-1-u64.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx-1-u64.c index 761d25c0833a..62c1ee996fd9 100644 --- a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx-1-u64.c +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx-1-u64.c @@ -12,6 +12,7 @@ DEF_VX_BI
[gcc r16-1356] RISC-V: Combine vec_duplicate + vremu.vv to vremu.vx on GR2VR cost
https://gcc.gnu.org/g:85de2b8b58e1644f6d5f0f182426122416b19e6f commit r16-1356-g85de2b8b58e1644f6d5f0f182426122416b19e6f Author: Pan Li Date: Mon Jun 9 16:24:34 2025 +0800 RISC-V: Combine vec_duplicate + vremu.vv to vremu.vx on GR2VR cost This patch would like to combine the vec_duplicate + vremu.vv to the vremu.vx. From example as below code. The related pattern will depend on the cost of vec_duplicate from GR2VR. Then the late-combine will take action if the cost of GR2VR is zero, and reject the combination if the GR2VR cost is greater than zero. Assume we have example code like below, GR2VR cost is 0. #define DEF_VX_BINARY(T, OP)\ void\ test_vx_binary (T * restrict out, T * restrict in, T x, unsigned n) \ { \ for (unsigned i = 0; i < n; i++) \ out[i] = in[i] OP x;\ } DEF_VX_BINARY(int32_t, /) Before this patch: 10 │ test_vx_binary_or_int32_t_case_0: 11 │ beq a3,zero,.L8 12 │ vsetvli a5,zero,e32,m1,ta,ma 13 │ vmv.v.x v2,a2 14 │ sllia3,a3,32 15 │ srlia3,a3,32 16 │ .L3: 17 │ vsetvli a5,a3,e32,m1,ta,ma 18 │ vle32.v v1,0(a1) 19 │ sllia4,a5,2 20 │ sub a3,a3,a5 21 │ add a1,a1,a4 22 │ vremu.vv v1,v1,v2 23 │ vse32.v v1,0(a0) 24 │ add a0,a0,a4 25 │ bne a3,zero,.L3 After this patch: 10 │ test_vx_binary_or_int32_t_case_0: 11 │ beq a3,zero,.L8 12 │ sllia3,a3,32 13 │ srlia3,a3,32 14 │ .L3: 15 │ vsetvli a5,a3,e32,m1,ta,ma 16 │ vle32.v v1,0(a1) 17 │ sllia4,a5,2 18 │ sub a3,a3,a5 19 │ add a1,a1,a4 20 │ vremu.vx v1,v1,a2 21 │ vse32.v v1,0(a0) 22 │ add a0,a0,a4 23 │ bne a3,zero,.L3 gcc/ChangeLog: * config/riscv/riscv-v.cc (expand_vx_binary_vec_vec_dup): Add new case UMOD. * config/riscv/riscv.cc (riscv_rtx_costs): Ditto. * config/riscv/vector-iterators.md: Add new op umod. Signed-off-by: Pan Li Diff: --- gcc/config/riscv/riscv-v.cc | 1 + gcc/config/riscv/riscv.cc| 1 + gcc/config/riscv/vector-iterators.md | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/gcc/config/riscv/riscv-v.cc b/gcc/config/riscv/riscv-v.cc index c31ec9e9b419..420baa587dc2 100644 --- a/gcc/config/riscv/riscv-v.cc +++ b/gcc/config/riscv/riscv-v.cc @@ -5570,6 +5570,7 @@ expand_vx_binary_vec_vec_dup (rtx op_0, rtx op_1, rtx op_2, case DIV: case UDIV: case MOD: +case UMOD: icode = code_for_pred_scalar (code, mode); break; default: diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index 14ac2f3cdbc1..d5ab128f05ff 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -3950,6 +3950,7 @@ riscv_rtx_costs (rtx x, machine_mode mode, int outer_code, int opno ATTRIBUTE_UN case DIV: case UDIV: case MOD: + case UMOD: *total = get_vector_binary_rtx_cost (op, scalar2vr_cost); break; default: diff --git a/gcc/config/riscv/vector-iterators.md b/gcc/config/riscv/vector-iterators.md index b1fd607320ef..42fc04c0ad38 100644 --- a/gcc/config/riscv/vector-iterators.md +++ b/gcc/config/riscv/vector-iterators.md @@ -4042,7 +4042,7 @@ ]) (define_code_iterator any_int_binop_no_shift_v_vdup [ - plus minus and ior xor mult div udiv mod + plus minus and ior xor mult div udiv mod umod ]) (define_code_iterator any_int_binop_no_shift_vdup_v [
[gcc r16-1359] RISC-V: Add test for vec_duplicate + vremu.vv combine case 1 with GR2VR cost 0, 1 and 2
https://gcc.gnu.org/g:bcabb6b0c707271b86a59be755f295ab7c125df1 commit r16-1359-gbcabb6b0c707271b86a59be755f295ab7c125df1 Author: Pan Li Date: Mon Jun 9 16:35:47 2025 +0800 RISC-V: Add test for vec_duplicate + vremu.vv combine case 1 with GR2VR cost 0, 1 and 2 Add asm dump check test for vec_duplicate + vremu.vv combine to vremu.vx, with the GR2VR cost is 0, 1 and 2. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/vx_vf/vx-4-u16.c: Add asm check for vremu.vx combine. * gcc.target/riscv/rvv/autovec/vx_vf/vx-4-u32.c: Ditto. * gcc.target/riscv/rvv/autovec/vx_vf/vx-4-u64.c: Ditto. * gcc.target/riscv/rvv/autovec/vx_vf/vx-4-u8.c: Ditto. * gcc.target/riscv/rvv/autovec/vx_vf/vx-5-u16.c: Ditto. * gcc.target/riscv/rvv/autovec/vx_vf/vx-5-u32.c: Ditto. * gcc.target/riscv/rvv/autovec/vx_vf/vx-5-u64.c: Ditto. * gcc.target/riscv/rvv/autovec/vx_vf/vx-5-u8.c: Ditto. * gcc.target/riscv/rvv/autovec/vx_vf/vx-6-u16.c: Ditto. * gcc.target/riscv/rvv/autovec/vx_vf/vx-6-u32.c: Ditto. * gcc.target/riscv/rvv/autovec/vx_vf/vx-6-u64.c: Ditto. * gcc.target/riscv/rvv/autovec/vx_vf/vx-6-u8.c: Ditto. Signed-off-by: Pan Li Diff: --- gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx-4-u16.c | 2 ++ gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx-4-u32.c | 2 ++ gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx-4-u64.c | 2 ++ gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx-4-u8.c | 2 ++ gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx-5-u16.c | 2 ++ gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx-5-u32.c | 2 ++ gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx-5-u64.c | 2 ++ gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx-5-u8.c | 2 ++ gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx-6-u16.c | 2 ++ gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx-6-u32.c | 2 ++ gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx-6-u64.c | 2 ++ gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx-6-u8.c | 2 ++ 12 files changed, 24 insertions(+) diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx-4-u16.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx-4-u16.c index 58e4a1e96d6c..16ccaea251b8 100644 --- a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx-4-u16.c +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx-4-u16.c @@ -12,6 +12,7 @@ DEF_VX_BINARY_CASE_1_WRAP(T, &, and, VX_BINARY_BODY_X16) DEF_VX_BINARY_CASE_1_WRAP(T, |, or, VX_BINARY_BODY_X16) DEF_VX_BINARY_CASE_1_WRAP(T, ^, xor, VX_BINARY_BODY_X16) DEF_VX_BINARY_CASE_1_WRAP(T, /, div, VX_BINARY_BODY_X16) +DEF_VX_BINARY_CASE_1_WRAP(T, %, rem, VX_BINARY_BODY_X16) /* { dg-final { scan-assembler {vadd.vx} } } */ /* { dg-final { scan-assembler {vsub.vx} } } */ @@ -20,3 +21,4 @@ DEF_VX_BINARY_CASE_1_WRAP(T, /, div, VX_BINARY_BODY_X16) /* { dg-final { scan-assembler {vor.vx} } } */ /* { dg-final { scan-assembler {vxor.vx} } } */ /* { dg-final { scan-assembler {vdivu.vx} } } */ +/* { dg-final { scan-assembler {vremu.vx} } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx-4-u32.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx-4-u32.c index 3d5f53568dbe..0e2ab8d7838d 100644 --- a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx-4-u32.c +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx-4-u32.c @@ -12,6 +12,7 @@ DEF_VX_BINARY_CASE_1_WRAP(T, &, and, VX_BINARY_BODY_X4) DEF_VX_BINARY_CASE_1_WRAP(T, |, or, VX_BINARY_BODY_X4) DEF_VX_BINARY_CASE_1_WRAP(T, ^, xor, VX_BINARY_BODY_X4) DEF_VX_BINARY_CASE_1_WRAP(T, /, div, VX_BINARY_BODY_X4) +DEF_VX_BINARY_CASE_1_WRAP(T, %, rem, VX_BINARY_BODY_X4) /* { dg-final { scan-assembler {vadd.vx} } } */ /* { dg-final { scan-assembler {vsub.vx} } } */ @@ -20,3 +21,4 @@ DEF_VX_BINARY_CASE_1_WRAP(T, /, div, VX_BINARY_BODY_X4) /* { dg-final { scan-assembler {vor.vx} } } */ /* { dg-final { scan-assembler {vxor.vx} } } */ /* { dg-final { scan-assembler {vdivu.vx} } } */ +/* { dg-final { scan-assembler {vremu.vx} } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx-4-u64.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx-4-u64.c index 0edb9257a7a7..80eb8a4752e3 100644 --- a/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx-4-u64.c +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/vx_vf/vx-4-u64.c @@ -12,6 +12,7 @@ DEF_VX_BINARY_CASE_1_WRAP(T, &, and, VX_BINARY_BODY) DEF_VX_BINARY_CASE_1_WRAP(T, |, or, VX_BINARY_BODY) DEF_VX_BINARY_CASE_1_WRAP(T, ^, xor, VX_BINARY_BODY) DEF_VX_BINARY_CASE_1_WRAP(T, /, div, VX_BINARY_BODY) +DEF_VX_BINARY_CASE_1_WRAP(T, %, rem, VX_BINARY_BODY) /* { dg-final { scan-assembler {vadd.vx} } } */ /* { dg-final { scan-assembler {vsub.vx} } } */ @@ -20,3 +21,4 @@ DEF_VX_BINARY_CASE_1_WRAP(T, /, div, VX_BINARY_BODY) /* { dg-final { scan-assembler {vor.vx} } } */ /* { dg-final { scan-assembler {vxor.v
[gcc r16-1350] c++: Fix template class lookup [PR120495, PR115605].
https://gcc.gnu.org/g:cf588f1a8e7406ced5b08f32f9d23f015a240a31 commit r16-1350-gcf588f1a8e7406ced5b08f32f9d23f015a240a31 Author: Iain Sandoe Date: Mon Jun 2 09:42:23 2025 +0100 c++: Fix template class lookup [PR120495, PR115605]. In the reported issues, using lookup_template_class () directly on (for example) the coroutine_handle identifier fails because a class-local TYPE_DECL is found. This is because, in the existing code, lookup is called with default parameters which means that class contexts are examined first. Fix this, when a context is provided by the caller, by doing lookup in namespace provided. PR c++/120495 PR c++/115605 gcc/cp/ChangeLog: * pt.cc (lookup_template_class): Honour provided namespace contexts when looking up class templates. gcc/testsuite/ChangeLog: * g++.dg/coroutines/pr120495.C: New test. * g++.dg/pr115605.C: New test. Signed-off-by: Iain Sandoe Diff: --- gcc/cp/pt.cc | 30 ++-- gcc/testsuite/g++.dg/coroutines/pr120495.C | 55 ++ gcc/testsuite/g++.dg/pr115605.C| 10 ++ 3 files changed, 84 insertions(+), 11 deletions(-) diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index b5c877a385f5..752b0ea8544c 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -10052,15 +10052,20 @@ tsubst_entering_scope (tree t, tree args, tsubst_flags_t complain, tree in_decl) D1 is the PTYPENAME terminal, and ARGLIST is the list of arguments. + If D1 is an identifier and CONTEXT is non-NULL, then the lookup is + carried out in CONTEXT. Currently, only namespaces are supported for + CONTEXT. + + If D1 is an identifier and CONTEXT is NULL, the lookup is performed + in the innermost non-namespace binding. + + Otherwise CONTEXT is ignored and no lookup is carried out. + IN_DECL, if non-NULL, is the template declaration we are trying to instantiate. Issue error and warning messages under control of COMPLAIN. - If the template class is really a local class in a template - function, then the FUNCTION_CONTEXT is the function in which it is - being instantiated. - ??? Note that this function is currently called *twice* for each template-id: the first time from the parser, while creating the incomplete type (finish_template_type), and the second type during the @@ -10079,20 +10084,23 @@ lookup_template_class (tree d1, tree arglist, tree in_decl, tree context, spec_entry **slot; spec_entry *entry; - if (identifier_p (d1)) + if (identifier_p (d1) && context) +{ + gcc_checking_assert (TREE_CODE (context) == NAMESPACE_DECL); + push_decl_namespace (context); + templ = lookup_name (d1, LOOK_where::NAMESPACE, LOOK_want::NORMAL); + pop_decl_namespace (); +} + else if (identifier_p (d1)) { tree value = innermost_non_namespace_value (d1); if (value && DECL_TEMPLATE_TEMPLATE_PARM_P (value)) templ = value; else - { - if (context) - push_decl_namespace (context); +{ templ = lookup_name (d1); templ = maybe_get_template_decl_from_type_decl (templ); - if (context) - pop_decl_namespace (); - } +} } else if (TREE_CODE (d1) == TYPE_DECL && MAYBE_CLASS_TYPE_P (TREE_TYPE (d1))) { diff --git a/gcc/testsuite/g++.dg/coroutines/pr120495.C b/gcc/testsuite/g++.dg/coroutines/pr120495.C new file mode 100644 index ..f59c34a86765 --- /dev/null +++ b/gcc/testsuite/g++.dg/coroutines/pr120495.C @@ -0,0 +1,55 @@ +// { dg-additional-options "-fsyntax-only" } + +#include +#include + +struct fire_and_forget { +}; + +template +struct std::coroutine_traits +{ +struct promise_type +{ +fire_and_forget get_return_object() const noexcept +{ +return{}; +} + +void return_void() const noexcept +{ +} + +suspend_never initial_suspend() const noexcept +{ +return{}; +} + +suspend_never final_suspend() const noexcept +{ +return{}; +} + +void unhandled_exception() const noexcept +{ +std::terminate(); +} +}; +}; + +struct foo +{ +fire_and_forget bar() +{ +co_await std::suspend_always{ }; +} + +private: +// The line below triggered the error. +using coroutine_handle = std::coroutine_handle<>; +}; + +int main() +{ +foo{}.bar(); +} diff --git a/gcc/testsuite/g++.dg/pr115605.C b/gcc/testsuite/g++.dg/pr115605.C new file mode 100644 index ..9e342555c894 --- /dev/null +++ b/gcc/testsuite/g++.dg/pr115605.C @@ -0,0 +1,10 @@ +// { dg-do compile { target c++20 } } + +#include + +int foo() { +int const tuple_size = 5; +std::array array {1, 2, 3}; +auto [a, b, c] = array;
[gcc r16-1354] [AutoFDO] Fix profile bootstrap for x86_64
https://gcc.gnu.org/g:79091220da796a4b60561a7bf2e9e8f5e5276bc4 commit r16-1354-g79091220da796a4b60561a7bf2e9e8f5e5276bc4 Author: Kugan Vivekanandarajah Date: Tue Jun 10 09:19:37 2025 +1000 [AutoFDO] Fix profile bootstrap for x86_64 This patch fixes profile bootstrap for x86_64 by special caseing cpu_type for x86_64 as it shares AUTO_PROFILE from i386. ChangeLog: * configure.ac: Special case cpu_type for x86_64. * configure: Regenerate. Signed-off-by: Kugan Vivekanandarajah Diff: --- configure| 4 configure.ac | 4 2 files changed, 8 insertions(+) diff --git a/configure b/configure index ed1e5a4e8187..8ec8a9f111b5 100755 --- a/configure +++ b/configure @@ -3397,6 +3397,10 @@ case "${target}" in esac cpu_type=`echo ${host} | sed 's/-.*$//'` +# Special case cpu_type for x86_64 as it shares AUTO_PROFILE from i386. +if test "${cpu_type}" = "x86_64" ; then + cpu_type="i386" +fi # Disable libssp for some systems. diff --git a/configure.ac b/configure.ac index 33c130f4e02a..5fa101f77fd4 100644 --- a/configure.ac +++ b/configure.ac @@ -622,6 +622,10 @@ case "${target}" in esac cpu_type=`echo ${host} | sed 's/-.*$//'` +# Special case cpu_type for x86_64 as it shares AUTO_PROFILE from i386. +if test "${cpu_type}" = "x86_64" ; then + cpu_type="i386" +fi AC_SUBST(cpu_type) # Disable libssp for some systems.
[gcc r16-1352] c: partial fix for qualifier inconsistency II [PR120510]
https://gcc.gnu.org/g:aea870e9533daf27f3df2d3b82e233c907f80e27 commit r16-1352-gaea870e9533daf27f3df2d3b82e233c907f80e27 Author: Martin Uecker Date: Sat Jun 7 14:24:28 2025 +0200 c: partial fix for qualifier inconsistency II [PR120510] This fixes a case where we invoke composite_type with types that do not have matching qualifiers. With this change, we can activate the checking assertion that makes sure the composite type is compatible with the two original types also for arrays. PR c/120510 gcc/c/ChangeLog: * c-typeck.cc (composite_type_internal): Activate checking assertion for arrays. (common_pointer_type): Remove qualifiers also from arrays. Diff: --- gcc/c/c-typeck.cc | 21 +++-- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc index 0ffb9f65bf13..b8a8279e50bd 100644 --- a/gcc/c/c-typeck.cc +++ b/gcc/c/c-typeck.cc @@ -1002,9 +1002,9 @@ composite_type (tree t1, tree t2) { struct composite_cache cache = { }; tree n = composite_type_internal (t1, t2, &cache); - /* For function and arrays there are some cases where qualifiers do + /* For function types there are some cases where qualifiers do not match. See PR120510. */ - if (FUNCTION_TYPE != TREE_CODE (n) && ARRAY_TYPE != TREE_CODE (n)) + if (FUNCTION_TYPE != TREE_CODE (n)) { gcc_checking_assert (comptypes (n, t1)); gcc_checking_assert (comptypes (n, t2)); @@ -1022,9 +1022,6 @@ static tree common_pointer_type (tree t1, tree t2) { tree attributes; - tree pointed_to_1, mv1; - tree pointed_to_2, mv2; - tree target; unsigned target_quals; addr_space_t as1, as2, as_common; int quals1, quals2; @@ -1046,15 +1043,11 @@ common_pointer_type (tree t1, tree t2) attributes = targetm.merge_type_attributes (t1, t2); /* Find the composite type of the target types, and combine the - qualifiers of the two types' targets. Do not lose qualifiers on - array element types by taking the TYPE_MAIN_VARIANT. */ - mv1 = pointed_to_1 = TREE_TYPE (t1); - mv2 = pointed_to_2 = TREE_TYPE (t2); - if (TREE_CODE (mv1) != ARRAY_TYPE) -mv1 = TYPE_MAIN_VARIANT (pointed_to_1); - if (TREE_CODE (mv2) != ARRAY_TYPE) -mv2 = TYPE_MAIN_VARIANT (pointed_to_2); - target = composite_type (mv1, mv2); + qualifiers of the two types' targets. */ + tree pointed_to_1 = TREE_TYPE (t1); + tree pointed_to_2 = TREE_TYPE (t2); + tree target = composite_type (TYPE_MAIN_VARIANT (pointed_to_1), + TYPE_MAIN_VARIANT (pointed_to_2)); /* Strip array types to get correct qualifier for pointers to arrays */ quals1 = TYPE_QUALS_NO_ADDR_SPACE (strip_array_types (pointed_to_1));
[gcc r16-1353] c: Add remove_qualifier helper function [PR120510]
https://gcc.gnu.org/g:ef626002447e4d2acc835914165dffc419ebbc85 commit r16-1353-gef626002447e4d2acc835914165dffc419ebbc85 Author: Martin Uecker Date: Sat Jun 7 15:55:34 2025 +0200 c: Add remove_qualifier helper function [PR120510] Add a helper function to replace repeated code for removing qualifiers but not atomic. Make sure to also remove qualifiers but not atomic from the element type of arrays. PR c/120510 gcc/c/ChangeLog: * c-typeck.cc (remove_qualifiers): New function. (composite_type_internal): Use it. (comp_target_types): Use it. (type_lists_compatible_p): Use it. (find_anonymous_field_with_type): Use it. (convert_to_anonymous_field): Use it. (convert_for_assignment): Use it. Diff: --- gcc/c/c-typeck.cc | 99 --- 1 file changed, 28 insertions(+), 71 deletions(-) diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc index b8a8279e50bd..539d4815ae4f 100644 --- a/gcc/c/c-typeck.cc +++ b/gcc/c/c-typeck.cc @@ -613,6 +613,17 @@ c_type_tag (const_tree t) return name; } +/* Remove qualifiers but not atomic. For arrays remove qualifiers + on the element type but also do not remove atomic. */ +static tree +remove_qualifiers (tree t) +{ + if (!t || t == error_mark_node) +return t; + return TYPE_ATOMIC (strip_array_types (t)) +? c_build_qualified_type (TYPE_MAIN_VARIANT (t), TYPE_QUAL_ATOMIC) +: TYPE_MAIN_VARIANT (t); +} /* Return the composite type of two compatible types. @@ -910,17 +921,8 @@ composite_type_internal (tree t1, tree t2, struct composite_cache* cache) for (; p1 && p1 != void_list_node; p1 = TREE_CHAIN (p1), p2 = TREE_CHAIN (p2), n = TREE_CHAIN (n)) { -tree mv1 = TREE_VALUE (p1); -if (mv1 && mv1 != error_mark_node) - mv1 = TYPE_ATOMIC (mv1) -? c_build_qualified_type (TYPE_MAIN_VARIANT (mv1), TYPE_QUAL_ATOMIC) -: TYPE_MAIN_VARIANT (mv1); - -tree mv2 = TREE_VALUE (p2); -if (mv2 && mv2 != error_mark_node) - mv2 = TYPE_ATOMIC (mv2) -? c_build_qualified_type (TYPE_MAIN_VARIANT (mv2), TYPE_QUAL_ATOMIC) -: TYPE_MAIN_VARIANT (mv2); +tree mv1 = remove_qualifiers (TREE_VALUE (p1)); +tree mv2 = remove_qualifiers (TREE_VALUE (p2)); /* A null type means arg type is not specified. Take whatever the other function type has. */ @@ -1789,15 +1791,9 @@ comp_target_types (location_t location, tree ttl, tree ttr) val_ped = comptypes (mvl, mvr); /* Qualifiers on element types of array types that are - pointer targets are lost by taking their TYPE_MAIN_VARIANT. */ - - mvl = (TYPE_ATOMIC (strip_array_types (mvl)) -? c_build_qualified_type (TYPE_MAIN_VARIANT (mvl), TYPE_QUAL_ATOMIC) -: TYPE_MAIN_VARIANT (mvl)); - - mvr = (TYPE_ATOMIC (strip_array_types (mvr)) -? c_build_qualified_type (TYPE_MAIN_VARIANT (mvr), TYPE_QUAL_ATOMIC) -: TYPE_MAIN_VARIANT (mvr)); + pointer targets are also removed. */ + mvl = remove_qualifiers (mvl); + mvr = remove_qualifiers (mvr); enum_and_int_p = false; val = comptypes_check_enum_int (mvl, mvr, &enum_and_int_p); @@ -2100,25 +2096,16 @@ type_lists_compatible_p (const_tree args1, const_tree args2, { while (1) { - tree a1, mv1, a2, mv2; if (args1 == NULL_TREE && args2 == NULL_TREE) return true; /* If one list is shorter than the other, they fail to match. */ if (args1 == NULL_TREE || args2 == NULL_TREE) return 0; - mv1 = a1 = TREE_VALUE (args1); - mv2 = a2 = TREE_VALUE (args2); - if (mv1 && mv1 != error_mark_node && TREE_CODE (mv1) != ARRAY_TYPE) - mv1 = (TYPE_ATOMIC (mv1) - ? c_build_qualified_type (TYPE_MAIN_VARIANT (mv1), -TYPE_QUAL_ATOMIC) - : TYPE_MAIN_VARIANT (mv1)); - if (mv2 && mv2 != error_mark_node && TREE_CODE (mv2) != ARRAY_TYPE) - mv2 = (TYPE_ATOMIC (mv2) - ? c_build_qualified_type (TYPE_MAIN_VARIANT (mv2), -TYPE_QUAL_ATOMIC) - : TYPE_MAIN_VARIANT (mv2)); + tree a1 = TREE_VALUE (args1); + tree a2 = TREE_VALUE (args2); + tree mv1 = remove_qualifiers (a1); + tree mv2 = remove_qualifiers (a2); /* A null pointer instead of a type means there is supposed to be an argument but nothing is specified about what type it has. @@ -2155,13 +2142,7 @@ type_lists_compatible_p (const_tree args1, const_tree args2, for (memb = TYPE_FIELDS (a1); memb; memb = DECL_CHAIN (memb)) { - tree mv3 = TREE_TYPE (memb); - if (mv3 && mv3 !=
[gcc r16-1351] c: partial fix for qualifier inconsistency [PR120510]
https://gcc.gnu.org/g:c1904cd27b2bb69f884e4958d9ceb78159470975 commit r16-1351-gc1904cd27b2bb69f884e4958d9ceb78159470975 Author: Martin Uecker Date: Thu Jun 5 23:55:39 2025 +0200 c: partial fix for qualifier inconsistency [PR120510] Checking assertions revealed that we sometimes produce composite types with incorrect qualifiers, e.g. the example int f(int [_Atomic]); int f(int [_Atomic]); int f(int [_Atomic]); was rejected because atomic was lost in the second declaration. PR c/120510 gcc/c/ChangeLog: * c-typeck.cc (composite_types_internal): Handle arrays declared with atomic for function arguments. gcc/testsuite/ChangeLog: * gcc.dg/pr120510.c Diff: --- gcc/c/c-typeck.cc | 14 -- gcc/testsuite/gcc.dg/pr120510.c | 7 +++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc index b59b5c8a8bb1..0ffb9f65bf13 100644 --- a/gcc/c/c-typeck.cc +++ b/gcc/c/c-typeck.cc @@ -911,14 +911,16 @@ composite_type_internal (tree t1, tree t2, struct composite_cache* cache) p1 = TREE_CHAIN (p1), p2 = TREE_CHAIN (p2), n = TREE_CHAIN (n)) { tree mv1 = TREE_VALUE (p1); -if (mv1 && mv1 != error_mark_node -&& TREE_CODE (mv1) != ARRAY_TYPE) - mv1 = TYPE_MAIN_VARIANT (mv1); +if (mv1 && mv1 != error_mark_node) + mv1 = TYPE_ATOMIC (mv1) +? c_build_qualified_type (TYPE_MAIN_VARIANT (mv1), TYPE_QUAL_ATOMIC) +: TYPE_MAIN_VARIANT (mv1); tree mv2 = TREE_VALUE (p2); -if (mv2 && mv2 != error_mark_node -&& TREE_CODE (mv2) != ARRAY_TYPE) - mv2 = TYPE_MAIN_VARIANT (mv2); +if (mv2 && mv2 != error_mark_node) + mv2 = TYPE_ATOMIC (mv2) +? c_build_qualified_type (TYPE_MAIN_VARIANT (mv2), TYPE_QUAL_ATOMIC) +: TYPE_MAIN_VARIANT (mv2); /* A null type means arg type is not specified. Take whatever the other function type has. */ diff --git a/gcc/testsuite/gcc.dg/pr120510.c b/gcc/testsuite/gcc.dg/pr120510.c new file mode 100644 index ..d99c329c1d7f --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr120510.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c23" } */ + +void f (int [_Atomic]); +void f (int [_Atomic]); +void f (int [_Atomic]); +
[gcc r16-1349] MAINTAINERS: Update my email address
https://gcc.gnu.org/g:e825ec7fcd81cf845bc6f926d07917b6040a585d commit r16-1349-ge825ec7fcd81cf845bc6f926d07917b6040a585d Author: Peter Bergner Date: Mon Jun 9 16:01:52 2025 -0500 MAINTAINERS: Update my email address 2025-06-09 Peter Bergner * MAINTAINERS: Update my email address and add myself to DCO. Signed-off-by: Peter Bergner Diff: --- MAINTAINERS | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index e473c01ef4bb..6f663742fccc 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -308,7 +308,7 @@ loop optimizer Zdenek Dvorak LTO Richard Biener LTO plugin Cary Coutant Plugin Le-Chun Wu -register allocation Peter Bergner +register allocation Peter Bergner register allocation Kenneth Zadeck register allocation Seongbae Park riscv port Robin Dapp @@ -358,7 +358,7 @@ Serge Belyshev - Jon Benistonjbeniston Andrew Bennett - Andrew Benson abensonca -Peter Bergner bergner +Peter Bergner bergner Daniel Berlin dberlin Pat Bernardi- Jan Beulich - @@ -934,6 +934,7 @@ information. Soumya AR +Peter Bergner Dhruv Chawla Juergen Christ Giuseppe D'Angelo
[gcc r16-1346] Fix profile updating in ipa-cp
https://gcc.gnu.org/g:b0d50cbb42ab2ce5fab8a832cb82fc54b371c914 commit r16-1346-gb0d50cbb42ab2ce5fab8a832cb82fc54b371c914 Author: Jan Hubicka Date: Fri Jun 6 17:57:00 2025 +0200 Fix profile updating in ipa-cp Bootstrapping with autoprofiledbootstrap, LTO and checking enables ICEs in WPA because we end up mixing local and IPA count in ipa-cp.cc:update_specialized_profile. This is because of missing call to profile_count::adjust_for_ipa_scaling. While looking into that I however noticed that the function forgets to update indirect call edges. This made me to commonize same logic which currently exists in clone_inlined_nodes, update_specialized_profile, update_profiling_info and update_counts_for_self_gen_clones. While testing it I noticed that we also ICE when linking with -fdump-ipa-all-details-blocks since IPA and local counts are temporarily mixed during IPA transformation stage, so I also added check to profile_count::dump to not crash and added verifier to gimple_verify_flow_info. Other problem I also noticed is that while profile updates done by inliner (via cgraph_node::clone) are correctly using global0 profiles instead of erasing profile completely when IPA counts drops to 0, the scaling in ipa-cp is not doing that, so we lose info and possibly some code quality. I will fix that incrementally. Similarly ipa-split, when offlining region with 0 entry count may re-do frequency propagation to get something useful. gcc/ChangeLog: * cgraph.cc (cgraph_node::apply_scale): New member function. * cgraph.h (struct cgraph_node): declare. * ipa-cp.cc (update_counts_for_self_gen_clones): Use cgraph_node::apply_scale. (update_profiling_info): Do not overwrite local profile when dropping to 0 global profile. (update_specialized_profile): Likewise. * ipa-inline-transform.cc (update_noncloned_counts): Remove. (can_remove_node_now_p_1): Fix formating. (clone_inlined_nodes): Use cgraph_node::apply_scale. * profile-count.cc (profile_count::dump): Do not ICE when count is not compatible with entry block count. * tree-cfg.cc (gimple_verify_flow_info): Check compatibility of count and entry block count. Diff: --- gcc/cgraph.cc | 20 + gcc/cgraph.h| 3 ++ gcc/ipa-cp.cc | 73 ++--- gcc/ipa-inline-transform.cc | 25 ++-- gcc/profile-count.cc| 13 ++-- gcc/tree-cfg.cc | 12 6 files changed, 70 insertions(+), 76 deletions(-) diff --git a/gcc/cgraph.cc b/gcc/cgraph.cc index 3f95ca1fa85c..4a037a7bab10 100644 --- a/gcc/cgraph.cc +++ b/gcc/cgraph.cc @@ -179,6 +179,26 @@ cgraph_node::function_version (void) return cgraph_fnver_htab->find (&key); } +/* Scale profile by NUM/DEN. Walk into inlined clones. */ + +void +cgraph_node::apply_scale (profile_count num, profile_count den) +{ + struct cgraph_edge *e; + + profile_count::adjust_for_ipa_scaling (&num, &den); + + for (e = callees; e; e = e->next_callee) +{ + if (!e->inline_failed) + e->callee->apply_scale (num, den); + e->count = e->count.apply_scale (num, den); +} + for (e = indirect_calls; e; e = e->next_callee) +e->count = e->count.apply_scale (num, den); + count = count.apply_scale (num, den); +} + /* Insert a new cgraph_function_version_info node into cgraph_fnver_htab corresponding to cgraph_node NODE. */ cgraph_function_version_info * diff --git a/gcc/cgraph.h b/gcc/cgraph.h index 8dbe36eac09d..ba9a8a25e396 100644 --- a/gcc/cgraph.h +++ b/gcc/cgraph.h @@ -1256,6 +1256,9 @@ struct GTY((tag ("SYMTAB_FUNCTION"))) cgraph_node : public symtab_node it is not used in any other non-standard way. */ bool only_called_directly_p (void); + /* Scale profile by NUM/DEN. Walk into inlined clones. */ + void apply_scale (profile_count num, profile_count den); + /* Return true when function is only called directly or it has alias. i.e. it is not externally visible, address was not taken and it is not used in any other non-standard way. */ diff --git a/gcc/ipa-cp.cc b/gcc/ipa-cp.cc index 73cf9040fad7..92e234e67162 100644 --- a/gcc/ipa-cp.cc +++ b/gcc/ipa-cp.cc @@ -4666,19 +4666,12 @@ update_counts_for_self_gen_clones (cgraph_node *orig_node, unsigned i = 0; for (cgraph_node *n : self_gen_clones) { - profile_count orig_count = n->count; profile_count new_count = (redist_sum / self_gen_clones.length () + other_edges_count[i]); new_count = lenient_count_portion_handling (new_count, orig_node); - n->count = new_count; - profile_count::adjust_for_ipa_scaling (&new_count, &orig_count); + n->apply_scale (new_count, n->count); for (cgraph_ed
[gcc r16-1348] diagnostics: convert enum logical_location_kind to enum class
https://gcc.gnu.org/g:bf0c6e1d34fd9cab0bef4d260f7e482e5fd4a371 commit r16-1348-gbf0c6e1d34fd9cab0bef4d260f7e482e5fd4a371 Author: David Malcolm Date: Mon Jun 9 14:15:25 2025 -0400 diagnostics: convert enum logical_location_kind to enum class No functional change intended. gcc/ChangeLog: * diagnostic-format-sarif.cc (maybe_get_sarif_kind): Update for conversion of enum logical_location_kind to enum class. * diagnostic.cc (logical_location_manager::function_p): Likewise. * libgdiagnostics.cc (html-output/missing-semicolon.py::get_kind): Likewise. * logical-location.h (enum logical_location_kind): Convert to... (enum class logical_location_kind): ...this. * selftest-logical-location.cc (test_logical_location_manager::item_from_funcname): Update for conversion of enum logical_location_kind to enum class. * tree-logical-location.cc (tree_logical_location_manager::get_kind): Likewise. Signed-off-by: David Malcolm Diff: --- gcc/diagnostic-format-sarif.cc | 40 +++--- gcc/diagnostic.cc| 18 - gcc/libgdiagnostics.cc | 38 ++-- gcc/logical-location.h | 42 gcc/selftest-logical-location.cc | 2 +- gcc/tree-logical-location.cc | 12 ++-- 6 files changed, 76 insertions(+), 76 deletions(-) diff --git a/gcc/diagnostic-format-sarif.cc b/gcc/diagnostic-format-sarif.cc index 7dcd126aeb23..853a8333b3cc 100644 --- a/gcc/diagnostic-format-sarif.cc +++ b/gcc/diagnostic-format-sarif.cc @@ -2735,51 +2735,51 @@ maybe_get_sarif_kind (enum logical_location_kind kind) { default: gcc_unreachable (); -case LOGICAL_LOCATION_KIND_UNKNOWN: +case logical_location_kind::unknown: return nullptr; /* Kinds within executable code. */ -case LOGICAL_LOCATION_KIND_FUNCTION: +case logical_location_kind::function: return "function"; -case LOGICAL_LOCATION_KIND_MEMBER: +case logical_location_kind::member: return "member"; -case LOGICAL_LOCATION_KIND_MODULE: +case logical_location_kind::module_: return "module"; -case LOGICAL_LOCATION_KIND_NAMESPACE: +case logical_location_kind::namespace_: return "namespace"; -case LOGICAL_LOCATION_KIND_TYPE: +case logical_location_kind::type: return "type"; -case LOGICAL_LOCATION_KIND_RETURN_TYPE: +case logical_location_kind::return_type: return "returnType"; -case LOGICAL_LOCATION_KIND_PARAMETER: +case logical_location_kind::parameter: return "parameter"; -case LOGICAL_LOCATION_KIND_VARIABLE: +case logical_location_kind::variable: return "variable"; /* Kinds within XML or HTML documents. */ -case LOGICAL_LOCATION_KIND_ELEMENT: +case logical_location_kind::element: return "element"; -case LOGICAL_LOCATION_KIND_ATTRIBUTE: +case logical_location_kind::attribute: return "attribute"; -case LOGICAL_LOCATION_KIND_TEXT: +case logical_location_kind::text: return "text"; -case LOGICAL_LOCATION_KIND_COMMENT: +case logical_location_kind::comment: return "comment"; -case LOGICAL_LOCATION_KIND_PROCESSING_INSTRUCTION: +case logical_location_kind::processing_instruction: return "processingInstruction"; -case LOGICAL_LOCATION_KIND_DTD: +case logical_location_kind::dtd: return "dtd"; -case LOGICAL_LOCATION_KIND_DECLARATION: +case logical_location_kind::declaration: return "declaration"; /* Kinds within JSON documents. */ -case LOGICAL_LOCATION_KIND_OBJECT: +case logical_location_kind::object: return "object"; -case LOGICAL_LOCATION_KIND_ARRAY: +case logical_location_kind::array: return "array"; -case LOGICAL_LOCATION_KIND_PROPERTY: +case logical_location_kind::property: return "property"; -case LOGICAL_LOCATION_KIND_VALUE: +case logical_location_kind::value: return "value"; } } diff --git a/gcc/diagnostic.cc b/gcc/diagnostic.cc index 5b8eb7d14042..ab52e34e2fb5 100644 --- a/gcc/diagnostic.cc +++ b/gcc/diagnostic.cc @@ -1059,17 +1059,17 @@ logical_location_manager::function_p (key k) const { default: gcc_unreachable (); -case LOGICAL_LOCATION_KIND_UNKNOWN: -case LOGICAL_LOCATION_KIND_MODULE: -case LOGICAL_LOCATION_KIND_NAMESPACE: -case LOGICAL_LOCATION_KIND_TYPE: -case LOGICAL_LOCATION_KIND_RETURN_TYPE: -case LOGICAL_LOCATION_KIND_PARAMETER: -case LOGICAL_LOCATION_KIND_VARIABLE: +case logical_location_kind::unknown: +case logical_location_kind::module_: +case logical_location_kind::namespace_: +case logical_location_kind::type: +case logical_location_kind::return_type: +case log
[gcc r16-1345] PR modula2/119779: ASM examples no longer work
https://gcc.gnu.org/g:0adb415d128cf54b607b71f1022bbf088ab6ae36 commit r16-1345-g0adb415d128cf54b607b71f1022bbf088ab6ae36 Author: Gaius Mulley Date: Mon Jun 9 15:26:35 2025 +0100 PR modula2/119779: ASM examples no longer work This patch introduces a regression test using the example in the documentation and tests it using -masm=intel on x86_64-*-gnu systems. gcc/testsuite/ChangeLog: PR modula2/119779 * gm2.dg/doc/examples/run/pass/doc-examples-run-pass.exp: New test. * gm2.dg/doc/examples/run/pass/exampleadd2.mod: New test. Signed-off-by: Gaius Mulley Diff: --- .../examples/run/pass/doc-examples-run-pass.exp| 17 +++ .../gm2.dg/doc/examples/run/pass/exampleadd2.mod | 35 ++ 2 files changed, 52 insertions(+) diff --git a/gcc/testsuite/gm2.dg/doc/examples/run/pass/doc-examples-run-pass.exp b/gcc/testsuite/gm2.dg/doc/examples/run/pass/doc-examples-run-pass.exp new file mode 100644 index ..6fb7d6e2cf37 --- /dev/null +++ b/gcc/testsuite/gm2.dg/doc/examples/run/pass/doc-examples-run-pass.exp @@ -0,0 +1,17 @@ +# Compile tests, no torture testing. +# +# These tests should all pass. + +# Load support procs. +load_lib gm2-dg.exp + +gm2_init_pim4 $srcdir/$subdir -masm=intel + +# Initialize `dg'. +dg-init + +# Main loop. +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.mod]] "" "" + +# All done. +dg-finish diff --git a/gcc/testsuite/gm2.dg/doc/examples/run/pass/exampleadd2.mod b/gcc/testsuite/gm2.dg/doc/examples/run/pass/exampleadd2.mod new file mode 100644 index ..8bab2994c226 --- /dev/null +++ b/gcc/testsuite/gm2.dg/doc/examples/run/pass/exampleadd2.mod @@ -0,0 +1,35 @@ +(* { dg-do assemble { target { x86_64-*-gnu* } } } *) +(* { dg-options "-masm=intel" } *) +(* { dg-do run { target x86_64-*-gnu* } } *) + +MODULE exampleadd2 ; + +FROM libc IMPORT printf, exit ; + + +PROCEDURE Example (foo, bar: LONGCARD) : CARDINAL ; +VAR + myout: LONGCARD ; +BEGIN + ASM VOLATILE ( +"mov rax, %[left]; add rax, %[right]; mov %[output], rax;" + : [output] "=rm" (myout) (* outputs *) + : [left] "rm" (foo), [right] "rm" (bar) (* inputs *) + : "rax") ;(* we trash *) + RETURN( myout ) +END Example ; + +VAR + a, b, c: CARDINAL ; +BEGIN + a := 1 ; + b := 2 ; + c := Example (a, b) ; + IF c = 3 + THEN + printf ("success result from function is %d\n", c) ; + ELSE + printf ("example failed to return 3, seen %d\n" , c) ; + exit (1) + END +END exampleadd2. \ No newline at end of file
[gcc r16-1347] PR modula2/120606: FOR loop ICE if the last expression uses an array
https://gcc.gnu.org/g:639a147414ab2b870f9482123fcaa1821e0d5475 commit r16-1347-g639a147414ab2b870f9482123fcaa1821e0d5475 Author: Gaius Mulley Date: Mon Jun 9 18:26:36 2025 +0100 PR modula2/120606: FOR loop ICE if the last expression uses an array This patch fixes the ICE which occurs if the last expression is an array. It ensures that the start and end values of the for loop expressions are dereferenced. gcc/m2/ChangeLog: PR modula2/120606 * gm2-compiler/M2Quads.mod (ForLoopLastIterator): Dereference start and end expressions e1 and e2 respectively. gcc/testsuite/ChangeLog: PR modula2/120606 * gm2/pim/pass/forarray.mod: New test. Signed-off-by: Gaius Mulley Diff: --- gcc/m2/gm2-compiler/M2Quads.mod | 2 ++ gcc/testsuite/gm2/pim/pass/forarray.mod | 21 + 2 files changed, 23 insertions(+) diff --git a/gcc/m2/gm2-compiler/M2Quads.mod b/gcc/m2/gm2-compiler/M2Quads.mod index b5455d09c66f..748ce2498dbb 100644 --- a/gcc/m2/gm2-compiler/M2Quads.mod +++ b/gcc/m2/gm2-compiler/M2Quads.mod @@ -4646,6 +4646,8 @@ BEGIN BySym) ; MetaErrorDecl (BySym, TRUE) ELSE + e1 := DereferenceLValue (e1tok, e1) ; + e2 := DereferenceLValue (e2tok, e2) ; GenQuadOTypetok (bytok, LastForIteratorOp, LastIterator, Make2Tuple (e1, e2), BySym, FALSE, FALSE, bytok, MakeVirtual2Tok (e1tok, e2tok), bytok) diff --git a/gcc/testsuite/gm2/pim/pass/forarray.mod b/gcc/testsuite/gm2/pim/pass/forarray.mod new file mode 100644 index ..e1b41e793bc0 --- /dev/null +++ b/gcc/testsuite/gm2/pim/pass/forarray.mod @@ -0,0 +1,21 @@ +MODULE forarray ; + + +VAR + array: ARRAY [0..10] OF CARDINAL ; + + +PROCEDURE Init ; +VAR + i, n: CARDINAL ; +BEGIN + array[0] := 10 ; + n := 0 ; + FOR i := 1 TO array[n] DO + END +END Init ; + + +BEGIN + Init +END forarray.