• Keith Randall's avatar
    cmd/compile: remove more nil ptr checks after newobject · f1517ec6
    Keith Randall authored
    For code like the following (where x escapes):
    
       x := []int{1}
    
    We're currently generating a nil check.  The line above is really 3 operations:
    
    	t := new([1]int)
    	t[0] = 1
    	x := t[:]
    
    We remove the nil check for t[0] = 1, but not for t[:].
    
    Our current nil check removal rule is too strict about the possible
    memory arguments of the nil check. Unlike zeroing or storing to the
    result of runtime.newobject, the nilness of runtime.newobject is
    always false, even after other stores have happened in the meantime.
    
    Change-Id: I95fad4e3a59c27effdb37c43ea215e18f30b1e5f
    Reviewed-on: https://go-review.googlesource.com/58711
    Run-TryBot: Keith Randall <khr@golang.org>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: 's avatarCherry Zhang <cherryyz@google.com>
    f1517ec6
nilptr3.go 6.04 KB