]> gcc.gnu.org Git - gcc.git/log
gcc.git
2 months agogccrs: Make DefaultResolver visit more of the AST
Owen Avery [Wed, 28 Feb 2024 22:42:49 +0000 (17:42 -0500)]
gccrs: Make DefaultResolver visit more of the AST

gcc/rust/ChangeLog:

* resolve/rust-default-resolver.cc
(DefaultResolver::visit): Visit inner AST nodes of ClosureExprInner,
ClosureExprInnerTyped, IfExpr, IfExprConseqElse, MatchExpr,
PathInExpression, EnumItemTuple, EnumItemStruct, and
EnumItemDiscriminant.
* ast/rust-item.h
(EnumItemDiscriminant::has_expr): New function.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2 months agogccrs: extern-types: Lower to HIR::ExternalTypeItem properly
Arthur Cohen [Tue, 20 Feb 2024 15:22:20 +0000 (16:22 +0100)]
gccrs: extern-types: Lower to HIR::ExternalTypeItem properly

gcc/rust/ChangeLog:

* hir/rust-ast-lower-extern.h: Lower to HIR::ExternalTypeItem nodes.
* hir/tree/rust-hir-item.h (class ExternalTypeItem): Create private
visibility by default as extern types have no visibility - add a comment
about the correctness of this.

2 months agogccrs: hir: Add ExternalTypeItem node
Arthur Cohen [Tue, 20 Feb 2024 14:45:35 +0000 (15:45 +0100)]
gccrs: hir: Add ExternalTypeItem node

gcc/rust/ChangeLog:

* hir/tree/rust-hir-item.h (class ExternalTypeItem): New class.
* hir/tree/rust-hir.cc (ExternalTypeItem::as_string): Likewise.
* backend/rust-compile-extern.h: Add base for handling HIR::ExternalTypeItem
node.
* checks/errors/borrowck/rust-bir-builder-struct.h: Likewise.
* checks/errors/borrowck/rust-function-collector.h: Likewise.
* checks/errors/rust-const-checker.cc (ConstChecker::visit): Likewise.
* checks/errors/rust-const-checker.h: Likewise.
* checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): Likewise.
* checks/errors/rust-unsafe-checker.h: Likewise.
* hir/rust-ast-lower-extern.h: Likewise.
* hir/rust-hir-dump.cc (Dump::visit): Likewise.
* hir/rust-hir-dump.h: Likewise.
* hir/tree/rust-hir-full-decls.h (class ExternalTypeItem): Likewise.
* hir/tree/rust-hir-visitor.h: Likewise.
(ExternalTypeItem::accept_vis): Likewise.
* typecheck/rust-hir-type-check-implitem.cc (TypeCheckTopLevelExternItem::visit): Likewise.
* typecheck/rust-hir-type-check-implitem.h: Likewise.

2 months agogccrs: extern-types: Declare external types in name resolver.
Arthur Cohen [Tue, 20 Feb 2024 13:53:32 +0000 (14:53 +0100)]
gccrs: extern-types: Declare external types in name resolver.

gcc/rust/ChangeLog:

* resolve/rust-ast-resolve-implitem.h: Declare external types as new
types.

2 months agogccrs: lang-items: Make lang items enum stronger, rename class, cleanup ns.
Arthur Cohen [Tue, 27 Feb 2024 13:39:22 +0000 (14:39 +0100)]
gccrs: lang-items: Make lang items enum stronger, rename class, cleanup ns.

gcc/rust/ChangeLog:

* util/rust-lang-item.h (class RustLangItem): Renamed to...
(class LangItem): ...this. Rename ItemType enum to Kind
* util/rust-lang-item.cc: Rename methods to use new class name.
* backend/rust-compile-expr.cc (CompileExpr::visit): Use new lang-item API.
(CompileExpr::resolve_operator_overload): Likewise.
* backend/rust-compile-expr.h: Likewise.
* hir/rust-ast-lower-base.cc (ASTLoweringBase::handle_lang_item_attribute): Likewise.
* typecheck/rust-autoderef.cc (Adjuster::try_deref_type): Likewise.
(AutoderefCycle::cycle): Likewise.
* typecheck/rust-autoderef.h: Likewise.
* typecheck/rust-hir-type-bounds.h: Likewise.
* typecheck/rust-hir-type-check-base.cc (TypeCheckBase::get_marker_predicate): Likewise.
* typecheck/rust-hir-type-check-base.h: Likewise.
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Likewise.
* typecheck/rust-hir-type-check-expr.h: Likewise.
* typecheck/rust-hir-type-check-type.cc (TypeResolveGenericParam::visit): Likewise.
* typecheck/rust-tyty-bounds.cc (TypeBoundsProbe::assemble_sized_builtin): Likewise.
(TypeBoundsProbe::assemble_builtin_candidate): Likewise.
(TypeCheckBase::get_predicate_from_bound): Likewise.
* typecheck/rust-tyty.cc (ClosureType::setup_fn_once_output): Likewise.
* util/rust-hir-map.cc (Mappings::get_lang_item): Likewise.
(Mappings::lookup_trait_item_lang_item): Likewise.
* util/rust-hir-map.h: Likewise.

2 months agogccrs: lang-items: Cleanup parsing and lookups of lang items.
Arthur Cohen [Tue, 27 Feb 2024 12:35:50 +0000 (13:35 +0100)]
gccrs: lang-items: Cleanup parsing and lookups of lang items.

gcc/rust/ChangeLog:

* Make-lang.in: Compile new rust-lang-item.o.
* util/rust-lang-item.h: Split into header and source.
* util/rust-lang-item.cc: Cleanup parsing of lang items by using a hashmap
and returning optional values, cleanup handling of exhaustive lang item
lookups.
* hir/rust-ast-lower-base.cc (ASTLoweringBase::handle_lang_item_attribute): Use
new optional API.

2 months agogccrs: Fix small FixMe task in rust macro builtins
jjasmine [Fri, 23 Feb 2024 21:06:14 +0000 (13:06 -0800)]
gccrs: Fix small FixMe task in rust macro builtins

gcc/rust/ChangeLog:

* expand/rust-macro-builtins.cc: Change BuiltinMacro in
builtin_macro_from_string to tl::optional<>
* expand/rust-macro-builtins.h (enum class): Change BuiltinMacro
in builtin_macro_from_string to tl::optional<>
* resolve/rust-early-name-resolver.cc (EarlyNameResolver::visit):
Resolved wrong type dependency of builtin_macro_from_string

Signed-off-by: jjasmine <tanghocle456@gmail.com>
2 months agogccrs: Adjust error checks to match name resolution 2.0
Owen Avery [Fri, 23 Feb 2024 15:20:55 +0000 (10:20 -0500)]
gccrs: Adjust error checks to match name resolution 2.0

gcc/testsuite/ChangeLog:

* rust/compile/bad_stmt_enums.rs: Adjust redefinition error.
* rust/compile/bad_toplevel_enums.rs: Likewise.
* rust/compile/redef_error1.rs: Likewise.
* rust/compile/redef_error3.rs: Likewise.
* rust/compile/redef_error4.rs: Likewise.
* rust/compile/redef_error6.rs: Likewise.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2 months agogccrs: format-parser: Add `is_some_and` method for Option<T>
Arthur Cohen [Mon, 26 Feb 2024 10:55:47 +0000 (11:55 +0100)]
gccrs: format-parser: Add `is_some_and` method for Option<T>

Workaround for Ubuntu 18.04, since we still use it for the GCC 4.8 CI.
The default Rust package is 1.65 (and unlikely to change I assume?),
but the generic format parser library uses `is_some_and` which was
introduced in 1.70. So this is a simple reimplementation, directly taken
from the standard library sources.

libgrust/ChangeLog:

* libformat_parser/generic_format_parser/src/lib.rs: Add IsSomeAnd<T>
trait, impl it for Option<T>.

2 months agogccrs: libformat_parser: Fix Rust warnings.
Arthur Cohen [Thu, 15 Feb 2024 12:11:26 +0000 (13:11 +0100)]
gccrs: libformat_parser: Fix Rust warnings.

libgrust/ChangeLog:

* libformat_parser/generic_format_parser/src/lib.rs: Remove
unused deprecated attribute and unused import.
* libformat_parser/src/lib.rs: Remove unused import.

2 months agogccrs: rust-fmt: Store parsed string in Pieces struct
Arthur Cohen [Tue, 13 Feb 2024 15:31:25 +0000 (16:31 +0100)]
gccrs: rust-fmt: Store parsed string in Pieces struct

gcc/rust/ChangeLog:

* ast/rust-fmt.cc (Pieces::collect): Fix signature to take ownership
of the given string.
* ast/rust-fmt.h (struct Pieces): Store parsed string in the struct.

libgrust/ChangeLog:

* libformat_parser/src/lib.rs: Add debug prompt.

2 months agogccrs: format_args: Parse entire token invocation
Arthur Cohen [Wed, 7 Feb 2024 11:46:16 +0000 (12:46 +0100)]
gccrs: format_args: Parse entire token invocation

gcc/rust/ChangeLog:

* expand/rust-macro-builtins.cc (MacroBuiltin::format_args_handler):
Transform entire invocation token stream into string for the parser.

2 months agogccrs: format_args: Parse format string properly
Arthur Cohen [Tue, 30 Jan 2024 15:16:36 +0000 (16:16 +0100)]
gccrs: format_args: Parse format string properly

gcc/rust/ChangeLog:

* expand/rust-macro-builtins.cc (MacroBuiltin::format_args_handler):
Construct string to parser properly.

2 months agogccrs: libformat_parser: Send boxed values across FFI properly
Arthur Cohen [Tue, 30 Jan 2024 00:48:13 +0000 (01:48 +0100)]
gccrs: libformat_parser: Send boxed values across FFI properly

gcc/rust/ChangeLog:

* ast/rust-fmt.cc (Pieces::~Pieces): Call libformat_parser's release
function in destructor.
* ast/rust-fmt.h (struct PieceSlice): Add capacity.
(destroy_pieces): New.
(struct Pieces): Add destructor.

libgrust/ChangeLog:

* libformat_parser/src/lib.rs: Leak Boxes properly for C++ to
see them, add memory release function.

2 months agogccrs: libformat_parser: Update header and remove old interface
Arthur Cohen [Mon, 29 Jan 2024 21:06:39 +0000 (22:06 +0100)]
gccrs: libformat_parser: Update header and remove old interface

gcc/rust/ChangeLog:

* ast/rust-fmt.cc (Pieces::collect): Use new Pieces API.
* ast/rust-fmt.h: Update interface with new FFI bindings.

libgrust/ChangeLog:

* libformat_parser/src/lib.rs: Add IntoFFI trait.
* libformat_parser/libformat-parser.h: Removed.

2 months agogccrs: libformat_parser: Start experimenting with cbindgen
Arthur Cohen [Mon, 29 Jan 2024 15:14:13 +0000 (16:14 +0100)]
gccrs: libformat_parser: Start experimenting with cbindgen

libgrust/ChangeLog:

* libformat_parser/cbindgen.toml: New file.
* libformat_parser/libformat-parser.h: New file.

gcc/rust/ChangeLog:

* ast/rust-fmt.h: Add remaining FFI types.

2 months agogccrs: libformat_parser: Add FFI safe interface
Arthur Cohen [Mon, 29 Jan 2024 15:13:24 +0000 (16:13 +0100)]
gccrs: libformat_parser: Add FFI safe interface

libgrust/ChangeLog:

* libformat_parser/generic_format_parser/src/lib.rs: Add generic
library.
* libformat_parser/src/lib.rs: Add base for FFI interface.

2 months agoRust: Move 'libformat_parser' build into libgrust
Thomas Schwinge [Thu, 29 Feb 2024 07:44:49 +0000 (08:44 +0100)]
Rust: Move 'libformat_parser' build into libgrust

Addresses #2883.

contrib/
* gcc_update (files_and_dependencies): Update for
'libformat_parser' in libgrust.
gcc/rust/
* Make-lang.in (LIBFORMAT_PARSER): Point to 'libformat_parser'
build in libgrust.
(%.toml:, $(LIBFORMAT_PARSER):): Remove.
libgrust/
* libformat_parser/Makefile.am: New.
* Makefile.am [!TARGET_LIBRARY] (SUBDIRS): Add 'libformat_parser'.
* configure.ac: Handle it.
(TARGET_LIBRARY): New 'AM_CONDITIONAL'.
* libformat_parser/Makefile.in: Generate.
* Makefile.in: Regenerate.
* configure: Likewise.

2 months agoRust: Move 'libformat_parser' build into the GCC build directory
Thomas Schwinge [Wed, 28 Feb 2024 22:26:39 +0000 (23:26 +0100)]
Rust: Move 'libformat_parser' build into the GCC build directory

Fixes #2883.

gcc/rust/ChangeLog:
* Make-lang.in (LIBFORMAT_PARSER): Point to the GCC build
directory.
* ($(LIBFORMAT_PARSER)): Build in the GCC build directory.

2 months agoRust: Don't cache 'libformat_parser.a'
Thomas Schwinge [Wed, 28 Feb 2024 22:02:19 +0000 (23:02 +0100)]
Rust: Don't cache 'libformat_parser.a'

gcc/rust/
* Make-lang.in (LIBFORMAT_PARSER): Point to the actual build artifact.
($(LIBFORMAT_PARSER)): Don't cache it.

2 months agogccrs: libgrust: Vendor Rust dependencies
Arthur Cohen [Tue, 9 Apr 2024 11:32:31 +0000 (13:32 +0200)]
gccrs: libgrust: Vendor Rust dependencies

This commits vendors and locks our dependencies so that our Rust components
do not need internet access to be built anymore. Tested in a docker container
with no network access.

We can think about merging the vendor directory once we have more than one
Rust component, e.g. when we add polonius to the mix.

