deferInit bugfix

This commit is contained in:
xushiwei
2024-06-03 01:32:25 +08:00
parent 56a5a7d72e
commit 2c799a8ccf
6 changed files with 63 additions and 95 deletions

View File

@@ -163,7 +163,7 @@ func (p Program) tyDeferFunc() *types.Signature {
}
*/
func (p Package) deferInit(b Builder) {
func (p Package) deferInit() {
keyVar := p.VarOf(deferKey)
if keyVar == nil {
return
@@ -173,6 +173,7 @@ func (p Package) deferInit(b Builder) {
keyVar.Init(keyNil)
keyVar.impl.SetLinkage(llvm.LinkOnceAnyLinkage)
b := p.afterBuilder()
eq := b.BinOp(token.EQL, b.Load(keyVar.Expr), keyNil)
b.IfThen(eq, func() {
b.pthreadKeyCreate(keyVar.Expr, prog.Null(prog.VoidPtr()))