1
0
mirror of https://github.com/golang/go synced 2024-10-05 16:31:21 -06:00

[dev.ssa] cmd/compile: move un-SSAable objects

We need to move any objects whose types are not SSA-able.

Fixes the "not lowered: Load ARRAY PTR64 mem" errors.

Change-Id: I7a0b609f917d7fb34bc9215fee4da15f9961cf6c
Reviewed-on: https://go-review.googlesource.com/14753
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Keith Randall 2015-09-18 22:58:10 -07:00
parent d3886906b1
commit 37590bddc4
5 changed files with 39 additions and 26 deletions

View File

@ -4242,6 +4242,10 @@ func (e *ssaExport) Auto(t ssa.Type) fmt.Stringer {
return n
}
func (e ssaExport) CanSSA(t ssa.Type) bool {
return canSSAType(t.(*Type))
}
// Log logs a message from the compiler.
func (e *ssaExport) Logf(msg string, args ...interface{}) {
// If e was marked as unimplemented, anything could happen. Ignore.

View File

@ -34,6 +34,8 @@ type TypeSource interface {
TypeUintptr() Type
TypeString() Type
TypeBytePtr() Type // TODO: use unsafe.Pointer instead?
CanSSA(t Type) bool
}
type Logger interface {

View File

@ -50,3 +50,8 @@ func (d DummyFrontend) TypeInt() Type { return TypeInt64 }
func (d DummyFrontend) TypeUintptr() Type { return TypeUInt64 }
func (d DummyFrontend) TypeString() Type { panic("unimplemented") }
func (d DummyFrontend) TypeBytePtr() Type { return TypeBytePtr }
func (d DummyFrontend) CanSSA(t Type) bool {
// There are no un-SSAable types in dummy land.
return true
}

View File

@ -176,9 +176,9 @@
data
(Store [config.PtrSize] dst itab mem))
// big-object moves (TODO: remove?)
(Store [size] dst (Load src mem) mem) && size > config.IntSize -> (Move [size] dst src mem)
(Store [size] dst (Load src mem) (VarDef {x} mem)) && size > config.IntSize -> (Move [size] dst src (VarDef {x} mem))
// un-SSAable values use mem->mem copies
(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)

View File

@ -430,7 +430,7 @@ func rewriteValuegeneric(v *Value, config *Config) bool {
case OpEqInter:
// match: (EqInter x y)
// cond:
// result: (EqPtr (ITab x) (ITab y))
// result: (EqPtr (ITab x) (ITab y))
{
x := v.Args[0]
y := v.Args[1]
@ -448,8 +448,8 @@ func rewriteValuegeneric(v *Value, config *Config) bool {
v.AddArg(v1)
return true
}
goto endfcedc545b9bbbe3790786c8981b12d32
endfcedc545b9bbbe3790786c8981b12d32:
goto end1cc40483caab33ece971ab7e6c8fdfca
end1cc40483caab33ece971ab7e6c8fdfca:
;
case OpEqPtr:
// match: (EqPtr p (ConstNil))
@ -497,7 +497,7 @@ func rewriteValuegeneric(v *Value, config *Config) bool {
case OpEqSlice:
// match: (EqSlice x y)
// cond:
// result: (EqPtr (SlicePtr x) (SlicePtr y))
// result: (EqPtr (SlicePtr x) (SlicePtr y))
{
x := v.Args[0]
y := v.Args[1]
@ -515,8 +515,8 @@ func rewriteValuegeneric(v *Value, config *Config) bool {
v.AddArg(v1)
return true
}
goto end2937092dca53f896cd527e59e92cab1d
end2937092dca53f896cd527e59e92cab1d:
goto end9cd53ca57ee90aa09c54f8071c8e8769
end9cd53ca57ee90aa09c54f8071c8e8769:
;
case OpIData:
// match: (IData (IMake _ data))
@ -1398,22 +1398,23 @@ func rewriteValuegeneric(v *Value, config *Config) bool {
goto endaa801a871178ae3256b3f6f5d9f13514
endaa801a871178ae3256b3f6f5d9f13514:
;
// match: (Store [size] dst (Load src mem) mem)
// cond: size > config.IntSize
// match: (Store [size] dst (Load <t> src mem) mem)
// cond: !config.fe.CanSSA(t)
// result: (Move [size] dst src mem)
{
size := v.AuxInt
dst := v.Args[0]
if v.Args[1].Op != OpLoad {
goto enda18a7163888e2f4fca9f38bae56cef42
goto end45295326269ba18413dceb7b608a0b9d
}
t := v.Args[1].Type
src := v.Args[1].Args[0]
mem := v.Args[1].Args[1]
if v.Args[2] != mem {
goto enda18a7163888e2f4fca9f38bae56cef42
goto end45295326269ba18413dceb7b608a0b9d
}
if !(size > config.IntSize) {
goto enda18a7163888e2f4fca9f38bae56cef42
if !(!config.fe.CanSSA(t)) {
goto end45295326269ba18413dceb7b608a0b9d
}
v.Op = OpMove
v.AuxInt = 0
@ -1425,29 +1426,30 @@ func rewriteValuegeneric(v *Value, config *Config) bool {
v.AddArg(mem)
return true
}
goto enda18a7163888e2f4fca9f38bae56cef42
enda18a7163888e2f4fca9f38bae56cef42:
goto end45295326269ba18413dceb7b608a0b9d
end45295326269ba18413dceb7b608a0b9d:
;
// match: (Store [size] dst (Load src mem) (VarDef {x} mem))
// cond: size > config.IntSize
// match: (Store [size] dst (Load <t> src mem) (VarDef {x} mem))
// cond: !config.fe.CanSSA(t)
// result: (Move [size] dst src (VarDef {x} mem))
{
size := v.AuxInt
dst := v.Args[0]
if v.Args[1].Op != OpLoad {
goto endc671c9b1be99e3125fe81e29018bc0e6
goto end7f3cc0baffb82ba3ee879599b189a512
}
t := v.Args[1].Type
src := v.Args[1].Args[0]
mem := v.Args[1].Args[1]
if v.Args[2].Op != OpVarDef {
goto endc671c9b1be99e3125fe81e29018bc0e6
goto end7f3cc0baffb82ba3ee879599b189a512
}
x := v.Args[2].Aux
if v.Args[2].Args[0] != mem {
goto endc671c9b1be99e3125fe81e29018bc0e6
goto end7f3cc0baffb82ba3ee879599b189a512
}
if !(size > config.IntSize) {
goto endc671c9b1be99e3125fe81e29018bc0e6
if !(!config.fe.CanSSA(t)) {
goto end7f3cc0baffb82ba3ee879599b189a512
}
v.Op = OpMove
v.AuxInt = 0
@ -1463,8 +1465,8 @@ func rewriteValuegeneric(v *Value, config *Config) bool {
v.AddArg(v0)
return true
}
goto endc671c9b1be99e3125fe81e29018bc0e6
endc671c9b1be99e3125fe81e29018bc0e6:
goto end7f3cc0baffb82ba3ee879599b189a512
end7f3cc0baffb82ba3ee879599b189a512:
;
case OpStringLen:
// match: (StringLen (StringMake _ len))