From 2c573c8a15ac568b35498a44148a28455ea0451f Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Fri, 17 Apr 2020 09:34:29 +0200 Subject: [PATCH] Fixed accidental uses of global context. --- src/compiler/llvm_codegen_expr.c | 6 +++--- src/compiler/llvm_codegen_function.c | 2 +- src/compiler/target.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/compiler/llvm_codegen_expr.c b/src/compiler/llvm_codegen_expr.c index b39cbf670..0f19e8231 100644 --- a/src/compiler/llvm_codegen_expr.c +++ b/src/compiler/llvm_codegen_expr.c @@ -84,7 +84,7 @@ static inline LLVMValueRef gencontext_emit_subscript_addr_from_value(GenContext case TYPE_ARRAY: // TODO insert trap on overflow. { - LLVMValueRef zero = LLVMConstInt(LLVMIntType(32), 0, false); + LLVMValueRef zero = LLVMConstInt(llvm_type(type_int), 0, false); LLVMValueRef indices[2] = { zero, index, @@ -119,7 +119,7 @@ static inline LLVMValueRef gencontext_emit_subscript_addr(GenContext *context, E case TYPE_ARRAY: { // TODO insert trap on overflow. - LLVMValueRef zero = LLVMConstInt(LLVMIntType(32), 0, false); + LLVMValueRef zero = LLVMConstInt(llvm_type(type_int), 0, false); LLVMValueRef indices[2] = { zero, index_value, @@ -371,7 +371,7 @@ static inline LLVMValueRef gencontext_emit_initializer_list_expr(GenContext *co case DESIGNATED_SUBSCRIPT: { // TODO range, more arrays - LLVMValueRef zero = LLVMConstInt(LLVMIntType(32), 0, false); + LLVMValueRef zero = LLVMConstInt(llvm_type(type_int), 0, false); LLVMValueRef index = gencontext_emit_expr(context, path->index_expr); LLVMValueRef indices[2] = { zero, diff --git a/src/compiler/llvm_codegen_function.c b/src/compiler/llvm_codegen_function.c index cb8d03aab..17539f60a 100644 --- a/src/compiler/llvm_codegen_function.c +++ b/src/compiler/llvm_codegen_function.c @@ -109,7 +109,7 @@ void gencontext_emit_function_body(GenContext *context, Decl *decl) context->current_block = entry; context->current_block_is_target = true; context->expr_block_exit = NULL; - context->builder = LLVMCreateBuilder(); + context->builder = LLVMCreateBuilderInContext(context->context); LLVMPositionBuilderAtEnd(context->builder, entry); LLVMValueRef alloca_point = LLVMBuildAlloca(context->builder, LLVMInt32TypeInContext(context->context), "alloca_point"); diff --git a/src/compiler/target.c b/src/compiler/target.c index 58a7a3582..5f7ea2b44 100644 --- a/src/compiler/target.c +++ b/src/compiler/target.c @@ -124,7 +124,7 @@ void target_setup() build_target.width_c_int = os_target_c_type_bits(build_target.os, build_target.arch, CTYPE_INT); build_target.width_c_long = os_target_c_type_bits(build_target.os, build_target.arch, CTYPE_LONG); build_target.width_c_long_long = os_target_c_type_bits(build_target.os, build_target.arch, CTYPE_LONG_LONG); - + LLVMContextDispose(context); builtin_setup(&build_target); }