Debian Codegraph @

debian/patches/0006-cmd-compile-fix-mergelocals-for-arm32-s390x-riscv64.patch

raw
1 From: "Dr. Tobias Quathamer" <[email protected]>
2 Date: Fri, 21 Aug 2026 17:57:28 +0200
3 Subject: cmd/compile: fix mergelocals for arm32/s390x/riscv64
4
5 This is a cherry-pick from https://go-review.googlesource.com/c/go/+/812920
6 ---
7 src/cmd/compile/internal/liveness/mergelocals.go | 19 ++++++++++++++++---
8 src/cmd/compile/internal/ssa/_gen/ARMOps.go | 2 ++
9 src/cmd/compile/internal/ssa/_gen/RISCV64Ops.go | 4 ++++
10 src/cmd/compile/internal/ssa/opGen.go | 4 ++++
11 4 files changed, 26 insertions(+), 3 deletions(-)
12
13 diff --git a/src/cmd/compile/internal/liveness/mergelocals.go b/src/cmd/compile/internal/liveness/mergelocals.go
14 index 28d034a..b9be0dd 100644
15 --- a/src/cmd/compile/internal/liveness/mergelocals.go
16 +++ b/src/cmd/compile/internal/liveness/mergelocals.go
17 @@ -516,9 +516,22 @@ func (cs *cstate) populateIndirectUseTable(cands []*ir.Name) ([]*ir.Name, []cand
18 for idx, arg := range v.Args {
19 if nc, ok := pendingUses[arg.ID]; ok {
20 if !v.AddrSinkArg(idx) {
21 - // If this op may propagate the argument address to its output,
22 - // then give up. See issue 80127.
23 - continue
24 + // If this op may propagate its input address
25 + // to somewhere else, we must track where that
26 + // somewhere else might be. See issue 80127.
27 + if v.Type.IsMemory() {
28 + // Might be stored to memory. Give up.
29 + continue
30 + }
31 + // Some sort of address arithmetic.
32 + if _, ok := pendingUses[v.ID]; ok {
33 + // v has used multiple addresses, which is something
34 + // we can't keep track of. Give up.
35 + continue
36 + }
37 + // Treat this op as producing the address of the same variable
38 + // that its argument was the address of.
39 + pendingUses[v.ID] = nameCount{n: nc.n, count: v.Uses}
40 }
41 // We found a use of some value that took the
42 // address of nc.n. Record this inst as a
43 diff --git a/src/cmd/compile/internal/ssa/_gen/ARMOps.go b/src/cmd/compile/internal/ssa/_gen/ARMOps.go
44 index f21f2cb..7a392db 100644
45 --- a/src/cmd/compile/internal/ssa/_gen/ARMOps.go
46 +++ b/src/cmd/compile/internal/ssa/_gen/ARMOps.go
47 @@ -505,6 +505,7 @@ func init() {
48 clobberFlags: true,
49 faultOnNilArg0: true,
50 addrSinkArg0: true,
51 + addrSinkArg1: true,
52 },
53
54 // large or unaligned move
55 @@ -530,6 +531,7 @@ func init() {
56 faultOnNilArg1: true,
57 addrSinkArg0: true,
58 addrSinkArg1: true,
59 + // TODO: could use addrSinkArg2 here.
60 },
61
62 // Scheduler ensures LoweredGetClosurePtr occurs only in entry block,
63 diff --git a/src/cmd/compile/internal/ssa/_gen/RISCV64Ops.go b/src/cmd/compile/internal/ssa/_gen/RISCV64Ops.go
64 index a72a6f5..49f54b9 100644
65 --- a/src/cmd/compile/internal/ssa/_gen/RISCV64Ops.go
66 +++ b/src/cmd/compile/internal/ssa/_gen/RISCV64Ops.go
67 @@ -290,6 +290,7 @@ func init() {
68 },
69 typ: "Mem",
70 faultOnNilArg0: true,
71 + addrSinkArg0: true,
72 },
73
74 // duffcopy
75 @@ -335,6 +336,8 @@ func init() {
76 },
77 typ: "Mem",
78 faultOnNilArg0: true,
79 + addrSinkArg0: true,
80 + addrSinkArg1: true,
81 },
82
83 // general unaligned move
84 @@ -363,6 +366,7 @@ func init() {
85 faultOnNilArg1: true,
86 addrSinkArg0: true,
87 addrSinkArg1: true,
88 + // TODO: could use addrSinkArg2 here.
89 },
90
91 // Atomic loads.
92 diff --git a/src/cmd/compile/internal/ssa/opGen.go b/src/cmd/compile/internal/ssa/opGen.go
93 index 442ac71..b7c9050 100644
94 --- a/src/cmd/compile/internal/ssa/opGen.go
95 +++ b/src/cmd/compile/internal/ssa/opGen.go
96 @@ -19480,6 +19480,7 @@ var opcodeTable = [...]opInfo{
97 clobberFlags: true,
98 faultOnNilArg0: true,
99 addrSinkArg0: true,
100 + addrSinkArg1: true,
101 reg: regInfo{
102 inputs: []inputInfo{
103 {0, 2}, // R1
104 @@ -35125,6 +35126,7 @@ var opcodeTable = [...]opInfo{
105 auxType: auxInt64,
106 argLen: 2,
107 faultOnNilArg0: true,
108 + addrSinkArg0: true,
109 reg: regInfo{
110 inputs: []inputInfo{
111 {0, 16777216}, // X25
112 @@ -35153,6 +35155,8 @@ var opcodeTable = [...]opInfo{
113 auxType: auxInt64,
114 argLen: 3,
115 faultOnNilArg0: true,
116 + addrSinkArg0: true,
117 + addrSinkArg1: true,
118 reg: regInfo{
119 inputs: []inputInfo{
120 {0, 16}, // X5