AfterInit bugfix: add param Builder
This commit is contained in:
@@ -110,6 +110,7 @@ _llgo_2: ; preds = %_llgo_3, %_llgo_1
|
||||
%47 = extractvalue { { i64 }, i1 } %45, 1
|
||||
br i1 %47, label %_llgo_4, label %_llgo_6
|
||||
|
||||
|
||||
_llgo_3: ; preds = %_llgo_0
|
||||
%48 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8
|
||||
%49 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %48, i32 0, i32 0
|
||||
|
||||
@@ -238,6 +238,13 @@ func newParams(fn Type, prog Program) (params []Type, hasVArg bool) {
|
||||
return
|
||||
}
|
||||
|
||||
/*
|
||||
// Name returns the function's name.
|
||||
func (p Function) Name() string {
|
||||
return p.impl.Name()
|
||||
}
|
||||
*/
|
||||
|
||||
// Params returns the function's ith parameter.
|
||||
func (p Function) Param(i int) Expr {
|
||||
i += p.base // skip if hasFreeVars
|
||||
|
||||
@@ -20,6 +20,7 @@ import (
|
||||
"go/token"
|
||||
"go/types"
|
||||
"log"
|
||||
"unsafe"
|
||||
|
||||
"github.com/goplus/llgo/ssa/abi"
|
||||
"github.com/goplus/llvm"
|
||||
@@ -44,7 +45,8 @@ func (b Builder) abiStruct(t *types.Struct) Expr {
|
||||
g = pkg.doNewVar(name, prog.AbiTypePtrPtr())
|
||||
g.Init(prog.Null(g.Type))
|
||||
g.impl.SetLinkage(llvm.LinkOnceAnyLinkage)
|
||||
pkg.ainits = append(pkg.ainits, func() {
|
||||
pkg.ainits = append(pkg.ainits, func(param unsafe.Pointer) {
|
||||
b := Builder(param)
|
||||
tabi := b.structOf(t)
|
||||
b.Store(g.Expr, tabi)
|
||||
})
|
||||
|
||||
@@ -19,6 +19,7 @@ package ssa
|
||||
import (
|
||||
"go/token"
|
||||
"go/types"
|
||||
"unsafe"
|
||||
|
||||
"github.com/goplus/llgo/ssa/abi"
|
||||
"github.com/goplus/llvm"
|
||||
@@ -490,7 +491,7 @@ func (p Program) Uint64() Type {
|
||||
type aPackage struct {
|
||||
mod llvm.Module
|
||||
abi abi.Builder
|
||||
ainits []func()
|
||||
ainits []func(b unsafe.Pointer) // b Builder
|
||||
vars map[string]Global
|
||||
fns map[string]Function
|
||||
stubs map[string]Function
|
||||
@@ -558,8 +559,8 @@ func (p Package) AfterInit(b Builder, ret BasicBlock) {
|
||||
doAfterInit := len(p.ainits) > 0 || p.pyHasModSyms()
|
||||
if doAfterInit {
|
||||
b.SetBlockEx(ret, afterInit)
|
||||
for _, afterInit := range p.ainits {
|
||||
afterInit()
|
||||
for _, fnAfterInit := range p.ainits {
|
||||
fnAfterInit(unsafe.Pointer(b))
|
||||
}
|
||||
p.pyLoadModSyms(b)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user