]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
5 months agolibatomic: Regenerate configure properly
Jakub Jelinek [Fri, 5 Apr 2024 10:15:06 +0000 (12:15 +0200)] 
libatomic: Regenerate configure properly

Seems configure hasn't been regenerated properly after the last
acinclude.m4 change.

2024-04-05  Jakub Jelinek  <jakub@redhat.com>

* configure: Regenerate.

5 months agomiddle-end/114599 - fix bitmap allocation for check_ifunc_callee_symtab_nodes
Richard Biener [Fri, 5 Apr 2024 08:16:41 +0000 (10:16 +0200)] 
middle-end/114599 - fix bitmap allocation for check_ifunc_callee_symtab_nodes

There's no default bitmap obstack during global CTORs, so allocate the
bitmap locally.

PR middle-end/114599
PR gcov-profile/114115
* symtab.cc (ifunc_ref_map): Do not use auto_bitmap.
(is_caller_ifunc_resolver): Optimize bitmap_bit_p/bitmap_set_bit
pair.
(symtab_node::check_ifunc_callee_symtab_nodes): Properly
allocate ifunc_ref_map here.

5 months agotestsuite: Fix up error on gcov1.d
Jakub Jelinek [Fri, 5 Apr 2024 09:05:01 +0000 (11:05 +0200)] 
testsuite: Fix up error on gcov1.d

On Fri, Feb 23, 2024 at 12:18:00PM +0100, Jørgen Kvalsvik wrote:
> This is a mostly straight port from the gcov-19.c tests from the C test
> suite. The only notable differences from C to D are that D flips the
> true/false outcomes for loop headers, and the D front end ties loop and
> ternary conditions to slightly different locus.
>
> The test for >64 conditions warning is disabled as it either needs
> support from the testing framework or a something similar to #pragma GCC
> diagnostic push to not cause a test failure from detecting a warning.
>
> gcc/testsuite/ChangeLog:
>
>       * gdc.dg/gcov.exp: New test.
>       * gdc.dg/gcov1.d: New test.

Unfortunately, this doesn't work.
I see
PASS: gdc.dg/gcov1.d   execution test
ERROR: (DejaGnu) proc "run-gcov conditions { --conditions gcov1.d }" does not exist.
The error code is TCL LOOKUP COMMAND run-gcov
The info on the error is:
invalid command name "run-gcov"
    while executing
"::tcl_unknown run-gcov conditions { --conditions gcov1.d }"
    ("uplevel" body line 1)
    invoked from within
"uplevel 1 ::tcl_unknown $args"
ERROR: gdc.dg/gcov1.d  : error executing dg-final: invalid command name "run-gcov"
both on x86_64-linux and i686-linux.
The problem is that the test hasn't been added to a new directory, but
to a directory already covered by a different *.exp file - dg.exp.
Now, usually either one has a test directory like gcc.misc-tests where
there are many *.exp files but each *.exp file globs for its own tests,
or there is one *.exp per directory and covers everything in there.
By having both dg.exp and gcov.exp in the same directory with dg.exp
covering all *.d files in there and gcov gcov*.d in there, the gcov*.d
tests are tested twice, once using the dg.exp driver and once using gcov.exp
driver.  With the latter, they do work properly, with the former they don't
because gcov.exp lib file isn't loaded and so run-gcov isn't available.

The following patch fixes that similarly how g++.dg/modules/modules.exp,
gcc.target/s390/s390.exp or gcc.target/i386/i386.exp deal with that,
by pruning some tests based on glob patterns from the list.

2024-04-05  Jakub Jelinek  <jakub@redhat.com>

* gdc.dg/dg.exp: Prune gcov*.d from the list of tests to run.
* gdc.dg/gcov.exp: Update copyright years.

5 months agoc++: Fix ICE with weird copy assignment operator [PR114572]
Jakub Jelinek [Fri, 5 Apr 2024 07:31:28 +0000 (09:31 +0200)] 
c++: Fix ICE with weird copy assignment operator [PR114572]

While ctors/dtors don't return anything (undeclared void or this pointer
on arm) and copy assignment operators normally return a reference to *this,
it isn't invalid to return uselessly some class object which might need
destructing, but the OpenMP clause handling code wasn't expecting that.

The following patch fixes that.

2024-04-05  Jakub Jelinek  <jakub@redhat.com>

PR c++/114572
* cp-gimplify.cc (cxx_omp_clause_apply_fn): Call build_cplus_new
on build_call_a result if it has class type.

* testsuite/libgomp.c++/pr114572.C: New test.

5 months agogo: Add go.install-dvi rule in go/Make-lang.in
Christophe Lyon [Thu, 4 Apr 2024 16:18:52 +0000 (16:18 +0000)] 
go: Add go.install-dvi rule in go/Make-lang.in

go has a go.dvi build rule, but lacks the go.install-dvi one.

2024-04-04  Christophe Lyon  <christophe.lyon@linaro.org>

gcc/go/
* Make-lang.in (go.install-dvi): New rule.

5 months agotestsuite/gcc.target/cris/pr93372-2.c: Handle xpass from combine improvement
Hans-Peter Nilsson [Fri, 5 Apr 2024 00:50:16 +0000 (02:50 +0200)] 
testsuite/gcc.target/cris/pr93372-2.c: Handle xpass from combine improvement

After r14-9692-g839bc42772ba7a, a sequence that actually
looks optimal is now emitted, observed at
r14-9788-gb7bd2ec73d66f7.  This caused an XPASS for this
test.  While adjusting the test, better also guard it
against regressions by checking that there are no redundant
move insns.

That's the only test that's improved to the point of
affecting test-patterns.  E.g. pr93372-5.c (which references
pr93372-2.c) is also improved, though it retains a redundant
compare insn.  (PR 93372 was about regressions from the cc0
representation; not further improvement like here, thus it's
not tagged.  Though, I did not double-check whether this
actually *was* a regression from cc0.)

* gcc.target/cris/pr93372-2.c: Tweak scan-assembler
checks to cover recent combine improvement.

5 months agotestsuite/gcc.dg/debug/btf/btf-datasec-1.c: Handle leading-underscore
Hans-Peter Nilsson [Thu, 4 Apr 2024 23:36:54 +0000 (01:36 +0200)] 
testsuite/gcc.dg/debug/btf/btf-datasec-1.c: Handle leading-underscore

I noticed my autotester for cris-elf flagging this as a regression.

* gcc.dg/debug/btf/btf-datasec-1.c: Adjust pattern for targets with
symbols having a leading underscore.

5 months agoDaily bump.
GCC Administrator [Fri, 5 Apr 2024 00:16:44 +0000 (00:16 +0000)] 
Daily bump.

5 months agolibatomic: Fix build for --disable-gnu-indirect-function [PR113986]
Wilco Dijkstra [Tue, 26 Mar 2024 15:08:02 +0000 (15:08 +0000)] 
libatomic: Fix build for --disable-gnu-indirect-function [PR113986]

Fix libatomic build to support --disable-gnu-indirect-function on AArch64.
Always build atomic_16.S, add aliases to the __atomic_ functions if !HAVE_IFUNC.
Include auto-config.h in atomic_16.S to avoid having to pass defines via
makefiles.  Fix build if HWCAP_ATOMICS/CPUID are not defined.

libatomic:
PR target/113986
* Makefile.in: Regenerated.
* Makefile.am: Make atomic_16.S not depend on HAVE_IFUNC.
Remove predefine of HAVE_FEAT_LSE128.
* acinclude.m4: Remove ARCH_AARCH64_HAVE_LSE128.
* configure: Regenerated.
* config/linux/aarch64/atomic_16.S: Add __atomic_ alias if !HAVE_IFUNC.
* config/linux/aarch64/host-config.h: Correctly handle !HAVE_IFUNC.
Add defines for HWCAP_ATOMICS and HWCAP_CPUID.

5 months agoc++: alias CTAD and template template parm [PR114377]
centurion [Wed, 27 Mar 2024 18:36:37 +0000 (18:36 +0000)] 
c++: alias CTAD and template template parm [PR114377]

To match all the other places that pull a _TEMPLATE_PARM out of a
_DECL (get_template_parm_index, etc.).

This change is too small to be legally significant for copyright.

PR c++/114377

gcc/cp/ChangeLog:

* pt.cc (find_template_parameter_info::found): Use TREE_TYPE for
TEMPLATE_DECL instead of DECL_INITIAL.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/class-deduction-alias19.C: New test.

Reviewed-by: Jason Merrill <jason@redhat.com>
5 months agoipa: Avoid duplicate replacements in IPA-SRA transformation phase
Martin Jambor [Thu, 4 Apr 2024 20:46:16 +0000 (22:46 +0200)] 
ipa: Avoid duplicate replacements in IPA-SRA transformation phase

When the analysis part of IPA-SRA figures out that it would split out
a scalar part of an aggregate which is known by IPA-CP to contain a
known constant, it skips it knowing that the transformation part looks
at IPA-CP aggregate results too and does the right thing (which can
include doing the propagation in GIMPLE because that is the last
moment the parameter exists).

However, when IPA-SRA wants to split out a smaller aggregate out
of an aggregate, which happens to be of the same size as a known
scalar constant at the same offset, the transformation bit fails to
recognize the situation, tries to do both splitting and constant
propagation and in PR 111571 testcase creates a nonsensical call
statement on which the call redirection then ICEs.

Fixed by making sure we don't try to do two replacements of the same
part of the same parameter.

The look-up among replacements requires these are sorted and this
patch just sorts them if they are not already sorted before each new
look-up.  The worst number of sortings that can happen is number of
parameters which are both split and have aggregate constants times
param_ipa_max_agg_items (default 16).  I don't think complicating the
source code to optimize for this unlikely case is worth it but if need
be, it can of course be done.

gcc/ChangeLog:

2024-03-15  Martin Jambor  <mjambor@suse.cz>

PR ipa/111571
* ipa-param-manipulation.cc
(ipa_param_body_adjustments::common_initialization): Avoid creating
duplicate replacement entries.

gcc/testsuite/ChangeLog:

2024-03-15  Martin Jambor  <mjambor@suse.cz>

PR ipa/111571
* gcc.dg/ipa/pr111571.c: New test.

5 months ago[PR114415][scheduler]: Fixing wrong code generation
Vladimir N. Makarov [Thu, 4 Apr 2024 20:04:04 +0000 (16:04 -0400)] 
[PR114415][scheduler]: Fixing wrong code generation

  For the test case, the insn scheduler (working for live range
shrinkage) moves insns modifying stack memory before an insn reserving
the stack memory. Comments in the patch contains more details about
the problem and its solution.

gcc/ChangeLog:

PR rtl-optimization/114415
* sched-deps.cc (add_insn_mem_dependence): Add memory check for mem argument.
(sched_analyze_1): Treat stack pointer modification as memory read.
(sched_analyze_2, sched_analyze_insn): Add memory guard for processing pending_read_mems.
* sched-int.h (deps_desc): Add comment to pending_read_mems.

gcc/testsuite/ChangeLog:

PR rtl-optimization/114415
* gcc.target/i386/pr114415.c: New test.

5 months agonvptx: In mkoffload.cc, call diagnostic_color_init + gcc_init_libintl
Tobias Burnus [Thu, 4 Apr 2024 19:55:29 +0000 (21:55 +0200)] 
nvptx: In mkoffload.cc, call diagnostic_color_init + gcc_init_libintl

gcc/ChangeLog:

* config/nvptx/mkoffload.cc (main): Call
gcc_init_libintl and diagnostic_color_init.

5 months agox86: Define __APX_F__ for -mapxf
H.J. Lu [Thu, 4 Apr 2024 15:05:58 +0000 (08:05 -0700)] 
x86: Define __APX_F__ for -mapxf

Define __APX_F__ when APX is enabled.

gcc/

PR target/114587
* config/i386/i386-c.cc (ix86_target_macros_internal): Define
__APX_F__ when APX is enabled.

gcc/testsuite/

PR target/114587
* gcc.target/i386/apx-2.c: New test.

5 months agoAdd gcov MC/DC tests for GDC
Jørgen Kvalsvik [Wed, 6 Dec 2023 08:08:46 +0000 (09:08 +0100)] 
Add gcov MC/DC tests for GDC

This is a mostly straight port from the gcov-19.c tests from the C test
suite. The only notable differences from C to D are that D flips the
true/false outcomes for loop headers, and the D front end ties loop and
ternary conditions to slightly different locus.

The test for >64 conditions warning is disabled as it either needs
support from the testing framework or a something similar to #pragma GCC
diagnostic push to not cause a test failure from detecting a warning.

gcc/testsuite/ChangeLog:

* gdc.dg/gcov.exp: New test.
* gdc.dg/gcov1.d: New test.

5 months agoAdd condition coverage (MC/DC)
Jørgen Kvalsvik [Tue, 5 Dec 2023 11:59:40 +0000 (12:59 +0100)] 
Add condition coverage (MC/DC)

This patch adds support in gcc+gcov for modified condition/decision
coverage (MC/DC) with the -fcondition-coverage flag. MC/DC is a type of
test/code coverage and it is particularly important for safety-critical
applicaitons in industries like aviation and automotive. Notably, MC/DC
is required or recommended by:

    * DO-178C for the most critical software (Level A) in avionics.
    * IEC 61508 for SIL 4.
    * ISO 26262-6 for ASIL D.

