-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Optimizer can't remove unused code without side effects #66496
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
Labels
compiler
The Swift compiler itself
DCE
Area → compiler → SILOptimizer: Dead Code Elimination
feature
A feature request or implementation
SILOptimizer
Area → compiler: SIL optimization passes
Comments
eeckstein
added a commit
to eeckstein/swift
that referenced
this issue
Jun 13, 2023
…ations to a static accesses In case of `var` initializations, SILGen creates a dynamic begin/end_access pair around the initialization store. If it's an initialization (and not a re-assign) it's guanranteed that it's an exlusive access and we can convert the access to an `[init] [static]` access. swiftlang#66496
eeckstein
added a commit
to eeckstein/swift
that referenced
this issue
Jun 13, 2023
Don't let access instructions prevent eliminating dead allocations swiftlang#66496
eeckstein
added a commit
to eeckstein/swift
that referenced
this issue
Jun 14, 2023
…ations to a static accesses In case of `var` initializations, SILGen creates a dynamic begin/end_access pair around the initialization store. If it's an initialization (and not a re-assign) it's guanranteed that it's an exlusive access and we can convert the access to an `[init] [static]` access. swiftlang#66496
eeckstein
added a commit
to eeckstein/swift
that referenced
this issue
Jun 14, 2023
Don't let access instructions prevent eliminating dead allocations swiftlang#66496
@eeckstein I'm not sure if you have seen updates in the thread on the forum, but in case you didn't, could you please take a look? I found two more cases when a dead object is not eliminated.
|
eeckstein
added a commit
to eeckstein/swift
that referenced
this issue
Jun 26, 2023
This allows to eliminate dead allocations of a ManagedBuffer object. swiftlang#66496
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
compiler
The Swift compiler itself
DCE
Area → compiler → SILOptimizer: Dead Code Elimination
feature
A feature request or implementation
SILOptimizer
Area → compiler: SIL optimization passes
Motivation
While prototyping a solution to this issue, I encountered a strange behavior of the optimizer.
It appears that the optimizer considers
init
with an assignment to a classlet
to be optimizable. However, it does not considerinit
with an assignment to a classvar
to be optimizable.Let's compare these two pieces of code.
And
The first one (with
let
field) compiles into no code aside fromret
, as expected:And the second one (with
var
field) compiles into invocation of__swift_instantiateConcreteTypeFromMangledName
andswift_initStackObject
:Live code
It feels a little like a bug somewhere.
Solution
I don't know.
Additional context
Discussion
The text was updated successfully, but these errors were encountered: