[LLVMdev] Questions on MachineFunctionPass and relaxation of pcrel calls (ARM/thumb2)

Jason Kim jasonwkim at chromium.org
Thu Feb 9 11:43:54 PST 2012


While implementing a MachineFunctionPass that runs as part of the
ARMTargetMachine::addPreEmitPass(), I've run into a problem.
This particular MFP can drastically increase the size (in MachineInstr
count) of the MachineFunction that it processes, so much so that
there is a real danger of pcrel calls and branches that use immediate
offsets to not be sufficient.

A naive test confirmed that under extreme duress, LLVM does not produce
correct BL/B sequences, as it defaults to using pcrel immediates which do
not have enough bits to encode the offset.

How do I convince LLVM to revert to materializing an offset in a register
and use register indirect BL/B sequences?  Is there some magic sequence of
getAnalysisUsage() which will tell the outer loop to replace the immediate
form of branches in lieu of a register indirect BL/B ?

Or is the answer to use some other framework (ModulePass?)  Or is this a
case where I need to carry out 'manual' (un)relaxation?

In either case, pointers and advice would be greatly appreciated.

Thanks!
-Jason
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120209/bcad49b7/attachment.html>


More information about the llvm-dev mailing list