I got the information
./main_test.go:23:3: func literal escapes to heap:
./main_test.go:23:3: flow: {heap} = &{storage for func literal}:
./main_test.go:23:3: from func literal (spill) at ./main_test.go:23:3
./main_test.go:23:3: from .autotmp_3(func literal) (call parameter) at ./main_test.go:23:3
./main_test.go:23:24: BenchmarkBelow3 capturing by ref: n (addr=false assign=true width=8)
./main_test.go:23:3: BenchmarkBelow3 capturing by ref: #exit1 (addr=false assign=true width=1)
./main_test.go:23:3: #exit1 escapes to heap:
./main_test.go:23:3: flow: {storage for func literal} = &#exit1:
./main_test.go:23:3: from #exit1 (captured by a closure) at ./main_test.go:23:3
./main_test.go:23:3: from #exit1 (reference) at ./main_test.go:23:3
./main_test.go:21:22: b does not escape
./main_test.go:9:15: f does not escape
./main_test.go:11:14: f does not escape
./main_test.go:23:3: moved to heap: #exit1
./main_test.go:23:24: func literal does not escape
./main_test.go:23:24: func literal does not escape
./main_test.go:23:3: func literal escapes to heap
./main_test.go:31:13: func literal escapes to heap:
./main_test.go:31:13: flow: {heap} = &{storage for func literal}:
./main_test.go:31:13: from func literal (spill) at ./main_test.go:31:13
./main_test.go:31:13: from .autotmp_2(func literal) (call parameter) at ./main_test.go:31:12
./main_test.go:31:9: BenchmarkBelow3direct capturing by ref: n (addr=false assign=true width=8)
./main_test.go:29:28: b does not escape
./main_test.go:9:15: f does not escape
./main_test.go:11:14: f does not escape
./main_test.go:31:9: func literal does not escape
./main_test.go:31:9: func literal does not escape
./main_test.go:31:13: func literal escapes to heap
Can anyone explain why range-over-func has two more alloc than direct-call-func?