From 14537e6e5410b403add59bb41d3954bdab0ade3e Mon Sep 17 00:00:00 2001 From: Matthew Dempsky Date: Fri, 15 Jan 2021 00:56:02 -0800 Subject: [PATCH] [dev.regabi] cmd/compile: move stkobj symbol generation to SSA The code for allocating linksyms and recording that we need runtime type descriptors is now concurrent-safe, so move it to where those symbols are actually needed to reduce complexity and risk of failing to generate all needed symbols in advance. For #43701. Change-Id: I759d2508213ac9a4e0b504b51a75fa10dfa37a8d Reviewed-on: https://go-review.googlesource.com/c/go/+/284076 Run-TryBot: Matthew Dempsky TryBot-Result: Go Bot Reviewed-by: Cuong Manh Le Trust: Matthew Dempsky --- src/cmd/compile/internal/gc/compile.go | 16 ---------------- src/cmd/compile/internal/ssagen/ssa.go | 8 +++----- 2 files changed, 3 insertions(+), 21 deletions(-) diff --git a/src/cmd/compile/internal/gc/compile.go b/src/cmd/compile/internal/gc/compile.go index a8a0106320..6e347bf0f1 100644 --- a/src/cmd/compile/internal/gc/compile.go +++ b/src/cmd/compile/internal/gc/compile.go @@ -13,7 +13,6 @@ import ( "cmd/compile/internal/base" "cmd/compile/internal/ir" "cmd/compile/internal/liveness" - "cmd/compile/internal/reflectdata" "cmd/compile/internal/ssagen" "cmd/compile/internal/typecheck" "cmd/compile/internal/types" @@ -84,21 +83,6 @@ func prepareFunc(fn *ir.Func) { walk.Walk(fn) ir.CurFunc = nil // enforce no further uses of CurFunc typecheck.DeclContext = ir.PEXTERN - - // Make sure type syms are declared for all types that might - // be types of stack objects. We need to do this here - // because symbols must be allocated before the parallel - // phase of the compiler. - for _, n := range fn.Dcl { - if liveness.ShouldTrack(n) && n.Addrtaken() { - reflectdata.WriteType(n.Type()) - // Also make sure we allocate a linker symbol - // for the stack object data, for the same reason. - if fn.LSym.Func().StackObjects == nil { - fn.LSym.Func().StackObjects = base.Ctxt.Lookup(fn.LSym.Name + ".stkobj") - } - } - } } // compileFunctions compiles all functions in compilequeue. diff --git a/src/cmd/compile/internal/ssagen/ssa.go b/src/cmd/compile/internal/ssagen/ssa.go index fe9a1f617b..c48ac22d2a 100644 --- a/src/cmd/compile/internal/ssagen/ssa.go +++ b/src/cmd/compile/internal/ssagen/ssa.go @@ -6494,7 +6494,8 @@ func emitStackObjects(e *ssafn, pp *objw.Progs) { // Populate the stack object data. // Format must match runtime/stack.go:stackObjectRecord. - x := e.curfn.LSym.Func().StackObjects + x := base.Ctxt.Lookup(e.curfn.LSym.Name + ".stkobj") + e.curfn.LSym.Func().StackObjects = x off := 0 off = objw.Uintptr(x, off, uint64(len(vars))) for _, v := range vars { @@ -6502,10 +6503,7 @@ func emitStackObjects(e *ssafn, pp *objw.Progs) { // in which case the offset is relative to argp. // Locals have a negative Xoffset, in which case the offset is relative to varp. off = objw.Uintptr(x, off, uint64(v.FrameOffset())) - if !types.TypeSym(v.Type()).Siggen() { - e.Fatalf(v.Pos(), "stack object's type symbol not generated for type %s", v.Type()) - } - off = objw.SymPtr(x, off, reflectdata.WriteType(v.Type()), 0) + off = objw.SymPtr(x, off, reflectdata.TypeLinksym(v.Type()), 0) } // Emit a funcdata pointing at the stack object data. -- 2.50.0