Files
c3c/test/test_suite/functions/func_ptr_null.check.c3t
2024-10-26 18:41:47 +02:00

44 lines
1.1 KiB
Plaintext

// #target: macos-aarch64
// #safe: yes
module test;
def TestFn = fn void();
fn int main()
{
TestFn foo;
foo();
return 0;
}
/* #expect: test.ll
define i32 @main() #0 {
entry:
%foo = alloca ptr, align 8
%taddr = alloca %"char[]", align 8
%taddr1 = alloca %"char[]", align 8
%taddr2 = alloca %"char[]", align 8
store ptr null, ptr %foo, align 8
%0 = load ptr, ptr %foo, align 8
%checknull = icmp eq ptr %0, null
%1 = call i1 @llvm.expect.i1(i1 %checknull, i1 false)
br i1 %1, label %panic, label %checkok
checkok: ; preds = %entry
call void %0()
ret i32 0
panic: ; preds = %entry
store %"char[]" { ptr @.panic_msg, i64 46 }, ptr %taddr, align 8
%2 = load [2 x i64], ptr %taddr, align 8
store %"char[]" { ptr @.file, i64 22 }, ptr %taddr1, align 8
%3 = load [2 x i64], ptr %taddr1, align 8
store %"char[]" { ptr @.func, i64 4 }, ptr %taddr2, align 8
%4 = load [2 x i64], ptr %taddr2, align 8
%5 = load ptr, ptr @std.core.builtin.panic, align 8
call void %5([2 x i64] %2, [2 x i64] %3, [2 x i64] %4, i32 7)
unreachable
}