Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/compile: better escape analysis tag encoding #31504
Currently escape.go mostly reuses esc.go's tagging scheme for simplicity, but that encoding scheme is unnecessarily lossy.
In particular, escape tags can only report that a parameter flows to the heap (EscHeap), or that it's dereferenced once before flowing to the heap (EscContentEscapes). However, there are hundreds of parameters in std cmd that are always dereferenced at least twice before flowing to the heap.
A quick experiment (tracking the shortest param path to heap and then logging when it's >=2) shows:
And this is probably an underestimate, since any functions that call other tagged functions will be analyzed based on the latter's lossy tags.