Skip to content
Snippets Groups Projects
  1. Oct 02, 2024
  2. Oct 01, 2024
    • Jason Merrill's avatar
      c++: don't advertise C++20 concepts in C++14 · 1c9b440b
      Jason Merrill authored
      There have been various problems with -std=c++14 -fconcepts; let's stop
      defining the feature test macro in that case.
      
      gcc/c-family/ChangeLog:
      
      	* c-cppbuiltin.cc (c_cpp_builtins): Don't define __cpp_concepts
      	before C++17.
      1c9b440b
    • Georg-Johann Lay's avatar
      AVR: avr.cc - Drop a superfluous sub-condition in avr_out_compare. · f72b1a44
      Georg-Johann Lay authored
      In avr.cc::avr_out_compare() there is this condition:
      
        if (n_bytes == 4
            && eqne_p
            && AVR_HAVE_ADIW
            && REGNO (xreg) >= REG_22
            && (xval == const0_rtx
      	  || (IN_RANGE (avr_int16 (xval, 2), 0, 63)
      	      && eqne_p
      	      && reg_unused_after (insn, xreg))))
      
      where the 2nd sub-expression "&& eqne_p" is superfluous.
      
      gcc/
      	* config/avr/avr.cc (avr_out_compare): Drop superfluous sub-condition.
      f72b1a44
    • Georg-Johann Lay's avatar
      AVR: avr-passes.cc - Fix a build warning. · 5e41e8fd
      Georg-Johann Lay authored
      gcc/
      	* config/avr/avr-passes.cc (avr_split_fake_addressing_move): Fix
      	a build warning.
      5e41e8fd
    • Saurabh Jha's avatar
      aarch64: Introduce new unspecs for smax/smin · ac4cdf5c
      Saurabh Jha authored
      Introduce two new unspecs, UNSPEC_COND_SMAX and UNSPEC_COND_SMIN,
      corresponding to rtl operators smax and smin. UNSPEC_COND_SMAX is used
      to generate fmaxnm instruction and UNSPEC_COND_SMIN is used to generate
      fminnm instruction.
      
      With these new unspecs, we can generate SVE2 max/min instructions using
      existing generic unpredicated and predicated instruction patterns that
      use optab attribute. Thus, we have removed specialised instruction
      patterns for max/min instructions that were using
      SVE_COND_FP_MAXMIN_PUBLIC iterator.
      
      No new test cases as the existing test cases should be enough to test
      this refactoring.
      
      gcc/ChangeLog:
      
      	* config/aarch64/aarch64-sve.md
      	(<fmaxmin><mode>3): Remove this instruction pattern.
      	(cond_<fmaxmin><mode>): Remove this instruction pattern.
      	* config/aarch64/iterators.md: New unspecs and changes to
      	iterators and attrs to use the new unspecs
      ac4cdf5c
    • Thomas Koenig's avatar
      Implement MAXVAL and MINVAL for UNSIGNED. · 9dd9a069
      Thomas Koenig authored
      gcc/fortran/ChangeLog:
      
      	* check.cc (int_or_real_or_char_or_unsigned_check_f2003): New function.
      	(gfc_check_minval_maxval): Use it.
      	* trans-intrinsic.cc (gfc_conv_intrinsic_minmaxval): Handle
      	initial values for UNSIGNED.
      	* gfortran.texi: Document MINVAL and MAXVAL for unsigned.
      
      libgfortran/ChangeLog:
      
      	* Makefile.am: Add minval and maxval files.
      	* Makefile.in: Regenerated.
      	* gfortran.map: Add new functions.
      	* generated/maxval_m1.c: New file.
      	* generated/maxval_m16.c: New file.
      	* generated/maxval_m2.c: New file.
      	* generated/maxval_m4.c: New file.
      	* generated/maxval_m8.c: New file.
      	* generated/minval_m1.c: New file.
      	* generated/minval_m16.c: New file.
      	* generated/minval_m2.c: New file.
      	* generated/minval_m4.c: New file.
      	* generated/minval_m8.c: New file.
      
      gcc/testsuite/ChangeLog:
      
      	* gfortran.dg/unsigned_34.f90: New test.
      9dd9a069
    • Eric Botcazou's avatar
      Fix wrong code out of NRV + RSO + inlining · be2f7a18
      Eric Botcazou authored
      The testcase is miscompiled with -O -flto beccause the three optimizations
      NRV + RSO + inlining are applied to the same call: when the LHS of the call
      is marked write-only before inlining, it will keep the mark after inlining
      although it may be read in GIMPLE from that point on.
      
      The fix is to apply the removal of the store, that would have been applied
      later if the call was not inlined, right before inlining, which will prevent
      the problematic references to the LHS from being generated during inlining.
      
      gcc/
      	* tree-inline.cc (expand_call_inline): Remove the store to the
      	return slot if it is a global variable that is only written to.
      
      gcc/testsuite/
      	* gnat.dg/lto28.adb: New test.
      	* gnat.dg/lto28_pkg1.ads: New helper.
      	* gnat.dg/lto28_pkg2.ads: Likewise.
      	* gnat.dg/lto28_pkg2.adb: Likewise.
      	* gnat.dg/lto28_pkg3.ads: Likewise.
      be2f7a18
    • Tsung Chun Lin's avatar
      [PATCH] RISC-V/libgcc: Fix incorrect and missing .cfi_offset for __riscv_save_[0-3] on RV32. · 97fd7772
      Tsung Chun Lin authored
      0001-RISC-V-libgcc-Fix-incorrect-and-missing-.cfi_offset-.patch
      
      From 06a370a0a2329dd4da0ffcab7c35ea7df2353baf Mon Sep 17 00:00:00 2001
      From: Jim Lin <jim@andestech.com>
      Date: Tue, 1 Oct 2024 14:42:56 +0800
      Subject: [PATCH] RISC-V/libgcc: Fix incorrect and missing .cfi_offset for
       __riscv_save_[0-3] on RV32.
      
      libgcc/ChangeLog:
      
      	* config/riscv/save-restore.S: Fix .cfi_offset for
      	__riscv_save_[0-3] on RV32.
      97fd7772
    • Giuseppe D'Angelo's avatar
      c++: introduce __builtin_is_virtual_base_of · 1b7cfa71
      Giuseppe D'Angelo authored
      P2985R0 (C++26) introduces std::is_virtual_base_of; this is the compiler
      builtin that will back up the library trait (which strictly requires
      compiler support).
      
      The name has been chosen to match LLVM/MSVC's, as per the discussion
      here:
      
      https://github.com/llvm/llvm-project/issues/98310
      
      
      
      The actual user-facing type trait in libstdc++ will be added later.
      
      gcc/cp/ChangeLog:
      
      	* constraint.cc (diagnose_trait_expr): New diagnostic.
      	* cp-trait.def (IS_VIRTUAL_BASE_OF): New builtin.
      	* cp-tree.h (enum base_access_flags): Add a new flag to be
      	able to request a search for a virtual base class.
      	* cxx-pretty-print.cc (pp_cxx_userdef_literal): Update the
      	list of GNU extensions to the grammar.
      	* search.cc (struct lookup_base_data_s): Add a field to
      	request searching for a virtual base class.
      	(dfs_lookup_base): Add the ability to look for a virtual
      	base class.
      	(lookup_base): Forward the flag to dfs_lookup_base.
      	* semantics.cc (trait_expr_value): Implement the builtin
      	by calling lookup_base with the new flag.
      	(finish_trait_expr): Handle the new builtin.
      
      gcc/ChangeLog:
      
      	* doc/extend.texi: Document the new
      	__builtin_is_virtual_base_of builtin; amend the docs for
      	__is_base_of.
      
      gcc/testsuite/ChangeLog:
      
      	* g++.dg/ext/is_virtual_base_of.C: New test.
      	* g++.dg/ext/is_virtual_base_of_diagnostic.C: New test.
      
      Signed-off-by: default avatarGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>
      Reviewed-by: default avatarJason Merrill <jason@redhat.com>
      1b7cfa71
    • Andrew Pinski's avatar
      phi-opt: Improve factor heurstic with constants and conversions from bool [PR116890] · 698e0ec8
      Andrew Pinski authored
      
      Take:
      ```
        if (t_3(D) != 0)
          goto <bb 3>;
        else
          goto <bb 4>;
      
        <bb 3>
        _8 = c_4(D) != 0;
        _9 = (int) _8;
      
        <bb 4>
        # e_2 = PHI <_9(3), 0(2)>
      ```
      
      We should factor out the conversion here as that will allow a simplfication to
      `(t_3 != 0) & (c_4 != 0)`. Unlike most other types; `a ? b : CST` will simplify
      for boolean result type to either `a | b` or `a & b` so allowing this conversion
      for all operations will be always profitable.
      
      Bootstrapped and tested on x86_64-linux-gnu with no regressions.
      
      Note on the phi-opt-7.c testcase change, we are now able to optimize this
      and remove the if due to the factoring out now so this is an improvement.
      
      	PR tree-optimization/116890
      
      gcc/ChangeLog:
      
      	* tree-ssa-phiopt.cc (factor_out_conditional_operation): Conversions
      	from bool is also should be considered as wanting to happen.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.dg/tree-ssa/phi-opt-7.c: Update testcase for no ifs left.
      	* gcc.dg/tree-ssa/phi-opt-42.c: New test.
      	* gcc.dg/tree-ssa/phi-opt-43.c: New test.
      
      Signed-off-by: default avatarAndrew Pinski <quic_apinski@quicinc.com>
      698e0ec8
    • Gaius Mulley's avatar
      modula2: Add FindIndice to library module gm2-libs/Indexing · 8273e31a
      Gaius Mulley authored
      
      This patch introduces the procedure function FindIndice to library
      module Indexing.
      
      gcc/m2/ChangeLog:
      
      	* gm2-libs/Indexing.def (FindIndice): New procedure
      	function.
      	* gm2-libs/Indexing.mod (FindIndice): Implement new
      	procedure function.
      
      Signed-off-by: default avatarGaius Mulley <gaiusmod2@gmail.com>
      8273e31a
    • Gaius Mulley's avatar
      PR modula2/116918 -fswig correct syntax · fda30a3c
      Gaius Mulley authored
      
      This patch fixes the syntax for the generated swig interface file.
      The % characters in fprintf require escaping.
      
      gcc/m2/ChangeLog:
      
      	PR modula2/116918
      	* gm2-compiler/M2Swig.mod (AnnotateProcedure): Capitalize
      	the generated comment, split comment into multiple lines and
      	terminate the comment with ".  */".
      	(DoCheckUnbounded): Escape the % character with %%.
      	(DoWriteFile): Ditto.
      
      Signed-off-by: default avatarGaius Mulley <gaiusmod2@gmail.com>
      fda30a3c
    • Claudio Bantaloukas's avatar
      aarch64: Add fp8 scalar types · 35dd5cfb
      Claudio Bantaloukas authored
      The ACLE defines a new scalar type, __mfp8. This is an opaque 8bit types that
      can only be used by fp8 intrinsics. Additionally, the mfloat8_t type is made
      available in arm_neon.h and arm_sve.h as an alias of the same.
      
      This implementation uses an unsigned INTEGER_TYPE, with precision 8 to
      represent __mfp8. Conversions to int and other types are disabled via the
      TARGET_INVALID_CONVERSION hook.
      Additionally, operations that are typically available to integer types are
      disabled via TARGET_INVALID_UNARY_OP and TARGET_INVALID_BINARY_OP hooks.
      
      gcc/ChangeLog:
      
      	* config/aarch64/aarch64-builtins.cc (aarch64_mfp8_type_node): Add node
      	for __mfp8 type.
      	(aarch64_mfp8_ptr_type_node): Add node for __mfp8 pointer type.
      	(aarch64_init_fp8_types): New function to initialise fp8 types and
      	register with language backends.
      	* config/aarch64/aarch64.cc (aarch64_mangle_type): Add ABI mangling for
      	new type.
      	(aarch64_invalid_conversion): Add function implementing
      	TARGET_INVALID_CONVERSION hook that blocks conversion to and from the
      	__mfp8 type.
      	(aarch64_invalid_unary_op): Add function implementing TARGET_UNARY_OP
      	hook that blocks operations on __mfp8 other than &.
      	(aarch64_invalid_binary_op): Extend TARGET_BINARY_OP hook to disallow
      	operations on __mfp8 type.
      	(TARGET_INVALID_CONVERSION): Add define.
      	(TARGET_INVALID_UNARY_OP): Likewise.
      	* config/aarch64/aarch64.h (aarch64_mfp8_type_node): Add node for __mfp8
      	type.
      	(aarch64_mfp8_ptr_type_node): Add node for __mfp8 pointer type.
      	* config/aarch64/arm_private_fp8.h (mfloat8_t): Add typedef.
      
      gcc/testsuite/ChangeLog:
      
      	* g++.target/aarch64/fp8_mangling.C: New tests exercising mangling.
      	* g++.target/aarch64/fp8_scalar_typecheck_2.C: New tests in C++.
      	* gcc.target/aarch64/fp8_scalar_1.c: New tests in C.
      	* gcc.target/aarch64/fp8_scalar_typecheck_1.c: Likewise.
      35dd5cfb
    • Richard Biener's avatar
      tree-optimization/116902 - vectorizer load hosting breaks UID order #2 · 27ddda8b
      Richard Biener authored
      This is another case of load hoisting breaking UID order in the
      preheader, this time between two hoistings.  The easiest way out is
      to do what we do for the main stmt - copy instead of move.
      
      	PR tree-optimization/116902
      	PR tree-optimization/116842
      	* tree-vect-stmts.cc (sort_after_uid): Remove again.
      	(hoist_defs_of_uses): Copy defs instead of hoisting them so
      	we can zero their UID.
      	(vectorizable_load): Separate analysis and transform call,
      	do transform on the stmt copy.
      
      	* g++.dg/torture/pr116902.C: New testcase.
      27ddda8b
    • Richard Biener's avatar
      tree-optimization/116905 - ICE with bogus range ops · 60fa7f51
      Richard Biener authored
      The following avoids querying ranges of vector entities.
      
      	PR tree-optimization/116905
      	* tree-vect-stmts.cc (supportable_indirect_convert_operation):
      	Fix guard for vect_get_range_info.
      
      	* gcc.dg/pr116905.c: New testcase.
      60fa7f51
    • Richard Biener's avatar
      tree-optimization/116906 - unsafe PRE with never executed edges · 3e1bd647
      Richard Biener authored
      When we're computing ANTIC for PRE we treat edges to not yet visited
      blocks as having a maximum ANTIC solution to get at an optimistic
      solution in the iteration.  That assumes the edges visted eventually
      execute.  This is a wrong assumption that can lead to wrong code
      (and not only non-optimality) when possibly trapping expressions
      are involved as the testcases in the PR show.  The following mitigates
      this by pruning trapping expressions from ANTIC computed when
      maximum sets are involved.
      
      	PR tree-optimization/116906
      	* tree-ssa-pre.cc (prune_clobbered_mems): Add clean_traps
      	argument.
      	(compute_antic_aux): Direct prune_clobbered_mems to prune
      	all traps when any MAX solution was involved in the ANTIC
      	computation.
      	(compute_partial_antic_aux): Adjust.
      
      	* gcc.dg/pr116906-1.c: New testcase.
      	* gcc.dg/pr116906-2.c: Likewise.
      3e1bd647
    • Jakub Jelinek's avatar
      range-cache: Fix ranger ICE if number of bbs increases [PR116899] · de25f172
      Jakub Jelinek authored
      Ranger cache during initialization reserves number of basic block slots
      in the m_workback vector (in an inefficient way by doing create (0)
      and safe_grow_cleared (n) and truncate (0) rather than say create (n)
      or reserve (n) after create).  The problem is that some passes split bbs and/or
      create new basic blocks and so when one is unlucky, the quick_push into that
      vector can ICE.
      
      The following patch replaces those 4 quick_push calls with safe_push.
      
      I've also gathered some statistics from compiling 63 gcc sources (picked those
      that dependent on gimple-range-cache.h just because I had to rebuild them once
      for the instrumentation), and that showed that in 81% of cases nothing has
      been pushed into the vector at all (and note, not everything was small, there
      were even cases with 10000+ basic blocks), another 18.5% of cases had just 1-4
      elements in the vector at most, 0.08% had 5-8 and 19 out of 305386 cases
      had at most 9-11 elements, nothing more.  So, IMHO reserving number of basic
      block in the vector is a waste of compile time memory and with the safe_push
      calls, the patch just initializes the vector to vNULL.
      
      2024-10-01  Jakub Jelinek  <jakub@redhat.com>
      
      	PR middle-end/116899
      	* gimple-range-cache.cc (ranger_cache::ranger_cache): Set m_workback
      	to vNULL instead of creating it, growing and then truncating.
      	(ranger_cache::fill_block_cache): Use safe_push rather than quick_push
      	on m_workback.
      	(ranger_cache::range_from_dom): Likewise.
      
      	* gcc.dg/bitint-111.c: New test.
      de25f172
    • Jakub Jelinek's avatar
      range-cache: Fix ICE on SSA_NAME with def_stmt not yet in the IL [PR116898] · bdbd0607
      Jakub Jelinek authored
      Some passes like the bitint lowering queue some statements on edges and only
      commit them at the end of the pass.  If they use ranger at the same time,
      the ranger might see such SSA_NAMEs and ICE on those.  The following patch
      instead just punts on them.
      
      2024-10-01  Jakub Jelinek  <jakub@redhat.com>
      
      	PR middle-end/116898
      	* gimple-range-cache.cc (ranger_cache::block_range): If a SSA_NAME
      	with NULL def_bb isn't SSA_NAME_IS_DEFAULT_DEF, return false instead
      	of failing assertion.  Formatting fix.
      
      	* gcc.dg/bitint-110.c: New test.
      bdbd0607
    • GCC Administrator's avatar
      Daily bump. · 0939c8ca
      GCC Administrator authored
      0939c8ca
    • Hans-Peter Nilsson's avatar
      libstdc++-v3: Fix signed-overflow warning for newlib/ctype_base.h, PR116895 · b1696ffd
      Hans-Peter Nilsson authored
      There are 100+ regressions when running the g++ testsuite for newlib
      targets (probably excepting ARM-based ones) e.g cris-elf after commit
      r15-3859-g63a598deb0c9fc "libstdc++: #ifdef out #pragma GCC
      system_header", which effectively no longer silences warnings for
      gcc-installed system headers.  Some of these regressions are fixed by
      r15-3928.  For the remaining ones, there's in g++.log:
      
      FAIL: g++.old-deja/g++.robertl/eb79.C  -std=c++26 (test for excess errors)
      Excess errors:
      /gccobj/cris-elf/libstdc++-v3/include/cris-elf/bits/ctype_base.h:50:53: \
       warning: overflow in conversion from 'int' to 'std::ctype_base::mask' \
       {aka 'char'} changes value from '151' to '-105' [-Woverflow]
      
      This is because the _B macro in newlib's ctype.h (from where the
      "_<letter>" macros come) is bit 7, the sign-bit of 8-bit types:
      
      #define	_B	0200
      
      Using it in an int-expression that is then truncated to 8 bits will
      "change" the value to negative for a default-signed char.  If this
      code was created from scratch, it should have been an unsigned type,
      however it's not advisable to change the type of mask as this affects
      the API.  The least ugly option seems to be to silence the warning by
      explict casts in the initializer, and for consistency, doing it for
      all members.
      
      	PR libstdc++/116895
      	* config/os/newlib/ctype_base.h: Avoid signed-overflow warnings by
      	explicitly casting initializer expressions to mask.
      b1696ffd
  3. Sep 30, 2024
    • Kugan Vivekanandarajah's avatar
      [testcase] Fix-absfloat16.c-testcase · ab07db3f
      Kugan Vivekanandarajah authored
      
      gcc/testsuite/ChangeLog:
      	* gcc.dg/tree-ssa/absfloat16.c: Fix testcase.
      
      Signed-off-by: default avatarKugan Vivekanandarajah <kvivekananda@nvidia.com>
      ab07db3f
    • Marek Polacek's avatar
      c++: concept in default argument [PR109859] · 4bcfaaed
      Marek Polacek authored
      
      1) We're hitting the assert in cp_parser_placeholder_type_specifier.
      It says that if it turns out to be false, we should do error() instead.
      Do so, then.
      
      2) lambda-targ8.C should compile fine, though.  The problem was that
      local_variables_forbidden_p wasn't cleared when we're about to parse
      the optional template-parameter-list for a lambda in a default argument.
      
      	PR c++/109859
      
      gcc/cp/ChangeLog:
      
      	* parser.cc (cp_parser_lambda_declarator_opt): Temporarily clear
      	local_variables_forbidden_p.
      	(cp_parser_placeholder_type_specifier): Turn an assert into an
      	error.
      
      gcc/testsuite/ChangeLog:
      
      	* g++.dg/cpp2a/concepts-defarg3.C: New test.
      	* g++.dg/cpp2a/lambda-targ8.C: New test.
      
      Reviewed-by: default avatarJason Merrill <jason@redhat.com>
      4bcfaaed
    • Eric Botcazou's avatar
      Fix internal error during inlining after ICF pass · 65073a5b
      Eric Botcazou authored
      The problem is that the ICF pass identifies two functions, one of which has
      a static chain while the other does not.  The fix is simply to prevent this
      identification from occurring.
      
      gcc/
      	PR ipa/113996
      	* ipa-icf.cc (sem_function::get_hash): Hash DECL_STATIC_CHAIN.
      	(sem_function::equals_wpa): Compare it.
      	(sem_function::equals_private): Likewise.
      
      gcc/testsuite/
      	* gnat.dg/lto27.adb: New test.
      65073a5b
    • David Malcolm's avatar
      diagnostics: return text buffer from test_show_locus [PR116613] · 9c14f9a9
      David Malcolm authored
      
      As work towards supporting multiple diagnostic outputs (where each
      output has its own pretty_printer), avoid referencing dc.m_printer
      throughout the selftests of diagnostic-show-locus.cc.  Instead
      have test_diagnostic_context::test_show_locus return the result
      buffer, hiding the specifics of which printer is in use in such
      test cases.
      
      No functional change intended.
      
      gcc/ChangeLog:
      	PR other/116613
      	* diagnostic-show-locus.cc
      	(selftest::test_diagnostic_show_locus_unknown_location): Move call
      	to dc.test_show_locus into ASSERT_STREQ, and compare against its
      	result, rather than explicitly using dc.m_printer.
      	(selftest::test_one_liner_simple_caret): Likewise.
      	(selftest::test_one_liner_no_column): Likewise.
      	(selftest::test_one_liner_caret_and_range): Likewise.
      	(selftest::test_one_liner_multiple_carets_and_ranges): Likewise.
      	(selftest::test_one_liner_fixit_insert_before): Likewise.
      	(selftest::test_one_liner_fixit_insert_after): Likewise.
      	(selftest::test_one_liner_fixit_remove): Likewise.
      	(selftest::test_one_liner_fixit_replace): Likewise.
      	(selftest::test_one_liner_fixit_replace_non_equal_range):
      	Likewise.
      	(selftest::test_one_liner_fixit_replace_equal_secondary_range):
      	Likewise.
      	(selftest::test_one_liner_fixit_validation_adhoc_locations):
      	Likewise.
      	(selftest::test_one_liner_many_fixits_1): Likewise.
      	(selftest::test_one_liner_many_fixits_2): Likewise.
      	(selftest::test_one_liner_labels): Likewise.
      	(selftest::test_one_liner_simple_caret_utf8): Likewise.
      	(selftest::test_one_liner_multiple_carets_and_ranges_utf8):
      	Likewise.
      	(selftest::test_one_liner_fixit_insert_before_utf8): Likewise.
      	(selftest::test_one_liner_fixit_insert_after_utf8): Likewise.
      	(selftest::test_one_liner_fixit_remove_utf8): Likewise.
      	(selftest::test_one_liner_fixit_replace_utf8): Likewise.
      	(selftest::test_one_liner_fixit_replace_non_equal_range_utf8):
      	Likewise.
      	(selftest::test_one_liner_fixit_replace_equal_secondary_range_utf8):
      	Likewise.
      	(selftest::test_one_liner_fixit_validation_adhoc_locations_utf8):
      	Likewise.
      	(selftest::test_one_liner_many_fixits_1_utf8): Likewise.
      	(selftest::test_one_liner_many_fixits_2_utf8): Likewise.
      	(selftest::test_one_liner_labels_utf8): Likewise.
      	(selftest::test_one_liner_colorized_utf8): Likewise.
      	(selftest::test_add_location_if_nearby): Likewise.
      	(selftest::test_diagnostic_show_locus_fixit_lines): Likewise.
      	(selftest::test_overlapped_fixit_printing): Likewise.
      	(selftest::test_overlapped_fixit_printing_utf8): Likewise.
      	(selftest::test_overlapped_fixit_printing_utf8): Likewise.
      	(selftest::test_overlapped_fixit_printing_2): Likewise.
      	(selftest::test_fixit_insert_containing_newline): Likewise.
      	(selftest::test_fixit_insert_containing_newline_2): Likewise.
      	(selftest::test_fixit_replace_containing_newline): Likewise.
      	(selftest::test_fixit_deletion_affecting_newline): Likewise.
      	(selftest::test_tab_expansion): Likewise.
      	(selftest::test_escaping_bytes_1): Likewise.
      	(selftest::test_escaping_bytes_2): Likewise.
      	(selftest::test_line_numbers_multiline_range): Likewise.
      	* selftest-diagnostic.cc
      	(selftest::test_diagnostic_context::test_show_locus): Return the
      	formatted text of m_printer.
      	* selftest-diagnostic.h
      	(selftest::test_diagnostic_context::test_show_locus): Convert
      	return type from void to const char *.
      
      Signed-off-by: default avatarDavid Malcolm <dmalcolm@redhat.com>
      9c14f9a9
    • David Malcolm's avatar
      diagnostics: require callers of diagnostic_show_locus to be explicit about the printer [PR116613] · e7a8fbe2
      David Malcolm authored
      
      As work towards supporting multiple diagnostic outputs (where each
      output has its own pretty_printer), update diagnostic_show_locus
      so that the pretty_printer must always be explicitly passed in.
      
      No functional change intended.
      
      gcc/c-family/ChangeLog:
      	PR other/116613
      	* c-format.cc (selftest::test_type_mismatch_range_labels):
      	Explicitly pass in dc.m_printer to diagnostic_show_locus.
      
      gcc/ChangeLog:
      	PR other/116613
      	* diagnostic-show-locus.cc (diagnostic_context::maybe_show_locus):
      	Convert param "pp" from * to &.  Drop logic for using the
      	context's m_printer when the param is null.
      	* diagnostic.h (diagnostic_context::maybe_show_locus): Convert
      	param "pp" from * to &.
      	(diagnostic_show_locus): Drop default "nullptr" value for pp
      	param.  Assert that it and context are nonnull.  Pass pp by
      	reference to maybe_show_locus.
      
      gcc/testsuite/ChangeLog:
      	PR other/116613
      	* gcc.dg/plugin/expensive_selftests_plugin.c (test_richloc):
      	Explicitly pass in dc.m_printer to diagnostic_show_locus.
      
      Signed-off-by: default avatarDavid Malcolm <dmalcolm@redhat.com>
      e7a8fbe2
    • David Malcolm's avatar
      diagnostics: isolate diagnostic_context with interface classes [PR116613] · be02253a
      David Malcolm authored
      
      As work towards supporting multiple diagnostic outputs (where each
      output has its own pretty_printer), avoid passing around
      diagnostic_context to the various printing routines, so that we
      can be more explicit about which pretty_printer is in use.
      
      Introduce a set of "policy" classes that capture the parts of
      diagnostic_context that are needed, and use these rather than
      diagnostic_context *.  Pass around pretty_printer & rather than
      taking value from context.  Split out the pretty_printer-using code
      from class layout into a new class layout_printer, separating the
      responsibilities of determining layout when quoting source versus
      actually printing the source.
      
      No functional change intended.
      
      gcc/analyzer/ChangeLog:
      	PR other/116613
      	* program-point.cc (function_point::print_source_line): Replace
      	call to diagnostic_show_locus with a call to
      	diagnostic_source_print_policy::print.
      
      gcc/ChangeLog:
      	PR other/116613
      	* diagnostic-format-json.cc (json_from_expanded_location): Replace
      	call to diagnostic_context::converted_column with call to
      	diagnostic_column_policy::converted_column.
      	* diagnostic-format-sarif.cc
      	(sarif_builder::make_location_object): Replace call to
      	diagnostic_show_locus with call to
      	diagnostic_source_print_policy::print.
      	* diagnostic-format-text.cc (get_location_text): Replace call to
      	diagnostic_context::get_location_text with call to
      	diagnostic_column_policy::get_location_text.
      	(diagnostic_text_output_format::report_current_module): Replace call
      	to diagnostic_context::converted_column with call to
      	diagnostic_column_policy::converted_column.
      	* diagnostic-format-text.h
      	(diagnostic_text_output_format::diagnostic_output_format):
      	Initialize m_column_policy.
      	(diagnostic_text_output_format::get_column_policy): New.
      	(diagnostic_text_output_format::m_column_policy): New.
      	* diagnostic-path.cc (class path_print_policy): New.
      	(event_range::maybe_add_event): Replace diagnostic_context param
      	with path_print_policy.
      	(event_range::print): Convert "pp" from * to &.  Convert first
      	param of start_span callback from diagnostic_context to
      	diagnostic_location_print_policy.
      	(path_summary::path_summary): Convert first param from
      	diagnostic_text_output_format to path_print_policy.  Add
      	colorize param.  Update for changes to
      	event_range::maybe_add_event.
      	(thread_event_printer::print_swimlane_for_event_range): Assert
      	that pp is non-null.  Update for change to event_range::print.
      	(diagnostic_text_output_format::print_path): Pass
      	path_print_policy to path_summary's ctor.
      	(selftest::test_empty_path): Likewise.
      	(selftest::test_intraprocedural_path): Likewise.
      	(selftest::test_interprocedural_path_1): Likewise.
      	(selftest::test_interprocedural_path_2): Likewise.
      	(selftest::test_recursion): Likewise.
      	(selftest::test_control_flow_1): Likewise.
      	(selftest::test_control_flow_2): Likewise.
      	(selftest::test_control_flow_3): Likewise.
      	(selftest::assert_cfg_edge_path_streq): Likewise.
      	(selftest::test_control_flow_5): Likewise.
      	(selftest::test_control_flow_6): Likewise.
      	* diagnostic-show-locus.cc (colorizer::set_range): Update for
      	change to m_pp.
      	(colorizer::m_pp): Convert from * to &.
      	(class layout): Add friend class layout_printer and move various
      	decls to it.
      	(layout::m_pp): Drop field.
      	(layout::m_policy): Rename to...
      	(layout::m_char_policy): ...this.
      	(layout::m_colorizer): Move field to class layout_printer.
      	(layout::m_diagnostic_path_p): Drop field.
      	(class layout_printer): New class, by refactoring class layout.
      	(colorizer::colorizer): Convert "pp" param from * to &.
      	(colorizer::set_named_color): Update for above change.
      	(colorizer::begin_state): Likewise.
      	(colorizer::finish_state): Likewise.
      	(make_policy): Rename to...
      	(make_char_policy): ...this, and update param from
      	diagnostic_context to diagnostic_source_print_policy.
      	(layout::layout): Update param from diagnostic_context to
      	diagnostic_source_print_policy.  Drop params "diagnostic_kind" and
      	"pp", moving these and other material to class layout_printer.
      	(layout::maybe_add_location_range): Update for renamed field.
      	(layout::print_gap_in_line_numbering): Convert to...
      	(layout_printer::print_gap_in_line_numbering): ...this.
      	(layout::calculate_x_offset_display): Update for renamed field.
      	(layout::print_source_line): Convert to...
      	(layout_printer::print_source_line): ...this.
      	(layout::print_leftmost_column): Convert to...
      	(layout_printer::print_leftmost_column): ...this.
      	(layout::start_annotation_line): Convert to...
      	(layout_printer::start_annotation_line): ...this.
      	(layout::print_annotation_line): Convert to...
      	(layout_printer::print_annotation_line): ...this.
      	(layout::print_any_labels): Convert to...
      	(layout_printer::print_any_labels): ...this.
      	(layout::print_leading_fixits): Convert to...
      	(layout_printer::print_leading_fixits): ...this.
      	(layout::print_trailing_fixits): Convert to...
      	(layout_printer::print_trailing_fixits): ...this.
      	(layout::print_newline): Convert to...
      	(layout_printer::print_newline): ...this.
      	(layout::get_state_at_point): Make const.
      	(layout::get_x_bound_for_row): Make const.
      	(layout::move_to_column): Convert to...
      	(layout_printer::move_to_column): ...this.
      	(layout::show_ruler): Convert to...
      	(layout_printer::show_ruler): ...this.
      	(layout::print_line): Convert to...
      	(layout_printer::print_line): ...this.
      	(layout::print_any_right_to_left_edge_lines): Convert to...
      	(layout_printer::print_any_right_to_left_edge_lines): ...this.
      	(layout::print_any_right_to_left_edge_lines): Likewise.
      	(layout_printer::layout_printer): New.
      	(layout::update_any_effects): Delete, moving logic to
      	layout_printer::print.
      	(gcc_rich_location::add_location_if_nearby): Update param from
      	diagnostic_context to diagnostic_source_print_policy.  Add
      	overload taking a diagnostic_context.
      	(diagnostic_context::maybe_show_locus): Move handling of null
      	pretty_printer here, from layout ctor.  Convert call to
      	diagnostic_context::show_locus to
      	diagnostic_source_print_policy::print.
      	(diagnostic_source_print_policy::diagnostic_source_print_policy):
      	New.
      	(diagnostic_context::show_locus): Convert to...
      	(diagnostic_source_print_policy::print): ...this.  Convert pp
      	from * to &.
      	(layout_printer::print): New, based on material in
      	diagnostic_context::show_locus.
      	(selftest::make_char_policy): New.
      	(selftest::test_display_widths): Update for above changes.
      	(selftest::test_offset_impl): Likewise.
      	(selftest::test_layout_x_offset_display_utf8): Likewise.
      	(selftest::test_layout_x_offset_display_tab): Likewise.
      	(selftest::test_diagnostic_show_locus_unknown_location): Use
      	test_diagnostic_context::test_show_locus rather than
      	diagnostic_show_locus.
      	(selftest::test_one_liner_no_column): Likewise.
      	(selftest::test_one_liner_caret_and_range): Likewise.
      	(selftest::test_one_liner_multiple_carets_and_ranges): Likewise.
      	(selftest::test_one_liner_fixit_insert_before): Likewise.
      	(selftest::test_one_liner_fixit_insert_after): Likewise.
      	(selftest::test_one_liner_fixit_remove): Likewise.
      	(selftest::test_one_liner_fixit_replace): Likewise.
      	(selftest::test_one_liner_fixit_replace_non_equal_range):
      	Likewise.
      	(selftest::test_one_liner_fixit_replace_equal_secondary_range):
      	Likewise.
      	(selftest::test_one_liner_fixit_validation_adhoc_locations):
      	Likewise.
      	(selftest::test_one_liner_many_fixits_1): Likewise.
      	(selftest::test_one_liner_many_fixits_2): Likewise.
      	(selftest::test_one_liner_labels): Likewise.
      	(selftest::test_one_liner_simple_caret_utf8): Likewise.
      	(selftest::test_one_liner_caret_and_range_utf8): Likewise.
      	(selftest::test_one_liner_multiple_carets_and_ranges_utf8):
      	Likewise.
      	(selftest::test_one_liner_fixit_insert_before_utf8): Likewise.
      	(selftest::test_one_liner_fixit_insert_after_utf8): Likewise.
      	(selftest::test_one_liner_fixit_remove_utf8): Likewise.
      	(selftest::test_one_liner_fixit_replace_utf8): Likewise.
      	(selftest::test_one_liner_fixit_replace_non_equal_range_utf8):
      	Likewise.
      	(selftest::test_one_liner_fixit_replace_equal_secondary_range_utf8):
      	Likewise.
      	(selftest::test_one_liner_fixit_validation_adhoc_locations_utf8):
      	Likewise.
      	(selftest::test_one_liner_many_fixits_1_utf8): Likewise.
      	(selftest::test_one_liner_many_fixits_2_utf8): Likewise.
      	(selftest::test_one_liner_labels_utf8): Likewise.
      	(selftest::test_one_liner_colorized_utf8): Likewise.
      	(selftest::test_add_location_if_nearby): Likewise.
      	(selftest::test_diagnostic_show_locus_fixit_lines): Likewise.
      	(selftest::test_overlapped_fixit_printing): Likewise.
      	(selftest::test_overlapped_fixit_printing_utf8): Likewise.
      	(selftest::test_overlapped_fixit_printing_2): Likewise.
      	(selftest::test_fixit_insert_containing_newline): Likewise.
      	(selftest::test_fixit_insert_containing_newline_2): Likewise.
      	(selftest::test_fixit_replace_containing_newline): Likewise.
      	(selftest::test_fixit_deletion_affecting_newline): Likewise.
      	(selftest::test_tab_expansion): Likewise.
      	(selftest::test_escaping_bytes_1): Likewise.
      	(selftest::test_escaping_bytes_2): Likewise.
      	(selftest::test_line_numbers_multiline_range): Likewise.
      	* diagnostic.cc
      	(diagnostic_column_policy::diagnostic_column_policy): New.
      	(diagnostic_context::converted_column): Convert to...
      	(diagnostic_column_policy::converted_column): ...this.
      	(diagnostic_context::get_location_text): Convert to...
      	(diagnostic_column_policy::get_location_text): ...this, adding
      	"show_column" param.
      	(diagnostic_location_print_policy::diagnostic_location_print_policy):
      	New ctors.
      	(default_diagnostic_start_span_fn): Convert param from
      	diagnostic_context * to const diagnostic_location_print_policy &.
      	Add "pp" param.
      	(selftest::assert_location_text): Update for above changes.
      	(selftest::test_diagnostic_get_location_text): Rename to...
      	(selftest::test_get_location_text): ...this.
      	(selftest::c_diagnostic_cc_tests): Update for renaming.
      	* diagnostic.h (class diagnostic_location_print_policy): New
      	forward decl.
      	(class diagnostic_source_print_policy): New forward decl.
      	(diagnostic_start_span_fn): Convert first param from
      	diagnostic_context * to const diagnostic_location_print_policy &
      	and add pretty_printer * param.
      	(class diagnostic_column_policy): New.
      	(class diagnostic_location_print_policy): New.
      	(class diagnostic_source_print_policy): New.
      	(class diagnostic_context): Add friend class
      	diagnostic_source_print_policy.
      	(diagnostic_context::converted_column): Drop decl in favor of
      	diagnostic_column_policy::converted_column.
      	(diagnostic_context::get_location_text): Drop decl in favor of
      	diagnostic_column_policy::get_location_text.
      	(diagnostic_context::show_locus): Drop decl in favor of
      	diagnostic_source_print_policy::print.
      	(default_diagnostic_start_span_fn): Update for change to
      	diagnostic_start_span_fn.
      	* gcc-rich-location.h (class diagnostic_source_print_policy): New
      	forward decl.
      	(gcc_rich_location::add_location_if_nearby): Convert first param
      	from diagnostic_context to diagnostic_source_print_policy.  Add
      	overload taking diagnostic_context.
      	* selftest-diagnostic.cc
      	(selftest::test_diagnostic_context::test_diagnostic_context): Turn
      	off colorization.
      	(selftest::test_diagnostic_context::start_span_cb): Update for
      	change to callback type.
      	(test_diagnostic_context::test_show_locus): New.
      	* selftest-diagnostic.h
      	(selftest::test_diagnostic_context::start_span_cb): Update for
      	change to callback type.
      	(test_diagnostic_context::test_show_locus): New decl.
      
      gcc/fortran/ChangeLog:
      	PR other/116613
      	* error.cc (gfc_diagnostic_build_locus_prefix): Convert first
      	param from diagnostic_context * to
      	const diagnostic_location_print_policy &.  Add colorize param.
      	Likewise for the "two expanded_locations" overload.
      	(gfc_diagnostic_text_starter): Update for above changes.
      	(gfc_diagnostic_start_span): Update for change to callback type.
      
      gcc/testsuite/ChangeLog:
      	PR other/116613
      	* gcc.dg/plugin/diagnostic_group_plugin.c
      	(test_diagnostic_start_span_fn): Update for change to callback
      	type.
      
      Signed-off-by: default avatarDavid Malcolm <dmalcolm@redhat.com>
      be02253a
    • David Malcolm's avatar
      diagnostics: avoid using diagnostic_context's m_printer [PR116613] · cce52867
      David Malcolm authored
      
      As work towards supporting multiple diagnostic outputs (where each
      output has its own pretty_printer), avoid using diagnostic_context's
      m_printer field.  Instead, use the output format's printer.  Currently
      this *is* the dc's printer, but eventually it might not be.
      
      No functional change intended.
      
      gcc/ChangeLog:
      	PR other/116613
      	* diagnostic-format-json.cc (diagnostic_output_format_init_json):
      	Pass in the format.  Use the format's printer when disabling
      	colorization.  Move the call to set_output_format into here.
      	(diagnostic_output_format_init_json_stderr): Update for above
      	change.
      	(diagnostic_output_format_init_json_file): Likewise.
      	* diagnostic-format-sarif.cc
      	(diagnostic_output_format_init_sarif): Use the format's printer
      	when disabling colorization.
      	* diagnostic-path.cc (selftest::test_empty_path): Use the
      	text_output's printer.
      	(selftest::test_intraprocedural_path): Likewise.
      	(selftest::test_interprocedural_path_1): Likewise.
      	(selftest::test_interprocedural_path_2): Likewise.
      	(selftest::test_recursion): Likewise.
      	(selftest::test_control_flow_1): Likewise.
      	(selftest::test_control_flow_2): Likewise.
      	(selftest::test_control_flow_3): Likewise.
      	(selftest::assert_cfg_edge_path_streq): Likewise.
      	(selftest::test_control_flow_5): Likewise.
      	(selftest::test_control_flow_6): Likewise.
      
      gcc/testsuite/ChangeLog:
      	PR other/116613
      	* gcc.dg/plugin/diagnostic_group_plugin.c
      	(test_output_format::on_begin_group): Use get_printer () rather
      	than accessing m_context.m_printer.
      	(test_output_format::on_end_group): Likewise.
      	* gcc.dg/plugin/diagnostic_plugin_xhtml_format.c
      	(xhtml_builder::m_printer): New field.
      	(xhtml_builder::xhtml_builder): Add "pp" param and use it to
      	initialize m_printer.
      	(xhtml_builder::on_report_diagnostic): Drop "context" param.
      	(xhtml_builder::make_element_for_diagnostic): Likewise.  Use
      	this->m_printer rather than the context's m_printer.  Pass
      	m_printer to call to diagnostic_show_locus.
      	(xhtml_builder::emit_diagram): Drop "context" param.
      	(xhtml_output_format::on_report_diagnostic): Drop context param
      	from call to m_builder.
      	(xhtml_output_format::on_diagram): Likewise.
      	(xhtml_output_format::xhtml_output_format): Pass result of
      	get_printer as printer for builder.
      	(diagnostic_output_format_init_xhtml): Use the fmt's printer
      	rather than the context's.
      
      Signed-off-by: default avatarDavid Malcolm <dmalcolm@redhat.com>
      cce52867
    • David Malcolm's avatar
      diagnostics: use "%e" to avoid intermediate strings [PR116613] · 3d3d20cc
      David Malcolm authored
      
      Various diagnostics build an intermediate string, potentially with
      colorization, and then use this in a diagnostic message.
      
      This won't work if we have multiple diagnostic sinks, where some might
      be colorized and some not.
      
      This patch reworks such places using "%e" and pp_element subclasses, so
      that any colorization happens within report_diagnostic's call to
      pp_format.
      
      gcc/analyzer/ChangeLog:
      	PR other/116613
      	* kf-analyzer.cc: Include "pretty-print-markup.h".
      	(kf_analyzer_dump_escaped::impl_call_pre): Defer colorization
      	choices by eliminating the construction of a intermediate string,
      	replacing it with a new pp_element subclass via "%e".
      
      gcc/ChangeLog:
      	PR other/116613
      	* attribs.cc: Include "pretty-print-markup.h".
      	(decls_mismatched_attributes): Defer colorization choices by
      	replacing printing to a pretty_printer * param with appending
      	to a vec of strings.
      	(maybe_diag_alias_attributes): As above, replacing pretty_printer
      	with usage of pp_markup::comma_separated_quoted_strings and "%e"
      	in two places.
      	* attribs.h (decls_mismatched_attributes): Update decl.
      	* gimple-ssa-warn-access.cc: Include "pretty-print-markup.h".
      	(pass_waccess::maybe_warn_memmodel): Defer colorization choices by
      	replacing printing to a pretty_printer * param with use of
      	pp_markup::comma_separated_quoted_strings and "%e".
      	(pass_waccess::maybe_warn_memmodel): Likewise, replacing printing
      	to a temporary buffer.
      	* pretty-print-markup.h
      	(class pp_markup::comma_separated_quoted_strings): New.
      	* pretty-print.cc
      	(pp_markup::comma_separated_quoted_strings::add_to_phase_2): New.
      	(selftest::test_pp_printf_within_pp_element): New.
      	(selftest::test_comma_separated_quoted_strings): New.
      	(selftest::pretty_print_cc_tests): Call the new tests.
      
      gcc/cp/ChangeLog:
      	PR other/116613
      	* pt.cc: Include "pretty-print-markup.h".
      	(warn_spec_missing_attributes): Defer colorization choices by
      	replacing printing to a pretty_printer * param with appending
      	to a vec of strings.  Replace pretty_printer with usage of
      	pp_markup::comma_separated_quoted_strings and "%e".
      
      gcc/testsuite/ChangeLog:
      	PR other/116613
      	* c-c++-common/analyzer/escaping-1.c: Update expected results to
      	remove type information from C++ results.  Previously we were
      	using %qD with default_tree_printer, which used
      	lang_hooks.decl_printable_name, whereas now we're using %qD with
      	a clone of the cxx_pretty_printer.
      
      Signed-off-by: default avatarDavid Malcolm <dmalcolm@redhat.com>
      3d3d20cc
    • David Malcolm's avatar
      diagnostics: add "dump" to pretty_printer and output_buffer · 4c7a58ac
      David Malcolm authored
      
      No functional change intended.
      
      gcc/ChangeLog:
      	* pretty-print.cc (output_buffer::dump): New.
      	(pretty_printer::dump): New.
      	* pretty-print.h (output_buffer::dump): New decls.
      	(pretty_printer::dump): New decls.
      
      Signed-off-by: default avatarDavid Malcolm <dmalcolm@redhat.com>
      4c7a58ac
    • David Malcolm's avatar
      diagnostics: fix typo in XHTML output [PR116792] · 3286b672
      David Malcolm authored
      
      gcc/testsuite/ChangeLog:
      	PR other/116792
      	* gcc.dg/plugin/diagnostic_plugin_xhtml_format.c: Fix stray
      	reference to JSON.
      
      Signed-off-by: default avatarDavid Malcolm <dmalcolm@redhat.com>
      3286b672
    • David Malcolm's avatar
      diagnostics: fix memory leak in SARIF selftests · ab6c7a32
      David Malcolm authored
      
      "make selftest-valgrind" was complaining about leaks of artifact objects
      in SARIF's selftest::test_make_location_object:
      
      -fself-test: 7638695 pass(es) in 89.999249 seconds
      ==3306525==
      ==3306525== HEAP SUMMARY:
      ==3306525==     in use at exit: 1,215,639 bytes in 2,808 blocks
      ==3306525==   total heap usage: 2,860,898 allocs, 2,858,090 frees, 1,336,446,579 bytes allocated
      ==3306525==
      ==3306525== 11,728 (1,536 direct, 10,192 indirect) bytes in 16 blocks are definitely lost in loss record 353 of 375
      ==3306525==    at 0x514FE7D: operator new(unsigned long) (vg_replace_malloc.c:342)
      ==3306525==    by 0x36E5FD2: sarif_builder::get_or_create_artifact(char const*, diagnostic_artifact_role, bool) (diagnostic-format-sarif.cc:2884)
      ==3306525==    by 0x36E3D57: sarif_builder::maybe_make_physical_location_object(unsigned int, diagnostic_artifact_role, int, content_renderer const*) (diagnostic-format-sarif.cc:2097)
      ==3306525==    by 0x36E34CE: sarif_builder::make_location_object(sarif_location_manager&, rich_location const&, logical_location const*, diagnostic_artifact_role) (diagnostic-format-sarif.cc:1922)
      ==3306525==    by 0x36E72C6: selftest::test_make_location_object(selftest::line_table_case const&) (diagnostic-format-sarif.cc:3500)
      ==3306525==    by 0x375609B: selftest::for_each_line_table_case(void (*)(selftest::line_table_case const&)) (input.cc:3898)
      ==3306525==    by 0x36E9668: selftest::diagnostic_format_sarif_cc_tests() (diagnostic-format-sarif.cc:3910)
      ==3306525==    by 0x3592A11: selftest::run_tests() (selftest-run-tests.cc:100)
      ==3306525==    by 0x17DBEF3: toplev::run_self_tests() (toplev.cc:2268)
      ==3306525==    by 0x17DC2BF: toplev::main(int, char**) (toplev.cc:2376)
      ==3306525==    by 0x36A1919: main (main.cc:39)
      ==3306525==
      ==3306525== 12,400 (1,536 direct, 10,864 indirect) bytes in 16 blocks are definitely lost in loss record 355 of 375
      ==3306525==    at 0x514FE7D: operator new(unsigned long) (vg_replace_malloc.c:342)
      ==3306525==    by 0x36E5FD2: sarif_builder::get_or_create_artifact(char const*, diagnostic_artifact_role, bool) (diagnostic-format-sarif.cc:2884)
      ==3306525==    by 0x36E2323: sarif_builder::sarif_builder(diagnostic_context&, line_maps const*, char const*, bool) (diagnostic-format-sarif.cc:1500)
      ==3306525==    by 0x36E70AA: selftest::test_make_location_object(selftest::line_table_case const&) (diagnostic-format-sarif.cc:3469)
      ==3306525==    by 0x375609B: selftest::for_each_line_table_case(void (*)(selftest::line_table_case const&)) (input.cc:3898)
      ==3306525==    by 0x36E9668: selftest::diagnostic_format_sarif_cc_tests() (diagnostic-format-sarif.cc:3910)
      ==3306525==    by 0x3592A11: selftest::run_tests() (selftest-run-tests.cc:100)
      ==3306525==    by 0x17DBEF3: toplev::run_self_tests() (toplev.cc:2268)
      ==3306525==    by 0x17DC2BF: toplev::main(int, char**) (toplev.cc:2376)
      ==3306525==    by 0x36A1919: main (main.cc:39)
      ==3306525==
      ==3306525== LEAK SUMMARY:
      ==3306525==    definitely lost: 3,072 bytes in 32 blocks
      ==3306525==    indirectly lost: 21,056 bytes in 368 blocks
      ==3306525==      possibly lost: 0 bytes in 0 blocks
      ==3306525==    still reachable: 1,191,511 bytes in 2,408 blocks
      ==3306525==         suppressed: 0 bytes in 0 blocks
      ==3306525== Reachable blocks (those to which a pointer was found) are not shown.
      ==3306525== To see them, rerun with: --leak-check=full --show-leak-kinds=all
      ==3306525==
      ==3306525== For lists of detected and suppressed errors, rerun with: -s
      ==3306525== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
      
      Fixed thusly.
      
      gcc/ChangeLog:
      	* diagnostic-format-sarif.cc (sarif_builder::~sarif_builder): New,
      	deleting any remaining artifact objects.
      	(sarif_builder::make_run_object): Empty the artifact map.
      	* ordered-hash-map.h (ordered_hash_map::empty): New.
      
      Signed-off-by: default avatarDavid Malcolm <dmalcolm@redhat.com>
      ab6c7a32
    • Victor Do Nascimento's avatar
      autovectorizer: Test autovectorization of different dot-prod modes. · 8398ef96
      Victor Do Nascimento authored
      Given the novel treatment of the dot product optab as a conversion, we
      are now able to target different relationships between output modes and
      input modes.
      
      This is made clearer by way of example. Previously, on AArch64, the
      following loop was vectorizable:
      
      uint32_t udot4(int n, uint8_t* data) {
        uint32_t sum = 0;
        for (int i=0; i<n; i+=1)
          sum += data[i] * data[i];
        return sum;
      }
      
      while the following was not:
      
      uint32_t udot2(int n, uint16_t* data) {
        uint32_t sum = 0;
        for (int i=0; i<n; i+=1)
          sum += data[i] * data[i];
        return sum;
      }
      
      Under the new treatment of the dot product optab, they are both now
      vectorizable.
      
      This adds the relevant target-agnostic check to ensure this behavior
      in the autovectorizer, gated behind the new check_effective_target
      `vect_dotprod_hisi' as well a runtime check targeting aarch64.
      
      gcc/testsuite/ChangeLog:
      
      	* lib/target-supports.exp (check_effective_target_vect_dotprod_hisi):
      	New.
      	* gcc.dg/vect/vect-dotprod-conv-optab.c: Likewise.
      	* gcc.target/aarch64/vect-dotprod-twoway-hisi.c: Likewise.
      8398ef96
    • Victor Do Nascimento's avatar
      c6x: Adjust dot-product backend patterns · fd35d999
      Victor Do Nascimento authored
      Following the migration of the dot_prod optab from a direct to a
      conversion-type optab, ensure all back-end patterns incorporate the
      second machine mode into pattern names.
      
      gcc/ChangeLog:
      
      	* config/c6x/c6x.md (sdot_prodv2hi): Renamed to...
      	(sdot_prodsiv2hi): ...this.
      fd35d999
    • Victor Do Nascimento's avatar
      rs6000: Adjust altivec dot-product backend patterns · 113e31cc
      Victor Do Nascimento authored
      Following the migration of the dot_prod optab from a direct to a
      conversion-type optab, ensure all back-end patterns incorporate the
      second machine mode into pattern names.
      
      gcc/ChangeLog:
      
      	* config/rs6000/altivec.md (udot_prod<mode>): Renamed to...
      	(udot_prodv4si<mode>): ...this.
      	(sdot_prodv8hi): Renamed to...
      	(sdot_prodv4siv8hi): ...this.
      113e31cc
    • Victor Do Nascimento's avatar
      mips: Adjust dot-product backend patterns · d33786b1
      Victor Do Nascimento authored
      Following the migration of the dot_prod optab from a direct to a
      conversion-type optab, ensure all back-end patterns incorporate the
      second machine mode into pattern names.
      
      gcc/ChangeLog:
      
      	* config/mips/loongson-mmi.md (sdot_prodv4hi): Renamed to...
      	(sdot_prodv2siv4hi): ...this.
      d33786b1
    • Victor Do Nascimento's avatar
      arc: Adjust dot-product backend patterns · 85a2ed05
      Victor Do Nascimento authored
      Following the migration of the dot_prod optab from a direct to a
      conversion-type optab, ensure all back-end patterns incorporate the
      second machine mode into pattern names.
      
      gcc/ChangeLog:
      
      	* config/arc/simdext.md (sdot_prodv2hi): Renamed to...
      	(sdot_prodsiv2hi): ...this.
      	(udot_prodv2hi): Renamed to...
      	(udot_prodsiv2hi): ...this.
      	(sdot_prodv4hi): Renamed to...
      	(sdot_prodv2siv4hi): ...this.
      	(udot_prodv4hi): Renamed to...
      	(udot_prodv2siv4hi): ...this.
      85a2ed05
    • Victor Do Nascimento's avatar
      i386: Fix dot_prod backend patterns for mmx and sse targets · c45ef5ee
      Victor Do Nascimento authored
      Following the migration of the dot_prod optab from a direct to a
      conversion-type optab, ensure all back-end patterns incorporate the
      second machine mode into pattern names.
      
      gcc/ChangeLog:
      
      	* config/i386/mmx.md (usdot_prodv8qi): Renamed to...
      	(usdot_prodv2siv8qi): ...this.
      	(sdot_prodv8qi): Renamed to...
      	(sdot_prodv2siv8qi): ...this.
      	(udot_prodv8qi): Renamed to...
      	(udot_prodv2siv8qi): ...this.
      	(usdot_prodv4hi): Renamed to...
      	(usdot_prodv2siv4hi): ...this.
      	(udot_prodv4hi): Renamed to...
      	(udot_prodv2siv4hi): ...this.
      	(sdot_prodv4hi): Renamed to...
      	(sdot_prodv2siv4hi): ...this.
      	* config/i386/sse.md (sdot_prod<mode>): Renamed to...
      	(sdot_prod<sseunpackmodelower><mode>): ...this.
      	(sdot_prodv4si): Renamed to...
      	(sdot_prodv2div4si): ...this.
      	(usdot_prod<mode>): Renamed to...
      	(usdot_prod<ssedvecmodelower><mode>): ...this.
      	(sdot_prod<mode>): Renamed to...
      	(sdot_prod<ssedvecmodelower><mode>): ...this.
      	(sdot_prodv64qi): Renamed to...
      	(sdot_prodv16siv64qi): ...this.
      	(udot_prod<mode>): Renamed to...
      	(udot_prod<ssedvecmodelower><mode>): ...this.
      	(udot_prodv64qi): Renamed to...
      	(udot_prodv16qiv64qi): ...this.
      	(usdot_prod<mode>): Renamed to...
      	(usdot_prod<sseunpackmodelower><mode>): ...this.
      	(udot_prod<mode>): Renamed to...
      	(udot_prod<sseunpackmodelower><mode>): ...this.
      c45ef5ee
    • Victor Do Nascimento's avatar
      arm: Fix arm backend-use of (u|s|us)dot_prod patterns · bfa44e60
      Victor Do Nascimento authored
      Given recent changes to the dot_prod standard pattern name, this patch
      fixes the arm back-end by implementing the following changes:
      
      1. Add 2nd mode to all patterns relating to the dot-product in .md
      files.
      2. redirect the single-mode CODE_FOR_neon_(u|s|us)dot<mode> values
      generated from `arm_neon_builtins.def' to their new 2-mode
      equivalents via means of simple aliases, as per the following example:
      
        constexpr insn_code CODE_FOR_neon_sdotv8qi
          = CODE_FOR_neon_sdotv2siv8qi;
      
      gcc/ChangeLog:
      
      	* config/arm/neon.md (<sup>dot_prod<vsi2qi>): Renamed to...
      	(<sup>dot_prod<mode><vsi2qi>): ...this.
      	(neon_<sup>dot<vsi2qi>): Renamed to...
      	(neon_<sup>dot<mode><vsi2qi>): ...this.
      	(neon_usdot<vsi2qi>): Renamed to...
      	(neon_usdot<mode><vsi2qi>): ...this.
      	(usdot_prod<vsi2qi>): Renamed to...
      	(usdot_prod<mode><vsi2qi>): ...this.
      	* config/arm/arm-builtins.cc
      	(CODE_FOR_neon_sdotv8qi): Definie as alias to
      	new CODE_FOR_neon_sdotv2siv8qi.
      	(CODE_FOR_neon_udotv8qi): Definie as alias to
      	new CODE_FOR_neon_udotv2siv8qi.
      	(CODE_FOR_neon_usdotv8qi): Definie as alias to
      	new CODE_FOR_neon_usdotv2siv8qi.
      	(CODE_FOR_neon_sdotv16qi): Definie as alias to
      	new CODE_FOR_neon_sdotv4siv16qi.
      	(CODE_FOR_neon_udotv16qi): Definie as alias to
      	new CODE_FOR_neon_udotv4siv16qi.
      	(CODE_FOR_neon_usdotv16qi): Definie as alias to
      	new CODE_FOR_neon_usdotv4siv16qi.
      bfa44e60
    • Victor Do Nascimento's avatar
      aarch64: Fix aarch64 backend-use of (u|s|us)dot_prod patterns · 0d0be1d1
      Victor Do Nascimento authored
      Given recent changes to the dot_prod standard pattern name, this patch
      fixes the aarch64 back-end by implementing the following changes:
      
      1. Add 2nd mode to all (u|s|us)dot_prod patterns in .md files.
      2. Rewrite initialization and function expansion mechanism for simd
      builtins.
      3. Fix all direct calls to back-end `dot_prod' patterns in SVE
      builtins.
      
      Finally, given that it is now possible for the compiler to
      differentiate between the two- and four-way dot product, we add a test
      to ensure that autovectorization picks up on dot-product patterns
      where the result is twice the width of the operands.
      
      gcc/ChangeLog:
      
      	* config/aarch64/aarch64-simd.md
      	(<sur>dot_prod<vsi2qi><vczle><vczbe>): Renamed to...
      	(<sur>dot_prod<mode><vsi2qi><vczle><vczbe>): ...this.
      	(usdot_prod<vsi2qi><vczle><vczbe>): Renamed to...
      	(usdot_prod<mode><vsi2qi><vczle><vczbe>): ...this.
      	(<su>sadv16qi): Adjust call to gen_udot_prod take second mode.
      	(popcount<mode2>): fix use of `udot_prod_optab'.
      	* config/aarch64/aarch64-sve.md
      	(<sur>dot_prod<vsi2qi>): Renamed to...
      	(<sur>dot_prod<mode><vsi2qi>): ...this.
      	(@<sur>dot_prod<vsi2qi>): Renamed to...
      	(@<sur>dot_prod<mode><vsi2qi>): ...this.
      	(<su>sad<vsi2qi>): Adjust call to gen_udot_prod take second mode.
      	* config/aarch64/aarch64-sve2.md
      	(@aarch64_sve_<sur>dotvnx4sivnx8hi): Renamed to...
      	(<sur>dot_prodvnx4sivnx8hi): ...this.
      	* config/aarch64/aarch64-simd-builtins.def: Modify macro
      	expansion-based initialization and expansion
      	of (u|s|us)dot_prod builtins.
      	* config/aarch64/aarch64-builtins.cc
      	(CODE_FOR_aarch64_sdot_prodv8qi): Define as alias to
      	new CODE_FOR_sdot_prodv2siv8qi.
      	(CODE_FOR_aarch64_udot_prodv8qi): Define as alias to
      	new CODE_FOR_udot_prodv2siv8qi.
      	(CODE_FOR_aarch64_usdot_prodv8qi): Define as alias to
      	new CODE_FOR_usdot_prodv2siv8qi.
      	(CODE_FOR_aarch64_sdot_prodv16qi): Define as alias to
      	new CODE_FOR_sdot_prodv4siv16qi.
      	(CODE_FOR_aarch64_udot_prodv16qi): Define as alias to
      	new CODE_FOR_udot_prodv4siv16qi.
      	(CODE_FOR_aarch64_usdot_prodv16qi): Define as alias to
      	new CODE_FOR_usdot_prodv4siv16qi.
      	* config/aarch64/aarch64-sve-builtins-base.cc
      	(svdot_impl::expand): s/direct/convert/ in
      	`convert_optab_handler_for_sign' function call.
      	(svusdot_impl::expand): add second mode argument in call to
      	`code_for_dot_prod'.
      	* config/aarch64/aarch64-sve-builtins.cc
      	(function_expander::convert_optab_handler_for_sign): New class
      	method.
      	* config/aarch64/aarch64-sve-builtins.h
      	(class function_expander): Add prototype for new
      	`convert_optab_handler_for_sign' method.
      
      gcc/testsuite/ChangeLog:
      	* gcc.target/aarch64/sme/vect-dotprod-twoway.c (udot2): New.
      0d0be1d1
    • Victor Do Nascimento's avatar
      autovectorizer: Add basic support for convert optabs · c7fba0e9
      Victor Do Nascimento authored
      Given the shift from modeling dot products as direct optabs to
      treating them as conversion optabs, we make necessary changes to the
      autovectorizer code to ensure that given the relevant tree code,
      together with the input and output data modes, we can retrieve the
      relevant optab and subsequently the insn_code for it.
      
      gcc/ChangeLog:
      
      	* gimple-match-exports.cc (directly_supported_p): Add overload
      	for conversion-type optabs.
      	* gimple-match.h (directly_supported_p): Add new function
      	prototype.
      	* optabs.cc (expand_widen_pattern_expr): Make the
      	DOT_PROD_EXPR tree code use `find_widening_optab_handler' to
      	retrieve icode.
      	* tree-vect-loop.cc (vect_is_emulated_mixed_dot_prod): make it
      	call conversion-type overloaded `directly_supported_p'.
      	* tree-vect-patterns.cc (vect_supportable_conv_optab_p): New.
      	(vect_recog_dot_prod_pattern): s/direct/conv/ in call to
      	`vect_supportable_direct_optab_p'.
      c7fba0e9
Loading