]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
3 months agogccrs: Fix narrowing conversion warnings
Owen Avery [Thu, 17 Apr 2025 02:53:18 +0000 (22:53 -0400)] 
gccrs: Fix narrowing conversion warnings

Fixes PR#119641

gcc/rust/ChangeLog:

* checks/errors/borrowck/rust-bir-place.h
(IndexVec::size_type): Add.
(IndexVec::MAX_INDEX): Add.
(IndexVec::size): Change the return type to the type of the
internal value used by the index type.
(PlaceDB::lookup_or_add_variable): Use the return value from the
PlaceDB::add_place call.
* checks/errors/borrowck/rust-bir.h
(struct BasicBlockId): Move this definition before the
definition of the struct Function.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
3 months agogccrs: Visit visibility in UseDeclaration
Pierre-Emmanuel Patry [Mon, 28 Apr 2025 11:05:49 +0000 (13:05 +0200)] 
gccrs: Visit visibility in UseDeclaration

Default visitor should visit all it's children.

gcc/rust/ChangeLog:

* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Visit visibility.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agogccrs: Some assorted tweaks and bug fixes
Owen Avery [Sat, 11 Jan 2025 05:15:05 +0000 (00:15 -0500)] 
gccrs: Some assorted tweaks and bug fixes

gcc/rust/ChangeLog:

* ast/rust-ast-visitor.cc
(DefaultASTVisitor::visit): Visit the loop labels of
WhileLetLoopExpr instances before visiting their scrutinee
expressions.
* resolve/rust-early-name-resolver-2.0.cc
(Early::resolve_glob_import): Pass the glob import's path
directly to NameResolutionContext::resolve_path.
* resolve/rust-toplevel-name-resolver-2.0.cc
(TopLevel::visit): Remove unnecessary call to
Identifier::as_string.
(flatten_glob): Improve handling of cases where a glob use tree
has no path.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
3 months agogccrs: Completely duplicate path node
Pierre-Emmanuel Patry [Fri, 25 Apr 2025 14:02:12 +0000 (16:02 +0200)] 
gccrs: Completely duplicate path node

Both nodes had the same id, this led to a resolution conflict.

gcc/rust/ChangeLog:

* expand/rust-derive-clone.cc (DeriveClone::clone_enum_struct): Clone
path to avoid using the same nodeid.

gcc/testsuite/ChangeLog:

* rust/compile/nr2/exclude: Remove now passing test from exclusion
list.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agogccrs: Use specialized param visit function for params
Pierre-Emmanuel Patry [Sat, 19 Apr 2025 12:14:25 +0000 (14:14 +0200)] 
gccrs: Use specialized param visit function for params

This commit introduce a new public function to visit function parameters
in the default visitor. It allows visitors derived from DefaultVisitor
to override only a small part of the default visitor.

gcc/rust/ChangeLog:

* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit_function_params):
Add specialized function to visit function parameters.
(DefaultASTVisitor::visit): Remove parameter visit and call specialized
function instead.
* ast/rust-ast-visitor.h: Add function prototye.
* resolve/rust-late-name-resolver-2.0.cc (Late::visit): Remove
function.
(Late::visit_function_params): Override specialized visit function.
* resolve/rust-late-name-resolver-2.0.h: Add overriden function
prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agogccrs: Remove passing test from exclusion list
Pierre-Emmanuel Patry [Sun, 6 Apr 2025 17:54:06 +0000 (19:54 +0200)] 
gccrs: Remove passing test from exclusion list

gcc/testsuite/ChangeLog:

* rust/compile/nr2/exclude: Remove passing test from exclusion list.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agogccrs: Use stacked context for nested bindings.
Pierre-Emmanuel Patry [Sun, 6 Apr 2025 16:49:11 +0000 (18:49 +0200)] 
gccrs: Use stacked context for nested bindings.

Binding context may be stacked when a new binding group is introduced
within a const expression.

gcc/rust/ChangeLog:

* resolve/rust-name-resolution-context.h: Use BindingLayer instead.
* resolve/rust-name-resolution-context.cc (BindingLayer::BindingLayer):
Add new constructor for binding layer.
(BindingLayer::bind_test): Add a function to test a binding constraint.
(BindingLayer::push): Push a new binding group.
(BindingLayer::and_binded): Add function to test and-binding
constraint.
(BindingLayer::or_binded): Add function to test or-binding constraints.
(BindingLayer::insert_ident): Insert a new identifier in the current
binding group.
(BindingLayer::merge): Merge current binding group with it's parent.
(BindingLayer::get_source): Get the source of the current binding
group.
* resolve/rust-late-name-resolver-2.0.cc: Use stacked context for
binding group.
* util/rust-stacked-contexts.h: Add mutable peek function.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agogccrs: Add pattern bindings
Pierre-Emmanuel Patry [Sun, 6 Apr 2025 16:17:41 +0000 (18:17 +0200)] 
gccrs: Add pattern bindings

gcc/rust/ChangeLog:

* resolve/rust-late-name-resolver-2.0.cc (Late::visit): Add binding
creation in visitor.
* resolve/rust-late-name-resolver-2.0.h: Add function prototypes.
* resolve/rust-name-resolution-context.h: Add binding context.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agogccrs: Add binding context class
Pierre-Emmanuel Patry [Sun, 6 Apr 2025 15:09:42 +0000 (17:09 +0200)] 
gccrs: Add binding context class

We need to differentiate bindings types, so the same binding cannot be
reused multiple time in a product binding.

gcc/rust/ChangeLog:

* resolve/rust-name-resolution-context.h (struct Binding): Add Binding
struct to differentiate Or and Product bindings in patterns.
(enum class): Add Binding kind.
(class BindingContext): Add binding context with Binding stack.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agogccrs: Add hash function for Identifiers
Pierre-Emmanuel Patry [Sat, 5 Apr 2025 23:44:18 +0000 (01:44 +0200)] 
gccrs: Add hash function for Identifiers

gcc/rust/ChangeLog:

* ast/rust-ast.h: Add hash function.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agogccrs: Add equality operator for identifiers
Pierre-Emmanuel Patry [Sat, 5 Apr 2025 23:43:20 +0000 (01:43 +0200)] 
gccrs: Add equality operator for identifiers

gcc/rust/ChangeLog:

* ast/rust-ast.h: Add equality operator.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agogccrs: Add fn_once and Sized lang items to the test
Pierre-Emmanuel Patry [Fri, 4 Apr 2025 13:35:15 +0000 (15:35 +0200)] 
gccrs: Add fn_once and Sized lang items to the test

gcc/testsuite/ChangeLog:

* rust/compile/multiple_bindings1.rs: Add missing lang items.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agogccrs: Change expected error output to match nr2
Pierre-Emmanuel Patry [Thu, 24 Apr 2025 12:28:59 +0000 (14:28 +0200)] 
gccrs: Change expected error output to match nr2

Name resolution 2.0 message describes the context around the unresolved
items and should therefore be kept.

gcc/testsuite/ChangeLog:

* rust/compile/nr2/exclude: Remove test from exclusion list.
* rust/compile/use_1.rs: Change expected output and remove test from
nr1.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agogccrs: Update generics9 expected error message
Pierre-Emmanuel Patry [Wed, 23 Apr 2025 12:41:24 +0000 (14:41 +0200)] 
gccrs: Update generics9 expected error message

gcc/testsuite/ChangeLog:

* rust/compile/generics9.rs: Change expected error message.
* rust/compile/nr2/exclude: Remove test from exclusion list.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agogccrs: Prevent forward declaration in type parameters
Pierre-Emmanuel Patry [Wed, 23 Apr 2025 12:40:22 +0000 (14:40 +0200)] 
gccrs: Prevent forward declaration in type parameters

gcc/rust/ChangeLog:

* resolve/rust-default-resolver.cc (DefaultResolver::visit): Add visit
function for TypeParam.
* resolve/rust-default-resolver.h: Add function prototype.
* resolve/rust-forever-stack.h: Add function to check for forward
declaration ban.
* resolve/rust-late-name-resolver-2.0.cc (Late::visit): Check forward
declarations.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agogccrs: Remove error state for GenericArg
Pierre-Emmanuel Patry [Mon, 7 Apr 2025 13:59:15 +0000 (15:59 +0200)] 
gccrs: Remove error state for GenericArg

gcc/rust/ChangeLog:

* ast/rust-ast-collector.cc (TokenCollector::visit): Remove error kind
and change function call.
* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Change call name.
* ast/rust-path.cc (ConstGenericParam::as_string): Likewise.
* ast/rust-path.h: Remove error kind.
* hir/rust-ast-lower-type.cc (ASTLowerGenericParam::visit): Change call
name.
* parse/rust-parse-impl.h (Parser::parse_generic_param): Use optional
on parsing failure.
(Parser::parse_generic_arg): Likewise.
(Parser::parse_path_generic_args): Likewise.
* parse/rust-parse.h: Likewise.
* resolve/rust-ast-resolve-type.h: Change call name.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agogccrs: Change error message to match expected test output
Pierre-Emmanuel Patry [Wed, 23 Apr 2025 15:24:04 +0000 (17:24 +0200)] 
gccrs: Change error message to match expected test output

gcc/rust/ChangeLog:

* resolve/rust-late-name-resolver-2.0.cc (Late::visit): Change error
message.

gcc/testsuite/ChangeLog:

* rust/compile/nr2/exclude: Remove passing test from exclusion list.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agogccrs: nr2.0: Improve error handling
Owen Avery [Thu, 17 Apr 2025 17:51:43 +0000 (13:51 -0400)] 
gccrs: nr2.0: Improve error handling

gcc/rust/ChangeLog:

* resolve/rust-early-name-resolver-2.0.cc
(Early::build_import_mapping): Avoid outputting an "unresolved
import" error if other errors are outputted during resolution.
* resolve/rust-early-name-resolver-2.0.h
(Early::resolve_path_in_all_ns): Collect path resolution errors
while avoiding duplicate errors for resolutions in each
namespace.
* resolve/rust-forever-stack.h
(ForeverStack::resolve_path): Add parameter for collecting
errors.
(ForeverStack::find_starting_point): Likewise.
(ForeverStack::resolve_segments): Likewise.
* resolve/rust-forever-stack.hxx
(check_leading_kw_at_start): Likewise.
(ForeverStack::find_starting_point): Likewise.
(ForeverStack::resolve_segments): Likewise.
(ForeverStack::resolve_path): Likewise.
* resolve/rust-name-resolution-context.h
(NameResolutionContext::resolve_path): Add optional parameter
for collecting errors.

gcc/testsuite/ChangeLog:

* rust/compile/nr2/exclude: Remove entry.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
3 months agogccrs: nr2.0: Fix derive-debug1.rs
Owen Avery [Sun, 6 Apr 2025 22:48:58 +0000 (18:48 -0400)] 
gccrs: nr2.0: Fix derive-debug1.rs

gcc/testsuite/ChangeLog:

* rust/compile/derive-debug1.rs: Adjust a path.
* rust/compile/nr2/exclude: Remove derive-debug1.rs.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
3 months agogccrs: prealloc the initilizer vector
Philip Herron [Thu, 17 Apr 2025 15:19:35 +0000 (16:19 +0100)] 
gccrs: prealloc the initilizer vector

There are two cases when initilizing an array, this is the
const context which means we need to build the array ctor,
which means using lots of memory, its super inefficient
because we are using a big wrapper over the GCC internals here
but preallocating the vectors here causes a:

  terminate called after throwing an instance of 'std::bad_alloc'

So this is a handy error condition to rely on for this senario.

Fixes Rust-GCC#3713
Fixes Rust-GCC#3727

gcc/rust/ChangeLog:

* backend/rust-compile-expr.cc (CompileExpr::array_copied_expr): prealloc the vector

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
3 months agogccrs: Fix ICE with empty generic arguments
Philip Herron [Thu, 17 Apr 2025 14:53:58 +0000 (15:53 +0100)] 
gccrs: Fix ICE with empty generic arguments

We have an assertion when accessing generic args if there are any which
is really useful so this adds the missing guards for the case where
they are specified but empty.

Fixes Rust-GCC#3649

gcc/rust/ChangeLog:

* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): add guard
* expand/rust-expand-visitor.cc (ExpandVisitor::visit): add guard

gcc/testsuite/ChangeLog:

* rust/compile/nr2/exclude: nr2 is missing error for this
* rust/compile/issue-3649.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
3 months agogccrs: Adjust segment start position errors
Owen Avery [Thu, 17 Apr 2025 20:51:21 +0000 (16:51 -0400)] 
gccrs: Adjust segment start position errors

gcc/rust/ChangeLog:

* resolve/rust-ast-resolve-path.cc
(ResolvePath::resolve_path): Adjust error messages.
* resolve/rust-ast-resolve-type.cc
(ResolveRelativeTypePath::go): Likewise.
* resolve/rust-forever-stack.hxx
(check_leading_kw_at_start): Likewise.

gcc/testsuite/ChangeLog:

* rust/compile/issue-3568.rs: Adjust expected errors.
* rust/compile/name_resolution9.rs: Likewise.
* rust/compile/self-path2.rs: Likewise.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
3 months agogccrs: Fix ICE when handling case of unknown field in HIR::FieldAccess
Philip Herron [Thu, 17 Apr 2025 12:50:55 +0000 (13:50 +0100)] 
gccrs: Fix ICE when handling case of unknown field in HIR::FieldAccess

We were wrongly adding the assertion that this must not be an enum but
this is a pointless assertion we only care that there are variant in the
ADT and if the field exists in the first variant.

Fixes Rust-GCC#3581

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): fix bad assertion

gcc/testsuite/ChangeLog:

* rust/compile/nonexistent-field.rs: fix bad error message
* rust/compile/issue-3581-1.rs: New test.
* rust/compile/issue-3581-2.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
3 months agogccrs: Add test case to show ice is fixed
Philip Herron [Fri, 18 Apr 2025 10:37:55 +0000 (11:37 +0100)] 
gccrs: Add test case to show ice is fixed

Fixes Rust-GCC#3652

gcc/testsuite/ChangeLog:

* rust/compile/nr2/exclude: nr2 does not error on the T it should require Self::T
* rust/compile/issue-3652.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
3 months agogccrs: nr2.0: Remove unnecessary copy of Node
Owen Avery [Thu, 17 Apr 2025 23:23:12 +0000 (19:23 -0400)] 
gccrs: nr2.0: Remove unnecessary copy of Node

gcc/rust/ChangeLog:

* resolve/rust-forever-stack.hxx
(ForeverStack::resolve_path): Pass instance of Node to lambda by
reference instead of by value.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
3 months agogccrs: Fix ICE in struct expressions
Philip Herron [Thu, 17 Apr 2025 13:38:04 +0000 (14:38 +0100)] 
gccrs: Fix ICE in struct expressions

The error handling here was done long ago when we didnt know how to do
any error handling very well. This removed bad fatal_errors and adds in
some nice rich_location error diagnostics instead.

Fixes Rust-GCC#3628

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-struct-field.h: keep reference to parent expression
* typecheck/rust-hir-type-check-struct.cc (TypeCheckStructExpr::TypeCheckStructExpr):
update ctor
(TypeCheckStructExpr::resolve): remove bad rust_fatal_errors
(TypeCheckStructExpr::visit): cleanup errors

gcc/testsuite/ChangeLog:

* rust/compile/macros/mbe/macro-issue2983_2984.rs: cleanup error diagnotics
* rust/compile/struct_init1.rs: likewise
* rust/compile/issue-3628.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
3 months agogccrs: nr2.0: Handle StructPatternFieldIdent
Owen Avery [Thu, 17 Apr 2025 18:02:45 +0000 (14:02 -0400)] 
gccrs: nr2.0: Handle StructPatternFieldIdent

gcc/rust/ChangeLog:

* resolve/rust-late-name-resolver-2.0.cc
(Late::visit): Handle StructPatternFieldIdent.
* resolve/rust-late-name-resolver-2.0.h
(Late::visit): Likewise.

gcc/testsuite/ChangeLog:

* rust/compile/nr2/exclude: Remove entry.

Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>
3 months agogccrs: Add test case to show ICE is fixed
Philip Herron [Thu, 17 Apr 2025 15:29:05 +0000 (16:29 +0100)] 
gccrs: Add test case to show ICE is fixed

Fixes Rust-GCC#3662

gcc/testsuite/ChangeLog:

* rust/compile/issue-3662.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
3 months agogccrs: Add test case to show issue is fixed
Philip Herron [Thu, 17 Apr 2025 15:04:55 +0000 (16:04 +0100)] 
gccrs: Add test case to show issue is fixed

This was already fixed in: bb01719f0e1 but we require fn_once lang item
to be defined as we are working on libcore support still.

Fixes Rust-GCC#3711

gcc/testsuite/ChangeLog:

* rust/compile/issue-3711.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
3 months agogccrs: Add gimple test for black box intrinsic
Pierre-Emmanuel Patry [Thu, 17 Apr 2025 16:28:52 +0000 (18:28 +0200)] 
gccrs: Add gimple test for black box intrinsic

gcc/testsuite/ChangeLog:

* rust/compile/black_box.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agogccrs: Add execute test for black_box intrinsic
Pierre-Emmanuel Patry [Thu, 17 Apr 2025 15:53:15 +0000 (17:53 +0200)] 
gccrs: Add execute test for black_box intrinsic

gcc/testsuite/ChangeLog:

* rust/execute/black_box.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agogccrs: Add LlvmInlineAsm node dump
Pierre-Emmanuel Patry [Thu, 17 Apr 2025 12:27:11 +0000 (14:27 +0200)] 
gccrs: Add LlvmInlineAsm node dump

gcc/rust/ChangeLog:

* ast/rust-ast-collector.cc (TokenCollector::visit): Dump llvm inline
asm tokens.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agogccrs: Parse and lower llvm asm node
Pierre-Emmanuel Patry [Tue, 15 Apr 2025 09:38:29 +0000 (11:38 +0200)] 
gccrs: Parse and lower llvm asm node

Add a new HIR LlvmInlineAsm HIR node as well as some structures to
represent it's options and operands. Lower AST::LlvmInlineAsm node to it
and then create a tree from that node.

gcc/rust/ChangeLog:

* ast/rust-ast-collector.cc (TokenCollector::visit): Remove unreachable
code.
* ast/rust-expr.h (struct LlvmOperand): Add LlvmOperand struct to
represent input and outputs.
(class LlvmInlineAsm): Add input, output and clobber operands.
(struct TupleTemplateStr): Add locus getter.
* backend/rust-compile-block.h: Add visit for LlvmInlineAsm.
* backend/rust-compile-expr.cc (CompileExpr::visit): Add llvm inline
asm stmt compilation.
* backend/rust-compile-expr.h: Add function prototype.
* backend/rust-compile-asm.h (class CompileLlvmAsm): Add llvm asm hir
not to gimple.
* backend/rust-compile-asm.cc (CompileLlvmAsm::CompileLlvmAsm): Add
constructor.
(CompileLlvmAsm::construct_operands): Add function to construct operand
tree.
(CompileLlvmAsm::construct_clobbers): Add function to construct clobber
tree.
(CompileLlvmAsm::tree_codegen_asm): Generate the whole tree for a given
llvm inline assembly node.
* checks/errors/borrowck/rust-bir-builder-expr-stmt.cc (ExprStmtBuilder::visit):
Add visit function.
* checks/errors/borrowck/rust-bir-builder-expr-stmt.h: Add function
prototype.
* checks/errors/borrowck/rust-bir-builder-lazyboolexpr.h: Add visit
function.
* checks/errors/borrowck/rust-bir-builder-struct.h: Likewise.
* checks/errors/borrowck/rust-function-collector.h: Likewise.
* checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::visit):
Likewise.
* checks/errors/privacy/rust-privacy-reporter.h: Add visit function
prototype.
* checks/errors/rust-const-checker.cc (ConstChecker::visit): Add visit
function.
* checks/errors/rust-const-checker.h: Add visit function prototype.
* checks/errors/rust-hir-pattern-analysis.cc (PatternChecker::visit):
Add visit function.
* checks/errors/rust-hir-pattern-analysis.h: Add visit function
prototype.
* checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): Add
visit function.
* checks/errors/rust-unsafe-checker.h: Add function prototype.
* expand/rust-macro-builtins-asm.cc (parse_llvm_templates): Parse
templates.
(parse_llvm_arguments): Add function to parse non template tokens.
(parse_llvm_operands): Add function to parse operands, either input or
output.
(parse_llvm_outputs): Add function to parse and collect llvm asm
outputs.
(parse_llvm_inputs): Likewise with inputs.
(parse_llvm_clobbers): Add function to parse llvm asm clobbers.
(parse_llvm_options): Add function to parse llvm asm options.
(parse_llvm_asm): Add function to parse llvm asm.
* expand/rust-macro-builtins-asm.h (class LlvmAsmContext): Add context
for llvm asm parser.
(parse_llvm_outputs): Add function prototype.
(parse_llvm_inputs): Likewise.
(parse_llvm_clobbers): Likewise.
(parse_llvm_options): Likewise.
* hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): Lower AST llvm
asm node to HIR.
* hir/rust-ast-lower-expr.h: Add function prototype.
* hir/rust-hir-dump.cc (Dump::visit): Add visit function.
* hir/rust-hir-dump.h: Add function prototype.
* hir/tree/rust-hir-expr-abstract.h: Add HIR llvm asm node kind.
* hir/tree/rust-hir-expr.h (struct LlvmOperand): Add LlvmOperand type
to represent input and outputs.
(class LlvmInlineAsm): Add LlvmInlineAsm hir node.
* hir/tree/rust-hir-full-decls.h (class LlvmInlineAsm): Add
LlvmInlineAsm hir node forward declaration.
* hir/tree/rust-hir-visitor.h: Add visit functions for LlvmInlineAsm
hir node.
* hir/tree/rust-hir.cc (LlvmInlineAsm::accept_vis): Add hir node
visitor related functions.
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit):
Type check input and output operands.
* typecheck/rust-hir-type-check-expr.h: Add function prototype.
* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Visit input and
output operand expressions.
* resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit): Resolve input
and output expressions.
* resolve/rust-ast-resolve-expr.h: Add function prototypes.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agogccrs: Add llvmInlineAsm node
Pierre-Emmanuel Patry [Thu, 10 Apr 2025 11:05:15 +0000 (13:05 +0200)] 
gccrs: Add llvmInlineAsm node

InlineAsm node does not support memory clobbers.

gcc/rust/ChangeLog:

* ast/rust-ast-collector.cc (TokenCollector::visit): Make visitor
unreachable.
* ast/rust-ast-collector.h: Add visit for LlvmInlineAsmNode.
* ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Add visit
function for the default ast visitor.
* ast/rust-ast-visitor.h: Add function prototype.
* ast/rust-ast.cc (LlvmInlineAsm::accept_vis): Add accept_vis to
LlvmInlineAsm node.
* ast/rust-ast.h: Add LlvmInlineAsm node kind.
* ast/rust-expr.h (class LlvmInlineAsm): Add LlvmInlineAsm node.
* expand/rust-derive.h: Add visit function for LlvmInlineAsm node.
* expand/rust-macro-builtins-asm.cc (MacroBuiltin::llvm_asm_handler):
Add handler for llvm inline assembly nodes.
(parse_llvm_asm): Add function to parse llvm assembly nodes.
* expand/rust-macro-builtins-asm.h (parse_llvm_asm): Add function
prototypes.
* expand/rust-macro-builtins.cc (inline_llvm_asm_maker): Add macro
transcriber.
* expand/rust-macro-builtins.h: Add transcriber function prototype.
* hir/rust-ast-lower-base.cc (ASTLoweringBase::visit): Add visit
function for LlvmInlineAsm node.
* hir/rust-ast-lower-base.h: Add visit function prototype.
* resolve/rust-ast-resolve-base.cc (ResolverBase::visit): Add visit
function for LlvmInlineAsm node.
* resolve/rust-ast-resolve-base.h: Add visit function prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agogccrs: Emit error with old asm syntax in new asm blocks
Pierre-Emmanuel Patry [Wed, 9 Apr 2025 15:41:24 +0000 (17:41 +0200)] 
gccrs: Emit error with old asm syntax in new asm blocks

gcc/rust/ChangeLog:

* expand/rust-macro-builtins-asm.cc (parse_asm_arg): Emit error
message.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
3 months agogccrs: Add check for placeholder (infer) type in return position
Philip Herron [Wed, 16 Apr 2025 19:38:17 +0000 (20:38 +0100)] 
gccrs: Add check for placeholder (infer) type in return position

It is not allowed to have a declared inference variable in the return
position of a function as this may never get infered you need good points
of truth.

Ideally if we get a student for GSoC 25 we will get the Default Hir Visitor
so that we can grab the HIR::InferredType locus instead of using the ref
location lookups.

Fixes Rust-GCC#402

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit): add diagnostic
* typecheck/rust-tyty.cc (BaseType::contains_infer): new helper to grab first infer var
* typecheck/rust-tyty.h: prototype

gcc/testsuite/ChangeLog:

* rust/compile/issue-402.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
3 months agogccrs: Fix ICE when checking shift's which are behind array refs
Philip Herron [Wed, 16 Apr 2025 16:13:04 +0000 (17:13 +0100)] 
gccrs: Fix ICE when checking shift's which are behind array refs

I copied a bad form of this check from the c front-end this updates it
to ensure the rhs is an INTEGER_CST and the lhs needs checked in the first
place.

Fixes Rust-GCC#3664

gcc/rust/ChangeLog:

* rust-gcc.cc (arithmetic_or_logical_expression): Ensure this is an integer

gcc/testsuite/ChangeLog:

* rust/compile/issue-3664.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
3 months agogccrs: Fix crash in hir dump as labels are optional
Philip Herron [Wed, 16 Apr 2025 16:00:28 +0000 (17:00 +0100)] 
gccrs: Fix crash in hir dump as labels are optional

gcc/rust/ChangeLog:

* hir/rust-hir-dump.cc (Dump::visit): add guard for optional label

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
3 months agogccrs: Update comments in repr parsing code
Yap Zhi Heng [Fri, 4 Apr 2025 11:37:03 +0000 (19:37 +0800)] 
gccrs: Update comments in repr parsing code

gcc/rust/ChangeLog:

* typecheck/rust-tyty.h: Remove extra redundant comment.
* typecheck/rust-hir-type-check-base.cc: Update comment on repr
handling.

Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
3 months agogccrs: Implement integer representation for enums
Zhi Heng [Thu, 3 Apr 2025 15:02:59 +0000 (23:02 +0800)] 
gccrs: Implement integer representation for enums

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-base.cc: Set enum representing
type properly if repr is an integer type.
* typecheck/rust-hir-type-check-item.cc: Update comments.

Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
3 months agogccrs: Implement typecheck for zero-variant enums
Zhi Heng [Thu, 3 Apr 2025 12:23:46 +0000 (20:23 +0800)] 
gccrs: Implement typecheck for zero-variant enums

gcc/rust/ChangeLog:

* typecheck/rust-tyty.h: Add new `ReprKind` enum to
`ReprOptions`.
* typecheck/rust-hir-type-check-base.cc: Handle setting of
`repr_kind`.
* typecheck/rust-hir-type-check-item.cc: New check for
zero-variant enums.

Signed-off-by: Yap Zhi Heng <yapzhhg@gmail.com>
3 months agogccrs: Fix segv in unsafe chcker
Philip Herron [Fri, 4 Apr 2025 15:35:13 +0000 (16:35 +0100)] 
gccrs: Fix segv in unsafe chcker

Trait constants were missing type resolution step, this adds that
as if it was a normal constant. The unsafe checker was missing a
null check.

Fixes Rust-GCC#3612

gcc/rust/ChangeLog:

* checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): add null check
* hir/tree/rust-hir-item.h: add has_type helper
* typecheck/rust-hir-trait-resolve.cc (TraitItemReference::resolve_item):
add missing type checking

gcc/testsuite/ChangeLog:

* rust/compile/issue-3612.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
3 months agosimplify-rtx: Split out native_decode_int
Richard Sandiford [Mon, 28 Apr 2025 13:40:09 +0000 (14:40 +0100)] 
simplify-rtx: Split out native_decode_int

native_decode_rtx handles integer modes by building up a wide_int
and then converting it to an rtx.  This patch splits out the
wide_int part, so that callers who don't want an rtx can avoid
creating garbage rtl.

gcc/
* rtl.h (native_decode_int): Declare.
* simplify-rtx.cc (native_decode_int): New function, split out from...
(native_decode_rtx): ...here.

3 months agox86: Properly find the maximum stack slot alignment
H.J. Lu [Tue, 14 Mar 2023 18:41:51 +0000 (11:41 -0700)] 
x86: Properly find the maximum stack slot alignment

Don't assume that stack slots can only be accessed by stack or frame
registers.  We first find all registers defined by stack or frame
registers.  Then check memory accesses by such registers, including
stack and frame registers.

gcc/

PR target/109780
PR target/109093
* config/i386/i386.cc (stack_access_data): New.
(ix86_update_stack_alignment): Likewise.
(ix86_find_all_reg_use_1): Likewise.
(ix86_find_all_reg_use): Likewise.
(ix86_find_max_used_stack_alignment): Also check memory accesses
from registers defined by stack or frame registers.

gcc/testsuite/

PR target/109780
PR target/109093
* g++.target/i386/pr109780-1.C: New test.
* gcc.target/i386/pr109093-1.c: Likewise.
* gcc.target/i386/pr109780-1.c: Likewise.
* gcc.target/i386/pr109780-2.c: Likewise.
* gcc.target/i386/pr109780-3.c: Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Co-Authored-By: Uros Bizjak <ubizjak@gmail.com>
3 months agoipa/119973 - IPA PTA issue with global initializers
Richard Biener [Mon, 28 Apr 2025 09:15:53 +0000 (11:15 +0200)] 
ipa/119973 - IPA PTA issue with global initializers

For global initializers with IPA PTA we initialize them from the
IPA reference data but that lacks references to the constant pool.
The following conservatively considers the whole initializer.

PR ipa/119973
* tree-ssa-structalias.cc (create_variable_info_for):
Build constraints from DECL_INITIAL directly rather than
the IPA reference list which is incomplete.

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

3 months agolto/113207 - make fld_type_variant more picky
Richard Biener [Mon, 3 Feb 2025 13:16:45 +0000 (14:16 +0100)] 
lto/113207 - make fld_type_variant more picky

The below adds additional verification to fld_type_variant that
there's only one variant matching fld_type_variant_equal_p on the
chain.  The PR shows that variants built with build_qualified_type
can be equal to others in that regard but not with regard to
what build_qualified_type does.

PR lto/113207
* ipa-free-lang-data.cc (fld_type_variant): Add extra checking.

3 months agotree-optimization/119044 - predcom fails to preserve alias info
Richard Biener [Thu, 27 Feb 2025 13:51:44 +0000 (14:51 +0100)] 
tree-optimization/119044 - predcom fails to preserve alias info

Predictive commoning fails to preserve alias info for the refs it
creates.  The following adds this to see whether it fixes the
observed regression in 436.cactusADM after r15-7665.

PR tree-optimization/119044
* tree-predcom.cc (ref_at_iteration): Copy alias info
from the original ref.

3 months agotree-optimization/119103 - missed overwidening detection for shift
Richard Biener [Tue, 4 Mar 2025 09:34:39 +0000 (10:34 +0100)] 
tree-optimization/119103 - missed overwidening detection for shift

When vectorizing a shift of u16 data by an amount that's known to
be less than 16 we currently fail to emit a vector u16 shift.  The
first reason is that the promotion of the shift amount is hoisted
only by PRE and that cannot preserve range info, the second reason
is that pattern detection doesn't use range info when computing
the precision required for an operation.

