]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile, runtime: mark R1 as clobbered for write barrier call
authorCherry Mui <cherryyz@google.com>
Sat, 13 Nov 2021 00:53:28 +0000 (19:53 -0500)
committerCherry Mui <cherryyz@google.com>
Mon, 15 Nov 2021 15:42:24 +0000 (15:42 +0000)
If the call to gcWriteBarrier is via PLT, the PLT stub will
clobber R1. Mark R1 clobbered.

For #49386.

Change-Id: I72df5bb3b8d10381fec5c567b15749aaf7d2ad70
Reviewed-on: https://go-review.googlesource.com/c/go/+/363698
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
src/cmd/compile/internal/ssa/gen/S390XOps.go
src/cmd/compile/internal/ssa/opGen.go
src/runtime/asm_s390x.s

index cd7bad7acb676fec3b0df09704ce02e001aa0c3a..eef8a2557ca39d51e91cb5c5715d3b4d5678c0a2 100644 (file)
@@ -509,8 +509,9 @@ func init() {
 
                // LoweredWB invokes runtime.gcWriteBarrier. arg0=destptr, arg1=srcptr, arg2=mem, aux=runtime.gcWriteBarrier
                // It saves all GP registers if necessary,
-               // but clobbers R14 (LR) because it's a call.
-               {name: "LoweredWB", argLength: 3, reg: regInfo{inputs: []regMask{buildReg("R2"), buildReg("R3")}, clobbers: (callerSave &^ gpg) | buildReg("R14")}, clobberFlags: true, aux: "Sym", symEffect: "None"},
+               // but clobbers R14 (LR) because it's a call,
+               // and also clobbers R1 as the PLT stub does.
+               {name: "LoweredWB", argLength: 3, reg: regInfo{inputs: []regMask{buildReg("R2"), buildReg("R3")}, clobbers: (callerSave &^ gpg) | buildReg("R14") | r1}, clobberFlags: true, aux: "Sym", symEffect: "None"},
 
                // There are three of these functions so that they can have three different register inputs.
                // When we check 0 <= c <= cap (A), then 0 <= b <= c (B), then 0 <= a <= b (C), we want the
index 2038575b0cfc5207c27f27f2790384052e397141..81fe5d4c23cbc6d99054e54f7e2c95688a465063 100644 (file)
@@ -32779,7 +32779,7 @@ var opcodeTable = [...]opInfo{
                                {0, 4}, // R2
                                {1, 8}, // R3
                        },
-                       clobbers: 4294918144, // R14 F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15
+                       clobbers: 4294918146, // R1 R14 F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15
                },
        },
        {
index 5894fe5783113e6717233aaf1a09afcfebdce4d1..9159a673721ff3aad7928c446ebfb136dee8c51c 100644 (file)
@@ -777,13 +777,12 @@ TEXT ·checkASM(SB),NOSPLIT,$0-1
 // gcWriteBarrier does NOT follow the Go ABI. It takes two arguments:
 // - R2 is the destination of the write
 // - R3 is the value being written at R2.
-// It clobbers R10 (the temp register).
+// It clobbers R10 (the temp register) and R1 (used by PLT stub).
 // It does not clobber any other general-purpose registers,
 // but may clobber others (e.g., floating point registers).
-TEXT runtime·gcWriteBarrier(SB),NOSPLIT,$104
+TEXT runtime·gcWriteBarrier(SB),NOSPLIT,$96
        // Save the registers clobbered by the fast path.
-       MOVD    R1, 96(R15)
-       MOVD    R4, 104(R15)
+       MOVD    R4, 96(R15)
        MOVD    g_m(g), R1
        MOVD    m_p(R1), R1
        // Increment wbBuf.next position.
@@ -798,8 +797,7 @@ TEXT runtime·gcWriteBarrier(SB),NOSPLIT,$104
        // Is the buffer full?
        CMPBEQ  R4, R1, flush
 ret:
-       MOVD    96(R15), R1
-       MOVD    104(R15), R4
+       MOVD    96(R15), R4
        // Do the write.
        MOVD    R3, (R2)
        RET