aot compiler: Fix NaN handling for opcode f32/f64.const in XIP mode (#3721)
If the value of a float constant is an NaN, the aot compiler creates an alloca, stores the converted i32 const into it and then loads f32 from it again, which may introduce a relocation in the AOT file and is not allowed for XIP mode.
This commit is contained in:
@ -68,7 +68,6 @@ aot_compile_op_f32_const(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
{
|
||||
LLVMValueRef alloca, value;
|
||||
|
||||
if (!isnan(f32_const)) {
|
||||
if (comp_ctx->is_indirect_mode
|
||||
&& aot_intrinsic_check_capability(comp_ctx, "f32.const")) {
|
||||
WASMValue wasm_value;
|
||||
@ -80,12 +79,11 @@ aot_compile_op_f32_const(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
}
|
||||
PUSH_F32(value);
|
||||
}
|
||||
else {
|
||||
else if (!isnan(f32_const)) {
|
||||
value = F32_CONST(f32_const);
|
||||
CHECK_LLVM_CONST(value);
|
||||
PUSH_F32(value);
|
||||
}
|
||||
}
|
||||
else {
|
||||
int32 i32_const;
|
||||
memcpy(&i32_const, &f32_const, sizeof(int32));
|
||||
@ -123,7 +121,6 @@ aot_compile_op_f64_const(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
{
|
||||
LLVMValueRef alloca, value;
|
||||
|
||||
if (!isnan(f64_const)) {
|
||||
if (comp_ctx->is_indirect_mode
|
||||
&& aot_intrinsic_check_capability(comp_ctx, "f64.const")) {
|
||||
WASMValue wasm_value;
|
||||
@ -135,12 +132,11 @@ aot_compile_op_f64_const(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
}
|
||||
PUSH_F64(value);
|
||||
}
|
||||
else {
|
||||
else if (!isnan(f64_const)) {
|
||||
value = F64_CONST(f64_const);
|
||||
CHECK_LLVM_CONST(value);
|
||||
PUSH_F64(value);
|
||||
}
|
||||
}
|
||||
else {
|
||||
int64 i64_const;
|
||||
memcpy(&i64_const, &f64_const, sizeof(int64));
|
||||
|
||||
Reference in New Issue
Block a user