]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: fix wrong position when rewriting to OpArg/OpArgXXX
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Fri, 26 Aug 2022 05:19:50 +0000 (12:19 +0700)
committerCuong Manh Le <cuong.manhle.vn@gmail.com>
Tue, 30 Aug 2022 00:49:19 +0000 (00:49 +0000)
When spilling arg to stack or register, if it's a newly created value,
the arg position should be preserved. Otherwise, we may end up using
position information from deadcode lines.

This fixes the minimized test case in #54625 by mdempsky@, and make
building std successfully. However, the inline trees for these tests
still be corrupted:

 - fixedbugs/issue53982.go
 - typeparam/issue47775.go
 - typeparam/issue47775b.go
 - typeparam/issue49432.go

We probably still mess up the inline position somewhere else.

Updates #54625

Change-Id: I0d87e26b9ab451b85b6e79787da74a2b79a16209
Reviewed-on: https://go-review.googlesource.com/c/go/+/425785
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/cmd/compile/internal/ssa/expand_calls.go

index 90ea2d50403fdb9e8dec321f58c9760c8bc10a19..a85d763a30767c438dc56293f69db3a9cdca4451 100644 (file)
@@ -1742,7 +1742,7 @@ func (x *expandState) newArgToMemOrRegs(baseArg, toReplace *Value, offset int64,
                        toReplace.Type = t
                        w = toReplace
                } else {
-                       w = baseArg.Block.NewValue0IA(pos, OpArg, t, auxInt, aux)
+                       w = baseArg.Block.NewValue0IA(baseArg.Pos, OpArg, t, auxInt, aux)
                }
                x.commonArgs[key] = w
                if toReplace != nil {
@@ -1773,7 +1773,7 @@ func (x *expandState) newArgToMemOrRegs(baseArg, toReplace *Value, offset int64,
                toReplace.Type = t
                w = toReplace
        } else {
-               w = baseArg.Block.NewValue0IA(pos, op, t, auxInt, aux)
+               w = baseArg.Block.NewValue0IA(baseArg.Pos, op, t, auxInt, aux)
        }
        x.commonArgs[key] = w
        if toReplace != nil {