aboutsummaryrefslogtreecommitdiffhomepage
path: root/transform
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2023-03-11 20:57:40 +0100
committerRon Evans <[email protected]>2023-03-22 00:34:43 +0100
commitf180339d6b2bf63e02b2d05312870a8fb52bbf39 (patch)
treed13cc017ae14379d376d9e9b888e1ec7e670ddac /transform
parent5ed0cecf0ddb57aab381f6a96542c30400cf0fbf (diff)
downloadtinygo-f180339d6b2bf63e02b2d05312870a8fb52bbf39.tar.gz
tinygo-f180339d6b2bf63e02b2d05312870a8fb52bbf39.zip
compiler: add alloc attributes to runtime.alloc
This gives a small improvement now, and is needed to be able to use the Heap2Stack transform that's available in the Attributor pass. This Heap2Stack transform could replace our custom OptimizeAllocs pass. Most of the changes are just IR that changed, the actual change is relatively small. To give an example of why this is useful, here is the code size before this change: $ tinygo build -o test -size=short ./testdata/stdlib.go code data bss | flash ram 95620 1812 968 | 97432 2780 $ tinygo build -o test -size=short ./testdata/stdlib.go code data bss | flash ram 95380 1812 968 | 97192 2780 That's a 0.25% reduction. Not a whole lot, but nice for such a small patch.
Diffstat (limited to 'transform')
-rw-r--r--transform/testdata/allocs2.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/transform/testdata/allocs2.go b/transform/testdata/allocs2.go
index bf39fdefa..3b08fbc9e 100644
--- a/transform/testdata/allocs2.go
+++ b/transform/testdata/allocs2.go
@@ -18,7 +18,7 @@ func main() {
s3 := make([]int, 3) // OUT: object allocated on the heap: escapes at line 19
returnIntSlice(s3)
- _ = make([]int, getUnknownNumber()) // OUT: object allocated on the heap: size is not constant
+ useSlice(make([]int, getUnknownNumber())) // OUT: object allocated on the heap: size is not constant
s4 := make([]byte, 300) // OUT: object allocated on the heap: object size 300 exceeds maximum stack allocation size 256
readByteSlice(s4)
@@ -82,3 +82,5 @@ func getComplex128() complex128
func useInterface(interface{})
func callVariadic(...int)
+
+func useSlice([]int)