We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
package main func Foo(s string) int { return len(s) } func Test() { for i := 0; i < 1000000; i++ { _ = Foo("hello") } } func main() { Test() }
Run with:
$ llgo build -o string . && ./string # github.com/goplus/llgo/_demo/string [1] 69802 segmentation fault ./string
Generated code by llgen:
llgen
define void @main.Test() { _llgo_0: br label %_llgo_3 _llgo_1: ; preds = %_llgo_3 %0 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8 %1 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %0, i32 0, i32 0 store ptr @0, ptr %1, align 8 %2 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %0, i32 0, i32 1 store i64 5, ptr %2, align 4 %3 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %0, align 8 %4 = call i64 @main.Foo(%"github.com/goplus/llgo/internal/runtime.String" %3) %5 = add i64 %6, 1 br label %_llgo_3 _llgo_2: ; preds = %_llgo_3 ret void _llgo_3: ; preds = %_llgo_1, %_llgo_0 %6 = phi i64 [ 0, %_llgo_0 ], [ %5, %_llgo_1 ] %7 = icmp slt i64 %6, 1000000 br i1 %7, label %_llgo_1, label %_llgo_2 }
Allocating memory by alloca on the stack in each iteration will exhaust the stack.
alloca
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Run with:
Generated code by
llgen
:Allocating memory by
alloca
on the stack in each iteration will exhaust the stack.The text was updated successfully, but these errors were encountered: