Skip to content
Snippets Groups Projects
  1. Aug 13, 2023
    • Iain Sandoe's avatar
      modula-2, plugin: Fix Darwin bootstrap issues. · 25be11e9
      Iain Sandoe authored
      
      This corrects some typos in the suffix of the m2rte pluing that
      lead to a bootstrap fail on Darwin, where the suffix is not '.so'.
      
      On some versions of Darwin, the linker complains if libSystem is not
      linked, so we disable all the default libs, but add libc back.
      
      Signed-off-by: default avatarIain Sandoe <iain@sandoe.co.uk>
      
      gcc/m2/ChangeLog:
      
      	* Make-lang.in: Update suffix spellings to use 'soext'.
      	Add libc to the plugin link.
      25be11e9
    • GCC Administrator's avatar
      Daily bump. · adae87c1
      GCC Administrator authored
      adae87c1
  2. Aug 12, 2023
    • Gaius Mulley's avatar
      PR modula2/110779 SysClock can not read the clock (Darwin portability fixes) · 63fb0bed
      Gaius Mulley authored
      
      This patch adds corrections to defensively check against glibc functions,
      structures and contains fallbacks.  These fixes were required under Darwin.
      
      gcc/m2/ChangeLog:
      
      	PR modula2/110779
      	* gm2-libs-iso/SysClock.mod (EpochTime): New procedure.
      	(GetClock): Call EpochTime if the C time functions are
      	unavailable.
      	* gm2-libs-iso/wrapclock.def (istimezone): New function
      	definition.
      
      libgm2/ChangeLog:
      
      	PR modula2/110779
      	* configure: Regenerate.
      	* configure.ac: Provide special case test for Darwin cross
      	configuration.
      	(GLIBCXX_CONFIGURE): New statement.
      	(GLIBCXX_CHECK_GETTIMEOFDAY): New statement.
      	(GLIBCXX_ENABLE_LIBSTDCXX_TIME): New statement.
      	* libm2iso/wrapclock.cc: New sys/time.h conditional include.
      	(sys/syscall.h): Conditional include.
      	(unistd.h): Conditional include.
      	(GetTimeRealtime): Re-implement.
      	(SetTimeRealtime): Re-implement.
      	(timezone): Re-implement.
      	(istimezone): New function.
      	(daylight): Re-implement.
      	(isdst): Re-implement.
      	(tzname): Re-implement.
      
      Signed-off-by: default avatarGaius Mulley <gaiusmod2@gmail.com>
      63fb0bed
    • Gaius Mulley's avatar
      PR modula2/108119 disable m2rte plugin by default · 46905fcd
      Gaius Mulley authored
      
      This patch disables the m2rte plugin by default.  The driver
      will only append the -fplugin=m2rte command line option for cc1gm2
      if -fm2-plugin is present.  It only enabled providing ENABLE_PLUGIN
      is defined.  gcc/m2/Make-file.in will only build and install m2rte
      if enable_plugin is yes.
      
      gcc/m2/ChangeLog:
      
      	PR modula2/108119
      	* Make-lang.in (M2RTE_PLUGIN_SO): Assigned to
      	plugin/m2rte$(exeext).so if enable_plugin is yes.
      	(m2.all.cross): Replace plugin/m2rte$(soext) with
      	$(M2RTE_PLUGIN_SO).
      	(m2.all.encap): Replace plugin/m2rte$(soext) with
      	$(M2RTE_PLUGIN_SO).
      	(m2.install-plugin): Add dummy rule when enable_plugin
      	is not yes.
      	(plugin/m2rte$(exeext).so): Add dummy rule when enable_plugin
      	is not yes.
      	(m2/stage2/cc1gm2$(exeext)): Replace plugin/m2rte$(soext) with
      	$(M2RTE_PLUGIN_SO).
      	(m2/stage1/cc1gm2$(exeext)): Replace plugin/m2rte$(soext) with
      	$(M2RTE_PLUGIN_SO).
      	* gm2spec.cc (lang_specific_driver): Set need_plugin to false
      	by default.
      
      gcc/testsuite/ChangeLog:
      
      	PR modula2/108119
      	* gm2/iso/check/fail/iso-check-fail.exp (gm2_init_iso): Add -fm2-plugin.
      	* gm2/switches/auto-init/fail/switches-auto-init-fail.exp
      	(gm2_init_iso): Add -fm2-plugin.
      	* gm2/switches/check-all/pim2/fail/switches-check-all-pim2-fail.exp
      	(gm2_init_pim2): Add -fm2-plugin.
      	* gm2/switches/check-all/plugin/iso/fail/switches-check-all-plugin-iso-fail.exp
      	(gm2_init_iso): Add -fm2-plugin.
      	* gm2/switches/check-all/plugin/pim2/fail/switches-check-all-plugin-pim2-fail.exp
      	(gm2_init_pim2): Add -fm2-plugin.
      
      Signed-off-by: default avatarGaius Mulley <gaiusmod2@gmail.com>
      46905fcd
    • Jakub Jelinek's avatar
      Add stdckdint.h header for C23 · 8441841a
      Jakub Jelinek authored
      This patch adds <stdckdint.h> header, which defines ckd_{add,sub,mul}
      using __builtin_{add,sub,mul}_overflow.  As requested, it doesn't
      pedantically diagnose things which work just fine, e.g. inputs with
      plain char, bool, bit-precise integer or enumerated types and
      result pointer to plain char or bit-precise integer.
      The header will #include_next <stdckdint.h> so that C library can supply
      its part if the header implementation in the future needs to be split
      between parts under the control of the compiler and parts under the
      control of C library.
      
      2023-08-12  Jakub Jelinek  <jakub@redhat.com>
      
      	* Makefile.in (USER_H): Add stdckdint.h.
      	* ginclude/stdckdint.h: New file.
      
      	* gcc.dg/stdckdint-1.c: New test.
      	* gcc.dg/stdckdint-2.c: New test.
      8441841a
    • Juzhe-Zhong's avatar
      RISC-V: Add TAREGT_VECTOR check into VLS modes · 9890f377
      Juzhe-Zhong authored
      This patch fixes bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110994
      
      This is caused VLS modes incorrect codes int register allocation.
      
      The original case trigger the ICE is fortran code but I can reproduce
      with a C code.
      
      gcc/ChangeLog:
      
      	PR target/110994
      	* config/riscv/riscv-opts.h (TARGET_VECTOR_VLS): Add TARGET_VETOR.
      
      gcc/testsuite/ChangeLog:
      
      	PR target/110994
      	* gcc.target/riscv/rvv/autovec/vls/pr110994.c: New test.
      9890f377
    • Patrick Palka's avatar
      tree-pretty-print: delimit TREE_VEC with braces · 8be20733
      Patrick Palka authored
      This makes the generic pretty printer print braces around a TREE_VEC,
      like we do for CONSTRUCTOR.  This should improve readability of nested
      TREE_VECs in particular.
      
      gcc/ChangeLog:
      
      	* tree-pretty-print.cc (dump_generic_node) <case TREE_VEC>:
      	Delimit output with braces.
      8be20733
    • Patrick Palka's avatar
      c++: bogus warning w/ deduction guide in anon ns [PR106604] · f50f603c
      Patrick Palka authored
      
      Here we're unintentionally issuing a "declared static but never defined"
      warning from wrapup_namespace_globals for a deduction guide declared in
      an anonymous namespace.  This patch fixes this by giving deduction guides
      a dummy DECL_INITIAL, which suppresses the warning and also allows us to
      simplify redeclaration checking for them.
      
      Co-authored-by: default avatarJason Merrill <jason@redhat.com>
      
      	PR c++/106604
      
      gcc/cp/ChangeLog:
      
      	* decl.cc (redeclaration_error_message): Remove special handling
      	for deduction guides.
      	(grokfndecl): Give deduction guides a dummy DECL_INITIAL.
      
      gcc/testsuite/ChangeLog:
      
      	* g++.dg/cpp1z/class-deduction74.C: Expect "defined" instead
      	of "declared" in the repeated deduction guide diagnostics.
      	* g++.dg/cpp1z/class-deduction116.C: New test.
      f50f603c
    • Ken Matsui's avatar
      libstdc++: Use __bool_constant entirely · 066c260a
      Ken Matsui authored
      
      This patch uses __bool_constant entirely instead of integral_constant<bool>
      in the type_traits header, specifically for true_type, false_type,
      and bool_constant.
      
      libstdc++-v3/ChangeLog:
      
      	* include/std/type_traits (true_type): Use __bool_constant
      	instead.
      	(false_type): Likewise.
      	(bool_constant): Likewise.
      
      Signed-off-by: default avatarKen Matsui <kmatsui@gcc.gnu.org>
      Reviewed-by: default avatarJonathan Wakely <jwakely@redhat.com>
      066c260a
    • Juzhe-Zhong's avatar
      RISC-V: Fix vec_series expander[PR110985] · 685abdb4
      Juzhe-Zhong authored
      This patch fix bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110985
      
      gcc/ChangeLog:
      	PR target/110985
      	* config/riscv/riscv-v.cc (expand_vec_series): Refactor the expander.
      
      gcc/testsuite/ChangeLog:
      	PR target/110985
      	* gcc.target/riscv/rvv/autovec/vls-vlmax/pr110985.c: New test.
      685abdb4
    • Juzhe-Zhong's avatar
      RISC-V: Allow CONST_VECTOR for VLS modes · e80c55e4
      Juzhe-Zhong authored
      This patch enables COSNT_VECTOR for VLS modes.
      
      void foo1 (int * __restrict a)
      {
          for (int i = 0; i < 16; i++)
            a[i] = 8;
      }
      
      void foo2 (int * __restrict a)
      {
          for (int i = 0; i < 16; i++)
            a[i] = i;
      }
      
      Compile option: -O3 --param=riscv-autovec-preference=scalable
      
      Before this patch:
      
      foo1:
              lui     a5,%hi(.LC0)
              addi    a5,a5,%lo(.LC0)
              vsetivli        zero,4,e32,m1,ta,ma
              addi    a4,a0,16
              vle32.v v1,0(a5)
              vse32.v v1,0(a0)
              vse32.v v1,0(a4)
              addi    a4,a0,32
              vse32.v v1,0(a4)
              addi    a0,a0,48
              vse32.v v1,0(a0)
              ret
      foo2:
              lui     a5,%hi(.LC1)
              addi    a5,a5,%lo(.LC1)
              vsetivli        zero,4,e32,m1,ta,ma
              vle32.v v1,0(a5)
              lui     a5,%hi(.LC2)
              addi    a5,a5,%lo(.LC2)
              vse32.v v1,0(a0)
              vle32.v v1,0(a5)
              lui     a5,%hi(.LC3)
              addi    a4,a0,16
              addi    a5,a5,%lo(.LC3)
              vse32.v v1,0(a4)
              vle32.v v1,0(a5)
              addi    a4,a0,32
              lui     a5,%hi(.LC4)
              vse32.v v1,0(a4)
              addi    a0,a0,48
              addi    a5,a5,%lo(.LC4)
              vle32.v v1,0(a5)
              vse32.v v1,0(a0)
              ret
      
      After this patch:
      
      foo1:
      	vsetivli	zero,16,e32,mf2,ta,ma
      	vmv.v.i	v1,8
      	vse32.v	v1,0(a0)
      	ret
      	.size	foo1, .-foo1
      	.align	1
      	.globl	foo2
      	.type	foo2, @function
      foo2:
      	vsetivli	zero,16,e32,mf2,ta,ma
      	vid.v	v1
      	vse32.v	v1,0(a0)
      	ret
      
      gcc/ChangeLog:
      
      	* config/riscv/autovec.md: Add VLS CONST_VECTOR.
      	* config/riscv/riscv.cc (riscv_const_insns): Ditto.
      	* config/riscv/vector.md: Ditto.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.target/riscv/rvv/autovec/vls/def.h: Add VLS CONST_VECTOR tests.
      	* gcc.target/riscv/rvv/autovec/vls/const-1.c: New test.
      	* gcc.target/riscv/rvv/autovec/vls/const-2.c: New test.
      	* gcc.target/riscv/rvv/autovec/vls/const-3.c: New test.
      	* gcc.target/riscv/rvv/autovec/vls/const-4.c: New test.
      	* gcc.target/riscv/rvv/autovec/vls/const-5.c: New test.
      	* gcc.target/riscv/rvv/autovec/vls/series-1.c: New test.
      	* gcc.target/riscv/rvv/autovec/vls/series-2.c: New test.
      	* gcc.target/riscv/rvv/autovec/vls/series-3.c: New test.
      	* gcc.target/riscv/rvv/autovec/vls/series-4.c: New test.
      e80c55e4
    • GCC Administrator's avatar
      Daily bump. · 886afed6
      GCC Administrator authored
      886afed6
  3. Aug 11, 2023
    • Jonathan Wakely's avatar
      libstdc++: Fix std::format_to_n return value [PR110990] · 003016a4
      Jonathan Wakely authored
      When writing to a contiguous iterator, std::format_to_n(out, n, ...)
      always returns out + n, even if it wrote fewer than n characters to the
      iterator.
      
      The problem is in the _M_finish() member function of the _Iter_sink
      specialization for contiguous iterators. _M_finish() calls _M_overflow()
      to update its count of characters written, so it can return the count of
      characters that would be written if there was room. But _M_overflow()
      assumes it's only called when the buffer is full, and so switches to the
      internal buffer. _M_finish() then thinks that if the internal buffer is
      in use, we already wrote at least n characters and so returns out+n as
      the output position.
      
      We can fix the problem by adding a check in _M_overflow() so that we
      don't update the count and switch to the internal buffer unless we've
      run out of room, i.e. _M_unused().size() is zero. The caller then needs
      to be prepared for _M_count not being the final total, and so add
      _M_used.size() to it.
      
      However, there's not actually any need for _M_finish() to call
      _M_overflow() to get the count. We now need to use _M_count and
      _M_used.size() to get the total anyway so _M_overflow() doesn't help
      with that. And we don't need to use _M_overflow() to flush unwritten
      characters to the output, because the specialization for contiguous
      iterators always writes directly to the output without buffering (except
      when we've exceeded the maximum number of characters, in which case we
      want to discard the buffered characters anyway). So _M_finish() can be
      simplified and can avoid calling _M_overflow().
      
      This change also fixes some member functions of other sink classes to
      only call _M_overflow() when there are characters in the buffer, which
      is needed to meet _M_overflow's precondition that _M_used().size()!=0.
      
      libstdc++-v3/ChangeLog:
      
      	PR libstdc++/110990
      	* include/std/format (_Seq_sink::get): Only call _M_overflow if
      	its precondition is met.
      	(_Iter_sink::_M_finish): Likewise.
      	(_Iter_sink<C, ContigIter>::_M_overflow): Only switch to the
      	internal buffer after running out of space.
      	(_Iter_sink<C, ContigIter>::_M_finish): Do not use _M_overflow.
      	(_Counting_sink::count): Likewise.
      	* testsuite/std/format/functions/format_to_n.cc: Check cases
      	where the output fits into the buffer.
      003016a4
    • David Malcolm's avatar
      analyzer: new warning: -Wanalyzer-unterminated-string [PR105899] · 325f9e88
      David Malcolm authored
      
      This patch adds new functions to the analyzer for checking that
      an argument at a callsite is a pointer to a valid null-terminated
      string, and uses this for the following known functions:
      
      - error (param 3, the format string)
      - error_at_line (param 5, the format string)
      - putenv
      - strchr (1st param)
      - strcpy (2nd param)
      - strdup
      
      Currently the check merely detects pointers to unterminated string
      constants, and adds a new -Wanalyzer-unterminated-string to complain
      about that.  I'm experimenting with detecting other ways in which
      a buffer can fail to be null-terminated, and for other problems with
      such buffers, but this patch at least adds the framework for wiring
      up the check to specific parameters of known_functions.
      
      gcc/analyzer/ChangeLog:
      	PR analyzer/105899
      	* analyzer.opt (Wanalyzer-unterminated-string): New.
      	* call-details.cc
      	(call_details::check_for_null_terminated_string_arg): New.
      	* call-details.h
      	(call_details::check_for_null_terminated_string_arg): New decl.
      	* kf-analyzer.cc (class kf_analyzer_get_strlen): New.
      	(register_known_analyzer_functions): Register it.
      	* kf.cc (kf_error::impl_call_pre): Check that format arg is a
      	valid null-terminated string.
      	(kf_putenv::impl_call_pre): Likewise for the sole param.
      	(kf_strchr::impl_call_pre): Likewise for the first param.
      	(kf_strcpy::impl_call_pre): Likewise for the second param.
      	(kf_strdup::impl_call_pre): Likewise for the sole param.
      	* region-model.cc (get_strlen): New.
      	(struct call_arg_details): New.
      	(inform_about_expected_null_terminated_string_arg): New.
      	(class unterminated_string_arg): New.
      	(region_model::check_for_null_terminated_string_arg): New.
      	* region-model.h
      	(region_model::check_for_null_terminated_string_arg): New decl.
      
      gcc/ChangeLog:
      	PR analyzer/105899
      	* doc/analyzer.texi (__analyzer_get_strlen): New.
      	* doc/invoke.texi: Add -Wanalyzer-unterminated-string.
      
      gcc/testsuite/ChangeLog:
      	PR analyzer/105899
      	* gcc.dg/analyzer/analyzer-decls.h (__analyzer_get_strlen): New.
      	* gcc.dg/analyzer/error-1.c (test_error_unterminated): New.
      	(test_error_at_line_unterminated): New.
      	* gcc.dg/analyzer/null-terminated-strings-1.c: New test.
      	* gcc.dg/analyzer/putenv-1.c (test_unterminated): New.
      	* gcc.dg/analyzer/strchr-1.c (test_unterminated): New.
      	* gcc.dg/analyzer/strcpy-1.c (test_unterminated): New.
      	* gcc.dg/analyzer/strdup-1.c (test_unterminated): New.
      
      Signed-off-by: default avatarDavid Malcolm <dmalcolm@redhat.com>
      325f9e88
    • Jeff Law's avatar
      [committed] Fix subdi3 synthesis on rx port · db08a096
      Jeff Law authored
      Some of Andrew's recent match.pd changes triggered a regression in my tester
      for the rx processor for c-torture/execute/pr66940.c which would be exposed
      only during an LTO compilation.
      
      Specifically the subdi3_internal pattern had the wrong idiom to detect a carry
      from the high word into the low word.  It had the wrong opcode and the operands
      were reversed.
      
      This resulted in combine doing a simplification that was valid according to the
      presented RTL, but which ultimately got the wrong result.
      
      I would often say this was a latent bug.  But the testsuite shows
      builtin-arith-overflow-14 and builtin-arith-overflow-p18 failures are fixed as
      well.  So it's been visible indefinitely, but nobody's ever looked into those
      failures.
      
      Committed to the trunk.
      
      gcc/
      	* config/rx/rx.md (subdi3): Fix test for borrow.
      db08a096
    • Juzhe-Zhong's avatar
      VECT: Fix ICE on MASK_LEN_{LOAD, STORE} when no LEN recorded[PR110989] · 5bfb5e77
      Juzhe-Zhong authored
      This ICE is caused because of this situation:
      
      mask__49.21_99 = vect__17.19_96 == { 0.0, ... };
      ...
      vect__6.24_107 = .MASK_LEN_LOAD (vectp.22_105, 32B, mask__49.21_99, POLY_INT_CST [2, 2], 0);
      
      The MASK_LEN_LOAD is using real MASK which is produced by the EQ comparison wheras the LEN
      is the dummy LEN which is the vectorization factor.
      
      In this situation, we didn't enter 'vect_record_loop_len' since there is no LEN loop control.
      Then 'LOOP_VINFO_RGROUP_IV_TYPE' is not suitable type for 'build_int_cst' used for producing
      LEN argument for 'MASK_LEN_LOAD', so use sizetype instead which is perfectly matching
      RVV length requirement.
      
      gcc/ChangeLog:
      	PR middle-end/110989
      	* tree-vect-stmts.cc (vectorizable_store): Replace iv_type with sizetype.
      	(vectorizable_load): Ditto.
      
      gcc/testsuite/ChangeLog:
      	PR middle-end/110989
      	* gcc.target/riscv/rvv/autovec/pr110989.c: New test.
      5bfb5e77
    • Patrick O'Neill's avatar
      RISC-V: Specify -mabi for ztso testcases · 2b1b804d
      Patrick O'Neill authored
      
      On rv32 targets, this patch fixes ztso testcases errors like this:
      cc1: error: ABI requires '-march=rv32'
      
      2023-08-11 Patrick O'Neill <patrick@rivosinc.com>
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.target/riscv/amo-table-ztso-amo-add-1.c: Add -mabi=lp64d
      	to dg-options.
      	* gcc.target/riscv/amo-table-ztso-amo-add-2.c: Ditto.
      	* gcc.target/riscv/amo-table-ztso-amo-add-3.c: Ditto.
      	* gcc.target/riscv/amo-table-ztso-amo-add-4.c: Ditto.
      	* gcc.target/riscv/amo-table-ztso-amo-add-5.c: Ditto.
      	* gcc.target/riscv/amo-table-ztso-compare-exchange-1.c: Ditto.
      	* gcc.target/riscv/amo-table-ztso-compare-exchange-2.c: Ditto.
      	* gcc.target/riscv/amo-table-ztso-compare-exchange-3.c: Ditto.
      	* gcc.target/riscv/amo-table-ztso-compare-exchange-4.c: Ditto.
      	* gcc.target/riscv/amo-table-ztso-compare-exchange-5.c: Ditto.
      	* gcc.target/riscv/amo-table-ztso-compare-exchange-6.c: Ditto.
      	* gcc.target/riscv/amo-table-ztso-compare-exchange-7.c: Ditto.
      	* gcc.target/riscv/amo-table-ztso-fence-1.c: Ditto.
      	* gcc.target/riscv/amo-table-ztso-fence-2.c: Ditto.
      	* gcc.target/riscv/amo-table-ztso-fence-3.c: Ditto.
      	* gcc.target/riscv/amo-table-ztso-fence-4.c: Ditto.
      	* gcc.target/riscv/amo-table-ztso-fence-5.c: Ditto.
      	* gcc.target/riscv/amo-table-ztso-load-1.c: Ditto.
      	* gcc.target/riscv/amo-table-ztso-load-2.c: Ditto.
      	* gcc.target/riscv/amo-table-ztso-load-3.c: Ditto.
      	* gcc.target/riscv/amo-table-ztso-store-1.c: Ditto.
      	* gcc.target/riscv/amo-table-ztso-store-2.c: Ditto.
      	* gcc.target/riscv/amo-table-ztso-store-3.c: Ditto.
      	* gcc.target/riscv/amo-table-ztso-subword-amo-add-1.c: Ditto.
      	* gcc.target/riscv/amo-table-ztso-subword-amo-add-2.c: Ditto.
      	* gcc.target/riscv/amo-table-ztso-subword-amo-add-3.c: Ditto.
      	* gcc.target/riscv/amo-table-ztso-subword-amo-add-4.c: Ditto.
      	* gcc.target/riscv/amo-table-ztso-subword-amo-add-5.c: Ditto.
      
      Signed-off-by: default avatarPatrick O'Neill <patrick@rivosinc.com>
      2b1b804d
    • Jonathan Wakely's avatar
      libstdc++: Implement C++20 std::chrono::parse [PR104167] · ce6c4d3b
      Jonathan Wakely authored
      This adds the missing C++20 features to <chrono>.
      
      I've implemented my proposed resolutions to LWG issues 3960, 3961, and
      3962. There are some unimplemented flags such as %OI which I think are
      not implementable in general. It might be possible to use na_llanginfo
      with ALT_DIGITS, but that isn't available on all targets. I intend to
      file another LWG issue about that.
      
      libstdc++-v3/ChangeLog:
      
      	PR libstdc++/104167
      	* include/bits/chrono_io.h (operator|=, operator|): Add noexcept
      	to _ChronoParts operators.
      	(from_stream, parse): Define new functions.
      	(__detail::_Parse, __detail::_Parser): New class templates.
      	* include/std/chrono (__cpp_lib_chrono): Define to 201907L for
      	C++20.
      	* include/std/version (__cpp_lib_chrono): Likewise.
      	* testsuite/20_util/duration/arithmetic/constexpr_c++17.cc:
      	Adjust expected value of feature test macro.
      	* testsuite/20_util/duration/io.cc: Test parsing.
      	* testsuite/std/time/clock/file/io.cc: Likewise.
      	* testsuite/std/time/clock/gps/io.cc: Likewise.
      	* testsuite/std/time/clock/system/io.cc: Likewise.
      	* testsuite/std/time/clock/tai/io.cc: Likewise.
      	* testsuite/std/time/clock/utc/io.cc: Likewise.
      	* testsuite/std/time/day/io.cc: Likewise.
      	* testsuite/std/time/month/io.cc: Likewise.
      	* testsuite/std/time/month_day/io.cc: Likewise.
      	* testsuite/std/time/weekday/io.cc: Likewise.
      	* testsuite/std/time/year/io.cc: Likewise.
      	* testsuite/std/time/year_month/io.cc: Likewise.
      	* testsuite/std/time/year_month_day/io.cc: Likewise.
      	* testsuite/std/time/syn_c++20.cc: Check value of macro and for
      	the existence of parse and from_stream in namespace chrono.
      	* testsuite/std/time/clock/local/io.cc: New test.
      	* testsuite/std/time/parse.cc: New test.
      ce6c4d3b
    • Jose E. Marchesi's avatar
      bpf: liberate R9 for general register allocation · f93a612f
      Jose E. Marchesi authored
      We were reserving one of the hard registers in BPF in order to
      implement dynamic stack allocation: alloca and VLAs. However, there is
      kernel code that has inline assembly that requires all the non-fixed
      registers to be available for register allocation.
      
      This patch:
      
      1. Liberates r9 that is now available for register allocation.
      
      2. Adds a check to GCC so it errors out if the user tries to do
         dynamic stack allocation.  A couple of tests are added for this.
      
      3. Changes xbpf so it no longer saves and restores callee-saved
         registers.  A couple of tests for this have been removed.
      
      4. Adds bpf-*-* to the list of targets that do not support alloca in
         target-support.exp.
      
      Tested in host x86_64-linux-gnu and target bpf-unknown-none.
      
      gcc/ChangeLog
      
      	* config/bpf/bpf.md (allocate_stack): Define.
      	* config/bpf/bpf.h (FIRST_PSEUDO_REGISTER): Make room for fake
      	stack pointer register.
      	(FIXED_REGISTERS): Adjust accordingly.
      	(CALL_USED_REGISTERS): Likewise.
      	(REG_CLASS_CONTENTS): Likewise.
      	(REGISTER_NAMES): Likewise.
      	* config/bpf/bpf.cc (bpf_compute_frame_layout): Do not reserve
      	space for callee-saved registers.
      	(bpf_expand_prologue): Do not save callee-saved registers in xbpf.
      	(bpf_expand_epilogue): Do not restore callee-saved registers in
      	xbpf.
      
      gcc/testsuite/ChangeLog
      
      	* lib/target-supports.exp (check_effective_target_alloca): BPF
      	target does not support alloca.
      	* gcc.target/bpf/diag-alloca-1.c: New test.
      	* gcc.target/bpf/diag-alloca-2.c: Likewise.
      	* gcc.target/bpf/xbpf-callee-saved-regs-1.c: Remove test.
      	* gcc.target/bpf/xbpf-callee-saved-regs-2.c: Likewise.
      	* gcc.target/bpf/regs-availability-1.c: Likewise.
      f93a612f
    • Jose E. Marchesi's avatar
      bpf: allow exceeding max num of args in BPF when always_inline · 6103df1e
      Jose E. Marchesi authored
      BPF currently limits the number of registers used to pass arguments to
      functions to five registers.  There is a check for this at function
      expansion time.  However, if a function is guaranteed to be always
      inlined (and its body never generated) by virtue of the always_inline
      attribute, it can "receive" any number of arguments.
      
      Tested in host x86_64-linux-gnu and target bpf-unknown-none.
      
      gcc/ChangeLog
      
      	* config/bpf/bpf.cc (bpf_function_arg_advance): Do not complain
      	about too many arguments if function is always inlined.
      
      gcc/testsuite/ChangeLog
      
      	* gcc.target/bpf/diag-funargs-inline-1.c: New test.
      	* gcc.target/bpf/diag-funargs.c: Adapt test.
      6103df1e
    • Eric Feng's avatar
      analyzer: More features for CPython analyzer plugin [PR107646] · 38c00edd
      Eric Feng authored
      
      This patch adds known function subclasses for Python/C API functions
      PyList_New, PyLong_FromLong, and PyList_Append. It also adds new
      optional parameters for
      region_model::get_or_create_region_for_heap_alloc, allowing for the
      newly allocated region to immediately transition from the start state to
      the assumed non-null state in the malloc state machine if desired.
      Finally, it adds a new procedure, dg-require-python-h, intended as a
      directive in Python-related analyzer tests, to append necessary Python
      flags during the tests' build process.
      
      The main warnings we gain in this patch with respect to the known function
      subclasses mentioned are leak related. For example:
      
      rc3.c: In function ‘create_py_object’:
      │
      rc3.c:21:10: warning: leak of ‘item’ [CWE-401] [-Wanalyzer-malloc-leak]
      │
         21 |   return list;
            │
            |          ^~~~
      │
        ‘create_py_object’: events 1-4
      │
          |
      │
          |    4 |   PyObject* item = PyLong_FromLong(10);
      │
          |      |                    ^~~~~~~~~~~~~~~~~~~
      │
          |      |                    |
      │
          |      |                    (1) allocated here
      │
          |      |                    (2) when ‘PyLong_FromLong’ succeeds
      │
          |    5 |   PyObject* list = PyList_New(2);
      │
          |      |                    ~~~~~~~~~~~~~
      │
          |      |                    |
      │
          |      |                    (3) when ‘PyList_New’ fails
      │
          |......
      │
          |   21 |   return list;
      │
          |      |          ~~~~
      │
          |      |          |
      │
          |      |          (4) ‘item’ leaks here; was allocated at (1)
      │
      
      Some concessions were made to
      simplify the analysis process when comparing kf_PyList_Append with the
      real implementation. In particular, PyList_Append performs some
      optimization internally to try and avoid calls to realloc if
      possible. For simplicity, we assume that realloc is called every time.
      Also, we grow the size by just 1 (to ensure enough space for adding a
      new element) rather than abide by the heuristics that the actual implementation
      follows.
      
      gcc/analyzer/ChangeLog:
      	PR analyzer/107646
      	* call-details.h: New function.
      	* region-model.cc (region_model::get_or_create_region_for_heap_alloc):
      	New optional parameters.
      	* region-model.h (class region_model): New optional parameters.
      	* sm-malloc.cc (on_realloc_with_move): New function.
      	(region_model::transition_ptr_sval_non_null): New function.
      
      gcc/testsuite/ChangeLog:
      	PR analyzer/107646
      	* gcc.dg/plugin/analyzer_cpython_plugin.c: Analyzer support for
      	PyList_New, PyList_Append, PyLong_FromLong
      	* gcc.dg/plugin/plugin.exp: New test.
      	* lib/target-supports.exp: New procedure.
      	* gcc.dg/plugin/cpython-plugin-test-2.c: New test.
      
      Signed-off-by: default avatarEric Feng <ef2648@columbia.edu>
      38c00edd
    • Patrick Palka's avatar
      c++: dependently scoped template-id in type-req [PR110927] · 63bd36be
      Patrick Palka authored
      Here we're incorrectly rejecting the first type-requirement at parse
      time with
      
        concepts-requires35.C:14:56: error: ‘typename A<T>::B’ is not a template [-fpermissive]
      
      We also incorrectly reject the second type-requirement at satisfaction time
      with
      
        concepts-requires35.C:17:34: error: ‘typename A<int>::B’ names ‘template<class U> struct A<int>::B’, which is not a type
      
      and similarly for the third type-requirement.  This seems to happen only
      within a type-requirement; if we instead use e.g. an alias template then
      it works as expected.
      
      The difference ultimately seems to be that during parsing of a using-decl,
      we pass check_dependency_p=true to cp_parser_nested_name_specifier_opt
      whereas for a type-requirement we pass check_dependency_p=false.
      Passing =false causes cp_parser_template_id for the dependently-scoped
      template-id B<bool> to create a TYPE_DECL of TYPENAME_TYPE (with
      TYPENAME_IS_CLASS_P unexpectedly set in the last two cases) whereas
      passing =true causes it to return a TEMPLATE_ID_EXPR.  We then call
      make_typename_type on this TYPE_DECL which does the wrong thing.
      
      Since there seems to be no justification for using check_dependency_p=false
      here, the simplest fix seems to be to pass check_dependency_p=true instead,
      matching the behavior of cp_parser_elaborated_type_specifier.
      
      	PR c++/110927
      
      gcc/cp/ChangeLog:
      
      	* parser.cc (cp_parser_type_requirement): Pass
      	check_dependency_p=true instead of =false.
      
      gcc/testsuite/ChangeLog:
      
      	* g++.dg/cpp2a/concepts-requires35.C: New test.
      63bd36be
    • Patrick Palka's avatar
      c++: recognize in-class var tmpl partial spec [PR71954] · ca267665
      Patrick Palka authored
      This makes us recognize member variable template partial specializations
      defined directly inside the class body.  It seems we mainly just need to
      call check_explicit_specialization when we see a static TEMPLATE_ID_EXPR
      data member, which sets SET_DECL_TEMPLATE_SPECIALIZATION for us and which
      we otherwise don't call (for the out-of-class case we call it from
      grokvardecl).
      
      We also need to make finish_member_template_decl return NULL_TREE for
      such partial specializations, matching its behavior for class template
      partial specializations, so that later we don't try to register it as a
      separate member declaration.
      
      	PR c++/71954
      
      gcc/cp/ChangeLog:
      
      	* decl.cc (grokdeclarator): Pass 'dname' instead of
      	'unqualified_id' as the name when building the VAR_DECL for a
      	static data member.  Call check_explicit_specialization for a
      	TEMPLATE_ID_EXPR such member.
      	* pt.cc (finish_member_template_decl): Return NULL_TREE
      	instead of 'decl' when DECL_TEMPLATE_SPECIALIZATION is not
      	set.
      
      gcc/testsuite/ChangeLog:
      
      	* g++.dg/cpp1y/var-templ84.C: New test.
      	* g++.dg/cpp1y/var-templ84a.C: New test.
      ca267665
    • Jonathan Wakely's avatar
      libstdc++: Do not call log10(0.0) in std::format [PR110860] · 9e33d718
      Jonathan Wakely authored
      Calling log10(0.0) returns -inf which has undefined behaviour when
      converted to an integer. We only need to use log10 for large values
      anyway. If the value is zero then the larger buffer is only needed due
      to a large precision, so we don't need to use log10 to estimate the
      number of digits for the significand.
      
      libstdc++-v3/ChangeLog:
      
      	PR libstdc++/110860
      	* include/std/format (__formatter_fp::format): Do not call log10
      	with zero values.
      9e33d718
    • Eric Feng's avatar
      MAINTAINERS: Add myself to write after approval · 20db5cab
      Eric Feng authored
      
      ChangeLog:
      
      	* MAINTAINERS: Add myself.
      
      Signed-off-by: default avatarEric Feng <ef2648@columbia.edu>
      20db5cab
    • Patrick Palka's avatar
      c++: improve debug_tree for templated types/decls · 1531de63
      Patrick Palka authored
      gcc/cp/ChangeLog:
      
      	* ptree.cc (cxx_print_decl): Check for DECL_LANG_SPECIFIC and
      	TS_DECL_COMMON only when necessary.  Print DECL_TEMPLATE_INFO
      	for all decls that have it, not just VAR_DECL or FUNCTION_DECL.
      	Also print DECL_USE_TEMPLATE.
      	(cxx_print_type): Print TYPE_TEMPLATE_INFO.
      	<case BOUND_TEMPLATE_TEMPLATE_PARM>: Don't print TYPE_TI_ARGS
      	anymore.
      	<case TEMPLATE_TYPE/TEMPLATE_PARM>: Print TEMPLATE_TYPE_PARM_INDEX
      	instead of printing the index, level and original level
      	individually.
      1531de63
    • Patrick Palka's avatar
      tree-pretty-print: handle COMPONENT_REF with non-decl RHS · a4238f6d
      Patrick Palka authored
      In the C++ front end, a COMPONENT_REF's second operand isn't always a
      decl (at least at template parse time).  This patch makes the generic
      pretty printer not ICE when printing such a COMPONENT_REF.
      
      gcc/ChangeLog:
      
      	* tree-pretty-print.cc (dump_generic_node) <case COMPONENT_REF>:
      	Don't call component_ref_field_offset if the RHS isn't a decl.
      a4238f6d
    • John David Anglin's avatar
      Use strtol instead of std::stoi [PR110646] · 834d1422
      John David Anglin authored
      Implementation of std::stoi was overlooked on hppa-hpux, so use
      strtol instead.
      
      2023-08-11  John David Anglin  <danglin@gcc.gnu.org>
      
      gcc/ChangeLog:
      
      	PR bootstrap/110646
      	* gensupport.cc(class conlist): Use strtol instead of std::stoi.
      834d1422
    • Thomas Neumann's avatar
      preserve base pointer for __deregister_frame [PR110956] · c46bded7
      Thomas Neumann authored
      Original bug report: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110956
      Rainer Orth successfully tested the patch on Solaris with a full bootstrap.
      
      Some uncommon unwinding table encodings need to access the base pointer
      for address computations. We do not have that information in calls to
      __deregister_frame_info_bases, and previously simply used nullptr as
      base pointer. That is usually fine, but for some Solaris i386 shared
      libraries that results in wrong address computations.
      
      To fix this problem we now associate the unwinding object with
      the table pointer itself, which is always known, in addition to
      the PC range. When deregistering a frame, we first locate the object
      using the table pointer, and then use the base pointer stored within
      the object to compute the PC range.
      
      libgcc/ChangeLog:
      	PR libgcc/110956
      	* unwind-dw2-fde.c: Associate object with address of unwinding
      	table.
      c46bded7
    • Vladimir N. Makarov's avatar
      [LRA]: Implement output stack pointer reloads · ef96754d
      Vladimir N. Makarov authored
      LRA prohibited output stack pointer reloads but it resulted in LRA
      failure for AVR target which has no arithmetic insns working with the
      stack pointer register.  Given patch implements the output stack
      pointer reloads.
      
      gcc/ChangeLog:
      
      	* lra-constraints.cc (goal_alt_out_sp_reload_p): New flag.
      	(process_alt_operands): Set the flag.
      	(curr_insn_transform): Modify stack pointer offsets if output
      	stack pointer reload is generated.
      ef96754d
    • Jonathan Wakely's avatar
      libstdc++: Handle invalid values in std::chrono pretty printers · c19b542a
      Jonathan Wakely authored
      This avoids an IndexError exception when printing invalid chrono::month
      or chrono::weekday values.
      
      libstdc++-v3/ChangeLog:
      
      	* python/libstdcxx/v6/printers.py (StdChronoCalendarPrinter):
      	Check for out-of-range month an weekday indices.
      	* testsuite/libstdc++-prettyprinters/chrono.cc: Check invalid
      	month and weekday values.
      c19b542a
    • Jonathan Wakely's avatar
      libstdc++: Revert accidentally committed change to bits/stl_iterator.h · 7723684f
      Jonathan Wakely authored
      In commit r14-3134-g9cb2a7c8d54b1f I only meant to change some uses of
      __clamp_iter_cat to use __iter_category_t, I didn't mean to commit the
      additional change introducing __clamped_iter_cat_t. This reverts that
      part.
      
      libstdc++-v3/ChangeLog:
      
      	* include/bits/stl_iterator.h (__clamped_iter_cat_t): Remove.
      7723684f
    • Joseph Myers's avatar
      config: Fix host -rdynamic detection for build != host != target · 4d9bc81a
      Joseph Myers authored
      The GCC_ENABLE_PLUGINS configure logic for detecting whether -rdynamic
      is necessary and supported uses an appropriate objdump for $host
      binaries (running on $build) in cases where $host is $build or
      $target.
      
      However, it is missing such logic in the case where $host is neither
      $build nor $target, resulting in the compilers not being linked with
      -rdynamic and plugins not being usable with such a compiler.  In fact
      $ac_cv_prog_OBJDUMP, as used when $build = $host, is always an objdump
      for $host binaries that runs on $build; that is, it's appropriate to
      use in this case as well.
      
      Tested in such a configuration that it does result in cc1 being linked
      with -rdynamic as expected.  Also bootstrapped with no regressions for
      x86_64-pc-linux-gnu.
      
      config/
      	* gcc-plugin.m4 (GCC_ENABLE_PLUGINS): Use
      	export_sym_check="$ac_cv_prog_OBJDUMP -T" also when host is not
      	build or target.
      
      gcc/
      	* configure: Regenerate.
      
      libcc1/
      	* configure: Regenerate.
      4d9bc81a
    • Richard Biener's avatar
      tree-optimization/110979 - fold-left reduction and partial vectors · 798a880a
      Richard Biener authored
      When we vectorize fold-left reductions with partial vectors but
      no target operation available we use a vector conditional to force
      excess elements to zero.  But that doesn't correctly preserve
      the sign of zero.  The following patch disables partial vector
      support when we have to do that and also need to honor rounding
      modes other than round-to-nearest.  When round-to-nearest is in
      effect and we have to preserve the sign of zero instead use
      negative zero for the excess elements.
      
      	PR tree-optimization/110979
      	* tree-vect-loop.cc (vectorizable_reduction): For
      	FOLD_LEFT_REDUCTION without target support make sure
      	we don't need to honor signed zeros and sign dependent rounding.
      
      	* gcc.dg/torture/pr110979.c: New testcase.
      798a880a
    • Richard Biener's avatar
      Improve BB vectorization opt-info · 3a13884b
      Richard Biener authored
      The following makes us more correctly print the used vector size
      when doing BB vectorization and also print all involved SLP graph
      roots, not just the random one we ended up picking as leader.
      In particular the last bit improves diffing opt-info between
      different GCC revs but it also requires some testsuite adjustments.
      
      	* tree-vect-slp.cc (vect_slp_region): Provide opt-info for all SLP
      	subgraph entries.  Dump the used vector size based on the
      	SLP subgraph entry root vector type.
      
      	* g++.dg/vect/slp-pr87105.cc: Adjust.
      	* gcc.dg/vect/bb-slp-17.c: Likewise.
      	* gcc.dg/vect/bb-slp-20.c: Likewise.
      	* gcc.dg/vect/bb-slp-21.c: Likewise.
      	* gcc.dg/vect/bb-slp-22.c: Likewise.
      	* gcc.dg/vect/bb-slp-subgroups-2.c: Likewise.
      3a13884b
    • Pan Li's avatar
      RISC-V: Support RVV VFMSUB rounding mode intrinsic API · 6a8203b7
      Pan Li authored
      
      This patch would like to support the rounding mode API for the
      VFMSUB as the below samples.
      
      * __riscv_vfmsub_vv_f32m1_rm
      * __riscv_vfmsub_vv_f32m1_rm_m
      * __riscv_vfmsub_vf_f32m1_rm
      * __riscv_vfmsub_vf_f32m1_rm_m
      
      Signed-off-by: default avatarPan Li <pan2.li@intel.com>
      
      gcc/ChangeLog:
      
      	* config/riscv/riscv-vector-builtins-bases.cc
      	(class vfmsub_frm): New class for vfmsub frm.
      	(vfmsub_frm): New declaration.
      	(BASE): Ditto.
      	* config/riscv/riscv-vector-builtins-bases.h: Ditto.
      	* config/riscv/riscv-vector-builtins-functions.def
      	(vfmsub_frm): New function declaration.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.target/riscv/rvv/base/float-point-msub.c: New test.
      6a8203b7
    • Juzhe-Zhong's avatar
      VECT: Add vec_mask_len_{load_lanes,store_lanes} patterns · 59d789b3
      Juzhe-Zhong authored
      This patch is add vec_mask_len_{load_lanes,store_stores} autovectorization patterns.
      
      Here we want to support this following autovectorization:
      
      void
      foo (int8_t *__restrict a,
      int8_t *__restrict b,
      int8_t *__restrict cond,
      int n)
      {
        for (intptr_t i = 0; i < n; ++i)
          {
            if (cond[i])
              a[i] = b[i * 2] + b[i * 2 + 1];
          }
      }
      
      ARM SVE IR:
      
      https://godbolt.org/z/cro1Eqc6a
      
        # loop_mask_60 = PHI <next_mask_82(4), max_mask_81(3)>
        ...
        mask__39.12_63 = vect__3.11_61 != { 0, ... };
        vec_mask_and_66 = loop_mask_60 & mask__39.12_63;
        ...
        vect_array.15 = .MASK_LOAD_LANES (_57, 8B, vec_mask_and_66);
        ...
      
      For RVV, we would like to see IR:
      
        loop_len = SELECT_VL;
        ...
        mask__39.12_63 = vect__3.11_61 != { 0, ... };
        ...
        vect_array.15 = .MASK_LEN_LOAD_LANES (_57, 8B, mask__39.12_63, loop_len, bias);
        ...
      
      Bootstrap and Regression on X86 passed.
      
      Ok for trunk ?
      
      gcc/ChangeLog:
      
      	* doc/md.texi: Add vec_mask_len_{load_lanes,store_lanes} patterns.
      	* internal-fn.cc (expand_partial_load_optab_fn): Ditto.
      	(expand_partial_store_optab_fn): Ditto.
      	* internal-fn.def (MASK_LEN_LOAD_LANES): Ditto.
      	(MASK_LEN_STORE_LANES): Ditto.
      	* optabs.def (OPTAB_CD): Ditto.
      59d789b3
    • Pan Li's avatar
      RISC-V: Support RVV VFNMADD rounding mode intrinsic API · bcda361d
      Pan Li authored
      
      This patch would like to support the rounding mode API for the
      VFNMADD as the below samples.
      
      * __riscv_vfnmadd_vv_f32m1_rm
      * __riscv_vfnmadd_vv_f32m1_rm_m
      * __riscv_vfnmadd_vf_f32m1_rm
      * __riscv_vfnmadd_vf_f32m1_rm_m
      
      Signed-off-by: default avatarPan Li <pan2.li@intel.com>
      
      gcc/ChangeLog:
      
      	* config/riscv/riscv-vector-builtins-bases.cc
      	(class vfnmadd_frm): New class for vfnmadd frm.
      	(vfnmadd_frm): New declaration.
      	(BASE): Ditto.
      	* config/riscv/riscv-vector-builtins-bases.h: Ditto.
      	* config/riscv/riscv-vector-builtins-functions.def
      	(vfnmadd_frm): New function declaration.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.target/riscv/rvv/base/float-point-nmadd.c: New test.
      bcda361d
    • Drew Ross's avatar
      match.pd: Implement missed optimization ((x ^ y) & z) | x -> (z & y) | x [PR109938] · 9f933492
      Drew Ross authored
      Adds a simplification for ((x ^ y) & z) | x to be folded into
      (z & y) | x. Merges this simplification with ((x | y) & z) | x -> (z & y) | x
      to prevent duplicate pattern.
      
      2023-08-11  Drew Ross  <drross@redhat.com>
      	    Jakub Jelinek  <jakub@redhat.com>
      
      	PR tree-optimization/109938
      	* match.pd (((x ^ y) & z) | x -> (z & y) | x): New simplification.
      
      	* gcc.c-torture/execute/pr109938.c: New test.
      	* gcc.dg/tree-ssa/pr109938.c: New test.
      9f933492
    • Pan Li's avatar
      RISC-V: Support RVV VFMADD rounding mode intrinsic API · 797334e9
      Pan Li authored
      
      This patch would like to support the rounding mode API for the
      VFMADD as the below samples.
      
      * __riscv_vfmadd_vv_f32m1_rm
      * __riscv_vfmadd_vv_f32m1_rm_m
      * __riscv_vfmadd_vf_f32m1_rm
      * __riscv_vfmadd_vf_f32m1_rm_m
      
      Signed-off-by: default avatarPan Li <pan2.li@intel.com>
      
      gcc/ChangeLog:
      
      	* config/riscv/riscv-vector-builtins-bases.cc
      	(class vfmadd_frm): New class for vfmadd frm.
      	(vfmadd_frm_obj): New declaration.
      	(BASE): Ditto.
      	* config/riscv/riscv-vector-builtins-bases.h: Ditto.
      	* config/riscv/riscv-vector-builtins-functions.def
      	(vfmadd_frm): New function definition.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.target/riscv/rvv/base/float-point-madd.c: New test.
      797334e9
Loading