-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/compile: run escape analysis on SSA form #31501
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
Comments
I was working on having package A
var escape func (*string)
func foo(a, b *string) *string {
escape(a)
return b
}
func Foo(a, b *string) {
a = foo(a, b)
} Here it incorrectly conclude that (if anyone is curious this is in
|
Our escape analysis is currently flow-insensitive, so in the statement
It doesn't understand that the assignment happens after the call. It thinks the assignment might happen before the call, in which base |
I'm pretty sure SSA would work since it would reach the Call value, lookup the arguments, figure out that There maybe are simpler ways to achieve this, rewriting into SSA would be a big task but it would also solve other control flow related issues. |
For my problem I just did that which looks very stupid on the diff but hey it works (*shift the goal post to an other problem): func (v Value) Set(x Value) {
v.mustBeAssignable()
x.mustBeExported() // do not let unexported x leak
var target unsafe.Pointer
if v.kind() == Interface {
target = v.ptr
}
- x = x.assignTo("reflect.Set", v.typ(), target)
- if x.flag&flagIndir != 0 {
- if x.ptr == unsafe.Pointer(&zeroVal[0]) {
+ z := x.assignTo("reflect.Set", v.typ(), target)
+ if z.flag&flagIndir != 0 {
+ if z.ptr == unsafe.Pointer(&zeroVal[0]) {
typedmemclr(v.typ(), v.ptr)
} else {
- typedmemmove(v.typ(), v.ptr, x.ptr)
+ typedmemmove(v.typ(), v.ptr, z.ptr)
}
} else {
- *(*unsafe.Pointer)(v.ptr) = x.ptr
+ *(*unsafe.Pointer)(v.ptr) = z.ptr
}
} |
Placeholder issue for discussion about running escape analysis on SSA form instead of the Node AST. I don't expect us to get to this for quite a while, but I think it's useful to have a single issue for cross-referencing related issues.
The text was updated successfully, but these errors were encountered: