mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: mark R12 clobbered for special calls
In external linking mode the external linker may insert trampolines, which use R12 as a scratch register. So a call could potentially clobber R12 if the target is laid out too far. Mark R12 clobbered. Also, we will use R12 for trampolines in the Go linker as well. CL 310731 updated the generated rewrite files so imports are grouped, but the generator was not updated to do so. Grouped imports are nice. But as those are generated files, for simplicity and my laziness, just regenerate with the current generator (which makes imports not grouped). Change-Id: Iddb741ff7314a291ade5fbffc7d315f555808409 Reviewed-on: https://go-review.googlesource.com/c/go/+/314453 Trust: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
This commit is contained in:
parent
4fe324dd0f
commit
4a7effa418
10 changed files with 31 additions and 46 deletions
|
|
@ -2,6 +2,7 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
//go:build ignore
|
||||||
// +build ignore
|
// +build ignore
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
@ -156,7 +157,7 @@ func init() {
|
||||||
reg: regInfo{
|
reg: regInfo{
|
||||||
inputs: []regMask{buildReg("R1"), buildReg("R0")},
|
inputs: []regMask{buildReg("R1"), buildReg("R0")},
|
||||||
outputs: []regMask{buildReg("R0"), buildReg("R1")},
|
outputs: []regMask{buildReg("R0"), buildReg("R1")},
|
||||||
clobbers: buildReg("R2 R3 R14"),
|
clobbers: buildReg("R2 R3 R12 R14"), // R14 is LR, R12 is linker trampoline scratch register
|
||||||
},
|
},
|
||||||
clobberFlags: true,
|
clobberFlags: true,
|
||||||
typ: "(UInt32,UInt32)",
|
typ: "(UInt32,UInt32)",
|
||||||
|
|
@ -459,7 +460,7 @@ func init() {
|
||||||
argLength: 3,
|
argLength: 3,
|
||||||
reg: regInfo{
|
reg: regInfo{
|
||||||
inputs: []regMask{buildReg("R1"), buildReg("R0")},
|
inputs: []regMask{buildReg("R1"), buildReg("R0")},
|
||||||
clobbers: buildReg("R1 R14"),
|
clobbers: buildReg("R1 R12 R14"), // R14 is LR, R12 is linker trampoline scratch register
|
||||||
},
|
},
|
||||||
faultOnNilArg0: true,
|
faultOnNilArg0: true,
|
||||||
},
|
},
|
||||||
|
|
@ -476,7 +477,7 @@ func init() {
|
||||||
argLength: 3,
|
argLength: 3,
|
||||||
reg: regInfo{
|
reg: regInfo{
|
||||||
inputs: []regMask{buildReg("R2"), buildReg("R1")},
|
inputs: []regMask{buildReg("R2"), buildReg("R1")},
|
||||||
clobbers: buildReg("R0 R1 R2 R14"),
|
clobbers: buildReg("R0 R1 R2 R12 R14"), // R14 is LR, R12 is linker trampoline scratch register
|
||||||
},
|
},
|
||||||
faultOnNilArg0: true,
|
faultOnNilArg0: true,
|
||||||
faultOnNilArg1: true,
|
faultOnNilArg1: true,
|
||||||
|
|
@ -564,8 +565,8 @@ func init() {
|
||||||
|
|
||||||
// LoweredWB invokes runtime.gcWriteBarrier. arg0=destptr, arg1=srcptr, arg2=mem, aux=runtime.gcWriteBarrier
|
// LoweredWB invokes runtime.gcWriteBarrier. arg0=destptr, arg1=srcptr, arg2=mem, aux=runtime.gcWriteBarrier
|
||||||
// It saves all GP registers if necessary,
|
// It saves all GP registers if necessary,
|
||||||
// but clobbers R14 (LR) because it's a call.
|
// but clobbers R14 (LR) because it's a call, and R12 which is linker trampoline scratch register.
|
||||||
{name: "LoweredWB", argLength: 3, reg: regInfo{inputs: []regMask{buildReg("R2"), buildReg("R3")}, clobbers: (callerSave &^ gpg) | buildReg("R14")}, clobberFlags: true, aux: "Sym", symEffect: "None"},
|
{name: "LoweredWB", argLength: 3, reg: regInfo{inputs: []regMask{buildReg("R2"), buildReg("R3")}, clobbers: (callerSave &^ gpg) | buildReg("R12 R14")}, clobberFlags: true, aux: "Sym", symEffect: "None"},
|
||||||
}
|
}
|
||||||
|
|
||||||
blocks := []blockData{
|
blocks := []blockData{
|
||||||
|
|
|
||||||
|
|
@ -13879,7 +13879,7 @@ var opcodeTable = [...]opInfo{
|
||||||
{0, 2}, // R1
|
{0, 2}, // R1
|
||||||
{1, 1}, // R0
|
{1, 1}, // R0
|
||||||
},
|
},
|
||||||
clobbers: 16396, // R2 R3 R14
|
clobbers: 20492, // R2 R3 R12 R14
|
||||||
outputs: []outputInfo{
|
outputs: []outputInfo{
|
||||||
{0, 1}, // R0
|
{0, 1}, // R0
|
||||||
{1, 2}, // R1
|
{1, 2}, // R1
|
||||||
|
|
@ -17228,7 +17228,7 @@ var opcodeTable = [...]opInfo{
|
||||||
{0, 2}, // R1
|
{0, 2}, // R1
|
||||||
{1, 1}, // R0
|
{1, 1}, // R0
|
||||||
},
|
},
|
||||||
clobbers: 16386, // R1 R14
|
clobbers: 20482, // R1 R12 R14
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -17242,7 +17242,7 @@ var opcodeTable = [...]opInfo{
|
||||||
{0, 4}, // R2
|
{0, 4}, // R2
|
||||||
{1, 2}, // R1
|
{1, 2}, // R1
|
||||||
},
|
},
|
||||||
clobbers: 16391, // R0 R1 R2 R14
|
clobbers: 20487, // R0 R1 R2 R12 R14
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -17403,7 +17403,7 @@ var opcodeTable = [...]opInfo{
|
||||||
{0, 4}, // R2
|
{0, 4}, // R2
|
||||||
{1, 8}, // R3
|
{1, 8}, // R3
|
||||||
},
|
},
|
||||||
clobbers: 4294918144, // R14 F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15
|
clobbers: 4294922240, // R12 R14 F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 F13 F14 F15
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,8 @@
|
||||||
|
|
||||||
package ssa
|
package ssa
|
||||||
|
|
||||||
import (
|
import "math"
|
||||||
"cmd/compile/internal/types"
|
import "cmd/compile/internal/types"
|
||||||
"math"
|
|
||||||
)
|
|
||||||
|
|
||||||
func rewriteValue386(v *Value) bool {
|
func rewriteValue386(v *Value) bool {
|
||||||
switch v.Op {
|
switch v.Op {
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,10 @@
|
||||||
|
|
||||||
package ssa
|
package ssa
|
||||||
|
|
||||||
import (
|
import "internal/buildcfg"
|
||||||
"cmd/compile/internal/types"
|
import "math"
|
||||||
"cmd/internal/obj"
|
import "cmd/internal/obj"
|
||||||
"internal/buildcfg"
|
import "cmd/compile/internal/types"
|
||||||
"math"
|
|
||||||
)
|
|
||||||
|
|
||||||
func rewriteValueAMD64(v *Value) bool {
|
func rewriteValueAMD64(v *Value) bool {
|
||||||
switch v.Op {
|
switch v.Op {
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,8 @@
|
||||||
|
|
||||||
package ssa
|
package ssa
|
||||||
|
|
||||||
import (
|
import "internal/buildcfg"
|
||||||
"cmd/compile/internal/types"
|
import "cmd/compile/internal/types"
|
||||||
"internal/buildcfg"
|
|
||||||
)
|
|
||||||
|
|
||||||
func rewriteValueARM(v *Value) bool {
|
func rewriteValueARM(v *Value) bool {
|
||||||
switch v.Op {
|
switch v.Op {
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,9 @@
|
||||||
|
|
||||||
package ssa
|
package ssa
|
||||||
|
|
||||||
import (
|
import "internal/buildcfg"
|
||||||
"cmd/compile/internal/types"
|
import "math"
|
||||||
"internal/buildcfg"
|
import "cmd/compile/internal/types"
|
||||||
"math"
|
|
||||||
)
|
|
||||||
|
|
||||||
func rewriteValuePPC64(v *Value) bool {
|
func rewriteValuePPC64(v *Value) bool {
|
||||||
switch v.Op {
|
switch v.Op {
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,8 @@
|
||||||
|
|
||||||
package ssa
|
package ssa
|
||||||
|
|
||||||
import (
|
import "math"
|
||||||
"cmd/compile/internal/types"
|
import "cmd/compile/internal/types"
|
||||||
"math"
|
|
||||||
)
|
|
||||||
|
|
||||||
func rewriteValueRISCV64(v *Value) bool {
|
func rewriteValueRISCV64(v *Value) bool {
|
||||||
switch v.Op {
|
switch v.Op {
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,9 @@
|
||||||
|
|
||||||
package ssa
|
package ssa
|
||||||
|
|
||||||
import (
|
import "math"
|
||||||
"cmd/compile/internal/types"
|
import "cmd/compile/internal/types"
|
||||||
"cmd/internal/obj/s390x"
|
import "cmd/internal/obj/s390x"
|
||||||
"math"
|
|
||||||
)
|
|
||||||
|
|
||||||
func rewriteValueS390X(v *Value) bool {
|
func rewriteValueS390X(v *Value) bool {
|
||||||
switch v.Op {
|
switch v.Op {
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,9 @@
|
||||||
|
|
||||||
package ssa
|
package ssa
|
||||||
|
|
||||||
import (
|
import "internal/buildcfg"
|
||||||
"cmd/compile/internal/types"
|
import "math"
|
||||||
"internal/buildcfg"
|
import "cmd/compile/internal/types"
|
||||||
"math"
|
|
||||||
)
|
|
||||||
|
|
||||||
func rewriteValueWasm(v *Value) bool {
|
func rewriteValueWasm(v *Value) bool {
|
||||||
switch v.Op {
|
switch v.Op {
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,8 @@
|
||||||
|
|
||||||
package ssa
|
package ssa
|
||||||
|
|
||||||
import (
|
import "math"
|
||||||
"cmd/compile/internal/types"
|
import "cmd/compile/internal/types"
|
||||||
"math"
|
|
||||||
)
|
|
||||||
|
|
||||||
func rewriteValuegeneric(v *Value) bool {
|
func rewriteValuegeneric(v *Value) bool {
|
||||||
switch v.Op {
|
switch v.Op {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue