From 07738e13efb1b78c54fde4e0ac568af59ab11679 Mon Sep 17 00:00:00 2001 From: xushiwei Date: Mon, 27 May 2024 15:49:25 +0800 Subject: [PATCH] AfterInit fix --- cl/_testgo/errors/in.go | 5 ++--- cl/_testgo/errors/out.ll | 2 +- cl/_testgo/struczero/out.ll | 2 +- ssa/package.go | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/cl/_testgo/errors/in.go b/cl/_testgo/errors/in.go index fe7d2c7b..4e73a70c 100644 --- a/cl/_testgo/errors/in.go +++ b/cl/_testgo/errors/in.go @@ -16,8 +16,7 @@ func (e *errorString) Error() string { } func main() { - println("main") err := New("an error") - println("err") - println(err, err.Error()) + println(err) + println(err.Error()) } diff --git a/cl/_testgo/errors/out.ll b/cl/_testgo/errors/out.ll index 15d2af0d..2449b613 100644 --- a/cl/_testgo/errors/out.ll +++ b/cl/_testgo/errors/out.ll @@ -61,7 +61,7 @@ _llgo_0: _llgo_1: ; preds = %_llgo_0 store i1 true, ptr @"main.init$guard", align 1 - call void @"main.init$abi3"() + call void @"main.init$abi"() br label %_llgo_2 _llgo_2: ; preds = %_llgo_1, %_llgo_0 diff --git a/cl/_testgo/struczero/out.ll b/cl/_testgo/struczero/out.ll index 5395f099..2de205da 100644 --- a/cl/_testgo/struczero/out.ll +++ b/cl/_testgo/struczero/out.ll @@ -115,7 +115,7 @@ _llgo_0: _llgo_1: ; preds = %_llgo_0 store i1 true, ptr @"main.init$guard", align 1 call void @"github.com/goplus/llgo/cl/internal/foo.init"() - call void @"main.init$abi3"() + call void @"main.init$abi"() br label %_llgo_2 _llgo_2: ; preds = %_llgo_1, %_llgo_0 diff --git a/ssa/package.go b/ssa/package.go index 6aa5af95..b80d06e9 100644 --- a/ssa/package.go +++ b/ssa/package.go @@ -589,6 +589,7 @@ func (p Package) AfterInit(b Builder, ret BasicBlock) { name := baseName idx := 1 fn := p.NewFunc(name, sigAbiInit, InC) + b.Call(fn.Expr) for { fnb := fn.MakeBody(1) first := fnb.blk @@ -603,7 +604,6 @@ func (p Package) AfterInit(b Builder, ret BasicBlock) { fnb.SetBlockEx(first, AtStart, false) fnb.Call(fn.Expr) } - b.Call(fn.Expr) } if doPyLoadModSyms { p.pyLoadModSyms(b)