mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[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>
This commit is contained in:
parent
198fc9a9eb
commit
d4cc51d411
11 changed files with 114 additions and 82 deletions
|
|
@ -35,7 +35,7 @@ func makeConstShiftFunc(c *Config, amount int64, op Op, typ Type) fun {
|
|||
Valu("load", OpLoad, typ, 0, nil, "argptr", "mem"),
|
||||
Valu("c", OpConst64, TypeUInt64, amount, nil),
|
||||
Valu("shift", op, typ, 0, nil, "load", "c"),
|
||||
Valu("store", OpStore, TypeMem, 0, nil, "resptr", "shift", "mem"),
|
||||
Valu("store", OpStore, TypeMem, 8, nil, "resptr", "shift", "mem"),
|
||||
Exit("store")))
|
||||
Compile(fun.f)
|
||||
return fun
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue