Page MenuHomePhabricator

[WebAssembly] FastISel : Bail to SelectionDAG for constexpr calls
ClosedPublic

Authored by jgravelle-google on Aug 23 2017, 9:45 AM.

Details

Summary

Currently FastISel lowers constexpr calls as indirect calls. We'd like those to direct calls, and falling back to SelectionDAGISel handles that.

Diff Detail

Repository
rL LLVM

Event Timeline

dschuff edited edge metadata.Aug 23 2017, 10:03 AM

Are there any other constants/constexprs besides bitcast that we might encounter, that we should test? Looking at the constexprs, I don't see too much that looks likely. Maybe GEP? I guess you can indirectly call a GlobalVariable, which ought to look the same as a local function pointer, maybe we should have a test for that too (presumably dag isel handles that too).
Also that this patch really does is just bail from fast-isel when the callee is a constant (which is fine), and that has the effect of causing calls of bitcasts to be lowered as direct calls.

OK nevermind, GlobalVariable doesn't make sense because you have to load it, and similarly for GEP. We could probably do inttoptr though, and maybe select, to get a function pointer and call that.

  • Test more constexpr instructions, make test name more explicit

Also looking back and my previous comment,

Also that this patch really does is just bail from fast-isel when the callee is a constant (which is fine), and that has the effect of causing calls of bitcasts to be lowered as direct calls.

it really wasn't clear what what I meant was that when you land this you should update the commit description to be more clear about what this change does (bail) and that that's why its effect is to cause calls of bitcasts to be direct.

test/CodeGen/WebAssembly/call.ll
163 ↗(On Diff #112579)

If the behavior of bailing from fast-isel is to go back and select the whole rest of the BB with the DAG isel, then these calls probably need to be in different BBs, so we can check that each independently causes a bail.

  • Add basic blocks to call_constexpr test
jgravelle-google retitled this revision from [WebAssembly] FastISel : Lower constant calls as direct calls to [WebAssembly] FastISel : Bail to SelectionDAG for constexpr calls.Aug 24 2017, 11:35 AM
jgravelle-google edited the summary of this revision. (Show Details)
dschuff accepted this revision.Aug 24 2017, 12:26 PM
This revision is now accepted and ready to land.Aug 24 2017, 12:26 PM
This revision was automatically updated to reflect the committed changes.
sunfish edited edge metadata.Aug 28 2017, 6:41 AM

This is subtle enough that it would be good to have a comment in the code itself explaining it.