aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/abi/abiutils.go
AgeCommit message (Collapse)Author
2021-08-27cmd/compile: eagerly CalcStructSize for synthetic ABI typesMatthew Dempsky
The next CL is going to replace Type.Width with Type.Size(), but Type.Size() isn't safe to call concurrently. So this CL calls CalcStructSize, which *is* allowed to be used concurrently, but then it's the caller's responsibility to ensure it's called right after NewStruct. Change-Id: If9cd81650ccb3a867b4449af757375fa56227901 Reviewed-on: https://go-review.googlesource.com/c/go/+/345483 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
2021-07-22cmd/compile: do not change field offset in ABI analysisCherry Mui
Currently, the ABI analysis assigns parameter/result offsets to the fields of function *Type. In some cases, we may have an ABI0 function reference and an ABIInternal reference share the same function *Type. For example, for an ABI0 function F, "f := F" will make f and (ABI0) F having the same *Type. But f, as a func value, should use ABIInternal. Analyses on F and f will collide and cause ICE. Also, changing field offsets in ABI analysis has to be done very carefully to avoid data races. It has been causing trickiness/difficulty. This CL removes the change of field offsets in ABI analysis altogether. The analysis result is stored in ABIParamAssignment, which is the only way to access parameter/result stack offset now. Fixes #47317. Fixes #47227. Change-Id: I23a3e081a6cf327ac66855da222daaa636ed1ead Reviewed-on: https://go-review.googlesource.com/c/go/+/336629 Trust: Cherry Mui <cherryyz@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Than McIntosh <thanm@google.com>
2021-06-04cmd/compile/internal/abi: fix typo in commentsryoya
Change-Id: I196045314b2b0e908d7b31ac0cea5b25404f3ee0 Reviewed-on: https://go-review.googlesource.com/c/go/+/325249 Reviewed-by: Matthew Dempsky <mdempsky@google.com> Trust: Keith Randall <khr@golang.org>
2021-04-30cmd/compile: handle field padding for register-passed structsThan McIntosh
When constructing multi-piece DWARF location expressions for struct-typed parameters using the register ABI, make sure that the location expressions generated properly reflect padding between elements (this is required by debuggers). Example: type small struct { x uint16 ; y uint8 ; z int32 } func ABC(p1 int, p2 small, f1 float32) { ... In the DWARF location expression for "p2" on entry to the routine, we need pieces for each field, but for debuggers (such as GDB) to work properly, we also need to describe the padding between elements. Thus instead of <rbx> DW_OP_piece 2 <rcx> DW_OP_piece 1 <rdi> DW_OP_piece 4 we need to emit <rbx> DW_OP_piece 2 <rcx> DW_OP_piece 1 DW_OP_piece 1 <rdi> DW_OP_piece 4 This patch adds a new helper routine in abiutils to compute the correct padding amounts for a struct type, a unit test for the helper, and updates the debug generation code to call the helper and insert apadding "piece" ops in the right spots. Updates #40724. Updates #45720. Change-Id: Ie208bee25776b9eb70642041869e65e4fa65a005 Reviewed-on: https://go-review.googlesource.com/c/go/+/315071 Trust: Than McIntosh <thanm@google.com> Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>
2021-04-13cmd/compile: don't modify underlying type when creating bitmap for bodyless ↵David Chase
function This fixes the build crash for GOEXPERIMENT=regabi,regabiargs GOOS=windows go build syscall Updates #40724. Change-Id: I4400f6ff2e83e7e7e93ad5e58c6063b327532504 Reviewed-on: https://go-review.googlesource.com/c/go/+/309110 Trust: David Chase <drchase@google.com> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-01cmd/compile: fix register/offset calculation for trailing empty field case.David Chase
Includes test. Long term, need to make the offending code be more in terms of official types package offsets, instead of duplicating that logic. For #40724. Change-Id: Id33a153f10aed3289cc48d1f99a8e0f6ece9474d Reviewed-on: https://go-review.googlesource.com/c/go/+/306469 Trust: David Chase <drchase@google.com> Run-TryBot: David Chase <drchase@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-01cmd/compile: fix parameter offset calculationCherry Zhang
For struct like { { a int64; b int16 }; c int32 }, on 64-bit machines the offset of c is 16, as the inner struct takes 16 bytes because we round up type size to its alignment. Update the abi package's offset calculation to include this. We only need to do this for struct type, because for all other types its size is naturally aligned. TODO: add a test. Change-Id: I0c661768cb1ed3cb409b20a88b7e23e059f8e3e1 Reviewed-on: https://go-review.googlesource.com/c/go/+/306449 Trust: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: David Chase <drchase@google.com>
2021-03-24cmd/compile: remove more dead code and data structuresDavid Chase
Remove more now-redundant code, methods, and types associated with transition to register ABI. Repaired some broken comments. Tested on link-register architectures (arm64, ppc64le) Updates #40724. Change-Id: Ie8433f6d38ec4a1d9705f22dcb596f267d81f203 Reviewed-on: https://go-review.googlesource.com/c/go/+/304189 Trust: David Chase <drchase@google.com> Run-TryBot: David Chase <drchase@google.com> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-03-24cmd/compile: fix array case in types-for-register parameterDavid Chase
Corrected typo/thinko. We should keep the test for this, but it doesn't run yet because of reflection as far as I know (but I am not testing w/ GOEXPERIMENT). See https://github.com/golang/go/issues/44816#issuecomment-805297295 Updates #40724 Updates #44816 Change-Id: Ia12d0d4db00a8ec7174e72de460173876bd17874 Reviewed-on: https://go-review.googlesource.com/c/go/+/304233 Trust: David Chase <drchase@google.com> Run-TryBot: David Chase <drchase@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-03-22cmd/compile: fix WriteFuncMap for new ABI.David Chase
replaced old type-based logic with new abi-based logic; earlier versions of this CL compared them for equality. For not-in-a-register, they match everywhere tested. also modified GetFrameOffset to make it more like the one it replaces; the LocalsOffset is subtracted. Change-Id: I65ce7f0646c493c277df6b6f46e4839a0d886ac9 Reviewed-on: https://go-review.googlesource.com/c/go/+/302072 Trust: David Chase <drchase@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-03-16cmd/compile: (fixed) spill output parameters passed in registers as autosDavid Chase
Repair of CL 300749. ALSO: found evidence that stack maps for bodyless methods are wrong. gofmt in test/abi removed never-executed code in types/size.go Updates #44816. Updates #40724. Change-Id: Ifeb5fee60f60e7c7b58ee0457f58a3265d6cf3f6 Reviewed-on: https://go-review.googlesource.com/c/go/+/302071 Trust: David Chase <drchase@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-03-15Revert "cmd/compile: spill output parameters passed in registers as autos"David Chase
This reverts commit 8ed438c077d82c4b4662c327dbbdb3c64e7547ca, CL 300749. Reason for revert: Looks like it crashes on link-register architectures Change-Id: I0c261df58900008cada3359889d2a87508158447 Reviewed-on: https://go-review.googlesource.com/c/go/+/302053 Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-03-15cmd/compile: spill output parameters passed in registers as autosDavid Chase
ALSO: found evidence that stack maps for bodyless methods are wrong. gofmt in test/abi removed never-executed code in types/size.go Updates #44816. Change-Id: I658c33f049337fb6f1e625f0c55430d25bfa877e Reviewed-on: https://go-review.googlesource.com/c/go/+/300749 Trust: David Chase <drchase@google.com> Run-TryBot: David Chase <drchase@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-03-09cmd/compile: fix failure to communicate between ABIinfo producer&consumerDavid Chase
ABI info producer and consumer had different ideas for register order for parameters. Includes a test, includes improvements to debugging output. Updates #44816. Change-Id: I4812976f7a6c08d6fc02aac1ec0544b1f141cca6 Reviewed-on: https://go-review.googlesource.com/c/go/+/299570 Trust: David Chase <drchase@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
2021-03-09cmd/compile: fix broken type+offset calc for register argsDavid Chase
Includes more enhancements to debugging output. Updates #44816. Change-Id: I5b21815cf37ed21e7dec6c06f538090f32260203 Reviewed-on: https://go-review.googlesource.com/c/go/+/299409 Trust: David Chase <drchase@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-03-04cmd/compile: implement too-big-to-SSA struct passing in registersDavid Chase
Added a test that exercises named results Change-Id: Ie228b68f4f846266595a95e0f65a6e4b8bf79635 Reviewed-on: https://go-review.googlesource.com/c/go/+/297029 Trust: David Chase <drchase@google.com> Run-TryBot: David Chase <drchase@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-03-04cmd/compile: implement simple register resultsDavid Chase
at least for ints and strings includes simple test For #40724. Change-Id: Ib8484e5b957b08f961574a67cfd93d3d26551558 Reviewed-on: https://go-review.googlesource.com/c/go/+/295309 Trust: David Chase <drchase@google.com> Run-TryBot: David Chase <drchase@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-03-04cmd/compile: register abi, morestack work and mole whackingDavid Chase
Morestack works for non-pointer register parameters Within a function body, pointer-typed parameters are correctly tracked. Results still not hooked up. For #40724. Change-Id: Icaee0b51d0da54af983662d945d939b756088746 Reviewed-on: https://go-review.googlesource.com/c/go/+/294410 Trust: David Chase <drchase@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-03-03cmd/compile: remove races introduced in abiutils field updateDavid Chase
This fix uses mutex around the problematic store and subsequent access; if this causes performance problems later a better fix is to do all the ABI binding in gc/walk where it is single-threaded. Change-Id: I488f28ab75beb8351c856fd50b0095cab463642e Reviewed-on: https://go-review.googlesource.com/c/go/+/298109 Trust: David Chase <drchase@google.com> Run-TryBot: David Chase <drchase@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com>
2021-03-03cmd/compile: retrieve Args from registersDavid Chase
in progress; doesn't fully work until they are also passed on register on the caller side. For #40724. Change-Id: I29a6680e60bdbe9d132782530214f2a2b51fb8f6 Reviewed-on: https://go-review.googlesource.com/c/go/+/293394 Trust: David Chase <drchase@google.com> Run-TryBot: David Chase <drchase@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-03-03cmd/compile: use abiutils for all rcvr/in/out frame offsets.David Chase
types thought it knew how to do this, but that's a lie, because types doesn't know what the ABI is. includes extra checking to help prevent things from accidentally working if they need to be changed but aren't. For #40724. Change-Id: I166cd948f262344b7bebde6a2c25e7a7f878bbfb Reviewed-on: https://go-review.googlesource.com/c/go/+/293393 Trust: David Chase <drchase@google.com> Run-TryBot: David Chase <drchase@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-03-02cmd/compile: better version of check frame offsets against abiDavid Chase
improved to run on more architectures. this is in preparation for turning off calculation of frame offsets in types.CalcSize. Replaces https://go-review.googlesource.com/c/go/+/293392 . Updates #44675. For #40724. Change-Id: I40ba496172447cf09b86bc646148859363c11ad9 Reviewed-on: https://go-review.googlesource.com/c/go/+/297637 Trust: David Chase <drchase@google.com> Run-TryBot: David Chase <drchase@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-03-01Revert "cmd/compile: check frame offsets against abi"Bryan C. Mills
This reverts CL 293392. Reason for revert: broke most non-x86 builders Fixes #44675 Change-Id: I1e815c3ab27a02e83a2f0d221a617909dd021403 Reviewed-on: https://go-review.googlesource.com/c/go/+/297549 Trust: Bryan C. Mills <bcmills@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Jeremy Faller <jeremy@golang.org>
2021-02-27cmd/compile: check frame offsets against abiDavid Chase
this is in preparation for turning off calculation of frame offsets in types.CalcSize For #40724. Change-Id: I2c29fd289c014674076e5ec5170055dbca5ea64b Reviewed-on: https://go-review.googlesource.com/c/go/+/293392 Trust: David Chase <drchase@google.com> Run-TryBot: David Chase <drchase@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Jeremy Faller <jeremy@golang.org>
2021-02-26cmd/compile: change StaticCall to return a "Results"David Chase
StaticLECall (multiple value in +mem, multiple value result +mem) -> StaticCall (multiple ergister value in +mem, multiple register-sized-value result +mem) -> ARCH CallStatic (multiple ergister value in +mem, multiple register-sized-value result +mem) But the architecture-dependent stuff is indifferent to whether it is mem->mem or (mem)->(mem) until Prog generation. Deal with OpSelectN -> Prog in ssagen/ssa.go, others, as they appear. For #40724. Change-Id: I1d0436f6371054f1881862641d8e7e418e4a6a16 Reviewed-on: https://go-review.googlesource.com/c/go/+/293391 Trust: David Chase <drchase@google.com> Run-TryBot: David Chase <drchase@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-02-24cmd/compile: plumb abi info into expandCallsDavid Chase
Work in progress. TODO: - insert debugging output for all the steps listed below - emit modified call instructions w/ multiple register inputs and Result-typed outputs (next CL) - initially just change output from "mem" to "Result{mem}" = most places this hits will be future work. - change OpArg to use registerized variants - (done) match abi paramresultinfo with particular arg, use Name - (this CL) push register offsets for "loads" and "stores" into recursive decomposition. - hand registerized Result to exit block For #40724. Change-Id: Ie5de9d71f8fd4e092f5ee9260b54de35abf91016 Reviewed-on: https://go-review.googlesource.com/c/go/+/293390 Trust: David Chase <drchase@google.com> Run-TryBot: David Chase <drchase@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Jeremy Faller <jeremy@golang.org>
2021-02-24cmd/compile: plumb abi info into ssagen/ssaDavid Chase
Plumb abi information into ssa/ssagen for plain calls and plain functions (not methods). Does not extend all the way through the compiler (yet). One test disabled because it extends far enough to break the test. Normalized all the compiler's register args TODOs to // TODO(register args) ... For #40724. Change-Id: I0173a4579f032ac3c9db3aef1749d40da5ea01ff Reviewed-on: https://go-review.googlesource.com/c/go/+/293389 Trust: David Chase <drchase@google.com> Run-TryBot: David Chase <drchase@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-01-25[dev.regabi] cmd/compile: modify abiutils for recently updated ABIDavid Chase
Discovered difficluties posed by earlier design, these modifications should work better. Updated tests, also added some helper functions for use in call lowering. Change-Id: I459f0f71ad8a6730c571244925c3f395e1df28de Reviewed-on: https://go-review.googlesource.com/c/go/+/285392 Trust: David Chase <drchase@google.com> Run-TryBot: David Chase <drchase@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2021-01-13[dev.regabi] cmd/compile: refactor abiutils from "gc" into new "abi"David Chase
Needs to be visible to ssagen, and might as well start clean to avoid creating a lot of accidental dependencies. Added some methods for export. Decided to use a pointer instead of value for ABIConfig uses. Tests ended up separate from abiutil itself; otherwise there are import cycles. Change-Id: I5570e1e6a463e303c5e2dc84e8dd4125e7c1adcc Reviewed-on: https://go-review.googlesource.com/c/go/+/282614 Trust: David Chase <drchase@google.com> Run-TryBot: David Chase <drchase@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Jeremy Faller <jeremy@golang.org>