Skip to content

Commit 204c618

Browse files
committed
cmd/link: eliminate a couple of unused DWARF attrs
The linker's DWARF generation occasionally computes and attaches an attribute X to a type even though the type's abbrev doesn't have the specified attr. For example, the DW_TAG_subroutine_type abbrev entry has no type attribute, but a type attr is given to it (wasting memory). Similarly there are some places where a byte size attr is added to a DIE whose abbrev lacks that attr. This patch trims away a few of these not-needed attrs, saving some very tiny amount of memory. Updates #26186 Change-Id: I69e853df468ac54b07772a614b4106d7c4dae01d Reviewed-on: https://go-review.googlesource.com/123296 Reviewed-by: Heschi Kreinick <[email protected]> Run-TryBot: Heschi Kreinick <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent ebdba42 commit 204c618

File tree

1 file changed

+0
-3
lines changed

1 file changed

+0
-3
lines changed

src/cmd/link/internal/ld/dwarf.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,6 @@ func newtype(ctxt *Link, gotype *sym.Symbol) *dwarf.DWDie {
451451

452452
case objabi.KindChan:
453453
die = newdie(ctxt, &dwtypes, dwarf.DW_ABRV_CHANTYPE, name, 0)
454-
newattr(die, dwarf.DW_AT_byte_size, dwarf.DW_CLS_CONSTANT, bytesize, 0)
455454
s := decodetypeChanElem(ctxt.Arch, gotype)
456455
newrefattr(die, dwarf.DW_AT_go_elem, defgotype(ctxt, s))
457456
// Save elem type for synthesizechantypes. We could synthesize here
@@ -462,7 +461,6 @@ func newtype(ctxt *Link, gotype *sym.Symbol) *dwarf.DWDie {
462461
die = newdie(ctxt, &dwtypes, dwarf.DW_ABRV_FUNCTYPE, name, 0)
463462
newattr(die, dwarf.DW_AT_byte_size, dwarf.DW_CLS_CONSTANT, bytesize, 0)
464463
dotypedef(ctxt, &dwtypes, name, die)
465-
newrefattr(die, dwarf.DW_AT_type, mustFind(ctxt, "void"))
466464
nfields := decodetypeFuncInCount(ctxt.Arch, gotype)
467465
for i := 0; i < nfields; i++ {
468466
s := decodetypeFuncInType(ctxt.Arch, gotype, i)
@@ -483,7 +481,6 @@ func newtype(ctxt *Link, gotype *sym.Symbol) *dwarf.DWDie {
483481
case objabi.KindInterface:
484482
die = newdie(ctxt, &dwtypes, dwarf.DW_ABRV_IFACETYPE, name, 0)
485483
dotypedef(ctxt, &dwtypes, name, die)
486-
newattr(die, dwarf.DW_AT_byte_size, dwarf.DW_CLS_CONSTANT, bytesize, 0)
487484
nfields := int(decodetypeIfaceMethodCount(ctxt.Arch, gotype))
488485
var s *sym.Symbol
489486
if nfields == 0 {

0 commit comments

Comments
 (0)