aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2022-01-17middle-end/101292 - invalid memory access with warning controlRichard Biener2-2/+6
The warning control falls into the C++ trap of using a reference to old hashtable contents for a put operation which can end up re-allocating that before reading from the old freed referenced to source. Fixed by introducing a temporary. 2022-01-17 Richard Biener <rguenther@suse.de> PR middle-end/101292 * diagnostic-spec.c (copy_warning): Make sure to not reference old hashtable content on possible resize. * warning-control.cc (copy_warning): Likewise.
2022-01-17Change kind of integer literal to fix a testcase.Hafiz Abid Qadeer1-1/+1
As Thomas reported in https://gcc.gnu.org/pipermail/gcc-patches/2022-January/588448.html a test added in my recent allocate clause patch fails on m32. It was due to default kind for integer matching c_intptr_t for m32. I have now changed it to 0_1 so that always integer with kind=1 is used. gcc/testsuite/ChangeLog: * gfortran.dg/gomp/allocate-2.f90: Change 0 to 0_1.
2022-01-17Fix glitch in entry for vxworks_posix_openOlivier Hainque1-1/+1
Which was incorrectly referring to the hack name from a previous change (vxworks_math_h_fp_c99).
2022-01-17widening_mul, i386: Improve spaceship expansion on x86 [PR103973]Jakub Jelinek52-26/+1220
C++20: #include <compare> auto cmp4way(double a, double b) { return a <=> b; } expands to: ucomisd %xmm1, %xmm0 jp .L8 movl $0, %eax jne .L8 .L2: ret .p2align 4,,10 .p2align 3 .L8: comisd %xmm0, %xmm1 movl $-1, %eax ja .L2 ucomisd %xmm1, %xmm0 setbe %al addl $1, %eax ret That is 3 comparisons of the same operands. The following patch improves it to just one comparison: comisd %xmm1, %xmm0 jp .L4 seta %al movl $0, %edx leal -1(%rax,%rax), %eax cmove %edx, %eax ret .L4: movl $2, %eax ret While a <=> b expands to a == b ? 0 : a < b ? -1 : a > b ? 1 : 2 where the first comparison is equality and this shouldn't raise exceptions on qNaN operands, if the operands aren't equal (which includes unordered cases), then it immediately performs < or > comparison and that raises exceptions even on qNaNs, so we can just perform a single comparison that raises exceptions on qNaN. As the 4 different cases are encoded as ZF CF PF 1 1 1 a unordered b 0 0 0 a > b 0 1 0 a < b 1 0 0 a == b we can emit optimal sequence of comparions, first jp for the unordered case, then je for the == case and finally jb for the < case. The patch pattern recognizes spaceship-like comparisons during widening_mul if the spaceship optab is implemented, and replaces those comparisons with comparisons of .SPACESHIP ifn which returns -1/0/1/2 based on the comparison. This seems to work well both for the case of just returning the -1/0/1/2 (when we have just a common successor with a PHI) or when the different cases are handled with various other basic blocks. The testcases cover both of those cases, the latter with different function calls in those. 2022-01-17 Jakub Jelinek <jakub@redhat.com> PR target/103973 * tree-cfg.h (cond_only_block_p): Declare. * tree-ssa-phiopt.c (cond_only_block_p): Move function to ... * tree-cfg.c (cond_only_block_p): ... here. No longer static. * optabs.def (spaceship_optab): New optab. * internal-fn.def (SPACESHIP): New internal function. * internal-fn.h (expand_SPACESHIP): Declare. * internal-fn.c (expand_PHI): Formatting fix. (expand_SPACESHIP): New function. * tree-ssa-math-opts.c (optimize_spaceship): New function. (math_opts_dom_walker::after_dom_children): Use it. * config/i386/i386.md (spaceship<mode>3): New define_expand. * config/i386/i386-protos.h (ix86_expand_fp_spaceship): Declare. * config/i386/i386-expand.c (ix86_expand_fp_spaceship): New function. * doc/md.texi (spaceship@var{m}3): Document. * gcc.target/i386/pr103973-1.c: New test. * gcc.target/i386/pr103973-2.c: New test. * gcc.target/i386/pr103973-3.c: New test. * gcc.target/i386/pr103973-4.c: New test. * gcc.target/i386/pr103973-5.c: New test. * gcc.target/i386/pr103973-6.c: New test. * gcc.target/i386/pr103973-7.c: New test. * gcc.target/i386/pr103973-8.c: New test. * gcc.target/i386/pr103973-9.c: New test. * gcc.target/i386/pr103973-10.c: New test. * gcc.target/i386/pr103973-11.c: New test. * gcc.target/i386/pr103973-12.c: New test. * gcc.target/i386/pr103973-13.c: New test. * gcc.target/i386/pr103973-14.c: New test. * gcc.target/i386/pr103973-15.c: New test. * gcc.target/i386/pr103973-16.c: New test. * gcc.target/i386/pr103973-17.c: New test. * gcc.target/i386/pr103973-18.c: New test. * gcc.target/i386/pr103973-19.c: New test. * gcc.target/i386/pr103973-20.c: New test. * g++.target/i386/pr103973-1.C: New test. * g++.target/i386/pr103973-2.C: New test. * g++.target/i386/pr103973-3.C: New test. * g++.target/i386/pr103973-4.C: New test. * g++.target/i386/pr103973-5.C: New test. * g++.target/i386/pr103973-6.C: New test. * g++.target/i386/pr103973-7.C: New test. * g++.target/i386/pr103973-8.C: New test. * g++.target/i386/pr103973-9.C: New test. * g++.target/i386/pr103973-10.C: New test. * g++.target/i386/pr103973-11.C: New test. * g++.target/i386/pr103973-12.C: New test. * g++.target/i386/pr103973-13.C: New test. * g++.target/i386/pr103973-14.C: New test. * g++.target/i386/pr103973-15.C: New test. * g++.target/i386/pr103973-16.C: New test. * g++.target/i386/pr103973-17.C: New test. * g++.target/i386/pr103973-18.C: New test. * g++.target/i386/pr103973-19.C: New test. * g++.target/i386/pr103973-20.C: New test.
2022-01-17Bump gcc/BASE-VER to 12.0.1 now that we are in stage4.Richard Biener1-1/+1
2021-01-17 Richard Biener <rguenther@suse.de> * BASE-VER: Bump to 12.0.1.
2022-01-17libstdc++: Define <stacktrace> header for C++23Jonathan Wakely30-14/+2605
Add the <stacktrace> header and a new libstdc++_libbacktrace.a library that provides the implementation. For now, the new library is only built if --enable-libstdcxx-backtrace=yes is used. As with the Filesystem TS, the new library is only provided as a static archive. libstdc++-v3/ChangeLog: * acinclude.m4 (GLIBCXX_ENABLE_BACKTRACE): New macro. * configure.ac: Use GLIBCXX_ENABLE_BACKTRACE. * include/Makefile.am: Add new header. * include/Makefile.in: Regenerate. * include/std/stacktrace: New header. * include/std/version (__cpp_lib_stacktrace): Define. * Makefile.in: Regenerate. * config.h.in: Regenerate. * configure: Regenerate. * doc/Makefile.in: Regenerate. * libsupc++/Makefile.in: Regenerate. * po/Makefile.in: Regenerate. * python/Makefile.in: Regenerate. * src/Makefile.am: Regenerate. * src/Makefile.in: Regenerate. * src/c++11/Makefile.in: Regenerate. * src/c++17/Makefile.in: Regenerate. * src/c++20/Makefile.in: Regenerate. * src/c++98/Makefile.in: Regenerate. * src/filesystem/Makefile.in: Regenerate. * testsuite/Makefile.in: Regenerate. * src/libbacktrace/Makefile.am: New file. * src/libbacktrace/Makefile.in: New file. * src/libbacktrace/backtrace-rename.h: New file. * src/libbacktrace/backtrace-supported.h.in: New file. * src/libbacktrace/config.h.in: New file. * testsuite/lib/libstdc++.exp (check_effective_target_stacktrace): New proc. * testsuite/20_util/stacktrace/entry.cc: New test. * testsuite/20_util/stacktrace/synopsis.cc: New test. * testsuite/20_util/stacktrace/version.cc: New test.
2022-01-17libstdc++: Document final option names for enabling C++20Jonathan Wakely2-4/+4
libstdc++-v3/ChangeLog: * doc/xml/manual/status_cxx2020.xml: Use final C++20 option names. * doc/html/manual/status.html: Regenerate.
2022-01-17libstdc++: Rename non-reserved macros in config header [PR103650]Jonathan Wakely3-0/+17
libstdc++-v3/ChangeLog: PR libstdc++/103650 * include/Makefile.am: Rename LT_OBJDIR and STDC_HEADERS. * include/Makefile.in: Regenerate. * testsuite/17_intro/headers/c++1998/103650.cc: New test.
2022-01-17Fortran: remove new files introduced by mistakeFrancois-Xavier Coudert2-280/+0
These two files were introduced by mistake in 86e3b476d5defaa79c94d40b76cbeec21cd02e5f gcc/testsuite/ChangeLog: * gfortran.dg/ieee/signaling_3.f90: Remove file. libgfortran/ChangeLog: * ieee/issignaling_fallback.h: Remove file.
2022-01-17Make the tests working.Martin Liska2-3/+3
gcc/testsuite/ChangeLog: * g++.dg/uninit-pred-loop-1_b.C: Fix invalid warnings. * g++.dg/uninit-pred-loop-1_c.C: Likewise.
2022-01-17Rename test-cases that are not executed.Martin Liska4-0/+0
gcc/testsuite/ChangeLog: * g++.dg/uninit-pred-loop-1_a.cc: Moved to... * g++.dg/uninit-pred-loop-1_a.C: ...here. * g++.dg/uninit-pred-loop-1_b.cc: Moved to... * g++.dg/uninit-pred-loop-1_b.C: ...here. * g++.dg/uninit-pred-loop-1_c.cc: Moved to... * g++.dg/uninit-pred-loop-1_c.C: ...here. * g++.dg/uninit-pred-loop_1.cc: Moved to... * g++.dg/uninit-pred-loop_1.C: ...here.
2022-01-17Add check_effective_target_pytest3.Martin Liska2-5/+16
gcc/testsuite/ChangeLog: * lib/gcov.exp: Use check_effective_target_pytest3. * lib/target-supports.exp: Add check_effective_target_pytest3.
2022-01-17libstdc++: Don't fail if math_errhandling is not definedMatthias Kretz1-1/+10
Older glibc does not define math_errhandling with -ffast-math, in which case floating-point exceptions are not used. Signed-off-by: Matthias Kretz <m.kretz@gsi.de> libstdc++-v3/ChangeLog: * include/experimental/bits/simd.h (__floating_point_flags): Do not rely on the presence of the math_errhandling macro.
2022-01-17Start using check-MAINTAINERS.py instead of legacy maintainers-verify.sh.Martin Liska3-52/+23
contrib/ChangeLog: * maintainers-verify.sh: Removed. gcc/testsuite/ChangeLog: * gcc.src/maintainers.exp: Start using check-MAINTAINERS.py. * lib/target-supports.exp: Add check_effective_target_python3.
2022-01-17Fix test warnings.Martin Liska1-10/+12
PR testsuite/104035 gcc/testsuite/ChangeLog: * g++.dg/torture/pr57993-2.C: Fix warnings.
2022-01-17libstdc++: Add 'typename' to dependent types in atomic<shared_ptr<T>>Jonathan Wakely1-2/+2
libstdc++-v3/ChangeLog: * include/bits/shared_ptr_atomic.h (_Sp_atomic): Add typename to qualified-id for dependent type.
2022-01-17Extend test cases for references in OpenACC 'private' clausesThomas Schwinge3-22/+364
libgomp/ * testsuite/libgomp.oacc-c++/privatized-ref-2.C: Extend. * testsuite/libgomp.oacc-c++/privatized-ref-3.C: Likewise. * testsuite/libgomp.oacc-fortran/privatized-ref-1.f95: Likewise.
2022-01-17Test cases for references in OpenACC 'private' clausesJulian Brown3-0/+211
libgomp/ * testsuite/libgomp.oacc-fortran/privatized-ref-1.f95: New test. * testsuite/libgomp.oacc-c++/privatized-ref-2.C: New test. * testsuite/libgomp.oacc-c++/privatized-ref-3.C: New test. Co-authored-by: Thomas Schwinge <thomas@codesourcery.com>
2022-01-17Allow for multiple defaults in endianness and r16 in GFORTRAN_CONVERT_UNIT.Thomas Koenig1-55/+56
With this patch, it is possible to specify multiple defaults inthe GFORTRAN_CONVERT_UNIT environment variable so that, for example, R16_IEEE and BIG_ENDIAN can be specified together. libgfortran/ChangeLog: * runtime/environ.c: Allow for multiple default values so that separate default specifications for IBM long double format and endianness are possible.
2022-01-16rs6000: Use known constant for GET_MODE_NUNITS and similarKewen Lin2-29/+12
This patch is to clean up some codes with GET_MODE_UNIT_SIZE or GET_MODE_NUNITS, which can use known constants or just be removed. Note that Carl Love helped to confirm altivec_vreveti2 introduced in r12-1341 is useless and can be removed. gcc/ChangeLog: * config/rs6000/altivec.md (altivec_vreveti2): Remove. * config/rs6000/vsx.md (*vsx_extract_si, *vsx_extract_si_<uns>float_df, *vsx_extract_si_<uns>float_<mode>, *vsx_insert_extract_v4sf_p9): Use known constant values to simplify code.
2022-01-17rs6000: Split pattern for TI to V1TI move [PR103124]Haochen Gui2-0/+28
This patch defines a new split pattern for TI to V1TI move. The pattern concatenates two subreg:DI of a TI to a V2DI. With the pattern, the subreg pass can do register split for TI when there is a TI to V1TI move. gcc/ PR target/103124 * config/rs6000/vsx.md (split pattern for TI to V1TI move): Defined. gcc/testsuite/ PR target/103124 * gcc.target/powerpc/pr103124.c: New testcase.
2022-01-17Daily bump.GCC Administrator7-1/+129
2022-01-17libstdc++: Update C++20 status tableJonathan Wakely2-23/+17
libstdc++-v3/ChangeLog: * doc/xml/manual/status_cxx2020.xml: Update. * doc/html/manual/status.html: Regenerate.
2022-01-17libstdc++: Implement C++20 atomic<shared_ptr> and atomic<weak_ptr>Jonathan Wakely5-0/+718
This adds another piece of C++20, the std::atomic specializations for std::shared_ptr and std::weak_ptr. The new _Sp_atomic type mimics the structure of shared_ptr<T> and weak_ptr<T>, holding a T* pointer (the one returned by get() on a shared_ptr/weak ptr) and a _Sp_counted_base<>* pointer to the ref-counted control block. For _Sp_atomic the low bit of the control block pointer is used as a lock bit, to ensure only one thread will access the object at a time. The pointer is actually stored as a uintptr_t to avoid accidental dereferences of the pointer when unlocked (which would be a race) or when locked (which would dereference the wrong pointer value due to the low bit being set). To get a raw pointer to the control block, the lock must be acquired. Converting between a _Sp_atomic and a shared_ptr or weak_ptr requires manually adjusting the T* and _Sp_counted_base<>* members of the shared/weak ptr, instead of going through the public API. This must be done carefully to ensure that any change in the number of owners is reflected in a ref-count update. Co-authored-by: Thomas Rodgers <trodgers@redhat.com> Signed-off-by: Thomas Rodgers <trodgers@redhat.com> libstdc++-v3/ChangeLog: * include/bits/shared_ptr_atomic.h (__cpp_lib_atomic_shared_ptr): New macro. (_Sp_atomic): New class template. (atomic<shared_ptr<T>>, atomic<weak_ptr<T>>): New partial specializations. * include/bits/shared_ptr_base.h (__shared_count, __weak_count) (__shared_ptr, __weak_ptr): Declare _Sp_atomic as a friend. * include/std/version (__cpp_lib_atomic_shared_ptr): New macro. * testsuite/20_util/shared_ptr/atomic/atomic_shared_ptr.cc: New test. * testsuite/20_util/weak_ptr/atomic_weak_ptr.cc: New test.
2022-01-17Fortran: xfail signaling NaN testcases on x87Francois-Xavier Coudert4-4/+288
The ABI for x87 and x86-32 is not suitable for passing around signaling NaNs in the way IEEE expects. See for example discussion in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57484 gcc/testsuite/ChangeLog: * gfortran.dg/ieee/signaling_1.f90: xfail on x87. * gfortran.dg/ieee/signaling_2.f90: xfail on x87.
2022-01-16Fortran: allow IEEE_VALUE to correctly return signaling NaNsFrancois-Xavier Coudert6-252/+203
I moved the library implementation of IEEE_VALUE in libgfortran from Fortran to C code, which gives us access to GCC's built-ins for NaN generation (both quiet and signalling). It will be perform better than the current Fortran implementation. libgfortran/ChangeLog: PR fortran/82207 * mk-kinds-h.sh: Add values for TINY. * ieee/ieee_arithmetic.F90: Call C helper functions for IEEE_VALUE. * ieee/ieee_helper.c: New functions ieee_value_helper_N for each floating-point type. gcc/testsuite/ChangeLog: PR fortran/82207 * gfortran.dg/ieee/ieee_10.f90: Do not create signaling NaNs. * gfortran.dg/ieee/signaling_2.f90: New test. * gfortran.dg/ieee/signaling_2_c.c: New file.
2022-01-16libstdc++: Ignore deprecated warnings [PR104037]Jonathan Wakely1-0/+1
The std::pointer_to_binary_function utility was deprecated in C++11 and removed in C++17. Libstdc++ has started to warn about using it, so suppress the warnings for this test. gcc/testsuite/ChangeLog: PR testsuite/104037 * g++.old-deja/g++.robertl/eb43.C: Ad -Wno-deprecated.
2022-01-16testsuite: Enrich tests with variants failing on the branch.Mikael Morin6-4/+20
Backporting the fix for pr103789 on the 11 branch revealed a lack of test coverage for the tests provided with that fix. Indeed, the tests use the KIND argument of the respective intrinsics only with keyword arguments. This adds variants with non-keyword arguments. The tests enriched this way fail on the branch if the fix is cherry-picked straightforwardly. The fix will have to be tweaked slightly there. PR fortran/103789 PR fortran/87711 PR fortran/97896 gcc/testsuite/ChangeLog: * gfortran.dg/index_5.f90: Enrich test with usages of INDEX with a non-keyword KIND argument. * gfortran.dg/len_trim.f90: Same for LEN_TRIM. * gfortran.dg/maskl_1.f90: Same for MASKL. * gfortran.dg/maskr_1.f90: Same for MASKR. * gfortran.dg/scan_3.f90: Same for SCAN. * gfortran.dg/verify_3.f90: Same for VERIFY.
2022-01-16amdgcn: Tune default OpenMP/OpenACC GPU utilizationKwok Cheung Yeung1-15/+67
libgomp/ * plugin/plugin-gcn.c (parse_target_attributes): Automatically set the number of teams and threads if necessary. (gcn_exec): Automatically set the number of gangs and workers if necessary. Co-Authored-By: Andrew Stubbs <ams@codesourcery.com>
2022-01-16Add VxWorks fixincludes hack, open posix API for C++Olivier Hainque3-5/+132
When system headers expose a strict "open" prototype with 3 args, arrange to expose a C++ overload with only two. 2021-01-10 Olivier Hainque <hainque@adacore.com> * inclhack.def (vxworks_math_h_fp_c99): New hack. * tests/base/fcntl.h: Update. * fixincl.x: Regenerate.
2022-01-16Add VxWorks fixincludes hack, #include sysLib.h in time.hOlivier Hainque3-5/+97
Make sure there is a visible prototype of sysClkRateGet() when CLOCKS_PER_SEC is #defined to that in time.h for VxWorks. This would typically be provided by sysLib.h. 2021-01-10 Olivier Hainque <hainque@adacore.com> * inclhack.def (vxworks_time_h_syslib): New hack. * tests/base/time.h: Update. * fixincl.x: Regenerate.
2022-01-16Add VxWorks fixincludes hack, C99 FP classificationOlivier Hainque3-5/+161
Arrange to provide missing defs for C99 FP classification functions and constants queried by libstdc++ configure checks (C99 support for C++98) 2021-01-10 Olivier Hainque <hainque@adacore.com> * inclhack.def (vxworks_math_h_fp_c99): New hack. * tests/base/math.h: Update. * fixincl.x: Regenerate.
2022-01-16[i386] GLC tuning: Break false dependency for dest register.wwwhhhyyy10-8/+427
For GoldenCove micro-architecture, force insert zero-idiom in asm template to break false dependency of dest register for several insns. The related insns are: VPERM/D/Q/PS/PD VRANGEPD/PS/SD/SS VGETMANTSS/SD/SH VGETMANDPS/PD - mem version only VPMULLQ VFMULCSH/PH VFCMULCSH/PH gcc/ChangeLog: * config/i386/i386.h (TARGET_DEST_FALSE_DEP_FOR_GLC): New macro. * config/i386/sse.md (<avx512>_<complexopname>_<mode><maskc_name><round_name>): Insert zero-idiom in output template when attr enabled, set new attribute to true for non-mask/maskz insn. (avx512fp16_<complexopname>sh_v8hf<mask_scalarc_name><round_scalarcz_name>): Likewise. (avx512dq_mul<mode>3<mask_name>): Likewise. (<avx2_avx512>_permvar<mode><mask_name>): Likewise. (avx2_perm<mode>_1<mask_name>): Likewise. (avx512f_perm<mode>_1<mask_name>): Likewise. (avx512dq_rangep<mode><mask_name><round_saeonly_name>): Likewise. (avx512dq_ranges<mode><mask_scalar_name><round_saeonly_scalar_name>): Likewise. (<avx512>_getmant<mode><mask_name><round_saeonly_name>): Likewise. (avx512f_vgetmant<mode><mask_scalar_name><round_saeonly_scalar_name>): Likewise. * config/i386/subst.md (mask3_dest_false_dep_for_glc_cond): New subst_attr. (mask4_dest_false_dep_for_glc_cond): Likewise. (mask6_dest_false_dep_for_glc_cond): Likewise. (mask10_dest_false_dep_for_glc_cond): Likewise. (maskc_dest_false_dep_for_glc_cond): Likewise. (mask_scalar4_dest_false_dep_for_glc_cond): Likewise. (mask_scalarc_dest_false_dep_for_glc_cond): Likewise. * config/i386/x86-tune.def (X86_TUNE_DEST_FALSE_DEP_FOR_GLC): New DEF_TUNE enabled for m_SAPPHIRERAPIDS and m_ALDERLAKE gcc/testsuite/ChangeLog: * gcc.target/i386/avx2-dest-false-dep-for-glc.c: New test. * gcc.target/i386/avx512dq-dest-false-dep-for-glc.c: Ditto. * gcc.target/i386/avx512f-dest-false-dep-for-glc.c: Ditto. * gcc.target/i386/avx512fp16-dest-false-dep-for-glc.c: Ditto. * gcc.target/i386/avx512fp16vl-dest-false-dep-for-glc.c: Ditto. * gcc.target/i386/avx512vl-dest-false-dep-for-glc.c: Ditto.
2022-01-16Daily bump.GCC Administrator9-1/+174
2022-01-15Add -Wdangling-pointer [PR63272].Martin Sebor18-61/+2043
Resolves: PR c/63272 - GCC should warn when using pointer to dead scoped variable with in the same function gcc/c-family/ChangeLog: PR c/63272 * c.opt (-Wdangling-pointer): New option. gcc/ChangeLog: PR c/63272 * diagnostic-spec.c (nowarn_spec_t::nowarn_spec_t): Handle -Wdangling-pointer. * doc/invoke.texi (-Wdangling-pointer): Document new option. * gimple-ssa-warn-access.cc (pass_waccess::clone): Set new member. (pass_waccess::check_pointer_uses): New function. (pass_waccess::gimple_call_return_arg): New function. (pass_waccess::gimple_call_return_arg_ref): New function. (pass_waccess::check_call_dangling): New function. (pass_waccess::check_dangling_uses): New function overloads. (pass_waccess::check_dangling_stores): New function. (pass_waccess::check_dangling_stores): New function. (pass_waccess::m_clobbers): New data member. (pass_waccess::m_func): New data member. (pass_waccess::m_run_number): New data member. (pass_waccess::m_check_dangling_p): New data member. (pass_waccess::check_alloca): Check m_early_checks_p. (pass_waccess::check_alloc_size_call): Same. (pass_waccess::check_strcat): Same. (pass_waccess::check_strncat): Same. (pass_waccess::check_stxcpy): Same. (pass_waccess::check_stxncpy): Same. (pass_waccess::check_strncmp): Same. (pass_waccess::check_memop_access): Same. (pass_waccess::check_read_access): Same. (pass_waccess::check_builtin): Call check_pointer_uses. (pass_waccess::warn_invalid_pointer): Add arguments. (is_auto_decl): New function. (pass_waccess::check_stmt): New function. (pass_waccess::check_block): Call check_stmt. (pass_waccess::execute): Call check_dangling_uses, check_dangling_stores. Empty m_clobbers. * passes.def (pass_warn_access): Invoke pass two more times. gcc/testsuite/ChangeLog: PR c/63272 * g++.dg/warn/Wfree-nonheap-object-6.C: Disable valid warnings. * g++.dg/warn/ref-temp1.C: Prune expected warning. * gcc.dg/uninit-pr50476.c: Expect a new warning. * c-c++-common/Wdangling-pointer-2.c: New test. * c-c++-common/Wdangling-pointer-3.c: New test. * c-c++-common/Wdangling-pointer-4.c: New test. * c-c++-common/Wdangling-pointer-5.c: New test. * c-c++-common/Wdangling-pointer-6.c: New test. * c-c++-common/Wdangling-pointer.c: New test. * g++.dg/warn/Wdangling-pointer-2.C: New test. * g++.dg/warn/Wdangling-pointer.C: New test. * gcc.dg/Wdangling-pointer-2.c: New test. * gcc.dg/Wdangling-pointer.c: New test.
2022-01-15Add -Wuse-after-free [PR80532].Martin Sebor23-32/+1625
gcc/c-family/ChangeLog PR tree-optimization/80532 * c.opt (-Wuse-after-free): New options. gcc/ChangeLog: PR tree-optimization/80532 * common.opt (-Wuse-after-free): New options. * diagnostic-spec.c (nowarn_spec_t::nowarn_spec_t): Handle OPT_Wreturn_local_addr and OPT_Wuse_after_free_. * diagnostic-spec.h (NW_DANGLING): New enumerator. * doc/invoke.texi (-Wuse-after-free): Document new option. * gimple-ssa-warn-access.cc (pass_waccess::check_call): Rename... (pass_waccess::check_call_access): ...to this. (pass_waccess::check): Rename... (pass_waccess::check_block): ...to this. (pass_waccess::check_pointer_uses): New function. (pass_waccess::gimple_call_return_arg): New function. (pass_waccess::warn_invalid_pointer): New function. (pass_waccess::check_builtin): Handle free and realloc. (gimple_use_after_inval_p): New function. (get_realloc_lhs): New function. (maybe_warn_mismatched_realloc): New function. (pointers_related_p): New function. (pass_waccess::check_call): Call check_pointer_uses. (pass_waccess::execute): Compute and free dominance info. libcpp/ChangeLog: * files.c (_cpp_find_file): Substitute a valid pointer for an invalid one to avoid -Wuse-after-free. libiberty/ChangeLog: * regex.c: Suppress -Wuse-after-free. gcc/testsuite/ChangeLog: PR tree-optimization/80532 * gcc.dg/Wmismatched-dealloc-2.c: Avoid -Wuse-after-free. * gcc.dg/Wmismatched-dealloc-3.c: Same. * gcc.dg/analyzer/file-1.c: Prune expected warning. * gcc.dg/analyzer/file-2.c: Same. * gcc.dg/attr-alloc_size-6.c: Disable -Wuse-after-free. * gcc.dg/attr-alloc_size-7.c: Same. * c-c++-common/Wuse-after-free-2.c: New test. * c-c++-common/Wuse-after-free-3.c: New test. * c-c++-common/Wuse-after-free-4.c: New test. * c-c++-common/Wuse-after-free-5.c: New test. * c-c++-common/Wuse-after-free-6.c: New test. * c-c++-common/Wuse-after-free-7.c: New test. * c-c++-common/Wuse-after-free.c: New test. * g++.dg/warn/Wmismatched-dealloc-3.C: New test. * g++.dg/warn/Wuse-after-free.C: New test.
2022-01-15Fortran: fix ICE and wrong code with TRANSFER and CHARACTER(kind=4)Harald Anlauf3-4/+130
gcc/fortran/ChangeLog: PR fortran/83079 * target-memory.c (gfc_interpret_character): Result length is in bytes and thus depends on the character kind. * trans-intrinsic.c (gfc_conv_intrinsic_transfer): Compute correct string length for the result of the TRANSFER intrinsic and for temporaries for the different character kinds. gcc/testsuite/ChangeLog: PR fortran/83079 * gfortran.dg/transfer_char_kind4.f90: New test.
2022-01-15libstdc++: Fix ODR issues with different -m flagsMatthias Kretz9-188/+440
Explicitly support use of the stdx::simd implementation in situations where the user links TUs that were compiled with different -m flags. In general, this is always a (quasi) ODR violation for inline functions because at least codegen may differ in important ways. However, in the resulting executable only one (unspecified which one) of them might be used. For simd we want to support users to compile code multiple times, with different -m flags and have a runtime dispatch to the TU matching the target CPU. But if internal functions are not inlined this may lead to unexpected performance loss or execution of illegal instructions. Therefore, inline functions that are not marked as always_inline must use an additional template parameter somewhere in their name, to disambiguate between the different -m translations. Signed-off-by: Matthias Kretz <m.kretz@gsi.de> libstdc++-v3/ChangeLog: * include/experimental/bits/simd.h: Move feature detection bools and add __have_avx512bitalg, __have_avx512vbmi2, __have_avx512vbmi, __have_avx512ifma, __have_avx512cd, __have_avx512vnni, __have_avx512vpopcntdq. (__detail::__machine_flags): New function which returns a unique uint64 depending on relevant -m and -f flags. (__detail::__odr_helper): New type alias for either an anonymous type or a type specialized with the __machine_flags number. (_SimdIntOperators): Change template parameters from _Impl to _Tp, _Abi because _Impl now has an __odr_helper parameter which may be _OdrEnforcer from the anonymous namespace, which makes for a bad base class. (many): Either add __odr_helper template parameter or mark as always_inline. * include/experimental/bits/simd_detail.h: Add defines for AVX512BITALG, AVX512VBMI2, AVX512VBMI, AVX512IFMA, AVX512CD, AVX512VNNI, AVX512VPOPCNTDQ, and AVX512VP2INTERSECT. * include/experimental/bits/simd_builtin.h: Add __odr_helper template parameter or mark as always_inline. * include/experimental/bits/simd_fixed_size.h: Ditto. * include/experimental/bits/simd_math.h: Ditto. * include/experimental/bits/simd_scalar.h: Ditto. * include/experimental/bits/simd_neon.h: Add __odr_helper template parameter. * include/experimental/bits/simd_ppc.h: Ditto. * include/experimental/bits/simd_x86.h: Ditto.
2022-01-15i386: Improve and optimize ix86_expand_sse_movccUros Bizjak2-78/+62
Modernize ix86_expand_sse_movcc to use expand_simple_{unop,binop} infrastructure to avoid manual twiddling with output registers. Also fix a couple of inconsistent vector_all_ones_operand usages, break a couple of unnecessary else-if chains, eliminate common subexpressions and do some general code simplifications. 2022-01-15 Uroš Bizjak <ubizjak@gmail.com> gcc/ChangeLog: * config/i386/i386-expand.c (ix86_expand_sse_movcc): Use expand_simple_unop and expand_simple_binop instead of manually constructing NOT, AND and IOR RTXes. Use vector_all_ones_operand consistently. Eliminate common subexpressions and simplify code. * config/i386/sse.md (<any_logic:code><MODEF:mode>3): New expander. (<any_logic:code><MODEF:mode>3): Make public.
2022-01-15libgcc: Fix __gthr_i486_lock_cmp_xchg clobber for WindowsJonathan Yong2-23/+2
2022-01-14 David <gccbugzilla@limegreensocks.com> libgcc/ * config/i386/gthr-win32.c (__gthr_i486_lock_cmp_xchg): Remove inlined version, Windows 95 is no longer relevant. * config/i386/gthr-win32.h (__GTHREAD_I486_INLINE_LOCK_PRIMITIVES): unset.
2022-01-15Daily bump.GCC Administrator12-1/+584
2022-01-14ada: Fix up handling of ghost units [PR104027]Andrew Pinski1-0/+5
As reported, libgnat-12.so gets PT_GNU_STACK RWE, which means it doesn't work in some SELinux configurations. This is caused by the a-nbnbig.o file, which is a ghost unit and since r12-5670 the FE emits an object file for it, but exits before compile_file has a chance to finalize it e.g. with targetm.asm_out.file_end () that emits the .note.GNU-stack section on various linux targets. Fixed by not existing but instead returning early to the caller. 2022-01-14 Andrew Pinski <apinski@marvell.com> PR ada/104027 * gnat1drv.adb (Gnat1drv): After Back_End.Gen_Or_Update_Object_File goto End_Of_Program.
2022-01-14analyzer: fix ICE when combining taint states has_ub and has_lbDavid Malcolm2-5/+66
gcc/analyzer/ChangeLog: * sm-taint.cc (taint_state_machine::combine_states): Handle combination of has_ub and has_lb. gcc/testsuite/ChangeLog: * gcc.dg/analyzer/taint-merger.c: New test. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-01-14analyzer: fix ICE in taint checker on unary ops [PR104029]David Malcolm3-1/+221
gcc/analyzer/ChangeLog: PR analyzer/104029 * sm-taint.cc (taint_state_machine::alt_get_inherited_state): Remove gcc_unreachable from default case for unary ops. gcc/testsuite/ChangeLog: PR analyzer/104029 * gcc.dg/analyzer/pr104029.c: New test. * gcc.dg/analyzer/taint-ops.c: New test. Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2022-01-14Fortran: always reject alternate return specifier as argument of intrinsicsHarald Anlauf2-1/+16
The intrinsics MOVE_ALLOC, C_F_POINTER, and C_F_PROCPOINTER require deferred checks of part of their actual argument types which may be of "any" type. This however excludes alternate return specifiers which therefore must be unconditionally rejected for all standard intrinsics. gcc/fortran/ChangeLog: PR fortran/99256 * intrinsic.c: Do not check formal argument type when checking arguments of intrinsics for alternate return specifiers. gcc/testsuite/ChangeLog: PR fortran/99256 * gfortran.dg/altreturn_11.f90: New test.
2022-01-14Fix reverse scalar storage order issues in IPA-SRAEric Botcazou6-29/+105
The IPA-SRA pass introduced in GCC 10 does not always play nice with the reverse scalar storage order that can be used in structures/records/unions. Reading the code, the pass apparently correctly detects it but fails to propagate the information to the rewriting phase in some cases and, in particular, does not stream it for LTO. gcc/ * ipa-param-manipulation.c (ipa_dump_adjusted_parameters): Dump reverse flag as "reverse" for the sake of consistency. * ipa-sra.c: Fix copyright year. (ipa_sra_function_summaries::duplicate): Copy the reverse flag. (dump_isra_access): Tweak dump line. (isra_write_node_summary): Write the reverse flag. (isra_read_node_info): Read it. (pull_accesses_from_callee): Test its consistency and copy it. gcc/testsuite/ * gnat.dg/lto25.adb: New test. * gnat.dg/opt96.adb: Likewise. * gnat.dg/opt96_pkg.ads, gnat.dg/opt96_pkg.adb: New helper.
2022-01-14vect: Fix uninitialised variable PR104026Richard Sandiford1-0/+1
As noted by Tobias in the PR, the loop_vec_info constructor wasn't initializing the new partial_load_store_bias field. gcc/ PR middle-end/104026 * tree-vect-loop.c (_loop_vec_info::_loop_vec_info): Initialize partial_load_store_bias.
2022-01-14Fortran: fix ICE overloading elemental intrinsicsHarald Anlauf2-3/+29
gcc/fortran/ChangeLog: PR fortran/103782 * expr.c (gfc_simplify_expr): Adjust logic for when to scalarize a call of an intrinsic which may have been overloaded. gcc/testsuite/ChangeLog: PR fortran/103782 * gfortran.dg/overload_4.f90: New test.
2022-01-14Use enclosing object size if it's smaller than member [PR 101475].Martin Sebor4-35/+383
Resolves: PR middle-end/101475 - missing -Wstringop-overflow storing a compound literal gcc/ChangeLog: PR middle-end/101475 * pointer-query.cc (handle_component_ref): Use the size of the enclosing object if it's smaller than the member. gcc/testsuite/ChangeLog: PR middle-end/101475 * gcc.dg/Wstringop-overflow-15.c: Remove xfails. * gcc.dg/Wstringop-overflow-68.c: Adjust, remove xfails. * gcc.dg/Wstringop-overflow-88.c: New test.
2022-01-14Test to verify -Wformat-overflow uses context-sensitive ranges.Martin Sebor1-0/+21
gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/builtin-sprintf-warn-28.c: New test.