aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2022-10-06ada: Clean up slice-of-component optimizationBob Duff1-2/+4
In the recursive case of Volatile_Or_Independent = False for array types, fall through into later checks, so for example we check the type of the prefix of a slice. The pattern here is "return True in certain cases, otherwise fall through into the final 'return False'". Remove check for "Ndim = 1"; if Slices is True, then the number of dimensions is necessarily 1, because Ada doesn't have multi-dimensional slices. gcc/ada/ * exp_ch5.adb (Expand_Assign_Array_Loop_Or_Bitfield): Minor cleanups.
2022-10-06ada: Do not issue compiler warnings in GNATprove modeYannick Moy1-0/+7
Use of pragma Warning with a string literal to set warning switches, should not impact GNATprove which is not subject to these switches. gcc/ada/ * sem_prag.adb (Analyze_Pragma): Ignore one variant of pragma Warnings in GNATprove mode.
2022-10-06ada: Disable slice-of-component optimization in some casesBob Duff1-0/+10
This patch disables the Fast_Copy_Bitfield optimization in certain rare cases that currently do not work (crash in gigi). We could improve Expand_Assign_Array_Bitfield_Fast to handle these cases properly, but that change is delicate, so for now, we simply disable the optimization. gcc/ada/ * exp_ch5.adb (Expand_Assign_Array_Loop_Or_Bitfield): Disable the Fast_Copy_Bitfield optimization in certain cases.
2022-10-06ada: Fix spurious warning on unreferenced refinement constituentsPiotr Trojanek1-1/+10
Listing an object as a state refinement constituent shouldn't be considered to be a reference, at least from the point of view of the machinery for detecting objects that are never referenced or written without being referenced. This patch fixes a spurious warning that rarely occurred in practice but was annoyingly emitted for minimal reproducers for issues related to state abstractions. Note: there are other pragmas that should be similarly recognized (e.g. Depends, Global and their refined variants), but recognizing them efficiently probably requires a dedicated utility routine (i.e. to avoid traversal of the parent chain for every kind of pragma). gcc/ada/ * sem_prag.adb (Sig_Pragma): Change flag for pragma Refined_State to mean "not significant"; this is primarily for documentation, because the exact value of the flag is not really taken into account for Refined_State. (Is_Non_Significant_Pragma_Reference): Add special handling for pragma Refined_State.
2022-10-06git_update_version: add robust loggingMartin Liska1-12/+24
contrib/ChangeLog: * gcc-changelog/git_update_version.py: Use logging module and provide robust debugging output.
2022-10-06arc: Remove max-page-size and common-page-size forced settingClaudiu Zissulescu1-1/+0
Max page size is defined in the ARC's BFD file, and the common page size is also set by the appropriate binutils macros. Remove them from LINK_SPEC. 2022-10-06 Claudiu Zissulescu <claziss@synopsys.com> * config/arc/linux.h (LINK_SPEC): Remove max-page-size and common-pave-size. Signed-off-by: Claudiu Zissulescu <claziss@gmail.com>
2022-10-06libgcc: Decrease size of _Unwind_FrameState and even more size of cleared ↵Jakub Jelinek35-292/+296
area in uw_frame_state_for The following patch implements something that has Florian found as low hanging fruit in our unwinder and has been discussed in the https://gcc.gnu.org/wiki/cauldron2022#cauldron2022talks.inprocess_unwinding_bof talk. _Unwind_FrameState type seems to be (unlike the pre-GCC 3 frame_state which has been part of ABI) private to unwind-dw2.c + unwind.inc it includes, it is always defined on the stack of some entrypoints, initialized by static uw_frame_state_for and the address of it is also passed to other static functions or the static inlines handling machine dependent unwinding, but it isn't fortunately passed to any callbacks or public functions, so I think we can safely change it any time we want. Florian mentioned that the structure is large even on x86_64, 384 bytes there, starts with 328 bytes long element with frame_state_reg_info type which then starts with an array with __LIBGCC_DWARF_FRAME_REGISTERS__ + 1 elements, each of them is 16 bytes long, on x86_64 __LIBGCC_DWARF_FRAME_REGISTERS__ is just 17 but even that is big, on say riscv __LIBGCC_DWARF_FRAME_REGISTERS__ is I think 128, on powerpc 111, on sh 153 etc. And, we memset to zero the whole fs variable with the _Unwind_FrameState type at the start of the unwinding. The reason why each element is 16 byte (on 64-bit arches) is that it contains some pointer or pointer sized integer and then an enum (with just 7 different enumerators) + padding. The following patch decreases it by moving the enum into a separate array and using just one byte for each register in that second array. We could compress it even more, say 4 bits per register, but I don't want to uglify the code for it too much and make the accesses slower. Furthermore, the clearing of the object can clear only thos how array and members after it, because REG_UNSAVED enumerator (0) doesn't actually need any pointer or pointer sized integer, it is just the other kinds that need to have there something. By doing this, on x86_64 the above numbers change to _Unwind_FrameState type being now 264 bytes long, frame_state_reg_info 208 bytes and we don't clear the first 144 bytes of the object, so the memset is 120 bytes, so ~ 31% of the old clearing size. On riscv 64-bit assuming it has same structure layout rules for the few types used there that would be ~ 2160 bytes of _Unwind_FrameState type before and ~ 1264 bytes after, with the memset previously ~ 2160 bytes and after ~ 232 bytes after. We've also talked about possibly adding a number of initially initialized regs and initializing the rest lazily, but at least for x86_64 with 18 elements in the array that doesn't seem to be worth it anymore, especially because return address column is 16 there and that is usually the first thing to be touched. It might theory help with lots of registers if they are usually untouched, but would uglify and complicate any stores to how by having to check there for the not initialized yet cases and lazy initialization, and similarly for all reads of how to do there if below last initialized one, use how, otherwise imply REG_UNSAVED. The disadvantage of the patch is that touching reg[x].loc and how[x] now means 2 cachelines rather than one as before, and I admit beyond bootstrap/regtest I haven't benchmarked it in any way. 2022-10-06 Jakub Jelinek <jakub@redhat.com> * unwind-dw2.h (REG_UNSAVED, REG_SAVED_OFFSET, REG_SAVED_REG, REG_SAVED_EXP, REG_SAVED_VAL_OFFSET, REG_SAVED_VAL_EXP, REG_UNDEFINED): New anonymous enum, moved from inside of struct frame_state_reg_info. (struct frame_state_reg_info): Remove reg[].how element and the anonymous enum there. Add how element. * unwind-dw2.c: Include stddef.h. (uw_frame_state_for): Don't clear first offsetof (_Unwind_FrameState, regs.how[0]) bytes of *fs. (execute_cfa_program, __frame_state_for, uw_update_context_1, uw_update_context): Use fs->regs.how[X] instead of fs->regs.reg[X].how or fs.regs.how[X] instead of fs.regs.reg[X].how. * config/sh/linux-unwind.h (sh_fallback_frame_state): Likewise. * config/bfin/linux-unwind.h (bfin_fallback_frame_state): Likewise. * config/pa/linux-unwind.h (pa32_fallback_frame_state): Likewise. * config/pa/hpux-unwind.h (UPDATE_FS_FOR_SAR, UPDATE_FS_FOR_GR, UPDATE_FS_FOR_FR, UPDATE_FS_FOR_PC, pa_fallback_frame_state): Likewise. * config/alpha/vms-unwind.h (alpha_vms_fallback_frame_state): Likewise. * config/alpha/linux-unwind.h (alpha_fallback_frame_state): Likewise. * config/arc/linux-unwind.h (arc_fallback_frame_state, arc_frob_update_context): Likewise. * config/riscv/linux-unwind.h (riscv_fallback_frame_state): Likewise. * config/nios2/linux-unwind.h (NIOS2_REG): Likewise. * config/nds32/linux-unwind.h (NDS32_PUT_FS_REG): Likewise. * config/s390/tpf-unwind.h (s390_fallback_frame_state): Likewise. * config/s390/linux-unwind.h (s390_fallback_frame_state): Likewise. * config/sparc/sol2-unwind.h (sparc64_frob_update_context, MD_FALLBACK_FRAME_STATE_FOR): Likewise. * config/sparc/linux-unwind.h (sparc64_fallback_frame_state, sparc64_frob_update_context, sparc_fallback_frame_state): Likewise. * config/i386/sol2-unwind.h (x86_64_fallback_frame_state, x86_fallback_frame_state): Likewise. * config/i386/w32-unwind.h (i386_w32_fallback_frame_state): Likewise. * config/i386/linux-unwind.h (x86_64_fallback_frame_state, x86_fallback_frame_state): Likewise. * config/i386/freebsd-unwind.h (x86_64_freebsd_fallback_frame_state): Likewise. * config/i386/dragonfly-unwind.h (x86_64_dragonfly_fallback_frame_state): Likewise. * config/i386/gnu-unwind.h (x86_gnu_fallback_frame_state): Likewise. * config/csky/linux-unwind.h (csky_fallback_frame_state): Likewise. * config/aarch64/linux-unwind.h (aarch64_fallback_frame_state): Likewise. * config/aarch64/freebsd-unwind.h (aarch64_freebsd_fallback_frame_state): Likewise. * config/aarch64/aarch64-unwind.h (aarch64_frob_update_context): Likewise. * config/or1k/linux-unwind.h (or1k_fallback_frame_state): Likewise. * config/mips/linux-unwind.h (mips_fallback_frame_state): Likewise. * config/loongarch/linux-unwind.h (loongarch_fallback_frame_state): Likewise. * config/m68k/linux-unwind.h (m68k_fallback_frame_state): Likewise. * config/xtensa/linux-unwind.h (xtensa_fallback_frame_state): Likewise. * config/rs6000/darwin-fallback.c (set_offset): Likewise. * config/rs6000/aix-unwind.h (MD_FROB_UPDATE_CONTEXT): Likewise. * config/rs6000/linux-unwind.h (ppc_fallback_frame_state): Likewise. * config/rs6000/freebsd-unwind.h (frob_update_context): Likewise.
2022-10-06openmp: Map holds clause to IFN_ASSUME for C/C++Jakub Jelinek3-6/+33
Now that [[assume (cond)]] support is in, this simple patch makes #pragma omp assume holds(cond) use it. 2022-10-06 Jakub Jelinek <jakub@redhat.com> * c-parser.cc (c_parser_omp_assumption_clauses): Emit IFN_ASSUME call for holds clause on assume construct. * parser.cc (cp_parser_omp_assumption_clauses): Emit IFN_ASSUME call for holds clause on assume construct. * c-c++-common/gomp/assume-4.c: New test.
2022-10-06c++, c: Implement C++23 P1774R8 - Portable assumptions [PR106654]Jakub Jelinek25-202/+1319
The following patch implements C++23 P1774R8 - Portable assumptions paper, by introducing support for [[assume (cond)]]; attribute for C++. In addition to that the patch adds [[gnu::assume (cond)]]; and __attribute__((assume (cond))); support to both C and C++. As described in C++23, the attribute argument is conditional-expression rather than the usual assignment-expression for attribute arguments, the condition is contextually converted to bool (for C truthvalue conversion is done on it) and is never evaluated at runtime. For C++ constant expression evaluation, I only check the simplest conditions for undefined behavior, because otherwise I'd need to undo changes to *ctx->global which happened during the evaluation (but I believe the spec allows that and we can further improve later). The patch uses a new internal function, .ASSUME, to hold the condition in the FEs. At gimplification time, if the condition is simple/without side-effects, it is gimplified as if (cond) ; else __builtin_unreachable (); and otherwise for now dropped on the floor. The intent is to incrementally outline the conditions into separate artificial functions and use .ASSUME further to tell the ranger and perhaps other optimization passes about the assumptions, as detailed in the PR. When implementing it, I found that assume entry hasn't been added to https://eel.is/c++draft/cpp.cond#6 Jonathan said he'll file a NB comment about it, this patch assumes it has been added into the table as 202207L when the paper has been voted in. With the attributes for both C/C++, I'd say we don't need to add __builtin_assume with similar purpose, especially when __builtin_assume in LLVM is just weird. It is strange for side-effects in function call's argument not to be evaluated, and LLVM in that case (annoyingly) warns and ignores the side-effects (but doesn't do then anything with it), if there are no side-effects, it will work like our if (!cond) __builtin_unreachable (); 2022-10-06 Jakub Jelinek <jakub@redhat.com> PR c++/106654 gcc/ * internal-fn.def (ASSUME): New internal function. * internal-fn.h (expand_ASSUME): Declare. * internal-fn.cc (expand_ASSUME): Define. * gimplify.cc (gimplify_call_expr): Gimplify IFN_ASSUME. * fold-const.h (simple_condition_p): Declare. * fold-const.cc (simple_operand_p_2): Rename to ... (simple_condition_p): ... this. Remove forward declaration. No longer static. Adjust function comment and fix a typo in it. Adjust recursive call. (simple_operand_p): Adjust function comment. (fold_truth_andor): Adjust simple_operand_p_2 callers to call simple_condition_p. * doc/extend.texi: Document assume attribute. Move fallthrough attribute example to its section. gcc/c-family/ * c-attribs.cc (handle_assume_attribute): New function. (c_common_attribute_table): Add entry for assume attribute. * c-lex.cc (c_common_has_attribute): Handle __have_cpp_attribute (assume). gcc/c/ * c-parser.cc (handle_assume_attribute): New function. (c_parser_declaration_or_fndef): Handle assume attribute. (c_parser_attribute_arguments): Add assume_attr argument, if true, parse first argument as conditional expression. (c_parser_gnu_attribute, c_parser_std_attribute): Adjust c_parser_attribute_arguments callers. (c_parser_statement_after_labels) <case RID_ATTRIBUTE>: Handle assume attribute. gcc/cp/ * cp-tree.h (process_stmt_assume_attribute): Implement C++23 P1774R8 - Portable assumptions. Declare. (diagnose_failing_condition): Declare. (find_failing_clause): Likewise. * parser.cc (assume_attr): New enumerator. (cp_parser_parenthesized_expression_list): Handle assume_attr. Remove identifier variable, for id_attr push the identifier into expression_list right away instead of inserting it before all the others at the end. (cp_parser_conditional_expression): New function. (cp_parser_constant_expression): Use it. (cp_parser_statement): Handle assume attribute. (cp_parser_expression_statement): Likewise. (cp_parser_gnu_attribute_list): Use assume_attr for assume attribute. (cp_parser_std_attribute): Likewise. Handle standard assume attribute like gnu::assume. * cp-gimplify.cc (process_stmt_assume_attribute): New function. * constexpr.cc: Include fold-const.h. (find_failing_clause_r, find_failing_clause): New functions, moved from semantics.cc with ctx argument added and if non-NULL, call cxx_eval_constant_expression rather than fold_non_dependent_expr. (cxx_eval_internal_function): Handle IFN_ASSUME. (potential_constant_expression_1): Likewise. * pt.cc (tsubst_copy_and_build): Likewise. * semantics.cc (diagnose_failing_condition): New function. (find_failing_clause_r, find_failing_clause): Moved to constexpr.cc. (finish_static_assert): Use it. Add auto_diagnostic_group. gcc/testsuite/ * gcc.dg/attr-assume-1.c: New test. * gcc.dg/attr-assume-2.c: New test. * gcc.dg/attr-assume-3.c: New test. * g++.dg/cpp2a/feat-cxx2a.C: Add colon to C++20 features comment, add C++20 attributes comment and move C++20 new features after the attributes before them. * g++.dg/cpp23/feat-cxx2b.C: Likewise. Test __has_cpp_attribute(assume). * g++.dg/cpp23/attr-assume1.C: New test. * g++.dg/cpp23/attr-assume2.C: New test. * g++.dg/cpp23/attr-assume3.C: New test. * g++.dg/cpp23/attr-assume4.C: New test.
2022-10-06cselib: Skip BImode while keeping track of subvalue relations [PR107088]Stefan Schulze Frielinghaus1-0/+1
For BImode get_narrowest_mode evaluates to QImode but BImode < QImode. Thus FOR_EACH_MODE_UNTIL never reaches BImode and iterates until OImode for which no wider mode exists so we end up with VOIDmode and fail. Fixed by adding a size guard so we effectively skip BImode. gcc/ChangeLog: PR rtl-optimization/107088 * cselib.cc (new_cselib_val): Skip BImode while keeping track of subvalue relations.
2022-10-06Setting explicit NANs sets UNDEFINED for -ffinite-math-only.Aldy Hernandez2-52/+67
We recently agreed that setting a range of NAN should instead set UNDEFINED for -ffinite-math-only. This patch makes that change to frange::set_nan() directly. Also, calling frange::update_nan() will now be a nop for !HONOR_NANS. Doing this in the setters simplifies everywhere we set NANs, as it keeps us from introducing NANs by mistake. gcc/ChangeLog: * value-range.cc (frange::set): Call set_nan unconditionally. (range_tests_nan): Adjust tests. (range_tests_signed_zeros): Same. (range_tests_floats): Same. * value-range.h (frange::update_nan): Guard with HONOR_NANS. (frange::set_nan): Set undefined if !HONOR_NANS.
2022-10-06Do not check finite_operands_p twice in range-ops-float.Aldy Hernandez1-8/+4
The uses of finite_operands_p removed are guarded by a call to finite_operands_p already. gcc/ChangeLog: * range-op-float.cc (foperator_lt::fold_range): Remove extra check to finite_operands_p. (foperator_le::fold_range): Same. (foperator_gt::fold_range): Same. (foperator_ge::fold_range): Same.
2022-10-06Do not double print INF and NAN in frange pretty printer.Aldy Hernandez1-1/+5
gcc/ChangeLog: * value-range-pretty-print.cc (vrange_printer::print_real_value): Avoid printing INF and NAN twice.
2022-10-06Daily bump.GCC Administrator9-1/+416
2022-10-05rs6000: Remove the wD constraintSegher Boessenkool2-9/+0
2022-10-05 Segher Boessenkool <segher@kernel.crashing.org> * config/rs6000/constraints.md (wD): Delete. * doc/md.texi (Machine Constraints): Adjust.
2022-10-05rs6000: Rework vsx_extract_<mode>Segher Boessenkool1-43/+37
Extracting the left and right halfs of a vector are entirely different operations. Things are simpler if they are separate define_insns, and it is easy to get rid of the "wD" constraint use then. This also give the variant that is a no-op copy its own alternative, of length 0 (and this, cost 0, making it more likely RA will choose it. 2022-10-05 Segher Boessenkool <segher@kernel.crashing.org> * config/rs6000/vsx.md (vsx_extract_<mode>): Replace define_insn by a define_expand. Split the contents to... (*vsx_extract_<mode>_0): ... this. Rewrite. (*vsx_extract_<mode>_1): ... and this. Rewrite.
2022-10-05rs6000: Remove "wD" from *vsx_extract_<mode>_storeSegher Boessenkool1-2/+3
We can use "n" instead of "wD" if we simply test the value of the integer constant directly. 2022-10-05 Segher Boessenkool <segher@kernel.crashing.org> * config/rs6000/vsx.md (*vsx_extract_<mode>_store): Use "n" instead of "wD" constraint.
2022-10-05contrib: run fetch before pushing Daily bumpMartin Liska1-1/+2
As seen from recent days, the script fails when it pushes a branch while another revision was pushed by a user. Prevent that by doing fetch right before the pull. The error message example: cmdline: git push origin releases/gcc-11 stderr: 'fatal: unable to parse object: 4249a65c814287af667aa78789436d3fc618e80a error: remote unpack failed: eof before pack header was fully read contrib/ChangeLog: * gcc-changelog/git_update_version.py: Do fetch before a push.
2022-10-05analyzer: add regression test for PR 107158David Malcolm1-0/+83
PR analyzer/107158 reports an ICE when using -fanalyzer -fanalyzer-call-summaries on a particular source file. It turns out I just fixed this ICE in r13-3094-g6832c95c0e1a58. This followup patch adds a somewhat reduced reproducer as a regression test. Unfortunately, although the ICE is fixed, there are two false positives from -Wanalyzer-malloc-leak on the test case, so I'm going to use PR analyzer/107158 for tracking those false positives. gcc/testsuite/ChangeLog: PR analyzer/107158 * gcc.dg/analyzer/call-summaries-pr107158.c: New test. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-10-05analyzer: simplify some includesDavid Malcolm41-180/+8
gcc/analyzer/ChangeLog: * analysis-plan.cc: Simplify includes. * analyzer-pass.cc: Likewise. * analyzer-selftests.cc: Likewise. * analyzer.cc: Likewise. * analyzer.h: Add includes of "json.h" and "tristate.h". * call-info.cc: Simplify includes. * call-string.cc: Likewise. * call-summary.cc: Likewise. * checker-path.cc: Likewise. * complexity.cc: Likewise. * constraint-manager.cc: Likewise. * diagnostic-manager.cc: Likewise. * engine.cc: Likewise. * feasible-graph.cc: Likewise. * known-function-manager.cc: Likewise. * pending-diagnostic.cc: Likewise. * program-point.cc: Likewise. * program-state.cc: Likewise. * region-model-asm.cc: Likewise. * region-model-impl-calls.cc: Likewise. * region-model-manager.cc: Likewise. * region-model-reachability.cc: Likewise. * region-model.cc: Likewise. * region-model.h: Include "selftest.h". * region.cc: Simplify includes. * sm-fd.cc: Likewise. * sm-file.cc: Likewise. * sm-malloc.cc: Likewise. * sm-pattern-test.cc: Likewise. * sm-sensitive.cc: Likewise. * sm-signal.cc: Likewise. * sm-taint.cc: Likewise. * sm.cc: Likewise. * state-purge.cc: Likewise. * store.cc: Likewise. * store.h: Likewise. * supergraph.cc: Likewise. * svalue.cc: Likewise. * svalue.h: Likewise. * trimmed-graph.cc: Likewise. * varargs.cc: Likewise. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-10-05analyzer: fix ICEs seen with call summaries on PR 107060David Malcolm9-15/+62
This doesn't fix the various false positives seen with -fanalyzer-call-summaries on PR 107060, but stops it crashing at -O2. gcc/analyzer/ChangeLog: PR analyzer/107060 * call-summary.cc (call_summary_replay::convert_svalue_from_summary_1): Handle NULL results from convert_svalue_from_summary in SK_UNARY_OP and SK_BIN_OP. * engine.cc (impl_region_model_context::on_unknown_change): Bail out on svalues that can't have associated state. * region-model-impl-calls.cc (region_model::impl_call_analyzer_get_unknown_ptr): New. * region-model.cc (region_model::on_stmt_pre): Handle "__analyzer_get_unknown_ptr". * region-model.h (region_model::impl_call_analyzer_get_unknown_ptr): New decl. * store.cc (store::replay_call_summary_cluster): Avoid trying to create binding clusters for base regions that shouldn't have them. gcc/ChangeLog: PR analyzer/107060 * doc/analyzer.texi (__analyzer_get_unknown_ptr): Document. gcc/testsuite/ChangeLog: PR analyzer/107060 * gcc.dg/analyzer/analyzer-decls.h (__analyzer_get_unknown_ptr): New decl. * gcc.dg/analyzer/call-summaries-2.c (test_summarized_writes_param_to_ptr_unknown): New test. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-10-05Fortran: Add OpenMP's assume(s) directivesTobias Burnus16-8/+665
libgomp/ChangeLog: * libgomp.texi (OpenMP 5.1 Impl. Status): Mark 'assume' as 'Y'. gcc/fortran/ChangeLog: * dump-parse-tree.cc (show_omp_assumes): New. (show_omp_clauses, show_namespace): Call it. (show_omp_node, show_code_node): Handle OpenMP ASSUME. * gfortran.h (enum gfc_statement): Add ST_OMP_ASSUME, ST_OMP_END_ASSUME, ST_OMP_ASSUMES and ST_NOTHING. (gfc_exec_op): Add EXEC_OMP_ASSUME. (gfc_omp_assumptions): New struct. (gfc_get_omp_assumptions): New XCNEW #define. (gfc_omp_clauses, gfc_namespace): Add assume member. (gfc_resolve_omp_assumptions): New prototype. * match.h (gfc_match_omp_assume, gfc_match_omp_assumes): New. * openmp.cc (omp_code_to_statement): Forward declare. (enum gfc_omp_directive_kind, struct gfc_omp_directive): New. (gfc_free_omp_clauses): Free assume member and its struct data. (enum omp_mask2): Add OMP_CLAUSE_ASSUMPTIONS. (gfc_omp_absent_contains_clause): New. (gfc_match_omp_clauses): Call it; optionally use passed omp_clauses argument. (omp_verify_merge_absent_contains, gfc_match_omp_assume, gfc_match_omp_assumes, gfc_resolve_omp_assumptions): New. (resolve_omp_clauses): Call the latter. (gfc_resolve_omp_directive, omp_code_to_statement): Handle EXEC_OMP_ASSUME. * parse.cc (decode_omp_directive): Parse OpenMP ASSUME(S). (next_statement, parse_executable, parse_omp_structured_block): Handle ST_OMP_ASSUME. (case_omp_decl): Add ST_OMP_ASSUMES. (gfc_ascii_statement): Handle Assumes, optional return string without '!$OMP '/'!$ACC ' prefix. * parse.h (gfc_ascii_statement): Add optional bool arg to prototype. * resolve.cc (gfc_resolve_blocks, gfc_resolve_code): Add EXEC_OMP_ASSUME. (gfc_resolve): Resolve ASSUMES directive. * symbol.cc (gfc_free_namespace): Free omp_assumes member. * st.cc (gfc_free_statement): Handle EXEC_OMP_ASSUME. * trans-openmp.cc (gfc_trans_omp_directive): Likewise. * trans.cc (trans_code): Likewise. gcc/testsuite/ChangeLog: * gfortran.dg/gomp/assume-1.f90: New test. * gfortran.dg/gomp/assume-2.f90: New test. * gfortran.dg/gomp/assumes-1.f90: New test. * gfortran.dg/gomp/assumes-2.f90: New test.
2022-10-05c++: lvalue_kind tweakJason Merrill1-1/+11
I was wondering how lvalue_kind handles VIEW_CONVERT_EXPR; in cases where the type actually changes, it should have the same prvalue->xvalue effect as ARRAY_REF, since we need to materialize a temporary to get an object we can reinterpret as another type. Currently this only fires on builtin-shufflevector-3.c, where we use VIEW_CONVERT_EXPR to reinterpret a vector as an array. REALPART_EXPR and IMAGPART_EXPR should also be treated like COMPONENT_REF. PREINCREMENT_EXPR and PREDECREMENT_EXPR should only be applied to glvalues, but if for some reason they were applied to a prvalue this would be correct. TRY_CATCH_EXPR around a prvalue is also questionable, but this is the right handling. gcc/cp/ChangeLog: * tree.cc (lvalue_kind) [VIEW_CONVERT_EXPR]: Change prvalue to xvalue.
2022-10-05RISC-V: Introduce RVV header to enable builtin typesJu-Zhe Zhong21-13/+665
gcc/ChangeLog: * config.gcc: Add riscv_vector.h. * config/riscv/riscv-builtins.cc: Add RVV builtin types support. * config/riscv/riscv-c.cc (riscv_pragma_intrinsic): New function. (riscv_register_pragmas): Ditto. * config/riscv/riscv-protos.h (riscv_register_pragmas): Ditto. (init_builtins): Move declaration from riscv-vector-builtins.h to riscv-protos.h. (mangle_builtin_type): Ditto. (verify_type_context): Ditto. (handle_pragma_vector): New function. * config/riscv/riscv-vector-builtins.cc (GTY): New variable. (register_vector_type): New function. (init_builtins): Add RVV builtin types support. (handle_pragma_vector): New function. * config/riscv/riscv-vector-builtins.h (GCC_RISCV_V_BUILTINS_H): Change name according to file name. (GCC_RISCV_VECTOR_BUILTINS_H): Ditto. (init_builtins): Remove declaration in riscv-vector-builtins.h. (mangle_builtin_type): Ditto. (verify_type_context): Ditto. * config/riscv/riscv.cc: Adjust for RVV builtin types support. * config/riscv/riscv.h (REGISTER_TARGET_PRAGMAS): New macro. * config/riscv/t-riscv: Remove redundant file including. * config/riscv/riscv_vector.h: New file. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/base/pragma-1.c: New test. * gcc.target/riscv/rvv/base/pragma-2.c: New test. * gcc.target/riscv/rvv/base/pragma-3.c: New test. * gcc.target/riscv/rvv/base/user-1.c: New test. * gcc.target/riscv/rvv/base/user-2.c: New test. * gcc.target/riscv/rvv/base/user-3.c: New test. * gcc.target/riscv/rvv/base/user-4.c: New test. * gcc.target/riscv/rvv/base/user-5.c: New test. * gcc.target/riscv/rvv/base/user-6.c: New test. * gcc.target/riscv/rvv/base/vread_csr.c: New test. * gcc.target/riscv/rvv/base/vwrite_csr.c: New test.
2022-10-05range-op: Keep nonzero mask up to date with truncating casts.Aldy Hernandez1-7/+11
gcc/ChangeLog: * range-op.cc (operator_cast::fold_range): Handle truncating casts for nonzero masks.
2022-10-05libtdc++: Regenerate Makefile.in after freestanding header changesJonathan Wakely1-52/+49
libstdc++-v3/ChangeLog: * include/Makefile.in: Regenerate.
2022-10-05c: support the attribute starting with '_'Martin Liska1-2/+2
PR c/107156 gcc/ChangeLog: * attribs.h (lookup_attribute_by_prefix): Support the attribute starting with underscore (_Noreturn).
2022-10-05libstdc++: Guard use of new built-in with __has_builtinJonathan Wakely1-0/+2
Another case where I forgot that non-GCC compilers don't have this built-in yet. libstdc++-v3/ChangeLog: * include/bits/invoke.h (__invoke_r): Check __has_builtin(__reference_converts_from_temporary) before using built-in.
2022-10-05[PR tree-optimization/107052] range-ops: Take into account nonzero mask in ↵Aldy Hernandez2-3/+25
popcount. PR tree-optimization/107052 gcc/ChangeLog: * gimple-range-op.cc (cfn_popcount::fold_range): Take into account nonzero bit mask.
2022-10-05[PR tree-optimization/107052] range-ops: Pass nonzero masks through cast.Aldy Hernandez1-0/+8
Track nonzero masks through a cast in range-ops. PR tree-optimization/107052 gcc/ChangeLog: * range-op.cc (operator_cast::fold_range): Set nonzero mask.
2022-10-05Fix bogus -Wstringop-overflow warning in AdaEric Botcazou6-7/+71
It comes from a discrepancy between get_offset_range, which uses a signed type, and handle_array_ref, which uses an unsigned one, to do computations. gcc/ PR tree-optimization/106698 * pointer-query.cc (handle_array_ref): Fix handling of low bound. gcc/testsuite/ * gnat.dg/lto26.adb: New test. * gnat.dg/lto26_pkg1.ads, gnat.dg/lto26_pkg1.adb: New helper. * gnat.dg/lto26_pkg2.ads, gnat.dg/lto26_pkg2.adb: Likewise.
2022-10-05analyzer: remove unused variablesMartin Liska4-8/+1
Fixes: gcc/analyzer/call-summary.h:103:13: warning: private field 'm_called_fn' is not used [-Wunused-private-field] gcc/analyzer/engine.cc:1631:24: warning: unused parameter 'uncertainty' [-Wunused-parameter] gcc/analyzer/ChangeLog: * call-summary.cc (call_summary_replay::call_summary_replay): Remove unused variable and arguments. * call-summary.h: Likewise. * engine.cc (exploded_node::on_stmt): Likewise. (exploded_node::replay_call_summaries): Likewise. (exploded_node::replay_call_summary): Likewise. * exploded-graph.h (class exploded_node): Likewise.
2022-10-05testsuite: mark a test with xfailMartin Liska1-1/+1
PR tree-optimization/106679 gcc/testsuite/ChangeLog: * gcc.dg/tree-prof/cmpsf-1.c: Mark as a known limitation.
2022-10-05testsuite: 'b' instruction can't do long enough jumpsTorbjörn SVENSSON2-3/+3
After moving the testglue in commit 9d503515cee, the jump to exit and abort is too far for the 'b' instruction on Cortex-M0. As most of the C code would generate a 'bl' instruction instead of a 'b' instruction, lets do the same for the inline assembler. The error seen without this patch: /tmp/cccCRiCl.o: in function `main': stack-protector-1.c:(.text+0x4e): relocation truncated to fit: R_ARM_THM_JUMP11 against symbol `__wrap_exit' defined in .text section in gcc_tg.o stack-protector-1.c:(.text+0x50): relocation truncated to fit: R_ARM_THM_JUMP11 against symbol `__wrap_abort' defined in .text section in gcc_tg.o collect2: error: ld returned 1 exit status gcc/testsuite/ChangeLog: * gcc.target/arm/stack-protector-1.c: Use 'bl' instead of 'b' instruction. * gcc.target/arm/stack-protector-3.c: Likewise. Co-Authored-By: Yvan ROUX <yvan.roux@foss.st.com> Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
2022-10-05testsuite: Windows reports errors with CreateProcessTorbjörn SVENSSON1-1/+1
When the mapper can't be executed, Windows report the error like: .../bad-mapper-1.C: error: failed CreateProcess mapper 'this-will-not-work' On Linux, the same error is reported this way: .../bad-mapper-1.C: error: failed execvp mapper 'this-will-not-work' This patch allows both output forms to be accepted. Patch has been verified on Windows and Linux. gcc/testsuite: * g++.dg/modules/bad-mapper-1.C: Also accept CreateProcess. Co-Authored-By: Yvan ROUX <yvan.roux@foss.st.com> Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com> Signed-off-by: Jonathan Yong <10walls@gmail.com>
2022-10-05testsuite: /dev/null is not accessible on WindowsTorbjörn SVENSSON1-5/+12
When running the DejaGNU testsuite on a toolchain built for native Windows, the path /dev/null can't be used to open a stream to void. On native Windows, the resource is instead named "nul". The error would look like this: c:/arm-11.3.rel1/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: cannot find @/dev/null: No such file or directory Patch has been verified on Windows and Linux. gcc/testsuite: * gcc.misc-tests/outputs.exp: Use "@nul" for Windows, "@/dev/null" for other environments. Co-Authored-By: Yvan ROUX <yvan.roux@foss.st.com> Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com> Signed-off-by: Jonathan Yong <10walls@gmail.com>
2022-10-05RISC-V: remove deprecate pic code model macroVineet Gupta9-29/+0
Came across this deprecated symbol when looking around for -mexplicit-relocs handling in code Signed-off-by: Vineet Gupta <vineetg@rivosinc.com> gcc/ChangeLog: * config/riscv/riscv-c.cc (riscv_cpu_cpp_builtins): Remove __riscv_cmodel_pic, that deprecated in last version. gcc/testsuite/ChangeLog: * gcc.target/riscv/predef-1.c: Remove __riscv_cmodel_pic check. * gcc.target/riscv/predef-2.c: Ditto. * gcc.target/riscv/predef-3.c: Ditto. * gcc.target/riscv/predef-4.c: Ditto. * gcc.target/riscv/predef-5.c: Ditto. * gcc.target/riscv/predef-6.c: Ditto. * gcc.target/riscv/predef-7.c: Ditto. * gcc.target/riscv/predef-8.c: Ditto.
2022-10-04analyzer: revamp side-effects of call summaries [PR107072]David Malcolm29-54/+2479
With -fanalyzer-call-summaries the analyzer canl attempt to summarize the effects of some function calls at their call site, rather than simulate the call directly, which can avoid big slowdowns during analysis. Previously, this summarization was extremely simplistic: no attempt was made to update sm-state, and region_model::update_for_call_summary would simply set the return value of the function to UNKNOWN, and assume the function had no side effects. This patch implements less simplistic summarizations: it tracks each possible return enode from the called function, and attempts to generate a successor enode from the callsite for each that have compatible conditions, mapping state changes in the summary to state changes at the callsite. It also implements the beginnings of heuristics for generating user-facing descriptions of a summary e.g. "when 'foo' returns NULL" versus: "when 'foo' returns a heap-allocated buffer" This still has some bugs, but much more accurately tracks the effects of a call, and so is an improvement; it should only have an effect when -fanalyzer-call-summaries is enabled. As before, -fanalyzer-call-summaries is disabled by default in analyzer.opt (but enabled by default in the test suite). gcc/ChangeLog: PR analyzer/107072 * Makefile.in (ANALYZER_OBJS): Add analyzer/call-summary.o. gcc/analyzer/ChangeLog: PR analyzer/107072 * analyzer-logging.h: Include "diagnostic-core.h". * analyzer.h: Include "function.h". (class call_summary): New forward decl. (class call_summary_replay): New forward decl. (struct per_function_data): New forward decl. (struct interesting_t): New forward decl. (custom_edge_info::update_state): New vfunc. * call-info.cc (custom_edge_info::update_state): New. * call-summary.cc: New file. * call-summary.h: New file. * constraint-manager.cc: Include "analyzer/call-summary.h". (class replay_fact_visitor): New. (constraint_manager::replay_call_summary): New. * constraint-manager.h (constraint_manager::replay_call_summary): New. * engine.cc: Include "analyzer/call-summary.h". (exploded_node::on_stmt): Handle call summaries. (class call_summary_edge_info): New. (exploded_node::replay_call_summaries): New. (exploded_node::replay_call_summary): New. (per_function_data::~per_function_data): New. (per_function_data::add_call_summary): Move here from header and reimplement. (exploded_graph::process_node): Call update_state rather than update_model when handling bifurcation (viz_callgraph_node::dump_dot): Use a regular label rather than an HTML table; add summaries to dump. * exploded-graph.h: Include "alloc-pool.h", "fibonacci_heap.h", "supergraph.h", "sbitmap.h", "shortest-paths.h", "analyzer/sm.h", "analyzer/program-state.h", and "analyzer/diagnostic-manager.h". (exploded_node::replay_call_summaries): New decl. (exploded_node::replay_call_summary): New decl. (per_function_data::~per_function_data): New decl. (per_function_data::add_call_summary): Move implemention from header. (per_function_data::m_summaries): Update type of element. * known-function-manager.h: Include "analyzer/analyzer-logging.h". * program-point.h: Include "pretty-print.h" and "analyzer/call-string.h". * program-state.cc: Include "analyzer/call-summary.h". (sm_state_map::replay_call_summary): New. (program_state::replay_call_summary): New. * program-state.h (sm_state_map::replay_call_summary): New decl. (program_state::replay_call_summary): New decl. * region-model-manager.cc (region_model_manager::get_or_create_asm_output_svalue): New overload. * region-model-manager.h (region_model_manager::get_or_create_asm_output_svalue): New overload decl. * region-model.cc: Include "analyzer/call-summary.h". (region_model::maybe_update_for_edge): Remove call to region_model::update_for_call_summary on SUPEREDGE_INTRAPROCEDURAL_CALL. (region_model::update_for_call_summary): Delete. (region_model::replay_call_summary): New. * region-model.h (region_model::replay_call_summary): New decl. (region_model::update_for_call_summary): Delete decl. * store.cc: Include "analyzer/call-summary.h". (store::replay_call_summary): New. (store::replay_call_summary_cluster): New. * store.h: Include "tristate.h". (is_a_helper <const ana::concrete_binding *>::test): New. (store::replay_call_summary): New decl. (store::replay_call_summary_cluster): New decl. * supergraph.cc (get_ultimate_function_for_cgraph_edge): Remove "static" from decl. (supergraph_call_edge): Make stmt param const. * supergraph.h: Include "ordered-hash-map.h", "cfg.h", "basic-block.h", "gimple.h", "gimple-iterator.h", and "digraph.h". (supergraph_call_edge): Make stmt param const. (get_ultimate_function_for_cgraph_edge): New decl. * svalue.cc (compound_svalue::compound_svalue): Assert that we're not nesting compound_svalues. * svalue.h: Include "json.h", "analyzer/store.h", and "analyzer/program-point.h". (asm_output_svalue::get_num_outputs): New accessor. gcc/testsuite/ChangeLog: PR analyzer/107072 * gcc.dg/analyzer/call-summaries-2.c: New test. * gcc.dg/analyzer/call-summaries-3.c: New test. * gcc.dg/analyzer/call-summaries-asm-x86.c: New test. * gcc.dg/analyzer/call-summaries-malloc.c: New test. * gcc.dg/analyzer/call-summaries-pr107072.c: New test. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-10-04analyzer: move region_model_manager decl to its own headerDavid Malcolm2-288/+313
gcc/analyzer/ChangeLog: * region-model.h: Include "analyzer/region-model-manager.h" (class region_model_manager): Move decl to... * region-model-manager.h: ...this new file. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-10-04analyzer: fold -(-(VAL)) to VALDavid Malcolm1-0/+11
gcc/analyzer/ChangeLog: * region-model-manager.cc (region_model_manager::maybe_fold_unaryop): Fold -(-(VAL)) to VAL. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-10-04analyzer: widening_svalues take a function_point rather than a program_pointDavid Malcolm5-12/+17
Enabling work towrads better call summarization. gcc/analyzer/ChangeLog: * region-model-manager.cc (region_model_manager::get_or_create_widening_svalue): Use a function_point rather than a program_point. * region-model.cc (selftest::test_widening_constraints): Likewise. * region-model.h (region_model_manager::get_or_create_widening_svalue): Likewise. (model_merger::get_function_point): New. * svalue.cc (svalue::can_merge_p): Use a function_point rather than a program_point. (svalue::can_merge_p): Likewise. * svalue.h (widening_svalue::key_t): Likewise. (widening_svalue::widening_svalue): Likewise. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-10-05Daily bump.GCC Administrator9-1/+277
2022-10-04c++: fix debug info for array temporary [PR107154]Jason Merrill2-0/+27
In the testcase the elaboration of the array init that happens at genericize time was getting the location info for the end of the function; fixed by doing the expansion at the location of the original expression. PR c++/107154 gcc/cp/ChangeLog: * cp-gimplify.cc (cp_genericize_init_expr): Use iloc_sentinel. (cp_genericize_target_expr): Likewise. gcc/testsuite/ChangeLog: * g++.dg/debug/dwarf2/lineno-array1.C: New test.
2022-10-04attribs: Add overloads with namespace nameJakub Jelinek2-0/+101
I've discovered a problem with the way we handle scoped attributes. For declaration or type attributes for attributes we don't know anything about we just don't add them to the declarations or types, so later in the FEs and middle-end it is fine to use lookup_attribute etc. which just check the attribute name and not namespace because non-standard non-GNU attributes just won't show there. But in the case of attributes on statements, nothing has filtered out the unknown attributes, so with my earlier assume attribute patch e.g. c-c++-common/Wno-attributes-6.c test failed because it uses: [[vendor::assume(1 + 1 == 2)]]; with -Wno-attributes=vendor::assume and lookup_attribute ("assume", ) finds such attribute and handled it that way. So, for those cases, this patch introduces lookup_attribute and remove_attribute overloads which specify also the namespace. I think the fallthrough, hot, cold, likely, unlikely attribute handling will need to use the new APIs too, so that we don't handle msft::fallthrough attribute as something we'd know. 2022-10-04 Jakub Jelinek <jakub@redhat.com> * attribs.h (remove_attribute): Declare overload with additional attr_ns argument. (private_lookup_attribute): Declare overload with additional attr_ns and attr_ns_len arguments. (lookup_attribute): New overload with additional attr_ns argument. * attribs.cc (remove_attribute): New overload with additional attr_ns argument. (private_lookup_attribute): New overload with additional attr_ns and attr_ns_len arguments.
2022-10-04attribs: Add missing auto_diagnostic_group 3 timesJakub Jelinek1-0/+3
In these spots, the error/error_at has some inform afterwards which are explanation part of the same diagnostics, so should be tied with auto_diagnostic_group with it. 2022-10-04 Jakub Jelinek <jakub@redhat.com> * attribs.cc (handle_ignored_attributes_option, decl_attributes, common_function_versions): Use auto_diagnostic_group.
2022-10-04Remove assert from set_nonzero_bits.Aldy Hernandez1-1/+0
The assert removed by this patch was there to keep users from passing masks of incompatible types. The self tests are passing host wide ints down (set_nonzero_bits (-1)), which seem to be 32 bits, whereas some embedded targets have integer_type_node's of 16-bits. This is causing problems in m32c-elf, among others. I suppose there's no harm in passing a 32-bit mask, because set_nonzero_bits calls wide_int::from() to convert the mask to the appropriate type. So we can remove the assert. gcc/ChangeLog: * value-range.cc (irange::set_nonzero_bits): Remove assert.
2022-10-04libstdc++: Fix test FAIL for old std::string ABIJonathan Wakely1-3/+9
libstdc++-v3/ChangeLog: * testsuite/std/ranges/adaptors/join_with/1.cc: Remove unused <sstream header. (test04): Remove constexpr for old std::string ABI and test at runtime.
2022-10-04libstdc++: Use new built-ins __remove_cv, __remove_reference etc.Jonathan Wakely1-9/+24
libstdc++-v3/ChangeLog: * include/std/type_traits (remove_cv): Use __remove_cv built-in. (remove_reference): Use __remove_reference built-in. (remove_cvref): Use __remove_cvref built-in. Remove inheritance for fallback implementation.
2022-10-04libstdc++: Refactor seed sequence constraints in <random>Jonathan Wakely2-18/+27
Every use of _If_seed_seq in <random> and <ext/random> uses it with enable_if. We can just move the enable_if into the helper alias instead of repeating it everywhere. libstdc++-v3/ChangeLog: * include/bits/random.h (__is_seed_seq): Replace with ... (_If_seed_seq_for): ... this. * include/ext/random: Adjust to use _If_seed_seq_for.
2022-10-04c++: install cp-trait.def as part of plugin headers [PR107136]Patrick Palka1-1/+1
This is apparently needed since we include cp-trait.def from cp-tree.h (in order to define the cp_trait_kind enum), as with operators.def. PR c++/107136 gcc/cp/ChangeLog: * Make-lang.in (CP_PLUGIN_HEADERS): Add cp-trait.def.