swift
swift copied to clipboard
[SR-161] Stack promotion fails to promote nested elements
| Previous ID | SR-161 |
| Radar | None |
| Original Reporter | @rudkx |
| Type | Bug |
Additional Detail from JIRA
| Votes | 0 |
| Component/s | Compiler |
| Labels | Bug, SILOptimizer |
| Assignee | @eeckstein |
| Priority | Medium |
md5: 31dd23fe56d493abedff68a7378655a3
Issue Description:
In an example like the one below we manage to promote 'c' in foo() to the stack, but not the 'd' within 'c', despite it being legal.
class D {
var y: Int = 0
}
class C {
var x: Int = 0
var d: D = D()
}
@inline(never)
func bar(c: C) {
c.x = 1
}
@inline(never)
func foo() -> Int {
let c = C()
bar(c)
return c.x
}
print(foo())
Note that you need to use -whole-module-optimization with this example to get 'c' promoted.
We are not promoting the inner element because of potential deinit side-effects, which we don't analyze yet.
Is this resolved, or no longer valid? If either, this should be closed.
Nothing has changed with respect to deinit side-effects. So I imagine it is still valid.