]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: document Move's type
authorJosh Bleecher Snyder <josharian@gmail.com>
Tue, 25 Feb 2020 00:16:27 +0000 (16:16 -0800)
committerJosh Bleecher Snyder <josharian@gmail.com>
Thu, 27 Feb 2020 20:32:29 +0000 (20:32 +0000)
Fixes #37381

Change-Id: I8abf07d6342c10fc8d52e11c6a70fb0ec09220d2
Reviewed-on: https://go-review.googlesource.com/c/go/+/220683
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/cmd/compile/internal/ssa/gen/generic.rules
src/cmd/compile/internal/ssa/gen/genericOps.go

index ac746b42bfa090544652d00ab28a6d7e6dc7882d..f4d487176b6cebad142bd5b12434f74896bba037 100644 (file)
 (IsNonNil (LocalAddr _ _)) -> (ConstBool [1])
 
 // Inline small or disjoint runtime.memmove calls with constant length.
+// See the comment in op Move in genericOps.go for discussion of the type.
 (StaticCall {sym} s1:(Store _ (Const(64|32) [sz]) s2:(Store  _ src s3:(Store {t} _ dst mem))))
        && sz >= 0
        && isSameSym(sym,"runtime.memmove")
index a82f147288f2c2f7c52c5c7335e1498d2b99e783..9f172996109ce67a8bbd7b7da5bc9f97a33e0acf 100644 (file)
@@ -351,6 +351,13 @@ var genericOps = []opData{
        // The source and destination of Move may overlap in some cases. See e.g.
        // memmove inlining in generic.rules. When inlineablememmovesize (in ../rewrite.go)
        // returns true, we must do all loads before all stores, when lowering Move.
+       // The type of Move is used for the write barrier pass to insert write barriers
+       // and for alignment on some architectures.
+       // For pointerless types, it is possible for the type to be inaccurate.
+       // For type alignment and pointer information, use the type in Aux;
+       // for type size, use the size in AuxInt.
+       // The "inline runtime.memmove" rewrite rule generates Moves with inaccurate types,
+       // such as type byte instead of the more accurate type [8]byte.
        {name: "Move", argLength: 3, typ: "Mem", aux: "TypSize"}, // arg0=destptr, arg1=srcptr, arg2=mem, auxint=size, aux=type.  Returns memory.
        {name: "Zero", argLength: 2, typ: "Mem", aux: "TypSize"}, // arg0=destptr, arg1=mem, auxint=size, aux=type. Returns memory.