]> git.ipfire.org Git - thirdparty/gcc.git/log
thirdparty/gcc.git
16 months agoRemove unsafe block empty visit function
Pierre-Emmanuel Patry [Tue, 6 Feb 2024 14:13:17 +0000 (15:13 +0100)] 
Remove unsafe block empty visit function

We need to visit subcomponents in unsafe elements, this means we can
leverage the default ast visitor's code instead of duplicating it.

gcc/rust/ChangeLog:

* resolve/rust-default-resolver.cc (DefaultResolver::visit): Remove
empty visit function.
* resolve/rust-default-resolver.h: Remove function prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
16 months agoRemove extern block scoping
Pierre-Emmanuel Patry [Tue, 6 Feb 2024 14:10:44 +0000 (15:10 +0100)] 
Remove extern block scoping

Remove extern block scoping visit function, use the default visitor visit
function instead. We do not need scoping for extern block as their
element shall be visible from the extern block scope.

gcc/rust/ChangeLog:

* resolve/rust-default-resolver.cc (DefaultResolver::visit): Remove
visitor implementation and scoping.
* resolve/rust-default-resolver.h: Remove function prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
16 months agoAdd constant identifiers to the value namespace
Pierre-Emmanuel Patry [Wed, 24 Jan 2024 16:11:59 +0000 (17:11 +0100)] 
Add constant identifiers to the value namespace

Constants could not be resolved without their identifier in the right
scope.

gcc/rust/ChangeLog:

* resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit): Add
constant identifiers to the resolver.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
16 months agoStruct are types, not values
Pierre-Emmanuel Patry [Wed, 24 Jan 2024 16:10:42 +0000 (17:10 +0100)] 
Struct are types, not values

We shall search in the right namespace. The correct namespace for struct
is type namespace.

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit): Change
search location for struct types.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
16 months agoChange enum namespace from value to type
Pierre-Emmanuel Patry [Wed, 24 Jan 2024 16:08:05 +0000 (17:08 +0100)] 
Change enum namespace from value to type

The enum type shall be in type namespace, not value namespace.

gcc/rust/ChangeLog:

* resolve/rust-toplevel-name-resolver-2.0.cc (GlobbingVisitor::visit):
Change enum type namespace.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
16 months agoAdd tuple struct to the type namespace
Pierre-Emmanuel Patry [Wed, 24 Jan 2024 16:06:56 +0000 (17:06 +0100)] 
Add tuple struct to the type namespace

Only tuple struct constructor was added to the resolver.

gcc/rust/ChangeLog:

* resolve/rust-toplevel-name-resolver-2.0.cc (GlobbingVisitor::visit):
Add tuple struct type to the resolver's context.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
16 months agoUnit struct constructor shall be resolved
Pierre-Emmanuel Patry [Wed, 24 Jan 2024 16:04:51 +0000 (17:04 +0100)] 
Unit struct constructor shall be resolved

Unit struct have a special constructor that should be added to the struct
namespace in order to be resolved later when called. As it is a function
it should be added in the value namespace.

gcc/rust/ChangeLog:

* resolve/rust-toplevel-name-resolver-2.0.cc (GlobbingVisitor::visit):
Add the struct constructor when the struct is a unit.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
16 months agoValues shall be inserted in the value namespace
Pierre-Emmanuel Patry [Wed, 24 Jan 2024 16:00:29 +0000 (17:00 +0100)] 
Values shall be inserted in the value namespace

Values were inserted in the label namespace instead of the value
namespace this lead to several bugs.

gcc/rust/ChangeLog:

* resolve/rust-late-name-resolver-2.0.cc (Late::visit): Change the
namespace for values from "label" to "values".

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
16 months agoRaw pointer type visitor didn't require overload
Pierre-Emmanuel Patry [Wed, 24 Jan 2024 15:57:37 +0000 (16:57 +0100)] 
Raw pointer type visitor didn't require overload

This overload did not dispatch the visitor to sub members of a raw
pointer like the default one. It is therefore useless as pointed type
shall be visited to be resolved correctly.

gcc/rust/ChangeLog:

* resolve/rust-default-resolver.cc (DefaultResolver::visit): Remove
function implementation.
* resolve/rust-default-resolver.h: Remove function prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
16 months agoVisit constant item type in default resolver
Pierre-Emmanuel Patry [Wed, 24 Jan 2024 15:50:27 +0000 (16:50 +0100)] 
Visit constant item type in default resolver

The type of constant item expression was not properly visited in the
default resolver.

gcc/rust/ChangeLog:

* resolve/rust-default-resolver.cc (DefaultResolver::visit): Visit
constant item's types.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
16 months agoVisit function return type in default resolver
Pierre-Emmanuel Patry [Wed, 24 Jan 2024 15:47:50 +0000 (16:47 +0100)] 
Visit function return type in default resolver

Function return type was not properly visited in the default resolver
visitor pattern.

gcc/rust/ChangeLog:

* resolve/rust-default-resolver.cc (DefaultResolver::visit): Visit
function return type.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
16 months agoChange error message to match test
Pierre-Emmanuel Patry [Wed, 17 Jan 2024 12:53:21 +0000 (13:53 +0100)] 
Change error message to match test

Error message did not match the test from the previous name resolver when
a given path cannot be resolved.

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-path.cc (TypeCheckExpr::resolve_root_path):
Change error message to match old resolver and test case.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
16 months agoAdd tuple struct constructor to value namespace
Pierre-Emmanuel Patry [Wed, 17 Jan 2024 12:02:51 +0000 (13:02 +0100)] 
Add tuple struct constructor to value namespace

A tuple struct constructor should be inserted in the value namespace
during name resolution in order to reject multiple definitions of the
function.

gcc/rust/ChangeLog:

* resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit): Add
the struct constructor to the value namespace.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
16 months agoAdd support for ambiguous use declarations
Pierre-Emmanuel Patry [Tue, 16 Jan 2024 12:55:02 +0000 (13:55 +0100)] 
Add support for ambiguous use declarations

Glob use declarations may lead to ambiguous situation where two
definitions with the same name are imported in a given scope. The
compiler now handles shadowable items inserted after non shadowable
items. An error is now thrown when multiple shadowable items are imported
and used in the same rib.

gcc/rust/ChangeLog:

* resolve/rust-early-name-resolver-2.0.cc (Early::visit): Adapt
resolved type to the new API.
(Early::visit_attributes): Retrieve the node id from the definition.
* resolve/rust-forever-stack.h: Change the return type of getter
functions. Those functions now return a definition type instead of a
node id.
* resolve/rust-forever-stack.hxx: Change member function implementation
in the forever stack to accomodate it's API changes.
* resolve/rust-late-name-resolver-2.0.cc (Late::visit): Use internal
node id. Emit an error when resolving multiple ambiguous values.
* resolve/rust-rib.cc (Rib::Definition::Definition): Add a default
constructor.
(Rib::Definition::is_ambiguous): Add a new function to determine
whether a function definition is ambiguous or not.
(Rib::Definition::to_string): Add a member function to convert a given
definition to a string.
(Rib::insert): Add new rules for value insertion in a rib. Insertion
order does not impact the result anymore: inserting a shadowable value
after a non shadowable one does not trigger an error anymore. All
shadowable values inserted in a rib are kepts until being replaced by a
non shadowable one.
(Rib::get): Return a definition instead of a node id.
* resolve/rust-rib.h: Update function prototypes.
* resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::handle_use_glob):
Update return value container to match the new function's prototype.
(TopLevel::handle_use_dec): Likewise.
(flatten_glob): Likewise.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
16 months agoMake globbing definition shadowable by default
Pierre-Emmanuel Patry [Mon, 15 Jan 2024 15:34:36 +0000 (16:34 +0100)] 
Make globbing definition shadowable by default

Elements from glob use declaration shall be shadowable by default.

gcc/rust/ChangeLog:

* resolve/rust-forever-stack.h: Add a new function prototype to insert
a shadowable definition.
* resolve/rust-forever-stack.hxx: Add the new insert_shadowable
function to insert shadowable definition into the forever stack.
* resolve/rust-name-resolution-context.cc (NameResolutionContext::insert_shadowable):
Likewise with the name resolution context.
* resolve/rust-name-resolution-context.h: Add name resolution context
insert_shadowable member function prototype.
* resolve/rust-toplevel-name-resolver-2.0.cc (GlobbingVisitor::visit):
Insert shadowable definition into the forever stack for glob use
declaration.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
16 months agoAdd call to globbing visitor
Pierre-Emmanuel Patry [Mon, 15 Jan 2024 12:41:01 +0000 (13:41 +0100)] 
Add call to globbing visitor

Globbing visitor did not visit subitems.

gcc/rust/ChangeLog:

* resolve/rust-late-name-resolver-2.0.cc (Late::visit): Add a check
for missing item.
* resolve/rust-toplevel-name-resolver-2.0.cc (GlobbingVisitor::go):
Add a new function in the visitor to dispatch the visitor to items in
the given module.
(TopLevel::handle_use_glob): Change call to visitor to use the pointer.
* resolve/rust-toplevel-name-resolver-2.0.h: Add prototype for new
member function.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
16 months agoShape up name resolver for normal direct calls
Pierre-Emmanuel Patry [Wed, 10 Jan 2024 15:44:09 +0000 (16:44 +0100)] 
Shape up name resolver for normal direct calls

Direct function calls did not work anymore due to the transition to the
new resolver.

gcc/rust/ChangeLog:

* checks/lints/rust-lint-marklive.cc (MarkLive::find_ref_node_id):
Add code path for the resolver 2.0
* resolve/rust-late-name-resolver-2.0.cc (Late::visit): Remove failing
label context resolve call.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
16 months agoAdd name resolution for on globbing use decl
Pierre-Emmanuel Patry [Tue, 9 Jan 2024 12:51:35 +0000 (13:51 +0100)] 
Add name resolution for on globbing use decl

This is the first part of the code required to enable globbing on use
declarations.

gcc/rust/ChangeLog:

* resolve/rust-toplevel-name-resolver-2.0.cc (GlobbingVisitor::visit):
Insert names into their namespace.
(TopLevel::visit): Insert ast module.
(TopLevel::handle_use_dec): Resolve use declaration.
(TopLevel::handle_use_glob): Use globbing visitor.
(flatten_list): Use globbing path vector.
(flatten_glob): Likewise.
(flatten): Likewise.
(prefix_subpaths): Add a function to prefix subpath.
* resolve/rust-toplevel-name-resolver-2.0.h (class GlobbingVisitor):
Add globbing visitor.
* util/rust-hir-map.cc (Mappings::insert_ast_module): Add function to
insert module in module hashmap.
(Mappings::lookup_ast_module): Add function to retrieve ast module.
* util/rust-hir-map.h: Add module map and getter/setter prototypes.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
16 months agoAdd modules to type namespace
Pierre-Emmanuel Patry [Mon, 8 Jan 2024 14:18:36 +0000 (15:18 +0100)] 
Add modules to type namespace

gcc/rust/ChangeLog:

* resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit): Module
should be added to the type namespace in order to be retrieved later.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
16 months agolate: Add bool builtin type
Arthur Cohen [Wed, 8 Nov 2023 23:39:46 +0000 (00:39 +0100)] 
late: Add bool builtin type

gcc/rust/ChangeLog:

* resolve/rust-late-name-resolver-2.0.cc (Late::setup_builtin_types):
Setup bool as builtin type.

16 months agoPrevent error emission on resolver reentry
Pierre-Emmanuel Patry [Mon, 18 Sep 2023 13:34:24 +0000 (15:34 +0200)] 
Prevent error emission on resolver reentry

The resolver was emitting an error when meeting the same symbol twice.
What is important here is the origin of the resolved symbol, we should
emit an error when the name is similar but the symbol isn't be not when
the resolver is simply meeting the exact same symbol.

gcc/rust/ChangeLog:

* resolve/rust-toplevel-name-resolver-2.0.cc (insert_macros): Add
constraint over the ast node id.
(TopLevel::visit): Likewise.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
16 months agoChange error message on unresolved import
Pierre-Emmanuel Patry [Sun, 24 Mar 2024 21:23:03 +0000 (22:23 +0100)] 
Change error message on unresolved import

The error message did not match rustc's.

gcc/rust/ChangeLog:

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

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
16 months agoEmit error on identical use declarations
Pierre-Emmanuel Patry [Fri, 15 Sep 2023 11:14:56 +0000 (13:14 +0200)] 
Emit error on identical use declarations

The compiler did not emit any warning when a same target was declared
from different sources.

gcc/rust/ChangeLog:

* resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::handle_use_dec):
Use the new dict to track down already resolved use declarations.
* resolve/rust-toplevel-name-resolver-2.0.h: Add new dict to store
previous use declarations.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
16 months agoFix duplicate detection
Pierre-Emmanuel Patry [Thu, 14 Sep 2023 15:39:37 +0000 (17:39 +0200)] 
Fix duplicate detection

The resolver did report duplicate symbols when being run multiple times
even if the node id was the same. This commit adds an additional
condition, the error will only be reported if the existing node id is
different from the current node id.

gcc/rust/ChangeLog:

* resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::insert_or_error_out):
Add new constraint to duplicate errors.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
16 months agolate: Setup builtin types properly, change Rib API
Arthur Cohen [Mon, 28 Aug 2023 14:40:12 +0000 (16:40 +0200)] 
late: Setup builtin types properly, change Rib API

gcc/rust/ChangeLog:

* resolve/rust-forever-stack.hxx: Start using Rib::Definition for
shadowable information.
* resolve/rust-late-name-resolver-2.0.cc (next_node_id): New.
(next_hir_id): New.
(Late::setup_builtin_types): Improve builtin type setup.
* resolve/rust-rib.cc (Rib::Definition::Definition): New constructor.
(Rib::Definition::Shadowable): Likewise.
(Rib::Definition::NonShadowable): Likewise.
(Rib::Rib): Fix general constructor.
(Rib::insert): Use Definition class.
(Rib::get): Likewise.
* resolve/rust-rib.h: New Definition class, new prototypes.

16 months agonr2.0: Start using newtype pattern for Usage and Declaration
Arthur Cohen [Thu, 14 Sep 2023 15:38:06 +0000 (17:38 +0200)] 
nr2.0: Start using newtype pattern for Usage and Declaration

gcc/rust/ChangeLog:

* resolve/rust-name-resolution-context.cc (NameResolutionContext::map_usage):
Use newtype pattern.
(NameResolutionContext::lookup): Likewise.
* resolve/rust-name-resolution-context.h (class Usage): New class.
(class Definition): Likewise.
* resolve/rust-late-name-resolver-2.0.cc (Late::visit): Create instances
of Usage and Definition.

16 months agobackend: Use new name resolver where necessary
Arthur Cohen [Fri, 25 Aug 2023 12:33:36 +0000 (14:33 +0200)] 
backend: Use new name resolver where necessary

gcc/rust/ChangeLog:

* backend/rust-compile-base.cc: Use new ImmutableNrCtx.
* backend/rust-compile-context.h: Likewise.
* backend/rust-compile-expr.cc: Likewise.
* backend/rust-compile-item.cc: Likewise.

16 months agotypecheck: Start using nr2.0 properly
Arthur Cohen [Thu, 24 Aug 2023 15:51:21 +0000 (17:51 +0200)] 
typecheck: Start using nr2.0 properly

