mirror of
https://github.com/golang/go.git
synced 2024-09-22 02:48:50 +00:00
cmd/compile: make sure field offset is aligned for structure splitting
Always use the aligned form -- the old code sometimes could at least nominally use a misaligned field in an SSA-able struct, even if not actually. Fixes #42181. Change-Id: Ibdce0985f9349da70921a37423054b85ee4200d0 Reviewed-on: https://go-review.googlesource.com/c/go/+/265277 Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com> Trust: David Chase <drchase@google.com>
This commit is contained in:
parent
7be9158ce5
commit
2414e1f17b
@ -6978,15 +6978,10 @@ func (e *ssafn) SplitInt64(name ssa.LocalSlot) (ssa.LocalSlot, ssa.LocalSlot) {
|
||||
|
||||
func (e *ssafn) SplitStruct(name ssa.LocalSlot, i int) ssa.LocalSlot {
|
||||
st := name.Type
|
||||
ft := st.FieldType(i)
|
||||
var offset int64
|
||||
for f := 0; f < i; f++ {
|
||||
offset += st.FieldType(f).Size()
|
||||
}
|
||||
// Note: the _ field may appear several times. But
|
||||
// have no fear, identically-named but distinct Autos are
|
||||
// ok, albeit maybe confusing for a debugger.
|
||||
return e.SplitSlot(&name, "."+st.FieldName(i), offset, ft)
|
||||
return e.SplitSlot(&name, "."+st.FieldName(i), st.FieldOff(i), st.FieldType(i))
|
||||
}
|
||||
|
||||
func (e *ssafn) SplitArray(name ssa.LocalSlot) ssa.LocalSlot {
|
||||
|
Loading…
Reference in New Issue
Block a user