This patch is aimed to resolve GitHub Issue #53789.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Unit Tests
Time | Test | |
---|---|---|
50 ms | x64 debian > LLVM.MC/WebAssembly::tables.s | |
60,070 ms | x64 debian > libFuzzer.libFuzzer::large.test |
Event Timeline
Thanks for working on this!
lld/test/wasm/funcref.s | ||
---|---|---|
23 ↗ | (On Diff #410214) | I think this test probably belongs in llvm/test/MC/WebAssembly/ since this change doesn't look like its related to the linker. |
llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmTypeCheck.cpp | ||
200 | Why is this needed? We don't support tables that contain i32 or i64 values do we? |
Thanks for the patch. In addition to what @sbc100 wrote, some further comments inline.
lld/test/wasm/funcref.s | ||
---|---|---|
23 ↗ | (On Diff #410214) | +1 to the comment from @sbc100 and also maybe change the filename to something more descriptive. For example, tableget-funcref-typecheck.s. |
llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmTypeCheck.cpp | ||
195 | If we are doing a getTable here, the only valid case here is WASM_SYMBOL_TYPE_TABLE. I think the others can be removed and the switch simplified to an if. |
llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmTypeCheck.cpp | ||
---|---|---|
185 | This function is almost identically copy-pasted from getGlobal, please look into a way of merging these two functions cleanly. |
llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmTypeCheck.cpp | ||
---|---|---|
195 | Can you use an early return here to avoid the else? if (if (WasmSym->getType().getValueOr(wasm::WASM_SYMBOL_TYPE_DATA) != wasm::WASM_SYMBOL_TYPE_TABLE) return typeError(ErrorLoc, StringRef("symbol ") + WasmSym->getName() + ... Type = static_cast<wasm::ValType>(WasmSym->getTableType().ElemType); return false; |
Thanks for your time working on the patch. It would be great to address @aardappel 's comments. The idea is to merge the function getGlobal with getTable, since they are so similar. I suppose into something like getGlobalOrTable. Add another switch case for wasm::WASM_SYMBOL_TYPE_TABLE to return the appropriate type.
llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmTypeCheck.cpp | ||
---|---|---|
185 | Yes, originally this function was cloned from getGlobal. |
I don't see see any nice way to merge these two functions. Since you made the original comment getTable has been simplified to make it more distinct. Perhaps there is some way to templatize, but I don't see it. I'd be OK with landing this change as is.
@pmatos do you want to take care of landing this? (since its kind of your area). If you are busy can also take care of it.
This caused two test failures on one of our bots: https://lab.llvm.org/buildbot/#/builders/183/builds/3684
For the new test, it's possible you had a wasm-ld on your path and that's why it worked locally.
Please investigate then reland.
@nokotan The test line should be something like: llvm-mc -mattr=+reference-types -triple=wasm32-unknown-unknown -filetype=obj -o - < %s | obj2yaml | FileCheck %s
However, I notice that MC/WebAssembly/tables.s is failing as well. Can you pls take a look?
Looks like the llvm/test/MC/WebAssembly/funcref-from-table.s test was incorrectly relying on wasm-ld. It should only dependent of obj2yaml and/or llvm-objdump. Looks like the change was reverted for now.
This function is almost identically copy-pasted from getGlobal, please look into a way of merging these two functions cleanly.