Skip to content

Commit cca23a7

Browse files
committed
cmd/compile: revert CL/316890
This is a revert of https://go-review.googlesource.com/c/go/+/316890, which has positive effects on debugging + DWARF variable locations for register parameters when the reg abi is in effect, but also turns out to interact badly with the register allocator. Fixes golang#46304. Change-Id: I624bd980493411a9cde45d44fcd3c46cad796909 Reviewed-on: https://go-review.googlesource.com/c/go/+/321830 Trust: Than McIntosh <[email protected]> Run-TryBot: Than McIntosh <[email protected]> Reviewed-by: Cherry Mui <[email protected]> TryBot-Result: Go Bot <[email protected]>
1 parent f87194c commit cca23a7

2 files changed

Lines changed: 76 additions & 16 deletions

File tree

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

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1717,22 +1717,6 @@ func (x *expandState) newArgToMemOrRegs(baseArg, toReplace *Value, offset int64,
17171717
} else {
17181718
w = baseArg.Block.NewValue0IA(pos, op, t, auxInt, aux)
17191719
}
1720-
// If we are creating an OpArgIntReg/OpArgFloatReg that
1721-
// corresponds to an in-param that fits entirely in a register,
1722-
// then enter it into the name/value table. The LocalSlot
1723-
// is somewhat fictitious, since there is no incoming live
1724-
// memory version of the parameter, but we need an entry in
1725-
// NamedValues in order for ssa debug tracking to include
1726-
// the value in the tracking analysis.
1727-
if len(pa.Registers) == 1 {
1728-
loc := LocalSlot{N: aux.Name, Type: t, Off: 0}
1729-
values, ok := x.f.NamedValues[loc]
1730-
if !ok {
1731-
ploc := x.f.localSlotAddr(loc)
1732-
x.f.Names = append(x.f.Names, ploc)
1733-
}
1734-
x.f.NamedValues[loc] = append(values, w)
1735-
}
17361720
x.commonArgs[key] = w
17371721
if toReplace != nil {
17381722
toReplace.copyOf(w)

test/fixedbugs/issue46304.go

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
// run
2+
3+
// Copyright 2021 The Go Authors. All rights reserved.
4+
// Use of this source code is governed by a BSD-style
5+
// license that can be found in the LICENSE file.
6+
7+
// This testcase caused a crash when the register ABI was in effect,
8+
// on amd64 (problem with register allocation).
9+
10+
package main
11+
12+
type Op struct {
13+
tag string
14+
_x []string
15+
_q [20]uint64
16+
plist []P
17+
}
18+
19+
type P struct {
20+
tag string
21+
_x [10]uint64
22+
b bool
23+
}
24+
25+
type M int
26+
27+
//go:noinline
28+
func (w *M) walkP(p *P) *P {
29+
np := &P{}
30+
*np = *p
31+
np.tag += "new"
32+
return np
33+
}
34+
35+
func (w *M) walkOp(op *Op) *Op {
36+
if op == nil {
37+
return nil
38+
}
39+
40+
orig := op
41+
cloned := false
42+
clone := func() {
43+
if !cloned {
44+
cloned = true
45+
op = &Op{}
46+
*op = *orig
47+
}
48+
}
49+
50+
pCloned := false
51+
for i := range op.plist {
52+
if s := w.walkP(&op.plist[i]); s != &op.plist[i] {
53+
if !pCloned {
54+
pCloned = true
55+
clone()
56+
op.plist = make([]P, len(orig.plist))
57+
copy(op.plist, orig.plist)
58+
}
59+
op.plist[i] = *s
60+
}
61+
}
62+
63+
return op
64+
}
65+
66+
func main() {
67+
var ww M
68+
w := &ww
69+
p1 := P{tag: "a"}
70+
p1._x[1] = 9
71+
o := Op{tag: "old", plist: []P{p1}}
72+
no := w.walkOp(&o)
73+
if no.plist[0].tag != "anew" {
74+
panic("bad")
75+
}
76+
}

0 commit comments

Comments
 (0)