The following addresses the first issue by making LIM hoist all
expressions for the pass that runs right before PRE and the
second issue by querying ranges for the shift amount.

PR tree-optimization/119103
* tree-ssa-loop-im.cc (in_loop_pipeline): Globalize.
(compute_invariantness): Override costing when we run
right before PRE and PRE is enabled.
(pass_lim::execute): Adjust.
* tree-vect-patterns.cc (vect_determine_precisions_from_users):
For variable shift amounts use range information.

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

3 months agomiddle-end/80342 - genmatch optimize outer conversions
Richard Biener [Tue, 21 Jan 2025 12:50:26 +0000 (13:50 +0100)] 
middle-end/80342 - genmatch optimize outer conversions

The following improves genmatch generated code so we avoid more
spurious SSA assignments to be pushed to the GIMPLE sequence or
simplifications rejected when we're not supposed to produce any
for outer and intermediate conversions.

* genmatch.cc (::gen_transform): Add in_place parameter.
Assert it isn't set in unexpected places.
(possible_noop_convert): New.
(expr::gen_transform): Support in_place and emit code to
compute a child in-place when the operation is a conversion.
(dt_simplify::gen_1): Arrange for an outermost conversion
to be elided by generating the transform of the operand
in-place.
* match.pd (__real cepxi (x) -> cos (x)): Use single_use.

3 months agomiddle-end/60779 - LTO vs. -fcx-fortran-rules and -fcx-limited-range
Richard Biener [Tue, 18 Feb 2025 11:52:34 +0000 (12:52 +0100)] 
middle-end/60779 - LTO vs. -fcx-fortran-rules and -fcx-limited-range

The following changes how flag_complex_method is managed towards
being able to record that in the optimization set so we can stream
and restore it per function.  Currently -fcx-fortran-rules and
-fcx-limited-range are separate recorded options but saving/restoring
does not restore flag_complex_method which is later used in the
middle-end.

The solution is to make -fcx-fortran-rules and -fcx-limited-range
aliases of a new -fcx-method= switch that represents flag_complex_method
directly so we can save and restore it.

PR middle-end/60779
* common.opt (fcx-method=): New, map to flag_complex_method.
(Enum complex_method): New.
(fcx-limited-range): Alias to -fcx-method=limited-range.
(fcx-fortran-rules): Alias to -fcx-medhot=fortran.
* ipa-inline-transform.cc (inline_call): Check flag_complex_method.
* ipa-inline.cc (can_inline_edge_by_limits_p): Likewise.
* opts.cc (finish_options): Adjust.
(set_fast_math_flags): Likewise.
* doc/invoke.texi (fcx-method=): Document.

* gcc.dg/lto/pr60779_0.c: New testcase.
* gcc.dg/lto/pr60779_1.c: Likewise.

3 months agomiddle-end/116083 - vectorizer slowness
Richard Biener [Tue, 3 Dec 2024 13:21:47 +0000 (14:21 +0100)] 
middle-end/116083 - vectorizer slowness

Turns out SLP discovery can end up doing a lot of vector type
builds from scalar types.  Those are all ultimatively cached but
end up built and layouted first.  The latter is particularly
expensive because it does tree node arithmetic to compute TYPE_SIZE
and TYPE_SIZE_UNIT.  The following replaces this with the appropriate
poly-int arithmetic which speeds up the testcase by 50%.

PR middle-end/116083
* stor-layout.cc (layout_type): Compute TYPE_SIZE and
TYPE_SIZE_UNIT for vector types from the component mode
sizes.

3 months agoPrune non-SLP paths from vectorizer loop analysis
Richard Biener [Thu, 30 Jan 2025 14:03:04 +0000 (15:03 +0100)] 
Prune non-SLP paths from vectorizer loop analysis

The following prunes non-SLP iteration and the parts of non-SLP
stmt analysis that is no longer necessary - we need to keep the
parts that bail on stmts not covered by SLP discovery or that
failed SLP discovery.  This will only go away when a we can build
a fully covering single-lane SLP graph to fall back to.

* tree-vect-loop.cc (vect_analyze_loop_operations): Prune
all actual analysis and only fail when we discover a not
SLP covered stmt.
(vect_analyze_loop_2): Remove path trying without SLP.

3 months agoRemove non-SLP vector loop transform
Richard Biener [Thu, 30 Jan 2025 12:45:00 +0000 (13:45 +0100)] 
Remove non-SLP vector loop transform

The following removes the stmt-based vectorization loop transform code.
This also removes some debug stmt handling (that looked incomplete)
which is also handled during peeling, and special-casing some stmts
that should be killed off early and not left to DCE.

Moving of dump from vect_transform_loop_stmt to vect_transform_stmt
is to avoid regressing a few testcases.

* tree-vect-loop.cc (vect_loop_kill_debug_uses): Remove.
(maybe_set_vectorized_backedge_value): Likewise.
(vect_transform_loop_stmt): Likewise.  Move dump printing
to vect_transform_stmt.
(vect_transform_loop): Remove loop over loop stmts transforming
them, but retain some DCE code still necessary.
* tree-vect-stmts.cc (vect_transform_stmt): Dump that
we're vectorizing a stmt.

3 months agoRemove --param vect-force-slp
Richard Biener [Thu, 30 Jan 2025 10:42:51 +0000 (11:42 +0100)] 
Remove --param vect-force-slp

The following removes the ability to switch back to non SLP-only
operation of the vectorizer - a requirement to start cleaning out
non-SLP paths without risk of regressing that case.

* params.opt (--param=vect-force-slp): Remove.
* doc/invoke.texi (--param=vect-force-slp): Likewise.
* tree-vect-loop.cc (vect_analyze_loop_2): Assume
param_vect_force_slp is 1.
* tree-vect-stmts.cc (vect_analyze_stmt): Likewise.

3 months agolibstdc++: Fix mingw build by using _M_span [PR119970]
Tomasz Kamiński [Mon, 28 Apr 2025 06:53:59 +0000 (08:53 +0200)] 
libstdc++: Fix mingw build by using _M_span [PR119970]

The r16-142-g01e5ef3e8b9128 chagned return type of _Str_sink::view()
to basic_string_view<_CharT>. The mutable access is provided by _M_span
function, that is now used for mingw path.

PR libstdc++/119970

libstdc++-v3/ChangeLog:

* include/std/ostream (vprint_unicode) [_WIN32 && !__CYGWIN__]: Call
_Str_sink::_M_span instead of view.
* include/std/print (vprint_unicode) [_WIN32 && !__CYGWIN__]: Call
_Str_sink::_M_span instead of view.

3 months agolibstdc++: Strip reference and cv-qual in range deduction guides for maps.
Tomasz Kamiński [Thu, 20 Mar 2025 08:02:03 +0000 (09:02 +0100)] 
libstdc++: Strip reference and cv-qual in range deduction guides for maps.

This implements part of LWG4223 that adjust the deduction guides for maps types
(map, unordered_map, flat_map and non-unique equivalent) from "range"
(std::from_range, iterator pair), such that referience and cv qualification are
stripped from the element of the pair-like value_type.

In combination with r15-8296-gd50171bc07006d, the LWG4223 is fully implemented now.

libstdc++-v3/ChangeLog:

* include/bits/ranges_base.h (__detail::__range_key_type):
Replace remove_const_t with remove_cvref_t.
(__detail::__range_mapped_type): Apply remove_cvref_t.
* include/bits/stl_iterator.h: (__detail::__iter_key_t):
Replace remove_const_t with __remove_cvref_t.
(__detail::__iter_val_t): Apply __remove_cvref_t.
* testsuite/23_containers/flat_map/1.cc: New tests.
* testsuite/23_containers/flat_multimap/1.cc: New tests.
* testsuite/23_containers/map/cons/deduction.cc: New tests.
* testsuite/23_containers/map/cons/from_range.cc: New tests.
* testsuite/23_containers/multimap/cons/deduction.cc: New tests.
* testsuite/23_containers/multimap/cons/from_range.cc: New tests.
* testsuite/23_containers/unordered_map/cons/deduction.cc: New tests.
* testsuite/23_containers/unordered_map/cons/from_range.cc: New tests.
* testsuite/23_containers/unordered_multimap/cons/deduction.cc:
New tests.
* testsuite/23_containers/unordered_multimap/cons/from_range.cc:
New tests.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
3 months agolibstdc++: Implement missing allocator-aware constructors for unordered containers.
Tomasz Kamiński [Tue, 18 Mar 2025 15:10:48 +0000 (16:10 +0100)] 
libstdc++: Implement missing allocator-aware constructors for unordered containers.

This patch implements remainder of LWG2713 (after r15-8293-g64f5c854597759)
by adding missing allocator aware version of unordered associative containers
constructors accepting pair of iterators or initializer_list, and corresponding
deduction guides.

libstdc++-v3/ChangeLog:

* include/bits/unordered_map.h (unordered_map):
Define constructors accepting:
(_InputIterator, _InputIterator, const allocator_type&),
(initializer_list<value_type>, const allocator_type&),
(unordered_multimap): Likewise.
* include/debug/unordered_map (unordered_map): Likewise.
(unordered_multimap): Likewise.
* include/bits/unordered_set.h (unordered_set):
Define constructors and deduction guide accepting:
(_InputIterator, _InputIterator, const allocator_type&),
(initializer_list<value_type>, const allocator_type&),
(unordered_multiset): Likewise.
* include/debug/unordered_set (unordered_set): Likewise.
(unordered_multiset): Likewise.
* testsuite/23_containers/unordered_map/cons/66055.cc: New tests.
* testsuite/23_containers/unordered_map/cons/deduction.cc: New tests.
* testsuite/23_containers/unordered_multimap/cons/66055.cc: New tests.
* testsuite/23_containers/unordered_multimap/cons/deduction.cc: New
tests.
* testsuite/23_containers/unordered_multiset/cons/66055.cc: New tests.
* testsuite/23_containers/unordered_multiset/cons/deduction.cc: New
tests.
* testsuite/23_containers/unordered_set/cons/66055.cc: New tests.
* testsuite/23_containers/unordered_set/cons/deduction.cc: New tests.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
3 months agotailc: Improve tail recursion handling [PR119493]
Jakub Jelinek [Mon, 28 Apr 2025 07:22:50 +0000 (09:22 +0200)] 
tailc: Improve tail recursion handling [PR119493]

Here is a patch to improve the tail recursion handling also for
non-musttail calls.

2025-04-28  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/119493
* tree-tailcall.cc (find_tail_calls): Handle non-gimple_reg_type
arguments which aren't just passed through for tail recursions
even for non-musttail calls.

