Merge pull request #218 from birth-software/loop-return-if

Loop return if
This commit is contained in:
David 2024-06-06 22:12:50 -06:00 committed by GitHub
commit a86f990a5f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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 => {
if (thread.functions.length > 0) {
if (thread.functions.length > 0 or thread.global_variables.length > 0) {
const context = LLVM.Context.create();
const module_name: []const u8 = "thread";
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));
}