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

Comments

Projects
None yet
5 participants
@dr2chase
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

This comment has been minimized.

gopherbot commented Dec 9, 2015

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

This comment has been minimized.

Member

bradfitz commented May 6, 2016

Didn't happen for 1.7.

@quentinmit quentinmit added the NeedsFix label Oct 6, 2016

@rsc rsc modified the milestones: Unplanned, Go1.8Early Oct 17, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment