Эх сурвалжийг харах

GC AOT: Fix compile warnings and errors (#2623)

Wenyong Huang 2 жил өмнө
parent
commit
ac426ee331

+ 1 - 1
.github/workflows/compilation_on_android_ubuntu.yml

@@ -65,7 +65,7 @@ env:
   THREADS_TEST_OPTIONS: "-s spec -b -p -P"
   X86_32_TARGET_TEST_OPTIONS: "-m x86_32 -P"
   WASI_TEST_OPTIONS: "-s wasi_certification -w -S"
-  WAMR_COMPILER_TEST_OPTIONS: "-s wamr_compiler -b -P"
+  WAMR_COMPILER_TEST_OPTIONS: "-s wamr_compiler -S -b -P"
   GC_TEST_OPTIONS: "-s spec -G -b -P"
 
 jobs:

+ 1 - 1
core/iwasm/aot/aot_loader.c

@@ -1251,7 +1251,7 @@ destroy_types(AOTType **types, uint32 count)
             else if (types[i]->type_flag == WASM_TYPE_STRUCT) {
                 AOTStructType *struct_type = (AOTStructType *)types[i];
                 if (struct_type->ref_type_maps != NULL) {
-                    bh_assert(func_type->ref_type_map_count > 0);
+                    bh_assert(struct_type->ref_type_map_count > 0);
                     wasm_runtime_free(struct_type->ref_type_maps);
                 }
             }

+ 2 - 2
core/iwasm/aot/aot_runtime.c

@@ -1125,7 +1125,7 @@ aot_instantiate(AOTModule *module, AOTModuleInstance *parent,
         (uint64)module->memory_count * sizeof(AOTMemoryInstance);
     uint64 total_size, table_size = 0;
     uint8 *p;
-    uint32 i, j, extra_info_offset;
+    uint32 i, extra_info_offset;
     const bool is_sub_inst = parent != NULL;
 #if WASM_ENABLE_MULTI_MODULE != 0
     bool ret = false;
@@ -1290,7 +1290,7 @@ aot_instantiate(AOTModule *module, AOTModuleInstance *parent,
         AOTTableInstance *table;
         table_elem_type_t *table_data;
         uint8 tbl_elem_type;
-        uint32 tbl_init_size, tbl_max_size;
+        uint32 tbl_init_size, tbl_max_size, j;
         WASMRefType *tbl_elem_ref_type;
 
         bh_assert(table_init_data);

+ 1 - 0
core/iwasm/common/gc/gc_common.c

@@ -723,6 +723,7 @@ wasm_runtime_call_func_ref(WASMExecEnv *exec_env,
     if (exec_env->module_inst->module_type == Wasm_Module_AoT) {
         AOTModuleInstance *module_inst =
             (AOTModuleInstance *)exec_env->module_inst;
+        (void)module_inst;
 
         bh_assert(func_idx < module_inst->module->import_function_count
                                  + module_inst->module->function_count);

+ 1 - 1
core/iwasm/compilation/aot_compiler.c

@@ -529,7 +529,6 @@ aot_compile_func(AOTCompContext *comp_ctx, uint32 func_index)
 #endif /* end of WASM_ENABLE_REF_TYPES != 0 || WASM_ENABLE_GC != 0 */
 
 #if WASM_ENABLE_GC != 0
-
             case WASM_OP_CALL_REF:
                 if (!comp_ctx->enable_gc) {
                     goto unsupport_gc;
@@ -676,6 +675,7 @@ aot_compile_func(AOTCompContext *comp_ctx, uint32 func_index)
                         aot_set_last_error("unsupported opcode");
                         return false;
                 }
+                break;
             }
 
 #endif /* end of WASM_ENABLE_GC != 0 */

+ 1 - 1
core/iwasm/compilation/aot_emit_compare.c

@@ -234,7 +234,7 @@ fail:
 bool
 aot_compile_op_ref_eq(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
 {
-    LLVMValueRef gc_obj1, gc_obj2, res;
+    LLVMValueRef gc_obj1 = NULL, gc_obj2 = NULL, res;
 
     POP_REF(gc_obj1);
     POP_REF(gc_obj2);

+ 5 - 2
core/iwasm/compilation/aot_emit_gc.c

@@ -292,8 +292,11 @@ aot_compile_op_i31_get(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
             goto fail;
         }
     }
+    else {
+        i31_val = i31_obj;
+    }
 
-    /* i31_obj >> 1 */
+    /* i31_val = i31_val >> 1 */
     if (!(i31_val = LLVMBuildLShr(comp_ctx->builder, i31_val, I32_ONE,
                                   "i31_value"))) {
         aot_set_last_error("llvm build lshr failed.");
@@ -301,7 +304,7 @@ aot_compile_op_i31_get(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
     }
 
     if (sign) {
-        /* i31_val = i31_val & 0x40000000? i31_val |= 0x80000000 : i31_val */
+        /* i31_val = i31_val & 0x40000000 ? i31_val |= 0x80000000 : i31_val */
         if (!(bit_30 = LLVMBuildAnd(comp_ctx->builder, i31_val,
                                     I32_CONST(0x40000000), "bit30"))) {
             aot_set_last_error("llvm build and failed.");

+ 2 - 0
samples/multi-module/CMakeLists.txt

@@ -49,6 +49,8 @@ endif ()
 if (NOT DEFINED WAMR_BUILD_JIT)
   set(WAMR_BUILD_JIT 0)
 endif ()
+set(WAMR_BUILD_SIMD 1)
+set(WAMR_BUILD_REF_TYPES 1)
 set(WAMR_BUILD_LIBC_BUILTIN 1)
 set(WAMR_BUILD_LIBC_WASI 1)
 set(WAMR_BUILD_MULTI_MODULE 1)