[PATCH] D96872: [WebAssembly][lld] --importTable flag only imports table if needed
Andy Wingo via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 17 08:21:40 PST 2021
wingo created this revision.
wingo added a reviewer: sbc100.
Herald added subscribers: ecnelises, sunfish, jgravelle-google, dschuff.
wingo requested review of this revision.
Herald added subscribers: llvm-commits, aheejin.
Herald added a project: LLVM.
Before, --importTable forced the creation of an indirect function table,
whether it was needed or not. Now it only imports a table if needed.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D96872
Files:
lld/test/wasm/import-table.test
lld/wasm/Driver.cpp
Index: lld/wasm/Driver.cpp
===================================================================
--- lld/wasm/Driver.cpp
+++ lld/wasm/Driver.cpp
@@ -830,10 +830,7 @@
}
if (config->importTable) {
- if (existing)
- return cast<TableSymbol>(existing);
- else
- return createUndefinedIndirectFunctionTable(functionTableName);
+ return cast_or_null<TableSymbol>(existing);
} else if ((existing && existing->isLive()) || config->exportTable) {
// A defined table is required. Either because the user request an exported
// table or because the table symbol is already live. The existing table is
Index: lld/test/wasm/import-table.test
===================================================================
--- lld/test/wasm/import-table.test
+++ lld/test/wasm/import-table.test
@@ -1,7 +1,15 @@
# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/start.s -o %t.start.o
-# RUN: wasm-ld --import-table -o %t.wasm %t.start.o
+# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %s -o %t.o
+# RUN: wasm-ld --export-all --import-table -o %t.wasm %t.start.o %t.o
# RUN: obj2yaml %t.wasm | FileCheck %s
+.globl require_function_table
+require_function_table:
+.functype require_function_table () -> ()
+ i32.const 1
+ call_indirect () -> ()
+ end_function
+
# Verify the --import-table flag creates a table import
# CHECK: - Type: IMPORT
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D96872.324316.patch
Type: text/x-patch
Size: 1440 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210217/3ea9c2ed/attachment.bin>
More information about the llvm-commits
mailing list