-gcflags '-m -l' escape_analysis1.go # command-line-arguments ./escape_analysis1.go:11: leaking param: z to result ~r1 level=0 ./escape_analysis1.go:7: main &x does not escape go は関数の引数は値渡しなので、identity にz のコピーが渡される けどz はidentity で参照されていないのでエスケープされなかった
-gcflags '-m -l' escape_analysis2.go # command-line-arguments ./escape_analysis2.go:11: &z escapes to heap ./escape_analysis2.go:10: moved to heap: z ref はz の参照を返すから、z はref のスタックフレームに入らない main にも見えるようにヒープに格納される
-gcflags '-m -l' escape_analysis3.go # command-line-arguments ./escape_analysis3.go:13: &y escapes to heap ./escape_analysis3.go:12: moved to heap: y 構造体のフィールドであってもエスケープされる
-gcflags '-m -l' escape_analysis4.go # command-line-arguments ./escape_analysis4.go:12: leaking param: y to result z level=0 ./escape_analysis4.go:9: main &i does not escape main のスタックフレーム内の参照だから、refStruct のz.y の値は知っている 参照が循環される。エスケープされない
-gcflags '-m -l' escape_analysis5.go # command-line-arguments ./escape_analysis5.go:13: leaking param: y ./escape_analysis5.go:13: ref z does not escape ./escape_analysis5.go:10: &i escapes to heap ./escape_analysis5.go:9: moved to heap: i ./escape_analysis5.go:10: main &x does not escape 入力された構造体に代入している 解析での入力は出力の値に対してのみ許可されている
-gcflags '-m -l' escape_analysis6.go # command-line-arguments ./escape_analysis6.go:13: &i[0] escapes to heap ./escape_analysis6.go:12: moved to heap: i 配列は一つの要素でもエスケープされてしまうと、全体もエスケープされる 一つもエスケープされないと、スタックフレームに乗る
-gcflags="-m -l" -bench=. escape_analysis8.go # command-line-arguments ./escape_analysis8.go:9: &v escapes to heap ./escape_analysis8.go:6: moved to heap: v ./escape_analysis8.go:8: main make(map[int]*S) does not escape map のvalue にセットされたポインターは常にエスケープされる
-gcflags="-m -l" -bench=. escape_analysis8.go # command-line-arguments ./escape_analysis9.go:9: &v escapes to heap ./escape_analysis9.go:6: moved to heap: v ./escape_analysis9.go:8: main []*S literal does not escape slice のvalue にセットされたポインターは常にエスケープされる