[PATCH] Fix thumbv4t indirect calls

Jonathan Roelofs jonathan at codesourcery.com
Wed Dec 3 17:23:09 PST 2014


Hi t.p.northover, rengolin, iains,

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

http://reviews.llvm.org/D6519

Files:
  lib/Target/ARM/ARMAsmPrinter.cpp
  lib/Target/ARM/ARMAsmPrinter.h
  test/CodeGen/ARM/none-macho-v4t.ll
  test/CodeGen/ARM/thumb_indirect_calls.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D6519.16903.patch
Type: text/x-patch
Size: 5408 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141204/40d14355/attachment.bin>


More information about the llvm-commits mailing list