Files
c3c/test/test_suite/debug_symbols/defer_macro.c3t

732 lines
37 KiB
C

// #target: macos-x64
// #debuginfo: yes
module test;
import foo;
import attach;
import std::io;
fn void foo(int x)
{
int! a = x;
while (try a)
{
a = 2;
}
}
fn int main(String[] args) {
// Case 1: Jump to create_foo
Foo* asdf = create_foo(attach::to_scope(), {.flag1 = true});
// Case 2: Ternary jump
test(args.len != 0 ? foo::BLACK : foo::WHITE);
test2();
return 0;
}
struct Foo {
void* asdf;
}
fn Foo* create_foo(Attach_Arg attach, Box_Flags flags, String name = {}) {
return mem::new(Foo);
}
bitstruct Box_Flags : ulong {
bool flag1;
}
fn Foo* test(Color color) {
io::printn(color);
return null;
}
fn void* test2() {
// Case 3: Trailing macro body exit jump
@scratch(; Arena* scratch) {
void* asdf;
return asdf;
};
}
module foo;
import std::io;
enum ID_Type : char {
NONE,
UNIQUE,
}
struct Id {
ulong value;
ID_Type type;
}
macro Id make(type, value) {
return Id {.type = type, .value = value};
}
macro Id unique() {
static char x;
return make(ID_Type.UNIQUE, (ulong)&x);
}
distinct Color = float[<4>];
const Color BLACK = {0, 0, 0, 1};
const Color WHITE = {1, 1, 1, 1};
struct Arena {
usz cursor;
}
struct Arena_Cursor {
Arena* arena;
usz cursor;
}
fn void rewind(Arena* arena, usz pos) @export("arena_rewind") {
arena.cursor = pos;
}
fn Arena_Cursor get_cursor(Arena* arena) @inline => Arena_Cursor {arena, arena.cursor};
fn void restore_cursor(Arena_Cursor cursor) @inline => rewind(cursor.arena, cursor.cursor);
fn Arena_Cursor scratch_begin(Arena*[] conflicts) @export("arena_scratch_begin") {
static Arena scratch_arena;
Arena* arena = &scratch_arena;
return arena ? get_cursor(arena) : Arena_Cursor {};
}
fn void scratch_end(Arena_Cursor cursor) @inline @export("arena_scratch_end") => restore_cursor(cursor);
macro void @scratch(Arena*... conflicts; @body(Arena* arena)) @builtin {
Arena_Cursor scratch = scratch_begin(conflicts);
defer scratch_end(scratch);
@body(scratch.arena);
}
module attach;
enum Attach_Arg_Kind {
TOP,
}
struct Attach_Arg {
Attach_Arg_Kind kind;
void* box;
}
fn Attach_Arg to_scope() @inline {
return {
TOP,
null
};
}
/* #expect: test.ll
define void @test.foo(i32 %0) #0 !dbg !16 {
entry:
%x = alloca i32, align 4
%a = alloca i32, align 4
%a.f = alloca i64, align 8
store i32 %0, ptr %x, align 4
call void @llvm.dbg.declare(metadata ptr %x, metadata !20, metadata !DIExpression()), !dbg !21
call void @llvm.dbg.declare(metadata ptr %a, metadata !22, metadata !DIExpression()), !dbg !23
%1 = load i32, ptr %x, align 4, !dbg !24
store i32 %1, ptr %a, align 4, !dbg !24
store i64 0, ptr %a.f, align 8, !dbg !24
br label %loop.cond, !dbg !25
loop.cond: ; preds = %loop.body, %entry
%load.err = load i64, ptr %a.f, align 8, !dbg !26
%result = icmp eq i64 %load.err, 0, !dbg !26
br i1 %result, label %loop.body, label %loop.exit, !dbg !26
loop.body: ; preds = %loop.cond
store i32 2, ptr %a, align 4, !dbg !28
store i64 0, ptr %a.f, align 8, !dbg !28
br label %loop.cond, !dbg !28
loop.exit: ; preds = %loop.cond
ret void, !dbg !28
}
define i32 @test.main(ptr %0, i64 %1) #0 !dbg !30 {
entry:
%args = alloca %"char[][]", align 8
%asdf = alloca ptr, align 8
%result = alloca %Attach_Arg, align 8
store ptr %0, ptr %args, align 8
%ptradd = getelementptr inbounds i8, ptr %args, i64 8
store i64 %1, ptr %ptradd, align 8
call void @llvm.dbg.declare(metadata ptr %args, metadata !46, metadata !DIExpression()), !dbg !47
call void @llvm.dbg.declare(metadata ptr %asdf, metadata !48, metadata !DIExpression()), !dbg !53
%2 = call { i32, ptr } @attach.to_scope() #4, !dbg !54
store { i32, ptr } %2, ptr %result, align 8
%lo = load i32, ptr %result, align 8, !dbg !55
%ptradd1 = getelementptr inbounds i8, ptr %result, i64 8, !dbg !55
%hi = load ptr, ptr %ptradd1, align 8, !dbg !55
%3 = call ptr @test.create_foo(i32 %lo, ptr %hi, i64 1, ptr null, i64 0), !dbg !56
store ptr %3, ptr %asdf, align 8, !dbg !56
%ptradd2 = getelementptr inbounds i8, ptr %args, i64 8, !dbg !57
%4 = load i64, ptr %ptradd2, align 8, !dbg !57
%neq = icmp ne i64 0, %4, !dbg !57
%ternary = select i1 %neq, <4 x float> <float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 1.000000e+00>, <4 x float> <float 1.000000e+00, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00>, !dbg !58
%5 = call ptr @test.test(<4 x float> %ternary), !dbg !59
%6 = call ptr @test.test2(), !dbg !60
ret i32 0, !dbg !61
}
define ptr @test.create_foo(i32 %0, ptr %1, i64 %2, ptr %3, i64 %4) #0 !dbg !62 {
entry:
%attach = alloca %Attach_Arg, align 8
%flags = alloca i64, align 8
%name = alloca %"char[]", align 8
store i32 %0, ptr %attach, align 8
%ptradd = getelementptr inbounds i8, ptr %attach, i64 8
store ptr %1, ptr %ptradd, align 8
call void @llvm.dbg.declare(metadata ptr %attach, metadata !65, metadata !DIExpression()), !dbg !66
store i64 %2, ptr %flags, align 8
call void @llvm.dbg.declare(metadata ptr %flags, metadata !67, metadata !DIExpression()), !dbg !68
store ptr %3, ptr %name, align 8
%ptradd1 = getelementptr inbounds i8, ptr %name, i64 8
store i64 %4, ptr %ptradd1, align 8
call void @llvm.dbg.declare(metadata ptr %name, metadata !69, metadata !DIExpression()), !dbg !70
%5 = call ptr @std.core.mem.calloc(i64 8) #4, !dbg !71
ret ptr %5, !dbg !71
}
define ptr @test.test(<4 x float> %0) #0 !dbg !75 {
entry:
%color = alloca <4 x float>, align 16
%x = alloca <4 x float>, align 16
%out = alloca ptr, align 8
%x1 = alloca <4 x float>, align 16
%len = alloca i64, align 8
%error_var = alloca i64, align 8
%out2 = alloca ptr, align 8
%x3 = alloca <4 x float>, align 16
%varargslots = alloca [1 x %any], align 16
%retparam = alloca i64, align 8
%taddr = alloca %any, align 8
%indirectarg = alloca %"any[]", align 8
%error_var5 = alloca i64, align 8
%error_var11 = alloca i64, align 8
store <4 x float> %0, ptr %color, align 16
call void @llvm.dbg.declare(metadata ptr %color, metadata !83, metadata !DIExpression()), !dbg !84
%1 = load <4 x float>, ptr %color, align 16
store <4 x float> %1, ptr %x, align 16
%2 = call ptr @std.io.stdout(), !dbg !85
store ptr %2, ptr %out, align 8
%3 = load <4 x float>, ptr %x, align 16
store <4 x float> %3, ptr %x1, align 16
call void @llvm.dbg.declare(metadata ptr %len, metadata !89, metadata !DIExpression()), !dbg !91
%4 = load ptr, ptr %out, align 8
store ptr %4, ptr %out2, align 8
%5 = load <4 x float>, ptr %x1, align 16
store <4 x float> %5, ptr %x3, align 16
%6 = load ptr, ptr %out2, align 8, !dbg !93
%7 = insertvalue %any undef, ptr %6, 0, !dbg !93
%8 = insertvalue %any %7, i64 ptrtoint (ptr @"$ct.std.io.File" to i64), 1, !dbg !93
%9 = insertvalue %any undef, ptr %x3, 0, !dbg !96
%10 = insertvalue %any %9, i64 ptrtoint (ptr @"$ct.foo.Color" to i64), 1, !dbg !96
store %any %10, ptr %varargslots, align 16, !dbg !96
%11 = insertvalue %"any[]" undef, ptr %varargslots, 0, !dbg !96
%"$$temp" = insertvalue %"any[]" %11, i64 1, 1, !dbg !96
store %any %8, ptr %taddr, align 8
%lo = load i64, ptr %taddr, align 8
%ptradd = getelementptr inbounds i8, ptr %taddr, i64 8
%hi = load ptr, ptr %ptradd, align 8
store %"any[]" %"$$temp", ptr %indirectarg, align 8
%12 = call i64 @std.io.fprintf(ptr %retparam, i64 %lo, ptr %hi, ptr @.str, i64 2, ptr byval(%"any[]") align 8 %indirectarg), !dbg !97
%not_err = icmp eq i64 %12, 0, !dbg !97
%13 = call i1 @llvm.expect.i1(i1 %not_err, i1 true), !dbg !97
br i1 %13, label %after_check, label %assign_optional, !dbg !97
assign_optional: ; preds = %entry
store i64 %12, ptr %error_var, align 8, !dbg !97
br label %guard_block, !dbg !97
after_check: ; preds = %entry
br label %noerr_block, !dbg !97
guard_block: ; preds = %assign_optional
br label %voiderr, !dbg !97
noerr_block: ; preds = %after_check
%14 = load i64, ptr %retparam, align 8, !dbg !97
store i64 %14, ptr %len, align 8, !dbg !97
%15 = load ptr, ptr %out, align 8, !dbg !98
%16 = call i64 @std.io.File.write_byte(ptr %15, i8 zeroext 10), !dbg !99
%not_err6 = icmp eq i64 %16, 0, !dbg !99
%17 = call i1 @llvm.expect.i1(i1 %not_err6, i1 true), !dbg !99
br i1 %17, label %after_check8, label %assign_optional7, !dbg !99
assign_optional7: ; preds = %noerr_block
store i64 %16, ptr %error_var5, align 8, !dbg !99
br label %guard_block9, !dbg !99
after_check8: ; preds = %noerr_block
br label %noerr_block10, !dbg !99
guard_block9: ; preds = %assign_optional7
br label %voiderr, !dbg !99
noerr_block10: ; preds = %after_check8
%18 = load ptr, ptr %out, align 8, !dbg !100
%19 = call i64 @std.io.File.flush(ptr %18), !dbg !100
%not_err12 = icmp eq i64 %19, 0, !dbg !100
%20 = call i1 @llvm.expect.i1(i1 %not_err12, i1 true), !dbg !100
br i1 %20, label %after_check14, label %assign_optional13, !dbg !100
assign_optional13: ; preds = %noerr_block10
store i64 %19, ptr %error_var11, align 8, !dbg !100
br label %guard_block15, !dbg !100
after_check14: ; preds = %noerr_block10
br label %noerr_block16, !dbg !100
guard_block15: ; preds = %assign_optional13
br label %voiderr, !dbg !100
noerr_block16: ; preds = %after_check14
%21 = load i64, ptr %len, align 8, !dbg !101
%add = add i64 %21, 1, !dbg !101
br label %voiderr, !dbg !92
voiderr: ; preds = %noerr_block16, %guard_block15, %guard_block9, %guard_block
ret ptr null, !dbg !102
}
define ptr @test.test2() #0 !dbg !103 {
entry:
%conflicts = alloca %"Arena*[]", align 8
%scratch = alloca %Arena_Cursor, align 8
%result = alloca %Arena_Cursor, align 8
%scratch1 = alloca ptr, align 8
%asdf = alloca ptr, align 8
store %"Arena*[]" zeroinitializer, ptr %conflicts, align 8
call void @llvm.dbg.declare(metadata ptr %scratch, metadata !106, metadata !DIExpression()), !dbg !116
%lo = load ptr, ptr %conflicts, align 8, !dbg !118
%ptradd = getelementptr inbounds i8, ptr %conflicts, i64 8, !dbg !118
%hi = load i64, ptr %ptradd, align 8, !dbg !118
%0 = call { ptr, i64 } @arena_scratch_begin(ptr %lo, i64 %hi), !dbg !119
store { ptr, i64 } %0, ptr %result, align 8
call void @llvm.memcpy.p0.p0.i32(ptr align 8 %scratch, ptr align 8 %result, i32 16, i1 false)
call void @llvm.dbg.declare(metadata ptr %scratch1, metadata !120, metadata !DIExpression()), !dbg !121
%1 = load ptr, ptr %scratch, align 8, !dbg !122
store ptr %1, ptr %scratch1, align 8, !dbg !122
call void @llvm.dbg.declare(metadata ptr %asdf, metadata !124, metadata !DIExpression()), !dbg !126
store ptr null, ptr %asdf, align 8, !dbg !126
%2 = load ptr, ptr %asdf, align 8, !dbg !127
%lo2 = load ptr, ptr %scratch, align 8, !dbg !128
%ptradd3 = getelementptr inbounds i8, ptr %scratch, i64 8, !dbg !128
%hi4 = load i64, ptr %ptradd3, align 8, !dbg !128
call void @arena_scratch_end(ptr %lo2, i64 %hi4) #4, !dbg !130
ret ptr %2, !dbg !130
}
define i32 @main(i32 %0, ptr %1) #0 !dbg !131 {
entry:
%.anon = alloca i32, align 4
%.anon1 = alloca ptr, align 8
%argc = alloca i32, align 4
%argv = alloca ptr, align 8
%blockret = alloca i32, align 4
%list = alloca %"char[][]", align 8
%argc2 = alloca i32, align 4
%argv3 = alloca ptr, align 8
%list5 = alloca %"char[][]", align 8
%elements = alloca i64, align 8
%allocator = alloca %any, align 8
%elements6 = alloca i64, align 8
%error_var = alloca i64, align 8
%allocator7 = alloca %any, align 8
%elements8 = alloca i64, align 8
%allocator10 = alloca %any, align 8
%size = alloca i64, align 8
%blockret11 = alloca ptr, align 8
%.inlinecache = alloca ptr, align 8
%.cachedtype = alloca ptr, align 8
%retparam = alloca ptr, align 8
%taddr = alloca ptr, align 8
%varargslots = alloca [1 x %any], align 16
%indirectarg = alloca %"any[]", align 8
%i = alloca i32, align 4
%arg = alloca ptr, align 8
%len = alloca i64, align 8
%ptr = alloca ptr, align 8
%len18 = alloca i64, align 8
store ptr null, ptr %.cachedtype, align 8
store i32 %0, ptr %.anon, align 4
call void @llvm.dbg.declare(metadata ptr %.anon, metadata !135, metadata !DIExpression()), !dbg !136
store ptr %1, ptr %.anon1, align 8
call void @llvm.dbg.declare(metadata ptr %.anon1, metadata !137, metadata !DIExpression()), !dbg !136
%2 = load i32, ptr %.anon, align 4
store i32 %2, ptr %argc, align 4
%3 = load ptr, ptr %.anon1, align 8
store ptr %3, ptr %argv, align 8
call void @llvm.dbg.declare(metadata ptr %list, metadata !138, metadata !DIExpression()), !dbg !141
%4 = load i32, ptr %argc, align 4
store i32 %4, ptr %argc2, align 4
%5 = load ptr, ptr %argv, align 8
store ptr %5, ptr %argv3, align 8
call void @llvm.dbg.declare(metadata ptr %list5, metadata !142, metadata !DIExpression()), !dbg !144
%6 = load i32, ptr %argc2, align 4, !dbg !146
%sext = sext i32 %6 to i64, !dbg !146
store i64 %sext, ptr %elements, align 8
call void @llvm.memcpy.p0.p0.i32(ptr align 8 %allocator, ptr align 8 @std.core.mem.allocator.thread_allocator, i32 16, i1 false)
%7 = load i64, ptr %elements, align 8
store i64 %7, ptr %elements6, align 8
call void @llvm.memcpy.p0.p0.i32(ptr align 8 %allocator7, ptr align 8 %allocator, i32 16, i1 false)
%8 = load i64, ptr %elements6, align 8
store i64 %8, ptr %elements8, align 8
call void @llvm.memcpy.p0.p0.i32(ptr align 8 %allocator10, ptr align 8 %allocator7, i32 16, i1 false)
%9 = load i64, ptr %elements8, align 8, !dbg !147
%mul = mul i64 16, %9, !dbg !155
store i64 %mul, ptr %size, align 8
%10 = load i64, ptr %size, align 8, !dbg !156
%not = icmp eq i64 %10, 0, !dbg !156
br i1 %not, label %if.then, label %if.exit, !dbg !156
if.then: ; preds = %entry
store ptr null, ptr %blockret11, align 8, !dbg !159
br label %expr_block.exit, !dbg !159
if.exit: ; preds = %entry
%ptradd = getelementptr inbounds i8, ptr %allocator10, i64 8, !dbg !160
%11 = load i64, ptr %ptradd, align 8, !dbg !160
%12 = inttoptr i64 %11 to ptr, !dbg !160
%type = load ptr, ptr %.cachedtype, align 8
%13 = icmp eq ptr %12, %type
br i1 %13, label %cache_hit, label %cache_miss
cache_miss: ; preds = %if.exit
%ptradd12 = getelementptr inbounds i8, ptr %12, i64 16
%14 = load ptr, ptr %ptradd12, align 8
%15 = call ptr @.dyn_search(ptr %14, ptr @"$sel.acquire")
store ptr %15, ptr %.inlinecache, align 8
store ptr %12, ptr %.cachedtype, align 8
br label %16
cache_hit: ; preds = %if.exit
%cache_hit_fn = load ptr, ptr %.inlinecache, align 8
br label %16
16: ; preds = %cache_hit, %cache_miss
%fn_phi = phi ptr [ %cache_hit_fn, %cache_hit ], [ %15, %cache_miss ]
%17 = icmp eq ptr %fn_phi, null
br i1 %17, label %missing_function, label %match
missing_function: ; preds = %16
%18 = load ptr, ptr @std.core.builtin.panic, align 8, !dbg !161
call void %18(ptr @.panic_msg, i64 44, ptr @.file, i64 16, ptr @.func, i64 6, i32 68), !dbg !161
unreachable, !dbg !161
match: ; preds = %16
%19 = load ptr, ptr %allocator10, align 8
%20 = load i64, ptr %size, align 8
%21 = call i64 %fn_phi(ptr %retparam, ptr %19, i64 %20, i32 0, i64 0), !dbg !161
%not_err = icmp eq i64 %21, 0, !dbg !161
%22 = call i1 @llvm.expect.i1(i1 %not_err, i1 true), !dbg !161
br i1 %22, label %after_check, label %assign_optional, !dbg !161
assign_optional: ; preds = %match
store i64 %21, ptr %error_var, align 8, !dbg !161
br label %panic_block, !dbg !161
after_check: ; preds = %match
%23 = load ptr, ptr %retparam, align 8, !dbg !161
store ptr %23, ptr %blockret11, align 8, !dbg !161
br label %expr_block.exit, !dbg !161
expr_block.exit: ; preds = %after_check, %if.then
%24 = load ptr, ptr %blockret11, align 8, !dbg !161
store ptr %24, ptr %taddr, align 8
%25 = load ptr, ptr %taddr, align 8
%26 = load i64, ptr %elements8, align 8, !dbg !162
%add = add i64 0, %26, !dbg !162
%size13 = sub i64 %add, 0, !dbg !162
%27 = insertvalue %"char[][]" undef, ptr %25, 0, !dbg !162
%28 = insertvalue %"char[][]" %27, i64 %size13, 1, !dbg !162
br label %noerr_block, !dbg !162
panic_block: ; preds = %assign_optional
%29 = insertvalue %any undef, ptr %error_var, 0, !dbg !162
%30 = insertvalue %any %29, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1, !dbg !162
store %any %30, ptr %varargslots, align 16
%31 = insertvalue %"any[]" undef, ptr %varargslots, 0
%"$$temp" = insertvalue %"any[]" %31, i64 1, 1
store %"any[]" %"$$temp", ptr %indirectarg, align 8
call void @std.core.builtin.panicf(ptr @.panic_msg.1, i64 36, ptr @.file, i64 16, ptr @.func, i64 6, i32 216, ptr byval(%"any[]") align 8 %indirectarg), !dbg !150
unreachable, !dbg !150
noerr_block: ; preds = %expr_block.exit
store %"char[][]" %28, ptr %list5, align 8, !dbg !150
call void @llvm.dbg.declare(metadata ptr %i, metadata !163, metadata !DIExpression()), !dbg !165
store i32 0, ptr %i, align 4, !dbg !166
br label %loop.cond, !dbg !166
loop.cond: ; preds = %loop.exit, %noerr_block
%32 = load i32, ptr %i, align 4, !dbg !167
%33 = load i32, ptr %argc2, align 4, !dbg !168
%lt = icmp slt i32 %32, %33, !dbg !167
br i1 %lt, label %loop.body, label %loop.exit26, !dbg !167
loop.body: ; preds = %loop.cond
call void @llvm.dbg.declare(metadata ptr %arg, metadata !169, metadata !DIExpression()), !dbg !171
%34 = load ptr, ptr %argv3, align 8, !dbg !172
%35 = load i32, ptr %i, align 4, !dbg !173
%sext14 = sext i32 %35 to i64, !dbg !173
%ptroffset = getelementptr inbounds [8 x i8], ptr %34, i64 %sext14, !dbg !173
%36 = load ptr, ptr %ptroffset, align 8, !dbg !173
store ptr %36, ptr %arg, align 8, !dbg !173
call void @llvm.dbg.declare(metadata ptr %len, metadata !174, metadata !DIExpression()), !dbg !175
store i64 0, ptr %len, align 8, !dbg !176
%37 = load ptr, ptr %list5, align 8, !dbg !177
%38 = load i32, ptr %i, align 4, !dbg !178
%sext15 = sext i32 %38 to i64, !dbg !178
%ptroffset16 = getelementptr inbounds [16 x i8], ptr %37, i64 %sext15, !dbg !178
%39 = load ptr, ptr %arg, align 8, !dbg !179
%40 = load ptr, ptr %arg, align 8
store ptr %40, ptr %ptr, align 8
call void @llvm.dbg.declare(metadata ptr %len18, metadata !180, metadata !DIExpression()), !dbg !182
store i64 0, ptr %len18, align 8, !dbg !184
br label %loop.cond19, !dbg !185
loop.cond19: ; preds = %loop.body21, %loop.body
%41 = load ptr, ptr %ptr, align 8, !dbg !186
%42 = load i64, ptr %len18, align 8, !dbg !188
%ptradd20 = getelementptr inbounds i8, ptr %41, i64 %42, !dbg !188
%43 = load i8, ptr %ptradd20, align 1, !dbg !188
%intbool = icmp ne i8 %43, 0, !dbg !188
br i1 %intbool, label %loop.body21, label %loop.exit, !dbg !188
loop.body21: ; preds = %loop.cond19
%44 = load i64, ptr %len18, align 8, !dbg !189
%add22 = add i64 %44, 1, !dbg !189
store i64 %add22, ptr %len18, align 8, !dbg !189
br label %loop.cond19, !dbg !189
loop.exit: ; preds = %loop.cond19
%45 = load i64, ptr %len18, align 8, !dbg !190
%add23 = add i64 0, %45, !dbg !190
%size24 = sub i64 %add23, 0, !dbg !190
%46 = insertvalue %"char[]" undef, ptr %39, 0, !dbg !190
%47 = insertvalue %"char[]" %46, i64 %size24, 1, !dbg !190
store %"char[]" %47, ptr %ptroffset16, align 8, !dbg !190
%48 = load i32, ptr %i, align 4, !dbg !191
%add25 = add i32 %48, 1, !dbg !191
store i32 %add25, ptr %i, align 4, !dbg !191
br label %loop.cond, !dbg !191
loop.exit26: ; preds = %loop.cond
call void @llvm.memcpy.p0.p0.i32(ptr align 8 %list, ptr align 8 %list5, i32 16, i1 false), !dbg !192
%lo = load ptr, ptr %list, align 8, !dbg !193
%ptradd27 = getelementptr inbounds i8, ptr %list, i64 8, !dbg !193
%hi = load i64, ptr %ptradd27, align 8, !dbg !193
%49 = call i32 @test.main(ptr %lo, i64 %hi), !dbg !194
store i32 %49, ptr %blockret, align 4, !dbg !194
%50 = load ptr, ptr %list, align 8, !dbg !195
call void @std.core.mem.free(ptr %50) #4, !dbg !197
br label %expr_block.exit28, !dbg !197
expr_block.exit28: ; preds = %loop.exit26
%51 = load i32, ptr %blockret, align 4, !dbg !197
ret i32 %51, !dbg !197
}
declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
declare { i32, ptr } @attach.to_scope() #0
declare ptr @std.core.mem.calloc(i64) #0
declare ptr @std.io.stdout() #0
declare i64 @std.io.fprintf(ptr, i64, ptr, ptr, i64, ptr byval(%"any[]") align 8) #0
declare i1 @llvm.expect.i1(i1, i1) #2
declare i64 @std.io.File.write_byte(ptr, i8 zeroext) #0
declare i64 @std.io.File.flush(ptr) #0
declare { ptr, i64 } @arena_scratch_begin(ptr, i64) #0
declare void @llvm.memcpy.p0.p0.i32(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i32, i1 immarg) #3
declare void @arena_scratch_end(ptr, i64) #0
define weak_odr ptr @.dyn_search(ptr %0, ptr %1) unnamed_addr {
entry:
br label %check
check: ; preds = %no_match, %entry
%2 = phi ptr [ %0, %entry ], [ %9, %no_match ]
%3 = icmp eq ptr %2, null
br i1 %3, label %missing_function, label %compare
missing_function: ; preds = %check
ret ptr null
compare: ; preds = %check
%4 = getelementptr inbounds { ptr, ptr, ptr }, ptr %2, i32 0, i32 1
%5 = load ptr, ptr %4, align 8
%6 = icmp eq ptr %5, %1
br i1 %6, label %match, label %no_match
match: ; preds = %compare
%7 = load ptr, ptr %2, align 8
ret ptr %7
no_match: ; preds = %compare
%8 = getelementptr inbounds { ptr, ptr, ptr }, ptr %2, i32 0, i32 2
%9 = load ptr, ptr %8, align 8
br label %check
}
!llvm.dbg.cu = !{!4}
!0 = !{i32 2, !"Dwarf Version", i32 4}
!1 = !{i32 2, !"Debug Info Version", i32 3}
!2 = !{i32 2, !"frame-pointer", i32 2}
!3 = !{i32 1, !"uwtable", i32 2}
!4 = distinct !DICompileUnit(language: DW_LANG_C11, file: !5, producer: "c3c", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !6, splitDebugInlining: false)
!6 = !{!7}
!7 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "Attach_Arg_Kind", scope: !8, file: !5, line: 116, baseType: !13, size: 32, align: 32, elements: !14)
!8 = !DICompositeType(tag: DW_TAG_structure_type, name: "Attach_Arg", scope: !5, file: !5, line: 120, size: 128, align: 64, elements: !9, identifier: "attach.Attach_Arg")
!9 = !{!10, !11}
!10 = !DIDerivedType(tag: DW_TAG_member, name: "kind", scope: !8, file: !5, line: 121, baseType: !7, size: 32, align: 32)
!11 = !DIDerivedType(tag: DW_TAG_member, name: "box", scope: !8, file: !5, line: 122, baseType: !12, size: 64, align: 64, offset: 64)
!12 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "void*", baseType: null, size: 64, align: 64, dwarfAddressSpace: 0)
!13 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
!14 = !{!15}
!15 = !DIEnumerator(name: "TOP", value: 0)
!16 = distinct !DISubprogram(name: "foo", linkageName: "test.foo", scope: !5, file: !5, line: 6, type: !17, scopeLine: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition
!17 = !DISubroutineType(types: !18)
!18 = !{null, !13}
!19 = !{}
!20 = !DILocalVariable(name: "x", arg: 1, scope: !16, file: !5, line: 6, type: !13)
!21 = !DILocation(line: 6, column: 17, scope: !16)
!22 = !DILocalVariable(name: "a", scope: !16, file: !5, line: 8, type: !13, align: 4)
!23 = !DILocation(line: 8, column: 7, scope: !16)
!24 = !DILocation(line: 8, column: 11, scope: !16)
!25 = !DILocation(line: 9, column: 2, scope: !16)
!26 = !DILocation(line: 9, column: 9, scope: !27)
!27 = distinct !DILexicalBlock(scope: !16, file: !5, line: 9, column: 2)
!28 = !DILocation(line: 11, column: 7, scope: !29)
!29 = distinct !DILexicalBlock(scope: !27, file: !5, line: 10, column: 2)
!30 = distinct !DISubprogram(name: "main", linkageName: "test.main", scope: !5, file: !5, line: 15, type: !31, scopeLine: 15, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition
!31 = !DISubroutineType(types: !32)
!32 = !{!13, !33}
!33 = !DICompositeType(tag: DW_TAG_structure_type, name: "String[]", size: 128, align: 64, elements: !34, identifier: "String[]")
!34 = !{!35, !45}
!35 = !DIDerivedType(tag: DW_TAG_member, name: "ptr", scope: !33, baseType: !36, size: 64, align: 64)
!36 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "String*", baseType: !37, size: 64, align: 64, dwarfAddressSpace: 0)
!37 = !DIDerivedType(tag: DW_TAG_typedef, name: "String", scope: !5, file: !5, line: 1, baseType: !38, align: 8)
!38 = !DICompositeType(tag: DW_TAG_structure_type, name: "char[]", size: 128, align: 64, elements: !39, identifier: "char[]")
!39 = !{!40, !43}
!40 = !DIDerivedType(tag: DW_TAG_member, name: "ptr", scope: !38, baseType: !41, size: 64, align: 64)
!41 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "char*", baseType: !42, size: 64, align: 64, dwarfAddressSpace: 0)
!42 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_unsigned_char)
!43 = !DIDerivedType(tag: DW_TAG_member, name: "len", scope: !38, baseType: !44, size: 64, align: 64, offset: 64)
!44 = !DIBasicType(name: "ulong", size: 64, encoding: DW_ATE_unsigned)
!45 = !DIDerivedType(tag: DW_TAG_member, name: "len", scope: !33, baseType: !44, size: 64, align: 64, offset: 64)
!46 = !DILocalVariable(name: "args", arg: 1, scope: !30, file: !5, line: 15, type: !33)
!47 = !DILocation(line: 15, column: 22, scope: !30)
!48 = !DILocalVariable(name: "asdf", scope: !30, file: !5, line: 18, type: !49, align: 8)
!49 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "Foo*", baseType: !50, size: 64, align: 64, dwarfAddressSpace: 0)
!50 = !DICompositeType(tag: DW_TAG_structure_type, name: "Foo", scope: !5, file: !5, line: 27, size: 64, align: 64, elements: !51, identifier: "test.Foo")
!51 = !{!52}
!52 = !DIDerivedType(tag: DW_TAG_member, name: "asdf", scope: !50, file: !5, line: 28, baseType: !12, size: 64, align: 64)
!53 = !DILocation(line: 18, column: 8, scope: !30)
!54 = !DILocation(line: 18, column: 34, scope: !30)
!55 = !DILocation(line: 33, column: 70, scope: !30)
!56 = !DILocation(line: 18, column: 15, scope: !30)
!57 = !DILocation(line: 21, column: 8, scope: !30)
!58 = !DILocation(line: 21, column: 42, scope: !30)
!59 = !DILocation(line: 21, column: 3, scope: !30)
!60 = !DILocation(line: 23, column: 3, scope: !30)
!61 = !DILocation(line: 24, column: 10, scope: !30)
!62 = distinct !DISubprogram(name: "create_foo", linkageName: "test.create_foo", scope: !5, file: !5, line: 33, type: !63, scopeLine: 33, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition
!63 = !DISubroutineType(types: !64)
!64 = !{!49, !8, !44, !37}
!65 = !DILocalVariable(name: "attach", arg: 1, scope: !62, file: !5, line: 33, type: !8)
!66 = !DILocation(line: 33, column: 31, scope: !62)
!67 = !DILocalVariable(name: "flags", arg: 2, scope: !62, file: !5, line: 33, type: !44)
!68 = !DILocation(line: 33, column: 49, scope: !62)
!69 = !DILocalVariable(name: "name", arg: 3, scope: !62, file: !5, line: 33, type: !37)
!70 = !DILocation(line: 33, column: 63, scope: !62)
!71 = !DILocation(line: 564, column: 10, scope: !72, inlinedAt: !74)
!72 = distinct !DISubprogram(name: "new", linkageName: "new", scope: !73, file: !73, line: 561, scopeLine: 561, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition
!73 = !DIFile(filename: "mem.c3", directory: "/Users/lerno/Projects/c3c/lib/std/core")
!74 = !DILocation(line: 34, column: 15, scope: !62)
!75 = distinct !DISubprogram(name: "test", linkageName: "test.test", scope: !5, file: !5, line: 41, type: !76, scopeLine: 41, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition
!76 = !DISubroutineType(types: !77)
!77 = !{!49, !78}
!78 = !DIDerivedType(tag: DW_TAG_typedef, name: "Color", scope: !5, file: !5, line: 79, baseType: !79, align: 16)
!79 = !DICompositeType(tag: DW_TAG_array_type, baseType: !80, size: 128, align: 32, flags: DIFlagVector, elements: !81)
!80 = !DIBasicType(name: "float", size: 32, encoding: DW_ATE_float)
!81 = !{!82}
!82 = !DISubrange(count: 4, lowerBound: 0)
!83 = !DILocalVariable(name: "color", arg: 1, scope: !75, file: !5, line: 41, type: !78)
!84 = !DILocation(line: 41, column: 20, scope: !75)
!85 = !DILocation(line: 151, column: 20, scope: !86, inlinedAt: !88)
!86 = distinct !DISubprogram(name: "printn", linkageName: "printn", scope: !87, file: !87, line: 149, scopeLine: 149, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition
!87 = !DIFile(filename: "io.c3"
!88 = !DILocation(line: 42, column: 7, scope: !75)
!89 = !DILocalVariable(name: "len", scope: !90, file: !5, line: 133, type: !44, align: 8)
!90 = distinct !DISubprogram(name: "fprintn", linkageName: "fprintn", scope: !87, file: !87, line: 131, scopeLine: 131, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition
!91 = !DILocation(line: 133, column: 6, scope: !90, inlinedAt: !92)
!92 = !DILocation(line: 151, column: 2, scope: !86, inlinedAt: !88)
!93 = !DILocation(line: 106, column: 19, scope: !94, inlinedAt: !95)
!94 = distinct !DISubprogram(name: "fprint", linkageName: "fprint", scope: !87, file: !87, line: 92, scopeLine: 92, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition
!95 = !DILocation(line: 133, column: 12, scope: !90, inlinedAt: !92)
!96 = !DILocation(line: 106, column: 30, scope: !94, inlinedAt: !95)
!97 = !DILocation(line: 106, column: 11, scope: !94, inlinedAt: !95)
!98 = !DILocation(line: 134, column: 17, scope: !90, inlinedAt: !92)
!99 = !DILocation(line: 134, column: 2, scope: !90, inlinedAt: !92)
!100 = !DILocation(line: 139, column: 4, scope: !90, inlinedAt: !92)
!101 = !DILocation(line: 141, column: 9, scope: !90, inlinedAt: !92)
!102 = !DILocation(line: 45, column: 10, scope: !75)
!103 = distinct !DISubprogram(name: "test2", linkageName: "test.test2", scope: !5, file: !5, line: 48, type: !104, scopeLine: 48, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition
!104 = !DISubroutineType(types: !105)
!105 = !{!12}
!106 = !DILocalVariable(name: "scratch", scope: !107, file: !5, line: 110, type: !108, align: 8)
!107 = distinct !DISubprogram(name: "@scratch", linkageName: "@scratch", scope: !5, file: !5, line: 109, scopeLine: 109, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit:
!108 = !DICompositeType(tag: DW_TAG_structure_type, name: "Arena_Cursor", scope: !5, file: !5, line: 88, size: 128, align: 64, elements: !109, identifier: "foo.Arena_Cursor")
!109 = !{!110, !115}
!110 = !DIDerivedType(tag: DW_TAG_member, name: "arena", scope: !108, file: !5, line: 89, baseType: !111, size: 64, align: 64)
!111 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "Arena*", baseType: !112, size: 64, align: 64, dwarfAddressSpace: 0)
!112 = !DICompositeType(tag: DW_TAG_structure_type, name: "Arena", scope: !5, file: !5, line: 84, size: 64, align: 64, elements: !113, identifier: "foo.Arena")
!113 = !{!114}
!114 = !DIDerivedType(tag: DW_TAG_member, name: "cursor", scope: !112, file: !5, line: 85, baseType: !44, size: 64, align: 64)
!115 = !DIDerivedType(tag: DW_TAG_member, name: "cursor", scope: !108, file: !5, line: 90, baseType: !44, size: 64, align: 64, offset: 64)
!116 = !DILocation(line: 110, column: 16, scope: !107, inlinedAt: !117)
!117 = !DILocation(line: 50, column: 3, scope: !103)
!118 = !DILocation(line: 110, column: 40, scope: !107, inlinedAt: !117)
!119 = !DILocation(line: 110, column: 26, scope: !107, inlinedAt: !117)
!120 = !DILocalVariable(name: "scratch", scope: !103, file: !5, line: 50, type: !111, align: 8)
!121 = !DILocation(line: 50, column: 21, scope: !103)
!122 = !DILocation(line: 112, column: 9, scope: !123, inlinedAt: !117)
!123 = distinct !DILexicalBlock(scope: !107, file: !5, line: 112, column: 3)
!124 = !DILocalVariable(name: "asdf", scope: !125, file: !5, line: 51, type: !12, align: 8)
!125 = distinct !DILexicalBlock(scope: !103, file: !5, line: 50, column: 30)
!126 = !DILocation(line: 51, column: 11, scope: !125)
!127 = !DILocation(line: 52, column: 12, scope: !125)
!128 = !DILocation(line: 111, column: 21, scope: !129, inlinedAt: !117)
!129 = distinct !DILexicalBlock(scope: !107, file: !5, line: 111, column: 9)
!130 = !DILocation(line: 111, column: 9, scope: !129, inlinedAt: !117)
!131 = distinct !DISubprogram(name: "_$main", linkageName: "main", scope: !5, file: !5, line: 15, type: !132, scopeLine: 15, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition
!132 = !DISubroutineType(types: !133)
!133 = !{!13, !13, !134}
!134 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "char**", baseType: !41, size: 64, align: 64
!135 = !DILocalVariable(name: ".anon", arg: 1, scope: !131, file: !5, line: 15, type: !13)
!136 = !DILocation(line: 15, column: 8, scope: !131)
!137 = !DILocalVariable(name: ".anon", arg: 2, scope: !131, file: !5, line: 15, type: !134)
!138 = !DILocalVariable(name: "list", scope: !139, file: !5, line: 45, type: !33, align: 8)
!141 = !DILocation(line: 45, column: 11, scope: !139, inlinedAt: !136)
!142 = !DILocalVariable(name: "list", scope: !143, file: !5, line: 24, type: !33, align: 8)
!144 = !DILocation(line: 24, column: 11, scope: !143, inlinedAt: !145)
!145 = !DILocation(line: 45, column: 18, scope: !139, inlinedAt: !136)
!146 = !DILocation(line: 24, column: 43, scope: !143, inlinedAt: !145)
!147 = !DILocation(line: 226, column: 55, scope: !148, inlinedAt: !150)
!150 = !DILocation(line: 216, column: 9, scope: !151, inlinedAt: !152)
!151 = distinct !DISubprogram(name: "alloc_array", linkageName: "alloc_array", scope: !149, file: !149, line: 214, scopeLine: 214, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition
!152 = !DILocation(line: 649, column: 20, scope: !153, inlinedAt: !154)
!153 = distinct !DISubprogram(name: "alloc_array", linkageName: "alloc_array", scope: !73, file: !73, line: 647, scopeLine: 647, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition
!154 = !DILocation(line: 24, column: 23, scope: !143, inlinedAt: !145)
!155 = !DILocation(line: 226, column: 40, scope: !148, inlinedAt: !150)
!156 = !DILocation(line: 62, column: 7, scope: !157, inlinedAt: !158)
!157 = distinct !DISubprogram(name: "malloc_try", linkageName: "malloc_try", scope: !149, file: !149, line: 60, scopeLine: 60, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition
!158 = !DILocation(line: 226, column: 10, scope: !148, inlinedAt: !150)
!159 = !DILocation(line: 62, column: 20, scope: !157, inlinedAt: !158)
!160 = !DILocation(line: 28, column: 71, scope: !157, inlinedAt: !158)
!161 = !DILocation(line: 68, column: 10, scope: !157, inlinedAt: !158)
!162 = !DILocation(line: 226, column: 67, scope: !148, inlinedAt: !150)
!163 = !DILocalVariable(name: "i", scope: !164, file: !5, line: 25, type: !13, align: 4)
!164 = distinct !DILexicalBlock(scope: !143, file: !140, line: 25, column: 2)
!165 = !DILocation(line: 25, column: 11, scope: !164, inlinedAt: !145)
!166 = !DILocation(line: 25, column: 15, scope: !164, inlinedAt: !145)
!167 = !DILocation(line: 25, column: 18, scope: !164, inlinedAt: !145)
!168 = !DILocation(line: 25, column: 22, scope: !164, inlinedAt: !145)
!169 = !DILocalVariable(name: "arg", scope: !170, file: !5, line: 27, type: !41, align: 8)
!170 = distinct !DILexicalBlock(scope: !164, file: !140, line: 26, column: 2)
!171 = !DILocation(line: 27, column: 9, scope: !170, inlinedAt: !145)
!172 = !DILocation(line: 27, column: 15, scope: !170, inlinedAt: !145)
!173 = !DILocation(line: 27, column: 20, scope: !170, inlinedAt: !145)
!174 = !DILocalVariable(name: "len", scope: !170, file: !5, line: 28, type: !44, align: 8)
!175 = !DILocation(line: 28, column: 7, scope: !170, inlinedAt: !145)
!176 = !DILocation(line: 28, column: 13, scope: !170, inlinedAt: !145)
!177 = !DILocation(line: 29, column: 3, scope: !170, inlinedAt: !145)
!178 = !DILocation(line: 29, column: 8, scope: !170, inlinedAt: !145)
!179 = !DILocation(line: 29, column: 21, scope: !170, inlinedAt: !145)
!180 = !DILocalVariable(name: "len", scope: !181, file: !5, line: 5, type: !44, align: 8)
!181 = distinct !DISubprogram(name: "_strlen", linkageName: "_strlen", scope: !140, file: !140, line: 3, scopeLine: 3, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition
!182 = !DILocation(line: 5, column: 6, scope: !181, inlinedAt: !183)
!183 = !DILocation(line: 29, column: 26, scope: !170, inlinedAt: !145)
!184 = !DILocation(line: 5, column: 12, scope: !181, inlinedAt: !183)
!185 = !DILocation(line: 6, column: 2, scope: !181, inlinedAt: !183)
!186 = !DILocation(line: 6, column: 9, scope: !187, inlinedAt: !183)
!187 = distinct !DILexicalBlock(scope: !181, file: !140, line: 6, column: 2)
!188 = !DILocation(line: 6, column: 13, scope: !187, inlinedAt: !183)
!189 = !DILocation(line: 6, column: 19, scope: !187, inlinedAt: !183)
!190 = !DILocation(line: 7, column: 9, scope: !181, inlinedAt: !183)
!191 = !DILocation(line: 25, column: 28, scope: !164, inlinedAt: !145)
!192 = !DILocation(line: 31, column: 9, scope: !143, inlinedAt: !145)
!193 = !DILocation(line: 47, column: 12, scope: !139, inlinedAt: !136)
!194 = !DILocation(line: 47, column: 9, scope: !139, inlinedAt: !136)
!195 = !DILocation(line: 46, column: 13, scope: !196, inlinedAt: !136)
!196 = distinct !DILexicalBlock(scope: !139, file: !140, line: 46, column: 8)
!197 = !DILocation(line: 46, column: 8, scope: !196, inlinedAt: !136)