libgrust/ChangeLog:

* libformat_parser/.cargo/config: New file.
* libformat_parser/vendor.NOTES: New file.
* libformat_parser/vendor/libc/.cargo-checksum.json: New file.
* libformat_parser/vendor/libc/CONTRIBUTING.md: New file.
* libformat_parser/vendor/libc/Cargo.toml: New file.
* libformat_parser/vendor/libc/LICENSE-APACHE: New file.
* libformat_parser/vendor/libc/LICENSE-MIT: New file.
* libformat_parser/vendor/libc/README.md: New file.
* libformat_parser/vendor/libc/build.rs: New file.
* libformat_parser/vendor/libc/rustfmt.toml: New file.
* libformat_parser/vendor/libc/src/fixed_width_ints.rs: New file.
* libformat_parser/vendor/libc/src/fuchsia/aarch64.rs: New file.
* libformat_parser/vendor/libc/src/fuchsia/align.rs: New file.
* libformat_parser/vendor/libc/src/fuchsia/mod.rs: New file.
* libformat_parser/vendor/libc/src/fuchsia/no_align.rs: New file.
* libformat_parser/vendor/libc/src/fuchsia/riscv64.rs: New file.
* libformat_parser/vendor/libc/src/fuchsia/x86_64.rs: New file.
* libformat_parser/vendor/libc/src/hermit/aarch64.rs: New file.
* libformat_parser/vendor/libc/src/hermit/mod.rs: New file.
* libformat_parser/vendor/libc/src/hermit/x86_64.rs: New file.
* libformat_parser/vendor/libc/src/lib.rs: New file.
* libformat_parser/vendor/libc/src/macros.rs: New file.
* libformat_parser/vendor/libc/src/psp.rs: New file.
* libformat_parser/vendor/libc/src/sgx.rs: New file.
* libformat_parser/vendor/libc/src/solid/aarch64.rs: New file.
* libformat_parser/vendor/libc/src/solid/arm.rs: New file.
* libformat_parser/vendor/libc/src/solid/mod.rs: New file.
* libformat_parser/vendor/libc/src/switch.rs: New file.
* libformat_parser/vendor/libc/src/teeos/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/aix/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/aix/powerpc64.rs: New file.
* libformat_parser/vendor/libc/src/unix/align.rs: New file.
* libformat_parser/vendor/libc/src/unix/bsd/apple/b32/align.rs: New file.
* libformat_parser/vendor/libc/src/unix/bsd/apple/b32/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/bsd/apple/b64/aarch64/align.rs: New file.
* libformat_parser/vendor/libc/src/unix/bsd/apple/b64/aarch64/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/bsd/apple/b64/align.rs: New file.
* libformat_parser/vendor/libc/src/unix/bsd/apple/b64/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/bsd/apple/b64/x86_64/align.rs: New file.
* libformat_parser/vendor/libc/src/unix/bsd/apple/b64/x86_64/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/bsd/apple/long_array.rs: New file.
* libformat_parser/vendor/libc/src/unix/bsd/apple/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/bsd/freebsdlike/dragonfly/errno.rs: New file.
* libformat_parser/vendor/libc/src/unix/bsd/freebsdlike/dragonfly/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/bsd/freebsdlike/freebsd/aarch64.rs: New file.
* libformat_parser/vendor/libc/src/unix/bsd/freebsdlike/freebsd/arm.rs: New file.
* libformat_parser/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd11/b64.rs: New file.
* libformat_parser/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd12/b64.rs: New file.
* libformat_parser/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd12/x86_64.rs:
New file.
* libformat_parser/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd13/b64.rs: New file.
* libformat_parser/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd13/x86_64.rs:
New file.
* libformat_parser/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd14/b64.rs: New file.
* libformat_parser/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd14/x86_64.rs:
New file.
* libformat_parser/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd15/b64.rs: New file.
* libformat_parser/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/bsd/freebsdlike/freebsd/freebsd15/x86_64.rs:
New file.
* libformat_parser/vendor/libc/src/unix/bsd/freebsdlike/freebsd/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/bsd/freebsdlike/freebsd/powerpc.rs: New file.
* libformat_parser/vendor/libc/src/unix/bsd/freebsdlike/freebsd/powerpc64.rs: New file.
* libformat_parser/vendor/libc/src/unix/bsd/freebsdlike/freebsd/riscv64.rs: New file.
* libformat_parser/vendor/libc/src/unix/bsd/freebsdlike/freebsd/x86.rs: New file.
* libformat_parser/vendor/libc/src/unix/bsd/freebsdlike/freebsd/x86_64/align.rs: New file.
* libformat_parser/vendor/libc/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/bsd/freebsdlike/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/bsd/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/bsd/netbsdlike/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/bsd/netbsdlike/netbsd/aarch64.rs: New file.
* libformat_parser/vendor/libc/src/unix/bsd/netbsdlike/netbsd/arm.rs: New file.
* libformat_parser/vendor/libc/src/unix/bsd/netbsdlike/netbsd/mips.rs: New file.
* libformat_parser/vendor/libc/src/unix/bsd/netbsdlike/netbsd/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/bsd/netbsdlike/netbsd/powerpc.rs: New file.
* libformat_parser/vendor/libc/src/unix/bsd/netbsdlike/netbsd/riscv64.rs: New file.
* libformat_parser/vendor/libc/src/unix/bsd/netbsdlike/netbsd/sparc64.rs: New file.
* libformat_parser/vendor/libc/src/unix/bsd/netbsdlike/netbsd/x86.rs: New file.
* libformat_parser/vendor/libc/src/unix/bsd/netbsdlike/netbsd/x86_64.rs: New file.
* libformat_parser/vendor/libc/src/unix/bsd/netbsdlike/openbsd/aarch64.rs: New file.
* libformat_parser/vendor/libc/src/unix/bsd/netbsdlike/openbsd/arm.rs: New file.
* libformat_parser/vendor/libc/src/unix/bsd/netbsdlike/openbsd/mips64.rs: New file.
* libformat_parser/vendor/libc/src/unix/bsd/netbsdlike/openbsd/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/bsd/netbsdlike/openbsd/powerpc.rs: New file.
* libformat_parser/vendor/libc/src/unix/bsd/netbsdlike/openbsd/powerpc64.rs: New file.
* libformat_parser/vendor/libc/src/unix/bsd/netbsdlike/openbsd/riscv64.rs: New file.
* libformat_parser/vendor/libc/src/unix/bsd/netbsdlike/openbsd/sparc64.rs: New file.
* libformat_parser/vendor/libc/src/unix/bsd/netbsdlike/openbsd/x86.rs: New file.
* libformat_parser/vendor/libc/src/unix/bsd/netbsdlike/openbsd/x86_64.rs: New file.
* libformat_parser/vendor/libc/src/unix/haiku/b32.rs: New file.
* libformat_parser/vendor/libc/src/unix/haiku/b64.rs: New file.
* libformat_parser/vendor/libc/src/unix/haiku/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/haiku/native.rs: New file.
* libformat_parser/vendor/libc/src/unix/haiku/x86_64.rs: New file.
* libformat_parser/vendor/libc/src/unix/hurd/align.rs: New file.
* libformat_parser/vendor/libc/src/unix/hurd/b32.rs: New file.
* libformat_parser/vendor/libc/src/unix/hurd/b64.rs: New file.
* libformat_parser/vendor/libc/src/unix/hurd/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/hurd/no_align.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/android/b32/arm.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/android/b32/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/android/b32/x86/align.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/android/b32/x86/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/android/b64/aarch64/align.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/android/b64/aarch64/int128.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/android/b64/aarch64/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/android/b64/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/android/b64/riscv64/align.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/android/b64/riscv64/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/android/b64/x86_64/align.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/android/b64/x86_64/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/android/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/emscripten/align.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/emscripten/lfs64.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/emscripten/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/emscripten/no_align.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/align.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/arch/generic/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/arch/mips/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/arch/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/arch/powerpc/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/arch/sparc/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/gnu/align.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/gnu/b32/arm/align.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/gnu/b32/arm/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/gnu/b32/csky/align.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/gnu/b32/csky/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/gnu/b32/m68k/align.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/gnu/b32/m68k/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/gnu/b32/mips/align.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/gnu/b32/mips/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/gnu/b32/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/gnu/b32/powerpc.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/gnu/b32/riscv32/align.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/gnu/b32/sparc/align.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/gnu/b32/sparc/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/gnu/b32/x86/align.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/gnu/b32/x86/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/gnu/b64/aarch64/align.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/gnu/b64/aarch64/fallback.rs:
New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/gnu/b64/aarch64/ilp32.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/gnu/b64/aarch64/int128.rs:
New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/gnu/b64/aarch64/lp64.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/gnu/b64/loongarch64/align.rs:
New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/gnu/b64/loongarch64/mod.rs:
New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/gnu/b64/mips64/align.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/gnu/b64/mips64/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/gnu/b64/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/gnu/b64/powerpc64/align.rs:
New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/gnu/b64/riscv64/align.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/gnu/b64/s390x.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/gnu/b64/sparc64/align.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/gnu/b64/x86_64/align.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/gnu/b64/x86_64/not_x32.rs:
New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/gnu/b64/x86_64/x32.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/gnu/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/gnu/no_align.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/musl/b32/arm/align.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/musl/b32/arm/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/musl/b32/hexagon.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/musl/b32/mips/align.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/musl/b32/mips/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/musl/b32/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/musl/b32/powerpc.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/musl/b32/riscv32/align.rs:
New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/musl/b32/riscv32/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/musl/b32/x86/align.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/musl/b32/x86/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/musl/b64/aarch64/align.rs:
New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/musl/b64/aarch64/int128.rs:
New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/musl/b64/mips64.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/musl/b64/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/musl/b64/powerpc64.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/musl/b64/riscv64/align.rs:
New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/musl/b64/riscv64/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/musl/b64/s390x.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/musl/b64/x86_64/align.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/musl/lfs64.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/musl/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/no_align.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/non_exhaustive.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/uclibc/align.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/uclibc/arm/align.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/uclibc/arm/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/uclibc/arm/no_align.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/uclibc/mips/mips32/align.rs:
New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs:
New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/uclibc/mips/mips32/no_align.rs:
New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/uclibc/mips/mips64/align.rs:
New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/uclibc/mips/mips64/mod.rs:
New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/uclibc/mips/mips64/no_align.rs:
New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/uclibc/mips/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/uclibc/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/uclibc/no_align.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/uclibc/x86_64/l4re.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/uclibc/x86_64/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/linux/uclibc/x86_64/other.rs: New file.
* libformat_parser/vendor/libc/src/unix/linux_like/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/newlib/aarch64/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/newlib/align.rs: New file.
* libformat_parser/vendor/libc/src/unix/newlib/arm/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/newlib/espidf/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/newlib/generic.rs: New file.
* libformat_parser/vendor/libc/src/unix/newlib/horizon/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/newlib/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/newlib/no_align.rs: New file.
* libformat_parser/vendor/libc/src/unix/newlib/powerpc/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/newlib/vita/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/no_align.rs: New file.
* libformat_parser/vendor/libc/src/unix/nto/aarch64.rs: New file.
* libformat_parser/vendor/libc/src/unix/nto/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/nto/neutrino.rs: New file.
* libformat_parser/vendor/libc/src/unix/nto/x86_64.rs: New file.
* libformat_parser/vendor/libc/src/unix/redox/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/solarish/compat.rs: New file.
* libformat_parser/vendor/libc/src/unix/solarish/illumos.rs: New file.
* libformat_parser/vendor/libc/src/unix/solarish/mod.rs: New file.
* libformat_parser/vendor/libc/src/unix/solarish/solaris.rs: New file.
* libformat_parser/vendor/libc/src/unix/solarish/x86.rs: New file.
* libformat_parser/vendor/libc/src/unix/solarish/x86_64.rs: New file.
* libformat_parser/vendor/libc/src/unix/solarish/x86_common.rs: New file.
* libformat_parser/vendor/libc/src/vxworks/aarch64.rs: New file.
* libformat_parser/vendor/libc/src/vxworks/arm.rs: New file.
* libformat_parser/vendor/libc/src/vxworks/mod.rs: New file.
* libformat_parser/vendor/libc/src/vxworks/powerpc.rs: New file.
* libformat_parser/vendor/libc/src/vxworks/powerpc64.rs: New file.
* libformat_parser/vendor/libc/src/vxworks/x86.rs: New file.
* libformat_parser/vendor/libc/src/vxworks/x86_64.rs: New file.
* libformat_parser/vendor/libc/src/wasi.rs: New file.
* libformat_parser/vendor/libc/src/windows/gnu/align.rs: New file.
* libformat_parser/vendor/libc/src/windows/gnu/mod.rs: New file.
* libformat_parser/vendor/libc/src/windows/mod.rs: New file.
* libformat_parser/vendor/libc/src/windows/msvc/mod.rs: New file.
* libformat_parser/vendor/libc/src/xous.rs: New file.
* libformat_parser/vendor/libc/tests/const_fn.rs: New file.
* libformat_parser/vendor/unicode-xid/.cargo-checksum.json: New file.
* libformat_parser/vendor/unicode-xid/COPYRIGHT: New file.
* libformat_parser/vendor/unicode-xid/Cargo.toml: New file.
* libformat_parser/vendor/unicode-xid/LICENSE-APACHE: New file.
* libformat_parser/vendor/unicode-xid/LICENSE-MIT: New file.
* libformat_parser/vendor/unicode-xid/README.md: New file.
* libformat_parser/vendor/unicode-xid/benches/xid.rs: New file.
* libformat_parser/vendor/unicode-xid/src/lib.rs: New file.
* libformat_parser/vendor/unicode-xid/src/tables.rs: New file.
* libformat_parser/vendor/unicode-xid/src/tests.rs: New file.
* libformat_parser/vendor/unicode-xid/tests/exhaustive_tests.rs: New file.

2 months agogccrs: Add 'gcc/rust/Make-lang.in:LIBFORMAT_PARSER'
Thomas Schwinge [Wed, 28 Feb 2024 21:51:24 +0000 (22:51 +0100)]
gccrs: Add 'gcc/rust/Make-lang.in:LIBFORMAT_PARSER'

... to avoid verbatim repetition.

gcc/rust/
* Make-lang.in (LIBPROC_MACRO_INTERNAL): New.
(RUST_LIBDEPS, crab1$(exeext), rust/libformat_parser.a): Use it.

2 months agogccrs: libgrust: Add format_parser library
Arthur Cohen [Tue, 23 Apr 2024 11:38:58 +0000 (13:38 +0200)]
gccrs: libgrust: Add format_parser library

Compile libformat_parser and link to it.

gcc/rust/ChangeLog:

* Make-lang.in: Compile libformat_parser.
* ast/rust-fmt.cc: New FFI definitions.
* ast/rust-fmt.h: Likewise.
* expand/rust-macro-builtins.cc (MacroBuiltin::format_args_handler): Call
into libformat_parser.
* expand/rust-macro-builtins.h: Define format_args!() handler proper.

libgrust/ChangeLog:

* libformat_parser/Cargo.lock: New file.
* libformat_parser/Cargo.toml: New file.
* libformat_parser/generic_format_parser/Cargo.toml: New file.
* libformat_parser/generic_format_parser/src/lib.rs: New file.
* libformat_parser/src/bin.rs: New file.
* libformat_parser/src/lib.rs: New file.

2 months agogccrs: fmt: Start working on format_args!() parser
Arthur Cohen [Thu, 9 Nov 2023 17:32:52 +0000 (18:32 +0100)]
gccrs: fmt: Start working on format_args!() parser

This commit adds a base class for parsing the various constructs of a
Rust format string, according to the grammar in the reference:

https://doc.rust-lang.org/std/fmt/index.html#syntax

gcc/rust/ChangeLog:

* Make-lang.in: Compile rust-fmt object
* ast/rust-fmt.cc: New file.
* ast/rust-fmt.h: New file.

2 months agogccrs: minor cleanup in langhook.type_for_mode
Marc Poulhiès [Mon, 19 Feb 2024 21:52:29 +0000 (22:52 +0100)]
gccrs: minor cleanup in langhook.type_for_mode

gcc/rust/ChangeLog:

* rust-lang.cc (grs_langhook_type_for_mode): simplify code for
xImode. Add missing long_double_type_node.

Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
2 months agogccrs: Fix false positive for top-level AltPattern
Owen Avery [Sun, 18 Feb 2024 05:19:25 +0000 (00:19 -0500)]
gccrs: Fix false positive for top-level AltPattern

gcc/rust/ChangeLog:

* hir/rust-ast-lower-pattern.cc
(ASTLoweringPattern::visit):
Reset is_let_top_level while visiting GroupedPattern.

gcc/testsuite/ChangeLog:

* rust/compile/let_alt.rs: Check for false positive.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
2 months agoRust: Make 'tree'-level 'MAIN_NAME_P' work
Thomas Schwinge [Wed, 12 Apr 2023 09:47:01 +0000 (11:47 +0200)]
Rust: Make 'tree'-level 'MAIN_NAME_P' work

'gcc/tree.h':

    #define main_identifier_node global_trees[TI_MAIN_IDENTIFIER]
    #define MAIN_NAME_P(NODE) \
      (IDENTIFIER_NODE_CHECK (NODE) == main_identifier_node)

..., which is not initialized by default, but has to be set up by every front
end individually.  'MAIN_NAME_P' enables certain code optimizations, but is
especially also relevant for back ends that emit additional program entry setup
code for 'main'.

gcc/rust/
* backend/rust-compile-base.cc (HIRCompileBase::compile_function):
For 'main', initialize 'main_identifier_node'.

2 months agotree-optimization/114659 - VN and FP to int punning
Richard Biener [Sun, 21 Jul 2024 09:56:07 +0000 (11:56 +0200)]
tree-optimization/114659 - VN and FP to int punning

The following addresses another case where x87 FP loads mangle the
bit representation and thus are not suitable for a representative
in other types.  VN was value-numbering a later integer load of 'x'
as the same as a former float load of 'x'.

We can use the new TARGET_MODE_CAN_TRANSFER_BITS hook to identify
problematic modes and enforce strict compatibility for those in
the reference comparison, improving the handling of modes with
padding in visit_reference_op_load.

PR tree-optimization/114659
* tree-ssa-sccvn.cc (visit_reference_op_load): Do not
prevent punning from modes with padding here, but ...
(vn_reference_eq): ... ensure this here, also honoring
types with modes that cannot act as bit container.

* gcc.target/i386/pr114659.c: New testcase.

2 months ago[x86] implement TARGET_MODE_CAN_TRANSFER_BITS
Richard Biener [Mon, 29 Jul 2024 11:10:18 +0000 (13:10 +0200)]
[x86] implement TARGET_MODE_CAN_TRANSFER_BITS

The following implements the hook, excluding x87 modes for scalar
and complex float modes.

* config/i386/i386.cc (TARGET_MODE_CAN_TRANSFER_BITS): Define.
(ix86_mode_can_transfer_bits): New function.

2 months agoAdd TARGET_MODE_CAN_TRANSFER_BITS
Richard Biener [Mon, 29 Jul 2024 11:06:52 +0000 (13:06 +0200)]
Add TARGET_MODE_CAN_TRANSFER_BITS

The following adds a target hook to specify whether regs of MODE can be
used to transfer bits.  The hook is supposed to be used for value-numbering
to decide whether a value loaded in such mode can be punned to another
mode instead of re-loading the value in the other mode and for SRA to
decide whether MODE is suitable as container holding a value to be
used in different modes.

* target.def (mode_can_transfer_bits): New target hook.
* target.h (mode_can_transfer_bits): New function wrapping the
hook and providing default behavior.
* doc/tm.texi.in: Update.
* doc/tm.texi: Re-generate.

2 months agoAVR: Tweak unsigned comparisons against 256 resp. 65536.
Georg-Johann Lay [Thu, 1 Aug 2024 08:21:53 +0000 (10:21 +0200)]
AVR: Tweak unsigned comparisons against 256 resp. 65536.

u16 >= 256 can be performed by testing the hi8 part against 0.
u32 >= 65536 can be performed by testing the high word against 0.
The optimization is performed in split2 after register allocation
because the register allocator likely spills for subregs.

gcc/
* config/avr/avr.md (cbranch<mode>4_insn): Split to a test of the
high part against 0 if possible.

2 months agoAVR: Tweak register pressure for const_fixed compares against "M".
Georg-Johann Lay [Thu, 1 Aug 2024 07:58:48 +0000 (09:58 +0200)]
AVR: Tweak register pressure for const_fixed compares against "M".

When comparing a 16-bit or 32-bit integer against a constant in
the range 0...0xff, constraint M is used because no scratch reg
is needed in that case.  Same can be done for fixed-point compares.

gcc/
* config/avr/constraints.md (YMM): New constraint.
* config/avr/avr.md (cmp<mode>3, *cmp<mode>3)
(cbranch<mode>4_insn): Allow YMM where M is allowed.

2 months agoi386: Fix up *<extract_type>_vinsert<shuffletype><extract_suf>_0 [PR115981]
Jakub Jelinek [Thu, 1 Aug 2024 08:32:54 +0000 (10:32 +0200)]
i386: Fix up *<extract_type>_vinsert<shuffletype><extract_suf>_0 [PR115981]

The r14-537 change started canonicalizing VEC_MERGE operands based on
swap_commutative_operands_p or if they have the same precedence least
significant bit of the third operand.
The *<extract_type>_vinsert<shuffletype><extract_suf>_0 pattern was
added for combine matching and no longer triggers after that change,
as it used the reg_or_0_operand as the first operand and VEC_DUPLICATE
as the second.
Now, reg_or_0_operand could be a REG, SUBREG of object or CONST_VECTOR.
REG has commutative_operand_precedence -1 or -2, SUBREG of object -3,
CONST_VECTOR -4, while VEC_DUPLICATE has 0, so VEC_DUPLICATE will always
go first and REG, SUBREG or CONST_VECTOR second.

This patch swaps the operands so that it matches again.

2024-08-01  Jakub Jelinek  <jakub@redhat.com>

PR target/115981
* config/i386/sse.md
(*<extract_type>_vinsert<shuffletype><extract_suf>_0): Swap the
first two VEC_MERGE operands, renumber match_operands and test
for 0xF or 0x3 rather than 0xFFF0 or 0xFC immediate.

* gcc.target/i386/avx512dq-pr90991-1.c: Add tests for no separate
zero extension instructions.
* gcc.target/i386/avx512dq-pr90991-2.c: Likewise.

2 months agoomp-offload.cc: Fix value-expr handling of 'declare target link' vars [PR115637]
Tobias Burnus [Thu, 1 Aug 2024 07:06:32 +0000 (09:06 +0200)]
omp-offload.cc: Fix value-expr handling of 'declare target link' vars [PR115637]

As the PR and included testcase shows, replacing 'arr2' by its value expression
'*arr2$13$linkptr' failed for
  MEM <uint128_t> [(c_char * {ref-all})&arr2]
which left 'arr2' in the code as unknown symbol. Now expand the value expression
already in pass_omp_target_link::execute's process_link_var_op walk_gimple_stmt
walk - and don't rely on gimple_regimplify_operands.

PR middle-end/115637

gcc/ChangeLog:

* gimplify.cc (gimplify_body): Fix macro name in the comment.
* omp-offload.cc (find_link_var_op): Rename to ...
(process_link_var_op): ... this. Replace value expr.
(pass_omp_target_link::execute): Update walk_gimple_stmt call.

libgomp/ChangeLog:

* testsuite/libgomp.fortran/declare-target-link.f90: Uncomment
now working code.

Co-authored-by: Richard Biener <rguenther@suse.de
2 months agoi386: Remove ndd support for *add<mode>_4 [PR113744]
Lingling Kong [Thu, 1 Aug 2024 03:05:41 +0000 (11:05 +0800)]
i386: Remove ndd support for *add<mode>_4 [PR113744]

*add<mode>_4 and *adddi_4 are for shorter opcode from cmp to
inc/dec or add $128. But NDD code is longer than the cmp code,
so there is no need to support ndd.

gcc/ChangeLog:

PR target/113744
* config/i386/i386.md (*add<mode>_4): Remove ndd support.
(*adddi_4): Ditto.

Co-Authored-By: Hu, Lin1 <lin1.hu@intel.com>
2 months agoRISC-V: NFC: Do not use zicond for pr105314 testcases
Xiao Zeng [Thu, 25 Jul 2024 01:50:03 +0000 (09:50 +0800)]
RISC-V: NFC: Do not use zicond for pr105314 testcases

gcc/testsuite/ChangeLog:

* gcc.target/riscv/pr105314-rtl.c: Skip zicond.
* gcc.target/riscv/pr105314-rtl32.c: Ditto.
* gcc.target/riscv/pr105314.c: Ditto.

Signed-off-by: Xiao Zeng <zengxiao@eswincomputing.com>
2 months agoFix ICE when using -gcodeview with empty struct
Mark Harmstone [Fri, 26 Jul 2024 19:46:33 +0000 (20:46 +0100)]
Fix ICE when using -gcodeview with empty struct

Empty structs result in empty LF_FIELDLIST types, which are valid, but
we weren't accounting for this and assuming they had to contain
subtypes.

gcc/
* dwarf2codeview.cc (get_type_num_struct): Fix NULL pointer dereference.

2 months agotestsuite: split out parts of jit.dg/jit.exp into a new lib/valgrind.exp
David Malcolm [Thu, 1 Aug 2024 00:38:41 +0000 (20:38 -0400)]
testsuite: split out parts of jit.dg/jit.exp into a new lib/valgrind.exp

I want to reuse some of the support for valgrind in jit.exp
in my upcoming testsuite for https://gcc.gnu.org/wiki/libdiagnostics
so this patch splits that out into a valgrind.exp.

No functional change intended.

gcc/testsuite/ChangeLog:
* jit.dg/jit.exp: Add load_lib valgrind.exp.
(proc report_leak): Move to valgrind.exp, and add argument
leak_report_function rather than hardcoding xfail.
(parse_valgrind_logfile): Likewise.
(fixed_host_execute): Pass xfail to parse_valgrind_logfile.
* lib/valgrind.exp: New file, based on the above.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 months agodiagnostics: handle logical locations with NULL name
David Malcolm [Thu, 1 Aug 2024 00:38:41 +0000 (20:38 -0400)]
diagnostics: handle logical locations with NULL name

gcc/ChangeLog:
* diagnostic-path.cc
(thread_event_printer::print_swimlane_for_event_range): Gracefully
handle logical_location::get_name_for_path_output returning null.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 months agotestsuite: drop unused import within sarif.py
David Malcolm [Thu, 1 Aug 2024 00:38:41 +0000 (20:38 -0400)]
testsuite: drop unused import within sarif.py

No functional change intended.

gcc/testsuite/ChangeLog:
* gcc.dg/sarif-output/sarif.py: Drop unused import of gzip.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 months agodiagnostics: SARIF output: capture unlabelled secondary locations
David Malcolm [Thu, 1 Aug 2024 00:38:41 +0000 (20:38 -0400)]
diagnostics: SARIF output: capture unlabelled secondary locations

This patch extends
* the work done in r15-2291-gd7a688fc960f78 to capture labels
  on location ranges in rich_locations in SARIF form as
  "annotations" (§3.28.6)
* the work done in r15-2354-g4d1f71d49e396c to support
  related locations (§3.27.22 and Â§3.34)

so that all location ranges in a rich_location now get captured in
the SARIF output:
- those with a label are handled as before as "annotations" (§3.28.6),
  per r15-2291-gd7a688fc960f78
- those without a label now get captured, in the result's
  "relatedLocations" (§3.27.22)

For example, given:

  int missing_semicolon (void)
  {
    return 42
  }

for which the textual output looks like this:

  PATH/missing-semicolon.c: In function 'missing_semicolon':
  PATH/missing-semicolon.c:9:12: error: expected ';' before '}' token
      9 |   return 42
        |            ^
        |            ;
     10 | }
        | ~

with this patch the SARIF output now has this for the result's location:

   "relationships": [{"target": 0,
                      "kinds": ["relevant"]}]}],

where the result gains a related location :

  "relatedLocations": [{"physicalLocation": {"artifactLocation": { [...snip...] },
                                             "region": {"startLine": 10,
                                                        "startColumn": 1,
                                                        "endColumn": 2},
                                             "contextRegion": {"startLine": 10,
                                                               "snippet": {"text": "}\n"}}},
                        "id": 0}]}]}]}

i.e. that the error also has the secondary location at the trailing
close brace which has the relationship "relevant" to the primary
location (at the suggested insertion point).

The patch also adds test coverage for the SARIF encoding of the fix-it hint.

gcc/ChangeLog:
* diagnostic-format-sarif.cc
(sarif_location_manager::worklist_item::unlabelled_secondary_location):
New enum value.
(sarif_location_manager::m_unlabelled_secondary_locations): New
field.
(sarif_location_manager::process_worklist_item): Handle unlabelled
secondary locations.
(sarif_builder::make_location_object): Generalize code to handle
ranges within a rich_location so as well as using annotations for
those with labels, we now add related locations for those without
labels.

gcc/testsuite/ChangeLog:
* gcc.dg/sarif-output/missing-semicolon.c: New test.
* gcc.dg/sarif-output/sarif.py (get_location_physical_region): New.
(get_location_snippet_text): New.
* gcc.dg/sarif-output/test-missing-semicolon.py: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 months agodiagnostics: SARIF output: eliminate some uses of "line_table" global
David Malcolm [Thu, 1 Aug 2024 00:38:40 +0000 (20:38 -0400)]
diagnostics: SARIF output: eliminate some uses of "line_table" global

No functional change intended.

gcc/ChangeLog:
* diagnostic-format-sarif.cc (sarif_builder::sarif_builder): Assert
that m_line_maps is nonnull.
(diagnostic_output_format_init_sarif_stderr): Add "line_maps"
param and pass to format ctor.
(diagnostic_output_format_init_sarif_file): Likewise.
(diagnostic_output_format_init_sarif_stream): Likewise.
* diagnostic.cc (diagnostic_output_format_init): Pass "line_table"
as line_maps param to the above.
* diagnostic.h (diagnostic_output_format_init_sarif_stderr): Add
"line_maps" param.
(diagnostic_output_format_init_sarif_file): Likewise.
(diagnostic_output_format_init_sarif_stream): Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 months agodiagnostics: SARIF output: tweak ASCII art in comment
David Malcolm [Thu, 1 Aug 2024 00:38:40 +0000 (20:38 -0400)]
diagnostics: SARIF output: tweak ASCII art in comment

gcc/ChangeLog:
* diagnostic-format-sarif.cc: Tweak ASCII art in comment
to show edges for both directions in the digraph.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
2 months agoDaily bump.
GCC Administrator [Thu, 1 Aug 2024 00:19:03 +0000 (00:19 +0000)]
Daily bump.

2 months agolibstdc++: Fix unexpected compilation error in neg tests
François Dumont [Wed, 31 Jul 2024 20:25:20 +0000 (22:25 +0200)]
libstdc++: Fix unexpected compilation error in neg tests

Fix a compilation error that is not expected by the tests preserving
the expected ones.

The 'test' variable declaration is missing since commit
a9260b7eb688df43a724e25421ba40f35a89fee9 that removed the test global
variable in testsuite files.

libstdc++-v3/ChangeLog:

* testsuite/23_containers/map/operators/1_neg.cc (test01): Add test variable
declaration.
* testsuite/23_containers/set/operators/1_neg.cc (test01): Likewise.

2 months agolibstdc++: Fix src/c++20/format.cc for non-gthreads targets
Jonathan Wakely [Wed, 31 Jul 2024 19:27:33 +0000 (20:27 +0100)]
libstdc++: Fix src/c++20/format.cc for non-gthreads targets

libstdc++-v3/ChangeLog:

* src/c++20/format.cc [!_GLIBCXX_HAS_GTHREADS] (mutex): Define
dummy mutex type.
* testsuite/std/time/format_localized.cc: Use loop variable
instead of creating the same locale on every iteration.

2 months agoFortran: Add newline character to test input.
Jerry DeLisle [Wed, 31 Jul 2024 15:58:17 +0000 (08:58 -0700)]
Fortran: Add newline character to test input.

gcc/testsuite/ChangeLog:

PR libfortran/105361

* gfortran.dg/pr105361.f90: Add newline character to test
input to provide more compliant test.

2 months agomatch: Fix types matching for `(?:) !=/== (?:)` [PR116134]
Andrew Pinski [Mon, 29 Jul 2024 18:33:58 +0000 (11:33 -0700)]
match: Fix types matching for `(?:) !=/== (?:)` [PR116134]

The problem here is that in generic types of comparisons don't need
to be boolean types (or vector boolean types). And fixes that by making
sure the types of the conditions match before doing the optimization.

Bootstrapped and tested on x86_64-linux-gnu with no regressions.

PR middle-end/116134

gcc/ChangeLog:

* match.pd (`(a ? x : y) eq/ne (b ? x : y)`): Check that
a and b types match.
(`(a ? x : y) eq/ne (b ? y : x)`): Likewise.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
2 months agodir-locals: apply our C settings in C++ also
Arsen Arsenović [Wed, 31 Jul 2024 14:53:35 +0000 (16:53 +0200)]
dir-locals: apply our C settings in C++ also

This also works with Emacs 30 Tree-Sitter C and C++ modes, as they are
submodes.

ChangeLog:

* .dir-locals.el: Change c-mode to a list of C, C++ and ObjC
modes that Emacs currently provides.

2 months ago[target/116104] Fix more rtl-checking failures in ext-dce
Jeff Law [Wed, 31 Jul 2024 17:30:27 +0000 (11:30 -0600)]
[target/116104] Fix more rtl-checking failures in ext-dce

More enable-rtl-checking fixes for ext-dce.  Very similar to the one recently
posted, this time covering more of the shift ops.

I checked all instances of CONSTANT_P guarding [U]INTVAL and fixed all that
looked wrong.  I also created a dummy assembler/linker so that I could run the
GCC testsuite on gcn and verified that wasn't tripping any rtl-checking bugs in
ext-dce anymore.

Obviously this has also gone through x86 bootstrap and regression tested.

Pushing to the trunk.

pr target/116104
gcc/
* ext-dce.cc (carry_backpropagate): Change more guards of [U]INTVAL to
test CONST_INT_P rather than CONSTANT_P, fixing rtl-checking failures.

2 months agopru: Enable section anchoring by default
Dimitar Dimitrov [Sun, 14 Jul 2024 16:45:09 +0000 (19:45 +0300)]
pru: Enable section anchoring by default

Loading an arbitrary constant address in a register is expensive for
PRU.  So enable section anchoring by default to utilize the unsigned
byte constant offset operand of load/store instructions.

gcc/ChangeLog:

* common/config/pru/pru-common.cc
(TARGET_OPTION_OPTIMIZATION_TABLE): New definition.
* config/pru/pru.cc (TARGET_MIN_ANCHOR_OFFSET): Set minimal
anchor offset.
(TARGET_MAX_ANCHOR_OFFSET): Set maximum anchor offset.

gcc/testsuite/ChangeLog:

* gcc.target/pru/section-anchors-1.c: New test.
* gcc.target/pru/section-anchors-2.c: New test.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
2 months agotestsuite: Fix for targets not passing argc/argv [PR116154]
Dimitar Dimitrov [Wed, 31 Jul 2024 16:20:20 +0000 (19:20 +0300)]
testsuite: Fix for targets not passing argc/argv [PR116154]

PRU and other simulator targets do not pass any argv arguments
to main.  Instead of erroneously relying on argc==0, use a volatile
variable instead.

I reverted the fix for PR67947 in r6-3891-g8a18fcf4aa1d5c, and made sure
that the updated test case still fails for x86_64:

  $ make check-gcc-c RUNTESTFLAGS="dg-torture.exp=pr67947.c"
  ...
  FAIL: gcc.dg/torture/pr67947.c   -O1  execution test
  ...
  # of expected passes            8
  # of unexpected failures        8

Fix was suggested by Andrew Pinski in PR116154.  Committed as obvious.

PR testsuite/116154

gcc/testsuite/ChangeLog:

* gcc.dg/torture/pr67947.c: Use volatile variable instead of
argc.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
2 months agolibstdc++: drop bogus 'dg_do run' directive
Sam James [Tue, 30 Jul 2024 20:39:48 +0000 (21:39 +0100)]
libstdc++: drop bogus 'dg_do run' directive

We already have a valid 'dg-do run' (- vs _) directive, so drop the bogus
one.

libstdc++-v3/ChangeLog:
* testsuite/28_regex/traits/char/translate.cc: Drop bogus 'dg_do run'.

2 months ago[PR rtl-optimization/116136] Fix previously latent SUBREG simplification bug
Jeff Law [Wed, 31 Jul 2024 16:15:01 +0000 (10:15 -0600)]
[PR rtl-optimization/116136] Fix previously latent SUBREG simplification bug

This fixes a testsuite regression seen on m68k after some of the recent ext-dce
changes.  Ultimately Richard S and I have concluded the bug was a latent issue
in subreg simplification.

Essentially when simplifying something like

(set (target:M1) (subreg:M1 (subreg:M2 (reg:M1) 0) 0))

Where M1 > M2.  We'd simplify to:

(set (target:M1) (reg:M1))

The problem is on a big endian target that's wrong.   Consider if M1 is DI and
M2 is SI.    The original should extract bits 32..63 from the source register
and store them into bits 0..31 of the target register. In the simplified form
it's just a copy, so bits 0..63 of the source end up bits 0..63 of the target.

This shows up as the following regressions on the m68k:

> Tests that now fail, but worked before (3 tests):
>
> gcc: gcc.c-torture/execute/960416-1.c   -O2  execution test
> gcc: gcc.c-torture/execute/960416-1.c   -O2 -flto -fno-use-linker-plugin -flto-partition=none  execution test
> gcc: gcc.c-torture/execute/960416-1.c   -Os  execution test

The fix is pretty trivial, instead of hardcoding "0" as the byte offset in the
test for the simplification, instead we need to use the subreg_lowpart_offset.

Anyway, bootstrapped and regression tested on m68k and x86_64 and tested on the
other embedded targets as well without regressions.  Naturally it fixes the
regression noted above.  I haven't see other testsuite improvements when I spot
checked some of the big endian crosses.

PR rtl-optimization/116136
gcc/
* simplify-rtx.cc (simplify_context::simplify_subreg): Check
that we're working with the lowpart offset rather than byte 0.

2 months agolibstdc++: Handle strerror returning null
Jonathan Wakely [Wed, 31 Jul 2024 12:56:14 +0000 (13:56 +0100)]
libstdc++: Handle strerror returning null

The linux man page for strerror says that some systems return NULL for
an unknown error number. That violates the C and POSIX standards, but we
can esily handle it to avoid a segfault.

libstdc++-v3/ChangeLog:

* src/c++11/system_error.cc (strerror_string): Handle
non-conforming NULL return from strerror.

2 months agolibstdc++: Only append "@euro" to locale names for Glibc testing
Jonathan Wakely [Wed, 31 Jul 2024 11:03:32 +0000 (12:03 +0100)]
libstdc++: Only append "@euro" to locale names for Glibc testing

The testsuite automatically appends "@euro" to "xx.ISO8859-15" locale
names on all targets except FreeBSD, DragonflyBSD, and NetBSD. It should
only be for Glibc, not all non-BSD targets.

libstdc++-v3/ChangeLog:

* testsuite/lib/libstdc++.exp (check_v3_target_namedlocale):
Only append "@euro" to ".ISO8859-15" locales for Glibc.

2 months agolibstdc++: Bump __cpp_lib_format value for std::runtime_format
Jonathan Wakely [Tue, 16 Jul 2024 09:22:40 +0000 (10:22 +0100)]
libstdc++: Bump __cpp_lib_format value for std::runtime_format

We already supported this feature, but couldn't set the feature test
macro accordingly because we were missing support for older features.
Now that we support all the older <format> changes, we can set this to
the correct value.

libstdc++-v3/ChangeLog:

* include/bits/version.def (format): Update value for C++26.
* include/bits/version.h: Regenerate.
* include/std/format (runtime_format, wruntime_format): Check
__cpp_lib_format instead of __cplusplus.
* testsuite/std/format/functions/format.cc: Update expected
value of macro for C++26 mode.

2 months agolibstdc++: Define C++26 member visit for std::basic_format_arg [PR110356]
Jonathan Wakely [Tue, 16 Jul 2024 09:14:45 +0000 (10:14 +0100)]
libstdc++: Define C++26 member visit for std::basic_format_arg [PR110356]

Implement the std::format changes from P2637R3. This adds visit member
functions to std::basic_format_arg and deprecates the non-member
function std::visit_format_arg.

libstdc++-v3/ChangeLog:

PR libstdc++/110356
* include/bits/c++config (_GLIBCXX26_DEPRECATED): Define.
(_GLIBCXX26_DEPRECATED_SUGGEST): Define.
* include/bits/version.def (format): Update for C++26.
* include/bits/version.h: Regenerate.
* include/std/format (basic_format_arg::visit): New member
functions.
(visit_format_arg): Add deprecated attribute.
* testsuite/std/format/arguments/args.cc: Expect deprecated
warnings. Check member visit.
* testsuite/std/format/functions/format.cc: Update expected
value for __cpp_lib_format macro.
* testsuite/std/format/parse_ctx.cc: Add dg-warning for
deprecation.

2 months agolibstdc++: Define C++26 member visit for std::variant [PR110356]
Jonathan Wakely [Tue, 9 Jul 2024 11:12:56 +0000 (12:12 +0100)]
libstdc++: Define C++26 member visit for std::variant [PR110356]

Implement the std::variant changes from P2637R3.

libstdc++-v3/ChangeLog:

PR libstdc++/110356
* include/bits/version.def (variant): Update for C++26.
* include/bits/version.h: Regenerate.
* include/std/variant (variant::visit): New member functions.
* testsuite/20_util/variant/visit.cc: Check second alternative.
* testsuite/20_util/variant/visit_member.cc: New test.

2 months agolibstdc++: Implement C++26 type checking for std::format args [PR115776]
Jonathan Wakely [Tue, 9 Jul 2024 11:12:56 +0000 (12:12 +0100)]
libstdc++: Implement C++26 type checking for std::format args [PR115776]

Implement the changes from P2757R3, which enhance the parse context to
be able to do type checking on format arguments, and to use that to
ensure that args used for width and precisions are integral types.

libstdc++-v3/ChangeLog:

PR libstdc++/115776
* include/bits/version.def (format): Update for C++26.
* include/bits/version.h: Regenerate.
* include/std/format (basic_format_parse_context): Remove
default argument from constructor and split into two
constructors. Make the constructor taking size_t private for
C++26 and later.
(basic_format_parse_context::check_dynamic_spec): New member
function template.
(basic_format_parse_context::check_dynamic_spec_integral): New
member function.
(basic_format_parse_context::check_dynamic_spec_string):
Likewise.
(__format::_Spec::_S_parse_width_or_precision): Use
check_dynamic_spec_integral.
(__format::__to_arg_t_enum): New helper function.
(basic_format_arg):  Declare __to_arg_t_enum as friend.
(__format::_Scanner): Define and use a derived parse context
type.
(__format::_Checking_scanner): Make arg types available to parse
context.
* testsuite/std/format/functions/format.cc: Check for new values
of __cpp_lib_format macro.
* testsuite/std/format/parse_ctx.cc: Check all members of
basic_format_parse_context.
* testsuite/std/format/parse_ctx_neg.cc: New test.
* testsuite/std/format/string.cc: Add more checks for dynamic
width and precision args.

2 months agolibstdc++: Support P2510R3 "Formatting pointers" as a DR for C++20
Jonathan Wakely [Thu, 11 Jul 2024 23:30:24 +0000 (00:30 +0100)]
libstdc++: Support P2510R3 "Formatting pointers" as a DR for C++20

We already enable this for -std=gnu++20 but we can do it for -std=c++20
too. Both libc++ and MSVC also treat this change as a DR for C++20.

Now that the previous change to the value of __cpp_lib_format is
supported, we can finally update it to 202304 to indicate support for
this feature too.

libstdc++-v3/ChangeLog:

* include/bits/version.def (format): Update value for P2510R3.
* include/bits/version.h: Regenerate.
* include/std/format (_GLIBCXX_P2518R3): Remove misspelled macro
and check __glibcxx_format instead.
* testsuite/std/format/functions/format.cc: Check value of the
__cpp_lib_format macro for formatting pointers support.
* testsuite/std/format/parse_ctx.cc: Likewise.

2 months agolibstdc++: Handle encodings in localized chrono formatting [PR109162]
Jonathan Wakely [Thu, 1 Feb 2024 11:14:48 +0000 (11:14 +0000)]
libstdc++: Handle encodings in localized chrono formatting [PR109162]

This implements the C++23 paper P2419R2 (Clarify handling of encodings
in localized formatting of chrono types). The requirement is that when
the literal encoding is "a Unicode encoding form" and the formatting
locale uses a different encoding, any locale-specific strings such as
"août" for std::chrono::August should be converted to the literal
encoding.

Using the recently-added std::locale::encoding() function we can check
the locale's encoding and then use iconv if a conversion is needed.
Because nl_langinfo_l and iconv_open both allocate memory, a naive
implementation would perform multiple allocations and deallocations for
every snippet of locale-specific text that needs to be converted to
UTF-8. To avoid that, a new internal locale::facet is defined to store
the text_encoding and an iconv_t descriptor, which are then cached in
the formatting locale. This requires access to the internals of a
std::locale object in src/c++20/format.cc, so that new file needs to be
compiled with -fno-access-control, as well as -std=gnu++26 in order to
use std::text_encoding.

Because the new std::text_encoding and std::locale::encoding() symbols
are only in the libstdc++exp.a archive, we need to include
src/c++26/text_encoding.cc in the main library, but not export its
symbols yet. This means they can be used by the two new functions which
are exported from the main library.

The encoding conversions are done for C++20, treating it as a DR that
resolves LWG 3656.

With this change we can increase the value of the __cpp_lib_format macro
for C++23. The value should be 202207 for P2419R2, but we already
implement P2510R3 (Formatting pointers) so can use the value 202304.

libstdc++-v3/ChangeLog:

PR libstdc++/109162
* acinclude.m4 (libtool_VERSION): Update to 6:34:0.
* config/abi/pre/gnu.ver: Disambiguate old patters. Add new
GLIBCXX_3.4.34 symbol version and new exports.
* configure: Regenerate.
* include/bits/chrono_io.h (_ChronoSpec::_M_locale_specific):
Add new accessor functions to use a reserved bit in _Spec.
(__formatter_chrono::_M_parse): Use _M_locale_specific(true)
when chrono-specs contains locale-dependent conversion
specifiers.
(__formatter_chrono::_M_format): Open iconv descriptor if
conversion to UTF-8 will be needed.
(__formatter_chrono::_M_write): New function to write a
localized string with possible character conversion.
(__formatter_chrono::_M_a_A, __formatter_chrono::_M_b_B)
(__formatter_chrono::_M_p, __formatter_chrono::_M_r)
(__formatter_chrono::_M_x, __formatter_chrono::_M_X)
(__formatter_chrono::_M_locale_fmt): Use _M_write.
* include/bits/version.def (format): Update value.
* include/bits/version.h: Regenerate.
* include/std/format (_GLIBCXX_P2518R3): Check feature test
macro instead of __cplusplus.
(basic_format_context): Declare __formatter_chrono as friend.
* src/c++20/Makefile.am: Add new file.
* src/c++20/Makefile.in: Regenerate.
* src/c++20/format.cc: New file.
* testsuite/std/time/format_localized.cc: New test.
* testsuite/util/testsuite_abi.cc: Add new symbol version.

2 months agotestsuite: fix dg-require-* order vs dg-additional-sources
Sam James [Tue, 30 Jul 2024 21:01:42 +0000 (22:01 +0100)]
testsuite: fix dg-require-* order vs dg-additional-sources

Per gccint, 'dg-require-*' must come before any
'dg-additional-sources' directives. Fix a handful of deviant cases.

* gcc.dg/tree-prof/crossmodule-indir-call-topn-1.c: Fix dg-require-profiling
directive order.
* gcc.dg/tree-prof/crossmodule-indir-call-topn-2.c: Likewise.

2 months agotestsuite: fix dg-require-effective-target order vs dg-additional-sources
Sam James [Tue, 30 Jul 2024 20:55:30 +0000 (21:55 +0100)]
testsuite: fix dg-require-effective-target order vs dg-additional-sources

Per gccint, 'dg-require-effective-target' must come before any
'dg-additional-sources' directives. Fix a handful of deviant cases.

gcc/testsuite/ChangeLog:
* gcc.target/aarch64/aapcs64/func-ret-3.c: Fix dg-require-effective-target directive order.
* gcc.target/aarch64/aapcs64/func-ret-4.c: Likewise.
* gfortran.dg/PR100914.f90: Likewise.

libgomp/ChangeLog:
* testsuite/libgomp.c++/pr24455.C: Fix dg-require-effective-target directive order.
* testsuite/libgomp.c/pr24455.c: Likewise.

2 months agotestsuite: fix 'dg-do-preprocess' typo
Sam James [Tue, 30 Jul 2024 20:46:29 +0000 (21:46 +0100)]
testsuite: fix 'dg-do-preprocess' typo

We want 'dg-do preprocess', not 'dg-do-preprocess'. Fix that.

PR target/106828
* g++.target/loongarch/pr106828.C: Fix 'dg-do compile' typo.

2 months agotestsuite: fix 'dg-do-compile' typos
Sam James [Tue, 30 Jul 2024 20:44:12 +0000 (21:44 +0100)]
testsuite: fix 'dg-do-compile' typos

We want 'dg-do compile', not 'dg-do-compile'. Fix that.

PR target/69194
PR c++/92024
PR c++/110057
* c-c++-common/Wshadow-1.c: Fix 'dg-do compile' typo.
* g++.dg/tree-ssa/devirt-array-destructor-1.C: Likewise.
* g++.dg/tree-ssa/devirt-array-destructor-2.C: Likewise.
* gcc.target/arm/pr69194.c: Likewise.

2 months agotestsuite: libgomp: fix dg-do run typo
Sam James [Thu, 18 Jul 2024 02:42:44 +0000 (03:42 +0100)]
testsuite: libgomp: fix dg-do run typo

'dg-run' is not a valid dejagnu directive, 'dg-do run' is needed here
for the test to be executed.

That said, it actually seems to be executed for me anyway, presumably
a default in the directory, but let's fix it to be consistent with
other uses in the tree and in that test directory even.

libgomp/ChangeLog:
* testsuite/libgomp.c++/declare-target-indirect-1.C: Fix 'dg-run' typo.

2 months agoaarch64: Add fpm register helper functions.
Claudio Bantaloukas [Wed, 31 Jul 2024 13:42:41 +0000 (14:42 +0100)]
aarch64: Add fpm register helper functions.

The ACLE declares several helper types and functions to facilitate construction
of `fpm` arguments. These are available when one of the arm_neon.h, arm_sve.h,
or arm_sme.h headers is included. These helpers don't map to specific FP8
instructions and there's no expectation that they will produce a given code
sequence, they're just an abstraction and an aid to the programmer. Thus they are
implemented in a new header file arm_private_fp8.h
Users are not expected to include this file, as it is a mere implementation detail,
subject to change. A check is included to guard against direct inclusion.

gcc/ChangeLog:

* config.gcc (extra_headers): Install arm_private_fp8.h.
* config/aarch64/arm_neon.h: Include arm_private_fp8.h.
* config/aarch64/arm_sve.h: Likewise.
* config/aarch64/arm_private_fp8.h: New file
(fpm_t): New type representing fpmr values.
(enum __ARM_FPM_FORMAT): New enum representing valid fp8 formats.
(enum __ARM_FPM_OVERFLOW): New enum representing how some fp8
calculations work.
(__arm_fpm_init): New.
(__arm_set_fpm_src1_format): Likewise.
(__arm_set_fpm_src2_format): Likewise.
(__arm_set_fpm_dst_format): Likewise.
(__arm_set_fpm_overflow_cvt): Likewise.
(__arm_set_fpm_overflow_mul): Likewise.
(__arm_set_fpm_lscale): Likewise.
(__arm_set_fpm_lscale2): Likewise.
(__arm_set_fpm_nscale): Likewise.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/acle/fp8-helpers-neon.c: New test of fpmr helper
functions.
* gcc.target/aarch64/acle/fp8-helpers-sve.c: New test of fpmr helper
functions presence.
* gcc.target/aarch64/acle/fp8-helpers-sme.c: New test of fpmr helper
functions presence.

2 months agoaarch64: Add support for moving fpm system register
Claudio Bantaloukas [Wed, 31 Jul 2024 13:42:40 +0000 (14:42 +0100)]
aarch64: Add support for moving fpm system register

Unlike most system registers, fpmr can be heavily written to in code that
exercises the fp8 functionality. That is because every fp8 instrinsic call
can potentially change the value of fpmr.
Rather than just use an unspec, we treat the fpmr system register like
all other registers and use a move operation to read and write to it.

We introduce a new class of moveable system registers that, currently,
only accepts fpmr and a new constraint, Umv, that allows us to
selectively use mrs and msr instructions when expanding rtl for them.
Given that there is code that depends on "real" registers coming before
"fake" ones, we introduce a new constant FPM_REGNUM that uses an
existing value and renumber registers below that.
This requires us to update the bitmaps that describe which registers
belong to each register class.

gcc/ChangeLog:

* config/aarch64/aarch64.cc (aarch64_hard_regno_nregs): Add
support for MOVEABLE_SYSREGS class.
(aarch64_hard_regno_mode_ok): Allow reads and writes to fpmr.
(aarch64_regno_regclass): Support MOVEABLE_SYSREGS class.
(aarch64_class_max_nregs): Likewise.
* config/aarch64/aarch64.h (FIXED_REGISTERS): add fpmr.
(CALL_REALLY_USED_REGISTERS): Likewise.
(REGISTER_NAMES): Likewise.
(enum reg_class): Add MOVEABLE_SYSREGS class.
(REG_CLASS_NAMES): Likewise.
(REG_CLASS_CONTENTS): Update class bitmaps to deal with fpmr,
the new MOVEABLE_REGS class and renumbering of registers.
* config/aarch64/aarch64.md: (FPM_REGNUM): added new register
number, reusing old value.
(FFR_REGNUM): Renumber.
(FFRT_REGNUM): Likewise.
(LOWERING_REGNUM): Likewise.
(TPIDR2_BLOCK_REGNUM): Likewise.
(SME_STATE_REGNUM): Likewise.
(TPIDR2_SETUP_REGNUM): Likewise.
(ZA_FREE_REGNUM): Likewise.
(ZA_SAVED_REGNUM): Likewise.
(ZA_REGNUM): Likewise.
(ZT0_REGNUM): Likewise.
(*mov<mode>_aarch64): Add support for moveable sysregs.
(*movsi_aarch64): Likewise.
(*movdi_aarch64): Likewise.
* config/aarch64/constraints.md (MOVEABLE_SYSREGS): New constraint.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/acle/fp8.c: New tests.

