return tmp
}
-// EstSavings returns the estimated reduction in stack size for
-// the given merge locals state.
-func (mls *MergeLocalsState) EstSavings() int {
- tot := 0
+// EstSavings returns the estimated reduction in stack size (number of bytes) for
+// the given merge locals state via a pair of ints, the first for non-pointer types and the second for pointer types.
+func (mls *MergeLocalsState) EstSavings() (int, int) {
+ totnp := 0
+ totp := 0
for n := range mls.partition {
if mls.Subsumed(n) {
- tot += int(n.Type().Size())
+ sz := int(n.Type().Size())
+ if n.Type().HasPointers() {
+ totp += sz
+ } else {
+ totnp += sz
+ }
}
}
- return tot
+ return totnp, totp
}
// check tests for various inconsistencies and problems in mls,
var mls *liveness.MergeLocalsState
if base.Debug.MergeLocals != 0 {
mls = liveness.MergeLocals(fn, f)
- if base.Debug.MergeLocalsTrace == 1 && mls != nil {
- fmt.Fprintf(os.Stderr, "%s: %d bytes of stack space saved via stack slot merging\n", ir.FuncName(fn), mls.EstSavings())
+ if base.Debug.MergeLocalsTrace > 0 && mls != nil {
+ savedNP, savedP := mls.EstSavings()
+ fmt.Fprintf(os.Stderr, "%s: %d bytes of stack space saved via stack slot merging (%d nonpointer %d pointer)\n", ir.FuncName(fn), savedNP+savedP, savedNP, savedP)
if base.Debug.MergeLocalsTrace > 1 {
fmt.Fprintf(os.Stderr, "=-= merge locals state for %v:\n%v",
fn, mls)