]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: use CTNIL for pointer-typed OLITERALs
authorMatthew Dempsky <mdempsky@google.com>
Thu, 5 Sep 2019 00:45:50 +0000 (17:45 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Fri, 6 Sep 2019 22:55:17 +0000 (22:55 +0000)
commitad1f2c96189be58c3c3c248af279b63a4f2466c1
tree162dee123ade769f4d8244a824d9eec01b5b4d3d
parente6ba19f9138dfaa981b281105fafabbf55250a18
cmd/compile: use CTNIL for pointer-typed OLITERALs

We used to be more aggressive about constant folding in the frontend,
handling expressions that the Go spec does not consider constant;
e.g., "(*int)(unsafe.Pointer(uintptr(200)))". However, that led to a
lot of subtle Go spec conformance issues, so we've since abandoned
that effort (CL 151320), leaving SSA to handle these cases instead.

As such, the only time we now end up with pointer-typed OLITERALs is
when "nil" is implicitly converted to a pointer-typed variable.
Instead of representing these OLITERALs with an CTINT of 0, we can
just use CTNIL.

Saves a few bytes of memory and lines of code.

Change-Id: Ibc5c756b992fdc89c3bdaf4fda3aa352e8e2b101
Reviewed-on: https://go-review.googlesource.com/c/go/+/193437
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
src/cmd/compile/internal/gc/const.go
src/cmd/compile/internal/gc/iexport.go
src/cmd/compile/internal/ssa/writebarrier.go