From the SQLite webpage:

    Two methods of measuring test coverage were described above:
    "statement" and "branch" coverage. There are many other test
    coverage metrics besides these two. Another popular metric is
    "Modified Condition/Decision Coverage" or MC/DC. Wikipedia defines
    MC/DC as follows:

        * Each decision tries every possible outcome.
        * Each condition in a decision takes on every possible outcome.
        * Each entry and exit point is invoked.
        * Each condition in a decision is shown to independently affect
          the outcome of the decision.

    In the C programming language where && and || are "short-circuit"
    operators, MC/DC and branch coverage are very nearly the same thing.
    The primary difference is in boolean vector tests. One can test for
    any of several bits in bit-vector and still obtain 100% branch test
    coverage even though the second element of MC/DC - the requirement
    that each condition in a decision take on every possible outcome -
    might not be satisfied.

    https://sqlite.org/testing.html#mcdc

MC/DC comes in different flavors, the most important being unique cause
MC/DC and masking MC/DC. This patch implements masking MC/DC, which is
works well with short circuiting semantics, and according to John
Chilenski's "An Investigation of Three Forms of the Modified Condition
Decision Coverage (MCDC) Criterion" (2001) is as good as unique cause at
catching bugs.

Whalen, Heimdahl, and De Silva "Efficient Test Coverage Measurement for
MC/DC" describes an algorithm for finding the masking table from an AST
walk, but my algorithm figures this out by analyzing the control flow
graph.  The CFG is considered a reduced ordered binary decision diagram
and an input vector a path through the BDD, which is recorded.  Specific
edges will mask ("null out") the contribution from earlier path
segments, which can be determined by finding short circuit endpoints.
Masking is most easily understood as circuiting of terms in the
reverse-ordered Boolean function, and the masked conditions do not
affect the decision like short-circuited conditions do not affect the
decision.

A tag/discriminator mapping from gcond->uid is created during
gimplification and made available through the function struct. The
values are unimportant as long as basic conditions constructed from a
single Boolean expression are given the same identifier. This happens in
the breaking down of ANDIF/ORIF trees, so the coverage generally works
well for frontends that create such trees.

