This is an archive of the discontinued LLVM Phabricator instance.

Revert "[WebAssembly] call_indirect issues table number relocs"
ClosedPublic

Authored by sbc100 on Jan 19 2021, 2:36 PM.

Details

Summary

This reverts commit 418df4a6ab35d343cc0f2608c90a73dd9b8d0ab1.

This change broke emscripten tests, I believe because it started
generating 5-byte a wide table index in the call_indirect instruction.
Neither v8 nor wabt seem to be able to handle that. The spec
currently says that this is single 0x0 byte and:

"In future versions of WebAssembly, the zero byte occurring in the
encoding of the call_indirectcall_indirect instruction may be used to
index additional tables."

So we need to revisit this change. For backwards compat I guess
we need to guarantee that __indirect_function_table is always at
address zero. We could also consider making this a single-byte
relocation with and assert if have more than 127 tables (for now).

Diff Detail

Event Timeline

sbc100 created this revision.Jan 19 2021, 2:36 PM
sbc100 requested review of this revision.Jan 19 2021, 2:36 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 19 2021, 2:36 PM
dschuff accepted this revision.Jan 19 2021, 3:04 PM
This revision is now accepted and ready to land.Jan 19 2021, 3:04 PM
This revision was landed with ongoing or failed builds.Jan 19 2021, 3:06 PM
This revision was automatically updated to reflect the committed changes.

actually, is the problem that the reftypes proposal isn't on by default yet?

oh, i see what you mean. for MVP compat the 0 has to be one byte and not 5

:-(

I checked FWIW and all browsers I had access to read the table index as a uleb, and simply assert that it's 0.

Furthermore the table index should always be 0 unless you define more tables, so I thought I had MVP compat handled. Evidently not :(

Furthermore the table index should always be 0 unless you define more tables, so I thought I had MVP compat handled. Evidently not :(

Perhaps you were using wasm-opt after linking? (or some other binaryen tool) Round-tripping through binaryen will always shrink the wide LEBs.

llvm/test/MC/WebAssembly/basic-assembly.s