| 1 |
From: "[email protected]" <[email protected]> |
| 2 |
Date: Tue, 21 Jul 2026 09:19:28 -0700 |
| 3 |
Subject: cmd/compile: fix mergelocals for arm32/s390x/riscv64 |
| 4 |
|
| 5 |
LoweredZero on arm32 and s390x also take an end-of-zero-range |
| 6 |
address. That input is also an address sink. |
| 7 |
|
| 8 |
Also allow propagation of addresses from input to output of a value, |
| 9 |
so that we handle at least simple address arithmetic. This is required |
| 10 |
to fix riscv64 because it has no indexed load/store, and thus does |
| 11 |
a bunch more explicit address arithmetic than other archs. |
| 12 |
|
| 13 |
Fixes #80484 |
| 14 |
|
| 15 |
Change-Id: I126eec1e2cc6c2ab5a39611ccc4d3371dca28292 |
| 16 |
Reviewed-on: https://go-review.googlesource.com/c/go/+/803660 |
| 17 |
Reviewed-by: Junyang Shao <[email protected]> |
| 18 |
Reviewed-by: David du Colombier <[email protected]> |
| 19 |
LUCI-TryBot-Result: [email protected] <[email protected]> |
| 20 |
Reviewed-by: Keith Randall <[email protected]> |
| 21 |
Auto-Submit: Keith Randall <[email protected]> |
| 22 |
--- |
| 23 |
src/cmd/compile/internal/liveness/mergelocals.go | 19 ++++++++++++++++--- |
| 24 |
src/cmd/compile/internal/ssa/_gen/ARMOps.go | 2 ++ |
| 25 |
src/cmd/compile/internal/ssa/_gen/S390XOps.go | 2 ++ |
| 26 |
src/cmd/compile/internal/ssa/opGen.go | 2 ++ |
| 27 |
4 files changed, 22 insertions(+), 3 deletions(-) |
| 28 |
|
| 29 |
diff --git a/src/cmd/compile/internal/liveness/mergelocals.go b/src/cmd/compile/internal/liveness/mergelocals.go |
| 30 |
index 28d034a..b9be0dd 100644 |
| 31 |
--- a/src/cmd/compile/internal/liveness/mergelocals.go |
| 32 |
+++ b/src/cmd/compile/internal/liveness/mergelocals.go |
| 33 |
@@ -516,9 +516,22 @@ func (cs *cstate) populateIndirectUseTable(cands []*ir.Name) ([]*ir.Name, []cand |
| 34 |
for idx, arg := range v.Args { |
| 35 |
if nc, ok := pendingUses[arg.ID]; ok { |
| 36 |
if !v.AddrSinkArg(idx) { |
| 37 |
- // If this op may propagate the argument address to its output, |
| 38 |
- // then give up. See issue 80127. |
| 39 |
- continue |
| 40 |
+ // If this op may propagate its input address |
| 41 |
+ // to somewhere else, we must track where that |
| 42 |
+ // somewhere else might be. See issue 80127. |
| 43 |
+ if v.Type.IsMemory() { |
| 44 |
+ // Might be stored to memory. Give up. |
| 45 |
+ continue |
| 46 |
+ } |
| 47 |
+ // Some sort of address arithmetic. |
| 48 |
+ if _, ok := pendingUses[v.ID]; ok { |
| 49 |
+ // v has used multiple addresses, which is something |
| 50 |
+ // we can't keep track of. Give up. |
| 51 |
+ continue |
| 52 |
+ } |
| 53 |
+ // Treat this op as producing the address of the same variable |
| 54 |
+ // that its argument was the address of. |
| 55 |
+ pendingUses[v.ID] = nameCount{n: nc.n, count: v.Uses} |
| 56 |
} |
| 57 |
// We found a use of some value that took the |
| 58 |
// address of nc.n. Record this inst as a |
| 59 |
diff --git a/src/cmd/compile/internal/ssa/_gen/ARMOps.go b/src/cmd/compile/internal/ssa/_gen/ARMOps.go |
| 60 |
index c40bdb3..624d1d9 100644 |
| 61 |
--- a/src/cmd/compile/internal/ssa/_gen/ARMOps.go |
| 62 |
+++ b/src/cmd/compile/internal/ssa/_gen/ARMOps.go |
| 63 |
@@ -507,6 +507,7 @@ func init() { |
| 64 |
clobberFlags: true, |
| 65 |
faultOnNilArg0: true, |
| 66 |
addrSinkArg0: true, |
| 67 |
+ addrSinkArg1: true, |
| 68 |
}, |
| 69 |
|
| 70 |
// large or unaligned move |
| 71 |
@@ -532,6 +533,7 @@ func init() { |
| 72 |
faultOnNilArg1: true, |
| 73 |
addrSinkArg0: true, |
| 74 |
addrSinkArg1: true, |
| 75 |
+ // TODO: could use addrSinkArg2 here. |
| 76 |
}, |
| 77 |
|
| 78 |
// Scheduler ensures LoweredGetClosurePtr occurs only in entry block, |
| 79 |
diff --git a/src/cmd/compile/internal/ssa/_gen/S390XOps.go b/src/cmd/compile/internal/ssa/_gen/S390XOps.go |
| 80 |
index 7774ac1..76e5d86 100644 |
| 81 |
--- a/src/cmd/compile/internal/ssa/_gen/S390XOps.go |
| 82 |
+++ b/src/cmd/compile/internal/ssa/_gen/S390XOps.go |
| 83 |
@@ -754,6 +754,7 @@ func init() { |
| 84 |
faultOnNilArg1: true, |
| 85 |
addrSinkArg0: true, |
| 86 |
addrSinkArg1: true, |
| 87 |
+ // TODO: could use addrSinkArg2 here. |
| 88 |
}, |
| 89 |
|
| 90 |
// large clear |
| 91 |
@@ -780,6 +781,7 @@ func init() { |
| 92 |
typ: "Mem", |
| 93 |
faultOnNilArg0: true, |
| 94 |
addrSinkArg0: true, |
| 95 |
+ addrSinkArg1: true, |
| 96 |
}, |
| 97 |
} |
| 98 |
|
| 99 |
diff --git a/src/cmd/compile/internal/ssa/opGen.go b/src/cmd/compile/internal/ssa/opGen.go |
| 100 |
index e54be43..25a6db9 100644 |
| 101 |
--- a/src/cmd/compile/internal/ssa/opGen.go |
| 102 |
+++ b/src/cmd/compile/internal/ssa/opGen.go |
| 103 |
@@ -65242,6 +65242,7 @@ var opcodeTable = [...]opInfo{ |
| 104 |
clobberFlags: true, |
| 105 |
faultOnNilArg0: true, |
| 106 |
addrSinkArg0: true, |
| 107 |
+ addrSinkArg1: true, |
| 108 |
reg: regInfo{ |
| 109 |
inputs: []inputInfo{ |
| 110 |
{0, 2}, // R1 |
| 111 |
@@ -85725,6 +85726,7 @@ var opcodeTable = [...]opInfo{ |
| 112 |
clobberFlags: true, |
| 113 |
faultOnNilArg0: true, |
| 114 |
addrSinkArg0: true, |
| 115 |
+ addrSinkArg1: true, |
| 116 |
reg: regInfo{ |
| 117 |
inputs: []inputInfo{ |
| 118 |
{0, 2}, // R1 |