mirror of
https://github.com/golang/go
synced 2024-10-05 18:31:28 -06:00
[dev.ssa] cmd/compile/internal/ssa: put new values for block rewrites in rewritten block
Don't put them in the control value's block. That may be many blocks up the dominator tree. Change-Id: Iab3ea36a890ffe0e355dadec7aeb676901c4f070 Reviewed-on: https://go-review.googlesource.com/13134 Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
This commit is contained in:
parent
b8efee0d8a
commit
683f5d7bdb
@ -104,6 +104,7 @@ func genRules(arch arch) {
|
||||
fmt.Fprintln(w, "// generated with: cd gen; go run *.go")
|
||||
fmt.Fprintln(w, "package ssa")
|
||||
fmt.Fprintf(w, "func rewriteValue%s(v *Value, config *Config) bool {\n", arch.name)
|
||||
fmt.Fprintln(w, "b := v.Block")
|
||||
|
||||
// generate code for each rule
|
||||
fmt.Fprintf(w, "switch v.Op {\n")
|
||||
@ -238,7 +239,7 @@ func genRules(arch arch) {
|
||||
|
||||
// Modify predecessor lists for no-longer-reachable blocks
|
||||
for succ := range m {
|
||||
fmt.Fprintf(w, "v.Block.Func.removePredecessor(b, %s)\n", succ)
|
||||
fmt.Fprintf(w, "b.Func.removePredecessor(b, %s)\n", succ)
|
||||
}
|
||||
|
||||
fmt.Fprintf(w, "b.Kind = %s\n", blockName(t[0], arch))
|
||||
@ -397,7 +398,7 @@ func genResult0(w io.Writer, arch arch, result string, alloc *int, top bool) str
|
||||
} else {
|
||||
v = fmt.Sprintf("v%d", *alloc)
|
||||
*alloc++
|
||||
fmt.Fprintf(w, "%s := v.Block.NewValue0(v.Line, %s, TypeInvalid)\n", v, opName(s[0], arch))
|
||||
fmt.Fprintf(w, "%s := b.NewValue0(v.Line, %s, TypeInvalid)\n", v, opName(s[0], arch))
|
||||
}
|
||||
for _, a := range s[1:] {
|
||||
if a[0] == '<' {
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -3,6 +3,7 @@
|
||||
package ssa
|
||||
|
||||
func rewriteValuegeneric(v *Value, config *Config) bool {
|
||||
b := v.Block
|
||||
switch v.Op {
|
||||
case OpAdd64:
|
||||
// match: (Add64 (Const64 [c]) (Const64 [d]))
|
||||
@ -65,7 +66,7 @@ func rewriteValuegeneric(v *Value, config *Config) bool {
|
||||
v.AuxInt = 0
|
||||
v.Aux = nil
|
||||
v.resetArgs()
|
||||
v0 := v.Block.NewValue0(v.Line, OpPtrIndex, TypeInvalid)
|
||||
v0 := b.NewValue0(v.Line, OpPtrIndex, TypeInvalid)
|
||||
v0.Type = v.Type.PtrTo()
|
||||
v0.AddArg(ptr)
|
||||
v0.AddArg(idx)
|
||||
@ -162,14 +163,14 @@ func rewriteValuegeneric(v *Value, config *Config) bool {
|
||||
v.AuxInt = 0
|
||||
v.Aux = nil
|
||||
v.resetArgs()
|
||||
v0 := v.Block.NewValue0(v.Line, OpAddr, TypeInvalid)
|
||||
v0 := b.NewValue0(v.Line, OpAddr, TypeInvalid)
|
||||
v0.Type = config.Frontend().TypeBytePtr()
|
||||
v0.Aux = config.fe.StringData(s.(string))
|
||||
v1 := v.Block.NewValue0(v.Line, OpSB, TypeInvalid)
|
||||
v1 := b.NewValue0(v.Line, OpSB, TypeInvalid)
|
||||
v1.Type = config.Frontend().TypeUintptr()
|
||||
v0.AddArg(v1)
|
||||
v.AddArg(v0)
|
||||
v2 := v.Block.NewValue0(v.Line, OpConstPtr, TypeInvalid)
|
||||
v2 := b.NewValue0(v.Line, OpConstPtr, TypeInvalid)
|
||||
v2.Type = config.Frontend().TypeUintptr()
|
||||
v2.AuxInt = int64(len(s.(string)))
|
||||
v.AddArg(v2)
|
||||
@ -291,12 +292,12 @@ func rewriteValuegeneric(v *Value, config *Config) bool {
|
||||
v.AuxInt = 0
|
||||
v.Aux = nil
|
||||
v.resetArgs()
|
||||
v0 := v.Block.NewValue0(v.Line, OpLoad, TypeInvalid)
|
||||
v0 := b.NewValue0(v.Line, OpLoad, TypeInvalid)
|
||||
v0.Type = config.Frontend().TypeUintptr()
|
||||
v0.AddArg(ptr)
|
||||
v0.AddArg(mem)
|
||||
v.AddArg(v0)
|
||||
v1 := v.Block.NewValue0(v.Line, OpConstPtr, TypeInvalid)
|
||||
v1 := b.NewValue0(v.Line, OpConstPtr, TypeInvalid)
|
||||
v1.Type = config.Frontend().TypeUintptr()
|
||||
v1.AuxInt = 0
|
||||
v.AddArg(v1)
|
||||
@ -343,14 +344,14 @@ func rewriteValuegeneric(v *Value, config *Config) bool {
|
||||
v.AuxInt = 0
|
||||
v.Aux = nil
|
||||
v.resetArgs()
|
||||
v0 := v.Block.NewValue0(v.Line, OpLoad, TypeInvalid)
|
||||
v0 := b.NewValue0(v.Line, OpLoad, TypeInvalid)
|
||||
v0.Type = config.Frontend().TypeBytePtr()
|
||||
v0.AddArg(ptr)
|
||||
v0.AddArg(mem)
|
||||
v.AddArg(v0)
|
||||
v1 := v.Block.NewValue0(v.Line, OpLoad, TypeInvalid)
|
||||
v1 := b.NewValue0(v.Line, OpLoad, TypeInvalid)
|
||||
v1.Type = config.Frontend().TypeUintptr()
|
||||
v2 := v.Block.NewValue0(v.Line, OpOffPtr, TypeInvalid)
|
||||
v2 := b.NewValue0(v.Line, OpOffPtr, TypeInvalid)
|
||||
v2.Type = config.Frontend().TypeBytePtr()
|
||||
v2.AuxInt = config.PtrSize
|
||||
v2.AddArg(ptr)
|
||||
@ -521,12 +522,12 @@ func rewriteValuegeneric(v *Value, config *Config) bool {
|
||||
v.AuxInt = 0
|
||||
v.Aux = nil
|
||||
v.resetArgs()
|
||||
v0 := v.Block.NewValue0(v.Line, OpLoad, TypeInvalid)
|
||||
v0 := b.NewValue0(v.Line, OpLoad, TypeInvalid)
|
||||
v0.Type = config.Frontend().TypeUintptr()
|
||||
v0.AddArg(ptr)
|
||||
v0.AddArg(mem)
|
||||
v.AddArg(v0)
|
||||
v1 := v.Block.NewValue0(v.Line, OpConstPtr, TypeInvalid)
|
||||
v1 := b.NewValue0(v.Line, OpConstPtr, TypeInvalid)
|
||||
v1.Type = config.Frontend().TypeUintptr()
|
||||
v1.AuxInt = 0
|
||||
v.AddArg(v1)
|
||||
@ -548,10 +549,10 @@ func rewriteValuegeneric(v *Value, config *Config) bool {
|
||||
v.Aux = nil
|
||||
v.resetArgs()
|
||||
v.AddArg(ptr)
|
||||
v0 := v.Block.NewValue0(v.Line, OpMulPtr, TypeInvalid)
|
||||
v0 := b.NewValue0(v.Line, OpMulPtr, TypeInvalid)
|
||||
v0.Type = config.Frontend().TypeUintptr()
|
||||
v0.AddArg(idx)
|
||||
v1 := v.Block.NewValue0(v.Line, OpConstPtr, TypeInvalid)
|
||||
v1 := b.NewValue0(v.Line, OpConstPtr, TypeInvalid)
|
||||
v1.Type = config.Frontend().TypeUintptr()
|
||||
v1.AuxInt = t.Elem().Size()
|
||||
v0.AddArg(v1)
|
||||
@ -575,10 +576,10 @@ func rewriteValuegeneric(v *Value, config *Config) bool {
|
||||
v.AuxInt = 0
|
||||
v.Aux = nil
|
||||
v.resetArgs()
|
||||
v0 := v.Block.NewValue0(v.Line, OpAddPtr, TypeInvalid)
|
||||
v0 := b.NewValue0(v.Line, OpAddPtr, TypeInvalid)
|
||||
v0.Type = ptr.Type
|
||||
v0.AddArg(ptr)
|
||||
v1 := v.Block.NewValue0(v.Line, OpConstPtr, TypeInvalid)
|
||||
v1 := b.NewValue0(v.Line, OpConstPtr, TypeInvalid)
|
||||
v1.Type = config.Frontend().TypeUintptr()
|
||||
v1.AuxInt = config.PtrSize * 2
|
||||
v0.AddArg(v1)
|
||||
@ -603,10 +604,10 @@ func rewriteValuegeneric(v *Value, config *Config) bool {
|
||||
v.AuxInt = 0
|
||||
v.Aux = nil
|
||||
v.resetArgs()
|
||||
v0 := v.Block.NewValue0(v.Line, OpAddPtr, TypeInvalid)
|
||||
v0 := b.NewValue0(v.Line, OpAddPtr, TypeInvalid)
|
||||
v0.Type = ptr.Type
|
||||
v0.AddArg(ptr)
|
||||
v1 := v.Block.NewValue0(v.Line, OpConstPtr, TypeInvalid)
|
||||
v1 := b.NewValue0(v.Line, OpConstPtr, TypeInvalid)
|
||||
v1.Type = config.Frontend().TypeUintptr()
|
||||
v1.AuxInt = config.PtrSize
|
||||
v0.AddArg(v1)
|
||||
@ -683,19 +684,19 @@ func rewriteValuegeneric(v *Value, config *Config) bool {
|
||||
v.AuxInt = 0
|
||||
v.Aux = nil
|
||||
v.resetArgs()
|
||||
v0 := v.Block.NewValue0(v.Line, OpOffPtr, TypeInvalid)
|
||||
v0 := b.NewValue0(v.Line, OpOffPtr, TypeInvalid)
|
||||
v0.Type = config.Frontend().TypeBytePtr()
|
||||
v0.AuxInt = config.PtrSize
|
||||
v0.AddArg(dst)
|
||||
v.AddArg(v0)
|
||||
v1 := v.Block.NewValue0(v.Line, OpStringLen, TypeInvalid)
|
||||
v1 := b.NewValue0(v.Line, OpStringLen, TypeInvalid)
|
||||
v1.Type = config.Frontend().TypeUintptr()
|
||||
v1.AddArg(str)
|
||||
v.AddArg(v1)
|
||||
v2 := v.Block.NewValue0(v.Line, OpStore, TypeInvalid)
|
||||
v2 := b.NewValue0(v.Line, OpStore, TypeInvalid)
|
||||
v2.Type = TypeMem
|
||||
v2.AddArg(dst)
|
||||
v3 := v.Block.NewValue0(v.Line, OpStringPtr, TypeInvalid)
|
||||
v3 := b.NewValue0(v.Line, OpStringPtr, TypeInvalid)
|
||||
v3.Type = config.Frontend().TypeBytePtr()
|
||||
v3.AddArg(str)
|
||||
v2.AddArg(v3)
|
||||
@ -759,7 +760,7 @@ func rewriteValuegeneric(v *Value, config *Config) bool {
|
||||
v.AuxInt = 0
|
||||
v.Aux = nil
|
||||
v.resetArgs()
|
||||
v0 := v.Block.NewValue0(v.Line, OpOffPtr, TypeInvalid)
|
||||
v0 := b.NewValue0(v.Line, OpOffPtr, TypeInvalid)
|
||||
v0.Type = v.Type.PtrTo()
|
||||
v0.AuxInt = idx
|
||||
v0.AddArg(ptr)
|
||||
@ -809,7 +810,7 @@ func rewriteBlockgeneric(b *Block) bool {
|
||||
if !(c.(bool)) {
|
||||
goto end9ff0273f9b1657f4afc287562ca889f0
|
||||
}
|
||||
v.Block.Func.removePredecessor(b, no)
|
||||
b.Func.removePredecessor(b, no)
|
||||
b.Kind = BlockPlain
|
||||
b.Control = nil
|
||||
b.Succs = b.Succs[:1]
|
||||
@ -833,7 +834,7 @@ func rewriteBlockgeneric(b *Block) bool {
|
||||
if !(!c.(bool)) {
|
||||
goto endf401a4553c3c7c6bed64801da7bba076
|
||||
}
|
||||
v.Block.Func.removePredecessor(b, yes)
|
||||
b.Func.removePredecessor(b, yes)
|
||||
b.Kind = BlockPlain
|
||||
b.Control = nil
|
||||
b.Succs = b.Succs[:1]
|
||||
|
Loading…
Reference in New Issue
Block a user