mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
37 lines
527 B
C
37 lines
527 B
C
|
|
fn int foo()
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
fn void test()
|
|
{
|
|
int x = foo();
|
|
if (x > 0) return;
|
|
@unreachable();
|
|
x++;
|
|
}
|
|
|
|
|
|
// #expect: unreachable.ll
|
|
|
|
%x = alloca i32
|
|
%0 = call i32 @unreachable.foo()
|
|
store i32 %0, i32* %x
|
|
%1 = load i32, i32* %x
|
|
%gt = icmp sgt i32 %1, 0
|
|
br i1 %gt, label %if.then, label %if.exit
|
|
|
|
if.then:
|
|
ret void
|
|
|
|
if.exit:
|
|
call void @llvm.trap()
|
|
unreachable
|
|
|
|
unreachable_block:
|
|
%2 = load i32, i32* %x
|
|
%add = add i32 %2, 1
|
|
store i32 %add, i32* %x
|
|
ret void
|