From f651a592948675457cf6af718fd6464dd2a234de Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Tue, 27 Jun 2023 13:19:28 +0200 Subject: [PATCH] Fix on rethrow + macros. --- lib/std/core/allocators/heap_allocator.c3 | 56 +- lib/std/core/allocators/mem_allocator_fn.c3 | 2 +- lib/std/core/allocators/on_stack_allocator.c3 | 2 +- lib/std/core/mem_allocator.c3 | 90 +- lib/std/io/os/fileinfo.c3 | 4 +- releasenotes.md | 3 +- src/compiler/compiler_internal.h | 1 + src/compiler/llvm_codegen_expr.c | 31 +- src/compiler/sema_expr.c | 10 +- src/version.h | 2 +- test/test_suite/errors/error_regression_2.c3t | 808 ++++++++++-------- test/test_suite/errors/macro_err.c3t | 13 +- .../macros/macro_failable_return_rethrow.c3t | 17 +- test/test_suite/stdlib/map.c3t | 25 +- 14 files changed, 566 insertions(+), 498 deletions(-) diff --git a/lib/std/core/allocators/heap_allocator.c3 b/lib/std/core/allocators/heap_allocator.c3 index 2c56f4a48..ea2e9fc1c 100644 --- a/lib/std/core/allocators/heap_allocator.c3 +++ b/lib/std/core/allocators/heap_allocator.c3 @@ -21,35 +21,73 @@ struct SimpleHeapAllocator fn void SimpleHeapAllocator.init(SimpleHeapAllocator* this, MemoryAllocFn allocator) { this.alloc_fn = allocator; - static AllocatorFunction alloc_fn = allocator_fn(SimpleHeapAllocator); + static AllocatorFunction alloc_fn = &simple_heap_allocator_function; this.allocator = { alloc_fn }; this.free_list = null; } +/** + * @param [&inout] this "The allocator" + * @param [inout] old_pointer "The pointer to free/realloc" + * @require !alignment || math::is_power_of_2(alignment) "Alignment must be a power of 2" + */ +fn void*! simple_heap_allocator_function(Allocator* this, usz size, usz alignment, usz offset, void* old_pointer, AllocationKind kind) @private +{ + SimpleHeapAllocator* heap = (SimpleHeapAllocator*)this; + switch (kind) + { + case ALIGNED_ALLOC: + return @aligned_alloc(heap._alloc, size, alignment, offset); + case ALLOC: + return heap._alloc(size); + case ALIGNED_CALLOC: + return @aligned_calloc(heap._calloc, size, alignment, offset); + case CALLOC: + return heap._calloc(size); + case ALIGNED_REALLOC: + if (!size) nextcase ALIGNED_FREE; + if (!old_pointer) nextcase ALIGNED_CALLOC; + return @aligned_realloc(heap._calloc, heap._free, old_pointer, size, alignment, offset); + case REALLOC: + if (!size) nextcase FREE; + if (!old_pointer) nextcase CALLOC; + return heap._realloc(old_pointer, size); + case RESET: + unreachable("Reset unsupported"); + case ALIGNED_FREE: + @aligned_free(heap._free, old_pointer)!; + return null; + case FREE: + heap._free(old_pointer); + return null; + default: + unreachable(); + } +} /** * @require this && old_pointer && bytes > 0 **/ -fn void*! SimpleHeapAllocator.realloc(SimpleHeapAllocator* this, void* old_pointer, usz bytes) +fn void*! SimpleHeapAllocator._realloc(SimpleHeapAllocator* this, void* old_pointer, usz bytes) @local { // Find the block header. Header* block = (Header*)old_pointer - 1; if (block.size >= bytes) return old_pointer; - void* new = this.alloc(bytes)!; + void* new = this._alloc(bytes)!; usz max_to_copy = math::min(block.size, bytes); mem::copy(new, old_pointer, max_to_copy); - (void)this.free(old_pointer); + this._free(old_pointer); return new; } -fn void*! SimpleHeapAllocator.calloc(SimpleHeapAllocator* this, usz bytes) +fn void*! SimpleHeapAllocator._calloc(SimpleHeapAllocator* this, usz bytes) @local { - void* data = this.alloc(bytes)!; + void* data = this._alloc(bytes)!; mem::clear(data, bytes, mem::DEFAULT_MEM_ALIGNMENT); return data; } -fn void*! SimpleHeapAllocator.alloc(SimpleHeapAllocator* this, usz bytes) +fn void*! SimpleHeapAllocator._alloc(SimpleHeapAllocator* this, usz bytes) @local { usz aligned_bytes = mem::aligned_offset(bytes, mem::DEFAULT_MEM_ALIGNMENT); if (!this.free_list) @@ -105,11 +143,11 @@ fn void! SimpleHeapAllocator.add_block(SimpleHeapAllocator* this, usz aligned_by Header* new_block = (Header*)result.ptr; new_block.size = result.len - Header.sizeof; new_block.next = null; - (void)this.free(new_block + 1); + this._free(new_block + 1); } -fn void! SimpleHeapAllocator.free(SimpleHeapAllocator* this, void* ptr) +fn void SimpleHeapAllocator._free(SimpleHeapAllocator* this, void* ptr) { // Empty ptr -> do nothing. if (!ptr) return; diff --git a/lib/std/core/allocators/mem_allocator_fn.c3 b/lib/std/core/allocators/mem_allocator_fn.c3 index a66d3102a..f41014f1d 100644 --- a/lib/std/core/allocators/mem_allocator_fn.c3 +++ b/lib/std/core/allocators/mem_allocator_fn.c3 @@ -121,7 +121,7 @@ fn void*! libc_allocator_fn(Allocator* unused, usz bytes, usz alignment, usz off if (!old_pointer) nextcase CALLOC; data = libc::realloc(old_pointer, bytes); case RESET: - return AllocationFailure.UNSUPPORTED_OPERATION?; + unreachable("Reset unsupported"); case ALIGNED_FREE: @aligned_free(libc::free, old_pointer)!!; return null; diff --git a/lib/std/core/allocators/on_stack_allocator.c3 b/lib/std/core/allocators/on_stack_allocator.c3 index 8891b16fe..b850645f1 100644 --- a/lib/std/core/allocators/on_stack_allocator.c3 +++ b/lib/std/core/allocators/on_stack_allocator.c3 @@ -120,7 +120,7 @@ fn void*! on_stack_allocator_function(Allocator* data, usz size, usz alignment, return null; case MARK: case RESET: - return AllocationFailure.UNSUPPORTED_OPERATION?; + unreachable("Reset unsupported"); } unreachable(); } diff --git a/lib/std/core/mem_allocator.c3 b/lib/std/core/mem_allocator.c3 index f951e3fb7..b3dff8e88 100644 --- a/lib/std/core/mem_allocator.c3 +++ b/lib/std/core/mem_allocator.c3 @@ -33,71 +33,6 @@ macro bool is_valid_aligned_allocator($Type) ); } -/** - * @require is_allocator($AllocatorType) : "Type does not implement all allocator methods" - * @require is_valid_aligned_allocator($AllocatorType) : "Type does not implement all aligned methods" - **/ -macro AllocatorFunction allocator_fn($AllocatorType) -{ - return fn void*!(Allocator* data, usz size, usz alignment, usz offset, void* old_pointer, AllocationKind kind) - { - $AllocatorType* allocator = ($AllocatorType*)data; - bool $supports_aligned = $defined(allocator.alloc_aligned); - switch (kind) - { - case CALLOC: - return allocator.calloc(size) @inline; - case ALIGNED_CALLOC: - $if $supports_aligned: - return allocator.calloc_aligned(size, alignment, offset) @inline; - $else - return @aligned_calloc(allocator.calloc, size, alignment, offset); - $endif - case ALLOC: - return allocator.alloc(size); - case ALIGNED_ALLOC: - $if $supports_aligned: - return allocator.alloc_aligned(size, alignment, offset) @inline; - $else - return @aligned_alloc(allocator.alloc, size, alignment, offset); - $endif - case REALLOC: - return allocator.realloc(old_pointer, size) @inline; - case ALIGNED_REALLOC: - $if $supports_aligned: - return allocator.realloc_aligned(old_pointer, size, alignment, offset) @inline; - $else - return @aligned_realloc(allocator.alloc, allocator.free, old_pointer, size, alignment, offset); - $endif - case ALIGNED_FREE: - $if $supports_aligned: - allocator.free_aligned(old_pointer, alignment, offset) @inline!; - return null; - $else - @aligned_free(allocator.free, old_pointer) @inline!; - return null; - $endif - case FREE: - allocator.free(old_pointer)!; - return null; - case MARK: - $if $defined(allocator.mark): - allocator.mark() @inline; - return null; - $else - return AllocationFailure.UNSUPPORTED_OPERATION?; - $endif - case RESET: - $if $defined(allocator.reset): - allocator.reset() @inline; - return null; - $else - return AllocationFailure.UNSUPPORTED_OPERATION?; - $endif - } - unreachable(); - }; -} struct Allocator { @@ -121,13 +56,12 @@ enum AllocationKind fault AllocationFailure { OUT_OF_MEMORY, - UNSUPPORTED_OPERATION, CHUNK_TOO_LARGE, } -fn void*! Allocator.alloc(Allocator* allocator, usz size) @inline +macro void*! Allocator.alloc(Allocator* allocator, usz size) { return allocator.function(allocator, size, 0, 0, null, ALLOC); } @@ -135,12 +69,12 @@ fn void*! Allocator.alloc(Allocator* allocator, usz size) @inline /** * @require alignment && math::is_power_of_2(alignment) */ -fn void*! Allocator.alloc_aligned(Allocator* allocator, usz size, usz alignment, usz offset = 0) @inline +macro void*! Allocator.alloc_aligned(Allocator* allocator, usz size, usz alignment, usz offset = 0) { return allocator.function(allocator, size, alignment, offset, null, ALIGNED_ALLOC); } -fn void*! Allocator.realloc(Allocator* allocator, void* old_pointer, usz size) @inline +macro void*! Allocator.realloc(Allocator* allocator, void* old_pointer, usz size) { return allocator.function(allocator, size, 0, 0, old_pointer, REALLOC); } @@ -148,18 +82,18 @@ fn void*! Allocator.realloc(Allocator* allocator, void* old_pointer, usz size) @ /** * @require alignment && math::is_power_of_2(alignment) */ -fn void*! Allocator.realloc_aligned(Allocator* allocator, void* old_pointer, usz size, usz alignment, usz offset = 0) @inline +macro void*! Allocator.realloc_aligned(Allocator* allocator, void* old_pointer, usz size, usz alignment, usz offset = 0) { return allocator.function(allocator, size, alignment, offset, old_pointer, ALIGNED_REALLOC); } -fn usz! Allocator.mark(Allocator* allocator) @inline +macro usz Allocator.mark(Allocator* allocator) { - return (usz)(uptr)allocator.function(allocator, 0, 0, 0, null, MARK); + return (usz)(uptr)allocator.function(allocator, 0, 0, 0, null, MARK) ?? 0; } -fn void*! Allocator.calloc(Allocator* allocator, usz size) @inline +macro void*! Allocator.calloc(Allocator* allocator, usz size) { return allocator.function(allocator, size, 0, 0, null, CALLOC); } @@ -167,24 +101,24 @@ fn void*! Allocator.calloc(Allocator* allocator, usz size) @inline /** * @require alignment && math::is_power_of_2(alignment) */ -fn void*! Allocator.calloc_aligned(Allocator* allocator, usz size, usz alignment, usz offset = 0) @inline +macro void*! Allocator.calloc_aligned(Allocator* allocator, usz size, usz alignment, usz offset = 0) { return allocator.function(allocator, size, alignment, offset, null, ALIGNED_CALLOC); } -fn void! Allocator.free(Allocator* allocator, void* old_pointer) @inline +macro void! Allocator.free(Allocator* allocator, void* old_pointer) { allocator.function(allocator, 0, 0, 0, old_pointer, FREE)!; } -fn void! Allocator.free_aligned(Allocator* allocator, void* old_pointer) @inline +macro void! Allocator.free_aligned(Allocator* allocator, void* old_pointer) { allocator.function(allocator, 0, 0, 0, old_pointer, ALIGNED_FREE)!; } -fn void Allocator.reset(Allocator* allocator, usz mark = 0) +macro void Allocator.reset(Allocator* allocator, usz mark = 0) { - allocator.function(allocator, mark, 0, 0, null, RESET)!!; + (void)allocator.function(allocator, mark, 0, 0, null, RESET); } fn usz alignment_for_allocation(usz alignment) @inline @private diff --git a/lib/std/io/os/fileinfo.c3 b/lib/std/io/os/fileinfo.c3 index 5eb9d7230..4352eab2f 100644 --- a/lib/std/io/os/fileinfo.c3 +++ b/lib/std/io/os/fileinfo.c3 @@ -1,4 +1,4 @@ -module std::io::os @if(env::LIBC); +module std::io::os; import libc; fn void! native_stat(Stat* stat, String path) @if(env::DARWIN || env::LINUX) @@ -113,3 +113,5 @@ fn bool native_is_dir(String path) return native_file_or_dir_exists(path) && !native_is_file(path); $endif } + + diff --git a/releasenotes.md b/releasenotes.md index 140cdb414..853fddde7 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -131,7 +131,8 @@ - Added `Clock` and `DateTime`. ### Fixes -- Fixes bug initializing a const struct with a const struct value +- Fix to bug when a macro is using rethrow. +- Fixes bug initializing a const struct with a const struct value. - Fixes bug when `void` is passed to an "any"-vararg. - Fixed defer/return value ordering in certain cases. - Fixes to the x64 ABI. diff --git a/src/compiler/compiler_internal.h b/src/compiler/compiler_internal.h index 882d2c9ab..c553eeb3e 100644 --- a/src/compiler/compiler_internal.h +++ b/src/compiler/compiler_internal.h @@ -1023,6 +1023,7 @@ typedef struct { Expr *inner; AstId cleanup; + BlockExit **in_block; } ExprGuard; diff --git a/src/compiler/llvm_codegen_expr.c b/src/compiler/llvm_codegen_expr.c index 8abe15b87..271fde62a 100644 --- a/src/compiler/llvm_codegen_expr.c +++ b/src/compiler/llvm_codegen_expr.c @@ -4091,7 +4091,7 @@ void llvm_emit_try_assign_try_catch(GenContext *c, bool is_try, BEValue *be_valu /** - * This is the foo? instruction. + * This is the foo! instruction. */ static inline void llvm_emit_rethrow_expr(GenContext *c, BEValue *be_value, Expr *expr) { @@ -4108,6 +4108,7 @@ static inline void llvm_emit_rethrow_expr(GenContext *c, BEValue *be_value, Expr c->catch_block = guard_block; llvm_emit_expr(c, be_value, expr->rethrow_expr.inner); + // Fold the optional. llvm_value_fold_optional(c, be_value); @@ -4126,9 +4127,23 @@ static inline void llvm_emit_rethrow_expr(GenContext *c, BEValue *be_value, Expr llvm_emit_statement_chain(c, expr->rethrow_expr.cleanup); BEValue value; llvm_value_set_address_abi_aligned(&value, error_var, type_anyfault); - llvm_emit_return_abi(c, NULL, &value); - c->current_block = NULL; - c->current_block_is_target = false; + if (expr->rethrow_expr.in_block) + { + BlockExit *exit = *expr->rethrow_expr.in_block; + if (exit->block_error_var) + { + llvm_store_to_ptr(c, exit->block_error_var, &value); + } + llvm_emit_br(c, exit->block_optional_exit); + c->current_block = NULL; + c->current_block_is_target = false; + } + else + { + llvm_emit_return_abi(c, NULL, &value); + c->current_block = NULL; + c->current_block_is_target = false; + } } llvm_emit_block(c, no_err_block); @@ -5683,8 +5698,12 @@ static inline void llvm_emit_return_block(GenContext *c, BEValue *be_value, Type llvm_value_set(be_value, NULL, type_void); return; } - llvm_emit_expr(c, be_value, expr); - return; + // We can only do this if there is no potential optional + if (!type_is_optional(type)) + { + llvm_emit_expr(c, be_value, expr); + return; + } } LLVMValueRef old_ret_out = c->return_out; diff --git a/src/compiler/sema_expr.c b/src/compiler/sema_expr.c index 882af00c1..fbb9f0916 100644 --- a/src/compiler/sema_expr.c +++ b/src/compiler/sema_expr.c @@ -1922,7 +1922,7 @@ bool sema_expr_analyse_macro_call(SemaContext *context, Expr *call_expr, Expr *s macro_context.macro_varargs = call_expr->call_expr.varargs; macro_context.original_inline_line = context->original_inline_line ? context->original_inline_line : call_expr->span.row; macro_context.macro_params = params; - BlockExit** block_exit_ref = MALLOCS(BlockExit*); + BlockExit** block_exit_ref = CALLOCS(BlockExit*); macro_context.block_exit_ref = block_exit_ref; VECEACH(params, i) @@ -6118,6 +6118,7 @@ static inline bool sema_expr_analyse_rethrow(SemaContext *context, Expr *expr) SEMA_ERROR(expr, "Rethrow cannot be used outside of a function."); return false; } + Expr *inner = expr->rethrow_expr.inner; if (!sema_analyse_expr(context, inner)) return false; @@ -6126,7 +6127,6 @@ static inline bool sema_expr_analyse_rethrow(SemaContext *context, Expr *expr) SEMA_ERROR(expr, "Returns are not allowed inside of defers."); return false; } - expr->rethrow_expr.cleanup = context_get_defers(context, context->active_scope.defer_last, 0, false); expr->type = type_no_optional(inner->type); @@ -6139,9 +6139,13 @@ static inline bool sema_expr_analyse_rethrow(SemaContext *context, Expr *expr) if (context->active_scope.flags & (SCOPE_EXPR_BLOCK | SCOPE_MACRO)) { vec_add(context->returns, NULL); + expr->rethrow_expr.in_block = context->block_exit_ref; + expr->rethrow_expr.cleanup = context_get_defers(context, context->active_scope.defer_last, context->block_return_defer, false); } else { + expr->rethrow_expr.cleanup = context_get_defers(context, context->active_scope.defer_last, 0, false); + expr->rethrow_expr.in_block = NULL; if (context->rtype && context->rtype->type_kind != TYPE_OPTIONAL) { SEMA_ERROR(expr, "This expression implicitly returns with an optional result, but the function does not allow optional results. Did you mean to use '!!' instead?"); @@ -6184,7 +6188,7 @@ static inline bool sema_expr_analyse_expr_block(SemaContext *context, Type *infe Ast **saved_returns = context_push_returns(context); Type *stored_block_type = context->expected_block_type; context->expected_block_type = infer_type; - BlockExit **ref = MALLOCS(BlockExit*); + BlockExit **ref = CALLOCS(BlockExit*); BlockExit **stored_block_exit = context->block_exit_ref; context->block_exit_ref = ref; expr->expr_block.block_exit_ref = ref; diff --git a/src/version.h b/src/version.h index 7f27b5abf..d7820ef75 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define COMPILER_VERSION "0.4.542" \ No newline at end of file +#define COMPILER_VERSION "0.4.543" \ No newline at end of file diff --git a/test/test_suite/errors/error_regression_2.c3t b/test/test_suite/errors/error_regression_2.c3t index a942beb91..3ba9d1930 100644 --- a/test/test_suite/errors/error_regression_2.c3t +++ b/test/test_suite/errors/error_regression_2.c3t @@ -277,74 +277,86 @@ entry: %using12 = alloca ptr, align 8 %end_padding13 = alloca i64, align 8 %.anon = alloca i64, align 8 + %allocator = alloca ptr, align 8 + %size = alloca i64, align 8 %retparam = alloca ptr, align 8 %varargslots = alloca [1 x %any], align 16 %indirectarg = alloca %"any[]", align 8 - %reterr21 = alloca i64, align 8 - %literal22 = alloca %Doc, align 8 - %error_var23 = alloca i64, align 8 - %value24 = alloca %Head, align 8 - %literal25 = alloca %Head, align 8 - %error_var26 = alloca i64, align 8 - %value27 = alloca %"char[]", align 8 - %temp28 = alloca ptr, align 8 - %using29 = alloca ptr, align 8 - %end_padding30 = alloca i64, align 8 - %error_var31 = alloca i64, align 8 - %using32 = alloca ptr, align 8 - %end_padding33 = alloca i64, align 8 - %.anon34 = alloca i64, align 8 - %retparam35 = alloca ptr, align 8 - %varargslots41 = alloca [1 x %any], align 16 - %indirectarg42 = alloca %"any[]", align 8 - %temp49 = alloca ptr, align 8 - %using50 = alloca ptr, align 8 - %end_padding51 = alloca i64, align 8 - %error_var52 = alloca i64, align 8 - %using53 = alloca ptr, align 8 - %end_padding54 = alloca i64, align 8 - %.anon55 = alloca i64, align 8 - %retparam56 = alloca ptr, align 8 - %varargslots62 = alloca [1 x %any], align 16 - %indirectarg63 = alloca %"any[]", align 8 + %reterr23 = alloca i64, align 8 + %literal24 = alloca %Doc, align 8 + %error_var25 = alloca i64, align 8 + %value26 = alloca %Head, align 8 + %literal27 = alloca %Head, align 8 + %error_var28 = alloca i64, align 8 + %value29 = alloca %"char[]", align 8 + %temp30 = alloca ptr, align 8 + %using31 = alloca ptr, align 8 + %end_padding32 = alloca i64, align 8 + %error_var33 = alloca i64, align 8 + %using34 = alloca ptr, align 8 + %end_padding35 = alloca i64, align 8 + %.anon36 = alloca i64, align 8 + %allocator38 = alloca ptr, align 8 + %size39 = alloca i64, align 8 + %retparam42 = alloca ptr, align 8 + %varargslots47 = alloca [1 x %any], align 16 + %indirectarg48 = alloca %"any[]", align 8 + %temp55 = alloca ptr, align 8 + %using56 = alloca ptr, align 8 + %end_padding57 = alloca i64, align 8 + %error_var58 = alloca i64, align 8 + %using59 = alloca ptr, align 8 + %end_padding60 = alloca i64, align 8 + %.anon61 = alloca i64, align 8 + %allocator63 = alloca ptr, align 8 + %size64 = alloca i64, align 8 + %retparam67 = alloca ptr, align 8 + %varargslots72 = alloca [1 x %any], align 16 + %indirectarg73 = alloca %"any[]", align 8 %len = alloca i32, align 4 %str = alloca ptr, align 8 - %using71 = alloca ptr, align 8 - %end_padding72 = alloca i64, align 8 - %error_var73 = alloca i64, align 8 - %using74 = alloca ptr, align 8 - %end_padding75 = alloca i64, align 8 - %.anon76 = alloca i32, align 4 - %retparam78 = alloca ptr, align 8 - %varargslots84 = alloca [1 x %any], align 16 - %indirectarg85 = alloca %"any[]", align 8 - %reterr93 = alloca i64, align 8 - %literal94 = alloca %Doc, align 8 - %error_var95 = alloca i64, align 8 - %value96 = alloca %Head, align 8 - %literal97 = alloca %Head, align 8 - %error_var98 = alloca i64, align 8 - %value99 = alloca %"char[]", align 8 - %temp102 = alloca ptr, align 8 - %using103 = alloca ptr, align 8 - %end_padding104 = alloca i64, align 8 - %error_var105 = alloca i64, align 8 - %using106 = alloca ptr, align 8 - %end_padding107 = alloca i64, align 8 - %.anon108 = alloca i64, align 8 - %retparam109 = alloca ptr, align 8 - %varargslots115 = alloca [1 x %any], align 16 - %indirectarg116 = alloca %"any[]", align 8 - %temp123 = alloca ptr, align 8 - %using124 = alloca ptr, align 8 - %end_padding125 = alloca i64, align 8 - %error_var126 = alloca i64, align 8 - %using127 = alloca ptr, align 8 - %end_padding128 = alloca i64, align 8 - %.anon129 = alloca i64, align 8 - %retparam130 = alloca ptr, align 8 - %varargslots136 = alloca [1 x %any], align 16 - %indirectarg137 = alloca %"any[]", align 8 + %using81 = alloca ptr, align 8 + %end_padding82 = alloca i64, align 8 + %error_var83 = alloca i64, align 8 + %using84 = alloca ptr, align 8 + %end_padding85 = alloca i64, align 8 + %.anon86 = alloca i32, align 4 + %allocator88 = alloca ptr, align 8 + %size89 = alloca i64, align 8 + %retparam91 = alloca ptr, align 8 + %varargslots96 = alloca [1 x %any], align 16 + %indirectarg97 = alloca %"any[]", align 8 + %reterr105 = alloca i64, align 8 + %literal106 = alloca %Doc, align 8 + %error_var107 = alloca i64, align 8 + %value108 = alloca %Head, align 8 + %literal109 = alloca %Head, align 8 + %error_var110 = alloca i64, align 8 + %value111 = alloca %"char[]", align 8 + %temp115 = alloca ptr, align 8 + %using116 = alloca ptr, align 8 + %end_padding117 = alloca i64, align 8 + %error_var118 = alloca i64, align 8 + %using119 = alloca ptr, align 8 + %end_padding120 = alloca i64, align 8 + %.anon121 = alloca i64, align 8 + %allocator123 = alloca ptr, align 8 + %size124 = alloca i64, align 8 + %retparam127 = alloca ptr, align 8 + %varargslots132 = alloca [1 x %any], align 16 + %indirectarg133 = alloca %"any[]", align 8 + %temp140 = alloca ptr, align 8 + %using141 = alloca ptr, align 8 + %end_padding142 = alloca i64, align 8 + %error_var143 = alloca i64, align 8 + %using144 = alloca ptr, align 8 + %end_padding145 = alloca i64, align 8 + %.anon146 = alloca i64, align 8 + %allocator148 = alloca ptr, align 8 + %size149 = alloca i64, align 8 + %retparam152 = alloca ptr, align 8 + %varargslots157 = alloca [1 x %any], align 16 + %indirectarg158 = alloca %"any[]", align 8 store ptr %1, ptr %url, align 8 %ptroffset = getelementptr inbounds i64, ptr %url, i64 1 store i64 %2, ptr %ptroffset, align 8 @@ -381,7 +393,7 @@ if.exit4: ; preds = %if.exit %hi6 = load i64, ptr %13, align 8 %14 = call i8 @test.contains(ptr %lo5, i64 %hi6, ptr @.str.4, i64 13) %15 = trunc i8 %14 to i1 - br i1 %15, label %if.then7, label %if.exit17 + br i1 %15, label %if.then7, label %if.exit19 if.then7: ; preds = %if.exit4 %16 = getelementptr inbounds %Doc, ptr %literal9, i32 0, i32 0 @@ -397,390 +409,432 @@ if.then7: ; preds = %if.exit4 store i64 %20, ptr %end_padding13, align 8 store i64 8, ptr %.anon, align 8 %21 = load ptr, ptr %using12, align 8 + store ptr %21, ptr %allocator, align 8 %22 = load i64, ptr %.anon, align 8 %23 = load i64, ptr %end_padding13, align 8 %add = add i64 %22, %23 - %24 = call i64 @std.core.mem.allocator.Allocator.alloc(ptr %retparam, ptr %21, i64 %add) #3 - %not_err = icmp eq i64 %24, 0 - %25 = call i1 @llvm.expect.i1(i1 %not_err, i1 true) - br i1 %25, label %after_check, label %assign_optional + store i64 %add, ptr %size, align 8 + %24 = load ptr, ptr %allocator, align 8 + %25 = getelementptr inbounds %Allocator, ptr %24, i32 0, i32 0 + %26 = load ptr, ptr %25, align 8 + %27 = load ptr, ptr %allocator, align 8 + %28 = load i64, ptr %size, align 8 + %29 = call i64 %26(ptr %retparam, ptr %27, i64 %28, i64 0, i64 0, ptr null, i32 0) + %not_err = icmp eq i64 %29, 0 + %30 = call i1 @llvm.expect.i1(i1 %not_err, i1 true) + br i1 %30, label %after_check, label %assign_optional assign_optional: ; preds = %if.then7 - store i64 %24, ptr %error_var11, align 8 + store i64 %29, ptr %error_var11, align 8 br label %panic_block after_check: ; preds = %if.then7 - %26 = load ptr, ptr %retparam, align 8 + %31 = load ptr, ptr %retparam, align 8 br label %noerr_block panic_block: ; preds = %assign_optional - %27 = insertvalue %any undef, ptr %error_var11, 0 - %28 = insertvalue %any %27, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1 - %29 = getelementptr inbounds [1 x %any], ptr %varargslots, i64 0, i64 0 - store %any %28, ptr %29, align 16 - %30 = insertvalue %"any[]" undef, ptr %varargslots, 0 - %31 = insertvalue %"any[]" %30, i64 1, 1 - store %"any[]" %31, ptr %indirectarg, align 8 + %32 = insertvalue %any undef, ptr %error_var11, 0 + %33 = insertvalue %any %32, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1 + %34 = getelementptr inbounds [1 x %any], ptr %varargslots, i64 0, i64 0 + store %any %33, ptr %34, align 16 + %35 = insertvalue %"any[]" undef, ptr %varargslots, 0 + %36 = insertvalue %"any[]" %35, i64 1, 1 + store %"any[]" %36, ptr %indirectarg, align 8 call void @std.core.builtin.panicf(ptr @.panic_msg, i64 36, ptr @.file, i64 6, ptr @.func, i64 7, i32 200, ptr byval(%"any[]") align 8 %indirectarg) unreachable noerr_block: ; preds = %after_check - store ptr %26, ptr %temp, align 8 - %32 = load ptr, ptr %temp, align 8 - %not = icmp eq ptr %32, null - br i1 %not, label %if.then14, label %if.exit15 + store ptr %31, ptr %temp, align 8 + %37 = load ptr, ptr %temp, align 8 + %not = icmp eq ptr %37, null + br i1 %not, label %if.then16, label %if.exit17 -if.then14: ; preds = %noerr_block +if.then16: ; preds = %noerr_block store i64 ptrtoint (ptr @"test.ReadError$OUT_OF_MEMORY" to i64), ptr %error_var, align 8 br label %guard_block -if.exit15: ; preds = %noerr_block - %33 = load ptr, ptr %temp, align 8 - call void @llvm.memcpy.p0.p0.i32(ptr align 8 %33, ptr align 8 %value, i32 8, i1 false) - br label %noerr_block16 +if.exit17: ; preds = %noerr_block + %38 = load ptr, ptr %temp, align 8 + call void @llvm.memcpy.p0.p0.i32(ptr align 8 %38, ptr align 8 %value, i32 8, i1 false) + br label %noerr_block18 -guard_block: ; preds = %if.then14 - %34 = load i64, ptr %error_var, align 8 - ret i64 %34 +guard_block: ; preds = %if.then16 + %39 = load i64, ptr %error_var, align 8 + ret i64 %39 -noerr_block16: ; preds = %if.exit15 - %35 = load ptr, ptr %temp, align 8 - store ptr %35, ptr %16, align 8 +noerr_block18: ; preds = %if.exit17 + %40 = load ptr, ptr %temp, align 8 + store ptr %40, ptr %16, align 8 call void @llvm.memcpy.p0.p0.i32(ptr align 8 %0, ptr align 8 %literal9, i32 8, i1 false) ret i64 0 -if.exit17: ; preds = %if.exit4 - %36 = getelementptr inbounds %"char[]", ptr %url, i32 0, i32 0 - %lo18 = load ptr, ptr %36, align 8 - %37 = getelementptr inbounds %"char[]", ptr %url, i32 0, i32 1 - %hi19 = load i64, ptr %37, align 8 - %38 = call i8 @test.contains(ptr %lo18, i64 %hi19, ptr @.str.5, i64 11) - %39 = trunc i8 %38 to i1 - br i1 %39, label %if.then20, label %if.exit70 +if.exit19: ; preds = %if.exit4 + %41 = getelementptr inbounds %"char[]", ptr %url, i32 0, i32 0 + %lo20 = load ptr, ptr %41, align 8 + %42 = getelementptr inbounds %"char[]", ptr %url, i32 0, i32 1 + %hi21 = load i64, ptr %42, align 8 + %43 = call i8 @test.contains(ptr %lo20, i64 %hi21, ptr @.str.5, i64 11) + %44 = trunc i8 %43 to i1 + br i1 %44, label %if.then22, label %if.exit80 -if.then20: ; preds = %if.exit17 - %40 = getelementptr inbounds %Doc, ptr %literal22, i32 0, i32 0 - store ptr null, ptr %literal25, align 8 - %41 = getelementptr inbounds %Head, ptr %literal25, i32 0, i32 0 - store %"char[]" zeroinitializer, ptr %value27, align 8 - %42 = load ptr, ptr @std.core.mem.thread_allocator, align 8 - store ptr %42, ptr %using29, align 8 - store i64 0, ptr %end_padding30, align 8 - %43 = load ptr, ptr %using29, align 8 - store ptr %43, ptr %using32, align 8 - %44 = load i64, ptr %end_padding30, align 8 - store i64 %44, ptr %end_padding33, align 8 - store i64 16, ptr %.anon34, align 8 - %45 = load ptr, ptr %using32, align 8 - %46 = load i64, ptr %.anon34, align 8 - %47 = load i64, ptr %end_padding33, align 8 - %add36 = add i64 %46, %47 - %48 = call i64 @std.core.mem.allocator.Allocator.alloc(ptr %retparam35, ptr %45, i64 %add36) #3 - %not_err37 = icmp eq i64 %48, 0 - %49 = call i1 @llvm.expect.i1(i1 %not_err37, i1 true) - br i1 %49, label %after_check39, label %assign_optional38 +if.then22: ; preds = %if.exit19 + %45 = getelementptr inbounds %Doc, ptr %literal24, i32 0, i32 0 + store ptr null, ptr %literal27, align 8 + %46 = getelementptr inbounds %Head, ptr %literal27, i32 0, i32 0 + store %"char[]" zeroinitializer, ptr %value29, align 8 + %47 = load ptr, ptr @std.core.mem.thread_allocator, align 8 + store ptr %47, ptr %using31, align 8 + store i64 0, ptr %end_padding32, align 8 + %48 = load ptr, ptr %using31, align 8 + store ptr %48, ptr %using34, align 8 + %49 = load i64, ptr %end_padding32, align 8 + store i64 %49, ptr %end_padding35, align 8 + store i64 16, ptr %.anon36, align 8 + %50 = load ptr, ptr %using34, align 8 + store ptr %50, ptr %allocator38, align 8 + %51 = load i64, ptr %.anon36, align 8 + %52 = load i64, ptr %end_padding35, align 8 + %add40 = add i64 %51, %52 + store i64 %add40, ptr %size39, align 8 + %53 = load ptr, ptr %allocator38, align 8 + %54 = getelementptr inbounds %Allocator, ptr %53, i32 0, i32 0 + %55 = load ptr, ptr %54, align 8 + %56 = load ptr, ptr %allocator38, align 8 + %57 = load i64, ptr %size39, align 8 + %58 = call i64 %55(ptr %retparam42, ptr %56, i64 %57, i64 0, i64 0, ptr null, i32 0) + %not_err43 = icmp eq i64 %58, 0 + %59 = call i1 @llvm.expect.i1(i1 %not_err43, i1 true) + br i1 %59, label %after_check45, label %assign_optional44 -assign_optional38: ; preds = %if.then20 - store i64 %48, ptr %error_var31, align 8 - br label %panic_block40 +assign_optional44: ; preds = %if.then22 + store i64 %58, ptr %error_var33, align 8 + br label %panic_block46 -after_check39: ; preds = %if.then20 - %50 = load ptr, ptr %retparam35, align 8 - br label %noerr_block43 +after_check45: ; preds = %if.then22 + %60 = load ptr, ptr %retparam42, align 8 + br label %noerr_block49 -panic_block40: ; preds = %assign_optional38 - %51 = insertvalue %any undef, ptr %error_var31, 0 - %52 = insertvalue %any %51, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1 - %53 = getelementptr inbounds [1 x %any], ptr %varargslots41, i64 0, i64 0 - store %any %52, ptr %53, align 16 - %54 = insertvalue %"any[]" undef, ptr %varargslots41, 0 - %55 = insertvalue %"any[]" %54, i64 1, 1 - store %"any[]" %55, ptr %indirectarg42, align 8 - call void @std.core.builtin.panicf(ptr @.panic_msg, i64 36, ptr @.file, i64 6, ptr @.func, i64 7, i32 200, ptr byval(%"any[]") align 8 %indirectarg42) +panic_block46: ; preds = %assign_optional44 + %61 = insertvalue %any undef, ptr %error_var33, 0 + %62 = insertvalue %any %61, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1 + %63 = getelementptr inbounds [1 x %any], ptr %varargslots47, i64 0, i64 0 + store %any %62, ptr %63, align 16 + %64 = insertvalue %"any[]" undef, ptr %varargslots47, 0 + %65 = insertvalue %"any[]" %64, i64 1, 1 + store %"any[]" %65, ptr %indirectarg48, align 8 + call void @std.core.builtin.panicf(ptr @.panic_msg, i64 36, ptr @.file, i64 6, ptr @.func, i64 7, i32 200, ptr byval(%"any[]") align 8 %indirectarg48) unreachable -noerr_block43: ; preds = %after_check39 - store ptr %50, ptr %temp28, align 8 - %56 = load ptr, ptr %temp28, align 8 - %not44 = icmp eq ptr %56, null - br i1 %not44, label %if.then45, label %if.exit46 +noerr_block49: ; preds = %after_check45 + store ptr %60, ptr %temp30, align 8 + %66 = load ptr, ptr %temp30, align 8 + %not50 = icmp eq ptr %66, null + br i1 %not50, label %if.then51, label %if.exit52 -if.then45: ; preds = %noerr_block43 - store i64 ptrtoint (ptr @"test.ReadError$OUT_OF_MEMORY" to i64), ptr %error_var26, align 8 - br label %guard_block47 +if.then51: ; preds = %noerr_block49 + store i64 ptrtoint (ptr @"test.ReadError$OUT_OF_MEMORY" to i64), ptr %error_var28, align 8 + br label %guard_block53 -if.exit46: ; preds = %noerr_block43 - %57 = load ptr, ptr %temp28, align 8 - call void @llvm.memcpy.p0.p0.i32(ptr align 8 %57, ptr align 8 %value27, i32 16, i1 false) - br label %noerr_block48 +if.exit52: ; preds = %noerr_block49 + %67 = load ptr, ptr %temp30, align 8 + call void @llvm.memcpy.p0.p0.i32(ptr align 8 %67, ptr align 8 %value29, i32 16, i1 false) + br label %noerr_block54 -guard_block47: ; preds = %if.then45 - %58 = load i64, ptr %error_var26, align 8 - ret i64 %58 +guard_block53: ; preds = %if.then51 + %68 = load i64, ptr %error_var28, align 8 + ret i64 %68 -noerr_block48: ; preds = %if.exit46 - %59 = load ptr, ptr %temp28, align 8 - store ptr %59, ptr %41, align 8 - call void @llvm.memcpy.p0.p0.i32(ptr align 8 %value24, ptr align 8 %literal25, i32 8, i1 false) - %60 = load ptr, ptr @std.core.mem.thread_allocator, align 8 - store ptr %60, ptr %using50, align 8 - store i64 0, ptr %end_padding51, align 8 - %61 = load ptr, ptr %using50, align 8 - store ptr %61, ptr %using53, align 8 - %62 = load i64, ptr %end_padding51, align 8 - store i64 %62, ptr %end_padding54, align 8 - store i64 8, ptr %.anon55, align 8 - %63 = load ptr, ptr %using53, align 8 - %64 = load i64, ptr %.anon55, align 8 - %65 = load i64, ptr %end_padding54, align 8 - %add57 = add i64 %64, %65 - %66 = call i64 @std.core.mem.allocator.Allocator.alloc(ptr %retparam56, ptr %63, i64 %add57) #3 - %not_err58 = icmp eq i64 %66, 0 - %67 = call i1 @llvm.expect.i1(i1 %not_err58, i1 true) - br i1 %67, label %after_check60, label %assign_optional59 +noerr_block54: ; preds = %if.exit52 + %69 = load ptr, ptr %temp30, align 8 + store ptr %69, ptr %46, align 8 + call void @llvm.memcpy.p0.p0.i32(ptr align 8 %value26, ptr align 8 %literal27, i32 8, i1 false) + %70 = load ptr, ptr @std.core.mem.thread_allocator, align 8 + store ptr %70, ptr %using56, align 8 + store i64 0, ptr %end_padding57, align 8 + %71 = load ptr, ptr %using56, align 8 + store ptr %71, ptr %using59, align 8 + %72 = load i64, ptr %end_padding57, align 8 + store i64 %72, ptr %end_padding60, align 8 + store i64 8, ptr %.anon61, align 8 + %73 = load ptr, ptr %using59, align 8 + store ptr %73, ptr %allocator63, align 8 + %74 = load i64, ptr %.anon61, align 8 + %75 = load i64, ptr %end_padding60, align 8 + %add65 = add i64 %74, %75 + store i64 %add65, ptr %size64, align 8 + %76 = load ptr, ptr %allocator63, align 8 + %77 = getelementptr inbounds %Allocator, ptr %76, i32 0, i32 0 + %78 = load ptr, ptr %77, align 8 + %79 = load ptr, ptr %allocator63, align 8 + %80 = load i64, ptr %size64, align 8 + %81 = call i64 %78(ptr %retparam67, ptr %79, i64 %80, i64 0, i64 0, ptr null, i32 0) + %not_err68 = icmp eq i64 %81, 0 + %82 = call i1 @llvm.expect.i1(i1 %not_err68, i1 true) + br i1 %82, label %after_check70, label %assign_optional69 -assign_optional59: ; preds = %noerr_block48 - store i64 %66, ptr %error_var52, align 8 - br label %panic_block61 +assign_optional69: ; preds = %noerr_block54 + store i64 %81, ptr %error_var58, align 8 + br label %panic_block71 -after_check60: ; preds = %noerr_block48 - %68 = load ptr, ptr %retparam56, align 8 - br label %noerr_block64 +after_check70: ; preds = %noerr_block54 + %83 = load ptr, ptr %retparam67, align 8 + br label %noerr_block74 -panic_block61: ; preds = %assign_optional59 - %69 = insertvalue %any undef, ptr %error_var52, 0 - %70 = insertvalue %any %69, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1 - %71 = getelementptr inbounds [1 x %any], ptr %varargslots62, i64 0, i64 0 - store %any %70, ptr %71, align 16 - %72 = insertvalue %"any[]" undef, ptr %varargslots62, 0 - %73 = insertvalue %"any[]" %72, i64 1, 1 - store %"any[]" %73, ptr %indirectarg63, align 8 - call void @std.core.builtin.panicf(ptr @.panic_msg, i64 36, ptr @.file, i64 6, ptr @.func, i64 7, i32 200, ptr byval(%"any[]") align 8 %indirectarg63) +panic_block71: ; preds = %assign_optional69 + %84 = insertvalue %any undef, ptr %error_var58, 0 + %85 = insertvalue %any %84, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1 + %86 = getelementptr inbounds [1 x %any], ptr %varargslots72, i64 0, i64 0 + store %any %85, ptr %86, align 16 + %87 = insertvalue %"any[]" undef, ptr %varargslots72, 0 + %88 = insertvalue %"any[]" %87, i64 1, 1 + store %"any[]" %88, ptr %indirectarg73, align 8 + call void @std.core.builtin.panicf(ptr @.panic_msg, i64 36, ptr @.file, i64 6, ptr @.func, i64 7, i32 200, ptr byval(%"any[]") align 8 %indirectarg73) unreachable -noerr_block64: ; preds = %after_check60 - store ptr %68, ptr %temp49, align 8 - %74 = load ptr, ptr %temp49, align 8 - %not65 = icmp eq ptr %74, null - br i1 %not65, label %if.then66, label %if.exit67 +noerr_block74: ; preds = %after_check70 + store ptr %83, ptr %temp55, align 8 + %89 = load ptr, ptr %temp55, align 8 + %not75 = icmp eq ptr %89, null + br i1 %not75, label %if.then76, label %if.exit77 -if.then66: ; preds = %noerr_block64 - store i64 ptrtoint (ptr @"test.ReadError$OUT_OF_MEMORY" to i64), ptr %error_var23, align 8 - br label %guard_block68 +if.then76: ; preds = %noerr_block74 + store i64 ptrtoint (ptr @"test.ReadError$OUT_OF_MEMORY" to i64), ptr %error_var25, align 8 + br label %guard_block78 -if.exit67: ; preds = %noerr_block64 - %75 = load ptr, ptr %temp49, align 8 - call void @llvm.memcpy.p0.p0.i32(ptr align 8 %75, ptr align 8 %value24, i32 8, i1 false) - br label %noerr_block69 +if.exit77: ; preds = %noerr_block74 + %90 = load ptr, ptr %temp55, align 8 + call void @llvm.memcpy.p0.p0.i32(ptr align 8 %90, ptr align 8 %value26, i32 8, i1 false) + br label %noerr_block79 -guard_block68: ; preds = %if.then66 - %76 = load i64, ptr %error_var23, align 8 - ret i64 %76 +guard_block78: ; preds = %if.then76 + %91 = load i64, ptr %error_var25, align 8 + ret i64 %91 -noerr_block69: ; preds = %if.exit67 - %77 = load ptr, ptr %temp49, align 8 - store ptr %77, ptr %40, align 8 - call void @llvm.memcpy.p0.p0.i32(ptr align 8 %0, ptr align 8 %literal22, i32 8, i1 false) +noerr_block79: ; preds = %if.exit77 + %92 = load ptr, ptr %temp55, align 8 + store ptr %92, ptr %45, align 8 + call void @llvm.memcpy.p0.p0.i32(ptr align 8 %0, ptr align 8 %literal24, i32 8, i1 false) ret i64 0 -if.exit70: ; preds = %if.exit17 - %78 = getelementptr inbounds %"char[]", ptr %url, i32 0, i32 1 - %79 = load i64, ptr %78, align 8 - %trunc = trunc i64 %79 to i32 - %80 = getelementptr inbounds %"char[]", ptr %url, i32 0, i32 0 - %81 = load ptr, ptr %80, align 8 - %82 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr null, i64 0, ptr @.str.6, i32 %trunc, ptr %81) - store i32 %82, ptr %len, align 4 - %83 = load ptr, ptr @std.core.mem.thread_allocator, align 8 - store ptr %83, ptr %using71, align 8 - store i64 0, ptr %end_padding72, align 8 - %84 = load ptr, ptr %using71, align 8 - store ptr %84, ptr %using74, align 8 - %85 = load i64, ptr %end_padding72, align 8 - store i64 %85, ptr %end_padding75, align 8 - %86 = load i32, ptr %len, align 4 - %add77 = add i32 %86, 1 - store i32 %add77, ptr %.anon76, align 4 - %87 = load ptr, ptr %using74, align 8 - %88 = load i32, ptr %.anon76, align 4 - %sext = sext i32 %88 to i64 - %89 = load i64, ptr %end_padding75, align 8 - %add79 = add i64 %sext, %89 - %90 = call i64 @std.core.mem.allocator.Allocator.alloc(ptr %retparam78, ptr %87, i64 %add79) #3 - %not_err80 = icmp eq i64 %90, 0 - %91 = call i1 @llvm.expect.i1(i1 %not_err80, i1 true) - br i1 %91, label %after_check82, label %assign_optional81 +if.exit80: ; preds = %if.exit19 + %93 = getelementptr inbounds %"char[]", ptr %url, i32 0, i32 1 + %94 = load i64, ptr %93, align 8 + %trunc = trunc i64 %94 to i32 + %95 = getelementptr inbounds %"char[]", ptr %url, i32 0, i32 0 + %96 = load ptr, ptr %95, align 8 + %97 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr null, i64 0, ptr @.str.6, i32 %trunc, ptr %96) + store i32 %97, ptr %len, align 4 + %98 = load ptr, ptr @std.core.mem.thread_allocator, align 8 + store ptr %98, ptr %using81, align 8 + store i64 0, ptr %end_padding82, align 8 + %99 = load ptr, ptr %using81, align 8 + store ptr %99, ptr %using84, align 8 + %100 = load i64, ptr %end_padding82, align 8 + store i64 %100, ptr %end_padding85, align 8 + %101 = load i32, ptr %len, align 4 + %add87 = add i32 %101, 1 + store i32 %add87, ptr %.anon86, align 4 + %102 = load ptr, ptr %using84, align 8 + store ptr %102, ptr %allocator88, align 8 + %103 = load i32, ptr %.anon86, align 4 + %sext = sext i32 %103 to i64 + %104 = load i64, ptr %end_padding85, align 8 + %add90 = add i64 %sext, %104 + store i64 %add90, ptr %size89, align 8 + %105 = load ptr, ptr %allocator88, align 8 + %106 = getelementptr inbounds %Allocator, ptr %105, i32 0, i32 0 + %107 = load ptr, ptr %106, align 8 + %108 = load ptr, ptr %allocator88, align 8 + %109 = load i64, ptr %size89, align 8 + %110 = call i64 %107(ptr %retparam91, ptr %108, i64 %109, i64 0, i64 0, ptr null, i32 0) + %not_err92 = icmp eq i64 %110, 0 + %111 = call i1 @llvm.expect.i1(i1 %not_err92, i1 true) + br i1 %111, label %after_check94, label %assign_optional93 -assign_optional81: ; preds = %if.exit70 - store i64 %90, ptr %error_var73, align 8 - br label %panic_block83 +assign_optional93: ; preds = %if.exit80 + store i64 %110, ptr %error_var83, align 8 + br label %panic_block95 -after_check82: ; preds = %if.exit70 - %92 = load ptr, ptr %retparam78, align 8 - br label %noerr_block86 +after_check94: ; preds = %if.exit80 + %112 = load ptr, ptr %retparam91, align 8 + br label %noerr_block98 -panic_block83: ; preds = %assign_optional81 - %93 = insertvalue %any undef, ptr %error_var73, 0 - %94 = insertvalue %any %93, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1 - %95 = getelementptr inbounds [1 x %any], ptr %varargslots84, i64 0, i64 0 - store %any %94, ptr %95, align 16 - %96 = insertvalue %"any[]" undef, ptr %varargslots84, 0 - %97 = insertvalue %"any[]" %96, i64 1, 1 - store %"any[]" %97, ptr %indirectarg85, align 8 - call void @std.core.builtin.panicf(ptr @.panic_msg, i64 36, ptr @.file, i64 6, ptr @.func, i64 7, i32 200, ptr byval(%"any[]") align 8 %indirectarg85) +panic_block95: ; preds = %assign_optional93 + %113 = insertvalue %any undef, ptr %error_var83, 0 + %114 = insertvalue %any %113, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1 + %115 = getelementptr inbounds [1 x %any], ptr %varargslots96, i64 0, i64 0 + store %any %114, ptr %115, align 16 + %116 = insertvalue %"any[]" undef, ptr %varargslots96, 0 + %117 = insertvalue %"any[]" %116, i64 1, 1 + store %"any[]" %117, ptr %indirectarg97, align 8 + call void @std.core.builtin.panicf(ptr @.panic_msg, i64 36, ptr @.file, i64 6, ptr @.func, i64 7, i32 200, ptr byval(%"any[]") align 8 %indirectarg97) unreachable -noerr_block86: ; preds = %after_check82 - store ptr %92, ptr %str, align 8 - %98 = load ptr, ptr %str, align 8 - %not87 = icmp eq ptr %98, null - br i1 %not87, label %if.then88, label %if.exit89 +noerr_block98: ; preds = %after_check94 + store ptr %112, ptr %str, align 8 + %118 = load ptr, ptr %str, align 8 + %not99 = icmp eq ptr %118, null + br i1 %not99, label %if.then100, label %if.exit101 -if.then88: ; preds = %noerr_block86 +if.then100: ; preds = %noerr_block98 ret i64 ptrtoint (ptr @"test.ReadError$OUT_OF_MEMORY" to i64) -if.exit89: ; preds = %noerr_block86 - %99 = load ptr, ptr %str, align 8 - %100 = load i32, ptr %len, align 4 - %sext90 = sext i32 %100 to i64 - %add91 = add i64 %sext90, 1 - %101 = getelementptr inbounds %"char[]", ptr %url, i32 0, i32 1 - %102 = load i64, ptr %101, align 8 - %trunc92 = trunc i64 %102 to i32 - %103 = getelementptr inbounds %"char[]", ptr %url, i32 0, i32 0 - %104 = load ptr, ptr %103, align 8 - %105 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr %99, i64 %add91, ptr @.str.7, i32 %trunc92, ptr %104) - %106 = getelementptr inbounds %Doc, ptr %literal94, i32 0, i32 0 - store ptr null, ptr %literal97, align 8 - %107 = getelementptr inbounds %Head, ptr %literal97, i32 0, i32 0 - %108 = load ptr, ptr %str, align 8 - %109 = load i32, ptr %len, align 4 - %sub = sub i32 %109, 1 - %sext100 = sext i32 %sub to i64 - %110 = add i64 %sext100, 1 - %size = sub i64 %110, 0 - %ptroffset101 = getelementptr inbounds i8, ptr %108, i64 0 - %111 = insertvalue %"char[]" undef, ptr %ptroffset101, 0 - %112 = insertvalue %"char[]" %111, i64 %size, 1 - store %"char[]" %112, ptr %value99, align 8 - %113 = load ptr, ptr @std.core.mem.thread_allocator, align 8 - store ptr %113, ptr %using103, align 8 - store i64 0, ptr %end_padding104, align 8 - %114 = load ptr, ptr %using103, align 8 - store ptr %114, ptr %using106, align 8 - %115 = load i64, ptr %end_padding104, align 8 - store i64 %115, ptr %end_padding107, align 8 - store i64 16, ptr %.anon108, align 8 - %116 = load ptr, ptr %using106, align 8 - %117 = load i64, ptr %.anon108, align 8 - %118 = load i64, ptr %end_padding107, align 8 - %add110 = add i64 %117, %118 - %119 = call i64 @std.core.mem.allocator.Allocator.alloc(ptr %retparam109, ptr %116, i64 %add110) #3 - %not_err111 = icmp eq i64 %119, 0 - %120 = call i1 @llvm.expect.i1(i1 %not_err111, i1 true) - br i1 %120, label %after_check113, label %assign_optional112 +if.exit101: ; preds = %noerr_block98 + %119 = load ptr, ptr %str, align 8 + %120 = load i32, ptr %len, align 4 + %sext102 = sext i32 %120 to i64 + %add103 = add i64 %sext102, 1 + %121 = getelementptr inbounds %"char[]", ptr %url, i32 0, i32 1 + %122 = load i64, ptr %121, align 8 + %trunc104 = trunc i64 %122 to i32 + %123 = getelementptr inbounds %"char[]", ptr %url, i32 0, i32 0 + %124 = load ptr, ptr %123, align 8 + %125 = call i32 (ptr, i64, ptr, ...) @snprintf(ptr %119, i64 %add103, ptr @.str.7, i32 %trunc104, ptr %124) + %126 = getelementptr inbounds %Doc, ptr %literal106, i32 0, i32 0 + store ptr null, ptr %literal109, align 8 + %127 = getelementptr inbounds %Head, ptr %literal109, i32 0, i32 0 + %128 = load ptr, ptr %str, align 8 + %129 = load i32, ptr %len, align 4 + %sub = sub i32 %129, 1 + %sext112 = sext i32 %sub to i64 + %130 = add i64 %sext112, 1 + %size113 = sub i64 %130, 0 + %ptroffset114 = getelementptr inbounds i8, ptr %128, i64 0 + %131 = insertvalue %"char[]" undef, ptr %ptroffset114, 0 + %132 = insertvalue %"char[]" %131, i64 %size113, 1 + store %"char[]" %132, ptr %value111, align 8 + %133 = load ptr, ptr @std.core.mem.thread_allocator, align 8 + store ptr %133, ptr %using116, align 8 + store i64 0, ptr %end_padding117, align 8 + %134 = load ptr, ptr %using116, align 8 + store ptr %134, ptr %using119, align 8 + %135 = load i64, ptr %end_padding117, align 8 + store i64 %135, ptr %end_padding120, align 8 + store i64 16, ptr %.anon121, align 8 + %136 = load ptr, ptr %using119, align 8 + store ptr %136, ptr %allocator123, align 8 + %137 = load i64, ptr %.anon121, align 8 + %138 = load i64, ptr %end_padding120, align 8 + %add125 = add i64 %137, %138 + store i64 %add125, ptr %size124, align 8 + %139 = load ptr, ptr %allocator123, align 8 + %140 = getelementptr inbounds %Allocator, ptr %139, i32 0, i32 0 + %141 = load ptr, ptr %140, align 8 + %142 = load ptr, ptr %allocator123, align 8 + %143 = load i64, ptr %size124, align 8 + %144 = call i64 %141(ptr %retparam127, ptr %142, i64 %143, i64 0, i64 0, ptr null, i32 0) + %not_err128 = icmp eq i64 %144, 0 + %145 = call i1 @llvm.expect.i1(i1 %not_err128, i1 true) + br i1 %145, label %after_check130, label %assign_optional129 -assign_optional112: ; preds = %if.exit89 - store i64 %119, ptr %error_var105, align 8 - br label %panic_block114 +assign_optional129: ; preds = %if.exit101 + store i64 %144, ptr %error_var118, align 8 + br label %panic_block131 -after_check113: ; preds = %if.exit89 - %121 = load ptr, ptr %retparam109, align 8 - br label %noerr_block117 +after_check130: ; preds = %if.exit101 + %146 = load ptr, ptr %retparam127, align 8 + br label %noerr_block134 -panic_block114: ; preds = %assign_optional112 - %122 = insertvalue %any undef, ptr %error_var105, 0 - %123 = insertvalue %any %122, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1 - %124 = getelementptr inbounds [1 x %any], ptr %varargslots115, i64 0, i64 0 - store %any %123, ptr %124, align 16 - %125 = insertvalue %"any[]" undef, ptr %varargslots115, 0 - %126 = insertvalue %"any[]" %125, i64 1, 1 - store %"any[]" %126, ptr %indirectarg116, align 8 - call void @std.core.builtin.panicf(ptr @.panic_msg, i64 36, ptr @.file, i64 6, ptr @.func, i64 7, i32 200, ptr byval(%"any[]") align 8 %indirectarg116) +panic_block131: ; preds = %assign_optional129 + %147 = insertvalue %any undef, ptr %error_var118, 0 + %148 = insertvalue %any %147, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1 + %149 = getelementptr inbounds [1 x %any], ptr %varargslots132, i64 0, i64 0 + store %any %148, ptr %149, align 16 + %150 = insertvalue %"any[]" undef, ptr %varargslots132, 0 + %151 = insertvalue %"any[]" %150, i64 1, 1 + store %"any[]" %151, ptr %indirectarg133, align 8 + call void @std.core.builtin.panicf(ptr @.panic_msg, i64 36, ptr @.file, i64 6, ptr @.func, i64 7, i32 200, ptr byval(%"any[]") align 8 %indirectarg133) unreachable -noerr_block117: ; preds = %after_check113 - store ptr %121, ptr %temp102, align 8 - %127 = load ptr, ptr %temp102, align 8 - %not118 = icmp eq ptr %127, null - br i1 %not118, label %if.then119, label %if.exit120 +noerr_block134: ; preds = %after_check130 + store ptr %146, ptr %temp115, align 8 + %152 = load ptr, ptr %temp115, align 8 + %not135 = icmp eq ptr %152, null + br i1 %not135, label %if.then136, label %if.exit137 -if.then119: ; preds = %noerr_block117 - store i64 ptrtoint (ptr @"test.ReadError$OUT_OF_MEMORY" to i64), ptr %error_var98, align 8 - br label %guard_block121 +if.then136: ; preds = %noerr_block134 + store i64 ptrtoint (ptr @"test.ReadError$OUT_OF_MEMORY" to i64), ptr %error_var110, align 8 + br label %guard_block138 -if.exit120: ; preds = %noerr_block117 - %128 = load ptr, ptr %temp102, align 8 - call void @llvm.memcpy.p0.p0.i32(ptr align 8 %128, ptr align 8 %value99, i32 16, i1 false) - br label %noerr_block122 +if.exit137: ; preds = %noerr_block134 + %153 = load ptr, ptr %temp115, align 8 + call void @llvm.memcpy.p0.p0.i32(ptr align 8 %153, ptr align 8 %value111, i32 16, i1 false) + br label %noerr_block139 -guard_block121: ; preds = %if.then119 - %129 = load i64, ptr %error_var98, align 8 - ret i64 %129 +guard_block138: ; preds = %if.then136 + %154 = load i64, ptr %error_var110, align 8 + ret i64 %154 -noerr_block122: ; preds = %if.exit120 - %130 = load ptr, ptr %temp102, align 8 - store ptr %130, ptr %107, align 8 - call void @llvm.memcpy.p0.p0.i32(ptr align 8 %value96, ptr align 8 %literal97, i32 8, i1 false) - %131 = load ptr, ptr @std.core.mem.thread_allocator, align 8 - store ptr %131, ptr %using124, align 8 - store i64 0, ptr %end_padding125, align 8 - %132 = load ptr, ptr %using124, align 8 - store ptr %132, ptr %using127, align 8 - %133 = load i64, ptr %end_padding125, align 8 - store i64 %133, ptr %end_padding128, align 8 - store i64 8, ptr %.anon129, align 8 - %134 = load ptr, ptr %using127, align 8 - %135 = load i64, ptr %.anon129, align 8 - %136 = load i64, ptr %end_padding128, align 8 - %add131 = add i64 %135, %136 - %137 = call i64 @std.core.mem.allocator.Allocator.alloc(ptr %retparam130, ptr %134, i64 %add131) #3 - %not_err132 = icmp eq i64 %137, 0 - %138 = call i1 @llvm.expect.i1(i1 %not_err132, i1 true) - br i1 %138, label %after_check134, label %assign_optional133 +noerr_block139: ; preds = %if.exit137 + %155 = load ptr, ptr %temp115, align 8 + store ptr %155, ptr %127, align 8 + call void @llvm.memcpy.p0.p0.i32(ptr align 8 %value108, ptr align 8 %literal109, i32 8, i1 false) + %156 = load ptr, ptr @std.core.mem.thread_allocator, align 8 + store ptr %156, ptr %using141, align 8 + store i64 0, ptr %end_padding142, align 8 + %157 = load ptr, ptr %using141, align 8 + store ptr %157, ptr %using144, align 8 + %158 = load i64, ptr %end_padding142, align 8 + store i64 %158, ptr %end_padding145, align 8 + store i64 8, ptr %.anon146, align 8 + %159 = load ptr, ptr %using144, align 8 + store ptr %159, ptr %allocator148, align 8 + %160 = load i64, ptr %.anon146, align 8 + %161 = load i64, ptr %end_padding145, align 8 + %add150 = add i64 %160, %161 + store i64 %add150, ptr %size149, align 8 + %162 = load ptr, ptr %allocator148, align 8 + %163 = getelementptr inbounds %Allocator, ptr %162, i32 0, i32 0 + %164 = load ptr, ptr %163, align 8 + %165 = load ptr, ptr %allocator148, align 8 + %166 = load i64, ptr %size149, align 8 + %167 = call i64 %164(ptr %retparam152, ptr %165, i64 %166, i64 0, i64 0, ptr null, i32 0) + %not_err153 = icmp eq i64 %167, 0 + %168 = call i1 @llvm.expect.i1(i1 %not_err153, i1 true) + br i1 %168, label %after_check155, label %assign_optional154 -assign_optional133: ; preds = %noerr_block122 - store i64 %137, ptr %error_var126, align 8 - br label %panic_block135 +assign_optional154: ; preds = %noerr_block139 + store i64 %167, ptr %error_var143, align 8 + br label %panic_block156 -after_check134: ; preds = %noerr_block122 - %139 = load ptr, ptr %retparam130, align 8 - br label %noerr_block138 +after_check155: ; preds = %noerr_block139 + %169 = load ptr, ptr %retparam152, align 8 + br label %noerr_block159 -panic_block135: ; preds = %assign_optional133 - %140 = insertvalue %any undef, ptr %error_var126, 0 - %141 = insertvalue %any %140, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1 - %142 = getelementptr inbounds [1 x %any], ptr %varargslots136, i64 0, i64 0 - store %any %141, ptr %142, align 16 - %143 = insertvalue %"any[]" undef, ptr %varargslots136, 0 - %144 = insertvalue %"any[]" %143, i64 1, 1 - store %"any[]" %144, ptr %indirectarg137, align 8 - call void @std.core.builtin.panicf(ptr @.panic_msg, i64 36, ptr @.file, i64 6, ptr @.func, i64 7, i32 200, ptr byval(%"any[]") align 8 %indirectarg137) +panic_block156: ; preds = %assign_optional154 + %170 = insertvalue %any undef, ptr %error_var143, 0 + %171 = insertvalue %any %170, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1 + %172 = getelementptr inbounds [1 x %any], ptr %varargslots157, i64 0, i64 0 + store %any %171, ptr %172, align 16 + %173 = insertvalue %"any[]" undef, ptr %varargslots157, 0 + %174 = insertvalue %"any[]" %173, i64 1, 1 + store %"any[]" %174, ptr %indirectarg158, align 8 + call void @std.core.builtin.panicf(ptr @.panic_msg, i64 36, ptr @.file, i64 6, ptr @.func, i64 7, i32 200, ptr byval(%"any[]") align 8 %indirectarg158) unreachable -noerr_block138: ; preds = %after_check134 - store ptr %139, ptr %temp123, align 8 - %145 = load ptr, ptr %temp123, align 8 - %not139 = icmp eq ptr %145, null - br i1 %not139, label %if.then140, label %if.exit141 +noerr_block159: ; preds = %after_check155 + store ptr %169, ptr %temp140, align 8 + %175 = load ptr, ptr %temp140, align 8 + %not160 = icmp eq ptr %175, null + br i1 %not160, label %if.then161, label %if.exit162 -if.then140: ; preds = %noerr_block138 - store i64 ptrtoint (ptr @"test.ReadError$OUT_OF_MEMORY" to i64), ptr %error_var95, align 8 - br label %guard_block142 +if.then161: ; preds = %noerr_block159 + store i64 ptrtoint (ptr @"test.ReadError$OUT_OF_MEMORY" to i64), ptr %error_var107, align 8 + br label %guard_block163 -if.exit141: ; preds = %noerr_block138 - %146 = load ptr, ptr %temp123, align 8 - call void @llvm.memcpy.p0.p0.i32(ptr align 8 %146, ptr align 8 %value96, i32 8, i1 false) - br label %noerr_block143 +if.exit162: ; preds = %noerr_block159 + %176 = load ptr, ptr %temp140, align 8 + call void @llvm.memcpy.p0.p0.i32(ptr align 8 %176, ptr align 8 %value108, i32 8, i1 false) + br label %noerr_block164 -guard_block142: ; preds = %if.then140 - %147 = load i64, ptr %error_var95, align 8 - ret i64 %147 +guard_block163: ; preds = %if.then161 + %177 = load i64, ptr %error_var107, align 8 + ret i64 %177 -noerr_block143: ; preds = %if.exit141 - %148 = load ptr, ptr %temp123, align 8 - store ptr %148, ptr %106, align 8 - call void @llvm.memcpy.p0.p0.i32(ptr align 8 %0, ptr align 8 %literal94, i32 8, i1 false) +noerr_block164: ; preds = %if.exit162 + %178 = load ptr, ptr %temp140, align 8 + store ptr %178, ptr %126, align 8 + call void @llvm.memcpy.p0.p0.i32(ptr align 8 %0, ptr align 8 %literal106, i32 8, i1 false) ret i64 0 } diff --git a/test/test_suite/errors/macro_err.c3t b/test/test_suite/errors/macro_err.c3t index 36afd49b8..3294da88d 100644 --- a/test/test_suite/errors/macro_err.c3t +++ b/test/test_suite/errors/macro_err.c3t @@ -17,7 +17,6 @@ fn void main() /* #expect: test.ll - define i64 @test.abc(ptr %0) #0 { entry: %reterr = alloca i64, align 8 @@ -43,13 +42,17 @@ after_check: ; preds = %entry br label %noerr_block guard_block: ; preds = %assign_optional - ret void + br label %else_block noerr_block: ; preds = %after_check %2 = load i32, ptr %retparam, align 4 br label %phi_block -phi_block: ; preds = %noerr_block - %3 = call i32 (ptr, ...) @printf(ptr @.str, i32 %2) +else_block: ; preds = %guard_block + br label %phi_block + +phi_block: ; preds = %else_block, %noerr_block + %val = phi i32 [ %2, %noerr_block ], [ 2, %else_block ] + %3 = call i32 (ptr, ...) @printf(ptr @.str, i32 %val) ret void -} +} \ No newline at end of file diff --git a/test/test_suite/macros/macro_failable_return_rethrow.c3t b/test/test_suite/macros/macro_failable_return_rethrow.c3t index a849ece1d..f08613b4b 100644 --- a/test/test_suite/macros/macro_failable_return_rethrow.c3t +++ b/test/test_suite/macros/macro_failable_return_rethrow.c3t @@ -21,6 +21,8 @@ entry: %error_var = alloca i64, align 8 %error_var1 = alloca i64, align 8 %retparam = alloca i32, align 4 + %varargslots = alloca [1 x %any], align 16 + %indirectarg = alloca %"any[]", align 8 %0 = call i64 @test.xy(ptr %retparam) %not_err = icmp eq i64 %0, 0 %1 = call i1 @llvm.expect.i1(i1 %not_err, i1 true) @@ -34,11 +36,24 @@ after_check: ; preds = %entry br label %noerr_block guard_block: ; preds = %assign_optional - ret void + %2 = load i64, ptr %error_var1, align 8 + store i64 %2, ptr %error_var, align 8 + br label %panic_block noerr_block: ; preds = %after_check br label %noerr_block2 +panic_block: ; preds = %guard_block + %3 = insertvalue %any undef, ptr %error_var, 0 + %4 = insertvalue %any %3, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1 + %5 = getelementptr inbounds [1 x %any], ptr %varargslots, i64 0, i64 0 + store %any %4, ptr %5, align 16 + %6 = insertvalue %"any[]" undef, ptr %varargslots, 0 + %7 = insertvalue %"any[]" %6, i64 1, 1 + store %"any[]" %7, ptr %indirectarg, align 8 + call void @std.core.builtin.panicf(ptr @.panic_msg, i64 36, ptr @.file, i64 32, ptr @.func, i64 4, i32 13, ptr byval(%"any[]") align 8 %indirectarg) + unreachable + noerr_block2: ; preds = %noerr_block ret void } \ No newline at end of file diff --git a/test/test_suite/stdlib/map.c3t b/test/test_suite/stdlib/map.c3t index bddfdca31..730e97a8c 100644 --- a/test/test_suite/stdlib/map.c3t +++ b/test/test_suite/stdlib/map.c3t @@ -79,7 +79,6 @@ entry: %14 = load { ptr, i64 }, ptr %result, align 8 ret { ptr, i64 } %14 } - ; Function Attrs: nounwind define void @test.main() #0 { entry: @@ -128,6 +127,9 @@ entry: %retparam53 = alloca i64, align 8 %varargslots54 = alloca [1 x %any], align 16 %result55 = alloca %"int[]", align 8 + %allocator58 = alloca ptr, align 8 + %mark59 = alloca i64, align 8 + %retparam60 = alloca ptr, align 8 call void @llvm.memset.p0.i64(ptr align 8 %map, i8 0, i64 40, i1 false) %0 = load ptr, ptr @std.core.mem.thread_allocator, align 8 call void @"std.collections.map$int$test.Foo$.HashMap.init"(ptr %map, i32 16, float 7.500000e-01, ptr %0) @@ -171,7 +173,6 @@ entry: %not_err = icmp eq i64 %26, 0 %27 = call i1 @llvm.expect.i1(i1 %not_err, i1 true) br i1 %27, label %after_check, label %after_check12 - after_check: ; preds = %entry %28 = getelementptr inbounds %Foo, ptr %retparam10, i32 0, i32 0 %29 = insertvalue %any undef, ptr %28, 0 @@ -182,7 +183,6 @@ after_check: ; preds = %entry %not_err11 = icmp eq i64 %32, 0 %33 = call i1 @llvm.expect.i1(i1 %not_err11, i1 true) br i1 %33, label %after_check12, label %after_check12 - after_check12: ; preds = %entry, %after_check, %after_check %34 = call i8 @"std.collections.map$int$test.Foo$.HashMap.has_key"(ptr %map, i32 1) store i8 %34, ptr %taddr, align 1 @@ -253,22 +253,18 @@ after_check12: ; preds = %entry, %after_check %80 = load ptr, ptr @std.core.mem.thread_temp_allocator, align 8 %not = icmp eq ptr %80, null br i1 %not, label %if.then, label %if.exit - if.then: ; preds = %after_check12 %81 = load ptr, ptr @std.core.mem.thread_allocator, align 8 %82 = call i64 @std.core.mem.allocator.new_temp(ptr %retparam49, i64 262144, ptr %81) %not_err50 = icmp eq i64 %82, 0 %83 = call i1 @llvm.expect.i1(i1 %not_err50, i1 true) br i1 %83, label %after_check51, label %assign_optional - assign_optional: ; preds = %if.then store i64 %82, ptr %error_var, align 8 br label %panic_block - after_check51: ; preds = %if.then %84 = load ptr, ptr %retparam49, align 8 br label %noerr_block - panic_block: ; preds = %assign_optional %85 = insertvalue %any undef, ptr %error_var, 0 %86 = insertvalue %any %85, i64 ptrtoint (ptr @"$ct.anyfault" to i64), 1 @@ -279,11 +275,9 @@ panic_block: ; preds = %assign_optional store %"any[]" %89, ptr %indirectarg, align 8 call void @std.core.builtin.panicf(ptr @.panic_msg, i64 36, ptr @.file, i64 6, ptr @.func, i64 4, i32 399, ptr byval(%"any[]") align 8 %indirectarg) unreachable - noerr_block: ; preds = %after_check51 store ptr %84, ptr @std.core.mem.thread_temp_allocator, align 8 br label %if.exit - if.exit: ; preds = %noerr_block, %after_check12 %90 = load ptr, ptr @std.core.mem.thread_temp_allocator, align 8 store ptr %90, ptr %allocator, align 8 @@ -306,25 +300,28 @@ if.exit: ; preds = %noerr_block, %after %102 = call i64 @std.io.printfn(ptr %retparam53, ptr @.str.11, i64 2, ptr %varargslots54, i64 1) %103 = load ptr, ptr %allocator, align 8 %104 = getelementptr inbounds %TempAllocator, ptr %103, i32 0, i32 0 + store ptr %104, ptr %allocator58, align 8 %105 = load i64, ptr %mark, align 8 - call void @std.core.mem.allocator.Allocator.reset(ptr %104, i64 %105) + store i64 %105, ptr %mark59, align 8 + %106 = load ptr, ptr %allocator58, align 8 + %107 = getelementptr inbounds %Allocator, ptr %106, i32 0, i32 0 + %108 = load ptr, ptr %107, align 8 + %109 = load ptr, ptr %allocator58, align 8 + %110 = load i64, ptr %mark59, align 8 + %111 = call i64 %108(ptr %retparam60, ptr %109, i64 %110, i64 0, i64 0, ptr null, i32 8) ret void } - define internal void @.static_initialize.0() { entry: br label %dtable_check - dtable_check: ; preds = %dtable_next, %entry %dtable_ref = phi ptr [ getelementptr inbounds (%.introspect, ptr @"$ct.test.Foo", i32 0, i32 1), %entry ], [ %next_dtable_ref, %dtable_next ] %dtable_ptr = load ptr, ptr %dtable_ref, align 8 %0 = icmp eq ptr %dtable_ptr, null br i1 %0, label %dtable_found, label %dtable_next - dtable_next: ; preds = %dtable_check %next_dtable_ref = getelementptr inbounds { ptr, ptr, ptr }, ptr %dtable_ptr, i32 0, i32 2 br label %dtable_check - dtable_found: ; preds = %dtable_check store ptr @"$ct.dyn.test.Foo.to_string", ptr %dtable_ref, align 8 ret void