Skip to content

Cherry-pick [Modules] Record whether VarDecl initializers contain side effects (#143739) #10825

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

Open
wants to merge 2 commits into
base: stable/20240723
Choose a base branch
from

Conversation

hnrklssn
Copy link

@hnrklssn hnrklssn commented Jun 11, 2025

Calling `DeclMustBeEmitted` should not lead to more deserialization, as
it may occur before previous deserialization has finished.
When passed a `VarDecl` with an initializer however, `DeclMustBeEmitted`
needs to know whether that initializer contains side effects. When the
`VarDecl` is deserialized but the initializer is not, this triggers
deserialization of the initializer. To avoid this we add a bit to the
serialization format for `VarDecl`s, indicating whether its initializer
contains side effects or not, so that the `ASTReader` can query this
information directly without deserializing the initializer.

rdar://153085264

This is a cherry-pick of 319a51a5ffb807b88ae7f73676894bf306a0d134

@hnrklssn hnrklssn requested a review from a team as a code owner June 11, 2025 15:57
@hnrklssn
Copy link
Author

@swift-ci please test

…lvm#143739)

Calling `DeclMustBeEmitted` should not lead to more deserialization, as
it may occur before previous deserialization has finished.
When passed a `VarDecl` with an initializer however, `DeclMustBeEmitted`
needs to know whether that initializer contains side effects. When the
`VarDecl` is deserialized but the initializer is not, this triggers
deserialization of the initializer. To avoid this we add a bit to the
serialization format for `VarDecl`s, indicating whether its initializer
contains side effects or not, so that the `ASTReader` can query this
information directly without deserializing the initializer.

rdar://153085264

This is a cherry-pick of 319a51a
@hnrklssn hnrklssn force-pushed the remove-deserialize-assert branch from 5bace4c to c8d3e93 Compare June 23, 2025 17:26
@hnrklssn hnrklssn changed the title Cherry-pick [ASTReader] Remove assert in GetExternalDeclStmt Cherry-pick [Modules] Record whether VarDecl initializers contain side effects (#143739) Jun 23, 2025
@hnrklssn
Copy link
Author

@swift-ci please test

@hnrklssn
Copy link
Author

@swift-ci please test llvm

Normally expressions passed to EvaluateInPlace have a type, but not when
a VarDecl initializer is evaluated before the untyped ParenListExpr is
replaced with a CXXConstructExpr. This can happen in LLDB. In these
cases consteval fails.
@hnrklssn
Copy link
Author

@swift-ci please test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant