Skip to content

Rebase SILScope generation on top of ASTScope. #64941

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

Merged
merged 14 commits into from
Apr 17, 2023

Conversation

adrian-prantl
Copy link
Contributor

@adrian-prantl adrian-prantl commented Apr 5, 2023

Rebase SILScope generation on top of ASTScope.

This patch replaces the stateful generation of SILScope information in SILGenFunction with data derived from the ASTScope hierarchy, which should be 100% in sync with the scopes needed for local variables. The goal is to eliminate the surprising effects that the stack of cleanup operations can have on the current state of SILBuilder leading to a fully deterministic (in the sense of: predictible by a human) association of SILDebugScopes with SILInstructions. The patch also eliminates the need to many workarounds. Thereare still some accomodations for several Sema transformation passes such as ResultBuilders, which don't correctly update the source locations when moving round nodes. If these were implemented as macros, this problem would disappear.

This necessary rewrite of the macro scope handling included in this patch also adds proper support nested macro expansions.

This fixes

rdar://88274783
and either fixes or at least partially addresses the following:

rdar://89252827
rdar://105186946
rdar://105757810
rdar://105997826
rdar://105102288


Cherry pick of #64551.

@adrian-prantl
Copy link
Contributor Author

@swift-ci test

@ahoppen ahoppen removed their request for review April 5, 2023 18:50
@xedin xedin removed their request for review April 5, 2023 20:42
@adrian-prantl
Copy link
Contributor Author

test with swiftlang/llvm-project#6611
@swift-ci test

@adrian-prantl adrian-prantl removed the request for review from shahmishal April 6, 2023 20:16
@adrian-prantl
Copy link
Contributor Author

@swift-ci test

1 similar comment
@adrian-prantl
Copy link
Contributor Author

@swift-ci test

@adrian-prantl
Copy link
Contributor Author

@swift-ci test

2 similar comments
@adrian-prantl
Copy link
Contributor Author

@swift-ci test

@adrian-prantl
Copy link
Contributor Author

@swift-ci test

and also make it easier to debug.

(cherry picked from commit bbcce34)
The pointsToEnd flag is only meaningful when combined with an AST node, and
moving it into the AST pointer frees up a bit in the flags bitfield for later
use.

(cherry picked from commit 63304d0)
This change aims at reducing the need for SIL passes to check into the AST
storage of SILLocations. The end goal is to eventually merge this with the
autogenerated flag, but at the moment the emergent semantics of both properties
are not identical.

(cherry picked from commit c5efebe)
This patch replaces the stateful generation of SILScope information in
SILGenFunction with data derived from the ASTScope hierarchy, which should be
100% in sync with the scopes needed for local variables. The goal is to
eliminate the surprising effects that the stack of cleanup operations can have
on the current state of SILBuilder leading to a fully deterministic (in the
sense of: predictible by a human) association of SILDebugScopes with
SILInstructions. The patch also eliminates the need to many workarounds. There
are still some accomodations for several Sema transformation passes such as
ResultBuilders, which don't correctly update the source locations when moving
around nodes. If these were implemented as macros, this problem would disappear.

This necessary rewrite of the macro scope handling included in this patch also
adds proper support nested macro expansions.

This fixes

rdar://88274783

and either fixes or at least partially addresses the following:

rdar://89252827
rdar://105186946
rdar://105757810
rdar://105997826
rdar://105102288
(cherry picked from commit 158772c)
rdar://105997826
(cherry picked from commit 475f779)
(cherry picked from commit e3445a8)
rdar://107764966
(cherry picked from commit c877a4a)
This is something that every visit() function needs to do and these manual
overloads forgot to. I tried to come up with a more general solution, but due
the rather nested inheritance of SILCloner this turned out harde than expected.

rdar://107984038
(cherry picked from commit fbf4c92)
…ted.

If a pattern reuses a value from a previous branch this could result in a step
backwords or a previous scope being reopeneed.

rdar://107764966
(cherry picked from commit 68aa944)
@adrian-prantl
Copy link
Contributor Author

Fix one more bug that was uncovered by the di-hole verification when building the source compatibility suite in debug mode.

@adrian-prantl
Copy link
Contributor Author

@swift-ci test

@adrian-prantl
Copy link
Contributor Author

@swift-ci test source compatibility

@adrian-prantl
Copy link
Contributor Author

Source compatibility failures are unrelated to this PR.

@adrian-prantl adrian-prantl merged commit 746a83f into swiftlang:release/5.9 Apr 17, 2023
@AnthonyLatsis AnthonyLatsis added the 🍒 release cherry pick Flag: Release branch cherry picks label May 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒 release cherry pick Flag: Release branch cherry picks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants