From: David Chase Date: Tue, 29 Oct 2019 18:44:54 +0000 (-0400) Subject: cmd/compile: add json logging for escape analysis X-Git-Tag: go1.14beta1~273 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=298be61f3c74a010d3f6bb6c827b268cd3a5fca8;p=gostls13.git cmd/compile: add json logging for escape analysis Change-Id: I7ca075e50d144aa449a20ebfbaf7337406e1e510 Reviewed-on: https://go-review.googlesource.com/c/go/+/204161 Run-TryBot: David Chase TryBot-Result: Gobot Gobot Reviewed-by: Cherry Zhang --- diff --git a/src/cmd/compile/internal/gc/escape.go b/src/cmd/compile/internal/gc/escape.go index bd4df1d84f..0f71f9990b 100644 --- a/src/cmd/compile/internal/gc/escape.go +++ b/src/cmd/compile/internal/gc/escape.go @@ -5,6 +5,7 @@ package gc import ( + "cmd/compile/internal/logopt" "cmd/compile/internal/types" "fmt" "math" @@ -1379,8 +1380,13 @@ func (e *Escape) finish(fns []*Node) { // Update n.Esc based on escape analysis results. if loc.escapes { - if Debug['m'] != 0 && n.Op != ONAME { - Warnl(n.Pos, "%S escapes to heap", n) + if n.Op != ONAME { + if Debug['m'] != 0 { + Warnl(n.Pos, "%S escapes to heap", n) + } + if logopt.Enabled() { + logopt.LogOpt(n.Pos, "escape", "escape", e.curfn.funcname()) + } } n.Esc = EscHeap addrescapes(n)