tinygo-org / tinygo

Go compiler for small places. Microcontrollers, WebAssembly (WASM/WASI), and command-line tools. Based on LLVM.
https://tinygo.org
Other
15.51k stars 914 forks source link

compiler: mark stringFromBytes as nocapture/readonly to help escape a… #4534

Closed dgryski closed 1 month ago

dgryski commented 1 month ago

…nalysis

Fixes #4525

dgryski commented 1 month ago

I have some time at airports today; I might look at some of the other strconv escape analysis issues and see if there's anything else there with an easy fix.

aykevl commented 1 month ago

Would it be possible to add a test to transform/testdata/allocs2.go?

dgryski commented 1 month ago

Added.

New test fails on dev with

        allocs2.go:53: object allocated on the heap: escapes at line 54

and passes on this branch.

deadprogram commented 1 month ago

OK this is great, I quite need this actually. Thank you very much @dgryski and to @aykevl for review.

Now merging.