Skip to content

Commit 2414e1f

Browse files
committed
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>
1 parent 7be9158 commit 2414e1f

1 file changed

Lines changed: 1 addition & 6 deletions

File tree

  • src/cmd/compile/internal/gc

src/cmd/compile/internal/gc/ssa.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6978,15 +6978,10 @@ func (e *ssafn) SplitInt64(name ssa.LocalSlot) (ssa.LocalSlot, ssa.LocalSlot) {
69786978

69796979
func (e *ssafn) SplitStruct(name ssa.LocalSlot, i int) ssa.LocalSlot {
69806980
st := name.Type
6981-
ft := st.FieldType(i)
6982-
var offset int64
6983-
for f := 0; f < i; f++ {
6984-
offset += st.FieldType(f).Size()
6985-
}
69866981
// Note: the _ field may appear several times. But
69876982
// have no fear, identically-named but distinct Autos are
69886983
// ok, albeit maybe confusing for a debugger.
6989-
return e.SplitSlot(&name, "."+st.FieldName(i), offset, ft)
6984+
return e.SplitSlot(&name, "."+st.FieldName(i), st.FieldOff(i), st.FieldType(i))
69906985
}
69916986

69926987
func (e *ssafn) SplitArray(name ssa.LocalSlot) ssa.LocalSlot {

0 commit comments

Comments
 (0)