Skip to content

cmd/compile: inline doesn't help for escape analysis #48660

@zigo101

Description

@zigo101

What version of Go are you using (go version)?

$ go version
go version go1.17.1 linux/amd64

Does this issue reproduce with the latest release?

Yes

What did you do?

package main

import "fmt"

type T struct{a, b, c, d float32}

func AddPP_P(x, y *T) *T {
	var z T
	z.a = x.a + y.a
	z.b = x.b + y.b
	z.c = x.c + y.c
	z.d = x.d + y.d
	return &z
}


func main() {
	var a, b T
	// inlining call to AddPP_P
	var c = AddPP_P(&a, &b) // moved to heap: z
	fmt.Println(c)
}

What did you expect to see?

no escapes

What did you see instead?

One escape.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions