Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Borrowck stage2 #2885

Merged
merged 14 commits into from
Apr 4, 2024
Merged

Borrowck stage2 #2885

merged 14 commits into from
Apr 4, 2024

Conversation

jdupak
Copy link
Contributor

@jdupak jdupak commented Feb 27, 2024

All changes except those Polonius crate dependant.

All tested for the format, change log, compile, and tests.

Depends on #2823

@CohenArthur
@braw-lee

@jdupak jdupak marked this pull request as draft February 27, 2024 23:56
@jdupak
Copy link
Contributor Author

jdupak commented Feb 27, 2024

Eh, bad gcc4. :( Anyway you can look at it, those will be only technical fixes.

@jdupak jdupak force-pushed the borrowck-stage2-cleaned branch 3 times, most recently from 10fa70d to 2611b4e Compare February 28, 2024 01:24
@jdupak jdupak marked this pull request as ready for review February 28, 2024 01:24
@jdupak jdupak marked this pull request as draft February 28, 2024 01:49
@jdupak jdupak force-pushed the borrowck-stage2-cleaned branch from 2611b4e to abfe3ac Compare February 28, 2024 16:30
@jdupak jdupak marked this pull request as ready for review February 28, 2024 17:16
@jdupak jdupak mentioned this pull request Feb 28, 2024
@jdupak jdupak force-pushed the borrowck-stage2-cleaned branch from abfe3ac to 709dc70 Compare February 29, 2024 08:52
Copy link
Member

@CohenArthur CohenArthur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will finish reviewing later today but I have something else I need to work on for now. I'll get all your PRs reviewed before the end of the day

@jdupak jdupak force-pushed the borrowck-stage2-cleaned branch from 709dc70 to 8e639f5 Compare March 22, 2024 19:39
@jdupak
Copy link
Contributor Author

jdupak commented Mar 22, 2024

All requested changes done

@jdupak jdupak requested a review from CohenArthur March 22, 2024 19:42
Copy link
Member

@P-E-P P-E-P left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't much to say beside nits. Great work!

@jdupak jdupak force-pushed the borrowck-stage2-cleaned branch 3 times, most recently from 970ad72 to 7a99582 Compare April 1, 2024 12:40
@jdupak
Copy link
Contributor Author

jdupak commented Apr 1, 2024

@P-E-P I just added one more commit removing all the block with single statement (more that just those you commented on).

@jdupak
Copy link
Contributor Author

jdupak commented Apr 1, 2024

@CohenArthur all comments resolved

Copy link
Member

@P-E-P P-E-P left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

jdupak added 3 commits April 3, 2024 13:12
Replace direct usage of system headers.

gcc/rust/ChangeLog:

	* checks/errors/borrowck/rust-bir-dump.cc: Use rust-system.h
	* checks/errors/borrowck/rust-bir-dump.h (RUST_BIR_DUMP_H): Use rust-system.h
	* checks/errors/borrowck/rust-bir-place.h (RUST_BIR_PLACE_H): Use rust-system.h
	* checks/errors/borrowck/rust-function-collector.h: Use rust-system.h
	* rust-system.h: Use rust-system.h
	* typecheck/rust-hir-type-check.h: Use rust-system.h
	* typecheck/rust-tyty-subst.cc: Use rust-system.h
	* typecheck/rust-tyty-subst.h: Use rust-system.h
	* typecheck/rust-tyty.h: Use rust-system.h

Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
gcc/rust/ChangeLog:

	* checks/errors/borrowck/bir-design-notes.md (nodes): Rename node to statement.
	(Nodes): Rename node to statement.
	* checks/errors/borrowck/rust-bir-builder-expr-stmt.cc (ExprStmtBuilder::visit):
	Rename node to statement.
	* checks/errors/borrowck/rust-bir-builder-internal.h: Rename node to statement.
	* checks/errors/borrowck/rust-bir-builder.h: Rename node to statement.
	* checks/errors/borrowck/rust-bir-dump.cc (Dump::go): Rename node to statement.
	(Dump::visit): Rename node to statement.
	* checks/errors/borrowck/rust-bir-dump.h (class Dump): Rename node to statement.
	* checks/errors/borrowck/rust-bir-visitor.h (class Node): Rename node to statement.
	(class Statement): Rename node to statement.
	* checks/errors/borrowck/rust-bir.h (class Node): Rename node to statement.
	(class Statement): Rename node to statement.
	(class AbstractExpr): Rename node to statement.
	(struct Function): Rename node to statement.
	(struct BasicBlock): Rename node to statement.

Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
gcc/rust/ChangeLog:

	* checks/errors/borrowck/rust-bir-builder-expr-stmt.cc (ExprStmtBuilder::visit):
	Use callable API

Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
jdupak added 11 commits April 3, 2024 13:12
gcc/rust/ChangeLog:

	* checks/errors/borrowck/rust-bir-place.h:
	Create place tree traverse API.

Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
gcc/rust/ChangeLog:

	* checks/errors/borrowck/rust-bir-builder-expr-stmt.cc (ExprStmtBuilder::setup_loop):
	Loop handling.
	(ExprStmtBuilder::visit): Handle scopes.
	* checks/errors/borrowck/rust-bir-builder-internal.h (struct BuilderContext):
	Handle scopes.
	* checks/errors/borrowck/rust-bir-dump.cc (Dump::go): Dump scopes.
	(Dump::visit): Add scopes dump.
	(Dump::indent): Add indentation logic.
	(Dump::visit_scope): Dump scope.
	* checks/errors/borrowck/rust-bir-dump.h: Dump methods.
	* checks/errors/borrowck/rust-bir-place.h (std::numeric_limits::max): Scope constants.
	(struct Scope): Scope representation.
	(class PlaceDB): Scope tracking.

Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
gcc/rust/ChangeLog:

	* checks/errors/borrowck/rust-bir-builder-expr-stmt.cc (ExprStmtBuilder::visit): Emit moves.
	* checks/errors/borrowck/rust-bir-builder-internal.h: Emit moves.
	* checks/errors/borrowck/rust-bir-builder-lazyboolexpr.h: Emit moves.
	* checks/errors/borrowck/rust-bir-dump.cc (Dump::visit_move_place): Emit moves.
	(Dump::visit): Emit moves.
	* checks/errors/borrowck/rust-bir-place.h (struct Place): Emit moves.
	* checks/errors/borrowck/rust-bir-visitor.h: Emit moves.
	* checks/errors/borrowck/rust-bir.h (enum class): Emit moves.
	(class AbstractExpr): Emit moves.
	(BasicBlock::is_terminated): Emit moves.

Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
gcc/rust/ChangeLog:

	* checks/errors/borrowck/rust-bir-dump.cc (Dump::visit): const
	visitor
	* checks/errors/borrowck/rust-bir-dump.h: const visitor
	* checks/errors/borrowck/rust-bir-visitor.h: const visitor
	* checks/errors/borrowck/rust-bir.h: const getter

Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Rust part is not build and not invoked at this point.

gcc/rust/ChangeLog:

	* checks/errors/borrowck/ffi-polonius/Cargo.toml: New file.
	* checks/errors/borrowck/ffi-polonius/src/gccrs_ffi.rs: New file.
	* checks/errors/borrowck/ffi-polonius/src/gccrs_ffi_generated.rs: New file.
	* checks/errors/borrowck/ffi-polonius/src/lib.rs: New file.
	* checks/errors/borrowck/polonius/rust-polonius-ffi.h: New file.
	* checks/errors/borrowck/polonius/rust-polonius.h: New file.

Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
gcc/rust/ChangeLog:

	* checks/errors/borrowck/rust-bir-free-region.h: New file.

Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
Biggybag on variance analysis to extract regions of fields from ADT
regions.

gcc/rust/ChangeLog:

	* typecheck/rust-tyty-variance-analysis-private.h (class FieldVisitorCtx):
	Region extraction.
	* typecheck/rust-tyty-variance-analysis.cc (query_field_regions): Region extraction.
	(FieldVisitorCtx::collect_regions): Region extraction.
	(FieldVisitorCtx::add_constraints_from_ty): Region extraction.
	(FieldVisitorCtx::add_constraints_from_region): Region
	extraction.
	(FieldVisitorCtx::add_constrints_from_param): Region extraction.
	* typecheck/rust-tyty-variance-analysis.h (query_field_regions):
	Region extraction.

Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
gcc/rust/ChangeLog:

	* checks/errors/borrowck/rust-bir-place.h (struct Lifetime):
	Extended regions and loans.
	(struct Loan): Representation of loan (result of borrowing)
	* checks/errors/borrowck/rust-bir-builder-expr-stmt.cc (ExprStmtBuilder::visit):
	Fix let stmt handling.
	* checks/errors/borrowck/rust-bir-builder-pattern.h: improved
	pattern translation
	* checks/errors/borrowck/rust-bir-builder-internal.h: region binding
	* checks/errors/borrowck/rust-bir-builder-expr-stmt.h (class ExprStmtBuilder):
	Region support.
	(class RenumberCtx): Region support.
	* checks/errors/borrowck/rust-bir-builder.h (class Builder): Region support.
	* checks/errors/borrowck/rust-bir-dump.cc (get_lifetime_name): Region support.
	(renumber_places): Region support.
	(Dump::go): Region support.
	(Dump::visit): Region support.
	(Dump::visit_lifetime): Region support.
	(Dump::visit_scope): Region support.
	* checks/errors/borrowck/rust-bir.h (class AbstractExpr): Region support.
	(struct Function): Region support.
	(class BorrowExpr): Region support.
	(class CallExpr): Region support.

Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
This is the main Polonius based logic which creates the information
Polonius needs from BIR. It is largly guessed and rever engineered, so
some aspects are probably wrong.

gcc/rust/ChangeLog:

	* checks/errors/borrowck/rust-bir-fact-collector.h: New file.
	* checks/errors/borrowck/rust-borrow-checker.cc (BorrowChecker::go):
	Enable fact collection.

Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
gcc/rust/ChangeLog:

	* checks/errors/borrowck/rust-bir-dump.cc (renumber_places):
	Remove unecessary braces.
	(Dump::go): Remove unecessary braces.
	(Dump::visit): Remove unecessary braces.
	(Dump::visit_scope): Remove unecessary braces.
	* checks/errors/borrowck/rust-bir-fact-collector.h (class FactCollector):
	Remove unecessary braces.
	(points): Remove unecessary braces.
	* checks/errors/borrowck/rust-bir-free-region.h: Remove unecessary braces.
	* checks/errors/borrowck/rust-bir-place.h: Remove unecessary braces.
	* checks/errors/borrowck/rust-borrow-checker.cc (BorrowChecker::go):
	Remove unecessary braces.
	* checks/errors/borrowck/rust-function-collector.h: Remove unecessary braces.

Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
gcc/rust/ChangeLog:

	* checks/errors/borrowck/ffi-polonius/src/gccrs_ffi.rs: Bump copyright.
	* checks/errors/borrowck/ffi-polonius/src/lib.rs: Bump copyright.
	* checks/errors/borrowck/polonius/rust-polonius-ffi.h: Bump copyright.
	* checks/errors/borrowck/polonius/rust-polonius.h: Bump copyright.
	* checks/errors/borrowck/rust-bir-dump.cc: Bump copyright.
	* checks/errors/borrowck/rust-bir-fact-collector.h: Bump copyright.
	* checks/errors/borrowck/rust-bir-free-region.h: Bump copyright.

Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
@jdupak jdupak force-pushed the borrowck-stage2-cleaned branch from 00030ad to 2c10c40 Compare April 3, 2024 11:12
@jdupak
Copy link
Contributor Author

jdupak commented Apr 3, 2024

@CohenArthur all comments resolved again :D

Copy link
Member

@CohenArthur CohenArthur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@CohenArthur
Copy link
Member

CohenArthur commented Apr 4, 2024

well done @jdupak, amazing work :D

@CohenArthur CohenArthur added this pull request to the merge queue Apr 4, 2024
Merged via the queue into Rust-GCC:master with commit ff196e4 Apr 4, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Merged
Development

Successfully merging this pull request may close these issues.

4 participants