Skip to content

Commit c643b29

Browse files
committed
cmd/compile: use callsite as line number for argument marshaling
Don't use the line number of the argument itself, as that may be from arbitrarily earlier in the function. Fixes #60673 Change-Id: Ifc0a2aaae221a256be3a4b0b2e04849bae4b79d7 Reviewed-on: https://go-review.googlesource.com/c/go/+/502656 TryBot-Result: Gopher Robot <[email protected]> Run-TryBot: Keith Randall <[email protected]> Reviewed-by: David Chase <[email protected]> Reviewed-by: Keith Randall <[email protected]>
1 parent 992afd9 commit c643b29

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,7 @@ func (x *expandState) rewriteArgs(v *Value, firstArg int) {
11151115
}
11161116
// "Dereference" of addressed (probably not-SSA-eligible) value becomes Move
11171117
// TODO(register args) this will be more complicated with registers in the picture.
1118-
mem = x.rewriteDereference(v.Block, sp, a, mem, aOffset, aux.SizeOfArg(auxI), aType, a.Pos)
1118+
mem = x.rewriteDereference(v.Block, sp, a, mem, aOffset, aux.SizeOfArg(auxI), aType, v.Pos)
11191119
} else {
11201120
var rc registerCursor
11211121
var result *[]*Value
@@ -1137,7 +1137,7 @@ func (x *expandState) rewriteArgs(v *Value, firstArg int) {
11371137
x.Printf("...storeArg %s, %v, %d\n", a.LongString(), aType, aOffset)
11381138
}
11391139
rc.init(aRegs, aux.abiInfo, result, sp)
1140-
mem = x.storeArgOrLoad(a.Pos, v.Block, a, mem, aType, aOffset, 0, rc)
1140+
mem = x.storeArgOrLoad(v.Pos, v.Block, a, mem, aType, aOffset, 0, rc)
11411141
}
11421142
}
11431143
var preArgStore [2]*Value

test/codegen/issue60673.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// asmcheck
2+
3+
// Copyright 2023 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+
package codegen
8+
9+
//go:noinline
10+
func f(x int32) {
11+
}
12+
13+
func g(p *int32) {
14+
// argument marshaling code should live at line 17, not line 15.
15+
x := *p
16+
// 386: `MOVL\s[A-Z]+,\s\(SP\)`
17+
f(x)
18+
}

0 commit comments

Comments
 (0)