Skip to content
Snippets Groups Projects
  1. Nov 14, 2023
    • Jonathan Wakely's avatar
      libstdc++: Fix <charconv> uses of signed types with <bit> functions · 1c153033
      Jonathan Wakely authored
      In <charconv> we pass the int __base parameter to our internal versions
      of <bit> functions, __bit_width and __countr_zero. Those functions are
      only defined for unsigned types, so we need to convert the base to
      unsigned. The base must be in the range [2,36] so we can mask off the
      low bits and then convert that to unsigned, so that we don't need to
      care about negative values becoming large unsigned values.
      
      libstdc++-v3/ChangeLog:
      
      	* include/std/charconv (__from_chars_pow2_base): Convert base to
      	unsigned for call to __countr_zero.
      	(__from_chars_alnum): Likewise for call to __bit_width.
      1c153033
    • Jonathan Wakely's avatar
      libstdc++: Fix std::hash<std::stacktrace> [PR112348] · 6f2fc42d
      Jonathan Wakely authored
      libstdc++-v3/ChangeLog:
      
      	PR libstdc++/112348
      	* include/std/stacktrace (hash<basic_stacktrace<Alloc>>): Fix
      	type of hash functio nfor entries.
      	* testsuite/19_diagnostics/stacktrace/hash.cc: New test.
      6f2fc42d
    • David Malcolm's avatar
      analyzer: enable taint state machine by default [PR103533] · cfaaa8b1
      David Malcolm authored
      
      gcc/analyzer/ChangeLog:
      	PR analyzer/103533
      	* sm-taint.cc: Remove "experimental" from comment.
      	* sm.cc (make_checkers): Always add taint state machine.
      
      gcc/ChangeLog:
      	PR analyzer/103533
      	* doc/invoke.texi (Static Analyzer Options): Add the six
      	-Wanalyzer-tainted-* warnings.  Update documentation of each
      	warning to reflect removed requirement to use
      	-fanalyzer-checker=taint.  Remove discussion of
      	-fanalyzer-checker=taint.
      
      gcc/testsuite/ChangeLog:
      	PR analyzer/103533
      	* c-c++-common/analyzer/attr-tainted_args-1.c: Remove use of
      	-fanalyzer-checker=taint.
      	* c-c++-common/analyzer/fread-1.c: Likewise.
      	* c-c++-common/analyzer/pr104029.c: Likewise.
      	* gcc.dg/analyzer/pr93032-mztools-signed-char.c: Add params to
      	work around state explosion.
      	* gcc.dg/analyzer/pr93032-mztools-unsigned-char.c: Likewise.
      	* gcc.dg/analyzer/pr93382.c: Remove use of
      	-fanalyzer-checker=taint.
      	* gcc.dg/analyzer/switch-enum-taint-1.c: Likewise.
      	* gcc.dg/analyzer/taint-CVE-2011-2210-1.c: Likewise.
      	* gcc.dg/analyzer/taint-CVE-2020-13143-1.c: Likewise.
      	* gcc.dg/analyzer/taint-CVE-2020-13143-2.c: Likewise.
      	* gcc.dg/analyzer/taint-CVE-2020-13143.h: Likewise.
      	* gcc.dg/analyzer/taint-alloc-1.c: Likewise.
      	* gcc.dg/analyzer/taint-alloc-2.c: Likewise.
      	* gcc.dg/analyzer/taint-alloc-3.c: Likewise.
      	* gcc.dg/analyzer/taint-alloc-4.c: Likewise.
      	* gcc.dg/analyzer/taint-alloc-5.c: Likewise.
      	* gcc.dg/analyzer/taint-assert-BUG_ON.c: Likewise.
      	* gcc.dg/analyzer/taint-assert-macro-expansion.c: Likewise.
      	* gcc.dg/analyzer/taint-assert-system-header.c: Likewise.
      	* gcc.dg/analyzer/taint-assert.c: Likewise.
      	* gcc.dg/analyzer/taint-divisor-1.c: Likewise.
      	* gcc.dg/analyzer/taint-divisor-2.c: Likewise.
      	* gcc.dg/analyzer/taint-merger.c: Likewise.
      	* gcc.dg/analyzer/taint-ops.c: Delete this test: it was a
      	duplicate of material in operations.c and data-model-1.c, with
      	-fanalyzer-checker=taint added.
      	* gcc.dg/analyzer/taint-read-index-1.c: Remove use of
      	-fanalyzer-checker=taint.
      	* gcc.dg/analyzer/taint-read-offset-1.c: Likewise.
      	* gcc.dg/analyzer/taint-realloc.c: Likewise.  Add missing
      	dg-warning for leak now that the malloc state machine is also
      	active.
      	* gcc.dg/analyzer/taint-size-1.c: Remove use of
      	-fanalyzer-checker=taint.
      	* gcc.dg/analyzer/taint-size-access-attr-1.c: Likewise.
      	* gcc.dg/analyzer/taint-write-index-1.c: Likewise.
      	* gcc.dg/analyzer/taint-write-offset-1.c: Likewise.
      	* gcc.dg/analyzer/torture/taint-read-index-2.c: Likewise.
      	* gcc.dg/analyzer/torture/taint-read-index-3.c: Likewise.
      	* gcc.dg/plugin/taint-CVE-2011-0521-1-fixed.c: Likewise.  Add
      	-Wno-pedantic.
      	* gcc.dg/plugin/taint-CVE-2011-0521-1.c: Likewise.
      	* gcc.dg/plugin/taint-CVE-2011-0521-2-fixed.c: Likewise.
      	* gcc.dg/plugin/taint-CVE-2011-0521-2.c: Likewise.
      	* gcc.dg/plugin/taint-CVE-2011-0521-3-fixed.c: Likewise.
      	* gcc.dg/plugin/taint-CVE-2011-0521-3.c: Likewise.  Fix C++-style
      	comment.
      	* gcc.dg/plugin/taint-CVE-2011-0521-4.c: Remove use of
      	-fanalyzer-checker=taint and add -Wno-pedantic. Remove xfail and
      	add missing dg-warning.
      	* gcc.dg/plugin/taint-CVE-2011-0521-5-fixed.c: Remove use of
      	-fanalyzer-checker=taint and add -Wno-pedantic.
      	* gcc.dg/plugin/taint-CVE-2011-0521-5.c: Likewise.
      	* gcc.dg/plugin/taint-CVE-2011-0521-6.c: Likewise.
      	* gcc.dg/plugin/taint-antipatterns-1.c: : Remove use of
      	-fanalyzer-checker=taint.
      
      Signed-off-by: default avatarDavid Malcolm <dmalcolm@redhat.com>
      cfaaa8b1
    • Jakub Jelinek's avatar
      Manually add ChangeLog entry for r14-5312-g040e5b0edbca861196d9e2ea2af5e805769c8d5d commit. · c6560525
      Jakub Jelinek authored
      This commit got ignored because ChangeLog update can't parse its log message.
      c6560525
    • Dimitar Dimitrov's avatar
      testsuite: Ignore warning for unsupported option · 3d8d443c
      Dimitar Dimitrov authored
      
      The -w option was used in gcc.dg/20020206-1.c to ignore warnings if the
      '-fprefetch-loop-arrays' option is not supported by target.
      
      When commit r14-5380-g5c432b0efab54e removed the -w option, some targets
      (arm-none-eabi, pru and possibly others) started failing the test:
      
        cc1: warning: '-fprefetch-loop-arrays' not supported for this target
        FAIL: gcc.dg/20020206-1.c (test for excess errors)
      
      Fix by instructing DejaGnu to prune the '-fprefetch-loop-arrays'
      warning.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.dg/20020206-1.c: Prune warning that
      	-fprefetch-loop-arrays is not supported.
      
      Signed-off-by: default avatarDimitar Dimitrov <dimitar@dinux.eu>
      3d8d443c
    • Nathaniel Shead's avatar
      c++: Stream virtual dtor vtable indices · 14979dd3
      Nathaniel Shead authored
      
      Virtual cloned functions have distinct vtable indices, stream them
      explicitly.
      
      As such, this patch ensures that DECL_VINDEX is properly passed on for
      cloned functions as well to prevent this from causing issues.
      
      	PR c++/103499
      
      gcc/cp/ChangeLog:
      
      	* module.cc (trees_out::decl_node): Write DECL_VINDEX for
      	virtual clones.
      	(trees_in::tree_node): Read DECL_VINDEX for virtual clones.
      
      gcc/testsuite/ChangeLog:
      
      	* g++.dg/modules/pr103499_a.C: New test.
      	* g++.dg/modules/pr103499_b.C: New test.
      
      Signed-off-by: default avatarNathaniel Shead <nathanieloshead@gmail.com>
      Signed-off-by: default avatarNathan Sidwell <nathan@acm.org>
      14979dd3
    • Nathaniel Shead's avatar
      c++: Fix exported using decls of templates · 5b9ecce8
      Nathaniel Shead authored
      
      We need to look at DECL_TEMPLATE_RESULT to get the module attachment.
      
      	PR c++/106849
      
      gcc/cp/ChangeLog:
      
      	* name-lookup.cc (do_nonmember_using_decl): Handle
      	TEMPLATE_DECLs when checking module attachment.
      
      gcc/testsuite/ChangeLog:
      
      	* g++.dg/modules/using-9.C: New test.
      
      Signed-off-by: default avatarNathaniel Shead <nathanieloshead@gmail.com>
      Signed-off-by: default avatarNathan Sidwell <nathan@acm.org>
      5b9ecce8
    • David Malcolm's avatar
      diagnostics: make option-handling callbacks private · 353f146c
      David Malcolm authored
      
      No functional change intended.
      
      gcc/c-family/ChangeLog:
      	* c-warn.cc (conversion_warning): Update call to
      	global_dc->m_option_enabled to use option_enabled_p.
      
      gcc/cp/ChangeLog:
      	* decl.cc (finish_function): Update call to
      	global_dc->m_option_enabled to use option_enabled_p.
      
      gcc/ChangeLog:
      	* diagnostic-format-json.cc
      	(json_output_format::on_end_diagnostic): Update calls to m_context
      	callbacks to use member functions; tighten up scopes.
      	* diagnostic-format-sarif.cc (sarif_builder::make_result_object):
      	Likewise.
      	(sarif_builder::make_reporting_descriptor_object_for_warning):
      	Likewise.
      	* diagnostic.cc (diagnostic_context::initialize): Update for
      	callbacks being moved into m_option_callbacks and being renamed.
      	(diagnostic_context::set_option_hooks): New.
      	(diagnostic_option_classifier::classify_diagnostic): Update call
      	to global_dc->m_option_enabled to use option_enabled_p.
      	(diagnostic_context::print_option_information): Update calls to
      	m_context callbacks to use member functions; tighten up scopes.
      	(diagnostic_context::diagnostic_enabled): Likewise.
      	* diagnostic.h (diagnostic_option_enabled_cb): New typedef.
      	(diagnostic_make_option_name_cb): New typedef.
      	(diagnostic_make_option_url_cb): New typedef.
      	(diagnostic_context::option_enabled_p): New.
      	(diagnostic_context::make_option_name): New.
      	(diagnostic_context::make_option_url): New.
      	(diagnostic_context::set_option_hooks): New decl.
      	(diagnostic_context::m_option_enabled): Rename to
      	m_option_enabled_cb and move within m_option_callbacks, using
      	typedef.
      	(diagnostic_context::m_option_state): Move within
      	m_option_callbacks.
      	(diagnostic_context::m_option_name): Rename to
      	m_make_option_name_cb and move within m_option_callbacks, using
      	typedef.
      	(diagnostic_context::m_get_option_url): Likewise, renaming to
      	m_make_option_url_cb.
      	* lto-wrapper.cc (print_lto_docs_link): Update call to m_context
      	callback to use member function.
      	(main): Use diagnostic_context::set_option_hooks.
      	* opts-diagnostic.h (option_name): Make context param const.
      	(get_option_url): Likewise.
      	* opts.cc (option_name): Likewise.
      	(get_option_url): Likewise.
      	* toplev.cc (general_init): Use
      	diagnostic_context::set_option_hooks.
      
      Signed-off-by: default avatarDavid Malcolm <dmalcolm@redhat.com>
      353f146c
    • David Malcolm's avatar
      diagnostics: make m_text_callbacks private · 07e568d7
      David Malcolm authored
      
      No functional change intended.
      
      gcc/ChangeLog:
      	* diagnostic-show-locus.cc (diagnostic_context::show_locus):
      	Update for renaming of text callbacks fields.
      	* diagnostic.cc (diagnostic_context::initialize): Likewise.
      	* diagnostic.h (class diagnostic_context): Add "friend" for
      	accessors to m_text_callbacks.
      	(diagnostic_context::m_text_callbacks): Make private, and add an
      	"m_" prefix to field names.
      	(diagnostic_starter): Convert from macro to inline function.
      	(diagnostic_start_span): New.
      	(diagnostic_finalizer): Convert from macro to inline function.
      
      gcc/fortran/ChangeLog:
      	* error.cc (gfc_diagnostics_init): Use diagnostic_start_span.
      
      gcc/ChangeLog:
      	* selftest-diagnostic.cc
      	(test_diagnostic_context::test_diagnostic_context): Use
      	diagnostic_start_span.
      	* tree-diagnostic-path.cc (struct event_range): Likewise.
      
      gcc/testsuite:
      	* gcc.dg/plugin/diagnostic_group_plugin.c: Use
      	diagnostic_start_span.
      
      Signed-off-by: default avatarDavid Malcolm <dmalcolm@redhat.com>
      07e568d7
    • David Malcolm's avatar
      diagnostics: convert diagnostic_ready_p to an inline function · d0bfd6ba
      David Malcolm authored
      
      No functional change intended.
      
      gcc/ChangeLog:
      	* diagnostic.h (diagnostic_ready_p): Convert from macro to inline
      	function.
      
      Signed-off-by: default avatarDavid Malcolm <dmalcolm@redhat.com>
      d0bfd6ba
    • Uros Bizjak's avatar
      i386: Generate strict_low_part QImode insn with high input register · b42a09b2
      Uros Bizjak authored
      Following testcase:
      
      struct S1
      {
        unsigned char val;
        unsigned char pad1;
        unsigned short pad2;
      };
      
      struct S2
      {
        unsigned char pad1;
        unsigned char val;
        unsigned short pad2;
      };
      
      struct S1 test_and (struct S1 a, struct S2 b)
      {
        a.val &= b.val;
      
        return a;
      }
      
      compiles with -O2 to:
      
      	movl    %esi, %edx
      	movl    %edi, %eax
      	movzbl  %dh, %esi
      	andb    %sil, %al
      
      ANDB could use high register %dh instead of %sil:
      
      	movl    %edi, %eax
      	movl    %esi, %edx
      	andb    %dh, %al
      
      Patch introduces strict_low_part QImode insn patterns with one of
      its input arguments extracted from high register.
      
      	PR target/78904
      
      gcc/ChangeLog:
      
      	* config/i386/i386.md (*addqi_ext<mode>_1_slp):
      	New define_insn_and_split pattern.
      	(*subqi_ext<mode>_1_slp): Ditto.
      	(*<any_logic:code>qi_ext<mode>_1_slp): Ditto.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.target/i386/pr78904-7.c: New test.
      	* gcc.target/i386/pr78904-7a.c: New test.
      	* gcc.target/i386/pr78904-7b.c: New test.
      b42a09b2
    • Jakub Jelinek's avatar
      libcpp, contrib: Update to Unicode 15.1 · d64b7c82
      Jakub Jelinek authored
      The following patch (in plaintext just a pseudo-patch where I've left out
      the too big parts of either wget downloaded or regenerated files out with
      ..., full patch attached compressed) updates to Unicode 15.1 from 15.0
      we had last year.  Apparently Unicode forgot to add a new range to 4-8 Table
      we are using, but from the other files it is clear what should have been
      added; I've filed a bugreport against Unicode.
      
      2023-11-14  Jakub Jelinek  <jakub@redhat.com>
      
      contrib/
      	* unicode/README: Adjust glibc git commit hash, number of Unicode
      	data files to be updated and latest Unicode version.
      	* unicode/from_glibc/utf8_gen.py: Update from glibc.
      	* unicode/UnicodeData.txt: Update from Unicode 15.1.
      	* unicode/EastAsianWidth.txt: Likewise.
      	* unicode/DerivedNormalizationProps.txt: Likewise.
      	* unicode/NameAliases.txt: Likewise.
      	* unicode/DerivedCoreProperties.txt: Likewise.
      	* unicode/PropList.txt: Likewise.
      libcpp/
      	* makeucnid.cc (write_copyright): Update copyright year.
      	* makeuname2c.cc (write_copyright): Likewise.
      	(struct generated): Update latest Unicode version.
      	(generated_ranges): Add 2ebf0-2ee5d CJK UNIFIED IDEOGRAPH
      	range which was forgotten to be added to 4-8 table, but
      	clearly is expected to be there from the 15.1 additions.
      	* ucnid.h: Regenerated.
      	* uname2c.h: Regenerated.
      	* generated_cpp_wcwidth.h: Regenerated.
      d64b7c82
    • Jakub Jelinek's avatar
      c++: Implement C++26 P1854R4 - Making non-encodable string literals ill-formed [PR110341] · 194825f2
      Jakub Jelinek authored
      This paper voted in as DR makes some multi-character literals ill-formed.
      'abcd' stays valid, but e.g. 'á' is newly invalid in UTF-8 exec charset
      while valid e.g. in ISO-8859-1, because it is a single character which needs
      2 bytes to be encoded.
      
      The following patch does that by checking (only pedantically, especially
      because it is a DR) if we'd emit a -Wmultichar warning because character
      constant has more than one byte in it whether the number of source characters
      is equal to the number of bytes in the multichar string.
      If it is, it is normal multi-character literal constant
      and is diagnosed normally with -Wmultichar, otherwise at least one of the
      c-chars in the sequence was encoded as 2+ bytes.
      
      2023-11-14  Jakub Jelinek  <jakub@redhat.com>
      
      	PR c++/110341
      libcpp/
      	* charset.cc: Implement C++26 P1854R4 - Making non-encodable string
      	literals ill-formed.
      	(one_count_chars, convert_count_chars, count_source_chars): New
      	functions.
      	(narrow_str_to_charconst): Change last arg type from cpp_ttype to
      	const cpp_token *.  For C++ if pedantic and i > 1 in CPP_CHAR
      	interpret token also as CPP_STRING32 and if number of characters
      	in the CPP_STRING32 is larger than number of bytes in CPP_CHAR,
      	pedwarn on it.  Make the diagnostics more detailed.
      	(wide_str_to_charconst): Change last arg type from cpp_ttype to
      	const cpp_token *.  Make the diagnostics more detailed.
      	(cpp_interpret_charconst): Adjust narrow_str_to_charconst and
      	wide_str_to_charconst callers.
      gcc/testsuite/
      	* g++.dg/cpp26/literals1.C: New test.
      	* g++.dg/cpp26/literals2.C: New test.
      	* g++.dg/cpp23/wchar-multi1.C: Adjust expected diagnostic wordings.
      	* g++.dg/cpp23/wchar-multi2.C: Likewise.
      	* gcc.dg/c23-utf8char-3.c: Likewise.
      	* gcc.dg/cpp/charconst-4.c: Likewise.
      	* gcc.dg/cpp/charconst.c: Likewise.
      	* gcc.dg/cpp/if-2.c: Likewise.
      	* gcc.dg/utf16-4.c: Likewise.
      	* gcc.dg/utf32-4.c: Likewise.
      	* g++.dg/cpp1z/utf8-neg.C: Likewise.
      	* g++.dg/cpp2a/ucn2.C: Likewise.
      	* g++.dg/ext/utf16-4.C: Likewise.
      	* g++.dg/ext/utf32-4.C: Likewise.
      194825f2
    • Andrew Stubbs's avatar
      Fix ICE generating uniform vector masks · 948b8b6e
      Andrew Stubbs authored
      Most targets have an "and" instructions for their vector mask size, but RISC-V
      only has DImode "and".  Fixed by allowing wider instruction modes.
      
      gcc/ChangeLog:
      
      	PR target/112481
      	* expr.cc (store_constructor): Use OPTAB_WIDEN for mask adjustment.
      948b8b6e
    • David Malcolm's avatar
      input.h: eliminate implicit users of global_dc's file_cache · 1bdd665a
      David Malcolm authored
      
      This patch eliminates the following functions that implicitly used
      global_dc's file cache:
      
        extern char_span location_get_source_line (const char *file_path, int line);
        extern char_span get_source_file_content (const char *file_path);
        extern bool location_missing_trailing_newline (const char *file_path);
      
      in favor of explicitly using a specific file_cache throughout, and only
      using global_dc's file_cache in gcc-specific code.
      
      Rather than creating global_dc's file_cache the first time its needed,
      this patch simply creates one when a diagnostic_context is initialized,
      and eliminates diagnostic_file_cache_init.
      
      No functional change intended.
      
      gcc/c-family/ChangeLog:
      	* c-common.cc (c_get_substring_location): Use global_dc's
      	file_cache.
      	* c-format.cc (get_corrected_substring): Likewise.
      	* c-indentation.cc (get_visual_column): Add file_cache param.
      	(get_first_nws_vis_column): Likewise.
      	(detect_intervening_unindent): Likewise.
      	(should_warn_for_misleading_indentation): Use global_dc's
      	file_cache.
      	(assert_get_visual_column_succeeds): Add file_cache param.
      	(ASSERT_GET_VISUAL_COLUMN_SUCCEEDS): Likewise.
      	(assert_get_visual_column_fails): Likewise.
      	(define ASSERT_GET_VISUAL_COLUMN_FAILS): Likewise.
      	(selftest::test_get_visual_column): Create and use a temporary
      	file_cache.
      
      gcc/cp/ChangeLog:
      	* contracts.cc (build_comment): Use global_dc's file_cache.
      
      gcc/ChangeLog:
      	* diagnostic-format-sarif.cc (sarif_builder::get_sarif_column):
      	Use m_context's file_cache.
      	(sarif_builder::maybe_make_artifact_content_object): Likewise.
      	(sarif_builder::get_source_lines): Likewise.
      	* diagnostic-show-locus.cc
      	(exploc_with_display_col::exploc_with_display_col): Add file_cache
      	param.
      	(layout::m_file_cache): New field.
      	(make_range): Add file_cache param.
      	(selftest::test_layout_range_for_single_point): Create and use a
      	temporary file_cache.
      	(selftest::test_layout_range_for_single_line): Likewise.
      	(selftest::test_layout_range_for_multiple_lines): Likewise.
      	(layout::layout): Initialize m_file_cache from the context and use it.
      	(layout::maybe_add_location_range): Use m_file_cache.
      	(layout::calculate_x_offset_display): Likewise.
      	(get_affected_range): Add file_cache param.
      	(get_printed_columns): Likewise.
      	(line_corrections::line_corrections): Likewwise.
      	(line_corrections::m_file_cache): New field.
      	(source_line::source_line): Add file_cache param.
      	(line_corrections::add_hint): Use m_file_cache.
      	(layout::print_trailing_fixits): Likewise.
      	(layout::print_line): Likewise.
      	(selftest::test_layout_x_offset_display_utf8): Create and use a
      	temporary file_cache.
      	(selftest::test_layout_x_offset_display_tab): Likewise.
      	(selftest::test_diagnostic_show_locus_one_liner_utf8): Likewise.
      	(selftest::test_add_location_if_nearby): Pass global_dc's
      	file_cache to temp_source_file ctor.
      	(selftest::test_overlapped_fixit_printing): Create and use a
      	temporary file_cache.
      	(selftest::test_overlapped_fixit_printing_utf8): Likewise.
      	(selftest::test_overlapped_fixit_printing_2): Use dc's file_cache.
      	* diagnostic.cc (diagnostic_context::initialize): Always create a
      	file_cache.
      	(diagnostic_context::initialize_input_context): Assume
      	m_file_cache has already been created.
      	(diagnostic_context::create_edit_context): Pass m_file_cache to
      	edit_context.
      	(convert_column_unit): Add file_cache param.
      	(diagnostic_context::converted_column): Use context's file_cache.
      	(print_parseable_fixits): Add file_cache param.
      	(diagnostic_context::report_diagnostic): Use context's file_cache.
      	(selftest::test_print_parseable_fixits_none): Create and use a
      	temporary file_cache.
      	(selftest::test_print_parseable_fixits_insert): Likewise.
      	(selftest::test_print_parseable_fixits_remove): Likewise.
      	(selftest::test_print_parseable_fixits_replace): Likewise.
      	(selftest::test_print_parseable_fixits_bytes_vs_display_columns):
      	Likewise.
      	* diagnostic.h (diagnostic_context::file_cache_init): Delete.
      	(diagnostic_context::get_file_cache): Convert return type from
      	pointer to reference.
      	* edit-context.cc (edited_file::get_file_cache): New.
      	(edited_file::m_edit_context): New.
      	(edit_context::edit_context): Add file_cache param.
      	(edit_context::get_or_insert_file): Pass this to edited_file's
      	ctor.
      	(edited_file::edited_file): Add edit_context param.
      	(edited_file::print_content): Use get_file_cache.
      	(edited_file::print_diff_hunk): Likewise.
      	(edited_file::print_run_of_changed_lines): Likewise.
      	(edited_file::get_or_insert_line): Likewise.
      	(edited_file::get_num_lines): Likewise.
      	(edited_line::edited_line): Pass in file_cache and use it.
      	(selftest::test_get_content): Create and use a
      	temporary file_cache.
      	(selftest::test_applying_fixits_insert_before): Likewise.
      	(selftest::test_applying_fixits_insert_after): Likewise.
      	(selftest::test_applying_fixits_insert_after_at_line_end):
      	Likewise.
      	(selftest::test_applying_fixits_insert_after_failure): Likewise.
      	(selftest::test_applying_fixits_insert_containing_newline):
      	Likewise.
      	(selftest::test_applying_fixits_growing_replace): Likewise.
      	(selftest::test_applying_fixits_shrinking_replace): Likewise.
      	(selftest::test_applying_fixits_replace_containing_newline):
      	Likewise.
      	(selftest::test_applying_fixits_remove): Likewise.
      	(selftest::test_applying_fixits_multiple): Likewise.
      	(selftest::test_applying_fixits_multiple_lines): Likewise.
      	(selftest::test_applying_fixits_modernize_named_init): Likewise.
      	(selftest::test_applying_fixits_modernize_named_init): Likewise.
      	(selftest::test_applying_fixits_unreadable_file): Likewise.
      	(selftest::test_applying_fixits_line_out_of_range): Likewise.
      	(selftest::test_applying_fixits_column_validation): Likewise.
      	(selftest::test_applying_fixits_column_validation): Likewise.
      	(selftest::test_applying_fixits_column_validation): Likewise.
      	(selftest::test_applying_fixits_column_validation): Likewise.
      	* edit-context.h (edit_context::edit_context): Add file_cache
      	param.
      	(edit_context::get_file_cache): New.
      	(edit_context::m_file_cache): New.
      	* final.cc: Include "diagnostic.h".
      	(asm_show_source): Use global_dc's file_cache.
      	* gcc-rich-location.cc (blank_line_before_p): Add file_cache
      	param.
      	(use_new_line): Likewise.
      	(gcc_rich_location::add_fixit_insert_formatted): Use global dc's
      	file_cache.
      	* input.cc (diagnostic_file_cache_init): Delete.
      	(diagnostic_context::file_cache_init): Delete.
      	(diagnostics_file_cache_forcibly_evict_file): Delete.
      	(file_cache::missing_trailing_newline_p): New.
      	(file_cache::evicted_cache_tab_entry): Don't call
      	diagnostic_file_cache_init.
      	(location_get_source_line): Delete.
      	(get_source_text_between): Add file_cache param.
      	(get_source_file_content): Delete.
      	(location_missing_trailing_newline): Delete.
      	(location_compute_display_column): Add file_cache param.
      	(dump_location_info): Create and use temporary file_cache.
      	(get_substring_ranges_for_loc): Add file_cache param.
      	(get_location_within_string): Likewise.
      	(get_source_range_for_char): Likewise.
      	(get_num_source_ranges_for_substring): Likewise.
      	(selftest::test_reading_source_line): Create and use temporary
      	file_cache.
      	(selftest::lexer_test::m_file_cache): New field.
      	(selftest::assert_char_at_range): Use test.m_file_cache.
      	(selftest::assert_num_substring_ranges): Likewise.
      	(selftest::assert_has_no_substring_ranges): Likewise.
      	(selftest::test_lexer_string_locations_concatenation_2): Likewise.
      	* input.h (class file_cache): New forward decl.
      	(location_compute_display_column): Add file_cache param.
      	(location_get_source_line): Delete.
      	(get_source_text_between): Add file_cache param.
      	(get_source_file_content): Delete.
      	(location_missing_trailing_newline): Delete.
      	(file_cache::missing_trailing_newline_p): New decl.
      	(diagnostics_file_cache_forcibly_evict_file): Delete.
      	* selftest.cc (named_temp_file::named_temp_file): Add file_cache
      	param.
      	(named_temp_file::~named_temp_file): Optionally evict the file
      	from the given file_cache.
      	(temp_source_file::temp_source_file): Add file_cache param.
      	* selftest.h (class file_cache): New forward decl.
      	(named_temp_file::named_temp_file): Add file_cache param.
      	(named_temp_file::m_file_cache): New field.
      	(temp_source_file::temp_source_file): Add file_cache param.
      	* substring-locations.h (get_location_within_string): Add
      	file_cache param.
      
      gcc/testsuite/ChangeLog:
      	* gcc.dg/plugin/diagnostic_plugin_test_show_locus.c: Use
      	global_dc's file cache.
      	* gcc.dg/plugin/expensive_selftests_plugin.c: Likewise.
      
      Signed-off-by: default avatarDavid Malcolm <dmalcolm@redhat.com>
      1bdd665a
    • David Malcolm's avatar
      json: reduce use of naked new in json-building code · 070944fd
      David Malcolm authored
      
      No functional change intended.
      
      gcc/ChangeLog:
      	* diagnostic-format-json.cc: Use type-specific "set_*" functions
      	of json::object to avoid naked new of json value subclasses.
      	* diagnostic-format-sarif.cc: Likewise.
      	* gcov.cc: Likewise.
      	* json.cc (object::set_string): New.
      	(object::set_integer): New.
      	(object::set_float): New.
      	(object::set_bool): New.
      	(selftest::test_writing_objects): Use object::set_string.
      	* json.h (object::set_string): New decl.
      	(object::set_integer): New decl.
      	(object::set_float): New decl.
      	(object::set_bool): New decl.
      	* optinfo-emit-json.cc: Use type-specific "set_*" functions of
      	json::object to avoid naked new of json value subclasses.
      	* timevar.cc: Likewise.
      	* tree-diagnostic-path.cc: Likewise.
      
      Signed-off-by: default avatarDavid Malcolm <dmalcolm@redhat.com>
      070944fd
    • Jonathan Wakely's avatar
      libstdc++: Fix std::deque::size() Xmethod [PR112491] · 4db82092
      Jonathan Wakely authored
      The Xmethod for std::deque::size() assumed that the first element would
      be at the start of the first node. That's only true if elements are only
      added at the back. If an element is inserted at the front, or removed
      from the front (or anywhere before the middle) then the first node will
      not be completely populated, and the Xmethod will give the wrong result.
      
      libstdc++-v3/ChangeLog:
      
      	PR libstdc++/112491
      	* python/libstdcxx/v6/xmethods.py (DequeWorkerBase.size): Fix
      	calculation to use _M_start._M_cur.
      	* testsuite/libstdc++-xmethods/deque.cc: Check failing cases.
      4db82092
    • Andrew MacLeod's avatar
      Use case label type to create case range. · 8f331be4
      Andrew MacLeod authored
      Create a range from the label type, and cast it to the required type.
      
      	PR tree-optimization/112509
      	gcc/
      	* tree-vrp.cc (find_case_label_range): Create range from case labels.
      
      	gcc/testsuite/
      	* gcc.dg/pr112509.c: New.
      8f331be4
    • Stefan Schulze Frielinghaus's avatar
      s390: Fix vec_scatter_element for vectors of floats · 2c2fcd6d
      Stefan Schulze Frielinghaus authored
      The offset for vec_scatter_element of floats should be a vector of type
      UV4SI instead of V4SF.  Note, this is an incompatibility change.
      
      gcc/ChangeLog:
      
      	* config/s390/s390-builtin-types.def: Add/remove types.
      	* config/s390/s390-builtins.def (s390_vec_scatter_element_flt):
      	The type for the offset should be UV4SI instead of V4SF.
      2c2fcd6d
    • Saurabh Jha's avatar
      Add a REG_P check for inc and dec for Arm MVE · ddb479e7
      Saurabh Jha authored
      This patch tightens mve_vector_mem_operand to reject non-register operands inside {PRE,POST}_{INC,DEC} addresses by introducing a REG_P check.
      
      This patch fixes this ICE:https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112337
      
      gcc/ChangeLog:
      
      	PR target/112337
      	* config/arm/arm.cc (mve_vector_mem_operand): Add a REG_P check for INC
      	and DEC operations.
      
      gcc/testsuite/ChangeLog:
      
      	PR target/112337
      	* gcc.target/arm/mve/pr112337.c: Test for REG_P check for INC and DEC
      	operations.
      ddb479e7
    • Richard Biener's avatar
      tree-optimization/111233 - loop splitting miscompile · 2066c29b
      Richard Biener authored
      The change in r14-2852-gf5fb9ff2396fd4 failed to update patch_loop_exit
      to compensate for rewriting of a NE/EQ_EXPR to a new code.  Fixed
      with the following.
      
      	PR tree-optimization/111233
      	PR tree-optimization/111652
      	PR tree-optimization/111727
      	PR tree-optimization/111838
      	PR tree-optimization/112113
      	* tree-ssa-loop-split.cc (patch_loop_exit): Get the new
      	guard code instead of the old guard stmt.
      	(split_loop): Adjust.
      
      	* gcc.dg/torture/pr111233.c: New testcase.
      	* gcc.dg/torture/pr111652.c: Likewise.
      	* gcc.dg/torture/pr111727.c: Likewise.
      	* gcc.dg/torture/pr111838.c: Likewise.
      	* gcc.dg/torture/pr112113.c: Likewise.
      2066c29b
    • Richard Biener's avatar
      Loop distribution fix for SCC detection · bc390ae7
      Richard Biener authored
      The following adjusts data_dep_in_cycle_p to properly consider the
      whole loop nest when looking for data dep cycles and exempting
      zero-distance DDRs instead of just the outermost loop.
      
      	* tree-loop-distribution.cc (loop_distribution::data_dep_in_cycle_p):
      	Consider all loops in the nest when looking for
      	lambda_vector_zerop.
      bc390ae7
    • Richard Biener's avatar
      tree-optimization/112281 - loop distribution and zero dependence distances · 5ea2965b
      Richard Biener authored
      We currently distribute
      
        for (c = 2; c; c--)
          for (e = 0; e < 2; e++) {
            d[c] = b = d[c + 1];
            d[c + 1].a = 0;
          }
      
      in a wrong way where the inner loop zero dependence distance should
      make us preserve stmt execution order.  We fail to do so since we
      only look for a fully zero distance vector rather than looking at
      the innermost loop distance.  This is somewhat similar to PR87022
      where we instead looked at the outermost loop distance and changed
      this to what we do now.  The following switches us to look at the
      innermost loop distance.
      
      	PR tree-optimization/112281
      	* tree-loop-distribution.cc (pg_add_dependence_edges):
      	Preserve stmt order when the innermost loop has exact
      	overlap.
      
      	* gcc.dg/torture/pr112281.c: New testcase.
      5ea2965b
    • GCC Administrator's avatar
      Daily bump. · b9fd8399
      GCC Administrator authored
      b9fd8399
    • Jakub Jelinek's avatar
      i386: Fix up <insn><dwi>3_doubleword_lowpart [PR112523] · aad65285
      Jakub Jelinek authored
      On Sun, Nov 12, 2023 at 09:03:42PM -0000, Roger Sayle wrote:
      > This patch improves register pressure during reload, inspired by PR 97756.
      > Normally, a double-word right-shift by a constant produces a double-word
      > result, the highpart of which is dead when followed by a truncation.
      > The dead code calculating the high part gets cleaned up post-reload, so
      > the issue isn't normally visible, except for the increased register
      > pressure during reload, sometimes leading to odd register assignments.
      > Providing a post-reload splitter, which clobbers a single wordmode
      > result register instead of a doubleword result register, helps (a bit).
      
      Unfortunately this broke bootstrap on i686-linux, broke all ACATS tests
      on x86_64-linux as well as miscompiled e.g. __floattisf in libgcc there
      as well.
      
      The bug is that shrd{l,q} instruction expects the low part of the input
      to be the same register as the output, rather than the high part as the
      patch implemented.
        split_double_mode (<DWI>mode, &operands[1], 1, &operands[1], &operands[3]);
      sets operands[1] to the lo_half and operands[3] to the hi_half, so if
      operands[0] is not the same register as operands[1] (rather than [3]) after
      RA, we should during splitting move operands[1] into operands[0].
      
      Your testcase:
      > #define MASK60 ((1ul << 60) - 1)
      > unsigned long foo (__uint128_t n)
      > {
      >   unsigned long a = n & MASK60;
      >   unsigned long b = (n >> 60);
      >   b = b & MASK60;
      >   unsigned long c = (n >> 120);
      >   return a+b+c;
      > }
      
      still has the same number of instructions.
      
      Bootstrapped/regtested on x86_64-linux (where it e.g. turns
                      === acats Summary ===
      -# of unexpected failures       2328
      +# of expected passes           2328
      +# of unexpected failures       0
      and fixes gcc.dg/torture/fp-int-convert-*timode.c FAILs as well)
      and i686-linux (where it previously didn't bootstrap, but compared to
      Friday evening's bootstrap the testresults are ok).
      
      2023-11-14  Jakub Jelinek  <jakub@redhat.com>
      
      	PR target/112523
      	PR ada/112514
      	* config/i386/i386.md (<insn><dwi>3_doubleword_lowpart): Move
      	operands[1] aka low part of input rather than operands[3] aka high
      	part of input to output if not the same register.
      aad65285
    • Jakub Jelinek's avatar
      contrib: Ignore the r14-5312-g040e5b0edbca861196d9e2ea2af5e805769c8d5d bogus commit · 0a1dd8b5
      Jakub Jelinek authored
      The r14-5312-g040e5b0edbca861196d9e2ea2af5e805769c8d5d commit log contains
      a line from git revert with correct hash, but unfortunately hand ammended
      with explanation, so it got through the pre-commit hook but failed during
      update_version_git generation.  Please don't do this.
      
      2023-11-14  Jakub Jelinek  <jakub@redhat.com>
      
      contrib/ChangeLog:
      	* gcc-changelog/git_update_version.py: Add
      	040e5b0e to ignored commits.
      0a1dd8b5
    • Georg-Johann Lay's avatar
      LibF7: sinh: Fix loss of precision due to cancellation for small values. · 3232e73c
      Georg-Johann Lay authored
      libgcc/config/avr/libf7/
      	* libf7-const.def [F7MOD_sinh_]: Add MiniMax polynomial.
      	* libf7.c (f7_sinh): Use it instead of (exp(x) - exp(-x)) / 2
      	when |x| < 0.5 to avoid loss of precision due to cancellation.
      3232e73c
    • Lehua Ding's avatar
      x86: Make testcase apx-spill_to_egprs-1.c more robust · e47e836f
      Lehua Ding authored
      Hi,
      
      This little patch adjust the assert in apx-spill_to_egprs-1.c testcase.
      The -mapxf compilation option allows more registers to be used, which in
      turn eliminates the need for local variables to be stored in stack memory.
      Therefore, the assertion is changed to detects no memory loaded through the
      %rsp register.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.target/i386/apx-spill_to_egprs-1.c: Make sure that no local
      	variables are stored on the stack.
      e47e836f
    • Andreas Krebbel's avatar
      IBM Z: Add GTY marker to builtin data structures · 426e9264
      Andreas Krebbel authored
      This adds GTY markers to s390_builtin_types, s390_builtin_fn_types,
      and s390_builtin_decls. These were missing causing problems in
      particular when using builtins after including a precompiled header.
      
      Unfortunately the declaration of these data structures use enum values
      from s390-builtins.h.  This file however is not included everywhere
      and is rather large.  In order to include it only for the purpose of
      gtype-desc.cc we place a preprocessed copy of it in the build
      directory and include only this.
      
      This is going to be backported to GCC 12 and 13.
      
      gcc/ChangeLog:
      
      	* config.gcc: Add s390-gen-builtins.h to target_gtfiles.
      	* config/s390/s390-builtins.h (s390_builtin_types)
      	(s390_builtin_fn_types, s390_builtin_decls): Add GTY marker.
      	* config/s390/t-s390 (EXTRA_GTYPE_DEPS): Add s390-gen-builtins.h.
      	Add build rule for s390-gen-builtins.h.
      426e9264
    • Andreas Krebbel's avatar
      IBM Z: Fix ICE with overloading and checking enabled · a745d206
      Andreas Krebbel authored
      s390_resolve_overloaded_builtin, when called on NON_DEPENDENT_EXPR,
      ICEs when using the type from it which ends up as error_mark_node.
      
      This particular instance of the problem does not occur anymore since
      NON_DEPENDENT_EXPR has been removed.  Nevertheless that case needs to
      be handled here.
      
      gcc/ChangeLog:
      
      	* config/s390/s390-c.cc (s390_fn_types_compatible): Add a check
      	for error_mark_node.
      
      gcc/testsuite/ChangeLog:
      
      	* g++.target/s390/zvec-templ-1.C: New test.
      a745d206
    • Jonathan Wakely's avatar
      c++: Link extended FP conversion pedwarns to -Wnarrowing [PR111842] · 69d69865
      Jonathan Wakely authored
      Several users have been confused by the status of these warnings,
      which can be misunderstood as "this might not be what you want",
      rather than diagnostics required by the C++ standard. Add the text "ISO
      C++ does not allow" to make this clear.
      
      Also link them to -Wnarrowing so that they can be disabled or promoted
      to errors independently of other pedwarns.
      
      	PR c++/111842
      	PR c++/112498
      
      gcc/cp/ChangeLog:
      
      	* call.cc (convert_like_internal): Use OPT_Wnarrowing for
      	pedwarns about illformed conversions involving extended
      	floating-point types. Clarify that ISO C++ requires these
      	diagnostics.
      
      gcc/testsuite/ChangeLog:
      
      	* g++.dg/cpp23/ext-floating16.C: New test.
      	* g++.dg/cpp23/ext-floating17.C: New test.
      69d69865
    • Jakub Jelinek's avatar
      Add type-generic clz/ctz/clrsb/ffs/parity/popcount builtins [PR111309] · 7383cb56
      Jakub Jelinek authored
      The following patch adds 6 new type-generic builtins,
      __builtin_clzg
      __builtin_ctzg
      __builtin_clrsbg
      __builtin_ffsg
      __builtin_parityg
      __builtin_popcountg
      The g at the end stands for generic because the unsuffixed variant
      of the builtins already have unsigned int or int arguments.
      
      The main reason to add these is to support arbitrary unsigned (for
      clrsb/ffs signed) bit-precise integer types and also __int128 which
      wasn't supported by the existing builtins, so that e.g. <stdbit.h>
      type-generic functions could then support not just bit-precise unsigned
      integer type whose width matches a standard or extended integer type,
      but others too.
      
      None of these new builtins promote their first argument, so the argument
      can be e.g. unsigned char or unsigned short or unsigned __int20 etc.
      The first 2 support either 1 or 2 arguments, if only 1 argument is supplied,
      the behavior is undefined for argument 0 like for other __builtin_c[lt]z*
      builtins, if 2 arguments are supplied, the second argument should be int
      that will be returned if the argument is 0.  All other builtins have
      just one argument.  For __builtin_clrsbg and __builtin_ffsg the argument
      shall be any signed standard/extended or bit-precise integer, for the others
      any unsigned standard/extended or bit-precise integer (bool not allowed).
      
      One possibility would be to also allow signed integer types for
      the clz/ctz/parity/popcount ones (and just cast the argument to
      unsigned_type_for during folding) and similarly unsigned integer types
      for the clrsb/ffs ones, dunno what is better; for stdbit.h the current
      version is sufficient and diagnoses use of the inappropriate sign,
      though on the other side I wonder if users won't be confused by
      __builtin_clzg (1) being an error and having to write __builtin_clzg (1U).
      
      The new builtins are lowered to corresponding builtins with other suffixes
      or internal calls (plus casts and adjustments where needed) during FE
      folding or during gimplification at latest, the non-suffixed builtins
      handling precisions up to precision of int, l up to precision of long,
      ll up to precision of long long, up to __int128 precision lowered to
      double-word expansion early and the rest (which must be _BitInt) lowered
      to internal fn calls - those are then lowered during bitint lowering pass.
      
      The patch also changes representation of IFN_CLZ and IFN_CTZ calls,
      previously they were in the IL only if they are directly supported optab
      and depending on C[LT]Z_DEFINED_VALUE_AT_ZERO (...) == 2 they had or didn't
      have defined behavior at 0, now they are in the IL either if directly
      supported optab, or for the large/huge BITINT_TYPEs and they have either
      1 or 2 arguments.  If one, the behavior is undefined at zero, if 2, the
      second argument is an int constant that should be returned for 0.
      As there is no extra support during expansion, for directly supported optab
      the second argument if present should still match the
      C[LT]Z_DEFINED_VALUE_AT_ZERO (...) == 2 value, but for BITINT_TYPE arguments
      it can be arbitrary int INTEGER_CST.
      
      The indended uses in stdbit.h are e.g.
       #ifdef __has_builtin
       #if __has_builtin(__builtin_clzg) && __has_builtin(__builtin_ctzg) && __has_builtin(__builtin_popcountg)
       #define stdc_leading_zeros(value) \
       ((unsigned int) __builtin_clzg (value, __builtin_popcountg ((__typeof (value)) ~(__typeof (value)) 0)))
       #define stdc_leading_ones(value) \
       ((unsigned int) __builtin_clzg ((__typeof (value)) ~(value), __builtin_popcountg ((__typeof (value)) ~(__typeof (value)) 0)))
       #define stdc_first_trailing_one(value) \
       ((unsigned int) (__builtin_ctzg (value, -1) + 1))
       #define stdc_trailing_zeros(value) \
       ((unsigned int) __builtin_ctzg (value, __builtin_popcountg ((__typeof (value)) ~(__typeof (value)) 0)))
       #endif
       #endif
      where __builtin_popcountg ((__typeof (x)) -1) computes the bit precision
      of x's type (kind of _Bitwidthof (x) alternative).
      
      They also allow casting of arbitrary unsigned _BitInt other than
      unsigned _BitInt(1) to corresponding signed _BitInt by using
      signed _BitInt(__builtin_popcountg ((__typeof (a)) -1))
      and of arbitrary signed _BitInt to corresponding unsigned _BitInt
      using unsigned _BitInt(__builtin_clrsbg ((__typeof (a)) -1) + 1).
      
      2023-11-14  Jakub Jelinek  <jakub@redhat.com>
      
      	PR c/111309
      gcc/
      	* builtins.def (BUILT_IN_CLZG, BUILT_IN_CTZG, BUILT_IN_CLRSBG,
      	BUILT_IN_FFSG, BUILT_IN_PARITYG, BUILT_IN_POPCOUNTG): New
      	builtins.
      	* builtins.cc (fold_builtin_bit_query): New function.
      	(fold_builtin_1): Use it for
      	BUILT_IN_{CLZ,CTZ,CLRSB,FFS,PARITY,POPCOUNT}G.
      	(fold_builtin_2): Use it for BUILT_IN_{CLZ,CTZ}G.
      	* fold-const-call.cc: Fix comment typo on tm.h inclusion.
      	(fold_const_call_ss): Handle
      	CFN_BUILT_IN_{CLZ,CTZ,CLRSB,FFS,PARITY,POPCOUNT}G.
      	(fold_const_call_sss): New function.
      	(fold_const_call_1): Call it for 2 argument functions returning
      	scalar when passed 2 INTEGER_CSTs.
      	* genmatch.cc (cmp_operand): For function calls also compare
      	number of arguments.
      	(fns_cmp): New function.
      	(dt_node::gen_kids): Sort fns and generic_fns.
      	(dt_node::gen_kids_1): Handle fns with the same id but different
      	number of arguments.
      	* match.pd (CLZ simplifications): Drop checks for defined behavior
      	at zero.  Add variant of simplifications for IFN_CLZ with 2 arguments.
      	(CTZ simplifications): Drop checks for defined behavior at zero,
      	don't optimize precisions above MAX_FIXED_MODE_SIZE.  Add variant of
      	simplifications for IFN_CTZ with 2 arguments.
      	(a != 0 ? CLZ(a) : CST -> .CLZ(a)): Use TREE_TYPE (@3) instead of
      	type, add BITINT_TYPE handling, create 2 argument IFN_CLZ rather than
      	one argument.  Add variant for matching CLZ with 2 arguments.
      	(a != 0 ? CTZ(a) : CST -> .CTZ(a)): Similarly.
      	* gimple-lower-bitint.cc (bitint_large_huge::lower_bit_query): New
      	method.
      	(bitint_large_huge::lower_call): Use it for IFN_{CLZ,CTZ,CLRSB,FFS}
      	and IFN_{PARITY,POPCOUNT} calls.
      	* gimple-range-op.cc (cfn_clz::fold_range): Don't check
      	CLZ_DEFINED_VALUE_AT_ZERO for m_gimple_call_internal_p, instead
      	assume defined value at zero if the call has 2 arguments and use
      	second argument value for that case.
      	(cfn_ctz::fold_range): Similarly.
      	(gimple_range_op_handler::maybe_builtin_call): Use op_cfn_clz_internal
      	or op_cfn_ctz_internal only if internal fn call has 2 arguments and
      	set m_op2 in that case.
      	* tree-vect-patterns.cc (vect_recog_ctz_ffs_pattern,
      	vect_recog_popcount_clz_ctz_ffs_pattern): For value defined at zero
      	use second argument of calls if present, otherwise assume UB at zero,
      	create 2 argument .CLZ/.CTZ calls if needed.
      	* tree-vect-stmts.cc (vectorizable_call): Handle 2 argument .CLZ/.CTZ
      	calls.
      	* tree-ssa-loop-niter.cc (build_cltz_expr): Create 2 argument
      	.CLZ/.CTZ calls if needed.
      	* tree-ssa-forwprop.cc (simplify_count_trailing_zeroes): Create 2
      	argument .CTZ calls if needed.
      	* tree-ssa-phiopt.cc (cond_removal_in_builtin_zero_pattern): Handle
      	2 argument .CLZ/.CTZ calls, handle BITINT_TYPE, create 2 argument
      	.CLZ/.CTZ calls.
      	* doc/extend.texi (__builtin_clzg, __builtin_ctzg, __builtin_clrsbg,
      	__builtin_ffsg, __builtin_parityg, __builtin_popcountg): Document.
      gcc/c-family/
      	* c-common.cc (check_builtin_function_arguments): Handle
      	BUILT_IN_{CLZ,CTZ,CLRSB,FFS,PARITY,POPCOUNT}G.
      	* c-gimplify.cc (c_gimplify_expr): If __builtin_c[lt]zg second
      	argument hasn't been folded into constant yet, transform it to one
      	argument call inside of a COND_EXPR which for first argument 0
      	returns the second argument.
      gcc/c/
      	* c-typeck.cc (convert_arguments): Don't promote first argument
      	of BUILT_IN_{CLZ,CTZ,CLRSB,FFS,PARITY,POPCOUNT}G.
      gcc/cp/
      	* call.cc (magic_varargs_p): Return 4 for
      	BUILT_IN_{CLZ,CTZ,CLRSB,FFS,PARITY,POPCOUNT}G.
      	(build_over_call): Don't promote first argument of
      	BUILT_IN_{CLZ,CTZ,CLRSB,FFS,PARITY,POPCOUNT}G.
      	* cp-gimplify.cc (cp_gimplify_expr): For BUILT_IN_C{L,T}ZG use
      	c_gimplify_expr.
      gcc/testsuite/
      	* c-c++-common/pr111309-1.c: New test.
      	* c-c++-common/pr111309-2.c: New test.
      	* gcc.dg/torture/bitint-43.c: New test.
      	* gcc.dg/torture/bitint-44.c: New test.
      7383cb56
    • Xi Ruoyao's avatar
      LoongArch: Disable relaxation if the assembler don't support conditional... · fe23a2ff
      Xi Ruoyao authored
      LoongArch: Disable relaxation if the assembler don't support conditional branch relaxation [PR112330]
      
      As the commit message of r14-4674 has indicated, if the assembler does
      not support conditional branch relaxation, a relocation overflow may
      happen on conditional branches when relaxation is enabled because the
      number of NOP instructions inserted by the assembler will be more than
      the number estimated by GCC.
      
      To work around this issue, disable relaxation by default if the
      assembler is detected incapable to perform conditional branch relaxation
      at GCC build time.  We also need to pass -mno-relax to the assembler to
      really disable relaxation.  But, if the assembler does not support
      -mrelax option at all, we should not pass -mno-relax to the assembler or
      it will immediately error out.  Also handle this with the build time
      assembler capability probing, and add a pair of options
      -m[no-]pass-mrelax-to-as to allow using a different assembler from the
      build-time one.
      
      With this change, if GCC is built with GAS 2.41, relaxation will be
      disabled by default.  So the default value of -mexplicit-relocs= is also
      changed to 'always' if -mno-relax is specified or implied by the
      build-time default, because using assembler macros for symbol addresses
      produces no benefit when relaxation is disabled.
      
      gcc/ChangeLog:
      
      	PR target/112330
      	* config/loongarch/genopts/loongarch.opt.in: Add
      	-m[no]-pass-relax-to-as.  Change the default of -m[no]-relax to
      	account conditional branch relaxation support status.
      	* config/loongarch/loongarch.opt: Regenerate.
      	* configure.ac (gcc_cv_as_loongarch_cond_branch_relax): Check if
      	the assembler supports conditional branch relaxation.
      	* configure: Regenerate.
      	* config.in: Regenerate.  Note that there are some unrelated
      	changes introduced by r14-5424 (which does not contain a
      	config.in regeneration).
      	* config/loongarch/loongarch-opts.h
      	(HAVE_AS_COND_BRANCH_RELAXATION): Define to 0 if not defined.
      	* config/loongarch/loongarch-driver.h (ASM_MRELAX_DEFAULT):
      	Define.
      	(ASM_MRELAX_SPEC): Define.
      	(ASM_SPEC): Use ASM_MRELAX_SPEC instead of "%{mno-relax}".
      	* config/loongarch/loongarch.cc: Take the setting of
      	-m[no-]relax into account when determining the default of
      	-mexplicit-relocs=.
      	* doc/invoke.texi: Document -m[no-]relax and
      	-m[no-]pass-mrelax-to-as for LoongArch.  Update the default
      	value of -mexplicit-relocs=.
      fe23a2ff
    • liuhongt's avatar
      Fix ICE in vectorizable_nonlinear_induction with bitfield. · f28306b4
      liuhongt authored
       if (TREE_CODE (init_expr) == INTEGER_CST)
          init_expr = fold_convert (TREE_TYPE (vectype), init_expr);
        else
          gcc_assert (tree_nop_conversion_p (TREE_TYPE (vectype),
                                             TREE_TYPE (init_expr)));
      
      and init_expr is a 24 bit integer type while vectype has 32bit components.
      
      The "fix" is to bail out instead of asserting.
      
      gcc/ChangeLog:
      
      	PR tree-optimization/112496
      	* tree-vect-loop.cc (vectorizable_nonlinear_induction): Return
      	false when !tree_nop_conversion_p (TREE_TYPE (vectype),
      	TREE_TYPE (init_expr)).
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.target/i386/pr112496.c: New test.
      f28306b4
    • Xi Ruoyao's avatar
      LoongArch: Use finer-grained DBAR hints · 4a70bfbf
      Xi Ruoyao authored
      LA664 defines DBAR hints 0x1 - 0x1f (except 0xf and 0x1f) as follows [1-2]:
      
      - Bit 4: kind of constraint (0: completion, 1: ordering)
      - Bit 3: barrier for previous read (0: true, 1: false)
      - Bit 2: barrier for previous write (0: true, 1: false)
      - Bit 1: barrier for succeeding read (0: true, 1: false)
      - Bit 0: barrier for succeeding write (0: true, 1: false)
      
      LLVM has already utilized them for different memory orders [3]:
      
      - Bit 4 is always set to one because it's only intended to be zero for
        things like MMIO devices, which are out of the scope of memory orders.
      - An acquire barrier is used to implement acquire loads like
      
          ld.d $a1, $t0, 0
          dbar acquire_hint
      
        where the load operation (ld.d) should not be reordered with any load
        or store operation after the acquire load.  To accomplish this
        constraint, we need to prevent the load operation from being reordered
        after the barrier, and also prevent any following load/store operation
        from being reordered before the barrier.  Thus bits 0, 1, and 3 must
        be zero, and bit 2 can be one, so acquire_hint should be 0b10100.
      - An release barrier is used to implement release stores like
      
          dbar release_hint
          st.d $a1, $t0, 0
      
        where the store operation (st.d) should not be reordered with any load
        or store operation before the release store.  So we need to prevent
        the store operation from being reordered before the barrier, and also
        prevent any preceding load/store operation from being reordered after
        the barrier.  So bits 0, 2, 3 must be zero, and bit 1 can be one.  So
        release_hint should be 0b10010.
      
      A similar mapping has been utilized for RISC-V GCC [4], LoongArch Linux
      kernel [1], and LoongArch LLVM [3].  So the mapping should be correct.
      And I've also bootstrapped & regtested GCC on a LA664 with this patch.
      
      The LoongArch CPUs should treat "unknown" hints as dbar 0, so we can
      unconditionally emit the new hints without a compiler switch.
      
      [1]: https://git.kernel.org/torvalds/c/e031a5f3f1ed
      [2]: https://github.com/loongson-community/docs/pull/12
      [3]: https://github.com/llvm/llvm-project/pull/68787
      [4]: https://gcc.gnu.org/r14-406
      
      gcc/ChangeLog:
      
      	* config/loongarch/sync.md (mem_thread_fence): Remove redundant
      	check.
      	(mem_thread_fence_1): Emit finer-grained DBAR hints for
      	different memory models, instead of 0.
      4a70bfbf
    • Jakub Jelinek's avatar
      tree: Handle BITINT_TYPE in type_contains_placeholder_1 [PR112511] · 6e5f318f
      Jakub Jelinek authored
      The following testcase ICEs because BITINT_TYPE isn't handled in
      type_contains_placeholder_1.  Given that Ada doesn't emit it, it doesn't
      matter that much where exactly we handle it as right now it should never
      contain a placeholder; I've picked the same spot as INTEGER_TYPE, but if
      you prefer e.g. the one with OFFSET_TYPE above, I can move it there too.
      
      2023-11-14  Jakub Jelinek  <jakub@redhat.com>
      
      	PR middle-end/112511
      	* tree.cc (type_contains_placeholder_1): Handle BITINT_TYPE like
      	INTEGER_TYPE.
      
      	* gcc.dg/pr112511.c: New test.
      6e5f318f
    • Jakub Jelinek's avatar
      i386: Don't optimize vshuf{i,f}{32x4,64x2} and vperm{i,f}128 to vblendps for %ymm16+ [PR112435] · 6043bfbd
      Jakub Jelinek authored
      The vblendps instruction is only VEX encoded, not EVEX, so can't be used if
      there are %ymm16+ or EGPR registers involved.
      
      2023-11-14  Jakub Jelinek  <jakub@redhat.com>
      	    Hu, Lin1  <lin1.hu@intel.com>
      
      	PR target/112435
      	* config/i386/sse.md (avx512vl_shuf_<shuffletype>32x4_1<mask_name>,
      	<mask_codefor>avx512dq_shuf_<shuffletype>64x2_1<mask_name>): Add
      	alternative with just x instead of v constraints and xjm instead of
      	vm and use vblendps as optimization only with that alternative.
      
      	* gcc.target/i386/avx512vl-pr112435-1.c: New test.
      	* gcc.target/i386/avx512vl-pr112435-2.c: New test.
      	* gcc.target/i386/avx512vl-pr112435-3.c: New test.
      6043bfbd
    • Juzhe-Zhong's avatar
      RISC-V: Fix init-2.c assembly check · bfcb6e51
      Juzhe-Zhong authored
      Notice the assembly check of init-2.c is wrong.
      
      Committed.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.target/riscv/rvv/autovec/vls/init-2.c: Fix vid.v check.
      bfcb6e51
    • liuhongt's avatar
      Handle bitop with INTEGER_CST in analyze_and_compute_bitop_with_inv_effect. · fd1596f9
      liuhongt authored
      analyze_and_compute_bitop_with_inv_effect assumes the first operand is
      loop invariant which is not the case when it's INTEGER_CST.
      
      gcc/ChangeLog:
      
      	PR tree-optimization/105735
      	PR tree-optimization/111972
      	* tree-scalar-evolution.cc
      	(analyze_and_compute_bitop_with_inv_effect): Handle bitop with
      	INTEGER_CST.
      
      gcc/testsuite/ChangeLog:
      
      	* gcc.target/i386/pr105735-3.c: New test.
      fd1596f9
    • Sam James's avatar
      maintainer-scripts/gcc_release: cleanup whitespace · d22b8786
      Sam James authored
      
      maintainer-scripts/
      	* gcc_release: Cleanup whitespace.
      
      Signed-off-by: default avatarSam James <sam@gentoo.org>
      d22b8786
Loading