@@ -389,7 +389,7 @@ func (c *compilerContext) getLLVMType(goType types.Type) llvm.Type {
389389// makeLLVMType creates a LLVM type for a Go type. Don't call this, use
390390// getLLVMType instead.
391391func (c * compilerContext ) makeLLVMType (goType types.Type ) llvm.Type {
392- switch typ := goType .(type ) {
392+ switch typ := types . Unalias ( goType ) .(type ) {
393393 case * types.Array :
394394 elemType := c .getLLVMType (typ .Elem ())
395395 return llvm .ArrayType (elemType , int (typ .Len ()))
@@ -497,6 +497,21 @@ func (c *compilerContext) createDIType(typ types.Type) llvm.Metadata {
497497 llvmType := c .getLLVMType (typ )
498498 sizeInBytes := c .targetData .TypeAllocSize (llvmType )
499499 switch typ := typ .(type ) {
500+ case * types.Alias :
501+ // Implement types.Alias just like types.Named: by treating them like a
502+ // C typedef.
503+ temporaryMDNode := c .dibuilder .CreateReplaceableCompositeType (llvm.Metadata {}, llvm.DIReplaceableCompositeType {
504+ Tag : dwarf .TagTypedef ,
505+ SizeInBits : sizeInBytes * 8 ,
506+ AlignInBits : uint32 (c .targetData .ABITypeAlignment (llvmType )) * 8 ,
507+ })
508+ c .ditypes [typ ] = temporaryMDNode
509+ md := c .dibuilder .CreateTypedef (llvm.DITypedef {
510+ Type : c .getDIType (types .Unalias (typ )), // TODO: use typ.Rhs in Go 1.23
511+ Name : typ .String (),
512+ })
513+ temporaryMDNode .ReplaceAllUsesWith (md )
514+ return md
500515 case * types.Array :
501516 return c .dibuilder .CreateArrayType (llvm.DIArrayType {
502517 SizeInBits : sizeInBytes * 8 ,
@@ -859,6 +874,11 @@ func (c *compilerContext) createPackage(irbuilder llvm.Builder, pkg *ssa.Package
859874 // Interfaces don't have concrete methods.
860875 continue
861876 }
877+ if _ , isalias := member .Type ().(* types.Alias ); isalias {
878+ // Aliases don't need to be redefined, since they just refer to
879+ // an already existing type whose methods will be defined.
880+ continue
881+ }
862882
863883 // Named type. We should make sure all methods are created.
864884 // This includes both functions with pointer receivers and those
0 commit comments