[LLVMdev] bx instruction getting generated in arm assembly for O1

David Chisnall David.Chisnall at cl.cam.ac.uk
Tue Nov 25 01:27:58 PST 2014


On 24 Nov 2014, at 15:00, MAYUR PANDEY <mayur.p at samsung.com> wrote:

> int (*indirect_func)();
> int indirect_call()
> {
>     return indirect_func();
> }
>  
> when generating the assembly with clang-3.5, for -march=armv5te,  there is a difference in the assemblies generated with O0 and O1:
>  
> In the assembly generated with O0, we are getting the "blx" instruction whereas with O1 we get "bx" (in 3.4.2 we used to get "blx" for both O0 and O1).

I'm a bit confused about what you think that you're testing - that's exactly what I'd expect to see.  Without optimisation, the call will be a blx (call) followed by a function epilog.  With optimisation, as the result of the callee is returned in the same register as the caller, it is a tail call, so a simple branch (bx - as you don't know at compile time whether it's a branch to ARM or Thumb code) should be emitted. 

David






More information about the llvm-dev mailing list