llgo/ssa: pkg.PyLoadModSyms (source code stablility)
This commit is contained in:
@@ -8,9 +8,9 @@ source_filename = "main"
|
||||
@__llgo_py.builtins.print = linkonce global ptr null
|
||||
@__llgo_py.builtins.iter = linkonce global ptr null
|
||||
@__llgo_py.builtins = external global ptr
|
||||
@0 = private unnamed_addr constant [4 x i8] c"max\00", align 1
|
||||
@1 = private unnamed_addr constant [6 x i8] c"print\00", align 1
|
||||
@2 = private unnamed_addr constant [5 x i8] c"iter\00", align 1
|
||||
@0 = private unnamed_addr constant [5 x i8] c"iter\00", align 1
|
||||
@1 = private unnamed_addr constant [4 x i8] c"max\00", align 1
|
||||
@2 = private unnamed_addr constant [6 x i8] c"print\00", align 1
|
||||
|
||||
define void @main.init() {
|
||||
_llgo_0:
|
||||
@@ -21,7 +21,7 @@ _llgo_1: ; preds = %_llgo_0
|
||||
store i1 true, ptr @"main.init$guard", align 1
|
||||
call void @"github.com/goplus/llgo/py/std.init"()
|
||||
%1 = load ptr, ptr @__llgo_py.builtins, align 8
|
||||
call void (ptr, ...) @llgoLoadPyModSyms(ptr %1, ptr @0, ptr @__llgo_py.builtins.max, ptr @1, ptr @__llgo_py.builtins.print, ptr @2, ptr @__llgo_py.builtins.iter, ptr null)
|
||||
call void (ptr, ...) @llgoLoadPyModSyms(ptr %1, ptr @0, ptr @__llgo_py.builtins.iter, ptr @1, ptr @__llgo_py.builtins.max, ptr @2, ptr @__llgo_py.builtins.print, ptr null)
|
||||
br label %_llgo_2
|
||||
|
||||
_llgo_2: ; preds = %_llgo_1, %_llgo_0
|
||||
|
||||
@@ -339,13 +339,6 @@ func (p *context) funcOf(fn *ssa.Function) (aFn llssa.Function, pyFn llssa.PyObj
|
||||
return
|
||||
}
|
||||
|
||||
func modOf(name string) string {
|
||||
if pos := strings.LastIndexByte(name, '.'); pos > 0 {
|
||||
return name[:pos]
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (p *context) compileBlock(b llssa.Builder, block *ssa.BasicBlock, n int, doMainInit, doModInit bool) llssa.BasicBlock {
|
||||
var last int
|
||||
var pyModInit bool
|
||||
@@ -361,26 +354,7 @@ func (p *context) compileBlock(b llssa.Builder, block *ssa.BasicBlock, n int, do
|
||||
} else {
|
||||
// TODO(xsw): confirm pyMod don't need to call LoadPyModSyms
|
||||
p.inits = append(p.inits, func() {
|
||||
if objs := pkg.PyObjs(); len(objs) > 0 {
|
||||
mods := make(map[string][]llssa.PyObjRef)
|
||||
for name, obj := range objs {
|
||||
modName := modOf(name)
|
||||
mods[modName] = append(mods[modName], obj)
|
||||
}
|
||||
|
||||
// sort by module name
|
||||
modNames := make([]string, 0, len(mods))
|
||||
for modName := range mods {
|
||||
modNames = append(modNames, modName)
|
||||
}
|
||||
sort.Strings(modNames)
|
||||
|
||||
b.SetBlockEx(ret, llssa.AfterInit)
|
||||
for _, modName := range modNames {
|
||||
objs := mods[modName]
|
||||
b.PyLoadModSyms(modName, objs...)
|
||||
}
|
||||
}
|
||||
pkg.PyLoadModSyms(b, ret)
|
||||
})
|
||||
}
|
||||
} else if doMainInit {
|
||||
|
||||
Reference in New Issue
Block a user