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:
Ayke van Laethem
2021-04-22 14:24:22 +02:00
committed by Ron Evans
parent c466465c32
commit 80caf2dab2
3 changed files with 24 additions and 2 deletions
+11
View File
@@ -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)
}