Skip to content

Commit 88859f3

Browse files
committed
cmd/compile: optimize unified IR handling of imported functions
This CL skips reading of imported function bodies except from the local package or for inlining. Previously, we wasted a bunch of CPU and memory by reading in normal function bodies for all imported functions and methods. Change-Id: I0b3df3f4a3e2819117dac11a1f9e4526288c14d8 Reviewed-on: https://go-review.googlesource.com/c/go/+/347030 Trust: Matthew Dempsky <[email protected]> Run-TryBot: Matthew Dempsky <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Cuong Manh Le <[email protected]>
1 parent 50f38d0 commit 88859f3

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/cmd/compile/internal/noder/reader.go

+6
Original file line numberDiff line numberDiff line change
@@ -920,6 +920,12 @@ func (r *reader) addBody(fn *ir.Func) {
920920
pri := pkgReaderIndex{r.p, r.reloc(relocBody), r.dict}
921921
bodyReader[fn] = pri
922922

923+
if fn.Nname.Defn == nil {
924+
// Don't read in function body for imported functions.
925+
// See comment in funcExt.
926+
return
927+
}
928+
923929
if r.curfn == nil {
924930
todoBodies = append(todoBodies, fn)
925931
return

0 commit comments

Comments
 (0)