1
0
mirror of https://github.com/golang/go synced 2024-11-07 13:26:10 -07:00
go/src/cmd
Cherry Zhang 6b8e3e2d06 cmd/compile: reduce redundant register moves for regabi calls
Currently, if we have AX=a and BX=b, and we want to make a call
F(1, a, b), to move arguments into the desired registers it emits

	MOVQ AX, CX
	MOVL $1, AX // AX=1
	MOVQ BX, DX
	MOVQ CX, BX // BX=a
	MOVQ DX, CX // CX=b

This has a few redundant moves.

This is because we process inputs in order. First, allocate 1 to
AX, which kicks out a (in AX) to CX (a free register at the
moment). Then, allocate a to BX, which kicks out b (in BX) to DX.
Finally, put b to CX.

Notice that if we start with allocating CX=b, then BX=a, AX=1,
we will not have redundant moves. This CL reduces redundant moves
by allocating them in different order: First, for inpouts that are
already in place, keep them there. Then allocate free registers.
Then everything else.

                             before       after
cmd/compile binary size     23703888    23609680
            text size        8565899     8533291

(with regabiargs enabled.)

Change-Id: I69e1bdf745f2c90bb791f6d7c45b37384af1e874
Reviewed-on: https://go-review.googlesource.com/c/go/+/311371
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2021-04-19 16:21:39 +00:00
..
addr2line all: update to use os.ReadFile, os.WriteFile, os.CreateTemp, os.MkdirTemp 2020-12-09 19:12:23 +00:00
api all: go fmt std cmd (but revert vendor) 2021-02-20 03:54:50 +00:00
asm internal/buildcfg: move build configuration out of cmd/internal/objabi 2021-04-16 19:20:53 +00:00
buildid
cgo internal/buildcfg: move build configuration out of cmd/internal/objabi 2021-04-16 19:20:53 +00:00
compile cmd/compile: reduce redundant register moves for regabi calls 2021-04-19 16:21:39 +00:00
cover cmd/cover: use golang.org/x/tools/cover directly 2021-03-25 20:57:58 +00:00
dist cmd/dist: defend self against misc/reboot test 2021-04-16 21:39:59 +00:00
doc cmd/doc: properly display interface methods 2021-03-19 03:05:26 +00:00
fix all: introduce and use internal/execabs 2021-01-21 19:10:18 +00:00
go cmd/go: drop GOEXPERIMENT in script tests 2021-04-19 02:43:30 +00:00
gofmt go/*,cmd/gofmt: guard AST changes with the typeparams build tag 2021-04-13 22:24:31 +00:00
internal internal/buildcfg: move build configuration out of cmd/internal/objabi 2021-04-16 19:20:53 +00:00
link cmd/link: fix defaultGOROOT package 2021-04-16 21:48:46 +00:00
nm all: go fmt std cmd (but revert vendor) 2021-02-20 03:54:50 +00:00
objdump cmd/objdump: update test with register ABI 2021-04-09 00:09:47 +00:00
pack cmd/pack: use testing.T.TempDir in tests 2021-04-07 13:24:10 +00:00
pprof cmd/vendor, cmd/pprof: use golang.org/x/term directly 2021-03-26 06:03:20 +00:00
test2json all: introduce and use internal/execabs 2021-01-21 19:10:18 +00:00
trace runtime: move next_gc and last_next_gc into gcControllerState 2021-04-14 14:03:30 +00:00
vendor cmd/go: upgrade and vendor golang.org/x/mod 2021-04-09 18:19:42 +00:00
vet cmd/vet: bring in sigchanyzer to report unbuffered channels to signal.Notify 2021-03-08 23:13:52 +00:00
go.mod cmd/go: upgrade and vendor golang.org/x/mod 2021-04-09 18:19:42 +00:00
go.sum cmd/go: upgrade and vendor golang.org/x/mod 2021-04-09 18:19:42 +00:00
README.vendor

See src/README.vendor for information on loading vendored packages
and updating the vendor directory.