Fetch the ImmutableNrCtx in order to access name resolver during
typechecking.

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit): Start
fetching name resolution information in the typechecker.
* typecheck/rust-hir-type-check-type.cc (TypeCheckType::resolve_root_path):
Likewise.
* typecheck/rust-hir-type-check-path.cc: Use nr 2.0.

16 months agonr2.0: Add lookup of resolved nodes.
Arthur Cohen [Thu, 24 Aug 2023 15:51:11 +0000 (17:51 +0200)] 
nr2.0: Add lookup of resolved nodes.

gcc/rust/ChangeLog:

* resolve/rust-name-resolution-context.cc (NameResolutionContext::lookup):
Add lookup function.
* resolve/rust-name-resolution-context.h: Include mappings and optional.

16 months agosession manager: Init Immutable name resolver.
Arthur Cohen [Thu, 24 Aug 2023 15:50:45 +0000 (17:50 +0200)] 
session manager: Init Immutable name resolver.

gcc/rust/ChangeLog:

* rust-session-manager.cc (Session::compile_crate): Create an immutable
view of the name resolution context.

16 months agosession-manager: Dump name resolution pass.
Arthur Cohen [Wed, 23 Aug 2023 13:14:46 +0000 (15:14 +0200)] 
session-manager: Dump name resolution pass.

gcc/rust/ChangeLog:

* rust-session-manager.cc: Add files for dumping name resolution, call
name resolution dump function.
(Session::dump_name_resolution): New.
* rust-session-manager.h: New declaration.

16 months agosesh: Add late name resolution 2.0
Arthur Cohen [Fri, 4 Aug 2023 09:11:13 +0000 (11:11 +0200)] 
sesh: Add late name resolution 2.0

gcc/rust/ChangeLog:

* rust-session-manager.cc (Session::compile_crate): Create name resolution
context for Session::expansion and subsequent name resolution passes.
(Session::expansion): Take name resolution context as a parameter
instead.
* rust-session-manager.h (Session::expansion): Fix declaration.

16 months agonr2.0: Add new ImmutableNameResolutionCtx class.
Arthur Cohen [Thu, 24 Aug 2023 15:49:42 +0000 (17:49 +0200)] 
nr2.0: Add new ImmutableNameResolutionCtx class.

gcc/rust/ChangeLog:

* Make-lang.in: Compile it.
* resolve/rust-immutable-name-resolution-context.cc: New file.
* resolve/rust-immutable-name-resolution-context.h: New file.

