Open And-ZJ opened 3 months ago
Related Issues and Documentation
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
It seems the auxint is computed pre-register-ABI in ssagen/ssa.go. For the stack ABI (ABI0), this would be correct. With register ABI, it can be smaller.
cc @dr2chase
Is this an issue that's new to the current release? (Is it observable in older releases?) For now, putting in Backlog under the assumption that it's from an older release.
I don't think it's new.
Hello, Thanks for the reply.
This problem should be existed in previous versions of go. I checked 1.22 and 1.20 under ARM64, AuxInt for newobject
is 24, AuxInt for test1
is 8.
Go version
go version go1.23rc2 linux/arm64
Output of
go env
in your module/workspace:What did you do?
When I look at the call to
runtime.newobject
in SSA, it looks like the AuxInt value is inaccurate.I think It is larger than expected. In addition, the value is larger in ARM64 than in AMD64.
My test code
temp.go
:Build, dump SSA and view assembly code:
ARM64(SSA dump in
before insert phis
phase):ARM64(assembly code):
AMD64(SSA dump in
before insert phis
phase):AMD64(assembly code):
In ARM64: The
newobject
's AuxInt is 24. The test1's AuxInt is 8. Note thetest1
function that has only one input parameter and one return value. The stack space of themain
function uses 48 bytes.In AMD64: The
newobject
's AuxInt is 16. Thetest1
's AuxInt is 8. The stack space of themain
function uses 24 bytes (0x10 + 8).The
StaticLECall
in https://github.com/golang/go/blob/30b6fd60a63c738c2736e83b6a6886a032e6f269/src/cmd/compile/internal/ssa/_gen/genericOps.go#L436Here, AuxInt indicates the size of the input parameter, but it is not specified whether the mem parameter is included. It is suspected that the mem parameter is not included.
The
auxCallOff
in https://github.com/golang/go/blob/30b6fd60a63c738c2736e83b6a6886a032e6f269/src/cmd/compile/internal/ssa/op.go#L365Here, AuxInt indicates includes the size of the input and output parameters?
The runtime call newobject may emit at (*state).newObject at https://github.com/golang/go/blob/30b6fd60a63c738c2736e83b6a6886a032e6f269/src/cmd/compile/internal/ssagen/ssa.go#L713
In this way, it call
(*state).rtcall
at https://github.com/golang/go/blob/30b6fd60a63c738c2736e83b6a6886a032e6f269/src/cmd/compile/internal/ssagen/ssa.go#L5941AuxInt appears to be the sum of the size of the input and output parameters and
FixedFrameSize
.The common call test1 may emit at (*state).call at https://github.com/golang/go/blob/30b6fd60a63c738c2736e83b6a6886a032e6f269/src/cmd/compile/internal/ssagen/ssa.go#L5353
In this way, AuxInt mostly equal to
(*ABIParamResultInfo).ArgWidth()
, This should be the size of the stack space to be used when calling. The space includes the spill space of the register transfer parameter, and the space on the stack of the input and output parameters of the stack transfer parameter.So, I've got a lot of explanations for AuxInt of this situation and I'm confused.
From the main function assembly, I think the space used on the stack is larger than what is actually needed.
The gray areas that are marked here are what I consider to be unused space.
For other functions that use the
(*state).rtcall
, the situation may be similar.This should have happened in previous versions of go.
I haven't been able to find out if anyone else has had the same problem.
Thank you for your reading.
My understanding may be incorrect, please point it out, thanks.
What did you see happen?
The caller's stack space used by newobject is larger than my expected. It's AuxInt is inaccurate?
What did you expect to see?
More precise AuxInt of newobject and other runtime calls?