New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/compile: investigate test/fixedbugs/issue20250.go with GOEXPERIMENT=unified #54402
Comments
Ohh, riscv64 is a regabi-supported architecture, but {amd64, arm64, ppc64, ppc64le} are regabi-always architectures: go/src/internal/buildcfg/exp.go Lines 59 to 70 in dfbecc0
So that explains why GOEXPERIMENT=noregabi only affects riscv64. It's still a bit puzzling that the specific combination Notably, the test does involve OCONVIFACE, and unified IR now adds explicit RTTI operands to these nodes upfront. So that plausibly influences backend code generation. And there's the generated call to |
Change https://go.dev/cl/422975 mentions this issue: |
@mdempsky The backend sort the stack variables for stable stack layout. See |
@cuonglm Thanks. But why does that sorting only change the output for GOEXPERIMENT=unified? Why do we always print the variables in the same order for GOEXPERIMENT=nounified? |
Seems related to how we record |
Oh right, because we removed unified's quirks mode and then changed the order that we visit assignment statements (9e5c968), which in turn affects the order that we capture variables. I remembered previously being careful that unified IR generated fn.ClosureVars in the same order. But it makes sense that it would sometimes be different now, including in this test case. Okay, that explains GOEXPERIMENT=unified's involvement here. Thanks. The last minor question then is why GOEXPERIMENT=nounified always prints in the same order, on both regabi and noregabi architectures? |
With GOEXPERIMENT=unified, the order variables are printed in "live at entry to f.func1" is sensitive to whether regabi is enabled for some reason. The order shouldn't matter to correctness, but it is odd. For now, this CL just relaxes the test expectation order to unblock enabling GOEXPERIMENT=unified by default. I've filed #54402 to investigate further to confirm this a concern. Updates #54402. Change-Id: Iddfbb12c6cf7cc17b2aec8102b33761abd5f93ad Reviewed-on: https://go-review.googlesource.com/c/go/+/422975 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
It's a direct closure call, so it isn't marked as need context register. Thus closure variables aren't passed via registers. |
Okay, I understand what's going on now. Thanks @cuonglm for the investigation. Full explanation: Since the removal of quirks mode, the unified frontend discovers captured variables in a different order. Given However, it does have the effect that f.func1's signature changed from (effectively) Note also that Also, parameters that are passed by register still get stack space reserved for them, but after any parameters that are passed on the stack. This is why the frame offsets for
Changing the parameter signature to Finally, that all affects how byStackVar sorts the fn.Dcl list (because parameters get sorted by stack offset); which in turn is the order that they get listed in liveness diagnostics. |
Change https://go.dev/cl/461456 mentions this issue: |
With CL 462898 merged, the fix could also just be to put them in the new deterministic sort order. |
test/fixedbugs/issue20250.go contains this ERROR expectation:
go/test/fixedbugs/issue20250.go
Line 19 in f469f20
This works fine currently on all trybots. It also works fine currently with GOEXPERIMENT=unified on most trybots.
But with GOEXPERIMENT=unified and the linux-arm and js-wasm trybots, we instead report:
on that line. Note:
&e a
instead ofa &e
.Semantically, this doesn't matter. But it's still odd.
Notably, unified IR is generating identical IR for linux-amd64, linux-arm, and js-wasm:
so it's odd linux-arm and js-wasm are different.
Compiling for all targets listed by
go tool dist list
, it looks like it's dependent upon GOARCH:a &e
: amd64, arm64, ppc64, ppc64le, riscv64&e a
: 386, arm, loong64, mips64, mips64le, s390x, wasmI thought maybe this is regabi vs no-regabi architectures, but adding
noregabi
to GOEXPERIMENT only causes riscv64 to switch sides. The distinction between (e.g.,) amd64 and arm remains.I plan to just relax the test expectations to allow either
a &e
or&e a
, because I don't think it's a real issue and its blocking enabling GOEXPERIMENT=unified by default. But filing an issue to remember to look into this further into the dev cycle.The text was updated successfully, but these errors were encountered: