Commit graph

218021 commits

Author SHA1 Message Date
Jakub Jelinek
35ba44f5ec One more libgcobol/configure.tgt tweak
On Tue, Mar 11, 2025 at 10:45:09AM +0100, Andreas Schwab wrote:
> I think that makes the x32 match obsolete.

You're right.  I've already committed the patch, so here is incremental one.

2025-03-11  Jakub Jelinek  <jakub@redhat.com>

	* configure.tgt: Remove x86_64-*-linux*x32 special case.
2025-03-11 11:50:18 +01:00
Richard Biener
c20e24f8e7 Fixup gcobol driver handling of -print-* options
We are not supposed to diagnose missing input files.

gcc/cobol/
	* gcobolspec.cc (lang_specific_driver): For OPT_print_* do
	not error on no input files.
2025-03-11 11:32:00 +01:00
Iain Sandoe
6a3f9f30d9 configure, Darwin: Require explicit selection of COBOL.
By defult, Darwin does not have sufficient tools to build COBOL
so we do not want to include it in --enable-languages=all since
this will break regular testing of all supported languages.

However, we do want to be able to build it on demand (where the
build system has sufficiently new tools) and so do not want to
disable it permanently.

ChangeLog:

	* configure: Regenerate.
	* configure.ac: Do not build COBOL on Darwin by default,
	even for --enable-languages=all.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
2025-03-11 10:14:57 +00:00
Jakub Jelinek
8e8546d126 cobol: Fix --enable-link-serialization build
--enable-link-serialization relies on each FE participating properly,
setting <lang>.serial, depending on $(<lang>.prev) and printing progress.
The configure option is mainly for LTO bootstraps when we don't want to link
all the FEs at once because that can consume too much memory.

The comment changes are unrelated, just something I've spotted while
working on this.  .exe is a Windows suffix, so either we shouldn't
talk about suffixes in the comments or use there $(exeext) as well
to make it clear that it is dependent on the host/build.

2025-03-11  Jakub Jelinek  <jakub@redhat.com>

	* Make-lang.in: Remove .exe extension from comments.
	(cobol.serial): Set to cobol1$(exeext).
	(cobol1$(exeext)): Depend on $(cobol.prev).  Add
	LINK_PROGRESS calls before/after the link command.
2025-03-11 11:08:27 +01:00
Jakub Jelinek
3f717f9565 cobol: Use *.cc suffix for bison/flex generated C++ files
In GCC 12 we've switched to using *.cc suffixes for C++ sources in GCC
sources, including generated files, instead of using *.c suffixes and
compiling them as C++ anyway (that was the case since we've switched
GCC to C++ in GCC 4.8).
I've noticed gcc/cobol has 3 generated files still with c extension
despite clearly having C++ code in it and being compiled as C++.

2025-03-11  Jakub Jelinek  <jakub@redhat.com>

	* Make-lang.in (cobol/parse.c, cobol/cdf.c, cobol/scan.c): Remove.
	(cobol/parse.cc, cobol/cdf.cc, cobol/scan.cc): New goals.
	(cobol/cdf.o): Depend on cobol/cdf.cc rather than cobol/cdf.c.
	(cobol/parse.o): Depend on cobol/parse.cc rather than cobol/parse.c.
	(cobol/scan.o): Depend on cobol/scan.cc rather than cobol/scan.c,
	on cobol/cdf.cc rather than cobol/cdf.c and on cobol/parse.cc rather
	than cobol/parse.c.
	(cobol.srcextra): Depend on cobol/parse.cc cobol/cdf.cc cobol/scan.cc
	rather than cobol/parse.c cobol/cdf.c cobol/scan.c.
2025-03-11 11:07:15 +01:00
Jakub Jelinek
8e1efc3c86 Make libgcobol/configure.tgt more similar to other libraries
When we know libgcobol is unsupported on 32-bit arches, we should just say
so in configure.tgt, the same way as on other targets.

2025-03-11  Jakub Jelinek  <jakub@redhat.com>

	* configure.tgt: Only set LIBGCOBOL_SUPPORTED for lp64
	multilibs of powerpc64le-*-linux* and x86_64-*-linux*.  Handle
	i?86-*-linux* the same as x86_64-*-linux*.
2025-03-11 11:05:13 +01:00
Jakub Jelinek
20e5aa9cc1 tree: Improve skip_simple_arithmetic [PR119183]
The following testcase takes very long time to compile, because
skip_simple_arithmetic decides to first call tree_invariant_p on
the second argument (and indirectly recurse there).  I think before
canonicalization of operands for commutative binary expressions
(and for non-commutative ones always) it is pretty common that the
first operand is a constant, something which tree_invariant_p handles
immediately, so the following patch special cases that; I've added
there a tree_invariant_p call too after the checks, while it is not
really needed currently, tree_invariant_p has the same checks, I wanted
to be prepared in case tree_invariant_p changes.  But if you think
I should avoid it, I can drop it too.

This is just a partial fix, I think one can certainly construct a testcase
which will still have horrible compile time complexity (but I've tried and
haven't managed to do so), so perhaps we should just limit the recursion
depth through skip_simple_arithmetic/tree_invariant_p with some defaulted
argument.

2025-03-11  Jakub Jelinek  <jakub@redhat.com>

	PR c/119183
	* tree.cc (skip_simple_arithmetic): If first operand of binary
	expr is TREE_CONSTANT or TREE_READONLY with no side-effects, call
	tree_invariant_p on that operand first instead of on the second.

	* gcc.dg/pr119183.c: New test.
2025-03-11 11:01:55 +01:00
Jakub Jelinek
e1da6283a1 complex: Don't DCE unused COMPLEX_EXPRs for -O0 [PR119190]
The PR116463 r15-3128 change regressed the following testcase at -O0.
While for -O1+ we can do -fvar-tracking-assignments, for -O0 we don't
(partly because it is compile time expensive and partly because at -O0
most of the vars live most of their lifetime in memory slots), so if we
DCE some statements, it can mean that DW_AT_location for some vars won't
be available or even it won't be possible to put a breakpoint at some
particular line in the source.
We normally perform dce just in the subpasses of
pass_local_optimization_passes or pass_all_optimizations or
pass_all_optimizations_g, so don't do that at all for -O0.  So the complex
change is an exception.  And it was described as a way to help forwprop and
reassoc, neither applies to -O0.

This regresses PR119120 again though, I'll post a patch for that momentarily.

2025-03-11  Jakub Jelinek  <jakub@redhat.com>

	PR debug/119190
	* tree-complex.cc (update_complex_assignment, tree_lower_complex):
	Perform simple dce on dce_worklist only if optimize.

	* gfortran.dg/guality/pr119190.f90: New test.
2025-03-11 10:57:30 +01:00
Stefan Schulze Frielinghaus
3b1bd1fdcd s390: Deprecate ESA/390 support
Deprecate support for the ESA/390 architecture which will be eventually
removed, and encourage the usage of the z/Architecture instead.

Furthermore, default for -m31 to -mzarch whereas previously we defaulted
to -mesa.

gcc/ChangeLog:

	* config.gcc: Fail in case of option --with-mode=esa.
	* config/s390/s390.cc (s390_option_override_internal): Default
	to z/Architecture mode.
	* config/s390/s390.h (DRIVER_SELF_SPECS): Ditto.
	* config/s390/s390.opt: Emit a warning for option -mesa.
	* doc/invoke.texi: Document the change.

gcc/testsuite/ChangeLog:

	* gcc.target/s390/20020926-1.c: Deal with deprecation warning.
	* gcc.target/s390/dwarfregtable-1.c: Ditto.
	* gcc.target/s390/fp2int1.c: Ditto.
	* gcc.target/s390/pr102222.c: Ditto.
	* gcc.target/s390/pr106355-3.c: Ditto.
	* gcc.target/s390/pr61078.c: Ditto.
	* gcc.target/s390/target-attribute/tattr-m31-10.c: Ditto.
	* gcc.target/s390/target-attribute/tattr-m31-12.c: Ditto.
	* gcc.target/s390/target-attribute/tattr-m31-14.c: Ditto.
	* gcc.target/s390/target-attribute/tattr-m31-18.c: Ditto.
	* gcc.target/s390/target-attribute/tattr-m31-2.c: Ditto.
	* gcc.target/s390/target-attribute/tattr-m31-20.c: Ditto.
	* gcc.target/s390/target-attribute/tattr-m31-22.c: Ditto.
	* gcc.target/s390/target-attribute/tattr-m31-24.c: Ditto.
	* gcc.target/s390/target-attribute/tattr-m31-26.c: Ditto.
	* gcc.target/s390/target-attribute/tattr-m31-28.c: Ditto.
	* gcc.target/s390/target-attribute/tattr-m31-30.c: Ditto.
	* gcc.target/s390/target-attribute/tattr-m31-32.c: Ditto.
	* gcc.target/s390/target-attribute/tattr-m31-4.c: Ditto.
	* gcc.target/s390/target-attribute/tattr-m31-6.c: Ditto.
	* gcc.target/s390/target-attribute/tattr-m31-8.c: Ditto.
2025-03-11 09:28:06 +01:00
Stefan Schulze Frielinghaus
229f4f0404 s390: Implement TARGET_INSN_COST [PR115835]
Currently insn_cost() only considers the source part of a SET.
Implement TARGET_INSN_COST in order to also take the destination into
account.  This may make a difference in case of a MEM where the address
is a SYMBOL_REF.

Fixes testsuite/gcc.target/s390/section-anchors.c.

gcc/ChangeLog:

	PR target/115835
	* config/s390/s390.cc (s390_insn_cost): Implement.
	(TARGET_INSN_COST): Define.
2025-03-11 08:59:15 +01:00
Richard Biener
c39b0d4fae tree-optimization/119166 - ICE with --param vect-force-slp=0
The following fixes a missing guard on slp_node in get_load_store_type.

	PR tree-optimization/119166
	* tree-vect-stmts.cc (get_load_store_type): Guard SLP tree
	access.
2025-03-11 08:30:38 +01:00
James K. Lowden
86c692c51c Update update_web_docs_git for cobol
maintainer-scripts/
	* update_web_docs_git: Add libgcobol module and cobol language.
2025-03-11 07:48:27 +01:00
James K. Lowden
45c281deb7 COBOL: config and build machinery
* Makefile.def: Add libgcobol module and cobol language.
	* Makefile.in: Regenerate.
	* configure.ac: Add libgcobol module and cobol language.
	* configure: Regenerate.
2025-03-11 07:48:27 +01:00
James K. Lowden
ab79cd87c8 COBOL: documentation updates for gcobol
gcc/
	* doc/contrib.texi: Update for gcobol.
	* doc/frontends.texi: Likewise.
	* doc/install.texi: Likewise.
	* doc/invoke.texi: Likewise.
	* doc/sourcebuild.texi: Likewise.
	* doc/standards.texi: Likewise.
2025-03-11 07:48:27 +01:00
James K. Lowden
86ff23c9cb COBOL: misc
gcc/
	* Makefile.in (installdirs): Create man3 directory.
	* common.opt (static-libgcobol): New driver option.
	* dwarf2out.cc (gen_compile_unit_die): Support Cobol as
	source language.
2025-03-11 07:48:27 +01:00
James K. Lowden
3c5ed996ac COBOL: Frontend
gcc/cobol/
	* LICENSE: New file.
	* Make-lang.in: New file.
	* config-lang.in: New file.
	* lang.opt: New file.
	* lang.opt.urls: New file.
	* cbldiag.h: New file.
	* cdfval.h: New file.
	* cobol-system.h: New file.
	* copybook.h: New file.
	* dts.h: New file.
	* exceptg.h: New file.
	* gengen.h: New file.
	* genmath.h: New file.
	* genutil.h: New file.
	* inspect.h: New file.
	* lang-specs.h: New file.
	* lexio.h: New file.
	* parse_ante.h: New file.
	* parse_util.h: New file.
	* scan_ante.h: New file.
	* scan_post.h: New file.
	* show_parse.h: New file.
	* structs.h: New file.
	* symbols.h: New file.
	* token_names.h: New file.
	* util.h: New file.
	* cdf-copy.cc: New file.
	* lexio.cc: New file.
	* scan.l: New file.
	* parse.y: New file.
	* genapi.cc: New file.
	* genapi.h: New file.
	* gengen.cc: New file.
	* genmath.cc: New file.
	* genutil.cc: New file.
	* cdf.y: New file.
	* cobol1.cc: New file.
	* convert.cc: New file.
	* except.cc: New file.
	* gcobolspec.cc: New file.
	* structs.cc: New file.
	* symbols.cc: New file.
	* symfind.cc: New file.
	* util.cc: New file.
	* gcobc: New file.
	* gcobol.1: New file.
	* gcobol.3: New file.
	* help.gen: New file.
	* udf/stored-char-length.cbl: New file.
2025-03-11 07:48:21 +01:00
James K. Lowden
a075418727 COBOL: libgcobol
libgcobol/
	* Makefile.am: New file.
	* Makefile.in: Autogenerate.
	* acinclude.m4: Likewise.
	* aclocal.m4: Likewise.
	* configure.ac: New file.
	* configure: Autogenerate.
	* configure.tgt: New file.
	* README: New file.
	* charmaps.cc: New file.
	* config.h.in: New file.
	* constants.cc: New file.
	* gfileio.cc: New file.
	* gmath.cc: New file.
	* io.cc: New file.
	* valconv.cc: New file.
	* charmaps.h: New file.
	* common-defs.h: New file.
	* ec.h: New file.
	* exceptl.h: New file.
	* gcobolio.h: New file.
	* gfileio.h: New file.
	* gmath.h: New file.
	* io.h: New file.
	* libgcobol.h: New file.
	* valconv.h: New file.
	* libgcobol.cc: New file.
	* intrinsic.cc: New file.
2025-03-11 07:48:15 +01:00
GCC Administrator
c6b277f1dc Daily bump. 2025-03-11 00:17:58 +00:00
Joseph Myers
ace0f23b53 Update cpplib de.po
* de.po: Update.
2025-03-10 23:31:38 +00:00
Joseph Myers
9c6f773442 Update gcc fr.po, sv.po
* fr.po, sv.po: Update.
2025-03-10 23:24:27 +00:00
Richard Sandiford
31dcf941ac aarch64: Avoid unnecessary use of 2-input TBLs [PR115258]
When using TBL for (say) a V4SI permutation, the aarch64 port first
asks target-independent code to lower to a V16QI permutation.
Then, during code generation, an input like:

  (reg:V4SI R)

gets converted to:

  (subreg:V16QI (reg:V4SI R) 0)

aarch64_vectorize_vec_perm_const had:

  d.op0 = op0 ? force_reg (op_mode, op0) : NULL_RTX;
  if (op0 == op1)
    d.op1 = d.op0;
  else
    d.op1 = op1 ? force_reg (op_mode, op1) : NULL_RTX;

But subregs (unlike regs) are not shared, so the op0 == op1 check
always failed for this case.  We'd then force each subreg into a
fresh register, meaning that during the later:

  aarch64_expand_vec_perm_1 (d->target, d->op0, d->op1, sel);

there is no way for aarch64_expand_vec_perm_1 to realise that
d->op0 and d->op1 are the same value.  It would therefore generate
a two-input TBL in the testcase, even though a single-input TBL
is enough.

I'm not sure forcing subregs to a fresh regiter is a good idea --
it caused problems for copysign & co. -- but that's not something
to fiddle with during stage 4.  Using op0 == op1 for rtx equality
is independently wrong, so we might as well just fix that for now.

The patch gets rid of extra MOVs that are a regression from GCC 14.

The testcase is based on one from Kugan, itself based on TSVC.

gcc/
	PR target/115258
	* config/aarch64/aarch64.cc (aarch64_vectorize_vec_perm_const): Use
	d.one_vector_p to decide whether op1 should be a copy of op0.

gcc/testsuite/
	PR target/115258
	* gcc.target/aarch64/pr115258_2.c: New test.

Co-authored-by: Kugan Vivekanandarajah <kvivekananda@nvidia.com>
2025-03-10 20:29:52 +00:00
Vladimir N. Makarov
e355fe414a [PR114991][IRA]: Improve reg equiv invariant calculation
In PR test case IRA preferred to allocate hard reg to a pseudo instead
of its equivalence.  This resulted in allocating caller-saved hard reg
and generating save/restore insns in the function prologue/epilogue.
The equivalence is an invariant (stack pointer plus offset) and the
pseudo is used mostly as memory address.  This happened as there was
no simplification of insn after the invariant substitution.  The patch
adds the necessary code.

gcc/ChangeLog:

	PR target/114991
	* ira-costs.cc (equiv_can_be_consumed_p): Add new argument invariant_p.
	Add code for dealing with the invariant.
	(calculate_equiv_gains): Don't consider init insns.  Pass the new
	argument to equiv_can_be_consumed_p.  Don't treat invariant as
	memory.

gcc/testsuite/ChangeLog:

	PR target/114991
	* gcc.target/aarch64/pr114991.c: New test.
2025-03-10 16:27:51 -04:00
Gaius Mulley
40a4f3dead PR modula2/119192 ICE if TBITSIZE is used in an expression
This patch fixes an ICE which will occur is TBITSIZE is used
within an expression.

gcc/m2/ChangeLog:

	PR modula2/119192
	* gm2-compiler/M2GCCDeclare.def (TryDeclareType): New procedure.
	* gm2-compiler/M2GCCDeclare.mod (IsAnyType): New procedure.
	(TryDeclareType): Ditto.
	* gm2-compiler/M2GenGCC.mod (FoldTBitsize): New procedure.
	(FoldStandardFunction): Call FoldTBitsize.
	* gm2-gcc/m2expr.cc (BuildTBitSize): Improve comment.
	(m2expr_BuildSystemTBitSize): New function.
	* gm2-gcc/m2expr.def (BuildSystemTBitSize): New procedure
	function.
	* gm2-gcc/m2expr.h (m2expr_BuildSystemTBitSize): New function
	prototype.

gcc/testsuite/ChangeLog:

	PR modula2/119192
	* gm2/sets/run/pass/simplepacked.mod: Uncomment asserts.

Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
2025-03-10 17:37:41 +00:00
Sandra Loosemore
85b46d0795 Sanitizer: Fix typo in previous documentation patch.
gcc/ChangeLog
	* doc/invoke.texi (Instrumentation Options): Fix typo introduced
	in commit 313edeeeb6.
2025-03-10 17:04:45 +00:00
Jakub Jelinek
7d2bf92c44 Add ChangeLog locations for gcc/cobol and libgcobol
* gcc-changelog/git_commit.py (default_changelog_locations):
	Add gcc/cobol and libgcobol entries.
2025-03-10 15:45:52 +01:00
Jakub Jelinek
c664055622 Add empty ChangeLog files for GCC COBOL. 2025-03-10 15:38:54 +01:00
Nathaniel Shead
65febfb255 c++/modules: Handle exposures of TU-local types in uninstantiated member templates
Previously, 'is_tu_local_entity' wouldn't detect the exposure of the (in
practice) TU-local lambda in the following example, unless instantiated:

  struct S {
    template <typename>
    static inline decltype([]{}) x = {};
  };

