@@ -389,7 +389,7 @@ func (c *compilerContext) getLLVMType(goType types.Type) llvm.Type {
389
389
// makeLLVMType creates a LLVM type for a Go type. Don't call this, use
390
390
// getLLVMType instead.
391
391
func (c * compilerContext ) makeLLVMType (goType types.Type ) llvm.Type {
392
- switch typ := goType .(type ) {
392
+ switch typ := types . Unalias ( goType ) .(type ) {
393
393
case * types.Array :
394
394
elemType := c .getLLVMType (typ .Elem ())
395
395
return llvm .ArrayType (elemType , int (typ .Len ()))
@@ -497,6 +497,21 @@ func (c *compilerContext) createDIType(typ types.Type) llvm.Metadata {
497
497
llvmType := c .getLLVMType (typ )
498
498
sizeInBytes := c .targetData .TypeAllocSize (llvmType )
499
499
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
500
515
case * types.Array :
501
516
return c .dibuilder .CreateArrayType (llvm.DIArrayType {
502
517
SizeInBits : sizeInBytes * 8 ,
@@ -859,6 +874,11 @@ func (c *compilerContext) createPackage(irbuilder llvm.Builder, pkg *ssa.Package
859
874
// Interfaces don't have concrete methods.
860
875
continue
861
876
}
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
+ }
862
882
863
883
// Named type. We should make sure all methods are created.
864
884
// This includes both functions with pointer receivers and those
0 commit comments