Commit graph

216075 commits

Author SHA1 Message Date
Matthew Malcomson
2c605367b4 libstdc++: editorconfig: Adjust wildcard patterns
According to the editorconfig file format description, a match against
one of multiple different strings is described with those different
strings separated by commas and within curly braces.  E.g.
    [{x,y}.txt]

https://editorconfig.org/, under "Wildcard Patterns".

The current libstdc++-v3/.editorconfig file has a few places where we
match against similar globs by using strings separated by commas but
without the curly braces.  E.g.
    [*.h,*.cc]

This doesn't take affect in neovim nor emacs (as far as I can tell), I
haven't looked into other editors.
I would expect that following the standard syntax described in the
documentation would satisfy more editors.  Hence this patch suggests
following that standard by using something like:
    [*.{h,cc}]

libstdc++-v3/ChangeLog:

	* .editorconfig: Adjust globbing style to standard syntax.

Signed-off-by: Matthew Malcomson <mmalcomson@nvidia.com>
2024-12-07 08:49:26 +00:00
Kito Cheng
567b0405e3 Revert "RISC-V: Add const to function_shape::get_name [NFC]"
This reverts commit 9bf4cad4e4.
2024-12-07 08:23:58 +08:00
GCC Administrator
2e02cdbc5e Daily bump. 2024-12-07 00:20:02 +00:00
Lewis Hyatt
85018b146c
Support for 64-bit location_t: libgdiagnostics parts
Tweak libgdiagnostics.cc, which is necessarily sensitive to line-map
internals, to support 64-bit location_t as well.

gcc/ChangeLog:

	* libgdiagnostics.cc (struct diagnostic_manager): Use location_t(-1)
	instead of UINT_MAX to support 64-bit location_t as well.
	(diagnostic_manager::diagnostic_manager): Change hard-coded "5" to
	line_map_suggested_range_bits.
2024-12-06 19:01:37 -05:00
Lewis Hyatt
5c8b978817
Support for 64-bit location_t: RTL parts
Some RTL objects need to store a location_t. Currently, they store it in the
rt_int field of union rtunion, but in a world where location_t could be
64-bit, they need to store it in a larger variable. Unfortunately, rtunion
does not currently have a 64-bit int type for that purpose, so add one. In
order to avoid increasing any overhead when 64-bit locations are not in use,
the new field is dedicated for location_t storage only and has type
"location_t" so it will only be 64-bit if necessary. This necessitates
adding a new RTX format code 'L' for locations. There are very many switch
statements in the codebase that inspect the RTX format code. I took the
approach of finding all of them that handle code 'i' or 'n' and making sure
they handle 'L' too. I am sure that some of these call sites can never see
an 'L' code, but I thought it would be safer and more future-proof to handle
as many as possible, given it's just a line or two to add in most cases.

gcc/ChangeLog:

	* rtl.def (DEBUG_INSN): Use new format code 'L' for location_t fields.
	(INSN): Likewise.
	(JUMP_INSN): Likewise.
	(CALL_INSN): Likewise.
	(ASM_INPUT): Likewise.
	(ASM_OPERANDS): Likewise.
	* rtl.h (union rtunion): Add new location_t RT_LOC member for use by
	the 'L' format.
	(struct rtx_debug_insn): Adjust comment.
	(struct rtx_nonjump_insn): Adjust comment.
	(struct rtx_call_insn): Adjust comment.
	(XLOC): New accessor macro for rtunion::rt_loc.
	(X0LOC): Likewise.
	(XCLOC): Likewise.
	(INSN_LOCATION): Use XLOC instead of XUINT to retrieve a location_t.
	(NOTE_MARKER_LOCATION): Likewise for XCUINT -> XCLOC.
	(ASM_OPERANDS_SOURCE_LOCATION): Likewise.
	(ASM_INPUT_SOURCE_LOCATION):Likewise.
	(gen_rtx_ASM_INPUT): Adjust to use sL format instead of si.
	(gen_rtx_INSN): Adjust prototype to use location_r rather than int
	for the location.
	* cfgrtl.cc (force_nonfallthru_and_redirect): Change type of LOC
	local variable from int to location_t.
	* rtlhash.cc (add_rtx): Support 'L' format in the switch statement.
	* var-tracking.cc (loc_cmp): Likewise.
	* alias.cc (rtx_equal_for_memref_p): Likewise.
	* config/alpha/alpha.cc (summarize_insn): Likewise.
	* config/ia64/ia64.cc (rtx_needs_barrier): Likewise.
	* config/rs6000/rs6000.cc (rs6000_hash_constant): Likewise.
	* cse.cc (hash_rtx): Likewise.
	(exp_equiv_p): Likewise.
	* cselib.cc (rtx_equal_for_cselib_1): Likewise.
	(cselib_hash_rtx): Likewise.
	(cselib_expand_value_rtx_1): Likewise.
	* emit-rtl.cc (copy_insn_1): Likewise.
	(gen_rtx_INSN): Change the location argument from int to location_t,
	and call the corresponding gen_rtf_fmt_* function.
	* final.cc (leaf_renumber_regs_insn): Support 'L' format in the
	switch statement.
	* genattrtab.cc (attr_rtx_1): Likewise.
	* genemit.cc (gen_exp): Likewise.
	* gengenrtl.cc (type_from_format): Likewise.
	(accessor_from_format): Likewise.
	* gengtype.cc (adjust_field_rtx_def): Likewise.
	* genpeep.cc (match_rtx): Likewise; just mark gcc_unreachable() for
	now.
	* genrecog.cc (find_operand): Support 'L' format in the switch statement.
	(find_matching_operand): Likewise.
	(validate_pattern): Likewise.
	* gensupport.cc (subst_pattern_match): Likewise.
	(get_alternatives_number): Likewise.
	(collect_insn_data): Likewise.
	(alter_predicate_for_insn): Likewise.
	(alter_constraints): Likewise.
	(subst_dup): Likewise.
	* jump.cc (rtx_renumbered_equal_p): Likewise.
	* loop-invariant.cc (hash_invariant_expr_1): Likewise.
	* lra-constraints.cc (operands_match_p): Likewise.
	* lra.cc (lra_rtx_hash): Likewise.
	* print-rtl.cc (rtx_writer::print_rtx_operand_code_i): Refactor
	location_t-relevant code to...
	(rtx_writer::print_rtx_operand_code_L): ...new function here.
	(rtx_writer::print_rtx_operand): Support 'L' format in the switch statement.
	* print-rtl.h (rtx_writer::print_rtx_operand_code_L): Add prototype
	for new function.
	* read-rtl-function.cc (function_reader::read_rtx_operand): Support
	'L' format in the switch statement.
	(function_reader::read_rtx_operand_i_or_n): Rename to...
	(function_reader::read_rtx_operand_inL): ...this, and support 'L' as
	well.
	* read-rtl.cc (apply_int_iterator): Support 'L' format in the switch
	statement.
	(rtx_reader::read_rtx_operand): Likewise.
	* reload.cc (operands_match_p): Likewise.
	* rtl.cc (rtx_format): Add new code 'L'.
	(rtx_equal_p): Support 'L' in the switch statement. Remove dead code
	in the handling for 'i' and 'n'.
2024-12-06 19:01:34 -05:00
Lewis Hyatt
eaefc8f322
final: Fix call to INSN_LOCATION on a NOTE rtl
This function has a code path that calls INSN_LOCATION on an rtl note. For a
note, this returns the note type enum rather than a location, but it runs
without complaint even with --enable-checking=rtl because both are stored in
the rt_int member of the rtunion. A subsequent commit will add a new rtl
format code specifically for locations, in which case attempting to call
INSN_LOCATION on a note will trigger an error. Fix it up by handling the
case of a note missing a location separately.

gcc/ChangeLog:

	* final.cc (reemit_insn_block_notes): Don't try to call
	INSN_LOCATION on a NOTE rtl object. Don't call change_scope () for a
	NOTE missing a location.
2024-12-06 19:01:32 -05:00
Lewis Hyatt
568b3b3021
middle-end: Handle resized PHI nodes in loop_version()
While testing upcoming support for 64-bit location_t, I came across some
test failures on sparc (32-bit) that trigger when location_t is changed to
be 64-bit. The reason is that several call sites that make use of
loop_version() for performing loop optimizations assume that a gphi*
obtained prior to calling loop_version() will remain valid afterwards, but
this is not the case for a PHI that needs to be resized. It doesn't happen
usually, because PHI nodes usually have room for at least 4 arguments and
this is usually more than are needed, but this is not guaranteed.

Fix the affected callers by avoiding the assumption that a PHI node pointer
remains valid. For most cases, this is done by remembering instead the
gphi->result pointer, which contains a pointer back to the PHI node that is
kept up to date when the PHI is moved to a new address.

gcc/ChangeLog:

	* tree-parloops.cc (struct reduction_info): Store the result of the
	reduction PHI rather than the PHI itself.
	(reduction_info::reduc_phi): New member function.
	(reduction_hasher::equal): Adapt to the change in struct reduction_info.
	(reduction_phi): Likewise.
	(initialize_reductions): Likewise.
	(create_call_for_reduction_1): Likewise.
	(transform_to_exit_first_loop_alt): Likewise.
	(transform_to_exit_first_loop): Likewise.
	(build_new_reduction): Likewise.
	(set_reduc_phi_uids): Likewise.
	(try_create_reduction_list): Likewise.
	* tree-ssa-loop-split.cc (split_loop): Remember the PHI result
	variable so that the PHI can be found in case it is resized and move
	to a new address.
	* tree-vect-loop-manip.cc (vect_loop_versioning): After calling
	loop_version(), fix up stored PHI pointers in case they have
	changed.
	* tree-vectorizer.cc (vec_info::resync_stmt_addr): New function.
	* tree-vectorizer.h (vec_info::resync_stmt_addr): Declare.
2024-12-06 19:01:28 -05:00
Andrew MacLeod
c7fd6c4369 Only add inferred ranges if they change the value.
Do not add an inferred range if it is already incorprated in the
current range of an SSA_NAME.

	PR tree-optimization/117467
	* gimple-range-infer.cc (infer_range_manager::add_ranges): Check
	range_of_expr to see if the inferred range is needed.
2024-12-06 16:41:19 -05:00
Andrew MacLeod
faddf22942 Add a range query to inferred ranges.
Provide a range_query for any inferred range processing which wants to
examine the range of an argument to make decisions.  Add some comments.

	* gimple-range-cache.cc (ranger_cache::ranger_cache): Create the
	infer oracle using THIS as the range_query.
	* gimple-range-infer.cc (gimple_infer_range::gimple_infer_range):
	Add a range_query to the constructor and use it.
	(infer_range_manager::infer_range_manager): Add a range_query.
	* gimple-range-infer.h (gimple_infer_range): Adjust prototype.
	(infer_range_manager): Add a range_query.
	* value-query.cc (range_query::create_infer_oracle): Add a range_query.
	* value-query.h (range_query::create_infer_oracle): Update prototype.
2024-12-06 16:40:05 -05:00
Andrew MacLeod
48eda34624 Do not calculate an entry range for invariant names.
If an SSA_NAME is invariant, do not calculate an on_entry value.

	PR tree-optimization/117467
	* gimple-range-cache.cc (ranger_cache::entry_range): Do not
	invoke range_from_dom for invariant ssa-names.
2024-12-06 16:32:16 -05:00
Vladimir N. Makarov
75e7d1600f [PR117248][LRA]: Rewriting reg notes update and fix calculation of conflict hard regs of pseudo.
LRA updates conflict hard regs of pseudo when some hard reg dies.  A
complicated PA div/mod insns reference for clobbered explicit hard regs and
hard reg as operands.  It prevents some hard reg dying although they
still conflict with pseudos living through.  Although on such insns LRA
updates wrongly reg notes (REG_DEAD, REG_UNUSED) which are used later in
rematerialization subpass.  The patch fixes the problems.

gcc/ChangeLog:

	PR rtl-optimization/117248
	* lra-lives.cc (start_living, start_dying): Remove.
	(insn_regnos, out_insn_regnos, insn_regnos_live_after): New.
	(sparseset_contains_pseudos_p): Remove.
	(make_hard_regno_live, make_hard_regno_dead): Return true if
	something in liveness is changed.
	(mark_pseudo_live,  mark_pseudo_dead): Ditto.
	(mark_regno_live, mark_regno_dead): Ditto.
	(clear_sparseset_regnos, regnos_in_sparseset_p): Use set instead
	of dead_set.
	(process_bb_lives): Rewrite dealing with reg notes.  Update
	conflict hard regs even when clobber hard reg is not marked as
	dead.
	(lra_create_live_ranges_1): Add initialization/finalization of
	insn_regnos, out_insn_regnos, insn_regnos_live_after.
2024-12-06 16:19:39 -05:00
Jeff Law
42d84ba5db [PR tree-optimization/117895] Fix sparc libgo build failure with CRC opts enabled
So as noted in the BZ, sparc builds of the golang libraries were failing due to
the CRC code.

Ultimately this was another mode problem in the table expansion.  Essentially
when the mode of the resultant crc was different than the mode of the input
data we could create mixed mode operations which is a no-no.  Not entirely sure
how we were getting away with it before, but it was clearly wrong.

The mode of the crc will always be at least as large at the mode of the data
for the cases we support.  So the code has been adjusted to convert the data's
mode to the crc's mode and do all the ops in the crc mode.

That fixes the libgo build problem on sparc and I've verfied that there aren't
any regressions on x86_64 as well as all the embedded targets in my tester.

	PR tree-optimization/117895
gcc/
	* expr.cc (calculate_table_based_CRC): Drop CRC_MODE argument.
	Convert DATA to CRC's mode, then do calculations in CRC's mode.
	(expand_crc_table_based): Corresponding changes.
	(expand_reversed_crc_table_based): Corresponding changes.
2024-12-06 13:44:41 -07:00
David Malcolm
339246fb9e c++: use diagnostic nesting [PR116253]
This patch uses the nested diagnostics capabilities added in the earlier
patch in the C++ frontend.

With this, and enabling the non-standard text formatting via:
  -fdiagnostics-set-output=text:experimental-nesting=yes
and using:
  -std=c++20 -fconcepts-diagnostics-depth=2
then the output for the example in SG15's P3358R0 ("SARIF for Structured
Diagnostics") is:

P3358R0.C: In function ‘int main()’:
P3358R0.C:26:6: error: no matching function for call to ‘pet(lizard)’
   26 |   pet(lizard{});
      |   ~~~^~~~~~~~~~
  • note: candidate: ‘template<class auto:1>  requires  pettable<auto:1> void pet(auto:1)’
    P3358R0.C:21:6:
       21 | void pet(pettable auto t);
          |      ^~~
    • note: template argument deduction/substitution failed:
      • note: constraints not satisfied
        • P3358R0.C: In substitution of ‘template<class auto:1>  requires  pettable<auto:1> void pet(auto:1) [with auto:1 = lizard]’:
        • required from here
          P3358R0.C:26:6:
             26 |   pet(lizard{});
                |   ~~~^~~~~~~~~~
        • required for the satisfaction of ‘pettable<auto:1>’ [with auto:1 = lizard]
          P3358R0.C:19:9:
             19 | concept pettable = has_member_pet<T> or has_default_pet<T>;
                |         ^~~~~~~~
        • note: no operand of the disjunction is satisfied
          P3358R0.C:19:38:
             19 | concept pettable = has_member_pet<T> or has_default_pet<T>;
                |                    ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
          • note: the operand ‘has_member_pet<T>’ is unsatisfied because
            P3358R0.C:19:20:
               19 | concept pettable = has_member_pet<T> or has_default_pet<T>;
                  |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            • required for the satisfaction of ‘has_member_pet<T>’ [with T = lizard]
              P3358R0.C:13:9:
                 13 | concept has_member_pet = requires(T t) { t.pet(); };
                    |         ^~~~~~~~~~~~~~
            • required for the satisfaction of ‘pettable<auto:1>’ [with auto:1 = lizard]
              P3358R0.C:19:9:
                 19 | concept pettable = has_member_pet<T> or has_default_pet<T>;
                    |         ^~~~~~~~
            • in requirements with ‘T t’ [with T = lizard]
              P3358R0.C:13:26:
                 13 | concept has_member_pet = requires(T t) { t.pet(); };
                    |                          ^~~~~~~~~~~~~~~~~~~~~~~~~~
            • note: the required expression ‘t.pet()’ is invalid, because
              P3358R0.C:13:47:
                 13 | concept has_member_pet = requires(T t) { t.pet(); };
                    |                                          ~~~~~^~
              • error: ‘struct lizard’ has no member named ‘pet’
                P3358R0.C:13:44:
                   13 | concept has_member_pet = requires(T t) { t.pet(); };
                      |                                          ~~^~~
          • note: the operand ‘has_default_pet<T>’ is unsatisfied because
            P3358R0.C:19:41:
               19 | concept pettable = has_member_pet<T> or has_default_pet<T>;
                  |                    ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
            • required for the satisfaction of ‘has_default_pet<T>’ [with T = lizard]
              P3358R0.C:16:9:
                 16 | concept has_default_pet = T::is_pettable;
                    |         ^~~~~~~~~~~~~~~
            • required for the satisfaction of ‘pettable<auto:1>’ [with auto:1 = lizard]
              P3358R0.C:19:9:
                 19 | concept pettable = has_member_pet<T> or has_default_pet<T>;
                    |         ^~~~~~~~
            • error: ‘is_pettable’ is not a member of ‘lizard’
              P3358R0.C:16:30:
                 16 | concept has_default_pet = T::is_pettable;
                    |                              ^~~~~~~~~~~
  • note: candidate: ‘void pet(dog)’
    P3358R0.C:9:6:
        9 | void pet(dog);
          |      ^~~
    • note: no known conversion for argument 1 from ‘lizard’ to ‘dog’
      P3358R0.C:9:10:
          9 | void pet(dog);
            |          ^~~
  • note: candidate: ‘void pet(cat)’
    P3358R0.C:10:6:
       10 | void pet(cat);
          |      ^~~
    • note: no known conversion for argument 1 from ‘lizard’ to ‘cat’
      P3358R0.C:10:10:
         10 | void pet(cat);
            |          ^~~

showing the hierarchical structure of the messages; ideally there
would be a UI here allowing the user to expand/collapse the messages
to drill out into the detail they are interested in.

The structure is also captured in SARIF output (via the "nestingLevel"
property).

gcc/cp/ChangeLog:
	PR other/116253
	* call.cc (print_conversion_rejection): Remove leading space from
	diagnostic messages.
	(print_conversion_rejection): Likewise.
	(print_arity_information): Likewise.
	(print_z_candidate): Likewise.  Add auto_diagnostic_nesting_level
	before calls to fn_type_unification and diagnose_constraints.
	(print_z_candidates): Add auto_diagnostic_nesting_level before
	looping over candidates.
	(conversion_null_warnings): Remove leading space from
	diagnostic messages.
	(maybe_inform_about_fndecl_for_bogus_argument_init): Likewise.
	* constraint.cc (tsubst_valid_expression_requirement): Add
	auto_diagnostic_nesting_level when showing why the expression is
	invalid.
	(satisfy_disjunction): Likewise when showing operans, and again
	when replaying each branch of the disjunction.
	(diagnose_constraints): Likewise when replaying satisfaction.
	* error.cc (cp_diagnostic_text_starter): Set prefix.
	(print_instantiation_full_context): Only show the file
	if we're not showing nesting or the user has opted in to
	showing location information in nested diagnostics.
	(class auto_context_line): New.
	(print_instantiation_partial_context_line): Replace calls to
	print_location and to diagnostic_show_locus with an
	auto_context_line.
	(print_instantiation_partial_context): Replace calls to
	print_location with an auto_context_line.
	(maybe_print_constexpr_context): Likewise.
	(print_constrained_decl_info): Likewise.
	(print_concept_check_info): Likewise.
	(print_constraint_context_head): Likewise.
	(print_requires_expression_info): Likewise.

gcc/testsuite/ChangeLog:
	PR other/116253
	* g++.dg/concepts/nested-diagnostics-1-truncated.C: New test.
	* g++.dg/concepts/nested-diagnostics-1.C: New test.
	* g++.dg/concepts/nested-diagnostics-2.C: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2024-12-06 13:40:55 -05:00
Uros Bizjak
171aef2974 i386: Add missing part from my previous commit.
gcc/ChangeLog:

	* config/i386/i386.cc (ix86_decompose_address):
	Add missing part from my previous commit.
2024-12-06 19:23:18 +01:00
Uros Bizjak
6a8ff7de75 i386: Fix gcc.target/i386/pr101716.c (and some related cleanups)
Fix pr101716.c testcase scan-assembler failure.  The combine pass will not
combine instructions that use registers in TARGET_CLASS_LIKELY_SPILLED
class, such as %eax return register in AREG class.

Change the testcase to use pseudos only and explicitly scan for
zero_extendsidi pattern name.

While looking there, also clean ix86_decompose_address a bit: eliminate
common code and use UINTVAL and HOST_WIDE_INT_UC macros in the condition
for AND wrapped address.

gcc/ChangeLog:

	* config/i386/i386.cc (ix86_decompose_address): Eliminate
	common code and use use UINTVAL and HOST_WIDE_INT_UC macros
	in the condition for AND wrapped address.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/pr101716.c (dg-options): Add -dp.
	(dg-final): Scan for zero_extendsidi.
	(sample1): Change the code to use pseudos only.
2024-12-06 19:01:34 +01:00
Christophe Lyon
115e4bf54e arm,testsuite: Add -mtune=cortex-m55 to dlstp-int8x16.c
Like dlstp-compile-asm-1.c, this test would fail if GCC is configured
with non-default options, such as -mtune=cortex-a9.

Force -mtune=cortex-m55 to avoid this unexpected issue.

gcc/testsuite/ChangeLog:

	* gcc.target/arm/mve/dlstp-int8x16.c: Add -mtune=cortex-m55
2024-12-06 17:29:13 +00:00
Uros Bizjak
1acc5cffbb i386: Fix unwanted fwprop to 3dNOW! insn [PR117926]
The compiler is able to forward propagate a partial vector V4SF instruction
using XMM registers to a 3dNOW! V2SF instruction using MM registers.  Prevent
unwanted transformation by tagging 3dNOW! V2SF instructions using generic
RTXes with "(unspec [(const_int 0)] UNSPEC_3DNOW)" tag.

	PR target/117926

gcc/ChangeLog:

	* config/i386/mmx.md (UNSPEC_3DNOW): New unspec.
	(mmx_addv2sf3): Tag insn with UNSPEC_3DNOW tag.
	(*mmx_addv2sf3): Ditto.
	(mmx_sub2vsf3): Ditto.
	(mmx_subrv2sf3): Ditto.
	(*mmx_subv2sf3): Ditto.
	(mmx_mulv2sf3): Ditto.
	(mmx_<smaxmin:code>v2sf3): Ditto.
	(*mmx_<smaxmin:code>v2sf3): Ditto.
	(mmx_ieee_<ieee_maxmin>v2sf3): Ditto.
	(mmx_eqv2sf3): Ditto.
	(*mmx_eqv2sf3): Ditto.
	(mmx_gtv2sf3): Ditto.
	(mmx_gev2sf3): Ditto.
	(mmx_fix_truncv2sfv2si2): Ditto.
	(mmx_floatv2siv2sf2): Ditto.

gcc/testsuite/ChangeLog:

	* gcc.target/i386/pr117926.c: New test.
2024-12-06 18:23:34 +01:00
Richard Earnshaw
92c7a190d7 arm: testsuite: fix some legacy C tests
These tests all lack ISO-C style function definitions.  Some
deliberatly so.  Rather than try to adjust the code and risk changing
the nature of the test, add -std=c17 to the test options.

gcc/testsuite/ChangeLog:

	* gcc.target/arm/20031108-1.c: Add -std=c17.
	* gcc.target/arm/fp16-unprototyped-1.c: Likewise.
	* gcc.target/arm/fp16-unprototyped-2.c: Likewise.
	* gcc.target/arm/neon-thumb2-move.c: Likewise.
	* gcc.target/arm/pr67756.c: Likewise.
	* gcc.target/arm/pr81863.c: Likewise.
2024-12-06 17:12:46 +00:00
Matthew Malcomson
7883341999 clang-format BraceWrapping.AfterCaseLabel to true
This setting seems to better match the indentation that is used in GCC.

Adds an exra level of indentation after braces in a case statement.

Only manual testing done on the switch statements in
c-common.cc:resolve_overloaded_builtin and
alias.cc:record_component_aliases.

Ok for trunk?

contrib/ChangeLog:

	* clang-format: Set BraceWrapping.AfterCaseLabel.

Signed-off-by: Matthew Malcomson <mmalcomson@nvidia.com>
2024-12-06 17:09:29 +00:00
David Malcolm
5a022062d2 diagnostics: UX: add doc URLs for attributes (v2)
This is v2 of the patch; v1 was here:
  https://gcc.gnu.org/pipermail/gcc-patches/2024-June/655541.html

Changed in v2:
* added a new TARGET_DOCUMENTATION_NAME hook for figuring out which
  documentation URL to use when there are multiple per-target docs,
  such as for __attribute__((interrupt)); implemented this for all
  targets that have target-specific attributes
* moved attribute_urlifier and its support code to a new
  gcc-attribute-urlifier.cc since it needs to use targetm for the
  above; gcc-urlifier.o is used by the driver.
* fixed extend.texi so that some attributes that failed to appear in
  attr-urls.def now do so (affected nvptx "kernel" and "shared" attrs)
* regenerated attr-urls.def for the above fix, and bringing in
  attributes added since v1 of the patch

In r14-5118-gc5db4d8ba5f3de I added a mechanism to automatically add
documentation URLs to quoted strings in diagnostics.
In r14-6920-g9e49746da303b8 I added a mechanism to generate URLs for
mentions of command-line options in quoted strings in diagnostics.

This patch does a similar thing for attributes.  It adds a new Python 3
script to scrape the generated HTML looking for documentation of
attributes, and uses this to (re)generate a new gcc/attr-urls.def file.

Running "make regenerate-attr-urls" after rebuilding the HTML docs will
regenerate gcc/attr-urls.def in the source directory.

The patch uses this to optionally add doc URLs for attributes in any
diagnostic emitted during the lifetime of a auto_urlify_attributes
instance, and adds such instances everywhere that a diagnostic refers
to a diagnostic within quotes (based on grepping the source tree
for references to attributes in strings and in code).

For example, given:

$ ./xgcc -B. -S ../../src/gcc/testsuite/gcc.dg/attr-access-2.c
../../src/gcc/testsuite/gcc.dg/attr-access-2.c:14:16: warning:
attribute ‘access(read_write, 2, 3)’ positional argument 2 conflicts
with previous designation by argument 1 [-Wattributes]

with this patch the quoted text `access(read_write, 2, 3)'
automatically gains the URL for our docs for "access":
https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-access-function-attribute
in a sufficiently modern terminal.

Like r14-6920-g9e49746da303b8 this avoids the Makefile target
depending on the generated HTML, since a missing URL is a minor
problem, whereas requiring all users to build HTML docs seems more
involved.  Doing so also avoids Python 3 as a build requirement for
everyone, but instead just for developers addding attributes.
Like the options, we could add a CI test for this.

The patch gathers both general and target-specific attributes.
For example, the function attribute "interrupt" has 19 URLs within our
docs: one common, and 18 target-specific ones.
The patch adds a new target hook used when selecting the most
appropriate one.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>

gcc/ChangeLog:
	* Makefile.in (OBJS): Add -attribute-urlifier.o.
	(ATTR_URLS_HTML_DEPS): New.
	(regenerate-attr-urls): New.
	(regenerate-attr-urls-unit-test): New.
	* attr-urls.def: New file.
	* attribs.cc: Include "gcc-urlifier.h".
	(decl_attributes): Use auto_urlify_attributes.
	* config/aarch64/aarch64.cc (TARGET_DOCUMENTATION_NAME): New.
	* config/arc/arc.cc (TARGET_DOCUMENTATION_NAME): New.
	* config/arm/arm.cc (TARGET_DOCUMENTATION_NAME): New.
	* config/bfin/bfin.cc (TARGET_DOCUMENTATION_NAME): New.
	* config/bpf/bpf.cc (TARGET_DOCUMENTATION_NAME): New.
	* config/epiphany/epiphany.cc (TARGET_DOCUMENTATION_NAME): New.
	* config/gcn/gcn.cc (TARGET_DOCUMENTATION_NAME): New.
	* config/h8300/h8300.cc (TARGET_DOCUMENTATION_NAME): New.
	* config/i386/i386.cc (TARGET_DOCUMENTATION_NAME): New.
	* config/ia64/ia64.cc (TARGET_DOCUMENTATION_NAME): New.
	* config/m32c/m32c.cc (TARGET_DOCUMENTATION_NAME): New.
	* config/m32r/m32r.cc (TARGET_DOCUMENTATION_NAME): New.
	* config/m68k/m68k.cc (TARGET_DOCUMENTATION_NAME): New.
	* config/mcore/mcore.cc (TARGET_DOCUMENTATION_NAME): New.
	* config/microblaze/microblaze.cc (TARGET_DOCUMENTATION_NAME):
	New.
	* config/mips/mips.cc (TARGET_DOCUMENTATION_NAME): New.
	* config/msp430/msp430.cc (TARGET_DOCUMENTATION_NAME): New.
	* config/nds32/nds32.cc (TARGET_DOCUMENTATION_NAME): New.
	* config/nvptx/nvptx.cc (TARGET_DOCUMENTATION_NAME): New.
	* config/riscv/riscv.cc (TARGET_DOCUMENTATION_NAME): New.
	* config/rl78/rl78.cc (TARGET_DOCUMENTATION_NAME): New.
	* config/rs6000/rs6000.cc (TARGET_DOCUMENTATION_NAME): New.
	* config/rx/rx.cc (TARGET_DOCUMENTATION_NAME): New.
	* config/s390/s390.cc (TARGET_DOCUMENTATION_NAME): New.
	* config/sh/sh.cc (TARGET_DOCUMENTATION_NAME): New.
	* config/stormy16/stormy16.cc (TARGET_DOCUMENTATION_NAME): New.
	* config/v850/v850.cc (TARGET_DOCUMENTATION_NAME): New.
	* config/visium/visium.cc (TARGET_DOCUMENTATION_NAME): New.

gcc/analyzer/ChangeLog:
	* region-model.cc: Include "gcc-urlifier.h".
	(reason_attr_access::emit): Use auto_urlify_attributes.
	* sm-taint.cc: Include "gcc-urlifier.h".
	(tainted_access_attrib_size::emit): Use auto_urlify_attributes.

gcc/c-family/ChangeLog:
	* c-attribs.cc: Include "gcc-urlifier.h".
	(positional_argument): Use auto_urlify_attributes.
	* c-common.cc: Include "gcc-urlifier.h".
	(parse_optimize_options): Use auto_urlify_attributes with
	OPT_Wattributes.
	(attribute_fallthrough_p): Use auto_urlify_attributes.
	* c-warn.cc: Include "gcc-urlifier.h".
	(diagnose_mismatched_attributes): Use auto_urlify_attributes.

gcc/c/ChangeLog:
	* c-decl.cc: Include "gcc-urlifier.h".
	(start_decl): Use auto_urlify_attributes with OPT_Wattributes.
	(start_function): Likewise.
	* c-parser.cc: Include "gcc-urlifier.h".
	(c_parser_statement_after_labels): Use auto_urlify_attributes with
	OPT_Wattributes.
	* c-typeck.cc: Include "gcc-urlifier.h".
	(maybe_warn_nodiscard): Use auto_urlify_attributes with
	OPT_Wunused_result.

gcc/cp/ChangeLog:
	* cp-gimplify.cc: Include "gcc-urlifier.h".
	(process_stmt_hotness_attribute): Use auto_urlify_attributes with
	OPT_Wattributes.
	* cvt.cc: Include "gcc-urlifier.h".
	(maybe_warn_nodiscard): Use auto_urlify_attributes with
	OPT_Wunused_result.
	* decl.cc: Include "gcc-urlifier.h".
	(start_decl): Use auto_urlify_attributes.
	(start_preparsed_function): Likewise.

gcc/ChangeLog:
	* diagnostic.cc (diagnostic_context::override_urlifier): New.
	* diagnostic.h (diagnostic_context::override_urlifier): New decl.
	* doc/extend.texi (Nvidia PTX Function Attributes): Update
	@cindex to specify that "kernel" is a function attribute and
	"shared" is a variable attribute, so that these entries are
	recognized by the regex in regenerate-attr-urls.py.
	* doc/tm.texi: Regenerate.
	* doc/tm.texi.in (TARGET_DOCUMENTATION_NAME): New.
	* gcc-attribute-urlifier.cc: New file.
	* gcc-urlifier.cc: Include diagnostic.h.
	(gcc_urlifier::make_doc): Convert to...
	(make_doc_url): ...this.
	(auto_override_urlifier::auto_override_urlifier): New.
	(auto_override_urlifier::~auto_override_urlifier): New.
	(selftest::gcc_urlifier_cc_tests): Split out body into...
	(selftest::test_gcc_urlifier): ...this.
	* gcc-urlifier.h: Include "pretty-print-urlifier.h" and "label-text.h".
	(make_doc_url): New decl.
	(class auto_override_urlifier): New.
	(class attribute_urlifier): New.
	(class auto_urlify_attributes): New.
	* gimple-ssa-warn-access.cc: Include "gcc-urlifier.h".
	(pass_waccess::execute): Use auto_urlify_attributes.
	* gimplify.cc: Include "gcc-urlifier.h".
	(expand_FALLTHROUGH): Use auto_urlify_attributes.
	* internal-fn.cc: Define INCLUDE_MEMORY and include
	"gcc-urlifier.h.
	(expand_FALLTHROUGH): Use auto_urlify_attributes.
	* ipa-pure-const.cc: Include "gcc-urlifier.h.
	(suggest_attribute): Use auto_urlify_attributes.
	* ipa-strub.cc: Include "gcc-urlifier.h.
	(can_strub_p): Use auto_urlify_attributes.
	* regenerate-attr-urls.py: New file.
	* selftest-run-tests.cc (selftest::run_tests): Call
	gcc_attribute_urlifier_cc_tests.
	* selftest.h (selftest::gcc_attribute_urlifier_cc_tests): New
	decl.
	* target.def (documentation_name): New DEFHOOKPOD.
	* tree-cfg.cc: Include "gcc-urlifier.h.
	(do_warn_unused_result): Use auto_urlify_attributes.
	* tree-ssa-uninit.cc: Include "gcc-urlifier.h.
	(maybe_warn_read_write_only): Use auto_urlify_attributes.
	(maybe_warn_pass_by_reference): Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2024-12-06 11:48:43 -05:00
David Malcolm
31c08879dc c++: handle misspelled concepts and missing #include <concepts>
gcc/cp/ChangeLog:
	* name-lookup.cc (suggest_alternative_in_explicit_scope):
	Gracefully handle non-namespaces, such as scoped enums.
	* parser.cc (cp_parser_name_lookup_error): Provide
	a name_hint for the case where we're in an explicit scope.
	* std-name-hint.gperf: Add <concepts>.
	* std-name-hint.h: Regenerate.

gcc/testsuite/ChangeLog:
	* g++.dg/concepts/missing-header.C: New test.
	* g++.dg/concepts/misspelled-concept.C: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2024-12-06 11:33:59 -05:00
David Malcolm
4f5b7f1b73 c++: consolidate location printing in error.cc [PR116253]
Consolidate the location-printing logic in cp/error.cc, as preliminary
work towards supporting nested diagnostics (PR other/116253).

gcc/cp/ChangeLog:
	PR other/116253
	* error.cc (print_location): Move to earlier in the file.
	(print_instantiation_partial_context_line): Replace
	location-printing logic with a call to print_location.
	(print_instantiation_partial_context): Likewise, splitting up
	pp_verbatim calls.
	(maybe_print_constexpr_context): Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2024-12-06 11:29:54 -05:00
Georg-Johann Lay
a1fa104f2d avr.opt.urls: Rebuild.
gcc/
	* config/avr/avr.opt.urls: Rebuild.
2024-12-06 14:45:38 +01:00
Georg-Johann Lay
2b44b11cae AVR: Disable generation of CRC lookup tables.
With -foptimize-crc, large lookup tables may be generated which
are places in .rodata (RAM).  This patch disables such tables.

gcc/
	* common/config/avr/avr-common.cc
	(avr_option_optimization_table): Default to -fno-optimize-crc.
2024-12-06 14:44:16 +01:00
kelefth
b317dca04e avoid-store-forwarding: bail when an instruction may throw [PR117816]
Avoid-store-forwarding doesn't handle the case where an instruction in
the store-load sequence contains a REG_EH_REGION note, leading to the
insertion of instructions after it, while it should be the last
instruction in the basic block. This causes an ICE when compiling
using `-O -fnon-call-exceptions -favoid-store-forwarding
-fno-forward-propagate -finstrument-functions`.

This patch rejects the transformation when there are instructions in
the sequence that may throw an exeption.

	PR rtl-optimization/117816

gcc/ChangeLog:

	* avoid-store-forwarding.cc (store_forwarding_analyzer::avoid_store_forwarding):
	Reject the transformation when having instructions that may
	throw exceptions in the sequence.

gcc/testsuite/ChangeLog:

	* gcc.dg/pr117816.c: New test.
2024-12-06 12:36:42 +01:00
Thomas Schwinge
ed210c69ce nvptx: Support '-march=sm_89'
gcc/
	* config/nvptx/nvptx-sm.def: Add '89'.
	* config/nvptx/nvptx-gen.h: Regenerate.
	* config/nvptx/nvptx-gen.opt: Likewise.
	* config/nvptx/nvptx.cc (first_ptx_version_supporting_sm): Adjust.
	* config/nvptx/nvptx.opt (-march-map=sm_89, -march-map=sm_90)
	(march-map=sm_90a): Likewise.
	* config.gcc: Likewise.
	* doc/invoke.texi (Nvidia PTX Options): Document '-march=sm_89'.
	* config/nvptx/gen-multilib-matches-tests: Extend.
	gcc/testsuite/
	* gcc.target/nvptx/march-map=sm_89.c: Adjust.
	* gcc.target/nvptx/march-map=sm_90.c: Likewise.
	* gcc.target/nvptx/march-map=sm_90a.c: Likewise.
	* gcc.target/nvptx/march=sm_89.c: New.
	libgomp/
	* testsuite/libgomp.c/declare-variant-3-sm89.c: New.
	* testsuite/libgomp.c/declare-variant-3.h: Adjust.
2024-12-06 12:30:20 +01:00
Thomas Schwinge
2fdc8cc97e nvptx: Support '-mptx=7.8'
gcc/
	* config/nvptx/nvptx-opts.h (enum ptx_version): Add
	'PTX_VERSION_7_8'.
	* config/nvptx/nvptx.cc (ptx_version_to_string)
	(ptx_version_to_number): Adjust.
	* config/nvptx/nvptx.h (TARGET_PTX_7_8): New.
	* config/nvptx/nvptx.opt (Enum(ptx_version)): Add 'EnumValue'
	'7.8' for 'PTX_VERSION_7_8'.
	* doc/invoke.texi (Nvidia PTX Options): Document '-mptx=7.8'.
	gcc/testsuite/
	* gcc.target/nvptx/mptx=7.8.c: New.
2024-12-06 12:30:20 +01:00
Thomas Schwinge
7cff338e5a nvptx: Support '-march=sm_52'
gcc/
	* config/nvptx/nvptx-sm.def: Add '52'.
	* config/nvptx/nvptx-gen.h: Regenerate.
	* config/nvptx/nvptx-gen.opt: Likewise.
	* config/nvptx/nvptx.cc (first_ptx_version_supporting_sm): Adjust.
	* config/nvptx/nvptx.opt (-march-map=sm_52): Likewise.
	* config.gcc: Likewise.
	* doc/invoke.texi (Nvidia PTX Options): Document '-march=sm_52'.
	* config/nvptx/gen-multilib-matches-tests: Extend.
	gcc/testsuite/
	* gcc.target/nvptx/march-map=sm_52.c: Adjust.
	* gcc.target/nvptx/march=sm_52.c: New.
	libgomp/
	* testsuite/libgomp.c/declare-variant-3-sm52.c: New.
	* testsuite/libgomp.c/declare-variant-3.h: Adjust.
2024-12-06 12:26:45 +01:00
Thomas Schwinge
7151d885c4 nvptx: Support '-march=sm_37'
gcc/
	* config/nvptx/nvptx-sm.def: Add '37'.
	* config/nvptx/nvptx-gen.h: Regenerate.
	* config/nvptx/nvptx-gen.opt: Likewise.
	* config/nvptx/nvptx.cc (first_ptx_version_supporting_sm): Adjust.
	* config/nvptx/nvptx.opt (-march-map=sm_37, -march-map=sm_50):
	Likewise.
	* config.gcc: Likewise.
	* doc/invoke.texi (Nvidia PTX Options): Document '-march=sm_37'.
	* config/nvptx/gen-multilib-matches-tests: Extend.
	gcc/testsuite/
	* gcc.target/nvptx/march-map=sm_37.c: Adjust.
	* gcc.target/nvptx/march-map=sm_50.c: Likewise.
	* gcc.target/nvptx/march-map=sm_52.c: Likewise.
	* gcc.target/nvptx/march=sm_37.c: New.
	libgomp/
	* testsuite/libgomp.c/declare-variant-3-sm37.c: New.
	* testsuite/libgomp.c/declare-variant-3.h: Adjust.
2024-12-06 12:26:45 +01:00
Thomas Schwinge
18d80e5ecf nvptx: Support '-mptx=4.1'
gcc/
	* config/nvptx/nvptx-opts.h (enum ptx_version): Add
	'PTX_VERSION_4_1'.
	* config/nvptx/nvptx.cc (ptx_version_to_string)
	(ptx_version_to_number): Adjust.
	* config/nvptx/nvptx.h (TARGET_PTX_4_1): New.
	* config/nvptx/nvptx.opt (Enum(ptx_version)): Add 'EnumValue'
	'4.1' for 'PTX_VERSION_4_1'.
	* doc/invoke.texi (Nvidia PTX Options): Document '-mptx=4.1'.
	gcc/testsuite/
	* gcc.target/nvptx/mptx=4.1.c: New.
2024-12-06 12:26:45 +01:00
Thomas Schwinge
1af83aa099 nvptx: Expose '-mptx=4.2'
'PTX_VERSION_4_2' was added in commit decde11183
"[nvptx] Choose -mptx default based on -misa" for use for '-march=sm_52'
('first_ptx_version_supporting_sm', 'PTX_ISA_SM53'), as documented by Nvidia.
However, '-mptx=4.2' wasn't exposed to the user, but there's no reason not to.

	gcc/
	* config/nvptx/nvptx.h (TARGET_PTX_4_2): New.
	* config/nvptx/nvptx.opt (Enum(ptx_version)): Add 'EnumValue'
	'4.2' for 'PTX_VERSION_4_2'.
	* doc/invoke.texi (Nvidia PTX Options): Document '-mptx=4.2'.
	gcc/testsuite/
	* gcc.target/nvptx/mptx=4.2.c: New.
2024-12-06 12:11:44 +01:00
Thomas Schwinge
380ceb23b1 nvptx: Clarify that our baseline is PTX ISA Version 3.1
Added in commit decde11183
"[nvptx] Choose -mptx default based on -misa", 'PTX_VERSION_3_0' was added for
'first_ptx_version_supporting_sm' to return it for 'PTX_ISA_SM30' (as
documented by Nvidia).  It's however then immediately overridden to 3.1, which
in GCC/nvptx "has been the smallest version historically", and also '-mptx=3.0'
isn't exposed to the user.  As we also elsewhere (machine description etc.)
assume that our baseline is PTX ISA Version 3.1, there's no real value added in
maintaining 'PTX_VERSION_3_0' for purposes of 'first_ptx_version_supporting_sm'
only.

No change in behavior intended.

	gcc/
	* config/nvptx/nvptx-opts.h (enum ptx_version): Remove
	'PTX_VERSION_3_0'.
	* config/nvptx/nvptx.cc (first_ptx_version_supporting_sm)
	(default_ptx_version_option, ptx_version_to_string)
	(ptx_version_to_number): Adjust.
	* config/nvptx/nvptx.h: Comment.
2024-12-06 12:06:40 +01:00
Thomas Schwinge
86b3a7532d nvptx: Support '--with-multilib-list'
No change in behavior unless specifying it.

	gcc/
	* config.gcc: nvptx: Support '--with-multilib-list'.
	* config/nvptx/gen-multilib-matches.sh: Adjust.
	* configure.ac: Likewise.
	* configure: Regenerate.
	* doc/install.texi: Update.
	* doc/invoke.texi: Align.
	* config/nvptx/gen-multilib-matches-tests: Extend.
2024-12-06 11:59:51 +01:00
Christophe Lyon
2b707b41b1 arm,testsuite: Add -mtune=cortex-m55 to dlstp-compile-asm-1.c test.
This test would fail if GCC is configured with non-default options,
such as -mtune=cortex-a9.

This 'unexpected' scheduling makes the DLSTP optimization generate
	subs    lr, #16
	bhi	.L4
	lctp
	pop     {r4, r5, pc}
.L4:
	sub     ip, ip, #16
	b      <loop-begin>

instead of the expected
sub     ip, ip, #16
letp lr, <loop-begin>

Although GCC still optimizes all 144 loops, only 96 use letp, 48
others use lctp.

The patch simply forces -mtune=cortex-m55 to avoid this unexpected
issue.

gcc/testsuite/ChangeLog:

	* gcc.target/arm/mve/dlstp-compile-asm-1.c: Add -mtune=cortex-m55
2024-12-06 10:42:12 +00:00
Thomas Schwinge
ee6711ead3 nvptx: Enhance '-march-map=[...]' test cases
This expands upon the one test case added in
commit de0ef04419 "[nvptx] Add march-map".

	gcc/testsuite/
	* gcc.target/nvptx/march-map.c: Remove; expanded into...
	* gcc.target/nvptx/march-map=sm_50.c: ... this.
	* gcc.target/nvptx/march-map=sm_30.c: New.
	* gcc.target/nvptx/march-map=sm_32.c: Likewise.
	* gcc.target/nvptx/march-map=sm_35.c: Likewise.
	* gcc.target/nvptx/march-map=sm_37.c: Likewise.
	* gcc.target/nvptx/march-map=sm_52.c: Likewise.
	* gcc.target/nvptx/march-map=sm_53.c: Likewise.
	* gcc.target/nvptx/march-map=sm_60.c: Likewise.
	* gcc.target/nvptx/march-map=sm_61.c: Likewise.
	* gcc.target/nvptx/march-map=sm_62.c: Likewise.
	* gcc.target/nvptx/march-map=sm_70.c: Likewise.
	* gcc.target/nvptx/march-map=sm_72.c: Likewise.
	* gcc.target/nvptx/march-map=sm_75.c: Likewise.
	* gcc.target/nvptx/march-map=sm_80.c: Likewise.
	* gcc.target/nvptx/march-map=sm_86.c: Likewise.
	* gcc.target/nvptx/march-map=sm_87.c: Likewise.
	* gcc.target/nvptx/march-map=sm_89.c: Likewise.
	* gcc.target/nvptx/march-map=sm_90.c: Likewise.
	* gcc.target/nvptx/march-map=sm_90a.c: Likewise.
	* gcc.target/nvptx/main.c: Remove.
2024-12-06 11:39:49 +01:00
Thomas Schwinge
ed96ce81b1 nvptx: Enhance '-march=[...]' test cases
This expands upon the test cases added in
commit 4706670cd3
"[nvptx, testsuite] Add gcc.target/nvptx/sm*.c".

	gcc/testsuite/
	* gcc.target/nvptx/sm30.c: Remove; expanded into...
	* gcc.target/nvptx/march=sm_30.c: ... this.
	* gcc.target/nvptx/sm35.c: Remove; expanded into...
	* gcc.target/nvptx/march=sm_35.c: ... this.
	* gcc.target/nvptx/sm53.c: Remove; expanded into...
	* gcc.target/nvptx/march=sm_53.c: ... this.
	* gcc.target/nvptx/sm70.c: Remove; expanded into...
	* gcc.target/nvptx/march=sm_70.c: ... this.
	* gcc.target/nvptx/sm75.c: Remove; expanded into...
	* gcc.target/nvptx/march=sm_75.c: ... this.
	* gcc.target/nvptx/sm80.c: Remove; expanded into...
	* gcc.target/nvptx/march=sm_80.c: ... this.
	* gcc.target/nvptx/march.c: Remove.
2024-12-06 11:36:45 +01:00
Thomas Schwinge
b7abc7cabd nvptx: Enhance '-mptx=[...]' test cases
This expands upon the test cases added in
commit a2eacdbd4c
"[nvptx] Add __PTX_ISA_VERSION_{MAJOR,MINOR}__".

	gcc/testsuite/
	* gcc.target/nvptx/ptx31.c: Remove; expanded into...
	* gcc.target/nvptx/mptx=3.1.c: ... this.
	* gcc.target/nvptx/ptx60.c: Remove; expanded into...
	* gcc.target/nvptx/mptx=6.0.c: ... this.
	* gcc.target/nvptx/ptx63.c: Remove; expanded into...
	* gcc.target/nvptx/mptx=6.3.c: ... this.
	* gcc.target/nvptx/ptx70.c: Remove; expanded into...
	* gcc.target/nvptx/mptx=7.0.c: ... this.
	* gcc.target/nvptx/mptx=_.c: New.
2024-12-06 11:32:00 +01:00
Jakub Jelinek
ecfc0e0737 Use new RAW_DATA_{U,S}CHAR_ELT macros in the middle-end and C FE
During the patch review of the C++ #embed optimization, Jason asked for
a macro for the common
((const unsigned char *) RAW_DATA_POINTER (value))[i]
and ditto with signed char patterns which appear in a lot of places.
In the just committed patch I've added
+#define RAW_DATA_UCHAR_ELT(NODE, I) \
+  (((const unsigned char *) RAW_DATA_POINTER (NODE))[I])
+#define RAW_DATA_SCHAR_ELT(NODE, I) \
+  (((const signed char *) RAW_DATA_POINTER (NODE))[I])
macros for that in tree.h.

The following patch is just a cleanup to use those macros where appropriate.

2024-12-06  Jakub Jelinek  <jakub@redhat.com>

gcc/
	* gimplify.cc (gimplify_init_ctor_eval): Use RAW_DATA_UCHAR_ELT
	macro.
	* gimple-fold.cc (fold_array_ctor_reference): Likewise.
	* tree-pretty-print.cc (dump_generic_node): Use RAW_DATA_UCHAR_ELT
	and RAW_DATA_SCHAR_ELT macros.
	* fold-const.cc (fold): Use RAW_DATA_UCHAR_ELT macro.
gcc/c/
	* c-parser.cc (c_parser_get_builtin_args, c_parser_expression,
	c_parser_expr_list): Use RAW_DATA_UCHAR_ELT macro.
	* c-typeck.cc (digest_init): Use RAW_DATA_UCHAR_ELT and
	RAW_DATA_SCHAR_ELT macros.
	(add_pending_init, maybe_split_raw_data): Use RAW_DATA_UCHAR_ELT
	macro.
2024-12-06 11:00:52 +01:00
Richard Biener
e65b09d461 More duplicates reported by genmatch
Here are a bit less obvious cases of duplicate, mostly of the
form (op (op:c @0 @1) (op:c @0 @1)) where it's enough to have
one :c to get all relevant cases.

	* match.pd: Remove redundant :c, reported by genmatch as
	duplicate patterns.
2024-12-06 10:29:08 +01:00
Richard Biener
1c07f7a1b4 Remove some duplicates reported by genmatch
genmatch currently has a difficulty to decide whether a duplicate
structural match is really duplicate as uses of captures within
predicates or in C code can be order dependent.  For example
a reported duplicate results in

 {
   tree captures[4] ATTRIBUTE_UNUSED = { _p1, _p0, _q20, _q21 }
   if (gimple_simplify_112 (res_op, seq, valueize, type, captures))
     return true;
 }
 {
   tree captures[4] ATTRIBUTE_UNUSED = { _p1, _p0, _q21, _q20 };
   if (gimple_simplify_112 (res_op, seq, valueize, type, captures))
     return true;
 }

where the difference is only in _q20 and _q21 being swapped but
that resulting in a call to bitwise_inverted_equal_p (_p1, X)
with X once _q20 and once _q21.  That is, we treat bare
captures as equal for reporting duplicates.

Due to bitwise_inverted_equal_p there are meanwhile a _lot_ of
duplicates reported that are not actual duplicates.

The following removes some that are though, as the operands are
only passed to types_match.

	* match.pd (.SAT_ADD patterns using IFN_ADD_OVERFLOW): Remove :c that
	only causes duplicate patterns.
2024-12-06 10:29:08 +01:00
Hau Hsu
feea589d78 RISC-V: Add --with-cmodel configure option
Sometimes we want to use default cmodel other than medlow. Add a GCC
configure option for that.

gcc/ChangeLog:

	* config.gcc (riscv*-*-*): Add support for --with-cmodel configure option.
	(all_defaults): Add cmodel.
	* config/riscv/riscv.h (TARGET_DEFAULT_CMODEL): Remove.
	* doc/install.texi: Document --with-cmodel configure option.
	* doc/invoke.texi (-mcmodel): Mention --with-cmodel configure option.

Co-authored-by: Kito Cheng <kito.cheng@sifive.com>
2024-12-06 17:27:36 +08:00
Thomas Schwinge
ccd6ec2317 'gcc/config/nvptx/gen-multilib-matches.sh': Support '--selftest'
..., and invoke that before actual use.

	gcc/
	* config/nvptx/gen-multilib-matches.sh: Support '--selftest'.
	* config/nvptx/t-nvptx (t-nvptx-gen-multilib-matches:): Invoke it.
	* config/nvptx/gen-multilib-matches-tests: New.
2024-12-06 10:25:25 +01:00
Thomas Schwinge
61da068638 'gcc/config/nvptx/gen-*.sh': Simplify interface
What we currently pass in as '$1' is simply 'dirname "$0"'.

	gcc/
	* config/nvptx/gen-h.sh: Don't pass in '$1'; compute it locally.
	* config/nvptx/gen-multilib-matches.sh: Likewise.
	* config/nvptx/gen-omp-device-properties.sh: Likewise.
	* config/nvptx/gen-opt.sh: Likewise.
	* config/nvptx/t-nvptx (s-nvptx-gen-h:, s-nvptx-gen-opt:)
	(t-nvptx-gen-multilib-matches:): Adjust.
	* config/nvptx/t-omp-device (omp-device-properties-nvptx):
	Likewise.
2024-12-06 10:08:19 +01:00
Thomas Schwinge
b352f89d81 'gcc/config/nvptx/gen-multilib-matches.sh': Encapsulate main logic
Refactoring for later extension.  No change in behavior intended.

	gcc/
	* config/nvptx/gen-multilib-matches.sh: Encapsulate main logic.
2024-12-06 10:04:38 +01:00
Thomas Schwinge
4904433576 'gcc/config/nvptx/t-nvptx': Don't use the 'shell' function of 'make'
The exit status of the command invoked in a 'Makefile' via '$(shell [...])'
effectively gets discarded (unless explicitly checking the GNU Make 4.2+
'.SHELLSTATUS' variable or jumping through other hoops).  In order to be able
to catch errors in what the 'shell' function invokes, let's make things
explicit: similar to how 'gcc/config/avr/t-avr' is doing with 't-multilib-avr',
for example.

	gcc/
	* config/nvptx/t-nvptx (multilib_matches): Don't use the 'shell'
	function of 'make'.
	* config/nvptx/gen-multilib-matches.sh: Adjust.
2024-12-06 09:57:49 +01:00
Thomas Schwinge
4ab02a7b26 nvptx: Tag '-misa=[...]', '-mptx=[...]' as 'Negative' of themselves [PR117916]
This issue is similar to what a year ago I resolved for GCN in PR112669
"GCN: wrong 'LIBRARY_PATH' in presence of several different '-march=[...]' flags".

Given the current standard nvptx configuration, we get:

    $ build-gcc-offload-nvptx-none/gcc/xgcc -print-multi-directory -mptx=6.3
    .
    $ build-gcc-offload-nvptx-none/gcc/xgcc -print-multi-directory -mptx=3.1
    mptx-3.1

... as expected.  The following, however, is not:

    $ build-gcc-offload-nvptx-none/gcc/xgcc -print-multi-directory -mptx=3.1 -mptx=6.3
    mptx-3.1

This should print '.'.

Or, in a '--with-arch=sm_70' configuration:

    $ build-gcc-offload-nvptx-none/gcc/xgcc -print-multi-directory -misa=sm_70
    .
    $ build-gcc-offload-nvptx-none/gcc/xgcc -print-multi-directory -misa=sm_30
    misa-sm_30

... as expected.  The following, however, are not:

    $ build-gcc-offload-nvptx-none/gcc/xgcc -print-multi-directory -misa=sm_30 -misa=sm_70
    misa-sm_30
    $ build-gcc-offload-nvptx-none/gcc/xgcc -print-multi-directory -misa=sm_30 -march=sm_70
    misa-sm_30
    $ build-gcc-offload-nvptx-none/gcc/xgcc -print-multi-directory -march=sm_30 -march=sm_70
    misa-sm_30
    $ build-gcc-offload-nvptx-none/gcc/xgcc -print-multi-directory -march=sm_30 -misa=sm_70
    misa-sm_30

These should all print '.'.

Even worse:

    $ build-gcc-offload-nvptx-none/gcc/xgcc -print-multi-directory -mgomp -mptx=3.1 -mptx=_
    .

This should print 'mgomp'.  Otherwise, for OpenMP offloading compilation
the wrong (non-'mgomp') multilib is linked in ('.'), and linking fails
due to 'unresolved symbol __nvptx_uni'.

	PR target/117916
	gcc/
	* config/nvptx/nvptx.opt (misa=, mptx=): Tag as 'Negative' of
	themselves.
2024-12-06 09:50:22 +01:00
Thomas Schwinge
c80ecfa092 Clarify libgomp nvptx 'omp_low_lat_mem_space' documentation
PTX '%dynamic_smem_size' was "Introduced in PTX ISA version 4.1", and
"Requires 'sm_20' or higher".  Given that GCC/nvptx generally supports
'sm_20', only the PTX ISA version matters here, and that's all fine if
just using GCC's defaults.  Follow-up to
commit e9a19ead49
"openmp, nvptx: low-lat memory access traits".

	libgomp/
	* libgomp.texi: Clarify nvptx 'omp_low_lat_mem_space'
	documentation.
2024-12-06 09:48:33 +01:00
Thomas Schwinge
ab5bd6ac68 Fortran: Use OpenACC's acc_on_device builtin, fix OpenMP' __builtin_is_initial_device: Revert 'gimple_fold_builtin_acc_on_device' change
The motivation of the 'gimple_fold_builtin_acc_on_device' change in
commit 3269a722b7
"Fortran: Use OpenACC's acc_on_device builtin, fix OpenMP' __builtin_is_initial_device"
is unclear, and it unnecessarily diverges GCC's (default)
'--disable-offload-targets' vs. '--enable-offload-targets=[...]'
configurations.

	PR testsuite/82250
	gcc/
	* gimple-fold.cc (gimple_fold_builtin_acc_on_device): Revert last
	change.
	libgomp/
	* testsuite/libgomp.oacc-c-c++-common/routine-nohost-1.c: Revert
	last change.
2024-12-06 09:48:33 +01:00
Richard Biener
3e14c126de testsuite/117714 - gcc.dg/vect/slp-reduc-4.c FAILs on 32-bit SPARC
The testcase tries to ensure we can elide all permutations when
vectorizing a MAX reduction.  For SPARC the issue is that the
MAX reduction isn't supported and since we're trying to fall back
to single-lane SLP the dumps contain VEC_PERM_EXPR for the
interleaving permute lowering.  Before all-SLP that wouldn't
be in the dumps when doing non-SLP, but eventually we'd fail to
vectorize so no VEC_PERM_EXPRs would be in the dumps either.

The following adds vect_no_int_min_max to the set of xfails for
this particular scan as well, like the existing check for vectorizing.

	PR testsuite/117714
	* gcc.dg/vect/slp-reduc-4.c: Add vect_no_int_min_max to the
	XFAIL for the VEC_PERM_EXPR scan.
2024-12-06 09:44:12 +01:00
Jakub Jelinek
0223119f1a libcpp, c++: Optimize initializers using #embed in C++
This patch adds similar optimizations to the C++ FE as have been
implemented earlier in the C FE.
The libcpp hunk enables use of CPP_EMBED token even for C++, not just
C; the preprocessor guarantees there is always a CPP_NUMBER CPP_COMMA
before CPP_EMBED and CPP_COMMA CPP_NUMBER after it which simplifies
parsing (unless #embed is more than 2GB, in that case it could be
CPP_NUMBER CPP_COMMA CPP_EMBED CPP_COMMA CPP_EMBED CPP_COMMA CPP_EMBED
CPP_COMMA CPP_NUMBER etc. with each CPP_EMBED covering at most INT_MAX
bytes).
Similarly to the C patch, this patch parses it into RAW_DATA_CST tree
in the braced initializers (and from there peels into INTEGER_CSTs unless
it is an initializer of an std::byte array or integral array with CHAR_BIT
element precision), parses CPP_EMBED in cp_parser_expression into just
the last INTEGER_CST in it because I think users don't need millions of
-Wunused-value warnings because they did useless
  int a = (
  #embed "megabyte.dat"
  );
and so most of the inner INTEGER_CSTs would be there just for the warning,
and in the rest of contexts like template argument list, function argument
list, attribute argument list, ...) parse it into a sequence of INTEGER_CSTs
(I wrote a range/iterator classes to simplify that).

My dumb
cat embed-11.c
constexpr unsigned char a[] = {
  #embed "cc1plus"
};
const unsigned char *b = a;
testcase where cc1plus is 492329008 bytes long when configured
--enable-checking=yes,rtl,extra against recent binutils with .base64 gas
support results in:
time ./xg++ -B ./ -S -O2 embed-11.c

real    0m4.350s
user    0m2.427s
sys     0m0.830s
time ./xg++ -B ./ -c -O2 embed-11.c

real    0m6.932s
user    0m6.034s
sys     0m0.888s
(compared to running out of memory or very long compilation).
On a shorter inclusion,
cat embed-12.c
constexpr unsigned char a[] = {
  #embed "xg++"
};
const unsigned char *b = a;
where xg++ is 15225904 bytes long, this takes using GCC with the #embed
patchset except for this patch:
time ~/src/gcc/obj36/gcc/xg++ -B ~/src/gcc/obj36/gcc/ -S -O2 embed-12.c

real    0m33.190s
user    0m32.327s
sys     0m0.790s
and with this patch:
time ./xg++ -B ./ -S -O2 embed-12.c

real    0m0.118s
user    0m0.090s
sys     0m0.028s

The patch doesn't change anything on what the first patch in the series
introduces even for C++, namely that #embed is expanded (actually or as if)
into a sequence of literals like
127,69,76,70,2,1,1,3,0,0,0,0,0,0,0,0,2,0,62,0,1,0,0,0,80,211,64,0,0,0,0,0,64,0,0,0,0,0,0,0,8,253
and so each element has int type.
That is how I believe it is in C23, and the different versions of the
C++ P1967 paper specified there some casts, P1967R12 in particular
"Otherwise, the integral constant expression is the value of std::fgetc’s return is cast
to unsigned char."
but please see
https://github.com/llvm/llvm-project/pull/97274#issuecomment-2230929277
comment and whether we really want the preprocessor to preprocess it for
C++ as (or as-if)
static_cast<unsigned char>(127),static_cast<unsigned char>(69),static_cast<unsigned char>(76),static_cast<unsigned char>(70),static_cast<unsigned char>(2),...
i.e. 9 tokens per byte rather than 2, or
(unsigned char)127,(unsigned char)69,...
or
((unsigned char)127),((unsigned char)69),...
etc.
Without a literal suffix for unsigned char constant literals it is horrible,
plus the incompatibility between C and C++.  Sure, we could use the magic
form more often for C++ to save the size and do the 9 or how many tokens
form only for the boundary constants and use #embed "." __gnu__::__base64__("...")
for what is in between if there are at least 2 tokens inside of it.
E.g. (unsigned char)127 vs. static_cast<unsigned char>(127) behaves
differently if there is constexpr long long p[] = { ... };
...
  #embed __FILE__
[p]

2024-12-06  Jakub Jelinek  <jakub@redhat.com>

libcpp/
	* files.cc (finish_embed): Use CPP_EMBED even for C++.
gcc/
	* tree.h (RAW_DATA_UCHAR_ELT, RAW_DATA_SCHAR_ELT): Define.
gcc/cp/ChangeLog:
	* cp-tree.h (class raw_data_iterator): New type.
	(class raw_data_range): New type.
	* parser.cc (cp_parser_postfix_open_square_expression): Handle
	parsing of CPP_EMBED.
	(cp_parser_parenthesized_expression_list): Likewise.  Use
	cp_lexer_next_token_is.
	(cp_parser_expression): Handle parsing of CPP_EMBED.
	(cp_parser_template_argument_list): Likewise.
	(cp_parser_initializer_list): Likewise.
	(cp_parser_oacc_clause_tile): Likewise.
	(cp_parser_omp_tile_sizes): Likewise.
	* pt.cc (tsubst_expr): Handle RAW_DATA_CST.
	* constexpr.cc (reduced_constant_expression_p): Likewise.
	(raw_data_cst_elt): New function.
	(find_array_ctor_elt): Handle RAW_DATA_CST.
	(cxx_eval_array_reference): Likewise.
	* typeck2.cc (digest_init_r): Emit -Wnarrowing and/or -Wconversion
	diagnostics.
	(process_init_constructor_array): Handle RAW_DATA_CST.
	* decl.cc (maybe_deduce_size_from_array_init): Likewise.
	(is_direct_enum_init): Fail for RAW_DATA_CST.
	(cp_maybe_split_raw_data): New function.
	(consume_init): New function.
	(reshape_init_array_1): Add VECTOR_P argument.  Handle RAW_DATA_CST.
	(reshape_init_array): Adjust reshape_init_array_1 caller.
	(reshape_init_vector): Likewise.
	(reshape_init_class): Handle RAW_DATA_CST.
	(reshape_init_r): Likewise.
gcc/testsuite/
	* c-c++-common/cpp/embed-22.c: New test.
	* c-c++-common/cpp/embed-23.c: New test.
	* g++.dg/cpp/embed-4.C: New test.
	* g++.dg/cpp/embed-5.C: New test.
	* g++.dg/cpp/embed-6.C: New test.
	* g++.dg/cpp/embed-7.C: New test.
	* g++.dg/cpp/embed-8.C: New test.
	* g++.dg/cpp/embed-9.C: New test.
	* g++.dg/cpp/embed-10.C: New test.
	* g++.dg/cpp/embed-11.C: New test.
	* g++.dg/cpp/embed-12.C: New test.
	* g++.dg/cpp/embed-13.C: New test.
	* g++.dg/cpp/embed-14.C: New test.
2024-12-06 09:09:12 +01:00