Loop return if

This commit is contained in:
David Gonzalez Martin 2024-06-06 22:10:03 -06:00
parent 663e4e8a1d
commit 110b1496ef
2 changed files with 22 additions and 1 deletions

View File

@ -3120,7 +3120,7 @@ fn worker_thread(thread_index: u32, cpu_count: *u32) void {
} }
}, },
.llvm_generate_ir => { .llvm_generate_ir => {
if (thread.functions.length > 0) { if (thread.functions.length > 0 or thread.global_variables.length > 0) {
const context = LLVM.Context.create(); const context = LLVM.Context.create();
const module_name: []const u8 = "thread"; const module_name: []const u8 = "thread";
const module = LLVM.Module.create(module_name.ptr, module_name.len, context); const module = LLVM.Module.create(module_name.ptr, module_name.len, context);

View File

@ -0,0 +1,21 @@
>m: s32 = 2;
>n: s32 = 6;
fn foo(arg: s32) s32 {
>i: s32 = 0;
loop (i < arg) {
if (i > 2) {
return i;
}
i += 1;
}
return 15;
}
fn[cc(.c)] main[export]() s32 {
>a = foo(n);
>b = foo(n);
return (a - b) + (a - (m + 1)) + (b - (m + 1));
}