From 629ae1cee673c66dd540b424c9e86a4ce3aaf9e3 Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Fri, 26 Aug 2022 12:19:50 +0700 Subject: [PATCH] cmd/compile: fix wrong position when rewriting to OpArg/OpArgXXX 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 TryBot-Result: Gopher Robot Reviewed-by: Heschi Kreinick Run-TryBot: Cuong Manh Le Reviewed-by: Matthew Dempsky --- src/cmd/compile/internal/ssa/expand_calls.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cmd/compile/internal/ssa/expand_calls.go b/src/cmd/compile/internal/ssa/expand_calls.go index 90ea2d5040..a85d763a30 100644 --- a/src/cmd/compile/internal/ssa/expand_calls.go +++ b/src/cmd/compile/internal/ssa/expand_calls.go @@ -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 { -- 2.50.0