aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCherry Zhang <cherryyz@google.com>2021-04-01 14:21:12 -0400
committerCherry Zhang <cherryyz@google.com>2021-04-02 00:45:56 +0000
commit5579ee169f12815660eb9ee66afd5f2abc77864f (patch)
tree8d3b674d623839c26c85ffe5c6ab2b35de1f07c5 /src
parent27d306281c54a89ff00e3dad6f4cea790a2f2f2d (diff)
downloadgo-5579ee169f12815660eb9ee66afd5f2abc77864f.tar.xz
cmd/compile: in expand calls, preserve pointer store type but decompose aggregate args
In CL 305672 we preserve the pointer type of a store by just not decomposing it. But this can be problematic when the source of the store is a direct interface aggregate type (e.g. struct { x map[int]int }. In this CL we take a different approach: we preserve the store type when generating the new store, but also decompose the source. Fixes #45344. Change-Id: If5dd496458dee95aa649c6d106b96a6cdcf3e60d Reviewed-on: https://go-review.googlesource.com/c/go/+/306669 Trust: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/cmd/compile/internal/ssa/expand_calls.go11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/cmd/compile/internal/ssa/expand_calls.go b/src/cmd/compile/internal/ssa/expand_calls.go
index 2935236473..a5fe6f4d29 100644
--- a/src/cmd/compile/internal/ssa/expand_calls.go
+++ b/src/cmd/compile/internal/ssa/expand_calls.go
@@ -589,6 +589,14 @@ func (x *expandState) decomposeArg(pos src.XPos, b *Block, source, mem *Value, t
if w == nil {
w = x.newArgToMemOrRegs(source, w, off, i, rt, pos)
}
+ if t.IsPtrShaped() {
+ // Preserve the original store type. This ensures pointer type
+ // properties aren't discarded (e.g, notinheap).
+ if rt.Width != t.Width || len(pa.Registers) != 1 || i != loadRegOffset {
+ b.Func.Fatalf("incompatible store type %v and %v, i=%d", t, rt, i)
+ }
+ rt = t
+ }
mem = x.storeArgOrLoad(pos, b, w, mem, rt, storeOffset+off, i, storeRc.next(rt))
}
return mem
@@ -1114,9 +1122,6 @@ func expandCalls(f *Func) {
for _, v := range b.Values {
if v.Op == OpStore {
t := v.Aux.(*types.Type)
- if t.IsPtrShaped() { // Everything already fits, and this ensures pointer type properties aren't discarded (e.g, notinheap)
- continue
- }
source := v.Args[1]
tSrc := source.Type
iAEATt := x.isAlreadyExpandedAggregateType(t)