3 months agoc-family: Improve location for -Wunknown-pragmas in a _Pragma [PR118838]
Lewis Hyatt [Tue, 11 Feb 2025 18:45:41 +0000 (13:45 -0500)] 
c-family: Improve location for -Wunknown-pragmas in a _Pragma [PR118838]

The warning for -Wunknown-pragmas is issued at the location provided by
libcpp to the def_pragma() callback. This location is
cpp_reader::directive_line, which is a location for the start of the line
only; it is also not a valid location in case the unknown pragma was lexed
from a _Pragma string. These factors make it impossible to suppress
-Wunknown-pragmas via _Pragma("GCC diagnostic...") directives on the same
source line, as in the PR and the test case. Address that by issuing the
warning at a better location returned by cpp_get_diagnostic_override_loc().
libcpp already maintains this location to handle _Pragma-related diagnostics
internally; it was needed also to make a publicly accessible version of it.

gcc/c-family/ChangeLog:

PR c/118838
* c-lex.cc (cb_def_pragma): Call cpp_get_diagnostic_override_loc()
to get a valid location at which to issue -Wunknown-pragmas, in case
it was triggered from a _Pragma.

libcpp/ChangeLog:

PR c/118838
* errors.cc (cpp_get_diagnostic_override_loc): New function.
* include/cpplib.h (cpp_get_diagnostic_override_loc): Declare.

gcc/testsuite/ChangeLog:

PR c/118838
* c-c++-common/cpp/pragma-diagnostic-loc-2.c: New test.
* g++.dg/gomp/macro-4.C: Adjust expected output.
* gcc.dg/gomp/macro-4.c: Likewise.
* gcc.dg/cpp/Wunknown-pragmas-1.c: Likewise.

3 months agogcc: For Windows x86-32, always attempt to realign stack regardless of SSE
LIU Hao [Sun, 27 Apr 2025 10:18:34 +0000 (18:18 +0800)] 
gcc: For Windows x86-32, always attempt to realign stack regardless of SSE

For Windows x86-32 targets, the Microsoft ABI only guarantees that the stack
is aligned to 4-byte boundaries. GCC knows about the default alignment of the
stack. However, before this commit, it did not realign the stack unless SSE
was also enabled.

When a stricter (larger) alignment is requested, it's always necessary to
realign the stack, as what Solaris does.

Reference: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111107#c14
Signed-off-by: LIU Hao <lh_mouse@126.com>
Signed-off-by: Jonathan Yong <10walls@gmail.com>
gcc/ChangeLog:

PR target/111107
* config/i386/cygming.h (STACK_REALIGN_DEFAULT): Copy from sol2.h.

3 months agoFix size_t in id-15.c and infoleak-net-ethtool-ioctl.c for llp64
Jonathan Yong [Thu, 24 Apr 2025 07:42:17 +0000 (07:42 +0000)] 
Fix size_t in id-15.c and infoleak-net-ethtool-ioctl.c for llp64

Use __SIZE_TYPE__ for size_t types so that it works for
llp64.

Signed-off-by: Jonathan Yong <10walls@gmail.com>
gcc/testsuite/ChangeLog:

* gcc.dg/graphite/id-15.c: Use __SIZE_TYPE__ instead of
unsigned long.
* gcc.dg/plugin/infoleak-net-ethtool-ioctl.c: ditto.

3 months agoDaily bump.
GCC Administrator [Mon, 28 Apr 2025 00:18:29 +0000 (00:18 +0000)] 
Daily bump.

3 months agoc++/modules: Ensure DECL_FRIEND_CONTEXT is streamed [PR119939]
Nathaniel Shead [Fri, 25 Apr 2025 14:10:34 +0000 (00:10 +1000)] 
c++/modules: Ensure DECL_FRIEND_CONTEXT is streamed [PR119939]

An instantiated friend function relies on DECL_FRIEND_CONTEXT being set
to be able to recover the template arguments of the class that
instantiated it, despite not being a template itself.  This patch
ensures that this data is streamed even when DECL_CLASS_SCOPE_P is not
true.

PR c++/119939

gcc/cp/ChangeLog:

* module.cc (trees_out::lang_decl_vals): Also stream
lang->u.fn.context when DECL_UNIQUE_FRIEND_P.
(trees_in::lang_decl_vals): Likewise.

gcc/testsuite/ChangeLog:

* g++.dg/modules/concept-11_a.H: New test.
* g++.dg/modules/concept-11_b.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
3 months agossa-fre-4.c: Enable for all targets and adjust scan match
H.J. Lu [Sun, 10 Nov 2024 09:55:20 +0000 (17:55 +0800)] 
ssa-fre-4.c: Enable for all targets and adjust scan match

Since the C frontend no longer promotes char argument, enable ssa-fre-4.c
for all targets and adjust scan match.

PR middle-end/112877
* gcc.dg/tree-ssa/ssa-fre-4.c: Enable for all targets and adjust
scan match.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
3 months agoscev-cast.c: Enable for all targets and adjust scan matches
H.J. Lu [Sun, 10 Nov 2024 08:50:46 +0000 (16:50 +0800)] 
scev-cast.c: Enable for all targets and adjust scan matches

Since the C frontend no longer promotes char argument, enable scev-cast.c
for all targets and adjust scan matches.

PR middle-end/112877
* gcc.dg/tree-ssa/scev-cast.c: Enable for all targets and adjust
scan match.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
3 months agovect-simd-clone-1[6-8][cd].c: Expect in-branch clones for x86
H.J. Lu [Sun, 10 Nov 2024 08:41:10 +0000 (16:41 +0800)] 
vect-simd-clone-1[6-8][cd].c: Expect in-branch clones for x86

Since the C frontend no longer promotes char and short arguments, expect
in-branch clones for x86.

PR middle-end/112877
* gcc.dg/vect/vect-simd-clone-16c.c: Expect in-branch clones for
x86.
* gcc.dg/vect/vect-simd-clone-16d.c: Likewise.
* gcc.dg/vect/vect-simd-clone-17c.c: Likewise.
* gcc.dg/vect/vect-simd-clone-17d.c: Likewise.
* gcc.dg/vect/vect-simd-clone-18c.c: Likewise.
* gcc.dg/vect/vect-simd-clone-18d.c: Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
3 months agoi386: Adjust apx-ndd.c for frontend promotion removal
H.J. Lu [Sun, 10 Nov 2024 03:27:14 +0000 (11:27 +0800)] 
i386: Adjust apx-ndd.c for frontend promotion removal

Since the C frontend no longer promotes integer argument smaller than int,
the apx-ndd.c codgen is slightly different:

apx-ndd.s (original) 2024-11-10 06:07:09.894876973 +0800
apx-ndd.s (updated)  2024-11-10 06:06:59.371860565 +0800
@@ -17,7 +17,7 @@ foo_add_char:
 foo1_add_char:
 .LFB1:
  .cfi_startproc
- leal (%rsi,%rdi), %eax
+ leal (%rdi,%rsi), %eax
  ret
  .cfi_endproc
 .LFE1:
@@ -50,7 +50,7 @@ foo_add_short:
 foo1_add_short:
 .LFB4:
  .cfi_startproc
- leal (%rsi,%rdi), %eax
+ leal (%rdi,%rsi), %eax
  ret
  .cfi_endproc
 .LFE4:
@@ -413,7 +413,7 @@ foo_and_char:
 foo1_and_char:
 .LFB37:
  .cfi_startproc
- andl %edi, %esi, %eax
+ andl %esi, %edi, %eax
  ret
  .cfi_endproc
 .LFE37:
@@ -435,7 +435,7 @@ foo_and_short:
 foo1_and_short:
 .LFB39:
  .cfi_startproc
- andl %edi, %esi, %eax
+ andl %esi, %edi, %eax
  ret
  .cfi_endproc
 .LFE39:
@@ -501,7 +501,7 @@ foo_or_char:
 foo1_or_char:
 .LFB45:
  .cfi_startproc
- orl %edi, %esi, %eax
+ orl %esi, %edi, %eax
  ret
  .cfi_endproc
 .LFE45:
@@ -523,7 +523,7 @@ foo_or_short:
 foo1_or_short:
 .LFB47:
  .cfi_startproc
- orl %edi, %esi, %eax
+ orl %esi, %edi, %eax
  ret
  .cfi_endproc
 .LFE47:
@@ -589,7 +589,7 @@ foo_xor_char:
 foo1_xor_char:
 .LFB53:
  .cfi_startproc
- xorl %edi, %esi, %eax
+ xorl %esi, %edi, %eax
  ret
  .cfi_endproc
 .LFE53:
@@ -611,7 +611,7 @@ foo_xor_short:
 foo1_xor_short:
 .LFB55:
  .cfi_startproc
- xorl %edi, %esi, %eax
+ xorl %esi, %edi, %eax
  ret
  .cfi_endproc
 .LFE55:
@@ -1018,7 +1018,7 @@ foo4_rol_uint64_t:
 foo1_imul_short:
 .LFB92:
  .cfi_startproc
- imull %edi, %esi, %eax
+ imull %esi, %edi, %eax
  ret
  .cfi_endproc
 .LFE92:

Adjust the assembler scans.

PR middle-end/112877
* gcc.target/i386/apx-ndd.c: Adjusted.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
3 months agoDrop targetm.promote_prototypes from C, C++ and Ada frontends
H.J. Lu [Wed, 20 Nov 2024 23:54:35 +0000 (07:54 +0800)] 
Drop targetm.promote_prototypes from C, C++ and Ada frontends

Remove the targetm.calls.promote_prototypes call from C, C++ and Ada
frontends.

gcc/

PR c/48274
PR middle-end/112877
PR middle-end/118288
* gimple.cc (gimple_builtin_call_types_compatible_p): Remove the
targetm.calls.promote_prototypes call.
* tree.cc (tree_builtin_call_types_compatible_p): Likewise.

gcc/ada/

PR middle-end/112877
* gcc-interface/utils.cc (create_param_decl): Remove the
targetm.calls.promote_prototypes call.

gcc/c/

PR c/48274
PR middle-end/112877
PR middle-end/118288
* c-decl.cc (start_decl): Remove the
targetm.calls.promote_prototypes call.
(store_parm_decls_oldstyle): Likewise.
(finish_function): Likewise.
* c-typeck.cc (convert_argument): Likewise.
(c_safe_arg_type_equiv_p): Likewise.

gcc/cp/

PR middle-end/112877
* call.cc (type_passed_as): Remove the
targetm.calls.promote_prototypes call.
(convert_for_arg_passing): Likewise.
* typeck.cc (cxx_safe_arg_type_equiv_p): Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
3 months agoHonor TARGET_PROMOTE_PROTOTYPES during RTL expand
H.J. Lu [Thu, 21 Nov 2024 00:11:06 +0000 (08:11 +0800)] 
Honor TARGET_PROMOTE_PROTOTYPES during RTL expand

