This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Fix for 0xc call_indirect changes
ClosedPublic

Authored by jgravelle-google on Oct 17 2016, 4:00 PM.

Details

Summary

Need to reorder the operands to have the callee as the last argument.
Adds a pseudo-instruction, and a pass to lower it into a real
call_indirect.

This is the first of two options for how to fix the problem.

Diff Detail

Repository
rL LLVM

Event Timeline

jgravelle-google retitled this revision from to [WebAssembly] Fix for 0xc call_indirect changes.
jgravelle-google updated this object.
jgravelle-google added reviewers: dschuff, sunfish.
jgravelle-google added a subscriber: llvm-commits.

In particular these two reviews are more "should we go with A or B". I don't think either are ready to land just yet, but feedback as to which direction to commit to would be helpful.

sunfish edited edge metadata.Oct 18 2016, 1:22 PM

Hrm, I see. My preference would be for the approach in this patch, rather than the other. It has the advantage that we handle it in one place, and don't require as much special-casing elsewhere.

As one minor nit, the CallIndirectFixup pass should be registered outside the getOptLevel() != CodeGenOpt::None test, since it's needed for correctness.

I also vote for this one, so it looks like we all agree.
I'll make this a bit more production-ready and update this review.

In particular:

  • Add a more complete test to validate that stackification errors are gone
  • Actually add a description of the WebAssemblyCallIndirectFixup pass
  • Make sure this runs regardless of opt level

Thanks!

jgravelle-google edited edge metadata.

More polished implementation of call_indirect lowering

  • added register stackification test
  • added description to new pass
  • made sure to run psuedo fixup on -O0
  • removed most autos
sunfish accepted this revision.Oct 20 2016, 1:50 PM
sunfish edited edge metadata.

Looks good!

lib/Target/WebAssembly/WebAssemblyInstrCall.td
32 ↗(On Diff #75347)

We can add "let isCodeGenOnly = 1 in" before this instruction to let various parts of LLVM know that this instruction isn't ever encoded or parsed.

45 ↗(On Diff #75347)

Ditto about isCodeGenOnly.

69 ↗(On Diff #75347)

Ditto here too :-).

This revision is now accepted and ready to land.Oct 20 2016, 1:50 PM
jgravelle-google edited edge metadata.

Mark pseudo call_indirects as isCodeGenOnly

This revision was automatically updated to reflect the committed changes.