Index: llgo/trunk/irgen/typemap.go =================================================================== --- llgo/trunk/irgen/typemap.go +++ llgo/trunk/irgen/typemap.go @@ -659,21 +659,25 @@ return b.String() } - pkg := f.Pkg - var pkgobj *types.Package - if pkg != nil { - pkgobj = pkg.Object - } else if f.Signature.Recv() != nil { - pkgobj = f.Signature.Recv().Pkg() - } else { + // Synthetic bound and thunk functions are special cases; they can only be + // distinguished using private data that is only exposed via String(). + if strings.HasSuffix(f.Name(), "$bound") || strings.HasSuffix(f.Name(), "$thunk") { b.WriteString(f.String()) return b.String() } + var pkg *types.Package + if f.Pkg != nil { + pkg = f.Pkg.Object + } else if !f.Object().Exported() { + pkg = f.Object().Pkg() + } + if pkg != nil { - ctx.manglePackagePath(pkgobj.Path(), &b) + ctx.manglePackagePath(pkg.Path(), &b) b.WriteRune('.') } + if f.Signature.Recv() == nil && f.Name() == "init" { b.WriteString(".import") } else { Index: llgo/trunk/test/irgen/Inputs/mangling-synthetic-p.go =================================================================== --- llgo/trunk/test/irgen/Inputs/mangling-synthetic-p.go +++ llgo/trunk/test/irgen/Inputs/mangling-synthetic-p.go @@ -0,0 +1,4 @@ +package p + +type U struct{} +func (U) f() Index: llgo/trunk/test/irgen/mangling-dot.go =================================================================== --- llgo/trunk/test/irgen/mangling-dot.go +++ llgo/trunk/test/irgen/mangling-dot.go @@ -0,0 +1,7 @@ +// RUN: llgo -fgo-pkgpath=llvm.org/llvm -S -emit-llvm -o - %s | FileCheck %s + +package llvm + +// CHECK: @llvm_org_llvm.F +func F() { +} Index: llgo/trunk/test/irgen/mangling-synthetic.go =================================================================== --- llgo/trunk/test/irgen/mangling-synthetic.go +++ llgo/trunk/test/irgen/mangling-synthetic.go @@ -0,0 +1,14 @@ +// RUN: llgo -fgo-pkgpath=p -c -o %T/p.o %S/Inputs/mangling-synthetic-p.go +// RUN: llgo -fgo-pkgpath=q -I %T -S -emit-llvm -o - %s | FileCheck %s + +package q + +import "p" + +// CHECK-DAG: define linkonce_odr void @p.f.N3_q.T(i8*) +// CHECK-DAG: define linkonce_odr void @p.f.pN3_q.T(i8*) +type T struct { p.U } + +// CHECK-DAG: declare void @q.f.N3_q.T(i8*) +// CHECK-DAG: define linkonce_odr void @q.f.pN3_q.T(i8*) +func (T) f() Index: llgo/trunk/test/irgen/mangling.go =================================================================== --- llgo/trunk/test/irgen/mangling.go +++ llgo/trunk/test/irgen/mangling.go @@ -1,7 +0,0 @@ -// RUN: llgo -fgo-pkgpath=llvm.org/llvm -S -emit-llvm -o - %s | FileCheck %s - -package llvm - -// CHECK: @llvm_org_llvm.F -func F() { -}