From 3dcc424be70b9d1824f756ab81f97508ae1a7738 Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Tue, 14 Jul 2015 13:20:08 -0700 Subject: [dev.ssa] cmd/compile/internal/ssa: compute outarg size correctly Keep track of the outargs size needed at each call. Compute the size of the outargs section of the stack frame. It's just the max of the outargs size at all the callsites in the function. Change-Id: I3d0640f654f01307633b1a5f75bab16e211ea6c0 Reviewed-on: https://go-review.googlesource.com/12178 Reviewed-by: Josh Bleecher Snyder --- src/cmd/compile/internal/ssa/stackalloc.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/cmd/compile/internal/ssa/stackalloc.go') diff --git a/src/cmd/compile/internal/ssa/stackalloc.go b/src/cmd/compile/internal/ssa/stackalloc.go index 85a55ece7c..0bd64a1a14 100644 --- a/src/cmd/compile/internal/ssa/stackalloc.go +++ b/src/cmd/compile/internal/ssa/stackalloc.go @@ -9,12 +9,16 @@ package ssa func stackalloc(f *Func) { home := f.RegAlloc - // First compute the size of the outargs section. - n := int64(16) //TODO: compute max of all callsites - - // Include one slot for deferreturn. - if false && n < f.Config.ptrSize { //TODO: check for deferreturn - n = f.Config.ptrSize + // Start with space for callee arguments/returns. + var n int64 + for _, b := range f.Blocks { + if b.Kind != BlockCall { + continue + } + v := b.Control + if n < v.AuxInt { + n = v.AuxInt + } } // TODO: group variables by ptr/nonptr, size, etc. Emit ptr vars last -- cgit v1.3-5-g9baa