diff options
author | Russ Cox <rsc@golang.org> | 2020-12-23 00:58:27 -0500 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2020-12-23 06:39:36 +0000 |
commit | 01fd2d05c8b7bfc083977ca73123a5541b289737 (patch) | |
tree | c769857e30a859d3c511dd64db1af0b3016633d3 /src/cmd/compile/internal/gc/main.go | |
parent | 6c34d2f42077bd7757c942c8d1b466366190b45a (diff) | |
download | go-01fd2d05c8b7bfc083977ca73123a5541b289737.tar.gz go-01fd2d05c8b7bfc083977ca73123a5541b289737.zip |
[dev.regabi] cmd/compile: split out package dwarfgen [generated]
[git-generate]
cd src/cmd/compile/internal/gc
rf '
# Inline and remove ngotype.
ex {
import "cmd/compile/internal/ir"
import "cmd/compile/internal/reflectdata"
var n ir.Node
ngotype(n) -> reflectdata.TypeSym(n.Type())
}
rm ngotype
mv recordFlags RecordFlags
mv recordPackageName RecordPackageName
mv RecordFlags RecordPackageName dwarf.go
mv debuginfo Info
mv genAbstractFunc AbstractFunc
mv scope.go scope_test.go dwarf.go dwinl.go cmd/compile/internal/dwarfgen
'
Change-Id: I31fa982900dbba2066ca4c7a706af922e5481c70
Reviewed-on: https://go-review.googlesource.com/c/go/+/279477
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'src/cmd/compile/internal/gc/main.go')
-rw-r--r-- | src/cmd/compile/internal/gc/main.go | 76 |
1 files changed, 5 insertions, 71 deletions
diff --git a/src/cmd/compile/internal/gc/main.go b/src/cmd/compile/internal/gc/main.go index 154235f744..2a8012b462 100644 --- a/src/cmd/compile/internal/gc/main.go +++ b/src/cmd/compile/internal/gc/main.go @@ -10,6 +10,7 @@ import ( "bufio" "bytes" "cmd/compile/internal/base" + "cmd/compile/internal/dwarfgen" "cmd/compile/internal/escape" "cmd/compile/internal/inline" "cmd/compile/internal/ir" @@ -114,7 +115,7 @@ func Main(archInit func(*ssagen.ArchInfo)) { // Record flags that affect the build result. (And don't // record flags that don't, since that would cause spurious // changes in the binary.) - recordFlags("B", "N", "l", "msan", "race", "shared", "dynlink", "dwarflocationlists", "dwarfbasentries", "smallframes", "spectre") + dwarfgen.RecordFlags("B", "N", "l", "msan", "race", "shared", "dynlink", "dwarflocationlists", "dwarfbasentries", "smallframes", "spectre") if !base.EnableTrace && base.Flag.LowerT { log.Fatalf("compiler not built with support for -t") @@ -134,8 +135,8 @@ func Main(archInit func(*ssagen.ArchInfo)) { } if base.Flag.Dwarf { - base.Ctxt.DebugInfo = debuginfo - base.Ctxt.GenAbstractFunc = genAbstractFunc + base.Ctxt.DebugInfo = dwarfgen.Info + base.Ctxt.GenAbstractFunc = dwarfgen.AbstractFunc base.Ctxt.DwFixups = obj.NewDwarfFixupTable(base.Ctxt) } else { // turn off inline generation if no dwarf at all @@ -211,7 +212,7 @@ func Main(archInit func(*ssagen.ArchInfo)) { ssagen.CgoSymABIs() base.Timer.Stop() base.Timer.AddEvent(int64(lines), "lines") - recordPackageName() + dwarfgen.RecordPackageName() // Typecheck. typecheck.Package() @@ -364,73 +365,6 @@ func writebench(filename string) error { return f.Close() } -// recordFlags records the specified command-line flags to be placed -// in the DWARF info. -func recordFlags(flags ...string) { - if base.Ctxt.Pkgpath == "" { - // We can't record the flags if we don't know what the - // package name is. - return - } - - type BoolFlag interface { - IsBoolFlag() bool - } - type CountFlag interface { - IsCountFlag() bool - } - var cmd bytes.Buffer - for _, name := range flags { - f := flag.Lookup(name) - if f == nil { - continue - } - getter := f.Value.(flag.Getter) - if getter.String() == f.DefValue { - // Flag has default value, so omit it. - continue - } - if bf, ok := f.Value.(BoolFlag); ok && bf.IsBoolFlag() { - val, ok := getter.Get().(bool) - if ok && val { - fmt.Fprintf(&cmd, " -%s", f.Name) - continue - } - } - if cf, ok := f.Value.(CountFlag); ok && cf.IsCountFlag() { - val, ok := getter.Get().(int) - if ok && val == 1 { - fmt.Fprintf(&cmd, " -%s", f.Name) - continue - } - } - fmt.Fprintf(&cmd, " -%s=%v", f.Name, getter.Get()) - } - - if cmd.Len() == 0 { - return - } - s := base.Ctxt.Lookup(dwarf.CUInfoPrefix + "producer." + base.Ctxt.Pkgpath) - s.Type = objabi.SDWARFCUINFO - // Sometimes (for example when building tests) we can link - // together two package main archives. So allow dups. - s.Set(obj.AttrDuplicateOK, true) - base.Ctxt.Data = append(base.Ctxt.Data, s) - s.P = cmd.Bytes()[1:] -} - -// recordPackageName records the name of the package being -// compiled, so that the linker can save it in the compile unit's DIE. -func recordPackageName() { - s := base.Ctxt.Lookup(dwarf.CUInfoPrefix + "packagename." + base.Ctxt.Pkgpath) - s.Type = objabi.SDWARFCUINFO - // Sometimes (for example when building tests) we can link - // together two package main archives. So allow dups. - s.Set(obj.AttrDuplicateOK, true) - base.Ctxt.Data = append(base.Ctxt.Data, s) - s.P = []byte(types.LocalPkg.Name) -} - func makePos(b *src.PosBase, line, col uint) src.XPos { return base.Ctxt.PosTable.XPos(src.MakePos(b, line, col)) } |