Skip to content

Commit ca3aefc

Browse files
committed
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 <[email protected]> Run-TryBot: David Chase <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Cuong Manh Le <[email protected]> Reviewed-by: Cherry Zhang <[email protected]>
1 parent c847932 commit ca3aefc

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -1114,6 +1114,9 @@ func expandCalls(f *Func) {
11141114
for _, v := range b.Values {
11151115
if v.Op == OpStore {
11161116
t := v.Aux.(*types.Type)
1117+
if t.IsPtrShaped() { // Everything already fits, and this ensures pointer type properties aren't discarded (e.g, notinheap)
1118+
continue
1119+
}
11171120
source := v.Args[1]
11181121
tSrc := source.Type
11191122
iAEATt := x.isAlreadyExpandedAggregateType(t)
@@ -1422,7 +1425,7 @@ func (x *expandState) newArgToMemOrRegs(baseArg, toReplace *Value, offset int64,
14221425
if x.debug {
14231426
x.indent(3)
14241427
defer x.indent(-3)
1425-
x.Printf("newArgToMemOrRegs(base=%s; toReplace=%s; t=%s; memOff=%d; regOff=%d)\n", baseArg.String(), toReplace.LongString(), t, offset, regOffset)
1428+
x.Printf("newArgToMemOrRegs(base=%s; toReplace=%s; t=%s; memOff=%d; regOff=%d)\n", baseArg.String(), toReplace.LongString(), t.String(), offset, regOffset)
14261429
}
14271430
key := selKey{baseArg, offset, t.Width, t}
14281431
w := x.commonArgs[key]

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

+3
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ func (v *Value) AuxArm64BitField() arm64BitField {
139139

140140
// long form print. v# = opcode <type> [aux] args [: reg] (names)
141141
func (v *Value) LongString() string {
142+
if v == nil {
143+
return "<NIL VALUE>"
144+
}
142145
s := fmt.Sprintf("v%d = %s", v.ID, v.Op)
143146
s += " <" + v.Type.String() + ">"
144147
s += v.auxString()

0 commit comments

Comments
 (0)