Skip to content
Snippets Groups Projects
  1. Nov 16, 2021
    • Iain Sandoe's avatar
      PCH: Make the save and restore diagnostics more robust. · e4641191
      Iain Sandoe authored
      
      When saving, if we cannot obtain a suitable memory segment there
      is no point in continuing, so exit with an error.
      
      When reading in the PCH, we have a situation that the read-in
      data will replace the line tables used by the diagnostics output.
      However, the state of the read-oin line tables is indeterminate
      at some points where diagnostics might be needed.
      
      To make this more robust, we save the existing line tables at
      the start and, once we have read in the pointer to the new one,
      put that to one side and restore the original table.  This
      avoids compiler hangs if the read or memory acquisition code
      issues an assert, fatal_error, segv etc.
      
      Once the read is complete, we swap in the new line table that
      came from the PCH.
      
      If the read-in PCH is corrupted then we still have a broken
      compilation w.r.t any future diagnostics - but there is little
      that can be done about that without more careful validation of
      the file.
      
      Signed-off-by: default avatarIain Sandoe <iain@sandoe.co.uk>
      
      gcc/ChangeLog:
      
      	* ggc-common.c (gt_pch_save): If we cannot find a suitable
      	memory segment for save, then error-out, do not try to
      	continue.
      	(gt_pch_restore): Save the existing line table, and when
      	the replacement is being read, use that when constructing
      	diagnostics.
      e4641191
    • Peter Bergner's avatar
      rs6000: MMA test case emits wrong code when building a vector pair [PR102976] · 4cdf7db9
      Peter Bergner authored
      PR102976 shows a test case where we generate wrong code when building
      a vector pair from 2 vector registers.  The bug here is that with unlucky
      register assignments, we can clobber one of the input operands before
      we write both registers of the output operand.  The solution is to use
      early-clobbers in the assemble pair and accumulator patterns.
      
      2021-11-16  Peter Bergner  <bergner@linux.ibm.com>
      
      gcc/
      	PR target/102976
      	* config/rs6000/mma.md (*vsx_assemble_pair): Add early-clobber for
      	output operand.
      	(*mma_assemble_acc): Likewise.
      
      gcc/testsuite/
      	PR target/102976
      	* gcc.target/powerpc/pr102976.c: New test.
      4cdf7db9
    • Mikael Morin's avatar
      fortran: Identify arguments by their names · 48a8c5be
      Mikael Morin authored
      This provides a new function to get the name of a dummy argument,
      so that identifying an argument can be made using just its name
      instead of a mix of name matching (for keyword actual arguments)
      and argument counting (for other actual arguments).
      
      gcc/fortran/ChangeLog:
      	* interface.c (gfc_dummy_arg_get_name): New function.
      	* gfortran.h (gfc_dummy_arg_get_name): Declare it.
      	* trans-array.c (arg_evaluated_for_scalarization): Pass a dummy
      	argument wrapper as argument instead of an actual argument
      	and an index number.  Check it’s non-NULL.  Use its name
      	to identify it.
      	(gfc_walk_elemental_function_args): Update call to
      	arg_evaluated for scalarization.  Remove argument counting.
      48a8c5be
    • Mikael Morin's avatar
      fortran: Delete redundant missing_arg_type field · e94e2cf9
      Mikael Morin authored
      Now that we can get information about an actual arg's associated
      dummy using the associated_dummy attribute, the field missing_arg_type
      contains redundant information.
      This removes it.
      
      gcc/fortran/ChangeLog:
      	* gfortran.h (gfc_actual_arglist::missing_arg_type): Remove.
      	* interface.c (gfc_compare_actual_formal): Remove
      	missing_arg_type initialization.
      	* intrinsic.c (sort_actual): Ditto.
      	* trans-expr.c (gfc_conv_procedure_call): Use associated_dummy
      	and gfc_dummy_arg_get_typespec to get the dummy argument type.
      e94e2cf9
    • Mikael Morin's avatar
      fortran: simplify elemental arguments walking · 5d9d16db
      Mikael Morin authored
      This adds two functions working with the wrapper struct gfc_dummy_arg
      and makes usage of them to simplify a bit the walking of elemental
      procedure arguments for scalarization.  As information about dummy arguments
      can be obtained from the actual argument through the just-introduced
      associated_dummy field, there is no need to carry around the procedure
      interface and walk dummy arguments manually together with actual arguments.
      
      gcc/fortran/ChangeLog:
      	* interface.c (gfc_dummy_arg_get_typespec,
      	gfc_dummy_arg_is_optional): New functions.
      	* gfortran.h (gfc_dummy_arg_get_typespec,
      	gfc_dummy_arg_is_optional): Declare them.
      	* trans.h (gfc_ss_info::dummy_arg): Use the wrapper type
      	as declaration type.
      	* trans-array.c (gfc_scalar_elemental_arg_saved_as_reference):
      	use gfc_dummy_arg_get_typespec function to get the type.
      	(gfc_walk_elemental_function_args): Remove proc_ifc argument.
      	Get info about the dummy arg using the associated_dummy field.
      	* trans-array.h (gfc_walk_elemental_function_args): Update declaration.
      	* trans-intrinsic.c (gfc_walk_intrinsic_function):
      	Update call to gfc_walk_elemental_function_args.
      	* trans-stmt.c (gfc_trans_call): Ditto.
      	(get_proc_ifc_for_call): Remove.
      5d9d16db
    • Mikael Morin's avatar
      fortran: Reverse actual vs dummy argument mapping · 5888512f
      Mikael Morin authored
      There was originally no way from an actual argument to get
      to the corresponding dummy argument, even if the job of sorting
      and matching actual with dummy arguments was done.
      The closest was a field named actual in gfc_intrinsic_arg that was
      used as scratch data when sorting arguments of one specific call.
      However that value was overwritten later on as arguments of another
      call to the same procedure were sorted and matched.
      
      This change removes that field from gfc_intrinsic_arg and adds instead
      a new field associated_dummy in gfc_actual_arglist.
      
      The new field has as type a new wrapper struct gfc_dummy_arg that provides
      a common interface to both dummy arguments of user-defined procedures
      (which have type gfc_formal_arglist) and dummy arguments of intrinsic procedures
      (which have type gfc_intrinsic_arg).
      
      As the removed field was used in the code sorting and matching arguments,
      that code has to be updated.  Two local vectors with matching indices
      are introduced for respectively dummy and actual arguments, and the
      loops are modified to use indices and update those argument vectors.
      
      gcc/fortran/ChangeLog:
      	* gfortran.h (gfc_dummy_arg_kind, gfc_dummy_arg): New.
      	(gfc_actual_arglist): New field associated_dummy.
      	(gfc_intrinsic_arg): Remove field actual.
      	* interface.c (get_nonintrinsic_dummy_arg): New.
      	(gfc_compare_actual): Initialize associated_dummy.
      	* intrinsic.c (get_intrinsic_dummy_arg): New.
      	(sort_actual):  Add argument vectors.
      	Use loops with indices on argument vectors.
      	Initialize associated_dummy.
      5888512f
    • Mikael Morin's avatar
      fortran: Tiny sort_actual internal refactoring · c31733c3
      Mikael Morin authored
      Preliminary refactoring to make further changes more obvious.
      No functional change.
      
      gcc/fortran/ChangeLog:
      	* intrinsic.c (sort_actual): initialise variable and use it earlier.
      c31733c3
    • Patrick Palka's avatar
      libstdc++: Merge latest Ryu sources · 7461b581
      Patrick Palka authored
      
      libstdc++-v3/ChangeLog:
      
      	* src/c++17/ryu/MERGE: Update the commit hash.
      	* src/c++17/ryu/d2s_intrinsics.h: Merge from Ryu's master
      	branch.
      
      Signed-off-by: default avatarPatrick Palka <ppalka@redhat.com>
      7461b581
    • Michael de Lang's avatar
      libstdc++: Implement constexpr std::basic_string for C++20 · b96e2ff9
      Michael de Lang authored
      This is only supported for the cxx11 ABI, not for COW strings.
      
      libstdc++-v3/ChangeLog:
      
      	* include/bits/basic_string.h (basic_string, operator""s): Add
      	constexpr for C++20.
      	(basic_string::basic_string(basic_string&&)): Only copy
      	initialized portion of the buffer.
      	(basic_string::basic_string(basic_string&&, const Alloc&)):
      	Likewise.
      	* include/bits/basic_string.tcc (basic_string): Add constexpr
      	for C++20.
      	(basic_string::swap(basic_string&)): Only copy initialized
      	portions of the buffers.
      	(basic_string::_M_replace): Add constexpr implementation that
      	doesn't depend on pointer comparisons.
      	* include/bits/cow_string.h: Adjust comment.
      	* include/ext/type_traits.h (__is_null_pointer): Add constexpr.
      	* include/std/string (erase, erase_if): Add constexpr.
      	* include/std/version (__cpp_lib_constexpr_string): Update
      	value.
      	* testsuite/21_strings/basic_string/cons/char/constexpr.cc:
      	New test.
      	* testsuite/21_strings/basic_string/cons/wchar_t/constexpr.cc:
      	New test.
      	* testsuite/21_strings/basic_string/literals/constexpr.cc:
      	New test.
      	* testsuite/21_strings/basic_string/modifiers/constexpr.cc: New test.
      	* testsuite/21_strings/basic_string/modifiers/swap/char/constexpr.cc:
      	New test.
      	* testsuite/21_strings/basic_string/modifiers/swap/wchar_t/constexpr.cc:
      	New test.
      	* testsuite/21_strings/basic_string/version.cc: New test.
      b96e2ff9
    • Jonathan Wakely's avatar
      libstdc++: Use hidden friends for vector<bool>::reference swap overloads · 59434931
      Jonathan Wakely authored
      These swap overloads are non-standard, but are needed to make swap work
      for vector<bool>::reference rvalues. They don't need to be called
      explicitly, only via ADL, so hide them from normal lookup. This is what
      I've proposed as the resolution to LWG 3638.
      
      libstdc++-v3/ChangeLog:
      
      	* include/bits/stl_bvector.h (swap(_Bit_reference, _Bit_reference))
      	(swap(_Bit_reference, bool&), swap(bool&, _Bit_reference)):
      	Define as hidden friends of _Bit_reference.
      59434931
    • Martin Sebor's avatar
      Avoid assuming maximum string length is constant [PR102960]. · ba6e17e7
      Martin Sebor authored
      Resolves:
      PR tree-optimization/102960 - ICE: in sign_mask, at wide-int.h:855 in GCC 10.3.0
      
      gcc/ChangeLog:
      
      	PR tree-optimization/102960
      	* gimple-fold.c (get_range_strlen): Take bitmap as an argument rather
      	than a pointer to it.
      	(get_range_strlen_tree): Same.  Remove bitmap allocation.  Use
      	an auto_bitmap.
      	(get_maxval_strlen): Use an auto_bitmap.
      	* tree-ssa-strlen.c (get_range_strlen_dynamic): Factor out PHI
      	handling...
      	(get_range_strlen_phi): ...into this function.
      	Avoid assuming maximum string length is constant
      	(printf_strlen_execute): Dump pointer query cache contents when
      	details are requisted.
      
      gcc/testsuite/ChangeLog:
      
      	PR tree-optimization/102960
      	* gcc.dg/Wstringop-overflow-84.c: New test.
      ba6e17e7
    • Tamar Christina's avatar
      shrn-combine-10: update test to current codegen. · 0002a8a1
      Tamar Christina authored
      When the rshrn commit was reverted I missed this testcase.
      This now updates it.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.target/aarch64/shrn-combine-10.c: Use shrn.
      0002a8a1
    • Tamar Christina's avatar
      signbit-2: make test check for scalar or vector versions · 9836e907
      Tamar Christina authored
      This updates the signbit-2 test to check for
      the scalar optimization if the target does not
      support vectorization.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.dg/signbit-2.c: CHeck vect or scalar.
      9836e907
    • David Malcolm's avatar
      analyzer: fix overeager sharing of bounded_range instances [PR102662] · e1c0c908
      David Malcolm authored
      
      This was leading to an assertion failure ICE on a switch stmt when using
      -fstrict-enums, due to erroneously reusing a range involving one enum
      with a range involving a different enum.
      
      gcc/analyzer/ChangeLog:
      	PR analyzer/102662
      	* constraint-manager.cc (bounded_range::operator==): Require the
      	types to be the same for equality.
      
      gcc/testsuite/ChangeLog:
      	PR analyzer/102662
      	* g++.dg/analyzer/pr102662.C: New test.
      
      Signed-off-by: default avatarDavid Malcolm <dmalcolm@redhat.com>
      e1c0c908
    • Jason Merrill's avatar
      c++: improve print_node of PTRMEM_CST · 132f1c27
      Jason Merrill authored
      It's been inconvenient that pretty-printing of PTRMEM_CST didn't display
      what member the constant refers to.
      
      Adding that is complicated by the absence of a langhook for CONSTANT_CLASS_P
      nodes; the simplest fix for that is to use the tcc_exceptional hook for
      tcc_constant as well.
      
      gcc/cp/ChangeLog:
      
      	* ptree.c (cxx_print_xnode): Handle PTRMEM_CST.
      
      gcc/ChangeLog:
      
      	* langhooks.h (struct lang_hooks): Adjust comment.
      	* print-tree.c (print_node): Also call print_xnode hook for
      	tcc_constant class.
      132f1c27
    • Andrew Pinski's avatar
      tree-optimization: [PR103218] Fold ((type)(a<0)) << SIGNBITOFA into ((type)a) & signbit · 11c4a06a
      Andrew Pinski authored
      This folds Fold ((type)(a<0)) << SIGNBITOFA into ((type)a) & signbit inside match.pd.
      This was already handled in fold-cost by:
      /* A < 0 ? <sign bit of A> : 0 is simply (A & <sign bit of A>).  */
      I have not removed as we only simplify "a ? POW2 : 0" at the gimple level to "a << CST1"
      and fold actually does the reverse of folding "(a<0)<<CST" into "(a<0) ? 1<<CST : 0".
      
      OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.
      
      	PR tree-optimization/103218
      
      gcc/ChangeLog:
      
      	* match.pd: New pattern for "((type)(a<0)) << SIGNBITOFA".
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.dg/tree-ssa/pr103218-1.c: New test.
      11c4a06a
    • Jonathan Wakely's avatar
      libstdc++: Fix out-of-bound array accesses in testsuite · 8d8e8f3a
      Jonathan Wakely authored
      I fixed some undefined behaviour in string tests in r238609, but I only
      fixed the narrow char versions. This applies the same fixes to the
      wchar_t ones. These problems were found when testing a patch to make
      std::basic_string usable in constexpr.
      
      libstdc++-v3/ChangeLog:
      
      	* testsuite/21_strings/basic_string/modifiers/append/wchar_t/1.cc:
      	Fix reads past the end of strings.
      	* testsuite/21_strings/basic_string/operations/compare/wchar_t/1.cc:
      	Likewise.
      	* testsuite/experimental/string_view/operations/compare/wchar_t/1.cc:
      	Likewise.
      8d8e8f3a
    • Jonathan Wakely's avatar
      libstdc++: Fix typos in tests · 97197694
      Jonathan Wakely authored
      libstdc++-v3/ChangeLog:
      
      	* testsuite/21_strings/basic_string/allocator/71964.cc: Fix
      	typo.
      	* testsuite/23_containers/set/allocator/71964.cc: Likewise.
      97197694
    • Claudiu Zissulescu's avatar
      arc: Update (u)maddhisi4 patterns · b796ab35
      Claudiu Zissulescu authored
      
      The (u)maddsihi4 patterns are using the ARC's VMAC2H(U)
      instruction with null destination, however, VMAC2H(U) doesn't
      rewrite the accumulator.  This patch solves the destination issue
      of VMAC2H by replacing it with DMACH(U) instruction.
      
      gcc/
      
      	* config/arc/arc.md (maddhisi4): Use a single move to accumulator.
      	(umaddhisi4): Likewise.
      	(machi): Update pattern.
      	(umachi): Likewise.
      
      gcc/testsuite/
      
      	* gcc.target/arc/tmac-4.c: New test.
      
      Signed-off-by: default avatarClaudiu Zissulescu <claziss@synopsys.com>
      b796ab35
    • Richard Biener's avatar
      tree-optimization/102880 - improve CD-DCE · 04520645
      Richard Biener authored
      The PR shows a missed control-dependent DCE caused by CFG cleanup
      merging a forwarder resulting in a partially degenerate PHI node.
      With control-dependent DCE we need to mark control dependences
      of incoming edges into PHIs as necessary but that is unnecessarily
      conservative for the case when two edges have the same value.
      There is no easy way to mark only a subset of control dependences
      of both edges necessary so the fix is to produce forwarder blocks
      where then the control dependence captures the requirements more
      precisely.
      
      For gcc.dg/tree-ssa/ssa-dom-thread-7.c the number of edges in the
      CFG decrease as we have commonized PHI arguments which in turn
      results in different threadings.  The testcase is too complex
      and the dump scanning too simple to do anything meaningful here
      but to adjust the number of expected threads.
      
      The same CFG massaging could be useful at RTL expansion time to
      reduce the number of copies we need to insert on edges.
      
      FAIL: gcc.dg/tree-ssa/ssa-hoist-4.c scan-tree-dump-times optimized "MAX_EXPR" 1
      
      2021-11-12  Richard Biener  <rguenther@suse.de>
      
      	PR tree-optimization/102880
      	* tree-ssa-dce.c (sort_phi_args): New function.
      	(make_forwarders_with_degenerate_phis): Likewise.
      	(perform_tree_ssa_dce): Call
      	make_forwarders_with_degenerate_phis.
      
      	* gcc.dg/tree-ssa/pr102880.c: New testcase.
      	* gcc.dg/tree-ssa/pr69270-3.c: Robustify.
      	* gcc.dg/tree-ssa/ssa-dom-thread-7.c: Change the number of
      	expected threadings.
      04520645
    • Richard Biener's avatar
      tree-optimization/102880 - make PHI-OPT recognize more CFGs · f98f373d
      Richard Biener authored
      This allows extra edges into the middle BB for the PHI-OPT
      transforms using replace_phi_edge_with_variable that do not
      end up moving stmts from that middle BB.  This avoids regressing
      gcc.dg/tree-ssa/ssa-hoist-4.c with the actual fix for PR102880
      where CFG cleanup has the choice to remove two forwarders and
      picks "the wrong" leading to
      
         if (a > b) /
             /\    /
            /  <BB>
           /    |
        # PHI <a, b>
      
      rather than
      
         if (a > b)  |
             /\      |
          <BB> \     |
           /    \    |
        # PHI <a, b, b>
      
      but it's relatively straight-forward to support extra edges
      into the middle-BB in paths ending in replace_phi_edge_with_variable
      and that do not require moving stmts.  That's because we really
      only want to remove the edge from the condition to the middle BB.
      Of course actually doing that means updating dominators in non-trival
      ways which is why I kept the original code for the single edge
      case and simply defer to CFG cleanup by adjusting the condition for
      the complicated case.
      
      The testcase needs to be a GIMPLE one since it's quite unreliable
      to produce the desired CFG.
      
      2021-11-15  Richard Biener  <rguenther@suse.de>
      
      	PR tree-optimization/102880
      	* tree-ssa-phiopt.c (tree_ssa_phiopt_worker): Push
      	single_pred (bb1) condition to places that really need it.
      	(match_simplify_replacement): Likewise.
      	(value_replacement): Likewise.
      	(replace_phi_edge_with_variable): Deal with extra edges
      	into the middle BB.
      
      	* gcc.dg/tree-ssa/phi-opt-26.c: New testcase.
      f98f373d
    • Claudiu Zissulescu's avatar
      arc: Update arc specific tests · d699f037
      Claudiu Zissulescu authored
      
      Update assembly output test pattern. Take into consideration also for
      which platform we do execute the test (baremetal or linux).
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.target/arc/add_n-combine.c: Update test patterns.
      	* gcc.target/arc/builtin_eh.c: Update test for linux platforms.
      	* gcc.target/arc/mul64-1.c: Disable this test while running on
      	linux.
      	* gcc.target/arc/tls-gd.c: Update matching patterns.
      	* gcc.target/arc/tls-ie.c: Likewise.
      	* gcc.target/arc/tls-ld.c: Likewise.
      	* gcc.target/arc/uncached-8.c: Likewise.
      
      Signed-off-by: default avatarClaudiu Zissulescu <claziss@synopsys.com>
      d699f037
    • Martin Jambor's avatar
      Replace more DEBUG_EXPR_DECL creations with build_debug_expr_decl · 23125fab
      Martin Jambor authored
      As discussed on the mailing list, this patch replaces all but one
      remaining open coded constructions of DEBUG_EXPR_DECL with calls to
      build_debug_expr_decl, even if - in order not to introduce any
      functional change - the mode of the constructed decl is then
      overwritten.
      
      It is not clear if changing the mode has any effect in practice and
      therefore I have added a FIXME note to code which does it, as
      requested.
      
      After this patch, DEBUG_EXPR_DECLs are created only by
      build_debug_expr_decl and make_debug_expr_from_rtl which looks like
      it should be left alone.
      
      gcc/ChangeLog:
      
      2021-11-11  Martin Jambor  <mjambor@suse.cz>
      
      	* cfgexpand.c (expand_gimple_basic_block): Use build_debug_expr_decl,
      	add a fixme note about the mode assignment perhaps being unnecessary.
      	* ipa-param-manipulation.c (ipa_param_adjustments::modify_call):
      	Likewise.
      	(ipa_param_body_adjustments::mark_dead_statements): Likewise.
      	(ipa_param_body_adjustments::reset_debug_stmts): Likewise.
      	* tree-inline.c (remap_ssa_name): Likewise.
      	(tree_function_versioning): Likewise.
      	* tree-into-ssa.c (rewrite_debug_stmt_uses): Likewise.
      	* tree-ssa-loop-ivopts.c (remove_unused_ivs): Likewise.
      	* tree-ssa.c (insert_debug_temp_for_var_def): Likewise.
      Unverified
      23125fab
    • Martin Jambor's avatar
      ipa-sra: Testcase that removing a "returns_nonnull" retval works · 9f7fc820
      Martin Jambor authored
      Since we can now remove return values of functions with return_nonnull
      type attribute, I'll feel a bit safer if we can test this does not ICE
      when someone attempts to access a non-existent call LHS.  Eventually
      we should probably drop the attribute when this happens.
      
      gcc/testsuite/ChangeLog:
      
      2021-11-15  Martin Jambor  <mjambor@suse.cz>
      
      	* gcc.dg/ipa/ipa-sra-ret-nonull.c: New test.
      Unverified
      9f7fc820
    • Jakub Jelinek's avatar
      libgomp: Mark thread_limit clause to target construct as implemented · 9ceaf0fe
      Jakub Jelinek authored
      After the Fortran changes we can mark it as implemented...
      
      2021-11-16  Jakub Jelinek  <jakub@redhat.com>
      
      	* libgomp.texi (OpenMP 5.1): Mark thread_limit clause to target
      	construct as implemented.
      9ceaf0fe
    • Jakub Jelinek's avatar
      openmp: Regimplify operands of GIMPLE_COND in a few more places [PR103208] · 47de0b56
      Jakub Jelinek authored
      As the testcase shows, the non-rectangular loop expansion code didn't
      try to regimplify operands of GIMPLE_CONDs it built in some cases.
      I have added a helper function which does that and used it in some places
      that were regimplifying already to simplify those spots, plus added it
      in a couple of other places where it was needed.
      
      2021-11-16  Jakub Jelinek  <jakub@redhat.com>
      
      	PR tree-optimization/103208
      	* omp-expand.c (expand_omp_build_cond): New function.
      	(expand_omp_for_init_counts, expand_omp_for_init_vars,
      	expand_omp_for_static_nochunk, expand_omp_for_static_chunk): Use it.
      
      	* c-c++-common/gomp/loop-11.c: New test.
      47de0b56
    • Jakub Jelinek's avatar
      waccess: Fix up pass_waccess::check_alloc_size_call [PR102009] · eacdfaf7
      Jakub Jelinek authored
      This function punts if the builtins have no arguments, but as can be seen
      on the testcase, even if it has some arguments but alloc_size attribute's
      arguments point to arguments that aren't passed, we get a warning earlier
      from the FE but should punt rather than ICE on it.
      Other users of alloc_size attribute e.g. in
      tree-object-size.c (alloc_object_size) punt similarly and similarly
      even in the same TU maybe_warn_nonstring_arg correctly verifies calls have
      enough arguments.
      
      2021-11-16  Jakub Jelinek  <jakub@redhat.com>
      
      	PR tree-optimization/102009
      	* gimple-ssa-warn-access.cc (pass_waccess::check_alloc_size_call):
      	Punt if any of alloc_size arguments is out of bounds vs. number of
      	call arguments.
      
      	* gcc.dg/pr102009.c: New test.
      eacdfaf7
    • Roger Sayle's avatar
      x86_64: Avoid rorx rotation instructions with -Os. · 473b5e87
      Roger Sayle authored
      This patch teaches the i386 backend to avoid using BMI2's rorx
      instructions when optimizing for size.  The benefits are shown
      with the following example:
      
      unsigned int ror1(unsigned int x) { return (x >> 1) | (x << 31); }
      unsigned int ror2(unsigned int x) { return (x >> 2) | (x << 30); }
      unsigned int rol2(unsigned int x) { return (x >> 30) | (x << 2); }
      unsigned int rol1(unsigned int x) { return (x >> 31) | (x << 1); }
      
      which currently with -Os -march=cascadelake generates:
      
      ror1:	rorx    $1, %edi, %eax		// 6 bytes
              ret
      ror2:	rorx    $2, %edi, %eax		// 6 bytes
              ret
      rol2:	rorx    $30, %edi, %eax		// 6 bytes
              ret
      rol1:	rorx    $31, %edi, %eax		// 6 bytes
              ret
      
      but with this patch now generates:
      
      ror1:	movl    %edi, %eax		// 2 bytes
              rorl    %eax			// 2 bytes
              ret
      ror2:	movl    %edi, %eax		// 2 bytes
              rorl    $2, %eax		// 3 bytes
              ret
      rol2:	movl    %edi, %eax		// 2 bytes
              roll    $2, %eax		// 3 bytes
              ret
      rol1:	movl    %edi, %eax		// 2 bytes
              roll    %eax			// 2 bytes
              ret
      
      I've confirmed that this patch is a win on the CSiBE benchmark,
      even though rotations are rare, where for example libmspack/test/md5.o
      shrinks from 5824 bytes to 5632 bytes.
      
      2021-11-16  Roger Sayle  <roger@nextmovesoftware.com>
      
      gcc/ChangeLog
      	* config/i386/i386.md (*bmi2_rorx<mode3>_1): Make conditional
      	on !optimize_function_for_size_p.
      	(*<any_rotate><mode>3_1): Add preferred_for_size attribute.
      	(define_splits): Conditionalize on !optimize_function_for_size_p.
      	(*bmi2_rorxsi3_1_zext): Likewise.
      	(*<any_rotate>si2_1_zext): Add preferred_for_size attribute.
      	(define_splits): Conditionalize on !optimize_function_for_size_p.
      473b5e87
    • Jan Hubicka's avatar
      Fix uninitialized access in merge_call_side_effects · e69b7c57
      Jan Hubicka authored
      gcc/ChangeLog:
      
      	PR ipa/103262
      	* ipa-modref.c (merge_call_side_effects): Fix uninitialized
      	access.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.dg/tree-ssa/modref-dse-5.c: New test.
      e69b7c57
    • Andrew Pinski's avatar
      tree-optimization: [PR103245] Improve detection of abs pattern using multiplication · 3200de91
      Andrew Pinski authored
      So while working on PR 103228 (and a few others), I noticed the testcase for PR 94785
      was failing. The problem is that the nop_convert moved from being inside the IOR to be
      outside of it. I also noticed the patch for PR 103228 was not needed to reproduce the
      issue either.
      This patch combines the two patterns together for the abs match when using multiplication
      and adds a few places where nop_convert are optional.
      
      OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.
      
      	PR tree-optimization/103245
      
      gcc/ChangeLog:
      
      	* match.pd: Combine the abs pattern matching using multiplication.
      	Adding optional nop_convert too.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.dg/tree-ssa/pr103245-1.c: New test.
      3200de91
    • H.J. Lu's avatar
      Add a missing return when transforming atomic bit test and operations · 074ee8d9
      H.J. Lu authored
      When failing to transform equivalent, but slighly different cases of
      atomic bit test and operations to their canonical forms, return
      immediately.
      
      gcc/
      
      	PR middle-end/103268
      	* tree-ssa-ccp.c (optimize_atomic_bit_test_and): Add a missing
      	return.
      
      gcc/testsuite/
      
      	PR middle-end/103268
      	* gcc.dg/pr103268-1.c: New test.
      	* gcc.dg/pr103268-2.c: Likewise.
      074ee8d9
    • Jim Wilson's avatar
      Update my email address. · a031aaa2
      Jim Wilson authored
      	* MAINTAINERS: Update my address.
      a031aaa2
    • GCC Administrator's avatar
      Daily bump. · e2b57363
      GCC Administrator authored
      e2b57363
  2. Nov 15, 2021
    • Jason Merrill's avatar
      c++: Add -fimplicit-constexpr · 87c2080b
      Jason Merrill authored
      With each successive C++ standard the restrictions on the use of the
      constexpr keyword for functions get weaker and weaker; it recently occurred
      to me that it is heading toward the same fate as the C register keyword,
      which was once useful for optimization but became obsolete.  Similarly, it
      seems to me that we should be able to just treat inlines as constexpr
      functions and not make people add the extra keyword everywhere.
      
      There were a lot of testcase changes needed; many disabling errors about
      non-constexpr functions that are now constexpr, and many disabling implicit
      constexpr so that the tests can check the same thing as before, whether
      that's mangling or whatever.
      
      gcc/c-family/ChangeLog:
      
      	* c.opt: Add -fimplicit-constexpr.
      	* c-cppbuiltin.c: Define __cpp_implicit_constexpr.
      	* c-opts.c (c_common_post_options): Disable below C++14.
      
      gcc/cp/ChangeLog:
      
      	* cp-tree.h (struct lang_decl_fn): Add implicit_constexpr.
      	(decl_implicit_constexpr_p): New.
      	* class.c (type_maybe_constexpr_destructor): Use
      	TYPE_HAS_TRIVIAL_DESTRUCTOR and maybe_constexpr_fn.
      	(finalize_literal_type_property): Simplify.
      	* constexpr.c (is_valid_constexpr_fn): Check for dtor.
      	(maybe_save_constexpr_fundef): Try to set DECL_DECLARED_CONSTEXPR_P
      	on inlines.
      	(cxx_eval_call_expression): Use maybe_constexpr_fn.
      	(maybe_constexpr_fn): Handle flag_implicit_constexpr.
      	(var_in_maybe_constexpr_fn): Use maybe_constexpr_fn.
      	(potential_constant_expression_1): Likewise.
      	(decl_implicit_constexpr_p): New.
      	* decl.c (validate_constexpr_redeclaration): Allow change with
      	-fimplicit-constexpr.
      	(grok_special_member_properties): Use maybe_constexpr_fn.
      	* error.c (dump_function_decl): Don't print 'constexpr'
      	if it's implicit.
      	* Make-lang.in (check-c++-all): Update.
      
      libstdc++-v3/ChangeLog:
      
      	* testsuite/20_util/to_address/1_neg.cc: Adjust error.
      	* testsuite/26_numerics/random/concept.cc: Adjust asserts.
      
      gcc/testsuite/ChangeLog:
      
      	* lib/g++-dg.exp: Handle "impcx".
      	* lib/target-supports.exp
      	(check_effective_target_implicit_constexpr): New.
      	* g++.dg/abi/abi-tag16.C:
      	* g++.dg/abi/abi-tag18a.C:
      	* g++.dg/abi/guard4.C:
      	* g++.dg/abi/lambda-defarg1.C:
      	* g++.dg/abi/mangle26.C:
      	* g++.dg/cpp0x/constexpr-diag3.C:
      	* g++.dg/cpp0x/constexpr-ex1.C:
      	* g++.dg/cpp0x/constexpr-ice5.C:
      	* g++.dg/cpp0x/constexpr-incomplete2.C:
      	* g++.dg/cpp0x/constexpr-memfn1.C:
      	* g++.dg/cpp0x/constexpr-neg3.C:
      	* g++.dg/cpp0x/constexpr-specialization.C:
      	* g++.dg/cpp0x/inh-ctor19.C:
      	* g++.dg/cpp0x/inh-ctor30.C:
      	* g++.dg/cpp0x/lambda/lambda-mangle3.C:
      	* g++.dg/cpp0x/lambda/lambda-mangle5.C:
      	* g++.dg/cpp1y/auto-fn12.C:
      	* g++.dg/cpp1y/constexpr-loop5.C:
      	* g++.dg/cpp1z/constexpr-lambda7.C:
      	* g++.dg/cpp2a/constexpr-dtor3.C:
      	* g++.dg/cpp2a/constexpr-new13.C:
      	* g++.dg/cpp2a/constinit11.C:
      	* g++.dg/cpp2a/constinit12.C:
      	* g++.dg/cpp2a/constinit14.C:
      	* g++.dg/cpp2a/constinit15.C:
      	* g++.dg/cpp2a/spaceship-constexpr1.C:
      	* g++.dg/cpp2a/spaceship-eq3.C:
      	* g++.dg/cpp2a/udlit-class-nttp-neg2.C:
      	* g++.dg/debug/dwarf2/auto1.C:
      	* g++.dg/debug/dwarf2/cdtor-1.C:
      	* g++.dg/debug/dwarf2/lambda1.C:
      	* g++.dg/debug/dwarf2/pr54508.C:
      	* g++.dg/debug/dwarf2/pubnames-2.C:
      	* g++.dg/debug/dwarf2/pubnames-3.C:
      	* g++.dg/ext/is_literal_type3.C:
      	* g++.dg/ext/visibility/template7.C:
      	* g++.dg/gcov/gcov-12.C:
      	* g++.dg/gcov/gcov-2.C:
      	* g++.dg/ipa/devirt-35.C:
      	* g++.dg/ipa/devirt-36.C:
      	* g++.dg/ipa/devirt-37.C:
      	* g++.dg/ipa/devirt-44.C:
      	* g++.dg/ipa/imm-devirt-1.C:
      	* g++.dg/lookup/builtin5.C:
      	* g++.dg/lto/inline-crossmodule-1_0.C:
      	* g++.dg/modules/enum-1_a.C:
      	* g++.dg/modules/fn-inline-1_c.C:
      	* g++.dg/modules/pmf-1_b.C:
      	* g++.dg/modules/used-1_c.C:
      	* g++.dg/tls/thread_local11.C:
      	* g++.dg/tls/thread_local11a.C:
      	* g++.dg/tm/pr46653.C:
      	* g++.dg/ubsan/pr70035.C:
      	* g++.old-deja/g++.other/delete6.C:
      	* g++.dg/modules/pmf-1_a.H:
      	Adjust for implicit constexpr.
      87c2080b
    • Jason Merrill's avatar
      c++: split_nonconstant_init and flexarrays · 29e4163a
      Jason Merrill authored
      split_nonconstant_init was doing the wrong thing for both the initialization
      and cleanup here; we know the size from the initializer, and we can pass it
      along.  This doesn't make the testcase work, since the y destructor is still
      broken, but it removes the wrong error for the aggregate initialization.
      
      gcc/cp/ChangeLog:
      
      	* typeck2.c (split_nonconstant_init_1): Handle flexarrays better.
      
      gcc/testsuite/ChangeLog:
      
      	* g++.dg/ext/flexary37.C: Remove expected error.
      29e4163a
    • Siddhesh Poyarekar's avatar
      gimple-fold: Use ranges to simplify strncat and snprintf · 323026c7
      Siddhesh Poyarekar authored
      
      Use ranges for lengths and object sizes in strncat and snprintf to
      determine if they can be transformed into simpler operations.
      
      gcc/ChangeLog:
      
      	* gimple-fold.c (gimple_fold_builtin_strncat): Use ranges to
      	determine if it is safe to transform to strcat.
      	(gimple_fold_builtin_snprintf): Likewise.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.dg/fold-stringops-2.c: Define size_t.
      	(safe1): Adjust.
      	(safe4): New test.
      	* gcc.dg/fold-stringops-3.c: New test.
      
      Signed-off-by: default avatarSiddhesh Poyarekar <siddhesh@gotplt.org>
      323026c7
    • Siddhesh Poyarekar's avatar
      gimple-fold: Use ranges to simplify _chk calls · cea4dab8
      Siddhesh Poyarekar authored
      
      Instead of comparing LEN and SIZE only if they are constants, use their
      ranges to decide if LEN will always be lower than or same as SIZE.
      
      This change ends up putting the stringop-overflow warning line number
      against the strcpy implementation, so adjust the warning check to be
      line number agnostic.
      
      gcc/ChangeLog:
      
      	* gimple-fold.c (known_lower): New function.
      	(gimple_fold_builtin_strncat_chk,
      	gimple_fold_builtin_memory_chk, gimple_fold_builtin_stxcpy_chk,
      	gimple_fold_builtin_stxncpy_chk,
      	gimple_fold_builtin_snprintf_chk,
      	gimple_fold_builtin_sprintf_chk): Use it.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.dg/Wobjsize-1.c: Make warning change line agnostic.
      	* gcc.dg/fold-stringops-2.c: New test.
      
      Signed-off-by: default avatarSiddhesh Poyarekar <siddhesh@gotplt.org>
      cea4dab8
    • Siddhesh Poyarekar's avatar
      gimple-fold: Transform stp*cpy_chk to str*cpy directly · d1753b4b
      Siddhesh Poyarekar authored
      
      Avoid going through another folding cycle and use the ignore flag to
      directly transform BUILT_IN_STPCPY_CHK to BUILT_IN_STRCPY when set,
      likewise for BUILT_IN_STPNCPY_CHK to BUILT_IN_STPNCPY.
      
      Dump the transformation in dump_file so that we can verify in tests that
      the direct transformation actually happened.
      
      gcc/ChangeLog:
      
      	* gimple-fold.c (dump_transformation): New function.
      	(gimple_fold_builtin_stxcpy_chk,
      	gimple_fold_builtin_stxncpy_chk): Use it.  Simplify to
      	BUILT_IN_STRNCPY if return value is not used.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.dg/fold-stringops-1.c: New test.
      
      Signed-off-by: default avatarSiddhesh Poyarekar <siddhesh@gotplt.org>
      d1753b4b
    • H.J. Lu's avatar
      Check optab before transforming atomic bit test and operations · 4c19122b
      H.J. Lu authored
      Check optab before transforming equivalent, but slighly different cases
      of atomic bit test and operations to their canonical forms.
      
      gcc/
      
      	PR middle-end/103184
      	* tree-ssa-ccp.c (optimize_atomic_bit_test_and): Check optab
      	before transforming equivalent, but slighly different cases to
      	their canonical forms.
      
      gcc/testsuite/
      
      	PR middle-end/103184
      	* gcc.dg/pr103184-1.c: New test.
      	* gcc.dg/pr103184-2.c: Likewise.
      4c19122b
    • Iain Sandoe's avatar
      IPA: Provide a mechanism to register static DTORs via cxa_atexit. · fabe8cc4
      Iain Sandoe authored
      
      For at least one target (Darwin) the platform convention is to
      register static destructors (i.e. __attribute__((destructor)))
      with __cxa_atexit rather than placing them into a list that is
      run by some other mechanism.
      
      This patch provides a target hook that allows a target to opt
      into this and handling for the process in ipa_cdtor_merge ().
      
      When the mode is enabled (dtors_from_cxa_atexit is set) we:
      
       * Generate new CTORs to register static destructors with
         __cxa_atexit and add them to the existing list of CTORs;
         we then process the revised CTORs list.
      
       * We sort the DTORs into priority and then TU order, this
         means that they are registered in that order with
         __cxa_atexit () and therefore will be run in the reverse
         order.
      
       * Likewise, CTORs are sorted into priority and then TU order,
         which means that they will run in that order.
      
      This matches the behavior of using init/fini (or
      mod_init_func/mod_term_func) sections.
      
      This also fixes a bug where Fortran needs a DTOR to be run to
      close IO.
      
      Signed-off-by: default avatarIain Sandoe <iain@sandoe.co.uk>
      
      	PR fortran/102992
      
      gcc/ChangeLog:
      
      	* config/darwin.h (TARGET_DTORS_FROM_CXA_ATEXIT): New.
      	* doc/tm.texi: Regenerated.
      	* doc/tm.texi.in: Add TARGET_DTORS_FROM_CXA_ATEXIT hook.
      	* ipa.c (cgraph_build_static_cdtor_1): Return the built
      	function decl.
      	(build_cxa_atexit_decl): New.
      	(build_dso_handle_decl): New.
      	(build_cxa_dtor_registrations): New.
      	(compare_cdtor_tu_order): New.
      	(build_cxa_atexit_fns): New.
      	(ipa_cdtor_merge): If dtors_from_cxa_atexit is set,
      	process the DTORs/CTORs accordingly.
      	(pass_ipa_cdtor_merge::gate): Also run if
      	dtors_from_cxa_atexit is set.
      	* target.def (dtors_from_cxa_atexit): New hook.
      fabe8cc4
Loading