Promote integer arguments smaller than int if TARGET_PROMOTE_PROTOTYPES
returns true.

gcc/

PR middle-end/112877
* calls.cc (initialize_argument_information): Promote small integer
arguments if TARGET_PROMOTE_PROTOTYPES returns true.

gcc/testsuite/

PR middle-end/112877
* gfortran.dg/pr112877-1.f90: New test.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
3 months agoRISC-V: Extract vector stepped for expand_const_vector [NFC]
Pan Li [Thu, 17 Apr 2025 02:27:17 +0000 (10:27 +0800)] 
RISC-V: Extract vector stepped for expand_const_vector [NFC]

Consider the expand_const_vector is quit long (about 500 lines)
and complicated, we would like to extract the different case
into different functions.  For example, the const vector stepped
will be extracted into expand_const_vector_stepped.

The below test suites are passed for this patch.
* The rv64gcv fully regression test.

gcc/ChangeLog:

* config/riscv/riscv-v.cc (expand_const_vector): Extract
const vector stepped into separated func.
(expand_const_vector_single_step_npatterns): Add new func
to take care of single step.
(expand_const_vector_interleaved_stepped_npatterns): Add new
func to take care of interleaved step.
(expand_const_vector_stepped): Add new func to take care of
const vector stepped.

Signed-off-by: Pan Li <pan2.li@intel.com>
3 months agoRISC-V: Extract vector duplicate for expand_const_vector [NFC]
Pan Li [Wed, 16 Apr 2025 07:47:21 +0000 (15:47 +0800)] 
RISC-V: Extract vector duplicate for expand_const_vector [NFC]

Consider the expand_const_vector is quit long (about 500 lines)
and complicated, we would like to extract the different case
into different functions.  For example, the const vector duplicate
will be extracted into expand_const_vector_duplicate, and then
expand_const_vector_duplicate_repeating and
expand_const_vector_duplicate_default for the underlying function.

The below test suites are passed for this patch.
* The rv64gcv fully regression test.

gcc/ChangeLog:

* config/riscv/riscv-v.cc (expand_const_vector_duplicate_repeating):
Add new func to take care of vector duplicate with repeating.
(expand_const_vector_duplicate_default): Add new func to take
care of default const vector duplicate.
(expand_const_vector_duplicate): Add new func to take care
of all const vector duplicate.
(expand_const_vector): Extract const vector duplicate into
separated function.

Signed-off-by: Pan Li <pan2.li@intel.com>
3 months agoRISC-V: Extract vec_series for expand_const_vector [NFC]
Pan Li [Wed, 16 Apr 2025 06:43:23 +0000 (14:43 +0800)] 
RISC-V: Extract vec_series for expand_const_vector [NFC]

Consider the expand_const_vector is quit long (about 500 lines)
and complicated, we would like to extract the different case
into different functions.  For example, the const vec_series
will be extracted into expand_const_vec_series.

The below test suites are passed for this patch.
* The rv64gcv fully regression test.

gcc/ChangeLog:

* config/riscv/riscv-v.cc (expand_const_vec_series): Add new
func to take care of the const vec_series.
(expand_const_vector): Extract const vec_series into separated
function.

Signed-off-by: Pan Li <pan2.li@intel.com>
3 months agoRISC-V: Extract vec_duplicate for expand_const_vector [NFC]
Pan Li [Wed, 16 Apr 2025 03:16:21 +0000 (11:16 +0800)] 
RISC-V: Extract vec_duplicate for expand_const_vector [NFC]

Consider the expand_const_vector is quit long (about 500 lines)
and complicated, we would like to extract the different case
into different functions.  For example, the const vec_duplicate
will be extracted into expand_const_vec_duplicate.

The below test suites are passed for this patch.
* The rv64gcv fully regression test.

gcc/ChangeLog:

* config/riscv/riscv-v.cc (expand_const_vector): Extract
const vec_duplicate into separated function.
(expand_const_vec_duplicate): Add new func to take care
of the const vec_duplicate.

Signed-off-by: Pan Li <pan2.li@intel.com>
3 months agoRefactor msse4 and mno-sse4.
liuhongt [Tue, 1 Apr 2025 07:30:07 +0000 (00:30 -0700)] 
Refactor msse4 and mno-sse4.

gcc/ChangeLog:

PR target/119549
* common/config/i386/i386-common.cc (ix86_handle_option):
Refactor msse4 and mno-sse4.
* config/i386/i386.opt (msse4): Remove RejectNegative.
(mno-sse4): Remove the entry.
* config/i386/i386-options.cc
(ix86_valid_target_attribute_inner_p): Remove special code
which handles mno-sse4.

3 months agoDaily bump.
GCC Administrator [Sun, 27 Apr 2025 00:16:47 +0000 (00:16 +0000)] 
Daily bump.

3 months agoFix i386 vectorizer cost of FP scalar MAX_EXPR and MIN_EXPR
Jan Hubicka [Sat, 26 Apr 2025 20:10:19 +0000 (22:10 +0200)] 
Fix i386 vectorizer cost of FP scalar MAX_EXPR and MIN_EXPR

I introduced a bug by last minute cleanups unifying the scalar and vector SSE conditional.
This patch fixes it and restores cost of 1 of SSE scalar MIN/MAX

Bootstrapped/regtested x86_64-linux, comitted.

gcc/ChangeLog:

PR target/105275
* config/i386/i386.cc (ix86_vector_costs::add_stmt_cost): Fix cost of FP scalar
MAX_EXPR and MIN_EXPR

3 months agoAdd m32c*-*-* to the list of obsolete targets
Iain Buclaw [Fri, 25 Apr 2025 17:45:07 +0000 (19:45 +0200)] 
Add m32c*-*-* to the list of obsolete targets

This patch marks m32c*-*-* targets obsolete in GCC 16.  The target has
not had a maintainer since GCC 9, and fails to compile even the
simplest of functions since GCC 8 (reported in PR83670).

contrib/ChangeLog:

* config-list.mk: Add m32c*-*-* to the list of obsoleted targets.

gcc/ChangeLog:

* config.gcc (LIST): --enable-obsolete for m32c-elf.

3 months agosimplify-rtx: Simplify `(zero_extend (and x CST))` -> (and (subreg x) CST)
Andrew Pinski [Wed, 5 Feb 2025 22:44:25 +0000 (14:44 -0800)] 
simplify-rtx: Simplify `(zero_extend (and x CST))` -> (and (subreg x) CST)

This adds the simplification of a ZERO_EXTEND of an AND. This optimization
was already handled in combine via combine_simplify_rtx and the handling
there of compound_operations (ZERO_EXTRACT).

Build and tested for aarch64-linux-gnu.
Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

* simplify-rtx.cc (simplify_context::simplify_unary_operation_1) <case ZERO_EXTEND>:
Add simplifcation for and with a constant.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
3 months agoDaily bump.
GCC Administrator [Sat, 26 Apr 2025 00:19:18 +0000 (00:19 +0000)] 
Daily bump.

3 months agotestsuite: Skip tests incompatible with generic thunk support
Dimitar Dimitrov [Sat, 11 Jan 2025 16:03:15 +0000 (18:03 +0200)] 
testsuite: Skip tests incompatible with generic thunk support

Some backends do not define TARGET_ASM_OUTPUT_MI_THUNK.  But the generic
thunk support cannot emit code for calling variadic methods of
multiple-inheritance classes.  Example error for pru-unknown-elf:

 .../gcc/gcc/testsuite/g++.dg/ipa/pr83549.C:7:24: error: generic thunk code fails for method 'virtual void C::_ZThn4_N1C3fooEz(...)' which uses '...'

Disable the affected tests for all targets which do not define
TARGET_ASM_OUTPUT_MI_THUNK.

Ensured that test results with and without this patch for
x86_64-pc-linux-gnu are the same.

gcc/ChangeLog:

* doc/sourcebuild.texi: Document variadic_mi_thunk effective
target check.

gcc/testsuite/ChangeLog:

* g++.dg/ipa/pr83549.C: Require effective target
variadic_mi_thunk.
* g++.dg/ipa/pr83667.C: Ditto.
* g++.dg/torture/pr81812.C: Ditto.
* g++.old-deja/g++.jason/thunk3.C: Ditto.
* lib/target-supports.exp
(check_effective_target_variadic_mi_thunk): New function.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
3 months agotestsuite: Add require target for SJLJ exception implementation
Dimitar Dimitrov [Sat, 18 Jan 2025 15:10:43 +0000 (17:10 +0200)] 
testsuite: Add require target for SJLJ exception implementation

Testcases for musttail call optimization fail on pru-unknown-elf:
  FAIL: c-c++-common/musttail14.c  -std=gnu++17 (test for excess errors)
  Excess errors:
  .../gcc/gcc/testsuite/c-c++-common/musttail14.c:37:14: error: cannot tail-call: caller uses sjlj exceptions

Silence these errors by disabling the tests if target uses SJLJ for
implementing exceptions.  Use a new effective target check for this.

Ensured that test results with and without this patch for
x86_64-pc-linux-gnu are the same.

gcc/ChangeLog:

* doc/sourcebuild.texi: Document effective target
using_sjlj_exceptions.

gcc/testsuite/ChangeLog:

* c-c++-common/musttail14.c: Disable test if effective target
using_sjlj_exceptions.
* c-c++-common/musttail22.c: Ditto.
* g++.dg/musttail8.C: Ditto.
* g++.dg/musttail9.C: Ditto.
* g++.dg/opt/musttail3.C: Ditto.
* g++.dg/opt/musttail4.C: Ditto.
* g++.dg/opt/musttail5.C: Ditto.
* g++.dg/opt/pr119613.C: Ditto.
* lib/target-supports.exp
(check_effective_target_using_sjlj_exceptions): New check.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
3 months agolibstdc++: Use markdown in some Doxygen comments
Jonathan Wakely [Fri, 25 Apr 2025 15:14:19 +0000 (16:14 +0100)] 
libstdc++: Use markdown in some Doxygen comments

libstdc++-v3/ChangeLog:

* include/bits/ptr_traits.h (to_address): Use markdown for
formatting in Doxygen comments.

3 months agolibstdc++: Add some makefile dependencies
Jonathan Wakely [Thu, 10 Apr 2025 11:56:43 +0000 (12:56 +0100)] 
libstdc++: Add some makefile dependencies

This ensures that wstring-inst.o and similar files will be rebuilt when
string-inst.cc changes.

libstdc++-v3/ChangeLog:

* src/c++11/Makefile.am: Add prerequisites for targets that
depend on string-inst.cc.
* src/c++11/Makefile.in: Regenerate.

3 months agolibstdc++: Micro-optimization for std::addressof
Jonathan Wakely [Fri, 25 Apr 2025 14:49:22 +0000 (15:49 +0100)] 
libstdc++: Micro-optimization for std::addressof

Currently std::addressof calls std::__addressof which uses
__builtin_addressof. This leads to me prefering std::__addressof in some
code, to avoid the extra hop. But it's not as though the implementation
of std::__addressof is complicated and reusing it avoids any code
duplication.

So let's just make std::addressof use the built-in directly, and then we
only need to use std::__addressof in C++98 code. (Transitioning existing
uses of std::__addressof to std::addressof isn't included in this
change.)

The front end does fold std::addressof with -ffold-simple-inlines but
this change still seems worthwhile.

libstdc++-v3/ChangeLog:

* include/bits/move.h (addressof): Use __builtin_addressof
directly.

3 months agolibstdc++: Remove c++26 dg-error lines for -Wdelete-incomplete errors
Jonathan Wakely [Fri, 25 Apr 2025 14:57:56 +0000 (15:57 +0100)] 
libstdc++: Remove c++26 dg-error lines for -Wdelete-incomplete errors

This fixes:
FAIL: tr1/2_general_utilities/shared_ptr/cons/43820_neg.cc  -std=gnu++26  (test for errors, line 283)
FAIL: tr1/2_general_utilities/shared_ptr/cons/43820_neg.cc  -std=gnu++26  (test for errors, line 305)

This is another consequence of r16-133-g8acea9ffa82ed8 which prevents
the -Wdelete-incomplete errors that happen after the first error.

libstdc++-v3/ChangeLog:

* testsuite/tr1/2_general_utilities/shared_ptr/cons/43820_neg.cc:
Remove dg-error directives for additional c++26 errors.

3 months agomatch: Move `(cmp (cond @0 @1 @2) @3)` simplification after the bool compare simplifc...
Andrew Pinski [Tue, 22 Apr 2025 22:13:39 +0000 (15:13 -0700)] 
match: Move `(cmp (cond @0 @1 @2) @3)` simplification after the bool compare simplifcation

This moves the `(cmp (cond @0 @1 @2) @3)` simplifcation to be after the boolean comparison
simplifcations so that we don't end up simplifing into the same thing for a GIMPLE_COND.

gcc/ChangeLog:

* match.pd: Move `(cmp (cond @0 @1 @2) @3)` simplifcation after
the bool comparison simplifications.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
3 months agogimple: Fix comment before gimple_cond_make_false/gimple_cond_make_true
Andrew Pinski [Wed, 23 Apr 2025 20:48:16 +0000 (13:48 -0700)] 
gimple: Fix comment before gimple_cond_make_false/gimple_cond_make_true

I noticed the comments and the code don't match.
The correct form is:
'if (0 != 0)': false
and
'if (1 != 0)': true

That is always NE and always 0 as the second operand.

Also there is a spello for statement in the comment in
front of gimple_cond_true_p.

Pushed as obvious.

gcc/ChangeLog:

* gimple.h (gimple_cond_make_false): Fix comment.
(gimple_cond_make_true): Likewise.
(gimple_cond_true_p): Fix spello for statement in comment.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
3 months agoFortran: fix procedure pointer handling with -fcheck=pointer [PR102900]
Harald Anlauf [Thu, 24 Apr 2025 19:28:35 +0000 (21:28 +0200)] 
Fortran: fix procedure pointer handling with -fcheck=pointer [PR102900]

PR fortran/102900

gcc/fortran/ChangeLog:

* trans-decl.cc (gfc_generate_function_code): Use sym->result
when generating fake result decl for functions returning
allocatable or pointer results.
* trans-expr.cc (gfc_conv_procedure_call): When checking the
pointer status of an actual argument passed to a non-allocatable,
non-pointer dummy which is of type CLASS, do not check the
class container of the actual if it is just a procedure pointer.
(gfc_trans_pointer_assignment): Fix treatment of assignment to
NULL of a procedure pointer.

gcc/testsuite/ChangeLog:

* gfortran.dg/proc_ptr_52.f90: Add -fcheck=pointer to options.
* gfortran.dg/proc_ptr_57.f90: New test.

3 months agoc++: pruning non-captures in noexcept lambda [PR119764]
Jason Merrill [Mon, 14 Apr 2025 16:18:06 +0000 (12:18 -0400)] 
c++: pruning non-captures in noexcept lambda [PR119764]

The patch for PR87185 fixed the ICE without fixing the underlying problem,
that we were failing to find the declaration of the capture proxy that we
are trying to decide whether to prune.  Fixed by looking at the right index
in stmt_list_stack.

Since this changes captures, it changes the ABI of noexcept lambdas; we
haven't worked hard to maintain lambda capture ABI, but it's easy enough to
control here.

PR c++/119764
PR c++/87185

gcc/cp/ChangeLog:

* lambda.cc (insert_capture_proxy): Handle noexcept lambda.
(prune_lambda_captures): Likewise, in ABI v21.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/lambda/lambda-noexcept1.C: New test.

3 months agoc++: add -fabi-version=21
Jason Merrill [Tue, 22 Apr 2025 20:37:30 +0000 (16:37 -0400)] 
c++: add -fabi-version=21

I'm about to add a bugfix that changes the ABI of noexcept lambdas, so first
let's add the new ABI version.  And I think it's time to update the
compatibility version; let's bump to GCC 13, before the addition of concepts
mangling.

gcc/ChangeLog:

* common.opt: Add ABI v21.

gcc/c-family/ChangeLog:

* c-opts.cc (c_common_post_options): Bump default ABI to 21
and compat ABI to 18.

gcc/testsuite/ChangeLog:

* g++.dg/abi/macro0.C: Update for -fabi-version=21.

3 months agolibstdc++: Rename std::latch data member
Jonathan Wakely [Thu, 30 Jan 2025 12:07:48 +0000 (12:07 +0000)] 
libstdc++: Rename std::latch data member

Rename _M_a to match the name of the exposition-only data member shown
in the standard, i.e. 'counter'.

libstdc++-v3/ChangeLog:

* include/std/latch (latch::_M_a): Rename to _M_counter.

Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
3 months agoicf: Remove unused constructors of sem_function and sem_variable
Andrew Pinski [Tue, 25 Mar 2025 05:32:54 +0000 (22:32 -0700)] 
icf: Remove unused constructors of sem_function and sem_variable

The constructors for sem_function and sem_variable that just
passes the bitmap obstack and NOT the cgraph node was unused
so let's remove it.

gcc/ChangeLog:

* ipa-icf.cc (sem_function::sem_function): Remove
the obstack argument version one.
(sem_variable::sem_variable): Likewise.
* ipa-icf.h (sem_function): Remove ctor for
obstack argument only one.
(sem_variable): Likewise.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
3 months agoicf: Remove nop code from sem_function::init.
Andrew Pinski [Tue, 25 Mar 2025 05:27:30 +0000 (22:27 -0700)] 
icf: Remove nop code from sem_function::init.

Here we had:
  node = node;
Which does nothing so let's remove it.

gcc/ChangeLog:

* ipa-icf.cc (sem_function::init): Remove assignment of node from itself.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
3 months agophiopt: Remove calls.h include [PR119811]
Andrew Pinski [Sat, 19 Apr 2025 00:10:12 +0000 (17:10 -0700)] 
phiopt: Remove calls.h include [PR119811]

When the patch, https://gcc.gnu.org/pipermail/gcc-patches/2024-August/660807.html was rewroked into r15-3047-g404d947d8ddd3c,
the include for calls.h was still included and missed that it was no longer needed.

Pushed as obvious.

PR tree-optimization/119811
gcc/ChangeLog:

* tree-ssa-phiopt.cc: Remove calls.h include.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
3 months agocobol: New testcases.
Robert Dubner [Fri, 25 Apr 2025 14:19:35 +0000 (10:19 -0400)] 
cobol: New testcases.

These testcases are derived from the cobolworx run_fundamental.at file.

gcc/testsuite

