diff options
author | David Chase <drchase@google.com> | 2020-10-26 19:06:39 -0400 |
---|---|---|
committer | David Chase <drchase@google.com> | 2020-10-28 01:22:47 +0000 |
commit | 2414e1f17b2f82be10110513b17cdfa80c9937c6 (patch) | |
tree | e2d2bac54c1c0a90110bf38869265626f750cb9a | |
parent | 7be9158ce50e8f9f9a9a624874b8e4f3ceb07f44 (diff) | |
download | go-2414e1f17b2f82be10110513b17cdfa80c9937c6.tar.gz go-2414e1f17b2f82be10110513b17cdfa80c9937c6.zip |
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>
-rw-r--r-- | src/cmd/compile/internal/gc/ssa.go | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/src/cmd/compile/internal/gc/ssa.go b/src/cmd/compile/internal/gc/ssa.go index 4488337924..fb9d3e811a 100644 --- a/src/cmd/compile/internal/gc/ssa.go +++ b/src/cmd/compile/internal/gc/ssa.go @@ -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 { |