Skip to content
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

cmd/compile: escape analysis overconservative for recursive calls #13547

Open
dr2chase opened this issue Dec 9, 2015 · 2 comments
Open

cmd/compile: escape analysis overconservative for recursive calls #13547

dr2chase opened this issue Dec 9, 2015 · 2 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@dr2chase
Copy link
Contributor

dr2chase commented Dec 9, 2015

Sample program. Allocation in inner loop of recursive foo does not escape, but conservative assumptions (because escape analysis does not do fixed-pointer iteration) force conclusion that it does.

package main
// import "fmt"
type Node struct {
    next *Node
    name string
}
var sink string
func foo(list *Node, names []string) {
    if len(names) > 0 {
        name := names[0]
        for i := 0; i < len(name); i++ {
            foo(&Node{list, name[i : i+1]}, names[1:]) // need not escape
        }
    } else if list != nil {
        // fmt.Printf("%s", list.name) // you don't want to to do this unless you are comparing output.
        sink = list.name
        foo(list.next, names)
    }
}
func main() {
    names := []string{"ant", "bat", "cat", "dog", "emu",
        "fox", "gnu", "hyena", "iguana", "jaguar"}
    foo(nil, names)
}
@gopherbot
Copy link

CL https://golang.org/cl/17581 mentions this issue.

@rsc rsc added this to the Go1.7Early milestone Dec 28, 2015
@bradfitz bradfitz modified the milestones: Go1.8Early, Go1.7Early May 6, 2016
@bradfitz
Copy link
Contributor

bradfitz commented May 6, 2016

Didn't happen for 1.7.

@quentinmit quentinmit added the NeedsFix The path to resolution is known, but the work has not been done. label Oct 6, 2016
@rsc rsc modified the milestones: Unplanned, Go1.8Early Oct 17, 2016
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

5 participants