1
0
mirror of https://github.com/golang/go synced 2024-11-26 17:07:09 -07:00

cmd/compile: make expandCalls preserve types of pointer stores

This is accomplished by checking for simple stores of pointer types
and leaving them alone.  The failure case was when a *mspan
(not in heap) stored type was replaced by unsafe.Pointer.

Updates #40724.

Change-Id: I529e1705bf58fb0e64e60d48fd550b3a407e57e7
Reviewed-on: https://go-review.googlesource.com/c/go/+/305672
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
David Chase 2021-03-29 20:14:51 -04:00
parent c847932804
commit ca3aefc4a9
2 changed files with 7 additions and 1 deletions

View File

@ -1114,6 +1114,9 @@ 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)
@ -1422,7 +1425,7 @@ func (x *expandState) newArgToMemOrRegs(baseArg, toReplace *Value, offset int64,
if x.debug {
x.indent(3)
defer x.indent(-3)
x.Printf("newArgToMemOrRegs(base=%s; toReplace=%s; t=%s; memOff=%d; regOff=%d)\n", baseArg.String(), toReplace.LongString(), t, offset, regOffset)
x.Printf("newArgToMemOrRegs(base=%s; toReplace=%s; t=%s; memOff=%d; regOff=%d)\n", baseArg.String(), toReplace.LongString(), t.String(), offset, regOffset)
}
key := selKey{baseArg, offset, t.Width, t}
w := x.commonArgs[key]

View File

@ -139,6 +139,9 @@ func (v *Value) AuxArm64BitField() arm64BitField {
// long form print. v# = opcode <type> [aux] args [: reg] (names)
func (v *Value) LongString() string {
if v == nil {
return "<NIL VALUE>"
}
s := fmt.Sprintf("v%d = %s", v.ID, v.Op)
s += " <" + v.Type.String() + ">"
s += v.auxString()