This is an archive of the discontinued LLVM Phabricator instance.

Fix thumbv4t indirect calls
ClosedPublic

Authored by jroelofs on Dec 3 2014, 5:23 PM.

Details

Summary

So there are a couple of issues with indirect calls on thumbv4t. First, the most 'obvious' instruction, 'blx' isn't available until v5t. And secondly, the next-most-obvious sequence: 'mov lr, pc; bx rN' doesn't DTRT in thumb code because the saved off pc has its thumb bit cleared, so when the callee returns we end up in ARM mode.... yuck.

The solution is to 'bl' to a nearby landing pad with a 'bx rN' in it.

We could cut down on code size by sharing the landing pads between call sites that are close enough, but for the moment let's do correctness first and look at performance later.

Patch by: Iain Sandoe

Diff Detail

Event Timeline

jroelofs updated this revision to Diff 16903.Dec 3 2014, 5:23 PM
jroelofs retitled this revision from to Fix thumbv4t indirect calls.
jroelofs updated this object.
jroelofs edited the test plan for this revision. (Show Details)
jroelofs added reviewers: t.p.northover, rengolin, iains.
jroelofs added a subscriber: Unknown Object (MLST).
t.p.northover accepted this revision.Dec 4 2014, 10:41 AM
t.p.northover edited edge metadata.

This looks pretty much fine, just one tiny niggle on naming (feel free to commit with that change):

lib/Target/ARM/ARMAsmPrinter.cpp
1311–1312

These names aren't consistently capitalised.

This revision is now accepted and ready to land.Dec 4 2014, 10:41 AM
jroelofs closed this revision.Dec 4 2014, 11:35 AM

Committed r223380. Thanks Tim!

Jon