Skip to content

Commit

Permalink
[dev.typeparams] cmd/compile: don't compile blank functions
Browse files Browse the repository at this point in the history
After typechecking a blank function, we can clear out its body and
skip applying middle-end optimizations (inlining, escape analysis). We
already skip sending them through SSA, and the previous CL updated
inlining and escape analysis regress tests to not depend on compiling
blank functions.

Updates #47446.

Change-Id: Ie678763b0e6ff13dd606ce14906b1ccf1bbccaae
Reviewed-on: https://go-review.googlesource.com/c/go/+/338095
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
  • Loading branch information
mdempsky committed Jul 28, 2021
1 parent adedf54 commit 506fd52
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/cmd/compile/internal/typecheck/typecheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ func FuncBody(n *ir.Func) {
Stmts(n.Body)
CheckUnused(n)
CheckReturn(n)
if base.Errors() > errorsBefore {
n.Body = nil // type errors; do not compile
if ir.IsBlank(n.Nname) || base.Errors() > errorsBefore {
n.Body = nil // blank function or type errors; do not compile
}
}

Expand Down

0 comments on commit 506fd52

Please sign in to comment.