Descriptioncmd/gc: fix &result escaping into result
There is a hierarchy of location defined by loop depth:
-1 = the heap
0 = function results
1 = local variables (and parameters)
2 = local variable declared inside a loop
3 = local variable declared inside a loop inside a loop
etc
In general if an address from loopdepth n is assigned to
something in loop depth m < n, that indicates an extended
lifetime of some form that requires a heap allocation.
Function results can be local variables too, though, and so
they don't actually fit into the hierarchy very well.
Treat the address of a function result as level 1 so that
if it is written back into a result, the address is treated
as escaping.
Fixes issue 8185.
Patch Set 1 #Patch Set 2 : diff -r f153208c0a0e https://code.google.com/p/go/ #Patch Set 3 : diff -r f153208c0a0e https://code.google.com/p/go/ #
Total comments: 1
Patch Set 4 : diff -r cb1af30a996c https://code.google.com/p/go/ #MessagesTotal messages: 5
|