Commit Graph

214074 Commits

Author SHA1 Message Date
Pranil Dey
c756ee328c Fixed extract_types_for_resx function
The function was recursive in nature and there is a chance of runnign out of stack, so now ann iterative approach was used to get the types for resx
2024-10-25 00:57:07 +05:30
Pranil Dey
c4ab1c5710 Formatting for all functions done according to GNU standards and fixed testsuite fail bugs 2024-10-07 02:23:24 +05:30
Pranil Dey
f5b29909d5 Added function bool extract_types_for_resx and fixed more functions for testcases
1. bool extract_types_for_resx (gimple *,vec<tree> *) - This is for intiating the function static bool extract_types_for_resx (basic_block, vec<tree> *)
which gets the resx stmt from a basic block and aclears the aux value for all blocks
2. update_stmt_eh_region - This is changed to unlink and reinsert the regions incase of a resx stmt properly
2024-10-06 18:25:27 +05:30
Pranil Dey
da431b3514 Updated code for unlinking regions and update stmt_eh_regions as well 2024-10-05 10:26:15 +05:30
Pranil Dey
cd716809b8 Updated code for unlinking regions 2024-10-04 13:12:12 +05:30
Pranil Dey
0d0df5179b Updated code for inserting regions and changed the return parameters of extract_types_for call 2024-10-03 10:11:07 +05:30
Pranil Dey
1a736e2570 Added code for inserting regions 2024-10-01 19:50:42 +05:30
Pranil Dey
132a0acfde Updated tree-eh.h 2024-10-01 10:32:27 +05:30
Pranil Dey
27be11a6b2 resolved more conflicts 2024-10-01 10:12:35 +05:30
Pranil Dey
5a924600ea removed conflicts 2024-10-01 10:10:17 +05:30
Pranil Dey
97933e9596 Reolved some conflicts 2024-10-01 10:03:43 +05:30
Pranil Dey
5f1a438ba6 Added functions extract_fun_resx_types 2024-10-01 10:00:59 +05:30
Pranil Dey
6db81730ef Merge remote-tracking branch 'origin/devel/nothrow-detection' into devel/nothrow-detection 2024-10-01 10:00:26 +05:30
Pranil Dey
079ca47d41 Updated parameters of functions and typecasted resx stmts 2024-10-01 09:48:04 +05:30
Pranil Dey
7ec7872003 Integrated the resx functions with stmt_throw_types
update_stmt_eh_region updated for resx stmt support and extract_fun_resx_types fixed
2024-10-01 09:48:04 +05:30
Pranil Dey
47c2d0f6e0 Added the previous functions to the tree-eh.h file
Functions added:
1. void extract_types_for_resx (gimple *, vec<tree> *);
2. void extract_fun_resx_types (function *);
2024-10-01 09:48:04 +05:30
Pranil Dey
d1a84d379d RESX statement processing functions added:
1. extract_types_for_resx - Used as a helper for getting the types from a resx statement to use later in the extract_fun_resx_types
2. extract_fun_resx_types - Used for getting the types thrown and propagated outside a function
2024-10-01 09:48:04 +05:30
Pranil Dey
70505f5757 Fixed some indentations and function names
1. Changed function name extract_exception_types_for_call to extract_types_for_call due to length of the name
2. Fixed space indentation in some places
2024-10-01 09:48:04 +05:30
Pranil Dey
ba70ece436 Added some functions and fixed some testcase failures
1. odr_equivalent_or_derived_p in ipa-devirt.cc
2. same_or_derived_type in in tree-eh.cc
3. Fixed catch-all handling in match_lp function
2024-10-01 09:48:04 +05:30
Pranil Dey
9a70651a21 Edge redirection for exceptions.
This commit is contains change in code for the tree-eh.cc, tree-eh.h, MAINTAINERS and tree-cfg.cc files.
 Specifically it contains four functions -
1. void extract_exception_types_for_call which extracts the exception types in a call stmt and adds them into a vector tree.
2. bool stmt_throw_types does the same as stmt_could_throw the difference being that it also gives the list of exception types as given by the
 extract_exception_types_for_call function.
3. bool match_lp checks if a landing pad can handle any of the exception types given as input parameters by looking into the catch handlers.
4. update_stmt_eh_region is the function that walks up the EH tree and changes the landing pad for the last statement in a basic block in the control
 flow graph so that when the edge by make_eh_edge is created it points to the correct handlers.

Further work to be done regarding RESX stmts.
2024-10-01 09:48:03 +05:30
GCC Administrator
0939c8ca2f Daily bump. 2024-10-01 00:20:07 +00:00
Hans-Peter Nilsson
b1696ffd46 libstdc++-v3: Fix signed-overflow warning for newlib/ctype_base.h, PR116895
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.
2024-10-01 02:14:10 +02:00
Kugan Vivekanandarajah
ab07db3f24 [testcase] Fix-absfloat16.c-testcase
gcc/testsuite/ChangeLog:
	* gcc.dg/tree-ssa/absfloat16.c: Fix testcase.

Signed-off-by: Kugan Vivekanandarajah <kvivekananda@nvidia.com>
2024-10-01 08:57:35 +10:00
Marek Polacek
4bcfaaed25 c++: concept in default argument [PR109859]
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: Jason Merrill <jason@redhat.com>
2024-09-30 15:20:31 -04:00
Eric Botcazou
65073a5b90 Fix internal error during inlining after ICF pass
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.
2024-09-30 21:07:38 +02:00
David Malcolm
9c14f9a9c1 diagnostics: return text buffer from test_show_locus [PR116613]
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: David Malcolm <dmalcolm@redhat.com>
2024-09-30 11:48:30 -04:00
David Malcolm
e7a8fbe2fe diagnostics: require callers of diagnostic_show_locus to be explicit about the printer [PR116613]
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: David Malcolm <dmalcolm@redhat.com>
2024-09-30 11:48:30 -04:00
David Malcolm
be02253af8 diagnostics: isolate diagnostic_context with interface classes [PR116613]
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: David Malcolm <dmalcolm@redhat.com>
2024-09-30 11:48:29 -04:00
David Malcolm
cce52867d1 diagnostics: avoid using diagnostic_context's m_printer [PR116613]
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: David Malcolm <dmalcolm@redhat.com>
2024-09-30 11:48:29 -04:00
David Malcolm
3d3d20ccd8 diagnostics: use "%e" to avoid intermediate strings [PR116613]
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: David Malcolm <dmalcolm@redhat.com>
2024-09-30 11:48:29 -04:00
David Malcolm
4c7a58ac26 diagnostics: add "dump" to pretty_printer and output_buffer
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: David Malcolm <dmalcolm@redhat.com>
2024-09-30 11:48:28 -04:00
David Malcolm
3286b6724e diagnostics: fix typo in XHTML output [PR116792]
gcc/testsuite/ChangeLog:
	PR other/116792
	* gcc.dg/plugin/diagnostic_plugin_xhtml_format.c: Fix stray
	reference to JSON.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2024-09-30 11:48:28 -04:00
