Fix several AOT compiler issues (#2697)

- Fix potential invalid push param phis and add incoming phis to a un-existed basic block
- Fix potential invalid shift count int rotl/rotr opcodes
- Resize memory_data_size to UINT32_MAX if it is 4G when hw bound check is enabled
- Fix negative linear memory offset is used for 64-bit target it is const and larger than INT32_MAX
This commit is contained in:
Wenyong Huang
2023-11-02 20:36:21 +08:00
committed by GitHub
parent 0b2313f6f8
commit 68a627ea2c
5 changed files with 37 additions and 6 deletions

View File

@ -777,17 +777,25 @@ compile_int_rot(AOTCompContext *comp_ctx, LLVMValueRef left, LLVMValueRef right,
if (IS_CONST_ZERO(right))
return left;
/* Calculate (bits - shif_count) */
/* Calculate (bits - shift_count) */
LLVM_BUILD_OP(Sub, is_i32 ? I32_32 : I64_64, right, bits_minus_shift_count,
"bits_minus_shift_count", NULL);
/* Calculate (bits - shift_count) & mask */
bits_minus_shift_count =
LLVMBuildAnd(comp_ctx->builder, bits_minus_shift_count,
is_i32 ? I32_31 : I64_63, "bits_minus_shift_count_and");
if (!bits_minus_shift_count) {
aot_set_last_error("llvm build and failed.");
return NULL;
}
if (is_rotl) {
/* left<<count | left>>(BITS-count) */
/* (left << count) | (left >> ((BITS - count) & mask)) */
LLVM_BUILD_OP(Shl, left, right, tmp_l, "tmp_l", NULL);
LLVM_BUILD_OP(LShr, left, bits_minus_shift_count, tmp_r, "tmp_r", NULL);
}
else {
/* left>>count | left<<(BITS-count) */
/* (left >> count) | (left << ((BITS - count) & mask)) */
LLVM_BUILD_OP(LShr, left, right, tmp_l, "tmp_l", NULL);
LLVM_BUILD_OP(Shl, left, bits_minus_shift_count, tmp_r, "tmp_r", NULL);
}