-
Notifications
You must be signed in to change notification settings - Fork 715
aot compiler: Fix the length type passed to aot_memmove/aot_memset #3378
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
call_aot_memmove = comp_ctx->is_indirect_mode || comp_ctx->is_jit_mode; | ||
if (call_aot_memmove) { | ||
LLVMTypeRef param_types[3], ret_type, func_type, func_ptr_type; | ||
LLVMValueRef func, params[3]; | ||
|
||
param_types[0] = INT8_PTR_TYPE; | ||
param_types[1] = INT8_PTR_TYPE; | ||
param_types[2] = I32_TYPE; | ||
param_types[2] = INTPTR_T_TYPE; /* int32 for 32-bit, int64 for 64-bit */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we perhaps define SIZE_T_TYPE (or MEM_OFFSET_T_TYPE) instead? Even though it will (almost) always have the same value as INTPTR_T_TYPE, semantically pointer and size are different so the code would probably be slightly easier to read and maintain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, updated to use SIZE_T_TYPE instead. I didn't add MEM_OFFSET_T_TYPE since it cannot be decided by the target bit width, e.g. in 64-bit target, the memory may be 32-bit or 64-bit. Or it seems we had to define MEM_OFFSET_T_TYPE(memory)
like macro to set its type according to the memory's type.
wrong link? |
/* zero extend to uint64 if the target is 64-bit */ | ||
len = LLVMBuildZExt(comp_ctx->builder, len, I64_TYPE, "len64"); | ||
if (!len) { | ||
aot_set_last_error("llvm build bitcast failed."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not a bitcast.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, thanks!
/* zero extend to uint64 if the target is 64-bit */ | ||
len = LLVMBuildZExt(comp_ctx->builder, len, I64_TYPE, "len64"); | ||
if (!len) { | ||
aot_set_last_error("llvm build bitcast failed."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
…ytecodealliance#3378) The current length type of aot_memmove/aot_memset is size_t, and on a 64 bit host it is uint64, while what the aot code passes to it is uint32, this might lead to unexpected behavior. ps. bytecodealliance#3376.
…ytecodealliance#3378) The current length type of aot_memmove/aot_memset is size_t, and on a 64 bit host it is uint64, while what the aot code passes to it is uint32, this might lead to unexpected behavior. ps. bytecodealliance#3376. Signed-off-by: victoryang00 <[email protected]>
…ytecodealliance#3378) The current length type of aot_memmove/aot_memset is size_t, and on a 64 bit host it is uint64, while what the aot code passes to it is uint32, this might lead to unexpected behavior. ps. bytecodealliance#3376. Signed-off-by: victoryang00 <[email protected]>
The current length type of aot_memmove/aot_memset is size_t, and on
a 64 bit host it is uint64, while what the aot code passes to it is uint32,
this might lead to unexpected behavior.
ps. #3375.