From e3a6d00876488c70b6ecc641954ed5cecb918cac Mon Sep 17 00:00:00 2001 From: Cherry Zhang Date: Wed, 8 Jun 2016 10:12:30 -0400 Subject: [PATCH] [dev.ssa] cmd/compile: ensure OffPtr has pointer type SSA treats SP as constant throughout a function, so as OffPtr [off] SP. When the stack moves, spilled OffPtr values become invalid, if they are not pointer-typed. (Currently it is fine because of the optimization rules that folds OffPtr into Load/Store. But it'd better be "optimization", not requirement.) Updates #15365. Change-Id: I76cf4008dfdc169e1cb5a55a2605b6678efc915d Reviewed-on: https://go-review.googlesource.com/23941 Run-TryBot: Cherry Zhang TryBot-Result: Gobot Gobot Reviewed-by: David Chase --- src/cmd/compile/internal/gc/ssa.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cmd/compile/internal/gc/ssa.go b/src/cmd/compile/internal/gc/ssa.go index 08544ff5be..3bf60ef778 100644 --- a/src/cmd/compile/internal/gc/ssa.go +++ b/src/cmd/compile/internal/gc/ssa.go @@ -2580,7 +2580,7 @@ func (s *state) call(n *Node, k callKind) *ssa.Value { i := s.expr(fn.Left) itab := s.newValue1(ssa.OpITab, Types[TUINTPTR], i) itabidx := fn.Xoffset + 3*int64(Widthptr) + 8 // offset of fun field in runtime.itab - itab = s.newValue1I(ssa.OpOffPtr, Types[TUINTPTR], itabidx, itab) + itab = s.newValue1I(ssa.OpOffPtr, Ptrto(Types[TUINTPTR]), itabidx, itab) if k == callNormal { codeptr = s.newValue2(ssa.OpLoad, Types[TUINTPTR], itab, s.mem()) } else { @@ -2603,7 +2603,7 @@ func (s *state) call(n *Node, k callKind) *ssa.Value { if k != callNormal { argStart += int64(2 * Widthptr) } - addr := s.entryNewValue1I(ssa.OpOffPtr, Types[TUINTPTR], argStart, s.sp) + addr := s.entryNewValue1I(ssa.OpOffPtr, Ptrto(Types[TUINTPTR]), argStart, s.sp) s.vars[&memVar] = s.newValue3I(ssa.OpStore, ssa.TypeMem, int64(Widthptr), addr, rcvr, s.mem()) } @@ -2612,7 +2612,7 @@ func (s *state) call(n *Node, k callKind) *ssa.Value { // Write argsize and closure (args to Newproc/Deferproc). argStart := Ctxt.FixedFrameSize() argsize := s.constInt32(Types[TUINT32], int32(stksize)) - addr := s.entryNewValue1I(ssa.OpOffPtr, Types[TUINTPTR], argStart, s.sp) + addr := s.entryNewValue1I(ssa.OpOffPtr, Ptrto(Types[TUINT32]), argStart, s.sp) s.vars[&memVar] = s.newValue3I(ssa.OpStore, ssa.TypeMem, 4, addr, argsize, s.mem()) addr = s.entryNewValue1I(ssa.OpOffPtr, Ptrto(Types[TUINTPTR]), argStart+int64(Widthptr), s.sp) s.vars[&memVar] = s.newValue3I(ssa.OpStore, ssa.TypeMem, int64(Widthptr), addr, closure, s.mem()) @@ -2968,7 +2968,7 @@ func (s *state) rtcall(fn *Node, returns bool, results []*Type, args ...*ssa.Val off = Rnd(off, t.Alignment()) ptr := s.sp if off != 0 { - ptr = s.newValue1I(ssa.OpOffPtr, Types[TUINTPTR], off, s.sp) + ptr = s.newValue1I(ssa.OpOffPtr, t.PtrTo(), off, s.sp) } size := t.Size() s.vars[&memVar] = s.newValue3I(ssa.OpStore, ssa.TypeMem, size, ptr, arg, s.mem()) @@ -3008,7 +3008,7 @@ func (s *state) rtcall(fn *Node, returns bool, results []*Type, args ...*ssa.Val off = Rnd(off, t.Alignment()) ptr := s.sp if off != 0 { - ptr = s.newValue1I(ssa.OpOffPtr, Types[TUINTPTR], off, s.sp) + ptr = s.newValue1I(ssa.OpOffPtr, Ptrto(t), off, s.sp) } res[i] = s.newValue2(ssa.OpLoad, t, ptr, s.mem()) off += t.Size() -- 2.48.1