closureStub: SetTailCall

This commit is contained in:
xushiwei
2024-05-06 16:40:52 +08:00
parent 1e075d4830
commit cffb5e9539
4 changed files with 4 additions and 3 deletions

View File

@@ -57,7 +57,7 @@ declare void @"github.com/goplus/llgo/internal/runtime.init"()
define linkonce void @__llgo_stub.main.print(ptr %0, ptr %1) {
_llgo_0:
call void @main.print(ptr %1)
tail call void @main.print(ptr %1)
ret void
}

View File

@@ -56,7 +56,7 @@ _llgo_0:
define linkonce void @"__llgo_stub.main.main$1"(ptr %0, i64 %1, i64 %2) {
_llgo_0:
call void @"main.main$1"(i64 %1, i64 %2)
tail call void @"main.main$1"(i64 %1, i64 %2)
ret void
}

View File

@@ -165,7 +165,7 @@ declare i32 @rand()
define linkonce i32 @__llgo_stub.rand(ptr %0) {
_llgo_0:
%1 = call i32 @rand()
%1 = tail call i32 @rand()
ret i32 %1
}

View File

@@ -388,6 +388,7 @@ func (p Package) closureStub(b Builder, t *types.Struct, v Expr) Expr {
}
b := fn.MakeBody(1)
call := b.Call(v, args...)
call.impl.SetTailCall(true)
switch nret {
case 0:
b.impl.CreateRetVoid()