Fixed accidental uses of global context.

This commit is contained in:
Christoffer Lerno
2020-04-17 09:34:29 +02:00
committed by Christoffer Lerno
parent 6117a1be7c
commit 2c573c8a15
3 changed files with 5 additions and 5 deletions

View File

@@ -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,

View File

@@ -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");

View File

@@ -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);
}