aboutsummaryrefslogtreecommitdiff
path: root/gcc
AgeCommit message (Collapse)AuthorFilesLines
8 daysada: Give a warning for huge imported objectsEric Botcazou1-25/+36
This is a follow-up to a recent change, where a warning was implemented for huge library-level objects. However it is not given if the objects are imported, although an indirection is also added for them under the hood to match the export side. gcc/ada/ChangeLog: * gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Variable>: Give a warning for huge imported objects as well.
8 daysada: Get rid of TYPE_ALIGN_OK flag in gcc-interfaceEric Botcazou6-19/+41
The TYPE_ALIGN_OK flag had originally been a GCC flag tested in the RTL expander and was at some point kicked out of the middle-end to become a pure Gigi flag. But it's only set for tagged types and CW-equivalent types and can be replaced by a explicit predicate without too much work. gcc/ada/ChangeLog: * gcc-interface/ada-tree.h (TYPE_ALIGN_OK): Delete. * gcc-interface/decl.cc (gnat_to_gnu_entity): Do not set it. * gcc-interface/gigi.h (standard_datatypes): Add ADT_tag_name_id. (tag_name_id): New macro. (type_is_tagged_or_cw_equivalent): New inline predicate. * gcc-interface/trans.cc (gigi): Initialize tag_name_id. (gnat_to_gnu) <N_Unchecked_Type_Conversion>: Replace tests on TYPE_ALIGN_OK with calls to type_is_tagged_or_cw_equivalent. (addressable_p): Likewise. * gcc-interface/utils.cc (convert): Likewise. * gcc-interface/utils2.cc (build_binary_op): Likewise.
8 daysada: Fix crash on reference to aliased object of packed array type with -gEric Botcazou1-0/+2
This happens when the object is declared in another compilation unit. gcc/ada/ChangeLog: * gcc-interface/misc.cc (gnat_get_array_descr_info): In the record type case, bail out if the original array type cannot be retrieved.
8 daysada: Implement overflow checking for unsigned typesEric Botcazou2-32/+79
The implementation is essentially mirrored from the one for signed types. gcc/ada/ChangeLog: * gcc-interface/gigi.h (standard_datatypes): Add ADT_uns_mulv64_decl and ADT_uns_mulv128_decl. (uns_mulv64_decl): New macro. (uns_mulv128_decl): Likewise. * gcc-interface/trans.cc (gigi): Create the uns_mulv64_decl and uns_mulv128_decl declarations. (gnat_to_gnu) <N_Op_Add>: Perform an overflow check for unsigned integer addition, subtraction and multiplication if required. <N_Op_Minus>: Perform an overflow check for unsigned integer negation if required. (build_unary_op_trapv): Add support for unsigned types. (build_binary_op_trapv): Likewise. <MINUS_EXPR>: Perform the check if the LHS is zero in the signed case as well.
8 daysada: Perform predicate check before, not after, parameter copy back.Steve Baird1-1/+5
In the case of a call to a subprogram that has an out (or in-out) parameter that is passed by copy, the caller performs copy-back after the call returns. If the actual parameter is a view conversion to a subtype that has an enabled predicate, then the predicate check performed at that point should be performed before, not after, the operand of the view conversion is updated. gcc/ada/ChangeLog: * exp_ch6.adb (Expand_Actuals): After building the tree for a predicate check, call Prepend_To instead of Append_To so that the check is performed before, instead of after, the corresponding parameter copy-back.
8 daysada: Create a ghost region for pragma annotateViljar Indus1-0/+9
Create a ghost region for pragma annotate so that we are able to analyze the entity references correctly inside the pragma. gcc/ada/ChangeLog: * sem_prag.adb: Create a ghost region for pragma annotate before analyzing its arguments.
8 daysada: Check instantces of ghost iterator functionsViljar Indus1-6/+25
Since we do not analyze the policy errors for expanded code we need to check the functions specified in the Iterable aspect whenever we are analyzing an iterator spcification with that aspect. gcc/ada/ChangeLog: * sem_ch5.adb (Analyze_Iterator_Specification): Check ghost context of Iterable functions when handling iterator specifications with an Iterable aspect.
8 daysada: Update coding styleViljar Indus1-6/+5
gcc/ada/ChangeLog: * ghost.adb (Check_Ghost_Policy): Update coding style.
8 daysada: Ignore ghost policy errors inside aspect IterableViljar Indus1-0/+29
It is OK to define a checked ghost type with an iterable aspect that has ignored Iterable functions. gcc/ada/ChangeLog: * ghost.adb (Check_Ghost_Policy): Avoid triggering a ghost policy error if the policy is referenced within the Iterable aspect.
8 daysada: Check ghost level dependencies inside assignmentsViljar Indus1-0/+39
Check that entities on the RHS are ghost level dependent on the entities on the LHS of the assignemnt. gcc/ada/ChangeLog: * ghost.adb (Is_OK_Statement): Check the levels of the assignee with the levels of the entity are ghost level dependent. (Check_Assignement_Levels): New function for checking the level dependencies.
8 daysada: Tune description of Ghost_Assertion_LevelPiotr Trojanek1-2/+2
Fix grammar in comment. gcc/ada/ChangeLog: * einfo.ads (Ghost_Assertion_Level): Fix comment.
8 daysada: Apply ghost regions for assigmnents correctlyViljar Indus1-76/+56
When frontend is operating in GNATprove mode (where expander is disabled), it should check ghost policy for assignment statements just like it does for other statements. This is because we want ghost policy errors to be reported not just by GNAT, but also by GNATprove. Additionally we need to perform the checks for valid location of ghost assigments based on the region around the assigment before we create the region for the assignment itself. gcc/ada/ChangeLog: * ghost.adb (Mark_And_Set_Ghost_Assignment): Create a ghost region for an assigment irregardless of whether the expander is active. Relocate the Assignment validity checks from Is_OK_Statement to this subprogram.
8 daysada: Compiler crash on container aggregate association with nonstatic key choiceGary Dismukes1-1/+3
The compiler blows up on a container aggregate with a container element association that has a key_choice given by a nonstatic key expression. This happens in the size computation for the aggregate due to calling Update_Choices with the nonstatic expression. The fix is simply to condition the call to Update_Choices on whether the choice expression is static. gcc/ada/ChangeLog: * exp_aggr.adb (Build_Container_Aggr_Code.Build_Size_Expr): In the case of an association with a single choice, only call Update_Choices when the choice expression is nonstatic.
8 daysada: Fix visibility bug related to target nameBob Duff2-16/+3
This patch fixes the following bug: If the right-hand side of an expression contains a target name (i.e. "@"), and also contains a reference to a user-defined operator that is directly visible because of a "use type" clause on a renaming of the package where the operator is declared, the compiler gives an incorrect error saying that the renamed package is not visible. It turns out that setting Entity of resolved nodes is unnecessary and wrong; the fix is to simply remove that code. gcc/ada/ChangeLog: * exp_ch5.adb (Expand_Assign_With_Target_Names.Replace_Target): Remove code setting Entity to Empty. * sinfo.ads (Has_Target_Names): Improve comment: add "@" to clarify what "target name" means, and remove the content-free phrase "and must be expanded accordingly."
8 daysada: Fix regression in Root_Type -- adjustmentBob Duff1-5/+1
Recent changes "Fix regression in Root_Type" and "Crash on b3a1004 with assertions enabled" are partially redundant; they are addressing the same bug. This patch adjusts the former in the case of Root_Type. But we leave Root_Type_If_Set alone; debugging printouts should survive bugs when possible. gcc/ada/ChangeLog: * einfo-utils.adb (Root_Type): Do not deal with missing Etype.
8 daysada: Fix regression in Root_TypeBob Duff1-7/+10
Previous change, "Make pp and friends more robust (base type only)" introduced a bug in Root_Type. Etype (T) can, in fact, be Empty (but only in case of errors.) This patch fixes it. gcc/ada/ChangeLog: * einfo-utils.adb (Root_Type): Deal with missing Etype. (Root_Type_If_Set): Likewise.
8 daysada: Crash on b3a1004 with assertions enabledJavier Miranda3-4/+18
The compilation of files b3a10041.ads and b3a10042.adb crash when the compiler is built with assertions enabled. gcc/ada/ChangeLog: * freeze.adb (Freeze_Entity): Protect call to Associated_Storage_Pool since it cannot be used when the Etype is not set. * sem_ch3.adb (Access_Type_Declaration): Ditto. * sem_aux.adb (Is_Derived_Type): Protect call to Root_Type since it cannot be used when the Etype is not set.
8 daysada: Fix argument type of read() and write() on windowsTonu Naks2-4/+7
gcc/ada/ChangeLog: * libgnat/s-crtl.ads: define unsigned * libgnat/s-crtl__mingw.adb (read, write): change arg type
8 daysada: Allow implicit packing of arrays when larger than neededBob Duff2-25/+24
For Implicit_Packing, do not require the Size clause to exactly match the packed size. For example, an array of 7 Booleans will fit in 7 bits if packed, or 7*8=56 bits if not packed. This patch allows "for T'Size use 8;" to force packing in Implicit_Packing mode; previously, the compiler ignored Implicit_Packing unless it was exactly "use 7". Apparently, customers have that sort of code, and the whole point of Implicit_Packing is to allow such legacy code to work. We already do the right thing for records, at least in cases tested. We deliberately avoid changing the error messages given here. They could possibly use some work, but there are subtle interactions with the messages given in Sem_Ch13 for the same thing. gcc/ada/ChangeLog: * freeze.adb (Freeze_Entity): Change "=" to ">=" in size comparison for Implicit_Packing mode. Keep it as "=" for giving error messages. * opt.ads (Implicit_Packing): Minor: correct obsolete comment.
8 daysada: Crash on null aggregate of multidimensional typeJavier Miranda1-3/+18
A compiler built with assertions enabled crashes processing a null aggregate of multidimensional type. gcc/ada/ChangeLog: * sem_aggr.adb (Report_Null_Array_Constraint_Error): Adjust code for reporting the error on enumeration types. (Resolve_Null_Array_Aggregate): On multidimiensional arrays, avoid reporting the same error several times. Flag the node as raising constraint error when the bounds are known and some of them is known to raise constraint error.
8 daysada: Make pp and friends more robust (base type only)Bob Duff4-51/+135
Prior to this fix, if pp(N) tried to print a "base type only" field, and Base_Type(N) was not yet set, it would raise an exception, which was confusing. This patch makes it simply ignore such fields. Similarly for Impl_Base_Type_Only and Root_Type_Only fields. We do this by having alternative versions of Base_Type, Implementation_Base_Type, and Root_Type that return Empty in error cases, and call these alteratives from Treepr. We don't want to Base_Type and friends to return Empty; we want them to blow up when called from anywhere but Treepr. gcc/ada/ChangeLog: * atree.ads (Node_To_Fetch_From_If_Set): Alternative to Node_To_Fetch_From that returns Empty in error cases. For use only in Treepr. * treepr.adb (Print_Entity_Field): Avoid printing field if Node_To_Fetch_From_If_Set returns Empty. * einfo-utils.ads (Base_Type_If_Set): Alternative to Base_Type that returns Empty in error cases. (Implementation_Base_Type_If_Set): Likewise. (Root_Type_If_Set): Likewise. (Underlying_Type): Use more accurate result subtype. * einfo-utils.adb (Base_Type): Add Asserts. (Implementation_Base_Type): Add Assert; minor cleanup. (Root_Type): Add Assert; minor cleanup. Remove Assert that is redundant with predicate. (Base_Type_If_Set): Body of new function. (Implementation_Base_Type_If_Set): Body of new function. (Root_Type_If_Set): Body of new function.
8 daysada: Disable signals when calling pthread_create on QNXJohannes Kliemann2-4/+83
The QNX Certified Products Defect Notification from February 2025 mentions a potential memory leak when pthread_create is interrupted by a signal. It recommends to disable signals for this function call. gcc/ada/ChangeLog: * adaint.c: Add functions to disable and enable signals on QNX. * libgnarl/s-taprop__qnx.adb (Create_Task): Disable signals when calling pthread_create.
8 daysada: Refine condition for reporting warnings on components with abstract ↵Gary Dismukes1-20/+40
equality The initial implementation of the warning resulted in unwanted false positives for types that have a user-defined equality function (in which case abstract equality on components will typically not ever be invoked). The conditions for reporting the warning are refined by this change to exclude checking for presence of abstract component equality functions in the case where the containing type has a user-defined equality. gcc/ada/ChangeLog: * exp_ch4.adb (Expand_N_Op_Eq): Test for absence of user-defined equality on type being compared (for both array and record types) as a condition for checking for abstract equality on component types. Add a "???" comment about current limitations on issuing the new warning. (Warn_On_Abstract_Equality_For_Component): Remove temporary disabling of the warning. Improve comment on declaration.
8 daysada: Fix commentsRonan Desplanques1-3/+2
This patch fixes a reference to an Ada RM clause, fixes an occurrence of "unconstrained" that should have been "indefinite", and removes an incorrect claim that completing a partial view without discriminants with a full view with defaulted discriminants is an error situation. gcc/ada/ChangeLog: * sem_ch3.adb (Process_Discriminants, Process_Full_View): Fix comments.
8 daysada: Fix compile time evaluation needed for static unfoldingsDenis Mazzucato1-7/+0
Unfolding of static expressions is needed when evaluating static bounds, even in the presence of strict analysis. Otherwise, we may wrongly identify static predicates as dynamic ones, and thus require unnecessary "others" default case. gcc/ada/ChangeLog: * sem_attr.adb (Eval_Attribute): Remove strict analysis condition.
8 daysada: Better warning when single letter package conflicts with predefined ↵Denis Mazzucato1-2/+35
unit naming This patch improves the warning message when the actual file name of a child package with a single letter parent isn't the expected one because it may collide with a predefined unit name. The warning explain why in this specific case the expected name is not the standard one using the minus to separate parents with children. gcc/ada/ChangeLog: * par-load.adb (Load): Better warning message.
8 daysada: Set Related_Expression on compiler-generated Valid_Scalars functionsTucker Taft1-2/+4
When creating the local functions to implement the Valid_Scalars attribute for array and record types, set a Related_Expression that points to the original attribute reference (blah'Valid_Scalars). This allows the Inspector to give a more user-friendly name when these functions are called and they are known, for example, to always return True. gcc/ada/ChangeLog: * exp_attr.adb (Build_Array_VS_Func and Build_Record_VS_Func): Pass in the Attr as the Related_Node parametr when calling Make_Temporary for the Func_Id for the array and record Valid_Scalars local functions.
8 daysada: Improve documentation comment of Find_Type_NameRonan Desplanques1-6/+19
The meaning of the return value of Find_Type_Name depends greatly on whether the declaration it's passed is a completion. This patch adds a description of this to the documentation comment of Find_Type_Name. gcc/ada/ChangeLog: * sem_ch3.ads (Find_Type_Name): Improve documentation comment.
8 daysada: Disable new warning for composite equality ops that can raise Program_ErrorGary Dismukes1-0/+7
The new warning is spuriously flagged on membership tests in vss-xml-implementation-html_writer_data.adb, leading to the GNAT CB failing, so we disable it until that issue can be resolved. gcc/ada/ChangeLog: * exp_ch4.adb (Warn_On_Abstract_Equality_For_Component): Temporarily disable warning.
8 daysRISC-V: Add min/max patterns for ifcvt.Robin Dapp4-3/+66
ifcvt likes to emit (set (if_then_else) (ge (reg 1) (reg2)) (reg 1) (reg 2)) which can be recognized as min/max patterns in the backend. This patch adds such patterns and the respective iterators as well as a test. gcc/ChangeLog: * config/riscv/bitmanip.md (*<bitmanip_minmax_cmp_insn>_cmp_<mode>3): New min/max ifcvt pattern. * config/riscv/iterators.md (minu): New iterator. * config/riscv/riscv.cc (riscv_noce_conversion_profitable_p): Remove riscv-specific adjustment. gcc/testsuite/ChangeLog: * gcc.target/riscv/zbb-min-max-04.c: New test.
8 daysifcvt: Clarify if_info.original_cost.Robin Dapp16-89/+112
Before noce_find_if_block processes a block it sets up an if_info structure that holds the original costs. At that point the costs of the then/else blocks have not been added so we only care about the "if" cost. The code originally used BRANCH_COST for that but was then changed to COST_N_INSNS (2) - a compare and a jump. This patch computes the jump costs via insn_cost (if_info.jump, ...) under the assumption that the target takes BRANCH_COST into account when costing a jump instruction. In noce_convert_multiple_sets we keep track of the need for the initial CC comparison. If needed for the generated sequence we add its cost in default_noce_conversion_profitable_p. gcc/ChangeLog: * ifcvt.cc (noce_convert_multiple_sets_1): Add use_cond_earliest param. (noce_convert_multiple_sets): Set use_cond_earliest. (noce_process_if_block): Just use original cost. (noce_find_if_block): Use insn_cost (jump_insn). gcc/testsuite/ChangeLog: * gcc.target/riscv/addsieq.c: Remove xfail and expect conversion through noce_convert_multiple_sets. * gcc.target/riscv/addsifeq.c: Ditto. * gcc.target/riscv/addsifge.c: Ditto. * gcc.target/riscv/addsifgt.c: Ditto. * gcc.target/riscv/addsifle.c: Ditto. * gcc.target/riscv/addsiflt.c: Ditto. * gcc.target/riscv/addsifne.c: Ditto. * gcc.target/riscv/addsige.c: Ditto. * gcc.target/riscv/addsigeu.c: Ditto. * gcc.target/riscv/addsigt.c: Ditto. * gcc.target/riscv/addsigtu.c: Ditto. * gcc.target/riscv/addsile.c: Ditto. * gcc.target/riscv/addsileu.c: Ditto. * gcc.target/riscv/addsilt.c: Ditto. * gcc.target/riscv/addsiltu.c: Ditto.
8 daystestsuite: Fix asm-hard-reg-error-{4,5}.c for non-LRA targetsStefan Schulze Frielinghaus2-7/+29
Hard register constraints are only supported for LRA and not old reload. Targets hppa, m68k, pdp11, rx, sh, vax do not default to LRA which is why these tests fail there. Limit the tests to LRA targets, although, this means that currently on these targets the tests are skipped by default. Since the tests are about general logic, the extra coverage we loose by skipping these targets is negligible. For hppa, register 0 cannot be used as a general register. Therefore, use temporary registers r20 and r21 instead. Likewise, for AVR use r20 and r24 instead. gcc/testsuite/ChangeLog: * gcc.dg/asm-hard-reg-error-4.c: Limit the test to LRA targets. Use registers r20 and r21 for hppa. Likewise, for AVR use r20 and r24 instead. * gcc.dg/asm-hard-reg-error-5.c: Ditto.
8 daysRISC-V: Fix can_find_related_mode_p for VLS typesKito Cheng5-4/+161
can_find_related_mode_p incorrectly handled VLS (Vector Length Specific) types by using TARGET_MIN_VLEN directly, which is in bits, instead of converting it to bytes as required. This patch fixes the issue by dividing TARGET_MIN_VLEN by 8 to convert from bits to bytes when calculating the number of units for VLS modes. The fix enables proper vectorization for several test cases: - zve32f-1.c: Now correctly finds vector mode for SF mode in foo3, enabling vectorization of an additional loop. - zve32f_zvl256b-1.c and zve32x_zvl256b-1.c: Added -mrvv-max-lmul=m2 option to handle V8SI[2] (vector array mode) requirements during vectorizer analysis, which needs V16SI to pass, and V16SI was enabled incorrectly before. Changes since V4: - Fix testsuite, also triaged why changed. gcc/ChangeLog: * config/riscv/riscv-selftests.cc (riscv_run_selftests): Call run_vectorize_related_mode_selftests. (test_vectorize_related_mode): New function to test vectorize_related_mode behavior. (run_vectorize_related_mode_selftests): New function to run all vectorize_related_mode tests. (run_vectorize_related_mode_vla_selftests): New function to test VLA modes. (run_vectorize_related_mode_vls_rv64gcv_selftests): New function to test VLS modes on rv64gcv. (run_vectorize_related_mode_vls_rv32gc_zve32x_zvl256b_selftests): New function to test VLS modes on rv32gc_zve32x_zvl256b. (run_vectorize_related_mode_vls_selftests): New function to run all VLS mode tests. * config/riscv/riscv-v.cc (can_find_related_mode_p): Fix VLS type handling by converting TARGET_MIN_VLEN from bits to bytes. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/zve32f-1.c: Update expected vectorization count from 2 to 3. * gcc.target/riscv/rvv/autovec/zve32f_zvl256b-1.c: Add -mrvv-max-lmul=m2 option. * gcc.target/riscv/rvv/autovec/zve32x_zvl256b-1.c: Add -mrvv-max-lmul=m2 option.
8 daysLoongArch: testsuite: Modify the tests to make the test pass.Lulu Cheng7-71/+47
Committing r16-3673 cause the test cases in the list to fail. Make the test pass by modifying the test case or adding compilation options. gcc/testsuite/ChangeLog: * gcc.target/loongarch/cmodel-extreme-1.c: Add -fPIC. * gcc.target/loongarch/cmodel-extreme-2.c: Likewise. * gcc.target/loongarch/tls-gd-noplt.c: Likewise. * gcc.target/loongarch/tls-extreme-macro.c: Likewise. * gcc.target/loongarch/func-call-medium-2.c: Modify. * gcc.target/loongarch/func-call-medium-3.c: Modify. * gcc.target/loongarch/func-call-medium-4.c: Removed.
8 daysDaily bump.GCC Administrator6-1/+180
9 daysc: Add tests for some C2Y removals of undefined behaviorJoseph Myers7-0/+142
C2Y removes various instances of undefined behavior, typically making them either constraint violations or implementation-defined. In many but not all such cases, GCC's existing behavior is compatible with the C2Y changes. For an initial batch of such cases, add explicit tests for how GCC behaves in C2Y mode; more such cases will need tests added in future patches, and there are also some such changes that will need changes to how GCC behaves, not just new tests. (Some of the individual examples in these tests may have been constraint violations even before C2Y.) Tested for x86_64-pc-linux-gnu. * gcc.dg/c2y-function-qual-1.c, gcc.dg/c2y-incomplete-1.c, gcc.dg/c2y-inline-1.c, gcc.dg/c2y-pointer-1.c, gcc.dg/c2y-register-array-1.c, gcc.dg/c2y-storage-class-1.c, gcc.dg/c2y-struct-empty-1.c: New tests.
9 daysAVR: Disable tree-switch-conversion per default.Georg-Johann Lay1-0/+7
There are at least two cases where tree-switch-conversion leads to unpleasant resource allocation: PR49857 The lookup table lives in RAM. This is the case for all devices that locate .rodata in RAM, which is for almost all AVR devices. PR81540 Code is bloated for 64-bit inputs. As far as PR49857 is concerned, a target hook that may add an address-space qualifier to the lookup table is the obvious solution, though a respective patch has always been rejected by global maintainers for non-technical reasons. gcc/ PR target/81540 PR target/49857 * common/config/avr/avr-common.cc: Disable -ftree-switch-conversion.
9 daysxtensa: Correct a typoTakayuki 'January June' Suwa1-1/+1
That was introduced in commit 42db504c2fb2b460e24ca0e73b8559fc33b3cf33, over 15 years ago! gcc/ChangeLog: * config/xtensa/xtensa.h (TARGET_SMALL_REGISTER_CLASSES_FOR_MODE_P): Change "Xtrnase" in the comment to "Xtensa".
9 daysRISC-V: Fix typo in tt-ascalon-d8's pipeline description [PR121878]Peter Bergner2-6/+17
PR121878 shows a typo in the tt-ascalon-d8's pipeline description that leads to an ICE. The problem is that the vector define_insn_reservation patterns test for scalar modes rather than vector modes, meaning the insns don't get handled correctly. We could correct the modes, but given we could have multiple VLEN values, the number of modes we'd have to check can be large and mode iterators are not allowed in the mode attribute check. Instead, I've removed the mode check and replaced it with a test of the Selected Elenent Width (SEW). 2025-09-09 Peter Bergner <bergner@tenstorrent.com> gcc/ PR target/121878 * config/riscv/tt-ascalon-d8.md (tt_ascalon_d8_vec_idiv_half): Test the Selected Element Width (SEW) rather than the mode. (tt_ascalon_d8_vec_idiv_single): Likewise. (tt_ascalon_d8_vec_idiv_double): Likewise. (tt_ascalon_d8_vec_float_divsqrt_half): Likewise. (tt_ascalon_d8_vec_float_divsqrt_single): Likewise. (tt_ascalon_d8_vec_float_divsqrt_double): Likewise. gcc/testsuite/ PR target/121878 * gcc.target/riscv/pr121878.c: New test. Signed-off-by: Peter Bergner <bergner@tenstorrent.com>
9 daysFix -Wlto-type-mismatch warning during GNAT LTO buildEric Botcazou7-15/+17
The recent addition of Pragma_Unsigned_Base_Range to the enumeration type Pragma_Id has made it exceed 256 enumeration values and thus overflow the unsigned 8-bit type used for it on the C side. This should have stopped the build, except that a glitch in the Snames machinery causes one value to be dropped on the C side, leaving it at just 256 enumeration values. This fixes both issues, i.e. ensures that the number of enumeration values is the same on both sides and bumps the size of the C type to 16 bits. gcc/ada/ PR ada/121885 * snames.ads-tmpl (Pragma_Id): Rename Unknown_Pragma to Pragma_Unknown for the sake of XSnamesT. * snames.adb-tmpl (Get_Pragma_Id): Adjust to above renaming. * snames.h-tmpl (Attribute_Id): Change underlying type to Byte. (Get_Attribute_Id): Use Byte as return value. (Pragma_Id): Change underlying type to Word. (Get_Pragma_Id): Use Word as return value. * types.h (Word): New typedef. * exp_prag.adb (Expand_N_Pragma): Remove useless comment. * par-prag.adb (Prag): Adjust to above renaming. * sem_prag.adb (Analyze_Pragma): Likewise. (Sig_Flags): Likewise.
9 daysFix load/store bias handling for extractlast.Juergen Christ2-10/+33
The length returned by vect_get_loop_len is REALLEN + BIAS, but was assumed to be REALLEN - BIAS. If BIAS is -1, this leads to wrong code. gcc/ChangeLog: * tree-vect-loop.cc (vectorizable_live_operation_1): Fix load/store bias handling. gcc/testsuite/ChangeLog: * gcc.dg/vect/nodump-extractlast-1.c: New test. Signed-off-by: Juergen Christ <jchrist@linux.ibm.com>
9 daysc: Warn when returning nested functions that require a non-local context.Martin Uecker7-31/+412
This patch adds a mechanism to keep track whether nested functions require non-local context because they reference a variable of an enclosing scope. This is used for extending the existing -Wreturn-address warning to also warn for such nested functions. Certain exceptions are implemented for functions that do not requite a non-local context, because they reference only static variables, named constants, non-local variables in unevaluated sizeof, typeof or countof operators, or typedef. The logic is based on the existing infrastructure for determining use of undeclared static functions. Finally, To make sure that no trampolines are generated even when not using optimization, we mark the exempt functions with TREE_NO_TRAMPOLINE. gcc/c/ChangeLog: * c-tree.h: Add new macro C_DECL_NONLOCAL_CONTEXT and prototype for mark_decl_used. * c-typeck.cc (mark_decl_used): New function. (function_to_pointer_conversion): Mark exempt functions. (record_maybe_used_decl): Add `address' parameter. (build_external_ref): Change to mark_decl_used. (pop_maybe_used): Call mark_decl_used. (c_mark_addressable): Ditto. (c_finish_goto_label): Ditto. (c_finish_return): Add warning. * c-decl.cc (declspecs_add_type): Ditto. (grokdeclarator): Don't set C_DECL_REGISTER on function declarators. gcc/testsuite/ChangeLog: * gcc.dg/Wreturn-nested-1.c: New test. * gcc.dg/Wreturn-nested-2.c: New test. * gcc.dg/Wtrampolines-2.c: New test. * gcc.dg/Wtrampolines-3.c: New test.
9 daysRISC-V: Add pattern for vector-scalar single widening floating-point subPaul-Antoine Arras12-7/+79
This pattern enables the combine pass (or late-combine, depending on the case) to merge a float_extend'ed vec_duplicate into a minus RTL instruction. The other minus operand is already wide. Before this patch, we have four instructions, e.g.: fcvt.d.s fa0,fa0 vsetvli a5,zero,e64,m1,ta,ma vfmv.v.f v2,fa0 vfsub.vv v1,v1,v2 After, we get only one: vfwsub.wf v1,v1,fa0 gcc/ChangeLog: * config/riscv/autovec-opt.md (*vfwsub_wf_<mode>): New pattern to combine float_extend + vec_duplicate + vfsub.vv into vfwsub.wf. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/vx_vf/vf-1-f16.c: Add vfwsub.wf. * gcc.target/riscv/rvv/autovec/vx_vf/vf-1-f32.c: Likewise. * gcc.target/riscv/rvv/autovec/vx_vf/vf-2-f16.c: Likewise. * gcc.target/riscv/rvv/autovec/vx_vf/vf-2-f32.c: Likewise. * gcc.target/riscv/rvv/autovec/vx_vf/vf-3-f16.c: Likewise. * gcc.target/riscv/rvv/autovec/vx_vf/vf-3-f32.c: Likewise. * gcc.target/riscv/rvv/autovec/vx_vf/vf-4-f16.c: Likewise. * gcc.target/riscv/rvv/autovec/vx_vf/vf-4-f32.c: Likewise. * gcc.target/riscv/rvv/autovec/vx_vf/vf_binop.h (DEF_VF_BINOP_WIDEN_CASE_2, DEF_VF_BINOP_WIDEN_CASE_3): Swap operands. * gcc.target/riscv/rvv/autovec/vx_vf/vf_vfwsub-run-2-f16.c: New test. * gcc.target/riscv/rvv/autovec/vx_vf/vf_vfwsub-run-2-f32.c: New test.
9 daysc++: Fix null deref in maybe_diagnose_standard_trait [PR121859]Nathaniel Shead2-1/+15
A static member template doesn't always have a DECL_INITIAL, as in the below testcase, and so checking its TREE_CODE performs a null-pointer dereference. I don't think we need to specially detect this case as traits we care about are unlikely to be members, so this just adds the missing null check. PR c++/121859 gcc/cp/ChangeLog: * constraint.cc (maybe_diagnose_standard_trait): Check if expr is non-null. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-traits5.C: New test. Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
9 daystestsuite: Only scan for known file extensions in lto.expJakub Jelinek1-2/+2
This is something that has bothered me for a few years but I've only found time for it now. The glob used for finding *_1.* etc. counterparts to the *_0.* tests is too broad, so if one has say next to *_1.c file also *_1.c~ or *_1.c.~1~ or *_1.c.orig or *_1.c.bak etc. files, lto.exp will report a warning and the test will fail. So, e.g. in rpm build if some backported commit in patch form adds some gcc/testsuite/*.dg/lto/ test and one uses -b option to patch, if one doesn't remove the backup files, the test will fail. Looking through all the *.dg/lto/ directories, I only see c, C, ii, f, f90 and d extensions used right now for the *_1.* files (and higher), while for the *_0.* files also m, mm and f03 extensions are used. So, the following patch only searches for those (plus for Fortran uses the extensions searched by the gfortran.dg/lto/ driver, i.e. \[fF\]{,90,95,03,08} , not just f, f90 and f03). Tested on x86_64-linux and verified I got exactly the same number of grep '^Executing.on.host.*_[1-9]\.' testsuite/*/*.log before/after this patch when doing make check RUNTESTFLAGS=lto.exp except for 2 new ones which were previously failed because I had backup files for 2 tests. 2025-09-10 Jakub Jelinek <jakub@redhat.com> * lib/lto.exp (lto-execute-1): Search for _1.* etc. files only with a list of known extensions.
9 daysbitint: Fix up lowering optimization of .*_OVERFLOW ifns [PR121828]Jakub Jelinek2-3/+75
THe lowering of .{ADD,SUB,MUL}_OVERFLOW ifns is optimized, so that we don't in the common cases uselessly don't create a large _Complex _BitInt temporary with the first (real) part being the result and second (imag) part just being a huge 0 or 1, although we still do that if it can't be done. The optimizable_arith_overflow function checks when that is possible, like whether the ifn result is used at most twice, once in REALPART_EXPR and once in IMAGPART_EXPR in the same bb, etc. For IMAGPART_EXPR it then checks if it has a single use which is a cast to some integral non-bitint type (usually bool or int etc.). The final check is whether that cast stmt appears after the REALPART_EXPR (the usual case), in that case it is optimizable, otherwise it is not (because the lowering for optimizable ifns of this kind is done at the location of the REALPART_EXPR and it tweaks the IMAGPART_EXPR cast location at that point, so otherwise it would be set after use. Now, we also have an optimization for the REALPART_EXPR lhs being used in a single stmt - store in the same bb, in that case we don't have to store the real part result in a temporary but it can go directly into memory. Except that nothing checks for the IMAGPART_EXPR cast being before or after the store in this case, so the following testcase ICEs because we have a use before a def stmt. In bar (the function handled right already before this patch) we have _6 = .SUB_OVERFLOW (y_4(D), x_5(D)); _1 = REALPART_EXPR <_6>; _2 = IMAGPART_EXPR <_6>; a = _1; _3 = (int) _2; baz (_3); before the lowering, so we can just store the limbs of the .SUB_OVERFLOW into the limbs of a variable and while doing that compute the value we eventually store into _3 instead of the former a = _1; stmt. In foo we have _5 = .SUB_OVERFLOW (y_3(D), x_4(D)); _1 = REALPART_EXPR <_5>; _2 = IMAGPART_EXPR <_5>; t_6 = (int) _2; baz (t_6); a = _1; and we can't do that because the lowering would be at the a = _1; stmt and would try to set t_6 to the overflow flag at that point. We don't need to punt completely and mark _5 as _Complex _BitInt VAR_DECL though in this case, all we need is not merge the a = _1; store with the .SUB_OVERFLOW and REALPART_EXPR/IMAGPART_EXPR lowering. So, add _1 to m_names and lower the first 3 stmts at the _1 = REALPART_EXPR <_5>; location, optimizable_arith_overflow returned non-zero and so the cast after IMAGPART_EXPR was after it and then a = _1; will copy from the temporary VAR_DECL to memory. 2025-09-10 Jakub Jelinek <jakub@redhat.com> PR middle-end/121828 * gimple-lower-bitint.cc (gimple_lower_bitint): For REALPART_EXPR consumed by store in the same bb and with REALPART_EXPR from optimizable_arith_overflow, don't add REALPART_EXPR lhs to the m_names bitmap only if the cast from IMAGPART_EXPR doesn't appear in between the REALPART_EXPR and the store. * gcc.dg/bitint-126.c: New test.
9 daysexpr: Handle RAW_DATA_CST in store_constructor [PR121831]Jakub Jelinek3-8/+163
I thought this wouldn't be necessary because RAW_DATA_CST can only appear inside of (array) CONSTRUCTORs within DECL_INITIAL of TREE_STATIC vars, so there shouldn't be a need to expand it. Except that we have an optimization when reading ARRAY_REF from such a CONSTRUCTOR which will try to expand the constructor if it either can be stored by pieces (I think that is just fine) or if it is mostly zeros (which is at least 75% of the initializer zeros). Now the second case is I think in some cases desirable (say 256MB initializer and just 20 elements out of that non-zero, so clear everything and store 20 elements must be fastest and short), but could be really bad as well (say 40GB initializer with 10GB non-zero in it, especially if it doesn't result in the original variable being optimized away). Maybe it would help if expand_constructor and store_constructor* etc. had some optional argument with addresses into the original VAR_DECL so that it could be copying larger amounts of data like larger RAW_DATA_CSTs from there instead of pushing those into new .rodata again. And another problem is that we apparently expand the initializes twice, expand_constructor in store_constructor can expand the stores one and if expand_constructor returns non-NULL, we then expand_expr the CONSTRUCTOR again. to the same location. This patch doesn't address either of those issues, just adds RAW_DATA_CST support to store_constructor for now. For the can_store_by_pieces cases it stores those by pieces using a new callback very similar to string_cst_read_str, for the rest (unfortunately) forces it into a memory and copies from there. 2025-09-10 Jakub Jelinek <jakub@redhat.com> PR middle-end/121831 * expr.cc (raw_data_cst_read_str): New function. (store_constructor) <case ARRAY_TYPE>: Handle RAW_DATA_CST. * g++.dg/lto/pr121831_0.C: New test. * g++.dg/lto/pr121831_1.C: New test.
9 dayss390: Implement clz and ctz for SI modeJuergen Christ5-6/+45
To properly implement __builtin_ffs for SI mode, implement clz and (for >= z17) ctz for SI mode. Otherwise, gcc falls back to a libcall which causes problems for Linux kernel code. Also adjust the C?Z_DEFINED_VALUE_AT_ZERO macros to return 2. Since the optabs now return exactly the value set by these macros, return value 2 is more appropriate and leads to better code. gcc/ChangeLog: * config/s390/s390.h (CLZ_DEFINED_VALUE_AT_ZERO): Adjust and return 2. (CTZ_DEFINED_VALUE_AT_ZERO): Return 2. * config/s390/s390.md (clzsi2): Implement. (ctzsi2): Implement. gcc/testsuite/ChangeLog: * gcc.dg/vect/pr109011-2.c: Fix expected outcome. * gcc.dg/vect/pr109011-4.c: Fix expected outcome. * gcc.target/s390/ffs-1.c: New test. Signed-off-by: Juergen Christ <jchrist@linux.ibm.com>
9 daysc++: Change mangling of Intel/Motorola extended long double literalsJakub Jelinek5-0/+60
On Fri, Sep 05, 2025 at 09:57:06PM +0200, Matthias Kretz wrote: > > Hmm, would this fail for x86 long double, which is 80 bits? OK, just > > checked. It's mangled as 12/16 bytes on i686/x86_64. > > It seems that Clang and GCC disagree on mangling 80-Bit long double: > > I like Clang's interpretation of https://itanium-cxx-abi.github.io/cxx-abi/ > abi.html#mangle.float better. This patch changes the mangling of 80-bit long double literals from 24 or 32 digits (on m68k with padding bits in the middle, on x86 at the start) to just 20 hex digits. 2025-09-10 Jakub Jelinek <jakub@redhat.com> * mangle.cc (write_real_cst): Mangle Intel/Motorola extended 80-bit formats using 20 hex digits instead of 24 or 32. * g++.target/i386/mangle-ldbl-1.C: New test. * g++.target/i386/mangle-ldbl-2.C: New test. * g++.target/m68k/mangle-ldbl-1.C: New test. * g++.target/m68k/mangle-ldbl-2.C: New test.
9 dayss390: fix vec_extract_plus define insnMaximilian Immanuel Brandtner2-6/+162
Because of a wrong define_insn for vec_extract_plus a vector access wasn't combined with a preceeding plus operation which set the offset at which to perform the vector access even though the instruction offers that capability. Bootstrapped and regtested on s390x. gcc/ChangeLog: * config/s390/vector.md (*vec_extract<mode>_plus_zero_extend): Fix define insn. gcc/testsuite/ChangeLog: * gcc.target/s390/vector/vec-extract-3.c: New test. Signed-off-by: Maximilian Immanuel Brandtner <maxbr@linux.ibm.com>