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: inline doesn't help for escape analysis #48660

Closed
go101 opened this issue Sep 28, 2021 · 1 comment
Closed

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

go101 opened this issue Sep 28, 2021 · 1 comment

Comments

@go101
Copy link

@go101 go101 commented Sep 28, 2021

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.

@go101
Copy link
Author

@go101 go101 commented Sep 28, 2021

Sorry, it looks the escape is caused by fmt.Println.

Loading

@go101 go101 closed this Sep 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant