Jorropo 38b5f91aa5 cmd/compile: on AMD64 use leave instruction for go compiled functions
This is a second try for CL 548317.

When the go compiler compiles a function it saves the frame pointer
on the stack and pushes the stack pointer. Thus it is safe to restore
from the stack.

For assembly function still use the mathematical based
restore as users might use the frame pointer as scratch space.

The results are very good, file size down 0.8%
codesize down 2%.

Files:
  file       before    after     Δ        %
  addr2line  3950752   3919200   -31552   -0.799%
  asm        7228164   7176284   -51880   -0.718%
  buildid    3813377   3782545   -30832   -0.809%
  cgo        6184696   6135728   -48968   -0.792%
  compile    37066595  36734315  -332280  -0.896%
  covdata    4529478   4497638   -31840   -0.703%
  cover      7906781   7840805   -65976   -0.834%
  dist       5329896   5285504   -44392   -0.833%
  distpack   4028506   3996578   -31928   -0.793%
  fix        12706126  12614110  -92016   -0.724%
  link       10097646  10020534  -77112   -0.764%
  nm         3924002   3896858   -27144   -0.692%
  objdump    6570663   6523399   -47264   -0.719%
  pack       3255175   3229463   -25712   -0.790%
  pprof      20273692  20094988  -178704  -0.881%
  preprofile 3373625   3351201   -22424   -0.665%
  test2json  4563667   4524259   -39408   -0.864%
  trace      18675260  18526132  -149128  -0.799%
  vet        12297424  12200576  -96848   -0.788%
  total      175775525 174350117 -1425408 -0.811%

Code: total 45787786 44851997 -935789 -2.044%

Change-Id: Ie20cb5a90b25e5dfe3b2ce2d6e73a6b049bc53a5
Reviewed-on: https://go-review.googlesource.com/c/go/+/801860
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Jorropo <jorropo.pgm@gmail.com>
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2026-07-21 14:29:18 -07:00
2026-07-20 12:51:53 -07:00
2026-07-09 11:24:04 -07:00

The Go Programming Language

Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.

Gopher image Gopher image by Renee French, licensed under Creative Commons 4.0 Attribution license.

Our canonical Git repository is located at https://go.googlesource.com/go. There is a mirror of the repository at https://github.com/golang/go.

Unless otherwise noted, the Go source files are distributed under the BSD-style license found in the LICENSE file.

Download and Install

Binary Distributions

Official binary distributions are available at https://go.dev/dl/.

After downloading a binary release, visit https://go.dev/doc/install for installation instructions.

Install From Source

If a binary distribution is not available for your combination of operating system and architecture, visit https://go.dev/doc/install/source for source installation instructions.

Contributing

Go is the work of thousands of contributors. We appreciate your help!

To contribute, please read the contribution guidelines at https://go.dev/doc/contribute.

Note that the Go project uses the issue tracker for bug reports and proposals only. See https://go.dev/wiki/Questions for a list of places to ask questions about the Go language.

Description
Languages
Go 95.1%
Assembly 4.5%
C 0.2%