This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Update WebAssemblyAsmTypeCheck for table.get
ClosedPublic

Authored by nokotan on Feb 20 2022, 9:58 PM.

Diff Detail

Event Timeline

nokotan created this revision.Feb 20 2022, 9:58 PM
nokotan requested review of this revision.Feb 20 2022, 9:58 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 20 2022, 9:58 PM

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.

aardappel added inline comments.Feb 22 2022, 11:56 AM
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.

nokotan updated this revision to Diff 410839.Feb 23 2022, 8:59 AM

This diff has 2 changes.

  • Moved test case 'funcref.s'
  • Simplify getTable
sbc100 added inline comments.Feb 23 2022, 9:15 AM
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;
nokotan updated this revision to Diff 411624.Feb 26 2022, 9:38 AM
sbc100 accepted this revision.Feb 28 2022, 8:57 AM
This revision is now accepted and ready to land.Feb 28 2022, 8:57 AM

I see my comment has not been addressed yet.

nokotan updated this revision to Diff 412691.EditedMar 3 2022, 5:54 AM

Applied clang-format.

Herald added a project: Restricted Project. · View Herald TranscriptMar 3 2022, 5:54 AM
pmatos added a comment.Mar 3 2022, 6:03 AM

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.

nokotan marked 3 inline comments as done.Mar 3 2022, 6:14 AM
nokotan added inline comments.
llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmTypeCheck.cpp
185

Yes, originally this function was cloned from getGlobal.
For now, I guess that getTable does not have to get merged with getGlobal, since getTable is already modified.

sbc100 added a comment.Mar 3 2022, 7:30 AM

I see my comment has not been addressed yet.

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.

I don't have access rights to the llvm repository, arc land failed from my terminal.

sbc100 added a comment.Mar 3 2022, 1:20 PM

I don't have access rights to the llvm repository, arc land failed from my terminal.

@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.

pmatos added a comment.Mar 4 2022, 3:24 AM

I don't have access rights to the llvm repository, arc land failed from my terminal.

@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.

Sure - I will land it.

This revision was landed with ongoing or failed builds.Mar 4 2022, 4:03 AM
This revision was automatically updated to reflect the committed changes.
DavidSpickett added a subscriber: DavidSpickett.EditedMar 4 2022, 5:39 AM

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.

pmatos added a comment.Mar 4 2022, 6:26 AM

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.

Thanks David, yes that was the issue.

pmatos added a comment.Mar 4 2022, 6:51 AM

@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?

sbc100 added a comment.Mar 4 2022, 7:06 AM

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.

nokotan reopened this revision.Mar 4 2022, 9:49 AM
This revision is now accepted and ready to land.Mar 4 2022, 9:49 AM
nokotan updated this revision to Diff 413049.Mar 4 2022, 9:50 AM
  • Update test directive in funcref.s
  • Add table.fill case in WebAssemblyAsmTypeCheck
nokotan updated this revision to Diff 413065.Mar 4 2022, 10:28 AM

Rebasing branch

pmatos added a comment.Mar 5 2022, 7:38 AM

Thanks - all tests pass, landing again.

This revision was landed with ongoing or failed builds.Mar 5 2022, 7:57 AM
This revision was automatically updated to reflect the committed changes.