Fix compile warnings/error reported in Windows (#3616)

Clear some compile warnings and fix undefined reference error for symbol ffs
in Windows platform.
This commit is contained in:
Wenyong Huang
2024-07-12 16:43:22 +08:00
committed by GitHub
parent 46695b992c
commit 73caf19e69
11 changed files with 49 additions and 23 deletions

View File

@ -91,6 +91,23 @@ get_memory_check_bound(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
return mem_check_bound;
}
#if defined(_WIN32) || defined(_WIN32_)
static inline int
ffs(int n)
{
int pos = 0;
if (n == 0)
return 0;
while (!(n & 1)) {
pos++;
n >>= 1;
}
return pos + 1;
}
#endif
static LLVMValueRef
get_memory_curr_page_count(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx);
@ -198,7 +215,7 @@ aot_check_memory_overflow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
* has the natural alignment. for platforms using mmap, it can
* be even larger. for now, use a conservative value.
*/
const int max_align = 8;
const unsigned int max_align = 8;
int shift = ffs((int)(unsigned int)mem_offset);
if (shift == 0) {
*alignp = max_align;

View File

@ -749,7 +749,8 @@ aot_add_llvm_func(AOTCompContext *comp_ctx, LLVMModuleRef module,
* and more importantly doesn't involve relocations.
*/
LLVMAttributeRef attr_short_call = LLVMCreateStringAttribute(
comp_ctx->context, "short-call", strlen("short-call"), "", 0);
comp_ctx->context, "short-call", (unsigned)strlen("short-call"),
"", 0);
LLVMAddAttributeAtIndex(func, LLVMAttributeFunctionIndex,
attr_short_call);
}
@ -3529,7 +3530,7 @@ aot_block_destroy(AOTCompContext *comp_ctx, AOTBlock *block)
bool
aot_checked_addr_list_add(AOTFuncContext *func_ctx, uint32 local_idx,
uint32 offset, uint32 bytes)
uint64 offset, uint32 bytes)
{
AOTCheckedAddr *node = func_ctx->checked_addr_list;
@ -3573,7 +3574,7 @@ aot_checked_addr_list_del(AOTFuncContext *func_ctx, uint32 local_idx)
bool
aot_checked_addr_list_find(AOTFuncContext *func_ctx, uint32 local_idx,
uint32 offset, uint32 bytes)
uint64 offset, uint32 bytes)
{
AOTCheckedAddr *node = func_ctx->checked_addr_list;

View File

@ -197,7 +197,7 @@ typedef struct AOTBlockStack {
typedef struct AOTCheckedAddr {
struct AOTCheckedAddr *next;
uint32 local_idx;
uint32 offset;
uint64 offset;
uint32 bytes;
} AOTCheckedAddr, *AOTCheckedAddrList;
@ -574,14 +574,14 @@ wasm_type_to_llvm_type(const AOTCompContext *comp_ctx,
bool
aot_checked_addr_list_add(AOTFuncContext *func_ctx, uint32 local_idx,
uint32 offset, uint32 bytes);
uint64 offset, uint32 bytes);
void
aot_checked_addr_list_del(AOTFuncContext *func_ctx, uint32 local_idx);
bool
aot_checked_addr_list_find(AOTFuncContext *func_ctx, uint32 local_idx,
uint32 offset, uint32 bytes);
uint64 offset, uint32 bytes);
void
aot_checked_addr_list_destroy(AOTFuncContext *func_ctx);

View File

@ -411,7 +411,7 @@ aot_compress_aot_func_names(AOTCompContext *comp_ctx, uint32 *p_size)
return NULL;
}
compressed_str_len = Result.size();
compressed_str_len = (uint32)Result.size();
if (!(compressed_str = (char *)wasm_runtime_malloc(compressed_str_len))) {
aot_set_last_error("allocate memory failed");
return NULL;

View File

@ -189,7 +189,7 @@ PartitionFunction(GlobalValueSet Requested)
auto GVName = GV->getName(); /* get the function name */
const char *gvname = GVName.begin(); /* C function name */
const char *wrapper;
uint32 prefix_len = strlen(AOT_FUNC_PREFIX);
uint32 prefix_len = (uint32)strlen(AOT_FUNC_PREFIX);
LOG_DEBUG("requested func %s", gvname);
/* Convert "aot_func#n_wrapper" to "aot_func#n" */

View File

@ -281,7 +281,7 @@ aot_compile_simd_load_zero(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
/* data_length in bytes */
static bool
simd_store(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, uint32 align,
uint32 offset, uint32 data_length, LLVMValueRef value,
mem_offset_t offset, uint32 data_length, LLVMValueRef value,
LLVMTypeRef value_ptr_type, bool enable_segue)
{
LLVMValueRef maddr, result;