mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 20:11:17 +00:00
48 lines
1.1 KiB
Plaintext
48 lines
1.1 KiB
Plaintext
// #target: macos-x64
|
|
// #safe: yes
|
|
module testing;
|
|
import std::io;
|
|
|
|
const FOO = (Foo[2]){ {11}, {22} };
|
|
|
|
struct Foo
|
|
{
|
|
int x;
|
|
}
|
|
|
|
fn void main()
|
|
{
|
|
for (usz i = 0; i < 20; i++)
|
|
{
|
|
int x = FOO[i].x;
|
|
}
|
|
}
|
|
|
|
/* #expect: testing.ll
|
|
|
|
loop.cond: ; preds = %checkok, %entry
|
|
%0 = load i64, ptr %i, align 8
|
|
%gt = icmp ugt i64 20, %0
|
|
br i1 %gt, label %loop.body, label %loop.exit
|
|
|
|
loop.body: ; preds = %loop.cond
|
|
%1 = load i64, ptr %i, align 8
|
|
%ge = icmp uge i64 %1, 2
|
|
%2 = call i1 @llvm.expect.i1(i1 %ge, i1 false)
|
|
br i1 %2, label %panic, label %checkok
|
|
|
|
checkok: ; preds = %loop.body
|
|
%ptroffset = getelementptr inbounds [4 x i8], ptr @testing.FOO, i64 %1
|
|
%3 = load i32, ptr %ptroffset, align 4
|
|
store i32 %3, ptr %x, align 4
|
|
%4 = load i64, ptr %i, align 8
|
|
%add = add i64 %4, 1
|
|
store i64 %add, ptr %i, align 8
|
|
br label %loop.cond
|
|
|
|
loop.exit: ; preds = %loop.cond
|
|
ret void
|
|
|
|
panic: ; preds = %loop.body
|
|
store i64 2, ptr %taddr, align 8
|