• Iskander Sharipov's avatar
    cmd/compile/internal/gc: better handling of self-assignments in esc.go · ff468a43
    Iskander Sharipov authored
    Teach escape analysis to recognize these assignment patterns
    as not causing the src to leak:
    
    	val.x = val.y
    	val.x[i] = val.y[j]
    	val.x1.x2 = val.x1.y2
    	... etc
    
    Helps to avoid "leaking param" with assignments showed above.
    The implementation is based on somewhat similiar xs=xs[a:b]
    special case that is ignored by the escape analysis.
    
    We may figure out more generalized version of this,
    but this one looks like a safe step into that direction.
    
    Updates #14858
    
    Change-Id: I6fe5bfedec9c03bdc1d7624883324a523bd11fde
    Reviewed-on: https://go-review.googlesource.com/126395
    Run-TryBot: Iskander Sharipov <iskander.sharipov@intel.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: 's avatarDavid Chase <drchase@google.com>
    ff468a43
escape_param.go 11.8 KB