From bd3f44e4ffe54e9cf841ebc8356e403bb38436bd Mon Sep 17 00:00:00 2001 From: Keith Randall Date: Tue, 2 May 2023 17:37:00 +0000 Subject: cmd/compile: constant-fold loads from constant dictionaries and types Retrying the original CL with a small modification. The original CL did not handle the case of reading an itab out of a dictionary correctly. When we read an itab out of a dictionary, we must treat the type inside that itab as maybe being put in an interface. Original CL: 486895 Revert CL: 490156 Change-Id: Id2dc1699d184cd8c63dac83986a70b60b4e6cbd7 Reviewed-on: https://go-review.googlesource.com/c/go/+/491495 Reviewed-by: Matthew Dempsky Reviewed-by: Cuong Manh Le Run-TryBot: Keith Randall Reviewed-by: Keith Randall TryBot-Result: Gopher Robot --- src/cmd/compile/internal/reflectdata/reflect.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/cmd/compile/internal/reflectdata') diff --git a/src/cmd/compile/internal/reflectdata/reflect.go b/src/cmd/compile/internal/reflectdata/reflect.go index eeda3cb4e2..ff2eb1aba9 100644 --- a/src/cmd/compile/internal/reflectdata/reflect.go +++ b/src/cmd/compile/internal/reflectdata/reflect.go @@ -835,7 +835,14 @@ func TypeLinksymLookup(name string) *obj.LSym { } func TypeLinksym(t *types.Type) *obj.LSym { - return TypeSym(t).Linksym() + lsym := TypeSym(t).Linksym() + signatmu.Lock() + if lsym.Extra == nil { + ti := lsym.NewTypeInfo() + ti.Type = t + } + signatmu.Unlock() + return lsym } // Deprecated: Use TypePtrAt instead. @@ -1869,7 +1876,9 @@ func MarkTypeUsedInInterface(t *types.Type, from *obj.LSym) { // Shape types shouldn't be put in interfaces, so we shouldn't ever get here. base.Fatalf("shape types have no methods %+v", t) } - tsym := TypeLinksym(t) + MarkTypeSymUsedInInterface(TypeLinksym(t), from) +} +func MarkTypeSymUsedInInterface(tsym *obj.LSym, from *obj.LSym) { // Emit a marker relocation. The linker will know the type is converted // to an interface if "from" is reachable. r := obj.Addrel(from) -- cgit v1.3