aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2022-09-06[Ada] Handle new At_End expansion during unnestingJustin Squirek1-1/+10
This patch modifies the marking of nested subprograms requiring static links, so that the changes made to "At end" procedures get handled properly. gcc/ada/ * exp_unst.adb (Visit_Node): Add N_Block_Statement to the enclosing construct case since they can now have "At end" procedures. Also, recognize calls from "At end" procedures when recording subprograms.
2022-09-06[Ada] Fix comment about mapping of parameters and inlining static funcsPiotr Trojanek1-2/+3
Fix glitch in a cross-reference in comment. gcc/ada/ * inline.adb (Replace_Formal): Fix name of the referenced routine.
2022-09-06[Ada] Cleanup unnecessary shadowing in expansion of attribute OldPiotr Trojanek1-1/+0
Code cleanup; semantics is unaffected. gcc/ada/ * exp_attr.adb (Expand_N_Attribute_Reference [Attribute_Old]): Remove unnecessary local constant that was shadowing another constant with the same initial value.
2022-09-06[Ada] Fix a bug in the contract of formal ordered setsJulien Bortolussi1-3/+4
There are 2 main issues in the postcondition of the function Replace of the formal ordered sets, in the sub package Generic_Keys. One is related to the fact that when the element is changed, the key is also changed. The second one is due to the fact that the arrival of the new element might modify the ordering of the set and thus the Positions might be modified. As a consequence, the postcondition might be false and thus fail at runtime. gcc/ada/ * libgnat/a-cforse.ads (Replace): Fix the postcondition.
2022-09-06[Ada] Cope with scalar subtypes that have a non-scalar basetype.Steve Baird2-2/+6
In some cases, the compiler builds a subtype entity Typ such that Is_Scalar (Typ) is True and Is_Scalar (Base_Type (Typ)) is False. This comes up in some cases involving a subtype of a private type, where the full view of the private type is a scalar type. In such a situation, it may also be the case that Is_Enumeration_Type (Typ) is True and Is_Enumeration_Type (Base_Type (Typ)) is False. Some code incorrectly assumed that if a subtype is known to be a scalar (respectively, enumeration) type, then the same must be true of the base type of that subtype. Fix that code to handle the case where that assumption does not hold. gcc/ada/ * exp_attr.adb (Attribute_Valid): Ensure that PBtyp is initialized to a value for which Is_Scalar_Type is True. * checks.adb (Determine_Range): Call Implemention_Base_Type instead of Base_Type in order to ensure that result is suitable for passing to Enum_Pos_To_Rep.
2022-09-06[Ada] Place "at end" on body nodesBob Duff16-404/+237
This patch fixes a bug where finalization code might refer to variables outside their lifetime. The previous version moved declarations into the Handled_Statement_Sequence (HSS), so that the "at end" handler of the HSS could handle exceptions raised by those declarations. The First_Real_Statement field was used to find the first statement after the moved declarations. In addition, if the HSS already had exception handlers, it was wrapped in another layer of block_statement. This doesn't work if there are variable-sized objects allocated on the (primary) stack, because the stack will be popped before the "at end" is invoked. In the new version, we allow "at end" on nodes such as N_Subprogram_Body, in addition to HSS. We modify gigi so that such an "at end" applies to the whole body (declarations and HSS) by extending support for At_End_Proc mechanism to N_Block_Statement and N_*_Body nodes. This also removes the support for First_Real_Statement. In particular, an exception raised by the declarations will trigger the "at end". We no longer move declarations into the HSS, we no longer have a First_Real_Statement field, and we no longer do the wrapping mentioned above. This change requires various other changes, in cases where we depended on the First_Real_Statement and the moving/wrapping mentioned above. gcc/ada/ * gen_il-fields.ads (First_Real_Statement): Remove this field. * gen_il-gen-gen_nodes.adb: Remove the First_Real_Statement field. Add the At_End_Proc field to nodes that have both Declarations and HSS. * sinfo.ads (At_End_Proc): Document new semantics. (First_Real_Statement): Remove comment. * exp_ch11.adb (Expand_N_Handled_Sequence_Of_Statements): Remove First_Real_Statement. * exp_ch7.adb (Build_Cleanup_Statements): Remove "Historical note"; it doesn't seem useful, and we have revision history. (Create_Finalizer): Insert the finalizer later, typically in the statement list, in some cases. (Build_Finalizer_Call): Attach the "at end" handler to the parent of the HSS node in most cases, so it applies to declarations. (Expand_Cleanup_Actions): Remove Wrap_HSS_In_Block and the call to it. Remove the code that moves declarations. Remove some redundant code. * exp_ch9.adb (Build_Protected_Entry): Copy the At_End_Proc. (Build_Protected_Subprogram_Body): Reverse the sense of Exc_Safe, to avoid double negatives. Remove "Historical note" as in exp_ch7.adb. (Build_Unprotected_Subprogram_Body): Copy the At_End_Proc from the protected version. (Expand_N_Conditional_Entry_Call): Use First (Statements(...)) instead of First_Real_Statement(...). (Expand_N_Task_Body): Put the Abort_Undefer call at the beginning of the declarations, rather than in the HSS. Use First (Statements(...)) instead of First_Real_Statement(...). Copy the At_End_Proc. * inline.adb (Has_Initialized_Type): Return False if the declaration does not come from source. * libgnarl/s-tpoben.ads (Lock_Entries, Lock_Entries_With_Status): Document when these things raise Program_Error. It's not clear that Lock_Entries_With_Status ought to be raising exceptions, but at least it's documented now. * sem.ads: Minor comment fixes. * sem_ch6.adb (Analyze_Subprogram_Body_Helper): Use First (Statements(...)) instead of First_Real_Statement(...). (Analyze_Null_Procedure): Minor comment fix. * sem_util.adb (Might_Raise): Return True for N_Raise_Expression. Adjust the part about exceptions generated by the back end to match the reality of what the back end generates. (Update_First_Real_Statement): Remove. * sem_util.ads: Remove First_Real_Statement from comment. * sinfo-utils.ads (First_Real_Statement): New function that always returns Empty. This should be removed once gnat-llvm and codepeer have been updated to not refer to First_Real_Statement. * sprint.adb (Sprint_At_End_Proc): Deal with printing At_End_Proc. * sem_prag.adb: Minor comment fixes. * gcc-interface/trans.cc (At_End_Proc_to_gnu): New function. (Subprogram_Body_to_gnu): Call it to handle an At_End_Proc. (Handled_Sequence_Of_Statements_to_gnu): Likewise. Remove the support for First_Real_Statement and clean up the rest. (Exception_Handler_to_gnu): Do not push binding levels. (Compilation_Unit_to_gnu): Adjust call to process_decls. (gnat_to_gnu) <N_Package_Specification>: Likewise. <N_Entry_Body>: Likewise. <N_Freeze_Entity>: Likewise. <N_Block_Statement>: Likewise and call At_End_Proc_to_gnu to handle an At_End_Proc. <N_Package_Body>: Likewise. (process_decls): Remove GNAT_END_LIST parameter and adjust recursive calls. Co-authored-by: Eric Botcazou <ebotcazou@adacore.com>
2022-09-06[Ada] Document change to legality checks for Inox case statementsSteve Baird2-2/+4
INOX (which is enabled via -gnatX) supports composite case-statement selectors. As a temporary measure, simplify the coverage-related compile-time checks for such case statements via two changes: an others choice is always required for such a case statement, and no legality checks relating to overlapping of case choices are performed. gcc/ada/ * doc/gnat_rm/implementation_defined_pragmas.rst: Document new temporary rule that a "when others =>" case choice must be given when casing on a composite selector. * gnat_rm.texi: Regenerate.
2022-09-06[Ada] Temporarily simplify legality checks for Inox case statementsSteve Baird1-4/+23
INOX (which is enabled via -gnatX) supports composite case-statement selectors. As a temporary measure, simplify the coverage-related compile-time checks for such case statements via two changes: an others choice is always required for such a case statement, and no legality checks relating to overlapping of case choices are performed. gcc/ada/ * sem_case.adb: Define a new Boolean constant, Simplified_Composite_Coverage_Rules, initialized to True. Setting this constant to True has two effects: 1- Representative value sets are not fully initialized - this is done to avoid capacity problems, as well as for performance. 2- In Check_Case_Pattern_Choices, the only legality check performed is a check that a "when others =>" choice is present.
2022-09-06[Ada] Tune message for illegal aspect Relaxed_InitializationPiotr Trojanek1-1/+1
Error message about illegal aspect Relaxed_Initialization was lacking a whitespace character. gcc/ada/ * sem_ch13.adb (Analyze_Aspect_Relaxed_Initialization): Fix error template.
2022-09-06[Ada] Bad Valid_Scalars result if signed int component type signed has ↵Steve Baird1-24/+24
partial view. For an object X of a composite type, the attribute X'Valid_Scalars should return False if and only if there exists at least one invalid scalar subcomponent of X. The validity test for a scalar part may include a range test. In some cases involving a private type that is implemented as a signed integer type, this range test was incorrectly implemented using unsigned comparisons. For an enclosing object X, this could result in X'Valid_Scalars yielding the wrong Boolean result. Such an incorrect result would almost always be False, although an incorrect True result is theoretically possible (this would require that both bounds of the component subtype are negative and that the invalid component has a positive value). gcc/ada/ * exp_attr.adb (Make_Range_Test): In determining which subtype's First and Last attributes are to be queried as part of a range test, call Validated_View in order to get a scalar (as opposed to private) subtype. (Attribute_Valid): In determining whether to perform a signed or unsigned comparison for a range test, call Validated_View in order to get a scalar (as opposed to private) type. Also correct a typo which, by itself, is the source of the problem reported for this ticket.
2022-09-06[Ada] ICE handling discriminant-dependent index constraint for access componentSteve Baird1-0/+85
The compiler would fail with an internal error in some cases involving a discriminated record type that provides a discriminant-dependent index constraint for the subtype of a component of an access-to-array type when a dereference of that component of some object is mentioned in a pre- or postcondition expression. gcc/ada/ * sem_ch4.adb (Analyze_Selected_Component): Define new Boolean-valued function, Constraint_Has_Unprefixed_Discriminant_Reference, which takes a subtype that is subject to a discriminant-dependent constraint and returns True if any of the constraint values are unprefixed discriminant names. Usually, the Etype of a selected component node is set to Etype of the component. However, in the case of an access-to-array component for which this predicate returns True, we instead use the base type of the Etype of the component. Normally such problematic discriminant references are addressed by calling Build_Actual_Subtype_Of_Component, but that doesn't work if Full_Analyze is False.
2022-09-06[Ada] Add formal verification dependencies to libgnatPiotr Trojanek1-0/+2
Spec units for verification of the GNAT standard library with GNATprove must be listed as part of the libgnat package, as otherwise libadalang will complain about missing dependencies. gcc/ada/ * Makefile.rtl (GNATRTL_NONTASKING_OBJS): Include System.Value_U_Spec and System.Value_I_Spec units.
2022-09-06[Ada] Correctly round Value attribute for floating point in more casesEric Botcazou8-54/+304
This provides correct rounding in the IEEE 754 sense for the Value attribute of floating-point types in more cases, by switching from tables of powers of 10 to tables of powers of 5 for precomputed values, thus making it possible to use a single divide for denormals and normalized numbers just above them. Although this significantly increases the size of the tables, object files for them are still quite small (1, 2 and 4 KB respectively on x86-64). gcc/ada/ * libgnat/s-powflt.ads (Powfive): New constant array. * libgnat/s-powlfl.ads (Powfive): Likewise. (Powfive_100): New constant. (Powfive_200): Likewise. (Powfive_300): Likewise. * libgnat/s-powllf.ads (Powfive): New constant array. (Powfive_100): New constant. (Powfive_200): Likewise. (Powfive_300): Likewise. * libgnat/s-valflt.ads (Impl): Replace Powten with Powfive and pass Null_Address for the address of large constants. * libgnat/s-vallfl.ads (Impl): Replace Powten with Powfive and pass the address of large constants. * libgnat/s-valllf.ads (Impl): Likewise. * libgnat/s-valrea.ads (System.Val_Real): Replace Powten_Address with Powfive_Address and add Powfive_{1,2,3}00_Address parameters. * libgnat/s-valrea.adb (Is_Large_Type): New boolean constant. (Is_Very_Large_Type): Likewise. (Maxexp32): Change value of 10 to that of 5. (Maxexp64): Likewise. (Maxexp80): Likewise. (Integer_to_Real): Use a combination of tables of powers of 5 and scaling if the base is 10. (Large_Powten): Rename into... (Large_Powfive): ...this. Add support for large constants. (Large_Powfive): New overloaded function for very large exponents.
2022-09-06[Ada] Improve detection of illegal Iterable aspectsPiotr Trojanek6-41/+71
Handling of aspect Iterable was lacking guards against illegal code, so the compiler either crashed or emitted cryptic errors while expanding loops that rely on this aspect. gcc/ada/ * doc/gnat_rm/implementation_defined_aspects.rst (Aspect Iterable): Include Last and Previous primitives in syntactic and semantic description. * exp_attr.adb (Expand_N_Attribute_Reference): Don't expect attributes like Iterable that can only appear in attribute definition clauses. * sem_ch13.adb (Analyze_Attribute_Definition_Clause): Prevent crash on non-aggregate Iterable attribute; improve basic diagnosis of attribute values. (Resolve_Iterable_Operation): Improve checks for illegal primitives in aspect Iterable, e.g. with wrong number of formal parameters. (Validate_Iterable_Aspect): Prevent crashes on syntactically illegal aspect expression. * sem_util.adb (Get_Cursor_Type): Fix style. * gnat_ugn.texi, gnat_rm.texi: Regenerate.
2022-09-06[Ada] Correctly round Value attribute for floating point in more casesEric Botcazou5-218/+253
This provides correct rounding in the IEEE 754 sense for the Value attribute of floating-point types in more cases, by bumping the number of significant bits used in the initial integer mantissa obtained from parsing. gcc/ada/ * libgnat/s-valuer.ads (System.Value_R): Add Parts formal parameter as well as Data_Index, Scale_Array and Value_Array types. (Scan_Raw_Real): Change type of Scale and return type. (Value_Raw_Real): Likewise. * libgnat/s-valuer.adb (Round_Extra): Reorder parameters and adjust recursive call. (Scan_Decimal_Digits): Reorder parameters, add N parameter and deal with multi-part scale and value. (Scan_Integral_Digits): Likewise. (Scan_Raw_Real): Change type of Scale and return type and deal with multi-part scale and value. (Value_Raw_Real): Change type of Scale and return type and tidy up. * libgnat/s-valued.adb (Impl): Pass 1 as Parts actual parameter. (Scan_Decimal): Adjust to type changes. (Value_Decimal): Likewise. * libgnat/s-valuef.adb (Impl): Pass 1 as Parts actual parameter. (Scan_Fixed): Adjust to type changes. (Value_Fixed): Likewise. * libgnat/s-valrea.adb (Need_Extra): Delete. (Precision_Limit): Always use the precision of the mantissa. (Impl): Pass 2 as Parts actual parameter. (Exact_Log2): New expression function. (Integer_to_Real): Change type of Scale and Val and deal with a 2-part integer mantissa. (Scan_Real): Adjust to type changes. (Value_Real): Likewise.
2022-09-06C-SKY: Fix missing operand when do spilt for cskyv2_addcc and ↵Xianmiao Qu1-2/+4
cskyv2_addcc_invert. It will cause ICE when compiling the case: gcc/testsuite/gcc.dg/params/blocksort-part.c gcc/ * config/csky/csky.md (cskyv2_addcc): Fix missing operand. (cskyv2_addcc_invert): Likewise.
2022-09-06bpf: remove unused variables from bpf_expand_{prologue,epilogue}Jose E. Marchesi1-10/+8
gcc/ChangeLog: * config/bpf/bpf.cc (bpf_expand_prologue): Remove unused automatic `insn'. (bpf_expand_epilogue): Likewise.
2022-09-06Update c-sky port maintainers' emails.Xianmiao Qu1-2/+2
/ * MAINTAINERS: Update c-sky port maintainers' emails.
2022-09-06Fix _mm512_cvt_roundps_ph to generate sae instruction.liuhongt3-3/+47
zmm-version vcvtps2ph is special, it encodes {sae} in evex, but put round control in the imm. For intrinsic _mm512_cvt_roundps_ph (a, imm), imm contains both {sae} and round control, we need to separate it in the assembly output since vcvtps2ph will ignore imm[3:7]. gcc/ChangeLog: * config/i386/i386-builtin.def (IX86_BUILTIN_CVTPS2PH512): Map to CODE_FOR_avx512f_vcvtps2ph512_mask_sae. * config/i386/sse.md (<mask_codefor>avx512f_vcvtps2ph512<mask_name>): Extend to .. (<mask_codefor>avx512f_vcvtps2ph512<mask_name><round_saeonly_name>): .. this. (avx512f_vcvtps2ph512_mask_sae): New expander gcc/testsuite/ChangeLog: * gcc.target/i386/avx512f-vcvtps2ph-sae.c: New test.
2022-09-06Merge branch 'master' into devel/sphinxMartin Liska63-290/+1562
2022-09-06Daily bump.GCC Administrator9-1/+659
2022-09-05preprocessor: Disable trigraphs for C2xJoseph Myers4-1/+21
ISO C2x removes trigraphs, so disable them accordingly for -std=c2x (they can still be enabled using -trigraphs). Bootstrapped with no regressions for x86_64-pc-linux-gnu. libcpp/ * init.cc (lang_defaults): Disable trigraphs for C2x. gcc/testsuite/ * gcc.dg/cpp/c11-trigraphs-1.c, gcc.dg/cpp/c2x-trigraphs-1.c, gcc.dg/cpp/c2x-trigraphs-2.c: New tests.
2022-09-05Do not fold __builtin_signbit if NAN is a possibility.Aldy Hernandez1-1/+3
I had some queued up work to try harder to keep the sign bit up to date in the presence of NANs, but after the discussion with Richi regarding the representation of NAN and signs in the frange, I've decided to put it aside until after Cauldron, since it'll probably get rewritten anyhow. So for now, the sign property in the frange is not applicable to NANs. Right now the only user of the sign bit that affects generated code (apart from signed zeros) is __builtin_sign, so I'm just checking for NAN there. Signed zeros continue working as before. Regstrapped and mpfr checked on x86-64 Linux. gcc/ChangeLog: * gimple-range-fold.cc (fold_using_range::range_of_builtin_int_call): Ignore sign bit when there's the possibility of a NAN.
2022-09-05Fold __builtin_signbit to nonzero instead of 1.Aldy Hernandez2-4/+25
After Joseph's comment wrt __builtin_signbit, I have been unable to convince myself that arbitrarily folding __builtin_signbit () of a negative number to 1 is correct. For example, on the true side of x < -5.0 we know the sign bit is set, but on the false side, we know nothing because X may be a NAN. I don't want to put ourselves in a position where the same call to __builtin_signbit can return two different things (1 or negative whatever), so I'm going to return nonzero which is correct across the board until someone can convince me otherwise. Setting the range to nonzero still allows us to fold conditionals checking __fold_builtin, while not actually propagating a 1. Zero propagation still works. That being said, I still think we should be folding __builtin_signbit's of negative numbers to whatever the hardware returns, instead of 1/0 like what the front ends do. gcc/ChangeLog: * gimple-range-fold.cc (fold_using_range::range_of_builtin_int_call): Fold a set signbit in __builtin_signbit to nonzero. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/vrp-float-signbit-2.c: New test.
2022-09-05i386: avoid zero extension for crc32qAlexander Monakov2-4/+18
The crc32q instruction takes 64-bit operands, but ignores high 32 bits of the destination operand, and zero-extends the result from 32 bits. Let's model this in the RTL pattern to avoid zero-extension when the _mm_crc32_u64 intrinsic is used with a 32-bit type. PR target/106453 gcc/ChangeLog: * config/i386/i386.md (sse4_2_crc32di): Model that only low 32 bits of operand 0 are consumed, and the result is zero-extended to 64 bits. gcc/testsuite/ChangeLog: * gcc.target/i386/pr106453.c: New test.
2022-09-05libstdc++: Move __success_type and __failure_type later in fileJonathan Wakely1-12/+13
libstdc++-v3/ChangeLog: * include/std/type_traits (__success_type, __failure_type): Move definitions later in the file.
2022-09-05Fortran/openmp: Partial OpenMP 5.2 doacross and omp_cur_iteration supportTobias Burnus11-117/+370
Add the Fortran support to the ME/C/C++ commit r13-2388-ga651e6d59188da8992f8bfae2df1cb4e6316f9e6 gcc/fortran/ChangeLog: * dump-parse-tree.cc (show_omp_namelist, show_omp_clauses): Handle omp_cur_iteration and distinguish doacross/depend. * gfortran.h (enum gfc_omp_depend_doacross_op): Renamed from gfc_omp_depend_op. (enum gfc_omp_depend_doacross_op): Add OMP_DOACROSS_SINK_FIRST, Rename OMP_DEPEND_SINK to OMP_DOACROSS_SINK. (gfc_omp_namelist) Handle renaming, rename depend_op to depend_doacross_op. (struct gfc_omp_clauses): Add doacross_source. * openmp.cc (gfc_match_omp_depend_sink): Renamed to ... (gfc_match_omp_doacross_sink): ... this; handle omp_all_memory. (enum omp_mask2): Add OMP_CLAUSE_DOACROSS. (gfc_match_omp_clauses): Handle 'doacross' and syntax changes to depend. (gfc_match_omp_depobj): Simplify as sink/source are now impossible. (gfc_match_omp_ordered_depend): Request OMP_CLAUSE_DOACROSS. (resolve_omp_clauses): Update sink/source checks. (gfc_resolve_omp_directive): Resolve EXEC_OMP_ORDERED clauses. * parse.cc (decode_omp_directive): Handle 'ordered doacross'. * trans-openmp.cc (gfc_trans_omp_clauses): Handle doacross. (gfc_trans_omp_do): Fix OMP_FOR_ORIG_DECLS handling if 'ordered' clause is present. (gfc_trans_omp_depobj): Update for member name change. libgomp/ChangeLog: * libgomp.texi (OpenMP 5.2): Update doacross/omp_cur_iteration status. gcc/testsuite/ChangeLog: * gfortran.dg/gomp/all-memory-1.f90: Update dg-error. * gfortran.dg/gomp/depend-iterator-2.f90: Likewise. * gfortran.dg/gomp/depobj-2.f90: Likewise. * gfortran.dg/gomp/doacross-5.f90: New test. * gfortran.dg/gomp/doacross-6.f90: New test.
2022-09-05Disable decimal floating point in frange.Aldy Hernandez2-11/+4
As Jakub mentioned in the PR, because many numbers have multiple possible representations, we can't reliably return true for singleton_p. For that matter, we may not be capable of modeling them just yet. Disabling them until someone with DFP knowledge can opine or extend frange. PR middle-end/106831 gcc/ChangeLog: * value-range.h (frange::supports_p): Disable decimal floats. * range-op-float.cc (frange_drop_inf): Remove DECIMAL_FLOAT_MODE_P check. (frange_drop_ninf): Same.
2022-09-05Do not ICE when updating a NAN to a non-NAN.Aldy Hernandez2-2/+86
Updating a definite NAN to a definitely not NAN was an assertion failure, but it turns out we can have such a scenario while attempting to thread an impossible path. This patch updates the range to undefined. What happens in the testcase is that we are trying to thread path that starts like this: <bb 5> [local count: 81335936906]: SR.30_3 = Nan; goto <bb 7>; [100.00%] <bb 7> [local count: 108447915740]: # SR.30_25 = PHI <SR.30_3(5), SR.30_12(6)> plus_33 = SR.30_25; w1$value__13 = f_distance$D2421$value__1; w2$value__14 = plus_33; if (w1$value__13 == w2$value__14) goto <bb 8>; [50.00%] else goto <bb 9>; [50.00%] On the path, SR.30_25 is NAN, which ultimately makes w2$value__14 a NAN. This means that the 7->8 is impossible on the path. On the true arm (foperator_equal::op1_range) we are asserting that op1 (w1$value__13) is a !NAN because for the == conditional to succeed, neither operand can be a NAN. But...we know that operand 2 is a NAN. This is an impossible scenario. We are ICEing because frange::set_nan() sees the NAN and the desire to set the NAN flag to NO. The correct thing to do is to set the range to undefined, which is basically unreachable, and will cause all the right things to happen. For that matter, the threader will see that an UNDEFINED range was calculated in the path and abort trying to investigate paths in that direction. PR middle-end/106824 gcc/ChangeLog: * value-range.cc (frange::set_nan): Set undefined when updating a NAN to a non-NAN. gcc/testsuite/ChangeLog: * g++.dg/pr106824.C: New test.
2022-09-05libstdc++: Use built-ins for more variable templatesJonathan Wakely1-12/+14
libstdc++-v3/ChangeLog: * include/std/type_traits (is_trivial_v, is_trivially_copyable_v) (is_standard_layout_v, is_pod_v, is_literal_type_v): Use built-in instead of class template. (is_same_v): Add partial specialization for true case.
2022-09-05analyzer: strcpy semanticsTim Lange5-3/+133
This patch adds modelling for the semantics of strcpy in the simple case where the analyzer is able to infer a concrete string size. Regrtested on Linux x86_64. 2022-09-04 Tim Lange <mail@tim-lange.me> gcc/analyzer/ChangeLog: * region-model-impl-calls.cc (region_model::impl_call_strcpy): Handle the constant string case. * region-model.cc (region_model::get_string_size): New function to get the string size from a region or svalue. * region-model.h (class region_model): Add get_string_size. gcc/testsuite/ChangeLog: * gcc.dg/analyzer/out-of-bounds-4.c: New test. * gcc.dg/analyzer/strcpy-3.c: New test.
2022-09-05analyzer: return a concrete offset for cast_regionsTim Lange3-0/+20
This patch fixes a bug where maybe_fold_sub_svalue did not fold the access of a single char from a string to a char when the offset was zero because get_relative_concrete_offset did return false for cast_regions. Regrtested on Linux x86_64. 2022-09-04 Tim Lange <mail@tim-lange.me> gcc/analyzer/ChangeLog: * region.cc (cast_region::get_relative_concrete_offset): New overloaded method. * region.h: Add cast_region::get_relative_concrete_offset. gcc/testsuite/ChangeLog: * gcc.dg/analyzer/fold-string-to-char.c: New test.
2022-09-05RISC-V: Fix division instructions for `m` with `zmmul` extension.Kito Cheng2-7/+3
gcc/ChangeLog: * config/riscv/riscv.cc (riscv_option_override): Fix wrong condition for MASK_DIV and simplify incompatible checking. * config/riscv/riscv.md (muldi3): Adding parentheses.
2022-09-05aarch64: Suggest an -mcpu option when user passes CPU name to -marchKyrylo Tkachov2-0/+18
This small patch helps users who confuse -march and -mcpu on AArch64. Sometimes users pass -march with a CPU name, where they most likely wanted to use -mcpu, which would select the right architecture features *and* tune for their desired CPU. Currently we'll just error out with an unkown architecture message and list the valid architecture options. With this patch we check if their string matches a known CPU and suggest they use an -mcpu option instead. So compiling with -march=neoverse-n1 will now give the error: cc1: error: unknown value 'neoverse-n1' for '-march' cc1: note: valid arguments are: armv8-a armv8.1-a armv8.2-a armv8.3-a armv8.4-a armv8.5-a armv8.6-a armv8.7-a armv8.8-a armv8-r armv9-a cc1: note: did you mean '-mcpu=neoverse-n1'? Bootstrapped and tested on aarch64-none-linux-gnu. gcc/ChangeLog: * config/aarch64/aarch64.cc (aarch64_validate_march): Check if invalid arch string is a valid -mcpu string and emit hint. gcc/testsuite/ChangeLog: * gcc.target/aarch64/spellcheck_10.c: New test.
2022-09-05RISC-V: Support Zmmul extensionLiaoShihua7-16/+70
gcc/ChangeLog: * common/config/riscv/riscv-common.cc: Add Zmmul. * config/riscv/riscv-opts.h (MASK_ZMMUL): New. (TARGET_ZMMUL): Ditto. * config/riscv/riscv.cc (riscv_option_override):Ditto. * config/riscv/riscv.md: Add Zmmul * config/riscv/riscv.opt: Ditto. gcc/testsuite/ChangeLog: * gcc.target/riscv/zmmul-1.c: New test. * gcc.target/riscv/zmmul-2.c: New test.
2022-09-05Remove MAX_SWITCH_CASES limitRichard Biener4-23/+8
The following removes the MAX_SWITCH_CASES limit to fight quadraticness when looking up case labels from edges. Instead use the {start,end}_recording_case_labels facility for that. For it to be usable I've exported get_cases_for_edge from tree-cfg.cc. * tree-cfg.h (get_cases_for_edge): Declare. * tree-cfg.cc (get_cases_for_edge): Export. * tree-ssa-uninit.cc (execute_late_warn_uninitialized): Start and end recording case labels. * gimple-predicate-analysis.cc (MAX_SWITCH_CASES): Remove. (predicate::init_from_control_deps): Use get_cases_for_edge.
2022-09-05Unify MAX_POSTDOM_CHECK and --param uninit-control-dep-attemptsRichard Biener1-17/+12
The following unifies both limits, in particular the MAX_POSTDOM_CHECK tends to be too low and is not user-controllable. * gimple-predicate-analysis.cc (MAX_POSTDOM_CHECK): Remove. (compute_control_dep_chain): Move uninit-control-dep-attempts checking where it also counts the post-dominator check invocations.
2022-09-05debug () for predicatesRichard Biener2-34/+52
The following adds a debug () member to the predicate class. * gimple-predicate-analysis.h (predicate::debug): New. (predicate::dump): Add FILE * argument, add base overload. * gimple-predicate-analysis.cc (debug): New. (dump_pred_info): Add FILE * argument. (dump_pred_chain): Likewise. (predicate::dump): Split out preamble into overload. Add FILE * argument. (predicate::debug): New. (predicate::simplify): Adjust. (predicate::normalize): Likewise. (predicate::init_from_control_deps): Likewise.
2022-09-05aarch64: Remove lazy SIMD builtin initialisationRichard Sandiford4-34/+1
At one time the aarch64 port registered the Advanced SIMD builtins lazily, when we first encountered a set of target flags that includes +simd. These days we always initialise them at start-up, temporarily forcing a conducive set of flags if necessary. This patch removes some vestiges of the old way of doing things. gcc/ * config/aarch64/aarch64-protos.h (aarch64_init_simd_builtins): Remove prototype. * config/aarch64/aarch64-builtins.cc (aarch64_simd_builtins_initialized_p): Delete. (aarch64_init_simd_builtins): Make static. Remove protection against multiple calls. * config/aarch64/aarch64-c.cc (aarch64_pragma_target_parse): Remove lazy SIMD builtin initialization. * config/aarch64/aarch64.cc (aarch64_option_valid_attribute_p): Likewise.
2022-09-05LoongArch: add -mdirect-extern-access optionXi Ruoyao6-0/+41
As a new target, LoongArch does not use copy relocation as it's problematic in some circumstances. One bad consequence is we are emitting GOT for all accesses to all extern objects with default visibility. The use of GOT is not needed in statically linked executables, OS kernels etc. The GOT entry just wastes space, and the GOT access just slow down the execution in those environments. Before -mexplicit-relocs, we used "-Wa,-mla-global-with-pcrel" to tell the assembler not to use GOT for extern access. But with -mexplicit-relocs, we have to opt the logic in GCC. The name "-mdirect-extern-access" is learnt from x86 port. gcc/ChangeLog: * config/loongarch/genopts/loongarch.opt.in: Add -mdirect-extern-access option. * config/loongarch/loongarch.opt: Regenerate. * config/loongarch/loongarch.cc (loongarch_symbol_binds_local_p): Return true if TARGET_DIRECT_EXTERN_ACCESS. (loongarch_option_override_internal): Complain if -mdirect-extern-access is used with -fPIC or -fpic. * doc/invoke.texi: Document -mdirect-extern-access for LoongArch. gcc/testsuite/ChangeLog: * gcc.target/loongarch/direct-extern-1.c: New test. * gcc.target/loongarch/direct-extern-2.c: New test.
2022-09-05Merge branch 'master' into devel/sphinxMartin Liska2-8/+8
2022-09-05docs: rename DEBUGGER_REGISTER_NUMBER in texiMartin Liska2-8/+8
gcc/ChangeLog: * doc/tm.texi.in: Rename DEBUGGER_REGISTER_NUMBER to DEBUGGER_REGNO. * doc/tm.texi: Regenerate.
2022-09-05Merge branch 'master' into devel/sphinxMartin Liska1040-29311/+53400
2022-09-05rename DBX_REGISTER_NUMBER to DEBUGGER_REGNOMartin Liska81-231/+200
gcc/ada/ChangeLog: * sigtramp-vxworks-target.h: Rename DBX_REGISTER_NUMBER to DEBUGGER_REGNO. gcc/ChangeLog: * config/aarch64/aarch64-protos.h (aarch64_dbx_regno): Rename DBX_REGISTER_NUMBER to DEBUGGER_REGNO. (aarch64_debugger_regno): Likewise. * config/aarch64/aarch64.cc (aarch64_dbx_regno): Likewise. (aarch64_debugger_regno): Likewise. * config/aarch64/aarch64.h (DBX_REGISTER_NUMBER): Likewise. (DEBUGGER_REGNO): Likewise. (DWARF_FRAME_REGNUM): Likewise. * config/alpha/alpha.h (DWARF_FRAME_REGNUM): Likewise. * config/arc/arc.cc (arc_init_reg_tables): Likewise. * config/arc/arc.h (DBX_REGISTER_NUMBER): Likewise. (DEBUGGER_REGNO): Likewise. * config/arm/arm-protos.h (arm_dbx_regno): Likewise. (arm_debugger_regno): Likewise. * config/arm/arm.cc (arm_dbx_regno): Likewise. (arm_debugger_regno): Likewise. * config/arm/arm.h (DBX_REGISTER_NUMBER): Likewise. (DEBUGGER_REGNO): Likewise. * config/bfin/bfin.h (DBX_REGISTER_NUMBER): Likewise. (DEBUGGER_REGNO): Likewise. * config/c6x/c6x.cc: Likewise. * config/c6x/c6x.h (DBX_REGISTER_NUMBER): Likewise. (DEBUGGER_REGNO): Likewise. * config/cris/cris.h (enum reg_class): Likewise. (DBX_REGISTER_NUMBER): Likewise. (DEBUGGER_REGNO): Likewise. * config/csky/csky.cc (enum reg_class): Likewise. * config/csky/csky.h (DWARF_FRAME_REGNUM): Likewise. (DBX_REGISTER_NUMBER): Likewise. (DEBUGGER_REGNO): Likewise. * config/frv/frv.h (DBX_REGISTER_NUMBER): Likewise. (DEBUGGER_REGNO): Likewise. * config/gcn/gcn-hsa.h (DBX_REGISTER_NUMBER): Likewise. (DEBUGGER_REGNO): Likewise. * config/gcn/gcn.cc (print_operand): Likewise. * config/i386/bsd.h (ASM_QUAD): Likewise. * config/i386/cygming.h (DBX_REGISTER_NUMBER): Likewise. (DEBUGGER_REGNO): Likewise. (DWARF_FRAME_REGNUM): Likewise. * config/i386/darwin.h (DBX_REGISTER_NUMBER): Likewise. (DEBUGGER_REGNO): Likewise. * config/i386/djgpp.h (DBX_REGISTER_NUMBER): Likewise. (DEBUGGER_REGNO): Likewise. * config/i386/dragonfly.h (DBX_REGISTER_NUMBER): Likewise. (DEBUGGER_REGNO): Likewise. * config/i386/freebsd.h (DBX_REGISTER_NUMBER): Likewise. (DEBUGGER_REGNO): Likewise. * config/i386/gas.h: Likewise. * config/i386/gnu-user.h (DBX_REGISTER_NUMBER): Likewise. (DEBUGGER_REGNO): Likewise. * config/i386/i386.cc (enum reg_class): Likewise. * config/i386/i386.h (DBX_REGISTER_NUMBER): Likewise. (DEBUGGER_REGNO): Likewise. * config/i386/i386elf.h (DBX_REGISTER_NUMBER): Likewise. (DEBUGGER_REGNO): Likewise. * config/i386/iamcu.h (DBX_REGISTER_NUMBER): Likewise. (DEBUGGER_REGNO): Likewise. * config/i386/lynx.h (DBX_REGISTER_NUMBER): Likewise. (DEBUGGER_REGNO): Likewise. * config/i386/netbsd-elf.h (DBX_REGISTER_NUMBER): Likewise. (DEBUGGER_REGNO): Likewise. * config/i386/nto.h (DBX_REGISTER_NUMBER): Likewise. (DEBUGGER_REGNO): Likewise. * config/i386/openbsdelf.h (DBX_REGISTER_NUMBER): Likewise. (DEBUGGER_REGNO): Likewise. * config/i386/sysv4.h (DBX_REGISTER_NUMBER): Likewise. (DEBUGGER_REGNO): Likewise. * config/i386/vxworks.h (DBX_REGISTER_NUMBER): Likewise. (DEBUGGER_REGNO): Likewise. * config/i386/x86-64.h (DBX_REGISTER_NUMBER): Likewise. (DEBUGGER_REGNO): Likewise. * config/ia64/ia64-protos.h (ia64_dbx_regno): Likewise. (ia64_debugger_regno): Likewise. * config/ia64/ia64.cc (ia64_output_function_prologue): Likewise. (ia64_dbx_regno): Likewise. (ia64_debugger_regno): Likewise. (process_cfa_adjust_cfa): Likewise. (process_cfa_register): Likewise. (ia64_asm_unwind_emit): Likewise. * config/ia64/ia64.h: Likewise. * config/ia64/sysv4.h (DBX_REGISTER_NUMBER): Likewise. (DEBUGGER_REGNO): Likewise. * config/lm32/lm32.h (DBX_REGISTER_NUMBER): Likewise. (DEBUGGER_REGNO): Likewise. * config/m32c/m32c.cc (m32c_eh_return_stackadj_rtx): Likewise. * config/m32c/m32c.h (DBX_REGISTER_NUMBER): Likewise. (DEBUGGER_REGNO): Likewise. * config/m68k/linux.h (DBX_REGISTER_NUMBER): Likewise. (DEBUGGER_REGNO): Likewise. * config/m68k/m68k.h (DBX_REGISTER_NUMBER): Likewise. (DEBUGGER_REGNO): Likewise. (__transfer_from_trampoline): Likewise. * config/m68k/m68kelf.h (DBX_REGISTER_NUMBER): Likewise. (DEBUGGER_REGNO): Likewise. * config/m68k/netbsd-elf.h (M68K_STATIC_CHAIN_REG_NAME): Likewise. (DBX_REGISTER_NUMBER): Likewise. (DEBUGGER_REGNO): Likewise. * config/microblaze/microblaze.cc (microblaze_option_override): Likewise. * config/microblaze/microblaze.h (DBX_REGISTER_NUMBER): Likewise. (DEBUGGER_REGNO): Likewise. (GP_DBX_FIRST): Likewise. (GP_DEBUGGER_FIRST): Likewise. * config/mips/vxworks.h (DBX_REGISTER_NUMBER): Likewise. (DEBUGGER_REGNO): Likewise. * config/mmix/mmix-protos.h (mmix_dbx_regno): Likewise. (mmix_debugger_regno): Likewise. * config/mmix/mmix.cc (mmix_dbx_regno): Likewise. (mmix_debugger_regno): Likewise. * config/mmix/mmix.h (DBX_REGISTER_NUMBER): Likewise. (DEBUGGER_REGNO): Likewise. * config/nds32/nds32-protos.h (nds32_dbx_regno): Likewise. (nds32_debugger_regno): Likewise. * config/nds32/nds32.cc (nds32_dbx_regno): Likewise. (nds32_debugger_regno): Likewise. (nds32_use_blocks_for_constant_p): Likewise. * config/nds32/nds32.h (DBX_REGISTER_NUMBER): Likewise. (DEBUGGER_REGNO): Likewise. * config/nvptx/nvptx.h (DBX_REGISTER_NUMBER): Likewise. (DEBUGGER_REGNO): Likewise. * config/or1k/or1k.h (DBX_REGISTER_NUMBER): Likewise. (DEBUGGER_REGNO): Likewise. * config/pa/pa32-regs.h (DBX_REGISTER_NUMBER): Likewise. (DEBUGGER_REGNO): Likewise. * config/pa/pa64-regs.h (DBX_REGISTER_NUMBER): Likewise. (DEBUGGER_REGNO): Likewise. * config/rs6000/rs6000-protos.h (rs6000_dbx_regno): Likewise. (rs6000_debugger_regno): Likewise. * config/rs6000/rs6000.cc (rs6000_dbx_regno): Likewise. (rs6000_debugger_regno): Likewise. * config/rs6000/rs6000.h (DBX_REGISTER_NUMBER): Likewise. (DEBUGGER_REGNO): Likewise. (DWARF2_FRAME_REG_OUT): Likewise. * config/s390/s390.h (DBX_REGISTER_NUMBER): Likewise. (DEBUGGER_REGNO): Likewise. * config/sh/elf.h (DBX_REGISTER_NUMBER): Likewise. (DEBUGGER_REGNO): Likewise. * config/sh/linux.h (DBX_REGISTER_NUMBER): Likewise. (DEBUGGER_REGNO): Likewise. * config/sh/sh.h (DBX_REGISTER_NUMBER): Likewise. (DEBUGGER_REGNO): Likewise. (SH_DBX_REGISTER_NUMBER): Likewise. (SH_DEBUGGER_REGNO): Likewise. * config/visium/visium.h (DBX_REGISTER_NUMBER): Likewise. (DEBUGGER_REGNO): Likewise. * config/xtensa/elf.h (DBX_REGISTER_NUMBER): Likewise. (DEBUGGER_REGNO): Likewise. * config/xtensa/linux.h (DBX_REGISTER_NUMBER): Likewise. (DEBUGGER_REGNO): Likewise. * config/xtensa/uclinux.h (DBX_REGISTER_NUMBER): Likewise. (DEBUGGER_REGNO): Likewise. * config/xtensa/xtensa-protos.h (xtensa_dbx_regno): Likewise. (xtensa_debugger_regno): Likewise. * config/xtensa/xtensa.cc (xtensa_dbx_regno): Likewise. (xtensa_debugger_regno): Likewise. * config/xtensa/xtensa.h (DBX_REGISTER_NUMBER): Likewise. (DEBUGGER_REGNO): Likewise. * defaults.h (DBX_REGISTER_NUMBER): Likewise. (DEBUGGER_REGNO): Likewise. (DWARF_FRAME_REGNUM): Likewise. * doc/tm.texi: Likewise. * doc/tm.texi.in: Likewise. * dwarf2out.cc (dbx_reg_number): Likewise. (debugger_reg_number): Likewise. (reg_loc_descriptor): Likewise. (multiple_reg_loc_descriptor): Likewise. (mem_loc_descriptor): Likewise. * except.cc: Likewise.
2022-09-05[Ada] Move check for null array aggregates to expansionPiotr Trojanek3-21/+22
Despite recent changes to runtime checks for null array aggregates, GNATprove still struggles with N_Raise_Constraint_Error nodes inserted into AST by aggregate resolution. The ultimate fix is to move these checks to expansion (which is disabled in GNATprove mode) and explicitly emit a proof check in the GNATprove backend. gcc/ada/ * exp_aggr.adb (Check_Bounds): Move code and comment related to check for null array aggregate from Resolve_Null_Array_Aggregate. * sem_aggr.ads (Is_Null_Aggregate): Move spec from unit body. * sem_aggr.adb (Resolve_Null_Array_Aggregate): Move check to expansion.
2022-09-05[Ada] Fix inconsistent building of itypes for null array aggregatesPiotr Trojanek1-23/+31
To analyze Ada 2022 null array aggregates we introduced a dedicated routine and bypassed the code for ordinary array aggregates. However, the types for the array indexes created by this dedicated routine differed from the types created for ordinary array aggregates, i.e. itypes for null array aggregates were associated with the array subtype declaration, while itypes for ordinary array aggregates were associated with the aggregate itself. These differences cause trouble for various routines in GNATprove. This patch reduces the special handling of null array aggregates and reuses the building of itypes for ordinary array aggregates. gcc/ada/ * sem_aggr.adb (Array_Aggr_Subtype): Bypass call to Collect_Aggr_Bound with dedicated code for null array aggregates. (Resolve_Array_Aggregate): Remove special handling of null array aggregates. (Resolve_Array_Aggregate): Create bounds, but let Array_Aggr_Subtype create itype entities.
2022-09-05[Ada] Fix insertion of a runtime check for null array aggregatePiotr Trojanek1-4/+2
A null array aggregate of Ada 2022 requires a conditional runtime check that was inserted as an if-statement. While gigi can handle statements inserted into a list of declarations, in GNATprove such a statement will cause a crash. It is better to insert a conditional raise node, which is properly handled by both gigi and GNATprove. gcc/ada/ * sem_aggr.adb (Resolve_Null_Array_Aggregate): Insert check as a Raise_Constraint_Error node and not an If_Statement.
2022-09-05[Ada] Cleanup iteration over aggregate component associationsPiotr Trojanek1-4/+2
Code cleanup related to fixes for iterated component associations in GNATprove ; semantics is unaffected. gcc/ada/ * sem_aggr.adb (Resolve_Container_Aggregate): Style cleanup. (Resolve_Record_Aggregate): Remove redundant guard.
2022-09-05[Ada] Remove VMS specific routine that is no longer referencedPiotr Trojanek2-18/+0
Code cleanup related to resctrition No_Local_Allocators. gcc/ada/ * exp_util.ads (Entry_Names_OK): Remove spec. * exp_util.adb (Entry_Names_OK): Remove body.
2022-09-05[Ada] Single-element Append performance improvementSteve Baird2-39/+49
Ada.Containers.Vectors has two Append procedures that take an Element value; one takes a Count parameter and one does not (the count is implicitly one for the latter). For the former version, there was code that took a faster path if certain conditions were met and otherwise took a slower path; one of the prerequisite conditions for this was Count = 1. For the latter version, no such special-case detection was performed; the more general code was always executed. Move the special-case detection/handling code from the former version into the latter and change the former version to simply call the latter version if Count = 1. Also apply same change to Ada.Containers.Indefinite_Vectors. gcc/ada/ * libgnat/a-coinve.adb, libgnat/a-convec.adb (Append): If the Append that takes an Element and a Count is called with Count = 1, then call the Append that does not take a Count parameter; otherwise call the code that handles the general case. Move the special case detection/handling code that was formerly in that version of Append into the version that does not take a Count parameter, so that now both versions get the performance benefit.