From 945180fe2aa3238bbc23f336a00eba934daa9ccc Mon Sep 17 00:00:00 2001 From: Michael Munday Date: Thu, 9 Mar 2017 13:03:07 -0500 Subject: [PATCH] cmd/compile: fix OffPtr type in 2-field struct Store rule The type of the OffPtr for the first field was incorrect. It should have been a pointer to the field type, rather than the field type itself. Fixes #19475. Change-Id: I3960b404da0f4bee759331126cce6140d2ce1df7 Reviewed-on: https://go-review.googlesource.com/37869 Run-TryBot: Michael Munday Reviewed-by: Keith Randall --- src/cmd/compile/internal/ssa/gen/generic.rules | 2 +- src/cmd/compile/internal/ssa/rewritegeneric.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cmd/compile/internal/ssa/gen/generic.rules b/src/cmd/compile/internal/ssa/gen/generic.rules index a81d2826d8..e921a1110b 100644 --- a/src/cmd/compile/internal/ssa/gen/generic.rules +++ b/src/cmd/compile/internal/ssa/gen/generic.rules @@ -800,7 +800,7 @@ (OffPtr [t.FieldOff(1)] dst) f1 (Store [t.FieldType(0).Size()] - (OffPtr [0] dst) + (OffPtr [0] dst) f0 mem)) (Store dst (StructMake3 f0 f1 f2) mem) -> (Store [t.FieldType(2).Size()] diff --git a/src/cmd/compile/internal/ssa/rewritegeneric.go b/src/cmd/compile/internal/ssa/rewritegeneric.go index 7690e73d41..c72d7c685d 100644 --- a/src/cmd/compile/internal/ssa/rewritegeneric.go +++ b/src/cmd/compile/internal/ssa/rewritegeneric.go @@ -14705,7 +14705,7 @@ func rewriteValuegeneric_OpStore(v *Value, config *Config) bool { } // match: (Store dst (StructMake2 f0 f1) mem) // cond: - // result: (Store [t.FieldType(1).Size()] (OffPtr [t.FieldOff(1)] dst) f1 (Store [t.FieldType(0).Size()] (OffPtr [0] dst) f0 mem)) + // result: (Store [t.FieldType(1).Size()] (OffPtr [t.FieldOff(1)] dst) f1 (Store [t.FieldType(0).Size()] (OffPtr [0] dst) f0 mem)) for { dst := v.Args[0] v_1 := v.Args[1] @@ -14725,7 +14725,7 @@ func rewriteValuegeneric_OpStore(v *Value, config *Config) bool { v.AddArg(f1) v1 := b.NewValue0(v.Pos, OpStore, TypeMem) v1.AuxInt = t.FieldType(0).Size() - v2 := b.NewValue0(v.Pos, OpOffPtr, t.FieldType(0)) + v2 := b.NewValue0(v.Pos, OpOffPtr, t.FieldType(0).PtrTo()) v2.AuxInt = 0 v2.AddArg(dst) v1.AddArg(v2)