This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Fixed 64-bit indices in br_table
ClosedPublic

Authored by aardappel on Jul 27 2020, 3:04 PM.

Details

Summary

LLVM selection dag assumes "switch" indices are pointer sized, which causes problems for our 32-bit br_table. The new function ensures 32-bit operands don't get unnecessarily extended, and 64-bit operands get truncated.

Note that the changes to the existing test test exactly that: the addition of -NEXT in 2 places ensures no extension is inserted (which the test previously ignored) and that the wrap is present (previously omitted in wasm64 mode).

Diff Detail

Event Timeline

aardappel created this revision.Jul 27 2020, 3:04 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 27 2020, 3:04 PM
aardappel updated this revision to Diff 281068.Jul 27 2020, 3:44 PM

Replace fragile way of finding the extend instruction by just getting the def of the br_table operand.

tlively accepted this revision.Jul 27 2020, 5:03 PM

LGTM!

This revision is now accepted and ready to land.Jul 27 2020, 5:03 PM
This revision was automatically updated to reflect the committed changes.