Change llvm void pointer to i8 pointer to avoid assert failed (#250)

This commit is contained in:
wenyongh 2020-05-08 13:40:04 +08:00 committed by GitHub
parent 44ccfd20ad
commit 7abd1ca813
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 2 additions and 50 deletions

View File

@ -192,7 +192,6 @@ typedef enum FloatArithmetic {
#define INT64_PTR_TYPE comp_ctx->basic_types.int64_ptr_type
#define F32_PTR_TYPE comp_ctx->basic_types.float32_ptr_type
#define F64_PTR_TYPE comp_ctx->basic_types.float64_ptr_type
#define VOID_PTR_TYPE comp_ctx->basic_types.void_ptr_type
#define I32_CONST(v) LLVMConstInt(I32_TYPE, v, true)
#define I64_CONST(v) LLVMConstInt(I64_TYPE, v, true)

View File

@ -583,7 +583,7 @@ aot_compile_op_memory_grow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
/* To be simple, call wasm_runtime_set_exception() no matter
enlarge success or not */
param_types[1] = VOID_PTR_TYPE;
param_types[1] = INT8_PTR_TYPE;
ret_type = VOID_TYPE;
if (!(func_type = LLVMFunctionType(ret_type, param_types, 2, false))) {
aot_set_last_error("llvm add function type failed.");
@ -614,7 +614,7 @@ aot_compile_op_memory_grow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
}
/* Call function wasm_runtime_set_exception(aot_inst, NULL) */
param_values[1] = LLVMConstNull(VOID_PTR_TYPE);
param_values[1] = LLVMConstNull(INT8_PTR_TYPE);
CHECK_LLVM_CONST(param_values[1]);
if (!(LLVMBuildCall(comp_ctx->builder, func, param_values, 2, ""))) {
aot_set_last_error("llvm build call failed.");

View File

@ -359,45 +359,6 @@ create_cur_exception(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
return true;
}
static bool
create_func_ptrs(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
{
LLVMValueRef offset, func_ptrs_ptr;
LLVMTypeRef void_ptr_type;
offset = I32_CONST(offsetof(AOTModuleInstance, func_ptrs.ptr));
func_ptrs_ptr = LLVMBuildInBoundsGEP(comp_ctx->builder,
func_ctx->aot_inst,
&offset, 1,
"func_ptrs_ptr");
if (!func_ptrs_ptr) {
aot_set_last_error("llvm build in bounds gep failed.");
return false;
}
if (!(void_ptr_type = LLVMPointerType(VOID_PTR_TYPE, 0))
|| !(void_ptr_type = LLVMPointerType(void_ptr_type, 0))) {
aot_set_last_error("llvm get pointer type failed.");
return false;
}
func_ctx->func_ptrs = LLVMBuildBitCast(comp_ctx->builder, func_ptrs_ptr,
void_ptr_type, "func_ptrs_tmp");
if (!func_ctx->func_ptrs) {
aot_set_last_error("llvm build bit cast failed.");
return false;
}
func_ctx->func_ptrs = LLVMBuildLoad(comp_ctx->builder, func_ctx->func_ptrs,
"func_ptrs");
if (!func_ctx->func_ptrs) {
aot_set_last_error("llvm build load failed.");
return false;
}
return true;
}
static bool
create_func_type_indexes(AOTCompContext *comp_ctx,
AOTFuncContext *func_ctx)
@ -636,10 +597,6 @@ aot_create_func_context(AOTCompData *comp_data, AOTCompContext *comp_ctx,
if (!create_cur_exception(comp_ctx, func_ctx))
goto fail;
/* Load function pointers */
if (!create_func_ptrs(comp_ctx, func_ctx))
goto fail;
/* Load function type indexes */
if (!create_func_type_indexes(comp_ctx, func_ctx))
goto fail;
@ -723,7 +680,6 @@ aot_set_llvm_basic_types(AOTLLVMTypes *basic_types, LLVMContextRef context)
basic_types->int64_ptr_type = LLVMPointerType(basic_types->int64_type, 0);
basic_types->float32_ptr_type = LLVMPointerType(basic_types->float32_type, 0);
basic_types->float64_ptr_type = LLVMPointerType(basic_types->float64_type, 0);
basic_types->void_ptr_type = LLVMPointerType(basic_types->void_type, 0);
return (basic_types->int8_ptr_type
&& basic_types->int16_ptr_type
@ -731,7 +687,6 @@ aot_set_llvm_basic_types(AOTLLVMTypes *basic_types, LLVMContextRef context)
&& basic_types->int64_ptr_type
&& basic_types->float32_ptr_type
&& basic_types->float64_ptr_type
&& basic_types->void_ptr_type
&& basic_types->meta_data_type) ? true : false;
}

View File

@ -122,7 +122,6 @@ typedef struct AOTFuncContext {
LLVMBasicBlockRef got_exception_block;
LLVMBasicBlockRef func_return_block;
LLVMValueRef exception_id_phi;
LLVMValueRef func_ptrs;
LLVMValueRef func_type_indexes;
LLVMValueRef locals[1];
} AOTFuncContext;
@ -143,7 +142,6 @@ typedef struct AOTLLVMTypes {
LLVMTypeRef int64_ptr_type;
LLVMTypeRef float32_ptr_type;
LLVMTypeRef float64_ptr_type;
LLVMTypeRef void_ptr_type;
LLVMTypeRef meta_data_type;
} AOTLLVMTypes;