]> Cypherpunks repositories - gostls13.git/commit
[dev.ssa] cmd/compile/internal/ssa: Use explicit size for store ops
authorKeith Randall <khr@golang.org>
Sat, 15 Aug 2015 04:47:20 +0000 (21:47 -0700)
committerKeith Randall <khr@golang.org>
Sat, 15 Aug 2015 23:18:21 +0000 (23:18 +0000)
commitd4cc51d4118027464f61034179908abd0005fab6
treea3ed9b868e304cb4d533d609b9bae791f7c2239b
parent198fc9a9eb7104d459bb5fea0aba5f2ff2c6f8d4
[dev.ssa] cmd/compile/internal/ssa: Use explicit size for store ops

Using the type of the store argument is not safe, it may change
during rewriting, giving us the wrong store width.

(Store ptr (Trunc32to16 val) mem)

This should be a 2-byte store.  But we have the rule:

(Trunc32to16 x) -> x

So if the Trunc rewrite happens before the Store -> MOVW rewrite,
then the Store thinks that the value it is storing is 4 bytes
in size and uses a MOVL.  Bad things ensue.

Fix this by encoding the store width explicitly in the auxint field.

In general, we can't rely on the type of arguments, as they may
change during rewrites.  The type of the op itself (as used by
the Load rules) is still ok to use.

Change-Id: I9e2359e4f657bb0ea0e40038969628bf0f84e584
Reviewed-on: https://go-review.googlesource.com/13636
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
src/cmd/compile/internal/gc/ssa.go
src/cmd/compile/internal/gc/testdata/loadstore_ssa.go
src/cmd/compile/internal/ssa/deadstore_test.go
src/cmd/compile/internal/ssa/func.go
src/cmd/compile/internal/ssa/gen/AMD64.rules
src/cmd/compile/internal/ssa/gen/generic.rules
src/cmd/compile/internal/ssa/gen/genericOps.go
src/cmd/compile/internal/ssa/rewriteAMD64.go
src/cmd/compile/internal/ssa/rewritegeneric.go
src/cmd/compile/internal/ssa/schedule_test.go
src/cmd/compile/internal/ssa/shift_test.go