]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.ssa] cmd/compile: fix string store rewrite
authorKeith Randall <khr@golang.org>
Tue, 18 Aug 2015 17:28:58 +0000 (10:28 -0700)
committerKeith Randall <khr@golang.org>
Tue, 18 Aug 2015 17:41:44 +0000 (17:41 +0000)
Store ops now need their size in the auxint field.  I missed this one.

Change-Id: I050fd6b5b00579883731702c426edafa3a5f7561
Reviewed-on: https://go-review.googlesource.com/13682
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
src/cmd/compile/internal/ssa/gen/generic.rules
src/cmd/compile/internal/ssa/gen/rulegen.go
src/cmd/compile/internal/ssa/rewritegeneric.go

index 75cd186a43f6bd4006fbf6ccf67f0c1184a0f87e..db66a457c33b643ce12eb37f218a0e41dc13912f 100644 (file)
@@ -88,7 +88,7 @@
 (Load <t> ptr mem) && t.IsString() -> (StringMake (Load <config.Frontend().TypeBytePtr()> ptr mem) (Load <config.Frontend().TypeUintptr()> (OffPtr <config.Frontend().TypeBytePtr()> [config.PtrSize] ptr) mem))
 (StringPtr (StringMake ptr _)) -> ptr
 (StringLen (StringMake _ len)) -> len
-(Store dst str mem) && str.Type.IsString() -> (Store (OffPtr <config.Frontend().TypeBytePtr()> [config.PtrSize] dst) (StringLen <config.Frontend().TypeUintptr()> str) (Store <TypeMem> dst (StringPtr <config.Frontend().TypeBytePtr()> str) mem))
+(Store [2*config.PtrSize] dst str mem) && str.Type.IsString() -> (Store [config.PtrSize] (OffPtr <config.Frontend().TypeBytePtr()> [config.PtrSize] dst) (StringLen <config.Frontend().TypeUintptr()> str) (Store [config.PtrSize] <TypeMem> dst (StringPtr <config.Frontend().TypeBytePtr()> str) mem))
 
 (If (IsNonNil (GetG)) yes no) -> (Plain nil yes)
 
index 57305413f97aa2b6db93389f3f629c24d739d730..057e68601b41a82495676a142b35d82bfd28c75d 100644 (file)
@@ -560,7 +560,7 @@ func unbalanced(s string) bool {
 
 // isVariable reports whether s is a single Go alphanumeric identifier.
 func isVariable(s string) bool {
-       b, err := regexp.MatchString("[A-Za-z_][A-Za-z_0-9]*", s)
+       b, err := regexp.MatchString("^[A-Za-z_][A-Za-z_0-9]*$", s)
        if err != nil {
                panic("bad variable regexp")
        }
index a0c5269e2e332cf1a2fc1f6135431571d9a6a04c..4c278cb1682d7e2f2bdfb4829b9adffd57fed786 100644 (file)
@@ -906,20 +906,24 @@ func rewriteValuegeneric(v *Value, config *Config) bool {
                goto enda18a7163888e2f4fca9f38bae56cef42
        enda18a7163888e2f4fca9f38bae56cef42:
                ;
-               // match: (Store dst str mem)
+               // match: (Store [2*config.PtrSize] dst str mem)
                // cond: str.Type.IsString()
-               // result: (Store (OffPtr <config.Frontend().TypeBytePtr()> [config.PtrSize] dst) (StringLen <config.Frontend().TypeUintptr()> str) (Store <TypeMem> dst (StringPtr <config.Frontend().TypeBytePtr()> str) mem))
+               // result: (Store [config.PtrSize] (OffPtr <config.Frontend().TypeBytePtr()> [config.PtrSize] dst) (StringLen <config.Frontend().TypeUintptr()> str) (Store [config.PtrSize] <TypeMem> dst (StringPtr <config.Frontend().TypeBytePtr()> str) mem))
                {
+                       if v.AuxInt != 2*config.PtrSize {
+                               goto end6942df62f9cb570a99ab97a5aeebfd2d
+                       }
                        dst := v.Args[0]
                        str := v.Args[1]
                        mem := v.Args[2]
                        if !(str.Type.IsString()) {
-                               goto enddf0c5a150f4b4bf6715fd2bd4bb4cc20
+                               goto end6942df62f9cb570a99ab97a5aeebfd2d
                        }
                        v.Op = OpStore
                        v.AuxInt = 0
                        v.Aux = nil
                        v.resetArgs()
+                       v.AuxInt = config.PtrSize
                        v0 := b.NewValue0(v.Line, OpOffPtr, TypeInvalid)
                        v0.Type = config.Frontend().TypeBytePtr()
                        v0.AuxInt = config.PtrSize
@@ -930,6 +934,7 @@ func rewriteValuegeneric(v *Value, config *Config) bool {
                        v1.AddArg(str)
                        v.AddArg(v1)
                        v2 := b.NewValue0(v.Line, OpStore, TypeInvalid)
+                       v2.AuxInt = config.PtrSize
                        v2.Type = TypeMem
                        v2.AddArg(dst)
                        v3 := b.NewValue0(v.Line, OpStringPtr, TypeInvalid)
@@ -940,8 +945,8 @@ func rewriteValuegeneric(v *Value, config *Config) bool {
                        v.AddArg(v2)
                        return true
                }
-               goto enddf0c5a150f4b4bf6715fd2bd4bb4cc20
-       enddf0c5a150f4b4bf6715fd2bd4bb4cc20:
+               goto end6942df62f9cb570a99ab97a5aeebfd2d
+       end6942df62f9cb570a99ab97a5aeebfd2d:
                ;
        case OpStringLen:
                // match: (StringLen (StringMake _ len))