transform: handle returned pointer alloc aliases

Follow returned pointer aliases when deciding whether runtime.alloc calls can
be lowered to stack allocations. A returned parameter is not the same as
nocapture: it still flows back to the caller and must be checked as an alias
of the original allocation.

Keep the analysis conservative for recursive returned-parameter chains and
unknown operands. The existing golden test now shows that the non-escaping
returned pointer cases no longer require heap allocation.
This commit is contained in:
Jake Bailey
2026-06-12 11:22:07 -07:00
committed by Ron Evans
parent 335b085fd2
commit a683881eb7
3 changed files with 71 additions and 9 deletions
-2
View File
@@ -1,4 +1,3 @@
testdata/allocs2.go:12.1,12.9 1 0
testdata/allocs2.go:21.1,21.22 1 0
testdata/allocs2.go:24.1,24.43 1 0
testdata/allocs2.go:26.1,26.25 1 0
@@ -8,7 +7,6 @@ testdata/allocs2.go:44.1,44.23 1 0
testdata/allocs2.go:46.1,46.22 1 0
testdata/allocs2.go:49.1,49.9 1 0
testdata/allocs2.go:50.1,50.9 1 0
testdata/allocs2.go:98.1,98.23 1 0
testdata/allocs2.go:107.1,107.21 1 0
testdata/allocs2.go:114.1,114.23 1 0
testdata/allocs2.go:128.1,128.23 1 0