Like Whalen et al this implementation records coverage in fixed-size
bitsets which gcov knows how to interpret. Recording conditions only
requires a few bitwise operations per condition and is very fast, but
comes with a limit on the number of terms in a single boolean
expression; the number of bits in a gcov_unsigned_type (which is usually
typedef'd to uint64_t). For most practical purposes this is acceptable,
and by default a warning will be issued if gcc cannot instrument the
expression.  This is a practical limitation in the implementation, and
not a limitation of the algorithm, so support for more conditions can be
supported by introducing arbitrary-sized bitsets.

In action it looks pretty similar to the branch coverage. The -g short
opt carries no significance, but was chosen because it was an available
option with the upper-case free too.

gcov --conditions:

        3:   17:void fn (int a, int b, int c, int d) {
        3:   18:    if ((a && (b || c)) && d)
conditions covered 3/8
condition  0 not covered (true false)
condition  1 not covered (true)
condition  2 not covered (true)
condition  3 not covered (true)
        1:   19:        x = 1;
        -:   20:    else
        2:   21:        x = 2;
        3:   22:}

gcov --conditions --json-format:

"conditions": [
    {
        "not_covered_false": [
            0
        ],
        "count": 8,
        "covered": 3,
        "not_covered_true": [
            0,
            1,
            2,
            3
        ]
    }
],

Expressions with constants may be heavily rewritten before it reaches
the gimplification, so constructs like int x = a ? 0 : 1 becomes
_x = (_a == 0). From source you would expect coverage, but it gets
neither branch nor condition coverage. The same applies to expressions
like int x = 1 || a which are simply replaced by a constant.

The test suite contains a lot of small programs and functions. Some of
these were designed by hand to test for specific behaviours and graph
shapes, and some are previously-failed test cases in other programs
adapted into the test suite.

gcc/ChangeLog:

* builtins.cc (expand_builtin_fork_or_exec): Check
condition_coverage_flag.
* collect2.cc (main): Add -fno-condition-coverage to OBSTACK.
* common.opt: Add new options -fcondition-coverage and
-Wcoverage-too-many-conditions.
* doc/gcov.texi: Add --conditions documentation.
* doc/invoke.texi: Add -fcondition-coverage documentation.
* function.cc (free_after_compilation): Free cond_uids.
* function.h (struct function): Add cond_uids.
* gcc.cc: Link gcov on -fcondition-coverage.
* gcov-counter.def (GCOV_COUNTER_CONDS): New.
* gcov-dump.cc (tag_conditions): New.
* gcov-io.h (GCOV_TAG_CONDS): New.
(GCOV_TAG_CONDS_LENGTH): New.
(GCOV_TAG_CONDS_NUM): New.
* gcov.cc (class condition_info): New.
(condition_info::condition_info): New.
(condition_info::popcount): New.
(struct coverage_info): New.
(add_condition_counts): New.
(output_conditions): New.
(print_usage): Add -g, --conditions.
(process_args): Likewise.
(output_intermediate_json_line): Output conditions.
(read_graph_file): Read condition counters.
(read_count_file): Likewise.
(file_summary): Print conditions.
(accumulate_line_info): Accumulate conditions.
(output_line_details): Print conditions.
* gimplify.cc (next_cond_uid): New.
(reset_cond_uid): New.
(shortcut_cond_r): Set condition discriminator.
(tag_shortcut_cond): New.
(gimple_associate_condition_with_expr): New.
(shortcut_cond_expr): Set condition discriminator.
(gimplify_cond_expr): Likewise.
(gimplify_function_tree): Call reset_cond_uid.
* ipa-inline.cc (can_early_inline_edge_p): Check
condition_coverage_flag.
* ipa-split.cc (pass_split_functions::gate): Likewise.
* passes.cc (finish_optimization_passes): Likewise.
* profile.cc (struct condcov): New declaration.
(cov_length): Likewise.
(cov_blocks): Likewise.
(cov_masks): Likewise.
(cov_maps): Likewise.
(cov_free): Likewise.
(instrument_decisions): New.
(read_thunk_profile): Control output to file.
(branch_prob): Call find_conditions, instrument_decisions.
(init_branch_prob): Add total_num_conds.
(end_branch_prob): Likewise.
* tree-core.h (struct tree_exp): Add condition_uid.
* tree-profile.cc (struct conds_ctx): New.
(CONDITIONS_MAX_TERMS): New.
(EDGE_CONDITION): New.
(topological_cmp): New.
(index_of): New.
(single_p): New.
(single_edge): New.
(contract_edge_up): New.
(struct outcomes): New.
(conditional_succs): New.
(condition_index): New.
(condition_uid): New.
(masking_vectors): New.
(emit_assign): New.
(emit_bitwise_op): New.
(make_top_index_visit): New.
(make_top_index): New.
(paths_between): New.
(struct condcov): New.
(cov_length): New.
(cov_blocks): New.
(cov_masks): New.
(cov_maps): New.
(cov_free): New.
(find_conditions): New.
(struct counters): New.
(find_counters): New.
(resolve_counter): New.
(resolve_counters): New.
(instrument_decisions): New.
(tree_profiling): Check condition_coverage_flag.
(pass_ipa_tree_profile::gate): Likewise.
* tree.h (SET_EXPR_UID): New.
(EXPR_COND_UID): New.

libgcc/ChangeLog:

* libgcov-merge.c (__gcov_merge_ior): New.

gcc/testsuite/ChangeLog:

* lib/gcov.exp: Add condition coverage test function.
* g++.dg/gcov/gcov-18.C: New test.
* gcc.misc-tests/gcov-19.c: New test.
* gcc.misc-tests/gcov-20.c: New test.
* gcc.misc-tests/gcov-21.c: New test.
* gcc.misc-tests/gcov-22.c: New test.
* gcc.misc-tests/gcov-23.c: New test.

5 months agoMAINTAINERS: Update my email address
Paul-Antoine Arras [Thu, 4 Apr 2024 14:39:52 +0000 (16:39 +0200)] 
MAINTAINERS: Update my email address

ChangeLog:

* MAINTAINERS: Update my email address.

5 months agoaarch64: Recognise svundef idiom [PR114577]
Richard Sandiford [Thu, 4 Apr 2024 13:15:49 +0000 (14:15 +0100)] 
aarch64: Recognise svundef idiom [PR114577]

GCC 14 adds the header file arm_neon_sve_bridge.h to help interface
SVE and Advanced SIMD code.  One of the defined idioms is:

  svset_neonq (svundef_TYPE (), advsimd_vector)

which simply reinterprets advsimd_vector as an SVE vector without
regard for what's in the upper bits.

GCC was failing to recognise this idiom, which was likely to
significantly hamper adoption.

There is (AFAIK) no good way of representing an extension with
undefined bits in gimple.  We could add an internal-only builtin
to represent it, but the current framework makes that somewhat
awkward.  It also doesn't seem very forward-looking.

This patch instead goes for the simpler approach of recognising
undefined arguments at expansion time.

gcc/
PR target/114577
* config/aarch64/aarch64-sve-builtins.h (aarch64_sve::lookup_fndecl):
Declare.
* config/aarch64/aarch64-sve-builtins.cc (aarch64_sve::lookup_fndecl):
New function.
* config/aarch64/aarch64-sve-builtins-base.cc (is_undef): Likewise.
(svset_neonq_impl::expand): Optimise expansions whose first argument
is undefined.

gcc/testsuite/
PR target/114577
* gcc.target/aarch64/sve/acle/general/pr114577_1.c: New test.
* gcc.target/aarch64/sve/acle/general/pr114577_2.c: Likewise.

5 months agotree-optimization/114485 - neg induction with partial vectors
Richard Biener [Thu, 4 Apr 2024 08:00:51 +0000 (10:00 +0200)] 
tree-optimization/114485 - neg induction with partial vectors

We can't use vect_update_ivs_after_vectorizer for partial vectors,
the following fixes vect_can_peel_nonlinear_iv_p accordingly.

PR tree-optimization/114485
* tree-vect-loop-manip.cc (vect_can_peel_nonlinear_iv_p):
vect_step_op_neg isn't OK for partial vectors but only
for unknown niter.

* gcc.dg/vect/pr114485.c: New testcase.

5 months agolibgomp.texi: Update entries in OpenMP TR12 implementation status
Tobias Burnus [Thu, 4 Apr 2024 10:20:48 +0000 (12:20 +0200)] 
libgomp.texi: Update entries in OpenMP TR12 implementation status

libgomp/ChangeLog:

* libgomp.texi (TR12): Honor post-TR12 directive name change; add
item about curly braces/BLOCK permitted in canonical loop nests.

5 months agofold-const: Handle NON_LVALUE_EXPR in native_encode_initializer [PR114537]
Jakub Jelinek [Thu, 4 Apr 2024 08:47:52 +0000 (10:47 +0200)] 
fold-const: Handle NON_LVALUE_EXPR in native_encode_initializer [PR114537]

The following testcase is incorrectly rejected.  The problem is that
for bit-fields native_encode_initializer expects the corresponding
CONSTRUCTOR elt value must be INTEGER_CST, but that isn't the case
here, it is wrapped into NON_LVALUE_EXPR by maybe_wrap_with_location.
We could STRIP_ANY_LOCATION_WRAPPER as well, but as all we are looking for
is INTEGER_CST inside, just looking through NON_LVALUE_EXPR seems easier.

2024-04-04  Jakub Jelinek  <jakub@redhat.com>

PR c++/114537
* fold-const.cc (native_encode_initializer): Look through
NON_LVALUE_EXPR if val is INTEGER_CST.

* g++.dg/cpp2a/bit-cast16.C: New test.

5 months agobitint: Handle m_bitfld_load cast in outer m_cast_conditional [PR114555]
Jakub Jelinek [Thu, 4 Apr 2024 08:47:00 +0000 (10:47 +0200)] 
bitint: Handle m_bitfld_load cast in outer m_cast_conditional [PR114555]

We ICE on the following testcase, because we use result of a PHI node
which is only conditional because of a m_cast_conditional on the outermost
loops PHI node argument and so is invalid SSA form.

The following patch fixes it like similar cases elsewhere by adding
needed intervening PHI(s).

2024-04-04  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/114555
* gimple-lower-bitint.cc (bitint_large_huge::handle_cast): For
m_bitfld_load and save_cast_conditional add any needed PHIs
and adjust t4 accordingly.

* gcc.dg/bitint-103.c: New test.
* gcc.dg/bitint-104.c: New test.

5 months ago[MAINTAINERS] Update my email address and step down as arm port maintainer
Kyrylo Tkachov [Thu, 4 Apr 2024 08:12:28 +0000 (09:12 +0100)] 
[MAINTAINERS] Update my email address and step down as arm port maintainer

* MAINTAINERS: Update my email details, remove myself as arm
maintainer.  Add myself to DCO section.

5 months agotree-optimization/114551 - loop splitting and undefined overflow
Richard Biener [Wed, 3 Apr 2024 12:53:30 +0000 (14:53 +0200)] 
tree-optimization/114551 - loop splitting and undefined overflow

When loop splitting hoists a guard computation it needs to make sure
that can be safely evaluated at this place when it was previously
only conditionally evaluated.  The following fixes this for the
case of undefined overflow.

PR tree-optimization/114551
* tree-ssa-loop-split.cc (split_loop): If the guard is
only conditionally evaluated rewrite computations with
possibly undefined overflow to unsigned arithmetic.

* gcc.dg/torture/pr114551.c: New testcase.

5 months agoDon't set full_profile in auto-profile [PR113765]
Eugene Rozenfeld [Tue, 26 Mar 2024 23:28:08 +0000 (16:28 -0700)] 
Don't set full_profile in auto-profile [PR113765]

auto-profile currently doesn't guarantee that it will set probabilities
on all edges because of zero basic block counts. Normally those edges
just have probabilities set by the preceding profile_estimate pass but
under -O0 profile_estimate pass doesn't run. The patch removes setting
of full_profile to true in auto-profile.

Tested on x86_64-pc-linux-gnu.

gcc/ChangeLog:
PR gcov-profile/113765
* auto-profile.cc (afdo_annotate_cfg): Don't set full_profile to true

5 months agoDaily bump.
GCC Administrator [Thu, 4 Apr 2024 00:16:38 +0000 (00:16 +0000)] 
Daily bump.

5 months agoUpdate gcc sv.po
Joseph Myers [Wed, 3 Apr 2024 20:47:47 +0000 (20:47 +0000)] 
Update gcc sv.po

* sv.po: Update.

5 months agoRegenerate i386.opt.urls
Mark Wielaard [Wed, 3 Apr 2024 15:35:25 +0000 (17:35 +0200)] 
Regenerate i386.opt.urls

LoongArch added an -mtls-dialect option, causing the similarly
named option for i386 get renumbered.

Fixes: b253b4695dda ("LoongArch: Add support for TLS descriptors.")
gcc/ChangeLog:

* config/i386/i386.opt.urls: Regenerate.

5 months agolibgcc: Add missing HWCAP entries to aarch64/cpuinfo.c
Wilco Dijkstra [Wed, 27 Mar 2024 16:06:13 +0000 (16:06 +0000)] 
libgcc: Add missing HWCAP entries to aarch64/cpuinfo.c

A few HWCAP entries are missing from aarch64/cpuinfo.c.  This results in build
errors on older machines.

libgcc/
* config/aarch64/cpuinfo.c: Add HWCAP_EVTSTRM, HWCAP_CRC32, HWCAP_CPUID,
HWCAP_PACA and HWCAP_PACG.

5 months agotree-profile: Disable indirect call profiling for IFUNC resolvers
H.J. Lu [Mon, 26 Feb 2024 16:38:58 +0000 (08:38 -0800)] 
tree-profile: Disable indirect call profiling for IFUNC resolvers

We can't profile indirect calls to IFUNC resolvers nor their callees as
it requires TLS which hasn't been set up yet when the dynamic linker is
resolving IFUNC symbols.

Add an IFUNC resolver caller marker to cgraph_node and set it if the
function is called by an IFUNC resolver.  Disable indirect call profiling
for IFUNC resolvers and their callees.

Tested with profiledbootstrap on Fedora 39/x86-64.

gcc/ChangeLog:

PR tree-optimization/114115
* cgraph.h (symtab_node): Add check_ifunc_callee_symtab_nodes.
(cgraph_node): Add called_by_ifunc_resolver.
* cgraphunit.cc (symbol_table::compile): Call
symtab_node::check_ifunc_callee_symtab_nodes.
* symtab.cc (check_ifunc_resolver): New.
(ifunc_ref_map): Likewise.
(is_caller_ifunc_resolver): Likewise.
(symtab_node::check_ifunc_callee_symtab_nodes): Likewise.
* tree-profile.cc (gimple_gen_ic_func_profiler): Disable indirect
call profiling for IFUNC resolvers and their callees.

gcc/testsuite/ChangeLog:

PR tree-optimization/114115
* gcc.dg/pr114115.c: New test.

5 months agolto-wrapper.cc: Add offload target name to 'offload_args' suffix
Tobias Burnus [Wed, 3 Apr 2024 13:47:12 +0000 (15:47 +0200)] 
lto-wrapper.cc: Add offload target name to 'offload_args' suffix

lto-wrapper.cc's compile_offload_image calls mkoffload with
an @./a.offload_args argument ('a.' in case of, e.g., 'a.out'). However,
when generating code for both nvptx and gcn, they use the same name
with -save-temps. Hence, this commit adds a <target> + '.' before
'offload_args' in line with other offload-target-specific files.

gcc/ChangeLog:

* lto-wrapper.cc (compile_offload_image): Prefix 'offload_args'
suffix by the target name.

5 months agolibphobos, Darwin: Enable libphobos for most Darwin.
Iain Sandoe [Mon, 1 Apr 2024 12:58:20 +0000 (13:58 +0100)] 
libphobos, Darwin: Enable libphobos for most Darwin.

Earlier Darwin systems can be made to work too - but they need non-
standard 'binutils', so for now these must be enabled specifically.

libphobos/ChangeLog:

* configure.tgt: Enable libphobos for Darwin >= 12.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
5 months agoGCN: install.texi update for Newlib change and LLVM 18 release
Tobias Burnus [Wed, 3 Apr 2024 12:16:41 +0000 (14:16 +0200)] 
GCN: install.texi update for Newlib change and LLVM 18 release

gcc/ChangeLog:

* doc/install.texi (amdgcn-*-amdhsa): Update Newlib recommendation
and update wording for LLVM 18 release.

5 months agolibstdc++: Reverse arguments in constraint for std::optional's <=> [PR104606]
Jonathan Wakely [Wed, 27 Mar 2024 21:51:13 +0000 (21:51 +0000)] 
libstdc++: Reverse arguments in constraint for std::optional's <=> [PR104606]

This is a workaround for a possible compiler bug that causes constraint
recursion in the operator<=>(const optional<T>&, const U&) overload.

libstdc++-v3/ChangeLog:

PR libstdc++/104606
* include/std/optional (operator<=>(const optional<T>&, const U&)):
Reverse order of three_way_comparable_with template arguments.
* testsuite/20_util/optional/relops/104606.cc: New test.

5 months agoGCN: Fix --with-arch= handling in mkoffload [PR111966]
Tobias Burnus [Wed, 3 Apr 2024 10:37:39 +0000 (12:37 +0200)] 
GCN: Fix --with-arch= handling in mkoffload [PR111966]

The default -march= setting used in mkoffload did not reflect the modified
default set by GCC's configure-time --with-arch=, causing issues when
generating debug code.

gcc/ChangeLog:

PR other/111966
* config/gcn/mkoffload.cc (get_arch): New; moved -march= flag
handling from ...
(main): ... here; call it to handle --with-arch config option
and -march= commandline.

5 months agolibquadmath: Don't assume the storage for __float128 arguments is aligned [PR114533]
Jakub Jelinek [Wed, 3 Apr 2024 08:02:35 +0000 (10:02 +0200)] 
libquadmath: Don't assume the storage for __float128 arguments is aligned [PR114533]

With the register_printf_type/register_printf_modifier/register_printf_specifier
APIs the C library is just told the size of the argument and is provided with
a callback to fetch the argument from va_list using va_arg into C library provided
memory.  The C library isn't told what alignment requirement it has, but we were
using direct load of a __float128 value from that memory which assumes
__alignof (__float128) alignment.

The following patch fixes that by using memcpy instead.

I haven't been able to reproduce an actual crash, tried
 #include <quadmath.h>
 #include <stdlib.h>
 #include <stdio.h>

int main ()
{
  __float128 r;
  int prec = 20;
  int width = 46;
  char buf[128];

  r = 2.0q;
  r = sqrtq (r);
  int n = quadmath_snprintf (buf, sizeof buf, "%+-#*.20Qe", width, r);
  if ((size_t) n < sizeof buf)
    printf ("%s\n", buf);
    /* Prints: +1.41421356237309504880e+00 */
  quadmath_snprintf (buf, sizeof buf, "%Qa", r);
  if ((size_t) n < sizeof buf)
    printf ("%s\n", buf);
    /* Prints: 0x1.6a09e667f3bcc908b2fb1366ea96p+0 */
  n = quadmath_snprintf (NULL, 0, "%+-#46.*Qe", prec, r);
  if (n > -1)
    {
      char *str = malloc (n + 1);
      if (str)
        {
          quadmath_snprintf (str, n + 1, "%+-#46.*Qe", prec, r);
          printf ("%s\n", str);
          /* Prints: +1.41421356237309504880e+00 */
        }
      free (str);
    }
  printf ("%+-#*.20Qe\n", width, r);
  printf ("%Qa\n", r);
  printf ("%+-#46.*Qe\n", prec, r);
  printf ("%d %Qe %d %Qe %d %Qe\n", 1, r, 2, r, 3, r);
  return 0;
}
In any case, I think memcpy for loading from it is right.

2024-04-03  Simon Chopin  <simon.chopin@canonical.com>
    Jakub Jelinek  <jakub@redhat.com>

PR libquadmath/114533
* printf/printf_fp.c (__quadmath_printf_fp): Use memcpy to copy
__float128 out of args.
* printf/printf_fphex.c (__quadmath_printf_fphex): Likewise.

Signed-off-by: Simon Chopin <simon.chopin@canonical.com>
5 months agoexpr: Fix up emit_push_insn [PR114552]
Jakub Jelinek [Wed, 3 Apr 2024 07:59:45 +0000 (09:59 +0200)] 
expr: Fix up emit_push_insn [PR114552]

r13-990 added optimizations in multiple spots to optimize during
expansion storing of constant initializers into targets.
In the load_register_parameters and expand_expr_real_1 cases,
it checks it has a tree as the source and so knows we are reading
that whole decl's value, so the code is fine as is, but in the
emit_push_insn case it checks for a MEM from which something
is pushed and checks for SYMBOL_REF as the MEM's address, but
still assumes the whole object is copied, which as the following
testcase shows might not always be the case.  In the testcase,
k is 6 bytes, then 2 bytes of padding, then another 4 bytes,
while the emit_push_insn wants to store just the 6 bytes.

The following patch simply verifies it is the whole initializer
that is being stored, I think that is best thing to do so late
in GCC 14 cycle as well for backporting.

For GCC 15, perhaps the code could stop requiring it must be at offset zero,
nor that the size is equal, but could use
get_symbol_constant_value/fold_ctor_reference gimple-fold APIs to actually
extract just part of the initializer if we e.g. push just some subset
(of course, still verify that it is a subset).  For sizes which are power
of two bytes and we have some integer modes, we could use as type for
fold_ctor_reference corresponding integral types, otherwise dunno, punt
or use some structure (e.g. try to find one in the initializer?), whatever.
But even in the other spots it could perhaps handle loading of
COMPONENT_REFs or MEM_REFs from the .rodata vars.

2024-04-03  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/114552
* expr.cc (emit_push_insn): Only use store_constructor for
immediate_const_ctor_p if int_expr_size matches size.

* gcc.c-torture/execute/pr114552.c: New test.

5 months agotree-optimization/114557 - reduce ehcleanup peak memory use
Richard Biener [Tue, 2 Apr 2024 10:31:04 +0000 (12:31 +0200)] 
tree-optimization/114557 - reduce ehcleanup peak memory use

The following reduces peak memory use for the PR114480 testcase at -O1
which is almost exclusively spent by the ehcleanup pass in allocating
PHI nodes.  The free_phinodes cache we maintain isn't very effective
since it has effectively two slots, one for 4 and one for 9 argument
PHIs and it is only ever used for allocations up to 9 arguments but
we put all larger PHIs in the 9 argument bucket.  This proves
uneffective resulting in much garbage to be kept when incrementally
growing PHI nodes by edge redirection.

The mitigation is to rely on the GC freelist for larger sizes and
thus immediately return all larger bucket sized PHIs to it via ggc_free.

This reduces the peak memory use from 19.8GB to 11.3GB and compile-time
from 359s to 168s.

PR tree-optimization/114557
PR tree-optimization/114480
* tree-phinodes.cc (release_phi_node): Return PHIs from
allocation buckets not covered by free_phinodes to GC.
(remove_phi_node): Release the PHI LHS before freeing the
PHI node.
* tree-vect-loop.cc (vectorizable_live_operation): Get PHI lhs
before releasing it.

5 months agoLoongArch: Remove unused code.
Jiahao Xu [Wed, 3 Apr 2024 01:38:23 +0000 (09:38 +0800)] 
LoongArch: Remove unused code.

gcc/ChangeLog:

* config/loongarch/lasx.md: Remove unused code.
* config/loongarch/loongarch-protos.h
(loongarch_split_lsx_copy_d): Remove.
(loongarch_split_lsx_insert_d): Ditto.
(loongarch_split_lsx_fill_d): Ditto.
* config/loongarch/loongarch.cc
(loongarch_split_lsx_copy_d): Ditto.
(loongarch_split_lsx_insert_d): Ditto.
(loongarch_split_lsx_fill_d): Ditto.
* config/loongarch/lsx.md (lsx_vpickve2gr_du): Remove splitter.
(lsx_vpickve2gr_<lsxfmt_f>): Ditto.
(abs<mode>2): Remove expander.
(vabs<mode>2): Rename 2 abs<mode>2.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/vector/lsx/lsx-abs.c: New test.

5 months agoDaily bump.
GCC Administrator [Wed, 3 Apr 2024 00:17:29 +0000 (00:17 +0000)] 
Daily bump.

5 months agoPR modula2/114565 progress trace would be useful to isolate ICE for users
Gaius Mulley [Tue, 2 Apr 2024 22:47:42 +0000 (23:47 +0100)] 
PR modula2/114565 progress trace would be useful to isolate ICE for users

This patch introduces the internal option -fm2-debug-trace= which can
be given a comma separated list of filter terms.  Currently it allows:
all,line,token,quad.  The patch allows users to trace the progress of
cc1gm2 so that source which causes an ICE can be reduced.  Once
PR113836 is complete it is expected that the trace information will be
written to file.

gcc/m2/ChangeLog:

PR modula2/114565
* gm2-compiler/M2GenGCC.mod (CodeStatement): Test
GetDebugTraceQuad before calling DisplayQuad.
* gm2-compiler/M2LexBuf.mod (NumberIO): Import CardToStr.
(GetToken): Test GetDebugTraceToken before writing the
token number or token line.
* gm2-compiler/M2Options.def (SetDebugTraceQuad): Rename to
(SetM2DebugTraceFilter): ...this.
(SetDebugTraceAPI): Remove.
(GetDebugTraceQuad): New procedure function.
(GetDebugTraceTree): Ditto.
(GetDebugTraceToken): Ditto.
(GetDebugTraceLine): Ditto.
(GetDebugFunctionLineNumbers): Ditto.
* gm2-compiler/M2Options.mod (DebugFunctionLineNumbers): New
boolean variable.
(DebugTraceQuad): Ditto.
(DebugTraceTree): Ditto.
(DebugTraceLine): Ditto.
(DebugTraceToken): Ditto.
(errors1): New procedure.
(SetDebugTraceQuad): Remove.
(SetM2DebugTraceFilter): New procedure implemented.
(SetM2DebugTrace): Ditto.
(GetDebugTraceQuad): Ditto.
(GetDebugTraceToken ): Ditto.
(GetDebugTraceLine): Ditto.
(SetDebugTraceLine): Remove.
* gm2-compiler/M2Quads.mod (GenQuadOTrash): Test
GetDebugTraceQuad and call DisplayQuad.
(GenQuadOTypetok): Ditto.
* gm2-compiler/SymbolTable.mod: Replace
DebugFunctionLineNumbers with GetDebugFunctionLineNumbers.
* gm2-gcc/init.cc (_M2_M2LangDump_init): Add prototype.
(init_PerCompilationInit): Add call.
* gm2-gcc/m2misc.cc (m2misc_cerror): New function.
(m2misc_error): Ditto.
* gm2-gcc/m2misc.def (error): New procedure.
(cerror): Ditto.
* gm2-gcc/m2misc.h (m2misc_cerror): New prototype.
(m2misc_error): Ditto.
* gm2-gcc/m2options.h (M2Options_SetDebugTraceQuad): New
prototype.
(M2Options_SetDebugTraceAPI): Remove.
(M2Options_GetDebugTraceToken): New prototype.
(M2Options_GetDebugTraceLine): Ditto.
(M2Options_SetDebugFunctionLineNumbers): Ditto.
(M2Options_GetDebugFunctionLineNumbers): Ditto.
(M2Options_SetM2DebugTraceFilter): Ditto.
* gm2-lang.cc (gm2_langhook_init_options): Remove
OPT_fdebug_trace_quad case.
Remove OPT_fdebug_trace_api case.
Add OPT_fm2_debug_trace_ case.
* lang.opt (fm2-debug-trace): New option.
(fdebug-trace-api): Remove.
(fdebug-trace-quad): Remove.
* m2.flex (m2flex_M2Error): Check s for NULL.
(skipnewline): New function.
(consumeLine): Call traceline.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
5 months agoFix ICE with -g and -std=c23 related to incomplete types [PR114361]
Martin Uecker [Thu, 28 Mar 2024 18:15:40 +0000 (19:15 +0100)] 
Fix ICE with -g and -std=c23 related to incomplete types [PR114361]

We did not copy TYPE_CANONICAL to the incomplete variants when
completing a structure.

PR c/114361

gcc/c/
* c-decl.cc (finish_struct): Set TYPE_CANONICAL when completing
strucute types.

gcc/testsuite/
* gcc.dg/pr114361.c: New test.
* gcc.dg/c23-tag-incomplete-1.c: New test.
* gcc.dg/c23-tag-incomplete-2.c: New test.

5 months agoanalyzer: prevent ICEs with null types
David Malcolm [Tue, 2 Apr 2024 21:42:16 +0000 (17:42 -0400)] 
analyzer: prevent ICEs with null types

Fixes some ICEs seen analyzing the Linux kernel.

gcc/analyzer/ChangeLog:
* region-model-manager.cc (maybe_undo_optimize_bit_field_compare):
Guard against null types.
* region-model.cc (apply_constraints_for_gswitch): Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
5 months agolibstdc++: Guard uses of char8_t with __cpp_char8_t [PR114519]
Jonathan Wakely [Thu, 28 Mar 2024 21:29:17 +0000 (21:29 +0000)] 
libstdc++: Guard uses of char8_t with __cpp_char8_t [PR114519]

libstdc++-v3/ChangeLog:

PR libstdc++/114519
* include/bits/unicode.h (_Utf8_view): Guard with check for
char8_t being enabled.
(__literal_encoding_is_unicode): Guard use of char8_t with check
for it being enabled.
* testsuite/std/format/functions/114519.cc: New test.

5 months agolibiberty: Invoke D demangler when --format=auto
Tom Tromey [Sat, 30 Mar 2024 19:48:30 +0000 (13:48 -0600)] 
libiberty: Invoke D demangler when --format=auto

Investigating GDB PR d/31580 showed that the libiberty demangler
doesn't automatically demangle D mangled names.  However, I think it
should -- like C++ and Rust (new-style), D mangled names are readily
distinguished by the leading "_D", and so the likelihood of confusion
is low.  The other non-"auto" cases in this code are Ada (where the
encoded form could more easily be confused by ordinary programs) and
Java (which is long gone, but which also shared the C++ mangling and
thus was just an output style preference).

This patch also fixed another GDB bug, though of course that part
won't apply to the GCC repository.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31580
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30276

libiberty
* cplus-dem.c (cplus_demangle): Try the D demangler with
"auto" format.
* testsuite/d-demangle-expected: Add --format=auto test.

5 months agoc++: make __is_array return false for T[0] [PR114479]
Marek Polacek [Mon, 1 Apr 2024 16:55:46 +0000 (12:55 -0400)] 
c++: make __is_array return false for T[0] [PR114479]

When we switched to using the __is_array built-in trait to implement
std::is_array in r14-6623-g7fd9c349e45534, we started saying that
T[0] is an array.  There are various opinions as to whether that is
the best answer, but it seems prudent to keep the GCC 13 result.

PR c++/114479

gcc/cp/ChangeLog:

* semantics.cc (trait_expr_value) <case CPTK_IS_ARRAY>: Return false
for zero-sized arrays.

gcc/testsuite/ChangeLog:

* g++.dg/ext/is_array.C: Extend.

5 months agoc++: ICE with scoped enum in switch condition [PR103825]
Marek Polacek [Fri, 29 Mar 2024 20:59:37 +0000 (16:59 -0400)] 
c++: ICE with scoped enum in switch condition [PR103825]

Here we ICE when gimplifying

  enum class Type { Pawn };
  struct Piece {
    Type type : 4;
  };
  void foo() {
    switch (Piece().type)
      case Type::Pawn:;
  }

because we ended up with TYPE_PRECISION (cond) < TYPE_PRECISION (case).
That's because the case expr type here is the unlowered type Type,
whereas the conditional's type is the lowered <unnamed-signed:4>.  This
is not supposed to happen: see the comment in pop_switch around the
is_bitfield_expr_with_lowered_type check.

But here we did not revert to the lowered SWITCH_STMT_TYPE, because
the conditional contains a TARGET_EXPR, which has side-effects, which
means that finish_switch_cond -> maybe_cleanup_point_expr wraps it
in a CLEANUP_POINT_EXPR.  And is_bitfield_expr_with_lowered_type does
not see through those.

PR c++/103825

gcc/cp/ChangeLog:

* typeck.cc (is_bitfield_expr_with_lowered_type): Handle
CLEANUP_POINT_EXPR.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/enum44.C: New test.

5 months agoc++: binding reference to comma expr [PR114561]
Jason Merrill [Tue, 2 Apr 2024 14:52:28 +0000 (10:52 -0400)] 
c++: binding reference to comma expr [PR114561]

We represent a reference binding where the referent type is more qualified
by a ck_ref_bind around a ck_qual.  We performed the ck_qual and then tried
to undo it with STRIP_NOPS, but that doesn't work if the conversion is
buried in COMPOUND_EXPR.  So instead let's avoid performing that fake
conversion in the first place.

PR c++/114561
PR c++/114562

gcc/cp/ChangeLog:

* call.cc (convert_like_internal): Avoid adding qualification
conversion in direct reference binding.

gcc/testsuite/ChangeLog:

* g++.dg/conversion/ref10.C: New test.
* g++.dg/conversion/ref11.C: New test.

5 months agolibstdc++: Allow adjacent __maybe_present_t<false, ...> fields to overlap
Patrick Palka [Tue, 2 Apr 2024 17:07:07 +0000 (13:07 -0400)] 
libstdc++: Allow adjacent __maybe_present_t<false, ...> fields to overlap

Currently __maybe_present_t<false, T> maps to the same empty class
type independent of T.  This is suboptimal because it means adjacent
__maybe_present_t<false, ...> members with the [[no_unique_address]]
attribute can't overlap even if the conditionally present types are
different.

This patch turns this empty class type into a template parameterized by
the conditionally present type, so that

  [[no_unique_address]] __maybe_present_t<false, T> _M_a;
  [[no_unique_address]] __maybe_present_t<false, U> _M_b;

now overlap if T and U are different.

This patch goes a step further and also adds an optional integer
discriminator parameter to allow for overlapping when T and U are
the same.

libstdc++-v3/ChangeLog:

* include/std/ranges (ranges::__detail::_Empty): Rename to ...
(ranges::__detail::_Absent): ... this.  Turn into a template
parameterized by the absent type _Tp and discriminator _Disc.
(ranges::__detail::__maybe_present_t): Add an optional
discriminator parameter.
(slide_view::_M_cached_begin): Pass a discriminator argument to
__maybe_present_t.
(slide_view::_M_cached_end): Likewise.
* testsuite/std/ranges/adaptors/sizeof.cc: Verify the size of
slide_view<V> is 3 instead 4 pointers.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
5 months agoaarch64: Fix typo in comment about FEATURE_STRING
Christophe Lyon [Fri, 29 Mar 2024 14:25:05 +0000 (14:25 +0000)] 
aarch64: Fix typo in comment about FEATURE_STRING

Fix the comment to document FEATURE_STRING instead of FEAT_STRING.

2024-03-29  Christophe Lyon  <christophe.lyon@linaro.org>

gcc/
* config/aarch64/aarch64-option-extensions.def: Fix comment.

5 months agoPrettify output of debug_dwarf_die
Tom Tromey [Thu, 28 Mar 2024 19:22:34 +0000 (13:22 -0600)] 
Prettify output of debug_dwarf_die

When debugging gcc, I tried calling debug_dwarf_die and I saw this
output:

      DW_AT_location: location descriptor:
        (0x7fffe9c2e870) DW_OP_dup 0, 0
        (0x7fffe9c2e8c0) DW_OP_bra location descriptor (0x7fffe9c2e640)
, 0
        (0x7fffe9c2e820) DW_OP_lit4 4, 0
        (0x7fffe9c2e910) DW_OP_skip location descriptor (0x7fffe9c2e9b0)
, 0
        (0x7fffe9c2e640) DW_OP_dup 0, 0

I think those ", 0" should not appear on their own lines.  The issue
seems to be that print_dw_val should not generally emit a newline,
except when recursing.

gcc/ChangeLog

* dwarf2out.cc (print_dw_val) <dw_val_class_loc>: Don't
print newline when not recursing.

5 months agoFortran: Add error for subroutine passed to a variable dummy [PR106999]
Paul Thomas [Tue, 2 Apr 2024 14:53:29 +0000 (15:53 +0100)] 
Fortran: Add error for subroutine passed to a variable dummy [PR106999]

2024-04-02  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/106999
* interface.cc (gfc_compare_interfaces): Add error for a
subroutine proc pointer passed to a variable formal.
(compare_parameter): If a procedure pointer is being passed to
a non-procedure formal arg, and there is an an interface, use
gfc_compare_interfaces to check and provide a more useful error
message.

gcc/testsuite/
PR fortran/106999
* gfortran.dg/pr106999.f90: New test.

5 months agoFortran: Fix wrong recursive errors and class initialization [PR112407]
Paul Thomas [Tue, 2 Apr 2024 13:19:09 +0000 (14:19 +0100)] 
Fortran: Fix wrong recursive errors and class initialization [PR112407]

2024-04-02  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/112407
* resolve.cc (resolve_procedure_expression): Change the test for
for recursion in the case of hidden procedures from modules.
(resolve_typebound_static): Add warning for possible recursive
calls to typebound procedures.
* trans-expr.cc (gfc_trans_class_init_assign): Do not apply
default initializer to class dummy where component initializers
are all null.

gcc/testsuite/
PR fortran/112407
* gfortran.dg/pr112407a.f90: New test.
* gfortran.dg/pr112407b.f90: New test.

5 months agoFix up postboot dependencies [PR106472]
Jakub Jelinek [Tue, 2 Apr 2024 11:40:27 +0000 (13:40 +0200)] 
Fix up postboot dependencies [PR106472]

On Wed, Mar 13, 2024 at 10:13:37AM +0100, Jakub Jelinek wrote:
> While the first Makefile.tpl hunk looks obviously ok, the others look
> completely wrong to me.
> There is nothing special about libgo vs. libbacktrace/libatomic
> compared to any other target library which is not bootstrapped vs. any
> of its dependencies which are in the bootstrapped set.
> So, Makefile.tpl shouldn't hardcode such dependencies.

Here is my version of the fix.
The dependencies in the toplevel Makefile simply didn't take into account
that some target modules could be in a bootstrapped build built in some
configurations as bootstrap modules (typically as dependencies of other
target bootstrap modules), while in other configurations just as
dependencies of non-bootstrap target modules and so not built during the
bootstrap, but after it.
Makefile.tpl arranges for those postboot target module -> target module
dependencies to be emitted only inside of an @unless gcc-bootstrap block,
while for @if gcc-bootstrap it just emits
configure-target-whatever: stage_last
dependencies which ensure those postbootstrap target modules are only built
after everything that is bootstrapped has been.

Now, the libbacktrace/libatomic target modules have bootstrap=true
target_modules = { module= libbacktrace; bootstrap=true; };
target_modules = { module= libatomic; bootstrap=true; lib_path=.libs; };
because those modules are dependencies of libphobos target module, so
when d is included among bootstrapped languages, those are all bootstrapped
and everything works correctly.
While if d is not included, libphobos target module is disabled,
libbacktrace/libatomic target modules aren't bootstrapped, nothing during
bootstrap needs them, but post bootstrap libgo target module depends on
the libatomic and libbacktrace target modules, libgfortran target module
depends on the libbacktrace target module and libgm2 target module depends
on the libatomic target module, but those dependencies were emitted only
@unless gcc-bootstrap.  There is a similar theoretical problem for zlib
target module if GCJ would be ressurected, libphobos as bootstrap target
module depends on the zlib target module, but if d is not configured,
fastjar also depends on it.

The following patch arranges for the @if gcc-bootstrap case to emit also
target module -> target module dependencies, but conditionally on the
on dependency not being bootstrapped.

In the generated Makefile.in you can see what the Makefile.tpl change
produces and that it just adds extra dependencies which weren't there
before in the @if gcc-bootstrap case.

I've bootstrapped without this patch with
../configure --enable-languages=c,c++,go; make
on x86_64-linux (note, make -j2 or higher usually worked) which failed
as described in the PR, then with this patch with the same command which
built fine and the Makefile difference between the two builds being
diff -up obj40{a,b}/Makefile
--- obj40a/Makefile     2024-03-31 00:35:22.243791499 +0100
+++ obj40b/Makefile     2024-03-31 22:40:38.143299144 +0200
@@ -29376,6 +29376,14 @@ configure-bison: stage_last
 configure-flex: stage_last
 configure-m4: stage_last

+configure-target-fastjar: maybe-configure-target-zlib
+all-target-fastjar: maybe-all-target-zlib
+all-target-libgo: maybe-all-target-libbacktrace
+all-target-libgo: maybe-all-target-libatomic
+all-target-libgm2: maybe-all-target-libatomic
+configure-target-libgfortran: maybe-all-target-libbacktrace
+configure-target-libgo: maybe-all-target-libbacktrace
+

 # Dependencies for target modules on other target modules are
 # described by lang_env_dependencies; the defaults apply to anything

which I believe are exactly the extra dependencies we want.
Plus I've done normal x86_64-linux and i686-linux bootstraps/regtests
which in my case include --enable-languages=default,ada,obj-c++,lto,go,d,rust,m2
for x86_64 and the same except ada for i686; those with my usual make -j32.
The Makefile difference in those builds vs. unpatched case
is just an extra empty line.

2024-04-02  Jakub Jelinek  <jakub@redhat.com>

PR bootstrap/106472
* Makefile.tpl (make-postboot-target-dep): New lambda.
Use it to add --enable-bootstrap dependencies of target modules
on other target modules if the latter aren't bootstrapped.
* Makefile.in: Regenerate.

5 months agoFix up duplicated words mostly in comments, part 1
Jakub Jelinek [Tue, 2 Apr 2024 11:39:11 +0000 (13:39 +0200)] 
Fix up duplicated words mostly in comments, part 1

Like in r12-7519-g027e30414492d50feb2854aff38227b14300dc4b, I've done
git grep -v 'long long\|optab optab\|template template\|double double' | grep ' \([a-zA-Z]\+\) \1 '

This is just part of the changes, mostly for non-gcc directories.
I'll try to get to the rest soon.  Obviously, the above command also
finds cases which are correct as is and shouldn't be changed, so one
needs to manually inspect everything.

I'd hope most of it is pretty obvious, but the config/ and libstdc++-v3/
hunks include a tweak in a license wording, though other copies of the
similar license have the wording right.

2024-04-02  Jakub Jelinek  <jakub@redhat.com>

* Makefile.tpl: Fix duplicated words; returns returns ->
returns.
config/
* lcmessage.m4: Fix duplicated words; can can -> can,
package package -> package.
libdecnumber/
* decCommon.c (decFinalize): Fix duplicated words in
comment; the the -> the.
libgcc/
* unwind-dw2-fde.c (struct fde_accumulator): Fix duplicated
words in comment; is is -> is.
libgfortran/
* configure.host: Fix duplicated words; the the -> the.
libgm2/
* configure.host: Fix duplicated words; the the -> the.
libgomp/
* libgomp.texi (OpenMP 5.2): Fix duplicated words; with with ->
with.
(omp_target_associate_ptr): Fix duplicated words; either either ->
either.
(omp_init_allocator): Fix duplicated words; be be -> be.
(omp_realloc): Fix duplicated words; is is -> is.
(OMP_ALLOCATOR): Fix duplicated words; other other -> other.
* priority_queue.h (priority_queue_multi_p): Fix duplicated words;
to to -> to.
libiberty/
* regex.c (byte_re_match_2_internal): Fix duplicated words in comment;
next next -> next.
* dyn-string.c (dyn_string_init): Fix duplicated words in comment;
of of -> of.
libitm/
* beginend.cc (GTM::gtm_thread::begin_transaction): Fix duplicated
words in comment; not not -> not to.
libobjc/
* init.c (duplicate_classes): Fix duplicated words in comment; in in
-> in.
* sendmsg.c (__objc_prepare_dtable_for_class): Fix duplicated words
in comment; the the -> the.
* encoding.c (objc_layout_structure): Likewise.
libstdc++-v3/
* acinclude.m4: Fix duplicated words; file file -> file can.
* configure.host: Fix duplicated words; the the -> the.
libvtv/
* vtv_rts.cc (vtv_fail): Fix duplicated words; to to -> to.
* vtv_fail.cc (vtv_fail): Likewise.

5 months agojit, Darwin: Implement library exports list.
Iain Sandoe [Sat, 13 Jan 2024 17:20:47 +0000 (17:20 +0000)] 
jit, Darwin: Implement library exports list.

Currently, we have no exports list for libgccjit, which means that
all symbols are exported, including those from libstdc++ which is
linked statically into the lib.  This causes failures when the
shared libstdc++ is used but some c++ symbols are satisfied from
libgccjit.

This implements an export file for Darwin (which is currently
manually created by cross-checking libgccjit.map).  Ideally we'd
script this, at some point.  Update libtool current and age to
reflect the current ABI version (we are not bumping the SO name
at this stage).

This fixes a number of new failures in jit testing.

gcc/jit/ChangeLog:

* Make-lang.in: Implement exports list, and use a shared
libgcc.
* libgccjit.exports: New file.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
5 months agotestsuite: Remove duplicate -lgcov [PR114034]
Iain Sandoe [Sun, 31 Mar 2024 10:22:58 +0000 (11:22 +0100)] 
testsuite: Remove duplicate -lgcov [PR114034]

Duplicate library entries now cause linker warnings with newer linker
versions on Darwin which leads to these tests regressing.  The library
is already added by the test flags so there is no need to put an extra
one in the options.

PR testsuite/114034

gcc/testsuite/ChangeLog:

* g++.dg/gcov/gcov-dump-1.C: Remove extra -lgcov.
* g++.dg/gcov/gcov-dump-2.C: Likewise.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
5 months agotestsuite, Darwin: Allow for an undefined symbol [PR114036].
Iain Sandoe [Sun, 31 Mar 2024 10:27:53 +0000 (11:27 +0100)] 
testsuite, Darwin: Allow for an undefined symbol [PR114036].

Darwin's linker defaults to requiring all symbols to be defined at
static link time (unless specifically noted or dynamic lookuo is
enabled).

For this test, we just need to note that the symbol is expected to
be undefined.

PR testsuite/114036

gcc/testsuite/ChangeLog:

* gcc.misc-tests/gcov-14.c: Allow for 'Foo' to be undefined
on Darwin link lines.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
5 months agoDarwin: Correct a version check.
Iain Sandoe [Mon, 1 Apr 2024 19:47:25 +0000 (20:47 +0100)] 
Darwin: Correct a version check.

When the version for dsymutil comes from a clang build, it is
of the form NNmm.pp.qq where NN and mm are the major and minor
LLVM version components.  We need to check for a major version
greater than or equal to 7 - so use 700 in the check.

gcc/ChangeLog:

* config/darwin.cc (darwin_override_options): Update the
clang major version value in the dsymutil check.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
5 months agoDarwin: Do not emit .macinfo when dsymutil cannot consume it.
Iain Sandoe [Sun, 31 Mar 2024 22:25:31 +0000 (23:25 +0100)] 
Darwin: Do not emit .macinfo when dsymutil cannot consume it.

Some verions of dsymutil do not ignore .macinfo sections, but instead
ignore the entire debug in the file.

To avoid this total loss of debug, when we detect that the debug level
is g3 and the dsymutil version cannot support it, we reduce the level
to g2 and issue a note.

This behaviour can be overidden by -gstrict-dwarf (although the objects
will contain macinfo; dsymutil will not produce a .dSYM with it).

gcc/ChangeLog:

* config/darwin.cc (darwin_override_options): Reduce the debug
level to 2 if dsymutil cannot handle .macinfo sections.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
5 months agotestsuite, Darwin: Update bad-mapper-1 after libiberty changes.
Iain Sandoe [Fri, 8 Mar 2024 09:21:39 +0000 (09:21 +0000)] 
testsuite, Darwin: Update bad-mapper-1 after libiberty changes.

A recent change to libiberty has improved the process spawning on
older Darwin platforms.  This patch updates the expected test output
after the changes.

gcc/testsuite/ChangeLog:

* g++.dg/modules/bad-mapper-1.C: Update expected test output
for earlier Darwin.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
5 months agoLoongArch: Fix missing plugin header
Yang Yujie [Tue, 2 Apr 2024 01:20:32 +0000 (09:20 +0800)] 
LoongArch: Fix missing plugin header

gcc/ChangeLog:

* config/loongarch/t-loongarch: Add loongarch-def-arrays.h
to OPTION_H_EXTRA.

5 months agoLoongArch: Add support for TLS descriptors.
mengqinggang [Tue, 2 Apr 2024 01:57:20 +0000 (09:57 +0800)] 
LoongArch: Add support for TLS descriptors.

Add support for TLS descriptors on normal code model and extreme
code model.

Normal code model instruction sequence:
  -mno-explicit-relocs:
    la.tls.desc $r4, s
    add.d $r12, $r4, $r2
  -mexplicit-relocs:
    pcalau12i $r4,%desc_pc_hi20(s)
    addi.d $r4,$r4,%desc_pc_lo12(s)
    ld.d $r1,$r4,%desc_ld(s)
    jirl $r1,$r1,%desc_call(s)
    add.d $r12, $r4, $r2

Extreme code model instruction sequence:
  -mno-explicit-relocs:
    la.tls.desc $r4, $r12, s
    add.d $r12, $r4, $r2
  -mexplicit-relocs:
    pcalau12i $r4,%desc_pc_hi20(s)
    addi.d $r12,$r0,%desc_pc_lo12(s)
    lu32i.d $r12,%desc64_pc_lo20(s)
    lu52i.d $r12,$r12,%desc64_pc_hi12(s)
    add.d $r4,$r4,$r12
    ld.d $r1,$r4,%desc_ld(s)
    jirl $r1,$r1,%desc_call(s)
    add.d $r12, $r4, $r2

The default is still traditional TLS model, but can be configured with
--with-tls={trad,desc}. The default can change to TLS descriptors once
libc and LLVM support this.

gcc/ChangeLog:

* config.gcc: Add --with-tls option to change TLS flavor.
* config/loongarch/genopts/loongarch.opt.in: Add -mtls-dialect to
configure TLS flavor.
* config/loongarch/loongarch-def.h (struct loongarch_target): Add
tls_dialect.
* config/loongarch/loongarch-driver.cc (la_driver_init): Add tls
flavor.
* config/loongarch/loongarch-opts.cc (loongarch_init_target): Add
tls_dialect.
(loongarch_config_target): Ditto.
(loongarch_update_gcc_opt_status): Ditto.
* config/loongarch/loongarch-opts.h (loongarch_init_target): Ditto.
(TARGET_TLS_DESC): New define.
* config/loongarch/loongarch.cc (loongarch_symbol_insns): Add TLS
DESC instructions sequence length.
(loongarch_legitimize_tls_address): New TLS DESC instruction sequence.
(loongarch_option_override_internal): Add la_opt_tls_dialect.
(loongarch_option_restore): Add la_target.tls_dialect.
* config/loongarch/loongarch.md (@got_load_tls_desc<mode>): Normal
code model for TLS DESC.
(got_load_tls_desc_off64): Extreme cmode model for TLS DESC.
* config/loongarch/loongarch.opt: Regenerate.
* config/loongarch/loongarch.opt.urls: Ditto.
* doc/invoke.texi: Add a description of the compilation option
'-mtls-dialect={trad,desc}'.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/cmodel-extreme-1.c: Add -mtls-dialect=trad.
* gcc.target/loongarch/cmodel-extreme-2.c: Ditto.
* gcc.target/loongarch/explicit-relocs-auto-tls-ld-gd.c: Ditto.
* gcc.target/loongarch/explicit-relocs-medium-call36-auto-tls-ld-gd.c:
Ditto.
* gcc.target/loongarch/func-call-medium-1.c: Ditto.
* gcc.target/loongarch/func-call-medium-2.c: Ditto.
* gcc.target/loongarch/func-call-medium-3.c: Ditto.
* gcc.target/loongarch/func-call-medium-4.c: Ditto.
* gcc.target/loongarch/tls-extreme-macro.c: Ditto.
* gcc.target/loongarch/tls-gd-noplt.c: Ditto.
* gcc.target/loongarch/explicit-relocs-auto-extreme-tls-desc.c: New test.
* gcc.target/loongarch/explicit-relocs-auto-tls-desc.c: New test.
* gcc.target/loongarch/explicit-relocs-extreme-tls-desc.c: New test.
* gcc.target/loongarch/explicit-relocs-tls-desc.c: New test.

Co-authored-by: Lulu Cheng <chenglulu@loongson.cn>
Co-authored-by: Xi Ruoyao <xry111@xry111.site>
5 months agoLoongArch: Regenerate loongarch.opt.urls.
Lulu Cheng [Mon, 1 Apr 2024 03:00:21 +0000 (11:00 +0800)] 
LoongArch: Regenerate loongarch.opt.urls.

Fixes: d28ea8e5a704 ("LoongArch: Split loongarch_option_override_internal
      into smaller procedures")

gcc/ChangeLog:

* config/loongarch/loongarch.opt.urls: Regenerate.

5 months agoDaily bump.
GCC Administrator [Tue, 2 Apr 2024 00:17:27 +0000 (00:17 +0000)] 
Daily bump.

5 months agoPR modula2/114548 gm2 fails to identify variable in a const expression
Gaius Mulley [Mon, 1 Apr 2024 18:18:36 +0000 (19:18 +0100)] 
PR modula2/114548 gm2 fails to identify variable in a const expression

This patch introduces stricter checking within standard procedure
functions which detect whether paramaters are variable when used
in a const expression.

gcc/m2/ChangeLog:

PR modula2/114548
* gm2-compiler/M2Quads.mod (ConvertToAddress): Pass
procedure, false parameters to BuildConvertFunction.
(PushOne): Pass procedure, true parameters to
BuildConvertFunction.
Remove usused parameter internal.
(BuildPseudoBy): Remove parameter to PushOne.
(BuildIncProcedure): Ditto.
(BuildDecProcedure): Ditto.
(BuildFunctionCall): Add ConstExpr parameter to
BuildPseudoFunctionCall.
(BuildConstFunctionCall): Add procedure and true to
BuildConvertFunction.
(BuildPseudoFunctionCall): Add ConstExpr parameter.
Pass ProcSym and ConstExpr to BuildLengthFunction,
BuildConvertFunction, BuildOddFunction, BuildAbsFunction,
BuildCapFunction, BuildValFunction, BuildChrFunction,
BuildOrdFunction, BuildIntFunction, BuildTruncFunction,
BuildFloatFunction, BuildAddAdrFunction, BuildSubAdrFunction,
BuildDifAdrFunction, BuildCastFunction, BuildReFunction,
BuildImFunction and BuildCmplxFunction.
(BuildAddAdrFunction): Add ProcSym, ConstExpr parameters and
check for constant parameters.
(BuildSubAdrFunction): Ditto.
(BuildDifAdrFunction): Ditto.
(ConstExprError): Ditto.
(BuildLengthFunction): Ditto.
(BuildOddFunction): Ditto.
(BuildAbsFunction): Ditto.
(BuildCapFunction): Ditto.
(BuildChrFunction): Ditto.
(BuildOrdFunction): Ditto.
(BuildIntFunction): Ditto.
(BuildValFunction): Ditto.
(BuildCastFunction): Ditto.
(BuildConvertFunction): Ditto.
(BuildTruncFunction): Ditto.
(BuildFloatFunction): Ditto.
(BuildReFunction): Ditto.
(BuildImFunction): Ditto.
(BuildCmplxFunction): Ditto.

gcc/testsuite/ChangeLog:

PR modula2/114548
* gm2/iso/const/fail/expression.mod: New test.
* gm2/iso/const/fail/iso-const-fail.exp: New test.
* gm2/iso/const/fail/testabs.mod: New test.
* gm2/iso/const/fail/testaddadr.mod: New test.
* gm2/iso/const/fail/testcap.mod: New test.
* gm2/iso/const/fail/testcap2.mod: New test.
* gm2/iso/const/fail/testchr.mod: New test.
* gm2/iso/const/fail/testchr2.mod: New test.
* gm2/iso/const/fail/testcmplx.mod: New test.
* gm2/iso/const/fail/testfloat.mod: New test.
* gm2/iso/const/fail/testim.mod: New test.
* gm2/iso/const/fail/testint.mod: New test.
* gm2/iso/const/fail/testlength.mod: New test.
* gm2/iso/const/fail/testodd.mod: New test.
* gm2/iso/const/fail/testord.mod: New test.
* gm2/iso/const/fail/testre.mod: New test.
* gm2/iso/const/fail/testtrunc.mod: New test.
* gm2/iso/const/fail/testval.mod: New test.
* gm2/iso/const/pass/constbool.mod: New test.
* gm2/iso/const/pass/constbool2.mod: New test.
* gm2/iso/const/pass/constbool3.mod: New test.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
5 months agoc++: C++26 returning reference to temporary
Jason Merrill [Fri, 29 Mar 2024 01:33:57 +0000 (21:33 -0400)] 
c++: C++26 returning reference to temporary

P2748R5 makes it ill-formed to return a reference to temporary in C++26;
implementing this is a simple matter of changing the existing warning to a
permerror.

For most of the tests I just changed dg-warning to dg-message to accept
both; I test the specific diagnostic type in Wreturn-local-addr-5.C.

gcc/cp/ChangeLog:

* typeck.cc (maybe_warn_about_returning_address_of_local):
Permerror in C++26.

gcc/testsuite/ChangeLog:

* g++.dg/conversion/pr16333.C: Change dg-warning to dg-message.
* g++.dg/cpp0x/constexpr-48324.C
* g++.dg/other/pr94326.C
* g++.dg/warn/Wreturn-local-addr-2.C
* g++.old-deja/g++.jason/warning8.C: Likewise.
* g++.dg/cpp1y/auto-fn6.C: Check that others don't complain.
* g++.dg/warn/Wreturn-local-addr-5.C: Expect error in C++26.

5 months agoLoongArch: Split loongarch_option_override_internal into smaller procedures
Yang Yujie [Sat, 30 Mar 2024 08:43:14 +0000 (16:43 +0800)] 
LoongArch: Split loongarch_option_override_internal into smaller procedures

gcc/ChangeLog:

* config/loongarch/genopts/loongarch.opt.in: Mark -m[no-]recip as
aliases to -mrecip={all,none}, respectively.
* config/loongarch/loongarch.opt: Regenerate.
* config/loongarch/loongarch-def.h (ABI_FPU_64): Rename to...
(ABI_FPU64_P): ...this.
(ABI_FPU_32): Rename to...
(ABI_FPU32_P): ...this.
(ABI_FPU_NONE): Rename to...
(ABI_NOFPU_P): ...this.
(ABI_LP64_P): Define.
* config/loongarch/loongarch.cc (loongarch_init_print_operand_punct):
Merged into loongarch_global_init.
(loongarch_cpu_option_override): Renamed to
loongarch_target_option_override.
(loongarch_option_override_internal): Move the work after
loongarch_config_target into loongarch_target_option_override.
(loongarch_global_init): Define.
(INIT_TARGET_FLAG): Move to loongarch-opts.cc.
(loongarch_option_override): Call loongarch_global_init
separately.
* config/loongarch/loongarch-opts.cc (loongarch_parse_mrecip_scheme):
Split the parsing of -mrecip=<string> from
loongarch_option_override_internal.
(loongarch_generate_mrecip_scheme): Define. Split from
loongarch_option_override_internal.
(loongarch_target_option_override): Define. Renamed from
loongarch_cpu_option_override.
(loongarch_init_misc_options): Define. Split from
loongarch_option_override_internal.
(INIT_TARGET_FLAG): Move from loongarch.cc.
* config/loongarch/loongarch-opts.h (loongarch_target_option_override):
New prototype.
(loongarch_parse_mrecip_scheme): New prototype.
(loongarch_init_misc_options): New prototype.
(TARGET_ABI_LP64): Simplify with ABI_LP64_P.
* config/loongarch/loongarch.h (TARGET_RECIP_DIV): Simplify.
Do not reference specific CPU architecture (LA664).
(TARGET_RECIP_SQRT): Same.
(TARGET_RECIP_RSQRT): Same.
(TARGET_RECIP_VEC_DIV): Same.
(TARGET_RECIP_VEC_SQRT): Same.
(TARGET_RECIP_VEC_RSQRT): Same.

5 months agoLoongArch: Add descriptions of the compilation options.
Lulu Cheng [Sat, 30 Mar 2024 07:14:14 +0000 (15:14 +0800)] 
LoongArch: Add descriptions of the compilation options.

Add descriptions for the compilation options '-mfrecipe' '-mdiv32'
'-mlam-bh' '-mlamcas' and '-mld-seq-sa'.

gcc/ChangeLog:

* doc/invoke.texi: Add descriptions for the compilation
options.

5 months agoDaily bump.
GCC Administrator [Mon, 1 Apr 2024 00:16:45 +0000 (00:16 +0000)] 
Daily bump.

5 months agomodula2: Fix m2.install-info in gcc/m2/Make-lang.in
Christophe Lyon [Fri, 29 Mar 2024 17:59:38 +0000 (17:59 +0000)] 
modula2: Fix m2.install-info in gcc/m2/Make-lang.in

Fix a few typos: the generated filename is m2.info (not gm2.info, and
gm2$(exeext) is a file not a directory (so test -d would always fail).

2024-03-29  Christophe Lyon  <christophe.lyon@linaro.org>

gcc/m2/
* Make-lang.in (m2.install-info): Fix rule.

5 months agomodula2: Add m2.install-html rule to gcc/m2/Make-lang.in
Christophe Lyon [Fri, 29 Mar 2024 17:10:36 +0000 (17:10 +0000)] 
modula2: Add m2.install-html rule to gcc/m2/Make-lang.in

This rule was missing, and 'make install-html' was failing.
It is copied from the corresponding one in fortran.

2024-03-29  Christophe Lyon  <christophe.lyon@linaro.org>

gcc/m2/
* Make-lang.in (install-html): New rule.

5 months ago[committed] RISC-V: Add missing insn types to XiangShan Nanhu scheduler model
Jeff Law [Sun, 31 Mar 2024 16:51:17 +0000 (10:51 -0600)] 
[committed] RISC-V: Add missing insn types to XiangShan Nanhu scheduler model

The test for the recently added XiangShan Nanhu microarchitecture is failing
because the scheduler description does not have entries for certain insn types.

I'm adding  branch, jalr, ret and sfb_alu to the scheduler description, that's
enough to get the trivial test to pass.  However, I strongly suspect running
any significant code through the compiler when scheduling for this
microarchitecture will trigger faults.

Basically we have checking now that will fault if we have an insn in the IL
without an associated type or if we have an insn in the IL that does not map to
an insn reservation in the scheduler model.  We were tripping the latter
assertion for one of those branch types.  My suspicion is many insn types
aren't handled by that DFA.

The branch insns were pretty obvious and easy to fix.  But someone with more
experience with the uarch needs to do an audit to ensure that all insn types
map to an insn reservation.

gcc/
* config/riscv/xiangshan.md (xiangshan_jump): Add branch, jalr, ret
and sfb_alu.

5 months agoRISC-V: Fix misspelled term builtin in error message
Pan Li [Sat, 30 Mar 2024 12:03:18 +0000 (20:03 +0800)] 
RISC-V: Fix misspelled term builtin in error message

This patch would like to fix below misspelled term in error message.

../../gcc/config/riscv/riscv-vector-builtins.cc:4592:16: error:
misspelled term 'builtin function' in format; use 'built-in function' instead [-Werror=format-diag]
 4592 |               "builtin function %qE requires the V ISA extension", exp);

The below tests are passed for this patch.
* The riscv regression test on rvv.exp and riscv.exp.

gcc/ChangeLog:

* config/riscv/riscv-vector-builtins.cc (expand_builtin): Take
the term built-in over builtin.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-7.c:
Adjust test dg-error.
* gcc.target/riscv/rvv/base/target_attribute_v_with_intrinsic-8.c:
Ditto.

Signed-off-by: Pan Li <pan2.li@intel.com>
5 months agoRISC-V: Fix one unused varable in riscv_subset_list::parse
Pan Li [Sat, 30 Mar 2024 13:32:06 +0000 (21:32 +0800)] 
RISC-V: Fix one unused varable in riscv_subset_list::parse

This patch would like to fix one unused variable as below:

../../gcc/common/config/riscv/riscv-common.cc: In static member function
'static riscv_subset_list* riscv_subset_list::parse(const char*, location_t)':
../../gcc/common/config/riscv/riscv-common.cc:1501:19: error: unused variable 'itr'
  [-Werror=unused-variable]
 1501 |   riscv_subset_t *itr;

The variable consume code was removed but missed the var itself in
previous.  Thus, we have unused variable here.

gcc/ChangeLog:

* common/config/riscv/riscv-common.cc (riscv_subset_list::parse):
Remove unused var decl.

Signed-off-by: Pan Li <pan2.li@intel.com>
5 months agoDaily bump.
GCC Administrator [Sun, 31 Mar 2024 00:16:32 +0000 (00:16 +0000)] 
Daily bump.

5 months agomips: Fix C23 (...) functions returning large aggregates [PR114175]
Xi Ruoyao [Wed, 20 Mar 2024 07:09:21 +0000 (15:09 +0800)] 
mips: Fix C23 (...) functions returning large aggregates [PR114175]

We were assuming TYPE_NO_NAMED_ARGS_STDARG_P don't have any named
arguments and there is nothing to advance, but that is not the case
for (...) functions returning by hidden reference which have one such
artificial argument.  This is causing gcc.dg/c23-stdarg-{6,8,9}.c to
fail.

Fix the issue by checking if arg.type is NULL, as r14-9503 explains.

gcc/ChangeLog:

PR target/114175
* config/mips/mips.cc (mips_setup_incoming_varargs): Only skip
mips_function_arg_advance for TYPE_NO_NAMED_ARGS_STDARG_P
functions if arg.type is NULL.

5 months agoDaily bump.
GCC Administrator [Sat, 30 Mar 2024 00:16:42 +0000 (00:16 +0000)] 
Daily bump.

5 months ago[PATCH] Allow `gcc_jit_type_get_size` to work with pointers
Guillaume Gomez [Fri, 29 Mar 2024 17:56:33 +0000 (18:56 +0100)] 
[PATCH] Allow `gcc_jit_type_get_size` to work with pointers

gcc/jit/ChangeLog:

* libgccjit.cc (gcc_jit_type_get_size): Add pointer support

5 months agoFix lrcpc3 testcase
Christophe Lyon [Fri, 29 Mar 2024 14:19:59 +0000 (14:19 +0000)] 
Fix lrcpc3 testcase

There was a typo in the testcase, with GCC_CPUINFO pointing to the
wrong file.

2024-03-29  Christophe Lyon  <christophe.lyon@linaro.org>

gcc/testsuite/
* gcc.target/aarch64/cpunative/native_cpu_24.c: Fix GCC_CPUINFO.

5 months agolibstdc++-v3: drop GCC Runtime Library Exception from gen tests
Arsen Arsenović [Fri, 29 Mar 2024 11:42:19 +0000 (12:42 +0100)] 
libstdc++-v3: drop GCC Runtime Library Exception from gen tests

It was mistakenly added to these files.

libstdc++-v3/ChangeLog:

* testsuite/24_iterators/range_generators/01.cc: Drop GCC
Runtime Library Exception.
* testsuite/24_iterators/range_generators/02.cc: Drop GCC
Runtime Library Exception.
* testsuite/24_iterators/range_generators/copy.cc: Drop GCC
Runtime Library Exception.
* testsuite/24_iterators/range_generators/except.cc: Drop GCC
Runtime Library Exception.
* testsuite/24_iterators/range_generators/subrange.cc: Drop GCC
Runtime Library Exception.
* testsuite/24_iterators/range_generators/synopsis.cc: Drop GCC
Runtime Library Exception.
* testsuite/24_iterators/range_generators/iter_deref_return.cc:
Drop GCC Runtime Library Exception from the "You should have
received a copy" paragraph.

5 months agoGCN: Enable effective-target 'vect_long_mult'
Thomas Schwinge [Wed, 20 Mar 2024 22:56:58 +0000 (23:56 +0100)] 
GCN: Enable effective-target 'vect_long_mult'

... as made apparent by commit bfd6b36f08021f023e0e9223f5aea315b74a5c56
"testsuite/vect: Fix pr25413a.c expectations [PR109705]" causing:

     PASS: gcc.dg/vect/pr25413a.c (test for excess errors)
     PASS: gcc.dg/vect/pr25413a.c execution test
    -PASS: gcc.dg/vect/pr25413a.c scan-tree-dump-times vect "vectorized 2 loops" 1
    +FAIL: gcc.dg/vect/pr25413a.c scan-tree-dump-times vect "vectorized 1 loops" 1

..., which this commit resolves.

gcc/testsuite/
* lib/target-supports.exp (check_effective_target_vect_long_mult):
Enable for GCN.

5 months agoGCN: Enable effective-target 'vect_hw_misalign'
Thomas Schwinge [Wed, 20 Mar 2024 22:52:26 +0000 (23:52 +0100)] 
GCN: Enable effective-target 'vect_hw_misalign'

... as made apparent by commit 4e1fcf44bdc582e71408175d75e025f5be8b0e55
"testsuite: vect: Require vect_hw_misalign in gcc.dg/vect/vect-cost-model-1.c etc. [PR98238]"
causing:

     PASS: gcc.dg/vect/vect-cost-model-1.c (test for excess errors)
    -PASS: gcc.dg/vect/vect-cost-model-1.c scan-tree-dump vect "LOOP VECTORIZED"

     PASS: gcc.dg/vect/vect-cost-model-3.c (test for excess errors)
    -PASS: gcc.dg/vect/vect-cost-model-3.c scan-tree-dump vect "LOOP VECTORIZED"

     PASS: gcc.dg/vect/vect-cost-model-5.c (test for excess errors)
    -PASS: gcc.dg/vect/vect-cost-model-5.c scan-tree-dump vect "LOOP VECTORIZED"

..., and similarly commit ffd47fb63ddc024db847daa07f8ae27fffdfcb28
"testsuite: Fix pr113431.c FAIL on sparc* [PR113431]" causing:

     PASS: gcc.dg/vect/pr113431.c (test for excess errors)
     PASS: gcc.dg/vect/pr113431.c execution test
    -PASS: gcc.dg/vect/pr113431.c scan-tree-dump-times slp1 "optimized: basic block part vectorized" 2

..., which this commit all restores, and also enables a good number of further
FAIL -> PASS, UNSUPPORTED -> PASS, etc. progressions.  There are also a small
number of regressions, mostly in the SLP area apparently:

     PASS: gcc.dg/vect/bb-slp-layout-12.c (test for excess errors)
    +XPASS: gcc.dg/vect/bb-slp-layout-12.c scan-tree-dump-not slp1 "duplicating permutation node"
    +XFAIL: gcc.dg/vect/bb-slp-layout-12.c scan-tree-dump-times slp1 "add new stmt: [^\\n\\r]* = VEC_PERM_EXPR" 3

     PASS: gcc.dg/vect/bb-slp-layout-6.c (test for excess errors)
    +FAIL: gcc.dg/vect/bb-slp-layout-6.c scan-tree-dump slp2 "absorbing input layouts"

     PASS: gcc.dg/vect/pr97428.c (test for excess errors)
     PASS: gcc.dg/vect/pr97428.c scan-tree-dump vect "Detected interleaving load of size 8"
     PASS: gcc.dg/vect/pr97428.c scan-tree-dump vect "Detected interleaving store of size 16"
     PASS: gcc.dg/vect/pr97428.c scan-tree-dump-not vect "gap of 6 elements"
    -XFAIL: gcc.dg/vect/pr97428.c scan-tree-dump-times vect "vectorizing stmts using SLP" 2
    +FAIL: gcc.dg/vect/pr97428.c scan-tree-dump-times vect "vectorizing stmts using SLP" 2

     PASS: gcc.dg/vect/vect-33.c (test for excess errors)
    +FAIL: gcc.dg/vect/vect-33.c scan-tree-dump vect "Vectorizing an unaligned access"
     PASS: gcc.dg/vect/vect-33.c scan-tree-dump-not optimized "Invalid sum"
     PASS: gcc.dg/vect/vect-33.c scan-tree-dump-times vect "vectorized 1 loops" 1

..., so some further conditionalizing etc. seems necessary.  These seem to
mostly appear next to pre-existing similar FAILs in related test cases.
(Overall, way more PASS than FAIL.)

gcc/testsuite/
* lib/target-supports.exp
(check_effective_target_vect_hw_misalign): Enable for GCN.
(check_effective_target_vect_element_align): Adjust.

5 months agoGCN: Enable effective-target 'vect_early_break', 'vect_early_break_hw'
Thomas Schwinge [Tue, 9 Jan 2024 09:25:48 +0000 (10:25 +0100)] 
GCN: Enable effective-target 'vect_early_break', 'vect_early_break_hw'

Via XPASSing test cases after commit a657c7e3518fcfc796f223d47385cad5e97dc9a5
"testsuite: un-xfail TSVC loops that check for exit control flow vectorization":

    PASS: gcc.dg/vect/tsvc/vect-tsvc-s332.c (test for excess errors)
    PASS: gcc.dg/vect/tsvc/vect-tsvc-s332.c execution test
    [-XFAIL:-]{+XPASS:+} gcc.dg/vect/tsvc/vect-tsvc-s332.c scan-tree-dump vect "vectorized 1 loops"

    PASS: gcc.dg/vect/tsvc/vect-tsvc-s481.c (test for excess errors)
    PASS: gcc.dg/vect/tsvc/vect-tsvc-s481.c execution test
    [-XFAIL:-]{+XPASS:+} gcc.dg/vect/tsvc/vect-tsvc-s481.c scan-tree-dump vect "vectorized 1 loops"

    PASS: gcc.dg/vect/tsvc/vect-tsvc-s482.c (test for excess errors)
    PASS: gcc.dg/vect/tsvc/vect-tsvc-s482.c execution test
    [-XFAIL:-]{+XPASS:+} gcc.dg/vect/tsvc/vect-tsvc-s482.c scan-tree-dump vect "vectorized 1 loops"

..., it became apparent that GCN, too, does support vectorization of loops with
early breaks.  The relevant test cases are all-PASS with just the following
exceptions, to be looked into individually, later on:

    PASS: gcc.dg/vect/vect-early-break_25.c (test for excess errors)
    PASS: gcc.dg/vect/vect-early-break_25.c scan-tree-dump-times vect "vectorized 1 loops" 1
    FAIL: gcc.dg/vect/vect-early-break_25.c scan-tree-dump-times vect "Alignment of access forced using peeling" 1

    PASS: gcc.dg/vect/vect-early-break_56.c (test for excess errors)
    PASS: gcc.dg/vect/vect-early-break_56.c execution test
    XPASS: gcc.dg/vect/vect-early-break_56.c scan-tree-dump-times vect "vectorized 2 loops" 2

gcc/testsuite/
* lib/target-supports.exp
(check_effective_target_vect_early_break)
(check_effective_target_vect_early_break_hw): Enable for GCN.

5 months agoFortran: fix NULL pointer dereference on overlapping initialization [PR50410]
Harald Anlauf [Thu, 28 Mar 2024 21:34:40 +0000 (22:34 +0100)] 
Fortran: fix NULL pointer dereference on overlapping initialization [PR50410]

gcc/fortran/ChangeLog:

PR fortran/50410
* trans-expr.cc (gfc_conv_structure): Check for NULL pointer.

gcc/testsuite/ChangeLog:

PR fortran/50410
* gfortran.dg/data_initialized_4.f90: New test.

5 months agoFortran: Fix a gimplifier ICE/wrong result with finalization [PR36337]
Paul Thomas [Fri, 29 Mar 2024 07:23:19 +0000 (07:23 +0000)] 
Fortran: Fix a gimplifier ICE/wrong result with finalization [PR36337]

2024-03-29  Paul Thomas  <pault@gcc.gnu.org>

gcc/fortran
PR fortran/36337
PR fortran/110987
PR fortran/113885
* trans-expr.cc (gfc_trans_assignment_1): Place finalization
block before rhs post block for elemental rhs.
* trans.cc (gfc_finalize_tree_expr): Check directly if a type
has no components, rather than the zero components attribute.
Treat elemental zero component expressions in the same way as
scalars.

gcc/testsuite/
PR fortran/113885
* gfortran.dg/finalize_54.f90: New test.
* gfortran.dg/finalize_55.f90: New test.

gcc/testsuite/
PR fortran/110987
* gfortran.dg/finalize_56.f90: New test.

5 months agoUse fatal_error instead of internal_error for when ZSTD is not enabled
Andrew Pinski [Thu, 28 Mar 2024 23:46:33 +0000 (16:46 -0700)] 
Use fatal_error instead of internal_error for when ZSTD is not enabled

This changes an internal error to be a fatal error for when the ZSTD
is not enabled but the section was compressed as ZSTD.

Committed as approved after bootstrap/test on x86_64-linux-gnu.

gcc/ChangeLog:

* lto-compress.cc (lto_end_uncompression): Use
fatal_error instead of internal_error when ZSTD
is not enabled.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
5 months agotestsuite: Add a test case for negating FP vectors containing zeros
Xi Ruoyao [Tue, 6 Feb 2024 09:49:50 +0000 (17:49 +0800)] 
testsuite: Add a test case for negating FP vectors containing zeros

Recently I've fixed two wrong FP vector negate implementation which
caused wrong sign bits in zeros in targets (r14-8786 and r14-8801).  To
prevent a similar issue from happening again, add a test case.

Tested on x86_64 (with SSE2, AVX, AVX2, and AVX512F), AArch64, MIPS
(with MSA), LoongArch (with LSX and LASX).

gcc/testsuite:

* gcc.dg/vect/vect-neg-zero.c: New test.

5 months agoDaily bump.
GCC Administrator [Fri, 29 Mar 2024 00:17:27 +0000 (00:17 +0000)] 
Daily bump.

5 months ago[committed] Provide suitable output template for zero_extendqihi2 on H8
Jeff Law [Thu, 28 Mar 2024 22:56:53 +0000 (16:56 -0600)] 
[committed] Provide suitable output template for zero_extendqihi2 on H8

Segher's recent combine change, quite unexpectedly, triggered a regression on
the H8 port.  It failed to build newlib.

The zero_extendqihi2 pattern provided two alternatives.  One where the source
and destination matched.  That turns into a suitable instruction trivially.
The second alternative was actually meant to capture cases where the value is
coming from memory.

What was missing here was the reg->reg case where the source and destination do
not match.  That fell into the second case which was requested to be split by
the pattern's output template.

The splitter had a suitable condition to make sure it only triggered in the
right cases.  Unfortunately with the pattern requiring a split in a case where
the splitter was going to fail led to the fault.

So regardless of what's going on in the combiner, this code was just wrong.
Fixed thusly by providing a suitable output template for the reg->reg case.

Regression tested on h8300-elf.  Pushing to the trunk.

gcc/

* config/h8300/extensions.md (zero_extendqihi*): Add output
template for reg->reg case where the regs don't match.

5 months agoFix failure of c-c++-common/analyzer/stdarg-pr111289-int.c on hpux
John David Anglin [Thu, 28 Mar 2024 18:32:12 +0000 (18:32 +0000)] 
Fix failure of c-c++-common/analyzer/stdarg-pr111289-int.c on hpux

2024-03-28  John David Anglin  <danglin@gcc.gnu.org>

gcc/testsuite/ChangeLog:

PR analyzer/111289
* c-c++-common/analyzer/stdarg-pr111289-int.c: Don't include
<limits.h>.

5 months agoc++: __is_constructible ref binding [PR100667]
Jason Merrill [Wed, 27 Mar 2024 20:14:01 +0000 (16:14 -0400)] 
c++: __is_constructible ref binding [PR100667]

The requirement that a type argument be complete is excessive in the case of
direct reference binding to the same type, which does not rely on any
properties of the type.  This is LWG 2939.

PR c++/100667

gcc/cp/ChangeLog:

* semantics.cc (same_type_ref_bind_p): New.
(finish_trait_expr): Use it.

gcc/testsuite/ChangeLog:

* g++.dg/ext/is_constructible8.C: New test.

5 months agoFortran: fix DATA and derived types with pointer components [PR114474]
Harald Anlauf [Wed, 27 Mar 2024 20:18:04 +0000 (21:18 +0100)] 
Fortran: fix DATA and derived types with pointer components [PR114474]

When matching actual arguments in match_actual_arg, these are initially
treated as a possible dummy procedure, assuming that the correct type is
determined later.  This resolution could fail when the procedure is a
derived type constructor with a pointer component and appears in a DATA
statement, where the pointer shall be associated with an initial data
target.  Check for those cases where the type obviously has not been
resolved yet, and which were missed because there was no component
reference.

gcc/fortran/ChangeLog:

PR fortran/114474
* primary.cc (gfc_variable_attr): Catch variables used in structure
constructors within DATA statements that are still tagged with a
temporary type BT_PROCEDURE from match_actual_arg and which have the
target attribute, and fix their typespec.

gcc/testsuite/ChangeLog:

PR fortran/114474
* gfortran.dg/data_pointer_3.f90: New test.

5 months agoRISC-V: testsuite: ensure vtype is call clobbered
Vineet Gupta [Wed, 27 Mar 2024 21:55:04 +0000 (14:55 -0700)] 
RISC-V: testsuite: ensure vtype is call clobbered

Per classic Vector calling convention ABI, vtype is call clobbered,
so ensure gcc regenerates a VSETVLI in following cases:
 - after a function call.
 - after an inline asm fragment which clobbers vtype.

ATM gcc seems to be doing the right thing, but a test can never hurt.

gcc/testsuite/ChangeLog:
* gcc.target/riscv/rvv/vtype-call-clobbered.c: New Test.

Signed-off-by: Vineet Gupta <vineetg@rivosinc.com>
5 months agoPR modula2/114520 Incorrect ordering of import/export statements cause confusion
Gaius Mulley [Thu, 28 Mar 2024 16:49:44 +0000 (16:49 +0000)] 
PR modula2/114520 Incorrect ordering of import/export statements cause confusion

The error recovery causes misleading error messages to appear if an
EXPORT and IMPORT statement are in the wrong order.  This patch
detects the incorrect order and issues an error message and prevents
error recovery.  The fix should be improved and made more general if
another similar case is required.

gcc/m2/ChangeLog:

PR modula2/114520
* gm2-compiler/P0SyntaxCheck.bnf (DetectImport): New
procedure.
(EnableImportCheck): New boolean.
(Expect): Call DetectImport.
(Export): Set EnableImportCheck TRUE before ';' and FALSE
afterwards.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
5 months agoPR modula2/114517 gm2 does not allow comparison operator hash in column one
Gaius Mulley [Thu, 28 Mar 2024 14:57:49 +0000 (14:57 +0000)] 
PR modula2/114517 gm2 does not allow comparison operator hash in column one

This patch allows -fno-cpp to be supplied to gm2.  Without this patch
it causes an ICE.  The patch allows -fno-cpp to turn off cpp flags.
These are tested in m2.flex to decide whether a change of state is
allowed (enabling handling of #line directives).

gcc/ChangeLog:

PR modula2/114517
* doc/gm2.texi: Mention gm2 treats a # in the first column
as a preprocessor directive unless -fno-cpp is supplied.

gcc/m2/ChangeLog:

PR modula2/114517
* gm2-compiler/M2Options.def (SetCpp): Add comment.
(GetCpp): Move after SetCpp.
(GetLineDirectives): New procedure function.
* gm2-compiler/M2Options.mod (GetLineDirectives): New
procedure function.
* gm2-gcc/m2options.h (M2Options_GetLineDirectives): New
prototype.
* gm2-lang.cc (gm2_langhook_init_options): OPT_fcpp only
assert if !value.
* m2.flex: Test GetLineDirectives before changing to LINE0
state.

gcc/testsuite/ChangeLog:

PR modula2/114517
* gm2/cpp/fail/hashfirstcolumn2.mod: New test.
* gm2/imports/fail/imports-fail.exp: New test.
* gm2/imports/fail/localmodule2.mod: New test.
* gm2/imports/run/pass/localmodule.mod: New test.

Signed-off-by: Gaius Mulley <(no_default)>
5 months agopredict: Fix comment typo
Jakub Jelinek [Thu, 28 Mar 2024 14:12:08 +0000 (15:12 +0100)] 
predict: Fix comment typo

I've noticed a typo in a comment.

2024-03-28  Jakub Jelinek  <jakub@redhat.com>

* predict.cc (estimate_bb_frequencies): Fix comment typo,
scalling -> scaling.

5 months agoprofile-count: Avoid overflows into uninitialized [PR112303]
Jakub Jelinek [Thu, 28 Mar 2024 14:00:44 +0000 (15:00 +0100)] 
profile-count: Avoid overflows into uninitialized [PR112303]

The testcase in the patch ICEs with
--- gcc/tree-scalar-evolution.cc
+++ gcc/tree-scalar-evolution.cc
@@ -3881,7 +3881,7 @@ final_value_replacement_loop (class loop *loop)

       /* Propagate constants immediately, but leave an unused initialization
         around to avoid invalidating the SCEV cache.  */
-      if (CONSTANT_CLASS_P (def) && !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rslt))
+      if (0 && CONSTANT_CLASS_P (def) && !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (rslt))
        replace_uses_by (rslt, def);

       /* Create the replacement statements.  */
(the addition of the above made the ICE latent), because profile_count
addition doesn't check for overflows and if unlucky, we can even overflow
into the uninitialized value.
Getting really huge profile counts is very easy even when not using
recursive inlining in loops, e.g.
__attribute__((noipa)) void
bar (void)
{
  __builtin_exit (0);
}

__attribute__((noipa)) void
foo (void)
{
  for (int i = 0; i < 1000; ++i)
  for (int j = 0; j < 1000; ++j)
  for (int k = 0; k < 1000; ++k)
  for (int l = 0; l < 1000; ++l)
  for (int m = 0; m < 1000; ++m)
  for (int n = 0; n < 1000; ++n)
  for (int o = 0; o < 1000; ++o)
  for (int p = 0; p < 1000; ++p)
  for (int q = 0; q < 1000; ++q)
  for (int r = 0; r < 1000; ++r)
  for (int s = 0; s < 1000; ++s)
  for (int t = 0; t < 1000; ++t)
  for (int u = 0; u < 1000; ++u)
  for (int v = 0; v < 1000; ++v)
  for (int w = 0; w < 1000; ++w)
  for (int x = 0; x < 1000; ++x)
  for (int y = 0; y < 1000; ++y)
  for (int z = 0; z < 1000; ++z)
  for (int a = 0; a < 1000; ++a)
  for (int b = 0; b < 1000; ++b)
    bar ();
}

int
main ()
{
  foo ();
}
reaches the maximum count already on the 11th loop.

Some other methods of profile_count like apply_scale already
do use MIN (val, max_count) before assignment to m_val, this patch
just extends that to operator{+,+=} methods.
Furthermore, one overload of apply_probability wasn't using
safe_scale_64bit and so could very easily overflow as well
- prob is required to be [0, 10000] and if m_val is near the max_count,
it can overflow even with multiplications by 8.

2024-03-28  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/112303
* profile-count.h (profile_count::operator+): Perform
addition in uint64_t variable and set m_val to MIN of that
val and max_count.
(profile_count::operator+=): Likewise.
(profile_count::operator-=): Formatting fix.
(profile_count::apply_probability): Use safe_scale_64bit
even in the int overload.

* gcc.c-torture/compile/pr112303.c: New test.

5 months ago[testsuite] Fixup dg-options in {gcc,g++,gfortran}.dg/vect.exp tests
Maxim Kuvyrkov [Wed, 13 Mar 2024 06:48:47 +0000 (06:48 +0000)] 
[testsuite] Fixup dg-options in {gcc,g++,gfortran}.dg/vect.exp tests

Testsuites driven by vect.exp rely on check_vect_support_and_set_flags
to set appropriate DEFAULT_VECTFLAGS for a given target (e.g., add
-mfpu=neon for arm-linux-gnueabi).  Unfortunately, these flags are
overwritten by dg-options directive, which can cause tests to fail.

Behavior of dg-options is documented in vect.exp files, but not
all developers look at the .exp file when adding a new testcase.
This caused a few dg-options directives to be used instead of
the more appropriate dg-additional-options.

This patch changes target-independent dg-options into
dg-additional-options.  This patch does not touch target-specific
dg-options and target-specific tests to avoid disturbing the gentle
balance of target-specific vectorization.

This patch also removes a couple of unneeded "dg-do run" directives
to avoid failures on compile-only targets.  Default action is, again,
set by check_vect_support_and_set_flags.

Lastly, I avoided renaming tests that use -O<n> options to O<n>-*
filename format because this support is not consistent between
gcc.dg/vect/, g++.dg/vect/, and gfortran.dg/vect/ testsuites.
It seems dg-additional-options is cleaner.

This patch does the following,
1. do not change target-specific tests, e.g., gcc.dg/vect/costmodel/riscv/*;
2. do not change { dg-options FOO { target { target-*-pattern } } };
3. do not remove { dg-do run { target { target-*-pattern } } };
4. change { dg-options FOO } to { dg-additional-options FOO };
5. remove { dg-do run } in several tests, where it is clearly not needed.

gcc/testsuite/ChangeLog:

PR testsuite/114307
* gcc.dg/vect/vect-cond-reduc-in-order-2-signed-zero.c: Remove dg-run.
* gcc.dg/vect/complex/complex-operations-run.c: Likewise.
* gcc.dg/vect/pr113576.c: Remove dg-run.  Use dg-additional-options for
test-specific flags.
* gcc.dg/vect/gimplefe-40.c: Use dg-additional-options for
test-specific flags.
* gcc.dg/vect/gimplefe-41.c: Likewise.
* gcc.dg/vect/pr101145inf.c: Likewise.
* gcc.dg/vect/pr101145inf_1.c: Likewise.
* gcc.dg/vect/pr108316.c: Likewise.
* gcc.dg/vect/pr109011-1.c: Likewise.
* gcc.dg/vect/pr109011-2.c: Likewise.
* gcc.dg/vect/pr109011-3.c: Likewise.
* gcc.dg/vect/pr109011-4.c: Likewise.
* gcc.dg/vect/pr109011-5.c: Likewise.
* gcc.dg/vect/pr111846.c: Likewise.
* gcc.dg/vect/pr111860-2.c: Likewise.
* gcc.dg/vect/pr111860-3.c: Likewise.
* gcc.dg/vect/pr113002.c: Likewise.
* gcc.dg/vect/pr84711.c: Likewise.
* gcc.dg/vect/pr85597.c: Likewise.
* gcc.dg/vect/pr88497-1.c: Likewise.
* gcc.dg/vect/pr88497-2.c: Likewise.
* gcc.dg/vect/pr88497-3.c: Likewise.
* gcc.dg/vect/pr88497-4.c: Likewise.
* gcc.dg/vect/pr88497-5.c: Likewise.
* gcc.dg/vect/pr88497-7.c: Likewise.
* gcc.dg/vect/pr92347.c: Likewise.
* gcc.dg/vect/pr93069.c: Likewise.
* gcc.dg/vect/pr97241.c: Likewise.
* gcc.dg/vect/pr99102.c: Likewise.
* gcc.dg/vect/vect-early-break_65.c: Likewise.
* gcc.dg/vect/vect-fold-1.c: Likewise.
* gcc.dg/vect/vect-ifcvt-19.c: Likewise.
* gcc.dg/vect/vect-ifcvt-20.c: Likewise.
* gcc.dg/vect/vect-reduc-epilogue-gaps.c: Likewise.
* gcc.dg/vect/vect-singleton_1.c: Likewise.
* g++.dg/vect/pr84556.cc: Likewise.
* gfortran.dg/vect/fast-math-mgrid-resid.f: Likewise.
* gfortran.dg/vect/pr77848.f: Likewise.
* gfortran.dg/vect/pr90913.f90: Likewise.

5 months agoHash operands of PHI in ipa-icf
Jan Hubicka [Thu, 28 Mar 2024 12:24:54 +0000 (13:24 +0100)] 
Hash operands of PHI in ipa-icf

This patch fixes cache colision on function whose body differs only by constants
at PHI operands.  As for

if (test)
  a = cst1;
else
  a = cst2;

gcc/ChangeLog:

PR middle-end/113907
* ipa-icf.cc (sem_function::init): Hash PHI operands
(sem_function::compare_phi_node): Add argument about preserving order