mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-05-07 04:06:16 +00:00
wamrc: add --disable-llvm-jump-tables option (#4224)
while ideally a user should not need to care this kind of optimization details, in reality i guess it's sometimes useful. both of clang and GCC expose a similar option. (-fno-jump-tables)
This commit is contained in:
parent
6593b3f347
commit
84767f9121
|
@ -711,8 +711,7 @@ aot_add_llvm_func(AOTCompContext *comp_ctx, LLVMModuleRef module,
|
||||||
prefix)))
|
prefix)))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
if (comp_ctx->is_indirect_mode) {
|
if (comp_ctx->disable_llvm_jump_tables) {
|
||||||
/* avoid LUT relocations ("switch-table") */
|
|
||||||
LLVMAttributeRef attr_no_jump_tables = LLVMCreateStringAttribute(
|
LLVMAttributeRef attr_no_jump_tables = LLVMCreateStringAttribute(
|
||||||
comp_ctx->context, "no-jump-tables",
|
comp_ctx->context, "no-jump-tables",
|
||||||
(uint32)strlen("no-jump-tables"), "true", (uint32)strlen("true"));
|
(uint32)strlen("no-jump-tables"), "true", (uint32)strlen("true"));
|
||||||
|
@ -2664,12 +2663,18 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option)
|
||||||
if (option->enable_aux_stack_check)
|
if (option->enable_aux_stack_check)
|
||||||
comp_ctx->enable_aux_stack_check = true;
|
comp_ctx->enable_aux_stack_check = true;
|
||||||
|
|
||||||
if (option->is_indirect_mode)
|
if (option->is_indirect_mode) {
|
||||||
comp_ctx->is_indirect_mode = true;
|
comp_ctx->is_indirect_mode = true;
|
||||||
|
/* avoid LUT relocations ("switch-table") */
|
||||||
|
comp_ctx->disable_llvm_jump_tables = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (option->disable_llvm_intrinsics)
|
if (option->disable_llvm_intrinsics)
|
||||||
comp_ctx->disable_llvm_intrinsics = true;
|
comp_ctx->disable_llvm_intrinsics = true;
|
||||||
|
|
||||||
|
if (option->disable_llvm_jump_tables)
|
||||||
|
comp_ctx->disable_llvm_jump_tables = true;
|
||||||
|
|
||||||
if (option->disable_llvm_lto)
|
if (option->disable_llvm_lto)
|
||||||
comp_ctx->disable_llvm_lto = true;
|
comp_ctx->disable_llvm_lto = true;
|
||||||
|
|
||||||
|
|
|
@ -448,6 +448,9 @@ typedef struct AOTCompContext {
|
||||||
/* Disable LLVM built-in intrinsics */
|
/* Disable LLVM built-in intrinsics */
|
||||||
bool disable_llvm_intrinsics;
|
bool disable_llvm_intrinsics;
|
||||||
|
|
||||||
|
/* Disable LLVM jump tables */
|
||||||
|
bool disable_llvm_jump_tables;
|
||||||
|
|
||||||
/* Disable LLVM link time optimization */
|
/* Disable LLVM link time optimization */
|
||||||
bool disable_llvm_lto;
|
bool disable_llvm_lto;
|
||||||
|
|
||||||
|
|
|
@ -73,6 +73,7 @@ typedef struct AOTCompOption {
|
||||||
bool enable_perf_profiling;
|
bool enable_perf_profiling;
|
||||||
bool enable_memory_profiling;
|
bool enable_memory_profiling;
|
||||||
bool disable_llvm_intrinsics;
|
bool disable_llvm_intrinsics;
|
||||||
|
bool disable_llvm_jump_tables;
|
||||||
bool disable_llvm_lto;
|
bool disable_llvm_lto;
|
||||||
bool enable_llvm_pgo;
|
bool enable_llvm_pgo;
|
||||||
bool enable_stack_estimation;
|
bool enable_stack_estimation;
|
||||||
|
@ -96,4 +97,4 @@ typedef struct AOTCompOption {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* end of __AOT_COMP_OPTION_H__ */
|
#endif /* end of __AOT_COMP_OPTION_H__ */
|
||||||
|
|
|
@ -180,6 +180,7 @@ print_help()
|
||||||
printf(" Available flags: all, i32.common, i64.common, f32.common, f64.common,\n");
|
printf(" Available flags: all, i32.common, i64.common, f32.common, f64.common,\n");
|
||||||
printf(" i32.clz, i32.ctz, etc, refer to doc/xip.md for full list\n");
|
printf(" i32.clz, i32.ctz, etc, refer to doc/xip.md for full list\n");
|
||||||
printf(" Use comma to separate, please refer to doc/xip.md for full list.\n");
|
printf(" Use comma to separate, please refer to doc/xip.md for full list.\n");
|
||||||
|
printf(" --disable-llvm-jump-tables Disable the LLVM jump tables similarly to clang's -fno-jump-tables\n");
|
||||||
printf(" --disable-llvm-lto Disable the LLVM link time optimization\n");
|
printf(" --disable-llvm-lto Disable the LLVM link time optimization\n");
|
||||||
printf(" --enable-llvm-pgo Enable LLVM PGO (Profile-Guided Optimization)\n");
|
printf(" --enable-llvm-pgo Enable LLVM PGO (Profile-Guided Optimization)\n");
|
||||||
printf(" --enable-llvm-passes=<passes>\n");
|
printf(" --enable-llvm-passes=<passes>\n");
|
||||||
|
@ -570,6 +571,9 @@ main(int argc, char *argv[])
|
||||||
PRINT_HELP_AND_EXIT();
|
PRINT_HELP_AND_EXIT();
|
||||||
option.builtin_intrinsics = argv[0] + 28;
|
option.builtin_intrinsics = argv[0] + 28;
|
||||||
}
|
}
|
||||||
|
else if (!strcmp(argv[0], "--disable-llvm-jump-tables")) {
|
||||||
|
option.disable_llvm_jump_tables = true;
|
||||||
|
}
|
||||||
else if (!strcmp(argv[0], "--disable-llvm-lto")) {
|
else if (!strcmp(argv[0], "--disable-llvm-lto")) {
|
||||||
option.disable_llvm_lto = true;
|
option.disable_llvm_lto = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user