mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-07-26 06:38:42 +00:00
transform: follow aggregate returned alloc aliases
Track whether an allocation reaches a callee return separately from the
instruction where it escapes. The extra result state is needed because LLVM's
returned parameter attribute only covers scalar returns: a slice helper returns
its data pointer inside a {ptr, len, cap} aggregate, so the alias is only
visible by walking insertvalue and ret uses in the callee.
This lets OptimizeAllocs keep the backing array for returnIntSlice(s) on the
stack when the returned slice is ignored, matching gc's escape decision for the
same pattern. The golden output still keeps the escaping returned-slice case on
the heap.
This commit is contained in:
Vendored
-1
@@ -1,4 +1,3 @@
|
||||
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
|
||||
testdata/allocs2.go:29.1,29.22 1 0
|
||||
|
||||
+1
-2
@@ -1,4 +1,3 @@
|
||||
testdata/allocs2.go:21:12: object allocated on the heap: escapes at line 22
|
||||
testdata/allocs2.go:24:15: object allocated on the heap: size is not constant
|
||||
testdata/allocs2.go:26:12: object allocated on the heap: object size 300 exceeds maximum stack allocation size 256
|
||||
testdata/allocs2.go:29:12: object allocated on the heap: escapes at line 30
|
||||
@@ -9,4 +8,4 @@ testdata/allocs2.go:49:2: object allocated on the heap: escapes at line 51
|
||||
testdata/allocs2.go:50:2: object allocated on the heap: escapes at line 51
|
||||
testdata/allocs2.go:107:11: object allocated on the heap: escapes at line 108
|
||||
testdata/allocs2.go:114:2: object allocated on the heap: escapes at line 117
|
||||
testdata/allocs2.go:128:2: object allocated on the heap: escapes at line 130
|
||||
testdata/allocs2.go:128:2: object allocated on the heap: escapes at unknown line
|
||||
|
||||
Reference in New Issue
Block a user