aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/typecheck/func.go
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2020-11-28 16:01:58 -0800
committerKeith Randall <khr@golang.org>2020-12-29 18:04:10 +0000
commit0523d525ae0dea229cffc5634caddd0acbc066af (patch)
treead08e8b89b02662043d39e04ba410a601595f386 /src/cmd/compile/internal/typecheck/func.go
parent9ea272e5ec5dd5eadd59d54c08377d5d9527a51b (diff)
downloadgo-0523d525ae0dea229cffc5634caddd0acbc066af.tar.gz
go-0523d525ae0dea229cffc5634caddd0acbc066af.zip
[dev.regabi] cmd/compile: separate out address taken computation from typechecker
This CL computes a second parallel addrtaken bit that we check against the old way of doing it. A subsequent CL will rip out the typechecker code and just use the new way. Change-Id: I62b7342c44f694144844695386f80088bbd40bf4 Reviewed-on: https://go-review.googlesource.com/c/go/+/275695 Trust: Keith Randall <khr@golang.org> Trust: Dan Scales <danscales@google.com> Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Dan Scales <danscales@google.com>
Diffstat (limited to 'src/cmd/compile/internal/typecheck/func.go')
-rw-r--r--src/cmd/compile/internal/typecheck/func.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/typecheck/func.go b/src/cmd/compile/internal/typecheck/func.go
index 060024951e..ce6f4027da 100644
--- a/src/cmd/compile/internal/typecheck/func.go
+++ b/src/cmd/compile/internal/typecheck/func.go
@@ -135,6 +135,7 @@ func CaptureVars(fn *ir.Func) {
v.SetByval(true)
} else {
outermost.Name().SetAddrtaken(true)
+ outermost.Name().SetAddrtaken2(true)
outer = NodAddr(outer)
}
@@ -163,6 +164,21 @@ func CaptureVars(fn *ir.Func) {
func ImportedBody(fn *ir.Func) {
lno := ir.SetPos(fn.Nname)
+ // When we load an inlined body, we need to allow OADDR
+ // operations on untyped expressions. We will fix the
+ // addrtaken flags on all the arguments of the OADDR with the
+ // computeAddrtaken call below (after we typecheck the body).
+ // TODO: export/import types and addrtaken marks along with inlined bodies,
+ // so this will be unnecessary.
+ incrementalAddrtaken = false
+ defer func() {
+ if dirtyAddrtaken {
+ computeAddrtaken(fn.Inl.Body) // compute addrtaken marks once types are available
+ dirtyAddrtaken = false
+ }
+ incrementalAddrtaken = true
+ }()
+
ImportBody(fn)
// typecheckinl is only for imported functions;