diff options
| author | Cuong Manh Le <cuong.manhle.vn@gmail.com> | 2021-09-03 10:49:32 +0700 |
|---|---|---|
| committer | Cuong Manh Le <cuong.manhle.vn@gmail.com> | 2021-09-09 04:37:47 +0000 |
| commit | 376a079762bf8db387510d50ed718ec1259d1b7c (patch) | |
| tree | c620005686f2c3abcf5f0443ea0c4d6385f5d564 /src/cmd/compile/internal/noder | |
| parent | 6edc57983a39b3cb911ea88b75a7ad39664383ec (diff) | |
| download | go-376a079762bf8db387510d50ed718ec1259d1b7c.tar.xz | |
cmd/compile: fix unified IR panic when expanding nested inline function
When reading body of inlining function, which has another inlined
function in the body, the reader still add this inlined function to
todoBodies, which it shouldn't because the inlined function was read
already.
To fix this, introduce new flag to signal that we are done construting
all functions in todoBodies, thus the addBody shouldn't add anything
to todoBodies then.
Updates #48094
Change-Id: I45105dd518f0a7b69c6dcbaf23b957623f271203
Reviewed-on: https://go-review.googlesource.com/c/go/+/347529
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'src/cmd/compile/internal/noder')
| -rw-r--r-- | src/cmd/compile/internal/noder/reader.go | 7 | ||||
| -rw-r--r-- | src/cmd/compile/internal/noder/unified.go | 1 |
2 files changed, 7 insertions, 1 deletions
diff --git a/src/cmd/compile/internal/noder/reader.go b/src/cmd/compile/internal/noder/reader.go index 57e8476099..48f4368113 100644 --- a/src/cmd/compile/internal/noder/reader.go +++ b/src/cmd/compile/internal/noder/reader.go @@ -927,6 +927,11 @@ var bodyReader = map[*ir.Func]pkgReaderIndex{} // constructed. var todoBodies []*ir.Func +// todoBodiesDone signals that we constructed all function in todoBodies. +// This is necessary to prevent reader.addBody adds thing to todoBodies +// when nested inlining happens. +var todoBodiesDone = false + func (r *reader) addBody(fn *ir.Func) { pri := pkgReaderIndex{r.p, r.reloc(relocBody), r.dict} bodyReader[fn] = pri @@ -937,7 +942,7 @@ func (r *reader) addBody(fn *ir.Func) { return } - if r.curfn == nil { + if r.curfn == nil && !todoBodiesDone { todoBodies = append(todoBodies, fn) return } diff --git a/src/cmd/compile/internal/noder/unified.go b/src/cmd/compile/internal/noder/unified.go index eff2eeaeff..3d4650a01f 100644 --- a/src/cmd/compile/internal/noder/unified.go +++ b/src/cmd/compile/internal/noder/unified.go @@ -136,6 +136,7 @@ func unified(noders []*noder) { } } todoBodies = nil + todoBodiesDone = true // Check that nothing snuck past typechecking. for _, n := range target.Decls { |
