Source file src/cmd/compile/internal/ssacompile/stackalloc.go

     1  // Copyright 2015 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // TODO: live at start of block instead?
     6  
     7  package ssacompile
     8  
     9  import (
    10  	"fmt"
    11  
    12  	"cmd/compile/internal/ssa"
    13  )
    14  
    15  // stackalloc allocates storage in the stack frame for
    16  // all Values that did not get a register.
    17  // Returns a map from block ID to the stack values live at the end of that block.
    18  func stackalloc(f *ssa.Func, spillLive [][]ssa.ID) [][]ssa.ID {
    19  	if f.Pass.Debug > ssa.StackDebug {
    20  		fmt.Println("before stackalloc")
    21  		fmt.Println(f.String())
    22  	}
    23  	s := ssa.NewStackAllocState(f)
    24  	s.Init(f, spillLive)
    25  	defer ssa.PutStackAllocState(s)
    26  
    27  	s.Stackalloc()
    28  	if f.Pass.Stats > 0 {
    29  		f.LogStat("stack_alloc_stats",
    30  			s.NArgSlot, "arg_slots", s.NNotNeed, "slot_not_needed",
    31  			s.NNamedSlot, "named_slots", s.NAuto, "auto_slots",
    32  			s.NReuse, "reused_slots", s.NSelfInterfere, "self_interfering")
    33  	}
    34  
    35  	return s.Live
    36  }
    37  

View as plain text