diff --git a/releasenotes.md b/releasenotes.md index 75c422f48..9c9578872 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -8,6 +8,7 @@ - Allow recursive function definitions as long as they are pointers. #1182 - Default CPU to native if less than AVX, otherwise use AVX. - Bounds checking on length for `foo[1:2]` slicing #1191. +- Foreach uses non-wrapping add/dec. ### Fixes - Incorrect length passed to scratch buffer printf. diff --git a/src/compiler/compiler_internal.h b/src/compiler/compiler_internal.h index 08eee7dca..32d3d27ba 100644 --- a/src/compiler/compiler_internal.h +++ b/src/compiler/compiler_internal.h @@ -764,6 +764,7 @@ typedef struct { Expr* expr; UnaryOp operator : 8; + bool no_wrap : 1; } ExprUnary; diff --git a/src/compiler/llvm_codegen_expr.c b/src/compiler/llvm_codegen_expr.c index f51dbb1f4..1b80d3fe1 100644 --- a/src/compiler/llvm_codegen_expr.c +++ b/src/compiler/llvm_codegen_expr.c @@ -17,16 +17,17 @@ static inline void llvm_emit_builtin_access(GenContext *c, BEValue *be_value, Ex static inline void llvm_emit_const_initialize_reference(GenContext *c, BEValue *ref, Expr *expr); static inline void llvm_emit_expr_block(GenContext *context, BEValue *be_value, Expr *expr); static inline void llvm_emit_optional(GenContext *c, BEValue *be_value, Expr *expr); -static inline void llvm_emit_inc_dec_change(GenContext *c, BEValue *addr, BEValue *after, BEValue *before, Expr *expr, - int diff); +static inline void +llvm_emit_inc_dec_change(GenContext *c, BEValue *addr, BEValue *after, BEValue *before, Expr *expr, int diff, + bool allow_wrap); static inline void llvm_emit_initialize_reference(GenContext *c, BEValue *ref, Expr *expr); static inline void llvm_emit_initialize_reference_bitstruct(GenContext *c, BEValue *ref, Decl *bitstruct, Expr** elements); static inline void llvm_emit_initialize_reference_list(GenContext *c, BEValue *ref, Expr *expr); static inline void llvm_emit_initialize_reference_vector(GenContext *c, BEValue *ref, Type *real_type, Expr **elements); static inline void llvm_emit_initializer_list_expr(GenContext *c, BEValue *value, Expr *expr); static inline void llvm_emit_macro_block(GenContext *c, BEValue *be_value, Expr *expr); -static inline void llvm_emit_post_inc_dec(GenContext *c, BEValue *value, Expr *expr, int diff); -static inline void llvm_emit_pre_inc_dec(GenContext *c, BEValue *value, Expr *expr, int diff); +static inline void llvm_emit_post_inc_dec(GenContext *c, BEValue *value, Expr *expr, int diff, bool allow_wrap); +static inline void llvm_emit_pre_inc_dec(GenContext *c, BEValue *value, Expr *expr, int diff, bool allow_wrap); static inline void llvm_emit_return_block(GenContext *c, BEValue *be_value, Type *type, AstId current, BlockExit **block_exit); static inline void llvm_emit_subscript_addr_with_base(GenContext *c, BEValue *result, BEValue *parent, BEValue *index, SourceSpan loc); static inline void llvm_emit_try_unwrap(GenContext *c, BEValue *value, Expr *expr); @@ -2318,7 +2319,7 @@ static inline void llvm_emit_initialize_reference(GenContext *c, BEValue *ref, E } } -static inline LLVMValueRef llvm_emit_inc_dec_value(GenContext *c, SourceSpan span, BEValue *original, int diff) +static inline LLVMValueRef llvm_emit_inc_dec_value(GenContext *c, SourceSpan span, BEValue *original, int diff, bool allow_wrap) { assert(!llvm_value_is_addr(original)); @@ -2343,9 +2344,21 @@ static inline LLVMValueRef llvm_emit_inc_dec_value(GenContext *c, SourceSpan spa // Instead of negative numbers do dec/inc with a positive number. LLVMTypeRef llvm_type = llvm_get_type(c, type); LLVMValueRef diff_value = LLVMConstInt(llvm_type, 1, false); + if (!allow_wrap) + { + if (type_is_signed(type)) + { + return diff > 0 + ? LLVMBuildNSWAdd(c->builder, original->value, diff_value, "addnsw") + : LLVMBuildNSWSub(c->builder, original->value, diff_value, "subnsw"); + } + return diff > 0 + ? LLVMBuildNUWAdd(c->builder, original->value, diff_value, "addnuw") + : LLVMBuildNUWSub(c->builder, original->value, diff_value, "subnuw"); + } return diff > 0 - ? llvm_emit_add_int(c, type, original->value, diff_value, span) - : llvm_emit_sub_int(c, type, original->value, diff_value, span); + ? llvm_emit_add_int(c, type, original->value, diff_value, span) + : llvm_emit_sub_int(c, type, original->value, diff_value, span); } case TYPE_VECTOR: { @@ -2381,8 +2394,8 @@ static inline LLVMValueRef llvm_emit_inc_dec_value(GenContext *c, SourceSpan spa UNREACHABLE } } -static inline void llvm_emit_inc_dec_change(GenContext *c, BEValue *addr, BEValue *after, BEValue *before, Expr *expr, - int diff) +static inline void llvm_emit_inc_dec_change(GenContext *c, BEValue *addr, BEValue *after, BEValue *before, + Expr *expr, int diff, bool allow_wrap) { EMIT_LOC(c, expr); @@ -2393,7 +2406,7 @@ static inline void llvm_emit_inc_dec_change(GenContext *c, BEValue *addr, BEValu // Store the original value if we want it if (before) *before = value; - LLVMValueRef after_value = llvm_emit_inc_dec_value(c, expr->span, &value, diff); + LLVMValueRef after_value = llvm_emit_inc_dec_value(c, expr->span, &value, diff, allow_wrap); // Store the result aligned. llvm_store_raw(c, addr, after_value); @@ -2475,7 +2488,7 @@ static inline void llvm_emit_pre_post_inc_dec_vector(GenContext *c, BEValue *val llvm_value_set(¤t_res, LLVMBuildExtractElement(c->builder, vector, index, ""), element); // Calculate the new value. - LLVMValueRef new_value = llvm_emit_inc_dec_value(c, expr->span, ¤t_res, diff); + LLVMValueRef new_value = llvm_emit_inc_dec_value(c, expr->span, ¤t_res, diff, false); // We update the vector value. vector = LLVMBuildInsertElement(c->builder, vector, new_value, index, ""); @@ -2490,7 +2503,7 @@ static inline void llvm_emit_pre_post_inc_dec_vector(GenContext *c, BEValue *val /** * This method implements the common ++x and --x operators */ -static inline void llvm_emit_pre_inc_dec(GenContext *c, BEValue *value, Expr *expr, int diff) +static inline void llvm_emit_pre_inc_dec(GenContext *c, BEValue *value, Expr *expr, int diff, bool allow_wrap) { if (expr_is_vector_subscript(expr)) { @@ -2508,7 +2521,7 @@ static inline void llvm_emit_pre_inc_dec(GenContext *c, BEValue *value, Expr *ex llvm_value_addr(c, &addr); // Set the value to the new value. - llvm_emit_inc_dec_change(c, &addr, value, NULL, expr, diff); + llvm_emit_inc_dec_change(c, &addr, value, NULL, expr, diff, allow_wrap); } static inline void llvm_emit_deref(GenContext *c, BEValue *value, Expr *inner, Type *type) @@ -2548,7 +2561,7 @@ static inline void llvm_emit_deref(GenContext *c, BEValue *value, Expr *inner, T /** * Emit the common x++ and x-- operations. */ -static inline void llvm_emit_post_inc_dec(GenContext *c, BEValue *value, Expr *expr, int diff) +static inline void llvm_emit_post_inc_dec(GenContext *c, BEValue *value, Expr *expr, int diff, bool allow_wrap) { if (expr_is_vector_subscript(expr)) { @@ -2568,7 +2581,7 @@ static inline void llvm_emit_post_inc_dec(GenContext *c, BEValue *value, Expr *e llvm_value_addr(c, &addr); // Perform the actual dec/inc to generate the new value. - llvm_emit_inc_dec_change(c, &addr, NULL, value, expr, diff); + llvm_emit_inc_dec_change(c, &addr, NULL, value, expr, diff, allow_wrap); } static void llvm_emit_dynamic_method_addr(GenContext *c, BEValue *value, Expr *expr) @@ -2716,10 +2729,10 @@ static void llvm_emit_unary_expr(GenContext *c, BEValue *value, Expr *expr) llvm_emit_deref(c, value, inner, type_lowering(expr->type)); return; case UNARYOP_INC: - llvm_emit_pre_inc_dec(c, value, inner, 1); + llvm_emit_pre_inc_dec(c, value, inner, 1, !expr->unary_expr.no_wrap); return; case UNARYOP_DEC: - llvm_emit_pre_inc_dec(c, value, inner, -1); + llvm_emit_pre_inc_dec(c, value, inner, -1, !expr->unary_expr.no_wrap); return; } UNREACHABLE @@ -4283,9 +4296,9 @@ static void llvm_emit_post_unary_expr(GenContext *context, BEValue *be_value, Ex { llvm_emit_post_inc_dec(context, - be_value, - expr->unary_expr.expr, - expr->unary_expr.operator == UNARYOP_INC ? 1 : -1); + be_value, + expr->unary_expr.expr, + expr->unary_expr.operator == UNARYOP_INC ? 1 : -1, !expr->unary_expr.no_wrap); } void llvm_emit_typeid(GenContext *c, BEValue *be_value, Type *type) diff --git a/src/compiler/sema_stmts.c b/src/compiler/sema_stmts.c index 5ca07f9ac..fb01ede69 100644 --- a/src/compiler/sema_stmts.c +++ b/src/compiler/sema_stmts.c @@ -1624,6 +1624,7 @@ static inline bool sema_analyse_foreach_stmt(SemaContext *context, Ast *statemen Expr *dec = expr_new(EXPR_UNARY, idx_decl->span); dec->unary_expr.expr = expr_variable(idx_decl); dec->unary_expr.operator = UNARYOP_DEC; + dec->unary_expr.no_wrap = true; Ast *update_stmt = new_ast(AST_EXPR_STMT, idx_decl->span); update_stmt->expr_stmt = dec; ast_append(&succ, update_stmt); @@ -1652,6 +1653,7 @@ static inline bool sema_analyse_foreach_stmt(SemaContext *context, Ast *statemen update = expr_new(EXPR_UNARY, idx_decl->span); update->unary_expr.expr = expr_variable(idx_decl); update->unary_expr.operator = UNARYOP_INC; + update->unary_expr.no_wrap = true; } // Create IndexType index = __idx$ diff --git a/test/test_suite/any/variant_test.c3t b/test/test_suite/any/variant_test.c3t index d7c6df48a..7f9f41db0 100644 --- a/test/test_suite/any/variant_test.c3t +++ b/test/test_suite/any/variant_test.c3t @@ -219,8 +219,8 @@ loop.body: ; preds = %loop.cond %hi = load ptr, ptr %ptradd3, align 8 call void @foo.test(i64 %lo, ptr %hi) %7 = load i64, ptr %.anon2, align 8 - %add = add i64 %7, 1 - store i64 %add, ptr %.anon2, align 8 + %addnuw = add nuw i64 %7, 1 + store i64 %addnuw, ptr %.anon2, align 8 br label %loop.cond loop.exit: ; preds = %loop.cond diff --git a/test/test_suite/bitstruct/bitstruct_be.c3t b/test/test_suite/bitstruct/bitstruct_be.c3t index 59239be2f..ac91e1ba8 100644 --- a/test/test_suite/bitstruct/bitstruct_be.c3t +++ b/test/test_suite/bitstruct/bitstruct_be.c3t @@ -82,8 +82,8 @@ loop.body: ; preds = %loop.cond store %"any*" %15, ptr %varargslots3, align 16 %16 = call i64 @std.io.printf(ptr %retparam4, ptr @.str.1, i64 3, ptr %varargslots3, i64 1) %17 = load i64, ptr %.anon1, align 8 - %add = add i64 %17, 1 - store i64 %add, ptr %.anon1, align 8 + %addnuw = add nuw i64 %17, 1 + store i64 %addnuw, ptr %.anon1, align 8 br label %loop.cond loop.exit: ; preds = %loop.cond @@ -139,101 +139,101 @@ guard_block17: ; preds = %assign_optional15 noerr_block18: ; preds = %after_check16 %26 = load i64, ptr %len, align 8 - %add19 = add i64 %26, 1 + %add = add i64 %26, 1 br label %voiderr voiderr: ; preds = %noerr_block18, %guard_block17, %guard_block11, %guard_block %27 = load ptr, ptr %z, align 8 - store ptr %27, ptr %.anon20, align 8 - store i64 0, ptr %.anon21, align 8 - br label %loop.cond22 - -loop.cond22: ; preds = %loop.body24, %voiderr - %28 = load i64, ptr %.anon21, align 8 - %gt23 = icmp ugt i64 4, %28 - br i1 %gt23, label %loop.body24, label %loop.exit32 - -loop.body24: ; preds = %loop.cond22 - %29 = load ptr, ptr %.anon20, align 8 - %30 = load i64, ptr %.anon21, align 8 - %ptradd26 = getelementptr inbounds i8, ptr %29, i64 %30 - %31 = load i8, ptr %ptradd26, align 1 - store i8 %31, ptr %d25, align 1 - %32 = insertvalue %"any*" undef, ptr %d25, 0 + store ptr %27, ptr %.anon19, align 8 + store i64 0, ptr %.anon20, align 8 + br label %loop.cond21 + +loop.cond21: ; preds = %loop.body23, %voiderr + %28 = load i64, ptr %.anon20, align 8 + %gt22 = icmp ugt i64 4, %28 + br i1 %gt22, label %loop.body23, label %loop.exit31 + +loop.body23: ; preds = %loop.cond21 + %29 = load ptr, ptr %.anon19, align 8 + %30 = load i64, ptr %.anon20, align 8 + %ptradd25 = getelementptr inbounds i8, ptr %29, i64 %30 + %31 = load i8, ptr %ptradd25, align 1 + store i8 %31, ptr %d24, align 1 + %32 = insertvalue %"any*" undef, ptr %d24, 0 %33 = insertvalue %"any*" %32, i64 ptrtoint (ptr @"$ct.char" to i64), 1 - store %"any*" %33, ptr %varargslots27, align 16 - %34 = call i64 @std.io.printf(ptr %retparam28, ptr @.str.2, i64 3, ptr %varargslots27, i64 1) - %35 = load i64, ptr %.anon21, align 8 - %add31 = add i64 %35, 1 - store i64 %add31, ptr %.anon21, align 8 - br label %loop.cond22 - -loop.exit32: ; preds = %loop.cond22 + store %"any*" %33, ptr %varargslots26, align 16 + %34 = call i64 @std.io.printf(ptr %retparam27, ptr @.str.2, i64 3, ptr %varargslots26, i64 1) + %35 = load i64, ptr %.anon20, align 8 + %addnuw30 = add nuw i64 %35, 1 + store i64 %addnuw30, ptr %.anon20, align 8 + br label %loop.cond21 + +loop.exit31: ; preds = %loop.cond21 %36 = call ptr @std.io.stdout() - %37 = call i64 @std.io.File.write(ptr %retparam36, ptr %36, ptr null, i64 0) - %not_err37 = icmp eq i64 %37, 0 - %38 = call i1 @llvm.expect.i1(i1 %not_err37, i1 true) - br i1 %38, label %after_check39, label %assign_optional38 + %37 = call i64 @std.io.File.write(ptr %retparam35, ptr %36, ptr null, i64 0) + %not_err36 = icmp eq i64 %37, 0 + %38 = call i1 @llvm.expect.i1(i1 %not_err36, i1 true) + br i1 %38, label %after_check38, label %assign_optional37 -assign_optional38: ; preds = %loop.exit32 - store i64 %37, ptr %error_var34, align 8 - br label %guard_block40 +assign_optional37: ; preds = %loop.exit31 + store i64 %37, ptr %error_var33, align 8 + br label %guard_block39 -after_check39: ; preds = %loop.exit32 - br label %noerr_block41 +after_check38: ; preds = %loop.exit31 + br label %noerr_block40 -guard_block40: ; preds = %assign_optional38 - br label %voiderr55 +guard_block39: ; preds = %assign_optional37 + br label %voiderr54 -noerr_block41: ; preds = %after_check39 - %39 = load i64, ptr %retparam36, align 8 - store i64 %39, ptr %len33, align 8 +noerr_block40: ; preds = %after_check38 + %39 = load i64, ptr %retparam35, align 8 + store i64 %39, ptr %len32, align 8 %40 = call i64 @std.io.File.write_byte(ptr %36, i8 zeroext 10) - %not_err43 = icmp eq i64 %40, 0 - %41 = call i1 @llvm.expect.i1(i1 %not_err43, i1 true) - br i1 %41, label %after_check45, label %assign_optional44 + %not_err42 = icmp eq i64 %40, 0 + %41 = call i1 @llvm.expect.i1(i1 %not_err42, i1 true) + br i1 %41, label %after_check44, label %assign_optional43 -assign_optional44: ; preds = %noerr_block41 - store i64 %40, ptr %error_var42, align 8 - br label %guard_block46 +assign_optional43: ; preds = %noerr_block40 + store i64 %40, ptr %error_var41, align 8 + br label %guard_block45 -after_check45: ; preds = %noerr_block41 - br label %noerr_block47 +after_check44: ; preds = %noerr_block40 + br label %noerr_block46 -guard_block46: ; preds = %assign_optional44 - br label %voiderr55 +guard_block45: ; preds = %assign_optional43 + br label %voiderr54 -noerr_block47: ; preds = %after_check45 +noerr_block46: ; preds = %after_check44 %42 = call i64 @std.io.File.flush(ptr %36) - %not_err49 = icmp eq i64 %42, 0 - %43 = call i1 @llvm.expect.i1(i1 %not_err49, i1 true) - br i1 %43, label %after_check51, label %assign_optional50 + %not_err48 = icmp eq i64 %42, 0 + %43 = call i1 @llvm.expect.i1(i1 %not_err48, i1 true) + br i1 %43, label %after_check50, label %assign_optional49 -assign_optional50: ; preds = %noerr_block47 - store i64 %42, ptr %error_var48, align 8 - br label %guard_block52 +assign_optional49: ; preds = %noerr_block46 + store i64 %42, ptr %error_var47, align 8 + br label %guard_block51 -after_check51: ; preds = %noerr_block47 - br label %noerr_block53 +after_check50: ; preds = %noerr_block46 + br label %noerr_block52 -guard_block52: ; preds = %assign_optional50 - br label %voiderr55 +guard_block51: ; preds = %assign_optional49 + br label %voiderr54 -noerr_block53: ; preds = %after_check51 - %44 = load i64, ptr %len33, align 8 - %add54 = add i64 %44, 1 - br label %voiderr55 +noerr_block52: ; preds = %after_check50 + %44 = load i64, ptr %len32, align 8 + %add53 = add i64 %44, 1 + br label %voiderr54 -voiderr55: ; preds = %noerr_block53, %guard_block52, %guard_block46, %guard_block40 +voiderr54: ; preds = %noerr_block52, %guard_block51, %guard_block45, %guard_block39 %45 = load i32, ptr %abc, align 4 %46 = call i32 @llvm.bswap.i32(i32 %45) %47 = and i32 65535, %46 %trunc = trunc i32 %47 to i16 - store i16 %trunc, ptr %taddr57, align 2 - %48 = insertvalue %"any*" undef, ptr %taddr57, 0 + store i16 %trunc, ptr %taddr56, align 2 + %48 = insertvalue %"any*" undef, ptr %taddr56, 0 %49 = insertvalue %"any*" %48, i64 ptrtoint (ptr @"$ct.ushort" to i64), 1 - store %"any*" %49, ptr %varargslots56, align 16 - %50 = call i64 @std.io.printfn(ptr %retparam58, ptr @.str.3, i64 10, ptr %varargslots56, i64 1) + store %"any*" %49, ptr %varargslots55, align 16 + %50 = call i64 @std.io.printfn(ptr %retparam57, ptr @.str.3, i64 10, ptr %varargslots55, i64 1) %51 = load i32, ptr %abc, align 4 %52 = call i32 @llvm.bswap.i32(i32 %51) %53 = and i32 %52, -65536 @@ -249,106 +249,106 @@ voiderr55: ; preds = %noerr_block53, %gua %61 = load i32, ptr %abc, align 4 %62 = call i32 @llvm.bswap.i32(i32 %61) %63 = and i32 65535, %62 - %trunc62 = trunc i32 %63 to i16 - store i16 %trunc62, ptr %taddr63, align 2 - %64 = insertvalue %"any*" undef, ptr %taddr63, 0 + %trunc61 = trunc i32 %63 to i16 + store i16 %trunc61, ptr %taddr62, align 2 + %64 = insertvalue %"any*" undef, ptr %taddr62, 0 %65 = insertvalue %"any*" %64, i64 ptrtoint (ptr @"$ct.ushort" to i64), 1 - store %"any*" %65, ptr %varargslots61, align 16 - %66 = call i64 @std.io.printfn(ptr %retparam64, ptr @.str.4, i64 12, ptr %varargslots61, i64 1) + store %"any*" %65, ptr %varargslots60, align 16 + %66 = call i64 @std.io.printfn(ptr %retparam63, ptr @.str.4, i64 12, ptr %varargslots60, i64 1) %67 = load ptr, ptr %z, align 8 - store ptr %67, ptr %.anon67, align 8 - store i64 0, ptr %.anon68, align 8 - br label %loop.cond69 - -loop.cond69: ; preds = %loop.body71, %voiderr55 - %68 = load i64, ptr %.anon68, align 8 - %gt70 = icmp ugt i64 4, %68 - br i1 %gt70, label %loop.body71, label %loop.exit79 - -loop.body71: ; preds = %loop.cond69 - %69 = load ptr, ptr %.anon67, align 8 - %70 = load i64, ptr %.anon68, align 8 - %ptradd73 = getelementptr inbounds i8, ptr %69, i64 %70 - %71 = load i8, ptr %ptradd73, align 1 - store i8 %71, ptr %d72, align 1 - %72 = insertvalue %"any*" undef, ptr %d72, 0 + store ptr %67, ptr %.anon66, align 8 + store i64 0, ptr %.anon67, align 8 + br label %loop.cond68 + +loop.cond68: ; preds = %loop.body70, %voiderr54 + %68 = load i64, ptr %.anon67, align 8 + %gt69 = icmp ugt i64 4, %68 + br i1 %gt69, label %loop.body70, label %loop.exit78 + +loop.body70: ; preds = %loop.cond68 + %69 = load ptr, ptr %.anon66, align 8 + %70 = load i64, ptr %.anon67, align 8 + %ptradd72 = getelementptr inbounds i8, ptr %69, i64 %70 + %71 = load i8, ptr %ptradd72, align 1 + store i8 %71, ptr %d71, align 1 + %72 = insertvalue %"any*" undef, ptr %d71, 0 %73 = insertvalue %"any*" %72, i64 ptrtoint (ptr @"$ct.char" to i64), 1 - store %"any*" %73, ptr %varargslots74, align 16 - %74 = call i64 @std.io.printf(ptr %retparam75, ptr @.str.5, i64 3, ptr %varargslots74, i64 1) - %75 = load i64, ptr %.anon68, align 8 - %add78 = add i64 %75, 1 - store i64 %add78, ptr %.anon68, align 8 - br label %loop.cond69 - -loop.exit79: ; preds = %loop.cond69 + store %"any*" %73, ptr %varargslots73, align 16 + %74 = call i64 @std.io.printf(ptr %retparam74, ptr @.str.5, i64 3, ptr %varargslots73, i64 1) + %75 = load i64, ptr %.anon67, align 8 + %addnuw77 = add nuw i64 %75, 1 + store i64 %addnuw77, ptr %.anon67, align 8 + br label %loop.cond68 + +loop.exit78: ; preds = %loop.cond68 %76 = call ptr @std.io.stdout() - %77 = call i64 @std.io.File.write(ptr %retparam83, ptr %76, ptr null, i64 0) - %not_err84 = icmp eq i64 %77, 0 - %78 = call i1 @llvm.expect.i1(i1 %not_err84, i1 true) - br i1 %78, label %after_check86, label %assign_optional85 + %77 = call i64 @std.io.File.write(ptr %retparam82, ptr %76, ptr null, i64 0) + %not_err83 = icmp eq i64 %77, 0 + %78 = call i1 @llvm.expect.i1(i1 %not_err83, i1 true) + br i1 %78, label %after_check85, label %assign_optional84 -assign_optional85: ; preds = %loop.exit79 - store i64 %77, ptr %error_var81, align 8 - br label %guard_block87 +assign_optional84: ; preds = %loop.exit78 + store i64 %77, ptr %error_var80, align 8 + br label %guard_block86 -after_check86: ; preds = %loop.exit79 - br label %noerr_block88 +after_check85: ; preds = %loop.exit78 + br label %noerr_block87 -guard_block87: ; preds = %assign_optional85 - br label %voiderr102 +guard_block86: ; preds = %assign_optional84 + br label %voiderr101 -noerr_block88: ; preds = %after_check86 - %79 = load i64, ptr %retparam83, align 8 - store i64 %79, ptr %len80, align 8 +noerr_block87: ; preds = %after_check85 + %79 = load i64, ptr %retparam82, align 8 + store i64 %79, ptr %len79, align 8 %80 = call i64 @std.io.File.write_byte(ptr %76, i8 zeroext 10) - %not_err90 = icmp eq i64 %80, 0 - %81 = call i1 @llvm.expect.i1(i1 %not_err90, i1 true) - br i1 %81, label %after_check92, label %assign_optional91 + %not_err89 = icmp eq i64 %80, 0 + %81 = call i1 @llvm.expect.i1(i1 %not_err89, i1 true) + br i1 %81, label %after_check91, label %assign_optional90 -assign_optional91: ; preds = %noerr_block88 - store i64 %80, ptr %error_var89, align 8 - br label %guard_block93 +assign_optional90: ; preds = %noerr_block87 + store i64 %80, ptr %error_var88, align 8 + br label %guard_block92 -after_check92: ; preds = %noerr_block88 - br label %noerr_block94 +after_check91: ; preds = %noerr_block87 + br label %noerr_block93 -guard_block93: ; preds = %assign_optional91 - br label %voiderr102 +guard_block92: ; preds = %assign_optional90 + br label %voiderr101 -noerr_block94: ; preds = %after_check92 +noerr_block93: ; preds = %after_check91 %82 = call i64 @std.io.File.flush(ptr %76) - %not_err96 = icmp eq i64 %82, 0 - %83 = call i1 @llvm.expect.i1(i1 %not_err96, i1 true) - br i1 %83, label %after_check98, label %assign_optional97 + %not_err95 = icmp eq i64 %82, 0 + %83 = call i1 @llvm.expect.i1(i1 %not_err95, i1 true) + br i1 %83, label %after_check97, label %assign_optional96 -assign_optional97: ; preds = %noerr_block94 - store i64 %82, ptr %error_var95, align 8 - br label %guard_block99 +assign_optional96: ; preds = %noerr_block93 + store i64 %82, ptr %error_var94, align 8 + br label %guard_block98 -after_check98: ; preds = %noerr_block94 - br label %noerr_block100 +after_check97: ; preds = %noerr_block93 + br label %noerr_block99 -guard_block99: ; preds = %assign_optional97 - br label %voiderr102 +guard_block98: ; preds = %assign_optional96 + br label %voiderr101 -noerr_block100: ; preds = %after_check98 - %84 = load i64, ptr %len80, align 8 - %add101 = add i64 %84, 1 - br label %voiderr102 +noerr_block99: ; preds = %after_check97 + %84 = load i64, ptr %len79, align 8 + %add100 = add i64 %84, 1 + br label %voiderr101 -voiderr102: ; preds = %noerr_block100, %guard_block99, %guard_block93, %guard_block87 +voiderr101: ; preds = %noerr_block99, %guard_block98, %guard_block92, %guard_block86 store i32 0, ptr %y, align 4 %85 = load i32, ptr %y, align 4 store i32 123, ptr %y, align 4 %86 = insertvalue %"any*" undef, ptr %y, 0 %87 = insertvalue %"any*" %86, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - store %"any*" %87, ptr %varargslots103, align 16 + store %"any*" %87, ptr %varargslots102, align 16 %88 = load i32, ptr %y, align 4 - store i32 %88, ptr %taddr104, align 4 - %89 = insertvalue %"any*" undef, ptr %taddr104, 0 + store i32 %88, ptr %taddr103, align 4 + %89 = insertvalue %"any*" undef, ptr %taddr103, 0 %90 = insertvalue %"any*" %89, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - %ptradd105 = getelementptr inbounds i8, ptr %varargslots103, i64 16 - store %"any*" %90, ptr %ptradd105, align 16 - %91 = call i64 @std.io.printf(ptr %retparam106, ptr @.str.6, i64 18, ptr %varargslots103, i64 2) + %ptradd104 = getelementptr inbounds i8, ptr %varargslots102, i64 16 + store %"any*" %90, ptr %ptradd104, align 16 + %91 = call i64 @std.io.printf(ptr %retparam105, ptr @.str.6, i64 18, ptr %varargslots102, i64 2) ret void } \ 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 92d6e182a..4232a0ffd 100644 --- a/test/test_suite/errors/error_regression_2.c3t +++ b/test/test_suite/errors/error_regression_2.c3t @@ -834,8 +834,8 @@ phi_block19: ; preds = %else_block18, %afte %ternary = select i1 %val20, ptr @.str.26, ptr @.str.27 %32 = call i32 (ptr, ...) @printf(ptr @.str.25, ptr %val14, ptr %ternary) %33 = load i64, ptr %.anon1, align 8 - %add = add i64 %33, 1 - store i64 %add, ptr %.anon1, align 8 + %addnuw = add nuw i64 %33, 1 + store i64 %addnuw, ptr %.anon1, align 8 br label %loop.cond loop.exit: ; preds = %loop.cond diff --git a/test/test_suite/generic/generic_over_fn.c3t b/test/test_suite/generic/generic_over_fn.c3t index e4a86c5b9..e288755ff 100644 --- a/test/test_suite/generic/generic_over_fn.c3t +++ b/test/test_suite/generic/generic_over_fn.c3t @@ -123,8 +123,8 @@ loop.body: ; preds = %loop.cond %hi = load i64, ptr %ptradd11, align 8 call void @"test_generic$sa$int$p$fn$int$int$$int$$.sort"(ptr %lo, i64 %hi, i64 0, i64 %sub, ptr @sort_test.cmp_int_value) %17 = load i64, ptr %.anon9, align 8 - %add = add i64 %17, 1 - store i64 %add, ptr %.anon9, align 8 + %addnuw = add nuw i64 %17, 1 + store i64 %addnuw, ptr %.anon9, align 8 br label %loop.cond loop.exit: ; preds = %loop.cond @@ -197,8 +197,8 @@ loop.body: ; preds = %loop.cond %hi = load i64, ptr %ptradd11, align 8 call void @"test_generic$sa$int$p$fn$int$int$$int$$.sort"(ptr %lo, i64 %hi, i64 0, i64 %sub, ptr @sort_test.cmp_int_value2) %17 = load i64, ptr %.anon9, align 8 - %add = add i64 %17, 1 - store i64 %add, ptr %.anon9, align 8 + %addnuw = add nuw i64 %17, 1 + store i64 %addnuw, ptr %.anon9, align 8 br label %loop.cond loop.exit: ; preds = %loop.cond diff --git a/test/test_suite/initializer_lists/ranges_to_dynamic.c3t b/test/test_suite/initializer_lists/ranges_to_dynamic.c3t index 934b1f29a..70106209a 100644 --- a/test/test_suite/initializer_lists/ranges_to_dynamic.c3t +++ b/test/test_suite/initializer_lists/ranges_to_dynamic.c3t @@ -54,8 +54,8 @@ loop.body: ; preds = %loop.cond %4 = load i32, ptr %v, align 4 call void (ptr, ...) @printf(ptr @.str, i32 %4) %5 = load i64, ptr %.anon, align 8 - %add = add i64 %5, 1 - store i64 %add, ptr %.anon, align 8 + %addnuw = add nuw i64 %5, 1 + store i64 %addnuw, ptr %.anon, align 8 br label %loop.cond loop.exit: ; preds = %loop.cond diff --git a/test/test_suite/macros/macro_typed_varargs.c3t b/test/test_suite/macros/macro_typed_varargs.c3t index 1273ab974..0d2ee5dea 100644 --- a/test/test_suite/macros/macro_typed_varargs.c3t +++ b/test/test_suite/macros/macro_typed_varargs.c3t @@ -75,8 +75,8 @@ loop.body: ; preds = %loop.cond store %"any*" %9, ptr %varargslots, align 16 %10 = call i64 @std.io.printfn(ptr %retparam, ptr @.str, i64 2, ptr %varargslots, i64 1) %11 = load i64, ptr %.anon1, align 8 - %add = add i64 %11, 1 - store i64 %add, ptr %.anon1, align 8 + %addnuw = add nuw i64 %11, 1 + store i64 %addnuw, ptr %.anon1, align 8 br label %loop.cond loop.exit: ; preds = %loop.cond @@ -125,8 +125,8 @@ loop.body15: ; preds = %loop.cond13 store %"any*" %29, ptr %varargslots18, align 16 %30 = call i64 @std.io.printfn(ptr %retparam19, ptr @.str.1, i64 2, ptr %varargslots18, i64 1) %31 = load i64, ptr %.anon12, align 8 - %add20 = add i64 %31, 1 - store i64 %add20, ptr %.anon12, align 8 + %addnuw20 = add nuw i64 %31, 1 + store i64 %addnuw20, ptr %.anon12, align 8 br label %loop.cond13 loop.exit21: ; preds = %loop.cond13 diff --git a/test/test_suite/macros/macro_vasplat.c3t b/test/test_suite/macros/macro_vasplat.c3t index 60c5ef61e..7d967faea 100644 --- a/test/test_suite/macros/macro_vasplat.c3t +++ b/test/test_suite/macros/macro_vasplat.c3t @@ -139,12 +139,10 @@ entry: call void @llvm.memcpy.p0.p0.i32(ptr align 4 %a, ptr align 4 @.__const, i32 12, i1 false) store i64 0, ptr %.anon, align 8 br label %loop.cond - loop.cond: ; preds = %loop.body, %entry %0 = load i64, ptr %.anon, align 8 %gt = icmp ugt i64 3, %0 br i1 %gt, label %loop.body, label %loop.exit - loop.body: ; preds = %loop.cond %1 = load i64, ptr %.anon, align 8 store i64 %1, ptr %i, align 8 @@ -161,10 +159,9 @@ loop.body: ; preds = %loop.cond store %"any*" %7, ptr %ptradd, align 16 %8 = call i64 @std.io.printfn(ptr %retparam, ptr @.str, i64 8, ptr %varargslots, i64 2) %9 = load i64, ptr %.anon, align 8 - %add = add i64 %9, 1 - store i64 %add, ptr %.anon, align 8 + %addnuw = add nuw i64 %9, 1 + store i64 %addnuw, ptr %.anon, align 8 br label %loop.cond - loop.exit: ; preds = %loop.cond call void @llvm.memcpy.p0.p0.i32(ptr align 4 %a1, ptr align 4 @.__const.1, i32 4, i1 false) store i64 0, ptr %.anon2, align 8 @@ -183,12 +180,10 @@ loop.exit: ; preds = %loop.cond call void @llvm.memcpy.p0.p0.i32(ptr align 16 %a8, ptr align 16 @.__const.3, i32 16, i1 false) store i64 0, ptr %.anon9, align 8 br label %loop.cond10 - loop.cond10: ; preds = %loop.body12, %loop.exit %17 = load i64, ptr %.anon9, align 8 %gt11 = icmp ugt i64 4, %17 br i1 %gt11, label %loop.body12, label %loop.exit20 - loop.body12: ; preds = %loop.cond10 %18 = load i64, ptr %.anon9, align 8 store i64 %18, ptr %i13, align 8 @@ -205,20 +200,17 @@ loop.body12: ; preds = %loop.cond10 store %"any*" %24, ptr %ptradd17, align 16 %25 = call i64 @std.io.printfn(ptr %retparam18, ptr @.str.4, i64 6, ptr %varargslots16, i64 2) %26 = load i64, ptr %.anon9, align 8 - %add19 = add i64 %26, 1 - store i64 %add19, ptr %.anon9, align 8 + %addnuw19 = add nuw i64 %26, 1 + store i64 %addnuw19, ptr %.anon9, align 8 br label %loop.cond10 - loop.exit20: ; preds = %loop.cond10 call void @llvm.memcpy.p0.p0.i32(ptr align 4 %a21, ptr align 4 @.__const.5, i32 8, i1 false) store i64 0, ptr %.anon22, align 8 br label %loop.cond23 - loop.cond23: ; preds = %loop.body25, %loop.exit20 %27 = load i64, ptr %.anon22, align 8 %gt24 = icmp ugt i64 2, %27 br i1 %gt24, label %loop.body25, label %loop.exit33 - loop.body25: ; preds = %loop.cond23 %28 = load i64, ptr %.anon22, align 8 store i64 %28, ptr %i26, align 8 @@ -235,20 +227,17 @@ loop.body25: ; preds = %loop.cond23 store %"any*" %34, ptr %ptradd30, align 16 %35 = call i64 @std.io.printfn(ptr %retparam31, ptr @.str.6, i64 6, ptr %varargslots29, i64 2) %36 = load i64, ptr %.anon22, align 8 - %add32 = add i64 %36, 1 - store i64 %add32, ptr %.anon22, align 8 + %addnuw32 = add nuw i64 %36, 1 + store i64 %addnuw32, ptr %.anon22, align 8 br label %loop.cond23 - loop.exit33: ; preds = %loop.cond23 call void @llvm.memcpy.p0.p0.i32(ptr align 4 %a34, ptr align 4 @.__const.7, i32 12, i1 false) store i64 0, ptr %.anon35, align 8 br label %loop.cond36 - loop.cond36: ; preds = %loop.body38, %loop.exit33 %37 = load i64, ptr %.anon35, align 8 %gt37 = icmp ugt i64 3, %37 br i1 %gt37, label %loop.body38, label %loop.exit46 - loop.body38: ; preds = %loop.cond36 %38 = load i64, ptr %.anon35, align 8 store i64 %38, ptr %i39, align 8 @@ -265,10 +254,9 @@ loop.body38: ; preds = %loop.cond36 store %"any*" %44, ptr %ptradd43, align 16 %45 = call i64 @std.io.printfn(ptr %retparam44, ptr @.str.8, i64 8, ptr %varargslots42, i64 2) %46 = load i64, ptr %.anon35, align 8 - %add45 = add i64 %46, 1 - store i64 %add45, ptr %.anon35, align 8 + %addnuw45 = add nuw i64 %46, 1 + store i64 %addnuw45, ptr %.anon35, align 8 br label %loop.cond36 - loop.exit46: ; preds = %loop.cond36 call void @llvm.memcpy.p0.p0.i32(ptr align 4 %a47, ptr align 4 @.__const.9, i32 4, i1 false) store i64 0, ptr %.anon48, align 8 @@ -287,12 +275,10 @@ loop.exit46: ; preds = %loop.cond36 call void @llvm.memcpy.p0.p0.i32(ptr align 4 %a54, ptr align 4 @.__const.11, i32 8, i1 false) store i64 0, ptr %.anon55, align 8 br label %loop.cond56 - loop.cond56: ; preds = %loop.body58, %loop.exit46 %54 = load i64, ptr %.anon55, align 8 %gt57 = icmp ugt i64 2, %54 br i1 %gt57, label %loop.body58, label %loop.exit66 - loop.body58: ; preds = %loop.cond56 %55 = load i64, ptr %.anon55, align 8 store i64 %55, ptr %i59, align 8 @@ -309,20 +295,17 @@ loop.body58: ; preds = %loop.cond56 store %"any*" %61, ptr %ptradd63, align 16 %62 = call i64 @std.io.printfn(ptr %retparam64, ptr @.str.12, i64 8, ptr %varargslots62, i64 2) %63 = load i64, ptr %.anon55, align 8 - %add65 = add i64 %63, 1 - store i64 %add65, ptr %.anon55, align 8 + %addnuw65 = add nuw i64 %63, 1 + store i64 %addnuw65, ptr %.anon55, align 8 br label %loop.cond56 - loop.exit66: ; preds = %loop.cond56 call void @llvm.memcpy.p0.p0.i32(ptr align 16 %a67, ptr align 16 @.__const.13, i32 20, i1 false) store i64 0, ptr %.anon68, align 8 br label %loop.cond69 - loop.cond69: ; preds = %loop.body71, %loop.exit66 %64 = load i64, ptr %.anon68, align 8 %gt70 = icmp ugt i64 5, %64 br i1 %gt70, label %loop.body71, label %loop.exit79 - loop.body71: ; preds = %loop.cond69 %65 = load i64, ptr %.anon68, align 8 store i64 %65, ptr %i72, align 8 @@ -339,20 +322,17 @@ loop.body71: ; preds = %loop.cond69 store %"any*" %71, ptr %ptradd76, align 16 %72 = call i64 @std.io.printfn(ptr %retparam77, ptr @.str.14, i64 8, ptr %varargslots75, i64 2) %73 = load i64, ptr %.anon68, align 8 - %add78 = add i64 %73, 1 - store i64 %add78, ptr %.anon68, align 8 + %addnuw78 = add nuw i64 %73, 1 + store i64 %addnuw78, ptr %.anon68, align 8 br label %loop.cond69 - loop.exit79: ; preds = %loop.cond69 call void @llvm.memcpy.p0.p0.i32(ptr align 16 %a80, ptr align 16 @.__const.15, i32 32, i1 false) store i64 0, ptr %.anon81, align 8 br label %loop.cond82 - loop.cond82: ; preds = %loop.body84, %loop.exit79 %74 = load i64, ptr %.anon81, align 8 %gt83 = icmp ugt i64 8, %74 br i1 %gt83, label %loop.body84, label %loop.exit92 - loop.body84: ; preds = %loop.cond82 %75 = load i64, ptr %.anon81, align 8 store i64 %75, ptr %i85, align 8 @@ -369,20 +349,17 @@ loop.body84: ; preds = %loop.cond82 store %"any*" %81, ptr %ptradd89, align 16 %82 = call i64 @std.io.printfn(ptr %retparam90, ptr @.str.16, i64 8, ptr %varargslots88, i64 2) %83 = load i64, ptr %.anon81, align 8 - %add91 = add i64 %83, 1 - store i64 %add91, ptr %.anon81, align 8 + %addnuw91 = add nuw i64 %83, 1 + store i64 %addnuw91, ptr %.anon81, align 8 br label %loop.cond82 - loop.exit92: ; preds = %loop.cond82 call void @llvm.memcpy.p0.p0.i32(ptr align 16 %b, ptr align 16 @.__const.17, i32 28, i1 false) store i64 0, ptr %.anon93, align 8 br label %loop.cond94 - loop.cond94: ; preds = %loop.body96, %loop.exit92 %84 = load i64, ptr %.anon93, align 8 %gt95 = icmp ugt i64 7, %84 br i1 %gt95, label %loop.body96, label %loop.exit104 - loop.body96: ; preds = %loop.cond94 %85 = load i64, ptr %.anon93, align 8 store i64 %85, ptr %i97, align 8 @@ -399,20 +376,17 @@ loop.body96: ; preds = %loop.cond94 store %"any*" %91, ptr %ptradd101, align 16 %92 = call i64 @std.io.printfn(ptr %retparam102, ptr @.str.18, i64 8, ptr %varargslots100, i64 2) %93 = load i64, ptr %.anon93, align 8 - %add103 = add i64 %93, 1 - store i64 %add103, ptr %.anon93, align 8 + %addnuw103 = add nuw i64 %93, 1 + store i64 %addnuw103, ptr %.anon93, align 8 br label %loop.cond94 - loop.exit104: ; preds = %loop.cond94 call void @llvm.memcpy.p0.p0.i32(ptr align 16 %c, ptr align 16 @.__const.19, i32 32, i1 false) store i64 0, ptr %.anon105, align 8 br label %loop.cond106 - loop.cond106: ; preds = %loop.body108, %loop.exit104 %94 = load i64, ptr %.anon105, align 8 %gt107 = icmp ugt i64 8, %94 br i1 %gt107, label %loop.body108, label %loop.exit116 - loop.body108: ; preds = %loop.cond106 %95 = load i64, ptr %.anon105, align 8 store i64 %95, ptr %i109, align 8 @@ -429,20 +403,17 @@ loop.body108: ; preds = %loop.cond106 store %"any*" %101, ptr %ptradd113, align 16 %102 = call i64 @std.io.printfn(ptr %retparam114, ptr @.str.20, i64 9, ptr %varargslots112, i64 2) %103 = load i64, ptr %.anon105, align 8 - %add115 = add i64 %103, 1 - store i64 %add115, ptr %.anon105, align 8 + %addnuw115 = add nuw i64 %103, 1 + store i64 %addnuw115, ptr %.anon105, align 8 br label %loop.cond106 - loop.exit116: ; preds = %loop.cond106 call void @llvm.memcpy.p0.p0.i32(ptr align 16 %a117, ptr align 16 @.__const.21, i32 24, i1 false) store i64 0, ptr %.anon118, align 8 br label %loop.cond119 - loop.cond119: ; preds = %loop.body121, %loop.exit116 %104 = load i64, ptr %.anon118, align 8 %gt120 = icmp ugt i64 6, %104 br i1 %gt120, label %loop.body121, label %loop.exit129 - loop.body121: ; preds = %loop.cond119 %105 = load i64, ptr %.anon118, align 8 store i64 %105, ptr %i122, align 8 @@ -459,10 +430,9 @@ loop.body121: ; preds = %loop.cond119 store %"any*" %111, ptr %ptradd126, align 16 %112 = call i64 @std.io.printfn(ptr %retparam127, ptr @.str.22, i64 6, ptr %varargslots125, i64 2) %113 = load i64, ptr %.anon118, align 8 - %add128 = add i64 %113, 1 - store i64 %add128, ptr %.anon118, align 8 + %addnuw128 = add nuw i64 %113, 1 + store i64 %addnuw128, ptr %.anon118, align 8 br label %loop.cond119 - loop.exit129: ; preds = %loop.cond119 ret void } diff --git a/test/test_suite/slices/slice_assign.c3t b/test/test_suite/slices/slice_assign.c3t index 493c86330..22346fbea 100644 --- a/test/test_suite/slices/slice_assign.c3t +++ b/test/test_suite/slices/slice_assign.c3t @@ -45,12 +45,10 @@ entry: store i32 52, ptr %ptradd5, align 4 store i64 0, ptr %.anon, align 8 br label %loop.cond - loop.cond: ; preds = %loop.body, %entry %0 = load i64, ptr %.anon, align 8 %gt = icmp ugt i64 8, %0 br i1 %gt, label %loop.body, label %loop.exit - loop.body: ; preds = %loop.cond %1 = load i64, ptr %.anon, align 8 %ptroffset = getelementptr inbounds [4 x i8], ptr %x, i64 %1 @@ -59,24 +57,20 @@ loop.body: ; preds = %loop.cond %3 = load i32, ptr %i, align 4 call void (ptr, ...) @printf(ptr @.str, i32 %3) %4 = load i64, ptr %.anon, align 8 - %add = add i64 %4, 1 - store i64 %add, ptr %.anon, align 8 + %addnuw = add nuw i64 %4, 1 + store i64 %addnuw, ptr %.anon, align 8 br label %loop.cond - loop.exit: ; preds = %loop.cond br label %cond - cond: ; preds = %assign, %loop.exit - %5 = phi i64 [ 0, %loop.exit ], [ %add7, %assign ] + %5 = phi i64 [ 0, %loop.exit ], [ %add, %assign ] %lt = icmp slt i64 %5, 8 br i1 %lt, label %assign, label %exit - assign: ; preds = %cond %ptroffset6 = getelementptr inbounds [4 x i8], ptr %x, i64 %5 store i32 123, ptr %ptroffset6, align 4 - %add7 = add i64 %5, 1 + %add = add i64 %5, 1 br label %cond - exit: ; preds = %cond ret void } diff --git a/test/test_suite/statements/custom_foreach_with_ref.c3t b/test/test_suite/statements/custom_foreach_with_ref.c3t index 74b435b4e..37c4db08b 100644 --- a/test/test_suite/statements/custom_foreach_with_ref.c3t +++ b/test/test_suite/statements/custom_foreach_with_ref.c3t @@ -138,35 +138,35 @@ entry: %i9 = alloca i32, align 4 %y10 = alloca ptr, align 8 %a11 = alloca i32, align 4 + %.anon16 = alloca i32, align 4 %.anon17 = alloca i32, align 4 - %.anon18 = alloca i32, align 4 - %i22 = alloca i32, align 4 - %y23 = alloca i32, align 4 - %a24 = alloca i32, align 4 + %i21 = alloca i32, align 4 + %y22 = alloca i32, align 4 + %a23 = alloca i32, align 4 + %.anon28 = alloca i32, align 4 %.anon29 = alloca i32, align 4 - %.anon30 = alloca i32, align 4 - %i34 = alloca i32, align 4 - %y35 = alloca i32, align 4 - %a36 = alloca i32, align 4 + %i33 = alloca i32, align 4 + %y34 = alloca i32, align 4 + %a35 = alloca i32, align 4 + %.anon40 = alloca i32, align 4 %.anon41 = alloca i32, align 4 - %.anon42 = alloca i32, align 4 - %i46 = alloca i32, align 4 - %y47 = alloca i32, align 4 - %a48 = alloca i32, align 4 - %.anon54 = alloca [5 x i32], align 16 - %.anon55 = alloca i64, align 8 - %i58 = alloca i64, align 8 - %y59 = alloca i32, align 4 - %.anon64 = alloca [5 x i32], align 16 - %.anon65 = alloca i64, align 8 - %i69 = alloca i64, align 8 - %y70 = alloca i32, align 4 - %.anon74 = alloca ptr, align 8 + %i45 = alloca i32, align 4 + %y46 = alloca i32, align 4 + %a47 = alloca i32, align 4 + %.anon53 = alloca [5 x i32], align 16 + %.anon54 = alloca i64, align 8 + %i57 = alloca i64, align 8 + %y58 = alloca i32, align 4 + %.anon62 = alloca [5 x i32], align 16 + %.anon63 = alloca i64, align 8 + %i67 = alloca i64, align 8 + %y68 = alloca i32, align 4 + %.anon72 = alloca ptr, align 8 %sretparam = alloca [5 x i32], align 4 - %.anon75 = alloca i64, align 8 - %i79 = alloca i64, align 8 - %y80 = alloca i32, align 4 - %y85 = alloca ptr, align 8 + %.anon73 = alloca i64, align 8 + %i77 = alloca i64, align 8 + %y78 = alloca i32, align 4 + %y83 = alloca ptr, align 8 call void @llvm.memcpy.p0.p0.i32(ptr align 4 %x, ptr align 4 @.__const.2, i32 12, i1 false) %ptradd = getelementptr inbounds i8, ptr %x, i64 4 %ptradd1 = getelementptr inbounds i8, ptr %x, i64 8 @@ -202,8 +202,8 @@ loop.body: ; preds = %loop.cond %13 = load i32, ptr %y, align 4 call void (ptr, ...) @printf(ptr @.str.4, i32 %12, i32 %13) %14 = load i32, ptr %.anon3, align 4 - %add = add i32 %14, 1 - store i32 %add, ptr %.anon3, align 4 + %addnsw = add nsw i32 %14, 1 + store i32 %addnsw, ptr %.anon3, align 4 br label %loop.cond loop.exit: ; preds = %loop.cond @@ -215,7 +215,7 @@ loop.cond6: ; preds = %loop.body8, %loop.e %15 = load i32, ptr %.anon5, align 4 %16 = load i32, ptr %.anon4, align 4 %lt7 = icmp slt i32 %15, %16 - br i1 %lt7, label %loop.body8, label %loop.exit16 + br i1 %lt7, label %loop.body8, label %loop.exit15 loop.body8: ; preds = %loop.cond6 %17 = load i32, ptr %.anon5, align 4 @@ -228,201 +228,201 @@ loop.body8: ; preds = %loop.cond6 store ptr %ptroffset13, ptr %y10, align 8 %20 = load ptr, ptr %y10, align 8 %21 = load i32, ptr %20, align 4 - %add14 = add i32 %21, 1 - store i32 %add14, ptr %20, align 4 + %add = add i32 %21, 1 + store i32 %add, ptr %20, align 4 %22 = load ptr, ptr %y10, align 8 %23 = load i32, ptr %i9, align 4 %24 = load i32, ptr %22, align 4 call void (ptr, ...) @printf(ptr @.str.5, i32 %23, i32 %24) %25 = load i32, ptr %.anon5, align 4 - %add15 = add i32 %25, 1 - store i32 %add15, ptr %.anon5, align 4 + %addnsw14 = add nsw i32 %25, 1 + store i32 %addnsw14, ptr %.anon5, align 4 br label %loop.cond6 -loop.exit16: ; preds = %loop.cond6 - store i32 3, ptr %.anon17, align 4 - store i32 0, ptr %.anon18, align 4 - br label %loop.cond19 - -loop.cond19: ; preds = %loop.body21, %loop.exit16 - %26 = load i32, ptr %.anon18, align 4 - %27 = load i32, ptr %.anon17, align 4 - %lt20 = icmp slt i32 %26, %27 - br i1 %lt20, label %loop.body21, label %loop.exit28 - -loop.body21: ; preds = %loop.cond19 - %28 = load i32, ptr %.anon18, align 4 - store i32 %28, ptr %i22, align 4 - %29 = load i32, ptr %.anon18, align 4 - store i32 %29, ptr %a24, align 4 - %30 = load i32, ptr %a24, align 4 - %sext25 = sext i32 %30 to i64 - %ptroffset26 = getelementptr inbounds [4 x i8], ptr %x, i64 %sext25 - %31 = load i32, ptr %ptroffset26, align 4 - store i32 %31, ptr %y23, align 4 - %32 = load i32, ptr %i22, align 4 - %33 = load i32, ptr %y23, align 4 +loop.exit15: ; preds = %loop.cond6 + store i32 3, ptr %.anon16, align 4 + store i32 0, ptr %.anon17, align 4 + br label %loop.cond18 + +loop.cond18: ; preds = %loop.body20, %loop.exit15 + %26 = load i32, ptr %.anon17, align 4 + %27 = load i32, ptr %.anon16, align 4 + %lt19 = icmp slt i32 %26, %27 + br i1 %lt19, label %loop.body20, label %loop.exit27 + +loop.body20: ; preds = %loop.cond18 + %28 = load i32, ptr %.anon17, align 4 + store i32 %28, ptr %i21, align 4 + %29 = load i32, ptr %.anon17, align 4 + store i32 %29, ptr %a23, align 4 + %30 = load i32, ptr %a23, align 4 + %sext24 = sext i32 %30 to i64 + %ptroffset25 = getelementptr inbounds [4 x i8], ptr %x, i64 %sext24 + %31 = load i32, ptr %ptroffset25, align 4 + store i32 %31, ptr %y22, align 4 + %32 = load i32, ptr %i21, align 4 + %33 = load i32, ptr %y22, align 4 call void (ptr, ...) @printf(ptr @.str.6, i32 %32, i32 %33) - %34 = load i32, ptr %.anon18, align 4 - %add27 = add i32 %34, 1 - store i32 %add27, ptr %.anon18, align 4 - br label %loop.cond19 - -loop.exit28: ; preds = %loop.cond19 - store i32 3, ptr %.anon29, align 4 - store i32 0, ptr %.anon30, align 4 - br label %loop.cond31 - -loop.cond31: ; preds = %loop.body33, %loop.exit28 - %35 = load i32, ptr %.anon30, align 4 - %36 = load i32, ptr %.anon29, align 4 - %lt32 = icmp slt i32 %35, %36 - br i1 %lt32, label %loop.body33, label %loop.exit40 - -loop.body33: ; preds = %loop.cond31 - %37 = load i32, ptr %.anon30, align 4 - store i32 %37, ptr %i34, align 4 - %38 = load i32, ptr %.anon30, align 4 - store i32 %38, ptr %a36, align 4 - %39 = load i32, ptr %a36, align 4 - %sext37 = sext i32 %39 to i64 - %ptroffset38 = getelementptr inbounds [4 x i8], ptr %x, i64 %sext37 - %40 = load i32, ptr %ptroffset38, align 4 - store i32 %40, ptr %y35, align 4 - %41 = load i32, ptr %i34, align 4 - %42 = load i32, ptr %y35, align 4 + %34 = load i32, ptr %.anon17, align 4 + %addnsw26 = add nsw i32 %34, 1 + store i32 %addnsw26, ptr %.anon17, align 4 + br label %loop.cond18 + +loop.exit27: ; preds = %loop.cond18 + store i32 3, ptr %.anon28, align 4 + store i32 0, ptr %.anon29, align 4 + br label %loop.cond30 + +loop.cond30: ; preds = %loop.body32, %loop.exit27 + %35 = load i32, ptr %.anon29, align 4 + %36 = load i32, ptr %.anon28, align 4 + %lt31 = icmp slt i32 %35, %36 + br i1 %lt31, label %loop.body32, label %loop.exit39 + +loop.body32: ; preds = %loop.cond30 + %37 = load i32, ptr %.anon29, align 4 + store i32 %37, ptr %i33, align 4 + %38 = load i32, ptr %.anon29, align 4 + store i32 %38, ptr %a35, align 4 + %39 = load i32, ptr %a35, align 4 + %sext36 = sext i32 %39 to i64 + %ptroffset37 = getelementptr inbounds [4 x i8], ptr %x, i64 %sext36 + %40 = load i32, ptr %ptroffset37, align 4 + store i32 %40, ptr %y34, align 4 + %41 = load i32, ptr %i33, align 4 + %42 = load i32, ptr %y34, align 4 call void (ptr, ...) @printf(ptr @.str.7, i32 %41, i32 %42) - %43 = load i32, ptr %.anon30, align 4 - %add39 = add i32 %43, 1 - store i32 %add39, ptr %.anon30, align 4 - br label %loop.cond31 - -loop.exit40: ; preds = %loop.cond31 - store i32 3, ptr %.anon41, align 4 - store i32 0, ptr %.anon42, align 4 - br label %loop.cond43 - -loop.cond43: ; preds = %loop.body45, %loop.exit40 - %44 = load i32, ptr %.anon42, align 4 - %45 = load i32, ptr %.anon41, align 4 - %lt44 = icmp slt i32 %44, %45 - br i1 %lt44, label %loop.body45, label %loop.exit53 - -loop.body45: ; preds = %loop.cond43 - %46 = load i32, ptr %.anon42, align 4 - store i32 %46, ptr %i46, align 4 - %47 = load i32, ptr %.anon42, align 4 - store i32 %47, ptr %a48, align 4 - %48 = load i32, ptr %a48, align 4 - %sext49 = sext i32 %48 to i64 - %ptroffset50 = getelementptr inbounds [4 x i8], ptr %x, i64 %sext49 - %49 = load i32, ptr %ptroffset50, align 4 - store i32 %49, ptr %y47, align 4 - %50 = load i32, ptr %i46, align 4 - %51 = load i32, ptr %y47, align 4 + %43 = load i32, ptr %.anon29, align 4 + %addnsw38 = add nsw i32 %43, 1 + store i32 %addnsw38, ptr %.anon29, align 4 + br label %loop.cond30 + +loop.exit39: ; preds = %loop.cond30 + store i32 3, ptr %.anon40, align 4 + store i32 0, ptr %.anon41, align 4 + br label %loop.cond42 + +loop.cond42: ; preds = %loop.body44, %loop.exit39 + %44 = load i32, ptr %.anon41, align 4 + %45 = load i32, ptr %.anon40, align 4 + %lt43 = icmp slt i32 %44, %45 + br i1 %lt43, label %loop.body44, label %loop.exit52 + +loop.body44: ; preds = %loop.cond42 + %46 = load i32, ptr %.anon41, align 4 + store i32 %46, ptr %i45, align 4 + %47 = load i32, ptr %.anon41, align 4 + store i32 %47, ptr %a47, align 4 + %48 = load i32, ptr %a47, align 4 + %sext48 = sext i32 %48 to i64 + %ptroffset49 = getelementptr inbounds [4 x i8], ptr %x, i64 %sext48 + %49 = load i32, ptr %ptroffset49, align 4 + store i32 %49, ptr %y46, align 4 + %50 = load i32, ptr %i45, align 4 + %51 = load i32, ptr %y46, align 4 call void (ptr, ...) @printf(ptr @.str.8, i32 %50, i32 %51) - %52 = load i32, ptr %i46, align 4 - %add51 = add i32 %52, 1 - store i32 %add51, ptr %i46, align 4 - %53 = load i32, ptr %.anon42, align 4 - %add52 = add i32 %53, 1 - store i32 %add52, ptr %.anon42, align 4 - br label %loop.cond43 - -loop.exit53: ; preds = %loop.cond43 - call void @llvm.memcpy.p0.p0.i32(ptr align 16 %.anon54, ptr align 16 @.__const.9, i32 20, i1 false) - store i64 0, ptr %.anon55, align 8 - br label %loop.cond56 - -loop.cond56: ; preds = %loop.body57, %loop.exit53 - %54 = load i64, ptr %.anon55, align 8 + %52 = load i32, ptr %i45, align 4 + %add50 = add i32 %52, 1 + store i32 %add50, ptr %i45, align 4 + %53 = load i32, ptr %.anon41, align 4 + %addnsw51 = add nsw i32 %53, 1 + store i32 %addnsw51, ptr %.anon41, align 4 + br label %loop.cond42 + +loop.exit52: ; preds = %loop.cond42 + call void @llvm.memcpy.p0.p0.i32(ptr align 16 %.anon53, ptr align 16 @.__const.9, i32 20, i1 false) + store i64 0, ptr %.anon54, align 8 + br label %loop.cond55 + +loop.cond55: ; preds = %loop.body56, %loop.exit52 + %54 = load i64, ptr %.anon54, align 8 %gt = icmp ugt i64 5, %54 - br i1 %gt, label %loop.body57, label %loop.exit63 - -loop.body57: ; preds = %loop.cond56 - %55 = load i64, ptr %.anon55, align 8 - store i64 %55, ptr %i58, align 8 - %56 = load i64, ptr %.anon55, align 8 - %ptroffset60 = getelementptr inbounds [4 x i8], ptr %.anon54, i64 %56 - %57 = load i32, ptr %ptroffset60, align 4 - store i32 %57, ptr %y59, align 4 - %58 = load i64, ptr %i58, align 8 - %59 = load i32, ptr %y59, align 4 + br i1 %gt, label %loop.body56, label %loop.exit61 + +loop.body56: ; preds = %loop.cond55 + %55 = load i64, ptr %.anon54, align 8 + store i64 %55, ptr %i57, align 8 + %56 = load i64, ptr %.anon54, align 8 + %ptroffset59 = getelementptr inbounds [4 x i8], ptr %.anon53, i64 %56 + %57 = load i32, ptr %ptroffset59, align 4 + store i32 %57, ptr %y58, align 4 + %58 = load i64, ptr %i57, align 8 + %59 = load i32, ptr %y58, align 4 call void (ptr, ...) @printf(ptr @.str.10, i64 %58, i32 %59) - %60 = load i64, ptr %i58, align 8 - %add61 = add i64 %60, 1 - store i64 %add61, ptr %i58, align 8 - %61 = load i64, ptr %.anon55, align 8 - %add62 = add i64 %61, 1 - store i64 %add62, ptr %.anon55, align 8 - br label %loop.cond56 - -loop.exit63: ; preds = %loop.cond56 - call void @foo.getFields(ptr sret([5 x i32]) align 4 %.anon64) - store i64 0, ptr %.anon65, align 8 - br label %loop.cond66 - -loop.cond66: ; preds = %loop.body68, %loop.exit63 - %62 = load i64, ptr %.anon65, align 8 - %gt67 = icmp ugt i64 5, %62 - br i1 %gt67, label %loop.body68, label %loop.exit73 - -loop.body68: ; preds = %loop.cond66 - %63 = load i64, ptr %.anon65, align 8 - store i64 %63, ptr %i69, align 8 - %64 = load i64, ptr %.anon65, align 8 - %ptroffset71 = getelementptr inbounds [4 x i8], ptr %.anon64, i64 %64 - %65 = load i32, ptr %ptroffset71, align 4 - store i32 %65, ptr %y70, align 4 - %66 = load i64, ptr %i69, align 8 - %67 = load i32, ptr %y70, align 4 + %60 = load i64, ptr %i57, align 8 + %add60 = add i64 %60, 1 + store i64 %add60, ptr %i57, align 8 + %61 = load i64, ptr %.anon54, align 8 + %addnuw = add nuw i64 %61, 1 + store i64 %addnuw, ptr %.anon54, align 8 + br label %loop.cond55 + +loop.exit61: ; preds = %loop.cond55 + call void @foo.getFields(ptr sret([5 x i32]) align 4 %.anon62) + store i64 0, ptr %.anon63, align 8 + br label %loop.cond64 + +loop.cond64: ; preds = %loop.body66, %loop.exit61 + %62 = load i64, ptr %.anon63, align 8 + %gt65 = icmp ugt i64 5, %62 + br i1 %gt65, label %loop.body66, label %loop.exit71 + +loop.body66: ; preds = %loop.cond64 + %63 = load i64, ptr %.anon63, align 8 + store i64 %63, ptr %i67, align 8 + %64 = load i64, ptr %.anon63, align 8 + %ptroffset69 = getelementptr inbounds [4 x i8], ptr %.anon62, i64 %64 + %65 = load i32, ptr %ptroffset69, align 4 + store i32 %65, ptr %y68, align 4 + %66 = load i64, ptr %i67, align 8 + %67 = load i32, ptr %y68, align 4 call void (ptr, ...) @printf(ptr @.str.11, i64 %66, i32 %67) - %68 = load i64, ptr %.anon65, align 8 - %add72 = add i64 %68, 1 - store i64 %add72, ptr %.anon65, align 8 - br label %loop.cond66 + %68 = load i64, ptr %.anon63, align 8 + %addnuw70 = add nuw i64 %68, 1 + store i64 %addnuw70, ptr %.anon63, align 8 + br label %loop.cond64 -loop.exit73: ; preds = %loop.cond66 +loop.exit71: ; preds = %loop.cond64 call void @foo.getFields(ptr sret([5 x i32]) align 4 %sretparam) - store ptr %sretparam, ptr %.anon74, align 8 - store i64 0, ptr %.anon75, align 8 - br label %loop.cond76 - -loop.cond76: ; preds = %loop.body78, %loop.exit73 - %69 = load i64, ptr %.anon75, align 8 - %gt77 = icmp ugt i64 5, %69 - br i1 %gt77, label %loop.body78, label %loop.exit83 - -loop.body78: ; preds = %loop.cond76 - %70 = load i64, ptr %.anon75, align 8 - store i64 %70, ptr %i79, align 8 - %71 = load ptr, ptr %.anon74, align 8 - %72 = load i64, ptr %.anon75, align 8 - %ptroffset81 = getelementptr inbounds [4 x i8], ptr %71, i64 %72 - %73 = load i32, ptr %ptroffset81, align 4 - store i32 %73, ptr %y80, align 4 - %74 = load i64, ptr %i79, align 8 - %75 = load i32, ptr %y80, align 4 + store ptr %sretparam, ptr %.anon72, align 8 + store i64 0, ptr %.anon73, align 8 + br label %loop.cond74 + +loop.cond74: ; preds = %loop.body76, %loop.exit71 + %69 = load i64, ptr %.anon73, align 8 + %gt75 = icmp ugt i64 5, %69 + br i1 %gt75, label %loop.body76, label %loop.exit81 + +loop.body76: ; preds = %loop.cond74 + %70 = load i64, ptr %.anon73, align 8 + store i64 %70, ptr %i77, align 8 + %71 = load ptr, ptr %.anon72, align 8 + %72 = load i64, ptr %.anon73, align 8 + %ptroffset79 = getelementptr inbounds [4 x i8], ptr %71, i64 %72 + %73 = load i32, ptr %ptroffset79, align 4 + store i32 %73, ptr %y78, align 4 + %74 = load i64, ptr %i77, align 8 + %75 = load i32, ptr %y78, align 4 call void (ptr, ...) @printf(ptr @.str.12, i64 %74, i32 %75) - %76 = load i64, ptr %.anon75, align 8 - %add82 = add i64 %76, 1 - store i64 %add82, ptr %.anon75, align 8 - br label %loop.cond76 + %76 = load i64, ptr %.anon73, align 8 + %addnuw80 = add nuw i64 %76, 1 + store i64 %addnuw80, ptr %.anon73, align 8 + br label %loop.cond74 -loop.exit83: ; preds = %loop.cond76 - %ptradd84 = getelementptr inbounds i8, ptr %x, i64 4 +loop.exit81: ; preds = %loop.cond74 + %ptradd82 = getelementptr inbounds i8, ptr %x, i64 4 %77 = load i32, ptr %x, align 4 - %78 = load i32, ptr %ptradd84, align 4 + %78 = load i32, ptr %ptradd82, align 4 call void (ptr, ...) @printf(ptr @.str.13, i32 %77, i32 %78) - %ptradd86 = getelementptr inbounds i8, ptr %x, i64 4 - store ptr %ptradd86, ptr %y85, align 8 - %79 = load ptr, ptr %y85, align 8 + %ptradd84 = getelementptr inbounds i8, ptr %x, i64 4 + store ptr %ptradd84, ptr %y83, align 8 + %79 = load ptr, ptr %y83, align 8 %80 = load i32, ptr %79, align 4 - %add87 = add i32 %80, 1 - store i32 %add87, ptr %79, align 4 - %ptradd88 = getelementptr inbounds i8, ptr %x, i64 4 + %add85 = add i32 %80, 1 + store i32 %add85, ptr %79, align 4 + %ptradd86 = getelementptr inbounds i8, ptr %x, i64 4 %81 = load i32, ptr %x, align 4 - %82 = load i32, ptr %ptradd88, align 4 + %82 = load i32, ptr %ptradd86, align 4 call void (ptr, ...) @printf(ptr @.str.14, i32 %81, i32 %82) ret void } diff --git a/test/test_suite/statements/foreach_break.c3t b/test/test_suite/statements/foreach_break.c3t index a46ddb94e..66bd8dcd7 100644 --- a/test/test_suite/statements/foreach_break.c3t +++ b/test/test_suite/statements/foreach_break.c3t @@ -64,8 +64,8 @@ if.exit4: ; preds = %if.exit loop.inc: ; preds = %if.exit4, %if.then3 %7 = load i64, ptr %.anon, align 8 - %add5 = add i64 %7, 1 - store i64 %add5, ptr %.anon, align 8 + %addnuw = add nuw i64 %7, 1 + store i64 %addnuw, ptr %.anon, align 8 br label %loop.cond loop.exit: ; preds = %if.then, %loop.cond diff --git a/test/test_suite/statements/foreach_common.c3t b/test/test_suite/statements/foreach_common.c3t index 6234d1044..3b60b4a67 100644 --- a/test/test_suite/statements/foreach_common.c3t +++ b/test/test_suite/statements/foreach_common.c3t @@ -111,8 +111,8 @@ loop.body: ; preds = %loop.cond %fpfpext = fpext float %3 to double call void (ptr, ...) @printf(ptr @.str, double %fpfpext) %4 = load i64, ptr %.anon, align 8 - %add = add i64 %4, 1 - store i64 %add, ptr %.anon, align 8 + %addnuw = add nuw i64 %4, 1 + store i64 %addnuw, ptr %.anon, align 8 br label %loop.cond loop.exit: ; preds = %loop.cond @@ -137,8 +137,8 @@ loop.body4: ; preds = %loop.cond2 %fpfpext7 = fpext float %10 to double call void (ptr, ...) @printf(ptr @.str.1, double %fpfpext7) %11 = load i64, ptr %.anon1, align 8 - %add8 = add i64 %11, 1 - store i64 %add8, ptr %.anon1, align 8 + %addnuw8 = add nuw i64 %11, 1 + store i64 %addnuw8, ptr %.anon1, align 8 br label %loop.cond2 loop.exit9: ; preds = %loop.cond2 @@ -159,8 +159,8 @@ loop.body13: ; preds = %loop.cond11 %fpfpext16 = fpext float %15 to double call void (ptr, ...) @printf(ptr @.str.2, double %fpfpext16) %16 = load i64, ptr %.anon10, align 8 - %add17 = add i64 %16, 1 - store i64 %add17, ptr %.anon10, align 8 + %addnuw17 = add nuw i64 %16, 1 + store i64 %addnuw17, ptr %.anon10, align 8 br label %loop.cond11 loop.exit18: ; preds = %loop.cond11 @@ -184,8 +184,8 @@ loop.body22: ; preds = %loop.cond20 %22 = load i64, ptr %i, align 8 call void (ptr, ...) @printf(ptr @.str.3, i64 %22, double %fpfpext25) %23 = load i64, ptr %.anon19, align 8 - %add26 = add i64 %23, 1 - store i64 %add26, ptr %.anon19, align 8 + %addnuw26 = add nuw i64 %23, 1 + store i64 %addnuw26, ptr %.anon19, align 8 br label %loop.cond20 loop.exit27: ; preds = %loop.cond20 @@ -211,8 +211,8 @@ loop.body31: ; preds = %loop.cond29 %29 = load double, ptr %a33, align 8 call void (ptr, ...) @printf(ptr @.str.4, i32 %zext, double %29) %30 = load i64, ptr %.anon28, align 8 - %add36 = add i64 %30, 1 - store i64 %add36, ptr %.anon28, align 8 + %addnuw36 = add nuw i64 %30, 1 + store i64 %addnuw36, ptr %.anon28, align 8 br label %loop.cond29 loop.exit37: ; preds = %loop.cond29 @@ -233,8 +233,8 @@ loop.body41: ; preds = %loop.cond39 %34 = load double, ptr %a42, align 8 call void (ptr, ...) @printf(ptr @.str.5, double %34) %35 = load i64, ptr %.anon38, align 8 - %add45 = add i64 %35, 1 - store i64 %add45, ptr %.anon38, align 8 + %addnuw45 = add nuw i64 %35, 1 + store i64 %addnuw45, ptr %.anon38, align 8 br label %loop.cond39 loop.exit46: ; preds = %loop.cond39 @@ -257,8 +257,8 @@ loop.body50: ; preds = %loop.cond49 %fpfpext52 = fpext float %41 to double call void (ptr, ...) @printf(ptr @.str.6, double %fpfpext52) %42 = load i64, ptr %.anon48, align 8 - %add53 = add i64 %42, 1 - store i64 %add53, ptr %.anon48, align 8 + %addnuw53 = add nuw i64 %42, 1 + store i64 %addnuw53, ptr %.anon48, align 8 br label %loop.cond49 loop.exit54: ; preds = %loop.cond49 @@ -285,8 +285,8 @@ loop.body59: ; preds = %loop.cond57 %fpfpext63 = fpext float %49 to double call void (ptr, ...) @printf(ptr @.str.7, double %fpfpext63) %50 = load i64, ptr %.anon56, align 8 - %add64 = add i64 %50, 1 - store i64 %add64, ptr %.anon56, align 8 + %addnuw64 = add nuw i64 %50, 1 + store i64 %addnuw64, ptr %.anon56, align 8 br label %loop.cond57 loop.exit65: ; preds = %loop.cond57 @@ -312,8 +312,8 @@ loop.body70: ; preds = %loop.cond68 %58 = load i64, ptr %i71, align 8 call void (ptr, ...) @printf(ptr @.str.8, i64 %58, double %fpfpext73) %59 = load i64, ptr %.anon67, align 8 - %add74 = add i64 %59, 1 - store i64 %add74, ptr %.anon67, align 8 + %addnuw74 = add nuw i64 %59, 1 + store i64 %addnuw74, ptr %.anon67, align 8 br label %loop.cond68 loop.exit75: ; preds = %loop.cond68 @@ -341,8 +341,8 @@ loop.body80: ; preds = %loop.cond78 %67 = load double, ptr %a83, align 8 call void (ptr, ...) @printf(ptr @.str.9, i32 %zext85, double %67) %68 = load i64, ptr %.anon77, align 8 - %add86 = add i64 %68, 1 - store i64 %add86, ptr %.anon77, align 8 + %addnuw86 = add nuw i64 %68, 1 + store i64 %addnuw86, ptr %.anon77, align 8 br label %loop.cond78 loop.exit87: ; preds = %loop.cond78 @@ -365,8 +365,8 @@ loop.body92: ; preds = %loop.cond90 %74 = load double, ptr %a93, align 8 call void (ptr, ...) @printf(ptr @.str.10, double %74) %75 = load i64, ptr %.anon89, align 8 - %add95 = add i64 %75, 1 - store i64 %add95, ptr %.anon89, align 8 + %addnuw95 = add nuw i64 %75, 1 + store i64 %addnuw95, ptr %.anon89, align 8 br label %loop.cond90 loop.exit96: ; preds = %loop.cond90 diff --git a/test/test_suite/statements/foreach_more_implementations.c3t b/test/test_suite/statements/foreach_more_implementations.c3t index 848bf8f67..79d9ffca4 100644 --- a/test/test_suite/statements/foreach_more_implementations.c3t +++ b/test/test_suite/statements/foreach_more_implementations.c3t @@ -51,13 +51,13 @@ entry: %element = alloca i64, align 8 %varargslots = alloca [1 x %"any*"], align 16 %retparam = alloca i64, align 8 - %.anon4 = alloca i64, align 8 - %vector5 = alloca %Vector, align 8 - %.anon6 = alloca i64, align 8 + %.anon3 = alloca i64, align 8 + %vector4 = alloca %Vector, align 8 + %.anon5 = alloca i64, align 8 %i = alloca i32, align 4 - %element10 = alloca i64, align 8 - %varargslots13 = alloca [1 x %"any*"], align 16 - %retparam14 = alloca i64, align 8 + %element9 = alloca i64, align 8 + %varargslots12 = alloca [1 x %"any*"], align 16 + %retparam13 = alloca i64, align 8 call void @llvm.memcpy.p0.p0.i32(ptr align 4 %x, ptr align 4 @.__const, i32 8, i1 false) store i64 2, ptr %v, align 8 %ptradd = getelementptr inbounds i8, ptr %v, i64 8 @@ -92,41 +92,41 @@ loop.body: ; preds = %loop.cond %add = add i32 %11, 2 store i32 %add, ptr %10, align 4 %12 = load i64, ptr %.anon1, align 8 - %add3 = add i64 %12, 1 - store i64 %add3, ptr %.anon1, align 8 + %addnuw = add nuw i64 %12, 1 + store i64 %addnuw, ptr %.anon1, align 8 br label %loop.cond loop.exit: ; preds = %loop.cond - call void @llvm.memcpy.p0.p0.i32(ptr align 8 %vector5, ptr align 8 %v, i32 16, i1 false) - %13 = load i64, ptr %vector5, align 8 - store i64 %13, ptr %.anon4, align 8 - store i64 0, ptr %.anon6, align 8 - br label %loop.cond7 + call void @llvm.memcpy.p0.p0.i32(ptr align 8 %vector4, ptr align 8 %v, i32 16, i1 false) + %13 = load i64, ptr %vector4, align 8 + store i64 %13, ptr %.anon3, align 8 + store i64 0, ptr %.anon5, align 8 + br label %loop.cond6 -loop.cond7: ; preds = %loop.body9, %loop.exit - %14 = load i64, ptr %.anon6, align 8 - %15 = load i64, ptr %.anon4, align 8 - %lt8 = icmp ult i64 %14, %15 - br i1 %lt8, label %loop.body9, label %loop.exit16 +loop.cond6: ; preds = %loop.body8, %loop.exit + %14 = load i64, ptr %.anon5, align 8 + %15 = load i64, ptr %.anon3, align 8 + %lt7 = icmp ult i64 %14, %15 + br i1 %lt7, label %loop.body8, label %loop.exit15 -loop.body9: ; preds = %loop.cond7 - %16 = load i64, ptr %.anon6, align 8 - store i64 %16, ptr %element10, align 8 - %ptradd11 = getelementptr inbounds i8, ptr %v, i64 8 - %17 = load ptr, ptr %ptradd11, align 8 - %18 = load i64, ptr %element10, align 8 - %ptroffset12 = getelementptr inbounds [4 x i8], ptr %17, i64 %18 - %19 = load i32, ptr %ptroffset12, align 4 +loop.body8: ; preds = %loop.cond6 + %16 = load i64, ptr %.anon5, align 8 + store i64 %16, ptr %element9, align 8 + %ptradd10 = getelementptr inbounds i8, ptr %v, i64 8 + %17 = load ptr, ptr %ptradd10, align 8 + %18 = load i64, ptr %element9, align 8 + %ptroffset11 = getelementptr inbounds [4 x i8], ptr %17, i64 %18 + %19 = load i32, ptr %ptroffset11, align 4 store i32 %19, ptr %i, align 4 %20 = insertvalue %"any*" undef, ptr %i, 0 %21 = insertvalue %"any*" %20, i64 ptrtoint (ptr @"$ct.int" to i64), 1 - store %"any*" %21, ptr %varargslots13, align 16 - %22 = call i64 @std.io.printf(ptr %retparam14, ptr @.str.1, i64 3, ptr %varargslots13, i64 1) - %23 = load i64, ptr %.anon6, align 8 - %add15 = add i64 %23, 1 - store i64 %add15, ptr %.anon6, align 8 - br label %loop.cond7 + store %"any*" %21, ptr %varargslots12, align 16 + %22 = call i64 @std.io.printf(ptr %retparam13, ptr @.str.1, i64 3, ptr %varargslots12, i64 1) + %23 = load i64, ptr %.anon5, align 8 + %addnuw14 = add nuw i64 %23, 1 + store i64 %addnuw14, ptr %.anon5, align 8 + br label %loop.cond6 -loop.exit16: ; preds = %loop.cond7 +loop.exit15: ; preds = %loop.cond6 ret void } \ No newline at end of file diff --git a/test/test_suite/statements/foreach_r_break.c3t b/test/test_suite/statements/foreach_r_break.c3t index fd3115148..b76700d4e 100644 --- a/test/test_suite/statements/foreach_r_break.c3t +++ b/test/test_suite/statements/foreach_r_break.c3t @@ -39,8 +39,8 @@ loop.cond: ; preds = %if.exit4, %if.then3 loop.body: ; preds = %loop.cond %1 = load i64, ptr %.anon, align 8 - %sub = sub i64 %1, 1 - store i64 %sub, ptr %.anon, align 8 + %subnuw = sub nuw i64 %1, 1 + store i64 %subnuw, ptr %.anon, align 8 %2 = load i64, ptr %.anon, align 8 %ptroffset = getelementptr inbounds [4 x i8], ptr %x, i64 %2 %3 = load i32, ptr %ptroffset, align 4 diff --git a/test/test_suite/statements/foreach_r_common.c3t b/test/test_suite/statements/foreach_r_common.c3t index 345be41fa..32e301478 100644 --- a/test/test_suite/statements/foreach_r_common.c3t +++ b/test/test_suite/statements/foreach_r_common.c3t @@ -99,8 +99,8 @@ loop.cond: ; preds = %loop.body, %entry loop.body: ; preds = %loop.cond %1 = load i64, ptr %.anon, align 8 - %sub = sub i64 %1, 1 - store i64 %sub, ptr %.anon, align 8 + %subnuw = sub nuw i64 %1, 1 + store i64 %subnuw, ptr %.anon, align 8 %2 = load i64, ptr %.anon, align 8 %ptroffset = getelementptr inbounds [4 x i8], ptr %foo, i64 %2 %3 = load float, ptr %ptroffset, align 4 @@ -121,8 +121,8 @@ loop.cond2: ; preds = %loop.body4, %loop.e loop.body4: ; preds = %loop.cond2 %6 = load i64, ptr %.anon1, align 8 - %sub5 = sub i64 %6, 1 - store i64 %sub5, ptr %.anon1, align 8 + %subnuw5 = sub nuw i64 %6, 1 + store i64 %subnuw5, ptr %.anon1, align 8 %7 = load i64, ptr %.anon1, align 8 %ptroffset7 = getelementptr inbounds [4 x i8], ptr %foo, i64 %7 store ptr %ptroffset7, ptr %a6, align 8 @@ -147,8 +147,8 @@ loop.cond11: ; preds = %loop.body13, %loop. loop.body13: ; preds = %loop.cond11 %13 = load i64, ptr %.anon10, align 8 - %sub14 = sub i64 %13, 1 - store i64 %sub14, ptr %.anon10, align 8 + %subnuw14 = sub nuw i64 %13, 1 + store i64 %subnuw14, ptr %.anon10, align 8 %14 = load i64, ptr %.anon10, align 8 %ptroffset16 = getelementptr inbounds [4 x i8], ptr %foo, i64 %14 store ptr %ptroffset16, ptr %a15, align 8 @@ -169,8 +169,8 @@ loop.cond20: ; preds = %loop.body22, %loop. loop.body22: ; preds = %loop.cond20 %18 = load i64, ptr %.anon19, align 8 - %sub23 = sub i64 %18, 1 - store i64 %sub23, ptr %.anon19, align 8 + %subnuw23 = sub nuw i64 %18, 1 + store i64 %subnuw23, ptr %.anon19, align 8 %19 = load i64, ptr %.anon19, align 8 store i64 %19, ptr %i, align 8 %20 = load i64, ptr %.anon19, align 8 @@ -194,8 +194,8 @@ loop.cond29: ; preds = %loop.body31, %loop. loop.body31: ; preds = %loop.cond29 %25 = load i64, ptr %.anon28, align 8 - %sub32 = sub i64 %25, 1 - store i64 %sub32, ptr %.anon28, align 8 + %subnuw32 = sub nuw i64 %25, 1 + store i64 %subnuw32, ptr %.anon28, align 8 %26 = load i64, ptr %.anon28, align 8 %trunc = trunc i64 %26 to i8 store i8 %trunc, ptr %i33, align 1 @@ -221,8 +221,8 @@ loop.cond39: ; preds = %loop.body41, %loop. loop.body41: ; preds = %loop.cond39 %32 = load i64, ptr %.anon38, align 8 - %sub42 = sub i64 %32, 1 - store i64 %sub42, ptr %.anon38, align 8 + %subnuw42 = sub nuw i64 %32, 1 + store i64 %subnuw42, ptr %.anon38, align 8 %33 = load i64, ptr %.anon38, align 8 %ptroffset44 = getelementptr inbounds [4 x i8], ptr %foo, i64 %33 %34 = load float, ptr %ptroffset44, align 4 @@ -243,8 +243,8 @@ loop.cond48: ; preds = %loop.body50, %loop. loop.body50: ; preds = %loop.cond48 %37 = load i64, ptr %.anon47, align 8 - %sub51 = sub i64 %37, 1 - store i64 %sub51, ptr %.anon47, align 8 + %subnuw51 = sub nuw i64 %37, 1 + store i64 %subnuw51, ptr %.anon47, align 8 %38 = load <3 x float>, ptr %foo2, align 16 %39 = load i64, ptr %.anon47, align 8 %40 = extractelement <3 x float> %38, i64 %39 @@ -265,8 +265,8 @@ loop.cond56: ; preds = %loop.body58, %loop. loop.body58: ; preds = %loop.cond56 %43 = load i64, ptr %.anon55, align 8 - %sub59 = sub i64 %43, 1 - store i64 %sub59, ptr %.anon55, align 8 + %subnuw59 = sub nuw i64 %43, 1 + store i64 %subnuw59, ptr %.anon55, align 8 %44 = load i64, ptr %.anon55, align 8 %ptroffset61 = getelementptr inbounds [4 x i8], ptr %foo2, i64 %44 store ptr %ptroffset61, ptr %a60, align 8 @@ -291,8 +291,8 @@ loop.cond66: ; preds = %loop.body68, %loop. loop.body68: ; preds = %loop.cond66 %50 = load i64, ptr %.anon65, align 8 - %sub69 = sub i64 %50, 1 - store i64 %sub69, ptr %.anon65, align 8 + %subnuw69 = sub nuw i64 %50, 1 + store i64 %subnuw69, ptr %.anon65, align 8 %51 = load i64, ptr %.anon65, align 8 store i64 %51, ptr %i70, align 8 %52 = load <3 x float>, ptr %foo2, align 16 @@ -316,8 +316,8 @@ loop.cond75: ; preds = %loop.body77, %loop. loop.body77: ; preds = %loop.cond75 %58 = load i64, ptr %.anon74, align 8 - %sub78 = sub i64 %58, 1 - store i64 %sub78, ptr %.anon74, align 8 + %subnuw78 = sub nuw i64 %58, 1 + store i64 %subnuw78, ptr %.anon74, align 8 %59 = load i64, ptr %.anon74, align 8 %trunc80 = trunc i64 %59 to i8 store i8 %trunc80, ptr %i79, align 1 @@ -343,8 +343,8 @@ loop.cond86: ; preds = %loop.body88, %loop. loop.body88: ; preds = %loop.cond86 %66 = load i64, ptr %.anon85, align 8 - %sub89 = sub i64 %66, 1 - store i64 %sub89, ptr %.anon85, align 8 + %subnuw89 = sub nuw i64 %66, 1 + store i64 %subnuw89, ptr %.anon85, align 8 %67 = load <3 x float>, ptr %foo2, align 16 %68 = load i64, ptr %.anon85, align 8 %69 = extractelement <3 x float> %67, i64 %68 diff --git a/test/test_suite/statements/foreach_r_custom.c3t b/test/test_suite/statements/foreach_r_custom.c3t index c55f39bad..a5094b26f 100644 --- a/test/test_suite/statements/foreach_r_custom.c3t +++ b/test/test_suite/statements/foreach_r_custom.c3t @@ -57,8 +57,8 @@ loop.cond: ; preds = %entry loop.body: ; preds = %loop.cond %4 = load i64, ptr %.anon, align 8 - %sub = sub i64 %4, 1 - store i64 %sub, ptr %.anon, align 8 + %subnuw = sub nuw i64 %4, 1 + store i64 %subnuw, ptr %.anon, align 8 %5 = load i64, ptr %.anon, align 8 store i64 %5, ptr %index, align 8 %6 = load ptr, ptr %x, align 8 diff --git a/test/test_suite/statements/foreach_r_custom_macro.c3t b/test/test_suite/statements/foreach_r_custom_macro.c3t index 466359243..fc5738b10 100644 --- a/test/test_suite/statements/foreach_r_custom_macro.c3t +++ b/test/test_suite/statements/foreach_r_custom_macro.c3t @@ -32,7 +32,20 @@ extern fn int printf(char *fmt, ...); /* #expect: test.ll +; ModuleID = 'test' +source_filename = "test" +target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-apple-macosx10.13.0" +%.introspect = type { i8, i64, ptr, i64, i64, i64, [0 x i64] } +%Foo = type { %"int[]" } +%"int[]" = type { ptr, i64 } + +@"$ct.test.Foo" = linkonce global %.introspect { i8 10, i64 0, ptr null, i64 16, i64 0, i64 1, [0 x i64] zeroinitializer }, align 8 +@.__const = private unnamed_addr constant [3 x i32] [i32 1, i32 3, i32 10], align 4 +@.str = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1 + +; Function Attrs: nounwind uwtable define void @test.main() #0 { entry: %i = alloca [3 x i32], align 4 @@ -56,8 +69,8 @@ loop.cond: ; preds = %entry loop.body: ; preds = %loop.cond %4 = load i64, ptr %.anon, align 8 - %sub = sub i64 %4, 1 - store i64 %sub, ptr %.anon, align 8 + %subnuw = sub nuw i64 %4, 1 + store i64 %subnuw, ptr %.anon, align 8 %5 = load i64, ptr %.anon, align 8 store i64 %5, ptr %index, align 8 %6 = load ptr, ptr %x, align 8 @@ -76,12 +89,18 @@ loop.exit: ; preds = %loop.body1, %loop.c ret void } -; Function Attrs: +; Function Attrs: nounwind uwtable declare i32 @printf(ptr, ...) #0 -; Function Attrs: +; Function Attrs: nounwind uwtable define i32 @main(i32 %0, ptr %1) #0 { entry: call void @test.main() ret i32 0 } + +; Function Attrs: argmemonly nocallback nofree nounwind willreturn +declare void @llvm.memcpy.p0.p0.i32(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i32, i1 immarg) #1 + +attributes #0 = { nounwind uwtable "no-trapping-math"="true" "stack-protector-buffer-size"="8" } +attributes #1 = { argmemonly nocallback nofree nounwind willreturn } \ No newline at end of file diff --git a/test/test_suite/switch/switch_in_defer_macro.c3t b/test/test_suite/switch/switch_in_defer_macro.c3t index 4dcd33131..bda83e598 100644 --- a/test/test_suite/switch/switch_in_defer_macro.c3t +++ b/test/test_suite/switch/switch_in_defer_macro.c3t @@ -831,8 +831,8 @@ noerr_block13: ; preds = %after_check11 %eq = icmp eq i8 %15, 1 call void @llvm.assume(i1 %eq) %16 = load i64, ptr %.anon1, align 8 - %add = add i64 %16, 1 - store i64 %add, ptr %.anon1, align 8 + %addnuw = add nuw i64 %16, 1 + store i64 %addnuw, ptr %.anon1, align 8 br label %loop.cond loop.exit: ; preds = %loop.cond diff --git a/test/test_suite/vector/vector_init_regression.c3t b/test/test_suite/vector/vector_init_regression.c3t index 5e389ac21..d6120d4e8 100644 --- a/test/test_suite/vector/vector_init_regression.c3t +++ b/test/test_suite/vector/vector_init_regression.c3t @@ -372,8 +372,8 @@ loop.body: ; preds = %loop.cond %fpfpext89 = fpext float %152 to double %153 = call i32 (ptr, ...) @printf(ptr @.str, double %fpfpext86, double %fpfpext87, double %fpfpext88, double %fpfpext89) %154 = load i64, ptr %.anon, align 8 - %add = add i64 %154, 1 - store i64 %add, ptr %.anon, align 8 + %addnuw = add nuw i64 %154, 1 + store i64 %addnuw, ptr %.anon, align 8 br label %loop.cond loop.exit: ; preds = %loop.cond @@ -405,8 +405,8 @@ loop.body93: ; preds = %loop.cond91 %fpfpext99 = fpext float %166 to double %167 = call i32 (ptr, ...) @printf(ptr @.str.2, double %fpfpext96, double %fpfpext97, double %fpfpext98, double %fpfpext99) %168 = load i64, ptr %.anon90, align 8 - %add100 = add i64 %168, 1 - store i64 %add100, ptr %.anon90, align 8 + %addnuw100 = add nuw i64 %168, 1 + store i64 %addnuw100, ptr %.anon90, align 8 br label %loop.cond91 loop.exit101: ; preds = %loop.cond91