Commit Graph

209882 Commits

Author SHA1 Message Date
Richard Biener
9ab8fdfeef 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.
2024-04-05 11:13:21 +02:00
Jakub Jelinek
effd947fcc 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.
2024-04-05 11:05:01 +02:00
Jakub Jelinek
592536eb3c 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.
2024-04-05 09:31:28 +02:00
Christophe Lyon
12b04452b4 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.
2024-04-05 07:04:27 +00:00
Hans-Peter Nilsson
4c8b3600c4 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.
2024-04-05 03:55:46 +02:00
Hans-Peter Nilsson
3b36e86d6a 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.
2024-04-05 03:54:58 +02:00
GCC Administrator
5192e72e7e Daily bump. 2024-04-05 00:16:44 +00:00
Wilco Dijkstra
27b6d081f6 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.
2024-04-04 22:28:58 +01:00
centurion
801e82acd6 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>
2024-04-04 17:18:56 -04:00
Martin Jambor
ca56b43105
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.
2024-04-04 22:56:48 +02:00
Vladimir N. Makarov
a24476422b [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.
2024-04-04 16:07:10 -04:00
Tobias Burnus
7520a4992c 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.
2024-04-04 21:55:29 +02:00
H.J. Lu
1df56719bd 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.
2024-04-04 11:49:23 -07:00
Jørgen Kvalsvik
dc8a25189d 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.
2024-04-04 20:29:12 +02:00
Jørgen Kvalsvik
08a5233180 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.
2024-04-04 20:28:44 +02:00
Paul-Antoine Arras
b7bd2ec73d MAINTAINERS: Update my email address
ChangeLog:

	* MAINTAINERS: Update my email address.
2024-04-04 16:39:52 +02:00
Richard Sandiford
86dce005a1 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.
2024-04-04 14:15:49 +01:00
Richard Biener
85621f98d2 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.
2024-04-04 13:09:19 +02:00
Tobias Burnus
1c89d1b9dc 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.
2024-04-04 12:20:48 +02:00
Jakub Jelinek
1baec8deb0 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.
2024-04-04 10:47:52 +02:00
Jakub Jelinek
48530efdcc 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.
2024-04-04 10:47:00 +02:00
Kyrylo Tkachov
f2ccfb2d0b [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.
2024-04-04 09:12:28 +01:00
Richard Biener
e152177b36 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.
2024-04-04 09:00:06 +02:00
Eugene Rozenfeld
fe385c2199 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
2024-04-03 17:28:30 -07:00
GCC Administrator
88ce7fbcc7 Daily bump. 2024-04-04 00:16:38 +00:00
Joseph Myers
f375550287 Update gcc sv.po
* sv.po: Update.
2024-04-03 20:47:47 +00:00
Mark Wielaard
5c749db15f Regenerate i386.opt.urls
LoongArch added an -mtls-dialect option, causing the similarly
named option for i386 get renumbered.

Fixes: b253b4695d ("LoongArch: Add support for TLS descriptors.")

gcc/ChangeLog:

	* config/i386/i386.opt.urls: Regenerate.
2024-04-03 17:39:15 +02:00
Wilco Dijkstra
8f9e92eec3 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.
2024-04-03 16:24:03 +01:00
H.J. Lu
cab32bacae 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.
2024-04-03 06:49:45 -07:00
Tobias Burnus
6f91cce9a3 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.
2024-04-03 15:47:12 +02:00
Iain Sandoe
d60968de69 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>
2024-04-03 13:18:15 +01:00
Tobias Burnus
ce7cb109ff 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.
2024-04-03 14:16:41 +02:00
Jonathan Wakely
7f65d8267f
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.
2024-04-03 11:45:35 +01:00
Tobias Burnus
b2460d621e 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.
2024-04-03 12:37:39 +02:00
Jakub Jelinek
8455d6f6cd 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>
2024-04-03 10:13:40 +02:00
Jakub Jelinek
03039744f3 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.
2024-04-03 09:59:45 +02:00
Richard Biener
e7b7188b1c 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.
2024-04-03 08:56:45 +02:00
Jiahao Xu
8677182f32 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.
2024-04-03 09:40:49 +08:00
GCC Administrator
a1e6798acf Daily bump. 2024-04-03 00:17:29 +00:00
Gaius Mulley
1bafa6a3fd 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>
2024-04-02 23:47:42 +01:00
Martin Uecker
871bb5ad2d 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.
2024-04-03 00:09:36 +02:00
David Malcolm
e945d322fc 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>
2024-04-02 17:42:16 -04:00
Jonathan Wakely
21aa57e73b 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.
2024-04-02 20:55:32 +01:00
Tom Tromey
ca2f7c8492 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.
2024-04-02 13:30:19 -06:00
Marek Polacek
2f2924078c 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.
2024-04-02 14:32:29 -04:00
Marek Polacek
daa2e7c7ff 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.
2024-04-02 14:19:16 -04:00
Jason Merrill
5d7e9a3502 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.
2024-04-02 14:11:13 -04:00
Patrick Palka
0e64bbb882 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>
2024-04-02 13:07:07 -04:00
Christophe Lyon
d5aa2ca06a 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.
2024-04-02 16:05:38 +00:00
Tom Tromey
1e459e6625 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.
2024-04-02 08:57:24 -06:00