aboutsummaryrefslogtreecommitdiff
path: root/gcc
AgeCommit message (Collapse)AuthorFilesLines
2022-11-23[Patch Arm] Add neon_fcadd and neon_fcmla to is_neon_type.Ramana Radhakrishnan1-1/+3
Appears to have been an oversight. gcc/ * config/arm/types.md: Update comment. (is_neon_type): Add neon_fcmla, neon_fcadd. Signed-off-by: Ramana Radhakrishnan <ramana.gcc@gmail.com>
2022-11-23doc: -Wdelete-non-virtual-dtor supersedes -Wnon-virtual-dtorJonathan Wakely1-0/+3
The newer -Wdelete-non-virtual-dtor has no false positives and fewer bugs. There is very little reason to use -Wnon-virtual-dtor instead. gcc/ChangeLog: * doc/invoke.texi (C++ Dialect Options): Recommend using -Wdelete-non-virtual-dtor instead of -Wnon-virtual-dtor.
2022-11-23Definition files in m2/gm2-gcc changed to FOR "C" and plugin fix.Gaius Mulley11-10/+19
gcc/m2/ChangeLog: * gm2-gcc/init.def: Change to DEFINITION FOR "C". * gm2-gcc/m2block.def: Change to DEFINITION FOR "C". * gm2-gcc/m2builtins.def: Change to DEFINITION FOR "C". * gm2-gcc/m2convert.def: Change to DEFINITION FOR "C". * gm2-gcc/m2except.def: Change to DEFINITION FOR "C". * gm2-gcc/m2misc.def: Change to DEFINITION FOR "C". * gm2-gcc/m2statement.def: Change to DEFINITION FOR "C". * gm2-gcc/m2top.def: Change to DEFINITION FOR "C". * gm2-gcc/m2tree.def: Change to DEFINITION FOR "C". * gm2-gcc/m2type.def: Change to DEFINITION FOR "C". * m2/gm2spec.cc: Generate an error if the user requests the m2-plugin when plugins were disabled during the build. Signed-off-by: Gaius Mulley <gaius.mulley@southwales.ac.uk>
2022-11-23diagnostics: Fix selftest ICE in certain locales [PR107722]Jakub Jelinek1-1/+4
As reported in the PR, since special_fname_builtin () call has been introduced, the diagnostics code compares filename against _("<built-in>") rather than "<built-in>", which means that if self tests are performed with the string being translated, one self-test fails. The following patch fixes that. 2022-11-23 Jakub Jelinek <jakub@redhat.com> PR bootstrap/107722 * diagnostic.cc (test_diagnostic_get_location_text): Test special_fname_builtin () rather than "<built-in>" and expect special_fname_builtin () concatenated with ":" for it.
2022-11-23d: respect --enable-link-mutex configure optionMartin Liska2-1/+2
I noticed the option is ignored because @DO_LINK_MUTEX@ is not defined in d/Make-lang.in. gcc/ChangeLog: * Makefile.in: Set DO_LINK_MUTEX. gcc/d/ChangeLog: * Make-lang.in: Use it as $DO_LINK_MUTEX.
2022-11-23c++: Fix up -fcontract* optionsJakub Jelinek1-5/+5
I've noticed +FAIL: compiler driver --help=c++ option(s): "^ +-.*[^:.]\$" absent from output: " -fcontract-build-level=[off|default|audit] Specify max contract level to generate runtime checks for" error, this is due to missing dot at the end of the description. The second part of the first hunk should fix that, but while at it, I find it weird that some options don't have RejectNegative, yet for options that accept an argument a negative option looks weird and isn't really handled. Though, shall we have those [on|off] options at all? Those are inconsistent with all other boolean options gcc has. Every other boolean option is -fwhatever for it being on and -fno-whatever for it being off, shouldn't the options be without arguments and accept negatives (-fcontract-assumption-mode vs. -fno-contract-assumption-mode etc.)? 2022-11-23 Jakub Jelinek <jakub@redhat.com> * c.opt (fcontract-assumption-mode=, fcontract-continuation-mode=, fcontract-role=, fcontract-semantic=): Add RejectNegative. (fcontract-build-level=): Terminate description with dot.
2022-11-23LoongArch: Add prefetch instructions.Lulu Cheng5-0/+55
Enable sw prefetching at -O3 and higher. Co-Authored-By: xujiahao <xujiahao@loongson.cn> gcc/ChangeLog: * config/loongarch/constraints.md (ZD): New constraint. * config/loongarch/loongarch-def.c: Initial number of parallel prefetch. * config/loongarch/loongarch-tune.h (struct loongarch_cache): Define number of parallel prefetch. * config/loongarch/loongarch.cc (loongarch_option_override_internal): Set up parameters to be used in prefetching algorithm. * config/loongarch/loongarch.md (prefetch): New template.
2022-11-22Revert "configure: Implement --enable-host-pie"Marek Polacek5-91/+39
This reverts commit 251c72a68af3a8b0638705b73ef120ffdf0053eb.
2022-11-22Revert "configure: Implement --enable-host-bind-now"Marek Polacek3-36/+3
This reverts commit 258d7149f92f19380c9f7763618d62408c064e60.
2022-11-22configure: Implement --enable-host-bind-nowMarek Polacek3-3/+36
As promised in the --enable-host-pie patch, this patch adds another configure option, --enable-host-bind-now, which adds -z now when linking the compiler executables in order to extend hardening. BIND_NOW with RELRO allows the GOT to be marked RO; this prevents GOT modification attacks. This option does not affect linking of target libraries; you can use LDFLAGS_FOR_TARGET=-Wl,-z,relro,-z,now to enable RELRO/BIND_NOW. c++tools/ChangeLog: * configure.ac (--enable-host-bind-now): New check. * configure: Regenerate. gcc/ChangeLog: * configure.ac (--enable-host-bind-now): New check. Add -Wl,-z,now to LD_PICFLAG if --enable-host-bind-now. * configure: Regenerate. * doc/install.texi: Document --enable-host-bind-now. lto-plugin/ChangeLog: * configure.ac (--enable-host-bind-now): New check. Link with -z,now. * configure: Regenerate.
2022-11-22configure: Implement --enable-host-pieMarek Polacek5-39/+91
This patch implements the --enable-host-pie configure option which makes the compiler executables PIE. This can be used to enhance protection against ROP attacks, and can be viewed as part of a wider trend to harden binaries. It is similar to the option --enable-host-shared, except that --e-h-s won't add -shared to the linker flags whereas --e-h-p will add -pie. It is different from --enable-default-pie because that option just adds an implicit -fPIE/-pie when the compiler is invoked, but the compiler itself isn't PIE. Since r12-5768-gfe7c3ecf, PCH works well with PIE, so there are no PCH regressions. When building the compiler, the build process may use various in-tree libraries; these need to be built with -fPIE so that it's possible to use them when building a PIE. For instance, when --with-included-gettext is in effect, intl object files must be compiled with -fPIE. Similarly, when building in-tree gmp, isl, mpfr and mpc, they must be compiled with -fPIE. I plan to add an option to link with -Wl,-z,now. ChangeLog: * Makefile.def: Pass $(PICFLAG) to AM_CFLAGS for gmp, mpfr, mpc, and isl. * Makefile.in: Regenerate. * Makefile.tpl: Set PICFLAG. * configure.ac (--enable-host-pie): New check. Set PICFLAG after this check. * configure: Regenerate. c++tools/ChangeLog: * Makefile.in: Rename PIEFLAG to PICFLAG. Set LD_PICFLAG. Use it. Use pic/libiberty.a if PICFLAG is set. * configure.ac (--enable-default-pie): Set PICFLAG instead of PIEFLAG. (--enable-host-pie): New check. * configure: Regenerate. fixincludes/ChangeLog: * Makefile.in: Set and use PICFLAG and LD_PICFLAG. Use the "pic" build of libiberty if PICFLAG is set. * configure.ac: * configure: Regenerate. gcc/ChangeLog: * Makefile.in: Set LD_PICFLAG. Use it. Set enable_host_pie. Remove NO_PIE_CFLAGS and NO_PIE_FLAG. Pass LD_PICFLAG to ALL_LINKERFLAGS. Use the "pic" build of libiberty if --enable-host-pie. * configure.ac (--enable-host-shared): Don't set PICFLAG here. (--enable-host-pie): New check. Set PICFLAG and LD_PICFLAG after this check. * configure: Regenerate. * doc/install.texi: Document --enable-host-pie. gcc/d/ChangeLog: * Make-lang.in: Remove NO_PIE_CFLAGS. intl/ChangeLog: * Makefile.in: Use @PICFLAG@ in COMPILE as well. * configure.ac (--enable-host-shared): Don't set PICFLAG here. (--enable-host-pie): New check. Set PICFLAG after this check. * configure: Regenerate. libcody/ChangeLog: * Makefile.in: Pass LD_PICFLAG to LDFLAGS. * configure.ac (--enable-host-shared): Don't set PICFLAG here. (--enable-host-pie): New check. Set PICFLAG and LD_PICFLAG after this check. * configure: Regenerate. libcpp/ChangeLog: * configure.ac (--enable-host-shared): Don't set PICFLAG here. (--enable-host-pie): New check. Set PICFLAG after this check. * configure: Regenerate. libdecnumber/ChangeLog: * configure.ac (--enable-host-shared): Don't set PICFLAG here. (--enable-host-pie): New check. Set PICFLAG after this check. * configure: Regenerate. libiberty/ChangeLog: * configure.ac: Also set shared when enable_host_pie. * configure: Regenerate. zlib/ChangeLog: * configure.ac (--enable-host-shared): Don't set PICFLAG here. (--enable-host-pie): New check. Set PICFLAG after this check. * configure: Regenerate.
2022-11-23Daily bump.GCC Administrator6-1/+447
2022-11-22Fix thinko in last patchJeff Law1-1/+1
gcc/ * tree-ssa-dom.cc (record_edge_info): Fix thinko in last commit.
2022-11-22Fix comment typos noticed by BernhardJeff Law1-4/+4
gcc/ * tree-ssa-dom.cc (record_edge_info): Fix comment typos.
2022-11-22Fix recent rvv/base/spill testcase failuresJeff Law1-1/+2
he core issue is we're expecting the frame to have a constant size, but it doesn't. So when using the to_constant method we abort. The safest thing to do is to set no shrink-wrapping components when the frame size is not fixed. We might be able to do better later -- iff we know the offset to the GPRs/FPRs is fixed and fits into the appropriate number of bits. Bootstrapped and regression tested (C-only) on riscv64-linux-gnu. As expected, it fixes a bucketload of failures in rvv/base/spill-*.c. gcc/ * config/riscv/riscv.cc (riscv_get_separate_components): Do not do shrink-wrapping for a frame with a variable size.
2022-11-22tree-object-size: Support strndup and strdupSiddhesh Poyarekar10-10/+500
Use string length of input to strdup to determine the usable size of the resulting object. Avoid doing the same for strndup since there's a chance that the input may be too large, resulting in an unnecessary overhead or worse, the input may not be NULL terminated, resulting in a crash where there would otherwise have been none. gcc/ChangeLog: * tree-object-size.cc (todo): New variable. (object_sizes_execute): Use it. (strdup_object_size): New function. (call_object_size): Use it. gcc/testsuite/ChangeLog: * gcc.dg/builtin-dynamic-object-size-0.c (test_strdup, test_strndup, test_strdup_min, test_strndup_min): New tests. (main): Call them. * gcc.dg/builtin-dynamic-object-size-1.c: Silence overread warnings. * gcc.dg/builtin-dynamic-object-size-2.c: Likewise. * gcc.dg/builtin-dynamic-object-size-3.c: Likewise. * gcc.dg/builtin-dynamic-object-size-4.c: Likewise. * gcc.dg/builtin-object-size-1.c: Silence overread warnings. Declare free, strdup and strndup. (test11): New test. (main): Call it. * gcc.dg/builtin-object-size-2.c: Silence overread warnings. Declare free, strdup and strndup. (test9): New test. (main): Call it. * gcc.dg/builtin-object-size-3.c: Silence overread warnings. Declare free, strdup and strndup. (test11): New test. (main): Call it. * gcc.dg/builtin-object-size-4.c: Silence overread warnings. Declare free, strdup and strndup. (test9): New test. (main): Call it.
2022-11-22analyzer: only look for named functions in root ns [PR107788]David Malcolm2-3/+24
gcc/analyzer/ChangeLog: PR analyzer/107788 * known-function-manager.cc (known_function_manager::get_match): Don't look up fndecls by name when they're not in the root namespace. gcc/testsuite/ChangeLog: PR analyzer/107788 * g++.dg/analyzer/named-functions.C: New test. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-11-22analyzer: fix ICE on 'bind(INT_CST, ...)' [PR107783]David Malcolm5-4/+27
This was crashing inside fd_phase_mismatch's ctor with assertion failure when the state was "fd-constant". Fix the ICE by not complaining about constants passed to these APIs. gcc/analyzer/ChangeLog: PR analyzer/107783 * sm-fd.cc (fd_state_machine::check_for_new_socket_fd): Don't complain when old state is "fd-constant". (fd_state_machine::on_listen): Likewise. (fd_state_machine::on_accept): Likewise. gcc/testsuite/ChangeLog: PR analyzer/107783 * gcc.dg/analyzer/fd-accept.c (test_accept_on_constant): New. * gcc.dg/analyzer/fd-bind.c (test_bind_on_constant): New. * gcc.dg/analyzer/fd-connect.c (test_connect_on_constant): New. * gcc.dg/analyzer/fd-listen.c (test_listen_on_connected_socket): Fix typo. (test_listen_on_constant): New. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-11-22analyzer: fix 'errno' on Solaris and OS X [PR107807]David Malcolm4-0/+97
gcc/analyzer/ChangeLog: PR analyzer/107807 * region-model-impl-calls.cc (register_known_functions): Register "___errno" and "__error" as synonyms for "__errno_location". gcc/testsuite/ChangeLog: PR analyzer/107807 * gcc.dg/analyzer/errno-___errno.c: New test. * gcc.dg/analyzer/errno-__error.c: New test. * gcc.dg/analyzer/errno-global-var.c: New test. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-11-22analyzer: eliminate region_model::impl_call_* special casesDavid Malcolm9-415/+648
Eliminate all of the remaining special cases in class region_model that handle various specific functions, replacing them with uses of known_function subclasses. Add various type-checks that ought to prevent ICEs for cases where functions match the name of a standard C library or POSIX function, but have incompatible arguments. gcc/analyzer/ChangeLog: * analyzer.h (class internal_known_function): New. (register_varargs_builtins): New decl. * engine.cc (exploded_node::on_stmt_pre): Remove "out_terminate_path" param from call to region_model::on_stmt_pre. (feasibility_state::maybe_update_for_edge): Likewise. * known-function-manager.cc: Include "basic-block.h", "gimple.h", and "analyzer/region-model.h". (known_function_manager::known_function_manager): Initialize m_combined_fns_arr. (known_function_manager::~known_function_manager): Clean up m_combined_fns_arr. (known_function_manager::get_by_identifier): Make const. (known_function_manager::add): New overloaded definitions for enum built_in_function and enum internal_fn. (known_function_manager::get_by_fndecl): Delete. (known_function_manager::get_match): New. (known_function_manager::get_internal_fn): New. (known_function_manager::get_normal_builtin): New. * known-function-manager.h (known_function_manager::get_by_identifier): Make private and add const qualifier. (known_function_manager::get_by_fndecl): Delete. (known_function_manager::add): Add overloaded decls for enum built_in_function name and enum internal_fn. (known_function_manager::get_match): New decl. (known_function_manager::get_internal_fn): New decl. (known_function_manager::get_normal_builtin): New decl. (known_function_manager::m_combined_fns_arr): New field. * region-model-impl-calls.cc (call_details::arg_is_size_p): New. (class kf_alloca): New. (region_model::impl_call_alloca): Convert to... (kf_alloca::impl_call_pre): ...this. (kf_analyzer_dump_capacity::matches_call_types_p): Rewrite check to use call_details::arg_is_pointer_p. (region_model::impl_call_builtin_expect): Convert to... (class kf_expect): ...this. (class kf_calloc): New, adding check that both arguments are size_t. (region_model::impl_call_calloc): Convert to... (kf_calloc::impl_call_pre): ...this. (kf_connect::matches_call_types_p): Rewrite check to use call_details::arg_is_pointer_p. (region_model::impl_call_error): Convert to... (class kf_error): ...this, and... (kf_error::impl_call_pre): ...this. (class kf_fgets): New, adding checks that args 0 and 2 are pointers. (region_model::impl_call_fgets): Convert to... (kf_fgets::impl_call_pre): ...this. (class kf_fread): New, adding checks on the argument types. (region_model::impl_call_fread): Convert to... (kf_fread::impl_call_pre): ...this. (class kf_free): New, adding check that the argument is a pointer. (region_model::impl_call_free): Convert to... (kf_free::impl_call_post): ...this. (class kf_getchar): New. (class kf_malloc): New, adding check that the argument is a size_t. (region_model::impl_call_malloc): Convert to... (kf_malloc::impl_call_pre): ...this. (class kf_memcpy): New, adding checks on arguments. (region_model::impl_call_memcpy): Convert to... (kf_memcpy::impl_call_pre): ...this. (class kf_memset): New. (region_model::impl_call_memset): Convert to... (kf_memset::impl_call_pre): ...this. (kf_pipe::matches_call_types_p): Rewrite check to use call_details::arg_is_pointer_p. (kf_putenv::matches_call_types_p): Likewise. (class kf_realloc): New, adding checks on the argument types. (region_model::impl_call_realloc): Convert to... (kf_realloc::impl_call_post): ...this. (class kf_strchr): New. (region_model::impl_call_strchr): Convert to... (kf_strchr::impl_call_post): ...this. (class kf_stack_restore): New. (class kf_stack_save): New. (class kf_stdio_output_fn): New. (class kf_strcpy): New, (region_model::impl_call_strcpy): Convert to... (kf_strcpy::impl_call_pre): ...this. (class kf_strlen): New. (region_model::impl_call_strlen): Convert to... (kf_strlen::impl_call_pre): ...this. (class kf_ubsan_bounds): New. (region_model::impl_deallocation_call): Reimplement to avoid call to impl_call_free. (register_known_functions): Add handlers for IFN_BUILTIN_EXPECT and IFN_UBSAN_BOUNDS. Add handlers for BUILT_IN_ALLOCA, BUILT_IN_ALLOCA_WITH_ALIGN, BUILT_IN_CALLOC, BUILT_IN_EXPECT, BUILT_IN_EXPECT_WITH_PROBABILITY, BUILT_IN_FPRINTF, BUILT_IN_FPRINTF_UNLOCKED, BUILT_IN_FPUTC, BUILT_IN_FPUTC_UNLOCKED, BUILT_IN_FPUTS, BUILT_IN_FPUTS_UNLOCKED, BUILT_IN_FREE, BUILT_IN_FWRITE, BUILT_IN_FWRITE_UNLOCKED, BUILT_IN_MALLOC, BUILT_IN_MEMCPY, BUILT_IN_MEMCPY_CHK, BUILT_IN_MEMSET, BUILT_IN_MEMSET_CHK, BUILT_IN_PRINTF, BUILT_IN_PRINTF_UNLOCKED, BUILT_IN_PUTC, BUILT_IN_PUTCHAR, BUILT_IN_PUTCHAR_UNLOCKED, BUILT_IN_PUTC_UNLOCKED, BUILT_IN_PUTS, BUILT_IN_PUTS_UNLOCKED, BUILT_IN_REALLOC, BUILT_IN_STACK_RESTORE, BUILT_IN_STACK_SAVE, BUILT_IN_STRCHR, BUILT_IN_STRCPY, BUILT_IN_STRCPY_CHK, BUILT_IN_STRLEN, BUILT_IN_VFPRINTF, and BUILT_IN_VPRINTF. Call register_varargs_builtins. Add handlers for "getchar", "memset", "fgets", "fgets_unlocked", "fread", "error", and "error_at_line". * region-model.cc (region_model::on_stmt_pre): Drop "out_terminate_path" param. (region_model::get_known_function): Reimplement by calling known_function_manager::get_match, passing new "cd" param. Add overload taking enum internal_fn. (region_model::on_call_pre): Drop "out_terminate_path" param. Remove special-case handling of internal fns IFN_BUILTIN_EXPECT, IFN_UBSAN_BOUNDS, and IFN_VA_ARG, of built-in fns BUILT_IN_ALLOCA, BUILT_IN_ALLOCA_WITH_ALIGN, BUILT_IN_CALLOC, BUILT_IN_EXPECT, BUILT_IN_EXPECT_WITH_PROBABILITY, BUILT_IN_FREE, BUILT_IN_MALLOC, BUILT_IN_MEMCPY, BUILT_IN_MEMCPY_CHK, BUILT_IN_MEMSET, BUILT_IN_MEMSET_CHK, BUILT_IN_REALLOC, BUILT_IN_STRCHR, BUILT_IN_STRCPY, BUILT_IN_STRCPY_CHK, BUILT_IN_STRLEN, BUILT_IN_STACK_SAVE, BUILT_IN_STACK_RESTORE, BUILT_IN_FPRINTF, BUILT_IN_FPRINTF_UNLOCKED, BUILT_IN_PUTC, BUILT_IN_PUTC_UNLOCKED, BUILT_IN_FPUTC, BUILT_IN_FPUTC_UNLOCKED, BUILT_IN_FPUTS, BUILT_IN_FPUTS_UNLOCKED, BUILT_IN_FWRITE, BUILT_IN_FWRITE_UNLOCKED, BUILT_IN_PRINTF, BUILT_IN_PRINTF_UNLOCKED, BUILT_IN_PUTCHAR, BUILT_IN_PUTCHAR_UNLOCKED, BUILT_IN_PUTS, BUILT_IN_PUTS_UNLOCKED, BUILT_IN_VFPRINTF, BUILT_IN_VPRINTF, BUILT_IN_VA_START, and BUILT_IN_VA_COPY, and of named functions "malloc", "calloc", "alloca", "realloc", "error", "error_at_line", "fgets", "fgets_unlocked", "fread", "getchar", "memset", "strchr", and "strlen". Replace all this special-casing with calls to get_known_function for internal fns and for fn decls. (region_model::on_call_post): Remove special-casing handling for "free" and "strchr", and for BUILT_IN_REALLOC, BUILT_IN_STRCHR, and BUILT_IN_VA_END. Replace by consolidating on usage of get_known_function. * region-model.h (call_details::arg_is_size_p): New. (region_model::on_stmt_pre): Drop "out_terminate_path" param. (region_model::on_call_pre): Likewise. (region_model::impl_call_alloca): Delete. (region_model::impl_call_builtin_expect): Delete. (region_model::impl_call_calloc): Delete. (region_model::impl_call_error): Delete. (region_model::impl_call_fgets): Delete. (region_model::impl_call_fread): Delete. (region_model::impl_call_free): Delete. (region_model::impl_call_malloc): Delete. (region_model::impl_call_memcpy): Delete. (region_model::impl_call_memset): Delete. (region_model::impl_call_realloc): Delete. (region_model::impl_call_strchr): Delete. (region_model::impl_call_strcpy): Delete. (region_model::impl_call_strlen): Delete. (region_model::impl_call_va_start): Delete. (region_model::impl_call_va_copy): Delete. (region_model::impl_call_va_arg): Delete. (region_model::impl_call_va_end): Delete. (region_model::check_region_for_write): Public. (region_model::get_known_function): Add "cd" param. Add overloaded decl taking enum internal_fn. * sm-malloc.cc: Update comments. * varargs.cc (class kf_va_start): New. (region_model::impl_call_va_start): Convert to... (kf_va_start::impl_call_pre): ...this. (class kf_va_copy): New. (region_model::impl_call_va_copy): Convert to... (kf_va_copy::impl_call_pre): ...this. (class kf_va_arg): New. (region_model::impl_call_va_arg): Convert to... (kf_va_arg::impl_call_pre): ...this. (class kf_va_end): New. (region_model::impl_call_va_end): Delete. (register_varargs_builtins): New. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-11-22testsuite: Fix missing EFFECTIVE_TARGETS variable errorsMaciej W. Rozycki1-18/+23
Permit running vector tests outside `check_vect_support_and_set_flags' environment, removing errors such as: ERROR: gcc.dg/analyzer/torture/pr93350.c -O0 : can't read "EFFECTIVE_TARGETS": no such variable for " dg-require-effective-target 1 vect_int " or: ERROR: gcc.dg/bic-bitmask-13.c: error executing dg-final: can't read "EFFECTIVE_TARGETS": no such variable with `mips-linux-gnu' target testing. The EFFECTIVE_TARGETS variable has originated from commit 9b7937cf8a06 ("Add support to run auto-vectorization tests for multiple effective targets."), where arrangements have been made to run vector tests run within `check_vect_support_and_set_flags' environment iteratively over all the vector unit variants available in the architecture using extra compilation flags regardless of whether the target environment arranged for a particular testsuite run has vector support enabled by default. So far this has been used for the MIPS target only. Vector tests have since been added though that run outside environment set up by `check_vect_support_and_set_flags' just using the current compilation environment with no extra flags added. This works for most targets, however causes problems with the MIPS target, because outside `check_vect_support_and_set_flags' environment the EFFECTIVE_TARGETS variable will not have been correctly set up even if it was added to the particular script invoking the test in question. Fix this by using just the current compilation environment whenever a vector feature is requested by `et-is-effective-target' in the absence of the EFFECTIVE_TARGETS variable. This required some modification to individual vector feature tests, which always added the compilation flags required for the determination of whether the given vector unit variant can be verified with the current testsuite run (except for the Loongson MMI variant). Now explicit flags are only passed in setting up EFFECTIVE_TARGETS and otherwise the current compilation environment will determine whether such a vector test is applicable. This changes how Loongson MMI is handled in that the `-mloongson-mmi' flag is explicitly passed for the determination of whether this vector unit variant can be verified, which I gather is how it was supposed to be arranged anyway because the flag is then added for testing the Loongson MMI variant. gcc/testsuite/ * lib/target-supports.exp (check_effective_target_mpaired_single): Add `args' argument and pass it to `check_no_compiler_messages' replacing `-mpaired-single'. (add_options_for_mips_loongson_mmi): Add `args' argument and pass it to `check_no_compiler_messages'. (check_effective_target_mips_msa): Add `args' argument and pass it to `check_no_compiler_messages' replacing `-mmsa'. (check_effective_target_mpaired_single_runtime) (add_options_for_mpaired_single): Pass `-mpaired-single' to `check_effective_target_mpaired_single'. (check_effective_target_mips_loongson_mmi_runtime) (add_options_for_mips_loongson_mmi): Pass `-mloongson-mmi' to `check_effective_target_mips_loongson_mmi'. (check_effective_target_mips_msa_runtime) (add_options_for_mips_msa): Pass `-mmsa' to `check_effective_target_mips_msa'. (et-is-effective-target): Verify that EFFECTIVE_TARGETS exists and if not, just check if the current compilation environment supports the target feature requested. (check_vect_support_and_set_flags): Pass `-mpaired-single', `-mloongson-mmi', and `-mmsa' to the respective target feature checks.
2022-11-22Fix wrong array type conversion with different storage ordeEric Botcazou2-1/+27
When two arrays of scalars have a different storage order in Ada, the front-end makes sure that the conversion is performed component-wise so that each component can be reversed. So it's a little bit counter productive that the ldist pass performs the opposite transformation and synthesizes a memcpy/memmove in this case. gcc/ * tree-loop-distribution.cc (loop_distribution::classify_builtin_ldst): Bail out if source and destination do not have the same storage order. gcc/testsuite/ * gnat.dg/sso18.adb: New test.
2022-11-22Improve detection of python.Gaius Mulley3-38/+557
Use a safer mechanism to detect python. gcc/ChangeLog: * configure.ac: Use AM_PATH_PYTHON and AM_CONDITIONAL to detect python. * aclocal.m4: Rebuilt. * configure: Rebuilt. Signed-off-by: Gaius Mulley <gaius.mulley@southwales.ac.uk>
2022-11-22ipa-sra: Dump edge summaries also for non-candidatesMartin Jambor1-5/+2
This should have been part of r12-578-g717d278af93a4a. Call edge summaries provide information required for IPA-SRA transformations in the callees but are generated when analyzing callers and thus also callers which are not IPA-SRA candidates themselves. Therefore we analyze them but don't dump them, which makes the dumops quite incomplete. This patch fixes that. gcc/ChangeLog: 2021-12-14 Martin Jambor <mjambor@suse.cz> * ipa-sra.cc (ipa_sra_dump_all_summaries): Dump edge summaries even for non-candidates.
2022-11-22ipa-cp: Do not consider useless aggregate constantsMartin Jambor1-1/+5
When building vectors of known aggregate values, there is no point in including those for parameters which are not used in any way whatsoever. This patch avoids that together with also other kinds of constants. gcc/ChangeLog: 2022-11-13 Martin Jambor <mjambor@suse.cz> * ipa-cp.cc (push_agg_values_from_edge): Do not consider constants in unused aggregate parameters.
2022-11-22ipa: IPA-SRA split detection simplificationMartin Jambor2-20/+13
I have noticed that the flag m_split_modifications_p of ipa_param_body_adjustments is not really necessary as it has to correspond to whether m_replacements is non-empty so this patches removes it. This also simplifies a bit some patches I work on. gcc/ChangeLog: 2022-11-10 Martin Jambor <mjambor@suse.cz> * ipa-param-manipulation.h (ipa_param_body_adjustments): Removed member m_split_modifications_p. * ipa-param-manipulation.cc (ipa_param_body_adjustments::common_initialization): Do not set m_split_modifications_p. (ipa_param_body_adjustments::ipa_param_body_adjustments): Remove initializations of m_split_modifications_p. (ipa_param_body_adjustments::modify_call_stmt): Check that m_replacements is empty instead of m_split_modifications_p.
2022-11-22ipa-cp: Do not be too optimistic about self-recursive edges (PR 107661)Martin Jambor2-7/+56
PR 107661 shows that function push_agg_values_for_index_from_edge should not attempt to optimize self-recursive call graph edges when called from cgraph_edge_brings_all_agg_vals_for_node. Unlike when being called from find_aggregate_values_for_callers_subset, we cannot expect that any cloning for constants would lead to the edge leading from a new clone to the same new clone, in this case it would only be redirected to a new callee. Fixed by adding a parameter to push_agg_values_from_edge whether being optimistic about self-recursive edges is possible. gcc/ChangeLog: 2022-11-22 Martin Jambor <mjambor@suse.cz> PR ipa/107661 * ipa-cp.cc (push_agg_values_from_edge): New parameter optimize_self_recursion, use it to decide whether to pass interim to the helper function. (find_aggregate_values_for_callers_subset): Pass true in the new parameter of push_agg_values_from_edge. (cgraph_edge_brings_all_agg_vals_for_node): Pass false in the new parameter of push_agg_values_from_edge. gcc/testsuite/ChangeLog: 2022-11-22 Martin Jambor <mjambor@suse.cz> PR ipa/107661 * g++.dg/ipa/pr107661.C: New test.
2022-11-22gcn: Add __builtin_gcn_{get_stack_limit,first_call_this_thread_p}Tobias Burnus3-2/+87
The new builtins have been added for newlib to reduce dependency on compiler-internal implementation choices of GCC in newlibs' getreent.c. gcc/ChangeLog: * config/gcn/gcn-builtins.def (FIRST_CALL_THIS_THREAD_P, GET_STACK_LIMIT): Add new builtins. * config/gcn/gcn.cc (gcn_expand_builtin_1): Expand them. * config/gcn/gcn.md (prologue_use): Add "register_operand" as arg to match_operand. (prologue_use_di): New; DI insn_and_split variant of the former. Co-Authored-By: Andrew Stubbs <ams@codesourcery.com>
2022-11-22c++: don't use strchrnul [PR107781]Jason Merrill1-2/+2
The contracts implementation was using strchrnul, which is a glibc extension, so bootstrap broke on non-glibc targets. Use C89 strcspn instead. PR c++/107781 gcc/cp/ChangeLog: * contracts.cc (role_name_equal): Use strcspn instead of strchrnul.
2022-11-22aarch64: Fix test_dfp_17.c for big-endian [PR 107604]Christophe Lyon1-0/+4
gcc.target/aarch64/aapcs64/test_dfp_17.c has been failing on big-endian, because the _Decimal32 on-stack argument is not padded in the same direction depending on endianness. This patch fixes the testcase so that it expects the argument in the right stack location, similarly to what other tests do in the same directory. gcc/testsuite/ChangeLog: PR target/107604 * gcc.target/aarch64/aapcs64/test_dfp_17.c: Fix for big-endian.
2022-11-22ada: Accept aspects Global and Depends on abstract subprogramsPiotr Trojanek1-0/+5
Aspects Global and Depends are now allowed on abstract subprograms (as substitutes for Global'Class and Depends'Class). This patch implements the recently modified rules SPARK RM 6.1.2(2-3). The behavior for Contract_Cases and aspects on null subprograms stays as it was. gcc/ada/ * sem_prag.adb (Analyze_Depends_Global): Accept aspects on abstract subprograms.
2022-11-22ada: Disable checking of Elab_Spec procedures in CodePeer_ModeGhjuvan Lacambre2-1/+18
This commit re-enables the Validate_Subprogram_Calls check that had been disabled in a previous commit and has said check skip over Elab_Spec procedures in CodePeer_Mode. gcc/ada/ * frontend.adb (Frontend): Re-enable Validate_Subprogram_Calls. * exp_ch6.adb (Check_BIP_Actuals): When in CodePeer mode, do not attempt to validate procedures coming from an Elab_Spec/Elab_Body/Elab_Subp_Body procedure.
2022-11-22ada: Adjust number of errors when removing warning in dead codePiotr Trojanek2-17/+29
When a warning about a runtime exception is emitted for a code in generic instance, we add continuation warnings "in instantiation ..." and only the original message increase the total number of errors. When removing these messages, e.g. after detecting that the code inside generic instance is dead, we must decrease the total number of errors, as otherwise the compiler exit status might stop gnatmake or gprbuild. gcc/ada/ * errout.adb (To_Be_Removed): Decrease total number of errors when removing a warning that has been escalated into error. * erroutc.adb (dmsg): Print Warn_Runtime_Raise flag.
2022-11-22ada: Fix formatting glitches in Make_Tag_AssignmentEric Botcazou1-19/+21
gcc/ada/ * exp_ch3.adb (Make_Tag_Assignment): Fix formatting glitches.
2022-11-22ada: Fix recent assertion failure on GPR2Eric Botcazou1-14/+4
It's the compiler trying to load the nonexistent body of a generic package when trying to inline a call to an expression function of this package that has a pre or post-condition (hence the need for -gnata to trigger the ICE). gcc/ada/ * contracts.adb (Build_Subprogram_Contract_Wrapper): Do not fiddle with the Was_Expression_Function flag. Move a few lines around.
2022-11-22tree-optimization/107803 - abnormal cleanup from the SSA propagatorRichard Biener2-2/+37
The SSA propagator is missing abnormal cleanup which shows in a sanity check in the uninit engine (and missed CFG verification). The following adds that. PR tree-optimization/107803 * tree-ssa-propagate.cc (substitute_and_fold_dom_walker): Add need_ab_cleanup member. (substitute_and_fold_dom_walker::before_dom_children): When a stmt can no longer transfer control flow abnormally set need_ab_cleanup. (substitute_and_fold_engine::substitute_and_fold): Cleanup abnormal control flow. * g++.dg/pr107803.C: New testcase.
2022-11-22tree-optimization/107672 - avoid vector mode type_for_mode callRichard Biener1-3/+9
The following avoids using type_for_mode on vector modes which might not work for all frontends. Instead we look for the inner mode type and use build_vector_type_for_mode instead. PR tree-optimization/107672 * tree-vect-stmts.cc (supportable_widening_operation): Avoid type_for_mode on vector modes.
2022-11-22tree-optimization/107766 - ICE with recent -ffp-contract=off fixRichard Biener2-1/+24
The following uses *node to check for FP types rather than the child nodes which could be constant leafs and thus without a vector type. PR tree-optimization/107766 * tree-vect-slp-patterns.cc (complex_mul_pattern::matches): Use *node to check for FP vector types. * g++.dg/vect/pr107766.cc: New testcase.
2022-11-22Guard 64/32-bit vector move patterns with ix86_hard_reg_move_ok.liuhongt1-2/+4
gcc/ChangeLog: * config/i386/mmx.md (*mov<mode>_internal): Add ix86_hard_reg_move_ok to condition.
2022-11-22Some tidy up for RA related hooks.liuhongt5-18/+17
1. We also need to guard size of TO to be less than TARGET_SSE2 ? 2 : 4 in ix86_can_change_mode_class. 2. Merge VALID_AVX512FP16_SCALAR_MODE plus BFmode into VALID_AVX512F_SCALAR_MODE since we've support 16-bit data move above SSE2, so no need for the condition of AVX512FP16 for those evex sse registers. 3. Allocate DI/HImode to sse register for SSE2 above just like SImode since we've supported 16-bit data move between sse and gpr above SSE2, this will help RA to handle cases like (subreg:HI (reg:V8HI) 0) or else RA will spill it. This enable optimization for pices-memset-{3,37,39}.c gcc/ChangeLog: * config/i386/i386.cc (ix86_can_change_mode_class): Also guard size of TO. (ix86_hard_regno_mode_ok): Remove VALID_AVX512FP16_SCALAR_MODE * config/i386/i386.h (VALID_AVX512FP16_SCALAR_MODE): Merged to .. (VALID_AVX512F_SCALAR_MODE): .. this, also add HImode. (VALID_SSE_REG_MODE): Add DI/HImode. gcc/testsuite/ChangeLog: * gcc.target/i386/pieces-memset-3.c: Remove xfail. * gcc.target/i386/pieces-memset-37.c: Remove xfail. * gcc.target/i386/pieces-memset-39.c: Remove xfail.
2022-11-21c++: contracts fixesJason Merrill2-8/+13
Fixing -Wunused-parm warnings and link errors depending on where -fcontracts appears on the command line. gcc/cp/ChangeLog: * contracts.cc (build_contract_condition_function): Set DECL_ARTIFICIAL on return value parm. * g++spec.cc (lang_specific_driver): Add -lstdc++exp just before -lstdc++.
2022-11-22Daily bump.GCC Administrator5-1/+312
2022-11-21analyzer: fix ICE on 'bind' that returns a struct [PR107788]David Malcolm2-0/+15
gcc/analyzer/ChangeLog: PR analyzer/107788 * region-model.cc (region_model::update_for_int_cst_return): Require that the return type be an integer type. (region_model::update_for_nonzero_return): Likewise. gcc/testsuite/ChangeLog: PR analyzer/107788 * g++.dg/analyzer/fd-bind-pr107783.C: New test. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-11-21analyzer: fix ICE on 'bind' with non-pointer arg [P107783]David Malcolm3-2/+13
gcc/analyzer/ChangeLog: PR analyzer/107783 * region-model-impl-calls.cc (kf_accept::matches_call_types_p): Require that args 1 and 2 be pointers. (kf_bind::matches_call_types_p): Require that arg 1 be a pointer. * region-model.h (call_details::arg_is_pointer_p): New gcc/testsuite/ChangeLog: PR analyzer/107783 * gcc.dg/analyzer/fd-bind-pr107783.c: New test. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-11-21analyzer: fix ICE on writes to errno [PR107777]David Malcolm4-0/+41
gcc/analyzer/ChangeLog: PR analyzer/107777 * call-summary.cc (call_summary_replay::convert_region_from_summary_1): Handle RK_THREAD_LOCAL and RK_ERRNO in switch. * region-model.cc (region_model::get_representative_path_var_1): Likewise. gcc/testsuite/ChangeLog: PR analyzer/107777 * gcc.dg/analyzer/call-summaries-errno.c: New test. * gcc.dg/analyzer/errno-pr107777.c: New test. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-11-21analyzer, testsuite: add more examples taken from CWEDavid Malcolm6-0/+381
gcc/testsuite/ChangeLog: * gcc.dg/analyzer/CWE-131-examples.c: New test. * gcc.dg/analyzer/file-CWE-1341-example.c: New test. * gcc.dg/analyzer/malloc-CWE-401-example.c: New test. * gcc.dg/analyzer/malloc-CWE-415-examples.c: New test. * gcc.dg/analyzer/malloc-CWE-416-examples.c: New test. * gcc.dg/analyzer/malloc-CWE-590-examples.c: New test. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-11-21libcpp: Fix paste error with unknown pragma after macro expansionLewis Hyatt1-0/+10
In directives.cc, do_pragma() contains logic to handle a case such as the new testcase pragma-omp-unknown.c, where an unknown pragma was the result of macro expansion (for pragma namespaces that permit expansion). This no longer works correctly as shown by the testcase, fixed by adding PREV_WHITE to the flags on the second token to prevent an unwanted paste. Also fixed the memory leak, since the temporary tokens are pushed on their own context, nothing prevents freeing of the buffer that holds them when the context is eventually popped. libcpp/ChangeLog: * directives.cc (do_pragma): Fix memory leak in token buffer. Fix unwanted paste between two tokens. gcc/testsuite/ChangeLog: * c-c++-common/gomp/pragma-omp-unknown.c: New test.
2022-11-21RTEMS: Use local-exec TLS model by defaultSebastian Huber1-0/+4
gcc/ChangeLog: * config/rtems.h (SUBTARGET_CC1_SPEC): Undef and define.
2022-11-21Allow subtarget customization of CC1_SPECSebastian Huber1-1/+8
gcc/ChangeLog: * gcc.cc (SUBTARGET_CC1_SPEC): Define if not defined. (cc1_spec): Append SUBTARGET_CC1_SPEC.
2022-11-21testsuite: Add filter for target socket supportDimitar Dimitrov19-0/+45
The new analyzer tests for sockets are failing on embedded targets. The newlib and avr-libc C libraries do not support sockets. Testing done: - No changes in gcc.sum for x86_64-pc-linux-gnu, with or without this patch. - Filtered cases are now UNSUPPORTED instead of failing on AVR and PRU backends. gcc/ChangeLog: * doc/sourcebuild.texi (sockets): Document new check. gcc/testsuite/ChangeLog: * gcc.dg/analyzer/fd-accept.c: Require sockets. * gcc.dg/analyzer/fd-bind.c: Ditto. * gcc.dg/analyzer/fd-connect.c: Ditto. * gcc.dg/analyzer/fd-datagram-socket.c: Ditto. * gcc.dg/analyzer/fd-glibc-byte-stream-connection-server.c: Ditto. * gcc.dg/analyzer/fd-glibc-byte-stream-socket.c: Ditto. * gcc.dg/analyzer/fd-glibc-datagram-client.c: Ditto. * gcc.dg/analyzer/fd-glibc-datagram-socket.c: Ditto. * gcc.dg/analyzer/fd-listen.c: Ditto. * gcc.dg/analyzer/fd-manpage-getaddrinfo-client.c: Ditto. * gcc.dg/analyzer/fd-mappage-getaddrinfo-server.c: Ditto. * gcc.dg/analyzer/fd-socket-meaning.c: Ditto. * gcc.dg/analyzer/fd-socket-misuse.c: Ditto. * gcc.dg/analyzer/fd-stream-socket-active-open.c: Ditto. * gcc.dg/analyzer/fd-stream-socket-passive-open.c: Ditto. * gcc.dg/analyzer/fd-stream-socket.c: Ditto. * gcc.dg/analyzer/fd-symbolic-socket.c: Ditto. * lib/target-supports.exp (check_effective_target_sockets): New check. Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>