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