From 8ef6f9dd7bbb1611dd7166c4e14034e53df4a8b6 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sun, 31 Oct 2021 00:11:38 +0100 Subject: Compile `wasm64`; Add `lb_run_remove_unused_function_pass` --- src/llvm_backend_proc.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/llvm_backend_proc.cpp') diff --git a/src/llvm_backend_proc.cpp b/src/llvm_backend_proc.cpp index 15689da36..29f7b6655 100644 --- a/src/llvm_backend_proc.cpp +++ b/src/llvm_backend_proc.cpp @@ -195,13 +195,19 @@ lbProcedure *lb_create_procedure(lbModule *m, Entity *entity, bool ignore_body) // then it is very likely it is required by LLVM and thus cannot have internal linkage if (entity->pkg != nullptr && entity->pkg->kind == Package_Runtime && p->body != nullptr) { GB_ASSERT(entity->kind == Entity_Procedure); - if (entity->Procedure.link_name != "") { - LLVMSetLinkage(p->value, LLVMExternalLinkage); + String link_name = entity->Procedure.link_name; + if (entity->flags & EntityFlag_CustomLinkName && + link_name != "") { + if (string_starts_with(link_name, str_lit("__"))) { + LLVMSetLinkage(p->value, LLVMExternalLinkage); + } else { + LLVMSetLinkage(p->value, LLVMInternalLinkage); + } } } } } - + if (p->is_foreign) { if (is_arch_wasm()) { char const *import_name = alloc_cstring(permanent_allocator(), p->name); @@ -217,6 +223,7 @@ lbProcedure *lb_create_procedure(lbModule *m, Entity *entity, bool ignore_body) LLVMAddTargetDependentFunctionAttr(p->value, "wasm-import-module", module_name); } } + // NOTE(bill): offset==0 is the return value isize offset = 1; -- cgit v1.2.3