ssa: fix named func call

This commit is contained in:
visualfc
2024-07-04 10:53:33 +08:00
parent fa53135c8a
commit d52d62badb
4 changed files with 141 additions and 5 deletions

View File

@@ -689,12 +689,14 @@ func (b Builder) ChangeType(t Type, x Expr) (ret Expr) {
log.Printf("ChangeType %v, %v\n", t.RawType(), x.impl)
}
typ := t.raw.Type
switch typ.(type) {
switch t.kind {
case vkClosure:
ret.impl = checkExpr(x, typ.Underlying(), b).impl
default:
ret.impl = llvm.CreateBitCast(b.impl, x.impl, t.ll)
ret.Type = b.Prog.rawType(typ)
return
ret.impl = x.impl
}
ret.Type = t
return
}
// The Convert instruction yields the conversion of value X to type

View File

@@ -486,7 +486,11 @@ func (p Program) toNamed(raw *types.Named) Type {
switch t := raw.Underlying().(type) {
case *types.Struct:
name := p.llvmNameOf(raw)
return &aType{p.toLLVMNamedStruct(name, t), rawType{raw}, vkStruct}
kind := vkStruct
if isClosure(t) {
kind = vkClosure
}
return &aType{p.toLLVMNamedStruct(name, t), rawType{raw}, kind}
default:
typ := p.rawType(t)
return &aType{typ.ll, rawType{raw}, typ.kind}