xip: Lookup float constants from table to reduce relocations (#894)
Lookup float/double constants from exec_env->native_symbol table but not construct them with LLVMBuildConst if XIP mode is enabled, these constants are introduced by f32/f64.const opcodes and some float/double conversion opcodes, and make wamrc generate some relocations in text section of AOT XIP file. This patch eliminates such relocations when "--enable-indirect-mode" is added to wamrc.
This commit is contained in:
@ -36,9 +36,21 @@ aot_compile_op_f32_const(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
LLVMValueRef alloca, value;
|
||||
|
||||
if (!isnan(f32_const)) {
|
||||
value = F32_CONST(f32_const);
|
||||
CHECK_LLVM_CONST(value);
|
||||
PUSH_F32(value);
|
||||
if (!comp_ctx->is_indirect_mode) {
|
||||
value = F32_CONST(f32_const);
|
||||
CHECK_LLVM_CONST(value);
|
||||
PUSH_F32(value);
|
||||
}
|
||||
else {
|
||||
WASMValue wasm_value;
|
||||
memcpy(&wasm_value.f32, &f32_const, sizeof(float32));
|
||||
value = aot_load_const_from_table(comp_ctx, func_ctx->native_symbol,
|
||||
&wasm_value, VALUE_TYPE_F32);
|
||||
if (!value) {
|
||||
return false;
|
||||
}
|
||||
PUSH_F32(value);
|
||||
}
|
||||
}
|
||||
else {
|
||||
int32 i32_const;
|
||||
@ -77,9 +89,21 @@ aot_compile_op_f64_const(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
|
||||
LLVMValueRef alloca, value;
|
||||
|
||||
if (!isnan(f64_const)) {
|
||||
value = F64_CONST(f64_const);
|
||||
CHECK_LLVM_CONST(value);
|
||||
PUSH_F64(value);
|
||||
if (!comp_ctx->is_indirect_mode) {
|
||||
value = F64_CONST(f64_const);
|
||||
CHECK_LLVM_CONST(value);
|
||||
PUSH_F64(value);
|
||||
}
|
||||
else {
|
||||
WASMValue wasm_value;
|
||||
memcpy(&wasm_value.f64, &f64_const, sizeof(float64));
|
||||
value = aot_load_const_from_table(comp_ctx, func_ctx->native_symbol,
|
||||
&wasm_value, VALUE_TYPE_F64);
|
||||
if (!value) {
|
||||
return false;
|
||||
}
|
||||
PUSH_F64(value);
|
||||
}
|
||||
}
|
||||
else {
|
||||
int64 i64_const;
|
||||
|
||||
Reference in New Issue
Block a user