aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/typecheck/typecheck.go
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2021-07-28 13:17:32 -0700
committerMatthew Dempsky <mdempsky@google.com>2021-07-28 21:41:21 +0000
commit506fd520d5cd6ea075ac82e79a23c502c1540170 (patch)
treea27282cd617f022b8868aa5cf7ca8165bcca24b3 /src/cmd/compile/internal/typecheck/typecheck.go
parentadedf54288e826bd93ccf22ad104f768d42289d4 (diff)
downloadgo-506fd520d5cd6ea075ac82e79a23c502c1540170.tar.gz
go-506fd520d5cd6ea075ac82e79a23c502c1540170.zip
[dev.typeparams] cmd/compile: don't compile blank functions
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>
Diffstat (limited to 'src/cmd/compile/internal/typecheck/typecheck.go')
-rw-r--r--src/cmd/compile/internal/typecheck/typecheck.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/cmd/compile/internal/typecheck/typecheck.go b/src/cmd/compile/internal/typecheck/typecheck.go
index 8f3d6cf4bb..db1b11c4cf 100644
--- a/src/cmd/compile/internal/typecheck/typecheck.go
+++ b/src/cmd/compile/internal/typecheck/typecheck.go
@@ -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
}
}