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:
YAMAMOTO Takashi
2025-04-28 17:43:53 +09:00
committed by GitHub
parent 6593b3f347
commit 84767f9121
4 changed files with 17 additions and 4 deletions

View File

@ -711,8 +711,7 @@ aot_add_llvm_func(AOTCompContext *comp_ctx, LLVMModuleRef module,
prefix)))
goto fail;
if (comp_ctx->is_indirect_mode) {
/* avoid LUT relocations ("switch-table") */
if (comp_ctx->disable_llvm_jump_tables) {
LLVMAttributeRef attr_no_jump_tables = LLVMCreateStringAttribute(
comp_ctx->context, "no-jump-tables",
(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)
comp_ctx->enable_aux_stack_check = true;
if (option->is_indirect_mode)
if (option->is_indirect_mode) {
comp_ctx->is_indirect_mode = true;
/* avoid LUT relocations ("switch-table") */
comp_ctx->disable_llvm_jump_tables = true;
}
if (option->disable_llvm_intrinsics)
comp_ctx->disable_llvm_intrinsics = true;
if (option->disable_llvm_jump_tables)
comp_ctx->disable_llvm_jump_tables = true;
if (option->disable_llvm_lto)
comp_ctx->disable_llvm_lto = true;