Skip to content

Commit

Permalink
ssa: checkCFunc in NewFuncEx
Browse files Browse the repository at this point in the history
  • Loading branch information
visualfc committed Jan 6, 2025
1 parent 6c27f49 commit 8a0b8a2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
3 changes: 0 additions & 3 deletions cl/instr.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,9 +351,6 @@ func (p *context) funcOf(fn *ssa.Function) (aFn llssa.Function, pyFn llssa.PyObj
if debugSymbols {
aFn.Inline(llssa.NoInline)
}
if ftype == cFunc {
llssa.CheckCFunc(aFn)
}
}
}
return
Expand Down
4 changes: 4 additions & 0 deletions ssa/decl.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"go/types"
"log"
"strconv"
"strings"

"github.com/goplus/llvm"
)
Expand Down Expand Up @@ -213,6 +214,9 @@ func (p Package) NewFuncEx(name string, sig *types.Signature, bg Background, has
}
ret := newFunction(fn, t, p, p.Prog, hasFreeVars)
p.fns[name] = ret
if bg == InC && !strings.Contains(name, ".") {
checkCFunc(ret)
}
return ret
}

Expand Down
6 changes: 3 additions & 3 deletions ssa/wrapabi.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"github.com/goplus/llvm"
)

func CheckCFunc(fn Function) {
func checkCFunc(fn Function) {
fn._kind |= kindCFunc
if checkWrapAbi(fn.Prog, fn.RawType().(*types.Signature)) {
fn._kind |= kindWrapABI
Expand Down Expand Up @@ -283,12 +283,12 @@ func wrapCallback(b Builder, v Expr) Expr {
param := fn.Param(1)
for i := 0; i < n; i++ {
ptr := b.Load(b.IndexAddr(param, b.Prog.Val(i)))
typ := b.Prog.Type(types.NewPointer(sig.Params().At(i).Type()), InGo)
typ := b.Prog.Type(types.NewPointer(sig.Params().At(i).Type()), InC)
args[i] = b.Load(Expr{ptr.impl, typ})
}
fr := b.Call(v, args...)
if sig.Results().Len() != 0 {
typ := b.Prog.Type(types.NewPointer(sig.Results().At(0).Type()), InGo)
typ := b.Prog.Type(types.NewPointer(sig.Results().At(0).Type()), InC)
b.Store(Expr{fn.Param(0).impl, typ}, fr)
}
b.impl.CreateRetVoid()
Expand Down

0 comments on commit 8a0b8a2

Please sign in to comment.