This is for two reasons.  Firstly, when traversing the TYPE_FIELDS of S
we only see the TEMPLATE_DECL, and never end up building a dependency on
its DECL_TEMPLATE_RESULT (due to not being instantiated).  This patch
fixes this by stripping any templates before checking for unnamed types.

The second reason is that we currently assume all class-scope entities
are not TU-local.  Despite this being unambiguous in the standard, this
is not actually true in our implementation just yet, due to issues with
mangling lambdas in some circumstances.  Allowing these lambdas to be
exported can cause issues in importers with apparently conflicting
declarations, so this patch treats them as TU-local as well.

After these changes, we now get double diagnostics from the two ways
that we can see the above lambda being exposed, via 'S' (through
TYPE_FIELDS) or via 'S::x'.  To workaround this we hide diagnostics from
the first case, so we only get errors from 'S::x' which will be closer
to the point the offending lambda is declared.

gcc/cp/ChangeLog:

	* module.cc (trees_out::has_tu_local_dep): Also look at the
	TI_TEMPLATE if we don't find a dep for a decl.
	(depset:#️⃣:is_tu_local_entity): Handle unnamed template
	types, treat lambdas specially.
	(is_exposure_of_member_type): New function.
	(depset:#️⃣:add_dependency): Use it.
	(depset:#️⃣:finalize_dependencies): Likewise.

gcc/testsuite/ChangeLog:

	* g++.dg/modules/internal-10.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Reviewed-by: Jason Merrill <jason@redhat.com>
2025-03-11 01:23:47 +11:00
Christophe Lyon
e187ed927a arm: [MVE] Fix predicates for vec_cmp, vec_vcmpu and vcond_mask (PR 115439)
When compiling c-c++-common/vector-compare-3.c with
-march=armv8.1-m.main+mve+fp.dp -mfloat-abi=hard -mfpu=auto
(which enables MVE), we fail to match vcond_mask because operand 3 has
s_register_operand as predicate for a MVE_VPRED mode, but we try to
match:
(insn 26 25 27 2 (set (reg:V4SI 137)
         (unspec:V4SI [
                 (reg:V4SI 144)
                 (reg:V4SI 145)
                 (subreg:V4BI (reg:HI 143) 0)
             ] VPSELQ_S)) "/src/gcc/testsuite/c-c++-common/vector-compare-3.c":23:6 -1
      (nil))

The fix is to use the right predicate: vpr_register_operand.

The patch also fixes vec_cmp and vec_cmpu in the same way.

When testing with
-mthumb/-march=armv8.1-m.main+mve.fp+fp.dp/-mtune=cortex-m55/-mfloat-abi=hard/-mfpu=auto
it fixes the ICES in c-c++-common/vector-compare-3.c,
g++.dg/opt/pr79734.C, g++.dg/tree-ssa/pr111150.C and
gcc.dg/tree-ssa/pr111150.c

	gcc/ChangeLog

	PR target/115439
	* config/arm/mve.md (vec_vcmp, vec_vcmpu, vcond_mask): Use
	vpr_register_operand predicate for MVE_VPRED operands.
2025-03-10 14:14:04 +00:00
Andre Vehreschild
f2339cefd6 Fortran: Fix gimplification error for pointer remapping in forall [PR107143]
Enhance dependency checking for data pointers to check for same derived
type and not only for a type being a derived type.  This prevent
generation of a descriptor for a function call, that is unsuitable in
forall's pointer assignment.

	PR fortran/107143

gcc/fortran/ChangeLog:

	* dependency.cc (check_data_pointer_types): Do not just compare
	for derived type, but for same derived type.

gcc/testsuite/ChangeLog:

	* gfortran.dg/forall_20.f90: New test.
2025-03-10 13:21:10 +01:00
Jakub Jelinek
21109b37e8 libgcc: Fix up unwind-dw2-btree.h [PR119151]
The following testcase shows a bug in unwind-dw2-btree.h.
In short, the header provides lock-free btree data structure (so no parent
link on nodes, both insertion and deletion are done in top-down walks
with some locking of just a few nodes at a time so that lookups can notice
concurrent modifications and retry, non-leaf (inner) nodes contain keys
which are initially the base address of the left-most leaf entry of the
following child (or all ones if there is none) minus one, insertion ensures
balancing of the tree to ensure [d/2, d] entries filled through aggressive
splitting if it sees a full tree while walking, deletion performs various
operations like merging neighbour trees, merging into parent or moving some
nodes from neighbour to the current one).
What differs from the textbook implementations is mostly that the leaf nodes
don't include just address as a key, but address range, address + size
(where we don't insert any ranges with zero size) and the lookups can be
performed for any address in the [address, address + size) range.  The keys
on inner nodes are still just address-1, so the child covers all nodes
where addr <= key unless it is covered already in children to the left.
The user (static executables or JIT) should always ensure there is no
overlap in between any of the ranges.

In the testcase a bunch of insertions are done, always followed by one
removal, followed by one insertion of a range slightly different from the
removed one.  E.g. in the first case [&code[0x50], &code[0x59]] range
is removed and then we insert [&code[0x4c], &code[0x53]] range instead.
This is valid, it doesn't overlap anything.  But the problem is that some
non-leaf (inner) one used the &code[0x4f] key (after the 11 insertions
completely correctly).  On removal, nothing adjusts the keys on the parent
nodes (it really can't in the top-down only walk, the keys could be many nodes
above it and unlike insertion, removal only knows the start address, doesn't
know the removed size and so will discover it only when reaching the leaf
node which contains it; plus even if it knew the address and size, it still
doesn't know what the second left-most leaf node will be (i.e. the one after
removal)).  And on insertion, if nodes aren't split at a level, nothing
adjusts the inner keys either.  If a range is inserted and is either fully
bellow key (keys are - 1, so having address + size - 1 being equal to key is
fine) or fully after key (i.e. address > key), it works just fine, but if
the key is in a middle of the range like in this case, &code[0x4f] is in the
middle of the [&code[0x4c], &code[0x53]] range, then insertion works fine
(we only use size on the leaf nodes), and lookup of the addresses below
the key work fine too (i.e. [&code[0x4c], &code[0x4f]] will succeed).
The problem is with lookups after the key (i.e. [&code[0x50, &code[0x53]]),
the lookup looks for them in different children of the btree and doesn't
find an entry and returns NULL.

As users need to ensure non-overlapping entries at any time, the following
patch fixes it by adjusting keys during insertion where we know not just
the address but also size; if we find during the top-down walk a key
which is in the middle of the range being inserted, we simply increase the
key to be equal to address + size - 1 of the range being inserted.
There can't be any existing leaf nodes overlapping the range in correct
programs and the btree rebalancing done on deletion ensures we don't have
any empty nodes which would also cause problems.

The patch adjusts the keys in two spots, once for the current node being
walked (the last hunk in the header, with large comment trying to explain
it) and once during inner node splitting in a parent node if we'd otherwise
try to add that key in the middle of the range being inserted into the
parent node (in that case it would be missed in the last hunk).
The testcase covers both of those spots, so succeeds with GCC 12 (which
didn't have btrees) and fails with vanilla GCC trunk and also fails if
either the
  if (fence < base + size - 1)
    fence = iter->content.children[slot].separator = base + size - 1;
or
  if (left_fence >= target && left_fence < target + size - 1)
    left_fence = target + size - 1;
hunk is removed (of course, only with the current node sizes, i.e. up to
15 children of inner nodes and up to 10 entries in leaf nodes).

2025-03-10  Jakub Jelinek  <jakub@redhat.com>
	    Michael Leuchtenburg  <michael@slashhome.org>

	PR libgcc/119151
	* unwind-dw2-btree.h (btree_split_inner): Add size argument.  If
	left_fence is in the middle of [target,target + size - 1] range,
	increase it to target + size - 1.
	(btree_insert): Adjust btree_split_inner caller.  If fence is smaller
	than base + size - 1, increase it and separator of the slot to
	base + size - 1.

	* gcc.dg/pr119151.c: New test.
2025-03-10 10:35:29 +01:00
Xi Ruoyao
c7d493baf1
LoongArch: Fix ICE when trying to recognize bitwise + alsl.w pair [PR119127]
When we call loongarch_reassoc_shift_bitwise for
<optab>_alsl_reversesi_extend, the mask is in DImode but we are trying
to operate it in SImode, causing an ICE.

To fix the issue sign-extend the mask into the mode we want.  And also
specially handle the case the mask is extended into -1 to avoid a
miss-optimization.

gcc/ChangeLog:

	PR target/119127
	* config/loongarch/loongarch.cc
	(loongarch_reassoc_shift_bitwise): Sign extend mask to mode,
	specially handle the case it's extended to -1.
	* config/loongarch/loongarch.md
	(loongarch_reassoc_shift_bitwise): Update the comment for the
	special case.
2025-03-10 17:12:05 +08:00
Jakub Jelinek
9fe5106ea9 libgcc: Formatting fixes for unwind-dw2-btree.h
Studying unwind-dw2-btree.h was really hard for me because
the formatting is wrong or weird in many ways all around the code
and that kept distracting my attention.
That includes all kinds of things, including wrong indentation, using
{} around single statement substatements, excessive use of ()s around
some parts of expressions which don't increase code clarity, no space
after dot in comments, some comments not starting with capital letters,
some not ending with dot, adding {} around some parts of code without
any obvious reason (and when it isn't done in a similar neighboring
function) or ( at the end of line without any reason.

The following patch fixes the formatting issues I found, no functional
changes.

2025-03-10  Jakub Jelinek  <jakub@redhat.com>

	* unwind-dw2-btree.h: Formatting fixes.
2025-03-10 09:33:55 +01:00
Jakub Jelinek
1301e18f69 gimple-ssa-warn-access: Adjust maybe_warn_nonstring_arg for nonstring multidimensional arrays [PR117178]
The following patch fixes 4 xfails in attr-nonstring-11.c (and results in 2
false positive warnings in attr-nonstring-12.c not being produced either).
The thing is that maybe_warn_nonstring_arg simply assumed that nonstring
arrays must be single-dimensional, so when it sees a nonstring decl with
ARRAY_TYPE, it just used its dimension.  With multi-dimensional arrays
that is not the right dimension to use though, it can be dimension of
some outer dimension, e.g. if we have
char a[5][6][7] __attribute__((nonstring)) if decl is
a[5] it would assume maximum non-NUL terminated string length of 5 rather than
7, if a[5][6] it would assume 6 and only for a[5][6][0] it would assume the
correct 7.  So, the following patch looks through all the outer dimensions
to reach the innermost one (which for attribute nonstring is guaranteed to
have char/unsigned char/signed char element type).

2025-03-10  Jakub Jelinek  <jakub@redhat.com>

	PR c/117178
	* gimple-ssa-warn-access.cc (maybe_warn_nonstring_arg): Look through
	multi-dimensional array types, stop at the innermost ARRAY_TYPE.

	* c-c++-common/attr-nonstring-11.c: Remove xfails.
	* c-c++-common/attr-nonstring-12.c (warn_strcmp_cst_1,
	warn_strcmp_cst_2): Don't expect any warnings here.
	(warn_strcmp_cst_3, warn_strcmp_cst_4): New functions with expected
	warnings.
2025-03-10 09:31:41 +01:00
Lulu Cheng
62a6a53766 LoongArch: testsuite: Fix gcc.dg/vect/slp-26.c.
After d34cda7209, what was originally
not vectorizable can now be vectorized.  So adjust
gcc.dg/vect/slp-26.c.

gcc/testsuite/ChangeLog:

	* gcc.dg/vect/slp-26.c: Adjust.
2025-03-10 12:00:08 +08:00
Lulu Cheng
546567367a LoongArch: testsuite: Fix gcc.dg/vect/bb-slp-77.c.
The issue is the same as 12383255fe.
Neither is .REDUC_PLUS set for V2SImode on LoongArch, so add it
to the list of targets not expecting BB vectorization.

gcc/testsuite/ChangeLog:

	* gcc.dg/vect/bb-slp-77.c: Add loongarch*-*-* to the list
	of expected failing targets.
2025-03-10 12:00:04 +08:00
Lulu Cheng
671702b29f LoongArch: testsuite: Fix pr112325.c and pr117888-1.c.
By default, vectorization is not enabled on LoongArch,
resulting in the failure of these two test cases.

gcc/testsuite/ChangeLog:

	* gcc.dg/vect/pr112325.c: Add the vector compilation
	option '-mlsx' for LoongArch.
	* gcc.dg/vect/pr117888-1.c: Likewise.
2025-03-10 11:59:58 +08:00
GCC Administrator
3ee18840ec Daily bump. 2025-03-10 00:17:22 +00:00
Jeff Law
7d3aec2a83 [rtl-optimization/117467] Mark FP destinations as dead
The next step in improving ext-dce is to clean up a minor wart in the
set/clobber handling code.

In that code the safe thing to do is to not process a destination at all.  That
will leave bits set in the live bitmaps for objects that may no longer be live.
Of course with extraneous bits set we use more memory and do more work managing
the bitmaps, but it's safe from a code correctness standpoint.

One case that is slipping through that we need to fix is scalar fp
destinations.  Essentially the code never tried to handle those and as a result
would leave those entities live and bubble them up through the CFG.

In the testcase at hand this takes us from ~10k live objects at entry to ~4k
live objects at entry.  Time spent in ext-dce goes from 2.14s to .64s.

Bootstrapped and regression tested on x86_64.

	PR rtl-optimization/117467
gcc/
	* ext-dce.cc (ext_dce_process_sets): Handle FP destinations better.
2025-03-09 14:25:37 -06:00
Jeff Law
4ed07a11ee [rtl-optimization/117467] Avoid unnecessarily marking things live in ext-dce
This is the first of what I expect to be a few patches to improve memory
consumption and performance of ext-dce.

While I haven't been able to reproduce the insane memory usage that Richi saw,
I can certainly see how we might get there.  I instrumented ext-dce to dump the
size of liveness sets, removed the memory allocation limiter, then compiled the
appropriate file from specfp on rv64.

In my test I saw the liveness sets growing to absurd sizes as we worked from
the last block back to the first.  Think 125k entries by the time we got back
to the entry block which would mean ~30k live registers.  Simply no way that's
correct.

The use handling is the primary source of problems and the code that I most
want to rewrite for gcc-16.  It's just a fugly mess.  I'm not terribly inclined
to do that rewrite for gcc-15 though.  So these will be spot adjustments.

The most important thing to know about use processing is it sets up an iterator
and walks that.  When a SET is encountered we actually manually
dive into the SRC/DEST and ideally terminate the iterator.

If during that SET processing we encounter something unexpected we let the
iterator continue normally, which causes iteration down into the SET_DEST
object.  That's safe behavior, though it can lead to too many objects as being
marked live.

We can refine that behavior by trivially realizing that we need not process the
SET_DEST if it is a naked REG (and probably for other cases too, but they're
not expected to be terribly important).  So once we see the SET with a simple
REG destination, we can bump the iterator to avoid having it dive into the
SET_DEST if something unexpected is seen on the SET_SRC side.

Fixing this alone takes us from 125k live objects to 10k live objects at the
entry block.  Time in ext-dce for rv64 on the testcase goes from 10.81s to
2.14s.

Given this reduces the things considered live, this could easily result in
finding more cases for ext-dce to improve.  In fact a missed optimization issue
for rv64 I've been poking at needs this patch as a prerequisite.

Bootstrapped and regression tested on x86_64.

Pushing to the trunk.

	PR rtl-optimization/117467
gcc
	* ext-dce.cc (ext_dce_process_uses): When trivially possible advance
	the iterator over the destination of a SET.
2025-03-09 13:31:09 -06:00
Thomas Koenig
9f5b508bc5 Use gfc_commit_symbol() to remove UNDO status instead of new function.
This is a cleaner version, removing an unneeded function and
making sure that no memory leaks can occur if callers change.

gcc/fortran/ChangeLog:

	PR fortran/119157
	* gfortran.h (gfc_pop_undo_symbol): Remove prototype.
	* interface.cc (gfc_get_formal_from_actual_arglist): Use
	gfc_commit_symbol() instead of gfc_pop_undo_symbol().
	* symbol.cc (gfc_pop_undo_symbol): Remove.
2025-03-09 19:47:42 +01:00
Andrew Pinski
7232c005af phiopt: Fix value_replacement for middle bb having phi nodes [PR118922]
After r12-5300-gf98f373dd822b3, value_replacement would be able to look at the
following cfg structure:
```
  <bb 5> [local count: 1014686024]:
  if (h_6 != 0)
    goto <bb 7>; [94.50%]
  else
    goto <bb 6>; [5.50%]

  <bb 6> [local count: 114863530]:
  # h_6 = PHI <0(4), 1(5)>

  <bb 7> [local count: 1073741824]:
  # f_8 = PHI <0(5), h_6(6)>
  _9 = f_8 ^ 1;
  a.0_10 = a;
  _11 = _9 + a.0_10;
  if (_11 != -117)
    goto <bb 5>; [94.50%]
  else
    goto <bb 8>; [5.50%]
```

value_replacement would incorrectly think the middle bb (6) was empty and so it decides
to remove condition in bb5 and replacing it with 0 as the function thought it was `h_6 ? 0 : h_6`.
But since the there is an incoming phi node to bb6 defining h_6 that is incorrect.

The fix is to check if there is phi nodes in the middle bb and set empty_or_with_defined_p to false.
This was not needed before r12-5300-gf98f373dd822b3 because the phi would have been dead otherwise due to
other checks.

Bootstrapped and tested on x86_64-linux-gnu.

	PR tree-optimization/118922

gcc/ChangeLog:

	* tree-ssa-phiopt.cc (value_replacement): Set empty_or_with_defined_p
	to false when there is phi nodes for the middle bb.

gcc/testsuite/ChangeLog:

	* gcc.dg/torture/pr118922-1.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2025-03-09 11:28:32 -07:00
Dimitar Dimitrov
1b21da6abf
testsuite: Require effective target float16 for test [PR119133]
The test spuriously failed on pru-unknown-elf due to missing support for
_Float16 type.

	PR target/119133

gcc/testsuite/ChangeLog:

	* gcc.dg/torture/pr119133.c: Require effective target float16.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
2025-03-09 16:04:31 +02:00
Sandra Loosemore
44b1d52e2f OpenMP: Integrate dynamic selectors with dispatch argument handling [PR118457]
Support for dynamic selectors in "declare variant" was developed in
parallel with support for the adjust_args/append_args clauses and the
dispatch construct; they collided in a bad way.  This patch fixes the
"sorry" for calls that need both by removing the adjust_args/append_args
code from gimplify_call_expr and invoking it from the new variant
substitution code instead.  It's handled as a tree -> tree transformation
rather than tree -> gimple because eventually this code may end up being
invoked from the front ends instead of the gimplifier (see PR115076).

gcc/ChangeLog
	PR middle-end/118457
	* gimplify.cc (modify_call_for_omp_dispatch): New, containing
	code split from gimplify_call_expr and modified to emit tree
	instead of gimple.  Remove the error for falling through to a call
	to the base function.
	(expand_variant_call_expr): New, split from gimplify_variant_call_expr.
	Call modify_call_for_omp_dispatch on calls to
	variants in a dispatch construct context.
	(gimplify_variant_call_expr): Make it call expand_variant_call_expr
	to do the actual work.
	(gimplify_call_expr): Remove sorry for calls involving both
	dynamic/late selectors and adjust_args/append_args, and adjust
	for new interface.  Move adjust_args/append_args code to
	modify_call_for_omp_dispatch.
	(gimplify_omp_dispatch): Add some comments.

gcc/testsuite/ChangeLog
	PR middle-end/118457
	* c-c++-common/gomp/adjust-args-6.c: Remove xfails and adjust
	expected output.
	* c-c++-common/gomp/append-args-5.c: Adjust expected output.
	* c-c++-common/gomp/append-args-dynamic.c: New.
	* c-c++-common/gomp/dispatch-11.c: Adjust expected output.
	* gfortran.dg/gomp/dispatch-11.f90: Likewise.
2025-03-09 01:52:52 +00:00
GCC Administrator
e270b89978 Daily bump. 2025-03-09 00:17:02 +00:00
Thomas Koenig
90d9cdfa82 Fix regression with -Wexternal-argument-mismatch.
The attached patch fixes an ICE regresseion where undo state was not
handled properly when generating formal from actual arguments, which
occurred under certain conditions with the newly introduced
-Wexternal-argument-mismatch option.

The fix is simple: When we are generating these symbols, we no
longer need to undo anything, so we can just remove them.
I had considered adding an extra optional argument, but decided
against it on code clarity grounds.

While looking at the code, I also saw that a member of gfc_symbol
introduced with my patch should be a bitfield of width 1.

gcc/fortran/ChangeLog:

	PR fortran/119157
	* gfortran.h (gfc_symbol): Make ext_dummy_arglist_mismatch a
	one-bit bitfield
	(gfc_pop_undo_symbol): Declare prototype.
	* symbol.cc (gfc_pop_undo_symbol): New function.
	* interface.cc (gfc_get_formal_from_actual_arglist): Call it
	for artificially introduced formal variables.

gcc/testsuite/ChangeLog:

	PR fortran/119157
	* gfortran.dg/interface_57.f90: New test.
2025-03-08 22:47:18 +01:00
Giuseppe D'Angelo
613f8ddbe3 libstdc++: constrain std::atomic's default constructor
This commit implements the proposed resolution to LWG4169, which is
to constrain std::atomic<T>'s default constructor based on whether
T itself is default constructible.

At the moment, std::atomic<T>'s primary template in libstdc++ has a
defaulted default constructor. Value-initialization of the T member
(since C++20 / P0883R2) is done via a NSDMI (= T()).

GCC already considers the defaulted constructor constrained/deleted,
however this behavior is non-standard (see the discussion in PR116769):
the presence of a NSDMI should not make the constructor unavailable to
overload resolution/deleted ([class.default.ctor]/2.5 does not apply).
When using libstdc++ on Clang, this causes build issues as the
constructor is *not* deleted there -- the interpretation of
[class.default.ctor]/4 seems to match Clang's behavior.

Therefore, although there would be "nothing to do" with GCC+libstdc++,
this commit changes the code as to stop relying on the GCC language
extension. In C++ >= 20 modes, std::atomic's defaulted default
constructor is changed to be a non-defaulted one, with a constraint
added as per LWG4169; value-initialization of the data member is moved
from the NSDMI to the member init list. The new signature matches the
one in the Standard as per [atomics.types.operations]/1.

In pre-C++20 modes, the constructor is left defaulted. This ensures
compatibility with C++11/14/17 behavior. In other words: we are not
backporting P0883R2 to earlier language modes here.

Amend an existing test to check that a std::atomic wrapping a
non-default constructible type is always non-default constructible:
from C++20, because of the constraint; before C++20, because we
are removing the NSDMI, and therefore [class.default.ctor]/2.5
applies.

Add another test that checks that std::atomic is trivially default
constructible in pre-C++20 modes, and it isn't afterwards.

libstdc++-v3/ChangeLog:

	* include/bits/version.def (atomic_value_initialization):
	Guard the FTM with the language concepts FTM.
	* include/bits/version.h: Regenerate.
	* include/std/atomic (atomic): When atomic value init is
	defined, change the defaulted default constructor to
	a non-defaulted one, constraining it as per LWG4169.
	Otherwise, keep the existing constructor.
	Remove the NSDMI for the _M_i member.
	(_GLIBCXX20_INIT): Drop the macro, as it is not needed any more.
	* testsuite/29_atomics/atomic/69301.cc: Test that
	an atomic wrapping a non-default-constructible type is
	always itself non-default-constructible (in all language
	modes).
	* testsuite/29_atomics/atomic/cons/trivial.cc: New test.
2025-03-08 19:47:15 +01:00
Sandra Loosemore
dff0592945 inline-asm: Improve documentation of "asm constexpr".
While working on an adjacent documentation fix, I noticed that the
documentation for the gnu++11 "asm constexpr" feature was very
confusing, in some cases being attached to parts of the asm syntax
that are not otherwise required to be string literals, and missing from
other parts of the syntax that are.  I've checked what the C++ parser
actually does and fixed the documentation to match, also improving it
to use correct markup and to be more explicit and less implementor-speaky.

gcc/cp/ChangeLog
	* parser.cc (cp_parser_asm_definition): Make comment more explicit.
	(cp_parser_asm_operand_list): Likewise.  Also correct the comment
	block at the top of the function to reflect reality.

gcc/ChangeLog
	* doc/extend.texi (Basic Asm): Document that AssemblerInstructions
	can be an asm constexpr.
	(Extended Asm): Move the notes about asm constexprs for
	AssemblerTemplate and Clobbers to the corresponding subsections.
	Remove the notes for OutputOperands and InputOperands and reword
	misleading descriptions of the list item syntax.  Note that
	constraint strings can be asm constexprs.
	(Asm constexprs): Use "title case" for subsection name.  Be
	explicit about what parts of the asm syntax this applies to and
	that the parentheses are required.  Correct markup and terminology.
2025-03-08 17:03:42 +00:00
Jason Merrill
b360d4aafc c++/modules: purview of explicit instantiations [PR114630]
When calling instantiate_pending_templates at end of parsing, any new
functions that are instantiated from this point have their module
purview set based on the current value of module_kind.

This is unideal, however, as the modules code will then treat these
instantiations as reachable and cause large swathes of the GMF to be
emitted into the module CMI, despite no code in the actual module
purview referencing it.

This patch fixes this by setting DECL_MODULE_PURVIEW_P as appropriate when
we see an explicit instantiation, and adjusting module_kind accordingly
during deferred instantiation, meaning that GMF entities won't be counted
as reachable unless referenced by an actually reachable entity.

Note that purviewness and attachment etc. is generally only determined
by the base template: this is purely for determining whether an
explicit instantiation is in the module purview and hence whether it
should be streamed out.  See the comment on 'set_instantiating_module'.

Incidentally, since the "xtreme" testcases are deliberately large (and this
commit adds another one), let's make sure we only run them once.

	PR c++/114630
	PR c++/114795

gcc/cp/ChangeLog:

	* pt.cc (reopen_tinst_level): Set or clear MK_PURVIEW.
	(mark_decl_instantiated): Call set_instantiating_module.
	(instantiate_pending_templates): Save and restore module_kind so
	it isn't affected by reopen_tinst_level.

gcc/testsuite/ChangeLog:

	* g++.dg/modules/modules.exp: Run xtreme tests once.
	* g++.dg/modules/gmf-3.C: New test.
	* g++.dg/modules/gmf-4.C: New test.
	* g++.dg/modules/gmf-xtreme.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
Co-authored-by: Nathaniel Shead <nathanieloshead@gmail.com>
2025-03-08 09:54:41 -05:00
Jonathan Wakely
d456728667
libstdc++: Simplify __memcpyable_iterators concept
My P3349R1 paper clarifies that we should be able to lower contiguous
iterators to pointers, without worrying about side effects of individual
increment or dereference operations.

We do need to advance the iterators, and we need to use std::to_address
on the result of advancing them. This ensures that iterators with error
detection get a chance to diagnose bugs. If we don't use std::to_address
on the advanced iterator, it would be possible for a memcpy on the
pointers to overflow a buffer. By performing the += or -= operations and
also using std::to_address, we give the iterator a chance to abort,
throw, or call a violation handler before the buffer overflow happens.

The new tests only check the std::copy* algorithms, because std::move
and std::move_backward use the same implementation details.

libstdc++-v3/ChangeLog:

	* include/bits/stl_algobase.h (__nothrow_contiguous_iterator):
	Remove.
	(__memcpyable_iterators): Simplify.
	(__copy_move_a2, __copy_n_a, __copy_move_backward_a2): Call
	std::to_address on the iterators after advancing them.
	* testsuite/25_algorithms/copy/contiguous.cc: New test.
	* testsuite/25_algorithms/copy_backward/contiguous.cc: New test.
	* testsuite/25_algorithms/copy_n/contiguous.cc: New test.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
2025-03-08 10:39:56 +00:00
Sandra Loosemore
f0ff753962 inline-asm: Clarify documentation of operand syntax [PR67301]
gcc/ChangeLog
	PR c/67301
	* doc/extend.texi (Extended Asm): Clarify that the square brackets
	around the asmSymbolicName of operands are a required part of
	the syntax.
2025-03-08 05:35:26 +00:00