Avoid switch lowering to lookup tables for XIP (#2339)

Because it involves relocations for the table. (.Lswitch.table.XXX)

Discussions: https://github.com/bytecodealliance/wasm-micro-runtime/issues/2316
This commit is contained in:
YAMAMOTO Takashi 2023-07-04 17:48:32 +09:00 committed by GitHub
parent 18092f86cc
commit 1f89e446d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -623,6 +623,15 @@ aot_add_llvm_func(AOTCompContext *comp_ctx, LLVMModuleRef module,
prefix))) prefix)))
goto fail; goto fail;
if (comp_ctx->is_indirect_mode) {
/* avoid LUT relocations ("switch-table") */
LLVMAttributeRef attr_no_jump_tables = LLVMCreateStringAttribute(
comp_ctx->context, "no-jump-tables", strlen("no-jump-tables"),
"true", strlen("true"));
LLVMAddAttributeAtIndex(func, LLVMAttributeFunctionIndex,
attr_no_jump_tables);
}
if (need_precheck) { if (need_precheck) {
if (!comp_ctx->is_jit_mode) if (!comp_ctx->is_jit_mode)
LLVMSetLinkage(func, LLVMInternalLinkage); LLVMSetLinkage(func, LLVMInternalLinkage);