mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-07-26 06:38:42 +00:00
copiler: add function attributes to some runtime calls
This allows better escape analysis even without being able to see the entire program. This makes the stack allocation test case more complete but probably won't have much of an effect outside of that (as the compiler is able to infer these attributes in the whole-program functionattrs pass).
This commit is contained in:
committed by
Ron Evans
parent
c466465c32
commit
80caf2dab2
Vendored
+11
@@ -22,6 +22,13 @@ func main() {
|
||||
|
||||
s4 := make([]byte, 300) // OUT: object allocated on the heap: object size 300 exceeds maximum stack allocation size 256
|
||||
readByteSlice(s4)
|
||||
|
||||
s5 := make([]int, 4) // OUT: object allocated on the heap: escapes at line 27
|
||||
s5 = append(s5, 5)
|
||||
|
||||
s6 := make([]int, 3)
|
||||
s7 := []int{1, 2, 3}
|
||||
copySlice(s6, s7)
|
||||
}
|
||||
|
||||
func derefInt(x *int) int {
|
||||
@@ -45,3 +52,7 @@ func returnIntSlice(s []int) []int {
|
||||
}
|
||||
|
||||
func getUnknownNumber() int
|
||||
|
||||
func copySlice(out, in []int) {
|
||||
copy(out, in)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user