From 92b4eeaa3589eb56fa85f48894702288255e9051 Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Wed, 10 Aug 2022 19:13:11 +0200 Subject: [PATCH] Update codegen for failable folding. Fixes chained init, e.g. "int! a = b = TestErr.FOO!" --- src/compiler/llvm_codegen_expr.c | 97 ++- src/compiler/llvm_codegen_internal.h | 3 +- src/compiler/llvm_codegen_value.c | 49 +- src/compiler/tilde_codegen.c | 2 +- src/version.h | 2 +- test/test_suite/enumerations/enum_cast.c3t | 6 +- test/test_suite/errors/anyerr_void.c3t | 16 +- test/test_suite/errors/else_checks.c3t | 44 +- test/test_suite/errors/error_regression_2.c3t | 60 +- .../errors/failable_chained_init.c3t | 722 ++++++++++++++++++ test/test_suite/errors/failable_inits.c3t | 24 +- .../errors/failable_taddr_and_access.c3t | 46 +- test/test_suite/errors/macro_err.c3t | 10 +- test/test_suite/errors/macro_err2.c3t | 6 +- test/test_suite/errors/printing_errors.c3t | 6 +- test/test_suite/errors/rethrow.c3t | 9 +- test/test_suite/errors/rethrow_mingw.c3t | 9 +- test/test_suite/errors/try_assign.c3t | 9 +- test/test_suite/errors/try_catch_if.c3t | 14 +- .../errors/try_unwrap_using_assert.c3t | 10 +- .../errors/try_with_chained_unwrap.c3t | 14 +- test/test_suite/errors/try_with_unwrap.c3t | 20 +- test/test_suite/errors/try_with_unwrapper.c3t | 27 +- .../expressions/chained_ternary.c3t | 34 +- .../from_docs/examples_if_catch.c3t | 26 +- test/test_suite/generic/enum_set_test.c3t | 30 +- test/test_suite/macros/macro_body_defer.c3t | 6 +- .../macros/macro_failable_return_rethrow.c3t | 10 +- .../statements/various_switching.c3t | 6 +- test/test_suite2/enumerations/enum_cast.c3t | 6 +- test/test_suite2/errors/anyerr_void.c3t | 16 +- test/test_suite2/errors/else_checks.c3t | 44 +- .../test_suite2/errors/error_regression_2.c3t | 72 +- .../errors/failable_chained_init.c3t | 672 ++++++++++++++++ test/test_suite2/errors/failable_inits.c3t | 24 +- .../errors/failable_taddr_and_access.c3t | 46 +- test/test_suite2/errors/macro_err.c3t | 10 +- test/test_suite2/errors/macro_err2.c3t | 6 +- test/test_suite2/errors/printing_errors.c3t | 6 +- test/test_suite2/errors/rethrow.c3t | 9 +- test/test_suite2/errors/rethrow_mingw.c3t | 9 +- test/test_suite2/errors/try_assign.c3t | 6 +- test/test_suite2/errors/try_catch_if.c3t | 12 +- .../errors/try_unwrap_using_assert.c3t | 10 +- .../errors/try_with_chained_unwrap.c3t | 14 +- test/test_suite2/errors/try_with_unwrap.c3t | 16 +- .../test_suite2/errors/try_with_unwrapper.c3t | 24 +- .../expressions/chained_ternary.c3t | 34 +- .../from_docs/examples_if_catch.c3t | 26 +- test/test_suite2/generic/enum_set_test.c3t | 30 +- test/test_suite2/macros/macro_body_defer.c3t | 6 +- .../macros/macro_failable_return_rethrow.c3t | 10 +- .../statements/various_switching.c3t | 6 +- 53 files changed, 1938 insertions(+), 493 deletions(-) create mode 100644 test/test_suite/errors/failable_chained_init.c3t create mode 100644 test/test_suite2/errors/failable_chained_init.c3t diff --git a/src/compiler/llvm_codegen_expr.c b/src/compiler/llvm_codegen_expr.c index 92c9ed141..7290dcbaf 100644 --- a/src/compiler/llvm_codegen_expr.c +++ b/src/compiler/llvm_codegen_expr.c @@ -22,35 +22,59 @@ static inline void llvm_emit_initialize_reference(GenContext *c, BEValue *ref, E BEValue llvm_emit_assign_expr(GenContext *c, BEValue *ref, Expr *expr, LLVMValueRef failable) { assert(ref->kind == BE_ADDRESS || ref->kind == BE_ADDRESS_FAILABLE); - LLVMBasicBlockRef assign_block = NULL; + + assert(failable || !IS_FAILABLE(expr)); + // Special optimization of handling of failable + if (expr->expr_kind == EXPR_FAILABLE) + { + PUSH_ERROR(); + + c->error_var = NULL; + c->catch_block = NULL; + BEValue result; + // Emit the fault type. + llvm_emit_expr(c, &result, expr->inner_expr); + LLVMValueRef err_val = result.value; + // Store it in the failable + llvm_store_value_dest_aligned(c, failable, &result); + // Set the result to an undef value + llvm_value_set(&result, LLVMGetUndef(llvm_get_type(c, ref->type)), ref->type); + + POP_ERROR(); + + // If we had a catch block outside then we want to jump to that exit. + if (c->catch_block) llvm_emit_jump_to_optional_exit(c, err_val); + + // This return value will not be used. + return result; + } PUSH_ERROR(); - if (failable) + + LLVMBasicBlockRef assign_block = NULL; + LLVMBasicBlockRef rejump_block = NULL; + + if (IS_FAILABLE(expr)) { - if (IS_FAILABLE(expr)) + assign_block = llvm_basic_block_new(c, "after_assign"); + assert(failable); + if (c->error_var) { - if (expr->expr_kind == EXPR_FAILABLE) - { - c->error_var = NULL; - c->catch_block = NULL; - BEValue result; - llvm_emit_expr(c, &result, expr->inner_expr); - llvm_store_value_dest_aligned(c, failable, &result); - llvm_value_set(&result, LLVMGetUndef(llvm_get_type(c, ref->type)), ref->type); - POP_ERROR(); - return result; - } - assign_block = llvm_basic_block_new(c, "after_assign"); - c->error_var = failable; - c->catch_block = assign_block; + c->catch_block = rejump_block = llvm_basic_block_new(c, "optional_assign_jump"); } else { - c->error_var = NULL; - c->catch_block = NULL; + c->catch_block = assign_block; } + c->error_var = failable; } + else + { + c->error_var = NULL; + c->catch_block = NULL; + } + BEValue value; if (type_is_vector(expr->type)) { @@ -79,9 +103,16 @@ BEValue llvm_emit_assign_expr(GenContext *c, BEValue *ref, Expr *expr, LLVMValue } POP_ERROR(); - if (failable && IS_FAILABLE(expr)) + if (assign_block) { llvm_emit_br(c, assign_block); + if (rejump_block) + { + llvm_emit_block(c, rejump_block); + LLVMValueRef error = llvm_load_natural_alignment(c, type_anyerr, failable, "reload_err"); + llvm_store_raw_abi_alignment(c, c->error_var, error, type_anyerr); + llvm_emit_br(c, c->catch_block); + } llvm_emit_block(c, assign_block); } @@ -4983,30 +5014,20 @@ void llvm_emit_call_expr(GenContext *c, BEValue *result_value, Expr *expr) { llvm_value_set_address_abi_aligned(&error_holder, c->error_var, type_anyerr); } - // 17b. Generate a boolean switch. - llvm_value_set_bool(&no_err, llvm_emit_is_no_error(c, llvm_load_value(c, &error_holder))); - // 17c. If we have an error var, or we aren't interested in the error variable - // - then it's straightforward. We just jump to the catch block. - LLVMBasicBlockRef after_block = llvm_basic_block_new(c, "after.errcheck"); - if (error_var || !c->error_var) + LLVMValueRef stored_error; + + if (error_var) { - llvm_emit_cond_br(c, &no_err, after_block, c->catch_block); + stored_error = c->error_var; + c->error_var = NULL; } - else + llvm_emit_jump_to_optional_exit(c, llvm_load_value(c, &error_holder)); + if (error_var) { - // 17d. If we have an error var we need to assign, then we need to - // first jump to an error block, where we do the copy. - LLVMBasicBlockRef error_block = llvm_basic_block_new(c, "error"); - llvm_emit_cond_br(c, &no_err, after_block, error_block); - llvm_emit_block(c, error_block); - llvm_store_value_aligned(c, c->error_var, result_value, type_alloca_alignment(type_anyerr)); - // 17e. Then jump to the catch. - llvm_emit_br(c, c->catch_block); + c->error_var = stored_error; } - // 17f. Emit the "after" block. - llvm_emit_block(c, after_block); // 17g. If void, be_value contents should be skipped. if (!prototype->ret_by_ref) diff --git a/src/compiler/llvm_codegen_internal.h b/src/compiler/llvm_codegen_internal.h index 0c131d3be..0f5a0dc80 100644 --- a/src/compiler/llvm_codegen_internal.h +++ b/src/compiler/llvm_codegen_internal.h @@ -256,10 +256,11 @@ LLVMTypeRef llvm_const_padding_type(GenContext *c, TypeSize size); LLVMValueRef llvm_emit_alloca(GenContext *c, LLVMTypeRef type, unsigned alignment, const char *name); LLVMValueRef llvm_emit_alloca_aligned(GenContext *c, Type *type, const char *name); void llvm_emit_and_set_decl_alloca(GenContext *c, Decl *decl); -BEValue llvm_emit_assign_expr(GenContext *context, BEValue *ref, Expr *expr, LLVMValueRef failable); +BEValue llvm_emit_assign_expr(GenContext *c, BEValue *ref, Expr *expr, LLVMValueRef failable); static inline LLVMValueRef llvm_emit_bitcast(GenContext *context, LLVMValueRef value, Type *type); void llvm_emit_block(GenContext *c, LLVMBasicBlockRef next_block); void llvm_emit_br(GenContext *c, LLVMBasicBlockRef next_block); +void llvm_emit_jump_to_optional_exit(GenContext *c, LLVMValueRef err_value); void llvm_emit_compound_stmt(GenContext *c, Ast *ast); LLVMValueRef llvm_emit_const_bitstruct(GenContext *c, ConstInitializer *initializer); void llvm_emit_convert_value_from_coerced(GenContext *c, BEValue *result, LLVMTypeRef coerced, LLVMValueRef value, Type *original_type); diff --git a/src/compiler/llvm_codegen_value.c b/src/compiler/llvm_codegen_value.c index f947d96a7..b96b2065d 100644 --- a/src/compiler/llvm_codegen_value.c +++ b/src/compiler/llvm_codegen_value.c @@ -47,7 +47,7 @@ void llvm_value_addr(GenContext *c, BEValue *value) void llvm_value_rvalue(GenContext *c, BEValue *value) { - if (value->kind != BE_ADDRESS && value->kind != BE_ADDRESS_FAILABLE) + if (!llvm_value_is_addr(value)) { if (value->type->type_kind == TYPE_BOOL && value->kind != BE_BOOLEAN) { @@ -71,27 +71,50 @@ void llvm_value_rvalue(GenContext *c, BEValue *value) value->kind = BE_VALUE; } -void llvm_value_fold_failable(GenContext *c, BEValue *value) +void llvm_emit_jump_to_optional_exit(GenContext *c, LLVMValueRef err_value) { - if (value->kind == BE_ADDRESS_FAILABLE) + assert(c->catch_block && "unexpected emit"); + bool is_constant_err = LLVMIsConstant(err_value); + + // Maybe we don't need to emit anything? + if (is_constant_err && LLVMIsNull(err_value)) return; + + LLVMBasicBlockRef after_block = llvm_basic_block_new(c, "after_check"); + // No error variable + if (!c->error_var) { - LLVMBasicBlockRef after_block = llvm_basic_block_new(c, "after_check"); - LLVMValueRef err_value = llvm_load_natural_alignment(c, type_anyerr, value->failable, ""); - LLVMValueRef was_ok = llvm_emit_is_no_error(c, err_value); - if (c->error_var) + // No error var and a constant error means jumping to the "catch" block + if (is_constant_err) { - LLVMBasicBlockRef error_block = llvm_basic_block_new(c, "error"); - llvm_emit_cond_br_raw(c, was_ok, after_block, error_block); - llvm_emit_block(c, error_block); - llvm_store_raw_abi_alignment(c, c->error_var, err_value, type_anyerr); llvm_emit_br(c, c->catch_block); } else { - assert(c->catch_block); - llvm_emit_cond_br_raw(c, was_ok, after_block, c->catch_block); + llvm_emit_cond_br_raw(c, llvm_emit_is_no_error(c, err_value), after_block, c->catch_block); } llvm_emit_block(c, after_block); + return; + } + + // If it's not a constant, then jump conditionally + if (!is_constant_err) + { + LLVMValueRef was_ok = llvm_emit_is_no_error(c, err_value); + LLVMBasicBlockRef error_block = llvm_basic_block_new(c, "assign_optional"); + llvm_emit_cond_br_raw(c, was_ok, after_block, error_block); + llvm_emit_block(c, error_block); + } + + llvm_store_raw_abi_alignment(c, c->error_var, err_value, type_anyerr); + llvm_emit_br(c, c->catch_block); + llvm_emit_block(c, after_block); +} + +void llvm_value_fold_failable(GenContext *c, BEValue *value) +{ + if (value->kind == BE_ADDRESS_FAILABLE) + { + llvm_emit_jump_to_optional_exit(c, llvm_load_natural_alignment(c, type_anyerr, value->failable, "")); value->kind = BE_ADDRESS; } } diff --git a/src/compiler/tilde_codegen.c b/src/compiler/tilde_codegen.c index c90056385..9ad904418 100644 --- a/src/compiler/tilde_codegen.c +++ b/src/compiler/tilde_codegen.c @@ -772,7 +772,7 @@ void llvm_value_fold_failable(GenContext *c, BEValue *value) llvm_value_set_bool(&comp, llvm_emit_is_no_error_value(c, &error_value)); if (c->error_var) { - LLVMBasicBlockRef error_block = llvm_basic_block_new(c, "error"); + LLVMBasicBlockRef error_block = llvm_basic_block_new(c, "assign_optional"); llvm_emit_cond_br(c, &comp, after_block, error_block); llvm_emit_block(c, error_block); llvm_store_bevalue_dest_aligned(c, c->error_var, &error_value); diff --git a/src/version.h b/src/version.h index 45ef2d2cc..331568928 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define COMPILER_VERSION "0.3.9" \ No newline at end of file +#define COMPILER_VERSION "0.3.10" \ No newline at end of file diff --git a/test/test_suite/enumerations/enum_cast.c3t b/test/test_suite/enumerations/enum_cast.c3t index 1cf83ab6e..36dfe4d52 100644 --- a/test/test_suite/enumerations/enum_cast.c3t +++ b/test/test_suite/enumerations/enum_cast.c3t @@ -78,9 +78,9 @@ entry: store i64 0, i64* %e.f, align 8 %3 = load i64, i64* %xf.f, align 8 %not_err = icmp eq i64 %3, 0 - br i1 %not_err, label %after_check, label %error + br i1 %not_err, label %after_check, label %assign_optional -error: ; preds = %entry +assign_optional: ; preds = %entry store i64 %3, i64* %e.f, align 8 br label %after_assign @@ -91,7 +91,7 @@ after_check: ; preds = %entry store i64 0, i64* %e.f, align 8 br label %after_assign -after_assign: ; preds = %after_check, %error +after_assign: ; preds = %after_check, %assign_optional br label %voiderr voiderr: ; preds = %after_assign diff --git a/test/test_suite/errors/anyerr_void.c3t b/test/test_suite/errors/anyerr_void.c3t index 3222b70e4..a46b30952 100644 --- a/test/test_suite/errors/anyerr_void.c3t +++ b/test/test_suite/errors/anyerr_void.c3t @@ -49,16 +49,16 @@ entry: store i64 0, i64* %error_var, align 8 %0 = call i64 @anyerr_void_errorThing() %not_err = icmp eq i64 %0, 0 - br i1 %not_err, label %after.errcheck, label %error + br i1 %not_err, label %after_check, label %assign_optional -error: ; preds = %entry +assign_optional: ; preds = %entry store i64 %0, i64* %error_var, align 8 br label %noerr_block -after.errcheck: ; preds = %entry +after_check: ; preds = %entry br label %noerr_block -noerr_block: ; preds = %after.errcheck, %error +noerr_block: ; preds = %after_check, %assign_optional %1 = load i64, i64* %error_var, align 8 store i64 %1, i64* %z, align 8 %2 = load i64, i64* %z, align 8 @@ -68,16 +68,16 @@ noerr_block: ; preds = %after.errcheck, %er store i64 0, i64* %error_var1, align 8 %3 = call i64 @anyerr_void_errorThing2() %not_err2 = icmp eq i64 %3, 0 - br i1 %not_err2, label %after.errcheck4, label %error3 + br i1 %not_err2, label %after_check4, label %assign_optional3 -error3: ; preds = %noerr_block +assign_optional3: ; preds = %noerr_block store i64 %3, i64* %error_var1, align 8 br label %noerr_block5 -after.errcheck4: ; preds = %noerr_block +after_check4: ; preds = %noerr_block br label %noerr_block5 -noerr_block5: ; preds = %after.errcheck4, %error3 +noerr_block5: ; preds = %after_check4, %assign_optional3 %4 = load i64, i64* %error_var1, align 8 store i64 %4, i64* %z, align 8 %5 = load i64, i64* %z, align 8 diff --git a/test/test_suite/errors/else_checks.c3t b/test/test_suite/errors/else_checks.c3t index 5ab8cfdf4..3d7538f91 100644 --- a/test/test_suite/errors/else_checks.c3t +++ b/test/test_suite/errors/else_checks.c3t @@ -31,31 +31,31 @@ entry: %retparam21 = alloca i32, align 4 %0 = call i64 @testError(i32* %retparam) %not_err = icmp eq i64 %0, 0 - br i1 %not_err, label %after.errcheck, label %else_block + br i1 %not_err, label %after_check, label %else_block -after.errcheck: ; preds = %entry +after_check: ; preds = %entry %1 = load i32, i32* %retparam, align 4 %2 = call i64 @testError(i32* %retparam1) %not_err2 = icmp eq i64 %2, 0 - br i1 %not_err2, label %after.errcheck3, label %else_block + br i1 %not_err2, label %after_check3, label %else_block -after.errcheck3: ; preds = %after.errcheck +after_check3: ; preds = %after_check %3 = load i32, i32* %retparam1, align 4 %add = add i32 %1, %3 br label %phi_block -else_block: ; preds = %after.errcheck, %entry +else_block: ; preds = %after_check, %entry br label %phi_block -phi_block: ; preds = %else_block, %after.errcheck3 - %val = phi i32 [ %add, %after.errcheck3 ], [ 100, %else_block ] +phi_block: ; preds = %else_block, %after_check3 + %val = phi i32 [ %add, %after_check3 ], [ 100, %else_block ] %sifp = sitofp i32 %val to double store double %sifp, double* %x, align 8 %4 = call i64 @testError(i32* %retparam4) %not_err5 = icmp eq i64 %4, 0 - br i1 %not_err5, label %after.errcheck6, label %else_block7 + br i1 %not_err5, label %after_check6, label %else_block7 -after.errcheck6: ; preds = %phi_block +after_check6: ; preds = %phi_block %5 = load i32, i32* %retparam4, align 4 %shl = shl i32 1, %5 %6 = freeze i32 %shl @@ -64,15 +64,15 @@ after.errcheck6: ; preds = %phi_block else_block7: ; preds = %phi_block br label %phi_block8 -phi_block8: ; preds = %else_block7, %after.errcheck6 - %val9 = phi i32 [ %6, %after.errcheck6 ], [ 100, %else_block7 ] +phi_block8: ; preds = %else_block7, %after_check6 + %val9 = phi i32 [ %6, %after_check6 ], [ 100, %else_block7 ] %sifp10 = sitofp i32 %val9 to double store double %sifp10, double* %y, align 8 %7 = call i64 @testError(i32* %retparam11) %not_err12 = icmp eq i64 %7, 0 - br i1 %not_err12, label %after.errcheck13, label %else_block14 + br i1 %not_err12, label %after_check13, label %else_block14 -after.errcheck13: ; preds = %phi_block8 +after_check13: ; preds = %phi_block8 %8 = load i32, i32* %retparam11, align 4 %ashr = ashr i32 %8, 1 %9 = freeze i32 %ashr @@ -81,30 +81,30 @@ after.errcheck13: ; preds = %phi_block8 else_block14: ; preds = %phi_block8 br label %phi_block15 -phi_block15: ; preds = %else_block14, %after.errcheck13 - %val16 = phi i32 [ %9, %after.errcheck13 ], [ 100, %else_block14 ] +phi_block15: ; preds = %else_block14, %after_check13 + %val16 = phi i32 [ %9, %after_check13 ], [ 100, %else_block14 ] %sifp17 = sitofp i32 %val16 to double store double %sifp17, double* %z, align 8 %10 = call i64 @testError(i32* %retparam18) %not_err19 = icmp eq i64 %10, 0 - br i1 %not_err19, label %after.errcheck20, label %else_block24 + br i1 %not_err19, label %after_check20, label %else_block24 -after.errcheck20: ; preds = %phi_block15 +after_check20: ; preds = %phi_block15 %11 = load i32, i32* %retparam18, align 4 %12 = call i64 @testError(i32* %retparam21) %not_err22 = icmp eq i64 %12, 0 - br i1 %not_err22, label %after.errcheck23, label %else_block24 + br i1 %not_err22, label %after_check23, label %else_block24 -after.errcheck23: ; preds = %after.errcheck20 +after_check23: ; preds = %after_check20 %13 = load i32, i32* %retparam21, align 4 %mul = mul i32 %11, %13 br label %phi_block25 -else_block24: ; preds = %after.errcheck20, %phi_block15 +else_block24: ; preds = %after_check20, %phi_block15 br label %phi_block25 -phi_block25: ; preds = %else_block24, %after.errcheck23 - %val26 = phi i32 [ %mul, %after.errcheck23 ], [ 100, %else_block24 ] +phi_block25: ; preds = %else_block24, %after_check23 + %val26 = phi i32 [ %mul, %after_check23 ], [ 100, %else_block24 ] %sifp27 = sitofp i32 %val26 to double store double %sifp27, double* %w, align 8 ret void diff --git a/test/test_suite/errors/error_regression_2.c3t b/test/test_suite/errors/error_regression_2.c3t index 38534b7e0..68d422d33 100644 --- a/test/test_suite/errors/error_regression_2.c3t +++ b/test/test_suite/errors/error_regression_2.c3t @@ -643,9 +643,9 @@ entry: %hi = load i64, i64* %6, align 8 %7 = call i64 @test_readDoc(%Doc* %retparam, i8* %lo, i64 %hi) %not_err = icmp eq i64 %7, 0 - br i1 %not_err, label %after.errcheck, label %else_block + br i1 %not_err, label %after_check, label %else_block -after.errcheck: ; preds = %entry +after_check: ; preds = %entry %8 = getelementptr inbounds %Doc, %Doc* %retparam, i32 0, i32 0 %9 = load %Head*, %Head** %8, align 8 %10 = call { %"char[]"*, i8 } @test_buildSummary(%Head* %9) @@ -662,8 +662,8 @@ else_block: ; preds = %entry %15 = load %Summary, %Summary* %literal, align 8 br label %phi_block -phi_block: ; preds = %else_block, %after.errcheck - %val = phi %Summary [ %12, %after.errcheck ], [ %15, %else_block ] +phi_block: ; preds = %else_block, %after_check + %val = phi %Summary [ %12, %after_check ], [ %15, %else_block ] store %Summary %val, %Summary* %taddr, align 8 %16 = bitcast { %"char[]"*, i8 }* %tempcoerce to i8* %17 = bitcast %Summary* %taddr to i8* @@ -730,29 +730,29 @@ entry: %hi = load i64, i64* %7, align 8 %8 = call i64 @test_readDoc(%Doc* %retparam1, i8* %lo, i64 %hi) %not_err = icmp eq i64 %8, 0 - br i1 %not_err, label %after.errcheck, label %error + br i1 %not_err, label %after_check, label %assign_optional -error: ; preds = %entry +assign_optional: ; preds = %entry store i64 %8, i64* %reterr, align 8 br label %err_retblock -after.errcheck: ; preds = %entry +after_check: ; preds = %entry %9 = getelementptr inbounds %Doc, %Doc* %retparam1, i32 0, i32 0 %10 = load %Head*, %Head** %9, align 8 %11 = call i64 @test_isTitleNonEmpty(i8* %retparam, %Head* %10) %not_err2 = icmp eq i64 %11, 0 - br i1 %not_err2, label %after.errcheck4, label %error3 + br i1 %not_err2, label %after_check4, label %assign_optional3 -error3: ; preds = %after.errcheck +assign_optional3: ; preds = %after_check store i64 %11, i64* %reterr, align 8 br label %err_retblock -after.errcheck4: ; preds = %after.errcheck +after_check4: ; preds = %after_check %12 = load i8, i8* %retparam, align 1 store i8 %12, i8* %0, align 1 ret i64 0 -err_retblock: ; preds = %error3, %error +err_retblock: ; preds = %assign_optional3, %assign_optional %13 = load i64, i64* %reterr, align 8 ret i64 %13 } @@ -840,7 +840,7 @@ entry: store i64 %11, i64* %anon2, align 8 br label %loop.cond -loop.cond: ; preds = %phi_block11, %entry +loop.cond: ; preds = %phi_block12, %entry %12 = load i64, i64* %anon, align 8 %13 = load i64, i64* %anon2, align 8 %lt = icmp ult i64 %12, %13 @@ -905,24 +905,24 @@ cond.phi: ; preds = %cond.rhs, %cond.lhs %hi5 = load i64, i64* %46, align 8 %47 = call i64 @test_readWhetherTitleNonEmpty(i8* %retparam, i8* %lo4, i64 %hi5) %not_err = icmp eq i64 %47, 0 - br i1 %not_err, label %after.errcheck, label %error + br i1 %not_err, label %after_check, label %assign_optional -error: ; preds = %cond.phi +assign_optional: ; preds = %cond.phi store i64 %47, i64* %has_title.f, align 8 br label %after_assign -after.errcheck: ; preds = %cond.phi +after_check: ; preds = %cond.phi %48 = load i8, i8* %retparam, align 1 store i8 %48, i8* %has_title, align 1 store i64 0, i64* %has_title.f, align 8 br label %after_assign -after_assign: ; preds = %after.errcheck, %error +after_assign: ; preds = %after_check, %assign_optional %49 = load i64, i64* %has_title.f, align 8 %not_err6 = icmp eq i64 %49, 0 - br i1 %not_err6, label %after_check, label %else_block + br i1 %not_err6, label %after_check7, label %else_block -after_check: ; preds = %after_assign +after_check7: ; preds = %after_assign %50 = load i8, i8* %has_title, align 1 %51 = call i8* @test_bool_to_string(i8 %50) br label %phi_block @@ -932,24 +932,24 @@ else_block: ; preds = %after_assign %53 = call i8* @test_nameFromError(i64 %52) br label %phi_block -phi_block: ; preds = %else_block, %after_check - %val7 = phi i8* [ %51, %after_check ], [ %53, %else_block ] +phi_block: ; preds = %else_block, %after_check7 + %val8 = phi i8* [ %51, %after_check7 ], [ %53, %else_block ] %54 = load i64, i64* %has_title.f, align 8 - %not_err8 = icmp eq i64 %54, 0 - br i1 %not_err8, label %after_check9, label %else_block10 + %not_err9 = icmp eq i64 %54, 0 + br i1 %not_err9, label %after_check10, label %else_block11 -after_check9: ; preds = %phi_block +after_check10: ; preds = %phi_block %55 = load i8, i8* %has_title, align 1 %56 = trunc i8 %55 to i1 - br label %phi_block11 + br label %phi_block12 -else_block10: ; preds = %phi_block - br label %phi_block11 +else_block11: ; preds = %phi_block + br label %phi_block12 -phi_block11: ; preds = %else_block10, %after_check9 - %val12 = phi i1 [ %56, %after_check9 ], [ false, %else_block10 ] - %ternary = select i1 %val12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.26, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.27, i32 0, i32 0) - %57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.25, i32 0, i32 0), i8* %val7, i8* %ternary) +phi_block12: ; preds = %else_block11, %after_check10 + %val13 = phi i1 [ %56, %after_check10 ], [ false, %else_block11 ] + %ternary = select i1 %val13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.26, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.27, i32 0, i32 0) + %57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.25, i32 0, i32 0), i8* %val8, i8* %ternary) %58 = load i64, i64* %anon, align 8 %add = add i64 %58, 1 store i64 %add, i64* %anon, align 8 diff --git a/test/test_suite/errors/failable_chained_init.c3t b/test/test_suite/errors/failable_chained_init.c3t new file mode 100644 index 000000000..278edd939 --- /dev/null +++ b/test/test_suite/errors/failable_chained_init.c3t @@ -0,0 +1,722 @@ +// #target: macos-x64 +module test; +import std::io; + +fault Test { FOO } + +fn void test1() +{ + int! a = 1; + int! b = a = Test.FOO!; + if (catch err = a) io::printfln("A err was: %s", err); + if (catch err = b) io::printfln("B err was: %s", err); + io::printfln("A was: %s", a); + io::printfln("B was: %s", b); +} + +fn void test2() +{ + int! x = Test.FOO!; + int! a = 1; + int! b = a = x; + if (catch err = a) io::printfln("A err was: %s", err); + if (catch err = b) io::printfln("B err was: %s", err); + io::printfln("A was: %s", a); + io::printfln("B was: %s", b); +} + + +fn void test3() +{ + int! x = 23; + int! a = 1; + int! b = a = x; + if (catch err = a) io::printfln("A err was: %s", err); + if (catch err = b) io::printfln("B err was: %s", err); + io::printfln("A was: %s", a); + io::printfln("B was: %s", b); +} + +fn void main() +{ + test1(); + test2(); + test3(); +} + +/* #expect: test.ll + +; Function Attrs: nounwind +define void @test_test1() #0 { +entry: + %a = alloca i32, align 4 + %a.f = alloca i64, align 8 + %b = alloca i32, align 4 + %b.f = alloca i64, align 8 + %err = alloca i64, align 8 + %retparam = alloca i64, align 8 + %taddr = alloca %"char[]", align 8 + %vararg = alloca %"variant[]", align 8 + %varargslots = alloca [1 x %variant], align 16 + %err5 = alloca i64, align 8 + %retparam13 = alloca i64, align 8 + %taddr14 = alloca %"char[]", align 8 + %vararg17 = alloca %"variant[]", align 8 + %varargslots18 = alloca [1 x %variant], align 16 + %retparam25 = alloca i64, align 8 + %taddr26 = alloca %"char[]", align 8 + %vararg29 = alloca %"variant[]", align 8 + %varargslots30 = alloca [1 x %variant], align 16 + %retparam38 = alloca i64, align 8 + %taddr39 = alloca %"char[]", align 8 + %vararg42 = alloca %"variant[]", align 8 + %varargslots43 = alloca [1 x %variant], align 16 + store i32 1, i32* %a, align 4 + store i64 0, i64* %a.f, align 8 + store i64 ptrtoint (%.fault* @"test_Test$FOO" to i64), i64* %a.f, align 8 + store i64 ptrtoint (%.fault* @"test_Test$FOO" to i64), i64* %b.f, align 8 + br label %after_assign + +after_assign: ; preds = %entry + br label %testblock + +testblock: ; preds = %after_assign + %0 = load i64, i64* %a.f, align 8 + %not_err = icmp eq i64 %0, 0 + br i1 %not_err, label %after_check, label %assign_optional + +assign_optional: ; preds = %testblock + store i64 %0, i64* %err, align 8 + br label %end_block + +after_check: ; preds = %testblock + store i64 0, i64* %err, align 8 + br label %end_block + +end_block: ; preds = %after_check, %assign_optional + %1 = load i64, i64* %err, align 8 + %neq = icmp ne i64 %1, 0 + br i1 %neq, label %if.then, label %if.exit + +if.then: ; preds = %end_block + store %"char[]" { i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i32 0, i32 0), i64 13 }, %"char[]"* %taddr, align 8 + %2 = bitcast %"char[]"* %taddr to { i8*, i64 }* + %3 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %2, i32 0, i32 0 + %lo = load i8*, i8** %3, align 8 + %4 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %2, i32 0, i32 1 + %hi = load i64, i64* %4, align 8 + %5 = bitcast i64* %err to i8* + %6 = insertvalue %variant undef, i8* %5, 0 + %7 = insertvalue %variant %6, i64 ptrtoint (%.introspect* @"ct$anyerr" to i64), 1 + %8 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots, i64 0, i64 0 + store %variant %7, %variant* %8, align 16 + %9 = getelementptr inbounds %"variant[]", %"variant[]"* %vararg, i32 0, i32 1 + store i64 1, i64* %9, align 8 + %10 = getelementptr inbounds %"variant[]", %"variant[]"* %vararg, i32 0, i32 0 + %11 = bitcast [1 x %variant]* %varargslots to %variant* + store %variant* %11, %variant** %10, align 8 + %12 = bitcast %"variant[]"* %vararg to { i8*, i64 }* + %13 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %12, i32 0, i32 0 + %lo1 = load i8*, i8** %13, align 8 + %14 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %12, i32 0, i32 1 + %hi2 = load i64, i64* %14, align 8 + %15 = call i64 @std_io_printfln(i64* %retparam, i8* %lo, i64 %hi, i8* %lo1, i64 %hi2) + %not_err3 = icmp eq i64 %15, 0 + br i1 %not_err3, label %after_check4, label %voiderr + +after_check4: ; preds = %if.then + br label %voiderr + +voiderr: ; preds = %after_check4, %if.then + br label %if.exit + +if.exit: ; preds = %voiderr, %end_block + br label %testblock6 + +testblock6: ; preds = %if.exit + %16 = load i64, i64* %b.f, align 8 + %not_err7 = icmp eq i64 %16, 0 + br i1 %not_err7, label %after_check9, label %assign_optional8 + +assign_optional8: ; preds = %testblock6 + store i64 %16, i64* %err5, align 8 + br label %end_block10 + +after_check9: ; preds = %testblock6 + store i64 0, i64* %err5, align 8 + br label %end_block10 + +end_block10: ; preds = %after_check9, %assign_optional8 + %17 = load i64, i64* %err5, align 8 + %neq11 = icmp ne i64 %17, 0 + br i1 %neq11, label %if.then12, label %if.exit24 + +if.then12: ; preds = %end_block10 + store %"char[]" { i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i32 0, i32 0), i64 13 }, %"char[]"* %taddr14, align 8 + %18 = bitcast %"char[]"* %taddr14 to { i8*, i64 }* + %19 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %18, i32 0, i32 0 + %lo15 = load i8*, i8** %19, align 8 + %20 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %18, i32 0, i32 1 + %hi16 = load i64, i64* %20, align 8 + %21 = bitcast i64* %err5 to i8* + %22 = insertvalue %variant undef, i8* %21, 0 + %23 = insertvalue %variant %22, i64 ptrtoint (%.introspect* @"ct$anyerr" to i64), 1 + %24 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots18, i64 0, i64 0 + store %variant %23, %variant* %24, align 16 + %25 = getelementptr inbounds %"variant[]", %"variant[]"* %vararg17, i32 0, i32 1 + store i64 1, i64* %25, align 8 + %26 = getelementptr inbounds %"variant[]", %"variant[]"* %vararg17, i32 0, i32 0 + %27 = bitcast [1 x %variant]* %varargslots18 to %variant* + store %variant* %27, %variant** %26, align 8 + %28 = bitcast %"variant[]"* %vararg17 to { i8*, i64 }* + %29 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %28, i32 0, i32 0 + %lo19 = load i8*, i8** %29, align 8 + %30 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %28, i32 0, i32 1 + %hi20 = load i64, i64* %30, align 8 + %31 = call i64 @std_io_printfln(i64* %retparam13, i8* %lo15, i64 %hi16, i8* %lo19, i64 %hi20) + %not_err21 = icmp eq i64 %31, 0 + br i1 %not_err21, label %after_check22, label %voiderr23 + +after_check22: ; preds = %if.then12 + br label %voiderr23 + +voiderr23: ; preds = %after_check22, %if.then12 + br label %if.exit24 + +if.exit24: ; preds = %voiderr23, %end_block10 + store %"char[]" { i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i32 0, i32 0), i64 9 }, %"char[]"* %taddr26, align 8 + %32 = bitcast %"char[]"* %taddr26 to { i8*, i64 }* + %33 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %32, i32 0, i32 0 + %lo27 = load i8*, i8** %33, align 8 + %34 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %32, i32 0, i32 1 + %hi28 = load i64, i64* %34, align 8 + %35 = load i64, i64* %a.f, align 8 + %not_err31 = icmp eq i64 %35, 0 + br i1 %not_err31, label %after_check32, label %voiderr37 + +after_check32: ; preds = %if.exit24 + %36 = bitcast i32* %a to i8* + %37 = insertvalue %variant undef, i8* %36, 0 + %38 = insertvalue %variant %37, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 + %39 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots30, i64 0, i64 0 + store %variant %38, %variant* %39, align 16 + %40 = getelementptr inbounds %"variant[]", %"variant[]"* %vararg29, i32 0, i32 1 + store i64 1, i64* %40, align 8 + %41 = getelementptr inbounds %"variant[]", %"variant[]"* %vararg29, i32 0, i32 0 + %42 = bitcast [1 x %variant]* %varargslots30 to %variant* + store %variant* %42, %variant** %41, align 8 + %43 = bitcast %"variant[]"* %vararg29 to { i8*, i64 }* + %44 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %43, i32 0, i32 0 + %lo33 = load i8*, i8** %44, align 8 + %45 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %43, i32 0, i32 1 + %hi34 = load i64, i64* %45, align 8 + %46 = call i64 @std_io_printfln(i64* %retparam25, i8* %lo27, i64 %hi28, i8* %lo33, i64 %hi34) + %not_err35 = icmp eq i64 %46, 0 + br i1 %not_err35, label %after_check36, label %voiderr37 + +after_check36: ; preds = %after_check32 + br label %voiderr37 + +voiderr37: ; preds = %after_check36, %after_check32, %if.exit24 + store %"char[]" { i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i32 0, i32 0), i64 9 }, %"char[]"* %taddr39, align 8 + %47 = bitcast %"char[]"* %taddr39 to { i8*, i64 }* + %48 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %47, i32 0, i32 0 + %lo40 = load i8*, i8** %48, align 8 + %49 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %47, i32 0, i32 1 + %hi41 = load i64, i64* %49, align 8 + %50 = load i64, i64* %b.f, align 8 + %not_err44 = icmp eq i64 %50, 0 + br i1 %not_err44, label %after_check45, label %voiderr50 + +after_check45: ; preds = %voiderr37 + %51 = bitcast i32* %b to i8* + %52 = insertvalue %variant undef, i8* %51, 0 + %53 = insertvalue %variant %52, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 + %54 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots43, i64 0, i64 0 + store %variant %53, %variant* %54, align 16 + %55 = getelementptr inbounds %"variant[]", %"variant[]"* %vararg42, i32 0, i32 1 + store i64 1, i64* %55, align 8 + %56 = getelementptr inbounds %"variant[]", %"variant[]"* %vararg42, i32 0, i32 0 + %57 = bitcast [1 x %variant]* %varargslots43 to %variant* + store %variant* %57, %variant** %56, align 8 + %58 = bitcast %"variant[]"* %vararg42 to { i8*, i64 }* + %59 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %58, i32 0, i32 0 + %lo46 = load i8*, i8** %59, align 8 + %60 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %58, i32 0, i32 1 + %hi47 = load i64, i64* %60, align 8 + %61 = call i64 @std_io_printfln(i64* %retparam38, i8* %lo40, i64 %hi41, i8* %lo46, i64 %hi47) + %not_err48 = icmp eq i64 %61, 0 + br i1 %not_err48, label %after_check49, label %voiderr50 + +after_check49: ; preds = %after_check45 + br label %voiderr50 + +voiderr50: ; preds = %after_check49, %after_check45, %voiderr37 + ret void +} + +; Function Attrs: nounwind +define void @test_test2() #0 { +entry: + %x = alloca i32, align 4 + %x.f = alloca i64, align 8 + %a = alloca i32, align 4 + %a.f = alloca i64, align 8 + %b = alloca i32, align 4 + %b.f = alloca i64, align 8 + %err = alloca i64, align 8 + %retparam = alloca i64, align 8 + %taddr = alloca %"char[]", align 8 + %vararg = alloca %"variant[]", align 8 + %varargslots = alloca [1 x %variant], align 16 + %err9 = alloca i64, align 8 + %retparam17 = alloca i64, align 8 + %taddr18 = alloca %"char[]", align 8 + %vararg21 = alloca %"variant[]", align 8 + %varargslots22 = alloca [1 x %variant], align 16 + %retparam29 = alloca i64, align 8 + %taddr30 = alloca %"char[]", align 8 + %vararg33 = alloca %"variant[]", align 8 + %varargslots34 = alloca [1 x %variant], align 16 + %retparam42 = alloca i64, align 8 + %taddr43 = alloca %"char[]", align 8 + %vararg46 = alloca %"variant[]", align 8 + %varargslots47 = alloca [1 x %variant], align 16 + store i64 ptrtoint (%.fault* @"test_Test$FOO" to i64), i64* %x.f, align 8 + store i32 1, i32* %a, align 4 + store i64 0, i64* %a.f, align 8 + %0 = load i64, i64* %x.f, align 8 + %not_err = icmp eq i64 %0, 0 + br i1 %not_err, label %after_check, label %assign_optional + +assign_optional: ; preds = %entry + store i64 %0, i64* %a.f, align 8 + br label %optional_assign_jump + +after_check: ; preds = %entry + %1 = load i32, i32* %x, align 4 + store i32 %1, i32* %a, align 4 + store i64 0, i64* %a.f, align 8 + br label %after_assign + +optional_assign_jump: ; preds = %assign_optional + %reload_err = load i64, i64* %a.f, align 8 + store i64 %reload_err, i64* %b.f, align 8 + br label %after_assign1 + +after_assign: ; preds = %after_check + store i32 %1, i32* %b, align 4 + store i64 0, i64* %b.f, align 8 + br label %after_assign1 + +after_assign1: ; preds = %after_assign, %optional_assign_jump + br label %testblock + +testblock: ; preds = %after_assign1 + %2 = load i64, i64* %a.f, align 8 + %not_err2 = icmp eq i64 %2, 0 + br i1 %not_err2, label %after_check4, label %assign_optional3 + +assign_optional3: ; preds = %testblock + store i64 %2, i64* %err, align 8 + br label %end_block + +after_check4: ; preds = %testblock + store i64 0, i64* %err, align 8 + br label %end_block + +end_block: ; preds = %after_check4, %assign_optional3 + %3 = load i64, i64* %err, align 8 + %neq = icmp ne i64 %3, 0 + br i1 %neq, label %if.then, label %if.exit + +if.then: ; preds = %end_block + store %"char[]" { i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i32 0, i32 0), i64 13 }, %"char[]"* %taddr, align 8 + %4 = bitcast %"char[]"* %taddr to { i8*, i64 }* + %5 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %4, i32 0, i32 0 + %lo = load i8*, i8** %5, align 8 + %6 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %4, i32 0, i32 1 + %hi = load i64, i64* %6, align 8 + %7 = bitcast i64* %err to i8* + %8 = insertvalue %variant undef, i8* %7, 0 + %9 = insertvalue %variant %8, i64 ptrtoint (%.introspect* @"ct$anyerr" to i64), 1 + %10 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots, i64 0, i64 0 + store %variant %9, %variant* %10, align 16 + %11 = getelementptr inbounds %"variant[]", %"variant[]"* %vararg, i32 0, i32 1 + store i64 1, i64* %11, align 8 + %12 = getelementptr inbounds %"variant[]", %"variant[]"* %vararg, i32 0, i32 0 + %13 = bitcast [1 x %variant]* %varargslots to %variant* + store %variant* %13, %variant** %12, align 8 + %14 = bitcast %"variant[]"* %vararg to { i8*, i64 }* + %15 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %14, i32 0, i32 0 + %lo5 = load i8*, i8** %15, align 8 + %16 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %14, i32 0, i32 1 + %hi6 = load i64, i64* %16, align 8 + %17 = call i64 @std_io_printfln(i64* %retparam, i8* %lo, i64 %hi, i8* %lo5, i64 %hi6) + %not_err7 = icmp eq i64 %17, 0 + br i1 %not_err7, label %after_check8, label %voiderr + +after_check8: ; preds = %if.then + br label %voiderr + +voiderr: ; preds = %after_check8, %if.then + br label %if.exit + +if.exit: ; preds = %voiderr, %end_block + br label %testblock10 + +testblock10: ; preds = %if.exit + %18 = load i64, i64* %b.f, align 8 + %not_err11 = icmp eq i64 %18, 0 + br i1 %not_err11, label %after_check13, label %assign_optional12 + +assign_optional12: ; preds = %testblock10 + store i64 %18, i64* %err9, align 8 + br label %end_block14 + +after_check13: ; preds = %testblock10 + store i64 0, i64* %err9, align 8 + br label %end_block14 + +end_block14: ; preds = %after_check13, %assign_optional12 + %19 = load i64, i64* %err9, align 8 + %neq15 = icmp ne i64 %19, 0 + br i1 %neq15, label %if.then16, label %if.exit28 + +if.then16: ; preds = %end_block14 + store %"char[]" { i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i32 0, i32 0), i64 13 }, %"char[]"* %taddr18, align 8 + %20 = bitcast %"char[]"* %taddr18 to { i8*, i64 }* + %21 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %20, i32 0, i32 0 + %lo19 = load i8*, i8** %21, align 8 + %22 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %20, i32 0, i32 1 + %hi20 = load i64, i64* %22, align 8 + %23 = bitcast i64* %err9 to i8* + %24 = insertvalue %variant undef, i8* %23, 0 + %25 = insertvalue %variant %24, i64 ptrtoint (%.introspect* @"ct$anyerr" to i64), 1 + %26 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots22, i64 0, i64 0 + store %variant %25, %variant* %26, align 16 + %27 = getelementptr inbounds %"variant[]", %"variant[]"* %vararg21, i32 0, i32 1 + store i64 1, i64* %27, align 8 + %28 = getelementptr inbounds %"variant[]", %"variant[]"* %vararg21, i32 0, i32 0 + %29 = bitcast [1 x %variant]* %varargslots22 to %variant* + store %variant* %29, %variant** %28, align 8 + %30 = bitcast %"variant[]"* %vararg21 to { i8*, i64 }* + %31 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %30, i32 0, i32 0 + %lo23 = load i8*, i8** %31, align 8 + %32 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %30, i32 0, i32 1 + %hi24 = load i64, i64* %32, align 8 + %33 = call i64 @std_io_printfln(i64* %retparam17, i8* %lo19, i64 %hi20, i8* %lo23, i64 %hi24) + %not_err25 = icmp eq i64 %33, 0 + br i1 %not_err25, label %after_check26, label %voiderr27 + +after_check26: ; preds = %if.then16 + br label %voiderr27 + +voiderr27: ; preds = %after_check26, %if.then16 + br label %if.exit28 + +if.exit28: ; preds = %voiderr27, %end_block14 + store %"char[]" { i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i32 0, i32 0), i64 9 }, %"char[]"* %taddr30, align 8 + %34 = bitcast %"char[]"* %taddr30 to { i8*, i64 }* + %35 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %34, i32 0, i32 0 + %lo31 = load i8*, i8** %35, align 8 + %36 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %34, i32 0, i32 1 + %hi32 = load i64, i64* %36, align 8 + %37 = load i64, i64* %a.f, align 8 + %not_err35 = icmp eq i64 %37, 0 + br i1 %not_err35, label %after_check36, label %voiderr41 + +after_check36: ; preds = %if.exit28 + %38 = bitcast i32* %a to i8* + %39 = insertvalue %variant undef, i8* %38, 0 + %40 = insertvalue %variant %39, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 + %41 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots34, i64 0, i64 0 + store %variant %40, %variant* %41, align 16 + %42 = getelementptr inbounds %"variant[]", %"variant[]"* %vararg33, i32 0, i32 1 + store i64 1, i64* %42, align 8 + %43 = getelementptr inbounds %"variant[]", %"variant[]"* %vararg33, i32 0, i32 0 + %44 = bitcast [1 x %variant]* %varargslots34 to %variant* + store %variant* %44, %variant** %43, align 8 + %45 = bitcast %"variant[]"* %vararg33 to { i8*, i64 }* + %46 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %45, i32 0, i32 0 + %lo37 = load i8*, i8** %46, align 8 + %47 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %45, i32 0, i32 1 + %hi38 = load i64, i64* %47, align 8 + %48 = call i64 @std_io_printfln(i64* %retparam29, i8* %lo31, i64 %hi32, i8* %lo37, i64 %hi38) + %not_err39 = icmp eq i64 %48, 0 + br i1 %not_err39, label %after_check40, label %voiderr41 + +after_check40: ; preds = %after_check36 + br label %voiderr41 + +voiderr41: ; preds = %after_check40, %after_check36, %if.exit28 + store %"char[]" { i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i32 0, i32 0), i64 9 }, %"char[]"* %taddr43, align 8 + %49 = bitcast %"char[]"* %taddr43 to { i8*, i64 }* + %50 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %49, i32 0, i32 0 + %lo44 = load i8*, i8** %50, align 8 + %51 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %49, i32 0, i32 1 + %hi45 = load i64, i64* %51, align 8 + %52 = load i64, i64* %b.f, align 8 + %not_err48 = icmp eq i64 %52, 0 + br i1 %not_err48, label %after_check49, label %voiderr54 + +after_check49: ; preds = %voiderr41 + %53 = bitcast i32* %b to i8* + %54 = insertvalue %variant undef, i8* %53, 0 + %55 = insertvalue %variant %54, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 + %56 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots47, i64 0, i64 0 + store %variant %55, %variant* %56, align 16 + %57 = getelementptr inbounds %"variant[]", %"variant[]"* %vararg46, i32 0, i32 1 + store i64 1, i64* %57, align 8 + %58 = getelementptr inbounds %"variant[]", %"variant[]"* %vararg46, i32 0, i32 0 + %59 = bitcast [1 x %variant]* %varargslots47 to %variant* + store %variant* %59, %variant** %58, align 8 + %60 = bitcast %"variant[]"* %vararg46 to { i8*, i64 }* + %61 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %60, i32 0, i32 0 + %lo50 = load i8*, i8** %61, align 8 + %62 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %60, i32 0, i32 1 + %hi51 = load i64, i64* %62, align 8 + %63 = call i64 @std_io_printfln(i64* %retparam42, i8* %lo44, i64 %hi45, i8* %lo50, i64 %hi51) + %not_err52 = icmp eq i64 %63, 0 + br i1 %not_err52, label %after_check53, label %voiderr54 + +after_check53: ; preds = %after_check49 + br label %voiderr54 + +voiderr54: ; preds = %after_check53, %after_check49, %voiderr41 + ret void +} + +; Function Attrs: nounwind +define void @test_test3() #0 { +entry: + %x = alloca i32, align 4 + %x.f = alloca i64, align 8 + %a = alloca i32, align 4 + %a.f = alloca i64, align 8 + %b = alloca i32, align 4 + %b.f = alloca i64, align 8 + %err = alloca i64, align 8 + %retparam = alloca i64, align 8 + %taddr = alloca %"char[]", align 8 + %vararg = alloca %"variant[]", align 8 + %varargslots = alloca [1 x %variant], align 16 + %err9 = alloca i64, align 8 + %retparam17 = alloca i64, align 8 + %taddr18 = alloca %"char[]", align 8 + %vararg21 = alloca %"variant[]", align 8 + %varargslots22 = alloca [1 x %variant], align 16 + %retparam29 = alloca i64, align 8 + %taddr30 = alloca %"char[]", align 8 + %vararg33 = alloca %"variant[]", align 8 + %varargslots34 = alloca [1 x %variant], align 16 + %retparam42 = alloca i64, align 8 + %taddr43 = alloca %"char[]", align 8 + %vararg46 = alloca %"variant[]", align 8 + %varargslots47 = alloca [1 x %variant], align 16 + store i32 23, i32* %x, align 4 + store i64 0, i64* %x.f, align 8 + store i32 1, i32* %a, align 4 + store i64 0, i64* %a.f, align 8 + %0 = load i64, i64* %x.f, align 8 + %not_err = icmp eq i64 %0, 0 + br i1 %not_err, label %after_check, label %assign_optional + +assign_optional: ; preds = %entry + store i64 %0, i64* %a.f, align 8 + br label %optional_assign_jump + +after_check: ; preds = %entry + %1 = load i32, i32* %x, align 4 + store i32 %1, i32* %a, align 4 + store i64 0, i64* %a.f, align 8 + br label %after_assign + +optional_assign_jump: ; preds = %assign_optional + %reload_err = load i64, i64* %a.f, align 8 + store i64 %reload_err, i64* %b.f, align 8 + br label %after_assign1 + +after_assign: ; preds = %after_check + store i32 %1, i32* %b, align 4 + store i64 0, i64* %b.f, align 8 + br label %after_assign1 + +after_assign1: ; preds = %after_assign, %optional_assign_jump + br label %testblock + +testblock: ; preds = %after_assign1 + %2 = load i64, i64* %a.f, align 8 + %not_err2 = icmp eq i64 %2, 0 + br i1 %not_err2, label %after_check4, label %assign_optional3 + +assign_optional3: ; preds = %testblock + store i64 %2, i64* %err, align 8 + br label %end_block + +after_check4: ; preds = %testblock + store i64 0, i64* %err, align 8 + br label %end_block + +end_block: ; preds = %after_check4, %assign_optional3 + %3 = load i64, i64* %err, align 8 + %neq = icmp ne i64 %3, 0 + br i1 %neq, label %if.then, label %if.exit + +if.then: ; preds = %end_block + store %"char[]" { i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i32 0, i32 0), i64 13 }, %"char[]"* %taddr, align 8 + %4 = bitcast %"char[]"* %taddr to { i8*, i64 }* + %5 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %4, i32 0, i32 0 + %lo = load i8*, i8** %5, align 8 + %6 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %4, i32 0, i32 1 + %hi = load i64, i64* %6, align 8 + %7 = bitcast i64* %err to i8* + %8 = insertvalue %variant undef, i8* %7, 0 + %9 = insertvalue %variant %8, i64 ptrtoint (%.introspect* @"ct$anyerr" to i64), 1 + %10 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots, i64 0, i64 0 + store %variant %9, %variant* %10, align 16 + %11 = getelementptr inbounds %"variant[]", %"variant[]"* %vararg, i32 0, i32 1 + store i64 1, i64* %11, align 8 + %12 = getelementptr inbounds %"variant[]", %"variant[]"* %vararg, i32 0, i32 0 + %13 = bitcast [1 x %variant]* %varargslots to %variant* + store %variant* %13, %variant** %12, align 8 + %14 = bitcast %"variant[]"* %vararg to { i8*, i64 }* + %15 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %14, i32 0, i32 0 + %lo5 = load i8*, i8** %15, align 8 + %16 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %14, i32 0, i32 1 + %hi6 = load i64, i64* %16, align 8 + %17 = call i64 @std_io_printfln(i64* %retparam, i8* %lo, i64 %hi, i8* %lo5, i64 %hi6) + %not_err7 = icmp eq i64 %17, 0 + br i1 %not_err7, label %after_check8, label %voiderr + +after_check8: ; preds = %if.then + br label %voiderr + +voiderr: ; preds = %after_check8, %if.then + br label %if.exit + +if.exit: ; preds = %voiderr, %end_block + br label %testblock10 + +testblock10: ; preds = %if.exit + %18 = load i64, i64* %b.f, align 8 + %not_err11 = icmp eq i64 %18, 0 + br i1 %not_err11, label %after_check13, label %assign_optional12 + +assign_optional12: ; preds = %testblock10 + store i64 %18, i64* %err9, align 8 + br label %end_block14 + +after_check13: ; preds = %testblock10 + store i64 0, i64* %err9, align 8 + br label %end_block14 + +end_block14: ; preds = %after_check13, %assign_optional12 + %19 = load i64, i64* %err9, align 8 + %neq15 = icmp ne i64 %19, 0 + br i1 %neq15, label %if.then16, label %if.exit28 + +if.then16: ; preds = %end_block14 + store %"char[]" { i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i32 0, i32 0), i64 13 }, %"char[]"* %taddr18, align 8 + %20 = bitcast %"char[]"* %taddr18 to { i8*, i64 }* + %21 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %20, i32 0, i32 0 + %lo19 = load i8*, i8** %21, align 8 + %22 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %20, i32 0, i32 1 + %hi20 = load i64, i64* %22, align 8 + %23 = bitcast i64* %err9 to i8* + %24 = insertvalue %variant undef, i8* %23, 0 + %25 = insertvalue %variant %24, i64 ptrtoint (%.introspect* @"ct$anyerr" to i64), 1 + %26 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots22, i64 0, i64 0 + store %variant %25, %variant* %26, align 16 + %27 = getelementptr inbounds %"variant[]", %"variant[]"* %vararg21, i32 0, i32 1 + store i64 1, i64* %27, align 8 + %28 = getelementptr inbounds %"variant[]", %"variant[]"* %vararg21, i32 0, i32 0 + %29 = bitcast [1 x %variant]* %varargslots22 to %variant* + store %variant* %29, %variant** %28, align 8 + %30 = bitcast %"variant[]"* %vararg21 to { i8*, i64 }* + %31 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %30, i32 0, i32 0 + %lo23 = load i8*, i8** %31, align 8 + %32 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %30, i32 0, i32 1 + %hi24 = load i64, i64* %32, align 8 + %33 = call i64 @std_io_printfln(i64* %retparam17, i8* %lo19, i64 %hi20, i8* %lo23, i64 %hi24) + %not_err25 = icmp eq i64 %33, 0 + br i1 %not_err25, label %after_check26, label %voiderr27 + +after_check26: ; preds = %if.then16 + br label %voiderr27 + +voiderr27: ; preds = %after_check26, %if.then16 + br label %if.exit28 + +if.exit28: ; preds = %voiderr27, %end_block14 + store %"char[]" { i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i32 0, i32 0), i64 9 }, %"char[]"* %taddr30, align 8 + %34 = bitcast %"char[]"* %taddr30 to { i8*, i64 }* + %35 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %34, i32 0, i32 0 + %lo31 = load i8*, i8** %35, align 8 + %36 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %34, i32 0, i32 1 + %hi32 = load i64, i64* %36, align 8 + %37 = load i64, i64* %a.f, align 8 + %not_err35 = icmp eq i64 %37, 0 + br i1 %not_err35, label %after_check36, label %voiderr41 + +after_check36: ; preds = %if.exit28 + %38 = bitcast i32* %a to i8* + %39 = insertvalue %variant undef, i8* %38, 0 + %40 = insertvalue %variant %39, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 + %41 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots34, i64 0, i64 0 + store %variant %40, %variant* %41, align 16 + %42 = getelementptr inbounds %"variant[]", %"variant[]"* %vararg33, i32 0, i32 1 + store i64 1, i64* %42, align 8 + %43 = getelementptr inbounds %"variant[]", %"variant[]"* %vararg33, i32 0, i32 0 + %44 = bitcast [1 x %variant]* %varargslots34 to %variant* + store %variant* %44, %variant** %43, align 8 + %45 = bitcast %"variant[]"* %vararg33 to { i8*, i64 }* + %46 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %45, i32 0, i32 0 + %lo37 = load i8*, i8** %46, align 8 + %47 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %45, i32 0, i32 1 + %hi38 = load i64, i64* %47, align 8 + %48 = call i64 @std_io_printfln(i64* %retparam29, i8* %lo31, i64 %hi32, i8* %lo37, i64 %hi38) + %not_err39 = icmp eq i64 %48, 0 + br i1 %not_err39, label %after_check40, label %voiderr41 + +after_check40: ; preds = %after_check36 + br label %voiderr41 + +voiderr41: ; preds = %after_check40, %after_check36, %if.exit28 + store %"char[]" { i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i32 0, i32 0), i64 9 }, %"char[]"* %taddr43, align 8 + %49 = bitcast %"char[]"* %taddr43 to { i8*, i64 }* + %50 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %49, i32 0, i32 0 + %lo44 = load i8*, i8** %50, align 8 + %51 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %49, i32 0, i32 1 + %hi45 = load i64, i64* %51, align 8 + %52 = load i64, i64* %b.f, align 8 + %not_err48 = icmp eq i64 %52, 0 + br i1 %not_err48, label %after_check49, label %voiderr54 + +after_check49: ; preds = %voiderr41 + %53 = bitcast i32* %b to i8* + %54 = insertvalue %variant undef, i8* %53, 0 + %55 = insertvalue %variant %54, i64 ptrtoint (%.introspect* @"ct$int" to i64), 1 + %56 = getelementptr inbounds [1 x %variant], [1 x %variant]* %varargslots47, i64 0, i64 0 + store %variant %55, %variant* %56, align 16 + %57 = getelementptr inbounds %"variant[]", %"variant[]"* %vararg46, i32 0, i32 1 + store i64 1, i64* %57, align 8 + %58 = getelementptr inbounds %"variant[]", %"variant[]"* %vararg46, i32 0, i32 0 + %59 = bitcast [1 x %variant]* %varargslots47 to %variant* + store %variant* %59, %variant** %58, align 8 + %60 = bitcast %"variant[]"* %vararg46 to { i8*, i64 }* + %61 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %60, i32 0, i32 0 + %lo50 = load i8*, i8** %61, align 8 + %62 = getelementptr inbounds { i8*, i64 }, { i8*, i64 }* %60, i32 0, i32 1 + %hi51 = load i64, i64* %62, align 8 + %63 = call i64 @std_io_printfln(i64* %retparam42, i8* %lo44, i64 %hi45, i8* %lo50, i64 %hi51) + %not_err52 = icmp eq i64 %63, 0 + br i1 %not_err52, label %after_check53, label %voiderr54 + +after_check53: ; preds = %after_check49 + br label %voiderr54 + +voiderr54: ; preds = %after_check53, %after_check49, %voiderr41 + ret void +} + diff --git a/test/test_suite/errors/failable_inits.c3t b/test/test_suite/errors/failable_inits.c3t index f3b964bb8..78cffa07b 100644 --- a/test/test_suite/errors/failable_inits.c3t +++ b/test/test_suite/errors/failable_inits.c3t @@ -43,16 +43,16 @@ entry: store i64 ptrtoint (%.fault* @"test_Foo$MY_VAL1" to i64), i64* %x.f, align 8 %0 = load i64, i64* %x.f, align 8 %not_err = icmp eq i64 %0, 0 - br i1 %not_err, label %after_check, label %error + br i1 %not_err, label %after_check, label %assign_optional -error: ; preds = %entry +assign_optional: ; preds = %entry store i64 %0, i64* %error_var, align 8 br label %guard_block after_check: ; preds = %entry br label %noerr_block -guard_block: ; preds = %error +guard_block: ; preds = %assign_optional %1 = load i64, i64* %error_var, align 8 ret i64 %1 @@ -76,16 +76,16 @@ entry: store i64 0, i64* %x.f, align 8 %1 = load i64, i64* %x.f, align 8 %not_err = icmp eq i64 %1, 0 - br i1 %not_err, label %after_check, label %error + br i1 %not_err, label %after_check, label %assign_optional -error: ; preds = %entry +assign_optional: ; preds = %entry store i64 %1, i64* %error_var, align 8 br label %guard_block after_check: ; preds = %entry br label %noerr_block -guard_block: ; preds = %error +guard_block: ; preds = %assign_optional %2 = load i64, i64* %error_var, align 8 ret i64 %2 @@ -101,19 +101,19 @@ define void @test_main() #0 { entry: %0 = call i64 @test_test1() %not_err = icmp eq i64 %0, 0 - br i1 %not_err, label %after.errcheck, label %voiderr + br i1 %not_err, label %after_check, label %voiderr -after.errcheck: ; preds = %entry +after_check: ; preds = %entry br label %voiderr -voiderr: ; preds = %after.errcheck, %entry +voiderr: ; preds = %after_check, %entry %1 = call i64 @test_test2() %not_err1 = icmp eq i64 %1, 0 - br i1 %not_err1, label %after.errcheck2, label %voiderr3 + br i1 %not_err1, label %after_check2, label %voiderr3 -after.errcheck2: ; preds = %voiderr +after_check2: ; preds = %voiderr br label %voiderr3 -voiderr3: ; preds = %after.errcheck2, %voiderr +voiderr3: ; preds = %after_check2, %voiderr ret void } diff --git a/test/test_suite/errors/failable_taddr_and_access.c3t b/test/test_suite/errors/failable_taddr_and_access.c3t index d54ff60dc..de5eb60f8 100644 --- a/test/test_suite/errors/failable_taddr_and_access.c3t +++ b/test/test_suite/errors/failable_taddr_and_access.c3t @@ -45,15 +45,15 @@ entry: %w = alloca %Foo*, align 8 %w.f = alloca i64, align 8 %literal = alloca %Foo, align 4 - %literal4 = alloca %Foo, align 4 + %literal5 = alloca %Foo, align 4 store i32 2, i32* %z, align 4 store i64 0, i64* %z.f, align 8 %0 = getelementptr inbounds %Foo, %Foo* %literal, i32 0, i32 0 %1 = load i64, i64* %z.f, align 8 %not_err = icmp eq i64 %1, 0 - br i1 %not_err, label %after_check, label %error + br i1 %not_err, label %after_check, label %assign_optional -error: ; preds = %entry +assign_optional: ; preds = %entry store i64 %1, i64* %w.f, align 8 br label %after_assign @@ -66,7 +66,7 @@ after_check: ; preds = %entry store i64 0, i64* %w.f, align 8 br label %after_assign -after_assign: ; preds = %after_check, %error +after_assign: ; preds = %after_check, %assign_optional %4 = load i64, i64* %w.f, align 8 %not_err1 = icmp eq i64 %4, 0 br i1 %not_err1, label %after_check2, label %voiderr @@ -80,42 +80,42 @@ after_check2: ; preds = %after_assign voiderr: ; preds = %after_check2, %after_assign store i64 ptrtoint (%.fault* @"test_MyErr$FOO" to i64), i64* %z.f, align 8 - br label %voiderr3 + br label %voiderr4 -voiderr3: ; preds = %voiderr - %9 = getelementptr inbounds %Foo, %Foo* %literal4, i32 0, i32 0 +voiderr4: ; preds = %voiderr + %9 = getelementptr inbounds %Foo, %Foo* %literal5, i32 0, i32 0 %10 = load i64, i64* %z.f, align 8 - %not_err5 = icmp eq i64 %10, 0 - br i1 %not_err5, label %after_check7, label %error6 + %not_err6 = icmp eq i64 %10, 0 + br i1 %not_err6, label %after_check8, label %assign_optional7 -error6: ; preds = %voiderr3 +assign_optional7: ; preds = %voiderr4 store i64 %10, i64* %w.f, align 8 - br label %after_assign8 + br label %after_assign9 -after_check7: ; preds = %voiderr3 +after_check8: ; preds = %voiderr4 %11 = load i32, i32* %z, align 4 store i32 %11, i32* %9, align 4 - %12 = getelementptr inbounds %Foo, %Foo* %literal4, i32 0, i32 1 + %12 = getelementptr inbounds %Foo, %Foo* %literal5, i32 0, i32 1 store i32 0, i32* %12, align 4 - store %Foo* %literal4, %Foo** %w, align 8 + store %Foo* %literal5, %Foo** %w, align 8 store i64 0, i64* %w.f, align 8 - br label %after_assign8 + br label %after_assign9 -after_assign8: ; preds = %after_check7, %error6 - br label %voiderr9 +after_assign9: ; preds = %after_check8, %assign_optional7 + br label %voiderr10 -voiderr9: ; preds = %after_assign8 +voiderr10: ; preds = %after_assign9 %13 = load i64, i64* %w.f, align 8 - %not_err10 = icmp eq i64 %13, 0 - br i1 %not_err10, label %after_check11, label %voiderr12 + %not_err11 = icmp eq i64 %13, 0 + br i1 %not_err11, label %after_check12, label %voiderr13 -after_check11: ; preds = %voiderr9 +after_check12: ; preds = %voiderr10 %14 = load %Foo*, %Foo** %w, align 8 %15 = getelementptr inbounds %Foo, %Foo* %14, i32 0, i32 0 %16 = load i32, i32* %15, align 8 %17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i32 0, i32 0), i32 %16) - br label %voiderr12 + br label %voiderr13 -voiderr12: ; preds = %after_check11, %voiderr9 +voiderr13: ; preds = %after_check12, %voiderr10 ret void } \ No newline at end of file diff --git a/test/test_suite/errors/macro_err.c3t b/test/test_suite/errors/macro_err.c3t index 04be99823..7f89c95f8 100644 --- a/test/test_suite/errors/macro_err.c3t +++ b/test/test_suite/errors/macro_err.c3t @@ -32,19 +32,19 @@ entry: %retparam = alloca i32, align 4 %0 = call i64 @test_abc(i32* %retparam) %not_err = icmp eq i64 %0, 0 - br i1 %not_err, label %after.errcheck, label %error + br i1 %not_err, label %after_check, label %assign_optional -error: ; preds = %entry +assign_optional: ; preds = %entry store i64 %0, i64* %error_var, align 8 br label %guard_block -after.errcheck: ; preds = %entry +after_check: ; preds = %entry br label %noerr_block -guard_block: ; preds = %error +guard_block: ; preds = %assign_optional ret void -noerr_block: ; preds = %after.errcheck +noerr_block: ; preds = %after_check %1 = load i32, i32* %retparam, align 4 br label %phi_block diff --git a/test/test_suite/errors/macro_err2.c3t b/test/test_suite/errors/macro_err2.c3t index 8aed9fc7c..d34314250 100644 --- a/test/test_suite/errors/macro_err2.c3t +++ b/test/test_suite/errors/macro_err2.c3t @@ -32,9 +32,9 @@ entry: %retparam = alloca i32, align 4 %0 = call i64 @test_abc(i32* %retparam) %not_err = icmp eq i64 %0, 0 - br i1 %not_err, label %after.errcheck, label %opt_block_cleanup + br i1 %not_err, label %after_check, label %opt_block_cleanup -after.errcheck: ; preds = %entry +after_check: ; preds = %entry %1 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i32 0, i32 0)) %2 = load i32, i32* %retparam, align 4 store i32 %2, i32* %blockret, align 4 @@ -44,7 +44,7 @@ opt_block_cleanup: ; preds = %entry %3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i32 0, i32 0)) br label %else_block -expr_block.exit: ; preds = %after.errcheck +expr_block.exit: ; preds = %after_check %4 = load i32, i32* %blockret, align 4 br label %phi_block diff --git a/test/test_suite/errors/printing_errors.c3t b/test/test_suite/errors/printing_errors.c3t index 1acbe55f0..7cabe9ff2 100644 --- a/test/test_suite/errors/printing_errors.c3t +++ b/test/test_suite/errors/printing_errors.c3t @@ -70,11 +70,11 @@ faultname_exit: ; preds = %faultname_ok, %faul %hi3 = load i64, i64* %20, align 8 %21 = call i64 @std_io_printf(i64* %retparam, i8* %lo, i64 %hi, i8* %lo2, i64 %hi3) %not_err = icmp eq i64 %21, 0 - br i1 %not_err, label %after.errcheck, label %voiderr + br i1 %not_err, label %after_check, label %voiderr -after.errcheck: ; preds = %faultname_exit +after_check: ; preds = %faultname_exit br label %voiderr -voiderr: ; preds = %after.errcheck, %faultname_exit +voiderr: ; preds = %after_check, %faultname_exit ret void } diff --git a/test/test_suite/errors/rethrow.c3t b/test/test_suite/errors/rethrow.c3t index dc80ae290..44069b5aa 100644 --- a/test/test_suite/errors/rethrow.c3t +++ b/test/test_suite/errors/rethrow.c3t @@ -6,25 +6,26 @@ fn void! test() i?; } -// #expect: rethrow.ll +/* #expect: rethrow.ll %i = alloca i32, align 4 %i.f = alloca i64, align 8 %error_var = alloca i64, align 8 + %reterr = alloca i64, align 8 store i64 0, i64* %i.f, align 8 store i32 0, i32* %i, align 4 %0 = load i64, i64* %i.f, align 8 %not_err = icmp eq i64 %0, 0 - br i1 %not_err, label %after_check, label %error + br i1 %not_err, label %after_check, label %assign_optional -error: ; preds = %entry +assign_optional: ; preds = %entry store i64 %0, i64* %error_var, align 8 br label %guard_block after_check: ; preds = %entry br label %noerr_block -guard_block: ; preds = %error +guard_block: ; preds = %assign_optional %1 = load i64, i64* %error_var, align 8 ret i64 %1 diff --git a/test/test_suite/errors/rethrow_mingw.c3t b/test/test_suite/errors/rethrow_mingw.c3t index 8069380d5..56cf8ec9a 100644 --- a/test/test_suite/errors/rethrow_mingw.c3t +++ b/test/test_suite/errors/rethrow_mingw.c3t @@ -8,27 +8,28 @@ fn void! test() i?; } -// #expect: rethrow.ll +/* #expect: rethrow.ll define i64 @rethrow_test() #0 { entry: %i = alloca i32, align 4 %i.f = alloca i64, align 8 %error_var = alloca i64, align 8 + %reterr = alloca i64, align 8 store i64 0, i64* %i.f, align 8 store i32 0, i32* %i, align 4 %0 = load i64, i64* %i.f, align 8 %not_err = icmp eq i64 %0, 0 - br i1 %not_err, label %after_check, label %error + br i1 %not_err, label %after_check, label %assign_optional -error: ; preds = %entry +assign_optional: ; preds = %entry store i64 %0, i64* %error_var, align 8 br label %guard_block after_check: ; preds = %entry br label %noerr_block -guard_block: ; preds = %error +guard_block: ; preds = %assign_optional %1 = load i64, i64* %error_var, align 8 ret i64 %1 diff --git a/test/test_suite/errors/try_assign.c3t b/test/test_suite/errors/try_assign.c3t index 1c42301ee..24c83e4c7 100644 --- a/test/test_suite/errors/try_assign.c3t +++ b/test/test_suite/errors/try_assign.c3t @@ -25,7 +25,8 @@ fn void main() } } -// #expect: try_assign.ll +/* #expect: try_assign.ll + define void @try_assign_main() #0 { entry: @@ -126,9 +127,9 @@ if.exit15: ; preds = %if.then14, %phi_try testblock: ; preds = %if.exit15 %12 = load i64, i64* %z.f, align 8 %not_err16 = icmp eq i64 %12, 0 - br i1 %not_err16, label %after_check17, label %error + br i1 %not_err16, label %after_check17, label %assign_optional -error: ; preds = %testblock +assign_optional: ; preds = %testblock store i64 %12, i64* %e, align 8 br label %end_block @@ -136,7 +137,7 @@ after_check17: ; preds = %testblock store i64 0, i64* %e, align 8 br label %end_block -end_block: ; preds = %after_check17, %error +end_block: ; preds = %after_check17, %assign_optional %13 = load i64, i64* %e, align 8 %neq = icmp ne i64 %13, 0 br i1 %neq, label %if.then18, label %if.exit19 diff --git a/test/test_suite/errors/try_catch_if.c3t b/test/test_suite/errors/try_catch_if.c3t index d6e251204..0ff3e4bb9 100644 --- a/test/test_suite/errors/try_catch_if.c3t +++ b/test/test_suite/errors/try_catch_if.c3t @@ -34,7 +34,7 @@ fn void main() test1(); } -// #expect: try_catch_if.ll +/* #expect: try_catch_if.ll define i64 @try_catch_if_tester(i32* %0) #0 { entry: @@ -57,9 +57,9 @@ entry: testblock: ; preds = %entry %0 = load i64, i64* %a.f, align 8 %not_err = icmp eq i64 %0, 0 - br i1 %not_err, label %after_check, label %error + br i1 %not_err, label %after_check, label %assign_optional -error: ; preds = %testblock +assign_optional: ; preds = %testblock store i64 %0, i64* %err, align 8 br label %end_block @@ -69,17 +69,17 @@ after_check: ; preds = %testblock testblock1: ; preds = %after_check %1 = call i64 @try_catch_if_tester(i32* %retparam) %not_err2 = icmp eq i64 %1, 0 - br i1 %not_err2, label %after.errcheck, label %error3 + br i1 %not_err2, label %after_check4, label %assign_optional3 -error3: ; preds = %testblock1 +assign_optional3: ; preds = %testblock1 store i64 %1, i64* %err, align 8 br label %end_block -after.errcheck: ; preds = %testblock1 +after_check4: ; preds = %testblock1 store i64 0, i64* %err, align 8 br label %end_block -end_block: ; preds = %after.errcheck, %error3, %error +end_block: ; preds = %after_check4, %assign_optional3, %assign_optional %2 = load i64, i64* %err, align 8 %neq = icmp ne i64 %2, 0 br i1 %neq, label %if.then, label %if.else diff --git a/test/test_suite/errors/try_unwrap_using_assert.c3t b/test/test_suite/errors/try_unwrap_using_assert.c3t index 9ee8d82c2..9974ae2df 100644 --- a/test/test_suite/errors/try_unwrap_using_assert.c3t +++ b/test/test_suite/errors/try_unwrap_using_assert.c3t @@ -11,7 +11,7 @@ fn int tester(int n) return num; } -// #expect: test.ll +/* #expect: test.ll define i32 @test_tester(i32 %0) #0 { entry: @@ -21,19 +21,19 @@ entry: %x = alloca i32, align 4 %1 = call i64 @maybe(i32* %retparam) %not_err = icmp eq i64 %1, 0 - br i1 %not_err, label %after.errcheck, label %error + br i1 %not_err, label %after_check, label %assign_optional -error: ; preds = %entry +assign_optional: ; preds = %entry store i64 %1, i64* %num.f, align 8 br label %after_assign -after.errcheck: ; preds = %entry +after_check: ; preds = %entry %2 = load i32, i32* %retparam, align 4 store i32 %2, i32* %num, align 4 store i64 0, i64* %num.f, align 8 br label %after_assign -after_assign: ; preds = %after.errcheck, %error +after_assign: ; preds = %after_check, %assign_optional %3 = load i32, i32* %num, align 4 store i32 %3, i32* %x, align 4 %4 = load i32, i32* %num, align 4 diff --git a/test/test_suite/errors/try_with_chained_unwrap.c3t b/test/test_suite/errors/try_with_chained_unwrap.c3t index 007c96df5..d419e18e6 100644 --- a/test/test_suite/errors/try_with_chained_unwrap.c3t +++ b/test/test_suite/errors/try_with_chained_unwrap.c3t @@ -26,24 +26,24 @@ entry: store i32 0, i32* %val, align 4 %0 = call i64 @readLine(i8** %retparam1) %not_err = icmp eq i64 %0, 0 - br i1 %not_err, label %after.errcheck, label %catch_landing + br i1 %not_err, label %after_check, label %catch_landing -after.errcheck: ; preds = %entry +after_check: ; preds = %entry %1 = load i8*, i8** %retparam1, align 8 %2 = call i64 @atoi(i32* %retparam, i8* %1) %not_err2 = icmp eq i64 %2, 0 - br i1 %not_err2, label %after.errcheck3, label %catch_landing + br i1 %not_err2, label %after_check3, label %catch_landing -after.errcheck3: ; preds = %after.errcheck +after_check3: ; preds = %after_check %3 = load i32, i32* %retparam, align 4 store i32 %3, i32* %val, align 4 br label %phi_try_catch -catch_landing: ; preds = %after.errcheck, %entry +catch_landing: ; preds = %after_check, %entry br label %phi_try_catch -phi_try_catch: ; preds = %catch_landing, %after.errcheck3 - %val4 = phi i1 [ true, %after.errcheck3 ], [ false, %catch_landing ] +phi_try_catch: ; preds = %catch_landing, %after_check3 + %val4 = phi i1 [ true, %after_check3 ], [ false, %catch_landing ] br i1 %val4, label %if.then, label %if.exit if.then: ; preds = %phi_try_catch diff --git a/test/test_suite/errors/try_with_unwrap.c3t b/test/test_suite/errors/try_with_unwrap.c3t index 00f764384..4759f09d3 100644 --- a/test/test_suite/errors/try_with_unwrap.c3t +++ b/test/test_suite/errors/try_with_unwrap.c3t @@ -19,9 +19,9 @@ fn void main() printf("You didn't type an integer :(\n"); } -// #expect: try_with_unwrap.ll +/* #expect: try_with_unwrap.ll - define void @try_with_unwrap_main() #0 { +define void @try_with_unwrap_main() #0 { entry: %line = alloca i8*, align 8 %line.f = alloca i64, align 8 @@ -31,19 +31,19 @@ entry: %retparam1 = alloca i32, align 4 %0 = call i64 @readLine(i8** %retparam) %not_err = icmp eq i64 %0, 0 - br i1 %not_err, label %after.errcheck, label %error + br i1 %not_err, label %after_check, label %assign_optional -error: ; preds = %entry +assign_optional: ; preds = %entry store i64 %0, i64* %line.f, align 8 br label %after_assign -after.errcheck: ; preds = %entry +after_check: ; preds = %entry %1 = load i8*, i8** %retparam, align 8 store i8* %1, i8** %line, align 8 store i64 0, i64* %line.f, align 8 br label %after_assign -after_assign: ; preds = %after.errcheck, %error +after_assign: ; preds = %after_check, %assign_optional %load.err = load i64, i64* %line.f, align 8 %result = icmp eq i64 %load.err, 0 br i1 %result, label %if.then, label %if.exit9 @@ -52,19 +52,19 @@ if.then: ; preds = %after_assign %2 = load i8*, i8** %line, align 8 %3 = call i64 @atoi(i32* %retparam1, i8* %2) %not_err2 = icmp eq i64 %3, 0 - br i1 %not_err2, label %after.errcheck4, label %error3 + br i1 %not_err2, label %after_check4, label %assign_optional3 -error3: ; preds = %if.then +assign_optional3: ; preds = %if.then store i64 %3, i64* %val.f, align 8 br label %after_assign5 -after.errcheck4: ; preds = %if.then +after_check4: ; preds = %if.then %4 = load i32, i32* %retparam1, align 4 store i32 %4, i32* %val, align 4 store i64 0, i64* %val.f, align 8 br label %after_assign5 -after_assign5: ; preds = %after.errcheck4, %error3 +after_assign5: ; preds = %after_check4, %assign_optional3 %load.err6 = load i64, i64* %val.f, align 8 %result7 = icmp eq i64 %load.err6, 0 br i1 %result7, label %if.then8, label %if.exit diff --git a/test/test_suite/errors/try_with_unwrapper.c3t b/test/test_suite/errors/try_with_unwrapper.c3t index 5aae73521..b9065ecdd 100644 --- a/test/test_suite/errors/try_with_unwrapper.c3t +++ b/test/test_suite/errors/try_with_unwrapper.c3t @@ -40,7 +40,8 @@ fn void test2() } } -// #expect: try_with_unwrapper.ll +/* #expect: try_with_unwrapper.ll + ; Function Attrs: nounwind @@ -93,28 +94,28 @@ chain_next: ; preds = %phi_try_catch store i32 0, i32* %c, align 4 %2 = call i64 @try_with_unwrapper_tester(i32* %retparam) %not_err1 = icmp eq i64 %2, 0 - br i1 %not_err1, label %after.errcheck, label %catch_landing2 + br i1 %not_err1, label %after_check2, label %catch_landing3 -after.errcheck: ; preds = %chain_next +after_check2: ; preds = %chain_next %3 = load i32, i32* %retparam, align 4 store i32 %3, i32* %c, align 4 - br label %phi_try_catch3 + br label %phi_try_catch4 -catch_landing2: ; preds = %chain_next - br label %phi_try_catch3 +catch_landing3: ; preds = %chain_next + br label %phi_try_catch4 -phi_try_catch3: ; preds = %catch_landing2, %after.errcheck - %val4 = phi i1 [ true, %after.errcheck ], [ false, %catch_landing2 ] - br i1 %val4, label %chain_next5, label %fail_chain +phi_try_catch4: ; preds = %catch_landing3, %after_check2 + %val5 = phi i1 [ true, %after_check2 ], [ false, %catch_landing3 ] + br i1 %val5, label %chain_next6, label %fail_chain -chain_next5: ; preds = %phi_try_catch3 +chain_next6: ; preds = %phi_try_catch4 br label %end_chain -fail_chain: ; preds = %phi_try_catch3, %phi_try_catch +fail_chain: ; preds = %phi_try_catch4, %phi_try_catch br label %end_chain -end_chain: ; preds = %fail_chain, %chain_next5 - %chain.phi = phi i1 [ true, %chain_next5 ], [ false, %fail_chain ] +end_chain: ; preds = %fail_chain, %chain_next6 + %chain.phi = phi i1 [ true, %chain_next6 ], [ false, %fail_chain ] br i1 %chain.phi, label %if.then, label %if.exit if.then: ; preds = %end_chain diff --git a/test/test_suite/expressions/chained_ternary.c3t b/test/test_suite/expressions/chained_ternary.c3t index 58a7d8d60..4b3c865d4 100644 --- a/test/test_suite/expressions/chained_ternary.c3t +++ b/test/test_suite/expressions/chained_ternary.c3t @@ -57,9 +57,9 @@ cond.phi4: ; preds = %cond.phi, %cond.lhs cond.lhs7: ; preds = %cond.phi4 %6 = load i64, i64* %x.f, align 8 %not_err = icmp eq i64 %6, 0 - br i1 %not_err, label %after_check, label %error + br i1 %not_err, label %after_check, label %assign_optional -error: ; preds = %cond.lhs7 +assign_optional: ; preds = %cond.lhs7 store i64 %6, i64* %y.f, align 8 br label %after_assign @@ -77,7 +77,7 @@ cond.phi9: ; preds = %cond.rhs8, %after_c store i64 0, i64* %y.f, align 8 br label %after_assign -after_assign: ; preds = %cond.phi9, %error +after_assign: ; preds = %cond.phi9, %assign_optional %9 = load i8*, i8** %a, align 8 %not11 = icmp eq i8* %9, null br i1 %not11, label %cond.lhs12, label %cond.rhs13 @@ -89,9 +89,9 @@ cond.lhs12: ; preds = %after_assign cond.rhs13: ; preds = %after_assign %11 = load i64, i64* %x.f, align 8 %not_err14 = icmp eq i64 %11, 0 - br i1 %not_err14, label %after_check16, label %error15 + br i1 %not_err14, label %after_check16, label %assign_optional15 -error15: ; preds = %cond.rhs13 +assign_optional15: ; preds = %cond.rhs13 store i64 %11, i64* %y.f, align 8 br label %after_assign19 @@ -105,7 +105,7 @@ cond.phi17: ; preds = %after_check16, %con store i64 0, i64* %y.f, align 8 br label %after_assign19 -after_assign19: ; preds = %cond.phi17, %error15 +after_assign19: ; preds = %cond.phi17, %assign_optional15 br label %voiderr voiderr: ; preds = %after_assign19 @@ -116,9 +116,9 @@ voiderr: ; preds = %after_assign19 cond.lhs21: ; preds = %voiderr %14 = load i64, i64* %x.f, align 8 %not_err22 = icmp eq i64 %14, 0 - br i1 %not_err22, label %after_check24, label %error23 + br i1 %not_err22, label %after_check24, label %assign_optional23 -error23: ; preds = %cond.lhs21 +assign_optional23: ; preds = %cond.lhs21 store i64 %14, i64* %y.f, align 8 br label %after_assign31 @@ -129,9 +129,9 @@ after_check24: ; preds = %cond.lhs21 cond.rhs25: ; preds = %voiderr %16 = load i64, i64* %x.f, align 8 %not_err26 = icmp eq i64 %16, 0 - br i1 %not_err26, label %after_check28, label %error27 + br i1 %not_err26, label %after_check28, label %assign_optional27 -error27: ; preds = %cond.rhs25 +assign_optional27: ; preds = %cond.rhs25 store i64 %16, i64* %y.f, align 8 br label %after_assign31 @@ -145,7 +145,7 @@ cond.phi29: ; preds = %after_check28, %aft store i64 0, i64* %y.f, align 8 br label %after_assign31 -after_assign31: ; preds = %cond.phi29, %error27, %error23 +after_assign31: ; preds = %cond.phi29, %assign_optional27, %assign_optional23 br label %voiderr32 voiderr32: ; preds = %after_assign31 @@ -156,9 +156,9 @@ voiderr32: ; preds = %after_assign31 cond.lhs34: ; preds = %voiderr32 %19 = load i64, i64* %x.f, align 8 %not_err35 = icmp eq i64 %19, 0 - br i1 %not_err35, label %after_check37, label %error36 + br i1 %not_err35, label %after_check37, label %assign_optional36 -error36: ; preds = %cond.lhs34 +assign_optional36: ; preds = %cond.lhs34 store i64 %19, i64* %y.f, align 8 br label %after_assign40 @@ -175,7 +175,7 @@ cond.phi39: ; preds = %after_check37 store i64 0, i64* %y.f, align 8 br label %after_assign40 -after_assign40: ; preds = %cond.phi39, %cond.rhs38, %error36 +after_assign40: ; preds = %cond.phi39, %cond.rhs38, %assign_optional36 br label %voiderr41 voiderr41: ; preds = %after_assign40 @@ -190,9 +190,9 @@ cond.lhs43: ; preds = %voiderr41 cond.rhs44: ; preds = %voiderr41 %22 = load i64, i64* %x.f, align 8 %not_err45 = icmp eq i64 %22, 0 - br i1 %not_err45, label %after_check47, label %error46 + br i1 %not_err45, label %after_check47, label %assign_optional46 -error46: ; preds = %cond.rhs44 +assign_optional46: ; preds = %cond.rhs44 store i64 %22, i64* %y.f, align 8 br label %after_assign49 @@ -205,7 +205,7 @@ cond.phi48: ; preds = %after_check47 store i64 0, i64* %y.f, align 8 br label %after_assign49 -after_assign49: ; preds = %cond.phi48, %error46, %cond.lhs43 +after_assign49: ; preds = %cond.phi48, %assign_optional46, %cond.lhs43 br label %voiderr50 voiderr50: ; preds = %after_assign49 diff --git a/test/test_suite/from_docs/examples_if_catch.c3t b/test/test_suite/from_docs/examples_if_catch.c3t index ff05e0bce..32152aa4e 100644 --- a/test/test_suite/from_docs/examples_if_catch.c3t +++ b/test/test_suite/from_docs/examples_if_catch.c3t @@ -74,20 +74,20 @@ entry: %1 = call i32 @demo_bar() %2 = call i64 @demo_divide(double* %retparam, i32 %0, i32 %1) %not_err = icmp eq i64 %2, 0 - br i1 %not_err, label %after.errcheck, label %error + br i1 %not_err, label %after_check, label %assign_optional -error: ; preds = %entry +assign_optional: ; preds = %entry store i64 %2, i64* %error_var, align 8 br label %guard_block -after.errcheck: ; preds = %entry +after_check: ; preds = %entry br label %noerr_block -guard_block: ; preds = %error +guard_block: ; preds = %assign_optional %3 = load i64, i64* %error_var, align 8 ret i64 %3 -noerr_block: ; preds = %after.errcheck +noerr_block: ; preds = %after_check ret i64 0 } @@ -103,35 +103,35 @@ entry: %1 = call i32 @demo_bar() %2 = call i64 @demo_divide(double* %retparam, i32 %0, i32 %1) %not_err = icmp eq i64 %2, 0 - br i1 %not_err, label %after.errcheck, label %error + br i1 %not_err, label %after_check, label %assign_optional -error: ; preds = %entry +assign_optional: ; preds = %entry store i64 %2, i64* %ratio.f, align 8 br label %after_assign -after.errcheck: ; preds = %entry +after_check: ; preds = %entry %3 = load double, double* %retparam, align 8 store double %3, double* %ratio, align 8 store i64 0, i64* %ratio.f, align 8 br label %after_assign -after_assign: ; preds = %after.errcheck, %error +after_assign: ; preds = %after_check, %assign_optional br label %testblock testblock: ; preds = %after_assign %4 = load i64, i64* %ratio.f, align 8 %not_err1 = icmp eq i64 %4, 0 - br i1 %not_err1, label %after_check, label %error2 + br i1 %not_err1, label %after_check3, label %assign_optional2 -error2: ; preds = %testblock +assign_optional2: ; preds = %testblock store i64 %4, i64* %err, align 8 br label %end_block -after_check: ; preds = %testblock +after_check3: ; preds = %testblock store i64 0, i64* %err, align 8 br label %end_block -end_block: ; preds = %after_check, %error2 +end_block: ; preds = %after_check3, %assign_optional2 %5 = load i64, i64* %err, align 8 %neq = icmp ne i64 %5, 0 br i1 %neq, label %if.then, label %if.exit diff --git a/test/test_suite/generic/enum_set_test.c3t b/test/test_suite/generic/enum_set_test.c3t index 67fb38f77..3cb4a96cb 100644 --- a/test/test_suite/generic/enum_set_test.c3t +++ b/test/test_suite/generic/enum_set_test.c3t @@ -81,12 +81,12 @@ entry: %hi3 = load i64, i64* %12, align 8 %13 = call i64 @std_io_printf(i64* %retparam, i8* %lo, i64 %hi, i8* %lo2, i64 %hi3) %not_err = icmp eq i64 %13, 0 - br i1 %not_err, label %after.errcheck, label %voiderr + br i1 %not_err, label %after_check, label %voiderr -after.errcheck: ; preds = %entry +after_check: ; preds = %entry br label %voiderr -voiderr: ; preds = %after.errcheck, %entry +voiderr: ; preds = %after_check, %entry call void @"std_enumset$$test_Abc_EnumSet_add"(i32* %set, i32 0) store %"char[]" { i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i32 0, i32 0), i64 14 }, %"char[]"* %taddr5, align 8 %14 = bitcast %"char[]"* %taddr5 to { i8*, i64 }* @@ -112,12 +112,12 @@ voiderr: ; preds = %after.errcheck, %en %hi12 = load i64, i64* %26, align 8 %27 = call i64 @std_io_printf(i64* %retparam4, i8* %lo6, i64 %hi7, i8* %lo11, i64 %hi12) %not_err13 = icmp eq i64 %27, 0 - br i1 %not_err13, label %after.errcheck14, label %voiderr15 + br i1 %not_err13, label %after_check14, label %voiderr15 -after.errcheck14: ; preds = %voiderr +after_check14: ; preds = %voiderr br label %voiderr15 -voiderr15: ; preds = %after.errcheck14, %voiderr +voiderr15: ; preds = %after_check14, %voiderr call void @"std_enumset$$test_Abc_EnumSet_add"(i32* %set, i32 1) store %"char[]" { i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i32 0, i32 0), i64 14 }, %"char[]"* %taddr17, align 8 %28 = bitcast %"char[]"* %taddr17 to { i8*, i64 }* @@ -143,12 +143,12 @@ voiderr15: ; preds = %after.errcheck14, % %hi24 = load i64, i64* %40, align 8 %41 = call i64 @std_io_printf(i64* %retparam16, i8* %lo18, i64 %hi19, i8* %lo23, i64 %hi24) %not_err25 = icmp eq i64 %41, 0 - br i1 %not_err25, label %after.errcheck26, label %voiderr27 + br i1 %not_err25, label %after_check26, label %voiderr27 -after.errcheck26: ; preds = %voiderr15 +after_check26: ; preds = %voiderr15 br label %voiderr27 -voiderr27: ; preds = %after.errcheck26, %voiderr15 +voiderr27: ; preds = %after_check26, %voiderr15 store i32 0, i32* %set2, align 4 %42 = load i32, i32* %set, align 4 call void @"std_enumset$$test_Abc_EnumSet_add_all"(i32* %set2, i32 %42) @@ -176,12 +176,12 @@ voiderr27: ; preds = %after.errcheck26, % %hi36 = load i64, i64* %55, align 8 %56 = call i64 @std_io_printf(i64* %retparam28, i8* %lo30, i64 %hi31, i8* %lo35, i64 %hi36) %not_err37 = icmp eq i64 %56, 0 - br i1 %not_err37, label %after.errcheck38, label %voiderr39 + br i1 %not_err37, label %after_check38, label %voiderr39 -after.errcheck38: ; preds = %voiderr27 +after_check38: ; preds = %voiderr27 br label %voiderr39 -voiderr39: ; preds = %after.errcheck38, %voiderr27 +voiderr39: ; preds = %after_check38, %voiderr27 %57 = load i32, i32* %set2, align 4 call void @"std_enumset$$test_Abc_EnumSet_remove_all"(i32* %set, i32 %57) store %"char[]" { i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i32 0, i32 0), i64 14 }, %"char[]"* %taddr41, align 8 @@ -208,11 +208,11 @@ voiderr39: ; preds = %after.errcheck38, % %hi48 = load i64, i64* %70, align 8 %71 = call i64 @std_io_printf(i64* %retparam40, i8* %lo42, i64 %hi43, i8* %lo47, i64 %hi48) %not_err49 = icmp eq i64 %71, 0 - br i1 %not_err49, label %after.errcheck50, label %voiderr51 + br i1 %not_err49, label %after_check50, label %voiderr51 -after.errcheck50: ; preds = %voiderr39 +after_check50: ; preds = %voiderr39 br label %voiderr51 -voiderr51: ; preds = %after.errcheck50, %voiderr39 +voiderr51: ; preds = %after_check50, %voiderr39 ret void } diff --git a/test/test_suite/macros/macro_body_defer.c3t b/test/test_suite/macros/macro_body_defer.c3t index 1d855aafb..0671f184c 100644 --- a/test/test_suite/macros/macro_body_defer.c3t +++ b/test/test_suite/macros/macro_body_defer.c3t @@ -106,12 +106,12 @@ define i32 @main(i32 %0, i8** %1) #0 { entry: %2 = call i64 @foo_main() %not_err = icmp eq i64 %2, 0 - br i1 %not_err, label %after.errcheck, label %error_block + br i1 %not_err, label %after_check, label %error_block -after.errcheck: ; preds = %entry +after_check: ; preds = %entry br label %noerr_block -noerr_block: ; preds = %after.errcheck +noerr_block: ; preds = %after_check br label %phi_trycatch_block error_block: ; preds = %entry diff --git a/test/test_suite/macros/macro_failable_return_rethrow.c3t b/test/test_suite/macros/macro_failable_return_rethrow.c3t index 9a80f813d..0366af5d7 100644 --- a/test/test_suite/macros/macro_failable_return_rethrow.c3t +++ b/test/test_suite/macros/macro_failable_return_rethrow.c3t @@ -24,19 +24,19 @@ entry: %retparam = alloca i32, align 4 %0 = call i64 @test_xy(i32* %retparam) %not_err = icmp eq i64 %0, 0 - br i1 %not_err, label %after.errcheck, label %error + br i1 %not_err, label %after_check, label %assign_optional -error: ; preds = %entry +assign_optional: ; preds = %entry store i64 %0, i64* %error_var1, align 8 br label %guard_block -after.errcheck: ; preds = %entry +after_check: ; preds = %entry br label %noerr_block -guard_block: ; preds = %error +guard_block: ; preds = %assign_optional ret void -noerr_block: ; preds = %after.errcheck +noerr_block: ; preds = %after_check store i32 1, i32* %blockret, align 4 br label %expr_block.exit diff --git a/test/test_suite/statements/various_switching.c3t b/test/test_suite/statements/various_switching.c3t index 3af5dfebe..43ac51bea 100644 --- a/test/test_suite/statements/various_switching.c3t +++ b/test/test_suite/statements/various_switching.c3t @@ -88,9 +88,9 @@ entry: testblock: ; preds = %entry %0 = load i64, i64* %x.f, align 8 %not_err = icmp eq i64 %0, 0 - br i1 %not_err, label %after_check, label %error + br i1 %not_err, label %after_check, label %assign_optional -error: ; preds = %testblock +assign_optional: ; preds = %testblock store i64 %0, i64* %err, align 8 br label %end_block @@ -98,7 +98,7 @@ after_check: ; preds = %testblock store i64 0, i64* %err, align 8 br label %end_block -end_block: ; preds = %after_check, %error +end_block: ; preds = %after_check, %assign_optional %1 = load i64, i64* %err, align 8 %neq = icmp ne i64 %1, 0 br i1 %neq, label %if.then, label %if.exit diff --git a/test/test_suite2/enumerations/enum_cast.c3t b/test/test_suite2/enumerations/enum_cast.c3t index 61cec3843..deb1ae866 100644 --- a/test/test_suite2/enumerations/enum_cast.c3t +++ b/test/test_suite2/enumerations/enum_cast.c3t @@ -78,9 +78,9 @@ entry: store i64 0, ptr %e.f, align 8 %3 = load i64, ptr %xf.f, align 8 %not_err = icmp eq i64 %3, 0 - br i1 %not_err, label %after_check, label %error + br i1 %not_err, label %after_check, label %assign_optional -error: ; preds = %entry +assign_optional: ; preds = %entry store i64 %3, ptr %e.f, align 8 br label %after_assign @@ -91,7 +91,7 @@ after_check: ; preds = %entry store i64 0, ptr %e.f, align 8 br label %after_assign -after_assign: ; preds = %after_check, %error +after_assign: ; preds = %after_check, %assign_optional br label %voiderr voiderr: ; preds = %after_assign diff --git a/test/test_suite2/errors/anyerr_void.c3t b/test/test_suite2/errors/anyerr_void.c3t index 4afac5f3f..bb931feec 100644 --- a/test/test_suite2/errors/anyerr_void.c3t +++ b/test/test_suite2/errors/anyerr_void.c3t @@ -50,16 +50,16 @@ entry: store i64 0, ptr %error_var, align 8 %0 = call i64 @anyerr_void_errorThing() %not_err = icmp eq i64 %0, 0 - br i1 %not_err, label %after.errcheck, label %error + br i1 %not_err, label %after_check, label %assign_optional -error: ; preds = %entry +assign_optional: ; preds = %entry store i64 %0, ptr %error_var, align 8 br label %noerr_block -after.errcheck: ; preds = %entry +after_check: ; preds = %entry br label %noerr_block -noerr_block: ; preds = %after.errcheck, %error +noerr_block: ; preds = %after_check, %assign_optional %1 = load i64, ptr %error_var, align 8 store i64 %1, ptr %z, align 8 %2 = load i64, ptr %z, align 8 @@ -69,16 +69,16 @@ noerr_block: ; preds = %after.errcheck, %er store i64 0, ptr %error_var1, align 8 %3 = call i64 @anyerr_void_errorThing2() %not_err2 = icmp eq i64 %3, 0 - br i1 %not_err2, label %after.errcheck4, label %error3 + br i1 %not_err2, label %after_check4, label %assign_optional3 -error3: ; preds = %noerr_block +assign_optional3: ; preds = %noerr_block store i64 %3, ptr %error_var1, align 8 br label %noerr_block5 -after.errcheck4: ; preds = %noerr_block +after_check4: ; preds = %noerr_block br label %noerr_block5 -noerr_block5: ; preds = %after.errcheck4, %error3 +noerr_block5: ; preds = %after_check4, %assign_optional3 %4 = load i64, ptr %error_var1, align 8 store i64 %4, ptr %z, align 8 %5 = load i64, ptr %z, align 8 diff --git a/test/test_suite2/errors/else_checks.c3t b/test/test_suite2/errors/else_checks.c3t index 7d7458870..7984188c4 100644 --- a/test/test_suite2/errors/else_checks.c3t +++ b/test/test_suite2/errors/else_checks.c3t @@ -31,31 +31,31 @@ entry: %retparam21 = alloca i32, align 4 %0 = call i64 @testError(ptr %retparam) %not_err = icmp eq i64 %0, 0 - br i1 %not_err, label %after.errcheck, label %else_block + br i1 %not_err, label %after_check, label %else_block -after.errcheck: ; preds = %entry +after_check: ; preds = %entry %1 = load i32, ptr %retparam, align 4 %2 = call i64 @testError(ptr %retparam1) %not_err2 = icmp eq i64 %2, 0 - br i1 %not_err2, label %after.errcheck3, label %else_block + br i1 %not_err2, label %after_check3, label %else_block -after.errcheck3: ; preds = %after.errcheck +after_check3: ; preds = %after_check %3 = load i32, ptr %retparam1, align 4 %add = add i32 %1, %3 br label %phi_block -else_block: ; preds = %after.errcheck, %entry +else_block: ; preds = %after_check, %entry br label %phi_block -phi_block: ; preds = %else_block, %after.errcheck3 - %val = phi i32 [ %add, %after.errcheck3 ], [ 100, %else_block ] +phi_block: ; preds = %else_block, %after_check3 + %val = phi i32 [ %add, %after_check3 ], [ 100, %else_block ] %sifp = sitofp i32 %val to double store double %sifp, ptr %x, align 8 %4 = call i64 @testError(ptr %retparam4) %not_err5 = icmp eq i64 %4, 0 - br i1 %not_err5, label %after.errcheck6, label %else_block7 + br i1 %not_err5, label %after_check6, label %else_block7 -after.errcheck6: ; preds = %phi_block +after_check6: ; preds = %phi_block %5 = load i32, ptr %retparam4, align 4 %shl = shl i32 1, %5 %6 = freeze i32 %shl @@ -64,15 +64,15 @@ after.errcheck6: ; preds = %phi_block else_block7: ; preds = %phi_block br label %phi_block8 -phi_block8: ; preds = %else_block7, %after.errcheck6 - %val9 = phi i32 [ %6, %after.errcheck6 ], [ 100, %else_block7 ] +phi_block8: ; preds = %else_block7, %after_check6 + %val9 = phi i32 [ %6, %after_check6 ], [ 100, %else_block7 ] %sifp10 = sitofp i32 %val9 to double store double %sifp10, ptr %y, align 8 %7 = call i64 @testError(ptr %retparam11) %not_err12 = icmp eq i64 %7, 0 - br i1 %not_err12, label %after.errcheck13, label %else_block14 + br i1 %not_err12, label %after_check13, label %else_block14 -after.errcheck13: ; preds = %phi_block8 +after_check13: ; preds = %phi_block8 %8 = load i32, ptr %retparam11, align 4 %ashr = ashr i32 %8, 1 %9 = freeze i32 %ashr @@ -81,30 +81,30 @@ after.errcheck13: ; preds = %phi_block8 else_block14: ; preds = %phi_block8 br label %phi_block15 -phi_block15: ; preds = %else_block14, %after.errcheck13 - %val16 = phi i32 [ %9, %after.errcheck13 ], [ 100, %else_block14 ] +phi_block15: ; preds = %else_block14, %after_check13 + %val16 = phi i32 [ %9, %after_check13 ], [ 100, %else_block14 ] %sifp17 = sitofp i32 %val16 to double store double %sifp17, ptr %z, align 8 %10 = call i64 @testError(ptr %retparam18) %not_err19 = icmp eq i64 %10, 0 - br i1 %not_err19, label %after.errcheck20, label %else_block24 + br i1 %not_err19, label %after_check20, label %else_block24 -after.errcheck20: ; preds = %phi_block15 +after_check20: ; preds = %phi_block15 %11 = load i32, ptr %retparam18, align 4 %12 = call i64 @testError(ptr %retparam21) %not_err22 = icmp eq i64 %12, 0 - br i1 %not_err22, label %after.errcheck23, label %else_block24 + br i1 %not_err22, label %after_check23, label %else_block24 -after.errcheck23: ; preds = %after.errcheck20 +after_check23: ; preds = %after_check20 %13 = load i32, ptr %retparam21, align 4 %mul = mul i32 %11, %13 br label %phi_block25 -else_block24: ; preds = %after.errcheck20, %phi_block15 +else_block24: ; preds = %after_check20, %phi_block15 br label %phi_block25 -phi_block25: ; preds = %else_block24, %after.errcheck23 - %val26 = phi i32 [ %mul, %after.errcheck23 ], [ 100, %else_block24 ] +phi_block25: ; preds = %else_block24, %after_check23 + %val26 = phi i32 [ %mul, %after_check23 ], [ 100, %else_block24 ] %sifp27 = sitofp i32 %val26 to double store double %sifp27, ptr %w, align 8 ret void diff --git a/test/test_suite2/errors/error_regression_2.c3t b/test/test_suite2/errors/error_regression_2.c3t index 61b497dcc..00e9fd03b 100644 --- a/test/test_suite2/errors/error_regression_2.c3t +++ b/test/test_suite2/errors/error_regression_2.c3t @@ -358,7 +358,7 @@ if.then15: ; preds = %if.exit9 store ptr null, ptr %25, align 8 %26 = load %Head, ptr %literal18, align 8 store %Head %26, ptr %value, align 8 - %27 = call ptr @std_core_mem_malloc(i64 8) + %27 = call ptr @std_core_mem_malloc(i64 8) #2 store ptr %27, ptr %temp, align 8 %28 = load ptr, ptr %temp, align 8 %not = icmp eq ptr %28, null @@ -402,7 +402,7 @@ if.then27: ; preds = %if.exit21 store ptr null, ptr %literal32, align 8 %39 = getelementptr inbounds %Head, ptr %literal32, i32 0, i32 0 store %"char[]" zeroinitializer, ptr %value34, align 8 - %40 = call ptr @std_core_mem_malloc(i64 16) + %40 = call ptr @std_core_mem_malloc(i64 16) #2 store ptr %40, ptr %temp35, align 8 %41 = load ptr, ptr %temp35, align 8 %not36 = icmp eq ptr %41, null @@ -426,7 +426,7 @@ noerr_block40: ; preds = %if.exit38 store ptr %44, ptr %39, align 8 %45 = load %Head, ptr %literal32, align 8 store %Head %45, ptr %value31, align 8 - %46 = call ptr @std_core_mem_malloc(i64 8) + %46 = call ptr @std_core_mem_malloc(i64 8) #2 store ptr %46, ptr %temp41, align 8 %47 = load ptr, ptr %temp41, align 8 %not42 = icmp eq ptr %47, null @@ -462,7 +462,7 @@ if.exit47: ; preds = %if.exit21 %56 = load i32, ptr %len, align 4 %siuiext = sext i32 %56 to i64 %add = add i64 %siuiext, 1 - %57 = call ptr @std_core_mem_malloc(i64 %add) + %57 = call ptr @std_core_mem_malloc(i64 %add) #2 store ptr %57, ptr %str, align 8 %58 = load ptr, ptr %str, align 8 %not48 = icmp eq ptr %58, null @@ -495,7 +495,7 @@ if.exit50: ; preds = %if.exit47 %71 = insertvalue %"char[]" undef, ptr %ptroffset, 0 %72 = insertvalue %"char[]" %71, i64 %size, 1 store %"char[]" %72, ptr %value60, align 8 - %73 = call ptr @std_core_mem_malloc(i64 16) + %73 = call ptr @std_core_mem_malloc(i64 16) #2 store ptr %73, ptr %temp61, align 8 %74 = load ptr, ptr %temp61, align 8 %not62 = icmp eq ptr %74, null @@ -519,7 +519,7 @@ noerr_block66: ; preds = %if.exit64 store ptr %77, ptr %67, align 8 %78 = load %Head, ptr %literal58, align 8 store %Head %78, ptr %value57, align 8 - %79 = call ptr @std_core_mem_malloc(i64 8) + %79 = call ptr @std_core_mem_malloc(i64 8) #2 store ptr %79, ptr %temp67, align 8 %80 = load ptr, ptr %temp67, align 8 %not68 = icmp eq ptr %80, null @@ -602,9 +602,9 @@ entry: %hi = load i64, ptr %5, align 8 %6 = call i64 @test_readDoc(ptr %retparam, ptr %lo, i64 %hi) %not_err = icmp eq i64 %6, 0 - br i1 %not_err, label %after.errcheck, label %else_block + br i1 %not_err, label %after_check, label %else_block -after.errcheck: ; preds = %entry +after_check: ; preds = %entry %7 = getelementptr inbounds %Doc, ptr %retparam, i32 0, i32 0 %8 = load ptr, ptr %7, align 8 %9 = call { ptr, i8 } @test_buildSummary(ptr %8) @@ -620,8 +620,8 @@ else_block: ; preds = %entry %13 = load %Summary, ptr %literal, align 8 br label %phi_block -phi_block: ; preds = %else_block, %after.errcheck - %val = phi %Summary [ %10, %after.errcheck ], [ %13, %else_block ] +phi_block: ; preds = %else_block, %after_check + %val = phi %Summary [ %10, %after_check ], [ %13, %else_block ] store %Summary %val, ptr %taddr, align 8 call void @llvm.memcpy.p0.p0.i32(ptr align 8 %tempcoerce, ptr align 8 %taddr, i32 16, i1 false) %14 = load { ptr, i8 }, ptr %tempcoerce, align 8 @@ -684,29 +684,29 @@ entry: %hi = load i64, ptr %6, align 8 %7 = call i64 @test_readDoc(ptr %retparam1, ptr %lo, i64 %hi) %not_err = icmp eq i64 %7, 0 - br i1 %not_err, label %after.errcheck, label %error + br i1 %not_err, label %after_check, label %assign_optional -error: ; preds = %entry +assign_optional: ; preds = %entry store i64 %7, ptr %reterr, align 8 br label %err_retblock -after.errcheck: ; preds = %entry +after_check: ; preds = %entry %8 = getelementptr inbounds %Doc, ptr %retparam1, i32 0, i32 0 %9 = load ptr, ptr %8, align 8 %10 = call i64 @test_isTitleNonEmpty(ptr %retparam, ptr %9) %not_err2 = icmp eq i64 %10, 0 - br i1 %not_err2, label %after.errcheck4, label %error3 + br i1 %not_err2, label %after_check4, label %assign_optional3 -error3: ; preds = %after.errcheck +assign_optional3: ; preds = %after_check store i64 %10, ptr %reterr, align 8 br label %err_retblock -after.errcheck4: ; preds = %after.errcheck +after_check4: ; preds = %after_check %11 = load i8, ptr %retparam, align 1 store i8 %11, ptr %0, align 1 ret i64 0 -err_retblock: ; preds = %error3, %error +err_retblock: ; preds = %assign_optional3, %assign_optional %12 = load i64, ptr %reterr, align 8 ret i64 %12 } @@ -791,7 +791,7 @@ entry: store i64 %8, ptr %anon2, align 8 br label %loop.cond -loop.cond: ; preds = %phi_block11, %entry +loop.cond: ; preds = %phi_block12, %entry %9 = load i64, ptr %anon, align 8 %10 = load i64, ptr %anon2, align 8 %lt = icmp ult i64 %9, %10 @@ -849,24 +849,24 @@ cond.phi: ; preds = %cond.rhs, %cond.lhs %hi5 = load i64, ptr %36, align 8 %37 = call i64 @test_readWhetherTitleNonEmpty(ptr %retparam, ptr %lo4, i64 %hi5) %not_err = icmp eq i64 %37, 0 - br i1 %not_err, label %after.errcheck, label %error + br i1 %not_err, label %after_check, label %assign_optional -error: ; preds = %cond.phi +assign_optional: ; preds = %cond.phi store i64 %37, ptr %has_title.f, align 8 br label %after_assign -after.errcheck: ; preds = %cond.phi +after_check: ; preds = %cond.phi %38 = load i8, ptr %retparam, align 1 store i8 %38, ptr %has_title, align 1 store i64 0, ptr %has_title.f, align 8 br label %after_assign -after_assign: ; preds = %after.errcheck, %error +after_assign: ; preds = %after_check, %assign_optional %39 = load i64, ptr %has_title.f, align 8 %not_err6 = icmp eq i64 %39, 0 - br i1 %not_err6, label %after_check, label %else_block + br i1 %not_err6, label %after_check7, label %else_block -after_check: ; preds = %after_assign +after_check7: ; preds = %after_assign %40 = load i8, ptr %has_title, align 1 %41 = call ptr @test_bool_to_string(i8 %40) br label %phi_block @@ -876,24 +876,24 @@ else_block: ; preds = %after_assign %43 = call ptr @test_nameFromError(i64 %42) br label %phi_block -phi_block: ; preds = %else_block, %after_check - %val7 = phi ptr [ %41, %after_check ], [ %43, %else_block ] +phi_block: ; preds = %else_block, %after_check7 + %val8 = phi ptr [ %41, %after_check7 ], [ %43, %else_block ] %44 = load i64, ptr %has_title.f, align 8 - %not_err8 = icmp eq i64 %44, 0 - br i1 %not_err8, label %after_check9, label %else_block10 + %not_err9 = icmp eq i64 %44, 0 + br i1 %not_err9, label %after_check10, label %else_block11 -after_check9: ; preds = %phi_block +after_check10: ; preds = %phi_block %45 = load i8, ptr %has_title, align 1 %46 = trunc i8 %45 to i1 - br label %phi_block11 + br label %phi_block12 -else_block10: ; preds = %phi_block - br label %phi_block11 +else_block11: ; preds = %phi_block + br label %phi_block12 -phi_block11: ; preds = %else_block10, %after_check9 - %val12 = phi i1 [ %46, %after_check9 ], [ false, %else_block10 ] - %ternary = select i1 %val12, ptr @.str.26, ptr @.str.27 - %47 = call i32 (ptr, ...) @printf(ptr @.str.25, ptr %val7, ptr %ternary) +phi_block12: ; preds = %else_block11, %after_check10 + %val13 = phi i1 [ %46, %after_check10 ], [ false, %else_block11 ] + %ternary = select i1 %val13, ptr @.str.26, ptr @.str.27 + %47 = call i32 (ptr, ...) @printf(ptr @.str.25, ptr %val8, ptr %ternary) %48 = load i64, ptr %anon, align 8 %add = add i64 %48, 1 store i64 %add, ptr %anon, align 8 diff --git a/test/test_suite2/errors/failable_chained_init.c3t b/test/test_suite2/errors/failable_chained_init.c3t new file mode 100644 index 000000000..597e5cee9 --- /dev/null +++ b/test/test_suite2/errors/failable_chained_init.c3t @@ -0,0 +1,672 @@ +// #target: macos-x64 +module test; +import std::io; + +fault Test { FOO } + +fn void test1() +{ + int! a = 1; + int! b = a = Test.FOO!; + if (catch err = a) io::printfln("A err was: %s", err); + if (catch err = b) io::printfln("B err was: %s", err); + io::printfln("A was: %s", a); + io::printfln("B was: %s", b); +} + +fn void test2() +{ + int! x = Test.FOO!; + int! a = 1; + int! b = a = x; + if (catch err = a) io::printfln("A err was: %s", err); + if (catch err = b) io::printfln("B err was: %s", err); + io::printfln("A was: %s", a); + io::printfln("B was: %s", b); +} + + +fn void test3() +{ + int! x = 23; + int! a = 1; + int! b = a = x; + if (catch err = a) io::printfln("A err was: %s", err); + if (catch err = b) io::printfln("B err was: %s", err); + io::printfln("A was: %s", a); + io::printfln("B was: %s", b); +} + +fn void main() +{ + test1(); + test2(); + test3(); +} + +/* #expect: test.ll + +define void @test_test1() #0 { +entry: + %a = alloca i32, align 4 + %a.f = alloca i64, align 8 + %b = alloca i32, align 4 + %b.f = alloca i64, align 8 + %err = alloca i64, align 8 + %retparam = alloca i64, align 8 + %taddr = alloca %"char[]", align 8 + %vararg = alloca %"variant[]", align 8 + %varargslots = alloca [1 x %variant], align 16 + %err5 = alloca i64, align 8 + %retparam13 = alloca i64, align 8 + %taddr14 = alloca %"char[]", align 8 + %vararg17 = alloca %"variant[]", align 8 + %varargslots18 = alloca [1 x %variant], align 16 + %retparam25 = alloca i64, align 8 + %taddr26 = alloca %"char[]", align 8 + %vararg29 = alloca %"variant[]", align 8 + %varargslots30 = alloca [1 x %variant], align 16 + %retparam38 = alloca i64, align 8 + %taddr39 = alloca %"char[]", align 8 + %vararg42 = alloca %"variant[]", align 8 + %varargslots43 = alloca [1 x %variant], align 16 + store i32 1, ptr %a, align 4 + store i64 0, ptr %a.f, align 8 + store i64 ptrtoint (ptr @"test_Test$FOO" to i64), ptr %a.f, align 8 + store i64 ptrtoint (ptr @"test_Test$FOO" to i64), ptr %b.f, align 8 + br label %after_assign + +after_assign: ; preds = %entry + br label %testblock + +testblock: ; preds = %after_assign + %0 = load i64, ptr %a.f, align 8 + %not_err = icmp eq i64 %0, 0 + br i1 %not_err, label %after_check, label %assign_optional + +assign_optional: ; preds = %testblock + store i64 %0, ptr %err, align 8 + br label %end_block + +after_check: ; preds = %testblock + store i64 0, ptr %err, align 8 + br label %end_block + +end_block: ; preds = %after_check, %assign_optional + %1 = load i64, ptr %err, align 8 + %neq = icmp ne i64 %1, 0 + br i1 %neq, label %if.then, label %if.exit + +if.then: ; preds = %end_block + store %"char[]" { ptr @.str, i64 13 }, ptr %taddr, align 8 + %2 = getelementptr inbounds { ptr, i64 }, ptr %taddr, i32 0, i32 0 + %lo = load ptr, ptr %2, align 8 + %3 = getelementptr inbounds { ptr, i64 }, ptr %taddr, i32 0, i32 1 + %hi = load i64, ptr %3, align 8 + %4 = insertvalue %variant undef, ptr %err, 0 + %5 = insertvalue %variant %4, i64 ptrtoint (ptr @"ct$anyerr" to i64), 1 + %6 = getelementptr inbounds [1 x %variant], ptr %varargslots, i64 0, i64 0 + store %variant %5, ptr %6, align 16 + %7 = getelementptr inbounds %"variant[]", ptr %vararg, i32 0, i32 1 + store i64 1, ptr %7, align 8 + %8 = getelementptr inbounds %"variant[]", ptr %vararg, i32 0, i32 0 + store ptr %varargslots, ptr %8, align 8 + %9 = getelementptr inbounds { ptr, i64 }, ptr %vararg, i32 0, i32 0 + %lo1 = load ptr, ptr %9, align 8 + %10 = getelementptr inbounds { ptr, i64 }, ptr %vararg, i32 0, i32 1 + %hi2 = load i64, ptr %10, align 8 + %11 = call i64 @std_io_printfln(ptr %retparam, ptr %lo, i64 %hi, ptr %lo1, i64 %hi2) + %not_err3 = icmp eq i64 %11, 0 + br i1 %not_err3, label %after_check4, label %voiderr + +after_check4: ; preds = %if.then + br label %voiderr + +voiderr: ; preds = %after_check4, %if.then + br label %if.exit + +if.exit: ; preds = %voiderr, %end_block + br label %testblock6 + +testblock6: ; preds = %if.exit + %12 = load i64, ptr %b.f, align 8 + %not_err7 = icmp eq i64 %12, 0 + br i1 %not_err7, label %after_check9, label %assign_optional8 + +assign_optional8: ; preds = %testblock6 + store i64 %12, ptr %err5, align 8 + br label %end_block10 + +after_check9: ; preds = %testblock6 + store i64 0, ptr %err5, align 8 + br label %end_block10 + +end_block10: ; preds = %after_check9, %assign_optional8 + %13 = load i64, ptr %err5, align 8 + %neq11 = icmp ne i64 %13, 0 + br i1 %neq11, label %if.then12, label %if.exit24 + +if.then12: ; preds = %end_block10 + store %"char[]" { ptr @.str.1, i64 13 }, ptr %taddr14, align 8 + %14 = getelementptr inbounds { ptr, i64 }, ptr %taddr14, i32 0, i32 0 + %lo15 = load ptr, ptr %14, align 8 + %15 = getelementptr inbounds { ptr, i64 }, ptr %taddr14, i32 0, i32 1 + %hi16 = load i64, ptr %15, align 8 + %16 = insertvalue %variant undef, ptr %err5, 0 + %17 = insertvalue %variant %16, i64 ptrtoint (ptr @"ct$anyerr" to i64), 1 + %18 = getelementptr inbounds [1 x %variant], ptr %varargslots18, i64 0, i64 0 + store %variant %17, ptr %18, align 16 + %19 = getelementptr inbounds %"variant[]", ptr %vararg17, i32 0, i32 1 + store i64 1, ptr %19, align 8 + %20 = getelementptr inbounds %"variant[]", ptr %vararg17, i32 0, i32 0 + store ptr %varargslots18, ptr %20, align 8 + %21 = getelementptr inbounds { ptr, i64 }, ptr %vararg17, i32 0, i32 0 + %lo19 = load ptr, ptr %21, align 8 + %22 = getelementptr inbounds { ptr, i64 }, ptr %vararg17, i32 0, i32 1 + %hi20 = load i64, ptr %22, align 8 + %23 = call i64 @std_io_printfln(ptr %retparam13, ptr %lo15, i64 %hi16, ptr %lo19, i64 %hi20) + %not_err21 = icmp eq i64 %23, 0 + br i1 %not_err21, label %after_check22, label %voiderr23 + +after_check22: ; preds = %if.then12 + br label %voiderr23 + +voiderr23: ; preds = %after_check22, %if.then12 + br label %if.exit24 + +if.exit24: ; preds = %voiderr23, %end_block10 + store %"char[]" { ptr @.str.2, i64 9 }, ptr %taddr26, align 8 + %24 = getelementptr inbounds { ptr, i64 }, ptr %taddr26, i32 0, i32 0 + %lo27 = load ptr, ptr %24, align 8 + %25 = getelementptr inbounds { ptr, i64 }, ptr %taddr26, i32 0, i32 1 + %hi28 = load i64, ptr %25, align 8 + %26 = load i64, ptr %a.f, align 8 + %not_err31 = icmp eq i64 %26, 0 + br i1 %not_err31, label %after_check32, label %voiderr37 + +after_check32: ; preds = %if.exit24 + %27 = insertvalue %variant undef, ptr %a, 0 + %28 = insertvalue %variant %27, i64 ptrtoint (ptr @"ct$int" to i64), 1 + %29 = getelementptr inbounds [1 x %variant], ptr %varargslots30, i64 0, i64 0 + store %variant %28, ptr %29, align 16 + %30 = getelementptr inbounds %"variant[]", ptr %vararg29, i32 0, i32 1 + store i64 1, ptr %30, align 8 + %31 = getelementptr inbounds %"variant[]", ptr %vararg29, i32 0, i32 0 + store ptr %varargslots30, ptr %31, align 8 + %32 = getelementptr inbounds { ptr, i64 }, ptr %vararg29, i32 0, i32 0 + %lo33 = load ptr, ptr %32, align 8 + %33 = getelementptr inbounds { ptr, i64 }, ptr %vararg29, i32 0, i32 1 + %hi34 = load i64, ptr %33, align 8 + %34 = call i64 @std_io_printfln(ptr %retparam25, ptr %lo27, i64 %hi28, ptr %lo33, i64 %hi34) + %not_err35 = icmp eq i64 %34, 0 + br i1 %not_err35, label %after_check36, label %voiderr37 + +after_check36: ; preds = %after_check32 + br label %voiderr37 + +voiderr37: ; preds = %after_check36, %after_check32, %if.exit24 + store %"char[]" { ptr @.str.3, i64 9 }, ptr %taddr39, align 8 + %35 = getelementptr inbounds { ptr, i64 }, ptr %taddr39, i32 0, i32 0 + %lo40 = load ptr, ptr %35, align 8 + %36 = getelementptr inbounds { ptr, i64 }, ptr %taddr39, i32 0, i32 1 + %hi41 = load i64, ptr %36, align 8 + %37 = load i64, ptr %b.f, align 8 + %not_err44 = icmp eq i64 %37, 0 + br i1 %not_err44, label %after_check45, label %voiderr50 + +after_check45: ; preds = %voiderr37 + %38 = insertvalue %variant undef, ptr %b, 0 + %39 = insertvalue %variant %38, i64 ptrtoint (ptr @"ct$int" to i64), 1 + %40 = getelementptr inbounds [1 x %variant], ptr %varargslots43, i64 0, i64 0 + store %variant %39, ptr %40, align 16 + %41 = getelementptr inbounds %"variant[]", ptr %vararg42, i32 0, i32 1 + store i64 1, ptr %41, align 8 + %42 = getelementptr inbounds %"variant[]", ptr %vararg42, i32 0, i32 0 + store ptr %varargslots43, ptr %42, align 8 + %43 = getelementptr inbounds { ptr, i64 }, ptr %vararg42, i32 0, i32 0 + %lo46 = load ptr, ptr %43, align 8 + %44 = getelementptr inbounds { ptr, i64 }, ptr %vararg42, i32 0, i32 1 + %hi47 = load i64, ptr %44, align 8 + %45 = call i64 @std_io_printfln(ptr %retparam38, ptr %lo40, i64 %hi41, ptr %lo46, i64 %hi47) + %not_err48 = icmp eq i64 %45, 0 + br i1 %not_err48, label %after_check49, label %voiderr50 + +after_check49: ; preds = %after_check45 + br label %voiderr50 + +voiderr50: ; preds = %after_check49, %after_check45, %voiderr37 + ret void +} + +; Function Attrs: nounwind +define void @test_test2() #0 { +entry: + %x = alloca i32, align 4 + %x.f = alloca i64, align 8 + %a = alloca i32, align 4 + %a.f = alloca i64, align 8 + %b = alloca i32, align 4 + %b.f = alloca i64, align 8 + %err = alloca i64, align 8 + %retparam = alloca i64, align 8 + %taddr = alloca %"char[]", align 8 + %vararg = alloca %"variant[]", align 8 + %varargslots = alloca [1 x %variant], align 16 + %err9 = alloca i64, align 8 + %retparam17 = alloca i64, align 8 + %taddr18 = alloca %"char[]", align 8 + %vararg21 = alloca %"variant[]", align 8 + %varargslots22 = alloca [1 x %variant], align 16 + %retparam29 = alloca i64, align 8 + %taddr30 = alloca %"char[]", align 8 + %vararg33 = alloca %"variant[]", align 8 + %varargslots34 = alloca [1 x %variant], align 16 + %retparam42 = alloca i64, align 8 + %taddr43 = alloca %"char[]", align 8 + %vararg46 = alloca %"variant[]", align 8 + %varargslots47 = alloca [1 x %variant], align 16 + store i64 ptrtoint (ptr @"test_Test$FOO" to i64), ptr %x.f, align 8 + store i32 1, ptr %a, align 4 + store i64 0, ptr %a.f, align 8 + %0 = load i64, ptr %x.f, align 8 + %not_err = icmp eq i64 %0, 0 + br i1 %not_err, label %after_check, label %assign_optional + +assign_optional: ; preds = %entry + store i64 %0, ptr %a.f, align 8 + br label %optional_assign_jump + +after_check: ; preds = %entry + %1 = load i32, ptr %x, align 4 + store i32 %1, ptr %a, align 4 + store i64 0, ptr %a.f, align 8 + br label %after_assign + +optional_assign_jump: ; preds = %assign_optional + %reload_err = load i64, ptr %a.f, align 8 + store i64 %reload_err, ptr %b.f, align 8 + br label %after_assign1 + +after_assign: ; preds = %after_check + store i32 %1, ptr %b, align 4 + store i64 0, ptr %b.f, align 8 + br label %after_assign1 + +after_assign1: ; preds = %after_assign, %optional_assign_jump + br label %testblock + +testblock: ; preds = %after_assign1 + %2 = load i64, ptr %a.f, align 8 + %not_err2 = icmp eq i64 %2, 0 + br i1 %not_err2, label %after_check4, label %assign_optional3 + +assign_optional3: ; preds = %testblock + store i64 %2, ptr %err, align 8 + br label %end_block + +after_check4: ; preds = %testblock + store i64 0, ptr %err, align 8 + br label %end_block + +end_block: ; preds = %after_check4, %assign_optional3 + %3 = load i64, ptr %err, align 8 + %neq = icmp ne i64 %3, 0 + br i1 %neq, label %if.then, label %if.exit + +if.then: ; preds = %end_block + store %"char[]" { ptr @.str.4, i64 13 }, ptr %taddr, align 8 + %4 = getelementptr inbounds { ptr, i64 }, ptr %taddr, i32 0, i32 0 + %lo = load ptr, ptr %4, align 8 + %5 = getelementptr inbounds { ptr, i64 }, ptr %taddr, i32 0, i32 1 + %hi = load i64, ptr %5, align 8 + %6 = insertvalue %variant undef, ptr %err, 0 + %7 = insertvalue %variant %6, i64 ptrtoint (ptr @"ct$anyerr" to i64), 1 + %8 = getelementptr inbounds [1 x %variant], ptr %varargslots, i64 0, i64 0 + store %variant %7, ptr %8, align 16 + %9 = getelementptr inbounds %"variant[]", ptr %vararg, i32 0, i32 1 + store i64 1, ptr %9, align 8 + %10 = getelementptr inbounds %"variant[]", ptr %vararg, i32 0, i32 0 + store ptr %varargslots, ptr %10, align 8 + %11 = getelementptr inbounds { ptr, i64 }, ptr %vararg, i32 0, i32 0 + %lo5 = load ptr, ptr %11, align 8 + %12 = getelementptr inbounds { ptr, i64 }, ptr %vararg, i32 0, i32 1 + %hi6 = load i64, ptr %12, align 8 + %13 = call i64 @std_io_printfln(ptr %retparam, ptr %lo, i64 %hi, ptr %lo5, i64 %hi6) + %not_err7 = icmp eq i64 %13, 0 + br i1 %not_err7, label %after_check8, label %voiderr + +after_check8: ; preds = %if.then + br label %voiderr + +voiderr: ; preds = %after_check8, %if.then + br label %if.exit + +if.exit: ; preds = %voiderr, %end_block + br label %testblock10 + +testblock10: ; preds = %if.exit + %14 = load i64, ptr %b.f, align 8 + %not_err11 = icmp eq i64 %14, 0 + br i1 %not_err11, label %after_check13, label %assign_optional12 + +assign_optional12: ; preds = %testblock10 + store i64 %14, ptr %err9, align 8 + br label %end_block14 + +after_check13: ; preds = %testblock10 + store i64 0, ptr %err9, align 8 + br label %end_block14 + +end_block14: ; preds = %after_check13, %assign_optional12 + %15 = load i64, ptr %err9, align 8 + %neq15 = icmp ne i64 %15, 0 + br i1 %neq15, label %if.then16, label %if.exit28 + +if.then16: ; preds = %end_block14 + store %"char[]" { ptr @.str.5, i64 13 }, ptr %taddr18, align 8 + %16 = getelementptr inbounds { ptr, i64 }, ptr %taddr18, i32 0, i32 0 + %lo19 = load ptr, ptr %16, align 8 + %17 = getelementptr inbounds { ptr, i64 }, ptr %taddr18, i32 0, i32 1 + %hi20 = load i64, ptr %17, align 8 + %18 = insertvalue %variant undef, ptr %err9, 0 + %19 = insertvalue %variant %18, i64 ptrtoint (ptr @"ct$anyerr" to i64), 1 + %20 = getelementptr inbounds [1 x %variant], ptr %varargslots22, i64 0, i64 0 + store %variant %19, ptr %20, align 16 + %21 = getelementptr inbounds %"variant[]", ptr %vararg21, i32 0, i32 1 + store i64 1, ptr %21, align 8 + %22 = getelementptr inbounds %"variant[]", ptr %vararg21, i32 0, i32 0 + store ptr %varargslots22, ptr %22, align 8 + %23 = getelementptr inbounds { ptr, i64 }, ptr %vararg21, i32 0, i32 0 + %lo23 = load ptr, ptr %23, align 8 + %24 = getelementptr inbounds { ptr, i64 }, ptr %vararg21, i32 0, i32 1 + %hi24 = load i64, ptr %24, align 8 + %25 = call i64 @std_io_printfln(ptr %retparam17, ptr %lo19, i64 %hi20, ptr %lo23, i64 %hi24) + %not_err25 = icmp eq i64 %25, 0 + br i1 %not_err25, label %after_check26, label %voiderr27 + +after_check26: ; preds = %if.then16 + br label %voiderr27 + +voiderr27: ; preds = %after_check26, %if.then16 + br label %if.exit28 + +if.exit28: ; preds = %voiderr27, %end_block14 + store %"char[]" { ptr @.str.6, i64 9 }, ptr %taddr30, align 8 + %26 = getelementptr inbounds { ptr, i64 }, ptr %taddr30, i32 0, i32 0 + %lo31 = load ptr, ptr %26, align 8 + %27 = getelementptr inbounds { ptr, i64 }, ptr %taddr30, i32 0, i32 1 + %hi32 = load i64, ptr %27, align 8 + %28 = load i64, ptr %a.f, align 8 + %not_err35 = icmp eq i64 %28, 0 + br i1 %not_err35, label %after_check36, label %voiderr41 + +after_check36: ; preds = %if.exit28 + %29 = insertvalue %variant undef, ptr %a, 0 + %30 = insertvalue %variant %29, i64 ptrtoint (ptr @"ct$int" to i64), 1 + %31 = getelementptr inbounds [1 x %variant], ptr %varargslots34, i64 0, i64 0 + store %variant %30, ptr %31, align 16 + %32 = getelementptr inbounds %"variant[]", ptr %vararg33, i32 0, i32 1 + store i64 1, ptr %32, align 8 + %33 = getelementptr inbounds %"variant[]", ptr %vararg33, i32 0, i32 0 + store ptr %varargslots34, ptr %33, align 8 + %34 = getelementptr inbounds { ptr, i64 }, ptr %vararg33, i32 0, i32 0 + %lo37 = load ptr, ptr %34, align 8 + %35 = getelementptr inbounds { ptr, i64 }, ptr %vararg33, i32 0, i32 1 + %hi38 = load i64, ptr %35, align 8 + %36 = call i64 @std_io_printfln(ptr %retparam29, ptr %lo31, i64 %hi32, ptr %lo37, i64 %hi38) + %not_err39 = icmp eq i64 %36, 0 + br i1 %not_err39, label %after_check40, label %voiderr41 + +after_check40: ; preds = %after_check36 + br label %voiderr41 + +voiderr41: ; preds = %after_check40, %after_check36, %if.exit28 + store %"char[]" { ptr @.str.7, i64 9 }, ptr %taddr43, align 8 + %37 = getelementptr inbounds { ptr, i64 }, ptr %taddr43, i32 0, i32 0 + %lo44 = load ptr, ptr %37, align 8 + %38 = getelementptr inbounds { ptr, i64 }, ptr %taddr43, i32 0, i32 1 + %hi45 = load i64, ptr %38, align 8 + %39 = load i64, ptr %b.f, align 8 + %not_err48 = icmp eq i64 %39, 0 + br i1 %not_err48, label %after_check49, label %voiderr54 + +after_check49: ; preds = %voiderr41 + %40 = insertvalue %variant undef, ptr %b, 0 + %41 = insertvalue %variant %40, i64 ptrtoint (ptr @"ct$int" to i64), 1 + %42 = getelementptr inbounds [1 x %variant], ptr %varargslots47, i64 0, i64 0 + store %variant %41, ptr %42, align 16 + %43 = getelementptr inbounds %"variant[]", ptr %vararg46, i32 0, i32 1 + store i64 1, ptr %43, align 8 + %44 = getelementptr inbounds %"variant[]", ptr %vararg46, i32 0, i32 0 + store ptr %varargslots47, ptr %44, align 8 + %45 = getelementptr inbounds { ptr, i64 }, ptr %vararg46, i32 0, i32 0 + %lo50 = load ptr, ptr %45, align 8 + %46 = getelementptr inbounds { ptr, i64 }, ptr %vararg46, i32 0, i32 1 + %hi51 = load i64, ptr %46, align 8 + %47 = call i64 @std_io_printfln(ptr %retparam42, ptr %lo44, i64 %hi45, ptr %lo50, i64 %hi51) + %not_err52 = icmp eq i64 %47, 0 + br i1 %not_err52, label %after_check53, label %voiderr54 + +after_check53: ; preds = %after_check49 + br label %voiderr54 + +voiderr54: ; preds = %after_check53, %after_check49, %voiderr41 + ret void +} + +; Function Attrs: nounwind +define void @test_test3() #0 { +entry: + %x = alloca i32, align 4 + %x.f = alloca i64, align 8 + %a = alloca i32, align 4 + %a.f = alloca i64, align 8 + %b = alloca i32, align 4 + %b.f = alloca i64, align 8 + %err = alloca i64, align 8 + %retparam = alloca i64, align 8 + %taddr = alloca %"char[]", align 8 + %vararg = alloca %"variant[]", align 8 + %varargslots = alloca [1 x %variant], align 16 + %err9 = alloca i64, align 8 + %retparam17 = alloca i64, align 8 + %taddr18 = alloca %"char[]", align 8 + %vararg21 = alloca %"variant[]", align 8 + %varargslots22 = alloca [1 x %variant], align 16 + %retparam29 = alloca i64, align 8 + %taddr30 = alloca %"char[]", align 8 + %vararg33 = alloca %"variant[]", align 8 + %varargslots34 = alloca [1 x %variant], align 16 + %retparam42 = alloca i64, align 8 + %taddr43 = alloca %"char[]", align 8 + %vararg46 = alloca %"variant[]", align 8 + %varargslots47 = alloca [1 x %variant], align 16 + store i32 23, ptr %x, align 4 + store i64 0, ptr %x.f, align 8 + store i32 1, ptr %a, align 4 + store i64 0, ptr %a.f, align 8 + %0 = load i64, ptr %x.f, align 8 + %not_err = icmp eq i64 %0, 0 + br i1 %not_err, label %after_check, label %assign_optional + +assign_optional: ; preds = %entry + store i64 %0, ptr %a.f, align 8 + br label %optional_assign_jump + +after_check: ; preds = %entry + %1 = load i32, ptr %x, align 4 + store i32 %1, ptr %a, align 4 + store i64 0, ptr %a.f, align 8 + br label %after_assign + +optional_assign_jump: ; preds = %assign_optional + %reload_err = load i64, ptr %a.f, align 8 + store i64 %reload_err, ptr %b.f, align 8 + br label %after_assign1 + +after_assign: ; preds = %after_check + store i32 %1, ptr %b, align 4 + store i64 0, ptr %b.f, align 8 + br label %after_assign1 + +after_assign1: ; preds = %after_assign, %optional_assign_jump + br label %testblock + +testblock: ; preds = %after_assign1 + %2 = load i64, ptr %a.f, align 8 + %not_err2 = icmp eq i64 %2, 0 + br i1 %not_err2, label %after_check4, label %assign_optional3 + +assign_optional3: ; preds = %testblock + store i64 %2, ptr %err, align 8 + br label %end_block + +after_check4: ; preds = %testblock + store i64 0, ptr %err, align 8 + br label %end_block + +end_block: ; preds = %after_check4, %assign_optional3 + %3 = load i64, ptr %err, align 8 + %neq = icmp ne i64 %3, 0 + br i1 %neq, label %if.then, label %if.exit + +if.then: ; preds = %end_block + store %"char[]" { ptr @.str.8, i64 13 }, ptr %taddr, align 8 + %4 = getelementptr inbounds { ptr, i64 }, ptr %taddr, i32 0, i32 0 + %lo = load ptr, ptr %4, align 8 + %5 = getelementptr inbounds { ptr, i64 }, ptr %taddr, i32 0, i32 1 + %hi = load i64, ptr %5, align 8 + %6 = insertvalue %variant undef, ptr %err, 0 + %7 = insertvalue %variant %6, i64 ptrtoint (ptr @"ct$anyerr" to i64), 1 + %8 = getelementptr inbounds [1 x %variant], ptr %varargslots, i64 0, i64 0 + store %variant %7, ptr %8, align 16 + %9 = getelementptr inbounds %"variant[]", ptr %vararg, i32 0, i32 1 + store i64 1, ptr %9, align 8 + %10 = getelementptr inbounds %"variant[]", ptr %vararg, i32 0, i32 0 + store ptr %varargslots, ptr %10, align 8 + %11 = getelementptr inbounds { ptr, i64 }, ptr %vararg, i32 0, i32 0 + %lo5 = load ptr, ptr %11, align 8 + %12 = getelementptr inbounds { ptr, i64 }, ptr %vararg, i32 0, i32 1 + %hi6 = load i64, ptr %12, align 8 + %13 = call i64 @std_io_printfln(ptr %retparam, ptr %lo, i64 %hi, ptr %lo5, i64 %hi6) + %not_err7 = icmp eq i64 %13, 0 + br i1 %not_err7, label %after_check8, label %voiderr + +after_check8: ; preds = %if.then + br label %voiderr + +voiderr: ; preds = %after_check8, %if.then + br label %if.exit + +if.exit: ; preds = %voiderr, %end_block + br label %testblock10 + +testblock10: ; preds = %if.exit + %14 = load i64, ptr %b.f, align 8 + %not_err11 = icmp eq i64 %14, 0 + br i1 %not_err11, label %after_check13, label %assign_optional12 + +assign_optional12: ; preds = %testblock10 + store i64 %14, ptr %err9, align 8 + br label %end_block14 + +after_check13: ; preds = %testblock10 + store i64 0, ptr %err9, align 8 + br label %end_block14 + +end_block14: ; preds = %after_check13, %assign_optional12 + %15 = load i64, ptr %err9, align 8 + %neq15 = icmp ne i64 %15, 0 + br i1 %neq15, label %if.then16, label %if.exit28 + +if.then16: ; preds = %end_block14 + store %"char[]" { ptr @.str.9, i64 13 }, ptr %taddr18, align 8 + %16 = getelementptr inbounds { ptr, i64 }, ptr %taddr18, i32 0, i32 0 + %lo19 = load ptr, ptr %16, align 8 + %17 = getelementptr inbounds { ptr, i64 }, ptr %taddr18, i32 0, i32 1 + %hi20 = load i64, ptr %17, align 8 + %18 = insertvalue %variant undef, ptr %err9, 0 + %19 = insertvalue %variant %18, i64 ptrtoint (ptr @"ct$anyerr" to i64), 1 + %20 = getelementptr inbounds [1 x %variant], ptr %varargslots22, i64 0, i64 0 + store %variant %19, ptr %20, align 16 + %21 = getelementptr inbounds %"variant[]", ptr %vararg21, i32 0, i32 1 + store i64 1, ptr %21, align 8 + %22 = getelementptr inbounds %"variant[]", ptr %vararg21, i32 0, i32 0 + store ptr %varargslots22, ptr %22, align 8 + %23 = getelementptr inbounds { ptr, i64 }, ptr %vararg21, i32 0, i32 0 + %lo23 = load ptr, ptr %23, align 8 + %24 = getelementptr inbounds { ptr, i64 }, ptr %vararg21, i32 0, i32 1 + %hi24 = load i64, ptr %24, align 8 + %25 = call i64 @std_io_printfln(ptr %retparam17, ptr %lo19, i64 %hi20, ptr %lo23, i64 %hi24) + %not_err25 = icmp eq i64 %25, 0 + br i1 %not_err25, label %after_check26, label %voiderr27 + +after_check26: ; preds = %if.then16 + br label %voiderr27 + +voiderr27: ; preds = %after_check26, %if.then16 + br label %if.exit28 + +if.exit28: ; preds = %voiderr27, %end_block14 + store %"char[]" { ptr @.str.10, i64 9 }, ptr %taddr30, align 8 + %26 = getelementptr inbounds { ptr, i64 }, ptr %taddr30, i32 0, i32 0 + %lo31 = load ptr, ptr %26, align 8 + %27 = getelementptr inbounds { ptr, i64 }, ptr %taddr30, i32 0, i32 1 + %hi32 = load i64, ptr %27, align 8 + %28 = load i64, ptr %a.f, align 8 + %not_err35 = icmp eq i64 %28, 0 + br i1 %not_err35, label %after_check36, label %voiderr41 + +after_check36: ; preds = %if.exit28 + %29 = insertvalue %variant undef, ptr %a, 0 + %30 = insertvalue %variant %29, i64 ptrtoint (ptr @"ct$int" to i64), 1 + %31 = getelementptr inbounds [1 x %variant], ptr %varargslots34, i64 0, i64 0 + store %variant %30, ptr %31, align 16 + %32 = getelementptr inbounds %"variant[]", ptr %vararg33, i32 0, i32 1 + store i64 1, ptr %32, align 8 + %33 = getelementptr inbounds %"variant[]", ptr %vararg33, i32 0, i32 0 + store ptr %varargslots34, ptr %33, align 8 + %34 = getelementptr inbounds { ptr, i64 }, ptr %vararg33, i32 0, i32 0 + %lo37 = load ptr, ptr %34, align 8 + %35 = getelementptr inbounds { ptr, i64 }, ptr %vararg33, i32 0, i32 1 + %hi38 = load i64, ptr %35, align 8 + %36 = call i64 @std_io_printfln(ptr %retparam29, ptr %lo31, i64 %hi32, ptr %lo37, i64 %hi38) + %not_err39 = icmp eq i64 %36, 0 + br i1 %not_err39, label %after_check40, label %voiderr41 + +after_check40: ; preds = %after_check36 + br label %voiderr41 + +voiderr41: ; preds = %after_check40, %after_check36, %if.exit28 + store %"char[]" { ptr @.str.11, i64 9 }, ptr %taddr43, align 8 + %37 = getelementptr inbounds { ptr, i64 }, ptr %taddr43, i32 0, i32 0 + %lo44 = load ptr, ptr %37, align 8 + %38 = getelementptr inbounds { ptr, i64 }, ptr %taddr43, i32 0, i32 1 + %hi45 = load i64, ptr %38, align 8 + %39 = load i64, ptr %b.f, align 8 + %not_err48 = icmp eq i64 %39, 0 + br i1 %not_err48, label %after_check49, label %voiderr54 + +after_check49: ; preds = %voiderr41 + %40 = insertvalue %variant undef, ptr %b, 0 + %41 = insertvalue %variant %40, i64 ptrtoint (ptr @"ct$int" to i64), 1 + %42 = getelementptr inbounds [1 x %variant], ptr %varargslots47, i64 0, i64 0 + store %variant %41, ptr %42, align 16 + %43 = getelementptr inbounds %"variant[]", ptr %vararg46, i32 0, i32 1 + store i64 1, ptr %43, align 8 + %44 = getelementptr inbounds %"variant[]", ptr %vararg46, i32 0, i32 0 + store ptr %varargslots47, ptr %44, align 8 + %45 = getelementptr inbounds { ptr, i64 }, ptr %vararg46, i32 0, i32 0 + %lo50 = load ptr, ptr %45, align 8 + %46 = getelementptr inbounds { ptr, i64 }, ptr %vararg46, i32 0, i32 1 + %hi51 = load i64, ptr %46, align 8 + %47 = call i64 @std_io_printfln(ptr %retparam42, ptr %lo44, i64 %hi45, ptr %lo50, i64 %hi51) + %not_err52 = icmp eq i64 %47, 0 + br i1 %not_err52, label %after_check53, label %voiderr54 + +after_check53: ; preds = %after_check49 + br label %voiderr54 + +voiderr54: ; preds = %after_check53, %after_check49, %voiderr41 + ret void +} diff --git a/test/test_suite2/errors/failable_inits.c3t b/test/test_suite2/errors/failable_inits.c3t index 3173bd79d..eea3ce878 100644 --- a/test/test_suite2/errors/failable_inits.c3t +++ b/test/test_suite2/errors/failable_inits.c3t @@ -43,16 +43,16 @@ entry: store i64 ptrtoint (ptr @"test_Foo$MY_VAL1" to i64), ptr %x.f, align 8 %0 = load i64, ptr %x.f, align 8 %not_err = icmp eq i64 %0, 0 - br i1 %not_err, label %after_check, label %error + br i1 %not_err, label %after_check, label %assign_optional -error: ; preds = %entry +assign_optional: ; preds = %entry store i64 %0, ptr %error_var, align 8 br label %guard_block after_check: ; preds = %entry br label %noerr_block -guard_block: ; preds = %error +guard_block: ; preds = %assign_optional %1 = load i64, ptr %error_var, align 8 ret i64 %1 @@ -72,16 +72,16 @@ entry: store i64 0, ptr %x.f, align 8 %0 = load i64, ptr %x.f, align 8 %not_err = icmp eq i64 %0, 0 - br i1 %not_err, label %after_check, label %error + br i1 %not_err, label %after_check, label %assign_optional -error: ; preds = %entry +assign_optional: ; preds = %entry store i64 %0, ptr %error_var, align 8 br label %guard_block after_check: ; preds = %entry br label %noerr_block -guard_block: ; preds = %error +guard_block: ; preds = %assign_optional %1 = load i64, ptr %error_var, align 8 ret i64 %1 @@ -95,19 +95,19 @@ define void @test_main() #0 { entry: %0 = call i64 @test_test1() %not_err = icmp eq i64 %0, 0 - br i1 %not_err, label %after.errcheck, label %voiderr + br i1 %not_err, label %after_check, label %voiderr -after.errcheck: ; preds = %entry +after_check: ; preds = %entry br label %voiderr -voiderr: ; preds = %after.errcheck, %entry +voiderr: ; preds = %after_check, %entry %1 = call i64 @test_test2() %not_err1 = icmp eq i64 %1, 0 - br i1 %not_err1, label %after.errcheck2, label %voiderr3 + br i1 %not_err1, label %after_check2, label %voiderr3 -after.errcheck2: ; preds = %voiderr +after_check2: ; preds = %voiderr br label %voiderr3 -voiderr3: ; preds = %after.errcheck2, %voiderr +voiderr3: ; preds = %after_check2, %voiderr ret void } diff --git a/test/test_suite2/errors/failable_taddr_and_access.c3t b/test/test_suite2/errors/failable_taddr_and_access.c3t index 6de69c597..aca3b89a0 100644 --- a/test/test_suite2/errors/failable_taddr_and_access.c3t +++ b/test/test_suite2/errors/failable_taddr_and_access.c3t @@ -44,15 +44,15 @@ entry: %w = alloca ptr, align 8 %w.f = alloca i64, align 8 %literal = alloca %Foo, align 4 - %literal4 = alloca %Foo, align 4 + %literal5 = alloca %Foo, align 4 store i32 2, ptr %z, align 4 store i64 0, ptr %z.f, align 8 %0 = getelementptr inbounds %Foo, ptr %literal, i32 0, i32 0 %1 = load i64, ptr %z.f, align 8 %not_err = icmp eq i64 %1, 0 - br i1 %not_err, label %after_check, label %error + br i1 %not_err, label %after_check, label %assign_optional -error: ; preds = %entry +assign_optional: ; preds = %entry store i64 %1, ptr %w.f, align 8 br label %after_assign @@ -65,7 +65,7 @@ after_check: ; preds = %entry store i64 0, ptr %w.f, align 8 br label %after_assign -after_assign: ; preds = %after_check, %error +after_assign: ; preds = %after_check, %assign_optional %4 = load i64, ptr %w.f, align 8 %not_err1 = icmp eq i64 %4, 0 br i1 %not_err1, label %after_check2, label %voiderr @@ -79,42 +79,42 @@ after_check2: ; preds = %after_assign voiderr: ; preds = %after_check2, %after_assign store i64 ptrtoint (ptr @"test_MyErr$FOO" to i64), ptr %z.f, align 8 - br label %voiderr3 + br label %voiderr4 -voiderr3: ; preds = %voiderr - %9 = getelementptr inbounds %Foo, ptr %literal4, i32 0, i32 0 +voiderr4: ; preds = %voiderr + %9 = getelementptr inbounds %Foo, ptr %literal5, i32 0, i32 0 %10 = load i64, ptr %z.f, align 8 - %not_err5 = icmp eq i64 %10, 0 - br i1 %not_err5, label %after_check7, label %error6 + %not_err6 = icmp eq i64 %10, 0 + br i1 %not_err6, label %after_check8, label %assign_optional7 -error6: ; preds = %voiderr3 +assign_optional7: ; preds = %voiderr4 store i64 %10, ptr %w.f, align 8 - br label %after_assign8 + br label %after_assign9 -after_check7: ; preds = %voiderr3 +after_check8: ; preds = %voiderr4 %11 = load i32, ptr %z, align 4 store i32 %11, ptr %9, align 4 - %12 = getelementptr inbounds %Foo, ptr %literal4, i32 0, i32 1 + %12 = getelementptr inbounds %Foo, ptr %literal5, i32 0, i32 1 store i32 0, ptr %12, align 4 - store ptr %literal4, ptr %w, align 8 + store ptr %literal5, ptr %w, align 8 store i64 0, ptr %w.f, align 8 - br label %after_assign8 + br label %after_assign9 -after_assign8: ; preds = %after_check7, %error6 - br label %voiderr9 +after_assign9: ; preds = %after_check8, %assign_optional7 + br label %voiderr10 -voiderr9: ; preds = %after_assign8 +voiderr10: ; preds = %after_assign9 %13 = load i64, ptr %w.f, align 8 - %not_err10 = icmp eq i64 %13, 0 - br i1 %not_err10, label %after_check11, label %voiderr12 + %not_err11 = icmp eq i64 %13, 0 + br i1 %not_err11, label %after_check12, label %voiderr13 -after_check11: ; preds = %voiderr9 +after_check12: ; preds = %voiderr10 %14 = load ptr, ptr %w, align 8 %15 = getelementptr inbounds %Foo, ptr %14, i32 0, i32 0 %16 = load i32, ptr %15, align 8 %17 = call i32 (ptr, ...) @printf(ptr @.str.1, i32 %16) - br label %voiderr12 + br label %voiderr13 -voiderr12: ; preds = %after_check11, %voiderr9 +voiderr13: ; preds = %after_check12, %voiderr10 ret void } \ No newline at end of file diff --git a/test/test_suite2/errors/macro_err.c3t b/test/test_suite2/errors/macro_err.c3t index 85591f886..0b51381bb 100644 --- a/test/test_suite2/errors/macro_err.c3t +++ b/test/test_suite2/errors/macro_err.c3t @@ -32,19 +32,19 @@ entry: %retparam = alloca i32, align 4 %0 = call i64 @test_abc(ptr %retparam) %not_err = icmp eq i64 %0, 0 - br i1 %not_err, label %after.errcheck, label %error + br i1 %not_err, label %after_check, label %assign_optional -error: ; preds = %entry +assign_optional: ; preds = %entry store i64 %0, ptr %error_var, align 8 br label %guard_block -after.errcheck: ; preds = %entry +after_check: ; preds = %entry br label %noerr_block -guard_block: ; preds = %error +guard_block: ; preds = %assign_optional ret void -noerr_block: ; preds = %after.errcheck +noerr_block: ; preds = %after_check %1 = load i32, ptr %retparam, align 4 br label %phi_block diff --git a/test/test_suite2/errors/macro_err2.c3t b/test/test_suite2/errors/macro_err2.c3t index 368d29d9d..c86a32432 100644 --- a/test/test_suite2/errors/macro_err2.c3t +++ b/test/test_suite2/errors/macro_err2.c3t @@ -32,9 +32,9 @@ entry: %retparam = alloca i32, align 4 %0 = call i64 @test_abc(ptr %retparam) %not_err = icmp eq i64 %0, 0 - br i1 %not_err, label %after.errcheck, label %opt_block_cleanup + br i1 %not_err, label %after_check, label %opt_block_cleanup -after.errcheck: ; preds = %entry +after_check: ; preds = %entry %1 = call i32 (ptr, ...) @printf(ptr @.str.1) %2 = load i32, ptr %retparam, align 4 store i32 %2, ptr %blockret, align 4 @@ -44,7 +44,7 @@ opt_block_cleanup: ; preds = %entry %3 = call i32 (ptr, ...) @printf(ptr @.str.2) br label %else_block -expr_block.exit: ; preds = %after.errcheck +expr_block.exit: ; preds = %after_check %4 = load i32, ptr %blockret, align 4 br label %phi_block diff --git a/test/test_suite2/errors/printing_errors.c3t b/test/test_suite2/errors/printing_errors.c3t index 7b4d452c6..da6f92d77 100644 --- a/test/test_suite2/errors/printing_errors.c3t +++ b/test/test_suite2/errors/printing_errors.c3t @@ -64,11 +64,11 @@ faultname_exit: ; preds = %faultname_ok, %faul %hi3 = load i64, ptr %14, align 8 %15 = call i64 @std_io_printf(ptr %retparam, ptr %lo, i64 %hi, ptr %lo2, i64 %hi3) %not_err = icmp eq i64 %15, 0 - br i1 %not_err, label %after.errcheck, label %voiderr + br i1 %not_err, label %after_check, label %voiderr -after.errcheck: ; preds = %faultname_exit +after_check: ; preds = %faultname_exit br label %voiderr -voiderr: ; preds = %after.errcheck, %faultname_exit +voiderr: ; preds = %after_check, %faultname_exit ret void } diff --git a/test/test_suite2/errors/rethrow.c3t b/test/test_suite2/errors/rethrow.c3t index 6887276a0..a92db5682 100644 --- a/test/test_suite2/errors/rethrow.c3t +++ b/test/test_suite2/errors/rethrow.c3t @@ -6,25 +6,26 @@ fn void! test() i?; } -// #expect: rethrow.ll +/* #expect: rethrow.ll %i = alloca i32, align 4 %i.f = alloca i64, align 8 %error_var = alloca i64, align 8 + %reterr = alloca i64, align 8 store i64 0, ptr %i.f, align 8 store i32 0, ptr %i, align 4 %0 = load i64, ptr %i.f, align 8 %not_err = icmp eq i64 %0, 0 - br i1 %not_err, label %after_check, label %error + br i1 %not_err, label %after_check, label %assign_optional -error: ; preds = %entry +assign_optional: ; preds = %entry store i64 %0, ptr %error_var, align 8 br label %guard_block after_check: ; preds = %entry br label %noerr_block -guard_block: ; preds = %error +guard_block: ; preds = %assign_optional %1 = load i64, ptr %error_var, align 8 ret i64 %1 diff --git a/test/test_suite2/errors/rethrow_mingw.c3t b/test/test_suite2/errors/rethrow_mingw.c3t index 386184673..cf7882821 100644 --- a/test/test_suite2/errors/rethrow_mingw.c3t +++ b/test/test_suite2/errors/rethrow_mingw.c3t @@ -8,27 +8,28 @@ fn void! test() i?; } -// #expect: rethrow.ll +/* #expect: rethrow.ll define i64 @rethrow_test() #0 { entry: %i = alloca i32, align 4 %i.f = alloca i64, align 8 %error_var = alloca i64, align 8 + %reterr = alloca i64, align 8 store i64 0, ptr %i.f, align 8 store i32 0, ptr %i, align 4 %0 = load i64, ptr %i.f, align 8 %not_err = icmp eq i64 %0, 0 - br i1 %not_err, label %after_check, label %error + br i1 %not_err, label %after_check, label %assign_optional -error: ; preds = %entry +assign_optional: ; preds = %entry store i64 %0, ptr %error_var, align 8 br label %guard_block after_check: ; preds = %entry br label %noerr_block -guard_block: ; preds = %error +guard_block: ; preds = %assign_optional %1 = load i64, ptr %error_var, align 8 ret i64 %1 diff --git a/test/test_suite2/errors/try_assign.c3t b/test/test_suite2/errors/try_assign.c3t index 055e4753c..ad85abaf9 100644 --- a/test/test_suite2/errors/try_assign.c3t +++ b/test/test_suite2/errors/try_assign.c3t @@ -127,9 +127,9 @@ if.exit15: ; preds = %if.then14, %phi_try testblock: ; preds = %if.exit15 %12 = load i64, ptr %z.f, align 8 %not_err16 = icmp eq i64 %12, 0 - br i1 %not_err16, label %after_check17, label %error + br i1 %not_err16, label %after_check17, label %assign_optional -error: ; preds = %testblock +assign_optional: ; preds = %testblock store i64 %12, ptr %e, align 8 br label %end_block @@ -137,7 +137,7 @@ after_check17: ; preds = %testblock store i64 0, ptr %e, align 8 br label %end_block -end_block: ; preds = %after_check17, %error +end_block: ; preds = %after_check17, %assign_optional %13 = load i64, ptr %e, align 8 %neq = icmp ne i64 %13, 0 br i1 %neq, label %if.then18, label %if.exit19 diff --git a/test/test_suite2/errors/try_catch_if.c3t b/test/test_suite2/errors/try_catch_if.c3t index ad41df15f..f7cc257f3 100644 --- a/test/test_suite2/errors/try_catch_if.c3t +++ b/test/test_suite2/errors/try_catch_if.c3t @@ -58,9 +58,9 @@ entry: testblock: ; preds = %entry %0 = load i64, ptr %a.f, align 8 %not_err = icmp eq i64 %0, 0 - br i1 %not_err, label %after_check, label %error + br i1 %not_err, label %after_check, label %assign_optional -error: ; preds = %testblock +assign_optional: ; preds = %testblock store i64 %0, ptr %err, align 8 br label %end_block @@ -70,17 +70,17 @@ after_check: ; preds = %testblock testblock1: ; preds = %after_check %1 = call i64 @try_catch_if_tester(ptr %retparam) %not_err2 = icmp eq i64 %1, 0 - br i1 %not_err2, label %after.errcheck, label %error3 + br i1 %not_err2, label %after_check4, label %assign_optional3 -error3: ; preds = %testblock1 +assign_optional3: ; preds = %testblock1 store i64 %1, ptr %err, align 8 br label %end_block -after.errcheck: ; preds = %testblock1 +after_check4: ; preds = %testblock1 store i64 0, ptr %err, align 8 br label %end_block -end_block: ; preds = %after.errcheck, %error3, %error +end_block: ; preds = %after_check4, %assign_optional3, %assign_optional %2 = load i64, ptr %err, align 8 %neq = icmp ne i64 %2, 0 br i1 %neq, label %if.then, label %if.else diff --git a/test/test_suite2/errors/try_unwrap_using_assert.c3t b/test/test_suite2/errors/try_unwrap_using_assert.c3t index 434ef9d0c..1870b5edb 100644 --- a/test/test_suite2/errors/try_unwrap_using_assert.c3t +++ b/test/test_suite2/errors/try_unwrap_using_assert.c3t @@ -11,7 +11,7 @@ fn int tester(int n) return num; } -// #expect: test.ll +/* #expect: test.ll define i32 @test_tester(i32 %0) #0 { entry: @@ -21,19 +21,19 @@ entry: %x = alloca i32, align 4 %1 = call i64 @maybe(ptr %retparam) %not_err = icmp eq i64 %1, 0 - br i1 %not_err, label %after.errcheck, label %error + br i1 %not_err, label %after_check, label %assign_optional -error: ; preds = %entry +assign_optional: ; preds = %entry store i64 %1, ptr %num.f, align 8 br label %after_assign -after.errcheck: ; preds = %entry +after_check: ; preds = %entry %2 = load i32, ptr %retparam, align 4 store i32 %2, ptr %num, align 4 store i64 0, ptr %num.f, align 8 br label %after_assign -after_assign: ; preds = %after.errcheck, %error +after_assign: ; preds = %after_check, %assign_optional %3 = load i32, ptr %num, align 4 store i32 %3, ptr %x, align 4 %4 = load i32, ptr %num, align 4 diff --git a/test/test_suite2/errors/try_with_chained_unwrap.c3t b/test/test_suite2/errors/try_with_chained_unwrap.c3t index 796f6e98d..4e12d57c5 100644 --- a/test/test_suite2/errors/try_with_chained_unwrap.c3t +++ b/test/test_suite2/errors/try_with_chained_unwrap.c3t @@ -27,24 +27,24 @@ entry: store i32 0, ptr %val, align 4 %0 = call i64 @readLine(ptr %retparam1) %not_err = icmp eq i64 %0, 0 - br i1 %not_err, label %after.errcheck, label %catch_landing + br i1 %not_err, label %after_check, label %catch_landing -after.errcheck: ; preds = %entry +after_check: ; preds = %entry %1 = load ptr, ptr %retparam1, align 8 %2 = call i64 @atoi(ptr %retparam, ptr %1) %not_err2 = icmp eq i64 %2, 0 - br i1 %not_err2, label %after.errcheck3, label %catch_landing + br i1 %not_err2, label %after_check3, label %catch_landing -after.errcheck3: ; preds = %after.errcheck +after_check3: ; preds = %after_check %3 = load i32, ptr %retparam, align 4 store i32 %3, ptr %val, align 4 br label %phi_try_catch -catch_landing: ; preds = %after.errcheck, %entry +catch_landing: ; preds = %after_check, %entry br label %phi_try_catch -phi_try_catch: ; preds = %catch_landing, %after.errcheck3 - %val4 = phi i1 [ true, %after.errcheck3 ], [ false, %catch_landing ] +phi_try_catch: ; preds = %catch_landing, %after_check3 + %val4 = phi i1 [ true, %after_check3 ], [ false, %catch_landing ] br i1 %val4, label %if.then, label %if.exit if.then: ; preds = %phi_try_catch diff --git a/test/test_suite2/errors/try_with_unwrap.c3t b/test/test_suite2/errors/try_with_unwrap.c3t index a1f6cefa6..7da35548e 100644 --- a/test/test_suite2/errors/try_with_unwrap.c3t +++ b/test/test_suite2/errors/try_with_unwrap.c3t @@ -31,19 +31,19 @@ entry: %retparam1 = alloca i32, align 4 %0 = call i64 @readLine(ptr %retparam) %not_err = icmp eq i64 %0, 0 - br i1 %not_err, label %after.errcheck, label %error + br i1 %not_err, label %after_check, label %assign_optional -error: ; preds = %entry +assign_optional: ; preds = %entry store i64 %0, ptr %line.f, align 8 br label %after_assign -after.errcheck: ; preds = %entry +after_check: ; preds = %entry %1 = load ptr, ptr %retparam, align 8 store ptr %1, ptr %line, align 8 store i64 0, ptr %line.f, align 8 br label %after_assign -after_assign: ; preds = %after.errcheck, %error +after_assign: ; preds = %after_check, %assign_optional %load.err = load i64, ptr %line.f, align 8 %result = icmp eq i64 %load.err, 0 br i1 %result, label %if.then, label %if.exit9 @@ -52,19 +52,19 @@ if.then: ; preds = %after_assign %2 = load ptr, ptr %line, align 8 %3 = call i64 @atoi(ptr %retparam1, ptr %2) %not_err2 = icmp eq i64 %3, 0 - br i1 %not_err2, label %after.errcheck4, label %error3 + br i1 %not_err2, label %after_check4, label %assign_optional3 -error3: ; preds = %if.then +assign_optional3: ; preds = %if.then store i64 %3, ptr %val.f, align 8 br label %after_assign5 -after.errcheck4: ; preds = %if.then +after_check4: ; preds = %if.then %4 = load i32, ptr %retparam1, align 4 store i32 %4, ptr %val, align 4 store i64 0, ptr %val.f, align 8 br label %after_assign5 -after_assign5: ; preds = %after.errcheck4, %error3 +after_assign5: ; preds = %after_check4, %assign_optional3 %load.err6 = load i64, ptr %val.f, align 8 %result7 = icmp eq i64 %load.err6, 0 br i1 %result7, label %if.then8, label %if.exit diff --git a/test/test_suite2/errors/try_with_unwrapper.c3t b/test/test_suite2/errors/try_with_unwrapper.c3t index be4584afd..8ac494b8a 100644 --- a/test/test_suite2/errors/try_with_unwrapper.c3t +++ b/test/test_suite2/errors/try_with_unwrapper.c3t @@ -94,28 +94,28 @@ chain_next: ; preds = %phi_try_catch store i32 0, ptr %c, align 4 %2 = call i64 @try_with_unwrapper_tester(ptr %retparam) %not_err1 = icmp eq i64 %2, 0 - br i1 %not_err1, label %after.errcheck, label %catch_landing2 + br i1 %not_err1, label %after_check2, label %catch_landing3 -after.errcheck: ; preds = %chain_next +after_check2: ; preds = %chain_next %3 = load i32, ptr %retparam, align 4 store i32 %3, ptr %c, align 4 - br label %phi_try_catch3 + br label %phi_try_catch4 -catch_landing2: ; preds = %chain_next - br label %phi_try_catch3 +catch_landing3: ; preds = %chain_next + br label %phi_try_catch4 -phi_try_catch3: ; preds = %catch_landing2, %after.errcheck - %val4 = phi i1 [ true, %after.errcheck ], [ false, %catch_landing2 ] - br i1 %val4, label %chain_next5, label %fail_chain +phi_try_catch4: ; preds = %catch_landing3, %after_check2 + %val5 = phi i1 [ true, %after_check2 ], [ false, %catch_landing3 ] + br i1 %val5, label %chain_next6, label %fail_chain -chain_next5: ; preds = %phi_try_catch3 +chain_next6: ; preds = %phi_try_catch4 br label %end_chain -fail_chain: ; preds = %phi_try_catch3, %phi_try_catch +fail_chain: ; preds = %phi_try_catch4, %phi_try_catch br label %end_chain -end_chain: ; preds = %fail_chain, %chain_next5 - %chain.phi = phi i1 [ true, %chain_next5 ], [ false, %fail_chain ] +end_chain: ; preds = %fail_chain, %chain_next6 + %chain.phi = phi i1 [ true, %chain_next6 ], [ false, %fail_chain ] br i1 %chain.phi, label %if.then, label %if.exit if.then: ; preds = %end_chain diff --git a/test/test_suite2/expressions/chained_ternary.c3t b/test/test_suite2/expressions/chained_ternary.c3t index 1788dc2cb..ee7e9b9f2 100644 --- a/test/test_suite2/expressions/chained_ternary.c3t +++ b/test/test_suite2/expressions/chained_ternary.c3t @@ -56,9 +56,9 @@ cond.phi4: ; preds = %cond.phi, %cond.lhs cond.lhs7: ; preds = %cond.phi4 %6 = load i64, ptr %x.f, align 8 %not_err = icmp eq i64 %6, 0 - br i1 %not_err, label %after_check, label %error + br i1 %not_err, label %after_check, label %assign_optional -error: ; preds = %cond.lhs7 +assign_optional: ; preds = %cond.lhs7 store i64 %6, ptr %y.f, align 8 br label %after_assign @@ -76,7 +76,7 @@ cond.phi9: ; preds = %cond.rhs8, %after_c store i64 0, ptr %y.f, align 8 br label %after_assign -after_assign: ; preds = %cond.phi9, %error +after_assign: ; preds = %cond.phi9, %assign_optional %9 = load ptr, ptr %a, align 8 %not11 = icmp eq ptr %9, null br i1 %not11, label %cond.lhs12, label %cond.rhs13 @@ -88,9 +88,9 @@ cond.lhs12: ; preds = %after_assign cond.rhs13: ; preds = %after_assign %11 = load i64, ptr %x.f, align 8 %not_err14 = icmp eq i64 %11, 0 - br i1 %not_err14, label %after_check16, label %error15 + br i1 %not_err14, label %after_check16, label %assign_optional15 -error15: ; preds = %cond.rhs13 +assign_optional15: ; preds = %cond.rhs13 store i64 %11, ptr %y.f, align 8 br label %after_assign19 @@ -104,7 +104,7 @@ cond.phi17: ; preds = %after_check16, %con store i64 0, ptr %y.f, align 8 br label %after_assign19 -after_assign19: ; preds = %cond.phi17, %error15 +after_assign19: ; preds = %cond.phi17, %assign_optional15 br label %voiderr voiderr: ; preds = %after_assign19 @@ -115,9 +115,9 @@ voiderr: ; preds = %after_assign19 cond.lhs21: ; preds = %voiderr %14 = load i64, ptr %x.f, align 8 %not_err22 = icmp eq i64 %14, 0 - br i1 %not_err22, label %after_check24, label %error23 + br i1 %not_err22, label %after_check24, label %assign_optional23 -error23: ; preds = %cond.lhs21 +assign_optional23: ; preds = %cond.lhs21 store i64 %14, ptr %y.f, align 8 br label %after_assign31 @@ -128,9 +128,9 @@ after_check24: ; preds = %cond.lhs21 cond.rhs25: ; preds = %voiderr %16 = load i64, ptr %x.f, align 8 %not_err26 = icmp eq i64 %16, 0 - br i1 %not_err26, label %after_check28, label %error27 + br i1 %not_err26, label %after_check28, label %assign_optional27 -error27: ; preds = %cond.rhs25 +assign_optional27: ; preds = %cond.rhs25 store i64 %16, ptr %y.f, align 8 br label %after_assign31 @@ -144,7 +144,7 @@ cond.phi29: ; preds = %after_check28, %aft store i64 0, ptr %y.f, align 8 br label %after_assign31 -after_assign31: ; preds = %cond.phi29, %error27, %error23 +after_assign31: ; preds = %cond.phi29, %assign_optional27, %assign_optional23 br label %voiderr32 voiderr32: ; preds = %after_assign31 @@ -155,9 +155,9 @@ voiderr32: ; preds = %after_assign31 cond.lhs34: ; preds = %voiderr32 %19 = load i64, ptr %x.f, align 8 %not_err35 = icmp eq i64 %19, 0 - br i1 %not_err35, label %after_check37, label %error36 + br i1 %not_err35, label %after_check37, label %assign_optional36 -error36: ; preds = %cond.lhs34 +assign_optional36: ; preds = %cond.lhs34 store i64 %19, ptr %y.f, align 8 br label %after_assign40 @@ -174,7 +174,7 @@ cond.phi39: ; preds = %after_check37 store i64 0, ptr %y.f, align 8 br label %after_assign40 -after_assign40: ; preds = %cond.phi39, %cond.rhs38, %error36 +after_assign40: ; preds = %cond.phi39, %cond.rhs38, %assign_optional36 br label %voiderr41 voiderr41: ; preds = %after_assign40 @@ -189,9 +189,9 @@ cond.lhs43: ; preds = %voiderr41 cond.rhs44: ; preds = %voiderr41 %22 = load i64, ptr %x.f, align 8 %not_err45 = icmp eq i64 %22, 0 - br i1 %not_err45, label %after_check47, label %error46 + br i1 %not_err45, label %after_check47, label %assign_optional46 -error46: ; preds = %cond.rhs44 +assign_optional46: ; preds = %cond.rhs44 store i64 %22, ptr %y.f, align 8 br label %after_assign49 @@ -204,7 +204,7 @@ cond.phi48: ; preds = %after_check47 store i64 0, ptr %y.f, align 8 br label %after_assign49 -after_assign49: ; preds = %cond.phi48, %error46, %cond.lhs43 +after_assign49: ; preds = %cond.phi48, %assign_optional46, %cond.lhs43 br label %voiderr50 voiderr50: ; preds = %after_assign49 diff --git a/test/test_suite2/from_docs/examples_if_catch.c3t b/test/test_suite2/from_docs/examples_if_catch.c3t index d1800b3cf..c2e39c17c 100644 --- a/test/test_suite2/from_docs/examples_if_catch.c3t +++ b/test/test_suite2/from_docs/examples_if_catch.c3t @@ -72,20 +72,20 @@ entry: %1 = call i32 @demo_bar() %2 = call i64 @demo_divide(ptr %retparam, i32 %0, i32 %1) %not_err = icmp eq i64 %2, 0 - br i1 %not_err, label %after.errcheck, label %error + br i1 %not_err, label %after_check, label %assign_optional -error: ; preds = %entry +assign_optional: ; preds = %entry store i64 %2, ptr %error_var, align 8 br label %guard_block -after.errcheck: ; preds = %entry +after_check: ; preds = %entry br label %noerr_block -guard_block: ; preds = %error +guard_block: ; preds = %assign_optional %3 = load i64, ptr %error_var, align 8 ret i64 %3 -noerr_block: ; preds = %after.errcheck +noerr_block: ; preds = %after_check ret i64 0 } @@ -100,35 +100,35 @@ entry: %1 = call i32 @demo_bar() %2 = call i64 @demo_divide(ptr %retparam, i32 %0, i32 %1) %not_err = icmp eq i64 %2, 0 - br i1 %not_err, label %after.errcheck, label %error + br i1 %not_err, label %after_check, label %assign_optional -error: ; preds = %entry +assign_optional: ; preds = %entry store i64 %2, ptr %ratio.f, align 8 br label %after_assign -after.errcheck: ; preds = %entry +after_check: ; preds = %entry %3 = load double, ptr %retparam, align 8 store double %3, ptr %ratio, align 8 store i64 0, ptr %ratio.f, align 8 br label %after_assign -after_assign: ; preds = %after.errcheck, %error +after_assign: ; preds = %after_check, %assign_optional br label %testblock testblock: ; preds = %after_assign %4 = load i64, ptr %ratio.f, align 8 %not_err1 = icmp eq i64 %4, 0 - br i1 %not_err1, label %after_check, label %error2 + br i1 %not_err1, label %after_check3, label %assign_optional2 -error2: ; preds = %testblock +assign_optional2: ; preds = %testblock store i64 %4, ptr %err, align 8 br label %end_block -after_check: ; preds = %testblock +after_check3: ; preds = %testblock store i64 0, ptr %err, align 8 br label %end_block -end_block: ; preds = %after_check, %error2 +end_block: ; preds = %after_check3, %assign_optional2 %5 = load i64, ptr %err, align 8 %neq = icmp ne i64 %5, 0 br i1 %neq, label %if.then, label %if.exit diff --git a/test/test_suite2/generic/enum_set_test.c3t b/test/test_suite2/generic/enum_set_test.c3t index 3624124a2..1eefab8ad 100644 --- a/test/test_suite2/generic/enum_set_test.c3t +++ b/test/test_suite2/generic/enum_set_test.c3t @@ -78,12 +78,12 @@ entry: %hi3 = load i64, ptr %9, align 8 %10 = call i64 @std_io_printf(ptr %retparam, ptr %lo, i64 %hi, ptr %lo2, i64 %hi3) %not_err = icmp eq i64 %10, 0 - br i1 %not_err, label %after.errcheck, label %voiderr + br i1 %not_err, label %after_check, label %voiderr -after.errcheck: ; preds = %entry +after_check: ; preds = %entry br label %voiderr -voiderr: ; preds = %after.errcheck, %entry +voiderr: ; preds = %after_check, %entry call void @"std_enumset$$test_Abc_EnumSet_add"(ptr %set, i32 0) store %"char[]" { ptr @.str.1, i64 14 }, ptr %taddr5, align 8 %11 = getelementptr inbounds { ptr, i64 }, ptr %taddr5, i32 0, i32 0 @@ -106,12 +106,12 @@ voiderr: ; preds = %after.errcheck, %en %hi12 = load i64, ptr %20, align 8 %21 = call i64 @std_io_printf(ptr %retparam4, ptr %lo6, i64 %hi7, ptr %lo11, i64 %hi12) %not_err13 = icmp eq i64 %21, 0 - br i1 %not_err13, label %after.errcheck14, label %voiderr15 + br i1 %not_err13, label %after_check14, label %voiderr15 -after.errcheck14: ; preds = %voiderr +after_check14: ; preds = %voiderr br label %voiderr15 -voiderr15: ; preds = %after.errcheck14, %voiderr +voiderr15: ; preds = %after_check14, %voiderr call void @"std_enumset$$test_Abc_EnumSet_add"(ptr %set, i32 1) store %"char[]" { ptr @.str.2, i64 14 }, ptr %taddr17, align 8 %22 = getelementptr inbounds { ptr, i64 }, ptr %taddr17, i32 0, i32 0 @@ -134,12 +134,12 @@ voiderr15: ; preds = %after.errcheck14, % %hi24 = load i64, ptr %31, align 8 %32 = call i64 @std_io_printf(ptr %retparam16, ptr %lo18, i64 %hi19, ptr %lo23, i64 %hi24) %not_err25 = icmp eq i64 %32, 0 - br i1 %not_err25, label %after.errcheck26, label %voiderr27 + br i1 %not_err25, label %after_check26, label %voiderr27 -after.errcheck26: ; preds = %voiderr15 +after_check26: ; preds = %voiderr15 br label %voiderr27 -voiderr27: ; preds = %after.errcheck26, %voiderr15 +voiderr27: ; preds = %after_check26, %voiderr15 store i32 0, ptr %set2, align 4 %33 = load i32, ptr %set, align 4 call void @"std_enumset$$test_Abc_EnumSet_add_all"(ptr %set2, i32 %33) @@ -164,12 +164,12 @@ voiderr27: ; preds = %after.errcheck26, % %hi36 = load i64, ptr %43, align 8 %44 = call i64 @std_io_printf(ptr %retparam28, ptr %lo30, i64 %hi31, ptr %lo35, i64 %hi36) %not_err37 = icmp eq i64 %44, 0 - br i1 %not_err37, label %after.errcheck38, label %voiderr39 + br i1 %not_err37, label %after_check38, label %voiderr39 -after.errcheck38: ; preds = %voiderr27 +after_check38: ; preds = %voiderr27 br label %voiderr39 -voiderr39: ; preds = %after.errcheck38, %voiderr27 +voiderr39: ; preds = %after_check38, %voiderr27 %45 = load i32, ptr %set2, align 4 call void @"std_enumset$$test_Abc_EnumSet_remove_all"(ptr %set, i32 %45) store %"char[]" { ptr @.str.4, i64 14 }, ptr %taddr41, align 8 @@ -193,11 +193,11 @@ voiderr39: ; preds = %after.errcheck38, % %hi48 = load i64, ptr %55, align 8 %56 = call i64 @std_io_printf(ptr %retparam40, ptr %lo42, i64 %hi43, ptr %lo47, i64 %hi48) %not_err49 = icmp eq i64 %56, 0 - br i1 %not_err49, label %after.errcheck50, label %voiderr51 + br i1 %not_err49, label %after_check50, label %voiderr51 -after.errcheck50: ; preds = %voiderr39 +after_check50: ; preds = %voiderr39 br label %voiderr51 -voiderr51: ; preds = %after.errcheck50, %voiderr39 +voiderr51: ; preds = %after_check50, %voiderr39 ret void } diff --git a/test/test_suite2/macros/macro_body_defer.c3t b/test/test_suite2/macros/macro_body_defer.c3t index adfdce935..ed32f42fc 100644 --- a/test/test_suite2/macros/macro_body_defer.c3t +++ b/test/test_suite2/macros/macro_body_defer.c3t @@ -106,12 +106,12 @@ define i32 @main(i32 %0, ptr %1) #0 { entry: %2 = call i64 @foo_main() %not_err = icmp eq i64 %2, 0 - br i1 %not_err, label %after.errcheck, label %error_block + br i1 %not_err, label %after_check, label %error_block -after.errcheck: ; preds = %entry +after_check: ; preds = %entry br label %noerr_block -noerr_block: ; preds = %after.errcheck +noerr_block: ; preds = %after_check br label %phi_trycatch_block error_block: ; preds = %entry diff --git a/test/test_suite2/macros/macro_failable_return_rethrow.c3t b/test/test_suite2/macros/macro_failable_return_rethrow.c3t index 8e5516dd1..8d1f7f67e 100644 --- a/test/test_suite2/macros/macro_failable_return_rethrow.c3t +++ b/test/test_suite2/macros/macro_failable_return_rethrow.c3t @@ -24,19 +24,19 @@ entry: %retparam = alloca i32, align 4 %0 = call i64 @test_xy(ptr %retparam) %not_err = icmp eq i64 %0, 0 - br i1 %not_err, label %after.errcheck, label %error + br i1 %not_err, label %after_check, label %assign_optional -error: ; preds = %entry +assign_optional: ; preds = %entry store i64 %0, ptr %error_var1, align 8 br label %guard_block -after.errcheck: ; preds = %entry +after_check: ; preds = %entry br label %noerr_block -guard_block: ; preds = %error +guard_block: ; preds = %assign_optional ret void -noerr_block: ; preds = %after.errcheck +noerr_block: ; preds = %after_check store i32 1, ptr %blockret, align 4 br label %expr_block.exit diff --git a/test/test_suite2/statements/various_switching.c3t b/test/test_suite2/statements/various_switching.c3t index ee9740bec..5c0189a26 100644 --- a/test/test_suite2/statements/various_switching.c3t +++ b/test/test_suite2/statements/various_switching.c3t @@ -88,9 +88,9 @@ entry: testblock: ; preds = %entry %0 = load i64, ptr %x.f, align 8 %not_err = icmp eq i64 %0, 0 - br i1 %not_err, label %after_check, label %error + br i1 %not_err, label %after_check, label %assign_optional -error: ; preds = %testblock +assign_optional: ; preds = %testblock store i64 %0, ptr %err, align 8 br label %end_block @@ -98,7 +98,7 @@ after_check: ; preds = %testblock store i64 0, ptr %err, align 8 br label %end_block -end_block: ; preds = %after_check, %error +end_block: ; preds = %after_check, %assign_optional %1 = load i64, ptr %err, align 8 %neq = icmp ne i64 %1, 0 br i1 %neq, label %if.then, label %if.exit