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;
|
LLVMValueRef alloca, value;
|
||||||
|
|
||||||
if (!isnan(f32_const)) {
|
|
||||||
if (comp_ctx->is_indirect_mode
|
if (comp_ctx->is_indirect_mode
|
||||||
&& aot_intrinsic_check_capability(comp_ctx, "f32.const")) {
|
&& aot_intrinsic_check_capability(comp_ctx, "f32.const")) {
|
||||||
WASMValue wasm_value;
|
WASMValue wasm_value;
|
||||||
@ -80,12 +79,11 @@ aot_compile_op_f32_const(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
|||||||
}
|
}
|
||||||
PUSH_F32(value);
|
PUSH_F32(value);
|
||||||
}
|
}
|
||||||
else {
|
else if (!isnan(f32_const)) {
|
||||||
value = F32_CONST(f32_const);
|
value = F32_CONST(f32_const);
|
||||||
CHECK_LLVM_CONST(value);
|
CHECK_LLVM_CONST(value);
|
||||||
PUSH_F32(value);
|
PUSH_F32(value);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
int32 i32_const;
|
int32 i32_const;
|
||||||
memcpy(&i32_const, &f32_const, sizeof(int32));
|
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;
|
LLVMValueRef alloca, value;
|
||||||
|
|
||||||
if (!isnan(f64_const)) {
|
|
||||||
if (comp_ctx->is_indirect_mode
|
if (comp_ctx->is_indirect_mode
|
||||||
&& aot_intrinsic_check_capability(comp_ctx, "f64.const")) {
|
&& aot_intrinsic_check_capability(comp_ctx, "f64.const")) {
|
||||||
WASMValue wasm_value;
|
WASMValue wasm_value;
|
||||||
@ -135,12 +132,11 @@ aot_compile_op_f64_const(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
|||||||
}
|
}
|
||||||
PUSH_F64(value);
|
PUSH_F64(value);
|
||||||
}
|
}
|
||||||
else {
|
else if (!isnan(f64_const)) {
|
||||||
value = F64_CONST(f64_const);
|
value = F64_CONST(f64_const);
|
||||||
CHECK_LLVM_CONST(value);
|
CHECK_LLVM_CONST(value);
|
||||||
PUSH_F64(value);
|
PUSH_F64(value);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
int64 i64_const;
|
int64 i64_const;
|
||||||
memcpy(&i64_const, &f64_const, sizeof(int64));
|
memcpy(&i64_const, &f64_const, sizeof(int64));
|
||||||
|
|||||||
Reference in New Issue
Block a user