mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.ssa] cmd/compile: getg needs a memory arg
getg reads from memory, so it should really have a memory arg. It is critical in functions which call setg to make sure getg gets ordered correctly with setg. Change-Id: Ief4875421f741fc49c07b0e1f065ce2535232341 Reviewed-on: https://go-review.googlesource.com/16100 Run-TryBot: Keith Randall <khr@golang.org> Reviewed-by: David Chase <drchase@google.com> Run-TryBot: David Chase <drchase@google.com>
This commit is contained in:
parent
65df9c4c2b
commit
d694f83c21
8 changed files with 16 additions and 19 deletions
|
|
@ -1870,7 +1870,7 @@ func (s *state) expr(n *Node) *ssa.Value {
|
|||
return s.call(n, callNormal)
|
||||
|
||||
case OGETG:
|
||||
return s.newValue0(ssa.OpGetG, n.Type)
|
||||
return s.newValue1(ssa.OpGetG, n.Type, s.mem())
|
||||
|
||||
case OAPPEND:
|
||||
// append(s, e1, e2, e3). Compile like:
|
||||
|
|
|
|||
|
|
@ -287,7 +287,7 @@
|
|||
(IsSliceInBounds idx len) -> (SETBE (CMPQ idx len))
|
||||
|
||||
(PanicNilCheck ptr mem) -> (LoweredPanicNilCheck ptr mem)
|
||||
(GetG) -> (LoweredGetG)
|
||||
(GetG mem) -> (LoweredGetG mem)
|
||||
(GetClosurePtr) -> (LoweredGetClosurePtr)
|
||||
|
||||
(Move [size] dst src mem) -> (REPMOVSB dst src (MOVQconst <config.Frontend().TypeUInt64()> [size]) mem)
|
||||
|
|
|
|||
|
|
@ -423,7 +423,7 @@ func init() {
|
|||
|
||||
// Pseudo-ops
|
||||
{name: "LoweredPanicNilCheck", reg: gp10},
|
||||
{name: "LoweredGetG", reg: gp01},
|
||||
{name: "LoweredGetG", reg: gp01}, // arg0=mem
|
||||
// Scheduler ensures LoweredGetClosurePtr occurs only in entry block,
|
||||
// and sorts it to the very beginning of the block to prevent other
|
||||
// use of DX (the closure pointer)
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@
|
|||
(Store [size] dst (Load <t> src mem) mem) && !config.fe.CanSSA(t) -> (Move [size] dst src mem)
|
||||
(Store [size] dst (Load <t> src mem) (VarDef {x} mem)) && !config.fe.CanSSA(t) -> (Move [size] dst src (VarDef {x} mem))
|
||||
|
||||
(If (IsNonNil (GetG)) yes no) -> (First nil yes no)
|
||||
(If (IsNonNil (GetG _)) yes no) -> (First nil yes no)
|
||||
|
||||
(If (Not cond) yes no) -> (If cond no yes)
|
||||
(If (ConstBool [c]) yes no) && c == 1 -> (First nil yes no)
|
||||
|
|
|
|||
|
|
@ -326,7 +326,7 @@ var genericOps = []opData{
|
|||
|
||||
// Pseudo-ops
|
||||
{name: "PanicNilCheck"}, // trigger a dereference fault; arg0=nil ptr, arg1=mem, returns mem
|
||||
{name: "GetG"}, // runtime.getg() (read g pointer)
|
||||
{name: "GetG"}, // runtime.getg() (read g pointer). arg0=mem
|
||||
{name: "GetClosurePtr"}, // get closure pointer from dedicated register
|
||||
|
||||
// Indexing operations
|
||||
|
|
|
|||
|
|
@ -982,11 +982,6 @@ func (v *Value) rematerializeable() bool {
|
|||
// which can't be moved.
|
||||
return false
|
||||
}
|
||||
if v.Op == OpAMD64LoweredGetG {
|
||||
// It would almost always be ok to rematerialize this op.
|
||||
// The annoying exception is functions that call runtime.setg.
|
||||
return false
|
||||
}
|
||||
if len(v.Args) == 0 {
|
||||
return true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2412,18 +2412,20 @@ func rewriteValueAMD64(v *Value, config *Config) bool {
|
|||
end6fd0b53f0acb4d35e7d7fa78d2ca1392:
|
||||
;
|
||||
case OpGetG:
|
||||
// match: (GetG)
|
||||
// match: (GetG mem)
|
||||
// cond:
|
||||
// result: (LoweredGetG)
|
||||
// result: (LoweredGetG mem)
|
||||
{
|
||||
mem := v.Args[0]
|
||||
v.Op = OpAMD64LoweredGetG
|
||||
v.AuxInt = 0
|
||||
v.Aux = nil
|
||||
v.resetArgs()
|
||||
v.AddArg(mem)
|
||||
return true
|
||||
}
|
||||
goto endb17140e71dd641aa4d89e14479160260
|
||||
endb17140e71dd641aa4d89e14479160260:
|
||||
goto endf543eaaf68c4bef1d4cdc8ba19683723
|
||||
endf543eaaf68c4bef1d4cdc8ba19683723:
|
||||
;
|
||||
case OpGoCall:
|
||||
// match: (GoCall [argwid] mem)
|
||||
|
|
|
|||
|
|
@ -1697,16 +1697,16 @@ func rewriteValuegeneric(v *Value, config *Config) bool {
|
|||
func rewriteBlockgeneric(b *Block) bool {
|
||||
switch b.Kind {
|
||||
case BlockIf:
|
||||
// match: (If (IsNonNil (GetG)) yes no)
|
||||
// match: (If (IsNonNil (GetG _)) yes no)
|
||||
// cond:
|
||||
// result: (First nil yes no)
|
||||
{
|
||||
v := b.Control
|
||||
if v.Op != OpIsNonNil {
|
||||
goto endafdc4e2525f9933ab0ae7effc3559597
|
||||
goto end41b95d88b4cebdb0ce392bd3c1c89e95
|
||||
}
|
||||
if v.Args[0].Op != OpGetG {
|
||||
goto endafdc4e2525f9933ab0ae7effc3559597
|
||||
goto end41b95d88b4cebdb0ce392bd3c1c89e95
|
||||
}
|
||||
yes := b.Succs[0]
|
||||
no := b.Succs[1]
|
||||
|
|
@ -1716,8 +1716,8 @@ func rewriteBlockgeneric(b *Block) bool {
|
|||
b.Succs[1] = no
|
||||
return true
|
||||
}
|
||||
goto endafdc4e2525f9933ab0ae7effc3559597
|
||||
endafdc4e2525f9933ab0ae7effc3559597:
|
||||
goto end41b95d88b4cebdb0ce392bd3c1c89e95
|
||||
end41b95d88b4cebdb0ce392bd3c1c89e95:
|
||||
;
|
||||
// match: (If (Not cond) yes no)
|
||||
// cond:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue