Commit 7bad0036 authored by Matthew Dempsky's avatar Matthew Dempsky

cmd/internal/obj: remove ATYPE

In cmd/compile, we can directly construct obj.Auto to represent local
variables and attach them to the function's obj.LSym.

In preparation for being able to emit more precise DWARF info based on
other compiler available information (e.g., lexical scoping).

Change-Id: I9c4225ec59306bec42552838493022e0e9d70228
Reviewed-on: https://go-review.googlesource.com/36420
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarHeschi Kreinick <heschi@google.com>
Reviewed-by: default avatarJosh Bleecher Snyder <josharian@gmail.com>
parent 38cb9d28
......@@ -23,7 +23,6 @@ const (
// As an exception to that rule, we typically write down all the
// size variants of an operation even if we just use a subset.
var progtable = [x86.ALAST & obj.AMask]gc.ProgInfo{
obj.ATYPE: {Flags: gc.Pseudo | gc.Skip},
obj.ATEXT: {Flags: gc.Pseudo},
obj.AFUNCDATA: {Flags: gc.Pseudo},
obj.APCDATA: {Flags: gc.Pseudo},
......
......@@ -22,7 +22,6 @@ const (
// As an exception to that rule, we typically write down all the
// size variants of an operation even if we just use a subset.
var progtable = [arm.ALAST & obj.AMask]gc.ProgInfo{
obj.ATYPE: {Flags: gc.Pseudo | gc.Skip},
obj.ATEXT: {Flags: gc.Pseudo},
obj.AFUNCDATA: {Flags: gc.Pseudo},
obj.APCDATA: {Flags: gc.Pseudo},
......
......@@ -25,7 +25,6 @@ const (
//
// The table is formatted for 8-space tabs.
var progtable = [arm64.ALAST & obj.AMask]gc.ProgInfo{
obj.ATYPE: {Flags: gc.Pseudo | gc.Skip},
obj.ATEXT: {Flags: gc.Pseudo},
obj.AFUNCDATA: {Flags: gc.Pseudo},
obj.APCDATA: {Flags: gc.Pseudo},
......
......@@ -299,7 +299,7 @@ func Patch(p *obj.Prog, to *obj.Prog) {
// Gins inserts instruction as. f is from, t is to.
func Gins(as obj.As, f, t *Node) *obj.Prog {
switch as {
case obj.AVARKILL, obj.AVARLIVE, obj.AVARDEF, obj.ATYPE,
case obj.AVARKILL, obj.AVARLIVE, obj.AVARDEF,
obj.ATEXT, obj.AFUNCDATA, obj.AUSEFIELD:
default:
Fatalf("unhandled gins op %v", as)
......
......@@ -422,29 +422,45 @@ func compile(fn *Node) {
}
}
for _, n := range fn.Func.Dcl {
gendebug(ptxt.From.Sym, fn.Func.Dcl)
genssa(ssafn, ptxt, gcargs, gclocals)
ssafn.Free()
}
func gendebug(fn *obj.LSym, decls []*Node) {
if fn == nil {
return
}
for _, n := range decls {
if n.Op != ONAME { // might be OTYPE or OLITERAL
continue
}
var name int16
switch n.Class {
case PAUTO:
if !n.Used {
continue
}
fallthrough
name = obj.NAME_AUTO
case PPARAM, PPARAMOUT:
// The symbol is excluded later from debugging info if its name begins ".autotmp_", but the type is still necessary.
// See bugs #17644 and #17830 and cmd/internal/dwarf/dwarf.go
p := Gins(obj.ATYPE, n, nil)
p.From.Sym = obj.Linklookup(Ctxt, n.Sym.Name, 0)
p.To.Type = obj.TYPE_MEM
p.To.Name = obj.NAME_EXTERN
p.To.Sym = Linksym(ngotype(n))
name = obj.NAME_PARAM
default:
continue
}
}
genssa(ssafn, ptxt, gcargs, gclocals)
ssafn.Free()
a := &obj.Auto{
Asym: obj.Linklookup(Ctxt, n.Sym.Name, 0),
Aoffset: int32(n.Xoffset),
Name: name,
Gotype: Linksym(ngotype(n)),
}
a.Link = fn.Autom
fn.Autom = a
}
}
type symByName []*Sym
......
......@@ -910,9 +910,7 @@ func checkptxt(fn *Node, firstp *obj.Prog) {
if false {
fmt.Printf("analyzing '%v'\n", p)
}
if p.As != obj.ATYPE {
checkprog(fn, p)
}
checkprog(fn, p)
}
}
......
......@@ -25,7 +25,6 @@ const (
//
// The table is formatted for 8-space tabs.
var progtable = [mips.ALAST & obj.AMask]gc.ProgInfo{
obj.ATYPE: {Flags: gc.Pseudo | gc.Skip},
obj.ATEXT: {Flags: gc.Pseudo},
obj.AFUNCDATA: {Flags: gc.Pseudo},
obj.APCDATA: {Flags: gc.Pseudo},
......
......@@ -25,7 +25,6 @@ const (
//
// The table is formatted for 8-space tabs.
var progtable = [mips.ALAST & obj.AMask]gc.ProgInfo{
obj.ATYPE: {Flags: gc.Pseudo | gc.Skip},
obj.ATEXT: {Flags: gc.Pseudo},
obj.AFUNCDATA: {Flags: gc.Pseudo},
obj.APCDATA: {Flags: gc.Pseudo},
......
......@@ -25,7 +25,6 @@ const (
//
// The table is formatted for 8-space tabs.
var progtable = [ppc64.ALAST & obj.AMask]gc.ProgInfo{
obj.ATYPE: {Flags: gc.Pseudo | gc.Skip},
obj.ATEXT: {Flags: gc.Pseudo},
obj.AFUNCDATA: {Flags: gc.Pseudo},
obj.APCDATA: {Flags: gc.Pseudo},
......
......@@ -18,7 +18,6 @@ import (
// As an exception to that rule, we typically write down all the
// size variants of an operation even if we just use a subset.
var progtable = [s390x.ALAST & obj.AMask]gc.ProgInfo{
obj.ATYPE & obj.AMask: {Flags: gc.Pseudo | gc.Skip},
obj.ATEXT & obj.AMask: {Flags: gc.Pseudo},
obj.AFUNCDATA & obj.AMask: {Flags: gc.Pseudo},
obj.APCDATA & obj.AMask: {Flags: gc.Pseudo},
......
......@@ -25,7 +25,6 @@ const (
//
// The table is formatted for 8-space tabs.
var progtable = [x86.ALAST & obj.AMask]gc.ProgInfo{
obj.ATYPE: {Flags: gc.Pseudo | gc.Skip},
obj.ATEXT: {Flags: gc.Pseudo},
obj.AFUNCDATA: {Flags: gc.Pseudo},
obj.APCDATA: {Flags: gc.Pseudo},
......
......@@ -1411,8 +1411,7 @@ func buildop(ctxt *obj.Link) {
AMOVM,
ARFE,
obj.ATEXT,
obj.AUSEFIELD,
obj.ATYPE:
obj.AUSEFIELD:
break
case AADDF:
......
......@@ -290,7 +290,6 @@ const (
APCDATA
ARET
ATEXT
ATYPE
AUNDEF
AUSEFIELD
AVARDEF
......
......@@ -50,30 +50,6 @@ func flushplist(ctxt *Link, freeProgs bool) {
case AEND:
continue
case ATYPE:
// Assume each TYPE instruction describes
// a different local variable or parameter,
// so no dedup.
// Using only the TYPE instructions means
// that we discard location information about local variables
// in C and assembly functions; that information is inferred
// from ordinary references, because there are no TYPE
// instructions there. Without the type information, gdb can't
// use the locations, so we don't bother to save them.
// If something else could use them, we could arrange to
// preserve them.
if curtext == nil {
continue
}
a := new(Auto)
a.Asym = p.From.Sym
a.Aoffset = int32(p.From.Offset)
a.Name = int16(p.From.Name)
a.Gotype = p.To.Sym
a.Link = curtext.Autom
curtext.Autom = a
continue
case ATEXT:
s := p.From.Sym
if s == nil {
......
......@@ -474,7 +474,6 @@ var Anames = []string{
"PCDATA",
"RET",
"TEXT",
"TYPE",
"UNDEF",
"USEFIELD",
"VARDEF",
......
......@@ -1699,7 +1699,6 @@ var optab =
{AXTEST, ynone, Px, [23]uint8{0x0f, 01, 0xd6}},
{AXGETBV, ynone, Pm, [23]uint8{01, 0xd0}},
{obj.AUSEFIELD, ynop, Px, [23]uint8{0, 0}},
{obj.ATYPE, nil, 0, [23]uint8{}},
{obj.AFUNCDATA, yfuncdata, Px, [23]uint8{0, 0}},
{obj.APCDATA, ypcdata, Px, [23]uint8{0, 0}},
{obj.AVARDEF, nil, 0, [23]uint8{}},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment