Hi I am recently doing research on binaries in ARM architecture. I noticed that when I compile the source code using thumb instruction set, llvm will use BL to jump to some basic blocks rather than B, which means the jump target by BL could also be a basic block rather than function start. Some disassemblers would directly set the target of BL as a start of a function, which is not right. I am really curious when the compiler would choose to use BL and when the compiler would choose to use B when the target is a basic block. I noticed sometimes there might be no differences between these two branch instructions. Many Thanks Regards Muhui -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190523/24845a28/attachment.html>
Tim Northover via llvm-dev
2019-May-23 11:30 UTC
[llvm-dev] "BL" or "B" when compiling ARM
Hi Muhui, On Thu, 23 May 2019 at 12:23, Muhui Jiang via llvm-dev <llvm-dev at lists.llvm.org> wrote:> I am really curious when the compiler would choose to use BL and when the compiler would choose to use B when the target is a basic block. I noticed sometimes there might be no differences between these two branch instructions.BL is one of the very few instructions that's 32-bits wide on CPUs that only support the Thumb1 instruction set (usually Cortex-M0 these days). Because of that it's got a much larger range than any other branch so LLVM uses it instead of a string of intermediate branches when a target block would be out of range of the usual unconditional branches. Cheers. Tim.