2 months agoaarch64: Add march flags for +fp8 arch extensions
Claudio Bantaloukas [Wed, 31 Jul 2024 13:42:39 +0000 (14:42 +0100)]
aarch64: Add march flags for +fp8 arch extensions

This introduces the relevant flags to enable access to the fpmr register and fp8 intrinsics, which will be added subsequently.

gcc/ChangeLog:

* config/aarch64/aarch64-option-extensions.def (fp8): New.
* config/aarch64/aarch64.h (TARGET_FP8): Likewise.
* doc/invoke.texi (AArch64 Options): Document new -march flags
and extensions.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/acle/fp8.c: New test.

2 months agoc++: array new with value-initialization, again [PR115645]
Marek Polacek [Wed, 17 Jul 2024 19:44:26 +0000 (15:44 -0400)]
c++: array new with value-initialization, again [PR115645]

Unfortunately, my r15-1946 fix broke the attached testcase; the
constexpr evaluation reported an error about not being able to
evaluate the code emitted by build_vec_init.  Jason figured out
it's because we were wrongly setting try_const to false, where
in fact it should have been true.  Value-initialization of scalars
is constexpr, so we should check that alongside of
type_has_constexpr_default_constructor.

PR c++/115645

gcc/cp/ChangeLog:

* init.cc (build_vec_init): When initializing a scalar type, try to
create a constant initializer.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/constexpr-new23.C: New test.

2 months agotestsuite: Adjust switch-exp-transform-3.c for 32bit
Filip Kastl [Wed, 31 Jul 2024 11:40:45 +0000 (13:40 +0200)]
testsuite: Adjust switch-exp-transform-3.c for 32bit

32bit x86 CPUs won't natively support the FFS operation on a 64 bit
type.  Therefore, I'm setting the long long int part of the
switch-exp-transform-3.c test to only execute with 64bit targets.

gcc/testsuite/ChangeLog:

* gcc.target/i386/switch-exp-transform-3.c: Set the long long
int test to only execute with 64bit targets.

Signed-off-by: Filip Kastl <fkastl@suse.cz>
2 months agoLoongArch: Rework bswap{hi,si,di}2 definition
Xi Ruoyao [Sun, 28 Jul 2024 11:57:02 +0000 (19:57 +0800)]
LoongArch: Rework bswap{hi,si,di}2 definition

Per a gcc-help thread we are generating sub-optimal code for
__builtin_bswap{32,64}.  To fix it:

- Use a single revb.d instruction for bswapdi2.
- Use a single revb.2w instruction for bswapsi2 for TARGET_64BIT,
  revb.2h + rotri.w for !TARGET_64BIT.
- Use a single revb.2h instruction for bswapsi2 (x) r>> 16, and a single
  revb.2w instruction for bswapdi2 (x) r>> 32.

Unfortunately I cannot figure out a way to make the compiler generate
revb.4h or revh.{2w,d} instructions.

gcc/ChangeLog:

* config/loongarch/loongarch.md (UNSPEC_REVB_2H, UNSPEC_REVB_4H,
UNSPEC_REVH_D): Remove UNSPECs.
(revb_4h, revh_d): Remove define_insn.
(revb_2h): Define as (rotatert:SI (bswap:SI x) 16) instead of
an UNSPEC.
(revb_2h_extend, revb_2w, *bswapsi2, bswapdi2): New define_insn.
(bswapsi2): Change to define_expand.  Only expand to revb.2h +
rotri.w if !TARGET_64BIT.
(bswapdi2): Change to define_insn of which the output is just a
revb.d instruction.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/revb.c: New test.

2 months agoLoongArch: Relax ins_zero_bitmask_operand and remove and<mode>3_align
Xi Ruoyao [Sun, 28 Jul 2024 09:02:49 +0000 (17:02 +0800)]
LoongArch: Relax ins_zero_bitmask_operand and remove and<mode>3_align

In r15-1207 I was too stupid to realize we just need to relax
ins_zero_bitmask_operand to allow using bstrins for aligning, instead of
adding a new split.  And, "> 12" in ins_zero_bitmask_operand also makes
no sense: it rejects bstrins for things like "x & ~4l" with no good
reason.

So fix my errors now.

gcc/ChangeLog:

* config/loongarch/predicates.md (ins_zero_bitmask_operand):
Cover more cases that bstrins can benefit.
(high_bitmask_operand): Remove.
* config/loongarch/constraints.md (Yy): Remove.
* config/loongarch/loongarch.md (and<mode>3_align): Remove.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/bstrins-4.c: New test.

2 months agomiddle-end/101478 - ICE with degenerate address during gimplification
Richard Biener [Wed, 31 Jul 2024 08:07:45 +0000 (10:07 +0200)]
middle-end/101478 - ICE with degenerate address during gimplification

When we gimplify &MEM[0B + 4] we are re-folding the address in case
types are not canonical which ends up with a constant address that
recompute_tree_invariant_for_addr_expr ICEs on.  Properly guard
that call.

PR middle-end/101478
* gimplify.cc (gimplify_addr_expr): Check we still have an
ADDR_EXPR before calling recompute_tree_invariant_for_addr_expr.

* gcc.dg/pr101478.c: New testcase.

2 months agoi386: Mark target option with optimization when enabled with opt level [PR116065]
Hongyu Wang [Fri, 26 Jul 2024 00:27:01 +0000 (08:27 +0800)]
i386: Mark target option with optimization when enabled with opt level [PR116065]

When introducing munroll-only-small-loops, the option was marked as
Target Save and added to -O2 default which makes attribute(optimize)
resets target option and causing error when cmdline has O1 and
funciton attribute has O2 and other target options. Mark this option
as Optimization to fix.

gcc/ChangeLog

PR target/116065
* config/i386/i386.opt (munroll-only-small-loops): Mark as
Optimization instead of Save.

gcc/testsuite/ChangeLog

PR target/116065
* gcc.target/i386/pr116065.c: New test.

2 months agorecog: Disallow subregs in mode-punned value [PR115881]
Richard Sandiford [Wed, 31 Jul 2024 08:23:35 +0000 (09:23 +0100)]
recog: Disallow subregs in mode-punned value [PR115881]

In g:9d20529d94b23275885f380d155fe8671ab5353a, I'd extended
insn_propagation to handle simple cases of hard-reg mode punning.
The punned "to" value was created using simplify_subreg rather
than simplify_gen_subreg, on the basis that hard-coded subregs
aren't generally useful after RA (where hard-reg propagation is
expected to happen).

This PR is about a case where the subreg gets pushed into the
operands of a plus, but the subreg on one of the operands
cannot be simplified.  Specifically, we have to generate
(subreg:SI (reg:DI sp) 0) rather than (reg:SI sp), since all
references to the stack pointer must be via stack_pointer_rtx.

However, code in x86 (reasonably) expects no subregs of registers
to appear after RA, except for special cases like strict_low_part.
This leads to an awkward situation where we can't ban subregs of sp
(because of the strict_low_part use), can't allow direct references
to sp in other modes (because of the stack_pointer_rtx requirement),
and can't allow rvalue uses of the subreg (because of the "no subregs
after RA" assumption).  It all seems a bit of a mess...

I sat on this for a while in the hope that a clean solution might
become apparent, but in the end, I think we'll just have to check
manually for nested subregs and punt on them.

gcc/
PR rtl-optimization/115881
* recog.cc: Include rtl-iter.h.
(insn_propagation::apply_to_rvalue_1): Check that the result
of simplify_subreg does not include nested subregs.

gcc/testsuite/
PR rtl-optimization/115881
* gcc.c-torture/compile/pr115881.c: New test.

2 months agors6000: Relax some FLOAT128 expander condition for FLOAT128_IEEE_P [PR105359]
Kewen Lin [Wed, 31 Jul 2024 02:21:15 +0000 (21:21 -0500)]
rs6000: Relax some FLOAT128 expander condition for FLOAT128_IEEE_P [PR105359]

As PR105359 shows, we disable some FLOAT128 expanders for
64-bit long double, but in fact IEEE float128 types like
__ieee128 are only guarded with TARGET_FLOAT128_TYPE and
TARGET_LONG_DOUBLE_128 is only checked when determining if
we can reuse long_double_type_node.  So this patch is to
relax all affected FLOAT128 expander conditions for
FLOAT128_IEEE_P.  By the way, currently IBM double double
type __ibm128 is guarded by TARGET_LONG_DOUBLE_128, so we
have to use TARGET_LONG_DOUBLE_128 for it.  IMHO, it's not
necessary and can be enhanced later.

Btw, for all test cases mentioned in PR105359, I removed
the xfails and tested them with explicit -mlong-double-64,
both pr79004.c and float128-hw.c are tested well and
float128-hw4.c isn't tested (unsupported due to 64 bit
long double conflicts with -mabi=ieeelongdouble).

PR target/105359

gcc/ChangeLog:

* config/rs6000/rs6000.md (@extenddf<FLOAT128:mode>2): Don't check
TARGET_LONG_DOUBLE_128 for FLOAT128_IEEE_P modes.
(extendsf<FLOAT128:mode>2): Likewise.
(trunc<FLOAT128:mode>df2): Likewise.
(trunc<FLOAT128:mode>sf2): Likewise.
(floatsi<FLOAT128:mode>2): Likewise.
(fix_trunc<FLOAT128:mode>si2): Likewise.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/pr79004.c: Remove xfails.

2 months agors6000: Use standard name uabd for absdu insns
Kewen Lin [Wed, 31 Jul 2024 02:20:51 +0000 (21:20 -0500)]
rs6000: Use standard name uabd for absdu insns

r14-1832 adds recognition pattern, ifn and optab for ABD
(ABsolute Difference), we have some vector absolute
difference unsigned instructions since ISA 3.0, as the
associated test cases shown, they are not exploited well
as we don't define it (them) with a standard name.  So this
patch is to rename it with standard name first.  And it
merges both define_expand and define_insn as a separated
define_expand isn't needed.  Besides, it adjusts the RTL
pattern by using generic umax and umin rather than
UNSPEC_VADU, it's more meaningful and can catch umin/umax
opportunity.

gcc/ChangeLog:

* config/rs6000/altivec.md (p9_vadu<mode>3): Rename to ...
(uabd<mode>3): ... this.  Update RTL pattern with umin and umax rather
than UNSPEC_VADU.
(vadu<mode>3): Remove.
(UNSPEC_VADU): Remove.
(usadv16qi): Replace gen_p9_vaduv16qi3 with gen_uabdv16qi3.
(usadv8hi): Replace gen_p9_vaduv8hi3 with gen_uabdv8hi3.
* config/rs6000/rs6000-builtins.def (__builtin_altivec_vadub): Replace
expander with uabdv16qi3.
(__builtin_altivec_vaduh): Adjust expander with uabdv8hi3.
(__builtin_altivec_vaduw): Adjust expander with uabdv4si3.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/abd-vectorize-1.c: New test.
* gcc.target/powerpc/abd-vectorize-2.c: New test.

2 months agoLoongArch: Expand some SImode operations through "si3_extend" instructions if TARGET_...
Xi Ruoyao [Sat, 20 Jul 2024 12:38:13 +0000 (20:38 +0800)]
LoongArch: Expand some SImode operations through "si3_extend" instructions if TARGET_64BIT

We already had "si3_extend" insns and we hoped the fwprop or combine
passes can use them to remove unnecessary sign extensions.  But this
does not always work: for cases like x << 1 | y, the compiler
tends to do

    (sign_extend:DI
      (ior:SI (ashift:SI (reg:SI $r4)
                         (const_int 1))
              (reg:SI $r5)))

instead of

    (ior:DI (sign_extend:DI (ashift:SI (reg:SI $r4) (const_int 1)))
            (sign_extend:DI (reg:SI $r5)))

So we cannot match the ashlsi3_extend instruction here and we get:

    slli.w $r4,$r4,1
    or     $r4,$r5,$r4
    slli.w $r4,$r4,0    # <= redundant
    jr    $r1

To eliminate this redundant extension we need to turn SImode shift etc.
to DImode "si3_extend" operations earlier, when we expand the SImode
operation.  We are already doing this for addition, now do it for
shifts, rotates, substract, multiplication, division, and modulo as
well.

The bytepick.w definition for TARGET_64BIT needs to be adjusted so it
won't be undone by the shift expanding.

gcc/ChangeLog:

