[llvm-dev] MachineInstr sizes for ARM jumptables

Phillip Raffeck via llvm-dev llvm-dev at lists.llvm.org
Sat Aug 11 09:16:12 PDT 2018


Hi llvm developers,

I might be overlooking something, but I think the ARMConstantIsland
pass uses the wrong size for the MachineInstrs representing jump
tables: Currently, there is the following calculation in
doInitialJumpTablePlacement
(lib/Target/ARM/ARMConstantIslandPass.cpp:588):

----------------------------------------------------------------------
unsigned Size = JT[JTI].MBBs.size() * sizeof(uint32_t);
----------------------------------------------------------------------

Obviously, a size of 4 bytes per entry is incorrect for jump tables
consisting of byte or halfword entries.

Additionally, when trying to optimize for table size later in
optimizeThumb2JumpTables, the opcode is updated without updating the
size (lib/Target/ARM/ARMConstantIslandPass.cpp:2229):

----------------------------------------------------------------------
unsigned JTOpc = ByteOk ? ARM::JUMPTABLE_TBB : ARM::JUMPTABLE_TBH;
----------------------------------------------------------------------

It seems to me, that the size of that MachineInstr is not used in any
critical calculations (or at all), so it maybe has no consequences
observable in the produced binary. I am however using an analysis
toolkit, which kind of relies on these sizes being correct.

I have attached a diff for better clarification of what I'm talking
about and what I think would be a solution. I will happily contribute
these changes, so if you can confirm my observations, please point me
to what would be the next steps.

Thank you for your help.

Kind regards,
Phillip Raffeck
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ARMConstantIslandPass.patch
Type: text/x-patch
Size: 1910 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180811/61da7b51/attachment.bin>


More information about the llvm-dev mailing list