cmd/compile: expose ir.Func to ssa

ssagen.ssafn already holds the ir.Func, and ssa.Frontend.SetWBPos and
ssa.Frontend.Lsym are simple wrappers around parts of the ir.Func.

Expose the ir.Func through ssa.Frontend, allowing us to remove these
wrapper methods and allowing future access to additional features of the
ir.Func if needed.

While we're here, drop ssa.Frontend.Line, which is unused.

For #58298.

Change-Id: I30c4cbd2743e9ad991d8c6b388484a7d1e95f3ae
Reviewed-on: https://go-review.googlesource.com/c/go/+/484215
Auto-Submit: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
This commit is contained in:
Michael Pratt 2023-04-11 16:40:12 -04:00 committed by Gopher Robot
parent 608f204ac7
commit 598cf5e6ac
5 changed files with 27 additions and 34 deletions

View file

@ -55,7 +55,18 @@ type Conf struct {
func (c *Conf) Frontend() Frontend {
if c.fe == nil {
c.fe = TestFrontend{t: c.tb, ctxt: c.config.ctxt}
f := ir.NewFunc(src.NoXPos)
f.Nname = ir.NewNameAt(f.Pos(), &types.Sym{
Pkg: types.NewPkg("my/import/path", "path"),
Name: "function",
})
f.LSym = &obj.LSym{Name: "my/import/path.function"}
c.fe = TestFrontend{
t: c.tb,
ctxt: c.config.ctxt,
f: f,
}
}
return c.fe
}
@ -65,6 +76,7 @@ func (c *Conf) Frontend() Frontend {
type TestFrontend struct {
t testing.TB
ctxt *obj.Link
f *ir.Func
}
func (TestFrontend) StringData(s string) *obj.LSym {
@ -79,9 +91,6 @@ func (TestFrontend) Auto(pos src.XPos, t *types.Type) *ir.Name {
func (d TestFrontend) SplitSlot(parent *LocalSlot, suffix string, offset int64, t *types.Type) LocalSlot {
return LocalSlot{N: parent.N, Type: t, Off: offset}
}
func (TestFrontend) Line(_ src.XPos) string {
return "unknown.go:0"
}
func (TestFrontend) AllocFrame(f *Func) {
}
func (d TestFrontend) Syslook(s string) *obj.LSym {
@ -90,8 +99,6 @@ func (d TestFrontend) Syslook(s string) *obj.LSym {
func (TestFrontend) UseWriteBarrier() bool {
return true // only writebarrier_test cares
}
func (TestFrontend) SetWBPos(pos src.XPos) {
}
func (d TestFrontend) Logf(msg string, args ...interface{}) { d.t.Logf(msg, args...) }
func (d TestFrontend) Log() bool { return true }
@ -101,10 +108,10 @@ func (d TestFrontend) Warnl(_ src.XPos, msg string, args ...interface{}) { d.t.
func (d TestFrontend) Debug_checknil() bool { return false }
func (d TestFrontend) MyImportPath() string {
return "my/import/path"
return d.f.Sym().Pkg.Path
}
func (d TestFrontend) LSym() string {
return "my/import/path.function"
func (d TestFrontend) Func() *ir.Func {
return d.f
}
var testTypes Types