Skip to content
Snippets Groups Projects
  1. Mar 10, 2023
    • Thomas Schwinge's avatar
      Fix OpenACC/GCN 'acc_ev_enqueue_launch_end' position · 649f1939
      Thomas Schwinge authored
      For an OpenACC compute construct, we've currently got:
      
        - [...]
        - acc_ev_enqueue_launch_start
        - launch kernel
        - free memory
        - acc_ev_free
        - acc_ev_enqueue_launch_end
      
      This confused another thing that I'm working on, so I adjusted that to:
      
        - [...]
        - acc_ev_enqueue_launch_start
        - launch kernel
        - acc_ev_enqueue_launch_end
        - free memory
        - acc_ev_free
      
      Correspondingly, verify 'acc_ev_alloc', 'acc_ev_free' in
      'libgomp.oacc-c-c++-common/acc_prof-parallel-1.c'.
      
      	libgomp/
      	* plugin/plugin-gcn.c (gcn_exec): Fix 'acc_ev_enqueue_launch_end'
      	position.
      	* testsuite/libgomp.oacc-c-c++-common/acc_prof-parallel-1.c:
      	Verify 'acc_ev_alloc', 'acc_ev_free'.
      649f1939
    • Jason Merrill's avatar
      c++: class NTTP and nested anon union [PR108566] · e1c8cf90
      Jason Merrill authored
      We were failing to come up with the name for the anonymous union.  It seems
      like unfortunate redundancy, but the ABI does say that the name of an
      anonymous union is its first named member.
      
      	PR c++/108566
      
      gcc/cp/ChangeLog:
      
      	* mangle.cc (anon_aggr_naming_decl): New.
      	(write_unqualified_name): Use it.
      
      gcc/testsuite/ChangeLog:
      
      	* g++.dg/abi/anon6.C: New test.
      e1c8cf90
    • David Malcolm's avatar
      analyzer: fix deref-before-check false +ves seen in haproxy [PR108475,PR109060] · c4fd232f
      David Malcolm authored
      
      Integration testing showed various false positives from
      -Wanalyzer-deref-before-check where the expression that's dereferenced
      is different from the one that's checked, but the diagnostic is emitted
      because they both evaluate to the same symbolic value.
      
      This patch rejects such warnings, unless we have tree expressions for
      both and that both tree expressions are "spelled the same way" i.e.
      would be printed to the same user-facing string.
      
      gcc/analyzer/ChangeLog:
      	PR analyzer/108475
      	PR analyzer/109060
      	* sm-malloc.cc (deref_before_check::deref_before_check):
      	Initialize new field m_deref_expr.  Assert that arg is non-NULL.
      	(deref_before_check::emit): Reject cases where the spelling of the
      	thing that was dereferenced differs from that of what is checked,
      	or if the dereference expression was not found.  Remove code to
      	handle NULL m_arg.
      	(deref_before_check::describe_state_change): Remove code to handle
      	NULL m_arg.
      	(deref_before_check::describe_final_event): Likewise.
      	(deref_before_check::sufficiently_similar_p): New.
      	(deref_before_check::m_deref_expr): New field.
      	(malloc_state_machine::maybe_complain_about_deref_before_check):
      	Don't warn if the diag_ptr is NULL.
      
      gcc/testsuite/ChangeLog:
      	PR analyzer/108475
      	PR analyzer/109060
      	* gcc.dg/analyzer/deref-before-check-pr108475-1.c: New test.
      	* gcc.dg/analyzer/deref-before-check-pr108475-haproxy-tcpcheck.c:
      	New test.
      	* gcc.dg/analyzer/deref-before-check-pr109060-haproxy-cfgparse.c:
      	New test.
      
      Signed-off-by: default avatarDavid Malcolm <dmalcolm@redhat.com>
      c4fd232f
    • Jakub Jelinek's avatar
      range-op-float: Extend lhs by 0.5ulp rather than 1ulp if not -frounding-math [PR109008] · 44f80a37
      Jakub Jelinek authored
      This patch, incremental to the just posted one, improves the reverse
      operation ranges significantly by widening just by 0.5ulp in each
      direction rather than 1ulp.  Again, REAL_VALUE_TYPE has both wider
      exponent range and wider mantissa precision (160 bits) than any
      supported type, this patch uses the latter property.
      
      The patch doesn't do it if -frounding-math, because then the rounding
      can be +-1ulp in each direction depending on the rounding mode which
      we don't know, or for IBM double double because that type is just weird
      and we can't trust in sane properties.
      
      I've performed testing of these 2 patches on 300000 random tests as with
      yesterday's patch, exact numbers are in the PR, but I see very significant
      improvement in the precision of the ranges while keeping it conservatively
      correct.
      
      2023-03-10  Jakub Jelinek  <jakub@redhat.com>
      
      	PR tree-optimization/109008
      	* range-op-float.cc (float_widen_lhs_range): If not
      	-frounding-math and not IBM double double format, extend lhs
      	range just by 0.5ulp rather than 1ulp in each direction.
      44f80a37
    • Jonathan Wakely's avatar
      libstdc++: Fix GDB Xmethod for std::shared_ptr::use_count() [PR109064] · 37c8a083
      Jonathan Wakely authored
      libstdc++-v3/ChangeLog:
      
      	PR libstdc++/109064
      	* python/libstdcxx/v6/xmethods.py (SharedPtrUseCountWorker):
      	Remove self-recursion in __init__. Add missing _supports.
      	* testsuite/libstdc++-xmethods/shared_ptr.cc: Check use_count()
      	and unique().
      37c8a083
    • Jakub Jelinek's avatar
      cygwin: Don't try to support multilibs [PR107998] · e3f8dfcd
      Jakub Jelinek authored
      
      As discussed in the PR, t-cygwin-w64 file has been introduced in 2013
      and has one important problem, two different multilib options -m64 and -m32,
      but MULTILIB_DIRNAMES with just one word in it.
      Before the genmultilib sanity checking was added, my understanding is that
      this essentially resulted in effective --disable-multilib,
      $ gcc -print-multi-lib
      .;
      ;@m32
      $ gcc -print-multi-directory
      .
      $ gcc -print-multi-directory -m64
      .
      $ gcc -print-multi-directory -m32
      
      $ gcc -print-multi-os-directory
      ../lib
      $ gcc -print-multi-os-directory -m64
      ../lib
      $ gcc -print-multi-os-directory -m32
      ../lib32
      and because of the way e.g. config-ml.in operates
      multidirs=
      for i in `${CC-gcc} --print-multi-lib 2>/dev/null`; do
        dir=`echo $i | sed -e 's/;.*$//'`
        if [ "${dir}" = "." ]; then
          true
        else
          if [ -z "${multidirs}" ]; then
            multidirs="${dir}"
          else
            multidirs="${multidirs} ${dir}"
          fi
        fi
      done
      dir was . first time (and so nothing was done) and empty
      second time, multidirs empty too, so multidirs was set to empty
      like it would be with --disable-multilib.
      
      With the added sanity checking the build fails unless --disable-multilib
      is used in configure (dunno whether people usually configure that way
      on cygwin).
      
      >From what has been said in the PR, multilibs were not meant to be supported
      and e.g. cygwin headers probably aren't ready for it.
      
      So the following patch just removes the file with the (incorrect) multilib
      stuff instead of fixing it (say by setting MULTILIB_DIRNAMES to 64 32).
      
      I have no way to test this though, no Windows around, can anyone please
      test this?  I just would like to get some progress on the P1s we have...
      
      2023-02-22  Jakub Jelinek  <jakub@redhat.com>
      
      gcc/ChangeLog:
      
      	PR target/107998
      	* config.gcc (x86_64-*-cygwin*): Don't add i386/t-cygwin-w64 into
      	$tmake_file.
      	* config/i386/t-cygwin-w64: Remove.
      
      Signed-off-by: default avatarJonathan Yong <10walls@gmail.com>
      e3f8dfcd
    • Jakub Jelinek's avatar
      tree: Use comdat tree_code_{type,length} even for C++11/14 [PR108634] · 4c599ae6
      Jakub Jelinek authored
      The recent change to undo the tree_code_type/tree_code_length
      excessive duplication apparently broke building the Linux kernel
      plugin.  While it is certainly desirable that GCC plugins are built
      with the same compiler as GCC has been built and with the same options
      (at least the important ones), it might be hard to arrange that,
      e.g. if gcc is built using a cross-compiler but the plugin then built
      natively, or GCC isn't bootstrapped for other reasons, or just as in
      the kernel case they were building the plugin with -std=gnu++11 while
      the bootstrapped GCC has been built without any such option and so with
      whatever the compiler defaulted to.
      
      For C++17 and later tree_code_{type,length} are UNIQUE symbols with
      those assembler names, while for C++11/14 they were
      _ZL14tree_code_type and _ZL16tree_code_length.
      
      The following patch uses a comdat var for those even for C++11/14
      as suggested by Maciej Cencora.  Relying on weak attribute is not an
      option because not all hosts support it and there are non-GNU system
      compilers.  While we could use it unconditionally,
      I think defining a template just to make it comdat is weird, and
      the compiler itself is always built with the same compiler.
      Plugins, being separate shared libraries, will have a separate copy of
      the arrays if they are ODR-used in the plugin, so there is not a big
      deal if e.g. cc1plus uses tree_code_type while plugin uses
      _ZN19tree_code_type_tmplILi0EE14tree_code_typeE or vice versa.
      
      2023-03-10  Jakub Jelinek  <jakub@redhat.com>
      
      	PR plugins/108634
      	* tree-core.h (tree_code_type, tree_code_length): For C++11 or
      	C++14, don't declare as extern const arrays.
      	(tree_code_type_tmpl, tree_code_length_tmpl): New types with
      	static constexpr member arrays for C++11 or C++14.
      	* tree.h (TREE_CODE_CLASS): For C++11 or C++14 use
      	tree_code_type_tmpl <0>::tree_code_type instead of tree_code_type.
      	(TREE_CODE_LENGTH): For C++11 or C++14 use
      	tree_code_length_tmpl <0>::tree_code_length instead of
      	tree_code_length.
      	* tree.cc (tree_code_type, tree_code_length): Remove.
      4c599ae6
    • Jakub Jelinek's avatar
      file-prefix-map: Fix up -f*-prefix-map= [PR108464] · 2eb0191a
      Jakub Jelinek authored
      On Tue, Nov 01, 2022 at 01:46:20PM -0600, Jeff Law via Gcc-patches wrote:
      > > This does cause a change of behaviour if users were previously relying upon
      > > symlinks or absolute paths not being resolved.
      >
      > I'm not too worried about this scenario.
      
      As mentioned in the PR, this patch breaks e.g. ccache testsuite.
      
      I strongly doubt most of the users want such a behavior, because it
      makes all filenames absolute when -f*-prefix-map= options remap one
      absolute path to another one.
      Say if I'm in /tmp and /tmp is the canonical path and there is
      src/test.c file, with -fdebug-prefix-map=/tmp=/blah
      previously there would be DW_AT_comp_dir "/blah" and it is still there,
      but DW_AT_name which was previouly "src/test.c" (relative against
      DW_AT_comp_dir) is now "/blah/src/test.c" instead.
      
      Even worse, the canonicalization is only done on the remap_filename
      argument, but not on the old_prefix side.  That is e.g. what breaks
      ccache.  If there is
      /tmp/foobar1 directory and
      ln -sf foobar1 /tmp/foobar2
      cd /tmp/foobar2
      then -fdebug-prefix-map=`pwd`:/blah will just not work, while
      src/test.c will be canonicalized to /tmp/foobar1/src/test.c,
      old_prefix is still what the user provided which is /tmp/foobar2.
      User would need to change their uses to use -fdebug-prefix-map=`realpath $(pwd)`=/blah
      
      I've created 3 patches for this.
      
      The first patch just reverts the patch (and its follow-up patch).
      
      The second introduces a new option, -f{,no}-canon-prefix-map which affects
      the behavior of -f{file,macro,debug,profile}-prefix-map=, if on it
      canonicalizes the old path of the prefix map option and compares that
      against the canonicalized filename for absolute paths but not relative.
      
      And last is like the second, but does that also for relative paths except
      for filenames with no / (or / or \ on DOS based fs).  So, the third patch
      gets an optional behavior of what has been on the trunk lately with the
      difference that the old_prefix is canonicalized by the compiler.
      
      Initially I've thought I'd just add some magic syntax to the OLD=NEW
      argument of those options (because there are 4 of them), but as noted
      in the comments, = is valid char in OLD (just not new), so it would
      be hard to figure out some syntax.  So instead a new option, which one
      can turn on and off for different -f*-prefix-map= options if needed.
      
      -fdebug-prefix-map=/path1=/mypath1 -fcanon-prefix-map \
      -fdebug-prefix-map=/path2=/mypath2 -fno-canon-prefix-map \
      -fdebug-prefix-map=/path3=/mypath3
      
      will use the old behavior for the /path1 and /path3 handling and
      the new one only for /path2 handling.
      
      This commit is the third patch described above.
      
      2023-03-10  Jakub Jelinek  <jakub@redhat.com>
      
      	PR other/108464
      	* common.opt (fcanon-prefix-map): New option.
      	* opts.cc: Include file-prefix-map.h.
      	(flag_canon_prefix_map): New variable.
      	(common_handle_option): Handle OPT_fcanon_prefix_map.
      	(gen_command_line_string): Ignore OPT_fcanon_prefix_map.
      	* file-prefix-map.h (flag_canon_prefix_map): Declare.
      	* file-prefix-map.cc (struct file_prefix_map): Add canonicalize
      	member.
      	(add_prefix_map): Initialize canonicalize member from
      	flag_canon_prefix_map, and if true canonicalize it using lrealpath.
      	(remap_filename): Revert 2022-11-01 and 2022-11-07 changes,
      	use lrealpath result only for map->canonicalize map entries.
      	* lto-opts.cc (lto_write_options): Ignore OPT_fcanon_prefix_map.
      	* opts-global.cc (handle_common_deferred_options): Clear
      	flag_canon_prefix_map at the start and handle OPT_fcanon_prefix_map.
      	* doc/invoke.texi (-fcanon-prefix-map): Document.
      	(-ffile-prefix-map, -fdebug-prefix-map, -fprofile-prefix-map): Add
      	see also for -fcanon-prefix-map.
      	* doc/cppopts.texi (-fmacro-prefix-map): Likewise.
      2eb0191a
    • Jakub Jelinek's avatar
      c, c++, cgraphunit: Prevent duplicated -Wunused-value warnings [PR108079] · 2c63cc72
      Jakub Jelinek authored
      On the following testcase, we warn with -Wunused-value twice, once
      in the FEs and later on cgraphunit again with slightly different
      wording.
      
      The following patch fixes that by registering a warning suppression in the
      FEs when we warn and not warning in cgraphunit anymore if that happened.
      
      2023-03-10  Jakub Jelinek  <jakub@redhat.com>
      
      	PR c/108079
      gcc/
      	* cgraphunit.cc (check_global_declaration): Don't warn for unused
      	variables which have OPT_Wunused_variable warning suppressed.
      gcc/c/
      	* c-decl.cc (pop_scope): Suppress OPT_Wunused_variable warning
      	after diagnosing it.
      gcc/cp/
      	* decl.cc (poplevel): Suppress OPT_Wunused_variable warning
      	after diagnosing it.
      gcc/testsuite/
      	* c-c++-common/Wunused-var-18.c: New test.
      2c63cc72
    • Jakub Jelinek's avatar
      range-op-float: Fix up -ffinite-math-only range extension and don't extend... · a1d5c729
      Jakub Jelinek authored
      range-op-float: Fix up -ffinite-math-only range extension and don't extend into infinities [PR109008]
      
      The following patch does two things (both related to range extension
      around the boundaries).
      
      The first part (in the 2 real_isfinite blocks) is to make the ranges
      narrower when the old boundaries are minimum and/or maximum representable
      finite number.  In that case frange_nextafter gives -Inf or +Inf,
      but then the resulting computed reverse range is very far from the actually
      needed range, usually extends up to infinity or could even result in NaNs.
      While infinities are really the next representable numbers in the
      corresponding mode, REAL_VALUE_TYPE is actually a type with wider range
      for exponent and 160 bit precision, so the patch instead uses
      nextafter number in a hypothetical floating point format with the same
      mantissa precision but wider range of exponents.  This significantly
      improves the actual ranges of the reverse operations, while still making
      them conservatively correct.
      
      The second part is a fix for miscompilation of the new testcase below.
      For -ffinite-math-only, without this patch we extend the minimum and/or
      maximum representable finite number to -Inf or +Inf, with the patch to
      some number outside of the normal exponent range of the mode, but then
      we use set which canonicalizes it and turns the boundaries back to
      the minimum and/or maximum representable finite numbers, but because
      in say [__DBL_MAX__, __DBL_MAX__] = op1 + [__DBL_MAX__, __DBL_MAX__]
      op1 can be larger than 0, up to the largest number which rounds to even
      down back to __DBL_MAX__ and there are still no infinities involved,
      it needs to work even with -ffinite-math-only.  So, we really need to
      widen the lhs range a little bit even in that case.  The patch does
      that through temporarily clearing -ffinite-math-only, such that the
      value with infinities or the outside of bounds values passes the
      setting and verification (the VR_VARYING case is needed because
      we get ICEs otherwise, but when lhs is VR_VARYING in -ffast-math,
      i.e. minimum to maximum representable finite and both signs of NaN,
      then set does all we need, we don't need to or in a NaN range).
      We don't really later use the range in a way that would become a problem
      that it is wider than varying, we actually just perform maths on the
      two boundaries.
      
      As I said in the PR, this doesn't fix the !MODE_HAS_INFINITIES case,
      I believe we actually need to treat the boundary values as infinities
      in that case because they (probably) work like that, but it is unclear
      if it is just the reverse operation lhs widening that is a problem there,
      or whether it is a general problem.  I have zero experience with
      floating points without infinities (PDP11, some ARM half type?,
      what else?).
      
      2023-03-10  Jakub Jelinek  <jakub@redhat.com>
      
      	PR tree-optimization/109008
      	* range-op-float.cc (float_widen_lhs_range): If lb is
      	minimum representable finite number or ub is maximum
      	representable finite number, instead of widening it to
      	-inf or inf widen it to negative or positive 0x0.8p+(EMAX+1).
      	Temporarily clear flag_finite_math_only when canonicalizing
      	the widened range.
      
      	* gcc.dg/pr109008.c: New test.
      a1d5c729
    • Ju-Zhe Zhong's avatar
      RISC-V: Add fault first load C/C++ support · 60bd33bc
      Ju-Zhe Zhong authored
      gcc/ChangeLog:
      
      	* config/riscv/riscv-builtins.cc (riscv_gimple_fold_builtin): New function.
      	* config/riscv/riscv-protos.h (riscv_gimple_fold_builtin): Ditto.
      	(gimple_fold_builtin):  Ditto.
      	* config/riscv/riscv-vector-builtins-bases.cc (class read_vl): New class.
      	(class vleff): Ditto.
      	(BASE): Ditto.
      	* config/riscv/riscv-vector-builtins-bases.h: Ditto.
      	* config/riscv/riscv-vector-builtins-functions.def (read_vl): Ditto.
      	(vleff): Ditto.
      	* config/riscv/riscv-vector-builtins-shapes.cc (struct read_vl_def): Ditto.
      	(struct fault_load_def): Ditto.
      	(SHAPE): Ditto.
      	* config/riscv/riscv-vector-builtins-shapes.h: Ditto.
      	* config/riscv/riscv-vector-builtins.cc
      	(rvv_arg_type_info::get_tree_type): Add size_ptr.
      	(gimple_folder::gimple_folder): New class.
      	(gimple_folder::fold): Ditto.
      	(gimple_fold_builtin): New function.
      	(get_read_vl_instance): Ditto.
      	(get_read_vl_decl): Ditto.
      	* config/riscv/riscv-vector-builtins.def (size_ptr): Add size_ptr.
      	* config/riscv/riscv-vector-builtins.h (class gimple_folder): New class.
      	(get_read_vl_instance): New function.
      	(get_read_vl_decl):  Ditto.
      	* config/riscv/riscv-vsetvl.cc (fault_first_load_p): Ditto.
      	(read_vl_insn_p): Ditto.
      	(available_occurrence_p): Ditto.
      	(backward_propagate_worthwhile_p): Ditto.
      	(gen_vsetvl_pat): Adapt for vleff support.
      	(get_forward_read_vl_insn): New function.
      	(get_backward_fault_first_load_insn): Ditto.
      	(source_equal_p): Adapt for vleff support.
      	(first_ratio_invalid_for_second_sew_p): Remove.
      	(first_ratio_invalid_for_second_lmul_p): Ditto.
      	(first_lmul_less_than_second_lmul_p): Ditto.
      	(first_ratio_less_than_second_ratio_p): Ditto.
      	(support_relaxed_compatible_p): New function.
      	(vector_insn_info::operator>): Remove.
      	(vector_insn_info::operator>=): Refine.
      	(vector_insn_info::parse_insn): Adapt for vleff support.
      	(vector_insn_info::compatible_p): Ditto.
      	(vector_insn_info::update_fault_first_load_avl): New function.
      	(pass_vsetvl::transfer_after): Adapt for vleff support.
      	(pass_vsetvl::demand_fusion): Ditto.
      	(pass_vsetvl::cleanup_insns): Ditto.
      	* config/riscv/riscv-vsetvl.def (DEF_INCOMPATIBLE_COND): Remove
      	redundant condtions.
      	* config/riscv/riscv-vsetvl.h (struct demands_cond): New function.
      	* config/riscv/riscv.cc (TARGET_GIMPLE_FOLD_BUILTIN): New target hook.
      	* config/riscv/riscv.md: Adapt for vleff support.
      	* config/riscv/t-riscv: Ditto.
      	* config/riscv/vector-iterators.md: New iterator.
      	* config/riscv/vector.md (read_vlsi): New pattern.
      	(read_vldi_zero_extend): Ditto.
      	(@pred_fault_load<mode>): Ditto.
      60bd33bc
    • Ju-Zhe Zhong's avatar
      Extend nops num in "maybe_gen_insn" for RISC-V Vector intrinsics · a803c268
      Ju-Zhe Zhong authored
      Hi, current maybe_gen_insn can only expand 9 nops.
      For RVV intrinsics, I need to extend it as 10, otherwise I should use GEN_FCN.
      This patch is quite obvious change, Ok for trunk ?
      
      Thanks.
      
      gcc/ChangeLog:
      
      	* config/riscv/riscv-vector-builtins.cc
      	(function_expander::use_ternop_insn): Use maybe_gen_insn instead.
      	(function_expander::use_widen_ternop_insn): Ditto.
      	* optabs.cc (maybe_gen_insn): Extend nops handling.
      a803c268
    • Ju-Zhe Zhong's avatar
      RISC-V: Fine tune merge operand constraint for integer/load/store · ab7bb445
      Ju-Zhe Zhong authored
      gcc/ChangeLog:
      
      	* config/riscv/riscv-vector-builtins-bases.cc: Split indexed load
      	patterns according to RVV ISA.
      	* config/riscv/vector-iterators.md: New iterators.
      	* config/riscv/vector.md
      	(@pred_indexed_<order>load<VNX1_QHSD:mode><VNX1_QHSDI:mode>): Remove.
      	(@pred_indexed_<order>load<mode>_same_eew): New pattern.
      	(@pred_indexed_<order>load<mode>_x2_greater_eew): Ditto.
      	(@pred_indexed_<order>load<mode>_x4_greater_eew): Ditto.
      	(@pred_indexed_<order>load<mode>_x8_greater_eew): Ditto.
      	(@pred_indexed_<order>load<mode>_x2_smaller_eew): Ditto.
      	(@pred_indexed_<order>load<mode>_x4_smaller_eew): Ditto.
      	(@pred_indexed_<order>load<mode>_x8_smaller_eew): Ditto.
      	(@pred_indexed_<order>load<VNX2_QHSD:mode><VNX2_QHSDI:mode>): Remove.
      	(@pred_indexed_<order>load<VNX4_QHSD:mode><VNX4_QHSDI:mode>): Ditto.
      	(@pred_indexed_<order>load<VNX8_QHSD:mode><VNX8_QHSDI:mode>): Ditto.
      	(@pred_indexed_<order>load<VNX16_QHS:mode><VNX16_QHSI:mode>): Ditto.
      	(@pred_indexed_<order>load<VNX32_QH:mode><VNX32_QHI:mode>): Ditto.
      	(@pred_indexed_<order>load<VNX64_Q:mode><VNX64_Q:mode>): Ditto.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.target/riscv/rvv/base/merge_constraint-1.c: New test.
      ab7bb445
    • Michael Collison's avatar
      [PATCH v2] vect: Check that vector factor is a compile-time constant · 2dc73876
      Michael Collison authored
      	* tree-vect-loop-manip.cc (vect_do_peeling): Use
      	result of constant_lower_bound instead of vf for the lower
      	bound of the epilog loop trip count.
      2dc73876
    • Jason Merrill's avatar
      c++: signed __int128_t [PR108099] · 2fc55f51
      Jason Merrill authored
      The code for handling signed + typedef was breaking on __int128_t, because
      it isn't a proper typedef: it doesn't have DECL_ORIGINAL_TYPE.
      
      	PR c++/108099
      
      gcc/cp/ChangeLog:
      
      	* decl.cc (grokdeclarator): Handle non-typedef typedef_decl.
      
      gcc/testsuite/ChangeLog:
      
      	* g++.dg/ext/int128-7.C: New test.
      2fc55f51
    • Jason Merrill's avatar
      c++: overloaded fn in contract [PR108542] · 68c5d92a
      Jason Merrill authored
      	PR c++/108542
      
      gcc/cp/ChangeLog:
      
      	* class.cc (instantiate_type): Strip location wrapper.
      
      gcc/testsuite/ChangeLog:
      
      	* g++.dg/contracts/contracts-err1.C: New test.
      68c5d92a
    • GCC Administrator's avatar
      Daily bump. · da2b9c6e
      GCC Administrator authored
      da2b9c6e
  2. Mar 09, 2023
    • Jason Merrill's avatar
      c++: allocator temps in list of arrays [PR108773] · e0324e26
      Jason Merrill authored
      The optimization to reuse the same allocator temporary for all string
      constructor calls was breaking on this testcase, because the temps were
      already in the argument to build_vec_init, and replacing them with
      references to one slot got confused with calls at multiple levels (for the
      initializer_list backing array, and then again for the array member of the
      std::array).  Fixed by reusing the whole TARGET_EXPR instead of pulling out
      the slot; gimplification ensures that it's only initialized once.
      
      I also moved the check for initializing a std:: class down into the tree
      walk, and handle multiple temps within a single array element
      initialization.
      
      	PR c++/108773
      
      gcc/cp/ChangeLog:
      
      	* init.cc (find_allocator_temps_r): New.
      	(combine_allocator_temps): Replace find_allocator_temp.
      	(build_vec_init): Adjust.
      
      gcc/testsuite/ChangeLog:
      
      	* g++.dg/cpp0x/initlist-array18.C: New test.
      	* g++.dg/cpp0x/initlist-array19.C: New test.
      e0324e26
    • David Malcolm's avatar
      testsuite: add various -Wanalyzer-null-dereference false +ve test cases · 4214bdb1
      David Malcolm authored
      
      There are various -Wanalyzer-null-dereference false +ves in bugzilla
      that I've been attempting to fix.  Unfortunately I haven't made much
      progress, but it seems worth at least capturing the reduced
      reproducers as test cases, to make it easier to spot changes in
      behavior.
      
      gcc/testsuite/ChangeLog:
      	PR analyzer/102671
      	PR analyzer/105755
      	PR analyzer/108251
      	PR analyzer/108400
      	* gcc.dg/analyzer/null-deref-pr102671-1.c: New test, reduced
      	from Emacs.
      	* gcc.dg/analyzer/null-deref-pr102671-2.c: Likewise.
      	* gcc.dg/analyzer/null-deref-pr105755.c: Likewise.
      	* gcc.dg/analyzer/null-deref-pr108251-smp_fetch_ssl_fc_has_early-O2.c:
      	New test, reduced from haproxy's src/ssl_sample.c.
      	* gcc.dg/analyzer/null-deref-pr108251-smp_fetch_ssl_fc_has_early.c:
      	Likewise.
      	* gcc.dg/analyzer/null-deref-pr108400-SoftEtherVPN-WebUi.c: New
      	test, reduced from SoftEtherVPN's src/Cedar/WebUI.c.
      
      Signed-off-by: default avatarDavid Malcolm <dmalcolm@redhat.com>
      4214bdb1
    • Tamar Christina's avatar
      middle-end: On emergency dumps finish the graph generation. · ec4bc86b
      Tamar Christina authored
      When doing an emergency dump the cfg output dumps are corrupted because the
      ending "}" is missing.
      
      Normally when the pass manager finishes it would call finish_graph_dump_file to
      produce this.  This is called here because each pass can dump multiple digraphs.
      
      However during an emergency dump we only dump the current function and so after
      that is done we never go back to the pass manager.
      
      As such, we need to manually call finish_graph_dump_file in order to properly
      finish off graph generation.
      
      With this -ftree-dump-*-graph works properly during a crash dump.
      
      gcc/ChangeLog:
      
      	* passes.cc (emergency_dump_function): Finish graph generation.
      ec4bc86b
    • Tamar Christina's avatar
      AArch64: Fix codegen regressions around tbz. · 8e26ac47
      Tamar Christina authored
      We were analyzing code quality after recent changes and have noticed that the
      tbz support somehow managed to increase the number of branches overall rather
      than decreased them.
      
      While investigating this we figured out that the problem is that when an
      existing & <contants> exists in gimple and the instruction is generated because
      of the range information gotten from the ANDed constant that we end up with the
      situation that you get a NOP AND in the RTL expansion.
      
      This is not a problem as CSE will take care of it normally.   The issue is when
      this original AND was done in a location where PRE or FRE "lift" the AND to a
      different basic block.  This triggers a problem when the resulting value is not
      single use.  Instead of having an AND and tbz, we end up generating an
      AND + TST + BR if the mode is HI or QI.
      
      This CSE across BB was a problem before but this change made it worse. Our
      branch patterns rely on combine being able to fold AND or zero_extends into the
      instructions.
      
      To work around this (since a proper fix is outside of the scope of stage-4) we
      are limiting the new tbranch optab to only HI and QI mode values.  This isn't a
      problem because these two modes are modes for which we don't have CBZ support,
      so they are the problematic cases to begin with.  Additionally booleans are QI.
      
      The second thing we're doing is limiting the only legal bitpos to pos 0. i.e.
      only the bottom bit.  This such that we prevent the double ANDs as much as
      possible.
      
      Now most other cases, i.e. where we had an explicit & in the source code are
      still handled correctly by the anonymous (*tb<optab><ALLI:mode><GPI:mode>1)
      pattern that was added along with tbranch support.
      
      This means we don't expand the superflous AND here, and while it doesn't fix the
      problem that in the cross BB case we loss tbz, it also doesn't make things worse.
      
      With these tweaks we've now reduced the number of insn uniformly was originally
      expected.
      
      gcc/ChangeLog:
      
      	* config/aarch64/aarch64.md (tbranch_<code><mode>3): Restrict to SHORT
      	and bottom bit only.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.target/aarch64/tbz_2.c: New test.
      	* gcc.target/aarch64/tbz_3.c: New test.
      8e26ac47
    • Patrick Palka's avatar
      libstdc++: Implement LWG 3820/3849 changes to cartesian_product_view · 96abc822
      Patrick Palka authored
      The LWG 3820 testcase revealed a bug in _M_advance, which this patch
      also fixes.
      
      libstdc++-v3/ChangeLog:
      
      	* include/std/ranges
      	(cartesian_product_view::_Iterator::_Iterator): Remove
      	constraint on default constructor as per LWG 3849.
      	(cartesian_product_view::_Iterator::_M_prev): Adjust position
      	of _Nm > 0 test as per LWG 3820.
      	(cartesian_product_view::_Iterator::_M_advance): Perform bounds
      	checking only on sized cartesian products.
      	* testsuite/std/ranges/cartesian_product/1.cc (test08): New test.
      96abc822
    • Patrick Palka's avatar
      libstdc++: Implement LWG 3796 changes to repeat_/chunk_by_view [PR109024] · 065c93b8
      Patrick Palka authored
      	PR libstdc++/109024
      
      libstdc++-v3/ChangeLog:
      
      	* include/std/ranges (chunk_by_view::_M_pred): Remove DMI as per
      	LWG 3796.
      	(repeat_view::_M_pred): Likewise.
      	* testsuite/std/ranges/adaptors/chunk_by/1.cc (test03): New test.
      	* testsuite/std/ranges/repeat/1.cc (test05): New test.
      065c93b8
    • Patrick Palka's avatar
      libstdc++: Make views::single/iota/istream SFINAE-friendly [PR108362] · 95827e1b
      Patrick Palka authored
      	PR libstdc++/108362
      
      libstdc++-v3/ChangeLog:
      
      	* include/std/ranges (__detail::__can_single_view): New concept.
      	(_Single::operator()): Constrain it.  Move [[nodiscard]] to the
      	end of the function declarator.
      	(__detail::__can_iota_view): New concept.
      	(_Iota::operator()): Constrain it.  Move [[nodiscard]] to the
      	end of the function declarator.
      	(__detail::__can_istream_view): New concept.
      	(_Istream::operator()): Constrain it.  Move [[nodiscard]] to the
      	end of the function declarator.
      	* testsuite/std/ranges/iota/iota_view.cc (test07): New test.
      	* testsuite/std/ranges/istream_view.cc (test08): New test.
      	* testsuite/std/ranges/single_view.cc (test07): New test.
      95827e1b
    • Andrew Pinski's avatar
      Fix PR 108980: note without warning due to array bounds check · c6232ba2
      Andrew Pinski authored
      The problem here is after r13-4748-g2a27ae32fabf85, in some
      cases we were calling inform without a corresponding warning.
      This changes the logic such that we only cause that to happen
      if there was a warning happened before hand.
      
      Changes since
      * v1: Fix formating and dump message as suggested by Jakub.
      
      OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.
      
      gcc/ChangeLog:
      
      	PR tree-optimization/108980
      	* gimple-array-bounds.cc (array_bounds_checker::check_array_ref):
      	Reorgnize the call to warning for not strict flexible arrays
      	to be before the check of warned.
      c6232ba2
    • Patrick Palka's avatar
      libstdc++: extraneous begin in cartesian_product_view::end [PR107572] · 3df9760d
      Patrick Palka authored
      ranges::begin() isn't guaranteed to be equality-preserving for non-forward
      ranges, so in cartesian_product_view::end we need to avoid needlessly
      calling begin() on the first range (which could be non-forward) in the
      case where __empty_tail is false as per its specification.
      
      Since we're already using a variadic lambda to compute __empty_tail, we
      might as well use that same lambda to build up the tuple of iterators
      instead of building it separately via e.g. std::apply or __tuple_transform.
      
      	PR libstdc++/107572
      
      libstdc++-v3/ChangeLog:
      
      	* include/std/ranges (cartesian_product_view::end): When
      	building the tuple of iterators, avoid calling ranges::begin on
      	the first range if __empty_tail is false.
      	* testsuite/std/ranges/cartesian_product/1.cc (test07): New test.
      3df9760d
    • Jonathan Wakely's avatar
      libstdc++: Really fix symver for __gnu_cxx11_ieee128::__try_use_facet [PR108882] · f366fdfe
      Jonathan Wakely authored
      libstdc++-v3/ChangeLog:
      
      	PR libstdc++/108882
      	* config/os/gnu-linux/ldbl-ieee128-extra.ver: Fix incorrect
      	patterns.
      f366fdfe
    • Jason Merrill's avatar
      c++: CTAD for less-specialized alias template [PR102529] · afe1f0c2
      Jason Merrill authored
      The standard was unclear what happens with the transformation of a deduction
      guide if the initial template argument deduction fails for a reason other
      than not deducing all the arguments; my implementation assumed that the
      right thing was to give up on the deduction guide.  But in consideration of
      CWG2664 this week I realized that we get a better result by just continuing
      with an empty set of deductions, so the alias deduction guide is the same as
      the original deduction guide plus the deducible constraint.
      
      	DR 2664
      	PR c++/102529
      
      gcc/cp/ChangeLog:
      
      	* pt.cc (alias_ctad_tweaks): Continue after deduction failure.
      
      gcc/testsuite/ChangeLog:
      
      	* g++.dg/DRs/dr2664.C: New test.
      	* g++.dg/cpp2a/class-deduction-alias15.C: New test.
      afe1f0c2
    • Jason Merrill's avatar
      c++: fix alias CTAD [PR105841] · 9e617009
      Jason Merrill authored
      
      In my initial implementation of alias CTAD, I described a couple of
      differences from the specification that I thought would not have a practical
      effect; this testcase demonstrates that I was wrong.  One difference is
      resolved by the CPTK_IS_DEDUCIBLE commit; the other (adding too many of the
      alias template parameters to the new deduction guide) is fixed by this
      patch.
      
      	PR c++/105841
      
      gcc/cp/ChangeLog:
      
      	* pt.cc	(corresponding_template_parameter_list): Split out...
      	(corresponding_template_parameter): ...from here.
      	(find_template_parameters): Factor out...
      	(find_template_parameter_info::find_in): ...this function.
      	(find_template_parameter_info::find_in_recursive): New.
      	(find_template_parameter_info::found): New.
      	(alias_ctad_tweaks): Only add parms used in the deduced args.
      
      gcc/testsuite/ChangeLog:
      
      	* g++.dg/cpp2a/class-deduction-alias14.C: New test.
      
      Co-authored-by: default avatarMichael Spertus <mike@spertus.com>
      9e617009
    • Jason Merrill's avatar
      c++: hide __is_deducible for GCC 13 · 30556bf8
      Jason Merrill authored
      I want to have more discussion about the interface before claiming the
      __is_deducible name, so for GCC 13 make it internal-only.
      
      gcc/ChangeLog:
      
      	* doc/extend.texi: Comment out __is_deducible docs.
      
      gcc/cp/ChangeLog:
      
      	* cp-trait.def (IS_DEDUCIBLE): Add space to name.
      
      gcc/testsuite/ChangeLog:
      
      	* g++.dg/ext/is_deducible1.C: Guard with
      	__has_builtin (__is_deducible).
      30556bf8
    • Jason Merrill's avatar
      c++: add __is_deducible trait [PR105841] · 148cbb15
      Jason Merrill authored
      C++20 class template argument deduction for an alias template involves
      adding a constraint that the template arguments for the alias template can
      be deduced from the return type of the deduction guide for the underlying
      class template.  In the standard, this is modeled as defining a class
      template with a partial specialization, but it's much more efficient to
      implement with a trait that directly tries to perform the deduction.
      
      The first argument to the trait is a template rather than a type, so various
      places needed to be adjusted to accommodate that.
      
      	PR c++/105841
      
      gcc/ChangeLog:
      
      	* doc/extend.texi (Type Traits):: Document __is_deducible.
      
      gcc/cp/ChangeLog:
      
      	* cp-trait.def (IS_DEDUCIBLE): New.
      	* cxx-pretty-print.cc (pp_cxx_trait): Handle non-type.
      	* parser.cc (cp_parser_trait): Likewise.
      	* tree.cc (cp_tree_equal): Likewise.
      	* pt.cc (tsubst_copy_and_build): Likewise.
      	(type_targs_deducible_from): New.
      	(alias_ctad_tweaks): Use it.
      	* semantics.cc (trait_expr_value): Handle CPTK_IS_DEDUCIBLE.
      	(finish_trait_expr): Likewise.
      	* constraint.cc (diagnose_trait_expr): Likewise.
      	* cp-tree.h (type_targs_deducible_from): Declare.
      
      gcc/testsuite/ChangeLog:
      
      	* g++.dg/ext/is_deducible1.C: New test.
      148cbb15
    • Costas Argyris's avatar
      Enable UTF-8 code page on Windows 64-bit host [PR108865] · d11e0882
      Costas Argyris authored
      
      Compile a resource object that contains the utf8 manifest.
      
      Then link that object into the driver and compiler proper.
      
      For compiler proper the link has to be forced because the
      resource object file gets into a static library (libbackend.a)
      and gets eventually dropped because it has no symbols of
      its own and nothing is referencing it inside the library.
      
      Therefore, an artificial symbol is planted to force the link.
      
      gcc/ChangeLog:
      
      	PR driver/108865
      	* config.host: add object for x86_64-*-mingw*.
      	* config/i386/sym-mingw32.cc: dummy file to attach
      	symbol.
      	* config/i386/utf8-mingw32.rc: windres resource file.
      	* config/i386/winnt-utf8.manifest: XML manifest to
      	enable UTF-8.
      	* config/i386/x-mingw32: reference to x-mingw32-utf8.
      	* config/i386/x-mingw32-utf8: Makefile fragment to
      	embed UTF-8 manifest.
      
      Signed-off-by: default avatarJonathan Yong <10walls@gmail.com>
      d11e0882
    • Vladimir N. Makarov's avatar
      LRA: For clobbered regs use operand mode instead of the biggest mode · a6457974
      Vladimir N. Makarov authored
      LRA is too conservative in calculation of conflicts with clobbered regs by
      using the biggest access mode.  This results in failure of possible reg
      coalescing and worse code.  This patch solves the problem.
      
              PR rtl-optimization/108999
      
      gcc/ChangeLog:
      
      	* lra-constraints.cc (process_alt_operands): Use operand modes for
      	clobbered regs instead of the biggest access mode.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.target/aarch64/pr108999.c: New.
      a6457974
    • Richard Biener's avatar
      middle-end/108995 - avoid folding when sanitizing overflow · ace65db9
      Richard Biener authored
      The following plugs one place in extract_muldiv where it should avoid
      folding when sanitizing overflow.
      
      	PR middle-end/108995
      	* fold-const.cc (extract_muldiv_1): Avoid folding
      	(CST * b) / CST2 when sanitizing overflow and we rely on
      	overflow being undefined.
      
      	* gcc.dg/ubsan/pr108995.c: New testcase.
      ace65db9
    • Jakub Jelinek's avatar
      range-op-float: Fix up reverse binary operations [PR109008] · bad177e8
      Jakub Jelinek authored
      The following testcase is reduced from miscompilation of scipy package.
      If we have say lhs = [1., 1.] - [1., 1.] and want to compute the range
      of lhs from it, we correctly determine it is [0., 0.] (if computations
      are exact, we generally don't try to round them further in
      frange_arithmetic).  In the testcase it is about a reverse operation,
      [1., 1.] = op1 + [1., 1.] and we want to compute range of op1 from that.
      Right now we just perform the inverse operation (there are some corner
      cases about NaN and infinities handling) and so arrive to range
      [0., 0.] as well, and because it is a singleton, optimize return eps;
      to return 0.  That is incorrect though, for the reverse ops we need to
      take into account also rounding, the right exact range is
      [-0x1.0p-54, 0x1.0p-53] in this case when rounding to nearest, i.e.
      all numbers which added to 1. with round to nearest still produce 1.
      
      The problem isn't solely on singleton ranges, and isn't solely on
      results around zero.  We basically need to consider also values
      where the result is up to 0.5ulp away from the lhs range boundaries
      in each direction.
      
      The following patch fixes it by extending the lhs range for the
      reverse operations by 1ulp in each direction.  The PR contains
      a pseudo-random test generator I've used to generate 300000 tests
      of + and - and then used the same test with * and / instead of + and -
      together with a hack to print the discovered ranges by the patch in
      a form that another test could then verify the range is conservatively
      correct and how far it is from a minimal range.
      
      I believe the results are good enough for now, though plan to look
      incrementally into trying to do something better on the -XXX_MAX or
      XXX_MAX boundaries (where I think frange_nextafter will use -inf or +inf)
      and also try to increase the range just by 0.5ulp rather than 1ulp
      if !flag_rounding_math.  But dunno if either of those will be doable
      and will pass the testing, so I think it is worth committing this fix
      first.
      
      2023-03-09  Jakub Jelinek  <jakub@redhat.com>
      	    Richard Biener  <rguenther@suse.de>
      
      	PR tree-optimization/109008
      	* range-op-float.cc (float_widen_lhs_range): New function.
      	(foperator_plus::op1_range, foperator_minus::op1_range,
      	foperator_minus::op2_range, foperator_mult::op1_range,
      	foperator_div::op1_range, foperator_div::op2_range): Use it.
      
      	* gcc.c-torture/execute/ieee/pr109008.c: New test.
      bad177e8
    • Hongyu Wang's avatar
      libgomp: Fix default value of GOMP_SPINCOUNT [PR 109062] · 288bc7b5
      Hongyu Wang authored
      When OMP_WAIT_POLICY is not specified, current implementation will cause
      icv flag GOMP_ICV_WAIT_POLICY unset, so global variable wait_policy
      will remain its uninitialized value. Initialize it to -1 to make
      GOMP_SPINCOUNT behavior consistent with its description.
      
      libgomp/ChangeLog:
      
      	PR libgomp/109062
      	* env.c (wait_policy): Initialize to -1.
      	(initialize_icvs): Initialize icvs->wait_policy to -1.
      	* testsuite/libgomp.c-c++-common/pr109062.c: New test.
      288bc7b5
    • GCC Administrator's avatar
      Daily bump. · 6a87fdd3
      GCC Administrator authored
      6a87fdd3
  3. Mar 08, 2023
    • Tobias Burnus's avatar
      libgomp.texi: Mention GCN_STACK_SIZE in Offload-Target Specifics · 2e3dd14d
      Tobias Burnus authored
      libgomp/ChangeLog:
      
      	* libgomp.texi (Offload-Target Specifics): Mention GCN_STACK_SIZE.
      2e3dd14d
    • Kewen Lin's avatar
      libgcc, rs6000: Fix bump size for powerpc64 elfv1 ABI [PR108727] · 15b83b69
      Kewen Lin authored
      As PR108727 shows, when cleanup code called by the stack
      unwinder calls function _Unwind_Resume, it goes via plt
      stub like:
      
         function 00000000.plt_call._Unwind_Resume:
      
      => 0x0000000010003580 <+0>:     std     r2,40(r1)
         0x0000000010003584 <+4>:     ld      r12,-31760(r2)
         0x0000000010003588 <+8>:     mtctr   r12
         0x000000001000358c <+12>:    ld      r2,-31752(r2)
         0x0000000010003590 <+16>:    cmpldi  r2,0
         0x0000000010003594 <+20>:    bnectr+
         0x0000000010003598 <+24>:    b       0x100031a4
                                              <_Unwind_Resume@plt>
      
      It wants to save TOC base (r2) to r1 + 40, but we only
      bump the stack segment by 32 bytes as follows:
      
         stdu %r29,-32(%r3)
      
      It means the access is out of the stack segment allocated
      by __generic_morestack, once the touch area isn't writable
      like this failure shows, it would cause segment fault.
      
      So fix the bump size with one reasonable value PARAMS.
      
      	PR libgcc/108727
      
      libgcc/ChangeLog:
      
      	* config/rs6000/morestack.S (__morestack): Use PARAMS for new stack
      	bump size.
      15b83b69
    • Kewen Lin's avatar
      testsuite: Adjust powerpc ppc-fortran.exp to support dg-{warning,error} · 2a2a159f
      Kewen Lin authored
      According to Haochen's finding in [1], currently ppc-fortran.exp
      doesn't support Fortran specific warning or error messages well.
      By looking into it, it's due to that gfortran uses some different
      warning/error prefixes as follows:
      
          set gcc_warning_prefix "\[Ww\]arning:"
          set gcc_error_prefix "(Fatal )?\[Ee\]rror:"
      
      comparing to:
      
          set gcc_warning_prefix "warning:"
          set gcc_error_prefix "(fatal )?error:"
      
      So this is to override these two prefixes and make it support
      dg-{warning,error} checks.
      
      [1] https://gcc.gnu.org/pipermail/gcc-patches/2023-March/613302.html
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.target/powerpc/ppc-fortran/ppc-fortran.exp: Override
      	gcc_{warning,error}_prefix with Fortran specific one used in
      	gfortran_init.
      2a2a159f
Loading