ssa: add debug info of function return type
This commit is contained in:
@@ -329,9 +329,12 @@ func (p Function) SetRecover(blk BasicBlock) {
|
|||||||
|
|
||||||
func (p Function) scopeMeta(b diBuilder, pos token.Position) DIScopeMeta {
|
func (p Function) scopeMeta(b diBuilder, pos token.Position) DIScopeMeta {
|
||||||
if p.diFunc == nil {
|
if p.diFunc == nil {
|
||||||
paramTypes := make([]llvm.Metadata, len(p.params))
|
sig := p.Type.raw.Type.(*types.Signature)
|
||||||
|
rt := p.Prog.Type(sig.Results(), InGo)
|
||||||
|
paramTypes := make([]llvm.Metadata, len(p.params)+1)
|
||||||
|
paramTypes[0] = b.diType(rt, pos).ll
|
||||||
for i, t := range p.params {
|
for i, t := range p.params {
|
||||||
paramTypes[i] = b.diType(t, pos).ll
|
paramTypes[i+1] = b.diType(t, pos).ll
|
||||||
}
|
}
|
||||||
diFuncType := b.di.CreateSubroutineType(llvm.DISubroutineType{
|
diFuncType := b.di.CreateSubroutineType(llvm.DISubroutineType{
|
||||||
File: b.file(pos.Filename).ll,
|
File: b.file(pos.Filename).ll,
|
||||||
|
|||||||
28
ssa/di.go
28
ssa/di.go
@@ -128,7 +128,6 @@ func (b diBuilder) createType(name string, ty Type, pos token.Position) DIType {
|
|||||||
Name: name,
|
Name: name,
|
||||||
SizeInBits: b.prog.SizeOf(b.prog.rawType(t)) * 8,
|
SizeInBits: b.prog.SizeOf(b.prog.rawType(t)) * 8,
|
||||||
AlignInBits: uint32(b.prog.sizes.Alignof(t) * 8),
|
AlignInBits: uint32(b.prog.sizes.Alignof(t) * 8),
|
||||||
AddressSpace: 0,
|
|
||||||
})
|
})
|
||||||
return &aDIType{typ}
|
return &aDIType{typ}
|
||||||
}
|
}
|
||||||
@@ -180,6 +179,8 @@ func (b diBuilder) createType(name string, ty Type, pos token.Position) DIType {
|
|||||||
case *types.Map:
|
case *types.Map:
|
||||||
ty := b.prog.rtType("Map")
|
ty := b.prog.rtType("Map")
|
||||||
return b.createMapType(name, ty, pos)
|
return b.createMapType(name, ty, pos)
|
||||||
|
case *types.Tuple:
|
||||||
|
return b.createTupleType(name, ty, pos)
|
||||||
default:
|
default:
|
||||||
panic(fmt.Errorf("can't create debug info of type: %v, %T", ty.RawType(), ty.RawType()))
|
panic(fmt.Errorf("can't create debug info of type: %v, %T", ty.RawType(), ty.RawType()))
|
||||||
}
|
}
|
||||||
@@ -365,9 +366,8 @@ func (b diBuilder) createPointerType(name string, ty Type, pos token.Position) D
|
|||||||
return &aDIType{ll: b.di.CreatePointerType(llvm.DIPointerType{
|
return &aDIType{ll: b.di.CreatePointerType(llvm.DIPointerType{
|
||||||
Name: name,
|
Name: name,
|
||||||
Pointee: b.diType(ty, pos).ll,
|
Pointee: b.diType(ty, pos).ll,
|
||||||
SizeInBits: b.prog.SizeOf(ty) * 8,
|
SizeInBits: b.prog.SizeOf(b.prog.VoidPtr()) * 8,
|
||||||
AlignInBits: uint32(b.prog.sizes.Alignof(ty.RawType())) * 8,
|
AlignInBits: uint32(b.prog.sizes.Alignof(b.prog.VoidPtr().RawType())) * 8,
|
||||||
AddressSpace: 0,
|
|
||||||
})}
|
})}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -421,6 +421,26 @@ func (b diBuilder) createStructType(name string, ty Type, pos token.Position) (r
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (b diBuilder) createTupleType(name string, ty Type, pos token.Position) DIType {
|
||||||
|
tupleType := ty.RawType().(*types.Tuple)
|
||||||
|
if tupleType.Len() == 0 {
|
||||||
|
return &aDIType{}
|
||||||
|
}
|
||||||
|
if tupleType.Len() == 1 {
|
||||||
|
t := b.prog.rawType(tupleType.At(0).Type())
|
||||||
|
return b.diType(t, pos)
|
||||||
|
}
|
||||||
|
return b.doCreateStructType(name, ty, pos, func(ditStruct DIType) []llvm.Metadata {
|
||||||
|
fields := make([]llvm.Metadata, ty.RawType().(*types.Tuple).Len())
|
||||||
|
for i := 0; i < ty.RawType().(*types.Tuple).Len(); i++ {
|
||||||
|
field := ty.RawType().(*types.Tuple).At(i)
|
||||||
|
tyField := b.prog.rawType(field.Type())
|
||||||
|
fields[i] = b.createMemberTypeEx(field.Name(), ty, tyField, i, pos, 0)
|
||||||
|
}
|
||||||
|
return fields
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func (b diBuilder) createFuncPtrType(name string, ty Type, pos token.Position) DIType {
|
func (b diBuilder) createFuncPtrType(name string, ty Type, pos token.Position) DIType {
|
||||||
ptr := b.prog.VoidPtr()
|
ptr := b.prog.VoidPtr()
|
||||||
return &aDIType{ll: b.di.CreatePointerType(llvm.DIPointerType{
|
return &aDIType{ll: b.di.CreatePointerType(llvm.DIPointerType{
|
||||||
|
|||||||
@@ -109,6 +109,8 @@ func (p goTypes) cvtType(typ types.Type) (raw types.Type, cvt bool) {
|
|||||||
if elem, cvt := p.cvtType(t.Elem()); cvt {
|
if elem, cvt := p.cvtType(t.Elem()); cvt {
|
||||||
return types.NewChan(t.Dir(), elem), true
|
return types.NewChan(t.Dir(), elem), true
|
||||||
}
|
}
|
||||||
|
case *types.Tuple:
|
||||||
|
return p.cvtTuple(t)
|
||||||
default:
|
default:
|
||||||
panic(fmt.Sprintf("cvtType: unexpected type - %T", typ))
|
panic(fmt.Sprintf("cvtType: unexpected type - %T", typ))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user