David Malcolm
ab6c7a329d diagnostics: fix memory leak in SARIF selftests
"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: David Malcolm <dmalcolm@redhat.com>
2024-09-30 11:48:28 -04:00
Victor Do Nascimento
8398ef96cc autovectorizer: Test autovectorization of different dot-prod modes.
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.
2024-09-30 15:59:43 +01:00
Victor Do Nascimento
fd35d99914 c6x: Adjust dot-product backend patterns
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.
2024-09-30 15:59:43 +01:00
Victor Do Nascimento
113e31cc32 rs6000: Adjust altivec dot-product backend patterns
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.
2024-09-30 15:59:43 +01:00
Victor Do Nascimento
d33786b162 mips: Adjust dot-product backend patterns
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.
2024-09-30 15:59:43 +01:00
Victor Do Nascimento
85a2ed0548 arc: Adjust dot-product backend patterns
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.
2024-09-30 15:59:43 +01:00
Victor Do Nascimento
c45ef5ee8d i386: Fix dot_prod backend patterns for mmx and sse targets
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.
2024-09-30 15:59:43 +01:00
Victor Do Nascimento
bfa44e604d arm: Fix arm backend-use of (u|s|us)dot_prod patterns
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.
2024-09-30 15:59:43 +01:00
Victor Do Nascimento
0d0be1d10d aarch64: Fix aarch64 backend-use of (u|s|us)dot_prod patterns
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.
2024-09-30 15:59:43 +01:00
Victor Do Nascimento
c7fba0e966 autovectorizer: Add basic support for convert optabs
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'.
2024-09-30 15:59:42 +01:00
Victor Do Nascimento
2f68d69e47 optabs: Make all `*dot_prod_optab's modeled as conversions
Given the specification in the GCC internals manual defines the
{u|s}dot_prod<m> standard name as taking "two signed elements of the
same mode, adding them to a third operand of wider mode", there is
currently ambiguity in the relationship between the mode of the first
two arguments and that of the third.

This vagueness means that, in theory, different modes may be
supportable in the third argument.  This flexibility would allow for a
given backend to add to the accumulator a different number of
vectorized products, e.g. A backend may provide instructions for both:

  accum += a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3]

and

  accum += a[0] * b[0] + a[1] * b[1],

as is now seen in the SVE2.1 extension to AArch64.  In spite of the
aforementioned flexibility, modeling the dot-product operation as a
direct optab means that we have no way to encode both input and the
accumulator data modes into the backend pattern name, which prevents
us from harnessing this flexibility.

We therefore make all dot_prod optabs conversions, allowing, for
example, for the encoding of both 2-way and 4-way dot product backend
patterns.

gcc/ChangeLog:

	* optabs.def (sdot_prod_optab): Convert from OPTAB_D to
	OPTAB_CD.
	(udot_prod_optab): Likewise.
	(usdot_prod_optab): Likewise.
	* doc/md.texi (Standard Names): update entries for u,s and us
	dot_prod names.
2024-09-30 15:59:42 +01:00
Richard Biener
18e905b461 tree-optimization/116879 - failure to recognize non-empty latch
When we relaxed the vectorizers constraint on loop structure verifying
the emptiness of the latch became too lose as can be seen in the case
for PR116879 where the latch effectively contains two basic-blocks
which one being an unmerged forwarder that's not empty.

	PR tree-optimization/116879
	* tree-vect-loop.cc (vect_analyze_loop_form): Scan all
	blocks that form the latch.

	* gcc.dg/pr116879.c: New testcase.
2024-09-30 16:19:43 +02:00
Pranil Dey
b602de4ed9 Merge branch 'master' of git+ssh://gcc.gnu.org/git/gcc into devel/nothrow-detection 2024-09-30 19:03:42 +05:30
Tamar Christina
87905f63a6 middle-end: check explicitly for external or constants when checking for loop invariant [PR116817]
The previous check if a value was external was checking
!vect_get_internal_def (vinfo, var) but this of course isn't completely right
as they could reductions etc.

This changes the check to just explicitly look at externals and constants.
Note that reductions remain unhandled here, but we don't support codegen of
boolean reductions today anyway.

So at the time we do then this would have the be handled as well in lowering.

gcc/ChangeLog:

	PR tree-optimization/116817
	* tree-vect-patterns.cc (vect_recog_bool_pattern): Check for const or
	externals.

gcc/testsuite/ChangeLog:

	PR tree-optimization/116817
	* g++.dg/vect/pr116817.cc: New test.
2024-09-30 13:06:24 +01:00
Andre Vehreschild
bac95615b5 Ensure coarrays in calls use a descriptor [PR81265]
gcc/fortran/ChangeLog:

	PR fortran/81265

	* trans-expr.cc (gfc_conv_procedure_call): Ensure coarrays use a
	descriptor when passed.

gcc/testsuite/ChangeLog:

	* gfortran.dg/coarray/pr81265.f90: New test.
2024-09-30 09:18:50 +02:00
Richard Biener
71bf3daa8d tree-optimization/116842 - vectorizer load hosting breaks UID order
The following fixes the case when vectorizing a load hoists an invariant
load and dependent stmts, thereby breaking UID order of said stmts.
While we duplicate the load we just move the dependences.

	PR tree-optimization/116842
	* tree-vect-stmts.cc (hoist_defs_of_uses): Sort stmts to hoist
	after UID to avoid breaking vect_stmt_dominates_stmt_p.

	* g++.dg/torture/pr116842.C: New testcase.
2024-09-30 07:41:04 +02:00
Richard Biener
85f5d06421 tree-optimization/116785 - relax volatile handling in PTA
When there's volatile qualified stores we do not have to treat the
destination as pointing to ANYTHING.  It's only when reading from
it that we want to treat the resulting pointers as pointing to ANYTHING.

	PR tree-optimization/116785
	* tree-ssa-structalias.cc (get_constraint_for_1): Only
	volatile qualified reads produce ANYTHING.
2024-09-30 07:41:04 +02:00
Richard Biener
64163657ba tree-optimization/116850 - corrupt post-dom info
Path isolation computes post-dominators on demand but can end up
splitting blocks after that, wrecking it.  We can delay splitting
of blocks until we no longer need the post-dom info which is what
the following patch does to solve the issue.

	PR tree-optimization/116850
	* gimple-ssa-isolate-paths.cc (bb_split_points): New global.
	(insert_trap): Delay BB splitting if post-doms are computed.
	(find_explicit_erroneous_behavior): Process delayed BB
	splitting after releasing post dominators.
	(gimple_ssa_isolate_erroneous_paths): Do not free post-dom
	info here.

	* gcc.dg/pr116850.c: New testcase.
2024-09-30 07:41:04 +02:00