From 0bbb54a02d38d067b9a39d85cfc425f0ddc2962e Mon Sep 17 00:00:00 2001 From: Alessandro Arzilli Date: Wed, 17 May 2023 11:35:52 +0200 Subject: [PATCH] cmd/link: add ReflectMethod flag to -dumpdep output Adds ReflectMethod flag to the output of -dumpdep. Fixes #60221 Change-Id: I631d72ee21b819a3a629780317ff4d962cc121e0 Reviewed-on: https://go-review.googlesource.com/c/go/+/495715 TryBot-Result: Gopher Robot Reviewed-by: Cherry Mui Run-TryBot: Alessandro Arzilli Reviewed-by: Heschi Kreinick --- src/cmd/link/internal/ld/deadcode.go | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/cmd/link/internal/ld/deadcode.go b/src/cmd/link/internal/ld/deadcode.go index e7028d3b544..c0969b25b01 100644 --- a/src/cmd/link/internal/ld/deadcode.go +++ b/src/cmd/link/internal/ld/deadcode.go @@ -325,15 +325,11 @@ func (d *deadcodePass) mark(symIdx, parent loader.Sym) { if *flagDumpDep { to := d.ldr.SymName(symIdx) if to != "" { - if d.ldr.AttrUsedInIface(symIdx) { - to += " " - } + to = d.dumpDepAddFlags(to, symIdx) from := "_" if parent != 0 { from = d.ldr.SymName(parent) - if d.ldr.AttrUsedInIface(parent) { - from += " " - } + from = d.dumpDepAddFlags(from, parent) } fmt.Printf("%s -> %s\n", from, to) } @@ -341,6 +337,20 @@ func (d *deadcodePass) mark(symIdx, parent loader.Sym) { } } +func (d *deadcodePass) dumpDepAddFlags(name string, symIdx loader.Sym) string { + var flags strings.Builder + if d.ldr.AttrUsedInIface(symIdx) { + flags.WriteString("") + } + if d.ldr.IsReflectMethod(symIdx) { + flags.WriteString("") + } + if flags.Len() > 0 { + return name + " " + flags.String() + } + return name +} + func (d *deadcodePass) markMethod(m methodref) { relocs := d.ldr.Relocs(m.src) d.mark(relocs.At(m.r).Sym(), m.src)