* cobol.dg/group2/88_level_with_FALSE_IS_clause.cob: New testcase.
* cobol.dg/group2/88_level_with_FILLER.cob: Likewise.
* cobol.dg/group2/88_level_with_THRU.cob: Likewise.
* cobol.dg/group2/ADD_CORRESPONDING.cob: Likewise.
* cobol.dg/group2/ADD_SUBTRACT_CORR_mixed_fix___float.cob: Likewise.
* cobol.dg/group2/ALPHABETIC-LOWER_test.cob: Likewise.
* cobol.dg/group2/ALPHABETIC_test.cob: Likewise.
* cobol.dg/group2/ALPHABETIC-UPPER_test.cob: Likewise.
* cobol.dg/group2/BLANK_WHEN_ZERO.cob: Likewise.
* cobol.dg/group2/Check_for_equality_of_COMP-1___COMP-2.cob: Likewise.
* cobol.dg/group2/Compare_COMP-2_with_floating-point_literal.cob: Likewise.
* cobol.dg/group2/Contained_program_visibility__3_.cob: Likewise.
* cobol.dg/group2/Contained_program_visibility__4_.cob: Likewise.
* cobol.dg/group2/Context_sensitive_words__1_.cob: Likewise.
* cobol.dg/group2/Context_sensitive_words__2_.cob: Likewise.
* cobol.dg/group2/Context_sensitive_words__3_.cob: Likewise.
* cobol.dg/group2/Context_sensitive_words__4_.cob: Likewise.
* cobol.dg/group2/Context_sensitive_words__5_.cob: Likewise.
* cobol.dg/group2/Context_sensitive_words__6_.cob: Likewise.
* cobol.dg/group2/Context_sensitive_words__7_.cob: Likewise.
* cobol.dg/group2/Context_sensitive_words__8_.cob: Likewise.
* cobol.dg/group2/debugging_lines__not_active_.cob: Likewise.
* cobol.dg/group2/debugging_lines__WITH_DEBUGGING_MODE_.cob: Likewise.
* cobol.dg/group2/DEBUG_Line.cob: Likewise.
* cobol.dg/group2/DISPLAY_and_assignment_NumericDisplay.cob: Likewise.
* cobol.dg/group2/DISPLAY_data_items_with_MOVE_statement.cob: Likewise.
* cobol.dg/group2/DISPLAY_data_items_with_VALUE_clause.cob: Likewise.
* cobol.dg/group2/DISPLAY_literals__DECIMAL-POINT_is_COMMA.cob: Likewise.
* cobol.dg/group2/GLOBAL_at_lower_level.cob: Likewise.
* cobol.dg/group2/GLOBAL_at_same_level.cob: Likewise.
* cobol.dg/group2/GLOBAL_FD__1_.cob: Likewise.
* cobol.dg/group2/GLOBAL_FD__2_.cob: Likewise.
* cobol.dg/group2/GLOBAL_FD__3_.cob: Likewise.
* cobol.dg/group2/GLOBAL_FD__4_.cob: Likewise.
* cobol.dg/group2/Hexadecimal_literal.cob: Likewise.
* cobol.dg/group2/integer_arithmetic_on_floating-point_var.cob: Likewise.
* cobol.dg/group2/MULTIPLY_BY_literal_in_INITIAL_program.cob: Likewise.
* cobol.dg/group2/Named_conditionals_-_fixed__float__and_alphabetic.cob: Likewise.
* cobol.dg/group2/Numeric_operations__1_.cob: Likewise.
* cobol.dg/group2/Numeric_operations__2_.cob: Likewise.
* cobol.dg/group2/Numeric_operations__3_.cob: Likewise.
* cobol.dg/group2/Numeric_operations__4_.cob: Likewise.
* cobol.dg/group2/Numeric_operations__5_.cob: Likewise.
* cobol.dg/group2/Numeric_operations__7_.cob: Likewise.
* cobol.dg/group2/Numeric_operations__8_.cob: Likewise.
* cobol.dg/group2/ROUNDED_AWAY-FROM-ZERO.cob: Likewise.
* cobol.dg/group2/ROUNDED_NEAREST-AWAY-FROM-ZERO.cob: Likewise.
* cobol.dg/group2/ROUNDED_NEAREST-EVEN.cob: Likewise.
* cobol.dg/group2/ROUNDED_NEAREST-TOWARD-ZERO.cob: Likewise.
* cobol.dg/group2/ROUNDED_TOWARD-GREATER.cob: Likewise.
* cobol.dg/group2/ROUNDED_TOWARD-LESSER.cob: Likewise.
* cobol.dg/group2/ROUNDED_TRUNCATION.cob: Likewise.
* cobol.dg/group2/ROUNDING_omnibus_Floating-Point_from_COMPUTE.cob: Likewise.
* cobol.dg/group2/ROUNDING_omnibus_NumericDisplay_from_COMPUTE.cob: Likewise.
* cobol.dg/group2/Separate_sign_positions__1_.cob: Likewise.
* cobol.dg/group2/Separate_sign_positions__2_.cob: Likewise.
* cobol.dg/group2/Simple_p-scaling.cob: Likewise.
* cobol.dg/group2/Simple_TYPEDEF.cob: Likewise.
* cobol.dg/group2/ADD_SUBTRACT_CORR_mixed_fix___float.out: New known-good result.
* cobol.dg/group2/BLANK_WHEN_ZERO.out: Likewise.
* cobol.dg/group2/Contained_program_visibility__4_.out: Likewise.
* cobol.dg/group2/Context_sensitive_words__1_.out: Likewise.
* cobol.dg/group2/Context_sensitive_words__2_.out: Likewise.
* cobol.dg/group2/Context_sensitive_words__3_.out: Likewise.
* cobol.dg/group2/Context_sensitive_words__4_.out: Likewise.
* cobol.dg/group2/Context_sensitive_words__5_.out: Likewise.
* cobol.dg/group2/Context_sensitive_words__6_.out: Likewise.
* cobol.dg/group2/Context_sensitive_words__7_.out: Likewise.
* cobol.dg/group2/Context_sensitive_words__8_.out: Likewise.
* cobol.dg/group2/debugging_lines__not_active_.out: Likewise.
* cobol.dg/group2/debugging_lines__WITH_DEBUGGING_MODE_.out: Likewise.
* cobol.dg/group2/DEBUG_Line.out: Likewise.
* cobol.dg/group2/DISPLAY_and_assignment_NumericDisplay.out: Likewise.
* cobol.dg/group2/DISPLAY_data_items_with_MOVE_statement.out: Likewise.
* cobol.dg/group2/DISPLAY_data_items_with_VALUE_clause.out: Likewise.
* cobol.dg/group2/DISPLAY_literals__DECIMAL-POINT_is_COMMA.out: Likewise.
* cobol.dg/group2/GLOBAL_at_lower_level.out: Likewise.
* cobol.dg/group2/GLOBAL_at_same_level.out: Likewise.
* cobol.dg/group2/Hexadecimal_literal.out: Likewise.
* cobol.dg/group2/Named_conditionals_-_fixed__float__and_alphabetic.out: Likewise.
* cobol.dg/group2/ROUNDED_AWAY-FROM-ZERO.out: Likewise.
* cobol.dg/group2/ROUNDED_NEAREST-AWAY-FROM-ZERO.out: Likewise.
* cobol.dg/group2/ROUNDED_NEAREST-EVEN.out: Likewise.
* cobol.dg/group2/ROUNDED_NEAREST-TOWARD-ZERO.out: Likewise.
* cobol.dg/group2/ROUNDED_TOWARD-GREATER.out: Likewise.
* cobol.dg/group2/ROUNDED_TOWARD-LESSER.out: Likewise.
* cobol.dg/group2/ROUNDED_TRUNCATION.out: Likewise.
* cobol.dg/group2/ROUNDING_omnibus_Floating-Point_from_COMPUTE.out: Likewise.
* cobol.dg/group2/ROUNDING_omnibus_NumericDisplay_from_COMPUTE.out: Likewise.
* cobol.dg/group2/Separate_sign_positions__1_.out: Likewise.
* cobol.dg/group2/Separate_sign_positions__2_.out: Likewise.
* cobol.dg/group2/Simple_p-scaling.out: Likewise.

3 months agolibstdc++: Minimalize temporary allocations when width is specified [PR109162]
Tomasz Kamiński [Wed, 23 Apr 2025 11:17:09 +0000 (13:17 +0200)] 
libstdc++: Minimalize temporary allocations when width is specified [PR109162]

When width parameter is specified for formatting range, tuple or escaped
presentation of string, we used to format characters to temporary string,
and write produce sequence padded according to the spec. However, once the
estimated width of formatted representation of input is larger than the value
of spec width, it can be written directly to the output. This limits size of
required allocation, especially for large ranges.

Similarly, if precision (maximum) width is provided for string presentation,
only a prefix of sequence with estimated width not greater than precision, needs
to be buffered.

To realize above, this commit implements a new _Padding_sink specialization.
This sink holds an output iterator, a value of padding width, (optionally)
maximum width and a string buffer inherited from _Str_sink.
Then any incoming characters are treated in one of following ways, depending of
estimated width W of written sequence:
* written to string if W is smaller than padding width and maximum width (if present)
* ignored, if W is greater than maximum width
* written to output iterator, if W is greater than padding width

The padding sink is used instead of _Str_sink in __format::__format_padded,
__formatter_str::_M_format_escaped functions.

Furthermore __formatter_str::_M_format implementation was reworked, to:
* reduce number of instantiations by delegating to _Rg& and const _Rg& overloads,
* non-debug presentation is written to _Out directly or via _Padding_sink
* if maximum width is specified for debug format with non-unicode encoding,
  string size is limited to that number.

PR libstdc++/109162

libstdc++-v3/ChangeLog:

* include/bits/formatfwd.h (__simply_formattable_range): Moved from
std/format.
* include/std/format (__formatter_str::_format): Extracted escaped
string handling to separate method...
(__formatter_str::_M_format_escaped): Use __Padding_sink.
(__formatter_str::_M_format): Adjusted implementation.
(__formatter_str::_S_trunc): Extracted as namespace function...
(__format::_truncate): Extracted from __formatter_str::_S_trunc.
(__format::_Seq_sink): Removed forward declarations, made members
protected and non-final.
(_Seq_sink::_M_trim): Define.
(_Seq_sink::_M_span): Renamed from view.
(_Seq_sink::view): Returns string_view instead of span.
(__format::_Str_sink): Moved after _Seq_sink.
(__format::__format_padded): Use _Padding_sink.
* testsuite/std/format/debug.cc: Add timeout and new tests.
* testsuite/std/format/ranges/sequence.cc: Specify unicode as
encoding and new tests.
* testsuite/std/format/ranges/string.cc: Likewise.
* testsuite/std/format/tuple.cc: Likewise.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
3 months agolibstdc++: Replace leftover std::queue with Adaptor in ranges/adaptors.cc.
Tomasz Kamiński [Fri, 25 Apr 2025 12:55:30 +0000 (14:55 +0200)] 
libstdc++: Replace leftover std::queue with Adaptor in ranges/adaptors.cc.

This was leftover from  work-in-progress state, where only std::queue was
tested.

libstdc++-v3/ChangeLog:

* testsuite/std/format/ranges/adaptors.cc: Updated test.

3 months agomodulo-sched: reject loop conditions when not decrementing with one [PR 116479]
Andre Vieira [Fri, 25 Apr 2025 13:02:43 +0000 (14:02 +0100)] 
modulo-sched: reject loop conditions when not decrementing with one [PR 116479]

In the commit titled 'doloop: Add support for predicated vectorized loops' the
doloop_condition_get function was changed to accept loops with decrements
larger than 1.  This patch rejects such loops for modulo-sched.

gcc/ChangeLog:

PR rtl-optimization/116479
* modulo-sched.cc (doloop_register_get): Reject conditions with
decrements that are not 1.

gcc/testsuite/ChangeLog:

* gcc.dg/pr116479.c: New test.

3 months agos390: Allow 5+ argument tail-calls in some -m31 -mzarch special cases [PR119873]
Jakub Jelinek [Fri, 25 Apr 2025 12:42:01 +0000 (14:42 +0200)] 
s390: Allow 5+ argument tail-calls in some -m31 -mzarch special cases [PR119873]

Here is a patch to handle the PARALLEL case too.
I think we can just use rtx_equal_p there, because it will always use
SImode in the EXPR_LIST REGs in that case.

2025-04-25  Jakub Jelinek  <jakub@redhat.com>

PR target/119873
* config/s390/s390.cc (s390_call_saved_register_used): Don't return
true if default definition of PARM_DECL SSA_NAME of the same register
is passed in call saved register in the PARALLEL case either.

* gcc.target/s390/pr119873-5.c: New test.

3 months agolibstdc++: Remove c++98_only dg-error
Jonathan Wakely [Fri, 25 Apr 2025 11:35:01 +0000 (12:35 +0100)] 
libstdc++: Remove c++98_only dg-error

This fixes
FAIL: 22_locale/ctype/is/string/89728_neg.cc  -std=gnu++98  (test for errors, line )

Since r16-133-g8acea9ffa82ed8 we don't keep issuing more errors after
the first one, so this dg-error no longer matches anything.

libstdc++-v3/ChangeLog:

* testsuite/22_locale/ctype/is/string/89728_neg.cc: Remove
dg-error for c++98_only effective target.