16 months agoMerge commit 'f3f2065910a02b0099d3d5f2ad3389d0e479c782' into HEAD [#2926]
Thomas Schwinge [Mon, 25 Mar 2024 07:19:46 +0000 (08:19 +0100)] 
Merge commit 'f3f2065910a02b0099d3d5f2ad3389d0e479c782' into HEAD [#2926]

16 months agoMerge commit '2f334bb12e3ba947714771408b9d49d398abb5df' into HEAD
Thomas Schwinge [Sun, 24 Mar 2024 22:37:24 +0000 (23:37 +0100)] 
Merge commit '2f334bb12e3ba947714771408b9d49d398abb5df' into HEAD

16 months agoAdjust '.github/bors_log_expected_warnings'
Thomas Schwinge [Sun, 24 Mar 2024 22:25:31 +0000 (23:25 +0100)] 
Adjust '.github/bors_log_expected_warnings'

16 months agoPlacate clang-format re 'gcc/rust/lex/rust-lex.cc'
Thomas Schwinge [Sun, 24 Mar 2024 22:08:12 +0000 (23:08 +0100)] 
Placate clang-format re 'gcc/rust/lex/rust-lex.cc'

Reformat the upstream GCC commit 61644aea34c4623d16273ff705f8b8b1ff2d87f0
"gccrs: tokenize Unicode identifiers" change to 'gcc/rust/lex/rust-lex.cc'
to clang-format's liking.

gcc/rust/
* lex/rust-lex.cc (is_identifier_start): Placate clang-format.

16 months agoMerge commit '9f7afa99c67f039e43019ebd08d14a7f01e2d89c' into HEAD
Thomas Schwinge [Fri, 22 Mar 2024 09:07:29 +0000 (10:07 +0100)] 
Merge commit '9f7afa99c67f039e43019ebd08d14a7f01e2d89c' into HEAD

16 months agoMerge commit 'cde6f1085b7027f6a42fdb71c786d422606a8765' into HEAD
Thomas Schwinge [Fri, 22 Mar 2024 08:58:10 +0000 (09:58 +0100)] 
Merge commit 'cde6f1085b7027f6a42fdb71c786d422606a8765' into HEAD

16 months agoMerge commit 'cde6f1085b7027f6a42fdb71c786d422606a8765^' into HEAD
Thomas Schwinge [Fri, 22 Mar 2024 08:58:02 +0000 (09:58 +0100)] 
Merge commit 'cde6f1085b7027f6a42fdb71c786d422606a8765^' into HEAD

16 months agoMerge commit '00dea7e8c41b672730d6e2c891b6012a83d8842c' into HEAD [#2284]
Thomas Schwinge [Fri, 22 Mar 2024 08:55:35 +0000 (09:55 +0100)] 
Merge commit '00dea7e8c41b672730d6e2c891b6012a83d8842c' into HEAD [#2284]

16 months agoMerge commit '00dea7e8c41b672730d6e2c891b6012a83d8842c^' into HEAD
Thomas Schwinge [Fri, 22 Mar 2024 08:49:13 +0000 (09:49 +0100)] 
Merge commit '00dea7e8c41b672730d6e2c891b6012a83d8842c^' into HEAD

16 months agoMerge commit 'a945c346f57ba40fc80c14ac59be0d43624e559d' into HEAD [#2842]
Thomas Schwinge [Fri, 22 Mar 2024 08:34:13 +0000 (09:34 +0100)] 
Merge commit 'a945c346f57ba40fc80c14ac59be0d43624e559d' into HEAD [#2842]

16 months agoMerge commit 'a945c346f57ba40fc80c14ac59be0d43624e559d^' into HEAD
Thomas Schwinge [Fri, 22 Mar 2024 08:26:05 +0000 (09:26 +0100)] 
Merge commit 'a945c346f57ba40fc80c14ac59be0d43624e559d^' into HEAD

16 months agoMerge commit '725fb3595622a4ad8cd078a42fab1c395cbf90cb' into HEAD [#1913, #2288]
Thomas Schwinge [Fri, 22 Mar 2024 00:19:10 +0000 (01:19 +0100)] 
Merge commit '725fb3595622a4ad8cd078a42fab1c395cbf90cb' into HEAD [#1913, #2288]

16 months agoMerge commit 'f37c55c14bc1176ef9a15fe584fb6d1bf2e6162f' into HEAD [#1913]
Thomas Schwinge [Fri, 22 Mar 2024 00:04:40 +0000 (01:04 +0100)] 
Merge commit 'f37c55c14bc1176ef9a15fe584fb6d1bf2e6162f' into HEAD [#1913]

16 months agoMerge commit 'f37c55c14bc1176ef9a15fe584fb6d1bf2e6162f^' into HEAD
Thomas Schwinge [Thu, 21 Mar 2024 23:30:43 +0000 (00:30 +0100)] 
Merge commit 'f37c55c14bc1176ef9a15fe584fb6d1bf2e6162f^' into HEAD

16 months agoMerge commit 'e4f0eb725d836ef0eec780cbb9e7be0d31c6fe8b' into HEAD [#2690, #2692,...
Thomas Schwinge [Tue, 19 Mar 2024 15:48:09 +0000 (16:48 +0100)] 
Merge commit 'e4f0eb725d836ef0eec780cbb9e7be0d31c6fe8b' into HEAD [#2690, #2692, #2853]

16 months agoSplit up rust-macro-builtins.cc
jjasmine [Sun, 25 Feb 2024 11:10:37 +0000 (03:10 -0800)] 
Split up rust-macro-builtins.cc

Fixes issue #2855

gcc/rust/ChangeLog:

* Make-lang.in: add new .o builds for new .cc files
* expand/rust-cfg-strip.h (RUST_CFG_STRIP_H): Add include guards
for rust-cfg-strip
* expand/rust-macro-builtins.cc (make_macro_path_str): moved to new respective files
(make_token): moved to new respective files
(make_string): moved to new respective files
(macro_end_token): moved to new respective files
(try_extract_string_literal_from_fragment): moved to new respective files
(try_expand_many_expr): moved to new respective files
(parse_single_string_literal): moved to new respective files
(source_relative_path): moved to new respective files
(load_file_bytes): moved to new respective files
(MacroBuiltin::assert_handler): moved to new respective files
(MacroBuiltin::file_handler): moved to new respective files
(MacroBuiltin::column_handler): moved to new respective files
(MacroBuiltin::include_bytes_handler): moved to new respective files
(MacroBuiltin::include_str_handler): moved to new respective files
(MacroBuiltin::compile_error_handler): moved to new respective files
(MacroBuiltin::concat_handler): moved to new respective files
(MacroBuiltin::env_handler): moved to new respective files
(MacroBuiltin::cfg_handler): moved to new respective files
(MacroBuiltin::include_handler): moved to new respective files
(MacroBuiltin::line_handler): moved to new respective files
(MacroBuiltin::stringify_handler): moved to new respective files
(struct FormatArgsInput): moved to new respective files
(struct FormatArgsParseError): moved to new respective files
(format_args_parse_arguments): moved to new respective files
(MacroBuiltin::format_args_handler): moved to new respective files
* expand/rust-macro-builtins.h (builtin_macro_from_string):
merge tl::optional from master
* expand/rust-macro-builtins-asm.cc: New file.
* expand/rust-macro-builtins-format-args.cc: New file.
* expand/rust-macro-builtins-helpers.cc: New file.
* expand/rust-macro-builtins-helpers.h: New file.
* expand/rust-macro-builtins-include.cc: New file.
* expand/rust-macro-builtins-location.cc: New file.
* expand/rust-macro-builtins-log-debug.cc: New file.
* expand/rust-macro-builtins-test-bench.cc: New file.
* expand/rust-macro-builtins-trait.cc: New file.
* expand/rust-macro-builtins-utility.cc: New file.

16 months agoFix typo
Guillaume Gomez [Tue, 5 Mar 2024 19:24:30 +0000 (20:24 +0100)] 
Fix typo

gcc/rust/ChangeLog:

* expand/rust-derive.cc (DeriveVisitor::derive): Fix typo

16 months agofixed README.md , dump ast using correct option
zhanghe9702 [Sat, 16 Mar 2024 04:25:28 +0000 (12:25 +0800)] 
fixed README.md , dump ast using correct option

ChangeLog:

* README.md: remove error dump option.

Signed-off-by: Zhang He <zhanghe9702@163.com>
16 months agoStore visibility properly in ExternalTypeItem
jjasmine [Sat, 9 Mar 2024 22:16:34 +0000 (17:16 -0500)] 
Store visibility properly in ExternalTypeItem

Fix issue 2897

gcc/rust/ChangeLog:

* hir/rust-ast-lower-extern.h: Add translate_visiblity
* hir/tree/rust-hir-item.h: Fix constructor of ExternalTypeItem

16 months agoTyTy: Collect variance info from types
Jakub Dupak [Fri, 2 Feb 2024 13:12:13 +0000 (14:12 +0100)] 
TyTy: Collect variance info from types

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit):
Collect variance info from types.

Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
16 months agoTyTy: Variance analysis module
Jakub Dupak [Fri, 2 Feb 2024 13:09:38 +0000 (14:09 +0100)] 
TyTy: Variance analysis module

gcc/rust/ChangeLog:

* Make-lang.in: Add new .cc file.
* rust-session-manager.cc (Session::compile_crate): Run
analysis.
* typecheck/rust-tyty-variance-analysis-private.h: New file.
* typecheck/rust-tyty-variance-analysis.cc: New file.
* typecheck/rust-tyty-variance-analysis.h: New file.
* typecheck/rust-typecheck-context.cc
(TypeCheckContext::get_variance_analysis_ctx):
Variance analysis context.
* typecheck/rust-hir-type-check.h (TypeCheckItem::visit):
Variance analysis context.

Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
16 months agoTyTy: add common SubstitutionRef API
Jakub Dupak [Fri, 2 Feb 2024 11:11:45 +0000 (12:11 +0100)] 
TyTy: add common SubstitutionRef API

gcc/rust/ChangeLog:

* typecheck/rust-tyty-subst.cc (SubstitutionRef::get_arg_at):
Add unified API.

Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
16 months agoformat-args: Only pass the format string to the parser.
Arthur Cohen [Thu, 7 Mar 2024 13:57:54 +0000 (14:57 +0100)] 
format-args: Only pass the format string to the parser.

This fixes an issue we had where the generated code ended with more static
pieces than its rustc counterpart.

gcc/rust/ChangeLog:

* expand/rust-macro-builtins.cc (struct FormatArgsInput): Store the format_str
as a string instead of an AST::Expr.
(format_args_parse_arguments): Transform format_expr into a format string
properly - add note for handling eager macro invocations later on.
(MacroBuiltin::format_args_handler): Parse the correct input, append
newline to format_str if necessary.

16 months agoformat-args: Add basic test case
Arthur Cohen [Thu, 29 Feb 2024 15:09:23 +0000 (16:09 +0100)] 
format-args: Add basic test case

gcc/testsuite/ChangeLog:

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

16 months agoformat-args: Add basic expansion of unnamed Display::fmt arguments.
Arthur Cohen [Thu, 29 Feb 2024 13:53:05 +0000 (14:53 +0100)] 
format-args: Add basic expansion of unnamed Display::fmt arguments.

gcc/rust/ChangeLog:

* ast/rust-ast-builder.h: Rename AST::AstBuilder -> AST::Builder
* ast/rust-ast-builder.cc: Likewise.
* expand/rust-derive.cc: Use new AST::Builder name.
* expand/rust-derive.h: Likewise.
* ast/rust-builtin-ast-nodes.h: Add required getters.
* expand/rust-expand-format-args.cc (format_arg): New.
(get_trait_name): New.
(expand_format_args): Properly expand basic format_args!() invocations.
* expand/rust-expand-format-args.h (expand_format_args): Fix signature.
* expand/rust-macro-builtins.cc (MacroBuiltin::format_args_handler):
Call into expand_format_args().

16 months agoformat-args: Start storing string in Rust memory
Arthur Cohen [Thu, 22 Feb 2024 15:26:40 +0000 (16:26 +0100)] 
format-args: Start storing string in Rust memory

gcc/rust/ChangeLog:

* ast/rust-fmt.cc (ffi::RustHamster::to_string): New.
(Pieces::collect): Adapt to use new handle API.
(Pieces::~Pieces): Likewise.
(Pieces::Pieces): Likewise.
(Pieces::operator=): Likewise.
* ast/rust-fmt.h (struct RustString): Add members.
(struct FormatArgsHandle): New.
(clone_pieces): Adapt for new FFI API.
(destroy_pieces): Likewise.
(struct Pieces): Store new FormatArgsHandle type.
* expand/rust-expand-format-args.cc (expand_format_args): Use proper
namespace.
* resolve/rust-ast-resolve-base.cc (ResolverBase::visit): FormatArgs
nodes are already resolved, so do nothing.

libgrust/ChangeLog:

* libformat_parser/src/lib.rs: Use new Handle struct and expose it.

16 months agoformat-args: Add base for expanding FormatArgs nodes
Arthur Cohen [Thu, 29 Feb 2024 12:01:32 +0000 (13:01 +0100)] 
format-args: Add base for expanding FormatArgs nodes

gcc/rust/ChangeLog:

* Make-lang.in: Add new object.
* hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): Remove calls to
FormatArgsLowering.
* expand/rust-expand-format-args.cc: New file.
* expand/rust-expand-format-args.h: New file.

16 months agoMerge commit 'a857ec6aada08d8c334c389c7b682198d749b6c9^' into HEAD
Thomas Schwinge [Tue, 19 Mar 2024 15:47:48 +0000 (16:47 +0100)] 
Merge commit 'a857ec6aada08d8c334c389c7b682198d749b6c9^' into HEAD

16 months agoMerge commit '8fc4e6c397e1ce64bec6f9fed148950821cc79e7' into HEAD
Thomas Schwinge [Tue, 19 Mar 2024 15:45:47 +0000 (16:45 +0100)] 
Merge commit '8fc4e6c397e1ce64bec6f9fed148950821cc79e7' into HEAD

Accordingly also adjust #2086 "break rust ðŸ’¥" code, to avoid:

    [...]/source-gcc/gcc/rust/resolve/rust-ast-resolve-expr.cc: In member function â€˜virtual void Rust::Resolver::ResolveExpr::visit(Rust::AST::IdentifierExpr&)’:
    [...]/source-gcc/gcc/rust/resolve/rust-ast-resolve-expr.cc:164:42: error: invalid conversion from â€˜void (*)(diagnostic_context*, diagnostic_info*, diagnostic_t)’ to â€˜diagnostic_finalizer_fn’ {aka â€˜void (*)(diagnostic_context*, con
iagnostic_info*, diagnostic_t)’} [-fpermissive]
      164 |       diagnostic_finalizer (global_dc) = funny_ice_finalizer;
          |                                          ^~~~~~~~~~~~~~~~~~~
          |                                          |
          |                                          void (*)(diagnostic_context*, diagnostic_info*, diagnostic_t)

16 months agoMerge commit '8fc4e6c397e1ce64bec6f9fed148950821cc79e7^' into HEAD
Thomas Schwinge [Tue, 19 Mar 2024 15:45:27 +0000 (16:45 +0100)] 
Merge commit '8fc4e6c397e1ce64bec6f9fed148950821cc79e7^' into HEAD

16 months agoMerge commit 'f7884f7673444b8a2c10ea0981d480f2e82dd16a'; commit 'adb56ef014effb17af27...
Thomas Schwinge [Tue, 19 Mar 2024 15:42:45 +0000 (16:42 +0100)] 
Merge commit 'f7884f7673444b8a2c10ea0981d480f2e82dd16a'; commit 'adb56ef014effb17af27ab7baf0d87bc8bc48a0c' into HEAD [#2916]

Merge "macro: Use MacroInvocation's node_id in ExternalItem constructor", to
avoid bootstrap failure:

    [...]
    In file included from [...]/source-gcc/gcc/rust/ast/rust-expr.h:6,
                     from [...]/source-gcc/gcc/rust/ast/rust-ast-full.h:24,
                     from [...]/source-gcc/gcc/rust/ast/rust-ast.cc:24:
    In copy constructor â€˜Rust::AST::MacroInvocation::MacroInvocation(const Rust::AST::MacroInvocation&)’,
        inlined from â€˜Rust::AST::MacroInvocation* Rust::AST::MacroInvocation::clone_macro_invocation_impl() const’ at [...]/source-gcc/gcc/rust/ast/rust-\
    macro.h:798:38:
    [...]/source-gcc/gcc/rust/ast/rust-macro.h:734:39: error: â€˜*(Rust::AST::MacroInvocation*)<unknown>.Rust::AST::MacroInvocation::Rust::AST::ExprWithout\
    Block.Rust::AST::ExprWithoutBlock::Rust::AST::Expr.Rust::AST::Expr::node_id’ is used uninitialized [-Werror=uninitialized]
      734 |       builtin_kind (other.builtin_kind)
          |                                       ^
    cc1plus: all warnings being treated as errors
    make[3]: *** [[...]/source-gcc/gcc/rust/Make-lang.in:423: rust/rust-ast.o] Error 1
    [...]
    In file included from [...]/source-gcc/gcc/rust/ast/rust-expr.h:6,
                     from [...]/source-gcc/gcc/rust/ast/rust-item.h:27,
                     from [...]/source-gcc/gcc/rust/parse/rust-parse.h:20,
                     from [...]/source-gcc/gcc/rust/expand/rust-macro-expand.h:24,
                     from [...]/source-gcc/gcc/rust/expand/rust-macro-expand.cc:19:
    In copy constructor â€˜Rust::AST::MacroInvocation::MacroInvocation(const Rust::AST::MacroInvocation&)’,
        inlined from â€˜Rust::AST::MacroInvocation* Rust::AST::MacroInvocation::clone_macro_invocation_impl() const’ at [...]/source-gcc/gcc/rust/ast/rust-\
    macro.h:798:38:
    [...]/source-gcc/gcc/rust/ast/rust-macro.h:734:39: error: â€˜*(Rust::AST::MacroInvocation*)<unknown>.Rust::AST::MacroInvocation::Rust::AST::ExprWithout\
    Block.Rust::AST::ExprWithoutBlock::Rust::AST::Expr.Rust::AST::Expr::node_id’ is used uninitialized [-Werror=uninitialized]
      734 |       builtin_kind (other.builtin_kind)
          |                                       ^
    cc1plus: all warnings being treated as errors
    make[3]: *** [[...]/source-gcc/gcc/rust/Make-lang.in:433: rust/rust-macro-expand.o] Error 1
    [...]

16 months agoMerge commit 'f7884f7673444b8a2c10ea0981d480f2e82dd16a^' into HEAD
Thomas Schwinge [Tue, 19 Mar 2024 15:37:35 +0000 (16:37 +0100)] 
Merge commit 'f7884f7673444b8a2c10ea0981d480f2e82dd16a^' into HEAD

16 months agomacro: Use MacroInvocation's node_id in ExternalItem constructor.
Arthur Cohen [Tue, 19 Mar 2024 12:12:20 +0000 (13:12 +0100)] 
macro: Use MacroInvocation's node_id in ExternalItem constructor.

gcc/rust/ChangeLog:

* ast/rust-macro.h: Use proper node id instead of the one in the base
Expr class - which is uninitialized.

16 months agoci: Install Rust directly from rustup instead of apt
Arthur Cohen [Mon, 18 Mar 2024 14:10:43 +0000 (15:10 +0100)] 
ci: Install Rust directly from rustup instead of apt

ChangeLog:

* .github/workflows/ccpp.yml: Install Rust manually.

16 months agomacro: Use MacroInvocation's node_id in ExternalItem constructor.
Arthur Cohen [Tue, 19 Mar 2024 12:12:20 +0000 (13:12 +0100)] 
macro: Use MacroInvocation's node_id in ExternalItem constructor.

gcc/rust/ChangeLog:

* ast/rust-macro.h: Use proper node id instead of the one in the base
Expr class - which is uninitialized.

16 months agotree-optimization/112653 - PTA and return
Richard Biener [Mon, 27 Nov 2023 09:20:02 +0000 (10:20 +0100)] 
tree-optimization/112653 - PTA and return

The following separates the escape solution for return stmts not
only during points-to solving but also for later querying.  This
requires adjusting the points-to-global tests to include escapes
through returns.  Technically the patch replaces the existing
post-processing which computes the transitive closure of the
returned value solution by a proper artificial variable with
transitive closure constraints.  Instead of adding the solution
to escaped we track it separately.

PR tree-optimization/112653
* gimple-ssa.h (gimple_df): Add escaped_return solution.
* tree-ssa.cc (init_tree_ssa): Reset it.
(delete_tree_ssa): Likewise.
* tree-ssa-structalias.cc (escaped_return_id): New.
(find_func_aliases): Handle non-IPA return stmts by
adding to ESCAPED_RETURN.
(set_uids_in_ptset): Adjust HEAP escaping to also cover
escapes through return.
(init_base_vars): Initialize ESCAPED_RETURN.
(compute_points_to_sets): Replace ESCAPED post-processing
with recording the ESCAPED_RETURN solution.
* tree-ssa-alias.cc (ref_may_alias_global_p_1): Check
the ESCAPED_RETUNR solution.
(dump_alias_info): Dump it.
* cfgexpand.cc (update_alias_info_with_stack_vars): Update it.
* ipa-icf.cc (sem_item_optimizer::fixup_points_to_sets):
Likewise.
* tree-inline.cc (expand_call_inline): Reset it.
* tree-parloops.cc (parallelize_loops): Likewise.
* tree-sra.cc (maybe_add_sra_candidate): Check it.

* gcc.dg/tree-ssa/pta-return-1.c: New testcase.

(cherry picked from commit f7884f7673444b8a2c10ea0981d480f2e82dd16a)

16 months agosra: SRA of non-escaped aggregates passed by reference to calls
Martin Jambor [Fri, 24 Nov 2023 16:32:35 +0000 (17:32 +0100)] 
sra: SRA of non-escaped aggregates passed by reference to calls

PR109849 shows that a loop that heavily pushes and pops from a stack
implemented by a C++ std::vec results in slow code, mainly because the
vector structure is not split by SRA and so we end up in many loads
and stores into it.  This is because it is passed by reference
to (re)allocation methods and so needs to live in memory, even though
it does not escape from them and so we could SRA it if we
re-constructed it before the call and then separated it to distinct
replacements afterwards.

This patch does exactly that, first relaxing the selection of
candidates to also include those which are addressable but do not
escape and then adding code to deal with the calls.  The
micro-benchmark that is also the (scan-dump) testcase in this patch
runs twice as fast with it than with current trunk.  Honza measured
its effect on the libjxl benchmark and it almost closes the
performance gap between Clang and GCC while not requiring excessive
inlining and thus code growth.

The patch disallows creation of replacements for such aggregates which
are also accessed with a precision smaller than their size because I
have observed that this led to excessive zero-extending of data
leading to slow-downs of perlbench (on some CPUs).  Apart from this
case I have not noticed any regressions, at least not so far.

Gimple call argument flags can tell if an argument is unused (and then
we do not need to generate any statements for it) or if it is not
written to and then we do not need to generate statements loading
replacements from the original aggregate after the call statement.
Unfortunately, we cannot symmetrically use flags that an aggregate is
not read because to avoid re-constructing the aggregate before the
call because flags don't tell which what parts of aggregates were not
written to, so we load all replacements, and so all need to have the
correct value before the call.

This version of the patch also takes care to avoid attempts to modify
abnormal edges, something which was missing in the previosu version.

gcc/ChangeLog:

2023-11-23  Martin Jambor  <mjambor@suse.cz>

PR middle-end/109849
* tree-sra.cc (passed_by_ref_in_call): New.
(sra_initialize): Allocate passed_by_ref_in_call.
(sra_deinitialize): Free passed_by_ref_in_call.
(create_access): Add decl pool candidates only if they are not
already candidates.
(build_access_from_expr_1): Bail out on ADDR_EXPRs.
(build_access_from_call_arg): New function.
(asm_visit_addr): Rename to scan_visit_addr, change the
disqualification dump message.
(scan_function): Check taken addresses for all non-call statements,
including phi nodes.  Process all call arguments, including the static
chain, build_access_from_call_arg.
(maybe_add_sra_candidate): Relax need_to_live_in_memory check to allow
non-escaped local variables.
(sort_and_splice_var_accesses): Disallow smaller-than-precision
replacements for aggregates passed by reference to functions.
(sra_modify_expr): Use a separate stmt iterator for adding satements
before the processed statement and after it.
(enum out_edge_check): New type.
(abnormal_edge_after_stmt_p): New function.
(sra_modify_call_arg): New function.
(sra_modify_assign): Adjust calls to sra_modify_expr.
(sra_modify_function_body): Likewise, use sra_modify_call_arg to
process call arguments, including the static chain.

gcc/testsuite/ChangeLog:

2023-11-23  Martin Jambor  <mjambor@suse.cz>

PR middle-end/109849
* g++.dg/tree-ssa/pr109849.C: New test.
* g++.dg/tree-ssa/sra-eh-1.C: Likewise.
* gcc.dg/tree-ssa/pr109849.c: Likewise.
* gcc.dg/tree-ssa/sra-longjmp-1.c: Likewise.
* gfortran.dg/pr43984.f90: Added -fno-tree-sra to dg-options.

(cherry picked from commit aae723d360ca26cd9fd0b039fb0a616bd0eae363)

16 months agoMerge commit '56ca59a03150cf44cea340f58967c990ed6bf43c' into HEAD
Thomas Schwinge [Sat, 16 Mar 2024 23:10:10 +0000 (00:10 +0100)] 
Merge commit '56ca59a03150cf44cea340f58967c990ed6bf43c' into HEAD

16 months agoMerge commit '56ca59a03150cf44cea340f58967c990ed6bf43c^' into HEAD
Thomas Schwinge [Sat, 16 Mar 2024 23:10:04 +0000 (00:10 +0100)] 
Merge commit '56ca59a03150cf44cea340f58967c990ed6bf43c^' into HEAD

16 months agoMerge commit 'db50aea62595452db12565186cb520728540d987' into HEAD
Thomas Schwinge [Sat, 16 Mar 2024 23:06:54 +0000 (00:06 +0100)] 
Merge commit 'db50aea62595452db12565186cb520728540d987' into HEAD

16 months agoMerge commit 'db50aea62595452db12565186cb520728540d987^' into HEAD
Thomas Schwinge [Sat, 16 Mar 2024 22:57:22 +0000 (23:57 +0100)] 
Merge commit 'db50aea62595452db12565186cb520728540d987^' into HEAD

16 months agoMerge commit '4968e4844a3ce30143ae2e267895c418f5c636a1' into HEAD
Thomas Schwinge [Sat, 16 Mar 2024 22:55:02 +0000 (23:55 +0100)] 
Merge commit '4968e4844a3ce30143ae2e267895c418f5c636a1' into HEAD

16 months agoMerge commit '28064d6430f3fa71e79d11ac9d4bf3e6adf52145' into HEAD
Thomas Schwinge [Sat, 16 Mar 2024 22:54:33 +0000 (23:54 +0100)] 
Merge commit '28064d6430f3fa71e79d11ac9d4bf3e6adf52145' into HEAD

16 months agoRevert "Add files to discourage submissions of PRs to the GitHub mirror."
Thomas Schwinge [Sat, 16 Mar 2024 22:32:57 +0000 (23:32 +0100)] 
Revert "Add files to discourage submissions of PRs to the GitHub mirror."

This is not applicable for GCC/Rust, which does use GitHub.

This reverts commit 2b9778c8d9d33174de63716b74b2f114d700e104.

16 months agoMerge commit '2b9778c8d9d33174de63716b74b2f114d700e104^' into HEAD
Thomas Schwinge [Sat, 16 Mar 2024 22:32:07 +0000 (23:32 +0100)] 
Merge commit '2b9778c8d9d33174de63716b74b2f114d700e104^' into HEAD

16 months agoMerge commit '6a6d3817afa02bbcd2388c8e005da6faf88932f1' into HEAD [#2714]
Thomas Schwinge [Sat, 16 Mar 2024 22:06:45 +0000 (23:06 +0100)] 
Merge commit '6a6d3817afa02bbcd2388c8e005da6faf88932f1' into HEAD [#2714]

16 months agoMerge commit '6a6d3817afa02bbcd2388c8e005da6faf88932f1^' into HEAD
Thomas Schwinge [Sat, 16 Mar 2024 22:03:21 +0000 (23:03 +0100)] 
Merge commit '6a6d3817afa02bbcd2388c8e005da6faf88932f1^' into HEAD

16 months agoReplace unique_ptr references with references
Pierre-Emmanuel Patry [Thu, 22 Feb 2024 17:55:53 +0000 (18:55 +0100)] 
Replace unique_ptr references with references

This kind of double indirection is pointless and prone to error. This
commit change the api of all getters from the AST to use references
directly instead of references to unique pointers.

gcc/rust/ChangeLog:

* ast/rust-ast-collector.cc (TokenCollector::visit): Remove reference
to unique pointer and replace it with a direct reference to the wrapped
data.
* ast/rust-ast.cc (VariadicParam::as_string): Likewise.
(BlockExpr::normalize_tail_expr): Likewise.
* ast/rust-expr.h: Likewise and add pointer getter in order to allow
pointer reseat.
* ast/rust-item.h: Likewise and add pointer getter for reseat.
* ast/rust-path.h: Likewise.
* ast/rust-pattern.h: Likewise.
* ast/rust-stmt.h: Likewise.
* ast/rust-type.h: Likewise.
* expand/rust-cfg-strip.cc (CfgStrip::maybe_strip_struct_fields):
Remove references to unique pointers and replace it with direct
references to the wrapped object.
(CfgStrip::maybe_strip_tuple_fields): Likewise.
(CfgStrip::maybe_strip_generic_args): Likewise.
(CfgStrip::maybe_strip_qualified_path_type): Likewise.
(CfgStrip::visit): Likewise.
* expand/rust-expand-visitor.cc (ExpandVisitor::maybe_expand_expr):
Likewise.
(ExpandVisitor::maybe_expand_type): Likewise.
(ExpandVisitor::visit): Likewise.
* expand/rust-expand-visitor.h: Likewise.
* hir/rust-ast-lower-base.cc (ASTLoweringBase::lower_binding):
Likewise.
(ASTLoweringBase::lower_generic_args): Likewise.
(ASTLoweringBase::lower_self): Likewise.
(ASTLoweringBase::lower_type_no_bounds): Likewise.
(ASTLoweringBase::lower_bound): Likewise.
(ASTLoweringBase::lower_range_pattern_bound): Likewise.
* hir/rust-ast-lower-base.h: Likewise.
* hir/rust-ast-lower-block.h: Likewise.
* hir/rust-ast-lower-enumitem.h: Likewise.
* hir/rust-ast-lower-expr.cc (ASTLoweringExpr::translate): Likewise.
(ASTLoweringExpr::visit): Likewise.
* hir/rust-ast-lower-expr.h: Likewise.
* hir/rust-ast-lower-extern.h: Likewise.
* hir/rust-ast-lower-implitem.cc (ASTLowerImplItem::translate):
Likewise.
(ASTLowerImplItem::visit): Likewise.
(ASTLowerTraitItem::translate): Likewise.
(ASTLowerTraitItem::visit): Likewise.
* hir/rust-ast-lower-implitem.h: Likewise.
* hir/rust-ast-lower-item.cc (ASTLoweringItem::translate): Likewise.
(ASTLoweringItem::visit): Likewise.
* hir/rust-ast-lower-item.h: Likewise.
* hir/rust-ast-lower-pattern.cc (ASTLoweringPattern::translate):
Likewise.
(ASTLoweringPattern::visit): Likewise.
* hir/rust-ast-lower-pattern.h: Likewise.
* hir/rust-ast-lower-stmt.cc (ASTLoweringStmt::visit): Likewise.
* hir/rust-ast-lower-struct-field-expr.h: Likewise.
* hir/rust-ast-lower-type.cc (ASTLowerTypePath::visit): Likewise.
(ASTLowerQualifiedPathInType::visit): Likewise.
(ASTLoweringType::translate): Likewise.
(ASTLoweringType::visit): Likewise.
(ASTLowerGenericParam::translate): Likewise.
(ASTLowerGenericParam::visit): Likewise.
(ASTLoweringTypeBounds::translate): Likewise.
(ASTLoweringTypeBounds::visit): Likewise.
(ASTLowerWhereClauseItem::visit): Likewise.
* hir/rust-ast-lower-type.h: Likewise.
* hir/rust-ast-lower.cc (ASTLowering::go): Likewise.
(ASTLoweringBlock::visit): Likewise.
(ASTLoweringIfBlock::visit): Likewise.
(ASTLoweringIfLetBlock::visit): Likewise.
(ASTLowerStructExprField::visit): Likewise.
(ASTLoweringExprWithBlock::visit): Likewise.
(ASTLoweringBase::lower_qual_path_type): Likewise.
(ASTLoweringBase::lower_closure_param): Likewise.
* resolve/rust-ast-resolve-base.cc (ResolverBase::resolve_visibility):
Likewise.
* resolve/rust-ast-resolve-expr.cc (ResolveExpr::go): Likewise.
(ResolveExpr::visit): Likewise.
(ResolveExpr::resolve_closure_param): Likewise.
* resolve/rust-ast-resolve-expr.h: Likewise.
* resolve/rust-ast-resolve-implitem.h: Likewise.
* resolve/rust-ast-resolve-item.cc (ResolveTraitItems::visit):
Likewise.
(ResolveItem::go): Likewise.
(ResolveItem::visit): Likewise.
(ResolveItem::resolve_impl_item): Likewise.
(ResolveItem::resolve_extern_item): Likewise.
(ResolveImplItems::go): Likewise.
(ResolveExternItem::go): Likewise.
(ResolveExternItem::visit): Likewise.
* resolve/rust-ast-resolve-item.h: Likewise.
* resolve/rust-ast-resolve-path.cc (ResolvePath::go): Likewise.
(ResolvePath::resolve_path): Likewise.
* resolve/rust-ast-resolve-path.h: Likewise.
* resolve/rust-ast-resolve-pattern.cc (PatternDeclaration::go):
Likewise.
(PatternDeclaration::visit): Likewise.
(resolve_range_pattern_bound): Likewise.
* resolve/rust-ast-resolve-pattern.h: Likewise.
* resolve/rust-ast-resolve-stmt.cc (ResolveStmt::visit): Likewise.
* resolve/rust-ast-resolve-stmt.h: Likewise.
* resolve/rust-ast-resolve-struct-expr-field.cc (ResolveStructExprField::go):
Likewise.
(ResolveStructExprField::visit): Likewise.
* resolve/rust-ast-resolve-struct-expr-field.h: Likewise.
* resolve/rust-ast-resolve-toplevel.h: Likewise.
* resolve/rust-ast-resolve-type.cc (ResolveType::visit): Likewise.
(ResolveRelativeTypePath::go): Likewise.
(ResolveRelativeQualTypePath::resolve_qual_seg): Likewise.
(ResolveTypeToCanonicalPath::go): Likewise.
(ResolveTypeToCanonicalPath::visit): Likewise.
(ResolveGenericArgs::resolve_disambiguated_generic): Likewise.
(ResolveGenericArgs::go): Likewise.
* resolve/rust-ast-resolve-type.h: Likewise.
* resolve/rust-ast-resolve.cc (NameResolution::go): Likewise.
* resolve/rust-default-resolver.cc (DefaultResolver::visit): Likewise.
* resolve/rust-early-name-resolver.cc (EarlyNameResolver::resolve_qualified_path_type):
Likewise.
(EarlyNameResolver::visit): Likewise.
* resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit):
Likewise.
* checks/errors/rust-ast-validation.cc: Likewise.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
16 months agoReplace reference to unique pointer with reference
Pierre-Emmanuel Patry [Wed, 21 Feb 2024 15:45:18 +0000 (16:45 +0100)] 
Replace reference to unique pointer with reference

Reference to unique pointers are a known anti pattern, only the element
shall be taken by reference instead of the whole wrapper.

gcc/rust/ChangeLog:

* ast/rust-item.h: Change getter function prototype to return a
reference directly instead of a reference to the wrapper type.
* checks/errors/rust-ast-validation.cc (ASTValidation::visit): Fix
the code to accept references instead.
* hir/rust-ast-lower-base.cc (ASTLoweringBase::lower_self): Change
function implementation to return a reference.
* hir/rust-ast-lower-base.h: Accept a reference instead of a unique
pointer reference.
* resolve/rust-ast-resolve-item.cc (ResolveItem::visit): Adapt the code
to a reference instead of a unique pointer.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
16 months agoMerge commit '1a9974d08bc1478a98f52b2ea95475a583747724' into HEAD [#2912]
Thomas Schwinge [Tue, 12 Mar 2024 08:41:55 +0000 (09:41 +0100)] 
Merge commit '1a9974d08bc1478a98f52b2ea95475a583747724' into HEAD [#2912]

16 months agoPlacate clang-format re 'gcc/rust/backend/rust-tree.cc'
Thomas Schwinge [Tue, 12 Mar 2024 08:36:43 +0000 (09:36 +0100)] 
Placate clang-format re 'gcc/rust/backend/rust-tree.cc'

Reformat the upstream GCC commit f4a2ae2338962208b8039f154f5912402e94c378
"Change MODE_BITSIZE to MODE_PRECISION for MODE_VECTOR_BOOL" change to
'gcc/rust/backend/rust-tree.cc' to clang-format's liking.

gcc/rust/
* backend/rust-tree.cc (c_common_type_for_mode): Placate clang-format.

16 months agoAdjust '.github/bors_log_expected_warnings'
Thomas Schwinge [Mon, 11 Mar 2024 22:44:18 +0000 (23:44 +0100)] 
Adjust '.github/bors_log_expected_warnings'

16 months agocse: Workaround GCC < 5 bug in cse_insn [PR111852]
Jakub Jelinek [Wed, 18 Oct 2023 15:01:26 +0000 (17:01 +0200)] 
cse: Workaround GCC < 5 bug in cse_insn [PR111852]

Before the r5-3834 commit for PR63362, GCC 4.8-4.9 refuses to compile
cse.cc which contains a variable with rtx_def type, because rtx_def
contains a union with poly_uint16 element.  poly_int template has
defaulted default constructor and a variadic template constructor which
could have empty parameter pack. GCC < 5 treated it as non-trivially
constructible class and deleted rtunion and rtx_def default constructors.

For the cse_insn purposes, all we need is a variable with size and alignment
of rtx_def, not necessarily rtx_def itself, which we then memset to 0 and
fill in like rtx is normally allocated from heap, so this patch for
GCC_VERSION < 5000 uses an unsigned char array of the right size/alignment.

2023-10-18  Jakub Jelinek  <jakub@redhat.com>

PR bootstrap/111852
* cse.cc (cse_insn): Add workaround for GCC 4.8-4.9, instead of
using rtx_def type for memory_extend_buf, use unsigned char
arrayy with size of rtx_def and its alignment.

(cherry picked from commit bc4bd69faf986326f6b0fd0400cdd6871577afd1)

16 months agoMerge commit 'af4bb221153359f5948da917d5ef2df738bb1e61' into HEAD
Thomas Schwinge [Mon, 11 Mar 2024 21:51:28 +0000 (22:51 +0100)] 
Merge commit 'af4bb221153359f5948da917d5ef2df738bb1e61' into HEAD

16 months agoMerge commit '46595ce72e5855189e3c60a140c3ca5aaddfb58c' into HEAD
Thomas Schwinge [Mon, 11 Mar 2024 21:43:19 +0000 (22:43 +0100)] 
Merge commit '46595ce72e5855189e3c60a140c3ca5aaddfb58c' into HEAD

16 months agoMerge commit '46595ce72e5855189e3c60a140c3ca5aaddfb58c^' into HEAD
Thomas Schwinge [Mon, 11 Mar 2024 21:38:33 +0000 (22:38 +0100)] 
Merge commit '46595ce72e5855189e3c60a140c3ca5aaddfb58c^' into HEAD

16 months agoMerge commit '7439f40dc17f47480620beadf5b2f5784b59aefe' into HEAD [#1543]
Thomas Schwinge [Mon, 11 Mar 2024 00:05:15 +0000 (01:05 +0100)] 
Merge commit '7439f40dc17f47480620beadf5b2f5784b59aefe' into HEAD [#1543]

16 months agoMerge commit 'b1c06fd9723453dd2b2ec306684cb806dc2b4fbb^' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 23:59:26 +0000 (00:59 +0100)] 
Merge commit 'b1c06fd9723453dd2b2ec306684cb806dc2b4fbb^' into HEAD

16 months agoMerge commit 'ce7a757fd9ecb99c4f54cfde5cf5ef9a9e7819fc' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 23:58:39 +0000 (00:58 +0100)] 
Merge commit 'ce7a757fd9ecb99c4f54cfde5cf5ef9a9e7819fc' into HEAD

16 months agoMerge commit 'ce7a757fd9ecb99c4f54cfde5cf5ef9a9e7819fc^' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 23:57:51 +0000 (00:57 +0100)] 
Merge commit 'ce7a757fd9ecb99c4f54cfde5cf5ef9a9e7819fc^' into HEAD

16 months agoMerge commit 'af91934c2f6b8efc67d625c99068b4761ae5edd0' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 23:56:06 +0000 (00:56 +0100)] 
Merge commit 'af91934c2f6b8efc67d625c99068b4761ae5edd0' into HEAD

16 months agoMerge commit 'af91934c2f6b8efc67d625c99068b4761ae5edd0^' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 23:47:49 +0000 (00:47 +0100)] 
Merge commit 'af91934c2f6b8efc67d625c99068b4761ae5edd0^' into HEAD

16 months agoMerge commit '1aee5d2ace9ea8f35baf5b18e36caf44fe018ea3' into HEAD [#1408]
Thomas Schwinge [Sun, 10 Mar 2024 23:45:13 +0000 (00:45 +0100)] 
Merge commit '1aee5d2ace9ea8f35baf5b18e36caf44fe018ea3' into HEAD [#1408]

16 months agoMerge commit '1ad5ae5a45f2e3fc6948b35a3b052fdd48453704' into HEAD [#1408]
Thomas Schwinge [Sun, 10 Mar 2024 23:34:47 +0000 (00:34 +0100)] 
Merge commit '1ad5ae5a45f2e3fc6948b35a3b052fdd48453704' into HEAD [#1408]

16 months agoMerge commit '1ad5ae5a45f2e3fc6948b35a3b052fdd48453704^' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 23:34:22 +0000 (00:34 +0100)] 
Merge commit '1ad5ae5a45f2e3fc6948b35a3b052fdd48453704^' into HEAD

16 months agoMerge commit 'f3f6ff7b16861cd0651eccff14689536550762ae' into HEAD [#2414]
Thomas Schwinge [Sun, 10 Mar 2024 23:33:08 +0000 (00:33 +0100)] 
Merge commit 'f3f6ff7b16861cd0651eccff14689536550762ae' into HEAD [#2414]

16 months agoMerge commit 'f3f6ff7b16861cd0651eccff14689536550762ae^' into HEAD
Thomas Schwinge [Sun, 10 Mar 2024 23:26:50 +0000 (00:26 +0100)] 
Merge commit 'f3f6ff7b16861cd0651eccff14689536550762ae^' into HEAD