* config/loongarch/loongarch.md (optab): Add (rotatert "rotr").
(<optab:any_shift><mode>3, <optab:any_div><mode>3,
sub<mode>3, rotr<mode>3, mul<mode>3): Add a "*" to the insn name
so we can redefine the names with define_expand.
(*<optab:any_shift>si3_extend): Remove "*" so we can use them
in expanders.
(*subsi3_extended, *mulsi3_extended): Likewise, also remove the
trailing "ed" for consistency.
(*<optab:any_div>si3_extended): Add mode for sign_extend to
prevent an ICE using it in expanders.
(shift_w, arith_w): New define_code_iterator.
(<optab:any_w><mode>3): New define_expand.  Expand with
<optab:any_w>si3_extend for SImode if TARGET_64BIT.
(<optab:arith_w><mode>3): Likewise.
(mul<mode>3): Expand to mulsi3_extended for SImode if
TARGET_64BIT and ISA_HAS_DIV32.
(<optab:any_div><mode>3): Expand to <optab:any_div>si3_extended
for SImode if TARGET_64BIT.
(rotl<mode>3): Expand to rotrsi3_extend for SImode if
TARGET_64BIT.
(bytepick_w_<bytepick_imm>): Add mode for lshiftrt and ashift.
(bitsize, bytepick_imm, bytepick_w_ashift_amount): New
define_mode_attr.
(bytepick_w_<bytepick_imm>_extend): Adjust for the RTL change
caused by 32-bit shift expanding.  Now bytepick_imm only covers
2 and 3, separate one remaining case to ...
(bytepick_w_1_extend): ... here, new define_insn.

gcc/testsuite/ChangeLog:

* gcc.target/loongarch/bitwise_extend.c: New test.

2 months agoDaily bump.
GCC Administrator [Wed, 31 Jul 2024 00:19:44 +0000 (00:19 +0000)]
Daily bump.

2 months agolibstdc++: Fix formatter for low-resolution chrono::zoned_time (LWG 4124)
Jonathan Wakely [Mon, 29 Jul 2024 11:52:40 +0000 (12:52 +0100)]
libstdc++: Fix formatter for low-resolution chrono::zoned_time (LWG 4124)

This implements the proposed resolution of LWG 4124, so that
low-resolution chrono::zoned_time objects can be formatted. The
formatter for zoned_time<D, P> needs to account for get_local_time
returning local_time<common_type_t<D, seconds>> not local_time<D>.

libstdc++-v3/ChangeLog:

* include/bits/chrono_io.h (__local_time_fmt_for): New alias
template.
(formatter<zoned_time<D, P>>): Use __local_time_fmt_for.
* testsuite/std/time/zoned_time/io.cc: Check zoned_time<minutes>
can be formatted.

2 months agolibstdc++: Fix std::format output for std::chrono::zoned_time
Jonathan Wakely [Fri, 26 Jul 2024 17:11:26 +0000 (18:11 +0100)]
libstdc++: Fix std::format output for std::chrono::zoned_time

When formatting a chrono::zoned_time with an empty chrono-specs, we were
only formatting its _M_time member, but the ostream insertion operator
uses the format "{:L%F %T %Z}" which includes the time zone
abbreviation. The %Z should also be used when formatting with an empty
chrono-specs.

This commit makes _M_format_to_ostream handle __local_time_fmt
specializations directly, rather than calling itself recursively to
format the _M_time member. We need to be able to customize the output of
_M_format_to_ostream for __local_time_fmt, because we use that type for
gps_time and tai_time as well as for zoned_time and __local_time_fmt.
When formatting gps_time and tai_time we don't want to include the time
zone abbreviation in the "{}" output, but for zoned_time we do want to.
We can reuse the __is_neg flag passed to _M_format_to_ostream (via
_M_format) to say that we want the time zone abbreviation.  Currently
the __is_neg flag is only used for duration specializations, so it's
available for __local_time_fmt to use.

In addition to fixing the zoned_time output to use %Z, this commit also
changes the __local_time_fmt output to use %Z. Previously it didn't use
it, just like zoned_time.  The standard doesn't actually say how to
format local-time-format-t for an empty chrono-specs, but this behaviour
seems sensible and is what I'm proposing as part of LWG 4124.

While testing this I noticed that some chrono types were not being
tested with empty chrono-specs, so this adds more tests. I also noticed
that std/time/clock/local/io.cc was testing tai_time instead of
local_time, which was completely wrong. That's fixed now too.

libstdc++-v3/ChangeLog:

* include/bits/chrono_io.h (__local_fmt_t): Remove unused
declaration.
(__formatter_chrono::_M_format_to_ostream): Add explicit
handling for specializations of __local_time_fmt, including the
time zone abbreviation in the output if __is_neg is true.
(formatter<chrono::tai_time<D>>::format): Add comment.
(formatter<chrono::gps_time<D>>::format): Likewise.
(formatter<chrono::__detail::__local_time_fmt::format): Call
_M_format with true for the __is_neg flag.
* testsuite/std/time/clock/gps/io.cc: Remove unused variable.
* testsuite/std/time/clock/local/io.cc: Fix test error that
checked tai_time instead of local_time. Add tests for
local-time-format-t formatting.
* testsuite/std/time/clock/system/io.cc: Check empty
chrono-specs.
* testsuite/std/time/clock/tai/io.cc: Likewise.
* testsuite/std/time/zoned_time/io.cc: Likewise.

2 months agolibstdc++: Implement LWG 3886 for std::optional and std::expected
Jonathan Wakely [Thu, 25 Jul 2024 22:08:14 +0000 (23:08 +0100)]
libstdc++: Implement LWG 3886 for std::optional and std::expected

This uses remove_cv_t<T> for the default template argument used for
deducing a type for a braced-init-list used with std::optional and
std::expected.

libstdc++-v3/ChangeLog:

* include/std/expected (expected(U&&), operator=(U&&))
(value_or): Use remove_cv_t on default template argument, as per
LWG 3886.
* include/std/optional (optional(U&&), operator=(U&&))
(value_or): Likewise.
* testsuite/20_util/expected/lwg3886.cc: New test.
* testsuite/20_util/optional/cons/lwg3886.cc: New test.

2 months agotestsuite: fix 'dg-compile' typos
Sam James [Tue, 30 Jul 2024 19:04:40 +0000 (20:04 +0100)]
testsuite: fix 'dg-compile' typos

'dg-compile' is not a thing, replace it with 'dg-do compile'.

PR target/68015
PR c++/83979
* c-c++-common/goacc/loop-shape.c: Fix 'dg-compile' typo.
* g++.dg/pr83979.C: Likewise.
* g++.target/aarch64/sve/acle/general-c++/attributes_2.C: Likewise.
* gcc.dg/tree-ssa/builtin-sprintf-7.c: Likewise.
* gcc.dg/tree-ssa/builtin-sprintf-8.c: Likewise.
* gcc.target/riscv/amo/zabha-rvwmo-all-amo-ops-char.c: Likewise.
* gcc.target/riscv/amo/zabha-rvwmo-all-amo-ops-short.c: Likewise.
* gcc.target/s390/20181024-1.c: Likewise.
* gcc.target/s390/addr-constraints-1.c: Likewise.
* gcc.target/s390/arch12/aghsghmgh-1.c: Likewise.
* gcc.target/s390/arch12/mul-1.c: Likewise.
* gcc.target/s390/arch13/bitops-1.c: Likewise.
* gcc.target/s390/arch13/bitops-2.c: Likewise.
* gcc.target/s390/arch13/fp-signedint-convert-1.c: Likewise.
* gcc.target/s390/arch13/fp-unsignedint-convert-1.c: Likewise.
* gcc.target/s390/arch13/popcount-1.c: Likewise.
* gcc.target/s390/pr68015.c: Likewise.
* gcc.target/s390/vector/fp-signedint-convert-1.c: Likewise.
* gcc.target/s390/vector/fp-unsignedint-convert-1.c: Likewise.
* gcc.target/s390/vector/reverse-elements-1.c: Likewise.
* gcc.target/s390/vector/reverse-elements-2.c: Likewise.
* gcc.target/s390/vector/reverse-elements-3.c: Likewise.
* gcc.target/s390/vector/reverse-elements-4.c: Likewise.
* gcc.target/s390/vector/reverse-elements-5.c: Likewise.
* gcc.target/s390/vector/reverse-elements-6.c: Likewise.
* gcc.target/s390/vector/reverse-elements-7.c: Likewise.
* gnat.dg/alignment15.adb: Likewise.
* gnat.dg/debug4.adb: Likewise.
* gnat.dg/inline21.adb: Likewise.
* gnat.dg/inline22.adb: Likewise.
* gnat.dg/opt37.adb: Likewise.
* gnat.dg/warn13.adb: Likewise.

2 months agolibstdc++: Fix name of source file in comment
Jonathan Wakely [Tue, 30 Jul 2024 14:42:04 +0000 (15:42 +0100)]
libstdc++: Fix name of source file in comment

libstdc++-v3/ChangeLog:

* src/c++17/fs_ops.cc: Fix file name in comment.

2 months agoi386/testsuite: Add testcase for fixed PR [PR51492]
Uros Bizjak [Tue, 30 Jul 2024 18:02:36 +0000 (20:02 +0200)]
i386/testsuite: Add testcase for fixed PR [PR51492]

PR target/51492

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr51492.c: New test.

2 months agoRISC-V: Add configure check for B extention support
Edwin Lu [Wed, 24 Jul 2024 23:37:18 +0000 (16:37 -0700)]
RISC-V: Add configure check for B extention support

Binutils 2.42 and before don't recognize the b extension in the march
strings even though it supports zba_zbb_zbs. Add a configure check to
ignore the b in the march string if found.

gcc/ChangeLog:

* common/config/riscv/riscv-common.cc (riscv_subset_list::to_string):
Skip b in march string
* config.in: Regenerate.
* configure: Regenerate.
* configure.ac: Add B assembler check

Signed-off-by: Edwin Lu <ewlu@rivosinc.com>
2 months agotestsuite: fix whitespace in dg-require-effective-target directives
Sam James [Tue, 30 Jul 2024 16:23:08 +0000 (17:23 +0100)]
testsuite: fix whitespace in dg-require-effective-target directives

PR middle-end/54400
PR target/98161
* gcc.dg/vect/bb-slp-layout-18.c: Fix whitespace in dg directive.
* gcc.dg/vect/bb-slp-pr54400.c: Likewise.
* gcc.target/i386/pr98161.c: Likewise.

2 months agogimple ssa: Teach switch conversion to optimize powers of 2 switches
Filip Kastl [Tue, 30 Jul 2024 16:40:29 +0000 (18:40 +0200)]
gimple ssa: Teach switch conversion to optimize powers of 2 switches

Sometimes a switch has case numbers that are powers of 2.  Switch
conversion usually isn't able to optimize these switches.  This patch
adds "exponential index transformation" to switch conversion.  After
switch conversion applies this transformation on the switch the index
variable of the switch becomes the exponent instead of the whole value.
For example:

switch (i)
  {
    case (1 << 0): return 0;
    case (1 << 1): return 1;
    case (1 << 2): return 2;
    ...
    case (1 << 30): return 30;
    default: return 31;
  }

gets transformed roughly into

switch (log2(i))
  {
    case 0: return 0;
    case 1: return 1;
    case 2: return 2;
    ...
    case 30: return 30;
    default: return 31;
  }

This enables switch conversion to further optimize the switch.

This patch only enables this transformation if there are optabs for FFS
so that the base 2 logarithm can be computed efficiently at runtime.

gcc/ChangeLog:

* tree-switch-conversion.cc (can_log2): New static function to
check if gen_log2 can be used on current target.
(gen_log2): New static function to generate efficient GIMPLE
code for taking an exact base 2 log.
(gen_pow2p): New static function to generate efficient GIMPLE
code for checking if a value is a power of 2.
(switch_conversion::switch_conversion): Track if the
transformation happened.
(switch_conversion::is_exp_index_transform_viable): New function
to decide whether the transformation should be applied.
(switch_conversion::exp_index_transform): New function to
execute the transformation.
(switch_conversion::gen_inbound_check): Don't remove the default
BB if the transformation happened.
(switch_conversion::expand): Execute the transform if it is
viable.  Skip the "sufficiently small case range" test if the
transformation is going to be executed.
* tree-switch-conversion.h: Add is_exp_index_transform_viable
and exp_index_transform.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/switch-3.c: Disable switch conversion.
* gcc.target/i386/switch-exp-transform-1.c: New test.
* gcc.target/i386/switch-exp-transform-2.c: New test.
* gcc.target/i386/switch-exp-transform-3.c: New test.

Signed-off-by: Filip Kastl <fkastl@suse.cz>
2 months agolibbacktrace: fix syntax of Windows registration functions
Ian Lance Taylor [Tue, 30 Jul 2024 16:25:03 +0000 (09:25 -0700)]
libbacktrace: fix syntax of Windows registration functions

Adjust the syntax to keep MSVC happy.

Fixes https://github.com/ianlancetaylor/libbacktrace/issues/131

* pecoff.c (LDR_DLL_NOTIFICATION): Put function modifier
inside parentheses.
(LDR_REGISTER_FUNCTION): Likewise.

2 months agotestsuite: fix whitespace in dg-do assemble directive
Sam James [Tue, 30 Jul 2024 16:10:01 +0000 (17:10 +0100)]
testsuite: fix whitespace in dg-do assemble directive

* gcc.target/aarch64/simd/vmmla.c: Fix whitespace in dg directive.

2 months agotestsuite: fix whitespace in dg-do preprocess directive
Sam James [Tue, 30 Jul 2024 11:21:42 +0000 (12:21 +0100)]
testsuite: fix whitespace in dg-do preprocess directive

PR preprocessor/90581
* c-c++-common/cpp/fmax-include-depth.c: Fix whitespace in dg directive.

2 months agotestsuite: fix whitespace in dg-do compile directives
Sam James [Tue, 30 Jul 2024 11:20:47 +0000 (12:20 +0100)]
testsuite: fix whitespace in dg-do compile directives

Nothing seems to change here in reality at least on x86_64-pc-linux-gnu,
but important to fix nonetheless in case people copy it.

PR rtl-optimization/48633
PR tree-optimization/83072
PR tree-optimization/83073
PR tree-optimization/96542
PR tree-optimization/96707
PR tree-optimization/97567
PR target/69225
PR target/89929
PR target/96562
* g++.dg/pr48633.C: Fix whitespace in dg directive.
* g++.dg/pr96707.C: Likewise.
* g++.target/i386/mv28.C: Likewise.
* gcc.dg/Warray-bounds-flex-arrays-1.c: Likewise.
* gcc.dg/pr83072-2.c: Likewise.
* gcc.dg/pr83073.c: Likewise.
* gcc.dg/pr96542.c: Likewise.
* gcc.dg/pr97567-2.c: Likewise.
* gcc.target/i386/avx512fp16-11a.c: Likewise.
* gcc.target/i386/avx512fp16-13.c: Likewise.
* gcc.target/i386/avx512fp16-14.c: Likewise.
* gcc.target/i386/avx512fp16-conjugation-1.c: Likewise.
* gcc.target/i386/avx512fp16-neg-1a.c: Likewise.
* gcc.target/i386/avx512fp16-set1-pch-1a.c: Likewise.
* gcc.target/i386/avx512fp16vl-conjugation-1.c: Likewise.
* gcc.target/i386/avx512fp16vl-neg-1a.c: Likewise.
* gcc.target/i386/avx512fp16vl-set1-pch-1a.c: Likewise.
* gcc.target/i386/avx512vlfp16-11a.c: Likewise.
* gcc.target/i386/pr69225-1.c: Likewise.
* gcc.target/i386/pr69225-2.c: Likewise.
* gcc.target/i386/pr69225-3.c: Likewise.
* gcc.target/i386/pr69225-4.c: Likewise.
* gcc.target/i386/pr69225-5.c: Likewise.
* gcc.target/i386/pr69225-6.c: Likewise.
* gcc.target/i386/pr69225-7.c: Likewise.
* gcc.target/i386/pr96562-1.c: Likewise.
* gcc.target/riscv/rv32e_stack.c: Likewise.
* gfortran.dg/c-interop/removed-restrictions-3.f90: Likewise.
* gnat.dg/renaming1.adb: Likewise.

2 months agoRISC-V: Add basic support for the Zacas extension
Gianluca Guida [Mon, 29 Jul 2024 22:13:46 +0000 (15:13 -0700)]
RISC-V: Add basic support for the Zacas extension

This patch adds support for amocas.{b|h|w|d}. Support for amocas.q
(64/128 bit cas for rv32/64) will be added in a future patch.

Extension: https://github.com/riscv/riscv-zacas
Ratification: https://jira.riscv.org/browse/RVS-680

gcc/ChangeLog:

* common/config/riscv/riscv-common.cc: Add zacas extension.
* config/riscv/arch-canonicalize: Make zacas imply zaamo.
* config/riscv/riscv.opt: Add zacas.
* config/riscv/sync.md (zacas_atomic_cas_value<mode>): New pattern.
(atomic_compare_and_swap<mode>): Use new pattern for compare-and-swap ops.
(zalrsc_atomic_cas_value_strong<mode>): Rename atomic_cas_value_strong.
* doc/sourcebuild.texi: Add Zacas documentation.

gcc/testsuite/ChangeLog:

* lib/target-supports.exp: Add zacas testsuite infra support.
* gcc.target/riscv/amo/zalrsc-rvwmo-compare-exchange-int-acquire-release.c:
Remove zacas to continue to test the lr/sc pairs.
* gcc.target/riscv/amo/zalrsc-rvwmo-compare-exchange-int-acquire.c: Ditto.
* gcc.target/riscv/amo/zalrsc-rvwmo-compare-exchange-int-consume.c: Ditto.
* gcc.target/riscv/amo/zalrsc-rvwmo-compare-exchange-int-relaxed.c: Ditto.
* gcc.target/riscv/amo/zalrsc-rvwmo-compare-exchange-int-release.c: Ditto.
* gcc.target/riscv/amo/zalrsc-rvwmo-compare-exchange-int-seq-cst-relaxed.c: Ditto.
* gcc.target/riscv/amo/zalrsc-rvwmo-compare-exchange-int-seq-cst.c: Ditto.
* gcc.target/riscv/amo/zalrsc-ztso-compare-exchange-int-acquire-release.c: Ditto.
* gcc.target/riscv/amo/zalrsc-ztso-compare-exchange-int-acquire.c: Ditto.
* gcc.target/riscv/amo/zalrsc-ztso-compare-exchange-int-consume.c: Ditto.
* gcc.target/riscv/amo/zalrsc-ztso-compare-exchange-int-relaxed.c: Ditto.
* gcc.target/riscv/amo/zalrsc-ztso-compare-exchange-int-release.c: Ditto.
* gcc.target/riscv/amo/zalrsc-ztso-compare-exchange-int-seq-cst-relaxed.c: Ditto.
* gcc.target/riscv/amo/zalrsc-ztso-compare-exchange-int-seq-cst.c: Ditto.
* gcc.target/riscv/amo/zabha-zacas-preferred-over-zalrsc.c: New test.
* gcc.target/riscv/amo/zacas-char-requires-zabha.c: New test.
* gcc.target/riscv/amo/zacas-char-requires-zacas.c: New test.
* gcc.target/riscv/amo/zacas-preferred-over-zalrsc.c: New test.
* gcc.target/riscv/amo/zacas-rvwmo-compare-exchange-char-acq-rel.c: New test.
* gcc.target/riscv/amo/zacas-rvwmo-compare-exchange-char-acquire.c: New test.
* gcc.target/riscv/amo/zacas-rvwmo-compare-exchange-char-relaxed.c: New test.
* gcc.target/riscv/amo/zacas-rvwmo-compare-exchange-char-release.c: New test.
* gcc.target/riscv/amo/zacas-rvwmo-compare-exchange-char-seq-cst.c: New test.
* gcc.target/riscv/amo/zacas-rvwmo-compare-exchange-compatability-mapping-no-fence.c:
New test.
* gcc.target/riscv/amo/zacas-rvwmo-compare-exchange-compatability-mapping.cc: New test.
* gcc.target/riscv/amo/zacas-rvwmo-compare-exchange-int-acq-rel.c: New test.
* gcc.target/riscv/amo/zacas-rvwmo-compare-exchange-int-acquire.c: New test.
* gcc.target/riscv/amo/zacas-rvwmo-compare-exchange-int-relaxed.c: New test.
* gcc.target/riscv/amo/zacas-rvwmo-compare-exchange-int-release.c: New test.
* gcc.target/riscv/amo/zacas-rvwmo-compare-exchange-int-seq-cst.c: New test.
* gcc.target/riscv/amo/zacas-rvwmo-compare-exchange-short-acq-rel.c: New test.
* gcc.target/riscv/amo/zacas-rvwmo-compare-exchange-short-acquire.c: New test.
* gcc.target/riscv/amo/zacas-rvwmo-compare-exchange-short-relaxed.c: New test.
* gcc.target/riscv/amo/zacas-rvwmo-compare-exchange-short-release.c: New test.
* gcc.target/riscv/amo/zacas-rvwmo-compare-exchange-short-seq-cst.c: New test.
* gcc.target/riscv/amo/zacas-ztso-compare-exchange-char-seq-cst.c: New test.
* gcc.target/riscv/amo/zacas-ztso-compare-exchange-char.c: New test.
* gcc.target/riscv/amo/zacas-ztso-compare-exchange-compatability-mapping-no-fence.c:
New test.
* gcc.target/riscv/amo/zacas-ztso-compare-exchange-compatability-mapping.cc: New test.
* gcc.target/riscv/amo/zacas-ztso-compare-exchange-int-seq-cst.c: New test.
* gcc.target/riscv/amo/zacas-ztso-compare-exchange-int.c: New test.
* gcc.target/riscv/amo/zacas-ztso-compare-exchange-short-seq-cst.c: New test.
* gcc.target/riscv/amo/zacas-ztso-compare-exchange-short.c: New test.

Co-authored-by: Patrick O'Neill <patrick@rivosinc.com>
Tested-by: Andrea Parri <andrea@rivosinc.com>
Signed-Off-By: Gianluca Guida <gianluca@rivosinc.com>
2 months agoRISC-V: Remove configure check for zabha
Patrick O'Neill [Tue, 30 Jul 2024 02:52:02 +0000 (19:52 -0700)]
RISC-V: Remove configure check for zabha

This patch removes the zabha configure check since it's not a breaking change
and updates the existing zaamo/zalrsc comment.

gcc/ChangeLog:

* common/config/riscv/riscv-common.cc
(riscv_subset_list::to_string): Remove zabha configure check
handling and clarify zaamo/zalrsc comment.
* config.in: Regenerate.
* configure: Regenerate.
* configure.ac: Remove zabha configure check.

Signed-off-by: Patrick O'Neill <patrick@rivosinc.com>
2 months agolibstdc++: Fix overwriting files with fs::copy_file on Windows
Jonathan Wakely [Tue, 30 Jul 2024 09:55:55 +0000 (10:55 +0100)]
libstdc++: Fix overwriting files with fs::copy_file on Windows

There are no inode numbers on Windows filesystems, so stat_type::st_ino
is always zero and the check for equivalent files in do_copy_file was
incorrectly identifying distinct files as equivalent. This caused
copy_file to incorrectly report errors when trying to overwrite existing
files.

The fs::equivalent function already does the right thing on Windows, so
factor that logic out into a new function that can be reused by
fs::copy_file.

The tests for fs::copy_file were quite inadequate, so this also adds
checks for that function's error conditions.

libstdc++-v3/ChangeLog:

* src/c++17/fs_ops.cc (auto_win_file_handle): Change constructor
parameter from const path& to const wchar_t*.
(fs::equiv_files): New function.
(fs::equivalent): Use equiv_files.
* src/filesystem/ops-common.h (fs::equiv_files): Declare.
(do_copy_file): Use equiv_files.
* src/filesystem/ops.cc (fs::equiv_files): Define.
(fs::copy, fs::equivalent): Use equiv_files.
* testsuite/27_io/filesystem/operations/copy.cc: Test
overwriting directory contents recursively.
* testsuite/27_io/filesystem/operations/copy_file.cc: Test
overwriting existing files.

2 months agolibstdc++: Fix fs::hard_link_count behaviour on MinGW [PR113663]
Lennox Shou Hao Ho [Mon, 29 Jul 2024 20:09:27 +0000 (21:09 +0100)]
libstdc++: Fix fs::hard_link_count behaviour on MinGW [PR113663]

std::filesystem::hard_link_count() always returns 1 on
mingw-w64ucrt-11.0.1-r3 on Windows 10 19045

hard_link_count() queries _wstat64() on MinGW-w64
The MSFT documentation claims _wstat64() will always return 1 *non*-NTFS volumes
https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2013/14h5k7ff(v=vs.120)

My tests suggest that is not always true -
hard_link_count()/_wstat64() still returns 1 on NTFS.
GetFileInformationByHandle does return the correct result of 2.
Please see the PR for a minimal repro.

This patch changes the Windows implementation to always call
GetFileInformationByHandle.

PR libstdc++/113663

libstdc++-v3/ChangeLog:

* src/c++17/fs_ops.cc (fs::equivalent): Moved helper class
auto_handle to anonymous namespace as auto_win_file_handle.
(fs::hard_link_count): Changed Windows implementation to use
information provided by GetFileInformationByHandle which is more
reliable.
* testsuite/27_io/filesystem/operations/hard_link_count.cc: New
test.

Signed-off-by: "Lennox" Shou Hao Ho <lennoxhoe@gmail.com>
Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
2 months agoc++: diagnose usage of co_await and co_yield in default args [PR115906]
Arsen Arsenović [Wed, 24 Jul 2024 23:00:02 +0000 (01:00 +0200)]
c++: diagnose usage of co_await and co_yield in default args [PR115906]

This is a partial fix for PR115906.  Per [expr.await] 2s3, "An
await-expression shall not appear in a default argument
([dcl.fct.default])".  This patch introduces the diagnostic in that
case, and in the case of a co_yield (as co_yield is defined in terms of
co_await, so prerequisites of co_await hold).

PR c++/115906 - [coroutines] missing diagnostic and ICE when co_await used as default argument in function declaration

gcc/cp/ChangeLog:

PR c++/115906
* parser.cc (cp_parser_unary_expression): Reject await
expressions if use of local variables is currently forbidden.
(cp_parser_yield_expression): Reject yield expressions if use of
local variables is currently forbidden.

gcc/testsuite/ChangeLog:

PR c++/115906
* g++.dg/coroutines/pr115906-yield.C: New test.
* g++.dg/coroutines/pr115906.C: New test.
* g++.dg/coroutines/co-await-syntax-02-outside-fn.C: Don't rely
on default arguments.
* g++.dg/coroutines/co-yield-syntax-01-outside-fn.C: Ditto.

2 months agoc++: fix ICE on FUNCTION_DECLs inside coroutines [PR115906]
Arsen Arsenovic [Tue, 30 Jul 2024 11:42:56 +0000 (13:42 +0200)]
c++: fix ICE on FUNCTION_DECLs inside coroutines [PR115906]

When register_local_var_uses iterates a BIND_EXPRs BIND_EXPR_VARS, it
fails to account for the fact that FUNCTION_DECLs might be present, and
later passes it to DECL_HAS_VALUE_EXPR_P.  This leads to a tree check
failure in DECL_HAS_VALUE_EXPR_P:

  tree check: expected var_decl or parm_decl or result_decl, have
  function_decl in register_local_var_uses

We only care about PARM_DECL and VAR_DECL, so select only those.

PR c++/115906 - [coroutines] missing diagnostic and ICE when co_await used as default argument in function declaration

gcc/cp/ChangeLog:

PR c++/115906
* coroutines.cc (register_local_var_uses): Only process
PARM_DECL and VAR_DECLs.

gcc/testsuite/ChangeLog:

PR c++/115906
* g++.dg/coroutines/coro-function-decl.C: New test.

This page took 0.124125 seconds and 5 git commands to generate.