Missing check on optional left hand side for s.x. #1360

This commit is contained in:
Christoffer Lerno
2024-08-15 21:15:59 +02:00
parent dc44254ba1
commit d0bb69516a
4 changed files with 393 additions and 344 deletions

View File

@@ -72,6 +72,7 @@
- Ordering issues with `$include` / `$exec` fixed #1302.
- Issues with wincrt linking.
- Debug info with recursive canonical type usage could cause segfault.
- Missing check on optional left hand side for `s.x`.
### Stdlib changes

View File

@@ -472,7 +472,6 @@ static bool sema_binary_is_expr_lvalue(SemaContext *context, Expr *top_expr, Exp
case EXPR_LAMBDA:
case EXPR_EMBED:
RETURN_SEMA_ERROR(expr, "This expression is a value and cannot be assigned to.");
case EXPR_SUBSCRIPT_ASSIGN:
case EXPR_CT_IDENT:
return true;
case EXPR_OTHER_CONTEXT:
@@ -525,20 +524,19 @@ static bool sema_binary_is_expr_lvalue(SemaContext *context, Expr *top_expr, Exp
return true;
case EXPR_BITACCESS:
case EXPR_ACCESS:
return sema_binary_is_expr_lvalue(context, top_expr, expr->access_expr.parent);
if (!sema_binary_is_expr_lvalue(context, top_expr, expr->access_expr.parent)) return false;
goto CHECK_OPTIONAL;
case EXPR_SUBSCRIPT:
case EXPR_SLICE:
case EXPR_SUBSCRIPT_ASSIGN:
case EXPR_SUBSCRIPT_ADDR:
if (IS_OPTIONAL(expr))
{
RETURN_SEMA_ERROR(top_expr, "You cannot assign to an optional value.");
}
return true;
goto CHECK_OPTIONAL;
case EXPR_HASH_IDENT:
RETURN_SEMA_ERROR(top_expr, "You cannot assign to an unevaluated expression.");
case EXPR_EXPRESSION_LIST:
if (!vec_size(expr->expression_list)) return false;
return sema_binary_is_expr_lvalue(context, top_expr, VECLAST(expr->expression_list));
goto CHECK_OPTIONAL;
case EXPR_CONST:
RETURN_SEMA_ERROR(top_expr, "You cannot assign to a constant expression.");
case EXPR_POISONED:
@@ -601,6 +599,13 @@ static bool sema_binary_is_expr_lvalue(SemaContext *context, Expr *top_expr, Exp
ERR:
SEMA_ERROR(top_expr, "An assignable expression, like a variable, was expected here.");
return false;
CHECK_OPTIONAL:
if (IS_OPTIONAL(expr))
{
RETURN_SEMA_ERROR(top_expr, "You cannot assign to an optional value.");
}
return true;
}
static bool expr_may_ref(Expr *expr)

View File

@@ -165,25 +165,25 @@ entry:
store ptr %0, ptr %args, align 8
%ptradd = getelementptr inbounds i8, ptr %args, i64 8
store i64 %1, ptr %ptradd, align 8
!46
!48
!47
!49
%2 = call { i32, ptr } @attach.to_scope()
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 !57
store ptr %3, ptr %asdf, align 8, !dbg !57
%ptradd2 = getelementptr inbounds i8, ptr %args, i64 8, !dbg !58
%4 = load i64, ptr %ptradd2, align 8, !dbg !58
%neq = icmp ne i64 0, %4, !dbg !58
%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 !59
%5 = call ptr @test.test(<4 x float> %ternary), !dbg !60
%6 = call ptr @test.test2(), !dbg !61
ret i32 0, !dbg !62
%lo = load i32, ptr %result, align 8, !dbg !56
%ptradd1 = getelementptr inbounds i8, ptr %result, i64 8, !dbg !56
%hi = load ptr, ptr %ptradd1, align 8, !dbg !56
%3 = call ptr @test.create_foo(i32 %lo, ptr %hi, i64 1, ptr null, i64 0), !dbg !58
store ptr %3, ptr %asdf, align 8, !dbg !58
%ptradd2 = getelementptr inbounds i8, ptr %args, i64 8, !dbg !59
%4 = load i64, ptr %ptradd2, align 8, !dbg !59
%neq = icmp ne i64 0, %4, !dbg !59
%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 !60
%5 = call ptr @test.test(<4 x float> %ternary), !dbg !61
%6 = call ptr @test.test2(), !dbg !62
ret i32 0, !dbg !63
}
define ptr @test.create_foo(i32 %0, ptr %1, i64 %2, ptr %3, i64 %4) #0 !dbg !63 {
define ptr @test.create_foo(i32 %0, ptr %1, i64 %2, ptr %3, i64 %4) #0 !dbg !64 {
entry:
%attach = alloca %Attach_Arg, align 8
%flags = alloca i64, align 8
@@ -191,18 +191,18 @@ entry:
store i32 %0, ptr %attach, align 8
%ptradd = getelementptr inbounds i8, ptr %attach, i64 8
store ptr %1, ptr %ptradd, align 8
!66
!67
store i64 %2, ptr %flags, align 8
!68
!69
store ptr %3, ptr %name, align 8
%ptradd1 = getelementptr inbounds i8, ptr %name, i64 8
store i64 %4, ptr %ptradd1, align 8
!70
!71
%5 = call ptr @std.core.mem.calloc(i64 8)
ret ptr %5, !dbg !72
ret ptr %5, !dbg !73
}
define ptr @test.test(<4 x float> %0) #0 !dbg !76 {
define ptr @test.test(<4 x float> %0) #0 !dbg !77
entry:
%color = alloca <4 x float>, align 16
%x = alloca <4 x float>, align 16
@@ -219,79 +219,92 @@ entry:
%error_var5 = alloca i64, align 8
%error_var11 = alloca i64, align 8
store <4 x float> %0, ptr %color, align 16
!84
!85
%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 !86
%2 = call ptr @std.io.stdout(), !dbg !87
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
!90
!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 !94
%7 = insertvalue %any undef, ptr %6, 0, !dbg !94
%8 = insertvalue %any %7, i64 ptrtoint (ptr @"$ct.std.io.File" to i64), 1, !dbg !94
%9 = insertvalue %any undef, ptr %x3, 0, !dbg !97
%10 = insertvalue %any %9, i64 ptrtoint (ptr @"$ct.foo.Color" to i64), 1, !dbg !97
store %any %10, ptr %varargslots, align 16, !dbg !97
%11 = insertvalue %"any[]" undef, ptr %varargslots, 0, !dbg !97
%"$$temp" = insertvalue %"any[]" %11, i64 1, 1, !dbg !97
%6 = load ptr, ptr %out2, align 8, !dbg !95
%7 = insertvalue %any undef, ptr %6, 0, !dbg !95
%8 = insertvalue %any %7, i64 ptrtoint (ptr @"$ct.std.io.File" to i64), 1, !dbg !95
%9 = insertvalue %any undef, ptr %x3, 0, !dbg !98
%10 = insertvalue %any %9, i64 ptrtoint (ptr @"$ct.foo.Color" to i64), 1, !dbg !98
store %any %10, ptr %varargslots, align 16, !dbg !98
%11 = insertvalue %"any[]" undef, ptr %varargslots, 0, !dbg !98
%"$$temp" = insertvalue %"any[]" %11, i64 1, 1, !dbg !98
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 !98
%not_err = icmp eq i64 %12, 0, !dbg !98
%13 = call i1 @llvm.expect.i1(i1 %not_err, i1 true), !dbg !98
br i1 %13, label %after_check, label %assign_optional, !dbg !98
%12 = call i64 @std.io.fprintf(ptr %retparam, i64 %lo, ptr %hi, ptr @.str, i64 2, ptr byval(%"any[]") align 8 %indirectarg), !dbg !99
%not_err = icmp eq i64 %12, 0, !dbg !99
%13 = call i1 @llvm.expect.i1(i1 %not_err, i1 true), !dbg !99
br i1 %13, label %after_check, label %assign_optional, !dbg !99
assign_optional: ; preds = %entry
store i64 %12, ptr %error_var, align 8, !dbg !98
br label %guard_block, !dbg !98
store i64 %12, ptr %error_var, align 8, !dbg !99
br label %guard_block, !dbg !99
after_check: ; preds = %entry
br label %noerr_block, !dbg !98
br label %noerr_block, !dbg !99
guard_block: ; preds = %assign_optional
br label %voiderr, !dbg !98
br label %voiderr, !dbg !99
noerr_block: ; preds = %after_check
%14 = load i64, ptr %retparam, align 8, !dbg !98
store i64 %14, ptr %len, align 8, !dbg !98
%15 = load ptr, ptr %out, align 8, !dbg !99
%16 = call i64 @std.io.File.write_byte(ptr %15, i8 zeroext 10), !dbg !100
%not_err6 = icmp eq i64 %16, 0, !dbg !100
%17 = call i1 @llvm.expect.i1(i1 %not_err6, i1 true), !dbg !100
br i1 %17, label %after_check8, label %assign_optional7, !dbg !100
%14 = load i64, ptr %retparam, align 8, !dbg !99
store i64 %14, ptr %len, align 8, !dbg !99
%15 = load ptr, ptr %out, align 8, !dbg !100
%16 = call i64 @std.io.File.write_byte(ptr %15, i8 zeroext 10), !dbg !101
%not_err6 = icmp eq i64 %16, 0, !dbg !101
%17 = call i1 @llvm.expect.i1(i1 %not_err6, i1 true), !dbg !101
br i1 %17, label %after_check8, label %assign_optional7, !dbg !101
assign_optional7: ; preds = %noerr_block
store i64 %16, ptr %error_var5, align 8, !dbg !100
br label %guard_block9, !dbg !100
store i64 %16, ptr %error_var5, align 8, !dbg !101
br label %guard_block9, !dbg !101
after_check8: ; preds = %noerr_block
br label %noerr_block10, !dbg !100
br label %noerr_block10, !dbg !101
guard_block9: ; preds = %assign_optional7
br label %voiderr, !dbg !100
noerr_block10: ; preds = %after_check8
%18 = load ptr, ptr %out, align 8, !dbg !101
%19 = call i64 @std.io.File.flush(ptr %18), !dbg !101
%not_err12 = icmp eq i64 %19, 0, !dbg !101
%20 = call i1 @llvm.expect.i1(i1 %not_err12, i1 true), !dbg !101
br i1 %20, label %after_check14, label %assign_optional13, !dbg !101
assign_optional13: ; preds = %noerr_block10
store i64 %19, ptr %error_var11, align 8, !dbg !101
br label %guard_block15, !dbg !101
after_check14: ; preds = %noerr_block10
br label %noerr_block16, !dbg !101
guard_block15: ; preds = %assign_optional13
br label %voiderr, !dbg !101
noerr_block10: ; preds = %after_check8
%18 = load ptr, ptr %out, align 8, !dbg !102
%19 = call i64 @std.io.File.flush(ptr %18), !dbg !102
%not_err12 = icmp eq i64 %19, 0, !dbg !102
%20 = call i1 @llvm.expect.i1(i1 %not_err12, i1 true), !dbg !102
br i1 %20, label %after_check14, label %assign_optional13, !dbg !102
assign_optional13: ; preds = %noerr_block10
store i64 %19, ptr %error_var11, align 8, !dbg !102
br label %guard_block15, !dbg !102
after_check14: ; preds = %noerr_block10
br label %noerr_block16, !dbg !102
guard_block15: ; preds = %assign_optional13
br label %voiderr, !dbg !102
noerr_block16: ; preds = %after_check14
%21 = load i64, ptr %len, align 8, !dbg !102
%add = add i64 %21, 1, !dbg !102
br label %voiderr, !dbg !93
%21 = load i64, ptr %len, align 8, !dbg !103
%add = add i64 %21, 1, !dbg !103
br label %voiderr, !dbg !94
voiderr: ; preds = %noerr_block16, %guard_block15, %guard_block9, %guard_block
ret ptr null, !dbg !103
ret ptr null, !dbg !104
}
define ptr @test.test2() #0 !dbg !104 {
define ptr @test.test2() #0 !dbg !105 {
entry:
%conflicts = alloca %"Arena*[]", align 8
%scratch = alloca %Arena_Cursor, align 8
@@ -299,27 +312,27 @@ entry:
%scratch1 = alloca ptr, align 8
%asdf = alloca ptr, align 8
store %"Arena*[]" zeroinitializer, ptr %conflicts, align 8
!107
%lo = load ptr, ptr %conflicts, align 8, !dbg !119
%ptradd = getelementptr inbounds i8, ptr %conflicts, i64 8, !dbg !119
%hi = load i64, ptr %ptradd, align 8, !dbg !119
%0 = call { ptr, i64 } @arena_scratch_begin(ptr %lo, i64 %hi), !dbg !120
!108
%lo = load ptr, ptr %conflicts, align 8, !dbg !120
%ptradd = getelementptr inbounds i8, ptr %conflicts, i64 8, !dbg !120
%hi = load i64, ptr %ptradd, align 8, !dbg !120
%0 = call { ptr, i64 } @arena_scratch_begin(ptr %lo, i64 %hi), !dbg !121
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)
!121
%1 = load ptr, ptr %scratch, align 8, !dbg !123
store ptr %1, ptr %scratch1, align 8, !dbg !123
!125
store ptr null, ptr %asdf, align 8, !dbg !127
%2 = load ptr, ptr %asdf, align 8, !dbg !128
%lo2 = load ptr, ptr %scratch, align 8, !dbg !129
%ptradd3 = getelementptr inbounds i8, ptr %scratch, i64 8, !dbg !129
%hi4 = load i64, ptr %ptradd3, align 8, !dbg !129
!122
%1 = load ptr, ptr %scratch, align 8, !dbg !124
store ptr %1, ptr %scratch1, align 8, !dbg !124
!126
store ptr null, ptr %asdf, align 8, !dbg !128
%2 = load ptr, ptr %asdf, align 8, !dbg !129
%lo2 = load ptr, ptr %scratch, align 8, !dbg !130
%ptradd3 = getelementptr inbounds i8, ptr %scratch, i64 8, !dbg !130
%hi4 = load i64, ptr %ptradd3, align 8, !dbg !130
call void @arena_scratch_end(ptr %lo2, i64 %hi4)
ret ptr %2, !dbg !131
ret ptr %2, !dbg !132
}
define i32 @main(i32 %0, ptr %1) #0 !dbg !132 {
define i32 @main(i32 %0, ptr %1) #0 !dbg !133 {
entry:
%.anon = alloca i32, align 4
%.anon1 = alloca ptr, align 8
@@ -352,21 +365,21 @@ entry:
%len18 = alloca i64, align 8
store ptr null, ptr %.cachedtype, align 8
store i32 %0, ptr %.anon, align 4
!136
!137
store ptr %1, ptr %.anon1, align 8
!138
!139
%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
!139
!140
%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
!143
%6 = load i32, ptr %argc2, align 4, !dbg !147
%sext = sext i32 %6 to i64, !dbg !147
!144
%6 = load i32, ptr %argc2, align 4, !dbg !148
%sext = sext i32 %6 to i64, !dbg !148
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
@@ -375,19 +388,21 @@ entry:
%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 !148
%mul = mul i64 16, %9, !dbg !156
%9 = load i64, ptr %elements8, align 8, !dbg !149
%mul = mul i64 16, %9, !dbg !157
store i64 %mul, ptr %size, align 8
%10 = load i64, ptr %size, align 8, !dbg !157
%not = icmp eq i64 %10, 0, !dbg !157
br i1 %not, label %if.then, label %if.exit, !dbg !157
%10 = load i64, ptr %size, align 8, !dbg !158
%not = icmp eq i64 %10, 0, !dbg !158
br i1 %not, label %if.then, label %if.exit, !dbg !158
if.then: ; preds = %entry
store ptr null, ptr %blockret11, align 8, !dbg !160
br label %expr_block.exit, !dbg !160
store ptr null, ptr %blockret11, align 8, !dbg !161
br label %expr_block.exit, !dbg !161
if.exit: ; preds = %entry
%ptradd = getelementptr inbounds i8, ptr %allocator10, i64 8, !dbg !161
%11 = load i64, ptr %ptradd, align 8, !dbg !161
%12 = inttoptr i64 %11 to ptr, !dbg !161
%ptradd = getelementptr inbounds i8, ptr %allocator10, i64 8, !dbg !162
%11 = load i64, ptr %ptradd, align 8, !dbg !162
%12 = inttoptr i64 %11 to ptr, !dbg !162
%type = load ptr, ptr %.cachedtype, align 8
%13 = icmp eq ptr %12, %type
br i1 %13, label %cache_hit, label %cache_miss
@@ -406,143 +421,169 @@ cache_hit: ; preds = %if.exit
%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 !163
call void %18(ptr @.panic_msg, i64 44, ptr @.file, i64 16, ptr @.func, i64 6, i32 68), !dbg !163
unreachable, !dbg !163
%18 = load ptr, ptr @std.core.builtin.panic, align 8, !dbg !164
call void %18(ptr @.panic_msg, i64 44, ptr @.file, i64 16, ptr @.func, i64 6, i32 68), !dbg !164
unreachable, !dbg !164
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 !163
%not_err = icmp eq i64 %21, 0, !dbg !163
%22 = call i1 @llvm.expect.i1(i1 %not_err, i1 true), !dbg !163
br i1 %22, label %after_check, label %assign_optional, !dbg !163
%21 = call i64 %fn_phi(ptr %retparam, ptr %19, i64 %20, i32 0, i64 0), !dbg !164
%not_err = icmp eq i64 %21, 0, !dbg !164
%22 = call i1 @llvm.expect.i1(i1 %not_err, i1 true), !dbg !164
br i1 %22, label %after_check, label %assign_optional, !dbg !164
assign_optional: ; preds = %match
store i64 %21, ptr %error_var, align 8, !dbg !163
br label %panic_block, !dbg !163
store i64 %21, ptr %error_var, align 8, !dbg !164
br label %panic_block, !dbg !164
after_check: ; preds = %match
%23 = load ptr, ptr %retparam, align 8, !dbg !163
store ptr %23, ptr %blockret11, align 8, !dbg !163
br label %expr_block.exit, !dbg !163
%23 = load ptr, ptr %retparam, align 8, !dbg !164
store ptr %23, ptr %blockret11, align 8, !dbg !164
br label %expr_block.exit, !dbg !164
expr_block.exit: ; preds = %after_check, %if.then
%24 = load ptr, ptr %blockret11, align 8, !dbg !163
%24 = load ptr, ptr %blockret11, align 8, !dbg !164
store ptr %24, ptr %taddr, align 8
%25 = load ptr, ptr %taddr, align 8
%26 = load i64, ptr %elements8, align 8, !dbg !164
%add = add i64 0, %26, !dbg !164
%size13 = sub i64 %add, 0, !dbg !164
%27 = insertvalue %"char[][]" undef, ptr %25, 0, !dbg !164
%28 = insertvalue %"char[][]" %27, i64 %size13, 1, !dbg !164
br label %noerr_block, !dbg !164
%26 = load i64, ptr %elements8, align 8, !dbg !165
%add = add i64 0, %26, !dbg !165
%size13 = sub i64 %add, 0, !dbg !165
%27 = insertvalue %"char[][]" undef, ptr %25, 0, !dbg !165
%28 = insertvalue %"char[][]" %27, i64 %size13, 1, !dbg !165
br label %noerr_block, !dbg !165
panic_block: ; preds = %assign_optional
%29 = insertvalue %any undef, ptr %error_var, 0, !dbg !164
%30 = insertvalue %any %29, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1, !dbg !164
%29 = insertvalue %any undef, ptr %error_var, 0, !dbg !165
%30 = insertvalue %any %29, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1, !dbg !165
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
unreachable, !dbg !151
unreachable, !dbg !152
noerr_block: ; preds = %expr_block.exit
store %"char[][]" %28, ptr %list5, align 8, !dbg !151
!165
store i32 0, ptr %i, align 4, !dbg !168
br label %loop.cond, !dbg !168
store %"char[][]" %28, ptr %list5, align 8, !dbg !152
!166
store i32 0, ptr %i, align 4, !dbg !169
br label %loop.cond, !dbg !169
loop.cond: ; preds = %loop.exit, %noerr_block
%32 = load i32, ptr %i, align 4, !dbg !169
%33 = load i32, ptr %argc2, align 4, !dbg !170
%lt = icmp slt i32 %32, %33, !dbg !169
br i1 %lt, label %loop.body, label %loop.exit26, !dbg !169
%32 = load i32, ptr %i, align 4, !dbg !170
%33 = load i32, ptr %argc2, align 4, !dbg !171
%lt = icmp slt i32 %32, %33, !dbg !170
br i1 %lt, label %loop.body, label %loop.exit26, !dbg !170
loop.body: ; preds = %loop.cond
!171
%34 = load ptr, ptr %argv3, align 8, !dbg !174
%35 = load i32, ptr %i, align 4, !dbg !175
%sext14 = sext i32 %35 to i64, !dbg !175
%ptroffset = getelementptr inbounds [8 x i8], ptr %34, i64 %sext14, !dbg !175
%36 = load ptr, ptr %ptroffset, align 8, !dbg !175
store ptr %36, ptr %arg, align 8, !dbg !175
!176
store i64 0, ptr %len, align 8, !dbg !178
%37 = load ptr, ptr %list5, align 8, !dbg !179
%38 = load i32, ptr %i, align 4, !dbg !180
%sext15 = sext i32 %38 to i64, !dbg !180
%ptroffset16 = getelementptr inbounds [16 x i8], ptr %37, i64 %sext15, !dbg !180
%39 = load ptr, ptr %arg, align 8, !dbg !181
!172
%34 = load ptr, ptr %argv3, align 8, !dbg !175
%35 = load i32, ptr %i, align 4, !dbg !176
%sext14 = sext i32 %35 to i64, !dbg !176
%ptroffset = getelementptr inbounds [8 x i8], ptr %34, i64 %sext14, !dbg !176
%36 = load ptr, ptr %ptroffset, align 8, !dbg !176
store ptr %36, ptr %arg, align 8, !dbg !176
!177
store i64 0, ptr %len, align 8, !dbg !179
%37 = load ptr, ptr %list5, align 8, !dbg !180
%38 = load i32, ptr %i, align 4, !dbg !181
%sext15 = sext i32 %38 to i64, !dbg !181
%ptroffset16 = getelementptr inbounds [16 x i8], ptr %37, i64 %sext15, !dbg !181
%39 = load ptr, ptr %arg, align 8, !dbg !182
%40 = load ptr, ptr %arg, align 8
store ptr %40, ptr %ptr, align 8
!182
store i64 0, ptr %len18, align 8, !dbg !186
br label %loop.cond19, !dbg !187
!183
store i64 0, ptr %len18, align 8, !dbg !187
br label %loop.cond19, !dbg !188
loop.cond19: ; preds = %loop.body21, %loop.body
%41 = load ptr, ptr %ptr, align 8, !dbg !188
%42 = load i64, ptr %len18, align 8, !dbg !190
%ptradd20 = getelementptr inbounds i8, ptr %41, i64 %42, !dbg !190
%43 = load i8, ptr %ptradd20, align 1, !dbg !190
%intbool = icmp ne i8 %43, 0, !dbg !190
br i1 %intbool, label %loop.body21, label %loop.exit, !dbg !190
%41 = load ptr, ptr %ptr, align 8, !dbg !189
%42 = load i64, ptr %len18, align 8, !dbg !191
%ptradd20 = getelementptr inbounds i8, ptr %41, i64 %42, !dbg !191
%43 = load i8, ptr %ptradd20, align 1, !dbg !191
%intbool = icmp ne i8 %43, 0, !dbg !191
br i1 %intbool, label %loop.body21, label %loop.exit, !dbg !191
loop.body21: ; preds = %loop.cond19
%44 = load i64, ptr %len18, align 8, !dbg !191
%add22 = add i64 %44, 1, !dbg !191
store i64 %add22, ptr %len18, align 8, !dbg !191
br label %loop.cond19, !dbg !191
%44 = load i64, ptr %len18, align 8, !dbg !192
%add22 = add i64 %44, 1, !dbg !192
store i64 %add22, ptr %len18, align 8, !dbg !192
br label %loop.cond19, !dbg !192
loop.exit: ; preds = %loop.cond19
%45 = load i64, ptr %len18, align 8, !dbg !192
%add23 = add i64 0, %45, !dbg !192
%size24 = sub i64 %add23, 0, !dbg !192
%46 = insertvalue %"char[]" undef, ptr %39, 0, !dbg !192
%47 = insertvalue %"char[]" %46, i64 %size24, 1, !dbg !192
store %"char[]" %47, ptr %ptroffset16, align 8, !dbg !192
%48 = load i32, ptr %i, align 4, !dbg !193
%add25 = add i32 %48, 1, !dbg !193
store i32 %add25, ptr %i, align 4, !dbg !193
br label %loop.cond, !dbg !193
%45 = load i64, ptr %len18, align 8, !dbg !193
%add23 = add i64 0, %45, !dbg !193
%size24 = sub i64 %add23, 0, !dbg !193
%46 = insertvalue %"char[]" undef, ptr %39, 0, !dbg !193
%47 = insertvalue %"char[]" %46, i64 %size24, 1, !dbg !193
store %"char[]" %47, ptr %ptroffset16, align 8, !dbg !193
%48 = load i32, ptr %i, align 4, !dbg !194
%add25 = add i32 %48, 1, !dbg !194
store i32 %add25, ptr %i, align 4, !dbg !194
br label %loop.cond, !dbg !194
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 !194
%lo = load ptr, ptr %list, align 8, !dbg !195
%ptradd27 = getelementptr inbounds i8, ptr %list, i64 8, !dbg !195
%hi = load i64, ptr %ptradd27, align 8, !dbg !195
%49 = call i32 @test.main(ptr %lo, i64 %hi), !dbg !196
store i32 %49, ptr %blockret, align 4, !dbg !196
%50 = load ptr, ptr %list, align 8, !dbg !197
call void @llvm.memcpy.p0.p0.i32(ptr align 8 %list, ptr align 8 %list5, i32 16, i1 false), !dbg !195
%lo = load ptr, ptr %list, align 8, !dbg !196
%ptradd27 = getelementptr inbounds i8, ptr %list, i64 8, !dbg !196
%hi = load i64, ptr %ptradd27, align 8, !dbg !196
%49 = call i32 @test.main(ptr %lo, i64 %hi), !dbg !197
store i32 %49, ptr %blockret, align 4, !dbg !197
%50 = load ptr, ptr %list, align 8, !dbg !198
call void @std.core.mem.free(ptr %50)
br label %expr_block.exit28, !dbg !199
br label %expr_block.exit28, !dbg !200
expr_block.exit28: ; preds = %loop.exit26
%51 = load i32, ptr %blockret, align 4, !dbg !199
ret i32 %51, !dbg !199
%51 = load i32, ptr %blockret, align 4, !dbg !200
ret i32 %51, !dbg !200
}
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)
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)
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
%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
%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}
@@ -577,7 +618,7 @@ no_match: ; preds = %compare
!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}
!34 = !{!35, !46}
!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", baseType: !38)
@@ -587,59 +628,59 @@ no_match: ; preds = %compare
!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
!56 = distinct !DISubprogram(name: "[DEFAULT INIT]", linkageName: "[DEFAULT INIT]", scope: !5, file: !5, line: 33, scopeLine: 33, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition
!57 = !DILocation(line: 18, column: 15, scope: !30)
!58 = !DILocation(line: 21, column: 8, scope: !30)
!59 = !DILocation(line: 21, column: 42, scope: !30)
!60 = !DILocation(line: 21, column: 3, scope: !30)
!61 = !DILocation(line: 23, column: 3, scope: !30)
!62 = !DILocation(line: 24, column: 10, scope: !30)
!63 = distinct !DISubprogram(name: "create_foo", linkageName: "test.create_foo", scope: !5, file: !5, line: 33, type: !64, scopeLine: 33, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition
!64 = !DISubroutineType(types: !65)
!65 = !{!49, !8, !44, !37}
!66 = !DILocalVariable(name: "attach", arg: 1, scope: !63, file: !5, line: 33, type: !8)
!67 = !DILocation(line: 33, column: 31, scope: !63)
!68 = !DILocalVariable(name: "flags", arg: 2, scope: !63, file: !5, line: 33, type: !44)
!69 = !DILocation(line: 33, column: 49, scope: !63)
!70 = !DILocalVariable(name: "name", arg: 3, scope: !63, file: !5, line: 33, type: !37)
!71 = !DILocation(line: 33, column: 63, scope: !63)
!72 = !DILocation(line:
!73 = distinct !DISubprogram(name: "new", linkageName: "new", scope: !74, file: !74
!74 = !DIFile(filename: "mem.c3"
!75 = !DILocation(line: 34, column: 15, scope: !63)
!76 = distinct !DISubprogram(name: "test", linkageName: "test.test", scope: !5, file: !5, line: 41, type: !77, scopeLine: 41, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition
!77 = !DISubroutineType(types: !78)
!78 = !{!49, !79}
!79 = !DIDerivedType(tag: DW_TAG_typedef, name: "Color", scope: !5, file: !5, line: 79, baseType: !80, align: 16)
!80 = !DICompositeType(tag: DW_TAG_array_type, baseType: !81, size: 128, align: 32, flags: DIFlagVector, elements: !82)
!81 = !DIBasicType(name: "float", size: 32, encoding: DW_ATE_float)
!82 = !{!83}
!83 = !DISubrange(count: 4, lowerBound: 0)
!84 = !DILocalVariable(name: "color", arg: 1, scope: !76, file: !5, line: 41, type: !79)
!85 = !DILocation(line: 41, column: 20, scope: !76)
!86 = !DILocation
!87 = distinct !DISubprogram(name: "printn", linkageName: "printn"
!88 = !DIFile(filename: "io.c3"
!89 = !DILocation(line: 42, column: 7, scope: !76)
!90 = !DILocalVariable(name: "len"
!91 = distinct !DISubprogram(name: "fprintn", linkageName: "fprintn"
!92 = !DILocation
!44 = !DIDerivedType(tag: DW_TAG_typedef, name: "usz", baseType: !45)
!45 = !DIBasicType(name: "ulong", size: 64, encoding: DW_ATE_unsigned)
!46 = !DIDerivedType(tag: DW_TAG_member, name: "len", scope: !33, baseType: !44, size: 64, align: 64, offset: 64)
!47 = !DILocalVariable(name: "args", arg: 1, scope: !30, file: !5, line: 15, type: !33)
!48 = !DILocation(line: 15, column: 22, scope: !30)
!49 = !DILocalVariable(name: "asdf", scope: !30, file: !5, line: 18, type: !50, align: 8)
!50 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "Foo*", baseType: !51, size: 64, align: 64, dwarfAddressSpace: 0)
!51 = !DICompositeType(tag: DW_TAG_structure_type, name: "Foo", scope: !5, file: !5, line: 27, size: 64, align: 64, elements: !52, identifier: "test.Foo")
!52 = !{!53}
!53 = !DIDerivedType(tag: DW_TAG_member, name: "asdf", scope: !51, file: !5, line: 28, baseType: !12, size: 64, align: 64)
!54 = !DILocation(line: 18, column: 8, scope: !30)
!55 = !DILocation(line: 18, column: 34, scope: !30)
!56 = !DILocation
!57 = distinct !DISubprogram(name: "[DEFAULT INIT]", linkageName: "[DEFAULT INIT]", scope: !5, file: !5, line: 33, scopeLine: 33, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition
!58 = !DILocation(line: 18, column: 15, scope: !30)
!59 = !DILocation(line: 21, column: 8, scope: !30)
!60 = !DILocation(line: 21, column: 42, scope: !30)
!61 = !DILocation(line: 21, column: 3, scope: !30)
!62 = !DILocation(line: 23, column: 3, scope: !30)
!63 = !DILocation(line: 24, column: 10, scope: !30)
!64 = distinct !DISubprogram(name: "create_foo", linkageName: "test.create_foo", scope: !5, file: !5, line: 33, type: !65, scopeLine: 33, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !4, retainedNodes: !19)
!65 = !DISubroutineType(types: !66)
!66 = !{!50, !8, !45, !37}
!67 = !DILocalVariable(name: "attach", arg: 1, scope: !64, file: !5, line: 33, type: !8)
!68 = !DILocation(line: 33, column: 31, scope: !64)
!69 = !DILocalVariable(name: "flags", arg: 2, scope: !64, file: !5, line: 33, type: !45)
!70 = !DILocation(line: 33, column: 49, scope: !64)
!71 = !DILocalVariable(name: "name", arg: 3, scope: !64, file: !5, line: 33, type: !37)
!72 = !DILocation(line: 33, column: 63, scope: !64)
!73 = !DILocation(line:
!74 = distinct !DISubprogram(name: "new", linkageName: "new", scope: !75, file: !75, line: 597, scopeLine: 597, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !4)
!75 = !DIFile(filename: "mem.c3"
!76 = !DILocation(line: 34, column: 15, scope: !64)
!77 = distinct !DISubprogram(name: "test", linkageName: "test.test", scope: !5, file: !5, line: 41, type: !78, scopeLine: 41, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !4, retainedNodes: !19)
!78 = !DISubroutineType(types: !79)
!79 = !{!50, !80}
!80 = !DIDerivedType(tag: DW_TAG_typedef, name: "Color", scope: !5, file: !5, line: 79, baseType: !81, align: 16)
!81 = !DICompositeType(tag: DW_TAG_array_type, baseType: !82, size: 128, align: 32, flags: DIFlagVector, elements: !83)
!82 = !DIBasicType(name: "float", size: 32, encoding: DW_ATE_float)
!83 = !{!84}
!84 = !DISubrange(count: 4, lowerBound: 0)
!85 = !DILocalVariable(name: "color", arg: 1, scope: !77, file: !5, line: 41, type: !80)
!86 = !DILocation(line: 41, column: 20, scope: !77)
!87 = !DILocation
!88 = distinct !DISubprogram(name: "printn", linkageName: "printn"
!89 = !DIFile(filename: "io.c3"
!90 = !DILocation(line: 42, column: 7, scope: !77)
!91 = !DILocalVariable(name: "len"
!92 = distinct !DISubprogram(name: "fprintn", linkageName: "fprintn", scope: !89, file: !89, line: 166, scopeLine: 166, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !4, retainedNodes: !19)
!93 = !DILocation
!94 = !DILocation
!95 = distinct !DISubprogram(name: "fprint", linkageName: "fprint"
!96 = !DILocation
!95 = !DILocation
!96 = distinct !DISubprogram(name: "fprint", linkageName: "fprint"
!97 = !DILocation
!98 = !DILocation
!99 = !DILocation
@@ -647,93 +688,93 @@ no_match: ; preds = %compare
!101 = !DILocation
!102 = !DILocation
!103 = !DILocation
!104 = distinct !DISubprogram(name: "test2", linkageName: "test.test2", scope: !5, file: !5, line: 48, type: !105, scopeLine: 48, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition
!105 = !DISubroutineType(types: !106)
!106 = !{!12}
!107 = !DILocalVariable(name: "scratch", scope: !108, file: !5, line: 110, type: !109, align: 8)
!108 = distinct !DISubprogram(name: "@scratch", linkageName: "@scratch", scope: !5, file: !5, line: 109, scopeLine: 109, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition
!109 = !DICompositeType(tag: DW_TAG_structure_type, name: "Arena_Cursor", scope: !5, file: !5, line: 88, size: 128, align: 64, elements: !110, identifier: "foo__Arena_Cursor")
!110 = !{!111, !116}
!111 = !DIDerivedType(tag: DW_TAG_member, name: "arena", scope: !109, file: !5, line: 89, baseType: !112, size: 64, align: 64)
!112 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "Arena*", baseType: !113, size: 64, align: 64, dwarfAddressSpace: 0)
!113 = !DICompositeType(tag: DW_TAG_structure_type, name: "Arena", scope: !5, file: !5, line: 84, size: 64, align: 64, elements: !114, identifier: "foo__Arena")
!114 = !{!115}
!115 = !DIDerivedType(tag: DW_TAG_member, name: "cursor", scope: !113, file: !5, line: 85, baseType: !44, size: 64, align: 64)
!116 = !DIDerivedType(tag: DW_TAG_member, name: "cursor", scope: !109, file: !5, line: 90, baseType: !44, size: 64, align: 64, offset: 64)
!117 = !DILocation
!118 = !DILocation(line: 50, column: 3, scope: !104)
!119 = !DILocation
!104 = !DILocation
!105 = distinct !DISubprogram(name: "test2", linkageName: "test.test2", scope: !5, file: !5, line: 48, type: !106, scopeLine: 48, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition
!106 = !DISubroutineType(types: !107)
!107 = !{!12}
!108 = !DILocalVariable(name: "scratch", scope: !109, file: !5, line: 110, type: !110, align: 8)
!109 = distinct !DISubprogram(name: "@scratch", linkageName: "@scratch", scope: !5, file: !5, line: 109, scopeLine: 109, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition
!110 = !DICompositeType(tag: DW_TAG_structure_type, name: "Arena_Cursor", scope: !5, file: !5, line: 88, size: 128, align: 64, elements: !111, identifier: "foo__Arena_Cursor")
!111 = !{!112, !117}
!112 = !DIDerivedType(tag: DW_TAG_member, name: "arena", scope: !110, file: !5, line: 89, baseType: !113, size: 64, align: 64)
!113 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "Arena*", baseType: !114, size: 64, align: 64, dwarfAddressSpace: 0)
!114 = !DICompositeType(tag: DW_TAG_structure_type, name: "Arena", scope: !5, file: !5, line: 84, size: 64, align: 64, elements: !115, identifier: "foo__Arena")
!115 = !{!116}
!116 = !DIDerivedType(tag: DW_TAG_member, name: "cursor", scope: !114, file: !5, line: 85, baseType: !44, size: 64, align: 64)
!117 = !DIDerivedType(tag: DW_TAG_member, name: "cursor", scope: !110, file: !5, line: 90, baseType: !44, size: 64, align: 64, offset: 64)
!118 = !DILocation
!119 = !DILocation(line: 50, column: 3, scope: !105)
!120 = !DILocation
!121 = !DILocalVariable(name: "scratch", scope: !104, file: !5, line: 50, type: !112, align: 8)
!122 = !DILocation(line: 50, column: 21, scope: !104)
!123 = !DILocation
!124 = distinct !DILexicalBlock(scope: !108, file: !5, line: 112, column: 3)
!125 = !DILocalVariable(name: "asdf", scope: !126, file: !5, line: 51, type: !12, align: 8)
!126 = distinct !DILexicalBlock(scope: !104, file: !5, line: 50, column: 30)
!127 = !DILocation(line: 51, column: 11, scope: !126)
!128 = !DILocation(line: 52, column: 12, scope: !126)
!129 = !DILocation
!130 = distinct !DILexicalBlock(scope: !108, file: !5, line: 111, column: 9)
!131 = !DILocation
!132 = distinct !DISubprogram(name: "_$main", linkageName: "main", scope: !5, file: !5, line: 15, type: !133, scopeLine: 15, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition
!133 = !DISubroutineType(types: !134)
!134 = !{!13, !13, !135}
!135 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "char**", baseType: !41, size: 64, align: 64
!136 = !DILocalVariable(name: ".anon", arg: 1, scope: !132, file: !5, line: 15, type: !13)
!137 = !DILocation(line: 15, column: 8, scope: !132)
!138 = !DILocalVariable(name: ".anon", arg: 2, scope: !132, file: !5, line: 15, type: !135)
!139 = !DILocalVariable(name: "list", scope: !140, file: !5, line: 45, type: !33, align: 8)
!140 = distinct !DISubprogram(name: "@main_to_int_main_args", linkageName: "@main_to_int_main_args"
!141 = !DIFile(filename: "main_stub.c3"
!142 = !DILocation
!143 = !DILocalVariable(name: "list", scope: !144, file: !5, line: 24, type: !33, align: 8)
!144 = distinct !DISubprogram(name: "args_to_strings"
!145 = !DILocation
!121 = !DILocation
!122 = !DILocalVariable(name: "scratch", scope: !105, file: !5, line: 50, type: !113, align: 8)
!123 = !DILocation(line: 50, column: 21, scope: !105)
!124 = !DILocation
!125 = distinct !DILexicalBlock(scope: !109, file: !5, line: 112, column: 3)
!126 = !DILocalVariable(name: "asdf", scope: !127, file: !5, line: 51, type: !12, align: 8)
!127 = distinct !DILexicalBlock(scope: !105, file: !5, line: 50, column: 30)
!128 = !DILocation(line: 51, column: 11, scope: !127)
!129 = !DILocation(line: 52, column: 12, scope: !127)
!130 = !DILocation
!131 = distinct !DILexicalBlock(scope: !109, file: !5, line: 111, column: 9)
!132 = !DILocation
!133 = distinct !DISubprogram(name: "_$main", linkageName: "main", scope: !5, file: !5, line: 15, type: !134, scopeLine: 15, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !4, retainedNodes: !19)
!134 = !DISubroutineType(types: !135)
!135 = !{!13, !13, !136}
!136 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "char**", baseType: !41, size: 64, align: 64
!137 = !DILocalVariable(name: ".anon", arg: 1, scope: !133, file: !5, line: 15, type: !13)
!138 = !DILocation(line: 15, column: 8, scope: !133)
!139 = !DILocalVariable(name: ".anon", arg: 2, scope: !133, file: !5, line: 15, type: !136)
!140 = !DILocalVariable(name: "list", scope: !141, file: !5, line: 45, type: !33, align: 8)
!141 = distinct !DISubprogram(name: "@main_to_int_main_args", linkageName: "@main_to_int_main_args"
!142 = !DIFile(filename: "main_stub.c3"
!143 = !DILocation
!144 = !DILocalVariable(name: "list", scope: !145, file: !5, line: 24, type: !33, align: 8)
!145 = distinct !DISubprogram(name: "args_to_strings", linkageName: "args_to_strings", scope: !142, file: !142, line: 22, scopeLine: 22, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !4, retainedNodes: !19)
!146 = !DILocation
!147 = !DILocation
!148 = !DILocation
!149 = distinct !DISubprogram(name: "alloc_array_try", linkageName: "alloc_array_try"
!150 = !DIFile(filename: "mem_allocator.c3"
!151 = !DILocation
!152 = distinct !DISubprogram(name: "alloc_array", linkageName: "alloc_array"
!153 = !DILocation
!154 = distinct !DISubprogram(name: "alloc_array", linkageName: "alloc_array"
!155 = !DILocation
!149 = !DILocation
!150 = distinct !DISubprogram(name: "alloc_array_try", linkageName: "alloc_array_try"
!151 = !DIFile(filename: "mem_allocator.c3"
!152 = !DILocation
!153 = distinct !DISubprogram(name: "alloc_array", linkageName: "alloc_array"
!154 = !DILocation
!155 = distinct !DISubprogram(name: "alloc_array", linkageName: "alloc_array"
!156 = !DILocation
!157 = !DILocation
!158 = distinct !DISubprogram(name: "malloc_try", linkageName: "malloc_try", scope: !150, file: !150, line: 60, scopeLine: 60, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition
!159 = !DILocation
!158 = !DILocation
!159 = distinct !DISubprogram(name: "malloc_try", linkageName: "malloc_try", scope: !151, file: !151, line: 60, scopeLine: 60, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !4)
!160 = !DILocation
!161 = !DILocation
!162 = distinct !DISubprogram(name: "[DEFAULT INIT]", linkageName: "[DEFAULT INIT]", scope: !150, file: !150, line: 28, scopeLine: 28, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition
!163 = !DILocation
!162 = !DILocation
!163 = distinct !DISubprogram(name: "[DEFAULT INIT]", linkageName: "[DEFAULT INIT]", scope: !151, file: !151, line: 28, scopeLine: 28, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !4)
!164 = !DILocation
!165 = !DILocalVariable(name: "i", scope: !166, file: !5, line: 25, type: !13, align: 4)
!166 = distinct !DILexicalBlock(scope: !144, file: !141, line: 25, column: 2)
!167 = !DILocation
!165 = !DILocation
!166 = !DILocalVariable(name: "i", scope: !167, file: !5, line: 25, type: !13, align: 4)
!167 = distinct !DILexicalBlock(scope: !145, file: !142, line: 25, column: 2)
!168 = !DILocation
!169 = !DILocation
!170 = !DILocation
!171 = !DILocalVariable(name: "arg", scope: !172, file: !5, line: 27, type: !41, align: 8)
!172 = distinct !DILexicalBlock(scope: !166, file: !141, line: 26, column: 2)
!173 = !DILocation
!171 = !DILocation
!172 = !DILocalVariable(name: "arg", scope: !173, file: !5, line: 27, type: !41, align: 8)
!173 = distinct !DILexicalBlock(scope: !167, file: !142, line: 26, column: 2)
!174 = !DILocation
!175 = !DILocation
!176 = !DILocalVariable(name: "len", scope: !172, file: !5, line: 28, type: !44, align: 8)
!177 = !DILocation
!176 = !DILocation
!177 = !DILocalVariable(name: "len", scope: !173, file: !5, line: 28, type: !44, align: 8)
!178 = !DILocation
!179 = !DILocation
!180 = !DILocation
!181 = !DILocation
!182 = !DILocalVariable(name: "len", scope: !183, file: !5, line: 5, type: !44, align: 8)
!183 = distinct !DISubprogram(name: "_strlen", linkageName: "_strlen", scope: !141, file: !141, line: 3, scopeLine: 3, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition
!184 = !DILocation
!182 = !DILocation
!183 = !DILocalVariable(name: "len", scope: !184, file: !5, line: 5, type: !44, align: 8)
!184 = distinct !DISubprogram(name: "_strlen", linkageName: "_strlen", scope: !142, file: !142, line: 3, scopeLine: 3, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition
!185 = !DILocation
!186 = !DILocation
!187 = !DILocation
!188 = !DILocation
!189 = distinct !DILexicalBlock(scope: !183, file: !141, line: 6, column: 2)
!190 = !DILocation
!189 = !DILocation
!190 = distinct !DILexicalBlock(scope: !184, file: !142, line: 6, column: 2)
!191 = !DILocation
!192 = !DILocation
!193 = !DILocation
@@ -741,5 +782,6 @@ no_match: ; preds = %compare
!195 = !DILocation
!196 = !DILocation
!197 = !DILocation
!198 = distinct !DILexicalBlock(scope: !140, file: !141, line: 46, column: 8)
!199 = !DILocation
!198 = !DILocation
!199 = distinct !DILexicalBlock(scope: !141,
!200 = !DILocation

View File

@@ -23,50 +23,51 @@ entry:
%ptradd = getelementptr inbounds i8, ptr %args, i64 8
store i64 %1, ptr %ptradd, align 8
!24
!27
%ptradd1 = getelementptr inbounds i8, ptr %args, i64 8, !dbg !27
%2 = load i64, ptr %ptradd1, align 8, !dbg !27
store i64 %2, ptr %.anon, align 8, !dbg !27
!27
store i64 0, ptr %.anon2, align 8, !dbg !27
br label %loop.cond, !dbg !27
!26
%ptradd1 = getelementptr inbounds i8, ptr %args, i64 8, !dbg !28
%2 = load i64, ptr %ptradd1, align 8, !dbg !28
store i64 %2, ptr %.anon, align 8, !dbg !28
!26
store i64 0, ptr %.anon2, align 8, !dbg !28
br label %loop.cond, !dbg !28
loop.cond: ; preds = %loop.body, %entry
%3 = load i64, ptr %.anon2, align 8, !dbg !27
%4 = load i64, ptr %.anon, align 8, !dbg !27
%lt = icmp ult i64 %3, %4, !dbg !27
br i1 %lt, label %loop.body, label %loop.exit, !dbg !27
%3 = load i64, ptr %.anon2, align 8, !dbg !28
%4 = load i64, ptr %.anon, align 8, !dbg !28
%lt = icmp ult i64 %3, %4, !dbg !28
br i1 %lt, label %loop.body, label %loop.exit, !dbg !28
loop.body: ; preds = %loop.cond
!30
%5 = load ptr, ptr %args, align 8, !dbg !31
%6 = load i64, ptr %.anon2, align 8, !dbg !31
%ptroffset = getelementptr inbounds [16 x i8], ptr %5, i64 %6, !dbg !31
call void @llvm.memcpy.p0.p0.i32(ptr align 8 %a, ptr align 8 %ptroffset, i32 16, i1 false), !dbg !31
!35
%ptradd3 = getelementptr inbounds i8, ptr %a, i64 8, !dbg !36
%7 = load i64, ptr %ptradd3, align 8, !dbg !36
%trunc = trunc i64 %7 to i32, !dbg !36
store i32 %trunc, ptr %x, align 4, !dbg !36
%8 = load i64, ptr %.anon2, align 8, !dbg !27
%addnuw = add nuw i64 %8, 1, !dbg !27
store i64 %addnuw, ptr %.anon2, align 8, !dbg !27
br label %loop.cond, !dbg !27
!29
%5 = load ptr, ptr %args, align 8, !dbg !32
%6 = load i64, ptr %.anon2, align 8, !dbg !32
%ptroffset = getelementptr inbounds [16 x i8], ptr %5, i64 %6, !dbg !32
call void @llvm.memcpy.p0.p0.i32(ptr align 8 %a, ptr align 8 %ptroffset, i32 16, i1 false), !dbg !32
!33
%ptradd3 = getelementptr inbounds i8, ptr %a, i64 8, !dbg !37
%7 = load i64, ptr %ptradd3, align 8, !dbg !37
%trunc = trunc i64 %7 to i32, !dbg !37
store i32 %trunc, ptr %x, align 4, !dbg !37
%8 = load i64, ptr %.anon2, align 8, !dbg !28
%addnuw = add nuw i64 %8, 1, !dbg !28
store i64 %addnuw, ptr %.anon2, align 8, !dbg !28
br label %loop.cond, !dbg !28
loop.exit: ; preds = %loop.cond
ret void, !dbg !27
ret void, !dbg !28
}
!23 = !DILocalVariable(name: "args", arg: 1, scope: !6, file: !5, line: 3, type: !9)
!24 = !DILocation(line: 3, column: 22, scope: !6)
!25 = !DILocalVariable(name: ".temp", scope: !26, file: !5, line: 5, type: !20, align: 8)
!26 = distinct !DILexicalBlock(scope: !6, file: !5, line: 5, column: 2)
!27 = !DILocation(line: 5, column: 15, scope: !26)
!28 = !DILocalVariable(name: "a", scope: !29, file: !5, line: 5, type: !13, align: 8)
!29 = distinct !DILexicalBlock(scope: !26, file: !5, line: 6, column: 2)
!30 = !DILocation(line: 5, column: 11, scope: !29)
!31 = !DILocation(line: 5, column: 15, scope: !29)
!32 = !DILocalVariable(name: "x", scope: !33, file: !5, line: 7, type: !34, align: 4)
!33 = distinct !DILexicalBlock(scope: !29, file: !5, line: 6, column: 2)
!34 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
!35 = !DILocation(line: 7, column: 7, scope: !33)
!36 = !DILocation(line: 7, column: 11, scope: !33)
!24 = !DILocalVariable(name: "args", arg: 1, scope: !6, file: !5, line: 3, type: !9)
!25 = !DILocation(line: 3, column: 22, scope: !6)
!26 = !DILocalVariable(name: ".temp", scope: !27, file: !5, line: 5, type: !20, align: 8)
!27 = distinct !DILexicalBlock(scope: !6, file: !5, line: 5, column: 2)
!28 = !DILocation(line: 5, column: 15, scope: !27)
!29 = !DILocalVariable(name: "a", scope: !30, file: !5, line: 5, type: !13, align: 8)
!30 = distinct !DILexicalBlock(scope: !27, file: !5, line: 6, column: 2)
!31 = !DILocation(line: 5, column: 11, scope: !30)
!32 = !DILocation(line: 5, column: 15, scope: !30)
!33 = !DILocalVariable(name: "x", scope: !34, file: !5, line: 7, type: !35, align: 4)
!34 = distinct !DILexicalBlock(scope: !30, file: !5, line: 6, column: 2)
!35 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
!36 = !DILocation(line: 7, column: 7, scope: !34)
!37 = !DILocation(line: 7, column: 11, scope: !34)